-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
970 additions
and
22 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"cross-env": "^7.0.3", | ||
"lerna": "^8.1.2", | ||
"rimraf": "^5.0.5", | ||
"snyk-nodejs-lockfile-parser": "^1.53.2", | ||
"ts-loader": "^9.5.1", | ||
"ts-node": "^10.9.2", | ||
"typescript": "~5.0.4", | ||
|
@@ -32,8 +33,8 @@ | |
"bump": "lerna version --exact --conventional-commits --no-push -m \"chore(release): publish %s\"", | ||
"graduate": "run bump --conventional-graduate", | ||
"publish2": "run build && lerna publish from-package --pre-dist-tag next", | ||
"validate:dependencies": "yarn npm audit --groups dependencies && run license-validate", | ||
"license-validate": "sofie-licensecheck --allowPackages \"@loupedeck/web-demo@$(node -p \"require('./packages/web-demo/package.json').version\");[email protected];[email protected];[email protected]\"", | ||
"validate:dependencies": "yarn npm audit && run license-validate", | ||
"license-validate": "node ./scripts/license-check.mjs", | ||
"g:husky": "./node_modules/.bin/husky", | ||
"g:lint-staged": "./node_modules/.bin/lint-staged" | ||
}, | ||
|
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 === '@loupedeck/web-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.