@rulecad/cad 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/lib/versions.mjs +5 -4
  2. package/package.json +1 -1
package/lib/versions.mjs CHANGED
@@ -65,15 +65,16 @@ export function materialise(d, version) {
65
65
  // ---------- what changed: compare() is @rulecad/versions' (exported above) ----------
66
66
 
67
67
  // The board engine's identity: its code and the tscircuit it runs on. A board's release tag records it ("engine: …").
68
- // A package's version, from the package.json above its entry point (some packages don't export their package.json)
69
- export function packageVersion(name) {
70
- for (let dir = path.dirname(createRequire(import.meta.url).resolve(name)); dir !== path.dirname(dir); dir = path.dirname(dir)) {
68
+ // A package's version, from the package.json above its entry point (some packages don't export their package.json).
69
+ // from: where to look from (a file URL), when it's another package's dependency, as tscircuit is the board engine's
70
+ export function packageVersion(name, from = import.meta.url) {
71
+ for (let dir = path.dirname(createRequire(from).resolve(name)); dir !== path.dirname(dir); dir = path.dirname(dir)) {
71
72
  const f = path.join(dir, 'package.json');
72
73
  if (fs.existsSync(f)) { const pj = JSON.parse(fs.readFileSync(f, 'utf8')); if (pj.name === name) return pj.version; }
73
74
  }
74
75
  return '';
75
76
  }
76
- const tscircuitVersion = () => packageVersion('tscircuit');
77
+ const tscircuitVersion = () => packageVersion('tscircuit', import.meta.resolve('@rulecad/pcb'));
77
78
  const engineHash = (code) => crypto.createHash('sha256').update(`${code.trimEnd()}\n${tscircuitVersion()}`).digest('hex').slice(0, 16);
78
79
  export const engineId = () => engineHash(fs.readFileSync(new URL(import.meta.resolve('@rulecad/pcb')), 'utf8'));
79
80
  // From a tag's message, or for releases before tags recorded it, from the engine's code in the repo at the tag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/cad",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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": {