| @@ -0,0 +1,14 | |||||
|
|
1 | { | |||
|
|
2 | "version": "0.2.0", | |||
|
|
3 | "configurations": [ | |||
|
|
4 | { | |||
|
|
5 | "name": "Launch browser tests", | |||
|
|
6 | "type": "node", | |||
|
|
7 | "request": "launch", | |||
|
|
8 | "program": "${workspaceFolder}/build/test/tests/index.js", | |||
|
|
9 | "cwd": "${workspaceFolder}/build/test", | |||
|
|
10 | "sourceMaps": true, | |||
|
|
11 | "preLaunchTask": "Build browser test" | |||
|
|
12 | } | |||
|
|
13 | ] | |||
|
|
14 | } No newline at end of file | |||
| @@ -0,0 +1,15 | |||||
|
|
1 | { | |||
|
|
2 | "version": "2.0.0", | |||
|
|
3 | "command": "./gradlew", | |||
|
|
4 | "type": "shell", | |||
|
|
5 | "tasks": [ | |||
|
|
6 | { | |||
|
|
7 | "label": "Build browser test", | |||
|
|
8 | "args": [ | |||
|
|
9 | "assembleTest", | |||
|
|
10 | "-Psymbols=local", | |||
|
|
11 | "-Pflavour=browser" | |||
|
|
12 | ] | |||
|
|
13 | } | |||
|
|
14 | ] | |||
|
|
15 | } No newline at end of file | |||
| @@ -4,18 +4,15 plugins { | |||||
| 4 | id "ivy-publish" |
|
4 | id "ivy-publish" | |
| 5 | } |
|
5 | } | |
| 6 |
|
6 | |||
| 7 | // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}*** |
|
7 | if (!symbols in ['local', 'pack', 'none']) | |
| 8 | // результатом будет версия '{num}.{distance}' где distance - расстояние от |
|
8 | throw new Exception("The symbols property value is invalid: $symbols"); | |
| 9 | // текущей ревизии до ревизии с тэгом |
|
9 | ||
| 10 | def tagDistance = 0; |
|
10 | if (!flavour in ['browser', 'node']) | |
|
|
11 | throw new Exception("The flavour property value is invalid: $flavour"); | |||
| 11 |
|
12 | |||
| 12 | ext { |
|
13 | ext { | |
| 13 | packageName = "@$npmScope/$name" |
|
14 | packageName = flavour == 'browser' ? "@$npmScope/$name-amd" : "@$npmScope/$name" | |
| 14 | lint = project.hasProperty('lint') ? lint : false |
|
15 | lint = project.hasProperty('lint') ? project.lint : false | |
| 15 | } |
|
|||
| 16 |
|
||||
| 17 | configurations { |
|
|||
| 18 |
|
||||
| 19 | } |
|
16 | } | |
| 20 |
|
17 | |||
| 21 | sources { |
|
18 | sources { | |
| @@ -52,41 +49,53 typescript { | |||||
| 52 | compilerOptions { |
|
49 | compilerOptions { | |
| 53 | types = [] |
|
50 | types = [] | |
| 54 | declaration = true |
|
51 | declaration = true | |
|
|
52 | ||||
|
|
53 | if(symbols != 'none') { | |||
| 55 | sourceMap = true |
|
54 | sourceMap = true | |
| 56 | sourceRoot = "_src" |
|
55 | sourceRoot = "_src" | |
| 57 | } |
|
56 | } | |
|
|
57 | ||||
|
|
58 | if (flavour == 'node') { | |||
|
|
59 | module = "commonjs" | |||
|
|
60 | target = "es2017" | |||
|
|
61 | lib = ["es2017", "dom", "scripthost"] | |||
|
|
62 | } else if (flavour == 'browser') { | |||
|
|
63 | module = "amd" | |||
|
|
64 | target = "es5" | |||
|
|
65 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable" ] | |||
|
|
66 | } | |||
|
|
67 | } | |||
| 58 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
68 | tscCmd = "$projectDir/node_modules/.bin/tsc" | |
| 59 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
|
69 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" | |
| 60 | esLintCmd = "$projectDir/node_modules/.bin/eslint" |
|
70 | esLintCmd = "$projectDir/node_modules/.bin/eslint" | |
| 61 | npmCmd = "npm" |
|
71 | npmCmd = "npm" | |
| 62 | } |
|
72 | } | |
| 63 |
|
73 | |||
| 64 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { |
|
|||
| 65 | dependsOn "prepare" |
|
|||
| 66 | } |
|
|||
| 67 |
|
||||
| 68 | tasks.matching{ it.name =~ /^lint/ }.configureEach { |
|
74 | tasks.matching{ it.name =~ /^lint/ }.configureEach { | |
| 69 | onlyIf { lint } |
|
75 | onlyIf { lint } | |
| 70 | } |
|
76 | } | |
| 71 |
|
77 | |||
| 72 | task prepare { |
|
78 | if (symbols == 'local') { | |
| 73 |
|
79 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { | ||
|
|
80 | compilerOptions { | |||
|
|
81 | sourceRoot = "file://" + it.rootDir | |||
|
|
82 | } | |||
|
|
83 | } | |||
| 74 | } |
|
84 | } | |
| 75 |
|
85 | |||
| 76 | task printVersion { |
|
86 | task printVersion { | |
| 77 | dependsOn prepare |
|
|||
| 78 |
|
||||
| 79 | doLast { |
|
87 | doLast { | |
|
|
88 | println "packageName: ${-> packageName}"; | |||
| 80 | println "version: ${-> version}"; |
|
89 | println "version: ${-> version}"; | |
| 81 |
println " |
|
90 | println "flavour: ${-> flavour}"; | |
| 82 | println "target: ${-> typescript.compilerOptions.target}"; |
|
91 | println "target: ${-> typescript.compilerOptions.target}"; | |
| 83 | println "module: ${-> typescript.compilerOptions.module}"; |
|
92 | println "module: ${-> typescript.compilerOptions.module}"; | |
|
|
93 | println "lint: ${-> lint}"; | |||
|
|
94 | println "symbols: ${-> symbols}"; | |||
| 84 | } |
|
95 | } | |
| 85 | } |
|
96 | } | |
| 86 |
|
97 | |||
| 87 | task clean { |
|
98 | task clean { | |
| 88 | prepare.mustRunAfter it |
|
|||
| 89 |
|
||||
| 90 | doLast { |
|
99 | doLast { | |
| 91 | delete buildDir |
|
100 | delete buildDir | |
| 92 | } |
|
101 | } | |
| @@ -118,112 +127,68 test { | |||||
| 118 | } |
|
127 | } | |
| 119 |
|
128 | |||
| 120 | assemble { |
|
129 | assemble { | |
| 121 | mustRunAfter sources.amd.output, |
|
130 | if (flavour == 'browser') { | |
| 122 |
sources. |
|
131 | dependsOn sources.amd.output | |
| 123 |
|
||||
| 124 | from sources.amd.output.compiledDir |
|
|||
| 125 | from sources.cjs.output.compiledDir |
|
|||
| 126 | } |
|
|||
| 127 |
|
||||
| 128 | assembleTest { |
|
|||
| 129 | mustRunAfter sources.amd.output, |
|
|||
| 130 | sources.cjs.output, |
|
|||
| 131 | sources.testAmd.output, |
|
|||
| 132 | sources.testCjs.output |
|
|||
| 133 |
|
||||
| 134 | from sources.amd.output.compiledDir |
|
132 | from sources.amd.output.compiledDir | |
|
|
133 | } | |||
|
|
134 | if (flavour == 'node') { | |||
|
|
135 | dependsOn sources.cjs.output | |||
| 135 | from sources.cjs.output.compiledDir |
|
136 | from sources.cjs.output.compiledDir | |
| 136 | from sources.testAmd.output.compiledDir |
|
|||
| 137 | from sources.testCjs.output.compiledDir |
|
|||
| 138 | } |
|
|||
| 139 |
|
||||
| 140 | task prepareLocalDebug { |
|
|||
| 141 | prepare.mustRunAfter it |
|
|||
| 142 |
|
||||
| 143 | doLast { |
|
|||
| 144 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { |
|
|||
| 145 | compilerOptions { |
|
|||
| 146 | sourceRoot = "file://" + it.rootDir |
|
|||
| 147 | } |
|
|||
| 148 | } |
|
|||
| 149 | } |
|
137 | } | |
| 150 | } |
|
138 | } | |
| 151 |
|
139 | |||
| 152 | task prepareNode { |
|
140 | assembleTest { | |
| 153 | prepare.mustRunAfter it |
|
141 | if (flavour == 'browser') { | |
|
|
142 | dependsOn sources.amd.output, sources.testAmd.output | |||
| 154 |
|
143 | |||
| 155 | doLast { |
|
144 | from sources.amd.output.compiledDir | |
| 156 | typescript { |
|
145 | from sources.testAmd.output.compiledDir | |
| 157 | compilerOptions { |
|
|||
| 158 | module = "commonjs" |
|
|||
| 159 | target = "es2017" |
|
|||
| 160 | lib = ["es2017", "dom", "scripthost"] |
|
|||
| 161 | } |
|
146 | } | |
| 162 | } |
|
147 | if (flavour == 'node') { | |
|
|
148 | dependsOn sources.cjs.output, sources.testCjs.output | |||
|
|
149 | ||||
|
|
150 | from sources.cjs.output.compiledDir | |||
|
|
151 | from sources.testCjs.output.compiledDir | |||
| 163 | } |
|
152 | } | |
| 164 | } |
|
153 | } | |
| 165 |
|
154 | |||
| 166 | task prepareBrowser { |
|
155 | task npmPackTypings(type: Copy) { | |
| 167 | prepare.mustRunAfter it |
|
156 | npmPack.dependsOn it | |
| 168 |
|
||||
| 169 | doLast { |
|
|||
| 170 | packageName = "@$npmScope/$project.name-amd" |
|
|||
| 171 |
|
||||
| 172 | typescript { |
|
|||
| 173 | compilerOptions { |
|
|||
| 174 | module = "amd" |
|
|||
| 175 | target = "es5" |
|
|||
| 176 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] |
|
|||
| 177 | } |
|
|||
| 178 | } |
|
|||
| 179 | } |
|
|||
| 180 | } |
|
|||
| 181 |
|
||||
| 182 | task npmPackTypingsAmd(type: Copy) { |
|
|||
| 183 | dependsOn sources.main.output |
|
157 | dependsOn sources.main.output | |
| 184 | dependsOn sources.amd.output |
|
|||
| 185 | npmPack.mustRunAfter it |
|
|||
| 186 |
|
158 | |||
| 187 | from sources.main.output.typingsDir |
|
159 | from sources.main.output.typingsDir | |
|
|
160 | ||||
|
|
161 | if (flavour == 'browser') { | |||
|
|
162 | dependsOn sources.amd.output | |||
| 188 | from sources.amd.output.typingsDir |
|
163 | from sources.amd.output.typingsDir | |
|
|
164 | } | |||
|
|
165 | if (flavour == 'node') { | |||
|
|
166 | dependsOn sources.cjs.output | |||
|
|
167 | from sources.cjs.output.typingsDir | |||
|
|
168 | } | |||
| 189 |
|
169 | |||
| 190 | into "${->buildDir}/npm/pack" |
|
170 | into "${->buildDir}/npm/pack" | |
| 191 | } |
|
171 | } | |
| 192 |
|
172 | |||
| 193 |
task npmPackSources |
|
173 | task npmPackSources(type: Copy) { | |
| 194 | from sources.main.ts |
|
174 | from sources.main.ts | |
|
|
175 | ||||
|
|
176 | if (flavour == 'browser') { | |||
| 195 | from sources.amd.ts |
|
177 | from sources.amd.ts | |
| 196 |
|
178 | } | ||
| 197 | npmPack.mustRunAfter it |
|
179 | if (flavour == 'node') { | |
|
|
180 | from sources.cjs.ts | |||
|
|
181 | } | |||
| 198 |
|
182 | |||
| 199 | into "${->buildDir}/npm/pack/_src" |
|
183 | into "${->buildDir}/npm/pack/_src" | |
| 200 | } |
|
184 | } | |
| 201 |
|
185 | |||
| 202 | task assembleBrowser { |
|
186 | if (symbols == 'pack') { | |
| 203 | dependsOn prepareBrowser, assemble, sources.amd.output |
|
187 | npmPack { | |
| 204 | } |
|
188 | dependsOn npmPackSources | |
| 205 |
|
||||
| 206 | task assembleNode { |
|
|||
| 207 | dependsOn prepareNode, assemble, sources.cjs.output |
|
|||
| 208 | } |
|
|||
| 209 |
|
||||
| 210 | task assembleTestBrowser { |
|
|||
| 211 | dependsOn prepareBrowser, prepareLocalDebug, assembleTest, sources.amd.output, sources.testAmd.output |
|
|||
| 212 | } |
|
189 | } | |
| 213 |
|
||||
| 214 | task testBrowser { |
|
|||
| 215 | dependsOn prepareBrowser, test, sources.amd.output, sources.testAmd.output |
|
|||
| 216 | } |
|
190 | } | |
| 217 |
|
191 | |||
| 218 | task testNode { |
|
|||
| 219 | dependsOn prepareNode, test, sources.cjs.output, sources.testCjs.output |
|
|||
| 220 | } |
|
|||
| 221 |
|
||||
| 222 | task npmPackBrowser { |
|
|||
| 223 | dependsOn assembleBrowser, npmPack, npmPackSourcesAmd, npmPackTypingsAmd |
|
|||
| 224 | } |
|
|||
| 225 |
|
||||
| 226 |
|
||||
| 227 | task packJsTar(type: Tar) { |
|
192 | task packJsTar(type: Tar) { | |
| 228 | dependsOn assemble; |
|
193 | dependsOn assemble; | |
| 229 |
|
194 | |||
| @@ -4,4 +4,6 author=Implab team | |||||
| 4 | description=Dependency injection, logging, simple and fast text processing tools |
|
4 | description=Dependency injection, logging, simple and fast text processing tools | |
| 5 | license=BSD-2-Clause |
|
5 | license=BSD-2-Clause | |
| 6 | repository=https://bitbucket.org/implab/implabjs-core |
|
6 | repository=https://bitbucket.org/implab/implabjs-core | |
| 7 | npmScope=implab No newline at end of file |
|
7 | npmScope=implab | |
|
|
8 | flavour=browser | |||
|
|
9 | symbols=pack No newline at end of file | |||
| @@ -4,7 +4,7 import { TraceSource } from "../log/Trac | |||||
| 4 | import m = require("module"); |
|
4 | import m = require("module"); | |
| 5 |
|
5 | |||
| 6 | const sandboxId = Uuid(); |
|
6 | const sandboxId = Uuid(); | |
| 7 | define(sandboxId, ["require"], r => r); |
|
7 | define(sandboxId, ["require"], (r: any) => r); | |
| 8 |
|
8 | |||
| 9 | const globalRequire = getGlobal().require as Require || requirejs; |
|
9 | const globalRequire = getGlobal().require as Require || requirejs; | |
| 10 |
|
10 | |||
General Comments 0
You need to be logged in to leave comments.
Login now
