Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions SfHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,11 @@ Write-Information -Message ("Loading {0} ..." -f ($PSCommandPath | Split-Path -L
#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
Get-ChildItem -Path $MODULE_PATH\$_\*.ps1 -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
try { . $_.fullname }
catch { Write-Error -Message "Failed to import function $($import.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

}
27 changes: 6 additions & 21 deletions Test/Test.psm1
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

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.

#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
20 changes: 0 additions & 20 deletions en-US/about_SfHelper.help.txt

This file was deleted.

File renamed without changes.
32 changes: 32 additions & 0 deletions include/MyWrite.ps1
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 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.
)
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.
)
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.
)
Write-Verbose -Message $message
}

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.
)
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.
}
19 changes: 19 additions & 0 deletions public/Install-SalesforceClient.ps1
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 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.
[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
Loading