Skip to content

Commit

Permalink
fix: emit warning if config var is unset
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Jan 17, 2024
1 parent 4a3a511 commit fc32218
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 4 additions & 0 deletions messages/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ A valid repository URL or directory for the custom org metadata templates.

A valid repository URL or directory for the custom org metadata templates.

# org-capitalize-record-types

Whether record types are capitalized on scrach org creation.

# invalidId

The given id %s is not a valid 15 or 18 character Salesforce ID.
2 changes: 1 addition & 1 deletion src/org/orgConfigProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export enum OrgConfigProperties {
export const ORG_CONFIG_ALLOWED_PROPERTIES = [
{
key: OrgConfigProperties.ORG_CAPITALIZE_RECORD_TYPES,
description: messages.getMessage(OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES),
description: messages.getMessage(OrgConfigProperties.ORG_CAPITALIZE_RECORD_TYPES),
},
{
key: OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES,
Expand Down
20 changes: 15 additions & 5 deletions src/org/scratchOrgCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Duration, toBoolean } from '@salesforce/kit';
import { Duration } from '@salesforce/kit';
import { ensureString } from '@salesforce/ts-types';
import { Messages } from '../messages';
import { Logger } from '../logger/logger';
Expand Down Expand Up @@ -150,7 +150,12 @@ export const scratchOrgResume = async (jobId: string): Promise<ScratchOrgCreateR
const configAggregator = await ConfigAggregator.create();

await emit({ stage: 'deploy settings', scratchOrgInfo: soi });
const settingsGenerator = new SettingsGenerator();

const capitalizeRecordTypes = await getCapitalizeRecordTypesConfig();

const settingsGenerator = new SettingsGenerator({
capitalizeRecordTypes,
});
await settingsGenerator.extract({ ...soi, ...definitionjson });
const [authInfo] = await Promise.all([
resolveUrl(scratchOrgAuthInfo),
Expand Down Expand Up @@ -228,11 +233,11 @@ export const scratchOrgCreate = async (options: ScratchOrgCreateOptions): Promis
ignoreAncestorIds,
});

const capitalizeRecordTypes = await getCapitalizeRecordTypesConfig();

// gets the scratch org settings (will use in both signup paths AND to deploy the settings)
const settingsGenerator = new SettingsGenerator({
capitalizeRecordTypes: toBoolean(
(await ConfigAggregator.create()).getInfo('org-capitalize-record-types').value ?? true
),
capitalizeRecordTypes,
});

const settings = await settingsGenerator.extract(scratchOrgInfo);
Expand Down Expand Up @@ -333,3 +338,8 @@ const getSignupTargetLoginUrl = async (): Promise<string | undefined> => {
// a project isn't required for org:create
}
};

async function getCapitalizeRecordTypesConfig(): Promise<boolean | undefined> {
const configAgg = await ConfigAggregator.create();
return configAgg.getInfo('org-capitalize-record-types').value as boolean | undefined;
}
10 changes: 9 additions & 1 deletion src/org/scratchOrgSettingsGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { StatusResult } from '../status/types';
import { PollingClient } from '../status/pollingClient';
import { ZipWriter } from '../util/zipWriter';
import { DirectoryWriter } from '../util/directoryWriter';
import { Lifecycle } from '../lifecycleEvents';
import { ScratchOrgInfo, ObjectSetting } from './scratchOrgTypes';
import { Org } from './org';

Expand Down Expand Up @@ -210,7 +211,14 @@ export default class SettingsGenerator {
capitalizeRecordTypes?: boolean;
}) {
this.logger = Logger.childFromRoot('SettingsGenerator');
this.capitalizeRecordTypes = options?.capitalizeRecordTypes ?? false;
if (options?.capitalizeRecordTypes === undefined) {
void Lifecycle.getInstance().emitWarning(
'record types will stop being capitalized by default in a future release.'
);
this.capitalizeRecordTypes = true;
} else {
this.capitalizeRecordTypes = options.capitalizeRecordTypes;
}
// If SFDX_MDAPI_TEMP_DIR is set, copy settings to that dir for people to inspect.
const mdApiTmpDir = options?.mdApiTmpDir ?? env.getString('SFDX_MDAPI_TEMP_DIR');
this.shapeDirName = options?.shapeDirName ?? `shape_${Date.now()}`;
Expand Down

3 comments on commit fc32218

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: fc32218 Previous: 725bf67 Ratio
Child logger creation 458264 ops/sec (±2.75%) 481735 ops/sec (±1.11%) 1.05
Logging a string on root logger 874473 ops/sec (±9.38%) 802872 ops/sec (±8.88%) 0.92
Logging an object on root logger 606088 ops/sec (±6.32%) 594659 ops/sec (±8.05%) 0.98
Logging an object with a message on root logger 4412 ops/sec (±223.94%) 8845 ops/sec (±205.65%) 2.00
Logging an object with a redacted prop on root logger 451710 ops/sec (±9.74%) 496053 ops/sec (±10.19%) 1.10
Logging a nested 3-level object on root logger 382013 ops/sec (±8.12%) 402072 ops/sec (±8.94%) 1.05

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: fc32218 Previous: 725bf67 Ratio
Logging an object with a message on root logger 4412 ops/sec (±223.94%) 8845 ops/sec (±205.65%) 2.00

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: fc32218 Previous: 725bf67 Ratio
Child logger creation 342269 ops/sec (±0.78%) 335895 ops/sec (±0.60%) 0.98
Logging a string on root logger 807298 ops/sec (±5.67%) 836773 ops/sec (±6.06%) 1.04
Logging an object on root logger 618996 ops/sec (±7.24%) 605208 ops/sec (±6.60%) 0.98
Logging an object with a message on root logger 7153 ops/sec (±203.73%) 3809 ops/sec (±217.49%) 0.53
Logging an object with a redacted prop on root logger 455661 ops/sec (±9.69%) 423788 ops/sec (±6.25%) 0.93
Logging a nested 3-level object on root logger 339215 ops/sec (±4.88%) 322063 ops/sec (±5.38%) 0.95

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.