@pristine-ts/cli 2.0.7 → 2.0.16
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/bin.js +0 -0
- package/dist/lib/cjs/bootstrap/app-module-cache.js +71 -0
- package/dist/lib/cjs/bootstrap/app-module-cache.js.map +1 -0
- package/dist/lib/cjs/bootstrap/app-module-discoverer.js +119 -0
- package/dist/lib/cjs/bootstrap/app-module-discoverer.js.map +1 -0
- package/dist/lib/cjs/bootstrap/app-module-discovery-candidate.js +21 -0
- package/dist/lib/cjs/bootstrap/app-module-discovery-candidate.js.map +1 -0
- package/dist/lib/cjs/bootstrap/app-module-discovery-reason.enum.js +15 -0
- package/dist/lib/cjs/bootstrap/app-module-discovery-reason.enum.js.map +1 -0
- package/dist/lib/cjs/bootstrap/app-module-prompt.js +78 -0
- package/dist/lib/cjs/bootstrap/app-module-prompt.js.map +1 -0
- 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/config-init.command.js +133 -0
- package/dist/lib/cjs/commands/config-init.command.js.map +1 -0
- 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/exit-code.enum.js +9 -0
- package/dist/lib/cjs/enums/exit-code.enum.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/console.manager.js +277 -0
- package/dist/lib/cjs/managers/console.manager.js.map +1 -0
- package/dist/lib/cjs/managers/managers.js +1 -0
- package/dist/lib/cjs/managers/managers.js.map +1 -1
- package/dist/lib/cjs/managers/repl-session.js +251 -0
- package/dist/lib/cjs/managers/repl-session.js.map +1 -0
- 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/app-module-cache.js +65 -0
- package/dist/lib/esm/bootstrap/app-module-cache.js.map +1 -0
- package/dist/lib/esm/bootstrap/app-module-discoverer.js +113 -0
- package/dist/lib/esm/bootstrap/app-module-discoverer.js.map +1 -0
- package/dist/lib/esm/bootstrap/app-module-discovery-candidate.js +17 -0
- package/dist/lib/esm/bootstrap/app-module-discovery-candidate.js.map +1 -0
- package/dist/lib/esm/bootstrap/app-module-discovery-reason.enum.js +12 -0
- package/dist/lib/esm/bootstrap/app-module-discovery-reason.enum.js.map +1 -0
- package/dist/lib/esm/bootstrap/app-module-prompt.js +75 -0
- package/dist/lib/esm/bootstrap/app-module-prompt.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/config-init.command.js +127 -0
- package/dist/lib/esm/commands/config-init.command.js.map +1 -0
- 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/exit-code.enum.js +6 -0
- package/dist/lib/esm/enums/exit-code.enum.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/console.manager.js +241 -0
- package/dist/lib/esm/managers/console.manager.js.map +1 -0
- package/dist/lib/esm/managers/managers.js +1 -0
- package/dist/lib/esm/managers/managers.js.map +1 -1
- package/dist/lib/esm/managers/repl-session.js +215 -0
- package/dist/lib/esm/managers/repl-session.js.map +1 -0
- 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/app-module-cache.d.ts +15 -0
- package/dist/types/bootstrap/app-module-discoverer.d.ts +30 -0
- package/dist/types/bootstrap/app-module-discovery-candidate.d.ts +18 -0
- package/dist/types/bootstrap/app-module-discovery-reason.enum.d.ts +10 -0
- package/dist/types/bootstrap/app-module-prompt.d.ts +20 -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/config-init.command.d.ts +18 -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/exit-code.enum.d.ts +4 -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/console.manager.d.ts +93 -0
- package/dist/types/managers/managers.d.ts +1 -0
- package/dist/types/managers/repl-session.d.ts +62 -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
package/dist/lib/cjs/bin.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AppModuleCache = void 0;
|
|
13
|
+
const tsyringe_1 = require("tsyringe");
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
/**
|
|
17
|
+
* Persists the user's selection from the disambiguation prompt so subsequent invocations of
|
|
18
|
+
* `pristine` in the same project skip the prompt. Stale entries (target file deleted since
|
|
19
|
+
* the cache was written) are auto-cleaned on read.
|
|
20
|
+
*
|
|
21
|
+
* Best-effort throughout — failures to read or write the cache file are swallowed because
|
|
22
|
+
* the cache is a UX optimization, not correctness-critical.
|
|
23
|
+
*/
|
|
24
|
+
let AppModuleCache = class AppModuleCache {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.cacheDirName = ".pristine";
|
|
27
|
+
this.cacheFileName = "last-app-module";
|
|
28
|
+
}
|
|
29
|
+
read(projectRoot) {
|
|
30
|
+
const cachePath = this.cachePath(projectRoot);
|
|
31
|
+
if (fs_1.default.existsSync(cachePath) === false) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
let cached;
|
|
35
|
+
try {
|
|
36
|
+
cached = fs_1.default.readFileSync(cachePath, "utf8").trim();
|
|
37
|
+
}
|
|
38
|
+
catch (_a) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
if (cached.length === 0 || fs_1.default.existsSync(cached) === false) {
|
|
42
|
+
// Stale cache — the user must have deleted or moved the file. Drop it so it doesn't
|
|
43
|
+
// keep being suggested on every subsequent invocation.
|
|
44
|
+
try {
|
|
45
|
+
fs_1.default.unlinkSync(cachePath);
|
|
46
|
+
}
|
|
47
|
+
catch (_b) {
|
|
48
|
+
// Best-effort cleanup.
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return cached;
|
|
53
|
+
}
|
|
54
|
+
write(projectRoot, absolutePath) {
|
|
55
|
+
try {
|
|
56
|
+
fs_1.default.mkdirSync(path_1.default.resolve(projectRoot, this.cacheDirName), { recursive: true });
|
|
57
|
+
fs_1.default.writeFileSync(this.cachePath(projectRoot), absolutePath, "utf8");
|
|
58
|
+
}
|
|
59
|
+
catch (_a) {
|
|
60
|
+
// Best-effort.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
cachePath(projectRoot) {
|
|
64
|
+
return path_1.default.resolve(projectRoot, this.cacheDirName, this.cacheFileName);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.AppModuleCache = AppModuleCache;
|
|
68
|
+
exports.AppModuleCache = AppModuleCache = __decorate([
|
|
69
|
+
(0, tsyringe_1.injectable)()
|
|
70
|
+
], AppModuleCache);
|
|
71
|
+
//# sourceMappingURL=app-module-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-cache.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoC;AACpC,4CAAoB;AACpB,gDAAwB;AAExB;;;;;;;GAOG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QACY,iBAAY,GAAW,WAAW,CAAC;QACnC,kBAAa,GAAW,iBAAiB,CAAC;IAyC7D,CAAC;IAvCC,IAAI,CAAC,WAAmB;QACtB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AppModuleDiscoverer = void 0;
|
|
22
|
+
const tsyringe_1 = require("tsyringe");
|
|
23
|
+
const fs_1 = __importDefault(require("fs"));
|
|
24
|
+
const path_1 = __importDefault(require("path"));
|
|
25
|
+
const app_module_discovery_candidate_1 = require("./app-module-discovery-candidate");
|
|
26
|
+
const app_module_discovery_reason_enum_1 = require("./app-module-discovery-reason.enum");
|
|
27
|
+
/**
|
|
28
|
+
* Scans well-known directories for files that look like AppModule definitions. Non-recursive
|
|
29
|
+
* (each search root is scanned at depth 1 only) so it stays fast on large repos and predictable
|
|
30
|
+
* when users have many nested module files.
|
|
31
|
+
*
|
|
32
|
+
* A file is a candidate when:
|
|
33
|
+
* - its filename matches `*.module.{js,mjs,cjs}` (and is not a test/spec file), AND
|
|
34
|
+
* - either the filename literally matches `app.module.{js,mjs,cjs}` (highest confidence,
|
|
35
|
+
* scored 0), OR the file's exports include a symbol named `AppModule` (scored 10).
|
|
36
|
+
*/
|
|
37
|
+
let AppModuleDiscoverer = class AppModuleDiscoverer {
|
|
38
|
+
constructor() {
|
|
39
|
+
/**
|
|
40
|
+
* Search roots scanned for candidates, relative to the project root. Order is intentional:
|
|
41
|
+
* compiled output first (most likely runtime entry), then build/, then the project root
|
|
42
|
+
* itself for trivial single-file demos.
|
|
43
|
+
*/
|
|
44
|
+
this.searchRoots = [
|
|
45
|
+
"dist",
|
|
46
|
+
"dist/lib/cjs",
|
|
47
|
+
"dist/lib/esm",
|
|
48
|
+
"build",
|
|
49
|
+
".",
|
|
50
|
+
];
|
|
51
|
+
this.moduleFileRegex = /^[A-Za-z0-9._-]+\.module\.(js|mjs|cjs)$/;
|
|
52
|
+
this.appModuleNameRegex = /^app\.module\.(js|mjs|cjs)$/i;
|
|
53
|
+
}
|
|
54
|
+
discover(projectRoot) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
const candidates = [];
|
|
58
|
+
for (const root of this.searchRoots) {
|
|
59
|
+
const dir = path_1.default.resolve(projectRoot, root);
|
|
60
|
+
if (fs_1.default.existsSync(dir) === false || fs_1.default.statSync(dir).isDirectory() === false) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
if (entry.isFile() === false)
|
|
66
|
+
continue;
|
|
67
|
+
if (this.moduleFileRegex.test(entry.name) === false)
|
|
68
|
+
continue;
|
|
69
|
+
if (entry.name.includes(".spec.") || entry.name.includes(".test."))
|
|
70
|
+
continue;
|
|
71
|
+
const absolutePath = path_1.default.resolve(dir, entry.name);
|
|
72
|
+
// Same physical file (e.g. dist/app.module.js and dist/lib/cjs/app.module.js pointing
|
|
73
|
+
// at duplicated builds) — keep the first occurrence (which respects searchRoots order).
|
|
74
|
+
if (seen.has(absolutePath))
|
|
75
|
+
continue;
|
|
76
|
+
seen.add(absolutePath);
|
|
77
|
+
const displayPath = path_1.default.relative(projectRoot, absolutePath);
|
|
78
|
+
if (this.appModuleNameRegex.test(entry.name)) {
|
|
79
|
+
candidates.push(new app_module_discovery_candidate_1.AppModuleDiscoveryCandidate(absolutePath, displayPath, 0, app_module_discovery_reason_enum_1.AppModuleDiscoveryReasonEnum.Named));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (this.exportsAppModule(absolutePath)) {
|
|
83
|
+
candidates.push(new app_module_discovery_candidate_1.AppModuleDiscoveryCandidate(absolutePath, displayPath, 10, app_module_discovery_reason_enum_1.AppModuleDiscoveryReasonEnum.Exports));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
candidates.sort((a, b) => {
|
|
88
|
+
if (a.score !== b.score)
|
|
89
|
+
return a.score - b.score;
|
|
90
|
+
return a.displayPath.localeCompare(b.displayPath);
|
|
91
|
+
});
|
|
92
|
+
return candidates;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Synchronous probe: does this file's exports include an `AppModule` symbol? Uses
|
|
97
|
+
* `require()` rather than dynamic `import()` because (a) we only accept `.js/.mjs/.cjs`
|
|
98
|
+
* whose CJS variants load synchronously, and (b) discarded probes shouldn't hold open
|
|
99
|
+
* `import()` promises.
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
exportsAppModule(absolutePath) {
|
|
103
|
+
try {
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
105
|
+
const loaded = require(absolutePath);
|
|
106
|
+
return loaded !== null && typeof loaded === "object" && "AppModule" in loaded;
|
|
107
|
+
}
|
|
108
|
+
catch (_a) {
|
|
109
|
+
// Treat unreadable / unloadable files as non-candidates — the loader couldn't open them
|
|
110
|
+
// either, so they cannot be the AppModule.
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
exports.AppModuleDiscoverer = AppModuleDiscoverer;
|
|
116
|
+
exports.AppModuleDiscoverer = AppModuleDiscoverer = __decorate([
|
|
117
|
+
(0, tsyringe_1.injectable)()
|
|
118
|
+
], AppModuleDiscoverer);
|
|
119
|
+
//# sourceMappingURL=app-module-discoverer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-discoverer.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-discoverer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,4CAAoB;AACpB,gDAAwB;AACxB,qFAA6E;AAC7E,yFAAgF;AAEhF;;;;;;;;;GASG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QACL;;;;WAIG;QACc,gBAAW,GAA0B;YACpD,MAAM;YACN,cAAc;YACd,cAAc;YACd,OAAO;YACP,GAAG;SACJ,CAAC;QAEe,oBAAe,GAAG,yCAAyC,CAAC;QAC5D,uBAAkB,GAAG,8BAA8B,CAAC;IA+DvE,CAAC;IA7DO,QAAQ,CAAC,WAAmB;;YAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;YAC/B,MAAM,UAAU,GAAkC,EAAE,CAAC;YAErD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpC,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC5C,IAAI,YAAE,CAAC,UAA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AC,IAAI,CAAC,IAAI,4DAA2B,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE,+DAA4B,CAAC,OAAO,CAAC,CAAC,CAAC;oBACxH,CAAC;gBACH,CAAC;YACH,CAAC;YAED,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACvB,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;oBAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;gBAClD,OAAO,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;IAED;;;;;;OAMG;IACK,gBAAgB,CAAC,YAAoB;QAC3C,IAAI,CAAC;YACH,8DAA8D;YAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;YACrC,OAAO,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,WAAW,IAAI,MAAM,CAAC;QAChF,CAAC;QAAC,WAAM,CAAC;YACP,wFAAwF;YACxF,2CAA2C;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AA9EY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,qBAAU,GAAE;GACA,mBAAmB,CA8E/B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppModuleDiscoveryCandidate = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A plausible AppModule found by the convention-based scan. Lower `score` beats higher;
|
|
6
|
+
* ties are ambiguous and trigger the disambiguation prompt.
|
|
7
|
+
*/
|
|
8
|
+
class AppModuleDiscoveryCandidate {
|
|
9
|
+
constructor(absolutePath,
|
|
10
|
+
/** Path relative to the project root. Used purely for human-facing display. */
|
|
11
|
+
displayPath,
|
|
12
|
+
/** Lower = better. Files literally named `app.module.*` get 0; AppModule-exporting `*.module.*` files get 10. */
|
|
13
|
+
score, reason) {
|
|
14
|
+
this.absolutePath = absolutePath;
|
|
15
|
+
this.displayPath = displayPath;
|
|
16
|
+
this.score = score;
|
|
17
|
+
this.reason = reason;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.AppModuleDiscoveryCandidate = AppModuleDiscoveryCandidate;
|
|
21
|
+
//# sourceMappingURL=app-module-discovery-candidate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-discovery-candidate.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-discovery-candidate.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,2BAA2B;IACtC,YACkB,YAAoB;IACpC,+EAA+E;IAC/D,WAAmB;IACnC,iHAAiH;IACjG,KAAa,EACb,MAAoC;QALpC,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAA8B;IAEtD,CAAC;CACF;AAVD,kEAUC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppModuleDiscoveryReasonEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Why a candidate file was considered a possible AppModule. Used by the disambiguation prompt
|
|
6
|
+
* so the user sees "(matches app.module.*)" vs "(exports AppModule)" alongside each option.
|
|
7
|
+
*/
|
|
8
|
+
var AppModuleDiscoveryReasonEnum;
|
|
9
|
+
(function (AppModuleDiscoveryReasonEnum) {
|
|
10
|
+
/** The filename matches `app.module.{js,mjs,cjs}`. Highest confidence. */
|
|
11
|
+
AppModuleDiscoveryReasonEnum["Named"] = "named";
|
|
12
|
+
/** The filename is `*.module.{js,mjs,cjs}` and the file's exports include an `AppModule` symbol. */
|
|
13
|
+
AppModuleDiscoveryReasonEnum["Exports"] = "exports";
|
|
14
|
+
})(AppModuleDiscoveryReasonEnum || (exports.AppModuleDiscoveryReasonEnum = AppModuleDiscoveryReasonEnum = {}));
|
|
15
|
+
//# sourceMappingURL=app-module-discovery-reason.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-discovery-reason.enum.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-discovery-reason.enum.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,0EAA0E;IAC1E,+CAAe,CAAA;IACf,oGAAoG;IACpG,mDAAmB,CAAA;AACrB,CAAC,EALW,4BAA4B,4CAA5B,4BAA4B,QAKvC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AppModulePrompt = void 0;
|
|
22
|
+
const tsyringe_1 = require("tsyringe");
|
|
23
|
+
const app_module_discovery_reason_enum_1 = require("./app-module-discovery-reason.enum");
|
|
24
|
+
const dynamic_importer_1 = require("./dynamic-importer");
|
|
25
|
+
/**
|
|
26
|
+
* TTY disambiguation for the AppModule discovery cascade. When multiple equally-ranked
|
|
27
|
+
* candidates exist and stdin/stdout are both connected to a real terminal, ask the user
|
|
28
|
+
* to pick one. When non-interactive (CI, Docker, redirected stdin), the caller should
|
|
29
|
+
* fall back to throwing an actionable error rather than guessing.
|
|
30
|
+
*
|
|
31
|
+
* `@inquirer/prompts` is dynamic-imported through `DynamicImporter` so the prompt UI
|
|
32
|
+
* dependency only loads when actually prompting — keeps non-interactive startup fast and
|
|
33
|
+
* avoids paying for inquirer's TTY-detection overhead on every invocation.
|
|
34
|
+
*/
|
|
35
|
+
let AppModulePrompt = class AppModulePrompt {
|
|
36
|
+
constructor(dynamicImporter) {
|
|
37
|
+
this.dynamicImporter = dynamicImporter;
|
|
38
|
+
this.cancelLabel = "Cancel";
|
|
39
|
+
}
|
|
40
|
+
isInteractive() {
|
|
41
|
+
return Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY);
|
|
42
|
+
}
|
|
43
|
+
prompt(candidates) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
46
|
+
const select = inquirer.select;
|
|
47
|
+
try {
|
|
48
|
+
const choice = yield select({
|
|
49
|
+
message: "Multiple AppModule candidates were found. Which one should pristine load?",
|
|
50
|
+
choices: [
|
|
51
|
+
...candidates.map(c => ({
|
|
52
|
+
name: `${c.displayPath} ${this.reasonLabel(c.reason)}`,
|
|
53
|
+
value: c.absolutePath,
|
|
54
|
+
})),
|
|
55
|
+
{ name: this.cancelLabel, value: null },
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
return choice !== null && choice !== void 0 ? choice : undefined;
|
|
59
|
+
}
|
|
60
|
+
catch (_a) {
|
|
61
|
+
// @inquirer throws on Ctrl+C / SIGINT — treat as a clean abort, not a crash.
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
reasonLabel(reason) {
|
|
67
|
+
switch (reason) {
|
|
68
|
+
case app_module_discovery_reason_enum_1.AppModuleDiscoveryReasonEnum.Named: return "(matches app.module.*)";
|
|
69
|
+
case app_module_discovery_reason_enum_1.AppModuleDiscoveryReasonEnum.Exports: return "(exports AppModule)";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.AppModulePrompt = AppModulePrompt;
|
|
74
|
+
exports.AppModulePrompt = AppModulePrompt = __decorate([
|
|
75
|
+
(0, tsyringe_1.injectable)(),
|
|
76
|
+
__metadata("design:paramtypes", [dynamic_importer_1.DynamicImporter])
|
|
77
|
+
], AppModulePrompt);
|
|
78
|
+
//# sourceMappingURL=app-module-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AAEpC,yFAAgF;AAChF,yDAAmD;AAEnD;;;;;;;;;GASG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAG1B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAF5C,gBAAW,G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,CAsC3B"}
|
|
@@ -21,7 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.BuildStalenessPrompt = void 0;
|
|
22
22
|
const tsyringe_1 = require("tsyringe");
|
|
23
23
|
const build_manifest_staleness_enum_1 = require("./build-manifest-staleness.enum");
|
|
24
|
-
const
|
|
24
|
+
const cli_prompt_manager_1 = require("../managers/cli-prompt.manager");
|
|
25
|
+
const prompt_cancelled_error_1 = require("../errors/prompt-cancelled.error");
|
|
25
26
|
/**
|
|
26
27
|
* When the build manifest is stale (source edited, output missing, etc.), `AppModuleLoader`
|
|
27
28
|
* stops the load and consults this prompt. In a TTY, asks the user whether to run
|
|
@@ -32,8 +33,8 @@ const dynamic_importer_1 = require("./dynamic-importer");
|
|
|
32
33
|
* this class stays small and testable.
|
|
33
34
|
*/
|
|
34
35
|
let BuildStalenessPrompt = class BuildStalenessPrompt {
|
|
35
|
-
constructor(
|
|
36
|
-
this.
|
|
36
|
+
constructor(cliPrompt) {
|
|
37
|
+
this.cliPrompt = cliPrompt;
|
|
37
38
|
this.promptMessage = "Run `pristine build` now to refresh?";
|
|
38
39
|
}
|
|
39
40
|
isInteractive() {
|
|
@@ -67,17 +68,15 @@ let BuildStalenessPrompt = class BuildStalenessPrompt {
|
|
|
67
68
|
*/
|
|
68
69
|
prompt(reason) {
|
|
69
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
71
|
-
const confirm = inquirer.confirm;
|
|
72
71
|
try {
|
|
73
|
-
return yield confirm({
|
|
74
|
-
message: `${this.describe(reason)}\n ${this.promptMessage}`,
|
|
75
|
-
default: true,
|
|
76
|
-
});
|
|
72
|
+
return yield this.cliPrompt.confirm(`${this.describe(reason)}\n ${this.promptMessage}`, true);
|
|
77
73
|
}
|
|
78
|
-
catch (
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof prompt_cancelled_error_1.PromptCancelledError) {
|
|
76
|
+
// Ctrl+C — treat as a clean cancellation so the caller can exit with the explanation.
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
throw error;
|
|
81
80
|
}
|
|
82
81
|
});
|
|
83
82
|
}
|
|
@@ -85,6 +84,6 @@ let BuildStalenessPrompt = class BuildStalenessPrompt {
|
|
|
85
84
|
exports.BuildStalenessPrompt = BuildStalenessPrompt;
|
|
86
85
|
exports.BuildStalenessPrompt = BuildStalenessPrompt = __decorate([
|
|
87
86
|
(0, tsyringe_1.injectable)(),
|
|
88
|
-
__metadata("design:paramtypes", [
|
|
87
|
+
__metadata("design:paramtypes", [cli_prompt_manager_1.CliPrompt])
|
|
89
88
|
], BuildStalenessPrompt);
|
|
90
89
|
//# sourceMappingURL=build-staleness-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-staleness-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-staleness-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,mFAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"build-staleness-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-staleness-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,mFAA2E;AAC3E,uEAAyD;AACzD,6EAAsE;AAEtE;;;;;;;;GAQG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG/B,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QAFhC,kBAAa,GAAW,sCAAsC,CAAC;IAGhF,CAAC;IAED,aAAa;QACX,OAAO,OAAO,CAAE,OAAO,CAAC,MAAc,CAAC,KAAK,CAAC,IAAI,OAAO,CAAE,OAAO,CAAC,KAAa,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,MAAkC;QACzC,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,0DAA0B,CAAC,OAAO;gBACrC,OAAO,6EAA6E,CAAC;YACvF,KAAK,0DAA0B,CAAC,iBAAiB;gBAC/C,OAAO,gIAAgI,CAAC;YAC1I,KAAK,0DAA0B,CAAC,iBAAiB;gBAC/C,OAAO,qIAAqI,CAAC;YAC/I,KAAK,0DAA0B,CAAC,oBAAoB;gBAClD,OAAO,4FAA4F,CAAC;YACtG,KAAK,0DAA0B,CAAC,aAAa;gBAC3C,OAAO,uFAAuF,CAAC;YACjG,KAAK,0DAA0B,CAAC,KAAK;gBACnC,oFAAoF;gBACpF,iBAAiB;gBACjB,OAAO,+BAA+B,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;OAGG;IACG,MAAM,CAAC,MAAkC;;YAC7C,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;YACjG,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,6CAAoB,EAAE,CAAC;oBAC1C,sFAAsF;oBACtF,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AAhDY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,qBAAU,GAAE;qCAI6B,8BAAS;GAHtC,oBAAoB,CAgDhC"}
|
|
@@ -20,10 +20,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.InitPrompt = void 0;
|
|
22
22
|
const tsyringe_1 = require("tsyringe");
|
|
23
|
-
const
|
|
23
|
+
const cli_prompt_manager_1 = require("../managers/cli-prompt.manager");
|
|
24
24
|
/**
|
|
25
|
-
* Interactive Q&A for `pristine init`.
|
|
26
|
-
*
|
|
25
|
+
* Interactive Q&A for `pristine init`. Prompts through {@link CliPrompt}, the CLI's native
|
|
26
|
+
* (no third-party dependency) terminal-prompt manager.
|
|
27
27
|
*
|
|
28
28
|
* Each method takes a "current value" so callers can pre-fill answers from CLI flags and
|
|
29
29
|
* only prompt for the gaps. Returning the same value the user passed in is intentional —
|
|
@@ -31,8 +31,8 @@ const dynamic_importer_1 = require("./dynamic-importer");
|
|
|
31
31
|
* prompt.
|
|
32
32
|
*/
|
|
33
33
|
let InitPrompt = class InitPrompt {
|
|
34
|
-
constructor(
|
|
35
|
-
this.
|
|
34
|
+
constructor(cliPrompt) {
|
|
35
|
+
this.cliPrompt = cliPrompt;
|
|
36
36
|
this.defaultSourcePath = "src/app.module.ts";
|
|
37
37
|
this.defaultOutputPath = "dist/app.module.js";
|
|
38
38
|
this.defaultTsconfig = "tsconfig.json";
|
|
@@ -45,83 +45,52 @@ let InitPrompt = class InitPrompt {
|
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
if (current !== undefined)
|
|
47
47
|
return current;
|
|
48
|
-
|
|
49
|
-
const input = inquirer.input;
|
|
50
|
-
return input({
|
|
51
|
-
message: "Where does your AppModule source file live?",
|
|
52
|
-
default: this.defaultSourcePath,
|
|
53
|
-
});
|
|
48
|
+
return this.cliPrompt.input("Where does your AppModule source file live?", this.defaultSourcePath);
|
|
54
49
|
});
|
|
55
50
|
}
|
|
56
51
|
askOutputPath(current) {
|
|
57
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
53
|
if (current !== undefined)
|
|
59
54
|
return current;
|
|
60
|
-
|
|
61
|
-
const input = inquirer.input;
|
|
62
|
-
return input({
|
|
63
|
-
message: "Where should the compiled AppModule output land?",
|
|
64
|
-
default: this.defaultOutputPath,
|
|
65
|
-
});
|
|
55
|
+
return this.cliPrompt.input("Where should the compiled AppModule output land?", this.defaultOutputPath);
|
|
66
56
|
});
|
|
67
57
|
}
|
|
68
58
|
askTsconfig(current) {
|
|
69
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
60
|
if (current !== undefined)
|
|
71
61
|
return current;
|
|
72
|
-
|
|
73
|
-
const input = inquirer.input;
|
|
74
|
-
return input({
|
|
75
|
-
message: "Which tsconfig should `pristine build` use?",
|
|
76
|
-
default: this.defaultTsconfig,
|
|
77
|
-
});
|
|
62
|
+
return this.cliPrompt.input("Which tsconfig should `pristine build` use?", this.defaultTsconfig);
|
|
78
63
|
});
|
|
79
64
|
}
|
|
80
65
|
askFormat(current) {
|
|
81
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
67
|
if (current !== undefined)
|
|
83
68
|
return current;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{ name: "esm (modern, recommended)", value: "esm" },
|
|
90
|
-
{ name: "cjs (CommonJS)", value: "cjs" },
|
|
91
|
-
{ name: "both (publish ESM + CJS)", value: "both" },
|
|
92
|
-
],
|
|
93
|
-
default: this.defaultFormat,
|
|
94
|
-
});
|
|
69
|
+
return this.cliPrompt.select("Which build format do you want?", [
|
|
70
|
+
{ name: "esm (modern, recommended)", value: "esm" },
|
|
71
|
+
{ name: "cjs (CommonJS)", value: "cjs" },
|
|
72
|
+
{ name: "both (publish ESM + CJS)", value: "both" },
|
|
73
|
+
], this.defaultFormat);
|
|
95
74
|
});
|
|
96
75
|
}
|
|
97
76
|
askScaffoldSource(current, sourcePath) {
|
|
98
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
78
|
if (current !== undefined)
|
|
100
79
|
return current;
|
|
101
|
-
|
|
102
|
-
const confirm = inquirer.confirm;
|
|
103
|
-
return confirm({
|
|
104
|
-
message: `Scaffold a starter AppModule at ${sourcePath}?`,
|
|
105
|
-
default: true,
|
|
106
|
-
});
|
|
80
|
+
return this.cliPrompt.confirm(`Scaffold a starter AppModule at ${sourcePath}?`, true);
|
|
107
81
|
});
|
|
108
82
|
}
|
|
109
83
|
askWritePackageScripts(current) {
|
|
110
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
85
|
if (current !== undefined)
|
|
112
86
|
return current;
|
|
113
|
-
|
|
114
|
-
const confirm = inquirer.confirm;
|
|
115
|
-
return confirm({
|
|
116
|
-
message: "Add `build`, `start`, `verify` scripts to package.json (only ones that don't already exist)?",
|
|
117
|
-
default: true,
|
|
118
|
-
});
|
|
87
|
+
return this.cliPrompt.confirm("Add `build`, `start`, `verify` scripts to package.json (only ones that don't already exist)?", true);
|
|
119
88
|
});
|
|
120
89
|
}
|
|
121
90
|
};
|
|
122
91
|
exports.InitPrompt = InitPrompt;
|
|
123
92
|
exports.InitPrompt = InitPrompt = __decorate([
|
|
124
93
|
(0, tsyringe_1.injectable)(),
|
|
125
|
-
__metadata("design:paramtypes", [
|
|
94
|
+
__metadata("design:paramtypes", [cli_prompt_manager_1.CliPrompt])
|
|
126
95
|
], InitPrompt);
|
|
127
96
|
//# sourceMappingURL=init-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/init-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"init-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/init-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,uEAAyD;AAgBzD;;;;;;;;GAQG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IAMrB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QALhC,sBAAiB,GAAW,mBAAmB,CAAC;QAChD,sBAAiB,GAAW,oBAAoB,CAAC;QACjD,oBAAe,GAAW,eAAe,CAAC;QAC1C,kBAAa,GAA2B,KAAK,CAAC;IAG/D,CAAC;IAED,aAAa;QACX,OAAO,OAAO,CAAE,OAAO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AAC,mCAAmC,UAAU,GAAG,EAAE,IAAI,CAAC,CAAC;QACxF,CAAC;KAAA;IAEK,sBAAsB,CAAC,OAA4B;;YACvD,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAC3B,8FAA8F,EAC9F,IAAI,CACL,CAAC;QACJ,CAAC;KAAA;CACF,CAAA;AArDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,qBAAU,GAAE;qCAO6B,8BAAS;GANtC,UAAU,CAqDtB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CliConfigurationKeys = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Typed configuration keys for `@pristine-ts/cli`. Use these constants with `@injectConfig`
|
|
6
|
+
* for autocomplete + rename safety, instead of typing the parameter name as a string.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import {injectConfig} from "@pristine-ts/common";
|
|
10
|
+
* import {CliConfigurationKeys} from "@pristine-ts/cli";
|
|
11
|
+
*
|
|
12
|
+
* constructor(@injectConfig(CliConfigurationKeys.InteractiveParameters) enabled: boolean) {}
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
exports.CliConfigurationKeys = {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the CLI may interactively ask for missing command parameters that declare a
|
|
18
|
+
* `question` (via `@commandParameter`). Defaults to `true`; set it to `false` to disable
|
|
19
|
+
* all such prompting (e.g. in CI). Prompting is also skipped automatically whenever the
|
|
20
|
+
* input is not an interactive terminal, regardless of this value.
|
|
21
|
+
*/
|
|
22
|
+
InteractiveParameters: "pristine.cli.interactiveParameters",
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=cli.configuration-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.configuration-keys.js","sourceRoot":"","sources":["../../../src/cli.configuration-keys.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACU,QAAA,oBAAoB,GAAG;IAClC;;;;;OAKG;IACH,qBAAqB,EAAE,oCAAoC;CACnD,CAAC"}
|
package/dist/lib/cjs/cli.js
CHANGED
|
@@ -24,6 +24,8 @@ const source_hasher_1 = require("./bootstrap/source-hasher");
|
|
|
24
24
|
const config_loader_1 = require("./config/config-loader");
|
|
25
25
|
const cli_module_1 = require("./cli.module");
|
|
26
26
|
const cli_error_reporter_1 = require("./reporters/cli-error.reporter");
|
|
27
|
+
const cli_prompt_manager_1 = require("./managers/cli-prompt.manager");
|
|
28
|
+
const terminal_key_reader_manager_1 = require("./managers/terminal-key-reader.manager");
|
|
27
29
|
/**
|
|
28
30
|
* Boots the CLI: discovers the consumer's AppModule, starts the kernel, and dispatches
|
|
29
31
|
* `process.argv` to whichever command matches. Returns the process exit code rather than
|
|
@@ -64,11 +66,17 @@ class Cli {
|
|
|
64
66
|
// and the alias commands can register signal handlers and resolve their delegates.
|
|
65
67
|
this.kernel.container.registerInstance(core_1.Kernel, this.kernel);
|
|
66
68
|
this.warnOnCommandCollisions();
|
|
67
|
-
|
|
68
|
-
// The
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
|
|
69
|
+
// Uniform dispatch: every argv shape flows through `kernel.handle(argv, {keyname:
|
|
70
|
+
// Cli})`. The mapping layer picks the right payload:
|
|
71
|
+
// - `[node, pristine, <command>, ...]` → `CommandEventMapper` → `CliEventHandler`
|
|
72
|
+
// runs the command and returns its exit code (no `process.exit`; exiting is
|
|
73
|
+
// `bin.ts`'s job).
|
|
74
|
+
// - `[node, pristine]` or `[node, pristine, repl, ...]` → `ReplStartEventMapper`
|
|
75
|
+
// → `ReplStartEventHandler` runs the interactive session and resolves with the
|
|
76
|
+
// exit code on `/exit` or EOF.
|
|
77
|
+
// No if-REPL branch needed here — the REPL is just another event handler.
|
|
78
|
+
const exitCode = yield this.kernel.handle(process.argv, { keyname: core_1.ExecutionContextKeynameEnum.Cli, context: null });
|
|
79
|
+
return typeof exitCode === "number" ? exitCode : 0;
|
|
72
80
|
}
|
|
73
81
|
catch (error) {
|
|
74
82
|
return yield this.reportFatalError(error);
|
|
@@ -136,11 +144,15 @@ class Cli {
|
|
|
136
144
|
});
|
|
137
145
|
}
|
|
138
146
|
/**
|
|
139
|
-
* Builds a synthetic outer AppModule that imports
|
|
147
|
+
* Builds a synthetic outer AppModule that imports the user's AppModule plus `CliModule`
|
|
148
|
+
* — so the CLI's own commands are always registered when the bin is the entry point.
|
|
149
|
+
* `CliModule` itself imports `ObservabilityModule`, so the logs/traces store travels
|
|
150
|
+
* along without being named here.
|
|
151
|
+
*
|
|
140
152
|
* The wrap is unconditional — the kernel dedupes module imports by keyname, so adding
|
|
141
|
-
* CliModule on top of a graph that already contains it is a no-op rather than an
|
|
142
|
-
* or duplicate registration. Cheaper than walking the user's import tree to
|
|
143
|
-
* already-present case.
|
|
153
|
+
* `CliModule` on top of a graph that already contains it is a no-op rather than an
|
|
154
|
+
* error or duplicate registration. Cheaper than walking the user's import tree to
|
|
155
|
+
* detect the already-present case.
|
|
144
156
|
*/
|
|
145
157
|
wrapWithCliModule(appModule) {
|
|
146
158
|
var _a;
|
|
@@ -163,7 +175,8 @@ class Cli {
|
|
|
163
175
|
const sourceHasher = new source_hasher_1.SourceHasher();
|
|
164
176
|
const buildManifestReader = new build_manifest_reader_1.BuildManifestReader();
|
|
165
177
|
const buildManifestChecker = new build_manifest_checker_1.BuildManifestChecker(sourceHasher);
|
|
166
|
-
const
|
|
178
|
+
const cliPrompt = new cli_prompt_manager_1.CliPrompt(new terminal_key_reader_manager_1.TerminalKeyReader());
|
|
179
|
+
const buildStalenessPrompt = new build_staleness_prompt_1.BuildStalenessPrompt(cliPrompt);
|
|
167
180
|
const buildRunner = new build_runner_1.BuildRunner();
|
|
168
181
|
return new app_module_loader_1.AppModuleLoader(configLoader, pluginLoader, dynamicImporter, buildManifestReader, buildManifestChecker, buildStalenessPrompt, buildRunner);
|
|
169
182
|
}
|