-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New menu for selecting output directory for "create" commands #1187
Conversation
@@ -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 SelectOutputDir('aura', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because aura bundles require the "aura" parent folder, we let the constructor know this requirement by specifying "true".
@@ -27,7 +27,11 @@ export default class SfdxPackageDirectories { | |||
if (dirPath.startsWith(path.sep)) { | |||
dirPath = dirPath.substring(1); | |||
} | |||
packageDirectoryPaths.push(dirPath); | |||
if (packageDirectory.default) { | |||
packageDirectoryPaths = [dirPath].concat(packageDirectoryPaths); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight modification to have the default package directory in a project be the first element of the list.
outputDirGatherer, | ||
fileNameGatherer | ||
fileNameGatherer, | ||
outputDirGatherer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched the order of these gatherers to keep the experience consistent with the other create commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this change to break Should create Lightning LWC
on the scaffolding.test.ts
I fixed a few days ago.
Codecov Report
@@ Coverage Diff @@
## develop #1187 +/- ##
==========================================
- Coverage 71.01% 71% -0.02%
==========================================
Files 196 196
Lines 7379 7397 +18
Branches 780 781 +1
==========================================
+ Hits 5240 5252 +12
- Misses 1983 1989 +6
Partials 156 156
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
this.globKeyWord = globKeyWord; | ||
private typeDir: string; | ||
private typeDirRequired: boolean | undefined; | ||
public readonly defaultOutput = '/main/default'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this (use of defaultOutput
's value as it is) is going to break on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes good catch
let relativePath = path.relative(srcPath, path.join(value, '/')); | ||
relativePath = path.join(relativePath, ''); | ||
public getCustomOptions(rootPath: string): string[] { | ||
return new glob.GlobSync(path.join(rootPath, '**/')).found.map(value => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is going to break on Windows, can you verify ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lcampos do we need a path utility in our core library maybe? This seems to be a common problem. Maybe if we prevented the use of require('path
)` and used our own utility, it would cut down on these windows bugs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, using path
is the right way to address this since its a Nodejs module and it does a good job across platforms.
@@ -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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (rootPath) { | ||
let packageDirs: string[] = []; | ||
try { | ||
packageDirs = await SfdxPackageDirectories.getPackageDirectoryPaths(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool handling for multiple packages.
@@ -90,10 +86,7 @@ const fileNameGatherer = new SelectFileName(); | |||
const filePathExistsChecker = new FilePathExistsChecker(APEX_TRIGGER_EXTENSION); | |||
|
|||
export async function forceApexTriggerCreate(explorerDir?: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep the explorerDir
parameter now that's not being used ? Same question applies to the other create commands being modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so? I wasn't really sure what it was being used for in the first place...
@brpowell I do think adding telemetry to see how the feature is used would help. I know we already have some to track the execution time. You can either add more details to that one or add a new log line, it's up to you. |
We should track overall use and maybe the result folder is worth doing - although don't track the folder name because it might contain PII, just track |
@@ -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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These template commands badly need to be refactored to avoid having so much duplicated code. I started doing so but stuck it in another branch to separate it from this work. I'll make a story for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/salesforcedx-vscode-core/src/commands/forceLightningInterfaceCreate.ts
Show resolved
Hide resolved
@lcampos or @brpowell - Please check this updated text for accuracy: Add a menu for selecting an output directory for commands that create metadata from a template; create the `default` directory, if it doesn’t exist, when running these commands ([PR #1187](#1187), [Issue #852](#852), [Issue #998](#998))
What does this PR do?
Revises the menu for selecting an output directory for the create commands that generates templates. Users are now prompted with a list of default output options. If they want to choose a custom directory, they can select the last option of the menu to show a list of all directories in the project. For components that require their parent folder to be named something specific, it is automatically created whether the chosen output directory has that name or not.
What issues does this PR fix or reference?
W-5815448
#852 #998