This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.ps1
88 lines (65 loc) · 2.5 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Get last commit hash and date
$commitComment = "// " + (git log --pretty=format:"%h - %ad" -1 --date=short)
# Initialise paths
$path = $MyInvocation.MyCommand.Path
$parentDir = $path.Remove($path.LastIndexOf("\"))
$cmplPath = "C:\google-closure\compiler.jar"
$srcPath = $parentDir + "\src\"
$bldPath = $parentDir + "\build\"
# Minify embed.js
Write-Host "---- minify embed.js ---- `n"
$embedSrc = $srcPath + "js\embed.js"
$embedBuild = $bldPath + "embed.min.js"
New-Item $embedBuild -type file -force | out-null
$minifiedResult = java -jar $cmplPath --js $embedSrc
$minifiedResult = $commitComment + "`n" + $minifiedResult
Add-Content $embedBuild $minifiedResult
Write-Host "complete `n"
# Combine timeline scripts
Write-Host "---- combine scripts ---- `n"
$combinedPath = $bldPath + "wellcomeTimeline.js"
$minifiedPath = $bldPath + "wellcomeTimeline.min.js"
New-Item $combinedPath -type file -force | out-null
New-Item $minifiedPath -type file -force | out-null
$files = @()
$files += $srcPath + "js\julianDateConverter.js"
$files += $srcPath + "js\jquery.plugins.js"
$files += $srcPath + "js\utils.js"
$files += $srcPath + "js\baseProvider.js"
$files += $srcPath + "js\wellcomeTimelineProvider.js"
$files += $srcPath + "js\baseTimeline.js"
$files += $srcPath + "js\wellcomeTimeline.js"
$files += $srcPath + "js\timeline.js"
$files += $srcPath + "js\shell.js"
$files += $srcPath + "js\headerPanelView.js"
$files += $srcPath + "js\mainPanelView.js"
$files += $srcPath + "js\footerPanelView.js"
$files += $srcPath + "js\baseDialogueView.js"
$files += $srcPath + "js\genericDialogueView.js"
$files += $srcPath + "js\embedView.js"
$files += $srcPath + "js\detailsView.js"
Add-Content $combinedPath $commitComment
foreach($file in $files){
$item = Get-Item $file
$fileContent = Get-Content $item
Add-Content $combinedPath $fileContent
Write-Host $file
}
Write-Host "`r"
Write-Host "complete `n"
# Minify combined timeline scripts
Write-Host "---- minify combined scripts ---- `n"
$minifiedResult = java -jar $cmplPath --js $combinedPath
$minifiedResult = $commitComment + "`n" + $minifiedResult
Add-Content $minifiedPath $minifiedResult
Write-Host "complete `n"
# Minify any further third party scripts (optional)
Write-Host "---- minify third-party scripts ---- `n"
$libs = @()
$libs += $srcPath + "js\libs\iscroll.js"
foreach($lib in $libs){
$i =$lib.LastIndexOf(".js")
$minifiedName = $lib.Remove($i) + ".min.js"
java -jar $cmplPath --js $lib --js_output_file $minifiedName
}
Write-Host "build complete `n"