From f4f54cc5367d9b082c94d3f2058cb4eceb0aba50 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Wed, 11 Jan 2023 16:03:57 -0500 Subject: [PATCH] chore(cli): update version of CLI on root readme (#1069) Fixes https://github.com/coveo/cli/issues/684 https://coveord.atlassian.net/browse/CDX-1272 ## Proposed changes When releasing, copy the usage section from the CLI to the root readme. Dumb but it works. ## Testing - [x] Manual Tests: ran the function. --- README.md | 17 ++++++++++++++--- .../releaseV2/phase2-git-commit-tag-push.mjs | 13 +++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2de1bc61a3..99362dfb17 100644 --- a/README.md +++ b/README.md @@ -67,10 +67,21 @@ npx @coveo/cli To validate your CLI installation, use the `coveo --version` command: + + +```sh-session +$ npm install -g @coveo/cli +$ coveo COMMAND +running command... +$ coveo (--version) +@coveo/cli/2.2.0 linux-x64 node-v18.12.1 +$ coveo --help [COMMAND] +USAGE + $ coveo COMMAND +... ``` -$ coveo --version -@coveo/cli/1.19.0 darwin-x64 node-v16.10.0 -``` + + ## Getting started diff --git a/scripts/releaseV2/phase2-git-commit-tag-push.mjs b/scripts/releaseV2/phase2-git-commit-tag-push.mjs index debf6a46c1..58feb49be7 100644 --- a/scripts/releaseV2/phase2-git-commit-tag-push.mjs +++ b/scripts/releaseV2/phase2-git-commit-tag-push.mjs @@ -14,7 +14,7 @@ import { import {Octokit} from 'octokit'; import angularChangelogConvention from 'conventional-changelog-angular'; import {dedent} from 'ts-dedent'; -import {readFileSync} from 'fs'; +import {readFileSync, writeFileSync} from 'fs'; const CLI_PKG_MATCHER = /^@coveo\/cli@(?\d+\.\d+\.\d+)$/gm; @@ -60,7 +60,7 @@ const getCliChangelog = () => { ); await writeChangelog(PATH, changelog); } - + updateRootReadme(); await gitCommit( dedent` [version bump] chore(release): release ${gitNewTag} [skip ci] @@ -98,3 +98,12 @@ const getCliChangelog = () => { body: releaseBody, }); })(); + +function updateRootReadme() { + const usageRegExp = /^(.|\n)*$/m; + const cliReadme = readFileSync('packages/cli/core/README.md', 'utf-8'); + let rootReadme = readFileSync('README.md'); + const cliUsage = usageRegExp.exec(cliReadme); + rootReadme.replace(usageRegExp, cliUsage[0]); + writeFileSync('README.md', rootReadme); +}