-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to surface JSPM dependencies in package.json and wire-up Snyk…
… job to use this workaround
- Loading branch information
1 parent
ce636f1
commit c4f5a64
Showing
4 changed files
with
52 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 |
---|---|---|
|
@@ -60,3 +60,5 @@ metals.sbt | |
.bloop | ||
.bsp | ||
|
||
v1_jspm_snyk_workaround/package-lock.json | ||
v1_jspm_snyk_workaround/result |
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,32 @@ | ||
const fs = require("fs"); | ||
|
||
const outputDirName = "result" | ||
const outputPath = `${outputDirName}/package.json`; | ||
|
||
const packageJson = JSON.parse(String(fs.readFileSync("../package.json"))); | ||
|
||
const jspmDependencies = Object.fromEntries( | ||
Object.values(packageJson.jspm.dependencies) // values because we don't care about what JSPM called them (i.e. the keys) | ||
.filter(_ => !_.includes("systemjs")) | ||
.map(jspmDepString => { | ||
const [source, nameAtVersion] = jspmDepString.split(":"); | ||
const [name, version] = nameAtVersion.split("@"); | ||
return [ | ||
name.split("/").slice(-1), // last part (e.g. 'fastselect' if 'dbrekalo/fastselect') | ||
source === "github" ? `git+/~https://github.com/${name}.git#${version}` : version | ||
] | ||
}) | ||
); | ||
|
||
const newPackageJson = { | ||
...packageJson, | ||
dependencies: { | ||
...packageJson.dependencies, | ||
...jspmDependencies | ||
} | ||
}; | ||
|
||
fs.mkdirSync(outputDirName, {recursive: true}); | ||
fs.writeFileSync(outputPath, JSON.stringify(newPackageJson, null, 2)); | ||
|
||
console.log(`Wrote alternate package.json for V1 to v1_jspm_workaround/${outputPath} , which surfaces the JSPM dependencies`) |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"preinstall": "node jspm-snyk-workaround.js" | ||
} | ||
} |