-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff62c8b
commit 15a1e14
Showing
4 changed files
with
1,466 additions
and
1,605 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
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,40 @@ | ||
import {readFileSync, writeFileSync} from "fs"; | ||
|
||
const pkg = JSON.parse(readFileSync("package-lock.json")); | ||
|
||
let out = {}; | ||
let deps = {}; | ||
|
||
[...Object.entries(pkg.dependencies), ...Object.entries(pkg.packages)].forEach(i => { | ||
let name = i[0]; | ||
let versionobj = i[1]; | ||
|
||
if (name.startsWith('node_modules/')){ | ||
name = name.replace('node_modules/', ''); | ||
} | ||
if (name.includes('/node_modules/')){ | ||
let parent = name.split('/node_modules/')[0]; | ||
let nm = name.split('/node_modules/')[1]; | ||
let existing = out[parent] || {} | ||
if (typeof existing === 'string'){ | ||
deps[parent] = existing; | ||
existing = {}; | ||
} | ||
name = parent; | ||
versionobj = { | ||
...existing, | ||
[nm]: i[1].version, | ||
} | ||
} else { | ||
versionobj = i[1].version; | ||
} | ||
out[name] = versionobj; | ||
}) | ||
|
||
let newPkg = JSON.parse(readFileSync('package.json')); | ||
|
||
newPkg.overrides = out; | ||
console.log(deps); | ||
newPkg.dependencies = {...(newPkg.dependencies || {}), ...deps}; | ||
|
||
writeFileSync("package.json", JSON.stringify(newPkg, null, 2)) |
Oops, something went wrong.