Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
if: steps.lerna-cache.outputs.cache-hit != 'true' || contains( github.event.pull_request.labels.*.name, 'SKIP_CACHE')
run: yarn install --with-frozen-lockfile --ignore-scripts

- name: Check In-Repo Package Versions
run: yarn run check-versions

- name: build packages
env:
# Workaround for https://github.com/nodejs/node/issues/51555
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
node-version-file: .nvmrc

- name: Install BitGoJS
run: yarn install --with-frozen-lockfile --ignore-scripts
run: yarn install --with-frozen-lockfile

- name: Set Environment Variable for Alpha
if: github.ref != 'refs/heads/master' # only publish changes if on feature branches
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ modules/**/pack-scoped/
coverage
/.direnv/
.claude/
scripts/cache/
109 changes: 109 additions & 0 deletions check-package-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env node

// Check versions of in-repo packages to make sure they match with the package.json version.
// This is to prevent inadvertent updates of dependency versions for packages which are symlinked
// by lerna. The dependency versions of these packages should only ever be updated in the release branch.

const execa = require('execa');
const path = require('path');

/**
* Create a function which can run lerna commands
* @param lernaPath {string} path to lerna binary
* @returns {function(string, string[], Object.<string, string>): Promise<string>}
*/
function getLernaRunner(lernaPath) {
return async (command, args = [], options = {}) => {
const { stdout } = await execa(lernaPath, [command, ...args], options);
return stdout;
};
}

/**
* Get information on the modules in this repo that are managed by lerna.
* @param lerna {function}
* @returns {Promise<{path: *, name: *, deps: *, version: *}[]>}
*/
async function getLernaManagedModules(lerna) {
const depGraph = JSON.parse(await lerna('list', ['--loglevel', 'silent', '--graph', '--all']));
const managedModules = JSON.parse(await lerna('list', ['--loglevel', 'silent', '--json', '--all']));
const managedModuleNames = managedModules.map(({ name }) => name);
return Object.entries(depGraph).map(([name, deps]) => {
const mod = managedModules.find((mod) => mod.name === name);
return {
name,
deps: deps.filter((d) => managedModuleNames.includes(d)),
path: mod.location,
version: mod.version,
};
});
}

/**
* Build a dictionary from package name to the expected version of that package.
* @param modules
* @returns {Object.<string, string>}
*/
function getExpectedVersions(modules) {
return Object.values(modules).reduce((acc, mod) => {
return Object.assign(acc, { [mod.name]: mod.version });
}, {});
}

/**
* For the module at `modPath`, get the version of the dependency `depName`.
* If the version is prefixed with a carat or tilde, it will be stripped.
* @param modPath {string}
* @param depName {string}
* @returns {string | undefined}
*/
function getDependencyVersion(modPath, depName) {
const packageJsonPath = path.join(modPath, 'package.json');
const {
dependencies = {},
devDependencies = {},
optionalDependencies = {},
peerDependencies = {},
} = require(packageJsonPath);

const deps = { ...dependencies, ...devDependencies, ...optionalDependencies, ...peerDependencies };
if (deps[depName]) {
const matches = deps[depName].match(/^([^~])?(.*)$/);
return matches[matches.length - 1];
}
}

async function main() {
const { stdout: lernaBinary } = await execa('yarn', ['bin', 'lerna'], { cwd: process.cwd() });

const lerna = getLernaRunner(lernaBinary);

const modules = await getLernaManagedModules(lerna);
const expectedVersions = getExpectedVersions(modules);

let exitCode = 0;

for (const mod of modules) {
for (const dep of mod.deps) {
const depVersion = getDependencyVersion(mod.path, dep);
if (depVersion && depVersion !== expectedVersions[dep]) {
// Handle pre-release versions by checking if the base version matches
const baseDepVersion = depVersion.split('-')[0];
const baseExpectedVersion = expectedVersions[dep].split('-')[0];

if (baseDepVersion !== baseExpectedVersion) {
console.log(
`error: expected lerna-managed module ${mod.name} to depend on package ${dep} using version ${expectedVersions[dep]}, but found version ${depVersion} instead`
);
exitCode = 1;
}
}
}
}

return exitCode;
}

main()
.then(process.exit)
.catch((e) => console.error(e));
8 changes: 1 addition & 7 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
"useWorkspaces": true,
"command": {
"version": {
"message": "chore(root): publish modules",
"allowBranch": "master",
"skipGit": true
},
"publish": {
"skipGit": true,
"allowBranch": "master"
"message": "chore(root): publish modules"
}
},
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
Expand Down
10 changes: 5 additions & 5 deletions modules/abstract-cosmos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitgo/abstract-cosmos",
"version": "0.0.0-semantic-release-managed",
"version": "11.14.2",
"description": "BitGo SDK coin library for COSMOS base implementation",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -38,10 +38,10 @@
]
},
"dependencies": {
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
"@bitgo/sdk-lib-mpc": "0.0.0-semantic-release-managed",
"@bitgo/secp256k1": "0.0.0-semantic-release-managed",
"@bitgo/statics": "0.0.0-semantic-release-managed",
"@bitgo/sdk-core": "^36.8.0",
"@bitgo/sdk-lib-mpc": "^10.7.0",
"@bitgo/secp256k1": "^1.5.0",
"@bitgo/statics": "^57.8.0",
"@cosmjs/amino": "^0.29.5",
"@cosmjs/crypto": "^0.30.1",
"@cosmjs/encoding": "^0.29.5",
Expand Down
14 changes: 7 additions & 7 deletions modules/abstract-eth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitgo/abstract-eth",
"version": "0.0.0-semantic-release-managed",
"version": "24.12.0",
"description": "BitGo SDK coin library for ETH base implementation",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -40,10 +40,10 @@
]
},
"dependencies": {
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
"@bitgo/sdk-lib-mpc": "0.0.0-semantic-release-managed",
"@bitgo/secp256k1": "0.0.0-semantic-release-managed",
"@bitgo/statics": "0.0.0-semantic-release-managed",
"@bitgo/sdk-core": "^36.8.0",
"@bitgo/sdk-lib-mpc": "^10.7.0",
"@bitgo/secp256k1": "^1.5.0",
"@bitgo/statics": "^57.8.0",
"@ethereumjs/common": "^2.6.5",
"@ethereumjs/rlp": "^4.0.0",
"@ethereumjs/tx": "^3.3.0",
Expand All @@ -60,8 +60,8 @@
"superagent": "^9.0.1"
},
"devDependencies": {
"@bitgo/sdk-api": "0.0.0-semantic-release-managed",
"@bitgo/sdk-test": "0.0.0-semantic-release-managed",
"@bitgo/sdk-api": "^1.68.3",
"@bitgo/sdk-test": "^9.0.9",
"@types/keccak": "^3.0.5"
},
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c"
Expand Down
8 changes: 4 additions & 4 deletions modules/abstract-lightning/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitgo/abstract-lightning",
"version": "0.0.0-semantic-release-managed",
"version": "7.0.0",
"description": "BitGo SDK coin library for base Lightning Network coin implementation",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -40,10 +40,10 @@
},
"dependencies": {
"@bitgo/public-types": "5.22.0",
"@bitgo/sdk-core": "^36.8.0",
"@bitgo/statics": "^57.8.0",
"@bitgo/utxo-lib": "^11.10.0",
"bip174": "npm:@bitgo-forks/bip174@3.1.0-master.4",
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
"@bitgo/statics": "0.0.0-semantic-release-managed",
"@bitgo/utxo-lib": "0.0.0-semantic-release-managed",
"bs58check": "^2.1.2",
"fp-ts": "^2.12.2",
"io-ts": "npm:@bitgo-forks/io-ts@2.1.4",
Expand Down
8 changes: 4 additions & 4 deletions modules/abstract-substrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitgo/abstract-substrate",
"version": "0.0.0-semantic-release-managed",
"version": "1.10.4",
"description": "BitGo SDK coin library for Substrate base implementation",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -38,9 +38,9 @@
]
},
"dependencies": {
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
"@bitgo/sdk-lib-mpc": "0.0.0-semantic-release-managed",
"@bitgo/statics": "0.0.0-semantic-release-managed",
"@bitgo/sdk-core": "^36.8.0",
"@bitgo/sdk-lib-mpc": "^10.7.0",
"@bitgo/statics": "^57.8.0",
"@polkadot/api": "14.1.1",
"@polkadot/keyring": "13.3.1",
"@polkadot/types": "14.1.1",
Expand Down
14 changes: 7 additions & 7 deletions modules/abstract-utxo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitgo/abstract-utxo",
"version": "0.0.0-semantic-release-managed",
"version": "9.26.0",
"description": "BitGo SDK coin library for UTXO base implementation",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -42,12 +42,12 @@
]
},
"dependencies": {
"@bitgo/blockapis": "0.0.0-semantic-release-managed",
"@bitgo/sdk-api": "0.0.0-semantic-release-managed",
"@bitgo/sdk-core": "0.0.0-semantic-release-managed",
"@bitgo/unspents": "0.0.0-semantic-release-managed",
"@bitgo/utxo-core": "0.0.0-semantic-release-managed",
"@bitgo/utxo-lib": "0.0.0-semantic-release-managed",
"@bitgo/blockapis": "^1.11.0",
"@bitgo/sdk-api": "^1.68.3",
"@bitgo/sdk-core": "^36.8.0",
"@bitgo/unspents": "^0.49.0",
"@bitgo/utxo-core": "^1.19.0",
"@bitgo/utxo-lib": "^11.10.0",
"@bitgo/wasm-miniscript": "2.0.0-beta.7",
"@types/lodash": "^4.14.121",
"@types/superagent": "4.1.15",
Expand Down
Loading