Skip to content
Merged
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
16 changes: 16 additions & 0 deletions .changeset/21496-text-face-exit-signal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@objectstack/cli': patch
---

fix(cli): `os package install`, `os package publish` and `os plugin sign` print one error line per refusal (#21496)

Clause-②: no

`os package install ./does-not-exist.json` printed `✗ Cannot read artifact: ENOENT …` and then a second line, `✗ EEXIT: 1`. The exit status, 1, was right. The extra line came from the command's own `catch`: the `this.exit(1)` inside its `try` throws oclif's exit signal, and the `catch` reported the signal as an error.

The same `catch` sat in two more commands:

- **`os package publish`.** Every refusal it makes printed the extra `✗ EEXIT: 1` line. Examples are an unreadable artifact, an invalid manifest id, no cloud login, a failed package registration and a failed version publish. An `--icon-file` whose image type it cannot infer printed three error lines: the refusal, then `✗ Cannot read --icon-file '…': EEXIT: 1`, then `✗ EEXIT: 1`.
- **`os plugin sign`.** A signature that failed its self-verification printed `✗ Self-verification error: EEXIT: 1` under the refusal.

Each refusal is now one error line, and every exit status is unchanged. A script that filtered out the `EEXIT` line can drop that filter.
3 changes: 2 additions & 1 deletion packages/cli/src/commands/package/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { readFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { resolve as resolvePath } from 'node:path';
import { Args, Command, Flags } from '@oclif/core';
import { printHeader, printKV, printSuccess, printError, printStep } from '../../utils/format.js';
import { printHeader, printKV, printSuccess, printError, printStep, isExitSignal } from '../../utils/format.js';

export default class PackageInstall extends Command {
static override description =
Expand Down Expand Up @@ -246,6 +246,7 @@ export default class PackageInstall extends Command {
console.log(` ${storageDir}`);
}
} catch (error) {
if (isExitSignal(error)) throw error;
printError((error as Error).message);
this.exit(1);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/commands/package/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { readFile } from 'node:fs/promises';
import { resolve as resolvePath, basename, dirname, isAbsolute } from 'node:path';
import { Args, Command, Flags } from '@oclif/core';
import { PackageSchema } from '@objectstack/spec/marketplace';
import { printHeader, printKV, printSuccess, printError, printStep } from '../../utils/format.js';
import { printHeader, printKV, printSuccess, printError, printStep, isExitSignal } from '../../utils/format.js';
import { DEFAULT_CLOUD_URL, tryReadCloudConfig } from '../../utils/cloud-config.js';
import { resolveCloudActiveEnvironmentId } from '../../utils/active-environment.js';
import { readErrorMessage } from '../../utils/response-envelope.js';
Expand Down Expand Up @@ -665,6 +665,7 @@ export default class PackagePublish extends Command {
const iconUrl = iconRes.body?.data?.icon_url ?? iconRes.body?.icon_url;
if (iconUrl) printKV(' Icon URL', String(iconUrl));
} catch (err: any) {
if (isExitSignal(err)) throw err;
printError(`Cannot read --icon-file '${iconPath}': ${err.message}`);
this.exit(1);
return;
Expand Down Expand Up @@ -794,6 +795,7 @@ export default class PackagePublish extends Command {
for (const v of violations) console.log(` • ${v}`);
}
} catch (error) {
if (isExitSignal(error)) throw error;
printError((error as Error).message);
this.exit(1);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/plugin/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { createPublicKey } from 'node:crypto';
import { resolve as resolvePath } from 'node:path';
import { Args, Command, Flags } from '@oclif/core';
import { parseSignature, signPayload, verifyPayload } from '@objectstack/core';
import { printError, printHeader, printKV, printStep, printSuccess } from '../../utils/format.js';
import { isExitSignal, printError, printHeader, printKV, printStep, printSuccess } from '../../utils/format.js';
import { OSPLUGIN_EXT } from '../../utils/osplugin.js';

export default class PluginSign extends Command {
Expand Down Expand Up @@ -99,6 +99,7 @@ export default class PluginSign extends Command {
return;
}
} catch (err) {
if (isExitSignal(err)) throw err;
printError(`Self-verification error: ${(err as Error).message}`);
this.exit(1);
return;
Expand Down
Loading
Loading