Skip to content

Commit bcbf17f

Browse files
authored
Merge pull request #248 from salesforcecli/sm/one-configAggregator
Sm/one config aggregator
2 parents c564568 + 6db2d04 commit bcbf17f

File tree

27 files changed

+1052
-524
lines changed

27 files changed

+1052
-524
lines changed

.github/workflows/onPushToMain.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ name: version, tag and github release
33

44
on:
55
push:
6-
branches: [main]
6+
branches:
7+
- main
8+
- prerelease/*
9+
tags-ignore:
10+
- '*'
711

812
jobs:
913
release:
1014
uses: salesforcecli/github-workflows/.github/workflows/githubRelease.yml@main
1115
secrets: inherit
16+
with:
17+
prerelease: ${{ github.ref_name != 'main' }}
1218

1319
# most repos won't use this
1420
# depends on previous job to avoid git collisions, not for any functionality reason

.github/workflows/onRelease.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: publish
22

33
on:
44
release:
5-
types: [released]
5+
types: [published]
66
# support manual release in case something goes wrong and needs to be repeated or tested
77
workflow_dispatch:
88
inputs:
@@ -11,11 +11,21 @@ on:
1111
type: string
1212
required: true
1313
jobs:
14+
getDistTag:
15+
outputs:
16+
tag: ${{ steps.distTag.outputs.tag }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.event.release.tag_name || inputs.tag }}
22+
- uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main
23+
id: distTag
24+
1425
npm:
1526
uses: salesforcecli/github-workflows/.github/workflows/npmPublish.yml@main
27+
needs: [getDistTag]
1628
with:
17-
ctc: true
18-
sign: true
19-
tag: latest
29+
tag: ${{ needs.getDistTag.outputs.tag || 'latest' }}
2030
githubTag: ${{ github.event.release.tag_name || inputs.tag }}
2131
secrets: inherit

CHANGELOG.md

Lines changed: 54 additions & 161 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@oclif/core": "^2.8.2",
9-
"@salesforce/core": "^3.34.6",
10-
"@salesforce/sf-plugins-core": "^2.2.4",
9+
"@salesforce/core": "^3.35.0",
10+
"@salesforce/sf-plugins-core": "^2.3.0",
1111
"fast-levenshtein": "^3.0.0",
1212
"tslib": "^2"
1313
},
@@ -19,6 +19,7 @@
1919
"@salesforce/dev-scripts": "^4.3.0",
2020
"@salesforce/kit": "^1.8.5",
2121
"@salesforce/plugin-command-reference": "^2.2.8",
22+
"@salesforce/plugin-deploy-retrieve": "^1.8.14",
2223
"@salesforce/prettier-config": "^0.0.2",
2324
"@salesforce/ts-sinon": "^1.4.4",
2425
"@salesforce/ts-types": "^1.7.1",
@@ -86,7 +87,8 @@
8687
"devPlugins": [
8788
"@oclif/plugin-help",
8889
"@oclif/plugin-command-snapshot",
89-
"@salesforce/plugin-command-reference"
90+
"@salesforce/plugin-command-reference",
91+
"@salesforce/plugin-deploy-retrieve"
9092
],
9193
"topics": {
9294
"config": {
@@ -113,6 +115,7 @@
113115
"reformat": "prettier --config .prettierrc --write './*.{js,json,md}' './**/*.{ts,json,md}'",
114116
"test": "wireit",
115117
"test:nuts": "nyc mocha \"test/**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --jobs 20",
118+
"test:nuts:config": "nyc mocha \"test/**/config/**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --jobs 20",
116119
"test:only": "wireit",
117120
"version": "oclif readme"
118121
},
@@ -224,4 +227,4 @@
224227
"output": []
225228
}
226229
}
227-
}
230+
}

src/commands/config/get.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import { Flags, loglevel } from '@salesforce/sf-plugins-core';
8-
import { ConfigAggregator, Messages, SfdxConfigAggregator } from '@salesforce/core';
8+
import { ConfigAggregator, Messages } from '@salesforce/core';
99
import { ConfigCommand, ConfigResponses, CONFIG_HELP_SECTION } from '../../config';
1010

1111
Messages.importMessagesDirectory(__dirname);
@@ -29,9 +29,6 @@ export class Get extends ConfigCommand<ConfigResponses> {
2929

3030
public async run(): Promise<ConfigResponses> {
3131
const { argv, flags } = await this.parse(Get);
32-
// instantiate a SfdxConfigAggregator to get the restDeploy <-> org-metadata-rest-deploy deprecation linked
33-
await SfdxConfigAggregator.create({});
34-
3532
if (!argv || argv.length === 0) {
3633
throw messages.createError('error.NoConfigKeysFound');
3734
}
@@ -40,25 +37,10 @@ export class Get extends ConfigCommand<ConfigResponses> {
4037

4138
for (const configName of argv as string[]) {
4239
try {
43-
this.pushSuccess(aggregator.getInfo(configName, true));
40+
this.pushSuccess(aggregator.getInfo(configName));
4441
} catch (err) {
4542
const error = err as Error;
46-
if (error.message.includes('Deprecated config name')) {
47-
// because we've caught the deprecated error, the 'newKey' property will be set
48-
const info = aggregator.getInfo(aggregator.getPropertyMeta(configName).newKey as string);
49-
// deprecated key, so we'll get the replacement and return the value
50-
this.responses.push({
51-
name: info.key,
52-
key: configName,
53-
value: info.value as string,
54-
deprecated: true,
55-
location: info.location,
56-
path: info.path,
57-
error,
58-
message: error.message,
59-
success: true,
60-
});
61-
} else if (error.name.includes('UnknownConfigKeyError') && !this.jsonEnabled()) {
43+
if (error.name.includes('UnknownConfigKeyError') && !this.jsonEnabled()) {
6244
const suggestion = this.calculateSuggestion(configName);
6345
// eslint-disable-next-line no-await-in-loop
6446
const answer = (await this.confirm(messages.getMessage('didYouMean', [suggestion]), 10 * 1000)) ?? false;

src/commands/config/list.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import { ConfigAggregator, Messages, SfdxConfigAggregator } from '@salesforce/core';
7+
import { ConfigAggregator, Messages } from '@salesforce/core';
88
import { loglevel } from '@salesforce/sf-plugins-core';
99
import { ConfigCommand, ConfigResponses } from '../../config';
1010

@@ -20,7 +20,6 @@ export default class List extends ConfigCommand<ConfigResponses> {
2020
public static flags = { loglevel };
2121

2222
public async run(): Promise<ConfigResponses> {
23-
await SfdxConfigAggregator.create({});
2423
const aggregator = await ConfigAggregator.create();
2524

2625
aggregator.getConfigInfo().forEach((c) => {

src/commands/config/set.ts

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { parseVarArgs, Flags, loglevel } from '@salesforce/sf-plugins-core';
9-
import { Config, Messages, Org, SfError, OrgConfigProperties, SfdxConfigAggregator } from '@salesforce/core';
9+
import { Config, Messages, Org, SfError, OrgConfigProperties } from '@salesforce/core';
1010
import { CONFIG_HELP_SECTION, ConfigCommand, Msg } from '../../config';
1111

1212
Messages.importMessagesDirectory(__dirname);
@@ -42,7 +42,10 @@ export class Set extends ConfigCommand<SetConfigCommandResult> {
4242

4343
for (const name of Object.keys(parsed)) {
4444
const value = parsed[name] as string;
45+
let resolvedName = name;
4546
try {
47+
// this needs to be inside the try/catch because it can throw an error
48+
resolvedName = this.configAggregator.getPropertyMeta(name)?.newKey ?? name;
4649
if (!value) {
4750
// Push a failure if users are try to unset a value with `set=`.
4851
this.pushFailure(name, messages.createError('error.ValueRequired'), value);
@@ -51,36 +54,13 @@ export class Set extends ConfigCommand<SetConfigCommandResult> {
5154
// currently no way to validate an org synchronously. Therefore, we have to manually
5255
// validate the org here and manually set the error message if it fails
5356
// eslint-disable-next-line no-await-in-loop
54-
if (isOrgKey(name) && value) await validateOrg(value);
55-
config.set(name, value);
56-
this.setResponses.successes.push({ name, value, success: true });
57+
if (isOrgKey(resolvedName) && value) await validateOrg(value);
58+
config.set(resolvedName, value);
59+
this.setResponses.successes.push({ name: resolvedName, value, success: true });
5760
}
5861
} catch (err) {
5962
const error = err as Error;
60-
if (error.name === 'DeprecatedConfigKeyError') {
61-
const newKey = Config.getPropertyConfigMeta(name)?.key ?? name;
62-
try {
63-
config.set(newKey, value);
64-
this.setResponses.successes.push({
65-
name,
66-
value,
67-
success: true,
68-
error,
69-
message: error.message.replace(/\.\.$/, '.'),
70-
});
71-
} catch (e) {
72-
const secondError = e as Error;
73-
// if that deprecated value was also set to an invalid value
74-
this.setResponses.failures.push({
75-
name,
76-
key: name,
77-
success: false,
78-
value,
79-
error: secondError,
80-
message: secondError.message.replace(/\.\.$/, '.'),
81-
});
82-
}
83-
} else if (error.name.includes('UnknownConfigKeyError')) {
63+
if (error.name.includes('UnknownConfigKeyError')) {
8464
if (this.jsonEnabled()) {
8565
process.exitCode = 1;
8666
this.setResponses.failures.push({
@@ -101,7 +81,7 @@ export class Set extends ConfigCommand<SetConfigCommandResult> {
10181
}
10282
}
10383
} else {
104-
this.pushFailure(name, err as Error, value);
84+
this.pushFailure(resolvedName, err as Error, value);
10585
}
10686
}
10787
}
@@ -128,7 +108,6 @@ export class Set extends ConfigCommand<SetConfigCommandResult> {
128108

129109
const loadConfig = async (global: boolean): Promise<Config> => {
130110
try {
131-
await SfdxConfigAggregator.create({});
132111
const config = await Config.create(Config.getDefaultOptions(global));
133112
await config.read();
134113
return config;

src/commands/config/unset.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { Flags, loglevel } from '@salesforce/sf-plugins-core';
9-
import { Config, Messages, SfdxConfigAggregator, SfError } from '@salesforce/core';
9+
import { Config, Messages, SfError } from '@salesforce/core';
1010
import { CONFIG_HELP_SECTION, ConfigCommand } from '../../config';
1111
import { SetConfigCommandResult } from './set';
1212

@@ -32,7 +32,6 @@ export class UnSet extends ConfigCommand<SetConfigCommandResult> {
3232

3333
public async run(): Promise<SetConfigCommandResult> {
3434
const { argv, flags } = await this.parse(UnSet);
35-
await SfdxConfigAggregator.create({});
3635

3736
if (!argv || argv.length === 0) {
3837
throw messages.createError('error.NoConfigKeysFound');
@@ -42,20 +41,12 @@ export class UnSet extends ConfigCommand<SetConfigCommandResult> {
4241
await config.read();
4342
for (const key of argv as string[]) {
4443
try {
45-
config.unset(key);
46-
this.unsetResponses.successes.push({ name: key, success: true });
44+
const resolvedName = this.configAggregator.getPropertyMeta(key)?.newKey ?? key;
45+
config.unset(resolvedName);
46+
this.unsetResponses.successes.push({ name: resolvedName, success: true });
4747
} catch (err) {
4848
const error = err as Error;
49-
if (error.message.includes('Deprecated config name')) {
50-
const meta = Config.getPropertyConfigMeta(key);
51-
config.unset(meta?.key ?? key);
52-
this.unsetResponses.successes.push({
53-
name: key,
54-
success: true,
55-
error,
56-
message: error.message.replace(/\.\.$/, '.'),
57-
});
58-
} else if (error.name.includes('UnknownConfigKeyError') && !this.jsonEnabled()) {
49+
if (error.name.includes('UnknownConfigKeyError') && !this.jsonEnabled()) {
5950
const suggestion = this.calculateSuggestion(key);
6051
// eslint-disable-next-line no-await-in-loop
6152
const answer = (await this.confirm(messages.getMessage('didYouMean', [suggestion]), 10 * 1000)) ?? false;

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export abstract class ConfigCommand<T> extends SfCommand<T> {
5151
name: configInfo.key,
5252
key: configInfo.key,
5353
value: configInfo.value as string | undefined,
54+
path: configInfo.path,
5455
success: true,
5556
location: configInfo.location,
5657
});

test/commands/alias/list.nut.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('alias list NUTs', () => {
1919
before(async () => {
2020
session = await TestSession.create({
2121
project: { name: 'aliasListNUTs' },
22+
devhubAuthStrategy: 'NONE',
2223
});
2324
});
2425

0 commit comments

Comments
 (0)