-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.ps1
126 lines (124 loc) · 3.48 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
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
function SetupDependency()
{
$pwd = $PSScriptRoot
if ($args[1] -eq "--remove-services"){
if((Test-Path $pwd\packages\@alicloud\services)){
Remove-Item -Path "$pwd\packages\@alicloud\services" -Recurse
}
}
if((Test-Path $pwd\packages\@alicloud\test)){
Remove-Item -Path "$pwd\packages\@alicloud\test" -Recurse
}
lerna bootstrap
npm install
}
function ClearDependency()
{
lerna clean
}
function Build()
{
lerna run build
}
function GenerateTsConfig()
{
npm i -g jsii
$pwd = $PSScriptRoot
$tempdir="$pwd\temp"
if((Test-Path $tempdir)){
Remove-Item -Path "$tempdir" -Recurse
}
New-Item -Path "$tempdir" -Force -type directory
Write-Output "Collecting package list..."
node scripts\list-packages $tempdir\jsii.txt $tempdir\nonjsii.txt
foreach($line in Get-Content $tempdir\jsii.txt) {
Write-Output "run command ->$line"
cd $line
jsii
}
cd $pwd
Remove-Item -Path "$tempdir" -Recurse
}
function Spec2ts()
{
$pwd = $PSScriptRoot
$services_dir = "$pwd\packages\@alicloud\services"
if((Test-Path $services_dir)){
Remove-Item -Path "$services_dir" -Recurse
}
New-Item -Path "$services_dir" -Force -type directory
$code_gen_dir="$pwd\packages\ros-cdk-codegen"
cd $code_gen_dir
Remove-Item -Path .\generatedPackages -Recurse
if ($args[1] -eq "--generate-spec"){
npm run genspec
}
npm run spec2ts
cd $pwd
}
function JsiiPack()
{
npm i -g jsii-pacmak
$pwd = $PSScriptRoot
$tempdir="$pwd\temp"
$distdir="$pwd\dist"
$js_dir="$distdir\js"
$jsii_dir="$distdir\jsii"
if((Test-Path $tempdir)){
Remove-Item -Path "$tempdir" -Recurse
}
New-Item -Path "$tempdir" -Force -type directory
if((Test-Path $distdir)){
Remove-Item -Path "$distdir" -Recurse
}
New-Item -Path "$distdir" -Force -type directory
if((Test-Path $js_dir)){
Remove-Item -Path "$js_dir" -Recurse
}
if((Test-Path $jsii_dir)){
Remove-Item -Path "$jsii_dir" -Recurse
}
Write-Output "Collecting package list..."
node scripts\list-packages $tempdir\jsii.txt $tempdir\nonjsii.txt
Write-Output "Packaging jsii modules"
foreach($line in Get-Content $tempdir\jsii.txt) {
jsii-pacmak --verbose $line
}
cd "$pwd\packages"
foreach($file in get-childitem -Recurse -Include "dist" -ErrorAction Ignore| select-string -NotMatch "node_modules") {
copy-item -ErrorAction Ignore -r $file\ $pwd\
}
move-item -path "$js_dir" "$jsii_dir"
cd $pwd
}
function CopyJs()
{
$pwd = $PSScriptRoot
$dist_dir="$pwd\dist"
if((Test-Path !$dist_dir)){
exit
}
$js_dir="$dist_dir\js"
if((Test-Path $js_dir)){
Remove-Item -Path "$js_dir" -Recurse -ErrorAction Ignore
}
New-Item -Path "$js_dir" -Force -type directory
cd "$pwd\packages"
get-childitem -Recurse -Include "*.tgz" -ErrorAction Ignore |Remove-Item -Force
get-childitem -Recurse -Include ".jsii"| Remove-Item -Force
cd $pwd
lerna clean
lerna run pack
cd "$pwd\packages"
get-childitem -Recurse -Include "*.tgz" -ErrorAction Ignore |select-string -NotMatch "dist" | copy-item -Destination $js_dir
}
switch($args[0])
{
setup-dependency{SetupDependency}
clear-dependency{ClearDependency}
generate-tsconfig{GenerateTsConfig}
build{Build}
spec2ts{Spec2ts}
jsii-pack{JsiiPack}
copy-js{CopyJs}
}