@pristine-ts/cli 2.0.7 → 2.0.17
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/lib/cjs/bootstrap/build-staleness-prompt.js +12 -13
- package/dist/lib/cjs/bootstrap/build-staleness-prompt.js.map +1 -1
- package/dist/lib/cjs/bootstrap/init-prompt.js +16 -47
- package/dist/lib/cjs/bootstrap/init-prompt.js.map +1 -1
- package/dist/lib/cjs/cli.configuration-keys.js +24 -0
- package/dist/lib/cjs/cli.configuration-keys.js.map +1 -0
- package/dist/lib/cjs/cli.js +23 -10
- package/dist/lib/cjs/cli.js.map +1 -1
- package/dist/lib/cjs/cli.module.js +29 -1
- package/dist/lib/cjs/cli.module.js.map +1 -1
- package/dist/lib/cjs/commands/commands.js +6 -0
- package/dist/lib/cjs/commands/commands.js.map +1 -1
- package/dist/lib/cjs/commands/logs-alias.command.js +49 -0
- package/dist/lib/cjs/commands/logs-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/logs.command-options.js +72 -0
- package/dist/lib/cjs/commands/logs.command-options.js.map +1 -0
- package/dist/lib/cjs/commands/logs.command.js +102 -0
- package/dist/lib/cjs/commands/logs.command.js.map +1 -0
- package/dist/lib/cjs/commands/requests-alias.command.js +49 -0
- package/dist/lib/cjs/commands/requests-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/requests.command-options.js +26 -0
- package/dist/lib/cjs/commands/requests.command-options.js.map +1 -0
- package/dist/lib/cjs/commands/requests.command.js +88 -0
- package/dist/lib/cjs/commands/requests.command.js.map +1 -0
- package/dist/lib/cjs/commands/trace-alias.command.js +49 -0
- package/dist/lib/cjs/commands/trace-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/trace.command-options.js +59 -0
- package/dist/lib/cjs/commands/trace.command-options.js.map +1 -0
- package/dist/lib/cjs/commands/trace.command.js +84 -0
- package/dist/lib/cjs/commands/trace.command.js.map +1 -0
- package/dist/lib/cjs/config/config-loader.js +34 -13
- package/dist/lib/cjs/config/config-loader.js.map +1 -1
- package/dist/lib/cjs/decorators/command-parameter.decorator.js +40 -0
- package/dist/lib/cjs/decorators/command-parameter.decorator.js.map +1 -0
- package/dist/lib/cjs/decorators/decorators.js +18 -0
- package/dist/lib/cjs/decorators/decorators.js.map +1 -0
- package/dist/lib/cjs/enums/cli-decorator-metadata-keyname.enum.js +14 -0
- package/dist/lib/cjs/enums/cli-decorator-metadata-keyname.enum.js.map +1 -0
- package/dist/lib/cjs/enums/enums.js +19 -0
- package/dist/lib/cjs/enums/enums.js.map +1 -0
- package/dist/lib/cjs/enums/terminal-key-name.enum.js +21 -0
- package/dist/lib/cjs/enums/terminal-key-name.enum.js.map +1 -0
- package/dist/lib/cjs/errors/cli-error-code.enum.js +11 -1
- package/dist/lib/cjs/errors/cli-error-code.enum.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/errors/prompt-cancelled.error.js +25 -0
- package/dist/lib/cjs/errors/prompt-cancelled.error.js.map +1 -0
- package/dist/lib/cjs/event-handlers/cli.event-handler.js +21 -65
- package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/cjs/event-handlers/event-handlers.js +1 -0
- package/dist/lib/cjs/event-handlers/event-handlers.js.map +1 -1
- package/dist/lib/cjs/event-handlers/repl-start.event-handler.js +280 -0
- package/dist/lib/cjs/event-handlers/repl-start.event-handler.js.map +1 -0
- package/dist/lib/cjs/event-payloads/event-payloads.js +1 -0
- package/dist/lib/cjs/event-payloads/event-payloads.js.map +1 -1
- package/dist/lib/cjs/event-payloads/start-repl.event-payload.js +19 -0
- package/dist/lib/cjs/event-payloads/start-repl.event-payload.js.map +1 -0
- package/dist/lib/cjs/interfaces/interfaces.js +1 -0
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/dist/lib/cjs/interfaces/terminal-key.interface.js +3 -0
- package/dist/lib/cjs/interfaces/terminal-key.interface.js.map +1 -0
- package/dist/lib/cjs/managers/cli-prompt.manager.js +181 -15
- package/dist/lib/cjs/managers/cli-prompt.manager.js.map +1 -1
- package/dist/lib/cjs/managers/managers.js +1 -0
- package/dist/lib/cjs/managers/managers.js.map +1 -1
- package/dist/lib/cjs/managers/terminal-key-reader.manager.js +99 -0
- package/dist/lib/cjs/managers/terminal-key-reader.manager.js.map +1 -0
- package/dist/lib/cjs/mappers/command-event.mapper.js +48 -8
- package/dist/lib/cjs/mappers/command-event.mapper.js.map +1 -1
- package/dist/lib/cjs/mappers/mappers.js +1 -0
- package/dist/lib/cjs/mappers/mappers.js.map +1 -1
- package/dist/lib/cjs/mappers/repl-start-event.mapper.js +80 -0
- package/dist/lib/cjs/mappers/repl-start-event.mapper.js.map +1 -0
- package/dist/lib/cjs/options/command-parameter.options.js +3 -0
- package/dist/lib/cjs/options/command-parameter.options.js.map +1 -0
- package/dist/lib/cjs/options/options.js +1 -0
- package/dist/lib/cjs/options/options.js.map +1 -1
- package/dist/lib/cjs/services/command-argument-resolver.js +62 -0
- package/dist/lib/cjs/services/command-argument-resolver.js.map +1 -0
- package/dist/lib/cjs/services/command-options-resolver.js +114 -0
- package/dist/lib/cjs/services/command-options-resolver.js.map +1 -0
- package/dist/lib/cjs/services/command-parameter-prompter.js +311 -0
- package/dist/lib/cjs/services/command-parameter-prompter.js.map +1 -0
- package/dist/lib/cjs/services/services.js +20 -0
- package/dist/lib/cjs/services/services.js.map +1 -0
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/types/start-repl-event-response.type.js +13 -0
- package/dist/lib/cjs/types/start-repl-event-response.type.js.map +1 -0
- package/dist/lib/cjs/types/types.js +1 -0
- package/dist/lib/cjs/types/types.js.map +1 -1
- package/dist/lib/cjs/utils/boolean-answer-parser.js +25 -0
- package/dist/lib/cjs/utils/boolean-answer-parser.js.map +1 -0
- package/dist/lib/cjs/utils/pristine-argv.js +87 -0
- package/dist/lib/cjs/utils/pristine-argv.js.map +1 -0
- package/dist/lib/cjs/utils/terminal-key-decoder.js +71 -0
- package/dist/lib/cjs/utils/terminal-key-decoder.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-staleness-prompt.js +12 -13
- package/dist/lib/esm/bootstrap/build-staleness-prompt.js.map +1 -1
- package/dist/lib/esm/bootstrap/init-prompt.js +16 -47
- package/dist/lib/esm/bootstrap/init-prompt.js.map +1 -1
- package/dist/lib/esm/cli.configuration-keys.js +21 -0
- package/dist/lib/esm/cli.configuration-keys.js.map +1 -0
- package/dist/lib/esm/cli.js +23 -10
- package/dist/lib/esm/cli.js.map +1 -1
- package/dist/lib/esm/cli.module.js +29 -1
- package/dist/lib/esm/cli.module.js.map +1 -1
- package/dist/lib/esm/commands/commands.js +6 -0
- package/dist/lib/esm/commands/commands.js.map +1 -1
- package/dist/lib/esm/commands/logs-alias.command.js +46 -0
- package/dist/lib/esm/commands/logs-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/logs.command-options.js +68 -0
- package/dist/lib/esm/commands/logs.command-options.js.map +1 -0
- package/dist/lib/esm/commands/logs.command.js +99 -0
- package/dist/lib/esm/commands/logs.command.js.map +1 -0
- package/dist/lib/esm/commands/requests-alias.command.js +46 -0
- package/dist/lib/esm/commands/requests-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/requests.command-options.js +22 -0
- package/dist/lib/esm/commands/requests.command-options.js.map +1 -0
- package/dist/lib/esm/commands/requests.command.js +85 -0
- package/dist/lib/esm/commands/requests.command.js.map +1 -0
- package/dist/lib/esm/commands/trace-alias.command.js +46 -0
- package/dist/lib/esm/commands/trace-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/trace.command-options.js +55 -0
- package/dist/lib/esm/commands/trace.command-options.js.map +1 -0
- package/dist/lib/esm/commands/trace.command.js +81 -0
- package/dist/lib/esm/commands/trace.command.js.map +1 -0
- package/dist/lib/esm/config/config-loader.js +34 -13
- package/dist/lib/esm/config/config-loader.js.map +1 -1
- package/dist/lib/esm/decorators/command-parameter.decorator.js +36 -0
- package/dist/lib/esm/decorators/command-parameter.decorator.js.map +1 -0
- package/dist/lib/esm/decorators/decorators.js +2 -0
- package/dist/lib/esm/decorators/decorators.js.map +1 -0
- package/dist/lib/esm/enums/cli-decorator-metadata-keyname.enum.js +11 -0
- package/dist/lib/esm/enums/cli-decorator-metadata-keyname.enum.js.map +1 -0
- package/dist/lib/esm/enums/enums.js +3 -0
- package/dist/lib/esm/enums/enums.js.map +1 -0
- package/dist/lib/esm/enums/terminal-key-name.enum.js +18 -0
- package/dist/lib/esm/enums/terminal-key-name.enum.js.map +1 -0
- package/dist/lib/esm/errors/cli-error-code.enum.js +11 -1
- package/dist/lib/esm/errors/cli-error-code.enum.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/errors/prompt-cancelled.error.js +21 -0
- package/dist/lib/esm/errors/prompt-cancelled.error.js.map +1 -0
- package/dist/lib/esm/event-handlers/cli.event-handler.js +22 -66
- package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/esm/event-handlers/event-handlers.js +1 -0
- package/dist/lib/esm/event-handlers/event-handlers.js.map +1 -1
- package/dist/lib/esm/event-handlers/repl-start.event-handler.js +244 -0
- package/dist/lib/esm/event-handlers/repl-start.event-handler.js.map +1 -0
- package/dist/lib/esm/event-payloads/event-payloads.js +1 -0
- package/dist/lib/esm/event-payloads/event-payloads.js.map +1 -1
- package/dist/lib/esm/event-payloads/start-repl.event-payload.js +15 -0
- package/dist/lib/esm/event-payloads/start-repl.event-payload.js.map +1 -0
- package/dist/lib/esm/interfaces/interfaces.js +1 -0
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
- package/dist/lib/esm/interfaces/terminal-key.interface.js +2 -0
- package/dist/lib/esm/interfaces/terminal-key.interface.js.map +1 -0
- package/dist/lib/esm/managers/cli-prompt.manager.js +182 -16
- package/dist/lib/esm/managers/cli-prompt.manager.js.map +1 -1
- package/dist/lib/esm/managers/managers.js +1 -0
- package/dist/lib/esm/managers/managers.js.map +1 -1
- package/dist/lib/esm/managers/terminal-key-reader.manager.js +96 -0
- package/dist/lib/esm/managers/terminal-key-reader.manager.js.map +1 -0
- package/dist/lib/esm/mappers/command-event.mapper.js +49 -9
- package/dist/lib/esm/mappers/command-event.mapper.js.map +1 -1
- package/dist/lib/esm/mappers/mappers.js +1 -0
- package/dist/lib/esm/mappers/mappers.js.map +1 -1
- package/dist/lib/esm/mappers/repl-start-event.mapper.js +77 -0
- package/dist/lib/esm/mappers/repl-start-event.mapper.js.map +1 -0
- package/dist/lib/esm/options/command-parameter.options.js +2 -0
- package/dist/lib/esm/options/command-parameter.options.js.map +1 -0
- package/dist/lib/esm/options/options.js +1 -0
- package/dist/lib/esm/options/options.js.map +1 -1
- package/dist/lib/esm/services/command-argument-resolver.js +59 -0
- package/dist/lib/esm/services/command-argument-resolver.js.map +1 -0
- package/dist/lib/esm/services/command-options-resolver.js +111 -0
- package/dist/lib/esm/services/command-options-resolver.js.map +1 -0
- package/dist/lib/esm/services/command-parameter-prompter.js +308 -0
- package/dist/lib/esm/services/command-parameter-prompter.js.map +1 -0
- package/dist/lib/esm/services/services.js +4 -0
- package/dist/lib/esm/services/services.js.map +1 -0
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/types/start-repl-event-response.type.js +9 -0
- package/dist/lib/esm/types/start-repl-event-response.type.js.map +1 -0
- package/dist/lib/esm/types/types.js +1 -0
- package/dist/lib/esm/types/types.js.map +1 -1
- package/dist/lib/esm/utils/boolean-answer-parser.js +21 -0
- package/dist/lib/esm/utils/boolean-answer-parser.js.map +1 -0
- package/dist/lib/esm/utils/pristine-argv.js +50 -0
- package/dist/lib/esm/utils/pristine-argv.js.map +1 -0
- package/dist/lib/esm/utils/terminal-key-decoder.js +67 -0
- package/dist/lib/esm/utils/terminal-key-decoder.js.map +1 -0
- package/dist/types/bootstrap/build-staleness-prompt.d.ts +3 -3
- package/dist/types/bootstrap/init-prompt.d.ts +5 -5
- package/dist/types/cli.configuration-keys.d.ts +32 -0
- package/dist/types/cli.d.ts +8 -4
- package/dist/types/cli.module.d.ts +4 -0
- package/dist/types/commands/commands.d.ts +6 -0
- package/dist/types/commands/logs-alias.command.d.ts +14 -0
- package/dist/types/commands/logs.command-options.d.ts +38 -0
- package/dist/types/commands/logs.command.d.ts +31 -0
- package/dist/types/commands/requests-alias.command.d.ts +14 -0
- package/dist/types/commands/requests.command-options.d.ts +8 -0
- package/dist/types/commands/requests.command.d.ts +25 -0
- package/dist/types/commands/trace-alias.command.d.ts +14 -0
- package/dist/types/commands/trace.command-options.d.ts +31 -0
- package/dist/types/commands/trace.command.d.ts +21 -0
- package/dist/types/config/config-loader.d.ts +15 -3
- package/dist/types/decorators/command-parameter.decorator.d.ts +30 -0
- package/dist/types/decorators/decorators.d.ts +1 -0
- package/dist/types/enums/cli-decorator-metadata-keyname.enum.d.ts +9 -0
- package/dist/types/enums/enums.d.ts +2 -0
- package/dist/types/enums/terminal-key-name.enum.d.ts +16 -0
- package/dist/types/errors/cli-error-code.enum.d.ts +12 -2
- package/dist/types/errors/errors.d.ts +1 -0
- package/dist/types/errors/prompt-cancelled.error.d.ts +13 -0
- package/dist/types/event-handlers/cli.event-handler.d.ts +16 -13
- package/dist/types/event-handlers/event-handlers.d.ts +1 -0
- package/dist/types/event-handlers/repl-start.event-handler.d.ts +70 -0
- package/dist/types/event-payloads/event-payloads.d.ts +1 -0
- package/dist/types/event-payloads/start-repl.event-payload.d.ts +13 -0
- package/dist/types/interfaces/interfaces.d.ts +1 -0
- package/dist/types/interfaces/terminal-key.interface.d.ts +11 -0
- package/dist/types/managers/cli-prompt.manager.d.ts +63 -6
- package/dist/types/managers/managers.d.ts +1 -0
- package/dist/types/managers/terminal-key-reader.manager.d.ts +31 -0
- package/dist/types/mappers/command-event.mapper.d.ts +10 -1
- package/dist/types/mappers/mappers.d.ts +1 -0
- package/dist/types/mappers/repl-start-event.mapper.d.ts +28 -0
- package/dist/types/options/command-parameter.options.d.ts +29 -0
- package/dist/types/options/options.d.ts +1 -0
- package/dist/types/services/command-argument-resolver.d.ts +24 -0
- package/dist/types/services/command-options-resolver.d.ts +35 -0
- package/dist/types/services/command-parameter-prompter.d.ts +113 -0
- package/dist/types/services/services.d.ts +3 -0
- package/dist/types/types/start-repl-event-response.type.d.ts +10 -0
- package/dist/types/types/types.d.ts +1 -0
- package/dist/types/utils/boolean-answer-parser.d.ts +11 -0
- package/dist/types/utils/pristine-argv.d.ts +33 -0
- package/dist/types/utils/terminal-key-decoder.d.ts +28 -0
- package/package.json +16 -12
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EventResponse } from "@pristine-ts/core";
|
|
2
|
+
/**
|
|
3
|
+
* The response shape produced by `ReplStartEventHandler` when the interactive session
|
|
4
|
+
* ends (`/exit` or EOF). Carries the exit code the bin should pass to `process.exit`,
|
|
5
|
+
* surfaced through `ReplStartEventMapper.reverseMap`.
|
|
6
|
+
*/
|
|
7
|
+
export class StartReplEventResponse extends EventResponse {
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=start-repl-event-response.type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-repl-event-response.type.js","sourceRoot":"","sources":["../../../../src/types/start-repl-event-response.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAIhD;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,aAAuD;CAClG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interprets a free-text answer as a boolean the way traditional CLIs do — accepting
|
|
3
|
+
* `y`/`yes`/`true`/`1` and `n`/`no`/`false`/`0` (case-insensitive, surrounding whitespace
|
|
4
|
+
* ignored). Returns `undefined` for anything unrecognized so callers can re-ask.
|
|
5
|
+
*
|
|
6
|
+
* Shared by `CliPrompt.confirm` (yes/no prompts) and `CommandParameterPrompter` (typed
|
|
7
|
+
* boolean parameters) so both accept exactly the same set of answers.
|
|
8
|
+
*/
|
|
9
|
+
export class BooleanAnswerParser {
|
|
10
|
+
static parse(raw) {
|
|
11
|
+
const normalized = raw.trim().toLowerCase();
|
|
12
|
+
if (normalized === "y" || normalized === "yes" || normalized === "true" || normalized === "1") {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (normalized === "n" || normalized === "no" || normalized === "false" || normalized === "0") {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=boolean-answer-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-answer-parser.js","sourceRoot":"","sources":["../../../../src/utils/boolean-answer-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,KAAK,CAAC,GAAW;QACtB,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC5C,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;YAC9F,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;YAC9F,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
/**
|
|
3
|
+
* Parses an argv array — typically `process.argv` — to locate the pristine bin and
|
|
4
|
+
* extract the user-typed arguments that follow it.
|
|
5
|
+
*
|
|
6
|
+
* Why scan rather than positional-index: argv shape is runtime-dependent. Node and Bun
|
|
7
|
+
* happen to put `[executable, scriptPath, ...userArgs]` today, but a different runtime
|
|
8
|
+
* (or a launcher that prepends flags before the script) can violate that. Locating the
|
|
9
|
+
* bin by name — an element whose basename (stripped of any extension like `.cjs` /
|
|
10
|
+
* `.js` / `.mjs`) is `pristine` — is robust across:
|
|
11
|
+
*
|
|
12
|
+
* - global installs (`pristine repl` → argv contains `/usr/local/.../pristine.cjs`)
|
|
13
|
+
* - local installs (`./node_modules/.bin/pristine`)
|
|
14
|
+
* - `npx pristine`
|
|
15
|
+
* - direct `node dist/bin/pristine.cjs`
|
|
16
|
+
* - alternative runtimes that may shape argv differently
|
|
17
|
+
* - the synthetic argv the REPL handler builds for each typed line
|
|
18
|
+
*
|
|
19
|
+
* Stateless after construction; instantiate per parse.
|
|
20
|
+
*/
|
|
21
|
+
export class PristineArgv {
|
|
22
|
+
constructor(rawArgv) {
|
|
23
|
+
const binIndex = rawArgv.findIndex(arg => PristineArgv.isPristineBin(arg));
|
|
24
|
+
if (binIndex === -1) {
|
|
25
|
+
this.scriptPath = "";
|
|
26
|
+
this.userArgs = [];
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const scriptPath = rawArgv[binIndex];
|
|
30
|
+
this.scriptPath = typeof scriptPath === "string" ? scriptPath : "";
|
|
31
|
+
this.userArgs = rawArgv
|
|
32
|
+
.slice(binIndex + 1)
|
|
33
|
+
.filter((arg) => typeof arg === "string");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* True when the argv was recognizable as a pristine invocation (the bin token was
|
|
37
|
+
* located). Mappers short-circuit `supportsMapping` on this.
|
|
38
|
+
*/
|
|
39
|
+
get isValid() {
|
|
40
|
+
return this.scriptPath !== "";
|
|
41
|
+
}
|
|
42
|
+
static isPristineBin(arg) {
|
|
43
|
+
if (typeof arg !== "string") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return path.basename(arg, path.extname(arg)) === PristineArgv.BIN_NAME;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
PristineArgv.BIN_NAME = "pristine";
|
|
50
|
+
//# sourceMappingURL=pristine-argv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pristine-argv.js","sourceRoot":"","sources":["../../../../src/utils/pristine-argv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,YAAY;IASvB,YAAY,OAA2B;QACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,IAAI,CAAC,QAAQ,GAAG,OAAO;aACpB,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC;aACnB,MAAM,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC;IAChC,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,GAAY;QACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,YAAY,CAAC,QAAQ,CAAC;IACzE,CAAC;;AAnCuB,qBAAQ,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TerminalKeyName } from "../enums/terminal-key-name.enum";
|
|
2
|
+
/**
|
|
3
|
+
* Translates the raw bytes Node delivers from a raw-mode stdin into structured
|
|
4
|
+
* {@link TerminalKey}s. Pure and static so it can be unit-tested without a real TTY.
|
|
5
|
+
*
|
|
6
|
+
* A single `data` chunk can carry more than one keystroke (notably a paste, or fast
|
|
7
|
+
* typing), so this returns an array. Control and escape sequences are recognized as one
|
|
8
|
+
* key each; a run of printable characters is split into one `Character` key per character
|
|
9
|
+
* so callers (masked input, menus) can echo and handle them uniformly.
|
|
10
|
+
*/
|
|
11
|
+
export class TerminalKeyDecoder {
|
|
12
|
+
/**
|
|
13
|
+
* Decodes a raw stdin chunk into the keys it represents.
|
|
14
|
+
*
|
|
15
|
+
* - A recognized control byte / escape sequence that spans the whole chunk → one key.
|
|
16
|
+
* - An unrecognized escape sequence (starts with ESC) → a single `Other` key, rather
|
|
17
|
+
* than splitting it into bogus printable characters.
|
|
18
|
+
* - Anything else → one key per character, with non-printable control bytes mapped to
|
|
19
|
+
* `Other` so they're ignored rather than echoed.
|
|
20
|
+
*/
|
|
21
|
+
static decode(data) {
|
|
22
|
+
const whole = TerminalKeyDecoder.decodeControl(data);
|
|
23
|
+
if (whole !== undefined) {
|
|
24
|
+
return [whole];
|
|
25
|
+
}
|
|
26
|
+
if (data.charCodeAt(0) === 0x1b) {
|
|
27
|
+
return [{ name: TerminalKeyName.Other, sequence: data }];
|
|
28
|
+
}
|
|
29
|
+
const keys = [];
|
|
30
|
+
for (const character of data) {
|
|
31
|
+
const control = TerminalKeyDecoder.decodeControl(character);
|
|
32
|
+
if (control !== undefined) {
|
|
33
|
+
keys.push(control);
|
|
34
|
+
}
|
|
35
|
+
else if (character.charCodeAt(0) < 0x20) {
|
|
36
|
+
keys.push({ name: TerminalKeyName.Other, sequence: character });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
keys.push({ name: TerminalKeyName.Character, sequence: character });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return keys;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Maps a single recognized control byte or escape sequence to its key, or `undefined`
|
|
46
|
+
* when the input isn't one we handle.
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
static decodeControl(sequence) {
|
|
50
|
+
switch (sequence) {
|
|
51
|
+
case "\x1b[A":
|
|
52
|
+
return { name: TerminalKeyName.Up, sequence };
|
|
53
|
+
case "\x1b[B":
|
|
54
|
+
return { name: TerminalKeyName.Down, sequence };
|
|
55
|
+
case "\r":
|
|
56
|
+
case "\n":
|
|
57
|
+
return { name: TerminalKeyName.Enter, sequence };
|
|
58
|
+
case "\x7f":
|
|
59
|
+
case "\b":
|
|
60
|
+
return { name: TerminalKeyName.Backspace, sequence };
|
|
61
|
+
case "\x03":
|
|
62
|
+
return { name: TerminalKeyName.CtrlC, sequence };
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=terminal-key-decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-key-decoder.js","sourceRoot":"","sources":["../../../../src/utils/terminal-key-decoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CAAC,IAAY;QACxB,MAAM,KAAK,GAAG,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAChC,OAAO,CAAC,EAAC,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,IAAI,GAAkB,EAAE,CAAC;QAC/B,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC5D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC;iBAAM,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;gBAC1C,IAAI,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,aAAa,CAAC,QAAgB;QAC3C,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,QAAQ;gBACX,OAAO,EAAC,IAAI,EAAE,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAC,CAAC;YAC9C,KAAK,QAAQ;gBACX,OAAO,EAAC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;YAChD,KAAK,IAAI,CAAC;YACV,KAAK,IAAI;gBACP,OAAO,EAAC,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAC,CAAC;YACjD,KAAK,MAAM,CAAC;YACZ,KAAK,IAAI;gBACP,OAAO,EAAC,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAC,CAAC;YACrD,KAAK,MAAM;gBACT,OAAO,EAAC,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAC,CAAC;QACnD,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildManifestStalenessEnum } from "./build-manifest-staleness.enum";
|
|
2
|
-
import {
|
|
2
|
+
import { CliPrompt } from "../managers/cli-prompt.manager";
|
|
3
3
|
/**
|
|
4
4
|
* When the build manifest is stale (source edited, output missing, etc.), `AppModuleLoader`
|
|
5
5
|
* stops the load and consults this prompt. In a TTY, asks the user whether to run
|
|
@@ -10,9 +10,9 @@ import { DynamicImporter } from "./dynamic-importer";
|
|
|
10
10
|
* this class stays small and testable.
|
|
11
11
|
*/
|
|
12
12
|
export declare class BuildStalenessPrompt {
|
|
13
|
-
private readonly
|
|
13
|
+
private readonly cliPrompt;
|
|
14
14
|
private readonly promptMessage;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(cliPrompt: CliPrompt);
|
|
16
16
|
isInteractive(): boolean;
|
|
17
17
|
/**
|
|
18
18
|
* Renders a one-line explanation of why the manifest is stale. Used by both the prompt
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CliPrompt } from "../managers/cli-prompt.manager";
|
|
2
2
|
/**
|
|
3
3
|
* Answers the init flow needs to gather. Each field corresponds to one config value that
|
|
4
4
|
* `pristine.config.ts` will end up with. The init command resolves these from CLI flags
|
|
@@ -13,8 +13,8 @@ export interface InitAnswers {
|
|
|
13
13
|
writePackageScripts: boolean;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Interactive Q&A for `pristine init`.
|
|
17
|
-
*
|
|
16
|
+
* Interactive Q&A for `pristine init`. Prompts through {@link CliPrompt}, the CLI's native
|
|
17
|
+
* (no third-party dependency) terminal-prompt manager.
|
|
18
18
|
*
|
|
19
19
|
* Each method takes a "current value" so callers can pre-fill answers from CLI flags and
|
|
20
20
|
* only prompt for the gaps. Returning the same value the user passed in is intentional —
|
|
@@ -22,12 +22,12 @@ export interface InitAnswers {
|
|
|
22
22
|
* prompt.
|
|
23
23
|
*/
|
|
24
24
|
export declare class InitPrompt {
|
|
25
|
-
private readonly
|
|
25
|
+
private readonly cliPrompt;
|
|
26
26
|
private readonly defaultSourcePath;
|
|
27
27
|
private readonly defaultOutputPath;
|
|
28
28
|
private readonly defaultTsconfig;
|
|
29
29
|
private readonly defaultFormat;
|
|
30
|
-
constructor(
|
|
30
|
+
constructor(cliPrompt: CliPrompt);
|
|
31
31
|
isInteractive(): boolean;
|
|
32
32
|
askSourcePath(current: string | undefined): Promise<string>;
|
|
33
33
|
askOutputPath(current: string | undefined): Promise<string>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed configuration keys for `@pristine-ts/cli`. Use these constants with `@injectConfig`
|
|
3
|
+
* for autocomplete + rename safety, instead of typing the parameter name as a string.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import {injectConfig} from "@pristine-ts/common";
|
|
7
|
+
* import {CliConfigurationKeys} from "@pristine-ts/cli";
|
|
8
|
+
*
|
|
9
|
+
* constructor(@injectConfig(CliConfigurationKeys.InteractiveParameters) enabled: boolean) {}
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const CliConfigurationKeys: {
|
|
13
|
+
/**
|
|
14
|
+
* Whether the CLI may interactively ask for missing command parameters that declare a
|
|
15
|
+
* `question` (via `@commandParameter`). Defaults to `true`; set it to `false` to disable
|
|
16
|
+
* all such prompting (e.g. in CI). Prompting is also skipped automatically whenever the
|
|
17
|
+
* input is not an interactive terminal, regardless of this value.
|
|
18
|
+
*/
|
|
19
|
+
readonly InteractiveParameters: "pristine.cli.interactiveParameters";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The expected runtime types for each configuration value defined by `@pristine-ts/cli`. The
|
|
23
|
+
* `@pristine-ts/eslint-plugin` rule `inject-config-type-match` reads the merged map to
|
|
24
|
+
* enforce parameter types on `@injectConfig` calls.
|
|
25
|
+
*/
|
|
26
|
+
export interface CliConfigurationValueMap {
|
|
27
|
+
"pristine.cli.interactiveParameters": boolean;
|
|
28
|
+
}
|
|
29
|
+
declare module "@pristine-ts/common" {
|
|
30
|
+
interface PristineConfigurationValueMap extends CliConfigurationValueMap {
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -47,11 +47,15 @@ export declare class Cli {
|
|
|
47
47
|
*/
|
|
48
48
|
private readEnvironmentFromConfigFile;
|
|
49
49
|
/**
|
|
50
|
-
* Builds a synthetic outer AppModule that imports
|
|
50
|
+
* Builds a synthetic outer AppModule that imports the user's AppModule plus `CliModule`
|
|
51
|
+
* — so the CLI's own commands are always registered when the bin is the entry point.
|
|
52
|
+
* `CliModule` itself imports `ObservabilityModule`, so the logs/traces store travels
|
|
53
|
+
* along without being named here.
|
|
54
|
+
*
|
|
51
55
|
* The wrap is unconditional — the kernel dedupes module imports by keyname, so adding
|
|
52
|
-
* CliModule on top of a graph that already contains it is a no-op rather than an
|
|
53
|
-
* or duplicate registration. Cheaper than walking the user's import tree to
|
|
54
|
-
* already-present case.
|
|
56
|
+
* `CliModule` on top of a graph that already contains it is a no-op rather than an
|
|
57
|
+
* error or duplicate registration. Cheaper than walking the user's import tree to
|
|
58
|
+
* detect the already-present case.
|
|
55
59
|
*/
|
|
56
60
|
private wrapWithCliModule;
|
|
57
61
|
/**
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ModuleInterface } from "@pristine-ts/common";
|
|
2
2
|
export * from "./bootstrap/bootstrap";
|
|
3
|
+
export * from "./cli.configuration-keys";
|
|
3
4
|
export * from "./commands/commands";
|
|
4
5
|
export * from "./config/config";
|
|
6
|
+
export * from "./decorators/decorators";
|
|
7
|
+
export * from "./enums/enums";
|
|
5
8
|
export * from "./errors/errors";
|
|
6
9
|
export * from "./event-handlers/event-handlers";
|
|
7
10
|
export * from "./event-payloads/event-payloads";
|
|
@@ -10,6 +13,7 @@ export * from "./managers/managers";
|
|
|
10
13
|
export * from "./mappers/mappers";
|
|
11
14
|
export * from "./options/options";
|
|
12
15
|
export * from "./reporters/cli-error.reporter";
|
|
16
|
+
export * from "./services/services";
|
|
13
17
|
export * from "./types/types";
|
|
14
18
|
export { Cli } from "./cli";
|
|
15
19
|
export declare const CliModule: ModuleInterface;
|
|
@@ -10,8 +10,14 @@ export * from "./init.command";
|
|
|
10
10
|
export * from "./init.command-options";
|
|
11
11
|
export * from "./list-alias.command";
|
|
12
12
|
export * from "./list.command";
|
|
13
|
+
export * from "./logs-alias.command";
|
|
14
|
+
export * from "./logs.command";
|
|
15
|
+
export * from "./requests-alias.command";
|
|
16
|
+
export * from "./requests.command";
|
|
13
17
|
export * from "./start-alias.command";
|
|
14
18
|
export * from "./start.command";
|
|
15
19
|
export * from "./start.command-options";
|
|
20
|
+
export * from "./trace-alias.command";
|
|
21
|
+
export * from "./trace.command";
|
|
16
22
|
export * from "./verify-alias.command";
|
|
17
23
|
export * from "./verify.command";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
|
+
import { CommandInterface } from "../interfaces/command.interface";
|
|
3
|
+
import { LogsCommand } from "./logs.command";
|
|
4
|
+
/**
|
|
5
|
+
* Top-level alias for `p:logs`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class LogsAliasCommand implements CommandInterface<null> {
|
|
8
|
+
private readonly delegate;
|
|
9
|
+
optionsType: null;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(delegate: LogsCommand);
|
|
13
|
+
run(args: any): Promise<ExitCode | number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* Flags + positional for `pristine logs [<id>] [--event-id <x>] [--trace-id <x>] [--request-id <x>] [--follow|-f]`.
|
|
4
|
+
*
|
|
5
|
+
* Filter the log stream by any of three correlation ids — `--event-id` is canonical,
|
|
6
|
+
* `--trace-id` covers the distributed-tracing case (a propagated `traceparent`),
|
|
7
|
+
* `--request-id` covers HTTP requests with an `x-pristine-request-id` header. A
|
|
8
|
+
* positional id (e.g. `pristine logs abc-123`) is tried against all three.
|
|
9
|
+
*
|
|
10
|
+
* `--follow` and `-f` are accepted as independent boolean keys (that's how
|
|
11
|
+
* `CommandEventMapper` records short-vs-long flags); the `isFollowing` getter combines
|
|
12
|
+
* them so the command body reads a single field.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LogsCommandOptions {
|
|
15
|
+
/** `--event-id <id>`: filter by the canonical event id. */
|
|
16
|
+
"event-id"?: string;
|
|
17
|
+
/** `--trace-id <id>`: filter by the trace id (distributed-tracing scenarios). */
|
|
18
|
+
"trace-id"?: string;
|
|
19
|
+
/** `--request-id <id>`: filter by the request id (HTTP `x-pristine-request-id`). */
|
|
20
|
+
"request-id"?: string;
|
|
21
|
+
/** `--follow`: tail the log stream and render new entries as they arrive. */
|
|
22
|
+
follow?: boolean;
|
|
23
|
+
/** `-f`: short alias for `--follow`. */
|
|
24
|
+
f?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Bare positional tokens. A positional id is tried against all three correlation
|
|
27
|
+
* fields by `LogStore.read(id)` / `LogStore.tail(id, ...)`. Decorators are required
|
|
28
|
+
* for `AutoDataMappingBuilder` to round-trip the field.
|
|
29
|
+
*/
|
|
30
|
+
_?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the filter id: an explicit flag wins over the positional, and explicit
|
|
33
|
+
* flags are preferred in `eventId > traceId > requestId` order on the (rare) chance
|
|
34
|
+
* the user passed several.
|
|
35
|
+
*/
|
|
36
|
+
get filterId(): string | undefined;
|
|
37
|
+
get isFollowing(): boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
|
+
import { LogStore } from "@pristine-ts/observability";
|
|
3
|
+
import { CommandInterface } from "../interfaces/command.interface";
|
|
4
|
+
import { CliOutput } from "../managers/cli-output.manager";
|
|
5
|
+
import { LogsCommandOptions } from "./logs.command-options";
|
|
6
|
+
/**
|
|
7
|
+
* Renders captured logs: `pristine logs` for everything (newest first across all
|
|
8
|
+
* processes), `pristine logs <id>` to filter by any of event/trace/request id, or
|
|
9
|
+
* the explicit `--event-id` / `--trace-id` / `--request-id` flags. With `--follow`/`-f`
|
|
10
|
+
* it tails the live writers (Ctrl-C to stop). A pure report command: output goes
|
|
11
|
+
* through `CliOutput`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class LogsCommand implements CommandInterface<LogsCommandOptions> {
|
|
14
|
+
private readonly cliOutput;
|
|
15
|
+
private readonly logStore;
|
|
16
|
+
optionsType: typeof LogsCommandOptions;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
constructor(cliOutput: CliOutput, logStore: LogStore);
|
|
20
|
+
run(args: LogsCommandOptions): Promise<ExitCode | number>;
|
|
21
|
+
/**
|
|
22
|
+
* Tails live writes, rendering each newly-appended line until SIGINT.
|
|
23
|
+
*/
|
|
24
|
+
private followLogs;
|
|
25
|
+
/**
|
|
26
|
+
* Renders one stored log entry through `PrettyLogFormatter`. The store keeps `date`
|
|
27
|
+
* as an ISO string and `severity` as a numeric `SeverityEnum`; rehydrate the date so
|
|
28
|
+
* the formatter (date-fns) can format it.
|
|
29
|
+
*/
|
|
30
|
+
private render;
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
|
+
import { CommandInterface } from "../interfaces/command.interface";
|
|
3
|
+
import { RequestsCommand } from "./requests.command";
|
|
4
|
+
/**
|
|
5
|
+
* Top-level alias for `p:requests`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RequestsAliasCommand implements CommandInterface<null> {
|
|
8
|
+
private readonly delegate;
|
|
9
|
+
optionsType: null;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(delegate: RequestsCommand);
|
|
13
|
+
run(args: any): Promise<ExitCode | number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
|
+
import { TraceStore } from "@pristine-ts/observability";
|
|
3
|
+
import { CommandInterface } from "../interfaces/command.interface";
|
|
4
|
+
import { CliOutput } from "../managers/cli-output.manager";
|
|
5
|
+
import { RequestsCommandOptions } from "./requests.command-options";
|
|
6
|
+
/**
|
|
7
|
+
* Lists recent requests captured in the observability store — the entry point for
|
|
8
|
+
* "what just happened, and what's the event id I want to inspect?".
|
|
9
|
+
*
|
|
10
|
+
* Pulls summaries from every captured process newest-first. A pure report command: all
|
|
11
|
+
* output goes through `CliOutput` so it pipes cleanly.
|
|
12
|
+
*
|
|
13
|
+
* Flags: `--limit <n>` (default 20).
|
|
14
|
+
*/
|
|
15
|
+
export declare class RequestsCommand implements CommandInterface<RequestsCommandOptions> {
|
|
16
|
+
private readonly cliOutput;
|
|
17
|
+
private readonly traceStore;
|
|
18
|
+
optionsType: typeof RequestsCommandOptions;
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
private static readonly DEFAULT_LIMIT;
|
|
22
|
+
constructor(cliOutput: CliOutput, traceStore: TraceStore);
|
|
23
|
+
run(args: RequestsCommandOptions): Promise<ExitCode | number>;
|
|
24
|
+
private renderTable;
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
|
+
import { CommandInterface } from "../interfaces/command.interface";
|
|
3
|
+
import { TraceCommand } from "./trace.command";
|
|
4
|
+
/**
|
|
5
|
+
* Top-level alias for `p:trace`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TraceAliasCommand implements CommandInterface<null> {
|
|
8
|
+
private readonly delegate;
|
|
9
|
+
optionsType: null;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(delegate: TraceCommand);
|
|
13
|
+
run(args: any): Promise<ExitCode | number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export type TraceFormat = "tree" | "flat" | "json";
|
|
3
|
+
/**
|
|
4
|
+
* Flags + positional for `pristine trace [<id>] [--event-id <x>] [--trace-id <x>] [--request-id <x>] [--format tree|flat|json]`.
|
|
5
|
+
*
|
|
6
|
+
* Look up a trace by any of three correlation ids — `--event-id` is canonical,
|
|
7
|
+
* `--trace-id` covers the distributed-tracing case (a propagated `traceparent`),
|
|
8
|
+
* `--request-id` covers HTTP requests with an `x-pristine-request-id` header. A
|
|
9
|
+
* positional id is tried against all three.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TraceCommandOptions {
|
|
12
|
+
/** `--event-id <id>`: look up by the canonical event id. */
|
|
13
|
+
"event-id"?: string;
|
|
14
|
+
/** `--trace-id <id>`: look up by the trace id (distributed-tracing scenarios). */
|
|
15
|
+
"trace-id"?: string;
|
|
16
|
+
/** `--request-id <id>`: look up by the request id (HTTP `x-pristine-request-id`). */
|
|
17
|
+
"request-id"?: string;
|
|
18
|
+
/** `--format tree|flat|json`: how to render the trace. Defaults to `tree`. */
|
|
19
|
+
format?: TraceFormat;
|
|
20
|
+
/**
|
|
21
|
+
* Bare positional tokens. A positional id is tried against all three correlation
|
|
22
|
+
* fields by `TraceStore.find(id)`. Decorators are required for `AutoDataMappingBuilder`
|
|
23
|
+
* to round-trip the field.
|
|
24
|
+
*/
|
|
25
|
+
_?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the lookup id: an explicit flag wins over the positional, and explicit
|
|
28
|
+
* flags are preferred in `eventId > traceId > requestId` order.
|
|
29
|
+
*/
|
|
30
|
+
get lookupId(): string | undefined;
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExitCode } from "@pristine-ts/common";
|
|
2
|
+
import { TraceStore } from "@pristine-ts/observability";
|
|
3
|
+
import { CommandInterface } from "../interfaces/command.interface";
|
|
4
|
+
import { CliOutput } from "../managers/cli-output.manager";
|
|
5
|
+
import { TraceCommandOptions } from "./trace.command-options";
|
|
6
|
+
/**
|
|
7
|
+
* Renders the span tree of one captured trace. Look it up by any of event/trace/request
|
|
8
|
+
* id — `pristine trace <id>` tries all three, or use the explicit `--event-id`,
|
|
9
|
+
* `--trace-id`, `--request-id` flags.
|
|
10
|
+
*
|
|
11
|
+
* `--format tree|flat|json` controls the rendering (defaults to `tree`).
|
|
12
|
+
*/
|
|
13
|
+
export declare class TraceCommand implements CommandInterface<TraceCommandOptions> {
|
|
14
|
+
private readonly cliOutput;
|
|
15
|
+
private readonly traceStore;
|
|
16
|
+
optionsType: typeof TraceCommandOptions;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
constructor(cliOutput: CliOutput, traceStore: TraceStore);
|
|
20
|
+
run(args: TraceCommandOptions): Promise<ExitCode | number>;
|
|
21
|
+
}
|
|
@@ -3,7 +3,8 @@ import { DynamicImporter } from "../bootstrap/dynamic-importer";
|
|
|
3
3
|
/**
|
|
4
4
|
* Loads `pristine.config.ts` (preferred) or `pristine.config.js` (escape hatch for
|
|
5
5
|
* pure-JS projects). Walks up from `process.cwd()` looking for the file, then loads it
|
|
6
|
-
* through
|
|
6
|
+
* through Node's native dynamic `import()`: TypeScript type-stripping (Node >= 22.18)
|
|
7
|
+
* handles `.ts`, while `.js` loads directly.
|
|
7
8
|
*
|
|
8
9
|
* Returns a `ResolvedPristineConfig` carrying the file path (when found) and per-field
|
|
9
10
|
* provenance, which `pristine p:config:print` uses to render an annotated dump.
|
|
@@ -31,10 +32,21 @@ export declare class ConfigLoader {
|
|
|
31
32
|
*/
|
|
32
33
|
private findConfigFile;
|
|
33
34
|
/**
|
|
34
|
-
* Loads a config file from `absolutePath
|
|
35
|
-
*
|
|
35
|
+
* Loads a config file from `absolutePath` via Node's native dynamic `import()`. A `.ts`
|
|
36
|
+
* config is handled by Node's built-in TypeScript type-stripping (Node >= 22.18); a `.js`
|
|
37
|
+
* config loads directly. Extracts the default export, falling back to a named
|
|
36
38
|
* `pristineConfig` export for users who prefer not to use `export default`.
|
|
37
39
|
* @private
|
|
38
40
|
*/
|
|
39
41
|
private importConfigFile;
|
|
42
|
+
/**
|
|
43
|
+
* Translates Node's low-level module-loading failures for a `.ts` config into an
|
|
44
|
+
* actionable error. Native type-stripping has two distinct failure modes worth telling
|
|
45
|
+
* apart: the running Node is too old (or has stripping disabled) to import `.ts` at all
|
|
46
|
+
* (`ERR_UNKNOWN_FILE_EXTENSION`), versus a config written with non-erasable TypeScript that
|
|
47
|
+
* stripping refuses (`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`). Any other error is passed through
|
|
48
|
+
* unchanged so genuine config bugs surface as-is.
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
private describeImportError;
|
|
40
52
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CommandParameterOptions } from "../options/command-parameter.options";
|
|
2
|
+
/**
|
|
3
|
+
* Describes a command-line parameter on a command's options class. Stored as property
|
|
4
|
+
* metadata and read by the CLI while resolving a command's arguments — before the arguments
|
|
5
|
+
* are mapped onto the options instance and validated.
|
|
6
|
+
*
|
|
7
|
+
* Two behaviors flow from the options:
|
|
8
|
+
*
|
|
9
|
+
* - `flag` rebinds the property to a differently-named flag (the property name is the
|
|
10
|
+
* default), so the property and the flag no longer have to be spelled identically.
|
|
11
|
+
* - `question` makes the CLI ask for the value interactively when the flag is absent
|
|
12
|
+
* (subject to configuration and an interactive terminal). Omit it to never prompt.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import {IsString, IsOptional} from "@pristine-ts/class-validator";
|
|
16
|
+
* import {commandParameter} from "@pristine-ts/cli";
|
|
17
|
+
*
|
|
18
|
+
* export class MigrateCommandOptions {
|
|
19
|
+
* @commandParameter({flag: "db-url", question: "What is the database URL?"})
|
|
20
|
+
* @IsString()
|
|
21
|
+
* databaseUrl?: string; // bound to --db-url; asked for when missing
|
|
22
|
+
*
|
|
23
|
+
* @commandParameter({flag: "dir"}) // bound to --dir; never asked for
|
|
24
|
+
* @IsOptional()
|
|
25
|
+
* @IsString()
|
|
26
|
+
* migrationsDirectory?: string;
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const commandParameter: (options?: CommandParameterOptions) => (target: any, propertyKey: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./command-parameter.decorator";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata keynames written by `@pristine-ts/cli`'s own property/class decorators and read
|
|
3
|
+
* back when resolving a command's options. Namespaced under `cli:` so they never collide
|
|
4
|
+
* with the keys other Pristine decorators (validation, data-mapping, mysql, …) store on the
|
|
5
|
+
* same class.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum CliDecoratorMetadataKeynameEnum {
|
|
8
|
+
CommandParameter = "cli:command-parameter"
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kinds of keypress the CLI's interactive prompts understand. `TerminalKeyDecoder`
|
|
3
|
+
* maps the raw bytes Node delivers from a raw-mode stdin onto one of these; every printable
|
|
4
|
+
* keystroke collapses to `Character` (with the literal character carried separately on
|
|
5
|
+
* {@link TerminalKey}). `Other` covers control/escape sequences the prompts don't act on
|
|
6
|
+
* (function keys, unhandled arrows) so callers can ignore them instead of echoing garbage.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum TerminalKeyName {
|
|
9
|
+
Up = "up",
|
|
10
|
+
Down = "down",
|
|
11
|
+
Enter = "enter",
|
|
12
|
+
Backspace = "backspace",
|
|
13
|
+
CtrlC = "ctrl-c",
|
|
14
|
+
Character = "character",
|
|
15
|
+
Other = "other"
|
|
16
|
+
}
|