create-rulecad 0.2.0 → 0.2.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 +3 -1
- package/index.mjs +24 -1
- package/package.json +1 -1
- package/template/AGENTS.md +2 -1
package/README.md
CHANGED
|
@@ -8,4 +8,6 @@ npx cad check home/soap-tray
|
|
|
8
8
|
|
|
9
9
|
Makes a [rulecad](https://github.com/JoniBach/rulecad) workspace with one design to start from: a soap tray with
|
|
10
10
|
ribs and drain slots, every measurement a variable that names its rule. `--no-install` makes the files without
|
|
11
|
-
running `npm install`.
|
|
11
|
+
running `npm install`. It asks how you'll share models: short links keep each shared model in a secret GitHub Gist
|
|
12
|
+
(needs the `gh` command, signed in); long links carry the model and upload nothing. `--share gist` or `--share long`
|
|
13
|
+
answers in advance (without either, and with no one to ask, links stay long).
|
package/index.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// npm create rulecad [folder]: a new rulecad workspace with a design to start from (a soap tray), then npm install.
|
|
3
3
|
// --no-install make the files only
|
|
4
|
+
// --share gist short model links: each model you share is stored in a secret GitHub Gist (needs gh, signed in)
|
|
5
|
+
// --share long links that carry the whole model (nothing is uploaded; too long for chat on bigger models)
|
|
6
|
+
// Without --share it asks, in a terminal; elsewhere it keeps links long, since nothing is uploaded without a choice.
|
|
4
7
|
import fs from 'node:fs';
|
|
5
8
|
import path from 'node:path';
|
|
6
|
-
import { execSync } from 'node:child_process';
|
|
9
|
+
import { execSync, execFileSync } from 'node:child_process';
|
|
10
|
+
import readline from 'node:readline/promises';
|
|
7
11
|
import { fileURLToPath } from 'node:url';
|
|
8
12
|
|
|
9
13
|
const args = process.argv.slice(2), install = !args.includes('--no-install');
|
|
@@ -24,5 +28,24 @@ fs.writeFileSync(path.join(dir, 'package.json'), `${JSON.stringify({
|
|
|
24
28
|
}, null, 2)}\n`);
|
|
25
29
|
|
|
26
30
|
console.log(`made ${path.relative(process.cwd(), dir) || '.'}: a soap tray to start from, in projects/home`);
|
|
31
|
+
|
|
32
|
+
// How models are shared: short links need somewhere to keep the model (a secret Gist); long links carry it
|
|
33
|
+
let share = args.includes('--share') ? args[args.indexOf('--share') + 1] : null;
|
|
34
|
+
if (share && !['gist', 'long'].includes(share)) { console.error(`--share is gist or long (got "${share}")`); process.exit(1); }
|
|
35
|
+
if (!share && process.stdin.isTTY && process.stdout.isTTY) {
|
|
36
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
37
|
+
const a = await rl.question('\nModel links: short ones are easy to paste into chat, but each model you share is stored in a secret\nGitHub Gist (needs the gh command, signed in). Long ones carry the model and upload nothing. Short links? [y/N] ');
|
|
38
|
+
rl.close();
|
|
39
|
+
share = /^y/i.test(a.trim()) ? 'gist' : 'long';
|
|
40
|
+
}
|
|
41
|
+
if (share === 'gist') {
|
|
42
|
+
const cfg = path.join(dir, 'cad.config.json'), c = JSON.parse(fs.readFileSync(cfg, 'utf8'));
|
|
43
|
+
c.targets = { ...c.targets, shorten: 'gist' };
|
|
44
|
+
fs.writeFileSync(cfg, `${JSON.stringify(c, null, 2)}\n`);
|
|
45
|
+
let ready = true;
|
|
46
|
+
try { execFileSync('gh', ['auth', 'status'], { stdio: 'ignore' }); } catch { ready = false; }
|
|
47
|
+
console.log(ready ? 'short links: models you share go into secret Gists (unlisted: only people with the link find them)'
|
|
48
|
+
: 'short links are on, but the gh command isn\'t installed or signed in: install it from cli.github.com and run gh auth login');
|
|
49
|
+
} else console.log(`model links carry the whole model${share ? '' : ' (no --share given)'}; for short ones later, add "shorten": "gist" to "targets" in cad.config.json`);
|
|
27
50
|
if (install) execSync('npm install', { cwd: dir, stdio: 'inherit' });
|
|
28
51
|
console.log(`\n cd ${path.relative(process.cwd(), dir)}\n npx cad check home/soap-tray\n npx cad preview home/soap-tray\n\nREADME.md says what's where.`);
|
package/package.json
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -62,7 +62,8 @@ variable says which rule it comes from. Follow these steps; they're what makes a
|
|
|
62
62
|
|
|
63
63
|
## Talking to the person
|
|
64
64
|
- Give links as one labelled line (`npx cad link <project>/<object> --md`), never a raw URL. If it says
|
|
65
|
-
"(not a release)", say so.
|
|
65
|
+
"(not a release)", say so. If it says the link is too long for chat, don't paste it: tell the person, and offer
|
|
66
|
+
short links (a secret Gist), which upload the model, so ask first.
|
|
66
67
|
- Say what the checks found, with numbers. Ask before anything that leaves the computer: releases with `--push`,
|
|
67
68
|
ordering boards, publishing.
|
|
68
69
|
- Designs are code: only run designs you or the person trust. Links and rule files are data and never run.
|