@rulecad/cad 0.1.3 → 0.1.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/bin/cad.mjs +2 -2
- package/lib/versions.mjs +10 -4
- package/package.json +2 -3
package/bin/cad.mjs
CHANGED
|
@@ -215,10 +215,10 @@ async function board(cmd, d, b, { title, version, tag }) {
|
|
|
215
215
|
}
|
|
216
216
|
// export: exports/<project>/<name>-fab.zip (Gerbers, drills, BOM, placement: upload it to JLCPCB as it is), KiCad's
|
|
217
217
|
// board and schematic beside it, and the matrix for firmware
|
|
218
|
-
const dir = paths.exports(d.project), {
|
|
218
|
+
const dir = paths.exports(d.project), { zip: zipOf } = await import('@rulecad/model-link');
|
|
219
219
|
fs.mkdirSync(dir, { recursive: true });
|
|
220
220
|
const fab = await pcb.fabFiles(b.circuit, d.name), zip = path.join(dir, `${name}-fab.zip`);
|
|
221
|
-
fs.writeFileSync(zip,
|
|
221
|
+
fs.writeFileSync(zip, await zipOf(Object.entries(fab)));
|
|
222
222
|
const written = [zip];
|
|
223
223
|
for (const [f, t] of Object.entries(await pcb.kicadFiles(b.circuit, name))) { fs.writeFileSync(path.join(dir, f), t); written.push(path.join(dir, f)); }
|
|
224
224
|
if (b.matrix) { const f = path.join(dir, `${name}-matrix.json`); fs.writeFileSync(f, JSON.stringify(b.matrix, null, 2) + '\n'); written.push(f); }
|
package/lib/versions.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import fs from 'node:fs';
|
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { execFileSync } from 'node:child_process';
|
|
9
9
|
import { createRequire } from 'node:module';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
10
11
|
import crypto from 'node:crypto';
|
|
11
12
|
import { resolve, loadRuleSet } from './rules.mjs';
|
|
12
13
|
import { WS, paths } from './workspace.mjs';
|
|
@@ -64,7 +65,8 @@ export function materialise(d, version) {
|
|
|
64
65
|
|
|
65
66
|
// ---------- what changed: compare() is @rulecad/versions' (exported above) ----------
|
|
66
67
|
|
|
67
|
-
// The board engine's identity: its code and the
|
|
68
|
+
// The board engine's identity: all its code, and the versions of the libraries that route, place and check a board. A
|
|
69
|
+
// board's release tag records it ("engine: …"), and the build cache keys boards on it.
|
|
68
70
|
// A package's version, from the package.json above its entry point (some packages don't export their package.json).
|
|
69
71
|
// from: where to look from (a file URL), when it's another package's dependency, as tscircuit is the board engine's
|
|
70
72
|
export function packageVersion(name, from = import.meta.url) {
|
|
@@ -74,9 +76,13 @@ export function packageVersion(name, from = import.meta.url) {
|
|
|
74
76
|
}
|
|
75
77
|
return '';
|
|
76
78
|
}
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
79
|
+
const ENGINE_LIBS = ['@tscircuit/capacity-autorouter', '@tscircuit/footprinter', '@tscircuit/checks', 'schematic-symbols'];
|
|
80
|
+
const engineLibs = () => ENGINE_LIBS.map((n) => `${n}@${packageVersion(n, import.meta.resolve('@rulecad/pcb'))}`).join(' ');
|
|
81
|
+
const engineHash = (code) => crypto.createHash('sha256').update(`${code.trimEnd()}\n${engineLibs()}`).digest('hex').slice(0, 16);
|
|
82
|
+
export const engineId = () => {
|
|
83
|
+
const dir = path.dirname(fileURLToPath(import.meta.resolve('@rulecad/pcb')));
|
|
84
|
+
return engineHash(fs.readdirSync(dir).filter((f) => f.endsWith('.mjs') && f !== 'test.mjs').sort().map((f) => fs.readFileSync(path.join(dir, f), 'utf8')).join('\n'));
|
|
85
|
+
};
|
|
80
86
|
// From a tag's message, or for releases before tags recorded it, from the engine's code in the repo at the tag
|
|
81
87
|
function taggedEngine(tag) {
|
|
82
88
|
const m = git('tag', '-l', '--format=%(contents)', tag).match(/^engine: (\w+)$/m);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/cad",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The cad command: JSCAD designs from traceable rules, checked for printing and fit, versioned by what fits, shared as links and exported as Bambu 3MF.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -47,12 +47,11 @@
|
|
|
47
47
|
"@rulecad/keyboard-layout": "^0.1.2",
|
|
48
48
|
"@rulecad/printcheck": "^0.1.0",
|
|
49
49
|
"@rulecad/fit": "^0.1.0",
|
|
50
|
-
"@rulecad/model-link": "^0.1.
|
|
50
|
+
"@rulecad/model-link": "^0.1.2",
|
|
51
51
|
"@rulecad/versions": "^0.1.0",
|
|
52
52
|
"@rulecad/shapes": "^0.1.0",
|
|
53
53
|
"@rulecad/rules": "^0.1.0",
|
|
54
54
|
"@jscad/modeling": "^2.12.0",
|
|
55
|
-
"fflate": "^0.8.2",
|
|
56
55
|
"three": "^0.186.1"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|