Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/test/test-version-utils/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ lib/test
# Default .npmignore rules only include the root node_modules.
# Adding an explicit rule here ensures we don't publish the compat_workspace's node_modules.
**/node_modules
# Preserve the .npmrc file in the compat-workspaces folder so that its settings apply to the postinstall script in test-version-utils
!compat-workspaces/.npmrc
Comment thread
Abe27342 marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node-linker=isolated
frozen-lockfile=true
engine-strict=true
strict-peer-dependencies=true
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"license": "MIT",
"author": "Microsoft and contributors",
"scripts": {
"preinstall": "node ../scripts/only-pnpm.cjs"
"preinstall": "node ./scripts/only-pnpm.cjs"
}
}
2 changes: 1 addition & 1 deletion packages/test/test-version-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"eslint:fix": "eslint --quiet --format stylish src --fix --fix-type problem,suggestion,layout",
"format": "npm run format:biome",
"format:biome": "biome check . --write",
"postinstall": "pnpm --dir compat-workspaces/full install --frozen-lockfile",
"postinstall": "pnpm --dir compat-workspaces/full install",
Comment thread
Abe27342 marked this conversation as resolved.
"lint": "fluid-build . --task lint",
"lint:fix": "fluid-build . --task eslint:fix --task format",
"test": "npm run test:mocha",
Expand Down
19 changes: 14 additions & 5 deletions packages/test/test-version-utils/scripts/updateCompatVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
* 3. Writes `compat-workspaces/generated-versions.cjs` with the resolved exact versions.
* 4. Creates or updates per-version `package.json` files in `compat-workspaces/full/`.
* 5. Removes version directories that are no longer needed.
* 6. Runs `pnpm install --no-frozen-lockfile` in the workspace to regenerate the lockfile.
* 6. Runs `pnpm install --no-frozen-lockfile [extra args]` in the workspace to regenerate the lockfile.
*
* Commit all files produced by this script, including the updated `pnpm-lock.yaml`.
*
* Any extra arguments passed to this script are forwarded verbatim to `pnpm install`. For example:
*
* pnpm run update-compat-versions -- --lockfile-only
* pnpm run update-compat-versions -- --store-dir /custom/store
*
* MACHINE-MAINTAINED (do not edit by hand — regenerated by this script):
* compat-workspaces/generated-versions.cjs
* compat-workspaces/full/<version>/package.json (one per version)
Expand Down Expand Up @@ -204,9 +209,10 @@ function removeStaleVersionDirs(workspaceDir: string, keepVersions: Set<string>)
return removed;
}

function pnpmInstallWorkspace(workspaceDir: string): void {
console.log(`\nRunning pnpm install in ${path.relative(pkgRoot, workspaceDir)} ...`);
execSync(`pnpm install --no-frozen-lockfile`, {
function pnpmInstallWorkspace(workspaceDir: string, extraPnpmArgs: string[] = []): void {
const args = ["install", "--no-frozen-lockfile", ...extraPnpmArgs].join(" ");
console.log(`\nRunning pnpm ${args} in ${path.relative(pkgRoot, workspaceDir)} ...`);
execSync(`pnpm ${args}`, {
cwd: workspaceDir,
Comment thread
Abe27342 marked this conversation as resolved.
env: { ...process.env, NODE_OPTIONS: "" },
stdio: "inherit",
Expand All @@ -218,6 +224,9 @@ function pnpmInstallWorkspace(workspaceDir: string): void {
// ---------------------------------------------------------------------------

async function main(): Promise<void> {
// Any arguments after the script name are forwarded to pnpm install.
const extraPnpmArgs = process.argv.slice(2);

// Read current package version
const pkgJsonPath = path.join(pkgRoot, "package.json");
const { version: pkgVer } = JSON.parse(readFileSync(pkgJsonPath, "utf8")) as {
Expand Down Expand Up @@ -331,7 +340,7 @@ async function main(): Promise<void> {

if (anyChanged) {
// Regenerate lockfile
pnpmInstallWorkspace(fullDir);
pnpmInstallWorkspace(fullDir, extraPnpmArgs);

console.log("\nDone. Commit all changes in compat-workspaces/ to the repository.");
} else {
Expand Down
Loading