Skip to content

Commit

Permalink
[Issue-16] Update automation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed Feb 29, 2024
1 parent 4f5b113 commit 1c312ed
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 32 deletions.
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web3-onboard-monorepo",
"version": "2.24.18",
"name": "subwallet-connect-monorepo",
"version": "1.0.1",
"private": true,
"workspaces": {
"packages": [
Expand All @@ -11,9 +11,11 @@
"**/csstype"
]
},
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"description": "SubWallet-Connect fork from Web3-Onboard. It makes it simple to connect not only Ethereum but also Polkadot hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
"Polkadot",
"SubWallet",
"Web3",
"EVM",
"dapp",
Expand Down Expand Up @@ -46,11 +48,11 @@
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"url": "https://github.com/Koniverse/SubWallet-Connect.git",
"directory": "packages/core"
},
"homepage": "https://onboard.blocknative.com",
"bugs": "https://github.com/blocknative/web3-onboard/issues",
"bugs": "https://github.com/Koniverse/SubWallet-Connect/issues",
"scripts": {
"install-m1-mac": "yarn install --ignore-optional",
"format": "prettier --write 'packages/**/*.ts'",
Expand All @@ -59,7 +61,9 @@
"type-check": "yarn wsrun type-check",
"file-check": "yarn install --check-files",
"check-all": "yarn build && yarn file-check && yarn type-check",
"test-playwright": "cd test && yarn && yarn playwright test"
"test-playwright": "cd test && yarn && yarn playwright test",
"update-version": "node scripts/update-version.js",
"publish-version": "node scripts/publish-version.js"
},
"devDependencies": {
"prettier": "^2.4.1",
Expand Down
32 changes: 32 additions & 0 deletions scripts/publish-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const glob = require('glob');
const execa = require('execa');
const path = require('path');

const prefix = '@subwallet-connect';

// Function to publish a package
async function publishPackage(packagePath) {
try {
const { stdout } = await execa('npm', ['publish', '--access', 'public'], { cwd: packagePath });
console.log(stdout);
} catch (error) {
console.error(`Failed to publish package at ${packagePath}:`, error.stderr);
}
}

// Find and publish all packages with the specified prefix
glob('packages/*/package.json', async (err, files) => {
if (err) {
return console.error('Error finding package.json files:', err);
}

for (const file of files) {
const packageJsonPath = path.resolve(file);
const packageJson = require(packageJsonPath);

if (packageJson.name && packageJson.name.startsWith(prefix)) {
console.log(`Publishing ${packageJson.name}...`);
await publishPackage(path.dirname(packageJsonPath));
}
}
});
33 changes: 7 additions & 26 deletions scripts/set-version.js → scripts/update-version.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
const jsonfile = require('jsonfile');
const glob = require('glob');
const path = require('path');
const jsonfile = require('jsonfile');
const {getAllPackageNames} = require("./utils");

// Get the target version from the command line arguments
const targetVersion = process.argv[2];
// Read the version from the root package.json
const rootPackageJsonPath = path.resolve('package.json');
const rootPackageJson = jsonfile.readFileSync(rootPackageJsonPath);
const targetVersion = rootPackageJson.version;

if (!targetVersion) {
console.error('Usage: node set-version.js <version>');
console.error('No version found in root package.json');
process.exit(1);
}

// This function reads all package.json files to collect package names
async function getAllPackageNames() {
return new Promise((resolve, reject) => {
glob('packages/*/package.json', async (err, files) => {
if (err) {
reject('Error finding package.json files:', err);
return;
}

const packageNames = [];
for (const file of files) {
try {
const packageJson = await jsonfile.readFile(path.resolve(file));
packageNames.push(packageJson.name);
} catch (error) {
console.error(`Error reading ${file}:`, error);
}
}
resolve(packageNames);
});
});
}

// Function to update package.json dependencies
async function updatePackageJson(filePath, packageNames) {
let fileUpdated = false;
Expand Down
30 changes: 30 additions & 0 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const jsonfile = require('jsonfile');
const glob = require('glob');
const path = require('path');

// This function reads all package.json files to collect package names
async function getAllPackageNames() {
return new Promise((resolve, reject) => {
glob('packages/*/package.json', async (err, files) => {
if (err) {
reject('Error finding package.json files:', err);
return;
}

const packageNames = [];
for (const file of files) {
try {
const packageJson = await jsonfile.readFile(path.resolve(file));
packageNames.push(packageJson.name);
} catch (error) {
console.error(`Error reading ${file}:`, error);
}
}
resolve(packageNames);
});
});
}

module.exports = {
getAllPackageNames
}

0 comments on commit 1c312ed

Please sign in to comment.