Skip to content

Commit

Permalink
Auto-upgrade to @salesforce/cli (#108)
Browse files Browse the repository at this point in the history
* Auto-upgrade to @salesforce/cli :)

Fixes #107

* Fix error when @salesforce/cli has been installed with nvm

Fixes https://github.com/hardisgroupcom/sfdx-hardis/issues/396
Co-Authored-by: @anthonygiuliano

* changelog

* Upgrade mega-linter-runner

* yarn-audit-fix

* Linter fixes

* linter

* [Mega-Linter] Apply linters fixes :)

* Add @salesforce/plugin-packaging in default plugins

* [Mega-Linter] Apply linters fixes :)

---------

Co-authored-by: nvuillam <[email protected]>
  • Loading branch information
nvuillam and nvuillam authored Aug 18, 2023
1 parent 3c01a33 commit 5d7a7aa
Show file tree
Hide file tree
Showing 16 changed files with 215 additions and 170 deletions.
2 changes: 2 additions & 0 deletions .github/linters/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"EDITORCONFIG",
"Eqoehef",
"FILEIO",
"GRYPE",
"HADOLINT",
"Hardis",
"IVMA",
Expand All @@ -44,6 +45,7 @@
"WIPO",
"activateinvalid",
"allowpurgefailure",
"anthonygiuliano",
"apexlog",
"apiversion",
"bestpractices",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
- name: Mega-Linter
id: ml
# You can override Mega-Linter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
# More info at https://megalinter.io/latest/flavors/
uses: oxsecurity/megalinter/flavors/javascript@v7
env:
# All available variables are described in documentation
# https://megalinter.io/configuration/
# https://megalinter.io/latest/config-file/
VALIDATE_ALL_CODEBASE: true # Set ${{ github.event_name == &#39;push&#39; &amp;&amp; github.ref == &#39;refs/heads/main&#39; }} to validate only diff with main branch
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
Expand Down
3 changes: 2 additions & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Configuration file for Mega-Linter
# See all available variables at https://megalinter.io/configuration/ and in linters documentation
# See all available variables at https://megalinter.io/latest/config-file/ and in linters documentation

APPLY_FIXES: all # all, none, or list of linter keys
DEFAULT_BRANCH: main # Usually master or main
Expand All @@ -8,6 +8,7 @@ DEFAULT_BRANCH: main # Usually master or main
DISABLE_LINTERS:
- TYPESCRIPT_STANDARD
DISABLE_ERRORS_LINTERS:
- REPOSITORY_GRYPE
- REPOSITORY_TRIVY
TYPESCRIPT_DEFAULT_STYLE: prettier
FILTER_REGEX_EXCLUDE: (\.vscode)
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## [Unreleased]

## [2.0.0] 2023-08-18

**BREAKING CHANGE**: Only for some CI scripts, please read [sfdx-hardis v4.0.0 release notes](https://github.com/hardisgroupcom/sfdx-hardis/releases/tag/v4.0.0)

- Automatically **uninstall sfdx-cli** then **install @salesforce/cli** to follow [Salesforce recommendations](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_move_to_sf_v2.htm)
- Add @salesforce/plugin-packaging in default plugins
- Fix false positive error when nvm has been used to install @salesforce/cli (thanks @anthonygiuliano :))
- Upgrade npm dependencies
- Upgrade MegaLinter

## [1.33.1] 2023-07-10

- Fix issue when sfdx is installed in nodejs folder
Expand Down
62 changes: 31 additions & 31 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Commands {
hardisCommandsProvider: HardisCommandsProvider,
hardisStatusProvider: HardisStatusProvider,
hardisPluginsProvider: HardisPluginsProvider,
reporter: TelemetryReporter
reporter: TelemetryReporter,
) {
this.hardisCommandsProvider = hardisCommandsProvider;
this.hardisStatusProvider = hardisStatusProvider;
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Commands {
if (this.terminalIsRunning) {
vscode.window.showErrorMessage(
"🦙 Wait for the current command to be completed before running a new one :)",
"Close"
"Close",
);
return;
}
Expand Down Expand Up @@ -111,8 +111,8 @@ export class Commands {
this.terminalStack = this.terminalStack.filter(
(terminal) =>
vscode.window.terminals.filter(
(vsTerminal) => vsTerminal.processId === terminal.processId
).length > 0
(vsTerminal) => vsTerminal.processId === terminal.processId,
).length > 0,
);
// Create new terminal if necessary
if (
Expand All @@ -132,25 +132,25 @@ export class Commands {
vscode.workspace.getConfiguration("vsCodeSfdxHardis");
if (config.get("disableGitBashCheck") !== true) {
vscode.commands.executeCommand(
"workbench.action.terminal.selectDefaultShell"
"workbench.action.terminal.selectDefaultShell",
);
vscode.window
.showWarningMessage(
"🦙 It is recommended to use Git Bash as default terminal shell (do it in the opened dialog at the top of the screen)",
"Download Git Bash",
"Ignore",
"Don't ask again"
"Don't ask again",
)
.then((selection) => {
if (selection === "Download Git Bash") {
vscode.env.openExternal(
vscode.Uri.parse("https://git-scm.com/downloads")
vscode.Uri.parse("https://git-scm.com/downloads"),
);
} else if (selection === "Don't ask again") {
config.update("disableGitBashCheck", true);
} else {
vscode.window.showInformationMessage(
"🦙 If you do not want to see this message anymore, set VsCode setting vsCodeSfdxHardis.disableGitBashCheck to true, or click on Don't ask again"
"🦙 If you do not want to see this message anymore, set VsCode setting vsCodeSfdxHardis.disableGitBashCheck to true, or click on Don't ask again",
);
}
});
Expand All @@ -166,7 +166,7 @@ export class Commands {
//const newTerminal = vscode.window.createTerminal(terminalOptions);
vscode.commands.executeCommand(
"workbench.action.terminal.newInActiveWorkspace",
"SFDX Hardis"
"SFDX Hardis",
);
new Promise((resolve) => setTimeout(resolve, 4000)).then(() => {
/* vscode.commands.executeCommand(
Expand All @@ -181,7 +181,7 @@ export class Commands {
// Run command in active terminal
this.runCommandInTerminal(sfdxHardisCommand);
}
}
},
);
this.disposables.push(disposable);
}
Expand All @@ -196,28 +196,28 @@ export class Commands {
const toReload = vscode.extensions.all.filter(
(extension) =>
extension.id === "salesforce.salesforcedx-vscode-core" &&
extension.isActive === false
extension.isActive === false,
);
if (toReload.length > 0) {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
}
},
);
this.disposables.push(disposable);
}

registerRefreshStatusView() {
const disposable = vscode.commands.registerCommand(
"vscode-sfdx-hardis.refreshStatusView",
() => this.hardisStatusProvider?.refresh()
() => this.hardisStatusProvider?.refresh(),
);
this.disposables.push(disposable);
}

registerRefreshPluginsView() {
const disposable = vscode.commands.registerCommand(
"vscode-sfdx-hardis.refreshPluginsView",
() => this.hardisPluginsProvider?.refresh()
() => this.hardisPluginsProvider?.refresh(),
);
this.disposables.push(disposable);
}
Expand All @@ -229,14 +229,14 @@ export class Commands {
() => {
vscode.commands.executeCommand(
"workbench.action.terminal.newInActiveWorkspace",
"SFDX Hardis"
"SFDX Hardis",
);
new Promise((resolve) => setTimeout(resolve, 4000)).then(() => {
const newTerminal =
vscode.window.terminals[vscode.window.terminals.length - 1];
this.terminalStack.push(newTerminal);
});
}
},
);
this.disposables.push(disposable);
}
Expand All @@ -245,7 +245,7 @@ export class Commands {
// Open external command
const disposable = vscode.commands.registerCommand(
"vscode-sfdx-hardis.openExternal",
(url) => vscode.env.openExternal(url)
(url) => vscode.env.openExternal(url),
);
this.disposables.push(disposable);
}
Expand All @@ -266,22 +266,22 @@ export class Commands {
.showInformationMessage(
`🦙 ${commandDetail}`,
{ modal: true },
...messageButtons
...messageButtons,
)
.then((selection) => {
if (selection === "Run command") {
vscode.commands.executeCommand(
"vscode-sfdx-hardis.execute-command",
item.hardisCommand
item.hardisCommand,
);
} else if (selection === "Open Online Help") {
vscode.commands.executeCommand(
"vscode-sfdx-hardis.openCommandHelp",
item
item,
);
}
});
}
},
);
this.disposables.push(disposable);
}
Expand All @@ -295,10 +295,10 @@ export class Commands {
vscode.env.openExternal(item.options.helpUrl);
} else {
vscode.window.showInformationMessage(
"🦙 No help url has been defined for this command"
"🦙 No help url has been defined for this command",
);
}
}
},
);
this.disposables.push(disposable);
}
Expand All @@ -307,7 +307,7 @@ export class Commands {
// Open external command
const disposable = vscode.commands.registerCommand(
"vscode-sfdx-hardis.openPluginHelp",
(item) => vscode.env.openExternal(item.options.helpUrl)
(item) => vscode.env.openExternal(item.options.helpUrl),
);
this.disposables.push(disposable);
}
Expand All @@ -322,7 +322,7 @@ export class Commands {
} else {
vscode.window.showInformationMessage(msg);
}
}
},
);
this.disposables.push(disposable);
}
Expand All @@ -344,15 +344,15 @@ export class Commands {
if (decodedUrl !== "") {
vscode.commands.executeCommand(
"vscode-sfdx-hardis.openExternal",
decodedUrl
decodedUrl,
);
} else {
vscode.window.showErrorMessage(
"🦙 This URL is not a valid Outlook validation link",
"Close"
"Close",
);
}
}
},
);
this.disposables.push(disposable);
}
Expand Down Expand Up @@ -393,7 +393,7 @@ export class Commands {
(quickpick.canSelectMany = false);
quickpick.items = keyFileList
.filter((choice: any) =>
fs.existsSync(currentWorkspaceFolderUri + path.sep + choice.file)
fs.existsSync(currentWorkspaceFolderUri + path.sep + choice.file),
)
.map((choice: any) => {
const quickPickItem: vscode.QuickPickItem = {
Expand All @@ -419,13 +419,13 @@ export class Commands {
quickpick.dispose();
if (value) {
var openPath = vscode.Uri.parse(
"file:///" + currentWorkspaceFolderUri + "/" + value
"file:///" + currentWorkspaceFolderUri + "/" + value,
);
vscode.workspace.openTextDocument(openPath).then((doc) => {
vscode.window.showTextDocument(doc);
});
}
}
},
);
}
}
16 changes: 8 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,31 @@ export function activate(context: vscode.ExtensionContext) {

// Register Commands tree data provider
const hardisCommandsProvider = new HardisCommandsProvider(
currentWorkspaceFolderUri
currentWorkspaceFolderUri,
);
const disposableTreeCommands = vscode.window.registerTreeDataProvider(
"sfdx-hardis-commands",
hardisCommandsProvider
hardisCommandsProvider,
);
context.subscriptions.push(disposableTreeCommands);

// Register Status TreeView
const hardisStatusProvider = new HardisStatusProvider(
currentWorkspaceFolderUri
currentWorkspaceFolderUri,
);
const disposableTreeInfo = vscode.window.registerTreeDataProvider(
"sfdx-hardis-status",
hardisStatusProvider
hardisStatusProvider,
);
context.subscriptions.push(disposableTreeInfo);

// Register Status TreeView
const hardisPluginsProvider = new HardisPluginsProvider(
currentWorkspaceFolderUri
currentWorkspaceFolderUri,
);
const disposableTreePlugins = vscode.window.registerTreeDataProvider(
"sfdx-hardis-plugins",
hardisPluginsProvider
hardisPluginsProvider,
);
context.subscriptions.push(disposableTreePlugins);

Expand All @@ -76,7 +76,7 @@ export function activate(context: vscode.ExtensionContext) {
hardisCommandsProvider,
hardisStatusProvider,
hardisPluginsProvider,
reporter
reporter,
);
context.subscriptions.push(...commands.disposables);

Expand Down Expand Up @@ -152,7 +152,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.workspace.onDidRenameFiles((event) => {
if (
event.files.filter((rename) =>
rename.newUri.fsPath.includes("sfdx-project.json")
rename.newUri.fsPath.includes("sfdx-project.json"),
)
) {
vscode.commands.executeCommand("vscode-sfdx-hardis.refreshCommandsView");
Expand Down
Loading

0 comments on commit 5d7a7aa

Please sign in to comment.