@vizualmodel/vmblu-cli 0.3.3 → 0.3.4
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/commands/init/index.js +10 -7
- package/commands/init/init-project.js +13 -11
- package/commands/init/make-package-json.js +49 -35
- package/commands/profile/profile.bundle.js +2011 -1278
- package/package.json +19 -6
- package/templates/0.8.3/vmblu.annex.md +2 -2
- package/templates/0.8.4/profile.schema.json +74 -0
- package/templates/0.8.4/seed.md +17 -0
- package/templates/0.8.4/vmblu.annex.md +151 -0
- package/templates/0.8.4/vmblu.schema.json +268 -0
package/commands/init/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// vmblu init [targetDir] --name <project> --schema <ver> --force --dry-run
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import { initProject } from './init-project.js';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { initProject } from './init-project.js';
|
|
5
|
+
import { createRequire } from 'module';
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const pckg = require('../../package.json');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
12
|
|
|
10
13
|
export const command = 'init <folder name>';
|
|
11
14
|
export const describe = 'Scaffold an empty vmblu project';
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// core/initProject.js
|
|
2
2
|
// Node 18+ (fs/promises, crypto). No external deps.
|
|
3
|
-
import * as fs from 'fs/promises';
|
|
4
|
-
import * as fssync from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
//import crypto from 'crypto';
|
|
7
|
-
import { makePackageJson } from './make-package-json.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
3
|
+
import * as fs from 'fs/promises';
|
|
4
|
+
import * as fssync from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
//import crypto from 'crypto';
|
|
7
|
+
import { makePackageJson } from './make-package-json.js';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
|
|
10
|
+
// Get the versions
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const pckg = require('../../package.json');
|
|
13
|
+
const SCHEMA_VERSION = pckg.schemaVersion
|
|
14
|
+
const CLI_VERSION = pckg.version
|
|
13
15
|
|
|
14
16
|
function rel(from, to) {
|
|
15
17
|
return path.posix.join(...path.relative(from, to).split(path.sep));
|
|
@@ -60,7 +62,7 @@ function defaultModel(projectName) {
|
|
|
60
62
|
saved: now,
|
|
61
63
|
utc: now,
|
|
62
64
|
style: "#2c7be5",
|
|
63
|
-
runtime: "@vizualmodel/vmblu
|
|
65
|
+
runtime: "@vizualmodel/vmblu-runtime",
|
|
64
66
|
description: `${projectName} — vmblu model (scaffolded)`
|
|
65
67
|
},
|
|
66
68
|
models: [],
|
|
@@ -1,58 +1,72 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { createRequire } from 'module';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const pckg = require('../../package.json');
|
|
7
|
+
|
|
8
|
+
async function readJsonIfExists(file) {
|
|
5
9
|
try { return JSON.parse(await fs.readFile(file, 'utf8')); } catch { return null; }
|
|
6
|
-
}
|
|
10
|
+
};
|
|
7
11
|
|
|
8
12
|
function sortKeys(obj) {
|
|
9
13
|
return Object.fromEntries(Object.entries(obj).sort(([a],[b]) => a.localeCompare(b)));
|
|
10
|
-
}
|
|
14
|
+
};
|
|
11
15
|
|
|
12
|
-
export async function makePackageJson({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
export async function makePackageJson({
|
|
17
|
+
absTarget,
|
|
18
|
+
projectName,
|
|
19
|
+
force,
|
|
20
|
+
dryRun,
|
|
21
|
+
addCliDep = true,
|
|
22
|
+
cliVersion = "^"+pckg.version
|
|
23
|
+
}, ui)
|
|
24
|
+
{
|
|
25
|
+
|
|
26
|
+
// check if a pckage file exists
|
|
16
27
|
const pkgPath = path.join(absTarget, 'package.json');
|
|
17
28
|
const existing = await readJsonIfExists(pkgPath);
|
|
18
29
|
|
|
19
|
-
//
|
|
20
|
-
|
|
30
|
+
// don't overwrite
|
|
31
|
+
if (existing && !force) return pkgPath;
|
|
32
|
+
|
|
33
|
+
// The base package with vite and typescript
|
|
34
|
+
const basePackage = {
|
|
21
35
|
name: projectName,
|
|
22
36
|
private: true,
|
|
23
37
|
version: "0.0.0",
|
|
38
|
+
type: "module",
|
|
39
|
+
dependencies: {
|
|
40
|
+
"@vizualmodel/vmblu-runtime": "^0.1.0"
|
|
41
|
+
},
|
|
42
|
+
devDependencies : {
|
|
43
|
+
"@vizualmodel/vmblu-cli": "^0.3.3",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vite": "^7.1.12",
|
|
46
|
+
// "ts-morph": "^26.0.0",
|
|
47
|
+
// "svelte": "^5.0.0",
|
|
48
|
+
// "@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
49
|
+
// "@tsconfig/svelte": "^5.0.2"
|
|
50
|
+
},
|
|
51
|
+
scripts : {
|
|
52
|
+
"vm:init": "vmblu init .",
|
|
53
|
+
"vm:profile": "vmblu profile",
|
|
54
|
+
"dev": "vite",
|
|
55
|
+
"build": "vite build",
|
|
56
|
+
"preview": "vite preview"
|
|
57
|
+
}
|
|
24
58
|
};
|
|
25
59
|
|
|
26
|
-
// Add/merge scripts (idempotent)
|
|
27
|
-
basePkg.scripts = Object.assign({}, basePkg.scripts, {
|
|
28
|
-
"vm:init": "vmblu init ."
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Optionally add the CLI as a devDependency
|
|
32
|
-
if (addCliDep) {
|
|
33
|
-
basePkg.devDependencies = Object.assign({}, basePkg.devDependencies, {
|
|
34
|
-
"@vizualmodel/vmblu-cli": basePkg.devDependencies?.["@vizualmodel/vmblu-cli"] || cliVersion
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Nice-to-have: keep deterministic key order
|
|
39
|
-
const ordered = {
|
|
40
|
-
...sortKeys(basePkg),
|
|
41
|
-
scripts: sortKeys(basePkg.scripts || {}),
|
|
42
|
-
devDependencies: basePkg.devDependencies ? sortKeys(basePkg.devDependencies) : undefined
|
|
43
|
-
};
|
|
44
60
|
|
|
45
|
-
if (existing
|
|
46
|
-
ui.info(`update package.json (merge scripts${addCliDep ? " + devDependency" : ""})`);
|
|
47
|
-
} else if (!existing) {
|
|
61
|
+
if (!existing) {
|
|
48
62
|
ui.info(`create ${pkgPath}`);
|
|
49
63
|
} else {
|
|
50
64
|
ui.info(`overwrite ${pkgPath} (force)`);
|
|
51
|
-
}
|
|
65
|
+
};
|
|
52
66
|
|
|
53
67
|
if (!dryRun) {
|
|
54
|
-
await fs.writeFile(pkgPath, JSON.stringify(
|
|
55
|
-
}
|
|
68
|
+
await fs.writeFile(pkgPath, JSON.stringify(basePackage, null, 2) + '\n', 'utf8');
|
|
69
|
+
};
|
|
56
70
|
|
|
57
|
-
return pkgPath;
|
|
58
|
-
}
|
|
71
|
+
return pkgPath;
|
|
72
|
+
}
|