mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
6fb4bb543a
Migrate package management from npm + Corepack to pnpm across the root,
web, and website workspaces:
- Swap npm/Corepack tooling for pnpm: drop package-lock.json files and the
bespoke Corepack bootstrap scripts (setup-corepack.mjs, utils/corepack.mjs,
lint-lockfile.mjs); add pnpm-lock.yaml + pnpm-workspace.yaml per workspace.
- CI uses the official pnpm/action-setup + actions/setup-node; pin the pnpm
store dir via PNPM_HOME so setup-node's `cache: pnpm` post-step succeeds.
- Docker sources pnpm from the official ghcr.io/pnpm/pnpm image via a
${BUILDPLATFORM}-pinned stage; the website docs build does a hoisted root
install so @goauthentik/docusaurus-config resolves its own deps.
- Gate the web install on the `node` dep so runtime-only jobs don't invoke
pnpm; scope the from-stable env setup so the new tooling doesn't run against
the stable checkout's npm packageManager field.
- Resolve @goauthentik/api (client-ts) from its TypeScript source instead of a
tsc-built dist, so it no longer depends on an install-time prepare having run
(the storybook build's environment never built it); sfe's rollup gains .ts
resolution to match.
- Netlify builds with pnpm; encode pnpm's supply-chain controls
(onlyBuiltDependencies/allowBuilds, minimumReleaseAge) in the workspace.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
96 lines
3.0 KiB
JavaScript
Executable File
96 lines
3.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
/**
|
|
* @file Lints the installed Node.js and pnpm versions against the requirements specified in package.json.
|
|
*
|
|
* Usage:
|
|
* lint-runtime [options] [directory]
|
|
*
|
|
* Exit codes:
|
|
* 0 Versions are in sync
|
|
* 1 Version mismatch detected
|
|
*/
|
|
|
|
import * as assert from "node:assert/strict";
|
|
import { parseArgs } from "node:util";
|
|
|
|
import { ConsoleLogger } from "../../packages/logger-js/lib/node.js";
|
|
import { parseCWD, reportAndExit } from "./utils/commands.mjs";
|
|
import { resolveRepoRoot } from "./utils/git.mjs";
|
|
import { compareVersions, findNPMPackage, loadJSON, node, pnpm, parseRange } from "./utils/node.mjs";
|
|
|
|
const logger = ConsoleLogger.prefix("lint-runtime");
|
|
|
|
/**
|
|
* @param {string} start
|
|
*/
|
|
async function readRequirements(start) {
|
|
const { packageJSONPath } = await findNPMPackage(start);
|
|
|
|
logger.info(`Checking versions in ${packageJSONPath}`);
|
|
|
|
const packageJSONData = await loadJSON(packageJSONPath);
|
|
|
|
const nodeVersion = await node`--version`().then((output) => output.replace(/^v/, ""));
|
|
|
|
const requiredPnpmVersion = packageJSONData.engines?.pnpm;
|
|
const requiredNodeVersion = packageJSONData.engines?.node;
|
|
|
|
return { nodeVersion, requiredPnpmVersion, requiredNodeVersion };
|
|
}
|
|
|
|
async function main() {
|
|
const parsedArgs = parseArgs({
|
|
allowPositionals: true,
|
|
});
|
|
|
|
const cwd = parseCWD(parsedArgs.positionals);
|
|
const repoRoot = await resolveRepoRoot(cwd).catch(() => null);
|
|
|
|
logger.info(`cwd ${cwd}`);
|
|
logger.info(`repository ${repoRoot || "not found"}`);
|
|
|
|
const pnpmVersion = await pnpm`--version`({ cwd }).catch((error) => {
|
|
logger.warn(`Failed to read pnpm version: ${error.message}`);
|
|
return null;
|
|
});
|
|
|
|
if (pnpmVersion) {
|
|
logger.info(`pnpm ${pnpmVersion}`);
|
|
}
|
|
|
|
const { nodeVersion, requiredPnpmVersion, requiredNodeVersion } = await readRequirements(cwd);
|
|
|
|
logger.info(`node ${nodeVersion}`);
|
|
|
|
if (requiredPnpmVersion && pnpmVersion) {
|
|
logger.info(`package.json pnpm ${requiredPnpmVersion}`);
|
|
|
|
const { operator, version: required } = parseRange(requiredPnpmVersion);
|
|
const result = compareVersions(pnpmVersion, required);
|
|
|
|
assert.ok(
|
|
operator === ">=" ? result >= 0 : result === 0,
|
|
`pnpm version ${pnpmVersion} does not satisfy required version ${requiredPnpmVersion}`,
|
|
);
|
|
}
|
|
|
|
if (requiredNodeVersion) {
|
|
logger.info(`package.json node ${requiredNodeVersion}`);
|
|
|
|
const { operator, version: required } = parseRange(requiredNodeVersion);
|
|
const result = compareVersions(nodeVersion, required);
|
|
|
|
assert.ok(
|
|
operator === ">=" ? result >= 0 : result === 0,
|
|
`Node.js version ${nodeVersion} does not satisfy required version ${requiredNodeVersion}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
main()
|
|
.then(() => {
|
|
logger.info("✅ Node.js and pnpm versions are in sync.");
|
|
process.exit(0);
|
|
})
|
|
.catch((error) => reportAndExit(error, logger));
|