-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pnpm): revert lockfile upgrade (#9862)
Reverts #9854
- Loading branch information
Showing
3 changed files
with
5,651 additions
and
7,443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Oops, something went wrong.