-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
3 changed files
with
851 additions
and
18 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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
"graduate": "run bump --conventional-graduate", | ||
"publish2": "run build && lerna publish from-package --pre-dist-tag next", | ||
"validate:dependencies": "yarn npm audit && run license-validate", | ||
"license-validate": "sofie-licensecheck --allowPackages \"@elgato-stream-deck/webhid-demo@$(node -p \"require('./packages/webhid-demo/package.json').version\");[email protected]\"", | ||
"license-validate": "node ./scripts/license-check.mjs", | ||
"g:tsc": "cd $INIT_CWD && tsc", | ||
"g:rimraf": "cd $INIT_CWD && rimraf", | ||
"g:husky": "./node_modules/.bin/husky", | ||
|
@@ -41,6 +41,7 @@ | |
"lerna": "^8.0.0", | ||
"rimraf": "^5.0.5", | ||
"sharp": "^0.33.0", | ||
"snyk-nodejs-lockfile-parser": "^1.52.8", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "~4.9.5", | ||
|
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,63 @@ | ||
import cp from 'child_process' | ||
import fs from 'fs/promises' | ||
import { buildDepTreeFromFiles } from 'snyk-nodejs-lockfile-parser' | ||
|
||
const allDepVersions = new Map() | ||
|
||
async function addDepsForRoot(root, subdir) { | ||
const tree = await buildDepTreeFromFiles( | ||
root, | ||
subdir ? `packages/${subdir}/package.json` : 'package.json', | ||
'yarn.lock', | ||
true, | ||
false | ||
) | ||
|
||
function flattenAndAddDeps(node) { | ||
let entry = allDepVersions.get(node.name) | ||
if (!entry) { | ||
entry = new Set() | ||
allDepVersions.set(node.name, entry) | ||
} | ||
|
||
if (!entry.has(node.version)) { | ||
entry.add(node.version) | ||
|
||
if (node.dependencies) { | ||
for (const obj of Object.values(node.dependencies)) { | ||
flattenAndAddDeps(obj) | ||
} | ||
} | ||
} | ||
} | ||
|
||
flattenAndAddDeps(tree) | ||
} | ||
|
||
await addDepsForRoot('.') | ||
for (const dirname of await fs.readdir(new URL('../packages', import.meta.url))) { | ||
await addDepsForRoot('.', dirname) | ||
} | ||
|
||
const allowPackages = [] | ||
for (const [name, versions] of allDepVersions) { | ||
if (name.startsWith('@img/sharp') || name === '@elgato-stream-deck/webhid-demo') { | ||
for (const version of versions) { | ||
allowPackages.push(`${name}@${version}`) | ||
} | ||
} | ||
} | ||
|
||
cp.exec(`yarn sofie-licensecheck --allowPackages "${allowPackages.join(';')}"`, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`error: ${error.message}`) | ||
return | ||
} | ||
|
||
if (stderr) { | ||
console.error(stderr) | ||
return | ||
} | ||
|
||
console.log(stdout) | ||
}) |
Oops, something went wrong.