Skip to content

Conversation

@rulasg
Copy link
Owner

@rulasg rulasg commented Mar 25, 2025

Refactor the file loading mechanism for improved clarity and efficiency. Introduce a new function to install the Salesforce CLI via npm, along with custom logging functions for better error handling and messaging. Export the new installation function for module usage.

@rulasg rulasg merged commit d878a97 into main Mar 25, 2025
2 checks passed
@rulasg rulasg deleted the install-sf branch March 25, 2025 06:53
@@ -1,31 +1,16 @@
Write-Information -Message ("Loading {0} ..." -f ($PSCommandPath | Split-Path -LeafBase)) -InformationAction continue
Write-Information -Message ("Loading {0} ..." -f ($PSScriptRoot | Split-Path -Leaf)) -InformationAction continue

Check warning

Code scanning / PSScriptAnalyzer

Cmdlet 'Write-Information' may be used incorrectly. Please check that all mandatory parameters are supplied. Warning

Cmdlet 'Write-Information' may be used incorrectly. Please check that all mandatory parameters are supplied.

function Write-MyError{
param(
[Parameter(Mandatory,ValueFromPipeline)][string]$Message

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
param(
[Parameter(Mandatory,ValueFromPipeline)][string]$Message
)
Write-Host "Error: $message" -ForegroundColor $ERROR_COLOR

Check warning

Code scanning / PSScriptAnalyzer

File 'MyWrite.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information. Warning

File 'MyWrite.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.

function Write-MyWarning{
param(
[Parameter(Mandatory,ValueFromPipeline)][string]$Message

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
param(
[Parameter(Mandatory,ValueFromPipeline)][string]$Message
)
Write-Host "Error: $message" -ForegroundColor $WARNING_COLOR

Check warning

Code scanning / PSScriptAnalyzer

File 'MyWrite.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information. Warning

File 'MyWrite.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.

function Write-MyVerbose{
param(
[Parameter(ValueFromPipeline)][string]$Message

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.

function Write-MyHost{
param(
[Parameter(ValueFromPipeline)][string]$Message

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
param(
[Parameter(ValueFromPipeline)][string]$Message
)
Write-Host $message -ForegroundColor $OUTPUT_COLOR

Check warning

Code scanning / PSScriptAnalyzer

File 'MyWrite.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information. Warning

File 'MyWrite.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
Set-MyInvokeCommandAlias -Alias GetNpmVersion -Command "npm --version"
Set-MyInvokeCommandAlias -Alias SalesforceCliInstall -Command "npm install @salesforce/cli --global"

function Install-SalesforceClient{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Install-SalesforceClient' does not have a help comment. Note

The cmdlet 'Install-SalesforceClient' does not have a help comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants