@pristine-ts/cli 1.0.440 → 2.0.1
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,315 @@
|
|
|
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 fs from "fs";
|
|
21
|
+
import path from "path";
|
|
22
|
+
import { pathToFileURL } from "url";
|
|
23
|
+
import { LoggingModuleKeyname, OutputModeEnum, SeverityEnum } from "@pristine-ts/logging";
|
|
24
|
+
import { DirectoryListResultEnum, DirectoryManager, FileManager, MatchTypeEnum, TypesEnum } from "@pristine-ts/file";
|
|
25
|
+
import { CliModule } from "../cli.module";
|
|
26
|
+
import { ConfigLoader } from "../config/config-loader";
|
|
27
|
+
import { BuildManifestChecker } from "./build-manifest-checker";
|
|
28
|
+
import { BuildManifestReader } from "./build-manifest-reader";
|
|
29
|
+
import { BuildManifestStalenessEnum } from "./build-manifest-staleness.enum";
|
|
30
|
+
import { BuildRunner } from "./build-runner";
|
|
31
|
+
import { BuildStalenessPrompt } from "./build-staleness-prompt";
|
|
32
|
+
import { DynamicImporter } from "./dynamic-importer";
|
|
33
|
+
import { LoadedAppModule } from "./loaded-app-module";
|
|
34
|
+
import { PluginLoader } from "./plugin-loader";
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the consumer's AppModule. The contract is intentionally narrow: there is
|
|
37
|
+
* exactly one supported way to specify the module — `appModule.sourcePath` +
|
|
38
|
+
* `appModule.outputPath` in `pristine.config.ts` (or `pristine.config.js`).
|
|
39
|
+
*
|
|
40
|
+
* Resolution path:
|
|
41
|
+
* 1. Read `pristine.config.{ts,js}` via `ConfigLoader`.
|
|
42
|
+
* 2. If `appModule` is configured: ensure the build is fresh (manifest check, prompt or
|
|
43
|
+
* fail on stale), then dynamically import the configured `outputPath`.
|
|
44
|
+
* 3. If anything above is missing or broken: fall back to a `CliModule`-only synthetic
|
|
45
|
+
* AppModule so built-in commands (notably `pristine init`) remain runnable. This is
|
|
46
|
+
* the only escape hatch — there is no convention scan, no package.json discovery,
|
|
47
|
+
* no cached prior selection.
|
|
48
|
+
*/
|
|
49
|
+
let AppModuleLoader = class AppModuleLoader {
|
|
50
|
+
constructor(configLoader, pluginLoader, dynamicImporter, buildManifestReader, buildManifestChecker, buildStalenessPrompt, buildRunner) {
|
|
51
|
+
this.configLoader = configLoader;
|
|
52
|
+
this.pluginLoader = pluginLoader;
|
|
53
|
+
this.dynamicImporter = dynamicImporter;
|
|
54
|
+
this.buildManifestReader = buildManifestReader;
|
|
55
|
+
this.buildManifestChecker = buildManifestChecker;
|
|
56
|
+
this.buildStalenessPrompt = buildStalenessPrompt;
|
|
57
|
+
this.buildRunner = buildRunner;
|
|
58
|
+
this.defaultExportName = "AppModule";
|
|
59
|
+
this.fallbackKeyname = "__auto_generated_app.module__";
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolves the consumer's AppModule and the kernel configuration the CLI should boot
|
|
63
|
+
* with. The flow has five stages, executed in order:
|
|
64
|
+
*
|
|
65
|
+
* 1. **Read the project's pristine.config.{ts,js}** — single source of truth for
|
|
66
|
+
* where the user's AppModule lives and what plugins to wire in.
|
|
67
|
+
* 2. **Check the compiled AppModule is in sync with its source** — when both
|
|
68
|
+
* `appModule.sourcePath` and `appModule.outputPath` are configured, compare the
|
|
69
|
+
* build manifest's recorded source hash against the current source. If they
|
|
70
|
+
* diverge (the user edited source but didn't rebuild), prompt to rebuild in an
|
|
71
|
+
* interactive terminal, or fail with an actionable error in CI / non-interactive
|
|
72
|
+
* contexts.
|
|
73
|
+
* 3. **Dynamically import the compiled AppModule** — load the JS file at
|
|
74
|
+
* `outputPath` and pull out the configured named export (default `AppModule`).
|
|
75
|
+
* 4. **Substitute a CliModule-only AppModule when nothing else worked** — when
|
|
76
|
+
* there is no config file, no `appModule` block in the config, or the import
|
|
77
|
+
* threw, build a synthetic AppModule that imports just CliModule. This keeps the
|
|
78
|
+
* bin runnable so the user can run `pristine init`, `pristine help`, etc. to
|
|
79
|
+
* recover. There is no convention scan, no package.json discovery — only this
|
|
80
|
+
* one escape hatch.
|
|
81
|
+
* 5. **Wrap with config-declared plugins** — load every plugin listed in the
|
|
82
|
+
* config's `plugins` array and merge their modules into the AppModule's import
|
|
83
|
+
* graph via a synthetic outer module.
|
|
84
|
+
*
|
|
85
|
+
* Final output: a `LoadedAppModule` carrying the (possibly wrapped) AppModule, the
|
|
86
|
+
* kernel configuration overlay, the logging-module-present flag, and the loaded
|
|
87
|
+
* plugin list.
|
|
88
|
+
*/
|
|
89
|
+
load() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
const projectRoot = process.cwd();
|
|
93
|
+
let appModule;
|
|
94
|
+
let isLoggingModulePresent = false;
|
|
95
|
+
let resolvedPath;
|
|
96
|
+
let appModuleExportName = this.defaultExportName;
|
|
97
|
+
// ── Stage 1: read the project's pristine.config.{ts,js}. ──
|
|
98
|
+
// Walks up from cwd looking for the config file; returns an empty config object
|
|
99
|
+
// when no file is found, which lets the substitute-AppModule branch in Stage 4
|
|
100
|
+
// take over instead of erroring out.
|
|
101
|
+
const resolvedConfig = yield this.configLoader.load({ startDir: projectRoot });
|
|
102
|
+
const appModuleConfig = resolvedConfig.config.appModule;
|
|
103
|
+
// Honor `appModule.export` for projects whose AppModule isn't named `AppModule`.
|
|
104
|
+
if ((appModuleConfig === null || appModuleConfig === void 0 ? void 0 : appModuleConfig.export) !== undefined) {
|
|
105
|
+
appModuleExportName = appModuleConfig.export;
|
|
106
|
+
}
|
|
107
|
+
// ── Stage 2: check the compiled AppModule is in sync with its source. ──
|
|
108
|
+
// Only runs when both sourcePath + outputPath are configured (the canonical setup).
|
|
109
|
+
// `ensureFreshBuild` returns false when the user declined to rebuild after a
|
|
110
|
+
// staleness prompt, or when we're non-interactive and stale. In either case we
|
|
111
|
+
// substitute the CliModule-only AppModule so commands like `pristine init` and
|
|
112
|
+
// `pristine help` still work.
|
|
113
|
+
if ((appModuleConfig === null || appModuleConfig === void 0 ? void 0 : appModuleConfig.sourcePath) !== undefined && (appModuleConfig === null || appModuleConfig === void 0 ? void 0 : appModuleConfig.outputPath) !== undefined) {
|
|
114
|
+
const ensured = yield this.ensureFreshBuild(projectRoot, appModuleConfig.sourcePath, appModuleConfig.outputPath);
|
|
115
|
+
if (ensured === false) {
|
|
116
|
+
const fallback = yield this.buildFallbackAppModule(projectRoot);
|
|
117
|
+
return new LoadedAppModule(fallback.appModule, this.buildKernelConfiguration(fallback.isLoggingModulePresent, resolvedConfig.config.kernelConfiguration), fallback.isLoggingModulePresent, []);
|
|
118
|
+
}
|
|
119
|
+
resolvedPath = path.resolve(projectRoot, appModuleConfig.outputPath);
|
|
120
|
+
}
|
|
121
|
+
// ── Stage 3: dynamically import the AppModule (or fall through to Stage 4). ──
|
|
122
|
+
if (resolvedPath !== undefined) {
|
|
123
|
+
// Stage 3: dynamic import. The compiled output is a regular JS module; we pull
|
|
124
|
+
// out the named export and detect LoggingModule presence so Stage 5 can decide
|
|
125
|
+
// whether to install the CLI's default console-logger configuration overlay.
|
|
126
|
+
try {
|
|
127
|
+
appModule = yield this.importAppModule(resolvedPath, appModuleExportName);
|
|
128
|
+
isLoggingModulePresent = ((_a = appModule.importModules) !== null && _a !== void 0 ? _a : []).find(m => m.keyname === LoggingModuleKeyname) !== undefined;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
// Stage 4 (the configured file is broken or missing): we don't crash — that
|
|
132
|
+
// would prevent `pristine init` from running and leave the user with no way to
|
|
133
|
+
// fix their config. Warn loudly, substitute the CliModule-only AppModule, and
|
|
134
|
+
// let the user re-run after fixing the issue.
|
|
135
|
+
process.stderr.write(`[pristine] Failed to load AppModule from '${resolvedPath}': ${error.message}\n` +
|
|
136
|
+
`[pristine] Falling back to built-in commands only. Fix your AppModule config and re-run.\n`);
|
|
137
|
+
const fallback = yield this.buildFallbackAppModule(projectRoot);
|
|
138
|
+
appModule = fallback.appModule;
|
|
139
|
+
isLoggingModulePresent = fallback.isLoggingModulePresent;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Stage 4 (no `appModule` block, or no config file at all): substitute the
|
|
144
|
+
// CliModule-only AppModule so the bin can still bootstrap the user's project.
|
|
145
|
+
// First-run case (`pristine init` from a fresh project) lands here.
|
|
146
|
+
const fallback = yield this.buildFallbackAppModule(projectRoot);
|
|
147
|
+
appModule = fallback.appModule;
|
|
148
|
+
isLoggingModulePresent = fallback.isLoggingModulePresent;
|
|
149
|
+
}
|
|
150
|
+
// ── Stage 5: wrap with config-declared plugins. ──
|
|
151
|
+
// Plugins declared in `pristine.config.ts` contribute additional modules (e.g.
|
|
152
|
+
// tooling-only modules the user doesn't want polluting their runtime AppModule).
|
|
153
|
+
// A failing plugin warns but doesn't abort — the bin stays usable so the user can
|
|
154
|
+
// fix the offending entry.
|
|
155
|
+
let plugins = [];
|
|
156
|
+
try {
|
|
157
|
+
plugins = yield this.pluginLoader.load(resolvedConfig.config, resolvedConfig.configFilePath, projectRoot);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
process.stderr.write(`${error.message}\n`);
|
|
161
|
+
process.stderr.write("[pristine] Continuing without plugins. Fix the plugin config and re-run.\n");
|
|
162
|
+
}
|
|
163
|
+
if (plugins.length > 0) {
|
|
164
|
+
// Wrap the AppModule with a synthetic outer module that imports both the user's
|
|
165
|
+
// module and every plugin. Re-detect logging because a plugin could have brought
|
|
166
|
+
// it in.
|
|
167
|
+
appModule = this.pluginLoader.wrap(appModule, plugins);
|
|
168
|
+
if (isLoggingModulePresent === false) {
|
|
169
|
+
isLoggingModulePresent = ((_b = appModule.importModules) !== null && _b !== void 0 ? _b : []).find(m => m.keyname === LoggingModuleKeyname) !== undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// ── Final: assemble the kernel configuration overlay and return. ──
|
|
173
|
+
// The CLI installs sensible defaults for LoggingModule (simple output mode,
|
|
174
|
+
// error-level threshold) when LoggingModule is present, then layers the user's
|
|
175
|
+
// `kernelConfiguration` on top so they can override anything they want.
|
|
176
|
+
const configuration = this.buildKernelConfiguration(isLoggingModulePresent, resolvedConfig.config.kernelConfiguration);
|
|
177
|
+
return new LoadedAppModule(appModule, configuration, isLoggingModulePresent, plugins);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Manifest gate. Checks whether the build manifest still describes the current source/output
|
|
182
|
+
* paths and source content. If not, prompts the user (TTY) or fails (non-TTY) with a clear
|
|
183
|
+
* explanation. On a successful inline rebuild, returns true.
|
|
184
|
+
*
|
|
185
|
+
* Returns true when the build is fresh or just got rebuilt; false when the user declined to
|
|
186
|
+
* rebuild or when non-TTY hit a stale state. Callers should treat false as "stop the load".
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
ensureFreshBuild(projectRoot, sourcePath, outputPath) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const manifest = this.buildManifestReader.read(projectRoot);
|
|
192
|
+
const staleness = this.buildManifestChecker.check(manifest, projectRoot, sourcePath, outputPath);
|
|
193
|
+
if (staleness === BuildManifestStalenessEnum.Fresh) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
// No manifest on disk → user is building with their own pipeline (raw `tsc`, esbuild,
|
|
197
|
+
// a CI step, etc.) and never invoking `pristine build`. The manifest's purpose is to
|
|
198
|
+
// detect drift between source and a Pristine-managed build; with no manifest there is
|
|
199
|
+
// nothing to compare against, so we skip the gate. We still require the configured
|
|
200
|
+
// `outputPath` to exist — otherwise there's nothing to load.
|
|
201
|
+
if (staleness === BuildManifestStalenessEnum.Missing) {
|
|
202
|
+
const absoluteOutput = path.resolve(projectRoot, outputPath);
|
|
203
|
+
if (fs.existsSync(absoluteOutput)) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
// Fall through to the "stale" path below — the output is genuinely missing,
|
|
207
|
+
// which the prompt/non-TTY branches handle with the right error message.
|
|
208
|
+
}
|
|
209
|
+
const explanation = this.buildStalenessPrompt.describe(staleness);
|
|
210
|
+
if (this.buildStalenessPrompt.isInteractive() === false) {
|
|
211
|
+
process.stderr.write(`[pristine] ${explanation}\n`);
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const shouldRebuild = yield this.buildStalenessPrompt.prompt(staleness);
|
|
215
|
+
if (shouldRebuild !== true) {
|
|
216
|
+
process.stderr.write(`[pristine] ${explanation}\n`);
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
process.stderr.write(`[pristine] Rebuilding...\n`);
|
|
220
|
+
const buildSucceeded = this.buildRunner.run();
|
|
221
|
+
if (buildSucceeded === false) {
|
|
222
|
+
process.stderr.write(`[pristine] Rebuild failed. Fix the build error and re-run.\n`);
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
// After a successful rebuild, re-check that the manifest now passes — guards against the
|
|
226
|
+
// edge case where `pristine build` ran but, for whatever reason (unconfigured paths,
|
|
227
|
+
// tsconfig mismatch), didn't write a fresh manifest.
|
|
228
|
+
const reReadManifest = this.buildManifestReader.read(projectRoot);
|
|
229
|
+
const recheckStaleness = this.buildManifestChecker.check(reReadManifest, projectRoot, sourcePath, outputPath);
|
|
230
|
+
if (recheckStaleness !== BuildManifestStalenessEnum.Fresh) {
|
|
231
|
+
process.stderr.write(`[pristine] Build ran but manifest is still stale: ${this.buildStalenessPrompt.describe(recheckStaleness)}\n`);
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
importAppModule(absolutePath, exportName) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
const url = pathToFileURL(absolutePath).href;
|
|
240
|
+
const loaded = yield this.dynamicImporter.import(url);
|
|
241
|
+
if (!loaded || !loaded[exportName]) {
|
|
242
|
+
throw new Error(`[pristine] The file at '${absolutePath}' was loaded but did not export '${exportName}'. ` +
|
|
243
|
+
`Make sure your AppModule file does \`export const ${exportName}: AppModuleInterface = { ... }\`.`);
|
|
244
|
+
}
|
|
245
|
+
return loaded[exportName];
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Builds the safety-net AppModule used when no `appModule` is configured or the configured
|
|
250
|
+
* file fails to load. Scrapes any `node_modules/@pristine-ts/*` packages already installed
|
|
251
|
+
* so built-in commands they contribute (e.g. `pristine list`) are still available, then
|
|
252
|
+
* appends `CliModule` so at minimum the CLI's own commands run. This is intentionally a
|
|
253
|
+
* one-way safety net, not a discovery tier — it only fires when nothing else worked.
|
|
254
|
+
*/
|
|
255
|
+
buildFallbackAppModule(projectRoot) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
const pristineNodeModulesPath = path.resolve(projectRoot, "node_modules", "@pristine-ts");
|
|
258
|
+
const modules = [];
|
|
259
|
+
let isLoggingModulePresent = false;
|
|
260
|
+
if (fs.existsSync(pristineNodeModulesPath)) {
|
|
261
|
+
const directoryManager = new DirectoryManager(new FileManager());
|
|
262
|
+
const moduleFiles = yield directoryManager.list(pristineNodeModulesPath, {
|
|
263
|
+
matchType: MatchTypeEnum.Path,
|
|
264
|
+
match: /.*\/cjs\/.*\.module\.js$/,
|
|
265
|
+
types: TypesEnum.File,
|
|
266
|
+
resultType: DirectoryListResultEnum.FilePath,
|
|
267
|
+
recurse: true,
|
|
268
|
+
});
|
|
269
|
+
for (const moduleFile of moduleFiles) {
|
|
270
|
+
const module = yield this.dynamicImporter.import(pathToFileURL(moduleFile).href);
|
|
271
|
+
for (const key in module) {
|
|
272
|
+
if (key === "LoggingModule")
|
|
273
|
+
isLoggingModulePresent = true;
|
|
274
|
+
if (key.endsWith("Module"))
|
|
275
|
+
modules.push(module[key]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (modules.length === 0) {
|
|
280
|
+
modules.push(CliModule);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
appModule: {
|
|
284
|
+
keyname: this.fallbackKeyname,
|
|
285
|
+
importModules: modules,
|
|
286
|
+
importServices: [],
|
|
287
|
+
},
|
|
288
|
+
isLoggingModulePresent,
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
buildKernelConfiguration(isLoggingModulePresent, userKernelConfiguration) {
|
|
293
|
+
const configuration = {};
|
|
294
|
+
if (isLoggingModulePresent) {
|
|
295
|
+
configuration[LoggingModuleKeyname + ".consoleLoggerOutputMode"] = OutputModeEnum.Simple;
|
|
296
|
+
configuration[LoggingModuleKeyname + ".logSeverityLevelConfiguration"] = SeverityEnum.Error;
|
|
297
|
+
}
|
|
298
|
+
if (userKernelConfiguration !== undefined) {
|
|
299
|
+
Object.assign(configuration, userKernelConfiguration);
|
|
300
|
+
}
|
|
301
|
+
return configuration;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
AppModuleLoader = __decorate([
|
|
305
|
+
injectable(),
|
|
306
|
+
__metadata("design:paramtypes", [ConfigLoader,
|
|
307
|
+
PluginLoader,
|
|
308
|
+
DynamicImporter,
|
|
309
|
+
BuildManifestReader,
|
|
310
|
+
BuildManifestChecker,
|
|
311
|
+
BuildStalenessPrompt,
|
|
312
|
+
BuildRunner])
|
|
313
|
+
], AppModuleLoader);
|
|
314
|
+
export { AppModuleLoader };
|
|
315
|
+
//# sourceMappingURL=app-module-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module-loader.js","sourceR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,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;YAED,OAAO;gBACL,SAAS,EAAE;oBACT,OAAO,EAAE,IAAI,CAAC,eAAe;oBAC7B,aAAa,EAAE,OAAO;oBACtB,cAAc,EAAE,EAAE;iBACnB;gBACD,sBAAsB;aACvB,CAAC;QACJ,CAAC;KAAA;IAEO,wBAAwB,CAAC,sBAA+B,EAAE,uBAA4D;QAC5H,MAAM,aAAa,GAAgD,EAAE,CAAC;QAEtE,IAAI,sBAAsB,EAAE,CAAC;YAC3B,aAAa,CAAC,oBAAoB,GAAG,0BAA0B,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC;YACzF,aAAa,CAAC,oBAAoB,GAAG,gCAAgC,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC;QAC9F,CAAC;QAED,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAA;AAzRY,eAAe;IAD3B,UAAU,EAAE;qCAMsB,YAAY;QACZ,YAAY;QACT,eAAe;QACX,mBAAmB;QAClB,oBAAoB;QACpB,oBAAoB;QAC7B,WAAW;GAXhC,eAAe,CAyR3B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./app-module-loader";
|
|
2
|
+
export * from "./build-manifest";
|
|
3
|
+
export * from "./build-manifest-checker";
|
|
4
|
+
export * from "./build-manifest-reader";
|
|
5
|
+
export * from "./build-manifest-staleness.enum";
|
|
6
|
+
export * from "./build-manifest-writer";
|
|
7
|
+
export * from "./build-runner";
|
|
8
|
+
export * from "./build-staleness-prompt";
|
|
9
|
+
export * from "./dynamic-importer";
|
|
10
|
+
export * from "./init-prompt";
|
|
11
|
+
export * from "./loaded-app-module";
|
|
12
|
+
export * from "./loaded-plugin";
|
|
13
|
+
export * from "./plugin-loader";
|
|
14
|
+
export * from "./source-hasher";
|
|
15
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
import { injectable } from "tsyringe";
|
|
11
|
+
import fs from "fs";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import { BuildManifestStalenessEnum } from "./build-manifest-staleness.enum";
|
|
14
|
+
import { SourceHasher } from "./source-hasher";
|
|
15
|
+
/**
|
|
16
|
+
* Decides whether an existing `BuildManifest` still describes the current state of the
|
|
17
|
+
* project. Compares the manifest's stored paths/hash against the live config + source file
|
|
18
|
+
* + filesystem. Returns the most-specific reason the manifest is stale so the caller can
|
|
19
|
+
* render a helpful message ("source changed", "output missing", etc.) rather than a vague
|
|
20
|
+
* "stale".
|
|
21
|
+
*
|
|
22
|
+
* Order of checks matches user impact: things that mean "you definitely need to rebuild"
|
|
23
|
+
* (output missing, source content changed) come before path drift (config edited but build
|
|
24
|
+
* not yet rerun) — both are correct to flag, but the messaging differs.
|
|
25
|
+
*/
|
|
26
|
+
let BuildManifestChecker = class BuildManifestChecker {
|
|
27
|
+
constructor(sourceHasher) {
|
|
28
|
+
this.sourceHasher = sourceHasher;
|
|
29
|
+
}
|
|
30
|
+
check(manifest, projectRoot, configuredSourcePath, configuredOutputPath) {
|
|
31
|
+
if (manifest === undefined) {
|
|
32
|
+
return BuildManifestStalenessEnum.Missing;
|
|
33
|
+
}
|
|
34
|
+
const absoluteConfiguredSource = path.resolve(projectRoot, configuredSourcePath);
|
|
35
|
+
const absoluteConfiguredOutput = path.resolve(projectRoot, configuredOutputPath);
|
|
36
|
+
if (manifest.appModuleSourcePath !== absoluteConfiguredSource) {
|
|
37
|
+
return BuildManifestStalenessEnum.SourcePathChanged;
|
|
38
|
+
}
|
|
39
|
+
if (manifest.appModuleOutputPath !== absoluteConfiguredOutput) {
|
|
40
|
+
return BuildManifestStalenessEnum.OutputPathChanged;
|
|
41
|
+
}
|
|
42
|
+
if (fs.existsSync(manifest.appModuleOutputPath) === false) {
|
|
43
|
+
return BuildManifestStalenessEnum.OutputMissing;
|
|
44
|
+
}
|
|
45
|
+
if (fs.existsSync(manifest.appModuleSourcePath) === false) {
|
|
46
|
+
// Source vanished — report as content-changed since "missing" is the extreme form.
|
|
47
|
+
return BuildManifestStalenessEnum.SourceContentChanged;
|
|
48
|
+
}
|
|
49
|
+
const currentHash = this.sourceHasher.hashFile(manifest.appModuleSourcePath);
|
|
50
|
+
if (currentHash !== manifest.sourceHash) {
|
|
51
|
+
return BuildManifestStalenessEnum.SourceContentChanged;
|
|
52
|
+
}
|
|
53
|
+
return BuildManifestStalenessEnum.Fresh;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
BuildManifestChecker = __decorate([
|
|
57
|
+
injectable(),
|
|
58
|
+
__metadata("design:paramtypes", [SourceHasher])
|
|
59
|
+
], BuildManifestChecker);
|
|
60
|
+
export { BuildManifestChecker };
|
|
61
|
+
//# sourceMappingURL=build-manifest-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-manifest-checker.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-manifest-checker.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,0BAA0B,EAAC,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;GAUG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IACvD,CAAC;IAED,KAAK,CACH,QAAmC,EACnC,WAAmB,EACnB,oBAA4B,EAC5B,oBAA4B;QAE5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,0BAA0B,CAAC,OAAO,CAAC;QAC5C,CAAC;QAED,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QACjF,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QAEjF,IAAI,QAAQ,CAAC,mBAAmB,KAAK,wBAAwB,EAAE,CAAC;YAC9D,OAAO,0BAA0B,CAAC,iBAAiB,CAAC;QACtD,CAAC;QAED,IAAI,QAAQ,CAAC,mBAAmB,KAAK,wBAAwB,EAAE,CAAC;YAC9D,OAAO,0BAA0B,CAAC,iBAAiB,CAAC;QACtD,CAAC;QAED,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,KAAK,EAAE,CAAC;YAC1D,OAAO,0BAA0B,CAAC,aAAa,CAAC;QAClD,CAAC;QAED,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,KAAK,EAAE,CAAC;YAC1D,mFAAmF;YACnF,OAAO,0BAA0B,CAAC,oBAAoB,CAAC;QACzD,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC7E,IAAI,WAAW,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;YACxC,OAAO,0BAA0B,CAAC,oBAAoB,CAAC;QACzD,CAAC;QAED,OAAO,0BAA0B,CAAC,KAAK,CAAC;IAC1C,CAAC;CACF,CAAA;AAzCY,oBAAoB;IADhC,UAAU,EAAE;qCAEgC,YAAY;GAD5C,oBAAoB,CAyChC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 fs from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { BuildManifest } from "./build-manifest";
|
|
11
|
+
/**
|
|
12
|
+
* Reads `<projectRoot>/.pristine/build-manifest.json` if present and returns a `BuildManifest`
|
|
13
|
+
* instance. Used by `AppModuleLoader` and `BuildManifestChecker` to inspect the last build.
|
|
14
|
+
*
|
|
15
|
+
* Returns `undefined` (not throws) when the manifest is missing — that's a normal state for
|
|
16
|
+
* fresh projects that haven't run `pristine build` yet. Genuine errors (corrupt JSON, IO
|
|
17
|
+
* failure) do throw, since silently treating those as "no manifest" would mask real problems.
|
|
18
|
+
*/
|
|
19
|
+
let BuildManifestReader = class BuildManifestReader {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.cacheDirName = ".pristine";
|
|
22
|
+
this.manifestFileName = "build-manifest.json";
|
|
23
|
+
}
|
|
24
|
+
read(projectRoot) {
|
|
25
|
+
const manifestPath = path.resolve(projectRoot, this.cacheDirName, this.manifestFileName);
|
|
26
|
+
if (fs.existsSync(manifestPath) === false) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
30
|
+
const parsed = JSON.parse(raw);
|
|
31
|
+
return new BuildManifest(parsed.appModuleSourcePath, parsed.appModuleOutputPath, parsed.sourceHash, parsed.builtAt);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
BuildManifestReader = __decorate([
|
|
35
|
+
injectable()
|
|
36
|
+
], BuildManifestReader);
|
|
37
|
+
export { BuildManifestReader };
|
|
38
|
+
//# sourceMappingURL=build-manifest-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-manifest-reader.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-manifest-reader.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;GAOG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QACY,iBAAY,GAAW,WAAW,CAAC;QACnC,qBAAgB,GAAW,qBAAqB,CAAC;IAkBpE,CAAC;IAhBC,IAAI,CAAC,WAAmB;QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzF,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE,CAAC;YAC1C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,OAAO,IAAI,aAAa,CACtB,MAAM,CAAC,mBAAmB,EAC1B,MAAM,CAAC,mBAAmB,EAC1B,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,OAAO,CACf,CAAC;IACJ,CAAC;CACF,CAAA;AApBY,mBAAmB;IAD/B,UAAU,EAAE;GACA,mBAAmB,CAoB/B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a build manifest is no longer trustworthy. Returned by `BuildManifestChecker` so the
|
|
3
|
+
* caller can render an error message specific to the actual cause rather than a vague "stale".
|
|
4
|
+
*/
|
|
5
|
+
export var BuildManifestStalenessEnum;
|
|
6
|
+
(function (BuildManifestStalenessEnum) {
|
|
7
|
+
/** Manifest is current — the build output matches what the config + source describe. */
|
|
8
|
+
BuildManifestStalenessEnum["Fresh"] = "fresh";
|
|
9
|
+
/** No manifest file on disk. The user hasn't run `pristine build` yet (or deleted the cache). */
|
|
10
|
+
BuildManifestStalenessEnum["Missing"] = "missing";
|
|
11
|
+
/** The configured `sourcePath` no longer matches the path stored in the manifest. */
|
|
12
|
+
BuildManifestStalenessEnum["SourcePathChanged"] = "source-path-changed";
|
|
13
|
+
/** The configured `outputPath` no longer matches the path stored in the manifest. */
|
|
14
|
+
BuildManifestStalenessEnum["OutputPathChanged"] = "output-path-changed";
|
|
15
|
+
/** The source file's content hash no longer matches what was hashed at build time. */
|
|
16
|
+
BuildManifestStalenessEnum["SourceContentChanged"] = "source-content-changed";
|
|
17
|
+
/** The compiled output file referenced by the manifest is missing from disk. */
|
|
18
|
+
BuildManifestStalenessEnum["OutputMissing"] = "output-missing";
|
|
19
|
+
})(BuildManifestStalenessEnum || (BuildManifestStalenessEnum = {}));
|
|
20
|
+
//# sourceMappingURL=build-manifest-staleness.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-manifest-staleness.enum.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-manifest-staleness.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,0BAaX;AAbD,WAAY,0BAA0B;IACpC,wFAAwF;IACxF,6CAAe,CAAA;IACf,iGAAiG;IACjG,iDAAmB,CAAA;IACnB,qFAAqF;IACrF,uEAAyC,CAAA;IACzC,qFAAqF;IACrF,uEAAyC,CAAA;IACzC,sFAAsF;IACtF,6EAA+C,CAAA;IAC/C,gFAAgF;IAChF,8DAAgC,CAAA;AAClC,CAAC,EAbW,0BAA0B,KAA1B,0BAA0B,QAarC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import { injectable } from "tsyringe";
|
|
11
|
+
import fs from "fs";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import { BuildManifest } from "./build-manifest";
|
|
14
|
+
import { SourceHasher } from "./source-hasher";
|
|
15
|
+
/**
|
|
16
|
+
* Writes the build manifest to `<projectRoot>/.pristine/build-manifest.json` atomically
|
|
17
|
+
* (write-then-rename) so a partial write can never poison subsequent reads. Used by
|
|
18
|
+
* `BuildCommand` after a successful compile.
|
|
19
|
+
*
|
|
20
|
+
* Atomicity matters: if `pristine build` is interrupted (Ctrl+C, OOM kill) mid-write, a
|
|
21
|
+
* half-written JSON file would make the next `pristine start` think the build was good but
|
|
22
|
+
* fail to parse the manifest. Renaming after a complete write ensures readers either see
|
|
23
|
+
* the previous manifest or the new one — never a torn one.
|
|
24
|
+
*/
|
|
25
|
+
let BuildManifestWriter = class BuildManifestWriter {
|
|
26
|
+
constructor(sourceHasher) {
|
|
27
|
+
this.sourceHasher = sourceHasher;
|
|
28
|
+
this.cacheDirName = ".pristine";
|
|
29
|
+
this.manifestFileName = "build-manifest.json";
|
|
30
|
+
}
|
|
31
|
+
write(projectRoot, sourcePath, outputPath) {
|
|
32
|
+
const absoluteSource = path.resolve(projectRoot, sourcePath);
|
|
33
|
+
const absoluteOutput = path.resolve(projectRoot, outputPath);
|
|
34
|
+
const manifest = new BuildManifest(absoluteSource, absoluteOutput, this.sourceHasher.hashFile(absoluteSource), new Date().toISOString());
|
|
35
|
+
const cacheDir = path.resolve(projectRoot, this.cacheDirName);
|
|
36
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
37
|
+
const finalPath = path.resolve(cacheDir, this.manifestFileName);
|
|
38
|
+
const tempPath = finalPath + ".tmp";
|
|
39
|
+
fs.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
|
|
40
|
+
fs.renameSync(tempPath, finalPath);
|
|
41
|
+
return manifest;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
BuildManifestWriter = __decorate([
|
|
45
|
+
injectable(),
|
|
46
|
+
__metadata("design:paramtypes", [SourceHasher])
|
|
47
|
+
], BuildManifestWriter);
|
|
48
|
+
export { BuildManifestWriter };
|
|
49
|
+
//# sourceMappingURL=build-manifest-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-manifest-writer.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-manifest-writer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;GASG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAI9B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;QAHtC,iBAAY,GAAW,WAAW,CAAC;QACnC,qBAAgB,GAAW,qBAAqB,CAAC;IAGlE,CAAC;IAED,KAAK,CAAC,WAAmB,EAAE,UAAkB,EAAE,UAAkB;QAC/D,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC7D,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAE7D,MAAM,QAAQ,GAAG,IAAI,aAAa,CAChC,cAAc,EACd,cAAc,EACd,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,EAC1C,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CACzB,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9D,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QAE1C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;QACpC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACtE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAEnC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AA5BY,mBAAmB;IAD/B,UAAU,EAAE;qCAKgC,YAAY;GAJ5C,mBAAmB,CA4B/B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-disk record of what `pristine build` produced. Written atomically at the end of a
|
|
3
|
+
* successful build to `.pristine/build-manifest.json`. Read by every downstream command that
|
|
4
|
+
* loads the AppModule (`pristine start`, `pristine verify`, etc.) so the loader can detect
|
|
5
|
+
* staleness — source file changed, config changed, output file missing — without scanning
|
|
6
|
+
* the filesystem.
|
|
7
|
+
*
|
|
8
|
+
* Plain class (no DI / no methods) because manifests serialize to/from JSON and the simpler
|
|
9
|
+
* the shape is, the harder it is to break the on-disk contract by accident.
|
|
10
|
+
*/
|
|
11
|
+
export class BuildManifest {
|
|
12
|
+
constructor(
|
|
13
|
+
/** Absolute path to the AppModule source file as it was at build time. */
|
|
14
|
+
appModuleSourcePath,
|
|
15
|
+
/** Absolute path to the compiled AppModule output file as it was at build time. */
|
|
16
|
+
appModuleOutputPath,
|
|
17
|
+
/** SHA-256 of the source file contents at build time. Drives staleness detection. */
|
|
18
|
+
sourceHash,
|
|
19
|
+
/** ISO-8601 timestamp of when the build completed. */
|
|
20
|
+
builtAt) {
|
|
21
|
+
this.appModuleSourcePath = appModuleSourcePath;
|
|
22
|
+
this.appModuleOutputPath = appModuleOutputPath;
|
|
23
|
+
this.sourceHash = sourceHash;
|
|
24
|
+
this.builtAt = builtAt;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=build-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-manifest.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IACxB;IACE,0EAA0E;IAC1D,mBAA2B;IAC3C,mFAAmF;IACnE,mBAA2B;IAC3C,qFAAqF;IACrE,UAAkB;IAClC,sDAAsD;IACtC,OAAe;QANf,wBAAmB,GAAnB,mBAAmB,CAAQ;QAE3B,wBAAmB,GAAnB,mBAAmB,CAAQ;QAE3B,eAAU,GAAV,UAAU,CAAQ;QAElB,YAAO,GAAP,OAAO,CAAQ;IAEjC,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { spawnSync } from "child_process";
|
|
9
|
+
/**
|
|
10
|
+
* Runs `pristine p:build` as a subprocess of the currently-running bin. Used by
|
|
11
|
+
* `AppModuleLoader` when the user accepts the "rebuild now?" prompt — re-running the build
|
|
12
|
+
* inline avoids the awkward "exit, ask the user to type a command, re-enter" loop.
|
|
13
|
+
*
|
|
14
|
+
* Spawning rather than dispatching to `BuildCommand` directly keeps `AppModuleLoader` free
|
|
15
|
+
* of the build pipeline's dependency graph (ConsoleManager, ShellManager, etc.) which only
|
|
16
|
+
* exists in the kernel container — and the kernel hasn't booted yet at the point this is
|
|
17
|
+
* called. The subprocess re-bootstraps the kernel cleanly with all of those services.
|
|
18
|
+
*
|
|
19
|
+
* Returns `true` on a successful build (exit code 0), `false` on any failure or signal.
|
|
20
|
+
*/
|
|
21
|
+
let BuildRunner = class BuildRunner {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.buildCommandName = "p:build";
|
|
24
|
+
}
|
|
25
|
+
run() {
|
|
26
|
+
// process.argv[1] is the absolute path to the running bin file (set by Node when the
|
|
27
|
+
// bin was invoked). Re-spawning the same bin guarantees we use the exact same CLI
|
|
28
|
+
// version + setup the user is currently running against — no risk of resolving a
|
|
29
|
+
// different `pristine` from PATH that doesn't match this process's expectations.
|
|
30
|
+
const result = spawnSync(process.execPath, [process.argv[1], this.buildCommandName], {
|
|
31
|
+
stdio: "inherit",
|
|
32
|
+
cwd: process.cwd(),
|
|
33
|
+
});
|
|
34
|
+
return result.status === 0;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
BuildRunner = __decorate([
|
|
38
|
+
injectable()
|
|
39
|
+
], BuildRunner);
|
|
40
|
+
export { BuildRunner };
|
|
41
|
+
//# sourceMappingURL=build-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-runner.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-runner.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC;;;;;;;;;;;GAWG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAAjB;QACY,qBAAgB,GAAW,SAAS,CAAC;IAcxD,CAAC;IAZC,GAAG;QACD,qFAAqF;QACrF,kFAAkF;QAClF,iFAAiF;QACjF,iFAAiF;QACjF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE;YACnF,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;SACnB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AAfY,WAAW;IADvB,UAAU,EAAE;GACA,WAAW,CAevB"}
|