-
-
Notifications
You must be signed in to change notification settings - Fork 0
Aadd Salesforce CLI installation function #17
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
Changes from all commits
820fe3b
3c0481b
6792a16
9533768
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
||
| #Module path is where resides the RootModule file. This file. :) | ||
| $MODULE_PATH = $PSScriptRoot | ||
|
|
||
| #Get public and private function definition files. | ||
| $Include = @( Get-ChildItem -Path $MODULE_PATH\include\*.ps1 -ErrorAction SilentlyContinue ) | ||
| $Private = @( Get-ChildItem -Path $MODULE_PATH\private\*.ps1 -Recurse -ErrorAction SilentlyContinue ) | ||
| $Public = @( Get-ChildItem -Path $MODULE_PATH\public\*.ps1 -Recurse -ErrorAction SilentlyContinue ) | ||
| # Load ps1 files on code folders in order | ||
| "config","helper","include","private","public" | ForEach-Object { | ||
|
|
||
| #Dot source the files | ||
| Foreach($import in @($Include + $Private + $Public)) | ||
| { | ||
| Try | ||
| { | ||
| . $import.fullname | ||
| } | ||
| Catch | ||
| { | ||
| Write-Error -Message "Failed to import function $($import.fullname): $_" | ||
| Get-ChildItem -Path $MODULE_PATH\$_\*.ps1 -Recurse -ErrorAction SilentlyContinue | ForEach-Object { | ||
| try { . $_.fullname } | ||
| catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } | ||
| } | ||
| } | ||
|
|
||
| # Here I might... | ||
| # Read in or create an initial config file and variable | ||
| # Export Public functions ($Public.BaseName) for WIP modules | ||
| # Set variables visible to the module and its functions only | ||
|
|
||
| Export-ModuleMember -Function Test_* | ||
|
|
||
| Reset-InvokeCommandMock | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
|
|
||
| $ERROR_COLOR = "Red" | ||
| $WARNING_COLOR = "Yellow" | ||
| $OUTPUT_COLOR = "DarkCyan" | ||
|
|
||
| function Write-MyError{ | ||
| param( | ||
| [Parameter(Mandatory,ValueFromPipeline)][string]$Message | ||
Check warningCode 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.
|
||
| ) | ||
| Write-Host "Error: $message" -ForegroundColor $ERROR_COLOR | ||
Check warningCode 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 warningCode 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.
|
||
| ) | ||
| Write-Host "Error: $message" -ForegroundColor $WARNING_COLOR | ||
Check warningCode 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 warningCode 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.
|
||
| ) | ||
| Write-Verbose -Message $message | ||
| } | ||
|
|
||
| function Write-MyHost{ | ||
| param( | ||
| [Parameter(ValueFromPipeline)][string]$Message | ||
Check warningCode 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.
|
||
| ) | ||
| Write-Host $message -ForegroundColor $OUTPUT_COLOR | ||
Check warningCode 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.
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| Set-MyInvokeCommandAlias -Alias GetNpmVersion -Command "npm --version" | ||
| Set-MyInvokeCommandAlias -Alias SalesforceCliInstall -Command "npm install @salesforce/cli --global" | ||
|
|
||
| function Install-SalesforceClient{ | ||
Check noticeCode scanning / PSScriptAnalyzer The cmdlet 'Install-SalesforceClient' does not have a help comment. Note
The cmdlet 'Install-SalesforceClient' does not have a help comment.
|
||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| # check that npm is install in the system | ||
| $result = Invoke-MyCommand -Command GetNpmVersion | ||
| if($null -eq $result){ | ||
| throw "npm not installed. Please install npm to install Sf-Cli through npm." | ||
| } | ||
|
|
||
| "Installing Salesforce CLI using npm..." | Write-MyHost | ||
| $result = Invoke-MyCommand -Command SalesforceCliInstall | ||
|
|
||
| return $result | ||
| } Export-ModuleMember -Function Install-SalesforceClient | ||
Check warning
Code scanning / PSScriptAnalyzer
Cmdlet 'Write-Information' may be used incorrectly. Please check that all mandatory parameters are supplied. Warning