Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reporting publish error messages #8740

Merged
merged 1 commit into from
Apr 3, 2024
Merged
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
13 changes: 8 additions & 5 deletions scopes/pkg/pkg/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,24 @@ export class Publisher {

const componentIdStr = capsule.id.toString();
const errors: string[] = [];
let metadata: TaskMetadata = {};
try {
this.logger.off();
// @todo: once capsule.exec works properly, replace this
// It is important to use stdio: 'inherit' so when npm asks for the OTP, the user can enter it
await execa(this.packageManager, publishParams, { cwd, stdio: 'inherit' });
this.logger.on();
this.logger.debug(`${componentIdStr}, successfully ran ${this.packageManager} ${publishParamsStr} at ${cwd}`);
const pkg = await fsx.readJSON(`${capsule.path}/package.json`);
metadata = this.options.dryRun ? {} : { publishedPackage: `${pkg.name}@${pkg.version}` };
} catch (err: any) {
const errorMsg = `failed running ${this.packageManager} ${publishParamsStr} at ${cwd}`;
} catch (err: unknown) {
const errorDetails = typeof err === 'object' && err && 'message' in err ? err.message : err;
const errorMsg = `failed running ${this.packageManager} ${publishParamsStr} at ${cwd}: ${errorDetails}`;
this.logger.error(`${componentIdStr}, ${errorMsg}`);
errors.push(errorMsg);
}
let metadata: TaskMetadata = {};
if (errors.length === 0 && !this.options.dryRun) {
const pkg = await fsx.readJSON(`${capsule.path}/package.json`);
metadata = { publishedPackage: `${pkg.name}@${pkg.version}` };
}
const component = capsule.component;
return { component, metadata, errors, startTime, endTime: Date.now() };
}
Expand Down