From ef99389afe669c699652b7b253fc831341880a6c Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 6 Dec 2021 19:28:58 +0200 Subject: [PATCH] publish 15.x.x packages only under '15.x.x' tag --- package.json | 3 +++ resources/build-npm.js | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4d78ece6fb..cfcf632f1c 100644 --- a/package.json +++ b/package.json @@ -67,5 +67,8 @@ "nyc": "15.1.0", "prettier": "2.2.1", "typescript": "4.1.3" + }, + "publishConfig": { + "tag": "15.x.x" } } diff --git a/resources/build-npm.js b/resources/build-npm.js index 15ccce6522..ce64e9dc3a 100644 --- a/resources/build-npm.js +++ b/resources/build-npm.js @@ -58,6 +58,10 @@ function buildPackageJSON() { packageJSON.engines = packageJSON.engines_on_npm; delete packageJSON.engines_on_npm; + // TODO: move to integration tests + const publishTag = packageJSON.publishConfig?.tag; + assert(publishTag != null, 'Should have packageJSON.publishConfig defined!'); + const { version } = packageJSON; const versionMatch = /^\d+\.\d+\.\d+-?(?.*)?$/.exec(version); if (!versionMatch) { @@ -72,9 +76,7 @@ function buildPackageJSON() { tag.startsWith('experimental-') || ['alpha', 'beta', 'rc'].includes(tag), `"${tag}" tag is supported.`, ); - - assert(!packageJSON.publishConfig, 'Can not override "publishConfig".'); - packageJSON.publishConfig = { tag: tag || 'latest' }; + assert.equal(tag, publishTag, 'Publish tag and version tag should match!'); } return packageJSON;