Skip to content

Commit

Permalink
fix(pnpm): revert lockfile upgrade (#9862)
Browse files Browse the repository at this point in the history
Reverts #9854
  • Loading branch information
tknickman authored Jan 31, 2025
1 parent 072e73b commit b2a8034
Show file tree
Hide file tree
Showing 3 changed files with 5,651 additions and 7,443 deletions.
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

0 comments on commit b2a8034

Please sign in to comment.