diff --git a/automation/build-bin.ts b/automation/build-bin.ts index badf1f7e..cff56e07 100644 --- a/automation/build-bin.ts +++ b/automation/build-bin.ts @@ -409,3 +409,12 @@ export async function catchUncommitted(): Promise { ]); } } + +export async function testShrinkwrap(): Promise { + if (process.env.DEBUG) { + console.error(`[debug] platform=${process.platform}`); + } + if (process.platform !== 'win32') { + await whichSpawn(path.resolve(__dirname, 'test-lock-deduplicated.sh')); + } +} diff --git a/automation/run.ts b/automation/run.ts index 4c163674..142442b6 100644 --- a/automation/run.ts +++ b/automation/run.ts @@ -21,6 +21,7 @@ import { buildOclifInstaller, buildStandaloneZip, catchUncommitted, + testShrinkwrap, } from './build-bin'; import { release, @@ -63,6 +64,7 @@ export async function run(args?: string[]) { 'build:installer': buildOclifInstaller, 'build:standalone': buildStandaloneZip, 'catch-uncommitted': catchUncommitted, + 'test-shrinkwrap': testShrinkwrap, fix1359: updateDescriptionOfReleasesAffectedByIssue1359, release, }; diff --git a/automation/test-lock-deduplicated.sh b/automation/test-lock-deduplicated.sh new file mode 100755 index 00000000..6c343924 --- /dev/null +++ b/automation/test-lock-deduplicated.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +cp npm-shrinkwrap.json npm-shrinkwrap.json.old +npm i +npm dedupe +npm i + +if ! diff -q npm-shrinkwrap.json npm-shrinkwrap.json.old > /dev/null; then + rm npm-shrinkwrap.json.old + echo "** npm-shrinkwrap.json was not deduplicated or not fully committed - FAIL **"; + echo "** Please run 'npm ci', followed by 'npm dedupe' **"; + exit 1; +fi + +rm npm-shrinkwrap.json.old diff --git a/automation/utils.ts b/automation/utils.ts index bffb0392..067516f2 100644 --- a/automation/utils.ts +++ b/automation/utils.ts @@ -206,7 +206,7 @@ export async function which(program: string): Promise { */ export async function whichSpawn( programName: string, - args: string[], + args?: string[], ): Promise { const program = await which(programName); let error: Error | undefined; diff --git a/package.json b/package.json index 38f43d75..3897d4fd 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "package": "npm run build:fast && npm run build:standalone && npm run build:installer", "release": "ts-node --transpile-only automation/run.ts release", "pretest": "npm run build", - "test": "npm run test:source && npm run test:standalone", + "test": "npm run test:shrinkwrap && npm run test:source && npm run test:standalone", + "test:shrinkwrap": "ts-node --transpile-only automation/run.ts test-shrinkwrap", "test:source": "cross-env BALENA_CLI_TEST_TYPE=source mocha", "test:standalone": "npm run build:standalone && npm run test:standalone:fast", "test:standalone:fast": "cross-env BALENA_CLI_TEST_TYPE=standalone mocha",