From e04f0e7a0e537b31e92d9a6177abcdd411b7f99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Colladon?= Date: Thu, 26 Jan 2023 09:24:53 +0100 Subject: [PATCH 1/5] refactor: rename Salesforce occurence with sfdx --- README.md | 2 +- __snapshots__/cli.js | 4 +-- __snapshots__/sfdx-project-json.js | 2 +- docs/customizing.md | 2 +- src/factory.ts | 4 +-- src/strategies/{salesforce.ts => sfdx.ts} | 6 ++-- .../{salesforce => sfdx}/sfdx-project-json.ts | 2 +- .../{salesforce => sfdx}/sfdx-project.json | 2 +- test/strategies/{salesforce.ts => sfdx.ts} | 34 +++++++++---------- test/updaters/fixtures/sfdx-project.json | 2 +- test/updaters/sfdx-project-json.ts | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) rename src/strategies/{salesforce.ts => sfdx.ts} (94%) rename src/updaters/{salesforce => sfdx}/sfdx-project-json.ts (95%) rename test/fixtures/strategies/{salesforce => sfdx}/sfdx-project.json (76%) rename test/strategies/{salesforce.ts => sfdx.ts} (85%) diff --git a/README.md b/README.md index 511b07f93..2c38134d3 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ Release Please automates releases for the following flavors of repositories: | `python` | [A Python repository, with a setup.py, setup.cfg, CHANGELOG.md](https://github.com/googleapis/python-storage) and optionally a pyproject.toml and a <project>/\_\_init\_\_.py | | `ruby` | A repository with a version.rb and a CHANGELOG.md | | `rust` | A Rust repository, with a Cargo.toml (either as a crate or workspace) and a CHANGELOG.md | -| `salesforce` | A repository with a sfdx-project.json and a CHANGELOG.md | +| `sfdx` | A repository with a [sfdx-project.json](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) and a CHANGELOG.md | | `simple` | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) | | `terraform-module` | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) | diff --git a/__snapshots__/cli.js b/__snapshots__/cli.js index 63b4a8c12..70ec371f9 100644 --- a/__snapshots__/cli.js +++ b/__snapshots__/cli.js @@ -42,7 +42,7 @@ Options: [choices: "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php", - "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "simple", + "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "sfdx", "simple", "terraform-module"] --config-file where can the config file be found in the project? [default: "release-please-config.json"] @@ -241,7 +241,7 @@ Options: [choices: "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php", - "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "simple", + "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "sfdx", "simple", "terraform-module"] --config-file where can the config file be found in the project? diff --git a/__snapshots__/sfdx-project-json.js b/__snapshots__/sfdx-project-json.js index a2b29081a..ffbaed788 100644 --- a/__snapshots__/sfdx-project-json.js +++ b/__snapshots__/sfdx-project-json.js @@ -6,7 +6,7 @@ exports['SfdxProjectJson updateContent updates version in sfdx-project.json 1'] "versionNumber": "2.3.4.NEXT" } ], - "name": "salesfore-test-repo" + "name": "sfdx-test-repo" } ` diff --git a/docs/customizing.md b/docs/customizing.md index 9f3ef8914..6299dd070 100644 --- a/docs/customizing.md +++ b/docs/customizing.md @@ -23,7 +23,7 @@ Release Please automates releases for the following flavors of repositories: | `python` | [A Python repository, with a setup.py, setup.cfg, CHANGELOG.md](https://github.com/googleapis/python-storage) and optionally a pyproject.toml and a <project>/\_\_init\_\_.py | | `ruby` | A repository with a version.rb and a CHANGELOG.md | | `rust` | A Rust repository, with a Cargo.toml (either as a crate or workspace) and a CHANGELOG.md | -| `salesforce` | A repository with a sfdx-project.json and a CHANGELOG.md | +| `sfdx` | A repository with a [sfdx-project.json](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) and a CHANGELOG.md | | `simple` | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) | | `terraform-module` | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) | diff --git a/src/factory.ts b/src/factory.ts index 5230aac2f..2033a6e84 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -25,7 +25,7 @@ import {Python} from './strategies/python'; import {Ruby} from './strategies/ruby'; import {RubyYoshi} from './strategies/ruby-yoshi'; import {Rust} from './strategies/rust'; -import {Salesforce} from './strategies/salesforce'; +import {Sfdx} from './strategies/sfdx'; import {Simple} from './strategies/simple'; import {TerraformModule} from './strategies/terraform-module'; import {Helm} from './strategies/helm'; @@ -100,7 +100,7 @@ const releasers: Record = { ruby: options => new Ruby(options), 'ruby-yoshi': options => new RubyYoshi(options), rust: options => new Rust(options), - salesforce: options => new Salesforce(options), + sfdx: options => new Sfdx(options), simple: options => new Simple(options), 'terraform-module': options => new TerraformModule(options), helm: options => new Helm(options), diff --git a/src/strategies/salesforce.ts b/src/strategies/sfdx.ts similarity index 94% rename from src/strategies/salesforce.ts rename to src/strategies/sfdx.ts index 95e5af356..d1deb8616 100644 --- a/src/strategies/salesforce.ts +++ b/src/strategies/sfdx.ts @@ -17,11 +17,11 @@ import {Update} from '../update'; import {Changelog} from '../updaters/changelog'; import {GitHubFileContents} from '@google-automations/git-file-utils'; import {FileNotFoundError, MissingRequiredFileError} from '../errors'; -import {SfdxProjectJson} from '../updaters/salesforce/sfdx-project-json'; +import {SfdxProjectJson} from '../updaters/sfdx/sfdx-project-json'; const sfdxProjectJsonFileName = 'sfdx-project.json'; -export class Salesforce extends BaseStrategy { +export class Sfdx extends BaseStrategy { private sfdxProjectJsonContents?: GitHubFileContents; protected async buildUpdates( @@ -69,7 +69,7 @@ export class Salesforce extends BaseStrategy { if (e instanceof FileNotFoundError) { throw new MissingRequiredFileError( this.addPath(sfdxProjectJsonFileName), - 'salesforce', + 'sfdx', `${this.repository.owner}/${this.repository.repo}` ); } diff --git a/src/updaters/salesforce/sfdx-project-json.ts b/src/updaters/sfdx/sfdx-project-json.ts similarity index 95% rename from src/updaters/salesforce/sfdx-project-json.ts rename to src/updaters/sfdx/sfdx-project-json.ts index f2dc66093..1c815a574 100644 --- a/src/updaters/salesforce/sfdx-project-json.ts +++ b/src/updaters/sfdx/sfdx-project-json.ts @@ -26,7 +26,7 @@ export type SfdxProjectFile = { }; /** - * This updates a Salesfore sfdx-project.json file's main version. + * This updates a sfdx sfdx-project.json file's main version. */ export class SfdxProjectJson extends DefaultUpdater { /** diff --git a/test/fixtures/strategies/salesforce/sfdx-project.json b/test/fixtures/strategies/sfdx/sfdx-project.json similarity index 76% rename from test/fixtures/strategies/salesforce/sfdx-project.json rename to test/fixtures/strategies/sfdx/sfdx-project.json index dbdbc61ed..6f2e8b638 100644 --- a/test/fixtures/strategies/salesforce/sfdx-project.json +++ b/test/fixtures/strategies/sfdx/sfdx-project.json @@ -5,5 +5,5 @@ "versionNumber": "1.0.0.NEXT" } ], - "name": "salesfore-test-repo" + "name": "sfdx-test-repo" } diff --git a/test/strategies/salesforce.ts b/test/strategies/sfdx.ts similarity index 85% rename from test/strategies/salesforce.ts rename to test/strategies/sfdx.ts index 67483b759..9231683c6 100644 --- a/test/strategies/salesforce.ts +++ b/test/strategies/sfdx.ts @@ -13,7 +13,7 @@ // limitations under the License. import {describe, it, afterEach, beforeEach} from 'mocha'; -import {Salesforce} from '../../src/strategies/salesforce'; +import {Sfdx} from '../../src/strategies/sfdx'; import { buildMockConventionalCommit, buildGitHubFileContent, @@ -26,15 +26,15 @@ import {Version} from '../../src/version'; import {TagName} from '../../src/util/tag-name'; import {expect} from 'chai'; import {Changelog} from '../../src/updaters/changelog'; -import {SfdxProjectJson} from '../../src/updaters/salesforce/sfdx-project-json'; +import {SfdxProjectJson} from '../../src/updaters/sfdx/sfdx-project-json'; import * as assert from 'assert'; import {MissingRequiredFileError, FileNotFoundError} from '../../src/errors'; nock.disableNetConnect(); const sandbox = sinon.createSandbox(); -const fixturesPath = './test/fixtures/strategies/salesforce'; +const fixturesPath = './test/fixtures/strategies/sfdx'; -describe('Salesforce', () => { +describe('Sfdx', () => { let github: GitHub; const commits = [ ...buildMockConventionalCommit( @@ -44,7 +44,7 @@ describe('Salesforce', () => { beforeEach(async () => { github = await GitHub.create({ owner: 'googleapis', - repo: 'salesforce-test-repo', + repo: 'sfdx-test-repo', defaultBranch: 'main', }); }); @@ -54,7 +54,7 @@ describe('Salesforce', () => { describe('buildReleasePullRequest', () => { it('returns release PR changes with defaultInitialVersion', async () => { const expectedVersion = '1.0.0'; - const strategy = new Salesforce({ + const strategy = new Sfdx({ targetBranch: 'main', github, component: 'google-cloud-automl', @@ -69,14 +69,14 @@ describe('Salesforce', () => { }); it('builds a release pull request', async () => { const expectedVersion = '0.123.5'; - const strategy = new Salesforce({ + const strategy = new Sfdx({ targetBranch: 'main', github, - component: 'some-salesforce-package', - packageName: 'some-salesforce-package', + component: 'some-sfdx-package', + packageName: 'some-sfdx-package', }); const latestRelease = { - tag: new TagName(Version.parse('0.123.4'), 'some-salesforce-package'), + tag: new TagName(Version.parse('0.123.4'), 'some-sfdx-package'), sha: 'abc123', notes: 'some notes', }; @@ -88,7 +88,7 @@ describe('Salesforce', () => { }); it('detects a default component', async () => { const expectedVersion = '0.123.5'; - const strategy = new Salesforce({ + const strategy = new Sfdx({ targetBranch: 'main', github, }); @@ -98,7 +98,7 @@ describe('Salesforce', () => { ), ]; const latestRelease = { - tag: new TagName(Version.parse('0.123.4'), 'salesforce-test-repo'), + tag: new TagName(Version.parse('0.123.4'), 'sfdx-test-repo'), sha: 'abc123', notes: 'some notes', }; @@ -117,7 +117,7 @@ describe('Salesforce', () => { }); it('detects a default packageName', async () => { const expectedVersion = '0.123.5'; - const strategy = new Salesforce({ + const strategy = new Sfdx({ targetBranch: 'main', github, component: 'abc-123', @@ -128,7 +128,7 @@ describe('Salesforce', () => { ), ]; const latestRelease = { - tag: new TagName(Version.parse('0.123.4'), 'salesforce-test-repo'), + tag: new TagName(Version.parse('0.123.4'), 'sfdx-test-repo'), sha: 'abc123', notes: 'some notes', }; @@ -149,12 +149,12 @@ describe('Salesforce', () => { sandbox .stub(github, 'getFileContentsOnBranch') .rejects(new FileNotFoundError('stub/path')); - const strategy = new Salesforce({ + const strategy = new Sfdx({ targetBranch: 'main', github, }); const latestRelease = { - tag: new TagName(Version.parse('0.123.4'), 'some-salesforce-package'), + tag: new TagName(Version.parse('0.123.4'), 'some-sfdx-package'), sha: 'abc123', notes: 'some notes', }; @@ -165,7 +165,7 @@ describe('Salesforce', () => { }); describe('buildUpdates', () => { it('builds common files', async () => { - const strategy = new Salesforce({ + const strategy = new Sfdx({ targetBranch: 'main', github, component: 'google-cloud-automl', diff --git a/test/updaters/fixtures/sfdx-project.json b/test/updaters/fixtures/sfdx-project.json index dbdbc61ed..6f2e8b638 100644 --- a/test/updaters/fixtures/sfdx-project.json +++ b/test/updaters/fixtures/sfdx-project.json @@ -5,5 +5,5 @@ "versionNumber": "1.0.0.NEXT" } ], - "name": "salesfore-test-repo" + "name": "sfdx-test-repo" } diff --git a/test/updaters/sfdx-project-json.ts b/test/updaters/sfdx-project-json.ts index af77ea947..21cb42638 100644 --- a/test/updaters/sfdx-project-json.ts +++ b/test/updaters/sfdx-project-json.ts @@ -17,7 +17,7 @@ import {resolve} from 'path'; import * as snapshot from 'snap-shot-it'; import {describe, it} from 'mocha'; import {Version} from '../../src/version'; -import {SfdxProjectJson} from '../../src/updaters/salesforce/sfdx-project-json'; +import {SfdxProjectJson} from '../../src/updaters/sfdx/sfdx-project-json'; const fixturesPath = './test/updaters/fixtures/'; From 6131c72cac0d42a3dfa622342100121c41beae96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Colladon?= Date: Fri, 27 Jan 2023 18:04:20 +0100 Subject: [PATCH 2/5] test: improve `updateContent` assert --- test/updaters/sfdx-project-json.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/updaters/sfdx-project-json.ts b/test/updaters/sfdx-project-json.ts index 21cb42638..1678e4be2 100644 --- a/test/updaters/sfdx-project-json.ts +++ b/test/updaters/sfdx-project-json.ts @@ -17,7 +17,11 @@ import {resolve} from 'path'; import * as snapshot from 'snap-shot-it'; import {describe, it} from 'mocha'; import {Version} from '../../src/version'; -import {SfdxProjectJson} from '../../src/updaters/sfdx/sfdx-project-json'; +import { + SfdxProjectJson, + SfdxProjectFile, +} from '../../src/updaters/sfdx/sfdx-project-json'; +import {expect} from 'chai'; const fixturesPath = './test/updaters/fixtures/'; @@ -35,6 +39,10 @@ describe('SfdxProjectJson', () => { }); const newContent = pom.updateContent(oldContent); snapshot(newContent); + const parsedNewContent = JSON.parse(newContent) as SfdxProjectFile; + expect(parsedNewContent.packageDirectories[0].versionNumber).to.equal( + '2.3.4.NEXT' + ); }); }); }); From 5c813b012918f46cc5c1fb473bb4a4a57797009c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Colladon?= Date: Tue, 7 Mar 2023 18:40:31 +0100 Subject: [PATCH 3/5] feat: reintroduce `salesforce` release-type to avoid breaking change make it disappear from documentation so newcomers will not use it --- src/factory.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/factory.ts b/src/factory.ts index 2033a6e84..0be36a2f7 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -100,6 +100,7 @@ const releasers: Record = { ruby: options => new Ruby(options), 'ruby-yoshi': options => new RubyYoshi(options), rust: options => new Rust(options), + salesforce: options => new Sfdx(options), sfdx: options => new Sfdx(options), simple: options => new Simple(options), 'terraform-module': options => new TerraformModule(options), From 5f49249875bf4f97afa2c17efbfc557787ca2590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Colladon?= Date: Wed, 8 Mar 2023 22:56:28 +0100 Subject: [PATCH 4/5] fix: display salesforce and sfdx release-type choice --- __snapshots__/cli.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/__snapshots__/cli.js b/__snapshots__/cli.js index 70ec371f9..acafab217 100644 --- a/__snapshots__/cli.js +++ b/__snapshots__/cli.js @@ -42,8 +42,8 @@ Options: [choices: "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php", - "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "sfdx", "simple", - "terraform-module"] + "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "sfdx", + "simple", "terraform-module"] --config-file where can the config file be found in the project? [default: "release-please-config.json"] --manifest-file where can the manifest file be found in the @@ -241,8 +241,8 @@ Options: [choices: "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php", - "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "sfdx", "simple", - "terraform-module"] + "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "sfdx", + "simple", "terraform-module"] --config-file where can the config file be found in the project? [default: "release-please-config.json"] From 97b3302a7b4ad5ded0f752f5a07fc6104eb92bdb Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Tue, 14 Mar 2023 10:50:24 -0700 Subject: [PATCH 5/5] test: fix test fixture --- __snapshots__/cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__snapshots__/cli.js b/__snapshots__/cli.js index acafab217..751d6e244 100644 --- a/__snapshots__/cli.js +++ b/__snapshots__/cli.js @@ -42,7 +42,7 @@ Options: [choices: "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php", - "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "sfdx", + "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "sfdx", "simple", "terraform-module"] --config-file where can the config file be found in the project? [default: "release-please-config.json"] @@ -241,7 +241,7 @@ Options: [choices: "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php", - "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "sfdx", + "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "salesforce", "sfdx", "simple", "terraform-module"] --config-file where can the config file be found in the project?