From 5453deeedc7c188bfa571c3cacc0186b0bffcaf3 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Tue, 28 May 2024 14:37:13 +0200 Subject: [PATCH 1/2] lsummary Signed-off-by: Jan Kowalleck --- tools/write-3rd-party-licenses.cjs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/write-3rd-party-licenses.cjs b/tools/write-3rd-party-licenses.cjs index 6c567478..ebf6f0be 100644 --- a/tools/write-3rd-party-licenses.cjs +++ b/tools/write-3rd-party-licenses.cjs @@ -74,6 +74,7 @@ async function getPackageMP (filePath, cache) { /** * @param {string} outputFile * @param {boolean} includeLicense + * @return {Promise.>} used licenses */ async function main (outputFile, includeLicense) { const metaData = JSON.parse(readFileSync(metaFile)) @@ -139,7 +140,8 @@ async function main (outputFile, includeLicense) { 'that are compatibly licensed. We list these here.\n') for (const tpLicense of tpLicenses) { writeSync(outputFH, `\n${'-'.repeat(80)}\n`) - writeSync(outputFH, `Library Name: ${tpLicense.name} (${tpLicense.version})\n`) + writeSync(outputFH, `Name: ${tpLicense.name}\n`) + writeSync(outputFH, `Version: ${tpLicense.version}\n`) writeSync(outputFH, `Distribution: https://www.npmjs.com/package/${tpLicense.name.replaceAll('@', '%40')}/v/${tpLicense.version}\n`) writeSync(outputFH, `License declared: ${tpLicense.licenseDeclared}\n`) for (const licenseFile of tpLicense.licenseFiles) { @@ -155,12 +157,20 @@ async function main (outputFile, includeLicense) { } closeSync(outputFH) + + return new Set(tpLicenses.map(l => l.licenseDeclared)) } if (require.main === module) { const outputFile = process.argv[2] || `${metaFile}.NOTICE` + const lsummaryFile = process.argv[3] || `${outputFile}.lsummary` const includeLicense = false - main(outputFile, includeLicense) + main(outputFile, includeLicense).then(licenses => { + const lsummaryFH = openSync(lsummaryFile, 'w') + writeSync(lsummaryFH, JSON.parse(readFileSync(join(projectRoot, 'package.json'))).license + '\n') + writeSync(lsummaryFH, Array.from(licenses).sort().join('\n')) + closeSync(lsummaryFH) + }) } else { module.exports = main } From b1a92b4d371263408b25737479ffa9ce3b0bbc48 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Tue, 28 May 2024 14:55:43 +0200 Subject: [PATCH 2/2] ci Signed-off-by: Jan Kowalleck --- .github/workflows/nodejs.yml | 38 ++++++++++++++++++++++++++++++++++++ .gitignore | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 0b6387ed..69c80597 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -147,6 +147,44 @@ jobs: - name: test run: yarn run test:lint + test-licenses: + needs: [ 'build' ] + name: test licenses + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: install flict + run: pip install flict + - name: Checkout + # see https://github.com/actions/checkout + uses: actions/checkout@v4 + - name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }} + # see https://github.com/actions/setup-node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_ACTIVE_LTS }} + # cache: 'yarn' + - name: Setup yarn ${{ env.YARN_VERSION }} + run: | + corepack enable yarn + yarn set version ${{ env.YARN_VERSION }} + - name: Setup subject + run: | + yarn install --no-immutable + yarn info --name-only --recursive + - name: fetch build artifact + # see https://github.com/actions/download-artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.BUNDLES_DIR }} + path: ${{ env.BUNDLES_DIR }} + - name: make NOTICE and summary + run: | + mkdir -p _tmp + yarn node tools/write-3rd-party-licenses.cjs _tmp/NOTICE _tmp/lsummary + - name: test license compatibility + run: flict display-compatibility $(cat _tmp/lsummary) + test-node: needs: [ 'build' ] name: test (node${{ matrix.node-version }} ${{ matrix.os }}) diff --git a/.gitignore b/.gitignore index 2c7bd58a..2d522963 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ /dist/ /release_assets/ - +_tmp/ # yarn stuff - for now, until setup is hardened # see also: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored