[E00-S01-T07] Commit and lock in pnpm 11.23.0 workspace #374
@@ -0,0 +1,86 @@
|
|||||||
|
/**
|
||||||
|
* Workspace configuration test — locks in the committed pnpm 11.23.0
|
||||||
|
* workspace for [E00-S01-T07] pnpm 11.23.0 workspace committed.
|
||||||
|
*
|
||||||
|
* Acceptance criteria covered (each test fails without the committed config):
|
||||||
|
* - "pnpm 11.23.0 workspace is committed" → root `package.json` pins
|
||||||
|
* `packageManager` to `pnpm@11.23.0`; `pnpm-workspace.yaml` declares the
|
||||||
|
* three package groups; `pnpm-lock.yaml` is committed with lockfile
|
||||||
|
* version 9.0 and an importer for every workspace package.
|
||||||
|
* - "install uses the committed pnpm version" → corepack resolves the
|
||||||
|
* pinned version (`corepack pnpm --version` == 11.23.0), and the
|
||||||
|
* committed CI workflow enables corepack and installs with
|
||||||
|
* `--frozen-lockfile` so the lockfile is the single source of truth.
|
||||||
|
*
|
||||||
|
* Run: `node --test tests/workspace-config.test.mjs`
|
||||||
|
* (node:test — built into Node >= 18; no dependencies, lockfile untouched.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
|
|
||||||
|
const read = (relPath) => readFileSync(path.join(REPO_ROOT, relPath), 'utf8');
|
||||||
|
|
||||||
|
const WORKSPACE_GROUPS = ['apps/*', 'packages/*', 'extensions/*'];
|
||||||
|
const WORKSPACE_PACKAGES = ['.', 'apps/server', 'packages/core', 'extensions/example'];
|
||||||
|
const PINNED_PNPM = '11.23.0';
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Tests
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
test('root package.json pins packageManager to pnpm@11.23.0', () => {
|
||||||
|
const manifest = JSON.parse(read('package.json'));
|
||||||
|
assert.equal(manifest.packageManager, `pnpm@${PINNED_PNPM}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('pnpm-workspace.yaml is committed and declares the three workspace groups', () => {
|
||||||
|
const workspace = read('pnpm-workspace.yaml');
|
||||||
|
for (const group of WORKSPACE_GROUPS) {
|
||||||
|
assert.ok(workspace.includes(group), `pnpm-workspace.yaml must declare group "${group}"`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('pnpm-lock.yaml is committed with lockfile version 9.0', () => {
|
||||||
|
const lockfile = read('pnpm-lock.yaml');
|
||||||
|
assert.ok(
|
||||||
|
lockfile.startsWith("lockfileVersion: '9.0'"),
|
||||||
|
'pnpm-lock.yaml must be the pnpm 9.x lockfile format written by pnpm 11.23.0',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('pnpm-lock.yaml has an importer for every workspace package', () => {
|
||||||
|
const lockfile = read('pnpm-lock.yaml');
|
||||||
|
for (const pkg of WORKSPACE_PACKAGES) {
|
||||||
|
const entry = pkg === '.' ? ' .:' : ` ${pkg}:`;
|
||||||
|
assert.ok(
|
||||||
|
lockfile.includes(entry),
|
||||||
|
`pnpm-lock.yaml must contain an importer for "${pkg}"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('corepack resolves the committed pnpm version (11.23.0)', () => {
|
||||||
|
const result = spawnSync('corepack', ['pnpm', '--version'], {
|
||||||
|
cwd: REPO_ROOT,
|
||||||
|
encoding: 'utf8',
|
||||||
|
timeout: 60_000,
|
||||||
|
});
|
||||||
|
assert.equal(result.status, 0, `corepack pnpm --version failed: ${result.stderr?.trim()}`);
|
||||||
|
assert.equal(result.stdout.trim(), PINNED_PNPM);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('committed CI workflow enables corepack and installs with the frozen lockfile', () => {
|
||||||
|
const workflow = read('.gitea/workflows/ci.yml');
|
||||||
|
assert.ok(workflow.includes('corepack enable'), 'CI must enable corepack (pinned pnpm)');
|
||||||
|
assert.ok(
|
||||||
|
workflow.includes('pnpm install --frozen-lockfile'),
|
||||||
|
'CI must install with the committed lockfile (--frozen-lockfile)',
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user