Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/puny-dryers-write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/cli': patch
---

chore: trap for yarn install failure and echo file in /tmp folder to console if it failed; also break on error instead of continuing (RHDHBUGS-2819)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@red-hat-developer-hub/cli",
"description": "CLI for developing Backstage plugins and apps",
"version": "1.9.1",
"version": "1.9.2",
"publishConfig": {
"access": "public"
},
Expand Down
18 changes: 16 additions & 2 deletions src/commands/export-dynamic-plugin/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as semver from 'semver';

import { execSync } from 'child_process';
import { createRequire } from 'node:module';
import os from 'node:os';
import * as path from 'path';

import { productionPack } from '../../lib/packager/productionPack';
Expand Down Expand Up @@ -356,15 +357,28 @@ throw new Error(
if (opts.install) {
Task.log(`Installing private dependencies of the main package`);

const logFile = 'yarn-install.log';
const logFile = path.join(os.tmpdir(), 'rhdh-cli.yarn-install.log');
const redirect = `> ${logFile}`;
const yarnInstall = yarnVersion.startsWith('1.')
? `${yarn} install --production${
yarnLockExists ? ' --frozen-lockfile' : ''
} ${redirect}`
: `${yarn} install${yarnLockExists ? ' --immutable' : ' --no-immutable'} ${redirect}`;

await Task.forCommand(yarnInstall, { cwd: target, optional: false });
try {
await Task.forCommand(yarnInstall, { cwd: target, optional: false });
} catch (err) {
if (await fs.pathExists(logFile)) {
const logContents = await fs.readFile(logFile, 'utf8');
console.error(
chalk.red(
`\n${chalk.bold('yarn install failed. Log output from')} ${chalk.cyan(logFile)}:\n`,
),
);
console.error(logContents);
}
throw err;
}
await fs.remove(paths.resolveTarget(targetRelativePath, '.yarn'));

// Checking if some shared dependencies have been included inside the private dependencies
Expand Down
Loading