fix(3571): load configuration manifests after install (#3572)
* fix(3571): load configuration manifests after install * test(3571): simplify missing manifest check
This commit is contained in:
@@ -14,11 +14,31 @@ const { readFileSync, writeFileSync, existsSync, readdirSync } = require('node:f
|
||||
const { join } = require('node:path');
|
||||
|
||||
// ─── Manifest requires ───────────────────────────────────────────────────────
|
||||
// Resolved relative to this file: get-shit-done/bin/lib/ → sdk/shared/
|
||||
// This file lives at: get-shit-done/bin/lib/configuration.generated.cjs
|
||||
// sdk/shared lives at: sdk/shared/ (3 dirs up from bin/lib, then into sdk/shared)
|
||||
const CONFIG_DEFAULTS = require('../../../sdk/shared/config-defaults.manifest.json');
|
||||
const SCHEMA_MANIFEST = require('../../../sdk/shared/config-schema.manifest.json');
|
||||
function loadConfigurationManifest(fileName) {
|
||||
const candidates = [
|
||||
// Installed runtime layout: get-shit-done/bin/shared/*.manifest.json
|
||||
join(__dirname, '..', 'shared', fileName),
|
||||
// Source-repo dev layout: sdk/shared/*.manifest.json
|
||||
join(__dirname, '..', '..', '..', 'sdk', 'shared', fileName),
|
||||
];
|
||||
let lastErr = null;
|
||||
for (const candidate of candidates) {
|
||||
try {
|
||||
return require(candidate);
|
||||
} catch (err) {
|
||||
const isMissingCandidate =
|
||||
err && err.code === 'MODULE_NOT_FOUND' && String(err.message || '').includes(candidate);
|
||||
if (!isMissingCandidate) throw err;
|
||||
lastErr = err;
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`${fileName} not found. Tried:\n${candidates.map((p) => ` ${p}`).join('\n')}\nLast error: ${lastErr?.message}`
|
||||
);
|
||||
}
|
||||
|
||||
const CONFIG_DEFAULTS = loadConfigurationManifest('config-defaults.manifest.json');
|
||||
const SCHEMA_MANIFEST = loadConfigurationManifest('config-schema.manifest.json');
|
||||
const VALID_CONFIG_KEYS = new Set(SCHEMA_MANIFEST.validKeys);
|
||||
const RUNTIME_STATE_KEYS = new Set(SCHEMA_MANIFEST.runtimeStateKeys);
|
||||
const DYNAMIC_KEY_PATTERNS = SCHEMA_MANIFEST.dynamicKeyPatterns.map((p) => {
|
||||
|
||||
Reference in New Issue
Block a user