@pristine-ts/configuration 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/cjs/configuration.module.js +1 -0
- package/dist/lib/cjs/configuration.module.js.map +1 -1
- package/dist/lib/cjs/errors/configuration-definition-already-exists.error.js +2 -6
- package/dist/lib/cjs/errors/configuration-definition-already-exists.error.js.map +1 -1
- package/dist/lib/cjs/errors/configuration-resolver.error.js +5 -9
- package/dist/lib/cjs/errors/configuration-resolver.error.js.map +1 -1
- package/dist/lib/cjs/errors/configuration-validation.error.js +1 -5
- package/dist/lib/cjs/errors/configuration-validation.error.js.map +1 -1
- package/dist/lib/cjs/loaders/loaders.js +19 -0
- package/dist/lib/cjs/loaders/loaders.js.map +1 -0
- package/dist/lib/cjs/loaders/pristine-config-file.interface.js +3 -0
- package/dist/lib/cjs/loaders/pristine-config-file.interface.js.map +1 -0
- package/dist/lib/cjs/loaders/pristine-config-file.loader.js +130 -0
- package/dist/lib/cjs/loaders/pristine-config-file.loader.js.map +1 -0
- package/dist/lib/cjs/managers/configuration.manager.js +82 -14
- package/dist/lib/cjs/managers/configuration.manager.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/esm/configuration.module.js +1 -0
- package/dist/lib/esm/configuration.module.js.map +1 -1
- package/dist/lib/esm/errors/configuration-definition-already-exists.error.js +3 -7
- package/dist/lib/esm/errors/configuration-definition-already-exists.error.js.map +1 -1
- package/dist/lib/esm/errors/configuration-resolver.error.js +6 -10
- package/dist/lib/esm/errors/configuration-resolver.error.js.map +1 -1
- package/dist/lib/esm/errors/configuration-validation.error.js +2 -6
- package/dist/lib/esm/errors/configuration-validation.error.js.map +1 -1
- package/dist/lib/esm/loaders/loaders.js +3 -0
- package/dist/lib/esm/loaders/loaders.js.map +1 -0
- package/dist/lib/esm/loaders/pristine-config-file.interface.js +2 -0
- package/dist/lib/esm/loaders/pristine-config-file.interface.js.map +1 -0
- package/dist/lib/esm/loaders/pristine-config-file.loader.js +124 -0
- package/dist/lib/esm/loaders/pristine-config-file.loader.js.map +1 -0
- package/dist/lib/esm/managers/configuration.manager.js +82 -14
- package/dist/lib/esm/managers/configuration.manager.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/configuration.module.d.ts +1 -0
- package/dist/types/errors/configuration-definition-already-exists.error.d.ts +2 -2
- package/dist/types/errors/configuration-resolver.error.d.ts +2 -2
- package/dist/types/errors/configuration-validation.error.d.ts +2 -2
- package/dist/types/loaders/loaders.d.ts +2 -0
- package/dist/types/loaders/pristine-config-file.interface.d.ts +15 -0
- package/dist/types/loaders/pristine-config-file.loader.d.ts +47 -0
- package/dist/types/managers/configuration.manager.d.ts +34 -8
- package/package.json +3 -3
|
@@ -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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
import { injectable } from "tsyringe";
|
|
17
|
+
import fs from "fs";
|
|
18
|
+
import path from "path";
|
|
19
|
+
/**
|
|
20
|
+
* Locates and dynamically imports `pristine.config.{ts,js}`. Lives in
|
|
21
|
+
* `@pristine-ts/configuration` so both the configuration manager (reads the `config:`
|
|
22
|
+
* block during kernel boot) and the CLI bootstrap (reads the `cli:` block before the
|
|
23
|
+
* kernel exists) share one walker, one importer, and one cache — avoiding drift between
|
|
24
|
+
* two separate readers seeing different files.
|
|
25
|
+
*
|
|
26
|
+
* **Memoized per absolute path**: once a config file is found at a given path, the
|
|
27
|
+
* parsed object is cached for the process lifetime. Repeated calls from different parts
|
|
28
|
+
* of the codebase (configuration manager, CLI bootstrap, plugin loader) parse the file
|
|
29
|
+
* exactly once.
|
|
30
|
+
*
|
|
31
|
+
* **Optional**: if no file is found, `load()` returns `undefined`. Callers degrade
|
|
32
|
+
* gracefully — the configuration manager falls back to its other resolution sources, the
|
|
33
|
+
* CLI falls back to a `CliModule`-only AppModule.
|
|
34
|
+
*/
|
|
35
|
+
let PristineConfigFileLoader = class PristineConfigFileLoader {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.configFileNames = [
|
|
38
|
+
"pristine.config.ts",
|
|
39
|
+
"pristine.config.js",
|
|
40
|
+
];
|
|
41
|
+
this.cache = new Map();
|
|
42
|
+
/**
|
|
43
|
+
* Wraps Node's real dynamic `import()` so it survives both tsc's CJS lowering and
|
|
44
|
+
* esbuild's bundling. Both otherwise rewrite `await import(x)` into `require(x)`, which
|
|
45
|
+
* fails for ESM-only packages and `file://` URLs. The Function constructor's body is
|
|
46
|
+
* opaque to those transforms, so the `import()` inside it goes through unrewritten.
|
|
47
|
+
*/
|
|
48
|
+
this.dynamicImport = new Function("specifier", "return import(specifier);");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Finds the nearest `pristine.config.{ts,js}` walking up from `startDir` (defaults to
|
|
52
|
+
* `process.cwd()`), dynamic-imports it, and returns the parsed object. Returns
|
|
53
|
+
* `undefined` when no file is found anywhere up the directory tree — callers must
|
|
54
|
+
* treat absence as "no overrides," not as an error.
|
|
55
|
+
*/
|
|
56
|
+
load() {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function* (startDir = process.cwd()) {
|
|
58
|
+
const filePath = this.findConfigFile(startDir);
|
|
59
|
+
if (filePath === undefined) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const cached = this.cache.get(filePath);
|
|
63
|
+
if (cached !== undefined) {
|
|
64
|
+
return cached;
|
|
65
|
+
}
|
|
66
|
+
const parsed = yield this.importConfigFile(filePath);
|
|
67
|
+
this.cache.set(filePath, parsed);
|
|
68
|
+
return parsed;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Walks up from `startDir` looking for any of the supported config file names. Stops at
|
|
73
|
+
* the first match. Walking up matters in monorepos: a tool invoked in `packages/foo/`
|
|
74
|
+
* should still find a `pristine.config.ts` at the repo root.
|
|
75
|
+
*/
|
|
76
|
+
findConfigFile(startDir) {
|
|
77
|
+
let current = path.resolve(startDir);
|
|
78
|
+
while (true) {
|
|
79
|
+
for (const name of this.configFileNames) {
|
|
80
|
+
const candidate = path.join(current, name);
|
|
81
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
|
|
82
|
+
return candidate;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const parent = path.dirname(current);
|
|
86
|
+
// path.dirname of root === root; we've hit the filesystem boundary.
|
|
87
|
+
if (parent === current)
|
|
88
|
+
return undefined;
|
|
89
|
+
current = parent;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Loads the config file via the appropriate mechanism for its extension: jiti for `.ts`
|
|
94
|
+
* (in-process TS transform with no build step needed), native dynamic import for `.js`.
|
|
95
|
+
* Extracts the default export, falling back to a named `pristineConfig` export.
|
|
96
|
+
*/
|
|
97
|
+
importConfigFile(absolutePath) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
var _a, _b, _c, _d;
|
|
100
|
+
const ext = path.extname(absolutePath).toLowerCase();
|
|
101
|
+
let loaded;
|
|
102
|
+
if (ext === ".ts") {
|
|
103
|
+
const jitiModule = yield this.dynamicImport("jiti");
|
|
104
|
+
const createJiti = (_b = (_a = jitiModule.default) !== null && _a !== void 0 ? _a : jitiModule.createJiti) !== null && _b !== void 0 ? _b : jitiModule;
|
|
105
|
+
const jiti = createJiti(absolutePath, { interopDefault: true });
|
|
106
|
+
loaded = jiti(absolutePath);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
loaded = yield this.dynamicImport(`file://${absolutePath}`);
|
|
110
|
+
}
|
|
111
|
+
const parsed = (_d = (_c = loaded === null || loaded === void 0 ? void 0 : loaded.default) !== null && _c !== void 0 ? _c : loaded === null || loaded === void 0 ? void 0 : loaded.pristineConfig) !== null && _d !== void 0 ? _d : loaded;
|
|
112
|
+
if (!parsed || typeof parsed !== "object") {
|
|
113
|
+
throw new Error(`[pristine] Config file at '${absolutePath}' did not export a valid configuration. ` +
|
|
114
|
+
`Use \`export default defineConfig({ ... })\` or \`export const pristineConfig = { ... }\`.`);
|
|
115
|
+
}
|
|
116
|
+
return parsed;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
PristineConfigFileLoader = __decorate([
|
|
121
|
+
injectable()
|
|
122
|
+
], PristineConfigFileLoader);
|
|
123
|
+
export { PristineConfigFileLoader };
|
|
124
|
+
//# sourceMappingURL=pristine-config-file.loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pristine-config-file.loader.js","sourceRoot":"","sources":["../../../../src/loaders/pristine-config-file.loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OA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,KAAK,CACb,8BAA8B,YAAY,0CAA0C;oBACpF,4FAA4F,CAC7F,CAAC;YACJ,CAAC;YAED,OAAO,MAA4B,CAAC;QACtC,CAAC;KAAA;CACF,CAAA;AA5FY,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CA4FpC"}
|
|
@@ -20,9 +20,11 @@ import { injectable } from "tsyringe";
|
|
|
20
20
|
import { ConfigurationDefinitionAlreadyExistsError } from "../errors/configuration-definition-already-exists.error";
|
|
21
21
|
import { ConfigurationParser } from "../parsers/configuration.parser";
|
|
22
22
|
import { ConfigurationValidationError } from "../errors/configuration-validation.error";
|
|
23
|
+
import { PristineConfigFileLoader } from "../loaders/pristine-config-file.loader";
|
|
23
24
|
let ConfigurationManager = class ConfigurationManager {
|
|
24
|
-
constructor(configurationParser) {
|
|
25
|
+
constructor(configurationParser, pristineConfigFileLoader) {
|
|
25
26
|
this.configurationParser = configurationParser;
|
|
27
|
+
this.pristineConfigFileLoader = pristineConfigFileLoader;
|
|
26
28
|
this.configurationDefinitions = {};
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
@@ -38,28 +40,63 @@ let ConfigurationManager = class ConfigurationManager {
|
|
|
38
40
|
this.configurationDefinitions[configurationDefinition.parameterName] = configurationDefinition;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
42
|
-
* will verify that a corresponding configurationDefinition exists and if it does, it will resolve the value.
|
|
43
|
+
* Loads configuration values into the container using the precedence chain:
|
|
43
44
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
45
|
+
* 1. `moduleConfigurationValues` — explicit overrides passed to `kernel.start()`.
|
|
46
|
+
* Highest precedence; wins all conflicts.
|
|
47
|
+
* 2. `pristine.config.ts:config` — values from the user-authored config file.
|
|
48
|
+
* Beats `configDefaults` and the resolver chain.
|
|
49
|
+
* 3. `configDefaults` — merged from every module's `ModuleInterface.configDefaults`.
|
|
50
|
+
* Beats the resolver chain.
|
|
51
|
+
* 4. `configurationDefinition.defaultResolvers` — per-key resolver list (env vars,
|
|
52
|
+
* secrets manager, etc.). First successful resolver wins.
|
|
53
|
+
* 5. `configurationDefinition.defaultValue` — hard fallback.
|
|
46
54
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
55
|
+
* Conflicts:
|
|
56
|
+
* - **Same key in `moduleConfigurationValues` and the file** → stderr warning naming
|
|
57
|
+
* both sources (never the value, which may be a secret); the overrides win.
|
|
58
|
+
* - **Unknown key** in any of the explicit sources (overrides / file / configDefaults)
|
|
59
|
+
* → validation error; throws at end of `load`.
|
|
60
|
+
* - **Two modules' `configDefaults` disagree** — handled by the kernel before this
|
|
61
|
+
* method runs (throws at registration). The merged `configDefaults` reaching this
|
|
62
|
+
* method is already conflict-free.
|
|
63
|
+
*
|
|
64
|
+
* @param moduleConfigurationValues Explicit overrides from `kernel.start()`.
|
|
65
|
+
* @param container The DI container to register resolved values into.
|
|
66
|
+
* @param configDefaults Merged `ModuleInterface.configDefaults` from every module in the
|
|
67
|
+
* graph. Optional; defaults to empty.
|
|
49
68
|
*/
|
|
50
|
-
load(
|
|
51
|
-
return __awaiter(this,
|
|
69
|
+
load(moduleConfigurationValues_1, container_1) {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function* (moduleConfigurationValues, container, configDefaults = {}) {
|
|
52
71
|
const validationErrors = [];
|
|
72
|
+
const fileConfig = yield this.readFileConfigSafely();
|
|
73
|
+
// Build the merged "explicit value" map by precedence, lowest to highest, so each
|
|
74
|
+
// later layer overwrites earlier ones. (1) configDefaults < (2) file < (3) overrides.
|
|
75
|
+
const mergedValues = {};
|
|
76
|
+
for (const key of Object.keys(configDefaults)) {
|
|
77
|
+
mergedValues[key] = configDefaults[key];
|
|
78
|
+
}
|
|
79
|
+
for (const key of Object.keys(fileConfig)) {
|
|
80
|
+
mergedValues[key] = fileConfig[key];
|
|
81
|
+
}
|
|
53
82
|
for (const key of Object.keys(moduleConfigurationValues)) {
|
|
54
|
-
if (
|
|
55
|
-
|
|
83
|
+
if (fileConfig.hasOwnProperty(key)) {
|
|
84
|
+
// Warn (never log values — could be secrets). The overrides win regardless.
|
|
85
|
+
process.stderr.write(`[pristine] WARNING: Configuration key '${key}' is set in BOTH:\n` +
|
|
86
|
+
` - the explicit overrides passed to kernel.start()\n` +
|
|
87
|
+
` - pristine.config.ts:config\n` +
|
|
88
|
+
`Using the value from the explicit overrides. Set the key in only one place to silence this warning.\n`);
|
|
56
89
|
}
|
|
90
|
+
mergedValues[key] = moduleConfigurationValues[key];
|
|
91
|
+
}
|
|
92
|
+
// Process every merged value against the registered definitions. Unknown keys land in
|
|
93
|
+
// validationErrors so multiple typos surface in a single throw at the end.
|
|
94
|
+
for (const key of Object.keys(mergedValues)) {
|
|
57
95
|
if (this.configurationDefinitions.hasOwnProperty(key) === false) {
|
|
58
96
|
validationErrors.push("There are no ConfigurationDefinition in any of the modules for the following key: '" + key + "'.");
|
|
59
97
|
continue;
|
|
60
98
|
}
|
|
61
|
-
const
|
|
62
|
-
const resolvedConfigurationValue = yield this.configurationParser.resolve(moduleConfigurationValue, container);
|
|
99
|
+
const resolvedConfigurationValue = yield this.configurationParser.resolve(mergedValues[key], container);
|
|
63
100
|
// Register the configuration in the container
|
|
64
101
|
this.registerConfigurationValue(key, resolvedConfigurationValue, container);
|
|
65
102
|
// Remove the configurationDefinition for the key
|
|
@@ -145,10 +182,41 @@ let ConfigurationManager = class ConfigurationManager {
|
|
|
145
182
|
// Register the configuration in the container
|
|
146
183
|
container.registerInstance("%" + configurationKey + "%", value);
|
|
147
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Reads the `config:` block from `pristine.config.{ts,js}` (if present). The file is
|
|
187
|
+
* optional — its absence is not an error, just produces an empty map. Failures to
|
|
188
|
+
* parse a present file are also swallowed (and reported via stderr) so misconfigured
|
|
189
|
+
* config files don't take down the whole boot.
|
|
190
|
+
*/
|
|
191
|
+
readFileConfigSafely() {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
try {
|
|
194
|
+
const parsed = yield this.pristineConfigFileLoader.load();
|
|
195
|
+
if (parsed === undefined) {
|
|
196
|
+
return {};
|
|
197
|
+
}
|
|
198
|
+
const block = parsed.config;
|
|
199
|
+
if (block === undefined || block === null) {
|
|
200
|
+
return {};
|
|
201
|
+
}
|
|
202
|
+
if (typeof block !== "object" || Array.isArray(block)) {
|
|
203
|
+
process.stderr.write(`[pristine] WARNING: pristine.config.ts:config is not a plain object. Ignoring file-based configuration overrides.\n`);
|
|
204
|
+
return {};
|
|
205
|
+
}
|
|
206
|
+
return block;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
process.stderr.write(`[pristine] WARNING: Failed to load pristine.config.ts for runtime configuration: ${error.message}\n` +
|
|
210
|
+
`Continuing without file-based configuration overrides.\n`);
|
|
211
|
+
return {};
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
148
215
|
};
|
|
149
216
|
ConfigurationManager = __decorate([
|
|
150
217
|
injectable(),
|
|
151
|
-
__metadata("design:paramtypes", [ConfigurationParser
|
|
218
|
+
__metadata("design:paramtypes", [ConfigurationParser,
|
|
219
|
+
PristineConfigFileLoader])
|
|
152
220
|
], ConfigurationManager);
|
|
153
221
|
export { ConfigurationManager };
|
|
154
222
|
//# sourceMappingURL=configuration.manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.manager.js","sourceRoot":"","sources":["../../../../src/managers/configuration.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAC,yCAAyC,EAAC,MAAM,yDAAyD,CAAC;AAElH,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,4BAA4B,EAAC,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"configuration.manager.js","sourceRoot":"","sources":["../../../../src/managers/configuration.man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