##// END OF EJS Templates
Move to org.implab.gradle-typescript
cin -
r87:dc13057a3f8d ts-plugin
parent child
Show More
@@ -1,3 +1,7
1 plugins {
2 id "org.implab.gradle-typescript" version "1.0-SNAPSHOT"
3 }
4
1 5 // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}***
2 6 // результатом будет версия '{num}.{distance}' где distance - расстояние от
3 7 // текущей ревизии до ревизии с тэгом
@@ -46,90 +50,34 if(!["es3", "es5", "es6", "es2016", "es2
46 50 throw new Exception("Invalid target specified: $target")
47 51
48 52 def targetLibs = [
49 "es3" : "es5,es2015.promise,es2015.symbol,dom,scripthost",
50 "es5" : "es5,es2015.promise,es2015.symbol,dom,scripthost"
53 "es3" : ["es5", "es2015.promise", "es2015.symbol", "dom", "scripthost"],
54 "es5" : ["es5", "es2015.promise", "es2015.symbol", "dom", "scripthost"]
51 55 ];
52 56
53 ext.packageName="@$npmScope/$npmName";
57 ext {
58 packageName = "@$npmScope/$npmName"
59 }
54 60
55 61 def srcDir = "$projectDir/src"
56 62 def typingsDir = "$srcDir/typings"
57 63 def distDir = "$buildDir/dist"
58 64 def testDir = "$buildDir/test"
59 def lib = targetLibs[target] ?: "${target},dom";
60
61 println "lib: $lib";
65 def jstarget = target;
62 66
63 def sourceSets = ["main", "amd", "cjs"];
64 def testSets = ["test", "testAmd", "testCjs"];
67 sources {
65 68
66 task beforeBuild {
67 69 }
68 70
69 def createSoursetTasks = { String name, String outDir ->
70 def setName = name.capitalize();
71
72 def compileDir = "$buildDir/compile/$name"
73 def declDir = "$typingsDir/$name"
74 def setDir = "$projectDir/src/$name"
75 def jsDir = outDir;
76
77 def beforeBuildTask = task "beforeBuild$setName"(dependsOn: beforeBuild) {
78 }
79
80 def copyJsTask = task "copyJs$setName"(dependsOn: beforeBuildTask, type: Copy) {
81 from "$setDir/js"
82 into jsDir
83 }
84
85 def lintJsTask = task "lintJs$setName"(dependsOn: beforeBuildTask, type: Exec) {
86 inputs.dir("$setDir/js/").skipWhenEmpty();
87 commandLine "eslint", '--format', 'stylish', "$setDir/js/"
71 typescript {
72 compilerOptions {
73 lib = targetLibs[target] ?: [target, "dom"]
74 target = jstarget
75 module = jsmodule
76 types = []
88 77 }
89
90 def compileTsTask = task "compileTs$setName"(dependsOn: beforeBuildTask, type: Exec) {
91 inputs.dir("$setDir/ts").skipWhenEmpty()
92 inputs.file("$srcDir/tsconfig.json")
93 inputs.file("$setDir/tsconfig.json")
94 outputs.dir(compileDir)
95 outputs.dir(declDir)
96
97 commandLine 'node_modules/.bin/tsc',
98 '-p', "$setDir/tsconfig.json",
99 '-t', target,
100 '-m', jsmodule,
101 '-d',
102 '--sourceMap',
103 '--sourceRoot', "file://$setDir/ts",
104 '--outDir', compileDir,
105 '--declarationDir', declDir
106
107 if (lib)
108 args '--lib', lib
109 }
110
111 def copyTsOutputTask = task "copyTsOutput$setName"(dependsOn: compileTsTask, type: Copy) {
112 from compileDir
113 into jsDir
114 }
115
116 def copyTypingsTask = task "copyTypings$setName"(dependsOn: compileTsTask, type: Copy) {
117 from declDir
118 into jsDir
119 }
120
121 def copyResourcesTask = task "copyResources$setName"(dependsOn: beforeBuildTask, type: Copy) {
122 from "$setDir/resources"
123 into outDir
124 }
125
126 task "build$setName" {
127 dependsOn copyTypingsTask,
128 copyTsOutputTask,
129 copyJsTask,
130 copyResourcesTask,
131 lintJsTask
132 }
78 tsLintCmd = "tslint"
79 esLintCmd = "eslint"
80 npmCmd = "npm"
133 81 }
134 82
135 83 task printVersion {
@@ -167,58 +115,7 task _initBuild {
167 115 }
168 116 }
169 117
170 task cleanNpm {
171 doLast {
172 delete 'node_modules'
173 }
174 }
175
176 task _npmInstall() {
177 inputs.file("package.json")
178 outputs.dir("node_modules")
179 doLast {
180 exec {
181 commandLine 'npm', 'install'
182 }
183 }
184 }
185
186 beforeBuild {
187 dependsOn _initBuild
188 dependsOn _npmInstall
189 }
190
191 sourceSets.each { createSoursetTasks(it, distDir) }
192
193 testSets.each { createSoursetTasks(it, testDir) }
194
195 compileTsAmd {
196 dependsOn compileTsMain
197 }
198
199 compileTsCjs {
200 dependsOn compileTsMain
201 }
202
203 task build(dependsOn: buildMain) {
204 if (jsmodule == "amd")
205 dependsOn buildAmd
206 if (jsmodule == "commonjs")
207 dependsOn buildCjs
208 }
209
210 compileTsTest {
211 dependsOn build
212 }
213
214 compileTsTestAmd {
215 dependsOn compileTsTest
216 }
217
218 compileTsTestCjs {
219 dependsOn compileTsTest
220 }
221
118 /*
222 119 task _installLocalCjsDependency(dependsOn: [buildTestCjs, "_packageMeta"], type: Exec) {
223 120 inputs.file("$distDir/package.json")
224 121 outputs.upToDateWhen {
@@ -230,7 +127,7 task _installLocalCjsDependency(dependsO
230 127 commandLine 'npm', 'install', '--no-save', '--force', distDir
231 128 }
232 129
233 task test(dependsOn: [buildTest], type: Exec) {
130 task _test(dependsOn: [buildTest], type: Exec) {
234 131 if (jsmodule == "amd")
235 132 dependsOn buildTestAmd
236 133 if (jsmodule == "commonjs") {
@@ -240,37 +137,7 task test(dependsOn: [buildTest], type:
240 137
241 138 commandLine 'node', "$testDir/run-tests.js"
242 139 }
243
244 task _packageMeta(type: Copy) {
245 mustRunAfter build
246
247 inputs.property("version", version)
248 from('.') {
249 include '.npmignore', 'readme.md', 'license', 'history.md'
250 }
251 from("$srcDir/package.${jsmodule}.tmpl.json") {
252 expand project.properties
253 rename { "package.json" }
254 }
255 into distDir
256 }
257
258 task pack(dependsOn: [build, _packageMeta], type: Exec) {
259 workingDir distDir
260 outputs.file("$npmScope-$npmName-${version}.tgz")
261
262 commandLine 'npm', 'pack'
263 }
264
265 task publish(dependsOn: [build, _packageMeta], type: Exec) {
266 doFirst {
267 if (!isRelease)
268 throw new Exception("Can't publish an unreleased version");
269 }
270 workingDir distDir
271
272 commandLine 'npm', 'publish', '--access', 'public'
273 }
140 */
274 141
275 142 task markRelease(type: Exec) {
276 143 onlyIf { tagDistance > 1 }
@@ -1,5 +1,5
1 1 distributionBase=GRADLE_USER_HOME
2 2 distributionPath=wrapper/dists
3 distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
3 distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
4 4 zipStoreBase=GRADLE_USER_HOME
5 5 zipStorePath=wrapper/dists
@@ -90,7 +90,7
90 90 },
91 91 "duplexer": {
92 92 "version": "0.1.1",
93 "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
93 "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
94 94 "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
95 95 "dev": true
96 96 },
@@ -144,7 +144,7
144 144 "dependencies": {
145 145 "tape": {
146 146 "version": "2.3.3",
147 "resolved": "https://registry.npmjs.org/tape/-/tape-2.3.3.tgz",
147 "resolved": "http://registry.npmjs.org/tape/-/tape-2.3.3.tgz",
148 148 "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=",
149 149 "dev": true,
150 150 "requires": {
@@ -277,7 +277,7
277 277 },
278 278 "minimist": {
279 279 "version": "0.0.5",
280 "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
280 "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
281 281 "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=",
282 282 "dev": true
283 283 },
@@ -316,7 +316,7
316 316 },
317 317 "readable-stream": {
318 318 "version": "1.1.14",
319 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
319 "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
320 320 "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
321 321 "dev": true,
322 322 "requires": {
@@ -369,7 +369,7
369 369 },
370 370 "string_decoder": {
371 371 "version": "0.10.31",
372 "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
372 "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
373 373 "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
374 374 "dev": true
375 375 },
@@ -432,7 +432,7
432 432 },
433 433 "through2": {
434 434 "version": "0.2.3",
435 "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
435 "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
436 436 "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=",
437 437 "dev": true,
438 438 "requires": {
@@ -1,5 +1,6
1 1 {
2 2 "extends": "tslint:recommended",
3 "defaultSeverity": "warn",
3 4 "rules": {
4 5 "align": [
5 6 true,
General Comments 0
You need to be logged in to leave comments. Login now