@pristine-ts/cli 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/pristine.cjs +6 -2
- package/dist/lib/cjs/bin.js +18 -1
- package/dist/lib/cjs/bin.js.map +1 -1
- package/dist/lib/cjs/bootstrap/app-module-loader.js +40 -78
- package/dist/lib/cjs/bootstrap/app-module-loader.js.map +1 -1
- package/dist/lib/cjs/bootstrap/loaded-app-module.js +9 -13
- package/dist/lib/cjs/bootstrap/loaded-app-module.js.map +1 -1
- package/dist/lib/cjs/bootstrap/plugin-loader.js +3 -3
- package/dist/lib/cjs/bootstrap/plugin-loader.js.map +1 -1
- package/dist/lib/cjs/cli.js +173 -85
- package/dist/lib/cjs/cli.js.map +1 -1
- package/dist/lib/cjs/cli.module.js +24 -8
- package/dist/lib/cjs/cli.module.js.map +1 -1
- package/dist/lib/cjs/commands/build-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/build.command.js +9 -10
- package/dist/lib/cjs/commands/build.command.js.map +1 -1
- package/dist/lib/cjs/commands/config-print.command.js +1 -2
- package/dist/lib/cjs/commands/config-print.command.js.map +1 -1
- package/dist/lib/cjs/commands/help-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/help.command.js +1 -2
- package/dist/lib/cjs/commands/help.command.js.map +1 -1
- package/dist/lib/cjs/commands/info-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/info.command.js +7 -8
- package/dist/lib/cjs/commands/info.command.js.map +1 -1
- package/dist/lib/cjs/commands/init-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/init.command.js +13 -12
- package/dist/lib/cjs/commands/init.command.js.map +1 -1
- package/dist/lib/cjs/commands/list-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/list.command.js +1 -2
- package/dist/lib/cjs/commands/list.command.js.map +1 -1
- package/dist/lib/cjs/commands/start-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/start.command.js +3 -4
- package/dist/lib/cjs/commands/start.command.js.map +1 -1
- package/dist/lib/cjs/commands/verify-alias.command.js.map +1 -1
- package/dist/lib/cjs/commands/verify.command.js +3 -4
- package/dist/lib/cjs/commands/verify.command.js.map +1 -1
- package/dist/lib/cjs/config/resolved-pristine-config.js +2 -3
- package/dist/lib/cjs/config/resolved-pristine-config.js.map +1 -1
- package/dist/lib/cjs/errors/cli-error-code.enum.js +17 -0
- package/dist/lib/cjs/errors/cli-error-code.enum.js.map +1 -0
- package/dist/lib/cjs/errors/command-not-found.error.js +11 -12
- package/dist/lib/cjs/errors/command-not-found.error.js.map +1 -1
- package/dist/lib/cjs/errors/errors.js +1 -0
- package/dist/lib/cjs/errors/errors.js.map +1 -1
- package/dist/lib/cjs/event-handlers/cli.event-handler.js +28 -20
- package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/cjs/reporters/cli-error.reporter.js +121 -0
- package/dist/lib/cjs/reporters/cli-error.reporter.js.map +1 -0
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/types/command-event-response.type.js.map +1 -1
- package/dist/lib/esm/bin.js +18 -1
- package/dist/lib/esm/bin.js.map +1 -1
- package/dist/lib/esm/bootstrap/app-module-loader.js +40 -78
- package/dist/lib/esm/bootstrap/app-module-loader.js.map +1 -1
- package/dist/lib/esm/bootstrap/loaded-app-module.js +9 -13
- package/dist/lib/esm/bootstrap/loaded-app-module.js.map +1 -1
- package/dist/lib/esm/bootstrap/plugin-loader.js +3 -3
- package/dist/lib/esm/bootstrap/plugin-loader.js.map +1 -1
- package/dist/lib/esm/cli.js +172 -84
- package/dist/lib/esm/cli.js.map +1 -1
- package/dist/lib/esm/cli.module.js +24 -8
- package/dist/lib/esm/cli.module.js.map +1 -1
- package/dist/lib/esm/commands/build-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/build.command.js +10 -11
- package/dist/lib/esm/commands/build.command.js.map +1 -1
- package/dist/lib/esm/commands/config-print.command.js +2 -3
- package/dist/lib/esm/commands/config-print.command.js.map +1 -1
- package/dist/lib/esm/commands/help-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/help.command.js +2 -3
- package/dist/lib/esm/commands/help.command.js.map +1 -1
- package/dist/lib/esm/commands/info-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/info.command.js +8 -9
- package/dist/lib/esm/commands/info.command.js.map +1 -1
- package/dist/lib/esm/commands/init-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/init.command.js +14 -13
- package/dist/lib/esm/commands/init.command.js.map +1 -1
- package/dist/lib/esm/commands/list-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/list.command.js +2 -3
- package/dist/lib/esm/commands/list.command.js.map +1 -1
- package/dist/lib/esm/commands/start-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/start.command.js +4 -5
- package/dist/lib/esm/commands/start.command.js.map +1 -1
- package/dist/lib/esm/commands/verify-alias.command.js.map +1 -1
- package/dist/lib/esm/commands/verify.command.js +4 -5
- package/dist/lib/esm/commands/verify.command.js.map +1 -1
- package/dist/lib/esm/config/resolved-pristine-config.js +2 -3
- package/dist/lib/esm/config/resolved-pristine-config.js.map +1 -1
- package/dist/lib/esm/errors/cli-error-code.enum.js +14 -0
- package/dist/lib/esm/errors/cli-error-code.enum.js.map +1 -0
- package/dist/lib/esm/errors/command-not-found.error.js +12 -13
- package/dist/lib/esm/errors/command-not-found.error.js.map +1 -1
- package/dist/lib/esm/errors/errors.js +1 -0
- package/dist/lib/esm/errors/errors.js.map +1 -1
- package/dist/lib/esm/event-handlers/cli.event-handler.js +29 -21
- package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/esm/reporters/cli-error.reporter.js +118 -0
- package/dist/lib/esm/reporters/cli-error.reporter.js.map +1 -0
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/types/command-event-response.type.js.map +1 -1
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/bootstrap/app-module-loader.d.ts +24 -25
- package/dist/types/bootstrap/loaded-app-module.d.ts +12 -26
- package/dist/types/bootstrap/plugin-loader.d.ts +1 -1
- package/dist/types/cli.d.ts +69 -9
- package/dist/types/cli.module.d.ts +2 -2
- package/dist/types/commands/build-alias.command.d.ts +2 -2
- package/dist/types/commands/build.command.d.ts +2 -2
- package/dist/types/commands/config-print.command.d.ts +2 -2
- package/dist/types/commands/help-alias.command.d.ts +2 -2
- package/dist/types/commands/help.command.d.ts +2 -2
- package/dist/types/commands/info-alias.command.d.ts +2 -2
- package/dist/types/commands/info.command.d.ts +2 -2
- package/dist/types/commands/init-alias.command.d.ts +2 -2
- package/dist/types/commands/init.command.d.ts +2 -2
- package/dist/types/commands/list-alias.command.d.ts +2 -2
- package/dist/types/commands/list.command.d.ts +2 -2
- package/dist/types/commands/start-alias.command.d.ts +2 -2
- package/dist/types/commands/start.command.d.ts +2 -2
- package/dist/types/commands/verify-alias.command.d.ts +2 -2
- package/dist/types/commands/verify.command.d.ts +2 -2
- package/dist/types/config/pristine-config.interface.d.ts +38 -12
- package/dist/types/config/resolved-pristine-config.d.ts +4 -6
- package/dist/types/errors/cli-error-code.enum.d.ts +12 -0
- package/dist/types/errors/command-not-found.error.d.ts +8 -7
- package/dist/types/errors/errors.d.ts +1 -0
- package/dist/types/event-handlers/cli.event-handler.d.ts +4 -19
- package/dist/types/interfaces/command.interface.d.ts +2 -2
- package/dist/types/reporters/cli-error.reporter.d.ts +45 -0
- package/dist/types/types/command-event-response.type.d.ts +2 -2
- package/package.json +9 -9
- package/dist/lib/cjs/enums/enums.js +0 -18
- package/dist/lib/cjs/enums/enums.js.map +0 -1
- package/dist/lib/cjs/enums/exit-code.enum.js +0 -9
- package/dist/lib/cjs/enums/exit-code.enum.js.map +0 -1
- package/dist/lib/esm/enums/enums.js +0 -2
- package/dist/lib/esm/enums/enums.js.map +0 -1
- package/dist/lib/esm/enums/exit-code.enum.js +0 -6
- package/dist/lib/esm/enums/exit-code.enum.js.map +0 -1
- package/dist/types/enums/enums.d.ts +0 -1
- package/dist/types/enums/exit-code.enum.d.ts +0 -4
|
@@ -5,20 +5,6 @@ import { CommandInterface } from "../interfaces/command.interface";
|
|
|
5
5
|
import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
6
6
|
import { Validator } from "@pristine-ts/class-validator";
|
|
7
7
|
import { ConsoleManager } from "../managers/console.manager";
|
|
8
|
-
import { ExitCodeEnum } from "../enums/exit-code.enum";
|
|
9
|
-
/**
|
|
10
|
-
* Resolution of a command's argv input. Either we successfully produced an instance of the
|
|
11
|
-
* command's `optionsType` (or the raw args for null-optionsType commands) and `args` is set,
|
|
12
|
-
* OR mapping/validation failed and `exitCode` carries the failure status. Mutually exclusive
|
|
13
|
-
* by construction — `args` is undefined iff `exitCode` is set.
|
|
14
|
-
*
|
|
15
|
-
* Used as the return value of `CliEventHandler.resolveArgs` so the call site can branch on
|
|
16
|
-
* the success/failure case without a thrown exception in the hot path.
|
|
17
|
-
*/
|
|
18
|
-
interface ResolvedCommandArgs {
|
|
19
|
-
args?: any;
|
|
20
|
-
exitCode?: ExitCodeEnum;
|
|
21
|
-
}
|
|
22
8
|
export declare class CliEventHandler implements EventHandlerInterface<any, any> {
|
|
23
9
|
private readonly logHandler;
|
|
24
10
|
private readonly validator;
|
|
@@ -34,12 +20,11 @@ export declare class CliEventHandler implements EventHandlerInterface<any, any>
|
|
|
34
20
|
* args through unchanged — the legacy escape hatch for commands that want to handle
|
|
35
21
|
* argv parsing themselves.
|
|
36
22
|
*
|
|
37
|
-
*
|
|
38
|
-
* `
|
|
39
|
-
*
|
|
23
|
+
* Throws `UsageError` for mapping failures and `ValidationError` for class-validator
|
|
24
|
+
* failures. Both carry structured `details` so `CliErrorReporter` can render them as
|
|
25
|
+
* readable stderr lines without this method touching the console directly.
|
|
40
26
|
*/
|
|
41
|
-
resolveArgs(command: CommandInterface<any>, rawArgs: any): Promise<
|
|
27
|
+
resolveArgs(command: CommandInterface<any>, rawArgs: any): Promise<any>;
|
|
42
28
|
supports(event: Event<any>): boolean;
|
|
43
29
|
private logExitStatus;
|
|
44
30
|
}
|
|
45
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassConstructor } from "class-transformer";
|
|
2
|
-
import {
|
|
2
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
3
3
|
/**
|
|
4
4
|
* The contract every CLI command implements. The CliEventHandler reads `optionsType` to
|
|
5
5
|
* map raw `process.argv` flags onto a typed instance of the declared options class, runs
|
|
@@ -30,5 +30,5 @@ export interface CommandInterface<T> {
|
|
|
30
30
|
* Invoked with a validated instance of `optionsType` (when `optionsType` is non-null) or
|
|
31
31
|
* the raw parsed argv shape (when `optionsType` is null). Return an exit code.
|
|
32
32
|
*/
|
|
33
|
-
run(args: T): Promise<
|
|
33
|
+
run(args: T): Promise<ExitCode | number>;
|
|
34
34
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EnvironmentManager } from "@pristine-ts/core";
|
|
2
|
+
/**
|
|
3
|
+
* Renders any thrown value to stderr and returns an appropriate process exit code.
|
|
4
|
+
* Counterpart to networking's `HttpErrorResponder`: same `PristineError`-based contract,
|
|
5
|
+
* different channel.
|
|
6
|
+
*
|
|
7
|
+
* **Production mode** (default): one-line `✗ CODE: message` for `UserError`s; a generic
|
|
8
|
+
* `Internal Error` for `SystemError`s (raw `Error`s, third-party throws). No stack
|
|
9
|
+
* trace, no cause chain.
|
|
10
|
+
*
|
|
11
|
+
* **Development mode** (`pristine.environment = dev`, env override
|
|
12
|
+
* `PRISTINE_ENV=dev`): full message even for system errors, structured details
|
|
13
|
+
* printed below, stack trace and cause chain appended at the end. Useful when debugging
|
|
14
|
+
* locally.
|
|
15
|
+
*
|
|
16
|
+
* Exit code selection: `error.options.exitCode` wins when present. Otherwise:
|
|
17
|
+
* `ExitCode.Error` (1) for user errors, `ExitCode.Software` (70) for system errors —
|
|
18
|
+
* both follow `sysexits.h` conventions.
|
|
19
|
+
*
|
|
20
|
+
* **Environment source**: `EnvironmentManager` is injected, not read from `process.env`
|
|
21
|
+
* directly. For the bin script's pre-DI fallback (kernel-boot failures), `bootstrap()`
|
|
22
|
+
* builds the manager from the configuration that `AppModuleLoader.load()` produced — same
|
|
23
|
+
* `pristine.environment` value that would have reached DI if the kernel had started. No
|
|
24
|
+
* code path reads `process.env` directly; env-var input enters exclusively through the
|
|
25
|
+
* `EnvironmentVariableResolver` registered on `CoreModule`'s configuration definitions.
|
|
26
|
+
*
|
|
27
|
+
* **Crash-isolated**: every stderr write is wrapped — if stderr is closed/broken, we
|
|
28
|
+
* still return an exit code rather than throwing back into the bin's catch handler.
|
|
29
|
+
*/
|
|
30
|
+
export declare class CliErrorReporter {
|
|
31
|
+
private readonly environmentManager;
|
|
32
|
+
constructor(environmentManager: EnvironmentManager);
|
|
33
|
+
/**
|
|
34
|
+
* Writes the error to stderr and returns the exit code the caller should pass to
|
|
35
|
+
* `process.exit`. The bin script wraps `bootstrap().catch(err => process.exit(reporter.report(err)))`.
|
|
36
|
+
*/
|
|
37
|
+
report(error: unknown): number;
|
|
38
|
+
/**
|
|
39
|
+
* Wraps `process.stderr.write` so a broken stderr (closed pipe, etc.) doesn't itself
|
|
40
|
+
* throw and confuse the bin's outer `.catch`. The exit code is the only thing that
|
|
41
|
+
* matters when stderr is dead.
|
|
42
|
+
*/
|
|
43
|
+
private write;
|
|
44
|
+
private safeStringify;
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventResponse } from "@pristine-ts/core";
|
|
2
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
3
|
import { CommandEventPayload } from "../event-payloads/command.event-payload";
|
|
3
|
-
|
|
4
|
-
export declare class CommandEventResponse extends EventResponse<CommandEventPayload, ExitCodeEnum | number> {
|
|
4
|
+
export declare class CommandEventResponse extends EventResponse<CommandEventPayload, ExitCode | number> {
|
|
5
5
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/cli.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/cli.module.js",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@inquirer/prompts": "^7.2.0",
|
|
28
|
-
"@pristine-ts/common": "^2.0.
|
|
29
|
-
"@pristine-ts/core": "^2.0.
|
|
30
|
-
"@pristine-ts/data-mapping": "^2.0.
|
|
31
|
-
"@pristine-ts/data-mapping-common": "^2.0.
|
|
32
|
-
"@pristine-ts/file": "^2.0.
|
|
33
|
-
"@pristine-ts/logging": "^2.0.
|
|
34
|
-
"@pristine-ts/validation": "^2.0.
|
|
28
|
+
"@pristine-ts/common": "^2.0.6",
|
|
29
|
+
"@pristine-ts/core": "^2.0.6",
|
|
30
|
+
"@pristine-ts/data-mapping": "^2.0.6",
|
|
31
|
+
"@pristine-ts/data-mapping-common": "^2.0.6",
|
|
32
|
+
"@pristine-ts/file": "^2.0.6",
|
|
33
|
+
"@pristine-ts/logging": "^2.0.6",
|
|
34
|
+
"@pristine-ts/validation": "^2.0.6",
|
|
35
35
|
"jiti": "^2.4.0",
|
|
36
36
|
"uuid": "^9.0.1"
|
|
37
37
|
},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"src/*.{js,ts}"
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "539029d624372f9bb1e22e09da7152eabb95c105",
|
|
76
76
|
"repository": {
|
|
77
77
|
"type": "git",
|
|
78
78
|
"url": "https://github.com/magieno/pristine-ts.git",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./exit-code.enum"), exports);
|
|
18
|
-
//# sourceMappingURL=enums.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExitCodeEnum = void 0;
|
|
4
|
-
var ExitCodeEnum;
|
|
5
|
-
(function (ExitCodeEnum) {
|
|
6
|
-
ExitCodeEnum[ExitCodeEnum["Success"] = 0] = "Success";
|
|
7
|
-
ExitCodeEnum[ExitCodeEnum["Error"] = 1] = "Error";
|
|
8
|
-
})(ExitCodeEnum || (exports.ExitCodeEnum = ExitCodeEnum = {}));
|
|
9
|
-
//# sourceMappingURL=exit-code.enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-code.enum.js","sourceRoot":"","sources":["../../../../src/enums/exit-code.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,iDAAS,CAAA;AACX,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-code.enum.js","sourceRoot":"","sources":["../../../../src/enums/exit-code.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,iDAAS,CAAA;AACX,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./exit-code.enum";
|