Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check-ci-version.ts #62

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ tsconfig.json
CHANGELOG.md
.nvmrc
replace-script-notation.ts
check-ci-version.ts
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.2

- Fixed the CI pipeline checks so version can never be the same.

## 0.8.1

- Reverted the tsconfig.json to decrease file size.
Expand Down
32 changes: 32 additions & 0 deletions check-ci-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable no-console */
import { execSync } from "child_process";
import { readFileSync } from "fs";

try {
const packageJSON = readFileSync("./package.json", "utf8");
const localVersion = JSON.parse(packageJSON).version;
const npmVersion = execSync("npm view validatees version").toString().trim() || "1.0.0";
const split = npmVersion.split(".");
const pkgSplit = localVersion.split(".");
console.log(split, pkgSplit);

if (
split[0] > pkgSplit[0] ||
(split[0] >= pkgSplit[0] && split[1] >= pkgSplit[1]) ||
(split[0] >= pkgSplit[0] && split[1] >= pkgSplit[1] && split[2] >= pkgSplit[2])
) {
if (split[0] > pkgSplit[0]) {
throw new Error(`This major version is outdated, ${localVersion}`);
} else if (split[0] >= pkgSplit[0] && split[1] > pkgSplit[1]) {
throw new Error(`This minor version is outdated on this major version, ${localVersion}`);
} else if (split[0] >= pkgSplit[0] && split[1] >= pkgSplit[1] && split[2] >= pkgSplit[2]) {
throw new Error(`This patch version is outdated on this major+minor version, ${localVersion}`);
} else {
console.info("Your version of validatees is up to date.");
}
}
process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "validatees",
"version": "0.8.1",
"version": "0.8.2",
"description": "Validation library for ES6+ modules",
"scripts": {
"test": "jest",
Expand All @@ -9,7 +9,7 @@
"build": "tsc",
"build:watch": "tsc --watch",
"lint": "eslint src --ext .ts",
"cli:check:ci": "npx ts-node ./src/cli/index.ts --check --ci",
"cli:check:ci": "npx ts-node ./check-ci-version.ts",
"replace": "npx ts-node replace-script-notation.ts"
},
"main": "./dist/index.js",
Expand Down