-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: failure when missing aura folder (#5718)
* fix: fix failure when missing aura folder @W-16285103@ no logner fails w/ aura or lwc no present add dup checks across component create * chore: wip * chore: wip * chore: fix a few remaing tidbits * chore: remove unneeded todo comments --------- Co-authored-by: Cristina Cañizales <113132642+CristiCanizales@users.noreply.github.com>
- Loading branch information
1 parent
b84e08c
commit b7f78db
Showing
15 changed files
with
394 additions
and
158 deletions.
There are no files selected for viewing
22 changes: 0 additions & 22 deletions
22
packages/salesforcedx-sobjects-faux-generator/src/utils/utils.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/salesforcedx-vscode-core/src/commands/util/lwcAuraDuplicateComponentCheckers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* 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 { getMessageFromError, notificationService, PostconditionChecker } from '@salesforce/salesforcedx-utils-vscode'; | ||
import * as fs from 'fs'; | ||
import { nls } from '../../messages'; | ||
import { ContinueOrCancel, getComponentName, getComponentPath, isContinue, OneOrMany } from '../../util'; | ||
import { isComponentName, isDirFileNameSelection} from '../../util/types'; | ||
import { | ||
RENAME_NOT_SUPPORTED_MESSAGE, | ||
INPUT_NO_COMPONENT_NAME_MESSAGE, | ||
COMPONENT_CANNOT_BE_EMPTY_MESSAGE, | ||
CREATE_NOT_SUPPORTED_MESSAGE, | ||
INPUT_INCORRECT_COMPONENT_PROPERTIES_MESSAGE, | ||
INPUT_DUP_ERROR, | ||
checkForExistingComponentInAltLocation, | ||
checkForDuplicateInComponent, | ||
checkForDuplicateName | ||
} from './lwcAuraDuplicateDetectionUtils'; | ||
|
||
|
||
/* | ||
* Checks for existing component name between LWC and Aura during rename | ||
*/ | ||
export class LwcAuraDuplicateComponentCheckerForRename implements PostconditionChecker<OneOrMany> { | ||
constructor(private readonly sourceFsPath: string) { } | ||
async check(inputs: ContinueOrCancel): Promise<ContinueOrCancel> { | ||
if (!isContinue(inputs)) { | ||
return Promise.resolve(inputs); | ||
} | ||
if (Array.isArray(inputs.data)) { | ||
return { type: 'CANCEL', msg: nls.localize(RENAME_NOT_SUPPORTED_MESSAGE) }; | ||
} | ||
const { data } = inputs; | ||
if (!isComponentName(data)) { | ||
return { type: 'CANCEL', msg: nls.localize(INPUT_NO_COMPONENT_NAME_MESSAGE) }; | ||
} | ||
const { name } = data; | ||
if (!name) { | ||
return { type: 'CANCEL', msg: nls.localize(COMPONENT_CANNOT_BE_EMPTY_MESSAGE) }; | ||
} | ||
|
||
try { | ||
const componentPath = await getComponentPath(this.sourceFsPath); | ||
await checkForDuplicateName(componentPath, name); | ||
const items = await fs.promises.readdir(componentPath); | ||
await checkForDuplicateInComponent(componentPath, name, items); | ||
return { type: 'CONTINUE', data: inputs.data }; | ||
} catch (error) { | ||
const errorMsg = getMessageFromError(error); | ||
void notificationService.showErrorMessage(errorMsg); | ||
return { type: 'CANCEL', msg: errorMsg }; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Checks for existing component name between LWC and Aura during create | ||
*/ | ||
export class LwcAuraDuplicateComponentCheckerForCreate implements PostconditionChecker<OneOrMany> { | ||
constructor() { } | ||
async check(inputs: ContinueOrCancel): Promise<ContinueOrCancel> { | ||
if (!isContinue(inputs)) { | ||
return Promise.resolve(inputs); | ||
} | ||
if (Array.isArray(inputs.data)) { | ||
return { type: 'CANCEL', msg: nls.localize(CREATE_NOT_SUPPORTED_MESSAGE) }; | ||
} | ||
|
||
if (!isDirFileNameSelection(inputs.data)) { | ||
return { type: 'CANCEL', msg: nls.localize(INPUT_INCORRECT_COMPONENT_PROPERTIES_MESSAGE) }; | ||
} | ||
|
||
const componentPath = inputs.data.outputdir; | ||
const componentName = getComponentName(inputs.data.fileName); | ||
return checkForExistingComponentInAltLocation(componentPath, componentName) | ||
.then(exists => { | ||
if (exists) { | ||
void notificationService.showErrorMessage(nls.localize(INPUT_DUP_ERROR)); | ||
return { type: 'CANCEL', msg: nls.localize(INPUT_DUP_ERROR) }; | ||
} | ||
// No duplicates found, continue with the process | ||
return { type: 'CONTINUE', data: inputs.data }; | ||
}); | ||
} | ||
} |
Oops, something went wrong.