From b83d5ef246bf7b2a4ae5a408c6696c7a718eed87 Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Thu, 14 Dec 2023 12:53:22 +0100 Subject: [PATCH 1/3] Explicitly invalid package version for @celo/abis and @celo/contracts by default --- packages/protocol/abis/package.json | 2 +- packages/protocol/contracts/package.json | 2 +- .../protocol/scripts/prepare-contracts-and-abis-publishing.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/protocol/abis/package.json b/packages/protocol/abis/package.json index e3a8a9a8b22..154cd0aab4c 100644 --- a/packages/protocol/abis/package.json +++ b/packages/protocol/abis/package.json @@ -1,6 +1,6 @@ { "name": "@celo/abis", - "version": "10.0.0-local", + "version": "dont-publish-invalid-version", "author": "cLabs", "license": "LGPL-3.0", "main": "./dist/cjs/index.js", diff --git a/packages/protocol/contracts/package.json b/packages/protocol/contracts/package.json index f5e3d544ead..8cba9dd5519 100644 --- a/packages/protocol/contracts/package.json +++ b/packages/protocol/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@celo/contracts", - "version": "0.0.0-template.version", + "version": "dont-publish-invalid-version", "author": "cLabs", "license": "LGPL-3.0", "repository": { diff --git a/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts b/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts index 25b298c4a76..c6bacb3e2c2 100644 --- a/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts +++ b/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts @@ -260,7 +260,7 @@ function prepareContractsPackage() { fs.writeFileSync( contractsPackageJsonPath, - contents.replace('0.0.0-template.version', process.env.RELEASE_VERSION) + contents.replace('dont-publish-invalid-version', process.env.RELEASE_VERSION) ) return From a24cde1575c19b1e16712f17ecd2f1dc5ea30400 Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Thu, 14 Dec 2023 14:10:11 +0100 Subject: [PATCH 2/3] remove abis from packages --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 03a6e7c5ce0..8d661be539c 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,7 @@ "packages": [ "packages/*", "packages/sdk/*", - "packages/sdk/wallets/*", - "packages/protocol/abis" + "packages/sdk/wallets/*" ], "nohoist": [ "**/openzeppelin-solidity", From c0df87b62cf1d2a914227c744107813dc7be2e6f Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Thu, 14 Dec 2023 15:38:44 +0100 Subject: [PATCH 3/3] remove versions and make private, refactor package.json handling --- packages/protocol/abis/package.json | 2 +- packages/protocol/contracts/package.json | 2 +- .../prepare-contracts-and-abis-publishing.ts | 31 +++++++++++-------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/protocol/abis/package.json b/packages/protocol/abis/package.json index 154cd0aab4c..d0f6a38d0c6 100644 --- a/packages/protocol/abis/package.json +++ b/packages/protocol/abis/package.json @@ -1,10 +1,10 @@ { "name": "@celo/abis", - "version": "dont-publish-invalid-version", "author": "cLabs", "license": "LGPL-3.0", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js", + "private": "true", "types": "./dist/types/index.d.ts", "typings": "./dist/types/index.d.ts", "repository": { diff --git a/packages/protocol/contracts/package.json b/packages/protocol/contracts/package.json index 8cba9dd5519..b4be0dad47a 100644 --- a/packages/protocol/contracts/package.json +++ b/packages/protocol/contracts/package.json @@ -1,8 +1,8 @@ { "name": "@celo/contracts", - "version": "dont-publish-invalid-version", "author": "cLabs", "license": "LGPL-3.0", + "private": "true", "repository": { "type": "git", "url": "https://github.com/celo-org/celo-monorepo.git", diff --git a/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts b/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts index c6bacb3e2c2..2b3d0cffea3 100644 --- a/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts +++ b/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts @@ -229,25 +229,35 @@ function processRawJsonsAndPrepareExports() { return exports } -function prepareAbisPackageJson(exports) { - log('Preparing @celo/abis package.json') - const packageJsonPath = path.join(ABIS_PACKAGE_SRC_DIR, 'package.json') +function replacePackageVersionAndMakePublic(packageJsonPath: string, onDone?: (json) => void) { const json = JSON.parse(fs.readFileSync(packageJsonPath).toString()) if (process.env.RELEASE_VERSION) { - log('Replacing @celo/abis version with provided RELEASE_VERSION') + log(`Replacing ${json.name} version with provided RELEASE_VERSION`) json.version = process.env.RELEASE_VERSION + json.private = false } else { log('No RELEASE_VERSION provided') } - log('Setting @celo/abis exports') - json.exports = exports + if (onDone !== undefined) { + onDone(json) + } fs.writeFileSync(packageJsonPath, JSON.stringify(json, null, 2)) } +function prepareAbisPackageJson(exports) { + log('Preparing @celo/abis package.json') + const packageJsonPath = path.join(ABIS_PACKAGE_SRC_DIR, 'package.json') + + replacePackageVersionAndMakePublic(packageJsonPath, (json) => { + log('Setting @celo/abis exports') + json.exports = exports + }) +} + function prepareContractsPackage() { const contracts08CpCommand = `cp -r ${CONTRACTS_08_SOURCE_DIR} ${CONTRACTS_08_PACKAGE_DESTINATION_DIR}` log(contracts08CpCommand) @@ -255,13 +265,8 @@ function prepareContractsPackage() { if (process.env.RELEASE_VERSION) { log('Replacing @celo/contracts version with RELEASE_VERSION)') - const contractsPackageJsonPath = path.join(CONTRACTS_PACKAGE_SRC_DIR, 'package.json') - const contents = fs.readFileSync(contractsPackageJsonPath).toString() - - fs.writeFileSync( - contractsPackageJsonPath, - contents.replace('dont-publish-invalid-version', process.env.RELEASE_VERSION) - ) + const packageJsonPath = path.join(CONTRACTS_PACKAGE_SRC_DIR, 'package.json') + replacePackageVersionAndMakePublic(packageJsonPath) return }