-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-app.ps1
54 lines (43 loc) · 2 KB
/
publish-app.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
# Copyright (C) 2022 reallyread.it, inc.
#
# This file is part of Readup.
#
# Readup is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
#
# Readup is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License version 3 along with Foobar. If not, see <https://www.gnu.org/licenses/>.
$outputDir = 'bin/prod/app'
$publishDir = 'pub/app'
$packageDir = 'pkg/app'
Write-Host 'Checking version...'
$project = Get-Content package.json | ConvertFrom-Json
$version = $project.{it.reallyread}.version.app
$versionDir = "$packageDir/$version"
$archivePath = "$versionDir/app-$version.zip"
if (Test-Path $versionDir) {
Write-Error "Package version $version already exists." -ErrorAction Stop
}
Write-Host 'Cleaning...'
npx gulp clean:prod:app
Write-Host 'Building...'
npx gulp build:prod:app
if (-not (Test-Path $publishDir)) {
Write-Host 'Creating publish directory...'
New-Item $publishDir -ItemType Directory
}
Write-Host 'Cleaning publish directory...'
# added -Force because .well-known is a hidden file https://stackoverflow.com/a/25806947/4973029
Get-ChildItem $publishDir -Exclude node_modules | Remove-Item -Recurse -Force
Write-Host 'Copying program files to publish directory...'
Copy-Item -Path $outputDir/* -Destination $publishDir -Recurse
Write-Host 'Creating package directory...'
New-Item $versionDir -ItemType Directory
Write-Host 'Moving static bundles to package directory...'
Move-Item -Path $publishDir/client/bundle-$Version.* -Destination $versionDir
Write-Host 'Installing packages...'
Push-Location $publishDir
npm ci --production
Pop-Location
Write-Host "Creating archive at $archivePath..."
Compress-Archive -Path $publishDir/* -DestinationPath $archivePath