From 75aabd24d968f80787f074cd4c2dbf45765f0657 Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 22 Mar 2019 09:42:57 -0700 Subject: [PATCH 1/9] new output directory selection --- .../src/commands/commands.ts | 54 +++++++++++++++++++ .../src/commands/forceApexClassCreate.ts | 7 +-- .../src/commands/forceApexTriggerCreate.ts | 13 ++--- .../src/commands/forceLightningAppCreate.ts | 10 ++-- .../commands/forceLightningComponentCreate.ts | 10 ++-- .../src/commands/forceLightningEventCreate.ts | 10 ++-- .../commands/forceLightningInterfaceCreate.ts | 10 ++-- .../src/messages/i18n.ts | 3 +- .../src/sfdxProject/sfdxPackageDirectories.ts | 10 +++- 9 files changed, 82 insertions(+), 45 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index 1847564254..8d0d8ed6f0 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -25,10 +25,13 @@ import { channelService } from '../channels'; import { nls } from '../messages'; import { notificationService, ProgressNotification } from '../notifications'; import { isSfdxProjectOpened } from '../predicates'; +import { SfdxPackageDirectories } from '../sfdxProject'; import { taskViewService } from '../statuses'; import { telemetryService } from '../telemetry'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; +const DEFAULT_SOURCE_PATH = '/main/default'; + export class LightningFilePathExistsChecker implements PostconditionChecker { public async check( @@ -216,6 +219,57 @@ export class SelectFileName } } +export class DirSelector implements ParametersGatherer<{ outputdir: string }> { + private typeDir: string; + private typeDirRequired: boolean | undefined; + private readonly customDirOption = `$(file-directory) ${nls.localize( + 'custom_output_directory' + )}`; + + public constructor(typeDir: string, typeDirRequired?: boolean) { + this.typeDir = typeDir; + this.typeDirRequired = typeDirRequired; + } + + public async gather(): Promise< + CancelResponse | ContinueResponse<{ outputdir: string }> + > { + const packageDirs = await SfdxPackageDirectories.getPackageDirectoryPaths(); + const options = packageDirs.map(packageDir => + path.join(packageDir, DEFAULT_SOURCE_PATH, this.typeDir) + ); + options.push(this.customDirOption); + + let outputdir = await vscode.window.showQuickPick(options, { + placeHolder: nls.localize('parameter_gatherer_enter_dir_name') + } as vscode.QuickPickOptions); + if (outputdir === this.customDirOption) { + outputdir = await this.selectCustomPath(); + } + + return outputdir + ? { type: 'CONTINUE', data: { outputdir } } + : { type: 'CANCEL' }; + } + + private async selectCustomPath(): Promise { + const rootPath = getRootWorkspacePath(); + const relPaths = new glob.GlobSync(path.join(rootPath, '**/')).found.map( + value => { + let relativePath = path.relative(rootPath, path.join(value, '/')); + relativePath = path.join( + relativePath, + this.typeDirRequired ? this.typeDir : '' + ); + return relativePath; + } + ); + return await vscode.window.showQuickPick(relPaths, { + placeHolder: nls.localize('parameter_gatherer_enter_dir_name') + } as vscode.QuickPickOptions); + } +} + export abstract class SelectDirPath implements ParametersGatherer<{ outputdir: string }> { private explorerDir: string | undefined; diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts index 52fd01b471..009e70c53f 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts @@ -23,9 +23,9 @@ import { notificationService, ProgressNotification } from '../notifications'; import { taskViewService } from '../statuses'; import { CompositeParametersGatherer, + DirSelector, FilePathExistsChecker, SelectFileName, - SelectPrioritizedDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -90,10 +90,7 @@ const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(APEX_FILE_EXTENSION); export async function forceApexClassCreate(explorerDir?: any) { - const outputDirGatherer = new SelectPrioritizedDirPath( - explorerDir, - 'classes' - ); + const outputDirGatherer = new DirSelector('classes'); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts index 8c087fd917..546d8b82b0 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, + DirSelector, FilePathExistsChecker, SelectFileName, - SelectPrioritizedDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -58,11 +58,7 @@ export class ForceApexTriggerCreateExecutor extends SfdxCommandletExecutor< execution.processExitSubject.subscribe(async data => { this.logMetric(execution.command.logName, startTime); - if ( - data !== undefined && - data.toString() === '0' && - hasRootWorkspace() - ) { + if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( path.join( @@ -90,10 +86,7 @@ const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(APEX_TRIGGER_EXTENSION); export async function forceApexTriggerCreate(explorerDir?: any) { - const outputDirGatherer = new SelectPrioritizedDirPath( - explorerDir, - 'triggers' - ); + const outputDirGatherer = new DirSelector('triggers'); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts index b41e562951..ddbe44ff0a 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, + DirSelector, LightningFilePathExistsChecker, SelectFileName, - SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -58,11 +58,7 @@ class ForceLightningAppCreateExecutor extends SfdxCommandletExecutor< execution.processExitSubject.subscribe(async data => { this.logMetric(execution.command.logName, startTime); - if ( - data !== undefined && - data.toString() === '0' && - hasRootWorkspace() - ) { + if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( path.join( @@ -92,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningAppCreate(explorerDir?: any) { - const outputDirGatherer = new SelectStrictDirPath(explorerDir, 'aura'); + const outputDirGatherer = new DirSelector('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts index 2d6df34ab5..dac68b5efa 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, + DirSelector, LightningFilePathExistsChecker, SelectFileName, - SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -58,11 +58,7 @@ class ForceLightningComponentCreateExecutor extends SfdxCommandletExecutor< execution.processExitSubject.subscribe(async data => { this.logMetric(execution.command.logName, startTime); - if ( - data !== undefined && - data.toString() === '0' && - hasRootWorkspace() - ) { + if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( path.join( @@ -92,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningComponentCreate(explorerDir?: any) { - const outputDirGatherer = new SelectStrictDirPath(explorerDir, 'aura'); + const outputDirGatherer = new DirSelector('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts index 90692c59be..7789dbfcd1 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, + DirSelector, LightningFilePathExistsChecker, SelectFileName, - SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -58,11 +58,7 @@ class ForceLightningEventCreateExecutor extends SfdxCommandletExecutor< execution.processExitSubject.subscribe(async data => { this.logMetric(execution.command.logName, startTime); - if ( - data !== undefined && - data.toString() === '0' && - hasRootWorkspace() - ) { + if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( path.join( @@ -92,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningEventCreate(explorerDir?: any) { - const outputDirGatherer = new SelectStrictDirPath(explorerDir, 'aura'); + const outputDirGatherer = new DirSelector('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts index 6e6f5d99f1..ae427ba0a0 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, + DirSelector, LightningFilePathExistsChecker, SelectFileName, - SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -58,11 +58,7 @@ class ForceLightningInterfaceCreateExecutor extends SfdxCommandletExecutor< execution.processExitSubject.subscribe(async data => { this.logMetric(execution.command.logName, startTime); - if ( - data !== undefined && - data.toString() === '0' && - hasRootWorkspace() - ) { + if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( path.join( @@ -92,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningInterfaceCreate(explorerDir?: any) { - const outputDirGatherer = new SelectStrictDirPath(explorerDir, 'aura'); + const outputDirGatherer = new DirSelector('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ts index 37af4b4de8..25dcccf17d 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ts @@ -235,5 +235,6 @@ export const messages = { error_no_default_username: 'No default org is set. Run "SFDX: Create a Default Scratch Org" or "SFDX: Authorize an Org" to set one.', error_no_default_devhubusername: - 'No default Dev Hub is set. Run "SFDX: Authorize a Dev Hub" to set one.' + 'No default Dev Hub is set. Run "SFDX: Authorize a Dev Hub" to set one.', + custom_output_directory: 'Select a Custom Directory' }; diff --git a/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts b/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts index ec5bd4d94c..e43ad2e731 100644 --- a/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts +++ b/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts @@ -18,6 +18,7 @@ export default class SfdxPackageDirectories { )) as JsonArray; if (packageDirectories) { const packageDirectoryPaths: string[] = []; + let defaultPath; packageDirectories.forEach(packageDir => { if (packageDir) { const packageDirectory = packageDir as JsonMap; @@ -27,10 +28,17 @@ export default class SfdxPackageDirectories { if (dirPath.startsWith(path.sep)) { dirPath = dirPath.substring(1); } - packageDirectoryPaths.push(dirPath); + if (packageDirectory.default) { + defaultPath = dirPath; + } else { + packageDirectoryPaths.push(dirPath); + } } } }); + if (defaultPath) { + packageDirectoryPaths.unshift(defaultPath); + } if (packageDirectoryPaths.length === 0) { const error = new Error(); error.name = 'NoPackageDirectoryPathsFound'; From 16baade47750c24a663596f51c04585498477f5a Mon Sep 17 00:00:00 2001 From: brpowell Date: Fri, 22 Mar 2019 16:01:43 -0700 Subject: [PATCH 2/9] update commands to use new selector --- .../src/commands/commands.ts | 96 ++----------------- .../src/commands/forceApexClassCreate.ts | 4 +- .../src/commands/forceApexTriggerCreate.ts | 4 +- .../src/commands/forceLightningAppCreate.ts | 4 +- .../commands/forceLightningComponentCreate.ts | 4 +- .../src/commands/forceLightningEventCreate.ts | 4 +- .../commands/forceLightningInterfaceCreate.ts | 4 +- .../forceVisualforceComponentCreate.ts | 13 +-- .../commands/forceVisualforcePageCreate.ts | 4 +- .../src/commands/index.ts | 1 + .../salesforcedx-vscode-core/src/index.ts | 2 + .../src/commands/forceLightningLwcCreate.ts | 8 +- 12 files changed, 32 insertions(+), 116 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index 8d0d8ed6f0..76fba7d346 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -30,8 +30,6 @@ import { taskViewService } from '../statuses'; import { telemetryService } from '../telemetry'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; -const DEFAULT_SOURCE_PATH = '/main/default'; - export class LightningFilePathExistsChecker implements PostconditionChecker { public async check( @@ -219,9 +217,11 @@ export class SelectFileName } } -export class DirSelector implements ParametersGatherer<{ outputdir: string }> { +export class SelectOutputDir + implements ParametersGatherer<{ outputdir: string }> { private typeDir: string; private typeDirRequired: boolean | undefined; + private readonly defaultOutput = '/main/default'; private readonly customDirOption = `$(file-directory) ${nls.localize( 'custom_output_directory' )}`; @@ -236,7 +236,7 @@ export class DirSelector implements ParametersGatherer<{ outputdir: string }> { > { const packageDirs = await SfdxPackageDirectories.getPackageDirectoryPaths(); const options = packageDirs.map(packageDir => - path.join(packageDir, DEFAULT_SOURCE_PATH, this.typeDir) + path.join(packageDir, this.defaultOutput, this.typeDir) ); options.push(this.customDirOption); @@ -252,14 +252,16 @@ export class DirSelector implements ParametersGatherer<{ outputdir: string }> { : { type: 'CANCEL' }; } - private async selectCustomPath(): Promise { + public async selectCustomPath(): Promise { const rootPath = getRootWorkspacePath(); const relPaths = new glob.GlobSync(path.join(rootPath, '**/')).found.map( value => { let relativePath = path.relative(rootPath, path.join(value, '/')); relativePath = path.join( relativePath, - this.typeDirRequired ? this.typeDir : '' + this.typeDirRequired && !relativePath.endsWith(this.typeDir) + ? this.typeDir + : '' ); return relativePath; } @@ -270,88 +272,6 @@ export class DirSelector implements ParametersGatherer<{ outputdir: string }> { } } -export abstract class SelectDirPath - implements ParametersGatherer<{ outputdir: string }> { - private explorerDir: string | undefined; - private globKeyWord: string | undefined; - - public constructor(explorerDir?: vscode.Uri, globKeyWord?: string) { - this.explorerDir = explorerDir ? explorerDir.fsPath : explorerDir; - this.globKeyWord = globKeyWord; - } - - public abstract globDirs(srcPath: string, priorityKeyword?: string): string[]; - - public async gather(): Promise< - CancelResponse | ContinueResponse<{ outputdir: string }> - > { - const rootPath = getRootWorkspacePath(); - let outputdir; - if (rootPath) { - if ( - !this.explorerDir && - this.globDirs(rootPath, this.globKeyWord).length === 0 - ) { - notificationService.showErrorMessage( - nls.localize( - 'parameter_directory_strict_not_available', - this.globKeyWord - ) - ); - return { type: 'CANCEL' }; - } - outputdir = this.explorerDir - ? path.relative(rootPath, this.explorerDir) - : await vscode.window.showQuickPick( - this.globDirs(rootPath, this.globKeyWord), - { - placeHolder: nls.localize('parameter_gatherer_enter_dir_name') - } as vscode.QuickPickOptions - ); - } - return outputdir - ? { type: 'CONTINUE', data: { outputdir } } - : { type: 'CANCEL' }; - } -} -export class SelectPrioritizedDirPath extends SelectDirPath { - public globDirs(srcPath: string, priorityKeyword?: string): string[] { - const unprioritizedRelDirs = new glob.GlobSync( - path.join(srcPath, '**/') - ).found.map(value => { - let relativePath = path.relative(srcPath, path.join(value, '/')); - relativePath = path.join(relativePath, ''); - return relativePath; - }); - if (priorityKeyword) { - const notPrioritized: string[] = []; - const prioritized = unprioritizedRelDirs.filter(dir => { - if (dir.includes(priorityKeyword)) { - return true; - } else { - notPrioritized.push(dir); - } - }); - return prioritized.concat(notPrioritized); - } - return unprioritizedRelDirs; - } -} - -export class SelectStrictDirPath extends SelectDirPath { - public globDirs(srcPath: string, priorityKeyword?: string): string[] { - const globPattern = priorityKeyword - ? path.join(srcPath, '**/', priorityKeyword + '/') - : path.join(srcPath, '**/'); - const relativeDirs = new glob.GlobSync(globPattern).found.map(value => { - let relativePath = path.relative(srcPath, path.join(value, '/')); - relativePath = path.join(relativePath, ''); - return relativePath; - }); - return relativeDirs; - } -} - export interface FlagParameter { flag: T; } diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts index 009e70c53f..63064e8f8f 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts @@ -23,9 +23,9 @@ import { notificationService, ProgressNotification } from '../notifications'; import { taskViewService } from '../statuses'; import { CompositeParametersGatherer, - DirSelector, FilePathExistsChecker, SelectFileName, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -90,7 +90,7 @@ const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(APEX_FILE_EXTENSION); export async function forceApexClassCreate(explorerDir?: any) { - const outputDirGatherer = new DirSelector('classes'); + const outputDirGatherer = new SelectOutputDir('classes'); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts index 546d8b82b0..cc765fe159 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, - DirSelector, FilePathExistsChecker, SelectFileName, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -86,7 +86,7 @@ const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(APEX_TRIGGER_EXTENSION); export async function forceApexTriggerCreate(explorerDir?: any) { - const outputDirGatherer = new DirSelector('triggers'); + const outputDirGatherer = new SelectOutputDir('triggers'); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts index ddbe44ff0a..2ce2f6638f 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, - DirSelector, LightningFilePathExistsChecker, SelectFileName, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -88,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningAppCreate(explorerDir?: any) { - const outputDirGatherer = new DirSelector('aura', true); + const outputDirGatherer = new SelectOutputDir('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts index dac68b5efa..4138c0c9c2 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, - DirSelector, LightningFilePathExistsChecker, SelectFileName, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -88,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningComponentCreate(explorerDir?: any) { - const outputDirGatherer = new DirSelector('aura', true); + const outputDirGatherer = new SelectOutputDir('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts index 7789dbfcd1..1f9a9c4c06 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, - DirSelector, LightningFilePathExistsChecker, SelectFileName, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -88,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningEventCreate(explorerDir?: any) { - const outputDirGatherer = new DirSelector('aura', true); + const outputDirGatherer = new SelectOutputDir('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts index ae427ba0a0..fb686eac31 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts @@ -24,9 +24,9 @@ import { taskViewService } from '../statuses'; import { getRootWorkspacePath, hasRootWorkspace } from '../util'; import { CompositeParametersGatherer, - DirSelector, LightningFilePathExistsChecker, SelectFileName, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -88,7 +88,7 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningInterfaceCreate(explorerDir?: any) { - const outputDirGatherer = new DirSelector('aura', true); + const outputDirGatherer = new SelectOutputDir('aura', true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts index e7ff25f9a9..68ace78f40 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts @@ -26,7 +26,7 @@ import { CompositeParametersGatherer, FilePathExistsChecker, SelectFileName, - SelectPrioritizedDirPath, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -59,11 +59,7 @@ class ForceVisualForceComponentCreateExecutor extends SfdxCommandletExecutor< execution.processExitSubject.subscribe(async data => { this.logMetric(execution.command.logName, startTime); - if ( - data !== undefined && - data.toString() === '0' && - hasRootWorkspace() - ) { + if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( path.join( @@ -91,10 +87,7 @@ const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(VF_CMP_EXTENSION); export async function forceVisualforceComponentCreate(explorerDir?: any) { - const outputDirGatherer = new SelectPrioritizedDirPath( - explorerDir, - 'components' - ); + const outputDirGatherer = new SelectOutputDir('components'); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts index 2415d5ee11..df2d8c8eb2 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts @@ -25,7 +25,7 @@ import { CompositeParametersGatherer, FilePathExistsChecker, SelectFileName, - SelectPrioritizedDirPath, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker @@ -91,7 +91,7 @@ const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(VF_PAGE_EXTENSION); export async function forceVisualforcePageCreate(explorerDir?: any) { - const outputDirGatherer = new SelectPrioritizedDirPath(explorerDir, 'pages'); + const outputDirGatherer = new SelectOutputDir('pages'); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/index.ts b/packages/salesforcedx-vscode-core/src/commands/index.ts index 255fe69fb1..a2d641b84f 100644 --- a/packages/salesforcedx-vscode-core/src/commands/index.ts +++ b/packages/salesforcedx-vscode-core/src/commands/index.ts @@ -10,6 +10,7 @@ export { EmptyParametersGatherer, SelectFileName, SelectStrictDirPath, + SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index 3ae77acf1c..f9c5b6e282 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -48,6 +48,7 @@ import { forceVisualforceComponentCreate, forceVisualforcePageCreate, SelectFileName, + SelectOutputDir, SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, @@ -437,6 +438,7 @@ export async function activate(context: vscode.ExtensionContext) { CompositeParametersGatherer, EmptyParametersGatherer, SelectFileName, + SelectOutputDir, SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, diff --git a/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts b/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts index 2307e53094..1ff348de33 100644 --- a/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts +++ b/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts @@ -27,7 +27,7 @@ const sfdxCoreExports = vscode.extensions.getExtension( const ProgressNotification = sfdxCoreExports.ProgressNotification; const CompositeParametersGatherer = sfdxCoreExports.CompositeParametersGatherer; const SelectFileName = sfdxCoreExports.SelectFileName; -const SelectStrictDirPath = sfdxCoreExports.SelectStrictDirPath; +const SelectOutputDir = sfdxCoreExports.SelectOutputDir; const SfdxCommandlet = sfdxCoreExports.SfdxCommandlet; const SfdxCommandletExecutor = sfdxCoreExports.SfdxCommandletExecutor; const SfdxWorkspaceChecker = sfdxCoreExports.SfdxWorkspaceChecker; @@ -128,10 +128,10 @@ const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); export async function forceLightningLwcCreate(explorerDir?: any) { - const outputDirGatherer = new SelectStrictDirPath(explorerDir, 'lwc'); + const outputDirGatherer = new SelectOutputDir('lwc', true); const parameterGatherer = new CompositeParametersGatherer( - outputDirGatherer, - fileNameGatherer + fileNameGatherer, + outputDirGatherer ); const commandlet = new SfdxCommandlet( workspaceChecker, From 6c362cbbdd60e4a33503cc260209a9145077879c Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 22 Mar 2019 19:55:27 -0700 Subject: [PATCH 3/9] tests --- .../src/commands/commands.ts | 52 ++++----- .../src/commands/index.ts | 1 - .../salesforcedx-vscode-core/src/index.ts | 2 - .../commands/commands.test.ts | 102 ++++++++++-------- .../sfdxPackageDirectories.test.ts | 8 +- 5 files changed, 90 insertions(+), 75 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index 76fba7d346..f844f49708 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -221,8 +221,8 @@ export class SelectOutputDir implements ParametersGatherer<{ outputdir: string }> { private typeDir: string; private typeDirRequired: boolean | undefined; - private readonly defaultOutput = '/main/default'; - private readonly customDirOption = `$(file-directory) ${nls.localize( + public readonly defaultOutput = '/main/default'; + public readonly customDirOption = `$(file-directory) ${nls.localize( 'custom_output_directory' )}`; @@ -235,16 +235,12 @@ export class SelectOutputDir CancelResponse | ContinueResponse<{ outputdir: string }> > { const packageDirs = await SfdxPackageDirectories.getPackageDirectoryPaths(); - const options = packageDirs.map(packageDir => - path.join(packageDir, this.defaultOutput, this.typeDir) - ); - options.push(this.customDirOption); + let dirOptions = this.getDefaultOptions(packageDirs); + let outputdir = await this.showMenu(dirOptions); - let outputdir = await vscode.window.showQuickPick(options, { - placeHolder: nls.localize('parameter_gatherer_enter_dir_name') - } as vscode.QuickPickOptions); if (outputdir === this.customDirOption) { - outputdir = await this.selectCustomPath(); + dirOptions = this.getCustomOptions(getRootWorkspacePath()); + outputdir = await this.showMenu(dirOptions); } return outputdir @@ -252,21 +248,29 @@ export class SelectOutputDir : { type: 'CANCEL' }; } - public async selectCustomPath(): Promise { - const rootPath = getRootWorkspacePath(); - const relPaths = new glob.GlobSync(path.join(rootPath, '**/')).found.map( - value => { - let relativePath = path.relative(rootPath, path.join(value, '/')); - relativePath = path.join( - relativePath, - this.typeDirRequired && !relativePath.endsWith(this.typeDir) - ? this.typeDir - : '' - ); - return relativePath; - } + public getDefaultOptions(packageDirectories: string[]): string[] { + const options = packageDirectories.map(packageDir => + path.join(packageDir, this.defaultOutput, this.typeDir) ); - return await vscode.window.showQuickPick(relPaths, { + options.push(this.customDirOption); + return options; + } + + public getCustomOptions(rootPath: string): string[] { + return new glob.GlobSync(path.join(rootPath, '**/')).found.map(value => { + let relativePath = path.relative(rootPath, path.join(value, '/')); + relativePath = path.join( + relativePath, + this.typeDirRequired && !relativePath.endsWith(this.typeDir) + ? this.typeDir + : '' + ); + return relativePath; + }); + } + + public async showMenu(options: string[]): Promise { + return await vscode.window.showQuickPick(options, { placeHolder: nls.localize('parameter_gatherer_enter_dir_name') } as vscode.QuickPickOptions); } diff --git a/packages/salesforcedx-vscode-core/src/commands/index.ts b/packages/salesforcedx-vscode-core/src/commands/index.ts index a2d641b84f..fae4e2b0d0 100644 --- a/packages/salesforcedx-vscode-core/src/commands/index.ts +++ b/packages/salesforcedx-vscode-core/src/commands/index.ts @@ -9,7 +9,6 @@ export { CompositeParametersGatherer, EmptyParametersGatherer, SelectFileName, - SelectStrictDirPath, SelectOutputDir, SfdxCommandlet, SfdxCommandletExecutor, diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index f9c5b6e282..0b3656115e 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -49,7 +49,6 @@ import { forceVisualforcePageCreate, SelectFileName, SelectOutputDir, - SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, SfdxWorkspaceChecker, @@ -439,7 +438,6 @@ export async function activate(context: vscode.ExtensionContext) { EmptyParametersGatherer, SelectFileName, SelectOutputDir, - SelectStrictDirPath, SfdxCommandlet, SfdxCommandletExecutor, sfdxCoreSettings, diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts index 501f7ab8ee..2550296f09 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts @@ -23,12 +23,13 @@ import { EmptyPostChecker, FilePathExistsChecker, LightningFilePathExistsChecker, - SelectPrioritizedDirPath, - SelectStrictDirPath, + SelectOutputDir, SfdxCommandlet } from '../../../src/commands/commands'; import { nls } from '../../../src/messages'; import { notificationService } from '../../../src/notifications'; +import { SfdxPackageDirectories } from '../../../src/sfdxProject'; +import { getRootWorkspacePath } from '../../../src/util'; // tslint:disable:no-unused-expression describe('Command Utilities', () => { @@ -222,52 +223,65 @@ describe('Command Utilities', () => { }); }); - describe('Glob Directories', () => { - describe('SelectPrioritizedDirPath', () => { - it('Should glob and return correct number of directories', async () => { - const dirPathGatherer = new SelectPrioritizedDirPath(); - if (!vscode.workspace.rootPath) { - throw new Error('Test workspace should be opened'); - } - const dirList: string[] = dirPathGatherer.globDirs( - vscode.workspace.rootPath - ); - expect(dirList[0]).to.not.contain(WORKSPACE_NAME); - expect(dirList.length).to.equal(SFDX_SIMPLE_NUM_OF_DIRS); - }); + describe('SelectOutputDir', () => { + it('Should correctly build default menu options', async () => { + const selector = new SelectOutputDir('test'); + const options = selector.getDefaultOptions(['testapp', 'testapp2']); - it('Should return list of relative paths with paths containing keyword prioritized to the top of list', async () => { - const dirPathGatherer = new SelectPrioritizedDirPath(); - if (!vscode.workspace.rootPath) { - throw new Error('Test workspace should be opened'); - } - const dirList: string[] = dirPathGatherer.globDirs( - vscode.workspace.rootPath, - 'classes' - ); - expect(dirList[0]).to.equal( - path.join('force-app', 'main', 'default', 'classes') - ); - expect(dirList[1]).to.equal( - path.join('force-app', 'test', 'default', 'classes') - ); - }); + expect(options).to.eql([ + path.join('testapp', selector.defaultOutput, 'test'), + path.join('testapp2', selector.defaultOutput, 'test'), + selector.customDirOption + ]); }); - describe('SelectStrictDirPath', () => { - it('Should glob and return a list of dirs containing only the keyword', async () => { - const strictDirPathGatherer = new SelectStrictDirPath(); - if (!vscode.workspace.rootPath) { - throw new Error('Test workspace should be opened'); - } - const dirList: string[] = strictDirPathGatherer.globDirs( - vscode.workspace.rootPath, - 'aura' - ); - dirList.forEach(value => { - expect(value).to.contain('aura'); + it('Should generate correct number of custom options for a workspace', async () => { + const selector = new SelectOutputDir('test'); + const options = selector.getCustomOptions(getRootWorkspacePath()); + + expect(options.length).to.be.equal(SFDX_SIMPLE_NUM_OF_DIRS); + }); + + it('Should correctly append type folder to paths for type that requires specific parent folder', () => { + const selector = new SelectOutputDir('aura', true); + const options = selector.getCustomOptions(getRootWorkspacePath()); + + expect( + options.every(outputDir => { + // don't append the type name if a dir already has that as its name + return outputDir.endsWith('aura') && !outputDir.endsWith('aura/aura'); + }) + ).to.be.true; + }); + + it('Should gather paths from correct sources and prompt custom dir if chosen', async () => { + const selector = new SelectOutputDir('test'); + const defaultOptions = selector.getDefaultOptions(['test-app']); + const customOptions = selector.getCustomOptions(getRootWorkspacePath()); + const getPackageDirPathsStub = sinon.stub( + SfdxPackageDirectories, + 'getPackageDirectoryPaths' + ); + const showMenuStub = sinon.stub(selector, 'showMenu'); + + const choice = customOptions[5]; + getPackageDirPathsStub.returns(['test-app']); + showMenuStub.onFirstCall().returns(selector.customDirOption); + showMenuStub.onSecondCall().returns(choice); + + const response = await selector.gather(); + + try { + expect(showMenuStub.getCall(0).calledWith(defaultOptions)).to.be.true; + expect(showMenuStub.getCall(1).calledWith(customOptions)).to.be.true; + expect(response).to.eql({ + type: 'CONTINUE', + data: { outputdir: choice } }); - }); + } finally { + getPackageDirPathsStub.restore(); + showMenuStub.restore(); + } }); }); diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/sfdxProject/sfdxPackageDirectories.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/sfdxProject/sfdxPackageDirectories.test.ts index 592e66eb9a..5fe7c1b054 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/sfdxProject/sfdxPackageDirectories.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/sfdxProject/sfdxPackageDirectories.test.ts @@ -31,16 +31,16 @@ describe('SFDX Package Directories', () => { ]); }); - it('should return multiple package directories', async () => { + it('should return multiple package directories with default as first', async () => { sfdxProjectConfigStub = stub(SfdxProjectConfig, 'getValue').returns([ { path: 'package1' }, { path: 'package2' }, - { path: 'package3' } + { path: 'package3', default: true } ]); expect(await SfdxPackageDirectories.getPackageDirectoryPaths()).to.eql([ + 'package3', 'package1', - 'package2', - 'package3' + 'package2' ]); }); From 843618922b4b5e8401bc347a763aaef6fa781c59 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sun, 24 Mar 2019 13:03:05 -0700 Subject: [PATCH 4/9] Don't show default dirs if no packageDirs --- .../src/commands/commands.ts | 12 +++++++++++- .../vscode-integration/commands/commands.test.ts | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index f844f49708..4edc2f5d76 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -234,7 +234,17 @@ export class SelectOutputDir public async gather(): Promise< CancelResponse | ContinueResponse<{ outputdir: string }> > { - const packageDirs = await SfdxPackageDirectories.getPackageDirectoryPaths(); + let packageDirs: string[] = []; + try { + packageDirs = await SfdxPackageDirectories.getPackageDirectoryPaths(); + } catch (e) { + if ( + e.name !== 'NoPackageDirectoryPathsFound' && + e.name !== 'NoPackageDirectoriesFound' + ) { + throw e; + } + } let dirOptions = this.getDefaultOptions(packageDirs); let outputdir = await this.showMenu(dirOptions); diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts index 2550296f09..22d8439bb5 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts @@ -248,7 +248,7 @@ describe('Command Utilities', () => { expect( options.every(outputDir => { - // don't append the type name if a dir already has that as its name + // don't append the type name if the output dir already has that as its name return outputDir.endsWith('aura') && !outputDir.endsWith('aura/aura'); }) ).to.be.true; @@ -263,7 +263,6 @@ describe('Command Utilities', () => { 'getPackageDirectoryPaths' ); const showMenuStub = sinon.stub(selector, 'showMenu'); - const choice = customOptions[5]; getPackageDirPathsStub.returns(['test-app']); showMenuStub.onFirstCall().returns(selector.customDirOption); From 732e6ca771f86d9053c11a258d04cf7637d18230 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sun, 24 Mar 2019 13:17:19 -0700 Subject: [PATCH 5/9] remove some extra code from getPackageDirectories --- .../src/sfdxProject/sfdxPackageDirectories.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts b/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts index e43ad2e731..02e918cf70 100644 --- a/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts +++ b/packages/salesforcedx-vscode-core/src/sfdxProject/sfdxPackageDirectories.ts @@ -17,8 +17,7 @@ export default class SfdxPackageDirectories { 'packageDirectories' )) as JsonArray; if (packageDirectories) { - const packageDirectoryPaths: string[] = []; - let defaultPath; + let packageDirectoryPaths: string[] = []; packageDirectories.forEach(packageDir => { if (packageDir) { const packageDirectory = packageDir as JsonMap; @@ -29,16 +28,13 @@ export default class SfdxPackageDirectories { dirPath = dirPath.substring(1); } if (packageDirectory.default) { - defaultPath = dirPath; + packageDirectoryPaths = [dirPath].concat(packageDirectoryPaths); } else { packageDirectoryPaths.push(dirPath); } } } }); - if (defaultPath) { - packageDirectoryPaths.unshift(defaultPath); - } if (packageDirectoryPaths.length === 0) { const error = new Error(); error.name = 'NoPackageDirectoryPathsFound'; From 26e144570e1936940b785428fb4ad850b9014526 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sun, 24 Mar 2019 15:24:29 -0700 Subject: [PATCH 6/9] system-test tweaks --- packages/system-tests/scenarios/scaffolding.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/system-tests/scenarios/scaffolding.test.ts b/packages/system-tests/scenarios/scaffolding.test.ts index 83f0eed6d4..1a560315ed 100644 --- a/packages/system-tests/scenarios/scaffolding.test.ts +++ b/packages/system-tests/scenarios/scaffolding.test.ts @@ -109,7 +109,7 @@ describe('Scaffolding commands', () => { await app.wait(); // Enter desired location (without slashes so it's OS-independent) - await common.type('force-appmaindefaultpages'); + await common.type('force-appmaindefaultcomponents'); await app.client.keys(['NULL', 'Enter', 'NULL'], false); await app.wait(); @@ -273,7 +273,7 @@ describe('Scaffolding commands', () => { await app.wait(); // Enter desired location (without slashes so it's OS-independent) - await common.type('defaultlightningcomponents'); + await common.type('defaultlwc'); await app.client.keys(['NULL', 'Enter', 'NULL'], false); await app.wait(); From 411d2e3e1c0e182fa8356ca359e2a6f4ad8ebde9 Mon Sep 17 00:00:00 2001 From: Bryan Date: Tue, 26 Mar 2019 11:53:15 -0700 Subject: [PATCH 7/9] os agnostic paths and logging --- .../src/commands/commands.ts | 32 ++++++++++--------- .../src/commands/forceApexClassCreate.ts | 12 +++++-- .../src/commands/forceApexTriggerCreate.ts | 12 +++++-- .../src/commands/forceLightningAppCreate.ts | 12 +++++-- .../commands/forceLightningComponentCreate.ts | 12 +++++-- .../src/commands/forceLightningEventCreate.ts | 12 +++++-- .../commands/forceLightningInterfaceCreate.ts | 12 +++++-- .../forceVisualforceComponentCreate.ts | 12 +++++-- .../commands/forceVisualforcePageCreate.ts | 12 +++++-- .../commands/commands.test.ts | 8 ++--- .../src/commands/forceLightningLwcCreate.ts | 15 +++++++-- 11 files changed, 105 insertions(+), 46 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/commands.ts b/packages/salesforcedx-vscode-core/src/commands/commands.ts index 4edc2f5d76..fa8ead03ee 100644 --- a/packages/salesforcedx-vscode-core/src/commands/commands.ts +++ b/packages/salesforcedx-vscode-core/src/commands/commands.ts @@ -221,8 +221,8 @@ export class SelectOutputDir implements ParametersGatherer<{ outputdir: string }> { private typeDir: string; private typeDirRequired: boolean | undefined; - public readonly defaultOutput = '/main/default'; - public readonly customDirOption = `$(file-directory) ${nls.localize( + public static readonly defaultOutput = path.join('main', 'default'); + public static readonly customDirOption = `$(file-directory) ${nls.localize( 'custom_output_directory' )}`; @@ -248,7 +248,7 @@ export class SelectOutputDir let dirOptions = this.getDefaultOptions(packageDirs); let outputdir = await this.showMenu(dirOptions); - if (outputdir === this.customDirOption) { + if (outputdir === SelectOutputDir.customDirOption) { dirOptions = this.getCustomOptions(getRootWorkspacePath()); outputdir = await this.showMenu(dirOptions); } @@ -260,23 +260,25 @@ export class SelectOutputDir public getDefaultOptions(packageDirectories: string[]): string[] { const options = packageDirectories.map(packageDir => - path.join(packageDir, this.defaultOutput, this.typeDir) + path.join(packageDir, SelectOutputDir.defaultOutput, this.typeDir) ); - options.push(this.customDirOption); + options.push(SelectOutputDir.customDirOption); return options; } public getCustomOptions(rootPath: string): string[] { - return new glob.GlobSync(path.join(rootPath, '**/')).found.map(value => { - let relativePath = path.relative(rootPath, path.join(value, '/')); - relativePath = path.join( - relativePath, - this.typeDirRequired && !relativePath.endsWith(this.typeDir) - ? this.typeDir - : '' - ); - return relativePath; - }); + return new glob.GlobSync(path.join(rootPath, '**', path.sep)).found.map( + value => { + let relativePath = path.relative(rootPath, path.join(value, '/')); + relativePath = path.join( + relativePath, + this.typeDirRequired && !relativePath.endsWith(this.typeDir) + ? this.typeDir + : '' + ); + return relativePath; + } + ); } public async showMenu(options: string[]): Promise { diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts index 63064e8f8f..44037897c2 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexClassCreate.ts @@ -31,6 +31,7 @@ import { SfdxWorkspaceChecker } from './commands'; const APEX_FILE_EXTENSION = '.cls'; +const APEX_CLASS_METADATA_DIR = 'classes'; class ForceApexClassCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -56,7 +57,12 @@ class ForceApexClassCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, APEX_CLASS_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if ( data !== undefined && data.toString() === '0' && @@ -89,8 +95,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(APEX_FILE_EXTENSION); -export async function forceApexClassCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('classes'); +export async function forceApexClassCreate() { + const outputDirGatherer = new SelectOutputDir(APEX_CLASS_METADATA_DIR); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts index cc765fe159..c693d36e22 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceApexTriggerCreate.ts @@ -33,6 +33,7 @@ import { } from './commands'; const APEX_TRIGGER_EXTENSION = '.trigger'; +const APEX_TRIGGER_METADATA_DIR = 'triggers'; export class ForceApexTriggerCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -57,7 +58,12 @@ export class ForceApexTriggerCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, APEX_TRIGGER_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( @@ -85,8 +91,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(APEX_TRIGGER_EXTENSION); -export async function forceApexTriggerCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('triggers'); +export async function forceApexTriggerCreate() { + const outputDirGatherer = new SelectOutputDir(APEX_TRIGGER_METADATA_DIR); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts index 2ce2f6638f..4023dc148c 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningAppCreate.ts @@ -33,6 +33,7 @@ import { } from './commands'; const LIGHTNING_APP_EXTENSION = '.app'; +const LIGHTNING_METADATA_DIR = 'aura'; class ForceLightningAppCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -57,7 +58,12 @@ class ForceLightningAppCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, LIGHTNING_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( @@ -87,8 +93,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); -export async function forceLightningAppCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('aura', true); +export async function forceLightningAppCreate() { + const outputDirGatherer = new SelectOutputDir(LIGHTNING_METADATA_DIR, true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts index 4138c0c9c2..c5597ad17a 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningComponentCreate.ts @@ -33,6 +33,7 @@ import { } from './commands'; const LIGHTNING_CMP_EXTENSION = '.cmp'; +const LIGHTNING_METADATA_DIR = 'aura'; class ForceLightningComponentCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -57,7 +58,12 @@ class ForceLightningComponentCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, LIGHTNING_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( @@ -87,8 +93,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); -export async function forceLightningComponentCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('aura', true); +export async function forceLightningComponentCreate() { + const outputDirGatherer = new SelectOutputDir(LIGHTNING_METADATA_DIR, true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts index 1f9a9c4c06..2f34104f71 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningEventCreate.ts @@ -33,6 +33,7 @@ import { } from './commands'; const LIGHTNING_EVT_EXTENSION = '.evt'; +const LIGHTNING_METADATA_DIR = 'aura'; class ForceLightningEventCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -57,7 +58,12 @@ class ForceLightningEventCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, LIGHTNING_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( @@ -87,8 +93,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); -export async function forceLightningEventCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('aura', true); +export async function forceLightningEventCreate() { + const outputDirGatherer = new SelectOutputDir(LIGHTNING_METADATA_DIR, true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts index fb686eac31..399c7d7a7e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts @@ -33,6 +33,7 @@ import { } from './commands'; const LIGHTNING_INT_EXTENSION = '.intf'; +const LIGHTNING_METADATA_DIR = 'aura'; class ForceLightningInterfaceCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -57,7 +58,12 @@ class ForceLightningInterfaceCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, LIGHTNING_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( @@ -87,8 +93,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); -export async function forceLightningInterfaceCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('aura', true); +export async function forceLightningInterfaceCreate() { + const outputDirGatherer = new SelectOutputDir(LIGHTNING_METADATA_DIR, true); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts index 68ace78f40..1a98a8f197 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceVisualforceComponentCreate.ts @@ -33,6 +33,7 @@ import { } from './commands'; const VF_CMP_EXTENSION = '.component'; +const VF_CMP_METADATA_DIR = 'components'; class ForceVisualForceComponentCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -58,7 +59,12 @@ class ForceVisualForceComponentCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, VF_CMP_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if (data !== undefined && data.toString() === '0' && hasRootWorkspace()) { vscode.workspace .openTextDocument( @@ -86,8 +92,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(VF_CMP_EXTENSION); -export async function forceVisualforceComponentCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('components'); +export async function forceVisualforceComponentCreate() { + const outputDirGatherer = new SelectOutputDir(VF_CMP_METADATA_DIR); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts b/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts index df2d8c8eb2..d2415de07a 100644 --- a/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts +++ b/packages/salesforcedx-vscode-core/src/commands/forceVisualforcePageCreate.ts @@ -32,6 +32,7 @@ import { } from './commands'; const VF_PAGE_EXTENSION = '.page'; +const VF_PAGE_METADATA_DIR = 'pages'; class ForceVisualForcePageCreateExecutor extends SfdxCommandletExecutor< DirFileNameSelection @@ -57,7 +58,12 @@ class ForceVisualForcePageCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, VF_PAGE_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if ( data !== undefined && data.toString() === '0' && @@ -90,8 +96,8 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const filePathExistsChecker = new FilePathExistsChecker(VF_PAGE_EXTENSION); -export async function forceVisualforcePageCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('pages'); +export async function forceVisualforcePageCreate() { + const outputDirGatherer = new SelectOutputDir(VF_PAGE_METADATA_DIR); const parameterGatherer = new CompositeParametersGatherer< DirFileNameSelection >(fileNameGatherer, outputDirGatherer); diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts index 22d8439bb5..ed4fb93f3c 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/commands.test.ts @@ -229,9 +229,9 @@ describe('Command Utilities', () => { const options = selector.getDefaultOptions(['testapp', 'testapp2']); expect(options).to.eql([ - path.join('testapp', selector.defaultOutput, 'test'), - path.join('testapp2', selector.defaultOutput, 'test'), - selector.customDirOption + path.join('testapp', SelectOutputDir.defaultOutput, 'test'), + path.join('testapp2', SelectOutputDir.defaultOutput, 'test'), + SelectOutputDir.customDirOption ]); }); @@ -265,7 +265,7 @@ describe('Command Utilities', () => { const showMenuStub = sinon.stub(selector, 'showMenu'); const choice = customOptions[5]; getPackageDirPathsStub.returns(['test-app']); - showMenuStub.onFirstCall().returns(selector.customDirOption); + showMenuStub.onFirstCall().returns(SelectOutputDir.customDirOption); showMenuStub.onSecondCall().returns(choice); const response = await selector.gather(); diff --git a/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts b/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts index 1ff348de33..7951dced17 100644 --- a/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts +++ b/packages/salesforcedx-vscode-lwc/src/commands/forceLightningLwcCreate.ts @@ -36,6 +36,7 @@ const notificationService = sfdxCoreExports.notificationService; const taskViewService = sfdxCoreExports.taskViewService; const LIGHTNING_LWC_EXTENSION = '.js'; +const LIGHTNING_LWC_METADATA_DIR = 'lwc'; export class LightningFilePathExistsChecker implements PostconditionChecker { @@ -93,7 +94,12 @@ class ForceLightningLwcCreateExecutor extends SfdxCommandletExecutor< }).execute(cancellationToken); execution.processExitSubject.subscribe(async data => { - this.logMetric(execution.command.logName, startTime); + const dirType = response.data.outputdir.endsWith( + path.join(SelectOutputDir.defaultOutput, LIGHTNING_LWC_METADATA_DIR) + ) + ? 'defaultDir' + : 'customDir'; + this.logMetric(`${execution.command.logName}_${dirType}`, startTime); if ( data !== undefined && data.toString() === '0' && @@ -127,8 +133,11 @@ const workspaceChecker = new SfdxWorkspaceChecker(); const fileNameGatherer = new SelectFileName(); const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); -export async function forceLightningLwcCreate(explorerDir?: any) { - const outputDirGatherer = new SelectOutputDir('lwc', true); +export async function forceLightningLwcCreate() { + const outputDirGatherer = new SelectOutputDir( + LIGHTNING_LWC_METADATA_DIR, + true + ); const parameterGatherer = new CompositeParametersGatherer( fileNameGatherer, outputDirGatherer From 811a75c1e3c0ebdebfa097d3f1c5b65849c6611a Mon Sep 17 00:00:00 2001 From: Ruth Sears-Blazej Date: Tue, 26 Mar 2019 17:37:40 -0700 Subject: [PATCH 8/9] Apply style guidelines to message --- packages/salesforcedx-vscode-core/src/messages/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/salesforcedx-vscode-core/src/messages/i18n.ts b/packages/salesforcedx-vscode-core/src/messages/i18n.ts index 25dcccf17d..e8d20c0bba 100644 --- a/packages/salesforcedx-vscode-core/src/messages/i18n.ts +++ b/packages/salesforcedx-vscode-core/src/messages/i18n.ts @@ -236,5 +236,5 @@ export const messages = { 'No default org is set. Run "SFDX: Create a Default Scratch Org" or "SFDX: Authorize an Org" to set one.', error_no_default_devhubusername: 'No default Dev Hub is set. Run "SFDX: Authorize a Dev Hub" to set one.', - custom_output_directory: 'Select a Custom Directory' + custom_output_directory: 'Choose a Custom Directory' }; From aabd51febb133c40466daccfd327a52810dca7ba Mon Sep 17 00:00:00 2001 From: Bryan Date: Wed, 27 Mar 2019 16:13:21 -0700 Subject: [PATCH 9/9] fix lwc system test --- packages/system-tests/scenarios/scaffolding.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/system-tests/scenarios/scaffolding.test.ts b/packages/system-tests/scenarios/scaffolding.test.ts index d12418b167..668dfc4231 100644 --- a/packages/system-tests/scenarios/scaffolding.test.ts +++ b/packages/system-tests/scenarios/scaffolding.test.ts @@ -267,13 +267,13 @@ describe('Scaffolding commands', () => { const fileName = `lwc_${new Date().getTime()}`; - // Enter desired location (without slashes so it's OS-independent) - await common.type('force-appmaindefaultlwc'); + // Enter file name + await common.type(fileName); await app.client.keys(['NULL', 'Enter', 'NULL'], false); await app.wait(); - // Enter file name - await common.type(fileName); + // Enter desired location (without slashes so it's OS-independent) + await common.type('force-appmaindefaultlwc'); await app.client.keys(['NULL', 'Enter', 'NULL'], false); await app.wait();