-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinitialize.ps1
164 lines (146 loc) · 5.46 KB
/
initialize.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Set error action preference to stop on error
$ErrorActionPreference = "Stop"
#
# Note: We remove package-lock.json everywhere and npm install everywhere (instead of using npm ci as done for linux),
# because npm has issues installing some optional dependency (for rollup)...
#
# This is the bug, but seems they are not very fast in fixing it...
# https://github.com/npm/cli/issues/4828
#
function NativeCommand {
Param($Cmd)
Invoke-Expression "$Cmd"
if ($LASTEXITCODE -ne 0) {
Write-Host "Command '$Cmd' failed"
Exit
}
}
# Removing all node_modules directories and dist directories
Write-Host "Removing all node_modules directories and dist directories..."
Remove-Item -Path "core\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "core\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "category-style\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "category-style\package-lock.json"-Force -ErrorAction SilentlyContinue
Remove-Item -Path "category-style\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "log4ts-style\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "log4ts-style\package-lock.json" -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "log4ts-style\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "node-channel\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "node-channel\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "node-channel\package-lock.json" -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\rollup\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\rollup\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\rollup\package-lock.json" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\webpack\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\webpack\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\webpack\package-lock.json" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\node-channel\node_modules" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\node-channel\dist" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\node-channel\package-lock.json" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "tests-integration\node-channel\k6" -Recurse -Force -ErrorAction SilentlyContinue
# Installing packages for core
Write-Host "Installing packages for core..."
Push-Location core
try {
NativeCommand "npm unlink -g"
NativeCommand "npm link"
NativeCommand "npm ci"
# Building core
Write-Host "Building core..."
NativeCommand "npm run build"
}
finally {
Pop-Location
}
# Installing packages for category-style
Write-Host "Installing packages for category-style..."
Push-Location category-style
try {
NativeCommand "npm link typescript-logging"
NativeCommand "npm install"
# Building category-style
Write-Host "Building category-style..."
NativeCommand "npm run build"
}
finally {
Pop-Location
}
# Installing packages for log4ts-style
Write-Host "Installing packages for log4ts-style..."
Push-Location log4ts-style
try {
NativeCommand "npm link typescript-logging"
NativeCommand "npm install"
# Building log4ts-style
Write-Host "Building log4ts-style..."
NativeCommand "npm run build"
}
finally {
Pop-Location
}
# Installing packages for node-channel
Write-Host "Installing packages for node-channel..."
Push-Location node-channel
try {
NativeCommand "npm link typescript-logging"
NativeCommand "npm install"
# Building node-channel
Write-Host "Building node-channel..."
NativeCommand "npm run build"
}
finally {
Pop-Location
}
# Installing packages for tests-integration/rollup
Write-Host "Installing packages for tests-integration/rollup"
Push-Location tests-integration/rollup
try {
NativeCommand "npm install"
Write-Host "Building tests-integration/rollup..."
NativeCommand "npm run build"
}
finally {
Pop-Location
}
# Installing packages for tests-integration/webpack
Write-Host "Installing packages for tests-integration/webpack"
Push-Location tests-integration/webpack
try {
NativeCommand "npm install"
Write-Host "Building tests-integration/webpack..."
NativeCommand "npm run build"
}
finally {
Pop-Location
}
# Setting up k6 for tests-integration/node-channel
Push-Location tests-integration/node-channel
try {
Write-Host "Downloading and putting k6 in node-channel/k6 directory..."
mkdir -Force k6\tmp
Push-Location k6\tmp
try {
Invoke-WebRequest -Uri "https://github.com/grafana/k6/releases/download/v0.50.0/k6-v0.50.0-windows-amd64.zip" -OutFile "k6.zip"
Expand-Archive -Path "k6.zip" -DestinationPath .\ -Force
# Remove the first folder from the extracted files
$extractedFolder = Get-ChildItem -Path .\ | Select-Object -First 1
Move-Item -Path ".\$($extractedFolder.Name)\*" -Destination ..
}
finally {
Pop-Location
}
}
finally {
Pop-Location
}
# Installing packages for tests-integration/node-channel
Write-Host "Installing packages for tests-integration/node-channel"
Push-Location tests-integration/node-channel
try {
NativeCommand "npm install"
Write-Host "Building tests-integration/node-channel..."
NativeCommand "npm run build-win"
}
finally {
Pop-Location
}