@divlet/cli 0.0.0-stage → 0.0.1
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 +12 -2
- package/dist/LICENSE +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +90 -0
- package/package.json +37 -4
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @divlet/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The command-line adapter for divlet. This package owns its implementation and depends on the exact matching `@divlet/core` product version; the core does not contain another copy.
|
|
4
|
+
|
|
5
|
+
Install:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx -y @divlet/cli@0.0.1 ./my-project
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The installed binary is `divlet`. Importing the package exposes `runCli` without starting a service; the executable starts it explicitly. Checkout commands use `node scripts/source.mjs cli/index.js` from the repository root.
|
|
12
|
+
|
|
13
|
+
Shared development, release notes and publication guidance live in the [divlet repository](https://github.com/llblab/divlet).
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 divlet contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { openRuntime, launch, makeHost } from '@divlet/core';
|
|
4
|
+
export async function runCli(argv = process.argv.slice(2)) {
|
|
5
|
+
const args = argv;
|
|
6
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
7
|
+
console.log(`divlet [path] [--port <0..65535>] [--no-demo] [--no-watch]
|
|
8
|
+
|
|
9
|
+
Opens the project at <path> (default: the current directory):
|
|
10
|
+
<path>.divlet open that project (created if absent)
|
|
11
|
+
<path>.pen or <path>.html convert once into the <name>.divlet beside it and open that; the imported file is kept as it was
|
|
12
|
+
<folder>/project.divlet default when the folder has no projects
|
|
13
|
+
<folder>/*.{divlet,pen} one opens directly; several show a launcher (.html files open only by path)
|
|
14
|
+
Local resources are resolved automatically, including files outside the project folder; no approval flags are needed.
|
|
15
|
+
Grants require one selected project, never extend to siblings, and remain fixed until restart.
|
|
16
|
+
Generated pages default to .divlet/<filename stem>/; set project outputDir to change it.
|
|
17
|
+
Set { "projects": "folder" } in <path>/divlet.config.json to use another collection folder.
|
|
18
|
+
Port 0 chooses a free port. Install in Pi with: pi install npm:@divlet/pi (after npm publication) or pi install /absolute/path/to/divlet/pi (after building a checkout)`);
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
let target = process.cwd();
|
|
22
|
+
let port = 0;
|
|
23
|
+
let createDemo = true;
|
|
24
|
+
let watch = true;
|
|
25
|
+
const externalFiles = [];
|
|
26
|
+
for (let i = 0; i < args.length; i++) {
|
|
27
|
+
const arg = args[i];
|
|
28
|
+
if ((arg === '--cwd' || arg === '--dir') && args[i + 1])
|
|
29
|
+
target = path.resolve(args[++i]);
|
|
30
|
+
else if (arg === '--port' && args[i + 1])
|
|
31
|
+
port = Number(args[++i]);
|
|
32
|
+
else if (arg === '--asset-file' && args[i + 1] && !args[i + 1].startsWith('-'))
|
|
33
|
+
externalFiles.push(path.resolve(args[++i]));
|
|
34
|
+
else if (arg === '--no-demo')
|
|
35
|
+
createDemo = false;
|
|
36
|
+
else if (arg === '--no-watch')
|
|
37
|
+
watch = false;
|
|
38
|
+
else if (!arg.startsWith('-'))
|
|
39
|
+
target = path.resolve(arg);
|
|
40
|
+
else {
|
|
41
|
+
console.error(`Unknown or incomplete argument: ${arg}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
46
|
+
console.error('Port must be an integer from 0 to 65535.');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const runtimes = new Map();
|
|
51
|
+
const hubs = new Map();
|
|
52
|
+
const openBoard = async (location) => {
|
|
53
|
+
const key = path.resolve(location.file);
|
|
54
|
+
if (!runtimes.has(key)) {
|
|
55
|
+
const runtime = await openRuntime({ ...location, port: runtimes.size ? 0 : port, createDemo, watch });
|
|
56
|
+
runtime.host = host;
|
|
57
|
+
runtimes.set(key, runtime);
|
|
58
|
+
}
|
|
59
|
+
return runtimes.get(key);
|
|
60
|
+
};
|
|
61
|
+
const host = makeHost({ openBoard: (location) => openBoard(location), hubs });
|
|
62
|
+
const opened = await launch(target, { openBoard, hubs, ...(externalFiles.length ? { externalFiles } : {}) });
|
|
63
|
+
if (opened.kind === 'project') {
|
|
64
|
+
const info = opened.runtime.info();
|
|
65
|
+
const imported = opened.imported ? `Imported ${path.basename(opened.imported.from)} → ${path.basename(opened.imported.to)} (${opened.imported.frames} frames as HTML + Tailwind: ${opened.imported.utilities} utility and ${opened.imported.arbitrary} arbitrary-property classes; the source is kept as ${path.basename(opened.imported.from)})\n` : '';
|
|
66
|
+
console.log(`divlet ${info.url}\nProject: ${info.project.file} · ${info.documents.length} frame${info.documents.length === 1 ? '' : 's'}\n${imported}The Agent tab works when the board is opened from Pi (/divlet) or by an MCP client. Press Ctrl+C to stop.`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.log(`divlet ${opened.hub.url}\n${opened.projects.length} project${opened.projects.length === 1 ? '' : 's'} in ${opened.collection} — pick one in the browser, or name a new one. Press Ctrl+C to stop.`);
|
|
70
|
+
}
|
|
71
|
+
let stopping = false;
|
|
72
|
+
const stop = async () => {
|
|
73
|
+
if (stopping)
|
|
74
|
+
return;
|
|
75
|
+
stopping = true;
|
|
76
|
+
for (const hub of hubs.values())
|
|
77
|
+
await hub.close();
|
|
78
|
+
for (const runtime of runtimes.values())
|
|
79
|
+
await runtime.close();
|
|
80
|
+
};
|
|
81
|
+
process.once('SIGINT', stop);
|
|
82
|
+
process.once('SIGTERM', stop);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error(`divlet: ${error.message}`);
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (import.meta.main)
|
|
90
|
+
await runCli();
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@divlet/cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The divlet command-line adapter",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/llblab/divlet.git",
|
|
11
|
+
"directory": "cli"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/llblab/divlet#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/llblab/divlet/issues"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.19.0"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"divlet-source": "./index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"divlet": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@divlet/core": "0.0.1"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"prepack": "node ../scripts/build.mjs"
|
|
38
|
+
}
|
|
39
|
+
}
|