@pristine-ts/cli 2.0.5 → 2.0.7
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-runner.js +1 -1
- package/dist/lib/cjs/cli.module.js +12 -7
- package/dist/lib/cjs/cli.module.js.map +1 -1
- package/dist/lib/cjs/commands/build.command.js +15 -14
- package/dist/lib/cjs/commands/build.command.js.map +1 -1
- package/dist/lib/cjs/commands/config-print.command.js +16 -11
- package/dist/lib/cjs/commands/config-print.command.js.map +1 -1
- package/dist/lib/cjs/commands/help.command.js +17 -17
- package/dist/lib/cjs/commands/help.command.js.map +1 -1
- package/dist/lib/cjs/commands/info.command.js +26 -21
- package/dist/lib/cjs/commands/info.command.js.map +1 -1
- package/dist/lib/cjs/commands/init.command.js +22 -21
- package/dist/lib/cjs/commands/init.command.js.map +1 -1
- package/dist/lib/cjs/commands/list.command.js +6 -6
- package/dist/lib/cjs/commands/list.command.js.map +1 -1
- package/dist/lib/cjs/commands/start.command.js +12 -13
- package/dist/lib/cjs/commands/start.command.js.map +1 -1
- package/dist/lib/cjs/event-handlers/cli.event-handler.js +9 -7
- package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/cjs/managers/cli-output.manager.js +45 -0
- package/dist/lib/cjs/managers/cli-output.manager.js.map +1 -0
- package/dist/lib/cjs/managers/cli-progress-bar.manager.js +49 -0
- package/dist/lib/cjs/managers/cli-progress-bar.manager.js.map +1 -0
- package/dist/lib/cjs/managers/cli-prompt.manager.js +99 -0
- package/dist/lib/cjs/managers/cli-prompt.manager.js.map +1 -0
- package/dist/lib/cjs/managers/cli-spinner.manager.js +93 -0
- package/dist/lib/cjs/managers/cli-spinner.manager.js.map +1 -0
- package/dist/lib/cjs/managers/managers.js +4 -1
- package/dist/lib/cjs/managers/managers.js.map +1 -1
- package/dist/lib/cjs/managers/shell.manager.js +25 -20
- package/dist/lib/cjs/managers/shell.manager.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/esm/bootstrap/build-runner.js +1 -1
- package/dist/lib/esm/cli.module.js +12 -7
- package/dist/lib/esm/cli.module.js.map +1 -1
- package/dist/lib/esm/commands/build.command.js +16 -15
- package/dist/lib/esm/commands/build.command.js.map +1 -1
- package/dist/lib/esm/commands/config-print.command.js +16 -11
- package/dist/lib/esm/commands/config-print.command.js.map +1 -1
- package/dist/lib/esm/commands/help.command.js +17 -17
- package/dist/lib/esm/commands/help.command.js.map +1 -1
- package/dist/lib/esm/commands/info.command.js +27 -22
- package/dist/lib/esm/commands/info.command.js.map +1 -1
- package/dist/lib/esm/commands/init.command.js +23 -22
- package/dist/lib/esm/commands/init.command.js.map +1 -1
- package/dist/lib/esm/commands/list.command.js +6 -6
- package/dist/lib/esm/commands/list.command.js.map +1 -1
- package/dist/lib/esm/commands/start.command.js +13 -14
- package/dist/lib/esm/commands/start.command.js.map +1 -1
- package/dist/lib/esm/event-handlers/cli.event-handler.js +9 -7
- package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/esm/managers/cli-output.manager.js +42 -0
- package/dist/lib/esm/managers/cli-output.manager.js.map +1 -0
- package/dist/lib/esm/managers/cli-progress-bar.manager.js +46 -0
- package/dist/lib/esm/managers/cli-progress-bar.manager.js.map +1 -0
- package/dist/lib/esm/managers/cli-prompt.manager.js +63 -0
- package/dist/lib/esm/managers/cli-prompt.manager.js.map +1 -0
- package/dist/lib/esm/managers/cli-spinner.manager.js +90 -0
- package/dist/lib/esm/managers/cli-spinner.manager.js.map +1 -0
- package/dist/lib/esm/managers/managers.js +4 -1
- package/dist/lib/esm/managers/managers.js.map +1 -1
- package/dist/lib/esm/managers/shell.manager.js +26 -21
- package/dist/lib/esm/managers/shell.manager.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bootstrap/build-runner.d.ts +1 -1
- package/dist/types/commands/build.command.d.ts +3 -3
- package/dist/types/commands/config-print.command.d.ts +8 -3
- package/dist/types/commands/help.command.d.ts +3 -3
- package/dist/types/commands/info.command.d.ts +5 -3
- package/dist/types/commands/init.command.d.ts +3 -3
- package/dist/types/commands/list.command.d.ts +3 -3
- package/dist/types/commands/start.command.d.ts +3 -3
- package/dist/types/event-handlers/cli.event-handler.d.ts +1 -3
- package/dist/types/managers/cli-output.manager.d.ts +21 -0
- package/dist/types/managers/cli-progress-bar.manager.d.ts +17 -0
- package/dist/types/managers/cli-prompt.manager.d.ts +22 -0
- package/dist/types/managers/cli-spinner.manager.d.ts +34 -0
- package/dist/types/managers/managers.d.ts +4 -1
- package/dist/types/managers/shell.manager.d.ts +3 -3
- package/package.json +9 -9
- package/dist/lib/cjs/managers/console.manager.js +0 -277
- package/dist/lib/cjs/managers/console.manager.js.map +0 -1
- package/dist/lib/esm/managers/console.manager.js +0 -241
- package/dist/lib/esm/managers/console.manager.js.map +0 -1
- package/dist/types/managers/console.manager.d.ts +0 -93
|
@@ -7,6 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
10
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,8 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
22
|
import fs from "fs";
|
|
20
23
|
import path from "path";
|
|
21
24
|
import { moduleScoped, ServiceDefinitionTagEnum, tag, ExitCode } from "@pristine-ts/common";
|
|
22
|
-
import { injectable } from "tsyringe";
|
|
23
|
-
import { ConsoleManager } from "../managers/console.manager";
|
|
25
|
+
import { inject, injectable } from "tsyringe";
|
|
24
26
|
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
25
27
|
import { InitCommandOptions } from "./init.command-options";
|
|
26
28
|
import { InitPrompt } from "../bootstrap/init-prompt";
|
|
@@ -40,8 +42,8 @@ import { InitPrompt } from "../bootstrap/init-prompt";
|
|
|
40
42
|
* Refuses to overwrite an existing `pristine.config.ts` so re-running init is safe.
|
|
41
43
|
*/
|
|
42
44
|
let InitCommand = class InitCommand {
|
|
43
|
-
constructor(
|
|
44
|
-
this.
|
|
45
|
+
constructor(logHandler, initPrompt) {
|
|
46
|
+
this.logHandler = logHandler;
|
|
45
47
|
this.initPrompt = initPrompt;
|
|
46
48
|
this.optionsType = InitCommandOptions;
|
|
47
49
|
this.name = "p:init";
|
|
@@ -54,7 +56,7 @@ let InitCommand = class InitCommand {
|
|
|
54
56
|
const projectRoot = process.cwd();
|
|
55
57
|
const configPath = path.resolve(projectRoot, this.configFileName);
|
|
56
58
|
if (fs.existsSync(configPath)) {
|
|
57
|
-
this.
|
|
59
|
+
this.logHandler.error(`${this.configFileName} already exists at ${configPath}. Aborting to avoid overwriting.`);
|
|
58
60
|
return ExitCode.Error;
|
|
59
61
|
}
|
|
60
62
|
const answers = yield this.gatherAnswers(args);
|
|
@@ -63,7 +65,7 @@ let InitCommand = class InitCommand {
|
|
|
63
65
|
return ExitCode.Error;
|
|
64
66
|
}
|
|
65
67
|
fs.writeFileSync(configPath, this.renderConfigTemplate(answers), "utf8");
|
|
66
|
-
this.
|
|
68
|
+
this.logHandler.success(`Created ${path.relative(projectRoot, configPath)}`);
|
|
67
69
|
if (answers.scaffoldSource) {
|
|
68
70
|
this.scaffoldSource(projectRoot, answers.sourcePath);
|
|
69
71
|
}
|
|
@@ -71,10 +73,10 @@ let InitCommand = class InitCommand {
|
|
|
71
73
|
this.addPackageScripts(projectRoot);
|
|
72
74
|
}
|
|
73
75
|
this.addToGitignore(projectRoot);
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
this.logHandler.info("Next steps:\n" +
|
|
77
|
+
" 1. npm install --save-dev @pristine-ts/cli (if you haven't already)\n" +
|
|
78
|
+
" 2. npm run build # compile your AppModule\n" +
|
|
79
|
+
" 3. npm run start # boot your app");
|
|
78
80
|
return ExitCode.Success;
|
|
79
81
|
});
|
|
80
82
|
}
|
|
@@ -97,8 +99,7 @@ let InitCommand = class InitCommand {
|
|
|
97
99
|
if (outputPath === undefined)
|
|
98
100
|
missing.push("--output-path");
|
|
99
101
|
if (missing.length > 0) {
|
|
100
|
-
this.
|
|
101
|
-
`Either run \`pristine init\` in a terminal or pass the flags explicitly.`);
|
|
102
|
+
this.logHandler.error("Non-interactive run is missing required flag(s). Either run `pristine init` in a terminal or pass the flags explicitly.", { highlights: { missing } });
|
|
102
103
|
return undefined;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
@@ -121,12 +122,12 @@ let InitCommand = class InitCommand {
|
|
|
121
122
|
scaffoldSource(projectRoot, sourcePath) {
|
|
122
123
|
const absolutePath = path.resolve(projectRoot, sourcePath);
|
|
123
124
|
if (fs.existsSync(absolutePath)) {
|
|
124
|
-
this.
|
|
125
|
+
this.logHandler.info("AppModule source already exists; skipping scaffold.", { highlights: { sourcePath } });
|
|
125
126
|
return;
|
|
126
127
|
}
|
|
127
128
|
fs.mkdirSync(path.dirname(absolutePath), { recursive: true });
|
|
128
129
|
fs.writeFileSync(absolutePath, this.renderAppModuleTemplate(), "utf8");
|
|
129
|
-
this.
|
|
130
|
+
this.logHandler.success(`Created ${sourcePath}`);
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
132
133
|
* Adds `build`, `start`, `verify` to package.json's scripts. Only adds scripts that
|
|
@@ -137,7 +138,7 @@ let InitCommand = class InitCommand {
|
|
|
137
138
|
var _a;
|
|
138
139
|
const packageJsonPath = path.resolve(projectRoot, "package.json");
|
|
139
140
|
if (fs.existsSync(packageJsonPath) === false) {
|
|
140
|
-
this.
|
|
141
|
+
this.logHandler.warning("package.json not found; skipping script additions.");
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
144
|
let parsed;
|
|
@@ -145,7 +146,7 @@ let InitCommand = class InitCommand {
|
|
|
145
146
|
parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
146
147
|
}
|
|
147
148
|
catch (error) {
|
|
148
|
-
this.
|
|
149
|
+
this.logHandler.error("Failed to parse package.json", { highlights: { error: error.message } });
|
|
149
150
|
return;
|
|
150
151
|
}
|
|
151
152
|
parsed.scripts = (_a = parsed.scripts) !== null && _a !== void 0 ? _a : {};
|
|
@@ -166,13 +167,13 @@ let InitCommand = class InitCommand {
|
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
if (added.length === 0) {
|
|
169
|
-
this.
|
|
170
|
+
this.logHandler.info("All target scripts already exist in package.json; nothing added.");
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
173
|
fs.writeFileSync(packageJsonPath, JSON.stringify(parsed, null, 2) + "\n", "utf8");
|
|
173
|
-
this.
|
|
174
|
+
this.logHandler.success(`Added ${added.length} script(s) to package.json`, { highlights: { added } });
|
|
174
175
|
if (skipped.length > 0) {
|
|
175
|
-
this.
|
|
176
|
+
this.logHandler.info("Kept existing script(s)", { highlights: { skipped } });
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
/**
|
|
@@ -192,7 +193,7 @@ let InitCommand = class InitCommand {
|
|
|
192
193
|
}
|
|
193
194
|
const separator = current.endsWith("\n") ? "" : "\n";
|
|
194
195
|
fs.appendFileSync(gitignorePath, `${separator}${this.gitignoreEntry}\n`, "utf8");
|
|
195
|
-
this.
|
|
196
|
+
this.logHandler.info(`Added '${this.gitignoreEntry}' to .gitignore`);
|
|
196
197
|
}
|
|
197
198
|
renderConfigTemplate(answers) {
|
|
198
199
|
return `import {defineConfig} from "@pristine-ts/cli";
|
|
@@ -237,8 +238,8 @@ InitCommand = __decorate([
|
|
|
237
238
|
tag(ServiceDefinitionTagEnum.Command),
|
|
238
239
|
moduleScoped(CliModuleKeyname),
|
|
239
240
|
injectable(),
|
|
240
|
-
|
|
241
|
-
|
|
241
|
+
__param(0, inject("LogHandlerInterface")),
|
|
242
|
+
__metadata("design:paramtypes", [Object, InitPrompt])
|
|
242
243
|
], InitCommand);
|
|
243
244
|
export { InitCommand };
|
|
244
245
|
//# sourceMappingURL=init.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.command.js","sourceRoot":"","sources":["../../../../src/commands/init.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.command.js","sourceRoot":"","sources":["../../../../src/commands/init.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAc,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAEjE;;;;;;;;;;;;;;GAcG;AAII,IAAM,WAAW,GAAjB,MAAM,WAAW;IAQtB,YACiC,UAAgD,EAC9D,UAAsB;QADS,eAAU,GAAV,UAAU,CAAqB;QAC9D,eAAU,GAAV,UAAU,CAAY;QATzC,gBAAW,GAAG,kBAAkB,CAAC;QACjC,SAAI,GAAG,QAAQ,CAAC;QAChB,gBAAW,GAAG,wFAAwF,CAAC;QAEtF,mBAAc,GAAW,oBAAoB,CAAC;QAC9C,mB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IACA,CAAC;IAEO,uBAAuB;QAC7B,OAAO;;;;;;;;;;;;;;CAcV,CAAC;IACA,CAAC;CACF,CAAA;AAnNY,WAAW;IAHvB,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC;IACrC,YAAY,CAAC,gBAAgB,CAAC;IAC9B,UAAU,EAAE;IAUR,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;6CACD,UAAU;GAV9B,WAAW,CAmNvB"}
|
|
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
};
|
|
22
22
|
import { moduleScoped, ServiceDefinitionTagEnum, tag, ExitCode } from "@pristine-ts/common";
|
|
23
23
|
import { inject, injectable } from "tsyringe";
|
|
24
|
-
import {
|
|
24
|
+
import { CliOutput } from "../managers/cli-output.manager";
|
|
25
25
|
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
26
26
|
/**
|
|
27
27
|
* Lists every registered command's name. Like `HelpCommand`, this resolves the command set
|
|
@@ -29,8 +29,8 @@ import { CliModuleKeyname } from "../cli.module.keyname";
|
|
|
29
29
|
* that constructor-time `@injectAll(Command)` would create — see `HelpCommand` for details.
|
|
30
30
|
*/
|
|
31
31
|
let ListCommand = class ListCommand {
|
|
32
|
-
constructor(
|
|
33
|
-
this.
|
|
32
|
+
constructor(cliOutput, container) {
|
|
33
|
+
this.cliOutput = cliOutput;
|
|
34
34
|
this.container = container;
|
|
35
35
|
this.optionsType = null;
|
|
36
36
|
this.name = "p:list";
|
|
@@ -38,7 +38,7 @@ let ListCommand = class ListCommand {
|
|
|
38
38
|
}
|
|
39
39
|
run(args) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
this.
|
|
41
|
+
this.cliOutput.writeLine("List of registered commands:");
|
|
42
42
|
// ── container.resolveAll, justified ─────────────────────────────────────────
|
|
43
43
|
// Per CLAUDE.md: constructor-time `@injectAll(Command)` would create a self-
|
|
44
44
|
// referential cycle since `ListCommand` is itself a `Command`-tagged service.
|
|
@@ -47,7 +47,7 @@ let ListCommand = class ListCommand {
|
|
|
47
47
|
// container itself is still acquired via proper DI — only the enumeration is
|
|
48
48
|
// late-bound.
|
|
49
49
|
const commands = this.container.resolveAll(ServiceDefinitionTagEnum.Command);
|
|
50
|
-
commands.forEach(command => this.
|
|
50
|
+
commands.forEach(command => this.cliOutput.writeLine(command.name));
|
|
51
51
|
return ExitCode.Success;
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -57,7 +57,7 @@ ListCommand = __decorate([
|
|
|
57
57
|
moduleScoped(CliModuleKeyname),
|
|
58
58
|
injectable(),
|
|
59
59
|
__param(1, inject(ServiceDefinitionTagEnum.CurrentChildContainer)),
|
|
60
|
-
__metadata("design:paramtypes", [
|
|
60
|
+
__metadata("design:paramtypes", [CliOutput, Object])
|
|
61
61
|
], ListCommand);
|
|
62
62
|
export { ListCommand };
|
|
63
63
|
//# sourceMappingURL=list.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.command.js","sourceRoot":"","sources":["../../../../src/commands/list.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"list.command.js","sourceRoot":"","sources":["../../../../src/commands/list.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAsB,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AAII,IAAM,WAAW,GAAjB,MAAM,WAAW;IAKtB,YACmB,SAAoB,EACmB,SAA+C;QADtF,cAAS,GAAT,SAAS,CAAW;QACoC,cAAS,GAAT,SAAS,CAAqB;QANzG,gBAAW,GAAG,IAAI,CAAC;QACnB,SAAI,GAAG,QAAQ,CAAC;QAChB,gBAAW,GAAG,sDAAsD,CAAC;IAMrE,CAAC;IAEK,GAAG,CAAC,IAAS;;YACjB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;YACzD,+EAA+E;YAC/E,6EAA6E;YAC7E,8EAA8E;YAC9E,yEAAyE;YACzE,4EAA4E;YAC5E,6EAA6E;YAC7E,cAAc;YACd,MAAM,QAAQ,GAA4B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;YACtG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEpE,OAAO,QAAQ,CAAC,OAAO,CAAC;QAC1B,CAAC;KAAA;CACF,CAAA;AAzBY,WAAW;IAHvB,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC;IACrC,YAAY,CAAC,gBAAgB,CAAC;IAC9B,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAA;qCAD3B,SAAS;GAN5B,WAAW,CAyBvB"}
|
|
@@ -21,9 +21,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
};
|
|
22
22
|
var StartCommand_1;
|
|
23
23
|
import { moduleScoped, ServiceDefinitionTagEnum, tag, ExitCode } from "@pristine-ts/common";
|
|
24
|
-
import { injectable, injectAll } from "tsyringe";
|
|
24
|
+
import { inject, injectable, injectAll } from "tsyringe";
|
|
25
25
|
import { Kernel } from "@pristine-ts/core";
|
|
26
|
-
import { ConsoleManager } from "../managers/console.manager";
|
|
27
26
|
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
28
27
|
import { StartCommandOptions } from "./start.command-options";
|
|
29
28
|
/**
|
|
@@ -57,8 +56,8 @@ import { StartCommandOptions } from "./start.command-options";
|
|
|
57
56
|
* `nodemon` or `tsx --watch`.
|
|
58
57
|
*/
|
|
59
58
|
let StartCommand = StartCommand_1 = class StartCommand {
|
|
60
|
-
constructor(
|
|
61
|
-
this.
|
|
59
|
+
constructor(logHandler, kernel, servers) {
|
|
60
|
+
this.logHandler = logHandler;
|
|
62
61
|
this.kernel = kernel;
|
|
63
62
|
this.servers = servers;
|
|
64
63
|
this.optionsType = StartCommandOptions;
|
|
@@ -81,7 +80,7 @@ let StartCommand = StartCommand_1 = class StartCommand {
|
|
|
81
80
|
yield server.start(overrides);
|
|
82
81
|
}
|
|
83
82
|
catch (error) {
|
|
84
|
-
this.
|
|
83
|
+
this.logHandler.error(`Failed to start server '${server.name}'`, { highlights: { server: server.name, error: error.message } });
|
|
85
84
|
// Best-effort: stop any servers that did start before we abort.
|
|
86
85
|
for (const started of servers) {
|
|
87
86
|
if (started === server)
|
|
@@ -95,11 +94,11 @@ let StartCommand = StartCommand_1 = class StartCommand {
|
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
if (servers.length === 0) {
|
|
98
|
-
this.
|
|
97
|
+
this.logHandler.success("Pristine app running. Send SIGTERM (or Ctrl+C) to stop.");
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
100
|
const labels = servers.map(s => s.name).join(", ");
|
|
102
|
-
this.
|
|
101
|
+
this.logHandler.success(`Pristine app running with ${servers.length} server(s): ${labels}. Send SIGTERM (or Ctrl+C) to stop.`, { highlights: { serverCount: servers.length } });
|
|
103
102
|
}
|
|
104
103
|
return new Promise((resolve) => {
|
|
105
104
|
let shuttingDown = false;
|
|
@@ -113,13 +112,13 @@ let StartCommand = StartCommand_1 = class StartCommand {
|
|
|
113
112
|
// Second signal arrived while we're already shutting down — escalate to an immediate
|
|
114
113
|
// hard exit. This mirrors the behavior of most production runtimes (one Ctrl+C =
|
|
115
114
|
// graceful, two = right now).
|
|
116
|
-
this.
|
|
115
|
+
this.logHandler.warning(`Received ${signal} again — forcing exit.`, { highlights: { signal } });
|
|
117
116
|
process.exit(130);
|
|
118
117
|
}
|
|
119
118
|
shuttingDown = true;
|
|
120
|
-
this.
|
|
119
|
+
this.logHandler.info(`Received ${signal}, shutting down gracefully...`, { highlights: { signal } });
|
|
121
120
|
const hardExitTimer = setTimeout(() => {
|
|
122
|
-
this.
|
|
121
|
+
this.logHandler.error(`Shutdown exceeded ${StartCommand_1.HARD_EXIT_TIMEOUT_MS}ms — forcing exit.`);
|
|
123
122
|
process.exit(1);
|
|
124
123
|
}, StartCommand_1.HARD_EXIT_TIMEOUT_MS);
|
|
125
124
|
// Don't keep the event loop alive just for the timer.
|
|
@@ -129,13 +128,13 @@ let StartCommand = StartCommand_1 = class StartCommand {
|
|
|
129
128
|
// HttpModule.onShutdown which calls KernelHttpServer.stop(). No need to stop the
|
|
130
129
|
// servers individually here.
|
|
131
130
|
yield this.kernel.stop();
|
|
132
|
-
this.
|
|
131
|
+
this.logHandler.success("Shutdown complete.");
|
|
133
132
|
clearTimeout(hardExitTimer);
|
|
134
133
|
clearInterval(heartbeat);
|
|
135
134
|
resolve(ExitCode.Success);
|
|
136
135
|
}
|
|
137
136
|
catch (error) {
|
|
138
|
-
this.
|
|
137
|
+
this.logHandler.error("Shutdown error", { highlights: { error: error.message } });
|
|
139
138
|
clearTimeout(hardExitTimer);
|
|
140
139
|
clearInterval(heartbeat);
|
|
141
140
|
resolve(ExitCode.Error);
|
|
@@ -157,9 +156,9 @@ StartCommand = StartCommand_1 = __decorate([
|
|
|
157
156
|
tag(ServiceDefinitionTagEnum.Command),
|
|
158
157
|
moduleScoped(CliModuleKeyname),
|
|
159
158
|
injectable(),
|
|
159
|
+
__param(0, inject("LogHandlerInterface")),
|
|
160
160
|
__param(2, injectAll(ServiceDefinitionTagEnum.RuntimeServer)),
|
|
161
|
-
__metadata("design:paramtypes", [
|
|
162
|
-
Kernel, Array])
|
|
161
|
+
__metadata("design:paramtypes", [Object, Kernel, Array])
|
|
163
162
|
], StartCommand);
|
|
164
163
|
export { StartCommand };
|
|
165
164
|
//# sourceMappingURL=start.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.command.js","sourceRoot":"","sources":["../../../../src/commands/start.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"start.command.js","sourceRoot":"","sources":["../../../../src/commands/start.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AACvD,OAAO,EAAC,MAAM,EAAyB,MAAM,mBAAmB,CAAC;AAGjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAII,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAgBvB,YACiC,UAAgD,EAC9D,MAAc,EACoB,OAAkD;QAFrD,eAAU,GAAV,UAAU,CAAqB;QAC9D,WAAM,GAAN,MAAM,CAAQ;QACqC,YAAO,GAAP,OAAO,CAA0B;QAlBvG,gBAAW,GAAG,mBAAmB,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,CAAC,CAAC;QACL,CAAC;KAAA;;AAlGD,2FAA2F;AAC3F,yFAAyF;AACzF,mBAAmB;AACK,iCAAoB,GAAG,KAAM,AAAT,CAAU;AAR3C,YAAY;IAHxB,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC;IACrC,YAAY,CAAC,gBAAgB,CAAC;IAC9B,UAAU,EAAE;IAkBR,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,SAAS,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAA;6CADzB,MAAM;GAlBtB,YAAY,CAwGxB"}
|
|
@@ -25,14 +25,12 @@ import { moduleScoped, ServiceDefinitionTagEnum, tag, UsageError, ValidationErro
|
|
|
25
25
|
import { CliErrorCode } from "../errors/cli-error-code.enum";
|
|
26
26
|
import { CommandNotFoundError } from "../errors/command-not-found.error";
|
|
27
27
|
import { Validator } from "@pristine-ts/class-validator";
|
|
28
|
-
import { ConsoleManager } from "../managers/console.manager";
|
|
29
28
|
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
30
29
|
import { plainToInstance } from "class-transformer";
|
|
31
30
|
let CliEventHandler = class CliEventHandler {
|
|
32
|
-
constructor(logHandler, validator,
|
|
31
|
+
constructor(logHandler, validator, commands) {
|
|
33
32
|
this.logHandler = logHandler;
|
|
34
33
|
this.validator = validator;
|
|
35
|
-
this.consoleManager = consoleManager;
|
|
36
34
|
this.commands = commands;
|
|
37
35
|
}
|
|
38
36
|
handle(event) {
|
|
@@ -119,7 +117,12 @@ let CliEventHandler = class CliEventHandler {
|
|
|
119
117
|
}
|
|
120
118
|
logExitStatus(commandName, exitCode) {
|
|
121
119
|
const status = exitCode === ExitCode.Success ? "Success" : "Error";
|
|
122
|
-
|
|
120
|
+
if (exitCode === ExitCode.Success) {
|
|
121
|
+
this.logHandler.info(`Command '${commandName}' exited`, { highlights: { status, exitCode, commandName } });
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.logHandler.error(`Command '${commandName}' exited`, { highlights: { status, exitCode, commandName } });
|
|
125
|
+
}
|
|
123
126
|
}
|
|
124
127
|
};
|
|
125
128
|
CliEventHandler = __decorate([
|
|
@@ -127,9 +130,8 @@ CliEventHandler = __decorate([
|
|
|
127
130
|
moduleScoped(CliModuleKeyname),
|
|
128
131
|
injectable(),
|
|
129
132
|
__param(0, inject("LogHandlerInterface")),
|
|
130
|
-
__param(
|
|
131
|
-
__metadata("design:paramtypes", [Object, Validator,
|
|
132
|
-
ConsoleManager, Array])
|
|
133
|
+
__param(2, injectAll(ServiceDefinitionTagEnum.Command)),
|
|
134
|
+
__metadata("design:paramtypes", [Object, Validator, Array])
|
|
133
135
|
], CliEventHandler);
|
|
134
136
|
export { CliEventHandler };
|
|
135
137
|
//# sourceMappingURL=cli.event-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.event-handler.js","sourceRoot":"","sources":["../../../../src/event-handlers/cli.event-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAC,mBAAmB,EAAC,MAAM,yCAAyC,CAAC;AAI5E,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AACvH,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;AAEvE,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"cli.event-handler.js","sourceRoot":"","sources":["../../../../src/event-handlers/cli.event-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,UAA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,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAC,EAAC,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC;CACF,CAAA;AArGY,eAAe;IAH3B,GAAG,CAAC,wBAAwB,CAAC,YAAY,CAAC;IAC1C,YAAY,CAAC,gBAAgB,CAAC;IAC9B,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,SAAS,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAA;6CADhB,SAAS;GAH5B,eAAe,CAqG3B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { injectable } from "tsyringe";
|
|
8
|
+
import { moduleScoped } from "@pristine-ts/common";
|
|
9
|
+
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
10
|
+
/**
|
|
11
|
+
* Pipe-friendly stdout primitives for the CLI. Use this when you need to emit text that
|
|
12
|
+
* a user might redirect or pipe — help banners, command tables, JSON dumps — and the
|
|
13
|
+
* `LogHandler` pipeline would be wrong because it can be severity-gated, routed to
|
|
14
|
+
* stderr per-severity, or fanned out to file/Sentry transports. For event narration
|
|
15
|
+
* ("Compiling X", "Server started"), use `LogHandler` instead.
|
|
16
|
+
*/
|
|
17
|
+
let CliOutput = class CliOutput {
|
|
18
|
+
/**
|
|
19
|
+
* Writes a message to stdout without a newline.
|
|
20
|
+
*/
|
|
21
|
+
write(message) {
|
|
22
|
+
process.stdout.write(message);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Writes a message to stdout with a newline.
|
|
26
|
+
*/
|
|
27
|
+
writeLine(message) {
|
|
28
|
+
process.stdout.write(message + "\n");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Renders an array of objects as a table using Node's `console.table`.
|
|
32
|
+
*/
|
|
33
|
+
writeTable(rows) {
|
|
34
|
+
console.table(rows);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
CliOutput = __decorate([
|
|
38
|
+
injectable(),
|
|
39
|
+
moduleScoped(CliModuleKeyname)
|
|
40
|
+
], CliOutput);
|
|
41
|
+
export { CliOutput };
|
|
42
|
+
//# sourceMappingURL=cli-output.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-output.manager.js","sourceRoot":"","sources":["../../../../src/managers/cli-output.manager.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD;;;;;;GAMG;AAGI,IAAM,SAAS,GAAf,MAAM,SAAS;IAEpB;;OAEG;IACH,KAAK,CAAC,OAAe;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,OAAe;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAW;QACpB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF,CAAA;AAtBY,SAAS;IAFrB,UAAU,EAAE;IACZ,YAAY,CAAC,gBAAgB,CAAC;GAClB,SAAS,CAsBrB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var CliProgressBar_1;
|
|
8
|
+
import { injectable } from "tsyringe";
|
|
9
|
+
import { moduleScoped } from "@pristine-ts/common";
|
|
10
|
+
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
11
|
+
import { clearLine, cursorTo } from "node:readline";
|
|
12
|
+
/**
|
|
13
|
+
* Inline progress bar rendered on the current TTY line. Each call clears and redraws
|
|
14
|
+
* the line, so callers must not interleave other output (LogHandler narration, raw
|
|
15
|
+
* CliOutput writes, etc.) between updates or the previous bar will be left behind on
|
|
16
|
+
* the line above.
|
|
17
|
+
*/
|
|
18
|
+
let CliProgressBar = CliProgressBar_1 = class CliProgressBar {
|
|
19
|
+
/**
|
|
20
|
+
* Renders the progress bar at the current line. When `current >= total` the cursor
|
|
21
|
+
* is advanced to the next line so subsequent output doesn't overwrite the finished bar.
|
|
22
|
+
*/
|
|
23
|
+
update(current, total, message = "", width = 30) {
|
|
24
|
+
const percentage = Math.min(Math.max(current / total, 0), 1);
|
|
25
|
+
const filledWidth = Math.round(width * percentage);
|
|
26
|
+
const emptyWidth = width - filledWidth;
|
|
27
|
+
const filledBar = CliProgressBar_1.FILLED.repeat(filledWidth);
|
|
28
|
+
const emptyBar = CliProgressBar_1.EMPTY.repeat(emptyWidth);
|
|
29
|
+
clearLine(process.stdout, 0);
|
|
30
|
+
cursorTo(process.stdout, 0);
|
|
31
|
+
process.stdout.write(`${CliProgressBar_1.CYAN}[${filledBar}${emptyBar}]${CliProgressBar_1.RESET} ${Math.round(percentage * 100)}% ${message}`);
|
|
32
|
+
if (current >= total) {
|
|
33
|
+
process.stdout.write("\n");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
CliProgressBar.FILLED = "█";
|
|
38
|
+
CliProgressBar.EMPTY = "░";
|
|
39
|
+
CliProgressBar.CYAN = "\x1b[36m";
|
|
40
|
+
CliProgressBar.RESET = "\x1b[0m";
|
|
41
|
+
CliProgressBar = CliProgressBar_1 = __decorate([
|
|
42
|
+
injectable(),
|
|
43
|
+
moduleScoped(CliModuleKeyname)
|
|
44
|
+
], CliProgressBar);
|
|
45
|
+
export { CliProgressBar };
|
|
46
|
+
//# sourceMappingURL=cli-progress-bar.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-progress-bar.manager.js","sourceRoot":"","sources":["../../../../src/managers/cli-progress-bar.manager.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAElD;;;;;GAKG;AAGI,IAAM,cAAc,sBAApB,MAAM,cAAc;IAOzB;;;OAGG;IACH,MAAM,CAAC,OAAe,EAAE,KAAa,EAAE,UAAkB,EAAE,EAAE,QAAgB,EAAE;QAC7E,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,KAAK,GAAG,WAAW,CAAC;QAEvC,MAAM,SAAS,GAAG,gBAAc,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,gBAAc,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAEzD,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7B,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,gBAAc,CAAC,IAAI,IAAI,SAAS,GAAG,QAAQ,IAAI,gBAAc,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;QAE3I,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;;AAxBuB,qBAAM,GAAG,GAAG,AAAN,CAAO;AACb,oBAAK,GAAG,GAAG,AAAN,CAAO;AACZ,mBAAI,GAAG,UAAU,AAAb,CAAc;AAClB,oBAAK,GAAG,SAAS,AAAZ,CAAa;AAL/B,cAAc;IAF1B,UAAU,EAAE;IACZ,YAAY,CAAC,gBAAgB,CAAC;GAClB,cAAc,CA2B1B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
import { injectable } from "tsyringe";
|
|
17
|
+
import { moduleScoped } from "@pristine-ts/common";
|
|
18
|
+
import { CliModuleKeyname } from "../cli.module.keyname";
|
|
19
|
+
import * as readline from "node:readline/promises";
|
|
20
|
+
import { moveCursor, clearLine } from "node:readline";
|
|
21
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
22
|
+
import { ConsoleReadlineOptions } from "../options/console-readline.options";
|
|
23
|
+
/**
|
|
24
|
+
* Interactive stdin reader for CLI commands. Wraps Node's `readline/promises` and offers
|
|
25
|
+
* a single `readLine` method with optional masking after input is received.
|
|
26
|
+
*/
|
|
27
|
+
let CliPrompt = class CliPrompt {
|
|
28
|
+
/**
|
|
29
|
+
* Reads a string from stdin synchronously. Returns whatever `process.stdin.read()`
|
|
30
|
+
* gives back (which may be `null` when no data is buffered).
|
|
31
|
+
*/
|
|
32
|
+
read() {
|
|
33
|
+
return process.stdin.read();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reads a line from stdin after displaying a prompt. When
|
|
37
|
+
* `options.showCharactersOnTyping` is false, the answered line is cleared and replaced
|
|
38
|
+
* with a masked echo so the typed value isn't left visible on screen.
|
|
39
|
+
*
|
|
40
|
+
* Note: this is not a true keystroke-suppressing password input — Node's stock
|
|
41
|
+
* `readline` does not support that without raw-mode handling. The current behavior is
|
|
42
|
+
* a post-input clear, sufficient for most CLI prompts.
|
|
43
|
+
*/
|
|
44
|
+
readLine(question_1) {
|
|
45
|
+
return __awaiter(this, arguments, void 0, function* (question, options = new ConsoleReadlineOptions()) {
|
|
46
|
+
const rl = readline.createInterface({ input, output });
|
|
47
|
+
const answer = yield rl.question(question);
|
|
48
|
+
if (!options.showCharactersOnTyping) {
|
|
49
|
+
moveCursor(output, 0, -1);
|
|
50
|
+
clearLine(output, 0);
|
|
51
|
+
process.stdout.write(`${question} [******]\n`);
|
|
52
|
+
}
|
|
53
|
+
rl.close();
|
|
54
|
+
return answer;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
CliPrompt = __decorate([
|
|
59
|
+
injectable(),
|
|
60
|
+
moduleScoped(CliModuleKeyname)
|
|
61
|
+
], CliPrompt);
|
|
62
|
+
export { CliPrompt };
|
|
63
|
+
//# sourceMappingURL=cli-prompt.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-prompt.manager.js","sourceRoot":"","sources":["../../../../src/managers/cli-prompt.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAE3E;;;GAGG;AAGI,IAAM,S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