Skip to content

Commit

Permalink
remove versions and make private, refactor package.json handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shazarre committed Dec 14, 2023
1 parent a24cde1 commit c0df87b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
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": "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": {
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": "dont-publish-invalid-version",
"author": "cLabs",
"license": "LGPL-3.0",
"private": "true",
"repository": {
"type": "git",
"url": "https://github.com/celo-org/celo-monorepo.git",
Expand Down
31 changes: 18 additions & 13 deletions packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts
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('dont-publish-invalid-version', process.env.RELEASE_VERSION)
)
const packageJsonPath = path.join(CONTRACTS_PACKAGE_SRC_DIR, 'package.json')
replacePackageVersionAndMakePublic(packageJsonPath)

return
}
Expand Down

0 comments on commit c0df87b

Please sign in to comment.