| @@ -1,256 +1,293 | |||
|
|
1 | 1 | plugins { |
|
|
2 | 2 | id "org.implab.gradle-typescript" version "1.0.1-rc3" |
|
|
3 | id "ivy-publish" | |
|
|
3 | 4 | } |
|
|
4 | 5 | |
|
|
5 | 6 | // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}*** |
|
|
6 | 7 | // результатом будет версия '{num}.{distance}' где distance - расстояние от |
|
|
7 | 8 | // текущей ревизии до ревизии с тэгом |
|
|
8 | 9 | def tagDistance = 0; |
|
|
9 | 10 | |
|
|
10 | 11 | ext { |
|
|
11 | 12 | packageName = "@$npmScope/$name" |
|
|
12 | 13 | lint = project.hasProperty('lint') ? lint : false |
|
|
13 | 14 | } |
|
|
14 | 15 | |
|
|
15 | 16 | if (!version) { |
|
|
16 | 17 | |
|
|
17 | 18 | def rev = ["hg", "log", "-r", ".", "--template", "{latesttag('re:^v') % '{tag}-{distance}'}"].execute().text.trim(); |
|
|
18 | 19 | |
|
|
19 | 20 | def tagVersion; |
|
|
20 | 21 | |
|
|
21 | 22 | def match = (rev =~ /^v(\d+\.\d+\.\d+).*-(\d+)$/); |
|
|
22 | 23 | |
|
|
23 | 24 | if (match.size()) { |
|
|
24 | 25 | tagVersion = match[0][1]; |
|
|
25 | 26 | tagDistance = match[0][2].toInteger(); |
|
|
26 | 27 | } else { |
|
|
27 | 28 | throw new Exception("A version must be specied"); |
|
|
28 | 29 | } |
|
|
29 | 30 | |
|
|
30 | 31 | version = tagVersion; |
|
|
31 | 32 | |
|
|
32 | 33 | if (tagDistance > 0) |
|
|
33 | 34 | version++; |
|
|
34 | 35 | } else { |
|
|
35 | 36 | println "explicit version: $version"; |
|
|
36 | 37 | } |
|
|
37 | 38 | |
|
|
38 | 39 | if (hasProperty('versionSuffix') && versionSuffix) { |
|
|
39 | 40 | version += "-$versionSuffix" |
|
|
40 | 41 | } |
|
|
41 | 42 | |
|
|
43 | configurations { | |
|
|
44 | ||
|
|
45 | } | |
|
|
46 | ||
|
|
42 | 47 | sources { |
|
|
43 | 48 | amd { |
|
|
44 | 49 | typings { |
|
|
45 | 50 | srcDir main.output.typingsDir |
|
|
46 | 51 | } |
|
|
47 | 52 | } |
|
|
48 | 53 | |
|
|
49 | 54 | cjs { |
|
|
50 | 55 | typings { |
|
|
51 | 56 | srcDir main.output.typingsDir |
|
|
52 | 57 | } |
|
|
53 | 58 | } |
|
|
54 | 59 | |
|
|
55 | 60 | testAmd { |
|
|
56 | 61 | typings { |
|
|
57 | 62 | srcDir main.output.typingsDir |
|
|
58 | 63 | srcDir amd.output.typingsDir |
|
|
59 | 64 | srcDir test.output.typingsDir |
|
|
60 | 65 | } |
|
|
61 | 66 | } |
|
|
62 | 67 | |
|
|
63 | 68 | testCjs { |
|
|
64 | 69 | typings { |
|
|
65 | 70 | srcDir main.output.typingsDir |
|
|
66 | 71 | srcDir cjs.output.typingsDir |
|
|
67 | 72 | srcDir test.output.typingsDir |
|
|
68 | 73 | } |
|
|
69 | 74 | } |
|
|
70 | 75 | } |
|
|
71 | 76 | |
|
|
72 | 77 | typescript { |
|
|
73 | 78 | compilerOptions { |
|
|
74 | 79 | types = [] |
|
|
75 | 80 | declaration = true |
|
|
76 | 81 | } |
|
|
77 | 82 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
|
78 | 83 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
|
|
79 | 84 | esLintCmd = "$projectDir/node_modules/.bin/eslint" |
|
|
80 | 85 | npmCmd = "npm" |
|
|
81 | 86 | } |
|
|
82 | 87 | |
|
|
83 | 88 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { |
|
|
84 | 89 | dependsOn "prepare" |
|
|
85 | 90 | } |
|
|
86 | 91 | |
|
|
87 | 92 | tasks.matching{ it.name =~ /^lint/ }.configureEach { |
|
|
88 | 93 | onlyIf { lint } |
|
|
89 | 94 | } |
|
|
90 | 95 | |
|
|
91 | 96 | task prepare { |
|
|
92 | 97 | |
|
|
93 | 98 | } |
|
|
94 | 99 | |
|
|
95 | 100 | task printVersion { |
|
|
96 | 101 | dependsOn prepare |
|
|
97 | 102 | |
|
|
98 | 103 | doLast { |
|
|
99 | 104 | println "version: ${-> version}"; |
|
|
100 | 105 | println "tagDistance: ${-> tagDistance}"; |
|
|
101 | 106 | println "packageName: ${-> packageName}"; |
|
|
102 | 107 | println "target: ${-> typescript.compilerOptions.target}"; |
|
|
103 | 108 | println "module: ${-> typescript.compilerOptions.module}"; |
|
|
104 | 109 | } |
|
|
105 | 110 | } |
|
|
106 | 111 | |
|
|
107 | 112 | task clean { |
|
|
108 | 113 | prepare.mustRunAfter it |
|
|
109 | ||
|
|
114 | ||
|
|
110 | 115 | doLast { |
|
|
111 | 116 | delete buildDir |
|
|
112 | 117 | } |
|
|
113 | 118 | } |
|
|
114 | 119 | |
|
|
115 | 120 | npmPackMeta { |
|
|
116 | 121 | meta { |
|
|
117 | 122 | name = packageName |
|
|
118 | 123 | } |
|
|
119 | 124 | } |
|
|
120 | 125 | |
|
|
121 | 126 | configureTsCjs { |
|
|
122 | 127 | dependsOn sources.main.output |
|
|
123 | 128 | compilerOptions { |
|
|
124 | 129 | types += [ "node" ] |
|
|
125 | 130 | } |
|
|
126 | 131 | } |
|
|
127 | 132 | |
|
|
128 | 133 | configureTsAmd { |
|
|
129 | 134 | dependsOn sources.main.output |
|
|
130 | 135 | compilerOptions { |
|
|
131 | 136 | types += [ "requirejs", "dojo-typings" ] |
|
|
132 | 137 | } |
|
|
133 | 138 | } |
|
|
134 | 139 | |
|
|
135 | 140 | test { |
|
|
136 | 141 | workingDir layout.buildDirectory.dir("test"); |
|
|
137 | 142 | commandLine "node", "tests/index.js" |
|
|
138 | 143 | } |
|
|
139 | 144 | |
|
|
140 | 145 | task assembleAmd { |
|
|
141 | 146 | dependsOn sources.amd.output |
|
|
142 | 147 | assemble.mustRunAfter it |
|
|
143 | 148 | |
|
|
144 | 149 | doLast { |
|
|
145 | 150 | assemble { |
|
|
146 | 151 | from(sources.amd.output.compiledDir) |
|
|
147 | 152 | } |
|
|
148 | 153 | } |
|
|
149 | 154 | } |
|
|
150 | 155 | |
|
|
151 | 156 | task assembleCjs { |
|
|
152 | 157 | dependsOn sources.cjs.output |
|
|
153 | 158 | assemble.mustRunAfter it |
|
|
154 | 159 | |
|
|
155 | 160 | doLast { |
|
|
156 | 161 | assemble { |
|
|
157 | 162 | from(sources.cjs.output.compiledDir) |
|
|
158 | 163 | } |
|
|
159 | 164 | } |
|
|
160 | 165 | } |
|
|
161 | 166 | |
|
|
162 | 167 | task assembleTestAmd { |
|
|
163 | 168 | dependsOn sources.amd.output |
|
|
164 | 169 | dependsOn sources.testAmd.output |
|
|
165 | 170 | assembleTest.mustRunAfter it |
|
|
166 | 171 | |
|
|
167 | 172 | doLast { |
|
|
168 | 173 | assembleTest { |
|
|
169 | 174 | from(sources.amd.output.compiledDir) |
|
|
170 | 175 | from(sources.testAmd.output.compiledDir) |
|
|
171 | 176 | } |
|
|
172 | 177 | } |
|
|
173 | 178 | } |
|
|
174 | 179 | |
|
|
175 | 180 | task assembleTestCjs { |
|
|
176 | 181 | dependsOn sources.cjs.output |
|
|
177 | 182 | dependsOn sources.testCjs.output |
|
|
178 | 183 | assembleTest.mustRunAfter it |
|
|
179 | 184 | |
|
|
180 | 185 | doLast { |
|
|
181 | 186 | assembleTest { |
|
|
182 | 187 | from(sources.cjs.output.compiledDir) |
|
|
183 | 188 | from(sources.testCjs.output.compiledDir) |
|
|
184 | 189 | } |
|
|
185 | 190 | } |
|
|
186 | 191 | } |
|
|
187 | 192 | |
|
|
188 | 193 | task prepareTargetEs5 { |
|
|
189 | 194 | prepare.mustRunAfter it |
|
|
190 | 195 | |
|
|
191 | 196 | doLast { |
|
|
192 | 197 | typescript { |
|
|
193 | 198 | compilerOptions { |
|
|
194 | 199 | target = "es5" |
|
|
195 | 200 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] |
|
|
196 | 201 | } |
|
|
197 | 202 | } |
|
|
198 | 203 | } |
|
|
199 | 204 | } |
|
|
200 | 205 | |
|
|
201 | 206 | task prepareTargetEsNext { |
|
|
202 | 207 | prepare.mustRunAfter it |
|
|
203 | 208 | |
|
|
204 | 209 | doLast { |
|
|
205 | 210 | typescript { |
|
|
206 | 211 | compilerOptions { |
|
|
207 | 212 | target = "es2017" |
|
|
208 | 213 | lib = ["es2017", "dom", "scripthost"] |
|
|
209 | 214 | } |
|
|
210 | 215 | } |
|
|
211 | 216 | } |
|
|
212 | 217 | } |
|
|
213 | 218 | |
|
|
214 | 219 | task prepareNode { |
|
|
215 | 220 | dependsOn prepareTargetEsNext |
|
|
216 | 221 | prepare.mustRunAfter it |
|
|
217 | 222 | |
|
|
218 | 223 | doLast { |
|
|
219 | 224 | typescript { |
|
|
220 | 225 | compilerOptions { |
|
|
221 | 226 | module = "commonjs" |
|
|
222 | 227 | } |
|
|
223 | 228 | } |
|
|
224 | 229 | } |
|
|
225 | 230 | } |
|
|
226 | 231 | |
|
|
227 | 232 | task prepareBrowser { |
|
|
228 | 233 | dependsOn prepareTargetEs5 |
|
|
229 | 234 | prepare.mustRunAfter it |
|
|
230 | 235 | |
|
|
231 | 236 | doLast { |
|
|
232 | 237 | packageName = "@$npmScope/$project.name-amd" |
|
|
233 | 238 | |
|
|
234 | 239 | typescript { |
|
|
235 | 240 | compilerOptions { |
|
|
236 | 241 | module = "amd" |
|
|
237 | 242 | } |
|
|
238 | 243 | } |
|
|
239 | 244 | } |
|
|
240 | 245 | } |
|
|
241 | 246 | |
|
|
242 | 247 | task assembleBrowser { |
|
|
243 | 248 | dependsOn prepareBrowser, assembleAmd, assemble |
|
|
244 | 249 | } |
|
|
245 | 250 | |
|
|
246 | 251 | task assembleNode { |
|
|
247 | 252 | dependsOn prepareNode, assembleCjs, assemble |
|
|
248 | 253 | } |
|
|
249 | 254 | |
|
|
250 | 255 | task testBrowser { |
|
|
251 | 256 | dependsOn prepareBrowser, assembleTestAmd, test |
|
|
252 | 257 | } |
|
|
253 | 258 | |
|
|
254 | 259 | task testNode { |
|
|
255 | 260 | dependsOn prepareNode, assembleTestCjs, test |
|
|
261 | } | |
|
|
262 | ||
|
|
263 | task packJsTar(type: Tar) { | |
|
|
264 | dependsOn assemble; | |
|
|
265 | ||
|
|
266 | archiveBaseName = provider { packageName } | |
|
|
267 | ||
|
|
268 | destinationDirectory = buildDir | |
|
|
269 | archiveClassifier = provider { typescript.compilerOptions.module } | |
|
|
270 | compression = Compression.GZIP | |
|
|
271 | ||
|
|
272 | from(assemble.outputs) | |
|
|
273 | ||
|
|
274 | doLast { | |
|
|
275 | println archiveName; | |
|
|
276 | } | |
|
|
277 | } | |
|
|
278 | ||
|
|
279 | publishing { | |
|
|
280 | publications { | |
|
|
281 | local(IvyPublication) { | |
|
|
282 | artifact(packJsTar) { | |
|
|
283 | type = "js" | |
|
|
284 | } | |
|
|
285 | } | |
|
|
286 | } | |
|
|
287 | ||
|
|
288 | repositories { | |
|
|
289 | ivy { | |
|
|
290 | url "ivy-repo" | |
|
|
291 | } | |
|
|
292 | } | |
|
|
256 | 293 | } No newline at end of file |
| @@ -1,6 +1,7 | |||
|
|
1 | group=org.implab | |
|
|
1 | 2 | version= |
|
|
2 | 3 | author=Implab team |
|
|
3 |
description=Dependency injection, logging, simple and fast text |
|
|
|
4 | description=Dependency injection, logging, simple and fast text processing tools | |
|
|
4 | 5 | license=BSD-2-Clause |
|
|
5 | 6 | repository=https://bitbucket.org/implab/implabjs-core |
|
|
6 | 7 | npmScope=implab No newline at end of file |
| @@ -1,13 +1,9 | |||
|
|
1 | 1 | var rjs = require('requirejs'); |
|
|
2 | 2 | |
|
|
3 | 3 | rjs.config({ |
|
|
4 | 4 | baseUrl: '.', |
|
|
5 | packages: [{ | |
|
|
6 | name: "dojo", | |
|
|
7 | location: "node_modules/dojo" | |
|
|
8 | }], | |
|
|
9 | 5 | nodeRequire: require |
|
|
10 | 6 | }); |
|
|
11 | 7 | |
|
|
12 | 8 | |
|
|
13 | 9 | rjs(['./tests/plan']); No newline at end of file |
|
|
1 | NO CONTENT: file was removed |
|
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now
