-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add script to gen prod lockfile (#9)
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
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
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,28 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const { execSync } = require('child_process') | ||
|
||
const cwd = process.cwd() | ||
|
||
const run = (cmd) => execSync(cmd, { encoding: 'utf8' }) | ||
|
||
const pkgJsonPaths = run(`find . -name package.json -type f | grep -v /node_modules/`) | ||
.trim() | ||
.split('\n') | ||
.map((filePath) => filePath.trim()) | ||
.filter(Boolean) | ||
.map((filePath) => path.resolve(cwd, filePath)) | ||
|
||
for (const pkgJsonPath of pkgJsonPaths) { | ||
const pkgJson = require(pkgJsonPath) | ||
if (!pkgJson.devDependencies) continue | ||
|
||
console.log(`found devDependencies in: ${pkgJsonPath}`) | ||
delete pkgJson.devDependencies | ||
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2)) | ||
} | ||
|
||
run(`yarn install && \ | ||
echo "yarn.lock now contains only prod deps. After you're done with it, don't forget to kill all unstaged changes."`) |