-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGenerate-PowerShellClient.ps1
54 lines (43 loc) · 1.51 KB
/
Generate-PowerShellClient.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# ITNOA
# This script installs required packages to generate and build BSN Iptable command-line
# Requirements:
# Powershell Core
# nvm (Node Version Manager)
# Internet (to install packages)
$ErrorActionPreference = 'Stop'
if ($PSEdition -ne 'Core') {
Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.'
}
try {
Write-Host "Nvm is installed, version" $(nvm --version)
}
catch {
Write-Error "Nvm is not installed, install it manually to continue."
}
# 18.18.0 is the latest LTS node version
New-Variable -Name desiredNodeVersion -Value 'v18.18.0' -Option ReadOnly
if ($(nvm current) -ne $desiredNodeVersion) {
nvm install $desiredNodeVersion
nvm use $desiredNodeVersion
}
else {
Write-Host "Node is installed, version" $desiredNodeVersion
}
try {
(autorest --version).Split([Environment]::NewLine) | Select -First 1
}
catch {
Write-Host "autorest is not installed, installing .." -ForegroundColor Yellow
npm install -g "[email protected]"
}
# Below command should be used if Autorest is not clean:
# autorest --reset
Write-Host "Generating Cli .." -ForegroundColor Green
autorest configuration.yaml --verbose
# Copy custom files
Write-Host "Copy custom files .." -ForegroundColor Green
cp custom/* generated/custom
# Build Module
Write-Host "Building generating Cli .." -ForegroundColor Green
.\generated\build-module.ps1
Write-Host "Generating Cli completed successfully .." -ForegroundColor Green