Skip to content

Commit

Permalink
fix(refactor): rename Salesforce to sfdx (#1829)
Browse files Browse the repository at this point in the history
* refactor: rename Salesforce occurence with sfdx

* test: improve `updateContent` assert

* feat: reintroduce `salesforce` release-type

to avoid breaking change
make it disappear from documentation
so newcomers will not use it

* fix: display salesforce and sfdx release-type choice

* test: fix test fixture

---------

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
scolladon and chingor13 authored Mar 14, 2023
1 parent dc48b55 commit 122820d
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;project&gt;/\_\_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) |

Expand Down
8 changes: 4 additions & 4 deletions __snapshots__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", "salesforce", "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
Expand Down Expand Up @@ -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", "salesforce", "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"]
Expand Down
2 changes: 1 addition & 1 deletion __snapshots__/sfdx-project-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
`
2 changes: 1 addition & 1 deletion docs/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;project&gt;/\_\_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) |

Expand Down
5 changes: 3 additions & 2 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -100,7 +100,8 @@ const releasers: Record<string, ReleaseBuilder> = {
ruby: options => new Ruby(options),
'ruby-yoshi': options => new RubyYoshi(options),
rust: options => new Rust(options),
salesforce: options => new Salesforce(options),
salesforce: options => new Sfdx(options),
sfdx: options => new Sfdx(options),
simple: options => new Simple(options),
'terraform-module': options => new TerraformModule(options),
helm: options => new Helm(options),
Expand Down
6 changes: 3 additions & 3 deletions src/strategies/salesforce.ts → src/strategies/sfdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}`
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"versionNumber": "1.0.0.NEXT"
}
],
"name": "salesfore-test-repo"
"name": "sfdx-test-repo"
}
34 changes: 17 additions & 17 deletions test/strategies/salesforce.ts → test/strategies/sfdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -44,7 +44,7 @@ describe('Salesforce', () => {
beforeEach(async () => {
github = await GitHub.create({
owner: 'googleapis',
repo: 'salesforce-test-repo',
repo: 'sfdx-test-repo',
defaultBranch: 'main',
});
});
Expand All @@ -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',
Expand All @@ -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',
};
Expand All @@ -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,
});
Expand All @@ -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',
};
Expand All @@ -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',
Expand All @@ -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',
};
Expand All @@ -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',
};
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/updaters/fixtures/sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"versionNumber": "1.0.0.NEXT"
}
],
"name": "salesfore-test-repo"
"name": "sfdx-test-repo"
}
10 changes: 9 additions & 1 deletion test/updaters/sfdx-project-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/salesforce/sfdx-project-json';
import {
SfdxProjectJson,
SfdxProjectFile,
} from '../../src/updaters/sfdx/sfdx-project-json';
import {expect} from 'chai';

const fixturesPath = './test/updaters/fixtures/';

Expand All @@ -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'
);
});
});
});

0 comments on commit 122820d

Please sign in to comment.