@specdest/devkit 0.3.2 → 0.3.3
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { readdir, readFile, rm, rmdir } from 'node:fs/promises';
|
|
2
|
+
import { access, readdir, readFile, rm, rmdir } from 'node:fs/promises';
|
|
3
3
|
import { join, relative } from 'node:path';
|
|
4
4
|
|
|
5
5
|
import { createCanonicalSource, detectProjectStack } from './canonical-source.js';
|
|
@@ -19,6 +19,19 @@ function execute(command, args, cwd) {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
async function fileExists(path) {
|
|
23
|
+
try { await access(path); return true; } catch (error) { if (error?.code === 'ENOENT') return false; throw error; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function missingProjectScaffold(projectRoot, copies) {
|
|
27
|
+
for (const copy of copies ?? []) {
|
|
28
|
+
if (copy.mode !== 'scaffold' && copy.mode !== 'create-only') continue;
|
|
29
|
+
const target = String(copy.target ?? copy.path ?? '');
|
|
30
|
+
if (target && !(await fileExists(join(projectRoot, target)))) return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
function flags(args) {
|
|
23
36
|
const known = new Set(['--refresh', '--json']);
|
|
24
37
|
for (const arg of args) if (!known.has(arg)) throw new Error(`Unknown option: ${arg}`);
|
|
@@ -111,7 +124,12 @@ export async function canonicalSync(projectRoot, source) {
|
|
|
111
124
|
if (!installed) {
|
|
112
125
|
await installRule({ projectRoot, payloadRoot: source.cachedModulePath(entry.id, entry.version), manifest: prepared.manifest });
|
|
113
126
|
changed.push({ id: entry.id, action: 'installed', version: entry.version });
|
|
114
|
-
} else if (
|
|
127
|
+
} else if (
|
|
128
|
+
installed.version !== entry.version ||
|
|
129
|
+
installed.contentHash !== entry.contentHash ||
|
|
130
|
+
(prepared.checkerPath && installed.check?.command?.[0] !== 'specdest-cache') ||
|
|
131
|
+
await missingProjectScaffold(projectRoot, prepared.manifest.copies)
|
|
132
|
+
) {
|
|
115
133
|
await syncRule({ projectRoot, payloadRoot: source.cachedModulePath(entry.id, entry.version), manifest: prepared.manifest });
|
|
116
134
|
changed.push({ id: entry.id, action: 'updated', version: entry.version });
|
|
117
135
|
}
|