@pristine-ts/cli 1.0.440 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/pristine.cjs +7 -0
- package/dist/lib/cjs/bin.js +15 -1
- package/dist/lib/cjs/bin.js.map +1 -1
- package/dist/lib/cjs/bootstrap/app-module-loader.js +321 -0
- package/dist/lib/cjs/bootstrap/app-module-loader.js.map +1 -0
- package/dist/lib/cjs/bootstrap/bootstrap.js +31 -0
- package/dist/lib/cjs/bootstrap/bootstrap.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-manifest-checker.js +67 -0
- package/dist/lib/cjs/bootstrap/build-manifest-checker.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-manifest-reader.js +44 -0
- package/dist/lib/cjs/bootstrap/build-manifest-reader.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-manifest-staleness.enum.js +23 -0
- package/dist/lib/cjs/bootstrap/build-manifest-staleness.enum.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-manifest-writer.js +55 -0
- package/dist/lib/cjs/bootstrap/build-manifest-writer.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-manifest.js +31 -0
- package/dist/lib/cjs/bootstrap/build-manifest.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-runner.js +44 -0
- package/dist/lib/cjs/bootstrap/build-runner.js.map +1 -0
- package/dist/lib/cjs/bootstrap/build-staleness-prompt.js +90 -0
- package/dist/lib/cjs/bootstrap/build-staleness-prompt.js.map +1 -0
- package/dist/lib/cjs/bootstrap/dynamic-importer.js +43 -0
- package/dist/lib/cjs/bootstrap/dynamic-importer.js.map +1 -0
- package/dist/lib/cjs/bootstrap/init-prompt.js +127 -0
- package/dist/lib/cjs/bootstrap/init-prompt.js.map +1 -0
- package/dist/lib/cjs/bootstrap/loaded-app-module.js +29 -0
- package/dist/lib/cjs/bootstrap/loaded-app-module.js.map +1 -0
- package/dist/lib/cjs/bootstrap/loaded-plugin.js +22 -0
- package/dist/lib/cjs/bootstrap/loaded-plugin.js.map +1 -0
- package/dist/lib/cjs/bootstrap/plugin-loader.js +149 -0
- package/dist/lib/cjs/bootstrap/plugin-loader.js.map +1 -0
- package/dist/lib/cjs/bootstrap/source-hasher.js +41 -0
- package/dist/lib/cjs/bootstrap/source-hasher.js.map +1 -0
- package/dist/lib/cjs/cli.js +94 -111
- package/dist/lib/cjs/cli.js.map +1 -1
- package/dist/lib/cjs/cli.module.js +9 -1
- package/dist/lib/cjs/cli.module.js.map +1 -1
- package/dist/lib/cjs/commands/build-alias.command.js +50 -0
- package/dist/lib/cjs/commands/build-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/build.command.js +173 -0
- package/dist/lib/cjs/commands/build.command.js.map +1 -0
- package/dist/lib/cjs/commands/commands.js +15 -0
- package/dist/lib/cjs/commands/commands.js.map +1 -1
- package/dist/lib/cjs/commands/config-print.command.js +75 -0
- package/dist/lib/cjs/commands/config-print.command.js.map +1 -0
- package/dist/lib/cjs/commands/help-alias.command.js +52 -0
- package/dist/lib/cjs/commands/help-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/help.command.js +44 -10
- package/dist/lib/cjs/commands/help.command.js.map +1 -1
- package/dist/lib/cjs/commands/info-alias.command.js +50 -0
- package/dist/lib/cjs/commands/info-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/info.command.js +162 -0
- package/dist/lib/cjs/commands/info.command.js.map +1 -0
- package/dist/lib/cjs/commands/init-alias.command.js +51 -0
- package/dist/lib/cjs/commands/init-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/init.command-options.js +53 -0
- package/dist/lib/cjs/commands/init.command-options.js.map +1 -0
- package/dist/lib/cjs/commands/init.command.js +249 -0
- package/dist/lib/cjs/commands/init.command.js.map +1 -0
- package/dist/lib/cjs/commands/list-alias.command.js +50 -0
- package/dist/lib/cjs/commands/list-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/list.command.js +7 -1
- package/dist/lib/cjs/commands/list.command.js.map +1 -1
- package/dist/lib/cjs/commands/start-alias.command.js +51 -0
- package/dist/lib/cjs/commands/start-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/start.command-options.js +34 -0
- package/dist/lib/cjs/commands/start.command-options.js.map +1 -0
- package/dist/lib/cjs/commands/start.command.js +169 -0
- package/dist/lib/cjs/commands/start.command.js.map +1 -0
- package/dist/lib/cjs/commands/verify-alias.command.js +50 -0
- package/dist/lib/cjs/commands/verify-alias.command.js.map +1 -0
- package/dist/lib/cjs/commands/verify.command.js +71 -0
- package/dist/lib/cjs/commands/verify.command.js.map +1 -0
- package/dist/lib/cjs/config/config-loader.js +136 -0
- package/dist/lib/cjs/config/config-loader.js.map +1 -0
- package/dist/lib/cjs/config/config-provenance.enum.js +15 -0
- package/dist/lib/cjs/config/config-provenance.enum.js.map +1 -0
- package/dist/lib/cjs/config/config.js +22 -0
- package/dist/lib/cjs/config/config.js.map +1 -0
- package/dist/lib/cjs/config/define-config.js +18 -0
- package/dist/lib/cjs/config/define-config.js.map +1 -0
- package/dist/lib/cjs/config/pristine-config.interface.js +3 -0
- package/dist/lib/cjs/config/pristine-config.interface.js.map +1 -0
- package/dist/lib/cjs/config/resolved-pristine-config.js +25 -0
- package/dist/lib/cjs/config/resolved-pristine-config.js.map +1 -0
- package/dist/lib/cjs/event-handlers/cli.event-handler.js +69 -48
- package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/lib/esm/bin.js +15 -1
- package/dist/lib/esm/bin.js.map +1 -1
- package/dist/lib/esm/bootstrap/app-module-loader.js +315 -0
- package/dist/lib/esm/bootstrap/app-module-loader.js.map +1 -0
- package/dist/lib/esm/bootstrap/bootstrap.js +15 -0
- package/dist/lib/esm/bootstrap/bootstrap.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-manifest-checker.js +61 -0
- package/dist/lib/esm/bootstrap/build-manifest-checker.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-manifest-reader.js +38 -0
- package/dist/lib/esm/bootstrap/build-manifest-reader.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-manifest-staleness.enum.js +20 -0
- package/dist/lib/esm/bootstrap/build-manifest-staleness.enum.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-manifest-writer.js +49 -0
- package/dist/lib/esm/bootstrap/build-manifest-writer.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-manifest.js +27 -0
- package/dist/lib/esm/bootstrap/build-manifest.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-runner.js +41 -0
- package/dist/lib/esm/bootstrap/build-runner.js.map +1 -0
- package/dist/lib/esm/bootstrap/build-staleness-prompt.js +87 -0
- package/dist/lib/esm/bootstrap/build-staleness-prompt.js.map +1 -0
- package/dist/lib/esm/bootstrap/dynamic-importer.js +40 -0
- package/dist/lib/esm/bootstrap/dynamic-importer.js.map +1 -0
- package/dist/lib/esm/bootstrap/init-prompt.js +124 -0
- package/dist/lib/esm/bootstrap/init-prompt.js.map +1 -0
- package/dist/lib/esm/bootstrap/loaded-app-module.js +25 -0
- package/dist/lib/esm/bootstrap/loaded-app-module.js.map +1 -0
- package/dist/lib/esm/bootstrap/loaded-plugin.js +18 -0
- package/dist/lib/esm/bootstrap/loaded-plugin.js.map +1 -0
- package/dist/lib/esm/bootstrap/plugin-loader.js +143 -0
- package/dist/lib/esm/bootstrap/plugin-loader.js.map +1 -0
- package/dist/lib/esm/bootstrap/source-hasher.js +35 -0
- package/dist/lib/esm/bootstrap/source-hasher.js.map +1 -0
- package/dist/lib/esm/cli.js +109 -0
- package/dist/lib/esm/cli.js.map +1 -0
- package/dist/lib/esm/cli.module.js +7 -0
- package/dist/lib/esm/cli.module.js.map +1 -1
- package/dist/lib/esm/commands/build-alias.command.js +47 -0
- package/dist/lib/esm/commands/build-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/build.command.js +167 -0
- package/dist/lib/esm/commands/build.command.js.map +1 -0
- package/dist/lib/esm/commands/commands.js +15 -0
- package/dist/lib/esm/commands/commands.js.map +1 -1
- package/dist/lib/esm/commands/config-print.command.js +69 -0
- package/dist/lib/esm/commands/config-print.command.js.map +1 -0
- package/dist/lib/esm/commands/help-alias.command.js +49 -0
- package/dist/lib/esm/commands/help-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/help.command.js +44 -10
- package/dist/lib/esm/commands/help.command.js.map +1 -1
- package/dist/lib/esm/commands/info-alias.command.js +47 -0
- package/dist/lib/esm/commands/info-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/info.command.js +156 -0
- package/dist/lib/esm/commands/info.command.js.map +1 -0
- package/dist/lib/esm/commands/init-alias.command.js +48 -0
- package/dist/lib/esm/commands/init-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/init.command-options.js +49 -0
- package/dist/lib/esm/commands/init.command-options.js.map +1 -0
- package/dist/lib/esm/commands/init.command.js +243 -0
- package/dist/lib/esm/commands/init.command.js.map +1 -0
- package/dist/lib/esm/commands/list-alias.command.js +47 -0
- package/dist/lib/esm/commands/list-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/list.command.js +8 -2
- package/dist/lib/esm/commands/list.command.js.map +1 -1
- package/dist/lib/esm/commands/start-alias.command.js +48 -0
- package/dist/lib/esm/commands/start-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/start.command-options.js +30 -0
- package/dist/lib/esm/commands/start.command-options.js.map +1 -0
- package/dist/lib/esm/commands/start.command.js +166 -0
- package/dist/lib/esm/commands/start.command.js.map +1 -0
- package/dist/lib/esm/commands/verify-alias.command.js +47 -0
- package/dist/lib/esm/commands/verify-alias.command.js.map +1 -0
- package/dist/lib/esm/commands/verify.command.js +68 -0
- package/dist/lib/esm/commands/verify.command.js.map +1 -0
- package/dist/lib/esm/config/config-loader.js +130 -0
- package/dist/lib/esm/config/config-loader.js.map +1 -0
- package/dist/lib/esm/config/config-provenance.enum.js +12 -0
- package/dist/lib/esm/config/config-provenance.enum.js.map +1 -0
- package/dist/lib/esm/config/config.js +6 -0
- package/dist/lib/esm/config/config.js.map +1 -0
- package/dist/lib/esm/config/define-config.js +14 -0
- package/dist/lib/esm/config/define-config.js.map +1 -0
- package/dist/lib/esm/config/pristine-config.interface.js +2 -0
- package/dist/lib/esm/config/pristine-config.interface.js.map +1 -0
- package/dist/lib/esm/config/resolved-pristine-config.js +21 -0
- package/dist/lib/esm/config/resolved-pristine-config.js.map +1 -0
- package/dist/lib/esm/event-handlers/cli.event-handler.js +69 -48
- package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/types/bootstrap/app-module-loader.d.ts +83 -0
- package/dist/types/bootstrap/bootstrap.d.ts +14 -0
- package/dist/types/bootstrap/build-manifest-checker.d.ts +19 -0
- package/dist/types/bootstrap/build-manifest-reader.d.ts +14 -0
- package/dist/types/bootstrap/build-manifest-staleness.enum.d.ts +18 -0
- package/dist/types/bootstrap/build-manifest-writer.d.ts +19 -0
- package/dist/types/bootstrap/build-manifest.d.ts +29 -0
- package/dist/types/bootstrap/build-runner.d.ts +16 -0
- package/dist/types/bootstrap/build-staleness-prompt.d.ts +27 -0
- package/dist/types/bootstrap/dynamic-importer.d.ts +13 -0
- package/dist/types/bootstrap/init-prompt.d.ts +38 -0
- package/dist/types/bootstrap/loaded-app-module.d.ts +40 -0
- package/dist/types/bootstrap/loaded-plugin.d.ts +20 -0
- package/dist/types/bootstrap/plugin-loader.d.ts +35 -0
- package/dist/types/bootstrap/source-hasher.d.ts +15 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/cli.module.d.ts +3 -0
- package/dist/types/commands/build-alias.command.d.ts +15 -0
- package/dist/types/commands/build.command.d.ts +47 -0
- package/dist/types/commands/commands.d.ts +15 -0
- package/dist/types/commands/config-print.command.d.ts +18 -0
- package/dist/types/commands/help-alias.command.d.ts +17 -0
- package/dist/types/commands/help.command.d.ts +19 -1
- package/dist/types/commands/info-alias.command.d.ts +15 -0
- package/dist/types/commands/info.command.d.ts +41 -0
- package/dist/types/commands/init-alias.command.d.ts +16 -0
- package/dist/types/commands/init.command-options.d.ts +22 -0
- package/dist/types/commands/init.command.d.ts +60 -0
- package/dist/types/commands/list-alias.command.d.ts +15 -0
- package/dist/types/commands/list.command.d.ts +6 -0
- package/dist/types/commands/start-alias.command.d.ts +16 -0
- package/dist/types/commands/start.command-options.d.ts +11 -0
- package/dist/types/commands/start.command.d.ts +47 -0
- package/dist/types/commands/verify-alias.command.d.ts +15 -0
- package/dist/types/commands/verify.command.d.ts +24 -0
- package/dist/types/config/config-loader.d.ts +40 -0
- package/dist/types/config/config-provenance.enum.d.ts +10 -0
- package/dist/types/config/config.d.ts +5 -0
- package/dist/types/config/define-config.d.ts +14 -0
- package/dist/types/config/pristine-config.interface.d.ts +67 -0
- package/dist/types/config/resolved-pristine-config.d.ts +28 -0
- package/dist/types/event-handlers/cli.event-handler.d.ts +30 -3
- package/dist/types/interfaces/command.interface.d.ts +31 -3
- package/package.json +16 -13
- package/readme.md +1023 -17
|
@@ -0,0 +1,87 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
import { injectable } from "tsyringe";
|
|
20
|
+
import { BuildManifestStalenessEnum } from "./build-manifest-staleness.enum";
|
|
21
|
+
import { DynamicImporter } from "./dynamic-importer";
|
|
22
|
+
/**
|
|
23
|
+
* When the build manifest is stale (source edited, output missing, etc.), `AppModuleLoader`
|
|
24
|
+
* stops the load and consults this prompt. In a TTY, asks the user whether to run
|
|
25
|
+
* `pristine build` now; in non-TTY (CI, Docker), refuses to prompt and lets the caller exit
|
|
26
|
+
* non-zero with the explanation — auto-rebuilding in CI hides bugs.
|
|
27
|
+
*
|
|
28
|
+
* Just the prompt UI here. The actual rebuild dispatch is the caller's responsibility so
|
|
29
|
+
* this class stays small and testable.
|
|
30
|
+
*/
|
|
31
|
+
let BuildStalenessPrompt = class BuildStalenessPrompt {
|
|
32
|
+
constructor(dynamicImporter) {
|
|
33
|
+
this.dynamicImporter = dynamicImporter;
|
|
34
|
+
this.promptMessage = "Run `pristine build` now to refresh?";
|
|
35
|
+
}
|
|
36
|
+
isInteractive() {
|
|
37
|
+
return Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Renders a one-line explanation of why the manifest is stale. Used by both the prompt
|
|
41
|
+
* (TTY) and the non-TTY error path so the messaging is identical regardless of channel.
|
|
42
|
+
*/
|
|
43
|
+
describe(reason) {
|
|
44
|
+
switch (reason) {
|
|
45
|
+
case BuildManifestStalenessEnum.Missing:
|
|
46
|
+
return "No build manifest found. Run `pristine build` before invoking this command.";
|
|
47
|
+
case BuildManifestStalenessEnum.SourcePathChanged:
|
|
48
|
+
return "Your config's `appModule.sourcePath` no longer matches the last build. Run `pristine build` to rebuild against the new source.";
|
|
49
|
+
case BuildManifestStalenessEnum.OutputPathChanged:
|
|
50
|
+
return "Your config's `appModule.outputPath` no longer matches the last build. Run `pristine build` to rebuild against the new output path.";
|
|
51
|
+
case BuildManifestStalenessEnum.SourceContentChanged:
|
|
52
|
+
return "Your AppModule source has changed since the last build. Run `pristine build` to recompile.";
|
|
53
|
+
case BuildManifestStalenessEnum.OutputMissing:
|
|
54
|
+
return "The compiled AppModule output is missing on disk. Run `pristine build` to produce it.";
|
|
55
|
+
case BuildManifestStalenessEnum.Fresh:
|
|
56
|
+
// Should never be asked to describe Fresh, but a safe fallback beats a thrown error
|
|
57
|
+
// in a hot path.
|
|
58
|
+
return "Build manifest is up to date.";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Asks the user whether to rebuild. Returns `true` for yes, `false` for no, `undefined`
|
|
63
|
+
* for cancellation (Ctrl+C). Caller decides what to do with each outcome.
|
|
64
|
+
*/
|
|
65
|
+
prompt(reason) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
68
|
+
const confirm = inquirer.confirm;
|
|
69
|
+
try {
|
|
70
|
+
return yield confirm({
|
|
71
|
+
message: `${this.describe(reason)}\n ${this.promptMessage}`,
|
|
72
|
+
default: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
// @inquirer throws on Ctrl+C. Treat as a clean cancellation.
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
BuildStalenessPrompt = __decorate([
|
|
83
|
+
injectable(),
|
|
84
|
+
__metadata("design:paramtypes", [DynamicImporter])
|
|
85
|
+
], BuildStalenessPrompt);
|
|
86
|
+
export { BuildStalenessPrompt };
|
|
87
|
+
//# sourceMappingURL=build-staleness-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-staleness-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-staleness-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,0BAA0B,EAAC,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;GAQG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG/B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAF5C,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,0BAA0B,CAAC,OAAO;gBACrC,OAAO,6EAA6E,CAAC;YACvF,KAAK,0BAA0B,CAAC,iBAAiB;gBAC/C,OAAO,gIAAgI,CAAC;YAC1I,KAAK,0BAA0B,CAAC,iBAAiB;gBAC/C,OAAO,qIAAqI,CAAC;YAC/I,KAAK,0BAA0B,CAAC,oBAAoB;gBAClD,OAAO,4FAA4F,CAAC;YACtG,KAAK,0BAA0B,CAAC,aAAa;gBAC3C,OAAO,uFAAuF,CAAC;YACjG,KAAK,0BAA0B,CAAC,KAAK;gBACnC,oFAAoF;gBACpF,iBAAiB;gBACjB,OAAO,+BAA+B,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;OAGG;IACG,MAAM,CAAC,MAAkC;;YAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,OAAO,GAAsC,QAAQ,CAAC,OAAO,CAAC;YAEpE,IAAI,CAAC;gBACH,OAAO,MAAM,OAAO,CAAC;oBACnB,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,aAAa,EAAE;oBAC5D,OAAO,EAAE,IAAI;iBACd,CAAC,CAAC;YACL,CAAC;YAAC,WAAM,CAAC;gBACP,6DAA6D;gBAC7D,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AAnDY,oBAAoB;IADhC,UAAU,EAAE;qCAImC,eAAe;GAHlD,oBAAoB,CAmDhC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Wraps Node's real dynamic `import()` so it survives both tsc's CJS lowering and esbuild's
|
|
19
|
+
* bundling. Both transformations otherwise rewrite `await import(x)` to a `require(x)` call —
|
|
20
|
+
* which is wrong for ESM-only packages and for `file://` URLs. The Function constructor's body
|
|
21
|
+
* is opaque to both, so the `import()` inside it goes through unrewritten.
|
|
22
|
+
*
|
|
23
|
+
* Centralized in one class so the same escape hatch isn't reimplemented in every consumer
|
|
24
|
+
* (loaders, plugin discovery, config loading, etc.).
|
|
25
|
+
*/
|
|
26
|
+
let DynamicImporter = class DynamicImporter {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.importFn = new Function("specifier", "return import(specifier);");
|
|
29
|
+
}
|
|
30
|
+
import(specifier) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return this.importFn(specifier);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
DynamicImporter = __decorate([
|
|
37
|
+
injectable()
|
|
38
|
+
], DynamicImporter);
|
|
39
|
+
export { DynamicImporter };
|
|
40
|
+
//# sourceMappingURL=dynamic-importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-importer.js","sourceRoot":"","sources":["../../../../src/bootstrap/dynamic-importer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC;;;;;;;;GAQG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QACY,aAAQ,GAAwC,IAAI,QAAQ,CAC3E,WAAW,EACX,2BAA2B,CACW,CAAC;IAK3C,CAAC;IAHO,MAAM,CAAC,SAAiB;;YAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;KAAA;CACF,CAAA;AATY,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAS3B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
import { injectable } from "tsyringe";
|
|
20
|
+
import { DynamicImporter } from "./dynamic-importer";
|
|
21
|
+
/**
|
|
22
|
+
* Interactive Q&A for `pristine init`. Lazy-loads `@inquirer/prompts` so the dep cost is
|
|
23
|
+
* only paid when actually prompting (the same pattern as `BuildStalenessPrompt` uses).
|
|
24
|
+
*
|
|
25
|
+
* Each method takes a "current value" so callers can pre-fill answers from CLI flags and
|
|
26
|
+
* only prompt for the gaps. Returning the same value the user passed in is intentional —
|
|
27
|
+
* it keeps the call sites uniform regardless of whether the value came from a flag or a
|
|
28
|
+
* prompt.
|
|
29
|
+
*/
|
|
30
|
+
let InitPrompt = class InitPrompt {
|
|
31
|
+
constructor(dynamicImporter) {
|
|
32
|
+
this.dynamicImporter = dynamicImporter;
|
|
33
|
+
this.defaultSourcePath = "src/app.module.ts";
|
|
34
|
+
this.defaultOutputPath = "dist/app.module.js";
|
|
35
|
+
this.defaultTsconfig = "tsconfig.json";
|
|
36
|
+
this.defaultFormat = "esm";
|
|
37
|
+
}
|
|
38
|
+
isInteractive() {
|
|
39
|
+
return Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY);
|
|
40
|
+
}
|
|
41
|
+
askSourcePath(current) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (current !== undefined)
|
|
44
|
+
return current;
|
|
45
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
46
|
+
const input = inquirer.input;
|
|
47
|
+
return input({
|
|
48
|
+
message: "Where does your AppModule source file live?",
|
|
49
|
+
default: this.defaultSourcePath,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
askOutputPath(current) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (current !== undefined)
|
|
56
|
+
return current;
|
|
57
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
58
|
+
const input = inquirer.input;
|
|
59
|
+
return input({
|
|
60
|
+
message: "Where should the compiled AppModule output land?",
|
|
61
|
+
default: this.defaultOutputPath,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
askTsconfig(current) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (current !== undefined)
|
|
68
|
+
return current;
|
|
69
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
70
|
+
const input = inquirer.input;
|
|
71
|
+
return input({
|
|
72
|
+
message: "Which tsconfig should `pristine build` use?",
|
|
73
|
+
default: this.defaultTsconfig,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
askFormat(current) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (current !== undefined)
|
|
80
|
+
return current;
|
|
81
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
82
|
+
const select = inquirer.select;
|
|
83
|
+
return select({
|
|
84
|
+
message: "Which build format do you want?",
|
|
85
|
+
choices: [
|
|
86
|
+
{ name: "esm (modern, recommended)", value: "esm" },
|
|
87
|
+
{ name: "cjs (CommonJS)", value: "cjs" },
|
|
88
|
+
{ name: "both (publish ESM + CJS)", value: "both" },
|
|
89
|
+
],
|
|
90
|
+
default: this.defaultFormat,
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
askScaffoldSource(current, sourcePath) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
if (current !== undefined)
|
|
97
|
+
return current;
|
|
98
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
99
|
+
const confirm = inquirer.confirm;
|
|
100
|
+
return confirm({
|
|
101
|
+
message: `Scaffold a starter AppModule at ${sourcePath}?`,
|
|
102
|
+
default: true,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
askWritePackageScripts(current) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
if (current !== undefined)
|
|
109
|
+
return current;
|
|
110
|
+
const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
|
|
111
|
+
const confirm = inquirer.confirm;
|
|
112
|
+
return confirm({
|
|
113
|
+
message: "Add `build`, `start`, `verify` scripts to package.json (only ones that don't already exist)?",
|
|
114
|
+
default: true,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
InitPrompt = __decorate([
|
|
120
|
+
injectable(),
|
|
121
|
+
__metadata("design:paramtypes", [DynamicImporter])
|
|
122
|
+
], InitPrompt);
|
|
123
|
+
export { InitPrompt };
|
|
124
|
+
//# sourceMappingURL=init-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/init-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAgBnD;;;;;;;;GAQG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IAMrB,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAL5C,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,CAAC,MAAc,CAAC,KAAK,CAAC,IAAI,OAAO,CAAE,OAAO,CAAC,KAAa,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC;IAEK,aAAa,CAAC,OAA2B;;YAC7C,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,KAAK,GAAqC,QAAQ,CAAC,KAAK,CAAC;YAC/D,OAAO,KAAK,CAAC;gBACX,OAAO,EAAE,6CAA6C;gBAC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K,EAAE,MAAM,EAAC;iBAClD;gBACD,OAAO,EAAE,IAAI,CAAC,aAAa;aAC5B,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,iBAAiB,CAAC,OAA4B,EAAE,UAAkB;;YACtE,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,OAAO,GAAsC,QAAQ,CAAC,OAAO,CAAC;YACpE,OAAO,OAAO,CAAC;gBACb,OAAO,EAAE,mCAAmC,UAAU,GAAG;gBACzD,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,sBAAsB,CAAC,OAA4B;;YACvD,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,OAAO,GAAsC,QAAQ,CAAC,OAAO,CAAC;YACpE,OAAO,OAAO,CAAC;gBACb,OAAO,EAAE,8FAA8F;gBACvG,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAA;AA7EY,UAAU;IADtB,UAAU,EAAE;qCAOmC,eAAe;GANlD,UAAU,CA6EtB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fully-resolved AppModule + ambient configuration that the CLI uses to boot the kernel.
|
|
3
|
+
* Returned by `AppModuleLoader.load()`.
|
|
4
|
+
*/
|
|
5
|
+
export class LoadedAppModule {
|
|
6
|
+
constructor(appModule, configuration,
|
|
7
|
+
/**
|
|
8
|
+
* True when `LoggingModule` is in the resolved AppModule's import graph. The CLI uses
|
|
9
|
+
* this to decide whether to layer in opinionated default logging configuration (Simple
|
|
10
|
+
* output mode, Error severity threshold) on top of the kernel configuration.
|
|
11
|
+
*/
|
|
12
|
+
isLoggingModulePresent,
|
|
13
|
+
/**
|
|
14
|
+
* Plugins loaded from `pristine.config.ts`'s `plugins` array. Empty when no plugins are
|
|
15
|
+
* declared. Carried through so commands like `pristine info` can show what's contributing
|
|
16
|
+
* extra modules to the runtime.
|
|
17
|
+
*/
|
|
18
|
+
plugins) {
|
|
19
|
+
this.appModule = appModule;
|
|
20
|
+
this.configuration = configuration;
|
|
21
|
+
this.isLoggingModulePresent = isLoggingModulePresent;
|
|
22
|
+
this.plugins = plugins;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=loaded-app-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loaded-app-module.js","sourceRoot":"","sources":["../../../../src/bootstrap/loaded-app-module.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,YACkB,SAA6B,EAC7B,aAA0D;IAC1E;;;;OAIG;IACa,sBAA+B;IAC/C;;;;OAIG;IACa,OAAuB;QAbvB,cAAS,GAAT,SAAS,CAAoB;QAC7B,kBAAa,GAAb,aAAa,CAA6C;QAM1D,2BAAsB,GAAtB,sBAAsB,CAAS;QAM/B,YAAO,GAAP,OAAO,CAAgB;IAEzC,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A successfully-loaded plugin. Records the package name (for collision diagnostics), the
|
|
3
|
+
* absolute path it was resolved to, and every `*Module` export the plugin's entry produced.
|
|
4
|
+
*/
|
|
5
|
+
export class LoadedPlugin {
|
|
6
|
+
constructor(
|
|
7
|
+
/** As declared in `pristine.config.ts` plugins[] (string form or `.name` form). */
|
|
8
|
+
name,
|
|
9
|
+
/** Absolute path resolved by `createRequire` from the consumer's project. */
|
|
10
|
+
resolvedPath,
|
|
11
|
+
/** Modules harvested from the plugin's exports — one entry per `*Module` named export. */
|
|
12
|
+
modules) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.resolvedPath = resolvedPath;
|
|
15
|
+
this.modules = modules;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=loaded-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loaded-plugin.js","sourceRoot":"","sources":["../../../../src/bootstrap/loaded-plugin.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,YAAY;IACvB;IACE,mFAAmF;IACnE,IAAY;IAC5B,6EAA6E;IAC7D,YAAoB;IACpC,0FAA0F;IAC1E,OAA0B;QAJ1B,SAAI,GAAJ,IAAI,CAAQ;QAEZ,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,YAAO,GAAP,OAAO,CAAmB;IAE5C,CAAC;CACF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
import { injectable } from "tsyringe";
|
|
20
|
+
import { createRequire } from "module";
|
|
21
|
+
import path from "path";
|
|
22
|
+
import { pathToFileURL } from "url";
|
|
23
|
+
import { DynamicImporter } from "./dynamic-importer";
|
|
24
|
+
import { LoadedPlugin } from "./loaded-plugin";
|
|
25
|
+
/**
|
|
26
|
+
* Resolves and loads every plugin declared in `config.plugins`. Plugin packages are resolved
|
|
27
|
+
* from the **consumer's project**, not from the CLI's install location — a plugin lives in
|
|
28
|
+
* the consumer's `node_modules`, not in `@pristine-ts/cli/node_modules`. Without
|
|
29
|
+
* `createRequire` pinned to the project location, `import("@my-org/plugin")` would walk up
|
|
30
|
+
* from the bin's install dir and miss it.
|
|
31
|
+
*
|
|
32
|
+
* A plugin that fails to load surfaces as a thrown error rather than being silently skipped —
|
|
33
|
+
* silent plugin loading is a footgun that makes "why isn't my command showing up" debuggable
|
|
34
|
+
* only by reading source.
|
|
35
|
+
*/
|
|
36
|
+
let PluginLoader = class PluginLoader {
|
|
37
|
+
constructor(dynamicImporter) {
|
|
38
|
+
this.dynamicImporter = dynamicImporter;
|
|
39
|
+
}
|
|
40
|
+
load(config, configFilePath, projectRoot) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
const plugins = (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
|
|
44
|
+
if (plugins.length === 0) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
// `createRequire` needs a "from" file to anchor resolution. When a config file exists,
|
|
48
|
+
// use it (so plugins resolve relative to where the config lives — important in monorepos).
|
|
49
|
+
// When no config file exists but plugins are somehow declared, anchor to the project root.
|
|
50
|
+
const anchor = configFilePath !== null && configFilePath !== void 0 ? configFilePath : path.join(projectRoot, "package.json");
|
|
51
|
+
const requireFn = createRequire(pathToFileURL(anchor).href);
|
|
52
|
+
const loaded = [];
|
|
53
|
+
for (const entry of plugins) {
|
|
54
|
+
const name = typeof entry === "string" ? entry : entry.name;
|
|
55
|
+
const resolvedPath = this.resolvePluginPath(name, requireFn, anchor);
|
|
56
|
+
const imported = yield this.importPlugin(name, resolvedPath);
|
|
57
|
+
const modules = this.harvestModuleExports(imported);
|
|
58
|
+
if (modules.length === 0) {
|
|
59
|
+
throw new Error(`[pristine] Plugin '${name}' exported no '*Module' symbols. A plugin must export at least one ` +
|
|
60
|
+
`ModuleInterface (e.g. \`export const FooModule: ModuleInterface = { keyname: "...", ... }\`).`);
|
|
61
|
+
}
|
|
62
|
+
loaded.push(new LoadedPlugin(name, resolvedPath, modules));
|
|
63
|
+
}
|
|
64
|
+
return loaded;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Synthesizes an outer AppModule whose `importModules` includes the user's AppModule plus
|
|
69
|
+
* every plugin-contributed module, deduplicated by reference. Preserves the user's keyname
|
|
70
|
+
* (suffixed with `.with-plugins`) so introspection tools (`pristine info`) still surface a
|
|
71
|
+
* recognizable label.
|
|
72
|
+
*/
|
|
73
|
+
wrap(appModule, plugins) {
|
|
74
|
+
var _a;
|
|
75
|
+
if (plugins.length === 0) {
|
|
76
|
+
return appModule;
|
|
77
|
+
}
|
|
78
|
+
const seen = new Set();
|
|
79
|
+
const importModules = [];
|
|
80
|
+
const add = (m) => {
|
|
81
|
+
if (seen.has(m))
|
|
82
|
+
return;
|
|
83
|
+
seen.add(m);
|
|
84
|
+
importModules.push(m);
|
|
85
|
+
};
|
|
86
|
+
add(appModule);
|
|
87
|
+
for (const plugin of plugins) {
|
|
88
|
+
for (const module of plugin.modules) {
|
|
89
|
+
add(module);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
keyname: `${appModule.keyname}.with-plugins`,
|
|
94
|
+
importModules,
|
|
95
|
+
importServices: (_a = appModule.importServices) !== null && _a !== void 0 ? _a : [],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
resolvePluginPath(name, requireFn, anchor) {
|
|
99
|
+
try {
|
|
100
|
+
return requireFn.resolve(name);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new Error(`[pristine] Failed to resolve plugin '${name}' from '${anchor}': ${error.message}. ` +
|
|
104
|
+
`Make sure the plugin package is installed in your project's node_modules.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
importPlugin(name, resolvedPath) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
try {
|
|
110
|
+
return yield this.dynamicImporter.import(pathToFileURL(resolvedPath).href);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
throw new Error(`[pristine] Failed to import plugin '${name}' from '${resolvedPath}': ${error.message}`);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Walks a plugin's exports collecting every value whose name ends in `Module` and looks
|
|
119
|
+
* like a `ModuleInterface` (has a `keyname` string). Accepts both ESM (default export) and
|
|
120
|
+
* CJS (named exports on the module namespace) plugin shapes.
|
|
121
|
+
*/
|
|
122
|
+
harvestModuleExports(imported) {
|
|
123
|
+
const modules = [];
|
|
124
|
+
const candidates = [imported, imported === null || imported === void 0 ? void 0 : imported.default].filter(o => o !== undefined && o !== null);
|
|
125
|
+
for (const candidate of candidates) {
|
|
126
|
+
for (const key of Object.keys(candidate)) {
|
|
127
|
+
if (key.endsWith("Module") === false)
|
|
128
|
+
continue;
|
|
129
|
+
const value = candidate[key];
|
|
130
|
+
if (value !== null && typeof value === "object" && typeof value.keyname === "string") {
|
|
131
|
+
modules.push(value);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return modules;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
PluginLoader = __decorate([
|
|
139
|
+
injectable(),
|
|
140
|
+
__metadata("design:paramtypes", [DynamicImporter])
|
|
141
|
+
], PluginLoader);
|
|
142
|
+
export { PluginLoader };
|
|
143
|
+
//# sourceMappingURL=plugin-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../../../../src/bootstrap/plugin-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAGlC,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;GAUG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAC7D,CAAC;IAEK,IAAI,CAAC,MAAsB,EAAE,cAAkC,EAAE,WAAmB;;;YACxF,MAAM,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,uFAAuF;YACvF,2FAA2F;YAC3F,2FAA2F;YAC3F,MAAM,MAAM,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YACxE,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;YAE5D,MAAM,MAAM,GAAm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AAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzC,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,KAAK;oBAAE,SAAS;gBAC/C,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;oBACrF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA/GY,YAAY;IADxB,UAAU,EAAE;qCAEmC,eAAe;GADlD,YAAY,CA+GxB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { createHash } from "crypto";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
/**
|
|
11
|
+
* Computes the content hash that goes into the build manifest. SHA-256 because it's
|
|
12
|
+
* collision-free for our purposes, ships with Node, and the hex digest is short enough
|
|
13
|
+
* to pretty-print in error messages without truncating.
|
|
14
|
+
*
|
|
15
|
+
* The hash is just a fingerprint of the source file's bytes — no AST awareness, no
|
|
16
|
+
* imports-aware tracing. That's intentional: a deeper hash (e.g. of the whole source tree)
|
|
17
|
+
* adds complexity and IO without changing the staleness story for the common case (user
|
|
18
|
+
* edits app.module.ts → hash changes → CLI tells them to rebuild).
|
|
19
|
+
*/
|
|
20
|
+
let SourceHasher = class SourceHasher {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.algorithm = "sha256";
|
|
23
|
+
this.digestPrefix = "sha256:";
|
|
24
|
+
}
|
|
25
|
+
hashFile(absolutePath) {
|
|
26
|
+
const hash = createHash(this.algorithm);
|
|
27
|
+
hash.update(fs.readFileSync(absolutePath));
|
|
28
|
+
return this.digestPrefix + hash.digest("hex");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
SourceHasher = __decorate([
|
|
32
|
+
injectable()
|
|
33
|
+
], SourceHasher);
|
|
34
|
+
export { SourceHasher };
|
|
35
|
+
//# sourceMappingURL=source-hasher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-hasher.js","sourceRoot":"","sources":["../../../../src/bootstrap/source-hasher.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB;;;;;;;;;GASG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACY,cAAS,GAAW,QAAQ,CAAC;QAC7B,iBAAY,GAAW,SAAS,CAAC;IAOpD,CAAC;IALC,QAAQ,CAAC,YAAoB;QAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;CACF,CAAA;AATY,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CASxB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { ExecutionContextKeynameEnum, Kernel } from "@pristine-ts/core";
|
|
11
|
+
import { ServiceDefinitionTagEnum } from "@pristine-ts/common";
|
|
12
|
+
import { AppModuleLoader } from "./bootstrap/app-module-loader";
|
|
13
|
+
import { BuildManifestChecker } from "./bootstrap/build-manifest-checker";
|
|
14
|
+
import { BuildManifestReader } from "./bootstrap/build-manifest-reader";
|
|
15
|
+
import { BuildRunner } from "./bootstrap/build-runner";
|
|
16
|
+
import { BuildStalenessPrompt } from "./bootstrap/build-staleness-prompt";
|
|
17
|
+
import { DynamicImporter } from "./bootstrap/dynamic-importer";
|
|
18
|
+
import { PluginLoader } from "./bootstrap/plugin-loader";
|
|
19
|
+
import { SourceHasher } from "./bootstrap/source-hasher";
|
|
20
|
+
import { ConfigLoader } from "./config/config-loader";
|
|
21
|
+
import { CliModule } from "./cli.module";
|
|
22
|
+
/**
|
|
23
|
+
* Boots the CLI: discovers the consumer's AppModule, starts the kernel, and dispatches
|
|
24
|
+
* `process.argv` to whichever command matches. Exported so `bin.ts` can call it explicitly
|
|
25
|
+
* — the auto-invoke at module load was removed so library consumers importing this file for
|
|
26
|
+
* its types or `bootstrap` reference do not accidentally trigger an entire kernel boot.
|
|
27
|
+
*
|
|
28
|
+
* The bootstrap-layer collaborators (loaders, discoverers, cache, prompt) are instantiated
|
|
29
|
+
* by hand here rather than resolved through DI. The kernel container does not exist yet at
|
|
30
|
+
* this point, so DI is not available — manually wiring the (small, stable) class graph is the
|
|
31
|
+
* least surprising option. Once the kernel is up, the kernel itself is registered into its
|
|
32
|
+
* own container so commands can inject it.
|
|
33
|
+
*/
|
|
34
|
+
export const bootstrap = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
const appModuleLoader = buildAppModuleLoader();
|
|
36
|
+
const { appModule, configuration } = yield appModuleLoader.load();
|
|
37
|
+
const kernel = new Kernel();
|
|
38
|
+
// Wrap the user's AppModule with CliModule so the CLI's own commands (`build`,
|
|
39
|
+
// `start`, `verify`, `init`, `help`, `list`, `info`, custom commands) are always
|
|
40
|
+
// registered when the bin is the entry point — regardless of whether the user's
|
|
41
|
+
// AppModule already imports CliModule. The kernel dedupes modules by keyname during
|
|
42
|
+
// start, so wrapping when CliModule is already in the graph is a no-op; we don't
|
|
43
|
+
// bother walking the graph to detect that case.
|
|
44
|
+
yield kernel.start(wrapWithCliModule(appModule), configuration);
|
|
45
|
+
// Make the running kernel resolvable from within commands so things like `pristine start`
|
|
46
|
+
// and the alias commands can register signal handlers and resolve their delegates.
|
|
47
|
+
kernel.container.registerInstance(Kernel, kernel);
|
|
48
|
+
warnOnCommandCollisions(kernel);
|
|
49
|
+
yield kernel.handle(process.argv, { keyname: ExecutionContextKeynameEnum.Cli, context: null });
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Hand-wired graph of the bootstrap-layer classes. The kernel container does not exist yet,
|
|
53
|
+
* so we cannot resolve via DI — but the class graph here is shallow and stable, so manual
|
|
54
|
+
* wiring stays readable. Each class is `@injectable()` so DI resolution would also work if
|
|
55
|
+
* we ever moved this into a kernel-pre-boot container.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Builds a synthetic outer AppModule that imports both the user's AppModule and CliModule.
|
|
59
|
+
* The wrap is unconditional — the kernel dedupes module imports by keyname, so adding
|
|
60
|
+
* CliModule on top of a graph that already contains it is a no-op rather than an error
|
|
61
|
+
* or duplicate registration. Cheaper than walking the user's import tree to detect the
|
|
62
|
+
* already-present case.
|
|
63
|
+
*/
|
|
64
|
+
const wrapWithCliModule = (appModule) => {
|
|
65
|
+
var _a;
|
|
66
|
+
return {
|
|
67
|
+
keyname: `${appModule.keyname}.with-cli`,
|
|
68
|
+
importModules: [appModule, CliModule],
|
|
69
|
+
importServices: (_a = appModule.importServices) !== null && _a !== void 0 ? _a : [],
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const buildAppModuleLoader = () => {
|
|
73
|
+
const dynamicImporter = new DynamicImporter();
|
|
74
|
+
const configLoader = new ConfigLoader(dynamicImporter);
|
|
75
|
+
const pluginLoader = new PluginLoader(dynamicImporter);
|
|
76
|
+
const sourceHasher = new SourceHasher();
|
|
77
|
+
const buildManifestReader = new BuildManifestReader();
|
|
78
|
+
const buildManifestChecker = new BuildManifestChecker(sourceHasher);
|
|
79
|
+
const buildStalenessPrompt = new BuildStalenessPrompt(dynamicImporter);
|
|
80
|
+
const buildRunner = new BuildRunner();
|
|
81
|
+
return new AppModuleLoader(configLoader, pluginLoader, dynamicImporter, buildManifestReader, buildManifestChecker, buildStalenessPrompt, buildRunner);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Walks every registered Command-tagged service and warns to stderr if multiple share a
|
|
85
|
+
* `name`. The CLI's event dispatcher picks whichever match it sees first — without this
|
|
86
|
+
* warning, a plugin silently shadowing a built-in command (or two plugins shadowing each
|
|
87
|
+
* other) would be invisible until someone debugged "why is my command not running?". Warning
|
|
88
|
+
* rather than throwing keeps the bin runnable; users decide whether to fix the conflict.
|
|
89
|
+
*/
|
|
90
|
+
const warnOnCommandCollisions = (kernel) => {
|
|
91
|
+
var _a;
|
|
92
|
+
let commands;
|
|
93
|
+
try {
|
|
94
|
+
commands = kernel.container.resolveAll(ServiceDefinitionTagEnum.Command);
|
|
95
|
+
}
|
|
96
|
+
catch (_b) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const byName = new Map();
|
|
100
|
+
for (const command of commands) {
|
|
101
|
+
byName.set(command.name, ((_a = byName.get(command.name)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
102
|
+
}
|
|
103
|
+
for (const [name, count] of byName.entries()) {
|
|
104
|
+
if (count > 1) {
|
|
105
|
+
process.stderr.write(`[pristine] WARNING: command '${name}' is registered ${count} times. Only the first match will be dispatched.\n`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,2BAA2B,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAqB,wBAAwB,EAAC,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC;;;;;;;;;;;GA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