@aikdna/kdna-cli 0.22.1 → 0.22.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 +4 -3
- package/src/cli.js +6 -1
- package/src/cmds/demo.js +59 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikdna/kdna-cli",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.3",
|
|
4
4
|
"description": "KDNA CLI — runtime control plane for verifying, installing, loading, comparing, publishing, and auditing existing .kdna assets.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"test:all": "npm run test:v1 && npm run test:smoke && npm run test:legacy",
|
|
29
29
|
"test:core-smoke": "node scripts/pretest-smoke.js",
|
|
30
30
|
"release:preflight": "node scripts/release-preflight.js",
|
|
31
|
-
"test:v1": "node --test tests/v1-global-cli.test.js",
|
|
31
|
+
"test:v1": "node --test tests/v1-global-cli.test.js tests/v1-demo-minimal.test.js",
|
|
32
32
|
"test:smoke": "npm run test:core-smoke",
|
|
33
|
-
"test:legacy": "node --test tests/v07-commands.test.js tests/v012-commands.test.js tests/asset-store.test.js"
|
|
33
|
+
"test:legacy": "node --test tests/v07-commands.test.js tests/v012-commands.test.js tests/asset-store.test.js",
|
|
34
|
+
"test:demo": "node --test tests/v1-demo-minimal.test.js"
|
|
34
35
|
},
|
|
35
36
|
"keywords": [
|
|
36
37
|
"kdna",
|
package/src/cli.js
CHANGED
|
@@ -37,6 +37,7 @@ const {
|
|
|
37
37
|
} = require('./cmds/license');
|
|
38
38
|
const { cmdProtect, cmdUnlock, cmdRecover } = require('./cmds/protect');
|
|
39
39
|
const { cmdPreview, cmdProject, cmdEval, cmdExport, cmdDemo } = require('./cmds/legacy');
|
|
40
|
+
const { cmdDemo: cmdDemoMinimal } = require('./cmds/demo');
|
|
40
41
|
const { cmdCardsValidate, cmdLockVerify } = require('./cmds/studio');
|
|
41
42
|
const { cmdTestRun, cmdTestImport } = require('./cmds/test');
|
|
42
43
|
const { cmdChangelog } = require('./cmds/changelog');
|
|
@@ -570,7 +571,11 @@ switch (cmd) {
|
|
|
570
571
|
break;
|
|
571
572
|
}
|
|
572
573
|
case 'demo': {
|
|
573
|
-
|
|
574
|
+
if (args[1] === 'minimal') {
|
|
575
|
+
cmdDemoMinimal(args.slice(1));
|
|
576
|
+
} else {
|
|
577
|
+
cmdDemo();
|
|
578
|
+
}
|
|
574
579
|
break;
|
|
575
580
|
}
|
|
576
581
|
case 'explain': {
|
package/src/cmds/demo.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
|
|
4
|
+
function cmdDemo(args) {
|
|
5
|
+
const force = args.includes('--force');
|
|
6
|
+
const sub = args.filter((a) => !a.startsWith('--'))[0];
|
|
7
|
+
if (sub !== 'minimal') {
|
|
8
|
+
console.error('Usage: kdna demo minimal <output-dir> [--force]');
|
|
9
|
+
console.error(' Copies the minimal v1 fixture to the target directory for first-run testing.');
|
|
10
|
+
process.exit(2);
|
|
11
|
+
}
|
|
12
|
+
const dest = args.filter((a) => !a.startsWith('--'))[1];
|
|
13
|
+
if (!dest) {
|
|
14
|
+
console.error('Usage: kdna demo minimal <output-dir> [--force]');
|
|
15
|
+
process.exit(2);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const srcDir = path.join(__dirname, '..', '..', 'fixtures', 'v1-minimal');
|
|
19
|
+
const outDir = path.resolve(dest);
|
|
20
|
+
|
|
21
|
+
if (!fs.existsSync(srcDir)) {
|
|
22
|
+
console.error(`Fixture not found at ${srcDir}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (fs.existsSync(outDir)) {
|
|
27
|
+
const existing = fs.readdirSync(outDir).filter((f) => f !== '.DS_Store');
|
|
28
|
+
if (existing.length > 0 && !force) {
|
|
29
|
+
console.error(
|
|
30
|
+
`Target already exists and is not empty: ${outDir}`,
|
|
31
|
+
);
|
|
32
|
+
console.error('Use --force to overwrite.');
|
|
33
|
+
process.exit(2);
|
|
34
|
+
}
|
|
35
|
+
if (!force) {
|
|
36
|
+
// empty dir — fine
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
41
|
+
const copied = [];
|
|
42
|
+
for (const f of fs.readdirSync(srcDir)) {
|
|
43
|
+
const s = path.join(srcDir, f);
|
|
44
|
+
const d = path.join(outDir, f);
|
|
45
|
+
if (fs.statSync(s).isFile()) {
|
|
46
|
+
fs.copyFileSync(s, d);
|
|
47
|
+
copied.push(f);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const f of copied) process.stdout.write(` ${f}\n`);
|
|
52
|
+
process.stdout.write(`\nMinimal KDNA Core v1 demo created at: ${outDir}\n\n`);
|
|
53
|
+
process.stdout.write('Next:\n');
|
|
54
|
+
process.stdout.write(` kdna inspect ${dest}\n`);
|
|
55
|
+
process.stdout.write(` kdna validate ${dest}\n`);
|
|
56
|
+
process.stdout.write(` kdna pack ${dest} ${dest}.kdna\n`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = { cmdDemo };
|