Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(pnpm): revert lockfile upgrade #9862

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 46 additions & 0 deletions examples/install-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { execSync } from "child_process";
import { readdirSync, existsSync, readFileSync } from "fs";
import * as path from "path";

/** Note: this script intentionally doesn't run during regular `pnpm install` from the project root because it's not something we expect to need to do all the time and integrating it into the project install flow is excessive */

const examplesDir = path.resolve(__dirname);

/** Get all directories in the examples folder */
const exampleDirs = readdirSync(examplesDir).filter((dir) =>
existsSync(path.join(examplesDir, dir, "package.json"))
);

exampleDirs.forEach((dir) => {
const packageJsonPath = path.join(examplesDir, dir, "package.json");

try {
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));

// Check the packageManager field and run the correct install command
const packageManager: string = packageJson.packageManager;
if (!packageManager) {
throw new Error(`Missing packageManager field in ${packageJsonPath}`);
}

let installCmd: string;

if (packageManager.startsWith("pnpm")) {
installCmd = "pnpm install";
} else if (packageManager.startsWith("yarn")) {
installCmd = "yarn install";
} else if (packageManager.startsWith("npm")) {
installCmd = "npm install";
} else {
throw new Error(`Unknown package manager "${packageManager}" in ${dir}`);
}

console.log(`Running ${installCmd} in ${dir}...`);
execSync(installCmd, {
stdio: "inherit",
cwd: path.join(examplesDir, dir),
});
} catch (error) {
throw new Error(`Failed to process ${packageJsonPath}: ${error}`);
}
});
8 changes: 7 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"name": "turborepo-examples"
"name": "turborepo-examples",
"scripts": {
"install-all": "tsx install-all.ts"
},
"devDependencies": {
"tsx": "4.19.1"
}
}
Loading
Loading