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

@celo/abis and @celo/contracts should not be available to publish by default #10832

Merged
merged 4 commits into from
Dec 15, 2023
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: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"packages": [
"packages/*",
"packages/sdk/*",
"packages/sdk/wallets/*",
"packages/protocol/abis"
"packages/sdk/wallets/*"
],
"nohoist": [
"**/openzeppelin-solidity",
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/abis/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@celo/abis",
"version": "10.0.0-local",
"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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@celo/contracts",
"version": "0.0.0-template.version",
"author": "cLabs",
"license": "LGPL-3.0",
"private": "true",
"repository": {
"type": "git",
"url": "https://github.com/celo-org/celo-monorepo.git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,39 +229,44 @@ 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)
child_process.execSync(contracts08CpCommand)

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('0.0.0-template.version', process.env.RELEASE_VERSION)
)
const packageJsonPath = path.join(CONTRACTS_PACKAGE_SRC_DIR, 'package.json')
replacePackageVersionAndMakePublic(packageJsonPath)

return
}
Expand Down
Loading