Skip to content

Commit

Permalink
upd apply version, bump v
Browse files Browse the repository at this point in the history
  • Loading branch information
lukachi committed Mar 7, 2024
1 parent 9514ab3 commit c6fb3e0
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/rarime-connector",
"version": "2.1.0-rc.3",
"version": "2.1.0-rc.4",
"description": "Facilitates interaction between a DApp and RariMe MetaMask snap",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/connector/src/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.1.0-rc.3"
"version": "2.1.0-rc.4"
}
2 changes: 1 addition & 1 deletion packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/rarime",
"version": "2.1.0-rc.3",
"version": "2.1.0-rc.4",
"description": "RariMe is a MetaMask Snap that safely holds any of your credentials and allows you to prove your identity without revealing any personal data. Powered by Rarimo Protocol and Zero-Knowledge Proof technology.",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "2.1.0-rc.3",
"version": "2.1.0-rc.4",
"description": "Securely store and manage all of your identity credentials. Use them across chains with ZK-protected privacy guarantees.",
"proposedName": "RariMe",
"repository": {
"type": "git",
"url": "https://github.com/rarimo/rarime.git"
},
"source": {
"shasum": "jB7ep9fkWawR8pJEDamZmRu6lKSgK4LnNwopuRqvAmc=",
"shasum": "mhUXbS3e3wQpaZOFiMoMKIoz8nZuiCi7xVNZSpW0RjA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/zkp-iden3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rarimo/zkp-iden3",
"version": "2.0.0",
"version": "2.1.0-rc.4",
"description": "Tools that generate zero-knowledge proofs for the Iden3 protocol.",
"repository": {
"type": "git",
Expand Down
115 changes: 66 additions & 49 deletions scripts/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,102 @@
/* eslint-disable curly */
/* eslint-disable jsdoc/require-jsdoc */
/* eslint-disable prettier/prettier */
const fs = require("fs")
const path = require("path")
const chalk = require("chalk")
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');

const ORGANIZATION_NAME = "@rarimo"
const VERSION_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
const VERSION = process.argv[2]

const issuesFound = []
const packages = fs.readdirSync(path.resolve(__dirname, "../packages"))
const ORGANIZATION_NAME = '@rarimo';
const VERSION_REGEX =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
const VERSION = process.argv[2];

const issuesFound = [];
const packages = fs.readdirSync(path.resolve(__dirname, '../packages'));

const run = () => {
validateSemverCompatibility()
validateSemverCompatibility();

if (!issuesFound.length) applyVersion()
if (!issuesFound.length) applyVersion();

report()
}
report();
};

function validateSemverCompatibility() {
if (process.argv.length !== 3) {
issuesFound.push("No version provided")
issuesFound.push('No version provided');
}

if (!VERSION_REGEX.test(VERSION)) {
issuesFound.push(`Version ${VERSION} is not semver compatible, should match https://semver.org/ specification`)
issuesFound.push(
`Version ${VERSION} is not semver compatible, should match https://semver.org/ specification`,
);
}
}


function applyVersion() {
for (const pkg of packages) {
const packageJsonPath = path.resolve(__dirname, `../packages/${pkg}/package.json`)
const packageJson = require(packageJsonPath)

if(pkg === 'snap') {
packageJson.dependencies['@rarimo/rarime-connector'] = VERSION
}

if(pkg === 'connector') {
const packageJsonVersionPath = path.resolve(__dirname, `../packages/${pkg}/src/version.json`)
const packageJsonVersion = require(packageJsonVersionPath)
const splitVersion = VERSION.split('.')
packageJsonVersion.version = `${splitVersion[0]}.${splitVersion[1]}.x`

fs.writeFile(packageJsonVersionPath, `${JSON.stringify(packageJsonVersion, null, 2)}\n`, (err) => {
if (err) issuesFound.push(`[${ORGANIZATION_NAME}/${pkg}]: Connector: snap version apply failed: ${err.toString()}`)
});
}
const packageJsonPath = path.resolve(
__dirname,
`../packages/${pkg}/package.json`,
);
const packageJson = require(packageJsonPath);

if (packageJson.version === VERSION) {
continue
continue;
}

packageJson.version = VERSION

fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, (err) => {
if (err) issuesFound.push(`[${ORGANIZATION_NAME}/${pkg}]: Version apply failed: ${err.toString()}`)
});
packageJson.version = VERSION;

if (pkg === 'connector') {
const packageJsonVersionPath = path.resolve(
__dirname,
`../packages/${pkg}/src/version.json`,
);
const packageJsonVersion = require(packageJsonVersionPath);
packageJsonVersion.version = `${VERSION}`;

fs.writeFile(
packageJsonVersionPath,
`${JSON.stringify(packageJsonVersion, null, 2)}\n`,
(err) => {
if (err)
issuesFound.push(
`[${ORGANIZATION_NAME}/${pkg}]: Connector: snap version apply failed: ${err.toString()}`,
);
},
);
}

if (issuesFound.length) break
fs.writeFile(
packageJsonPath,
`${JSON.stringify(packageJson, null, 2)}\n`,
(err) => {
if (err)
issuesFound.push(
`[${ORGANIZATION_NAME}/${pkg}]: Version apply failed: ${err.toString()}`,
);
},
);

if (issuesFound.length) break;
}
}


function report() {
if (issuesFound.length) {
console.error(chalk`{red Version {yellow ${VERSION}} apply failed!}`)
console.error(chalk`{red Version {yellow ${VERSION}} apply failed!}`);
issuesFound.forEach((issue) => {
console.error(chalk`{red ${issue}}`)
})
process.exitCode = 1
console.error(chalk`{red ${issue}}`);
});
process.exitCode = 1;
} else {
console.log(chalk`{green Version {yellow ${VERSION}} apply passed}`)
console.log(chalk`{green Version {yellow ${VERSION}} apply passed}`);
packages.forEach((pkg) => {
console.error(chalk`{yellow [${ORGANIZATION_NAME}/${pkg}]}: {green ${VERSION}}`)
})
process.exitCode = 0
console.error(
chalk`{yellow [${ORGANIZATION_NAME}/${pkg}]}: {green ${VERSION}}`,
);
});
process.exitCode = 0;
}
}

Expand Down

0 comments on commit c6fb3e0

Please sign in to comment.