@henols/c64-re-tools 2.0.0 → 2.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 CHANGED
@@ -51,7 +51,7 @@ npx -y --package=@henols/c64-re-tools@latest c64-re-tools-host
51
51
 
52
52
  ### Dev container
53
53
 
54
- This is the preferred way. The container gets ACME, dxa, Java 21 and Ghidra,
54
+ This is the preferred way. The container gets Node.js 24, ACME, dxa, Java 21 and Ghidra,
55
55
  installs the toolkit into the project when it is created, and updates it at
56
56
  each start. Add to `.devcontainer/devcontainer.json`:
57
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henols/c64-re-tools",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Agent-friendly Commodore 64 engineering toolkit for reverse engineering, debugging, development and testing.",
5
5
  "license": "MIT",
6
6
  "author": "Henrik Olsson",
package/src/cli/main.ts CHANGED
@@ -7,7 +7,7 @@ import { dirname, join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { parseArgs } from "node:util";
9
9
 
10
- import { PACKAGE } from "../package.ts";
10
+ import { oldNodeRefusal, PACKAGE } from "../package.ts";
11
11
  import { localToolContext } from "../native/local.ts";
12
12
  import { localToolStatus } from "../native/status.ts";
13
13
  import { WireFailure } from "../protocol/messages.ts";
@@ -112,6 +112,12 @@ async function main(argv: string[]): Promise<number> {
112
112
  }
113
113
  }
114
114
 
115
+ const oldNode = oldNodeRefusal();
116
+ if (oldNode !== undefined) {
117
+ console.error(oldNode);
118
+ process.exit(1);
119
+ }
120
+
115
121
  try {
116
122
  process.exitCode = await main(process.argv.slice(2));
117
123
  } catch (error) {
package/src/host/main.ts CHANGED
@@ -11,7 +11,7 @@ import { inspect } from "./tools/c1541.ts";
11
11
  import { createToolDispatcher } from "./tools/index.ts";
12
12
  import { checkViceStarts, findVice } from "./vice/process.ts";
13
13
  import { viceSessionFactory } from "./vice/session.ts";
14
- import { PACKAGE } from "../package.ts";
14
+ import { oldNodeRefusal, PACKAGE } from "../package.ts";
15
15
 
16
16
  const HELP = `c64-re-tools-host
17
17
 
@@ -144,4 +144,10 @@ async function main(): Promise<number> {
144
144
  return 0;
145
145
  }
146
146
 
147
+ const oldNode = oldNodeRefusal();
148
+ if (oldNode !== undefined) {
149
+ log(oldNode);
150
+ process.exit(1);
151
+ }
152
+
147
153
  process.exitCode = await main();
package/src/mcp/main.ts CHANGED
@@ -13,7 +13,7 @@ import { machineTools } from "./tools/machine.ts";
13
13
  import { mediaTools } from "./tools/media.ts";
14
14
  import { memoryTools } from "./tools/memory.ts";
15
15
  import { videoTools } from "./tools/video.ts";
16
- import { PACKAGE } from "../package.ts";
16
+ import { oldNodeRefusal, PACKAGE } from "../package.ts";
17
17
 
18
18
  const HELP = `c64-re-tools-mcp
19
19
 
@@ -131,4 +131,10 @@ async function main(): Promise<void> {
131
131
  await server.connect(new StdioServerTransport());
132
132
  }
133
133
 
134
+ const oldNode = oldNodeRefusal();
135
+ if (oldNode !== undefined) {
136
+ log(oldNode);
137
+ process.exit(1);
138
+ }
139
+
134
140
  await main();
package/src/package.ts CHANGED
@@ -14,8 +14,18 @@ export function channelOf(version: string): "latest" | "next" {
14
14
  return version.includes("-") ? "next" : "latest";
15
15
  }
16
16
 
17
- /** The name, version and dist-tag of this npm package, from its package.json. */
17
+ /** The name, version and dist-tag of this npm package, and the Node.js major version that its engines field requires. */
18
18
  export const PACKAGE = (() => {
19
- const metadata = JSON.parse(readFileSync(join(import.meta.dirname, "..", "package.json"), "utf8")) as { name: string; version: string };
20
- return { name: metadata.name, version: metadata.version, tag: channelOf(metadata.version) };
19
+ const metadata = JSON.parse(readFileSync(join(import.meta.dirname, "..", "package.json"), "utf8")) as { name: string; version: string; engines?: { node?: string } };
20
+ const nodeMajor = Number(/(\d+)/.exec(metadata.engines?.node ?? "")?.[1]);
21
+ return { name: metadata.name, version: metadata.version, tag: channelOf(metadata.version), nodeMajor: Number.isInteger(nodeMajor) ? nodeMajor : undefined };
21
22
  })();
23
+
24
+ /**
25
+ * The refusal for a Node.js older than `required`, or undefined. An older Node.js
26
+ * cannot run the skill scripts: they are TypeScript and use node:sqlite.
27
+ */
28
+ export function oldNodeRefusal(version: string = process.versions.node, required: number | undefined = PACKAGE.nodeMajor): string | undefined {
29
+ if (required === undefined || Number(version.split(".")[0]) >= required) return undefined;
30
+ return `c64-re-tools needs Node.js ${required} or newer, and this is Node.js ${version}. Install Node.js ${required} from https://nodejs.org/ and run the command again.`;
31
+ }