-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.ps1
73 lines (68 loc) · 2.16 KB
/
Build.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
# Creates a package for the chrome extension
[CmdletBinding()]
Param (
[switch]
$CreatePackage,
[switch]
$IgnoreExtension,
[switch]
$IgnoreSidePanel,
[switch]
$Development
)
# variables
$source = "unpacked"
$dist = "dist"
$filename = "bexio-chrome-extension.zip"
$destinationFile = "$dist/$filename"
$packageDirectorySource = Join-Path $PWD.path $source
$packageDirectoryDestination = $PWD.path + "/$destinationFile"
if ($Development) {
$buildTask = "build:dev"
}
else {
$buildTask = "build"
}
# Build bexio chrome extension
if (!$IgnoreExtension) {
try {
npm run $buildTask -w @bexio-chrome-extension/chrome-extension
Write-Host "OK Bexio chrome extension successfully built" -ForegroundColor Green
}
catch {
Write-Host "An error occurred while attempting to build bexio-chrome-extension" -ForegroundColor Red
}
}
# Build sidePanel import app
if (!$IgnoreSidePanel) {
try {
npm run $buildTask -w @bexio-chrome-extension/side-panel-import
Write-Host "OK sidePanel import app successfully built" -ForegroundColor Green
}
catch {
Write-Host "An error occurred while attempting to build sidePanel import app" -ForegroundColor Red
}
}
# build the package
if ($CreatePackage) {
Write-Host ""
Write-Host "Creating extension package..."
try {
# create dist folder
if (-not(Test-Path -Path $dist)) {
New-Item -ItemType Directory -Path $dist -Force
Write-Host "OK Creating dist folder" -ForegroundColor Green
}
# zip folder
Compress-Archive -Path $packageDirectorySource -DestinationPath $packageDirectoryDestination -Force
Write-Host "OK Package built at: $packageDirectoryDestination" -ForegroundColor Green
Write-Host ""
# Open a specific webpage
Start-Process "https://chrome.google.com/u/1/webstore/devconsole/7ec9c1b5-988c-4cef-84b5-50b85d0fb0d0/nbmjdligmcfaeebdihmgbdpahdfddlhm/edit/package?hl=de"
# Open explorer with the dist folder containing the package
Invoke-Item -Path "./dist"
}
catch {
Write-Host "FAILED " -ForegroundColor Red
}
}