From 5c46228d6414f46708f256edee85aeb50cc23020 Mon Sep 17 00:00:00 2001 From: Jordi Vives Date: Wed, 30 Oct 2024 14:30:26 +0100 Subject: [PATCH] fix(create-release-branch): define releaseBranch also on `.release.branches.[].channel` as that is used to tag on npm --- README.md | 12 ++++++++++++ lib/shell/sh-update-package.js | 19 +++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 57253c3..d3c8b0e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,18 @@ When you want to manage a product with different releases and support old versio npm test ``` +## Test the release tools locally +Change the directory to a repository you want to test the release tools with (e.g. livingdocs-server), the release tools will be executed in the context of the repository you are in. Both repositories should be in the same parent directory. Then run the following command: +```bash +node ../release-tools/bin/cmd.js create-release-branch \ + --repo=repoName \ + --base-tag=validVersion \ + --release-branch-name=test-release \ + --npm-token=validNPMToken +``` +A validVersion is a tag that exists in the repository you are in and fulfils semver constraints: +- latest version of minor bump (e.g. 1.2.latest) +- newer minor or major version exist (e.g. 1.3.0 or 2.0.0 exist) ## Copyright diff --git a/lib/shell/sh-update-package.js b/lib/shell/sh-update-package.js index c17cc5f..361d7aa 100644 --- a/lib/shell/sh-update-package.js +++ b/lib/shell/sh-update-package.js @@ -13,15 +13,22 @@ module.exports = function (dep) { // eslint-disable-next-line no-extra-boolean-cast const result = exec(`jq '.release.branches != null' package.json`) if (result.stdout === 'true') { - propertyName = 'release.branches.[0].name' + exec(`cat package.json \ + | jq ".release.branches.[0].name=\\"${argv.releaseBranchName}\\" \ + | .release.branches.[0].channel=\\"${argv.releaseBranchName}\\" \ + | .publishConfig.tag=\\"${argv.releaseBranchName}\\"" \ + | cat > package.json.tmp && mv package.json.tmp package.json` + ) + propertyName = 'release.branches' } else { + exec(`cat package.json \ + | jq ".release.branch=\\"${argv.releaseBranchName}\\" \ + | .publishConfig.tag=\\"${argv.releaseBranchName}\\"" \ + | cat > package.json.tmp && mv package.json.tmp package.json` + ) propertyName = 'release.branch' } - exec(`cat package.json \ - | jq ".${propertyName}=\\"${argv.releaseBranchName}\\" \ - | .publishConfig.tag=\\"${argv.releaseBranchName}\\"" \ - | cat > package.json.tmp && mv package.json.tmp package.json` - ) + logYellow(`Updated ${propertyName} in package.json`) } }