@aikdna/kdna-cli 0.22.2 → 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.
Files changed (2) hide show
  1. package/package.json +4 -3
  2. package/src/cmds/demo.js +33 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikdna/kdna-cli",
3
- "version": "0.22.2",
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/cmds/demo.js CHANGED
@@ -1,34 +1,59 @@
1
1
  const fs = require('node:fs');
2
2
  const path = require('node:path');
3
- const { error, EXIT } = require('./_common');
4
3
 
5
4
  function cmdDemo(args) {
6
- const sub = args[0];
5
+ const force = args.includes('--force');
6
+ const sub = args.filter((a) => !a.startsWith('--'))[0];
7
7
  if (sub !== 'minimal') {
8
- console.error('Usage: kdna demo minimal <output-dir>');
8
+ console.error('Usage: kdna demo minimal <output-dir> [--force]');
9
9
  console.error(' Copies the minimal v1 fixture to the target directory for first-run testing.');
10
10
  process.exit(2);
11
11
  }
12
- const dest = args[1];
12
+ const dest = args.filter((a) => !a.startsWith('--'))[1];
13
13
  if (!dest) {
14
- console.error('Usage: kdna demo minimal <output-dir>');
14
+ console.error('Usage: kdna demo minimal <output-dir> [--force]');
15
15
  process.exit(2);
16
16
  }
17
+
17
18
  const srcDir = path.join(__dirname, '..', '..', 'fixtures', 'v1-minimal');
18
19
  const outDir = path.resolve(dest);
20
+
19
21
  if (!fs.existsSync(srcDir)) {
20
- error(`Fixture not found at ${srcDir}`, EXIT.INPUT_ERROR);
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
+ }
21
38
  }
39
+
22
40
  fs.mkdirSync(outDir, { recursive: true });
41
+ const copied = [];
23
42
  for (const f of fs.readdirSync(srcDir)) {
24
43
  const s = path.join(srcDir, f);
25
44
  const d = path.join(outDir, f);
26
45
  if (fs.statSync(s).isFile()) {
27
46
  fs.copyFileSync(s, d);
28
- console.log(` ${f}`);
47
+ copied.push(f);
29
48
  }
30
49
  }
31
- console.log(`Minimal v1 fixture copied to: ${outDir}`);
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`);
32
57
  }
33
58
 
34
59
  module.exports = { cmdDemo };