forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_utils.xml
123 lines (95 loc) · 4.8 KB
/
node_utils.xml
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
<project name="Node.js utils" xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="common.xml" optional="false"/>
<!-- Expected that these properties will be overridden by system properties -->
<property name="kotlin.deploy.version" value="0.0.0"/>
<property name="kotlin.compiler.deploy.version" value="0.0.0"/>
<property name="kotlin.npmjs.auth.token" value="AUTH"/>
<property name="node.version" value="v6.3.1"/>
<property name="node.dir" value="${dependencies}/node"/>
<property name="node.executable" value="${node.dir}/bin/node"/>
<target name="download-nodejs-and-npm" depends="make-dependency-dirs">
<property name="linux-x86" value="linux-x86"/>
<property name="platform" value="win-x86" if:set="isWindows"/>
<property name="platform" value="darwin-x64" if:set="isMac"/>
<property name="platform" value="${linux-x86}" if:set="isLinux"/>
<property name="node.tar.gz" value="${dependencies}/download/node.tar.gz"/>
<property name="node.exe" value="${node.executable}.exe"/>
<property name="node.name.prefix" value="${platform}" unless:set="isWindows"/>
<property name="node.name.prefix" value="${linux-x86}" if:set="isWindows"/>
<property name="node.full.name" value="node-${node.version}-${node.name.prefix}"/>
<property name="url.node.tar.gz" value="https://nodejs.org/dist/${node.version}/${node.full.name}.tar.gz"/>
<property name="url.node.exe" value="https://nodejs.org/dist/${node.version}/${platform}/node.exe"/>
<get src="${url.node.tar.gz}" dest="${node.tar.gz}" usetimestamp="true"/>
<exec executable="tar" unless:set="isWindows">
<arg value="-zxf"/>
<arg path="${node.tar.gz}"/>
<arg value="-C"/>
<arg path="${dependencies}"/>
</exec>
<untar src="${node.tar.gz}" dest="${dependencies}" compression="gzip" if:set="isWindows"/>
<move file="${dependencies}/${node.full.name}" tofile="${dependencies}/node"/>
<delete dir="${dependencies}/${node.full.name}"/>
<delete file="${node.tar.gz}"/>
<sequential if:set="isWindows">
<get src="${url.node.exe}" dest="${node.exe}" usetimestamp="true"/>
</sequential>
</target>
<macrodef name="node">
<attribute name="dir" default="."/>
<attribute name="failonerror" default="true"/>
<element name="args" implicit="true"/>
<sequential>
<exec executable="${node.executable}" dir="@{dir}" failonerror="@{failonerror}">
<args/>
</exec>
</sequential>
</macrodef>
<macrodef name="npm">
<attribute name="command"/>
<attribute name="dir" default="."/>
<attribute name="failonerror" default="true"/>
<element name="args" optional="true" implicit="true"/>
<sequential>
<node dir="@{dir}" failonerror="@{failonerror}">
<arg file="${node.dir}/lib/node_modules/npm/bin/npm-cli.js"/>
<arg value="@{command}"/>
<args/>
</node>
</sequential>
</macrodef>
<macrodef name="publish-to-npm">
<attribute name="template"/>
<attribute name="version"/>
<element name="actions" optional="true" implicit="true"/>
<sequential>
<property name="deploy_to_npm_dir" value="${output}/deploy_to_npm"/>
<property name="package_deploy_dir" value="${deploy_to_npm_dir}/@{template}"/>
<delete dir="${deploy_to_npm_dir}"/>
<mkdir dir="${deploy_to_npm_dir}"/>
<copy todir="${package_deploy_dir}">
<fileset dir="js/npm.templates/@{template}"/>
</copy>
<actions/>
<npm command="version" dir="${package_deploy_dir}">
<arg value="@{version}"/>
</npm>
<npm command="publish" dir="${package_deploy_dir}">
<arg value="--//registry.npmjs.org/:_authToken=${kotlin.npmjs.auth.token}"/>
</npm>
</sequential>
</macrodef>
<target name="publish-kotlin-js-to-npm">
<publish-to-npm template="kotlin" version="${kotlin.deploy.version}">
<copy file="${js.stdlib.output.dir}/kotlin.js" todir="${package_deploy_dir}" failonerror="true" />
<copy file="${js.stdlib.output.dir}/kotlin.meta.js" todir="${package_deploy_dir}" failonerror="true" />
</publish-to-npm>
</target>
<target name="publish-kotlin-compiler-to-npm">
<publish-to-npm template="kotlin-compiler" version="${kotlin.compiler.deploy.version}">
</publish-to-npm>
</target>
<!-- Used on TeamCity-->
<target name="unzip-jslib.jar">
<unzip src="${output}/kotlinc/lib/kotlin-jslib.jar" dest="${js.stdlib.output.dir}"/>
</target>
</project>