From d8529a7f921cad2287304ecb71202dd557a1d79f Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Mon, 18 Sep 2023 17:34:54 +0200 Subject: [PATCH] feat: add prerelease checks script --- package.json | 2 +- prerelease.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 prerelease.js diff --git a/package.json b/package.json index 53fad71..9664440 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "rollup-plugin-visualizer": "^5.9.2" }, "scripts": { - "release": "yarn run test && yarn run build", + "release": "node ./prerelease.js && yarn run test && yarn run build", "build": "rm -rf ./dist/ && yarn run build:bundle && yarn run build:minify", "build:bundle": "rollup -c", "build:minify": "minify ./dist/doip.core.js > ./dist/doip.core.min.js && minify ./dist/doip.fetchers.js > ./dist/doip.fetchers.min.js && minify ./dist/doip.fetchers.minimal.js > ./dist/doip.fetchers.minimal.min.js", diff --git a/prerelease.js b/prerelease.js new file mode 100644 index 0000000..04f9d94 --- /dev/null +++ b/prerelease.js @@ -0,0 +1,33 @@ +/* +Copyright 2023 Yarmo Mackenbach + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import * as C from './src/constants.js' +import { readFile } from 'fs/promises' + +const main = async () => { + const pkg = JSON.parse( + await readFile( + new URL('./package.json', import.meta.url) + ) + ) + + // Assert that the constant version equals the package version + if (C.version !== pkg.version) { + console.log(`!!! Mismatch between constants.js version (${C.version}) and package.json version (${pkg.version})`) + process.exit(1) + } +} + +main() \ No newline at end of file