From 9e986332a54b01423bf832ee63a38bb0a90d4906 Mon Sep 17 00:00:00 2001 From: peternhale Date: Mon, 18 Dec 2023 11:17:30 -0700 Subject: [PATCH 1/4] chore: refactor to arrow function vscode lightning (#5282) * chore: vs lightning to arrow @W-14564471@ * chore: fix tests --- .../fix-these-rules.json | 1 + .../src/index.ts | 37 +++++++++---------- .../src/messages/index.ts | 4 +- .../unit/package/packageDependencies.test.ts | 4 +- .../test/vscode-integration/extension.test.ts | 4 +- .../test/vscode-integration/hover.test.ts | 10 +++-- .../vscode-integration/intellisense.test.ts | 12 +++--- .../vscode-integration/navigation.test.ts | 20 +++++----- 8 files changed, 47 insertions(+), 45 deletions(-) diff --git a/packages/salesforcedx-vscode-lightning/fix-these-rules.json b/packages/salesforcedx-vscode-lightning/fix-these-rules.json index 158aeb45c5..43ffa95fb9 100644 --- a/packages/salesforcedx-vscode-lightning/fix-these-rules.json +++ b/packages/salesforcedx-vscode-lightning/fix-these-rules.json @@ -1,5 +1,6 @@ { "rules": { + "prefer-arrow/prefer-arrow-functions": ["error", {}], "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/no-unsafe-argument": "warn", "@typescript-eslint/no-unsafe-assignment": "warn", diff --git a/packages/salesforcedx-vscode-lightning/src/index.ts b/packages/salesforcedx-vscode-lightning/src/index.ts index 4cac74df16..1153a167a2 100644 --- a/packages/salesforcedx-vscode-lightning/src/index.ts +++ b/packages/salesforcedx-vscode-lightning/src/index.ts @@ -24,7 +24,7 @@ import { import { nls } from './messages'; // See https://github.com/Microsoft/vscode-languageserver-node/issues/105 -export function code2ProtocolConverter(value: Uri): string { +export const code2ProtocolConverter = (value: Uri): string => { if (/^win32/.test(process.platform)) { // The *first* : is also being encoded which is not the standard for URI on Windows // Here we transform it back to the standard way @@ -32,18 +32,18 @@ export function code2ProtocolConverter(value: Uri): string { } else { return value.toString(); } -} +}; -function protocol2CodeConverter(value: string): Uri { +const protocol2CodeConverter = (value: string): Uri => { return Uri.parse(value); -} +}; -function getActivationMode(): string { +const getActivationMode = (): string => { const config = workspace.getConfiguration('salesforcedx-vscode-lightning'); return config.get('activationMode') || 'autodetect'; // default to autodetect -} +}; -export async function activate(extensionContext: ExtensionContext) { +export const activate = async (extensionContext: ExtensionContext) => { const extensionHRStart = process.hrtime(); console.log('Activation Mode: ' + getActivationMode()); // Run our auto detection routine before we activate @@ -179,23 +179,22 @@ export async function activate(extensionContext: ExtensionContext) { // Notify telemetry that our extension is now active TelemetryService.getInstance().sendExtensionActivationEvent(extensionHRStart); -} +}; let indexingResolve: any; -function startIndexing(): void { +const startIndexing = (): void => { const indexingPromise: Promise = new Promise(resolve => { indexingResolve = resolve; }); - reportIndexing(indexingPromise); -} + void reportIndexing(indexingPromise); +}; -function endIndexing(): void { +const endIndexing = (): void => { indexingResolve(undefined); -} - -function reportIndexing(indexingPromise: Promise) { - window.withProgress( +}; +const reportIndexing = async (indexingPromise: Promise) => { + void window.withProgress( { location: ProgressLocation.Window, title: nls.localize('index_components_text'), @@ -205,9 +204,9 @@ function reportIndexing(indexingPromise: Promise) { return indexingPromise; } ); -} +}; -export function deactivate() { +export const deactivate = () => { console.log('Aura Components Extension Deactivated'); TelemetryService.getInstance().sendExtensionDeactivationEvent(); -} +}; diff --git a/packages/salesforcedx-vscode-lightning/src/messages/index.ts b/packages/salesforcedx-vscode-lightning/src/messages/index.ts index 2d8ecba89e..a71f090430 100644 --- a/packages/salesforcedx-vscode-lightning/src/messages/index.ts +++ b/packages/salesforcedx-vscode-lightning/src/messages/index.ts @@ -16,7 +16,7 @@ import { messages as enMessages } from './i18n'; import { messages as jaMessages } from './i18n.ja'; const supportedLocales = [DEFAULT_LOCALE, LOCALE_JA]; -function loadMessageBundle(config?: Config): Message { +const loadMessageBundle = (config?: Config): Message => { const base = new Message(enMessages); const localeConfig = config ? config.locale : DEFAULT_LOCALE; @@ -30,7 +30,7 @@ function loadMessageBundle(config?: Config): Message { } return base; -} +}; export const nls = new Localization( loadMessageBundle( diff --git a/packages/salesforcedx-vscode-lightning/test/unit/package/packageDependencies.test.ts b/packages/salesforcedx-vscode-lightning/test/unit/package/packageDependencies.test.ts index 50ea12a11c..80f7afe12e 100644 --- a/packages/salesforcedx-vscode-lightning/test/unit/package/packageDependencies.test.ts +++ b/packages/salesforcedx-vscode-lightning/test/unit/package/packageDependencies.test.ts @@ -15,13 +15,13 @@ const checkedPackagePatterns: RegExp[] = [ /^@salesforce\/salesforcedx/i ]; -function readJsonFile(jsonFilePath: string) { +const readJsonFile = (jsonFilePath: string): any => { try { return JSON.parse(fs.readFileSync(jsonFilePath, 'utf8')); } catch (e) { throw new Error(`Error reading json file from ${jsonFilePath}: ${e}`); } -} +}; const packageJsonPath = path.join( __dirname, diff --git a/packages/salesforcedx-vscode-lightning/test/vscode-integration/extension.test.ts b/packages/salesforcedx-vscode-lightning/test/vscode-integration/extension.test.ts index 2402418b1c..f9ffe00a5a 100644 --- a/packages/salesforcedx-vscode-lightning/test/vscode-integration/extension.test.ts +++ b/packages/salesforcedx-vscode-lightning/test/vscode-integration/extension.test.ts @@ -11,14 +11,14 @@ import * as vscode from 'vscode'; const PERFECT_MATCH = 10; -async function matchExtensionAsHtml(extension: string) { +const matchExtensionAsHtml = async (extension: string) => { const doc = await vscode.workspace.openTextDocument( vscode.Uri.parse(`untitled:fake/path/doc.${extension}`) ); expect(vscode.languages.match({ language: 'html' }, doc)).to.equal( PERFECT_MATCH ); -} +}; describe('Lightning file association', () => { it('Should support .app association', async () => { diff --git a/packages/salesforcedx-vscode-lightning/test/vscode-integration/hover.test.ts b/packages/salesforcedx-vscode-lightning/test/vscode-integration/hover.test.ts index aa4b58f4ec..2d37cc33fb 100644 --- a/packages/salesforcedx-vscode-lightning/test/vscode-integration/hover.test.ts +++ b/packages/salesforcedx-vscode-lightning/test/vscode-integration/hover.test.ts @@ -21,7 +21,7 @@ describe('Aura Hovers', function() { let auraDir: string; - beforeEach(async function() { + beforeEach(async () => { auraDir = path.join( workspace.workspaceFolders![0].uri.fsPath, 'force-app', @@ -33,10 +33,11 @@ describe('Aura Hovers', function() { await new Promise(r => setTimeout(r, 1000)); }); - afterEach(async function() { + afterEach(async () => { await commands.executeCommand('workbench.action.closeActiveEditor'); }); + // eslint-disable-next-line prefer-arrow/prefer-arrow-functions it('Should provide additional details when hovering over an aura tag', async function() { const doc = await workspace.openTextDocument( path.join(auraDir, 'auraPubsubSubscriber', 'auraPubsubSubscriber.cmp') @@ -64,6 +65,7 @@ describe('Aura Hovers', function() { expect(content!.value).to.include('View in Component Library'); }); + // eslint-disable-next-line prefer-arrow/prefer-arrow-functions it('Should provide additional details when hovering over an aura attribute', async function() { const doc = await workspace.openTextDocument( path.join(auraDir, 'auraPubsubSubscriber', 'auraPubsubSubscriber.cmp') @@ -100,7 +102,7 @@ describe('Aura Hovers', function() { * @param expectedContent - content that is being searched for * @returns the first content which includes the expected value || undefined */ -function findContentFromInstances(instances: Hover[], expectedContent: string) { +const findContentFromInstances = (instances: Hover[], expectedContent: string) => { for (const instance of instances) { // type assertion to prevent using a deprecated type // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion @@ -115,4 +117,4 @@ function findContentFromInstances(instances: Hover[], expectedContent: string) { return content; } } -} +}; diff --git a/packages/salesforcedx-vscode-lightning/test/vscode-integration/intellisense.test.ts b/packages/salesforcedx-vscode-lightning/test/vscode-integration/intellisense.test.ts index fc2cf7205b..0707f21a11 100644 --- a/packages/salesforcedx-vscode-lightning/test/vscode-integration/intellisense.test.ts +++ b/packages/salesforcedx-vscode-lightning/test/vscode-integration/intellisense.test.ts @@ -9,7 +9,7 @@ import { assert, expect } from 'chai'; import * as path from 'path'; import * as vscode from 'vscode'; -describe('Aura Intellisense Test Suite', function () { +describe('Aura Intellisense Test Suite', () => { let auraDir: string; beforeEach(async () => { @@ -159,11 +159,11 @@ describe('Aura Intellisense Test Suite', function () { // NOTE: Because the completion providers always returns all possible results and then VSCode // does the filtering based on what is typed, we have no good way of testing what vscode is // actually displaying to the user based on what we typed -async function testCompletion( +const testCompletion = async ( docUri: vscode.Uri, position: vscode.Position, expectedCompletionList: vscode.CompletionList -) { +) => { // Simulate triggering a completion // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion const actualCompletionList = (await vscode.commands.executeCommand( @@ -172,8 +172,8 @@ async function testCompletion( position )) as vscode.CompletionList; - expectedCompletionList.items.forEach(function (expectedItem) { - const actualItem = actualCompletionList.items.find(function (obj) { + expectedCompletionList.items.forEach(expectedItem => { + const actualItem = actualCompletionList.items.find(obj => { if (obj.label) { return obj.label === expectedItem.label; } @@ -211,4 +211,4 @@ async function testCompletion( ); } }); -} +}; diff --git a/packages/salesforcedx-vscode-lightning/test/vscode-integration/navigation.test.ts b/packages/salesforcedx-vscode-lightning/test/vscode-integration/navigation.test.ts index 100c423ff7..ec2a9829f2 100644 --- a/packages/salesforcedx-vscode-lightning/test/vscode-integration/navigation.test.ts +++ b/packages/salesforcedx-vscode-lightning/test/vscode-integration/navigation.test.ts @@ -10,11 +10,11 @@ import * as path from 'path'; import { Location, Position, commands, window, workspace } from 'vscode'; import URI from 'vscode-uri'; -describe('Aura Definition Linking', function() { +describe('Aura Definition Linking', () => { let auraDir: string; let lwcDir: string; - beforeEach(async function() { + beforeEach(async () => { auraDir = path.join( workspace.workspaceFolders![0].uri.fsPath, 'force-app', @@ -34,22 +34,22 @@ describe('Aura Definition Linking', function() { await new Promise(r => setTimeout(r, 1500)); }); - afterEach(async function() { + afterEach(async () => { await commands.executeCommand('workbench.action.closeActiveEditor'); }); - it('Should provide navigation to a selected Aura tag', function() { + it('Should provide navigation to a selected Aura tag', async () => { // select the 'c:DemoComponent' Aura tag - testDefinitionNavigation( + await testDefinitionNavigation( path.join(auraDir, 'DemoApp', 'DemoApp.app'), path.join(auraDir, 'DemoComponent', 'DemoComponent.cmp'), new Position(1, 12) ); }); - it('Should provide navigation to a selected LWC tag', function() { + it('Should provide navigation to a selected LWC tag', async () => { // select the 'c:contactList' LWC tag - testDefinitionNavigation( + await testDefinitionNavigation( path.join(auraDir, 'auraEmbeddedLWC', 'auraEmbeddedLWC.cmp'), path.join(lwcDir, 'contactList', 'contactList.js'), new Position(20, 28) @@ -63,11 +63,11 @@ describe('Aura Definition Linking', function() { * @param endLocation - expected definition location given the position * @param position - position to initiate the definition lookup */ -async function testDefinitionNavigation( +const testDefinitionNavigation = async ( startLocation: string, endLocation: string, position: Position -) { +) => { const doc = await workspace.openTextDocument(startLocation); const editor = await window.showTextDocument(doc); @@ -88,4 +88,4 @@ async function testDefinitionNavigation( const expectedURI = URI.file(endLocation); expect(location.uri.toString()).to.equal(expectedURI.toString()); -} +}; From 353d2ad7fda2534f2b6f980f727a0462a31b72d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristina=20Ca=C3=B1izales?= <113132642+CristiCanizales@users.noreply.github.com> Date: Tue, 19 Dec 2023 13:55:20 -0300 Subject: [PATCH 2/4] Cristi/config commands (#5273) * chore: config commands * chore: config commands * chore: config commands * chore: missed command from command palette * chore: sfdx to sf * chore: sfdx to sf set default org --- .../src/adapter/apexDebug.ts | 125 +++++++++--------- .../src/context/isvContextUtil.ts | 16 +-- .../test/unit/adapter/apexDebug.test.ts | 16 +-- .../cli/{forceConfigGet.ts => configGet.ts} | 14 +- .../src/cli/index.ts | 2 +- .../src/types/constants.ts | 4 +- .../src/types/index.ts | 4 +- .../cli/{forceConfigGet.ts => configGet.ts} | 10 +- packages/salesforcedx-utils/src/cli/index.ts | 2 +- .../src/constants/constants.ts | 4 +- ...rceConfigGet.test.ts => configGet.test.ts} | 28 ++-- .../salesforcedx-vscode-core/package.json | 12 +- .../package.nls.ja.json | 4 +- .../salesforcedx-vscode-core/package.nls.json | 4 +- .../src/commands/auth/orgLogout.ts | 10 +- .../{forceConfigList.ts => configList.ts} | 12 +- .../{forceConfigSet.ts => configSet.ts} | 34 +++-- .../src/commands/index.ts | 4 +- .../salesforcedx-vscode-core/src/constants.ts | 4 +- .../salesforcedx-vscode-core/src/index.ts | 26 ++-- .../src/messages/i18n.ja.ts | 4 +- .../src/messages/i18n.ts | 6 +- .../src/orgPicker/orgList.ts | 19 ++- ...eConfigList.test.ts => configList.test.ts} | 10 +- ...rceConfigSet.test.ts => configSet.test.ts} | 46 +++++-- .../orgPicker/orgList.test.ts | 4 +- 26 files changed, 220 insertions(+), 204 deletions(-) rename packages/salesforcedx-utils-vscode/src/cli/{forceConfigGet.ts => configGet.ts} (73%) rename packages/salesforcedx-utils/src/cli/{forceConfigGet.ts => configGet.ts} (78%) rename packages/salesforcedx-utils/test/jest/cli/{forceConfigGet.test.ts => configGet.test.ts} (75%) rename packages/salesforcedx-vscode-core/src/commands/{forceConfigList.ts => configList.ts} (75%) rename packages/salesforcedx-vscode-core/src/commands/{forceConfigSet.ts => configSet.ts} (75%) rename packages/salesforcedx-vscode-core/test/vscode-integration/commands/{forceConfigList.test.ts => configList.test.ts} (66%) rename packages/salesforcedx-vscode-core/test/vscode-integration/commands/{forceConfigSet.test.ts => configSet.test.ts} (70%) diff --git a/packages/salesforcedx-apex-debugger/src/adapter/apexDebug.ts b/packages/salesforcedx-apex-debugger/src/adapter/apexDebug.ts index 6af6cb2b44..ba707e828d 100644 --- a/packages/salesforcedx-apex-debugger/src/adapter/apexDebug.ts +++ b/packages/salesforcedx-apex-debugger/src/adapter/apexDebug.ts @@ -7,11 +7,11 @@ import { extractJsonObject, - ForceConfigGet, + ConfigGet, OrgDisplay, RequestService, - SFDX_CONFIG_ISV_DEBUGGER_SID, - SFDX_CONFIG_ISV_DEBUGGER_URL + SF_CONFIG_ISV_DEBUGGER_SID, + SF_CONFIG_ISV_DEBUGGER_URL } from '@salesforce/salesforcedx-utils'; import * as os from 'os'; import { basename } from 'path'; @@ -272,7 +272,7 @@ export class ScopeContainer implements VariableContainer { filter: FilterType, start?: number, count?: number - /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable @typescript-eslint/no-unused-vars */ ): Promise { if ( !this.frameInfo.locals && @@ -303,10 +303,11 @@ export class ScopeContainer implements VariableContainer { return Promise.all( values.map(async value => { - const variableReference = await session.resolveApexIdToVariableReference( - this.frameInfo.requestId, - value.ref - ); + const variableReference = + await session.resolveApexIdToVariableReference( + this.frameInfo.requestId, + value.ref + ); return new ApexVariable( value, variableKind, @@ -339,7 +340,7 @@ export class ObjectReferenceContainer implements VariableContainer { filter: FilterType, start?: number, count?: number - /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable @typescript-eslint/no-unused-vars */ ): Promise { if (!this.reference.fields) { // this object is empty @@ -348,10 +349,11 @@ export class ObjectReferenceContainer implements VariableContainer { return Promise.all( this.reference.fields.map(async value => { - const variableReference = await session.resolveApexIdToVariableReference( - this.requestId, - value.ref - ); + const variableReference = + await session.resolveApexIdToVariableReference( + this.requestId, + value.ref + ); return new ApexVariable( value, ApexVariableKind.Field, @@ -476,7 +478,7 @@ export class MapTupleContainer implements VariableContainer { filter: FilterType, start?: number, count?: number - /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable @typescript-eslint/no-unused-vars */ ): Promise { if (!this.tuple.key && !this.tuple.value) { // this object is empty @@ -496,9 +498,9 @@ export class MapTupleContainer implements VariableContainer { if (this.tuple.key) { const keyVariableReference = this.tuple.key.ref ? await session.resolveApexIdToVariableReference( - this.requestId, - this.tuple.key.ref - ) + this.requestId, + this.tuple.key.ref + ) : undefined; variables.push( new ApexVariable( @@ -512,9 +514,9 @@ export class MapTupleContainer implements VariableContainer { if (this.tuple.value) { const valueVariableReference = this.tuple.value.ref ? await session.resolveApexIdToVariableReference( - this.requestId, - this.tuple.value.ref - ) + this.requestId, + this.tuple.value.ref + ) : undefined; variables.push( new ApexVariable( @@ -569,7 +571,7 @@ export class ApexDebug extends LoggingDebugSession { protected initializeRequest( response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments - /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable @typescript-eslint/no-unused-vars */ ): void { this.initializedResponse = response; this.initializedResponse.body = { @@ -595,7 +597,7 @@ export class ApexDebug extends LoggingDebugSession { protected attachRequest( response: DebugProtocol.AttachResponse, args: DebugProtocol.AttachRequestArguments - /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable @typescript-eslint/no-unused-vars */ ): void { response.success = false; this.sendResponse(response); @@ -674,13 +676,13 @@ export class ApexDebug extends LoggingDebugSession { } try { if (args.connectType === CONNECT_TYPE_ISV_DEBUGGER) { - const forceConfig = await new ForceConfigGet().getConfig( + const config = await new ConfigGet().getConfig( args.sfdxProject, - SFDX_CONFIG_ISV_DEBUGGER_SID, - SFDX_CONFIG_ISV_DEBUGGER_URL + SF_CONFIG_ISV_DEBUGGER_SID, + SF_CONFIG_ISV_DEBUGGER_URL ); - const isvDebuggerSid = forceConfig.get(SFDX_CONFIG_ISV_DEBUGGER_SID); - const isvDebuggerUrl = forceConfig.get(SFDX_CONFIG_ISV_DEBUGGER_URL); + const isvDebuggerSid = config.get(SF_CONFIG_ISV_DEBUGGER_SID); + const isvDebuggerUrl = config.get(SF_CONFIG_ISV_DEBUGGER_URL); if ( typeof isvDebuggerSid === 'undefined' || typeof isvDebuggerUrl === 'undefined' @@ -746,10 +748,8 @@ export class ApexDebug extends LoggingDebugSession { if (args && args.lineBreakpointInfo) { const lineBpInfo: LineBreakpointInfo[] = args.lineBreakpointInfo; if (lineBpInfo && lineBpInfo.length > 0) { - const lineNumberMapping: Map< - string, - LineBreakpointsInTyperef[] - > = new Map(); + const lineNumberMapping: Map = + new Map(); const typerefMapping: Map = new Map(); for (const info of lineBpInfo) { if (!lineNumberMapping.has(info.uri)) { @@ -804,7 +804,8 @@ export class ApexDebug extends LoggingDebugSession { ); } else { this.errorToDebugConsole( - `${nls.localize('command_error_help_text')}:${os.EOL + `${nls.localize('command_error_help_text')}:${ + os.EOL }${terminatedSessionId}` ); } @@ -837,17 +838,18 @@ export class ApexDebug extends LoggingDebugSession { TRACE_CATEGORY_BREAKPOINTS, `setBreakPointsRequest: uri=${uri}` ); - const knownBps = await this.myBreakpointService.reconcileLineBreakpoints( - this.sfdxProject, - uri, - this.mySessionService.getSessionId(), - args.lines!.map(line => this.convertClientLineToDebugger(line)) - ); + const knownBps = + await this.myBreakpointService.reconcileLineBreakpoints( + this.sfdxProject, + uri, + this.mySessionService.getSessionId(), + args.lines!.map(line => this.convertClientLineToDebugger(line)) + ); return Promise.resolve(knownBps); } ); // tslint:disable-next-line:no-empty - } catch (error) { } + } catch (error) {} verifiedBreakpoints.forEach(verifiedBreakpoint => { const lineNumber = this.convertDebuggerLineToClient(verifiedBreakpoint); response.body.breakpoints.push({ @@ -1001,7 +1003,7 @@ export class ApexDebug extends LoggingDebugSession { this.log( TRACE_CATEGORY_VARIABLES, 'stackTraceRequest: state=' + - JSON.stringify(stateRespObj.stateResponse.state) + JSON.stringify(stateRespObj.stateResponse.state) ); if ( stateRespObj.stateResponse.state.locals && @@ -1049,9 +1051,9 @@ export class ApexDebug extends LoggingDebugSession { serverFrames[i].fullName, sourcePath ? new Source( - basename(sourcePath), - this.convertDebuggerPathToClient(sourcePath) - ) + basename(sourcePath), + this.convertDebuggerPathToClient(sourcePath) + ) : undefined, this.convertDebuggerLineToClient(serverFrames[i].lineNumber), 0 @@ -1135,7 +1137,9 @@ export class ApexDebug extends LoggingDebugSession { break; case LIST_EXCEPTION_BREAKPOINTS_REQUEST: response.body = { - typerefs: Array.from(this.myBreakpointService.getExceptionBreakpointCache().keys()) + typerefs: Array.from( + this.myBreakpointService.getExceptionBreakpointCache().keys() + ) }; break; default: @@ -1258,7 +1262,7 @@ export class ApexDebug extends LoggingDebugSession { this.log( TRACE_CATEGORY_VARIABLES, `fetchFrameVariables: frame ${frameInfo.frameNumber} frame=` + - JSON.stringify(frameRespObj.frameResponse.frame) + JSON.stringify(frameRespObj.frameResponse.frame) ); if ( frameRespObj.frameResponse.frame.locals && @@ -1384,9 +1388,8 @@ export class ApexDebug extends LoggingDebugSession { return; } } - const variableReference = this.variableContainerReferenceByApexId.get( - apexId - ); + const variableReference = + this.variableContainerReferenceByApexId.get(apexId); this.log( TRACE_CATEGORY_VARIABLES, `resolveApexIdToVariableReference: resolved apexId=${apexId} to variableReference=${variableReference}` @@ -1405,9 +1408,8 @@ export class ApexDebug extends LoggingDebugSession { const referencesResponse = await this.myRequestService.execute( new ReferencesCommand(requestId, ...apexIds) ); - const referencesResponseObj: DebuggerResponse = JSON.parse( - referencesResponse - ); + const referencesResponseObj: DebuggerResponse = + JSON.parse(referencesResponse); if ( referencesResponseObj && referencesResponseObj.referencesResponse && @@ -1513,7 +1515,8 @@ export class ApexDebug extends LoggingDebugSession { } if (errorObj.action) { this.errorToDebugConsole( - `${nls.localize('command_error_help_text')}:${os.EOL}${errorObj.action + `${nls.localize('command_error_help_text')}:${os.EOL}${ + errorObj.action }` ); } @@ -1664,17 +1667,17 @@ export class ApexDebug extends LoggingDebugSession { if (matches && matches.length === 3) { const possibleClassName = matches[1]; const possibleClassLine = parseInt(matches[2], 10); - const possibleSourcePath = this.myBreakpointService.getSourcePathFromPartialTyperef( - possibleClassName - ); + const possibleSourcePath = + this.myBreakpointService.getSourcePathFromPartialTyperef( + possibleClassName + ); if (possibleSourcePath) { eventDescriptionSourceFile = new Source( basename(possibleSourcePath), this.convertDebuggerPathToClient(possibleSourcePath) ); - eventDescriptionSourceLine = this.convertDebuggerLineToClient( - possibleClassLine - ); + eventDescriptionSourceLine = + this.convertDebuggerLineToClient(possibleClassLine); } } } @@ -1778,10 +1781,8 @@ export class ApexDebug extends LoggingDebugSession { // if breakpointid is found in exception breakpoint cache // set the reason for stopped event to that reason if (message.sobject.BreakpointId) { - const cache: Map< - string, - string - > = this.myBreakpointService.getExceptionBreakpointCache(); + const cache: Map = + this.myBreakpointService.getExceptionBreakpointCache(); cache.forEach((value, key) => { if (value === message.sobject.BreakpointId) { // typerefs for exceptions will change based on whether they are custom, diff --git a/packages/salesforcedx-apex-debugger/src/context/isvContextUtil.ts b/packages/salesforcedx-apex-debugger/src/context/isvContextUtil.ts index 058d3b58cf..20fdedfc0a 100644 --- a/packages/salesforcedx-apex-debugger/src/context/isvContextUtil.ts +++ b/packages/salesforcedx-apex-debugger/src/context/isvContextUtil.ts @@ -8,23 +8,23 @@ import { ENV_SF_ORG_INSTANCE_URL, ENV_SF_TARGET_ORG, - ForceConfigGet, + ConfigGet, GlobalCliEnvironment, - SFDX_CONFIG_ISV_DEBUGGER_SID, - SFDX_CONFIG_ISV_DEBUGGER_URL + SF_CONFIG_ISV_DEBUGGER_SID, + SF_CONFIG_ISV_DEBUGGER_URL } from '@salesforce/salesforcedx-utils'; export class IsvContextUtil { public async setIsvDebuggerContext(projectWorkspacePath: string) { let isvDebugProject = false; if (projectWorkspacePath) { - const forceConfig = await new ForceConfigGet().getConfig( + const config = await new ConfigGet().getConfig( projectWorkspacePath, - SFDX_CONFIG_ISV_DEBUGGER_SID, - SFDX_CONFIG_ISV_DEBUGGER_URL + SF_CONFIG_ISV_DEBUGGER_SID, + SF_CONFIG_ISV_DEBUGGER_URL ); - const isvDebuggerSid = forceConfig.get(SFDX_CONFIG_ISV_DEBUGGER_SID); - const isvDebuggerUrl = forceConfig.get(SFDX_CONFIG_ISV_DEBUGGER_URL); + const isvDebuggerSid = config.get(SF_CONFIG_ISV_DEBUGGER_SID); + const isvDebuggerUrl = config.get(SF_CONFIG_ISV_DEBUGGER_URL); if ( typeof isvDebuggerSid !== 'undefined' && diff --git a/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebug.test.ts b/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebug.test.ts index d4fddd1a37..85731e3821 100644 --- a/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebug.test.ts +++ b/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebug.test.ts @@ -8,7 +8,7 @@ // tslint:disable:no-floating-promises import { DEFAULT_CONNECTION_TIMEOUT_MS, - ForceConfigGet, + ConfigGet, OrgDisplay, OrgInfo, RequestService @@ -177,7 +177,7 @@ describe('Interactive debugger adapter - unit', () => { .stub(OrgDisplay.prototype, 'getOrgInfo') .returns({} as OrgInfo); configGetSpy = sinon - .stub(ForceConfigGet.prototype, 'getConfig') + .stub(ConfigGet.prototype, 'getConfig') .returns({} as Map); args = { sfdxProject: 'project', @@ -668,10 +668,8 @@ describe('Interactive debugger adapter - unit', () => { { uri: 'file:///bar.cls', typeref: 'bar', lines: [1, 2, 3] }, { uri: 'file:///bar.cls', typeref: 'bar$inner', lines: [4, 5, 6] } ]; - const expectedLineNumberMapping: Map< - string, - LineBreakpointsInTyperef[] - > = new Map(); + const expectedLineNumberMapping: Map = + new Map(); const expectedTyperefMapping: Map = new Map(); expectedLineNumberMapping.set('file:///foo.cls', [ { typeref: 'foo', lines: [1, 2, 3] }, @@ -1554,10 +1552,8 @@ describe('Interactive debugger adapter - unit', () => { describe('Logging', () => { let breakpointService: BreakpointService; let response: DebugProtocol.Response; - const lineNumberMapping: Map< - string, - LineBreakpointsInTyperef[] - > = new Map(); + const lineNumberMapping: Map = + new Map(); const typerefMapping: Map = new Map(); const fooUri = 'file:///foo.cls'; lineNumberMapping.set(fooUri, [ diff --git a/packages/salesforcedx-utils-vscode/src/cli/forceConfigGet.ts b/packages/salesforcedx-utils-vscode/src/cli/configGet.ts similarity index 73% rename from packages/salesforcedx-utils-vscode/src/cli/forceConfigGet.ts rename to packages/salesforcedx-utils-vscode/src/cli/configGet.ts index e127fe7552..151753bc16 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/forceConfigGet.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/configGet.ts @@ -9,19 +9,17 @@ import { SfdxCommandBuilder } from './commandBuilder'; import { CliCommandExecutor } from './commandExecutor'; import { CommandOutput } from './commandOutput'; -export const FORCE_CONFIG_GET_COMMAND = 'force:config:get'; +export const CONFIG_GET_COMMAND = 'config:get'; /** * @deprecated * NOTE: This code is deprecated in favor of using ConfigUtil.ts */ -export class ForceConfigGet { +export class ConfigGet { public async getConfig( projectPath: string, ...keys: string[] ): Promise> { - const commandBuilder = new SfdxCommandBuilder().withArg( - FORCE_CONFIG_GET_COMMAND - ); + const commandBuilder = new SfdxCommandBuilder().withArg(CONFIG_GET_COMMAND); keys.forEach(key => commandBuilder.withArg(key)); const execution = new CliCommandExecutor( @@ -34,10 +32,10 @@ export class ForceConfigGet { const cmdOutput = new CommandOutput(); const result = await cmdOutput.getCmdResult(execution); try { - const forceConfigMap = new Map(); + const configMap = new Map(); const results = JSON.parse(result).result as any[]; - results.forEach(entry => forceConfigMap.set(entry.key, entry.value)); - return Promise.resolve(forceConfigMap); + results.forEach(entry => configMap.set(entry.key, entry.value)); + return Promise.resolve(configMap); } catch (e) { return Promise.reject(e); } diff --git a/packages/salesforcedx-utils-vscode/src/cli/index.ts b/packages/salesforcedx-utils-vscode/src/cli/index.ts index 96e54fa5fb..7759b29668 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/index.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/index.ts @@ -30,7 +30,7 @@ export { DiffResultParser, DiffSuccessResponse } from './diffResultParser'; -export { ForceConfigGet } from './forceConfigGet'; +export { ConfigGet } from './configGet'; export { LocalCommandExecution } from './localCommandExecutor'; export { OrgCreateErrorResult, diff --git a/packages/salesforcedx-utils-vscode/src/types/constants.ts b/packages/salesforcedx-utils-vscode/src/types/constants.ts index 8be753d832..fa11e0206b 100644 --- a/packages/salesforcedx-utils-vscode/src/types/constants.ts +++ b/packages/salesforcedx-utils-vscode/src/types/constants.ts @@ -15,5 +15,5 @@ export const SFDX_FOLDER = '.sfdx'; export const ENV_SF_TARGET_ORG = 'SF_TARGET_ORG'; export const ENV_SF_ORG_INSTANCE_URL = 'SF_ORG_INSTANCE_URL'; -export const SFDX_CONFIG_ISV_DEBUGGER_SID = 'isvDebuggerSid'; -export const SFDX_CONFIG_ISV_DEBUGGER_URL = 'isvDebuggerUrl'; +export const SF_CONFIG_ISV_DEBUGGER_SID = 'isvDebuggerSid'; +export const SF_CONFIG_ISV_DEBUGGER_URL = 'isvDebuggerUrl'; diff --git a/packages/salesforcedx-utils-vscode/src/types/index.ts b/packages/salesforcedx-utils-vscode/src/types/index.ts index b9f9f3bdfe..f622f42c18 100644 --- a/packages/salesforcedx-utils-vscode/src/types/index.ts +++ b/packages/salesforcedx-utils-vscode/src/types/index.ts @@ -11,8 +11,8 @@ export { SFDX_PROJECT_FILE, ENV_SF_TARGET_ORG, ENV_SF_ORG_INSTANCE_URL, - SFDX_CONFIG_ISV_DEBUGGER_SID, - SFDX_CONFIG_ISV_DEBUGGER_URL, + SF_CONFIG_ISV_DEBUGGER_SID, + SF_CONFIG_ISV_DEBUGGER_URL, TARGET_ORG_KEY, DEFAULT_CONNECTION_TIMEOUT_MS, CLIENT_ID diff --git a/packages/salesforcedx-utils/src/cli/forceConfigGet.ts b/packages/salesforcedx-utils/src/cli/configGet.ts similarity index 78% rename from packages/salesforcedx-utils/src/cli/forceConfigGet.ts rename to packages/salesforcedx-utils/src/cli/configGet.ts index ee309ff4ae..7a8042e056 100644 --- a/packages/salesforcedx-utils/src/cli/forceConfigGet.ts +++ b/packages/salesforcedx-utils/src/cli/configGet.ts @@ -12,12 +12,12 @@ import { SfdxCommandBuilder } from './sfdxCommandBuilder'; * @deprecated * NOTE: This code is deprecated in favor of using ConfigUtil.ts */ -export class ForceConfigGet { +export class ConfigGet { public async getConfig( projectPath: string, ...keys: string[] ): Promise> { - const commandBuilder = new SfdxCommandBuilder().withArg('force:config:get'); + const commandBuilder = new SfdxCommandBuilder().withArg('config:get'); keys.forEach(key => commandBuilder.withArg(key)); const execution = new CliCommandExecutor( @@ -30,10 +30,10 @@ export class ForceConfigGet { const cmdOutput = new CommandOutput(); const result = await cmdOutput.getCmdResult(execution); try { - const forceConfigMap = new Map(); + const configMap = new Map(); const results = JSON.parse(result).result as any[]; - results.forEach(entry => forceConfigMap.set(entry.key, entry.value)); - return Promise.resolve(forceConfigMap); + results.forEach(entry => configMap.set(entry.key, entry.value)); + return Promise.resolve(configMap); } catch (e) { return Promise.reject(e); } diff --git a/packages/salesforcedx-utils/src/cli/index.ts b/packages/salesforcedx-utils/src/cli/index.ts index 00f4c53f23..bf96ce3468 100644 --- a/packages/salesforcedx-utils/src/cli/index.ts +++ b/packages/salesforcedx-utils/src/cli/index.ts @@ -8,7 +8,7 @@ export { CliCommandExecution } from './cliCommandExecution'; export { CliCommandExecutor } from './cliCommandExecutor'; export { CommandBuilder } from './commandBuilder'; export { CommandOutput } from './commandOutput'; -export { ForceConfigGet } from './forceConfigGet'; +export { ConfigGet } from './configGet'; export { GlobalCliEnvironment } from './globalCliEnvironment'; export { OrgDisplay } from './orgDisplay'; export { SfdxCommandBuilder } from './sfdxCommandBuilder'; diff --git a/packages/salesforcedx-utils/src/constants/constants.ts b/packages/salesforcedx-utils/src/constants/constants.ts index 34434d9817..5f22c0704d 100644 --- a/packages/salesforcedx-utils/src/constants/constants.ts +++ b/packages/salesforcedx-utils/src/constants/constants.ts @@ -17,6 +17,6 @@ export const DEFAULT_LOCALE = 'en'; export const LOCALE_JA = 'ja'; export const MISSING_LABEL_MSG = '!!! MISSING LABEL !!!'; export const SFDX_COMMAND = 'sfdx'; -export const SFDX_CONFIG_ISV_DEBUGGER_SID = 'isvDebuggerSid'; -export const SFDX_CONFIG_ISV_DEBUGGER_URL = 'isvDebuggerUrl'; +export const SF_CONFIG_ISV_DEBUGGER_SID = 'isvDebuggerSid'; +export const SF_CONFIG_ISV_DEBUGGER_URL = 'isvDebuggerUrl'; export const TELEMETRY_HEADER = 'salesforce-vscode-extensions'; diff --git a/packages/salesforcedx-utils/test/jest/cli/forceConfigGet.test.ts b/packages/salesforcedx-utils/test/jest/cli/configGet.test.ts similarity index 75% rename from packages/salesforcedx-utils/test/jest/cli/forceConfigGet.test.ts rename to packages/salesforcedx-utils/test/jest/cli/configGet.test.ts index 22c2963a81..1eb74c7074 100644 --- a/packages/salesforcedx-utils/test/jest/cli/forceConfigGet.test.ts +++ b/packages/salesforcedx-utils/test/jest/cli/configGet.test.ts @@ -4,18 +4,14 @@ * 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 { - CliCommandExecutor, - CommandOutput, - ForceConfigGet -} from '../../../src'; +import { CliCommandExecutor, CommandOutput, ConfigGet } from '../../../src'; import { JSON_FLAG } from '../../../src/cli/commandBuilder'; -describe('ForceOrgGet unit tests.', () => { +describe('OrgGet unit tests.', () => { const fakeExecution = { totally: 'fake' }; - // forceConfigGet expect and array with named keys which does not play nice in TS land + // configGet expect and array with named keys which does not play nice in TS land // eslint-disable-next-line @typescript-eslint/no-explicit-any const configMap: any = [ { key: 'config1', value: 'true' }, @@ -41,14 +37,14 @@ describe('ForceOrgGet unit tests.', () => { }); it('Should create instance.', () => { - const forceConfigGet = new ForceConfigGet(); - expect(forceConfigGet).toBeInstanceOf(ForceConfigGet); + const configGet = new ConfigGet(); + expect(configGet).toBeInstanceOf(ConfigGet); }); describe('getConfig()', () => { it('Should be able to get all configs.', async () => { - const forceConfigGet = new ForceConfigGet(); - const config = await forceConfigGet.getConfig(fakePath); + const configGet = new ConfigGet(); + const config = await configGet.getConfig(fakePath); expect(config).toBeInstanceOf(Map); expect(config.size).toEqual(3); expect(config.get(configMap[0].key)).toEqual(configMap[0].value); @@ -59,8 +55,8 @@ describe('ForceOrgGet unit tests.', () => { }); it('Should be able to pass an arg to the command.', async () => { - const forceConfigGet = new ForceConfigGet(); - const config = await forceConfigGet.getConfig(fakePath, JSON_FLAG); + const configGet = new ConfigGet(); + const config = await configGet.getConfig(fakePath, JSON_FLAG); expect(config).toBeInstanceOf(Map); expect(config.size).toEqual(3); expect(executeSpy).toHaveBeenCalled(); @@ -70,9 +66,11 @@ describe('ForceOrgGet unit tests.', () => { it('Should reject with result when json is not parseable.', async () => { const partialJson = fakeResult.substring(2); getCmdResultSpy.mockResolvedValue(partialJson); - const forceConfigGet = new ForceConfigGet(); + const configGet = new ConfigGet(); // Unexpected token error is thrown b/c json can not be parsed. - expect(forceConfigGet.getConfig(fakePath)).rejects.toThrowError(/Unexpected token/); + expect(configGet.getConfig(fakePath)).rejects.toThrowError( + /Unexpected token/ + ); }); }); }); diff --git a/packages/salesforcedx-vscode-core/package.json b/packages/salesforcedx-vscode-core/package.json index 24e7fe0667..f10ef3ed8c 100644 --- a/packages/salesforcedx-vscode-core/package.json +++ b/packages/salesforcedx-vscode-core/package.json @@ -432,7 +432,7 @@ "when": "sfdx:project_opened" }, { - "command": "sfdx.force.config.list", + "command": "sfdx.config.list", "when": "sfdx:project_opened" }, { @@ -540,7 +540,7 @@ "when": "sfdx:project_opened && resourceLangId != 'forcesourcemanifest' && editorIsOpen" }, { - "command": "sfdx.force.set.default.org", + "command": "sfdx.set.default.org", "when": "sfdx:project_opened" }, { @@ -743,8 +743,8 @@ "title": "%debugger_stop_text%" }, { - "command": "sfdx.force.config.list", - "title": "%force_config_list_text%" + "command": "sfdx.config.list", + "title": "%config_list_text%" }, { "command": "sfdx.alias.list", @@ -835,8 +835,8 @@ "title": "%delete_source_this_source_text%" }, { - "command": "sfdx.force.set.default.org", - "title": "%force_config_set_org_text%" + "command": "sfdx.set.default.org", + "title": "%config_set_org_text%" }, { "command": "sfdx.force.lightning.lwc.create", diff --git a/packages/salesforcedx-vscode-core/package.nls.ja.json b/packages/salesforcedx-vscode-core/package.nls.ja.json index 8e84d673c4..76dd187a30 100644 --- a/packages/salesforcedx-vscode-core/package.nls.ja.json +++ b/packages/salesforcedx-vscode-core/package.nls.ja.json @@ -25,7 +25,7 @@ "force_source_status_local_text": "SFDX: ローカルの変更を表示", "force_source_status_remote_text": "SFDX: デフォルトのスクラッチ組織内の変更を表示", "debugger_stop_text": "SFDX: Apex デバッガセッションを停止", - "force_config_list_text": "SFDX: すべての設定変数を一覧表示", + "config_list_text": "SFDX: すべての設定変数を一覧表示", "alias_list_text": "SFDX: すべてのエイリアスを一覧表示", "force_org_delete_default_text": "SFDX: デフォルトの組織を削除", "force_org_delete_username_text": "SFDX: 組織を削除...", @@ -59,7 +59,7 @@ "force_source_deploy_in_manifest_text": "SFDX: マニフェストファイルのソースを組織へデプロイ", "delete_source_text": "SFDX: プロジェクトおよび組織から削除", "delete_source_this_source_text": "SFDX: このソースをプロジェクトと組織から削除", - "force_config_set_org_text": "SFDX: デフォルトの組織を設定", + "config_set_org_text": "SFDX: デフォルトの組織を設定", "refresh_types_text": "SFDX: メタデータ型を更新", "refresh_components_text": "SFDX: コンポーネントを更新", "force_source_retrieve_display_text": "組織からソースを取得", diff --git a/packages/salesforcedx-vscode-core/package.nls.json b/packages/salesforcedx-vscode-core/package.nls.json index 20ab0ad853..5673c82b56 100644 --- a/packages/salesforcedx-vscode-core/package.nls.json +++ b/packages/salesforcedx-vscode-core/package.nls.json @@ -28,7 +28,7 @@ "force_source_status_local_text": "SFDX: View Local Changes", "force_source_status_remote_text": "SFDX: View Changes in Default Org", "debugger_stop_text": "SFDX: Stop Apex Debugger Session", - "force_config_list_text": "SFDX: List All Config Variables", + "config_list_text": "SFDX: List All Config Variables", "alias_list_text": "SFDX: List All Aliases", "force_org_delete_default_text": "SFDX: Delete Default Org", "force_org_delete_username_text": "SFDX: Delete Org...", @@ -64,7 +64,7 @@ "force_source_deploy_in_manifest_text": "SFDX: Deploy Source in Manifest to Org", "delete_source_text": "SFDX: Delete from Project and Org", "delete_source_this_source_text": "SFDX: Delete This from Project and Org", - "force_config_set_org_text": "SFDX: Set a Default Org", + "config_set_org_text": "SFDX: Set a Default Org", "refresh_types_text": "SFDX: Refresh Types", "refresh_components_text": "SFDX: Refresh Components", "force_source_retrieve_display_text": "Retrieve Source from Org", diff --git a/packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts b/packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts index 94ee8c8f15..fad78da56e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts +++ b/packages/salesforcedx-vscode-core/src/commands/auth/orgLogout.ts @@ -8,17 +8,17 @@ import { AuthRemover } from '@salesforce/core'; import { Command, + ContinueResponse, + LibraryCommandletExecutor, notificationService, SfdxCommandBuilder } from '@salesforce/salesforcedx-utils-vscode'; -import { LibraryCommandletExecutor } from '@salesforce/salesforcedx-utils-vscode'; -import { ContinueResponse } from '@salesforce/salesforcedx-utils-vscode'; import { CancellationToken, Progress } from 'vscode'; import { OUTPUT_CHANNEL } from '../../channels'; import { nls } from '../../messages'; import { telemetryService } from '../../telemetry'; import { OrgAuthInfo } from '../../util'; -import { forceConfigSet } from '../forceConfigSet'; +import { configSet } from '../configSet'; import { EmptyParametersGatherer, SfdxCommandlet, @@ -77,7 +77,7 @@ export class OrgLogoutDefault extends LibraryCommandletExecutor { increment?: number | undefined; }>, token?: CancellationToken - /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable @typescript-eslint/no-unused-vars */ ): Promise { try { await removeUsername(response.data); @@ -113,7 +113,7 @@ export async function orgLogoutDefault() { } async function removeUsername(username: string) { - await forceConfigSet(''); + await configSet(''); const authRemover = await AuthRemover.create(); await authRemover.removeAuth(username); } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts b/packages/salesforcedx-vscode-core/src/commands/configList.ts similarity index 75% rename from packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts rename to packages/salesforcedx-vscode-core/src/commands/configList.ts index c3c8d6f484..fa531bbc21 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceConfigList.ts +++ b/packages/salesforcedx-vscode-core/src/commands/configList.ts @@ -17,26 +17,26 @@ import { SfdxWorkspaceChecker } from './util'; -export class ForceConfigList extends SfdxCommandletExecutor<{}> { +export class ConfigList extends SfdxCommandletExecutor<{}> { // eslint-disable-next-line @typescript-eslint/no-unused-vars public build(data: {}): Command { return new SfdxCommandBuilder() - .withDescription(nls.localize('force_config_list_text')) - .withArg('force:config:list') - .withLogName('force_config_list') + .withDescription(nls.localize('config_list_text')) + .withArg('config:list') + .withLogName('config_list') .build(); } } const workspaceChecker = new SfdxWorkspaceChecker(); const parameterGatherer = new EmptyParametersGatherer(); -const executor = new ForceConfigList(); +const executor = new ConfigList(); const commandlet = new SfdxCommandlet( workspaceChecker, parameterGatherer, executor ); -export async function forceConfigList() { +export async function configList() { await commandlet.run(); } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts b/packages/salesforcedx-vscode-core/src/commands/configSet.ts similarity index 75% rename from packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts rename to packages/salesforcedx-vscode-core/src/commands/configSet.ts index 33744ab52b..fda1d4cf26 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceConfigSet.ts +++ b/packages/salesforcedx-vscode-core/src/commands/configSet.ts @@ -4,7 +4,13 @@ * 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 { ConfigUtil, ContinueResponse, LibraryCommandletExecutor, Row, Table} from '@salesforce/salesforcedx-utils-vscode'; +import { + ConfigUtil, + ContinueResponse, + LibraryCommandletExecutor, + Row, + Table +} from '@salesforce/salesforcedx-utils-vscode'; import { channelService, OUTPUT_CHANNEL } from '../channels'; import { CONFIG_SET_EXECUTOR, @@ -21,15 +27,17 @@ import { SfdxWorkspaceChecker } from './util'; -export class ForceConfigSetExecutor extends LibraryCommandletExecutor<{}> { +export class ConfigSetExecutor extends LibraryCommandletExecutor<{}> { private usernameOrAlias: string; protected showChannelOutput = false; private outputTableRow: Row = {}; - constructor( - usernameOrAlias: string - ) { - super(nls.localize(CONFIG_SET_EXECUTOR), CONFIG_SET_EXECUTOR, OUTPUT_CHANNEL); + constructor(usernameOrAlias: string) { + super( + nls.localize(CONFIG_SET_EXECUTOR), + CONFIG_SET_EXECUTOR, + OUTPUT_CHANNEL + ); this.usernameOrAlias = `${usernameOrAlias}`.split(',')[0]; } @@ -41,12 +49,14 @@ export class ForceConfigSetExecutor extends LibraryCommandletExecutor<{}> { result = true; await ConfigUtil.setDefaultUsernameOrAlias(this.usernameOrAlias); } catch (error) { - message = error instanceof Error - ? error.message - : String(error); + message = error instanceof Error ? error.message : String(error); result = false; } - this.outputTableRow = { name: TARGET_ORG_KEY, val: this.usernameOrAlias, success: String(result) }; + this.outputTableRow = { + name: TARGET_ORG_KEY, + val: this.usernameOrAlias, + success: String(result) + }; const outputTable = this.formatOutput(this.outputTableRow); channelService.appendLine(outputTable); if (message) { @@ -75,11 +85,11 @@ export class ForceConfigSetExecutor extends LibraryCommandletExecutor<{}> { const workspaceChecker = new SfdxWorkspaceChecker(); const parameterGatherer = new EmptyParametersGatherer(); -export async function forceConfigSet(usernameOrAlias: string) { +export async function configSet(usernameOrAlias: string) { const commandlet = new SfdxCommandlet( workspaceChecker, parameterGatherer, - new ForceConfigSetExecutor(usernameOrAlias) + new ConfigSetExecutor(usernameOrAlias) ); await commandlet.run(); } diff --git a/packages/salesforcedx-vscode-core/src/commands/index.ts b/packages/salesforcedx-vscode-core/src/commands/index.ts index 6389d892b0..972afa4bfe 100644 --- a/packages/salesforcedx-vscode-core/src/commands/index.ts +++ b/packages/salesforcedx-vscode-core/src/commands/index.ts @@ -48,8 +48,8 @@ export { ManifestChecker, deleteSource } from './deleteSource'; -export { ForceConfigList, forceConfigList } from './forceConfigList'; -export { ForceConfigSetExecutor, forceConfigSet } from './forceConfigSet'; +export { ConfigList, configList } from './configList'; +export { ConfigSetExecutor, configSet } from './configSet'; export { forceCreateManifest } from './forceCreateManifest'; export { ForceDescribeMetadataExecutor, diff --git a/packages/salesforcedx-vscode-core/src/constants.ts b/packages/salesforcedx-vscode-core/src/constants.ts index 52061cca4b..b85e2cabf6 100644 --- a/packages/salesforcedx-vscode-core/src/constants.ts +++ b/packages/salesforcedx-vscode-core/src/constants.ts @@ -23,8 +23,8 @@ export const TELEMETRY_OPT_OUT_LINK = 'https://developer.salesforce.com/tools/vscode/en/faq/telemetry'; export const TELEMETRY_METADATA_COUNT = 'metadataCount'; -export const CONFIG_SET_EXECUTOR = 'force_config_set_org_text'; -export const CONFIG_SET_NAME = 'force_config_set_title'; +export const CONFIG_SET_EXECUTOR = 'config_set_org_text'; +export const CONFIG_SET_NAME = 'config_set_title'; export const TABLE_NAME_COL = 'table_header_name'; export const TABLE_VAL_COL = 'table_header_value'; export const TABLE_SUCCESS_COL = 'table_header_success'; diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index 3501dde314..529e816554 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -16,6 +16,8 @@ import { channelService } from './channels'; import { aliasList, checkSObjectsAndRefresh, + configList, + configSet, dataQuery, debuggerStop, deleteSource, @@ -24,8 +26,6 @@ import { forceApexTriggerCreate, forceApexUnitClassCreate, forceAuthAccessToken, - forceConfigList, - forceConfigSet, forceCreateManifest, forceInternalLightningAppCreate, forceInternalLightningComponentCreate, @@ -283,9 +283,9 @@ function registerCommands( 'sfdx.debugger.stop', debuggerStop ); - const forceConfigListCmd = vscode.commands.registerCommand( - 'sfdx.force.config.list', - forceConfigList + const configListCmd = vscode.commands.registerCommand( + 'sfdx.config.list', + configList ); const forceAliasListCmd = vscode.commands.registerCommand( 'sfdx.alias.list', @@ -355,9 +355,9 @@ function registerCommands( isvDebugBootstrap ); - const forceConfigSetCmd = vscode.commands.registerCommand( - 'sfdx.force.config.set', - forceConfigSet + const configSetCmd = vscode.commands.registerCommand( + 'sfdx.config.set', + configSet ); const forceDiffFile = vscode.commands.registerCommand( @@ -423,7 +423,7 @@ function registerCommands( forceLightningLwcCreateCmd, forceLightningLwcTestCreateCmd, debuggerStopCmd, - forceConfigListCmd, + configListCmd, forceAliasListCmd, orgDisplayDefaultCmd, orgDisplayUsernameCmd, @@ -434,7 +434,7 @@ function registerCommands( startApexDebugLoggingCmd, stopApexDebugLoggingCmd, isvDebugBootstrapCmd, - forceConfigSetCmd, + configSetCmd, orgListCleanCmd, orgLoginWebCmd, orgLoginWebDevHubCmd, @@ -485,11 +485,11 @@ function registerInternalDevCommands( } function registerOrgPickerCommands(orgListParam: OrgList): vscode.Disposable { - const forceSetDefaultOrgCmd = vscode.commands.registerCommand( - 'sfdx.force.set.default.org', + const setDefaultOrgCmd = vscode.commands.registerCommand( + 'sfdx.set.default.org', () => orgListParam.setDefaultOrg() ); - return vscode.Disposable.from(forceSetDefaultOrgCmd); + return vscode.Disposable.from(setDefaultOrgCmd); } async function setupOrgBrowser( diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts index 47dd0461c2..7c579904f3 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ja.ts @@ -142,7 +142,7 @@ export const messages = { warning_prompt_other_existing: '%s つの既存コンポーネント', warning_prompt_other_not_shown: '...表示されていない残り %s つのコンポーネント\n', - force_config_list_text: 'SFDX: すべての設定変数を一覧表示', + config_list_text: 'SFDX: すべての設定変数を一覧表示', alias_list_text: 'SFDX: すべてのエイリアスを一覧表示', org_display_default_text: 'SFDX: デフォルトの組織の詳細を表示', org_display_username_text: 'SFDX: 組織の詳細を表示...', @@ -245,7 +245,7 @@ export const messages = { 'ソースをデプロイまたは取得中にエラー: デプロイまたは取得しようとしたファイルかディレクトリが sfdx-project.json ファイルで指定されたパッケージディレクトリにありません。この場所を "packageDirectories" の値に追加するか、異なるファイルやディレクトリをデプロイまたは取得してください。sfdx-project.json についての詳細は https://developer.salesforce.com/docs/atlas.ja-jp.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm を参照してください。', org_select_text: 'デフォルトに設定する組織を選択', missing_default_org: 'デフォルトの組織が未設定', - force_config_set_org_text: 'SFDX: デフォルトの組織を設定', + config_set_org_text: 'SFDX: デフォルトの組織を設定', error_parsing_sfdx_project_file: 'sfdx-project.json ファイル (%s) をパースできませんでした。パースエラー: %s', sfdx_cli_not_found: diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ts index 509e631a00..a034ae1eec 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ts @@ -177,7 +177,7 @@ export const messages = { warning_prompt_skip_all: 'Skip All', warning_prompt_other_existing: '%s other existing components', warning_prompt_other_not_shown: '...%s other components not shown\n', - force_config_list_text: 'SFDX: List All Config Variables', + config_list_text: 'SFDX: List All Config Variables', alias_list_text: 'SFDX: List All Aliases', force_org_delete_default_text: 'SFDX: Delete Default Org', force_org_delete_username_text: 'SFDX: Delete Org...', @@ -283,8 +283,8 @@ export const messages = { org_select_text: 'Select an org to set as default', org_expired: 'Expired', missing_default_org: 'No Default Org Set', - force_config_set_org_text: 'SFDX: Set a Default Org', - force_config_set_title: 'Set Config', + config_set_org_text: 'SFDX: Set a Default Org', + config_set_title: 'Set Config', table_header_name: 'Name', table_header_value: 'Value', table_header_success: 'Success', diff --git a/packages/salesforcedx-vscode-core/src/orgPicker/orgList.ts b/packages/salesforcedx-vscode-core/src/orgPicker/orgList.ts index d8a34b46e8..474987f14e 100644 --- a/packages/salesforcedx-vscode-core/src/orgPicker/orgList.ts +++ b/packages/salesforcedx-vscode-core/src/orgPicker/orgList.ts @@ -24,7 +24,7 @@ export class OrgList implements vscode.Disposable { vscode.StatusBarAlignment.Left, 49 ); - this.statusBarItem.command = 'sfdx.force.set.default.org'; + this.statusBarItem.command = 'sfdx.set.default.org'; this.statusBarItem.tooltip = nls.localize('status_bar_org_picker_tooltip'); this.statusBarItem.show(); @@ -149,24 +149,21 @@ export class OrgList implements vscode.Disposable { } case '$(plus) ' + nls.localize('force_org_create_default_scratch_org_text'): { - vscode.commands.executeCommand('sfdx.force.org.create'); - return { type: 'CONTINUE', data: {} }; - } + vscode.commands.executeCommand('sfdx.force.org.create'); + return { type: 'CONTINUE', data: {} }; + } case '$(plus) ' + nls.localize('force_auth_access_token_authorize_org_text'): { - vscode.commands.executeCommand('sfdx.force.auth.accessToken'); - return { type: 'CONTINUE', data: {} }; - } + vscode.commands.executeCommand('sfdx.force.auth.accessToken'); + return { type: 'CONTINUE', data: {} }; + } case '$(plus) ' + nls.localize('org_list_clean_text'): { vscode.commands.executeCommand('sfdx.org.list.clean'); return { type: 'CONTINUE', data: {} }; } default: { const usernameOrAlias = selection.split(' - ', 1); - vscode.commands.executeCommand( - 'sfdx.force.config.set', - usernameOrAlias - ); + vscode.commands.executeCommand('sfdx.config.set', usernameOrAlias); return { type: 'CONTINUE', data: {} }; } } diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceConfigList.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/configList.test.ts similarity index 66% rename from packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceConfigList.test.ts rename to packages/salesforcedx-vscode-core/test/vscode-integration/commands/configList.test.ts index 9b18490ac3..497a702397 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceConfigList.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/configList.test.ts @@ -6,17 +6,17 @@ */ import { expect } from 'chai'; -import { ForceConfigList } from '../../../src/commands'; +import { ConfigList } from '../../../src/commands'; import { nls } from '../../../src/messages'; // tslint:disable:no-unused-expression -describe('Force Config List', () => { +describe('Config List', () => { it('Should build the config list command', async () => { - const configList = new ForceConfigList(); + const configList = new ConfigList(); const configListCommand = configList.build({}); - expect(configListCommand.toCommand()).to.equal('sfdx force:config:list'); + expect(configListCommand.toCommand()).to.equal('sfdx config:list'); expect(configListCommand.description).to.equal( - nls.localize('force_config_list_text') + nls.localize('config_list_text') ); }); }); diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceConfigSet.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/configSet.test.ts similarity index 70% rename from packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceConfigSet.test.ts rename to packages/salesforcedx-vscode-core/test/vscode-integration/commands/configSet.test.ts index 7fe9ddfe1b..33ff874b8a 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/forceConfigSet.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/configSet.test.ts @@ -9,7 +9,7 @@ import { ConfigUtil, Table } from '@salesforce/salesforcedx-utils-vscode'; import { expect } from 'chai'; import * as sinon from 'sinon'; import { channelService } from '../../../src/channels'; -import { forceConfigSet, ForceConfigSetExecutor } from '../../../src/commands'; +import { configSet, ConfigSetExecutor } from '../../../src/commands'; import { CONFIG_SET_NAME, TARGET_ORG_KEY } from '../../../src/constants'; import { nls } from '../../../src/messages'; @@ -18,13 +18,16 @@ let channelSpy: sinon.SinonSpy; let setDefaultUsernameOrAliasStub: sinon.SinonStub; let tableSpy: sinon.SinonSpy; -describe('Force Config Set', () => { +describe('Config Set', () => { const errorMessage = 'An error occurred.'; const usernameOrAlias = 'test-username1@gmail.com'; beforeEach(() => { channelSpy = sandbox.spy(channelService, 'appendLine'); - setDefaultUsernameOrAliasStub = sandbox.stub(ConfigUtil, 'setDefaultUsernameOrAlias'); + setDefaultUsernameOrAliasStub = sandbox.stub( + ConfigUtil, + 'setDefaultUsernameOrAlias' + ); tableSpy = sandbox.spy(Table.prototype, 'createTable'); }); @@ -33,39 +36,54 @@ describe('Force Config Set', () => { }); it('should set config with the given username or alias', async () => { - await forceConfigSet(usernameOrAlias); + await configSet(usernameOrAlias); expect(setDefaultUsernameOrAliasStub.callCount).to.equal(1); - expect(setDefaultUsernameOrAliasStub.calledWith(usernameOrAlias)).to.equal(true); + expect(setDefaultUsernameOrAliasStub.calledWith(usernameOrAlias)).to.equal( + true + ); }); it('should set config with first alias', async () => { const aliases = ['alias1', 'alias2']; const expectedAlias = aliases[0]; - await forceConfigSet(aliases.join(',')); + await configSet(aliases.join(',')); expect(setDefaultUsernameOrAliasStub.callCount).to.equal(1); - expect(setDefaultUsernameOrAliasStub.calledWith(expectedAlias)).to.equal(true); + expect(setDefaultUsernameOrAliasStub.calledWith(expectedAlias)).to.equal( + true + ); }); it('should display formatted output in output channel', async () => { const expectedOutput = 'Successful table row'; - sandbox.stub(ForceConfigSetExecutor.prototype as any, 'formatOutput').returns(expectedOutput); - await forceConfigSet(usernameOrAlias); + sandbox + .stub(ConfigSetExecutor.prototype as any, 'formatOutput') + .returns(expectedOutput); + await configSet(usernameOrAlias); expect(channelSpy.callCount).to.equal(1); expect(channelSpy.calledWith(expectedOutput)).to.equal(true); }); it('should display correct output to user', async () => { - const outputTableRow = { name: TARGET_ORG_KEY, val: usernameOrAlias, success: String(true) }; - const forceConfigSetInstance = new ForceConfigSetExecutor(usernameOrAlias); - const formatOutput = (forceConfigSetInstance as any).formatOutput(outputTableRow); + const outputTableRow = { + name: TARGET_ORG_KEY, + val: usernameOrAlias, + success: String(true) + }; + const configSetInstance = new ConfigSetExecutor(usernameOrAlias); + const formatOutput = (configSetInstance as any).formatOutput( + outputTableRow + ); expect(tableSpy.callCount).to.equal(1); - expect(formatOutput).to.contain(nls.localize(CONFIG_SET_NAME), TARGET_ORG_KEY); + expect(formatOutput).to.contain( + nls.localize(CONFIG_SET_NAME), + TARGET_ORG_KEY + ); expect(formatOutput).to.contain(usernameOrAlias, String(true)); }); it('should display error message in output channel', async () => { setDefaultUsernameOrAliasStub.throws(new Error(errorMessage)); - await forceConfigSet(usernameOrAlias); + await configSet(usernameOrAlias); expect(channelSpy.callCount).to.equal(2); expect(channelSpy.lastCall.args.length).to.equal(1); expect(channelSpy.lastCall.args[0]).to.contain(errorMessage); diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/orgPicker/orgList.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/orgPicker/orgList.test.ts index 2d8139896e..72772b2230 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/orgPicker/orgList.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/orgPicker/orgList.test.ts @@ -393,9 +393,7 @@ describe('orgList Tests', () => { quickPickStub.returns('$(plus)' + orgsList[0].split(' ', 1)); const response = await orgList.setDefaultOrg(); expect(response.type).to.equal('CONTINUE'); - expect(executeCommandStub.calledWith('sfdx.force.config.set')).to.equal( - true - ); + expect(executeCommandStub.calledWith('sfdx.config.set')).to.equal(true); }); }); }); From 22a1131c058113b16165171d5e5bf5405154d93b Mon Sep 17 00:00:00 2001 From: peternhale Date: Tue, 19 Dec 2023 12:25:08 -0700 Subject: [PATCH 3/4] chore: apex debugger arrow functions (#5285) @W-14564471@ refactor apex debugger function defs to arrow functions --- .../salesforcedx-apex-debugger/fix-these-rules.json | 1 + .../salesforcedx-apex-debugger/src/messages/index.ts | 8 ++++---- .../test/integration/adapter.test.ts | 6 +++--- .../unit/adapter/apexDebugVariablesHandling.test.ts | 6 +++--- .../test/unit/commands/baseDebuggerCommand.test.ts | 10 ++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/salesforcedx-apex-debugger/fix-these-rules.json b/packages/salesforcedx-apex-debugger/fix-these-rules.json index 093b55a118..3077701020 100644 --- a/packages/salesforcedx-apex-debugger/fix-these-rules.json +++ b/packages/salesforcedx-apex-debugger/fix-these-rules.json @@ -1,5 +1,6 @@ { "rules": { + "prefer-arrow/prefer-arrow-functions": ["error", {}], "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/no-unsafe-argument": "warn", "@typescript-eslint/no-unsafe-assignment": "warn", diff --git a/packages/salesforcedx-apex-debugger/src/messages/index.ts b/packages/salesforcedx-apex-debugger/src/messages/index.ts index b78dd6e99a..bac4e0ea7d 100644 --- a/packages/salesforcedx-apex-debugger/src/messages/index.ts +++ b/packages/salesforcedx-apex-debugger/src/messages/index.ts @@ -16,13 +16,13 @@ import { import { messages } from './i18n'; import { messages as jaMessages } from './i18n.ja'; -function loadMessageBundle(config?: Config): Message { +const loadMessageBundle = (config?: Config): Message => { // eslint-disable-next-line @typescript-eslint/no-unused-vars - function resolveFileName(locale: string): string { + const resolveFileName = (locale: string): string => { return locale === DEFAULT_LOCALE ? `${BASE_FILE_NAME}.${BASE_FILE_EXTENSION}` : `${BASE_FILE_NAME}.${locale}.${BASE_FILE_EXTENSION}`; - } + }; const base = new Message(messages); @@ -36,7 +36,7 @@ function loadMessageBundle(config?: Config): Message { } return base; -} +}; export const nls = new Localization( loadMessageBundle( diff --git a/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts b/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts index f84a27fa8f..602d21551e 100644 --- a/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts +++ b/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts @@ -196,10 +196,10 @@ describe.skip('Interactive debugger adapter - integration', () => { }); }); -function execApexNoWait( +const execApexNoWait = ( apexExecFilePath: string, userName: string -): CommandExecution { +): CommandExecution => { return new CliCommandExecutor( new SfdxCommandBuilder() .withArg('force:apex:execute') @@ -209,4 +209,4 @@ function execApexNoWait( .build(), { cwd: process.cwd() } ).execute(); -} +}; diff --git a/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts b/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts index 14f38f2698..b142fd3d33 100644 --- a/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts +++ b/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts @@ -975,11 +975,11 @@ describe('Debugger adapter variable handling - unit', () => { }); }); -export function newStringValue( +export const newStringValue = ( name: string, value = 'value', slot?: number -): Value { +): Value => { const result: any = { name, declaredTypeRef: 'java/lang/String', @@ -990,7 +990,7 @@ export function newStringValue( result.slot = slot; } return result; -} +}; export class DummyContainer implements VariableContainer { public variables: ApexVariable[]; diff --git a/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts b/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts index 5bec0ded97..5e15c93483 100644 --- a/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts +++ b/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts @@ -27,7 +27,7 @@ class DummyCommand extends BaseDebuggerCommand { } } -export function getDefaultHeaders(contentLength: number): any { +export const getDefaultHeaders = (contentLength: number): any => { return { 'Content-Type': 'application/json;charset=utf-8', Accept: 'application/json', @@ -35,7 +35,7 @@ export function getDefaultHeaders(contentLength: number): any { 'Content-Length': String(contentLength), 'Sforce-Call-Options': `client=${CLIENT_ID}` }; -} +}; describe('Base command', () => { let sendRequestSpy: sinon.SinonStub; @@ -85,8 +85,7 @@ describe('Base command', () => { ); const expectedOptions: XHROptions = { type: 'POST', - url: - 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', + url: 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', timeout: DEFAULT_CONNECTION_TIMEOUT_MS, headers: getDefaultHeaders(0), data: undefined @@ -119,8 +118,7 @@ describe('Base command', () => { const requestBody = JSON.stringify(myRequest); const expectedOptions: XHROptions = { type: 'POST', - url: - 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', + url: 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', timeout: DEFAULT_CONNECTION_TIMEOUT_MS, headers: getDefaultHeaders(Buffer.byteLength(requestBody, 'utf-8')), data: requestBody From 45c87a78b52e7bebf831d0143b45e479235ce390 Mon Sep 17 00:00:00 2001 From: Daphne Yang <139700604+daphne-sfdc@users.noreply.github.com> Date: Tue, 19 Dec 2023 22:09:51 -0500 Subject: [PATCH 4/4] chore: update publishing.md with the automated changelog generation process (#5286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update publishing.md with the automated changelog generation process * chore: add word * Update contributing/publishing.md Co-authored-by: Cristina Cañizales <113132642+CristiCanizales@users.noreply.github.com> --------- Co-authored-by: Cristina Cañizales <113132642+CristiCanizales@users.noreply.github.com> --- contributing/publishing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/publishing.md b/contributing/publishing.md index 034d11676b..429a7669b7 100644 --- a/contributing/publishing.md +++ b/contributing/publishing.md @@ -28,7 +28,7 @@ If any code changes are made between the time the release branch is automaticall ## Updating the Change Log -After the release branch is created, the changelog needs to be updated. To do so, the engineer should go into VSCode, pull the latest changes, and switch to the release branch. Then, they should open a Terminal window and run `npm run changelog` to generate the changelog entry for the upcoming release. This task will gather commits that should be published (like `feat` or `fix`) and write the update to `CHANGELOG.md`. If there are no commits worth publishing (for instance, if everything was a `chore` or a `ci` commit), then the changelog entry for the upcoming release can be skipped. If a changelog is necessary, the engineer will then push the changelog to the release branch with the commit name of `chore: generated CHANGELOG for vXX.YY.ZZ`, where XX.YY.ZZ are the numbers of the current release. +The changelog will be automatically generated as part of the Create Release Branch workflow. This task will gather commits that should be published (like `feat` or `fix`) and write the update to `CHANGELOG.md`. If there are no commits worth publishing (for instance, if everything was a `chore` or a `ci` commit), then the changelog entry for the upcoming release can be skipped. The workflow will then push the changelog to the release branch with the commit name of `chore: generated CHANGELOG for vXX.YY.ZZ`, where XX.YY.ZZ are the numbers of the current release. The engineer should work with the team and doc writer to update and finalize the contents of the changelog. During the update process, if the writer wants to make further changes to changelog through the browser, they can do that by switching the branch from develop to release/vXX.YY.ZZ and go to `CHANGELOG.md` and clicking on the pencil icon to edit the file.