CI: fix "unknown cli/env config" warnings from npm v11 (#1851)

npm v12 will drop support for unknown config options.
This commit is contained in:
larabr 2025-05-19 17:54:42 +02:00 committed by GitHub
parent 843a69d0ad
commit 45d825c64a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 13 deletions

View File

@ -114,7 +114,7 @@ jobs:
- name: Run browser tests (lightweight) # overwrite test/lib - name: Run browser tests (lightweight) # overwrite test/lib
run: | run: |
npm run build-test --lightweight npm run build-test -- --config-test-lightweight-build
npm run test-browser:ci -- --static-logging npm run test-browser:ci -- --static-logging
test-browsers-compatibility: test-browsers-compatibility:
@ -162,7 +162,7 @@ jobs:
- name: Run browserstack tests (lightweight) # overwrite test/lib - name: Run browserstack tests (lightweight) # overwrite test/lib
run: | run: |
npm run build-test --lightweight npm run build-test -- --config-test-lightweight-build
npm run test-browserstack -- --static-logging npm run test-browserstack -- --static-logging
env: env:
LIGHTWEIGHT: true LIGHTWEIGHT: true

View File

@ -43,7 +43,7 @@
], ],
"scripts": { "scripts": {
"build": "rollup --config", "build": "rollup --config",
"build-test": "npm run build --build-only=test", "build-test": "npm run build -- --config-build-only=test",
"prepare": "npm run build", "prepare": "npm run build",
"test": "mocha --timeout 120000 test/unittests.js", "test": "mocha --timeout 120000 test/unittests.js",
"test-type-definitions": "tsx test/typescript/definitions.ts", "test-type-definitions": "tsx test/typescript/definitions.ts",

View File

@ -136,7 +136,7 @@ const lightweightBrowserBuild = {
] ]
}; };
const testBuild = { const getBrowserTestBuild = useLightweightBuild => ({
input: 'test/unittests.js', input: 'test/unittests.js',
output: [ output: [
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true, inlineDynamicImports: true } { file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true, inlineDynamicImports: true }
@ -145,7 +145,7 @@ const testBuild = {
plugins: [ plugins: [
alias({ alias({
entries: { entries: {
openpgp: `./dist/${process.env.npm_config_lightweight ? 'lightweight/' : ''}openpgp.mjs` openpgp: `./dist/${useLightweightBuild ? 'lightweight/' : ''}openpgp.mjs`
} }
}), }),
resolve({ resolve({
@ -164,21 +164,31 @@ const testBuild = {
}), }),
wasm(wasmOptions.browser) wasm(wasmOptions.browser)
] ]
}; });
export default Object.assign([ /**
* Rollup CLI supports custom options; their name must start with `config`,
* e.g. see `--configDebug` example at
* https://rollupjs.org/command-line-interface/#configuration-files
*
* The custom options we support are:
* - "config-build-only": 'dist'|'node'|'lightweight'|'test'|string - to specify a build target;
* defaults to 'dist', which does not build tests;
* - "config-test-lightweight-build": Boolean - in the context of building browser tests,
* whether the lightweight build should be included instead of the standard one
*/
export default commandLineArgs => Object.assign([
nodeBuild, nodeBuild,
fullBrowserBuild, fullBrowserBuild,
lightweightBrowserBuild, lightweightBrowserBuild,
testBuild getBrowserTestBuild(commandLineArgs['config-test-lightweight-build'])
].filter(config => { ].filter(rollupConfig => {
config.output = config.output.filter(output => { rollupConfig.output = rollupConfig.output.filter(output => {
return (output.file || output.dir + '/' + output.entryFileNames).includes( return (output.file || output.dir + '/' + output.entryFileNames).includes(
process.env.npm_config_build_only || // E.g. `npm install --build-only=lightweight`. commandLineArgs['config-build-only'] || 'dist' // Don't build test bundle by default.
'dist' // Don't build test bundle by default.
); );
}); });
return config.output.length; return rollupConfig.output.length;
}), { }), {
allow_empty: true // Fake option to trick rollup into accepting empty config array when filtered above. allow_empty: true // Fake option to trick rollup into accepting empty config array when filtered above.
}); });