@modeldesk/cli 0.2.0 → 0.3.0
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/README.md +32 -3
- package/dist/modeldesk.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -7,7 +7,9 @@ not render, host, or publish documents.
|
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
10
|
-
The CLI runs on Node.js (version
|
|
10
|
+
The CLI runs on Node.js (version 22 or newer), on Linux, macOS, and Windows. It is plain JavaScript
|
|
11
|
+
with no native dependencies, so the Node version is the only requirement. Run it on demand with
|
|
12
|
+
`npx`, or install it globally.
|
|
11
13
|
|
|
12
14
|
```bash
|
|
13
15
|
npx @modeldesk/cli@latest bundle pull --model <modelId> --stack respec --template conceptueel-toc
|
|
@@ -15,6 +17,11 @@ npx @modeldesk/cli@latest bundle pull --model <modelId> --stack respec --templat
|
|
|
15
17
|
npm install -g @modeldesk/cli
|
|
16
18
|
```
|
|
17
19
|
|
|
20
|
+
On Windows, a global install is invoked through the `modeldesk.ps1` shim npm generates. If your
|
|
21
|
+
PowerShell execution policy blocks scripts ("running scripts is disabled on this system"), call
|
|
22
|
+
`modeldesk.cmd`, use `npx @modeldesk/cli@latest` instead, or, if your organization permits it, allow
|
|
23
|
+
signed scripts for your own account with `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`.
|
|
24
|
+
|
|
18
25
|
## Commands
|
|
19
26
|
|
|
20
27
|
```
|
|
@@ -32,8 +39,12 @@ no positional arguments.
|
|
|
32
39
|
|
|
33
40
|
`modeldesk auth login` opens your browser to the ModelDesk sign-in page. You authenticate there (the
|
|
34
41
|
CLI never sees your password), and after a successful login the CLI stores a refresh token in
|
|
35
|
-
`~/.modeldesk/credentials.json` (
|
|
36
|
-
refreshes silently and only re-opens the browser when the stored
|
|
42
|
+
`~/.modeldesk/credentials.json` (on Windows, `%USERPROFILE%\.modeldesk\credentials.json`). Later
|
|
43
|
+
commands run unattended: the CLI refreshes silently and only re-opens the browser when the stored
|
|
44
|
+
credential lapses.
|
|
45
|
+
|
|
46
|
+
The token file is readable only by you: on Linux and macOS the CLI sets file mode `0600`, and on
|
|
47
|
+
Windows it inherits the default private permissions of your user profile.
|
|
37
48
|
|
|
38
49
|
```bash
|
|
39
50
|
modeldesk auth login --host modeldesk.io
|
|
@@ -150,11 +161,29 @@ modeldesk bundle pull --model <modelId> --stack respec --template conceptueel-to
|
|
|
150
161
|
`--no-diagrams` is convenient while iterating on text, but any diagram `data-include` will 404 at
|
|
151
162
|
bake time until you run a full pull.
|
|
152
163
|
|
|
164
|
+
> **Keep the content root LF.** The CLI always writes fragments with LF line endings. On Windows,
|
|
165
|
+
> Git's `core.autocrlf=true` rewrites them to CRLF on checkout, so every pull would then show a
|
|
166
|
+
> diff on files whose content never changed. Pin the content root in `.gitattributes`:
|
|
167
|
+
>
|
|
168
|
+
> ```
|
|
169
|
+
> data/model/** text eol=lf
|
|
170
|
+
> ```
|
|
171
|
+
|
|
153
172
|
> **Ignore the manifest.** Each pull records what it wrote in `.modeldesk/<stack>.manifest.json`
|
|
154
173
|
> (for ReSpec, `.modeldesk/respec.manifest.json`). It is regenerated every pull and is used for
|
|
155
174
|
> precise cleanup and rename hints, so add `.modeldesk/*.manifest.json` to your `.gitignore` —
|
|
156
175
|
> committing it is unnecessary and a stale committed copy can only mislead a later pull.
|
|
157
176
|
|
|
177
|
+
### Portable file names
|
|
178
|
+
|
|
179
|
+
Generated paths are safe to check out on any operating system. Element and diagram names that would
|
|
180
|
+
otherwise produce a name Windows reserves for a device (`con`, `prn`, `aux`, `nul`, `com0`-`com9`,
|
|
181
|
+
`lpt0`-`lpt9`) get a short id suffix automatically, exactly as any other name clash does, so no
|
|
182
|
+
action is needed. The one case that cannot be resolved automatically is a custom **metamodel type**
|
|
183
|
+
whose name slugs to a reserved word: a type name becomes a folder shared by every element of that
|
|
184
|
+
type, so there is nothing unique to suffix it with. The bundle then fails to build with an error
|
|
185
|
+
naming the type to rename.
|
|
186
|
+
|
|
158
187
|
### Safe removal
|
|
159
188
|
|
|
160
189
|
A pull's one destructive step — removing orphaned files — is guarded so a misconfiguration cannot
|
package/dist/modeldesk.js
CHANGED
|
@@ -33,7 +33,7 @@ import{chmodSync as xe,existsSync as Ft,mkdirSync as Ht,readFileSync as Ut,write
|
|
|
33
33
|
`)};var Z=e=>{let t=[];for(let n of e)n.forEach((o,r)=>{t[r]=Math.max(t[r]??0,o.length)});return t},O=(e,{indent:t="",gap:n=2,widths:o}={})=>{let s=Z(e).map((c,l)=>o?.[l]??c),a=" ".repeat(n);return e.map(c=>t+c.map((l,d)=>d===c.length-1?l:l.padEnd(s[d])).join(a))};var Gn=["STACK","TEMPLATE","NAME"],Rt=async e=>{let{values:t}=S(e.argv,{host:{type:"string"},model:{type:"string"},stack:{type:"string"}}),n=J(e,{host:t.host,model:t.model}),o=Q(n.instance,e.env),r=await o.getJson(`/models/${n.model}`),s=(r.metamodelExtensions??[]).map(h=>h.id),a=s.length>0?{metamodelExtensions:s.join(",")}:void 0,{items:c}=await o.getJson(`/metamodels/${r.metamodel.id}/templates`,a),l=c??[];if(l.length===0)return process.stdout.write(`This model has no document templates.
|
|
34
34
|
`),0;let d=t.stack,p=d?l.filter(h=>h.stack===d):l;if(p.length===0)return process.stdout.write(`No document templates for stack '${d}'.
|
|
35
35
|
`),0;let u=p.map(h=>[h.stack??"",h.key??h.id,h.name]);for(let h of O([Gn,...u]))process.stdout.write(`${h}
|
|
36
|
-
`);return 0};var Ce={bundle:{pull:{summary:"Materialize a model's content bundle into a local folder",usage:"bundle pull --model <id> --stack <id> --template <slug> [--host <host>] [--version <name>] [--no-diagrams] [--dry-run]",handler:Pt},templates:{summary:"List a model's document templates",usage:"bundle templates --model <id> [--stack <id>] [--host <host>]",handler:Rt}},auth:{login:{summary:"Log in through the browser (OAuth authorization code + PKCE)",usage:"auth login [--host <host>]",handler:Qe},logout:{summary:"Remove the stored credential for the active host",usage:"auth logout [--host <host>]",handler:Xe},status:{summary:"Show the active host, logged-in identity, and token validity",usage:"auth status [--host <host>]",handler:Ze}}};var At={name:"@modeldesk/cli",version:"0.
|
|
36
|
+
`);return 0};var Ce={bundle:{pull:{summary:"Materialize a model's content bundle into a local folder",usage:"bundle pull --model <id> --stack <id> --template <slug> [--host <host>] [--version <name>] [--no-diagrams] [--dry-run]",handler:Pt},templates:{summary:"List a model's document templates",usage:"bundle templates --model <id> [--stack <id>] [--host <host>]",handler:Rt}},auth:{login:{summary:"Log in through the browser (OAuth authorization code + PKCE)",usage:"auth login [--host <host>]",handler:Qe},logout:{summary:"Remove the stored credential for the active host",usage:"auth logout [--host <host>]",handler:Xe},status:{summary:"Show the active host, logged-in identity, and token validity",usage:"auth status [--host <host>]",handler:Ze}}};var At={name:"@modeldesk/cli",version:"0.3.0",description:"Command-line interface (CLI) for the ModelDesk platform",keywords:["modeldesk","cli","documentation","content-bundle","respec","mim","information-model"],homepage:"https://modeldesk.io",repository:{type:"git",url:"git+https://github.com/model-desk/modeldesk.git",directory:"packages/cli"},license:"MIT",type:"module",bin:{modeldesk:"dist/modeldesk.js"},files:["dist"],publishConfig:{access:"public"},engines:{node:">=22"},scripts:{build:"node esbuild.config.mjs",prepublishOnly:"npm run build",typecheck:"tsc --noEmit",lint:"eslint","lint:fix":"eslint --fix",test:"vitest run","test:watch":"vitest"},devDependencies:{"@eslint/js":"^10.0.1","@modeldesk/content-bundle":"*","@types/node":"^24.13.2",esbuild:"^0.28.2",eslint:"^10.9.1","eslint-config-prettier":"^10.1.5","eslint-plugin-prettier":"^5.5.6",globals:"^17.11.0",prettier:"^3.9.5",typescript:"^6.0.3","typescript-eslint":"^8.69.0",vitest:"^5.0.0"}};var _t=At.version;var Wn={out:e=>process.stdout.write(e),err:e=>process.stderr.write(e)},Lt=new Set(["--help","-h","help"]),Dt=async(e,t=Wn)=>{try{return await Kn(e,t)}catch(n){return n instanceof i?(t.err(`error: ${n.message}
|
|
37
37
|
`),n.exitCode):(t.err(`error: ${n instanceof Error?n.message:String(n)}
|
|
38
38
|
`),1)}},Kn=async(e,t)=>{let[n,...o]=e;if(n===void 0||Lt.has(n))return t.out(Vn()),0;if(n==="--version"||n==="-v")return t.out(`${_t}
|
|
39
39
|
`),0;let r=Ce[n];if(!r)throw new i(`Unknown command '${n}'. Run 'modeldesk --help' to see available commands.`);let[s,...a]=o;if(s===void 0){let p=Object.keys(r).join(", ");throw new i(`'${n}' requires a subcommand (${p}). Run 'modeldesk ${n} --help'.`)}if(Lt.has(s))return t.out(Yn(n,r)),0;let c=r[s];if(!c)throw new i(`Unknown '${n}' command '${s}'. Run 'modeldesk ${n} --help'.`);let l={argv:a,env:process.env,cwd:process.cwd()},d=await c.handler(l);return typeof d=="number"?d:0},Ot=[["--help, -h","Show help"],["--version, -v","Show the CLI version"]],Vn=()=>{let e=[];for(let[o,r]of Object.entries(Ce))for(let[s,a]of Object.entries(r))e.push([`${o} ${s}`,a.summary]);let[t]=Z([...e,...Ot]);return`${["ModelDesk CLI","","Usage: modeldesk <command> <subcommand> [options]","","Commands:",...O(e,{indent:" ",widths:[t]}),"","Global options:",...O(Ot,{indent:" ",widths:[t]}),""].join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modeldesk/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Command-line interface (CLI) for the ModelDesk platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"modeldesk",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=22"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "node esbuild.config.mjs",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"@eslint/js": "^10.0.1",
|
|
45
45
|
"@modeldesk/content-bundle": "*",
|
|
46
46
|
"@types/node": "^24.13.2",
|
|
47
|
-
"esbuild": "^0.28.
|
|
48
|
-
"eslint": "^10.
|
|
47
|
+
"esbuild": "^0.28.2",
|
|
48
|
+
"eslint": "^10.9.1",
|
|
49
49
|
"eslint-config-prettier": "^10.1.5",
|
|
50
50
|
"eslint-plugin-prettier": "^5.5.6",
|
|
51
|
-
"globals": "^17.
|
|
51
|
+
"globals": "^17.11.0",
|
|
52
52
|
"prettier": "^3.9.5",
|
|
53
53
|
"typescript": "^6.0.3",
|
|
54
|
-
"typescript-eslint": "^8.
|
|
55
|
-
"vitest": "^
|
|
54
|
+
"typescript-eslint": "^8.69.0",
|
|
55
|
+
"vitest": "^5.0.0"
|
|
56
56
|
}
|
|
57
57
|
}
|