Skip to content

Commit b2a8034

Browse files
authored
fix(pnpm): revert lockfile upgrade (#9862)
Reverts #9854
1 parent 072e73b commit b2a8034

File tree

3 files changed

+5651
-7443
lines changed

3 files changed

+5651
-7443
lines changed

examples/install-all.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { execSync } from "child_process";
2+
import { readdirSync, existsSync, readFileSync } from "fs";
3+
import * as path from "path";
4+
5+
/** 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 */
6+
7+
const examplesDir = path.resolve(__dirname);
8+
9+
/** Get all directories in the examples folder */
10+
const exampleDirs = readdirSync(examplesDir).filter((dir) =>
11+
existsSync(path.join(examplesDir, dir, "package.json"))
12+
);
13+
14+
exampleDirs.forEach((dir) => {
15+
const packageJsonPath = path.join(examplesDir, dir, "package.json");
16+
17+
try {
18+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
19+
20+
// Check the packageManager field and run the correct install command
21+
const packageManager: string = packageJson.packageManager;
22+
if (!packageManager) {
23+
throw new Error(`Missing packageManager field in ${packageJsonPath}`);
24+
}
25+
26+
let installCmd: string;
27+
28+
if (packageManager.startsWith("pnpm")) {
29+
installCmd = "pnpm install";
30+
} else if (packageManager.startsWith("yarn")) {
31+
installCmd = "yarn install";
32+
} else if (packageManager.startsWith("npm")) {
33+
installCmd = "npm install";
34+
} else {
35+
throw new Error(`Unknown package manager "${packageManager}" in ${dir}`);
36+
}
37+
38+
console.log(`Running ${installCmd} in ${dir}...`);
39+
execSync(installCmd, {
40+
stdio: "inherit",
41+
cwd: path.join(examplesDir, dir),
42+
});
43+
} catch (error) {
44+
throw new Error(`Failed to process ${packageJsonPath}: ${error}`);
45+
}
46+
});

examples/package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"name": "turborepo-examples"
2+
"name": "turborepo-examples",
3+
"scripts": {
4+
"install-all": "tsx install-all.ts"
5+
},
6+
"devDependencies": {
7+
"tsx": "4.19.1"
8+
}
39
}

0 commit comments

Comments
 (0)