diff --git a/.changeset/bright-nodes-align.md b/.changeset/bright-nodes-align.md new file mode 100644 index 0000000..00dc533 --- /dev/null +++ b/.changeset/bright-nodes-align.md @@ -0,0 +1,5 @@ +--- +'@ankhorage/devtools': minor +--- + +Add the canonical Node 24 LTS tooling policy and render managed CI/release workflows from the shared Bun and Node runtime baselines. diff --git a/src/policy/bunRuntimePolicy.ts b/src/policy/bunRuntimePolicy.ts index 3c1fe3a..5529198 100644 --- a/src/policy/bunRuntimePolicy.ts +++ b/src/policy/bunRuntimePolicy.ts @@ -1,11 +1,24 @@ /** - * Canonical Bun runtime policy for Ankhorage repositories. + * Canonical runtime/tooling policies for Ankhorage repositories. * - * Import this from `@ankhorage/devtools/policy` when another package needs to inspect - * the managed Bun version without defining an independent version authority. + * Import these from `@ankhorage/devtools/policy` when another package needs to inspect + * the managed Bun or Node baseline without defining an independent version authority. */ export const bunRuntimePolicy = { packageManager: 'bun@1.3.14', typesRange: '^1.3.14', version: '1.3.14', } as const; + +/** + * Canonical Node LTS baseline for Node-based Ankhorage tooling and CI execution. + * + * Bun remains the repository package manager/primary command runtime where configured; + * this policy makes Node-based tooling deterministic instead of inheriting the ambient + * Node version from a CI runner image. + */ +export const nodeRuntimePolicy = { + engineRange: '24.x', + major: 24, + setupVersion: '24', +} as const; diff --git a/src/tools/workflows/files/ci.yml b/src/tools/workflows/files/ci.yml index b5881ae..220a2b2 100644 --- a/src/tools/workflows/files/ci.yml +++ b/src/tools/workflows/files/ci.yml @@ -24,6 +24,11 @@ jobs: with: bun-version: '__ANKH_BUN_VERSION__' + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '__ANKH_NODE_VERSION__' + - name: Install dependencies run: bun install --frozen-lockfile diff --git a/src/tools/workflows/files/release.yml b/src/tools/workflows/files/release.yml index b3b60ec..45ad211 100644 --- a/src/tools/workflows/files/release.yml +++ b/src/tools/workflows/files/release.yml @@ -32,7 +32,7 @@ jobs: - name: Setup Node for npm publishing uses: actions/setup-node@v4 with: - node-version: 24 + node-version: '__ANKH_NODE_VERSION__' registry-url: https://registry.npmjs.org - name: Update npm diff --git a/src/tools/workflows/index.test.ts b/src/tools/workflows/index.test.ts new file mode 100644 index 0000000..3599a7d --- /dev/null +++ b/src/tools/workflows/index.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, test } from 'bun:test'; + +import { bunRuntimePolicy, nodeRuntimePolicy } from '../../policy/bunRuntimePolicy.js'; +import { workflowManagedFiles } from './index.js'; + +describe('managed workflows', () => { + test('render the canonical Bun and Node runtime policies', async () => { + for (const definition of workflowManagedFiles) { + expect(definition.render).toBeDefined(); + const rendered = await definition.render?.('.'); + expect(rendered).toContain(`bun-version: '${bunRuntimePolicy.version}'`); + expect(rendered).toContain(`node-version: '${nodeRuntimePolicy.setupVersion}'`); + expect(rendered).not.toContain('__ANKH_BUN_VERSION__'); + expect(rendered).not.toContain('__ANKH_NODE_VERSION__'); + } + }); +}); diff --git a/src/tools/workflows/index.ts b/src/tools/workflows/index.ts index 7e4c341..f6a5a20 100644 --- a/src/tools/workflows/index.ts +++ b/src/tools/workflows/index.ts @@ -1,9 +1,10 @@ import { readFile } from 'node:fs/promises'; -import { bunRuntimePolicy } from '../../policy/bunRuntimePolicy.js'; +import { bunRuntimePolicy, nodeRuntimePolicy } from '../../policy/bunRuntimePolicy.js'; import type { ManagedFileDefinition } from '../shared/managedFiles.js'; const BUN_VERSION_TOKEN = '__ANKH_BUN_VERSION__'; +const NODE_VERSION_TOKEN = '__ANKH_NODE_VERSION__'; export const workflowManagedFiles = [ createWorkflowDefinition('.github/workflows/ci.yml', './files/ci.yml'), @@ -16,7 +17,9 @@ function createWorkflowDefinition(relativePath: string, sourcePath: string): Man relativePath, render: async () => { const template = await readFile(sourceUrl, 'utf8'); - return template.replaceAll(BUN_VERSION_TOKEN, bunRuntimePolicy.version); + return template + .replaceAll(BUN_VERSION_TOKEN, bunRuntimePolicy.version) + .replaceAll(NODE_VERSION_TOKEN, nodeRuntimePolicy.setupVersion); }, }; }