whet 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/bin/HxOverrides.d.ts +0 -1
- package/bin/HxOverrides.js +0 -7
- package/bin/haxe/Exception.d.ts +1 -0
- package/bin/haxe/Exception.js +9 -0
- package/bin/whet/Project.js +4 -25
- package/bin/whet/Source.d.ts +3 -2
- package/bin/whet/Source.js +15 -38
- package/bin/whet/SourceId.d.ts +17 -5
- package/bin/whet/SourceId.js +93 -68
- package/bin/whet/Stone.d.ts +11 -0
- package/bin/whet/Stone.js +52 -26
- package/bin/whet/Whet.js +12 -2
- package/bin/whet/cache/BaseCache.js +70 -85
- package/bin/whet/cache/CacheManager.js +18 -37
- package/bin/whet/cache/FileCache.js +28 -146
- package/bin/whet/magic/RoutePathType.js +8 -45
- package/bin/whet/route/Router.js +43 -136
- package/bin/whet/stones/Files.d.ts +1 -0
- package/bin/whet/stones/Files.js +56 -24
- package/bin/whet/stones/JsonStone.d.ts +2 -2
- package/bin/whet/stones/JsonStone.js +6 -13
- package/bin/whet/stones/RemoteFile.js +1 -10
- package/bin/whet/stones/Server.js +9 -52
- package/bin/whet/stones/Zip.d.ts +2 -2
- package/bin/whet/stones/Zip.js +4 -26
- package/bin/whet/stones/haxe/HaxeBuild.js +6 -35
- package/bin/whet/stones/haxe/Hxml.js +21 -67
- package/bin/whet.d.ts +1 -0
- package/bin/whet.js +1 -0
- package/package.json +1 -1
|
@@ -9,7 +9,6 @@ import * as Path from "path"
|
|
|
9
9
|
import {Register} from "../../../genes/Register.js"
|
|
10
10
|
import * as ChildProcess from "child_process"
|
|
11
11
|
import {StringTools} from "../../../StringTools.js"
|
|
12
|
-
import {HxOverrides} from "../../../HxOverrides.js"
|
|
13
12
|
|
|
14
13
|
const $global = Register.$global
|
|
15
14
|
|
|
@@ -31,20 +30,7 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
31
30
|
var _gthis = this;
|
|
32
31
|
Log.log(30, ...["Building Haxe project."]);
|
|
33
32
|
return new Promise(function (res, rej) {
|
|
34
|
-
var cwd = process.cwd();
|
|
35
|
-
var this1 = _gthis.project.rootDir;
|
|
36
|
-
var s = "/";
|
|
37
|
-
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
38
|
-
if (str.length > 0) {
|
|
39
|
-
str = Path.posix.normalize(str);
|
|
40
|
-
str = StringTools.replace(str, "\\", "/");
|
|
41
|
-
};
|
|
42
|
-
s = str;
|
|
43
|
-
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
44
|
-
if (this1.charAt(0) != "/") {
|
|
45
|
-
throw new Error("Badly formed SourceId.");
|
|
46
|
-
};
|
|
47
|
-
var cwd1 = Path.join(cwd, Path.posix.join(".", root, ".", this1));
|
|
33
|
+
var cwd = Path.join(process.cwd(), Path.posix.join(".", "./", ".", _gthis.project.rootDir));
|
|
48
34
|
var _g = [];
|
|
49
35
|
var e = Register.iter(_gthis.config.hxml.getBuildArgs());
|
|
50
36
|
while (e.hasNext()) {
|
|
@@ -59,7 +45,7 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
59
45
|
var i = _g1++;
|
|
60
46
|
result[i] = StringTools.replace(_g[i], "\"", "\\\"");
|
|
61
47
|
};
|
|
62
|
-
ChildProcess.exec(result.join(" "), {"cwd":
|
|
48
|
+
ChildProcess.exec(result.join(" "), {"cwd": cwd, "windowsHide": true}, function (err, stdout, stderr) {
|
|
63
49
|
if (err != null) {
|
|
64
50
|
var haxeError = new Error(stderr);
|
|
65
51
|
haxeError.name = "Haxe Build Error";
|
|
@@ -75,15 +61,12 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
75
61
|
var _gthis = this;
|
|
76
62
|
if (this.config.hxml.isSingleFile()) {
|
|
77
63
|
var pathId = this.config.hxml.getBuildExportPath();
|
|
78
|
-
var
|
|
79
|
-
if (pathId.charAt(0) != "/") {
|
|
80
|
-
throw new Error("Badly formed SourceId.");
|
|
81
|
-
};
|
|
82
|
-
var path = Path.posix.join(".", root, ".", pathId);
|
|
64
|
+
var path = Path.posix.join(".", RootDir.fromProject(this.project), ".", pathId);
|
|
83
65
|
return Utils.deleteAll(path).then(function (_) {
|
|
84
66
|
return _gthis.build();
|
|
85
67
|
}).then(function (_) {
|
|
86
|
-
|
|
68
|
+
var id = pathId;
|
|
69
|
+
return SourceData.fromFile(id.substring(id.lastIndexOf("/") + 1), path, pathId).then(function (file) {
|
|
87
70
|
return [file];
|
|
88
71
|
});
|
|
89
72
|
});
|
|
@@ -111,19 +94,7 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
111
94
|
var _g1 = _this.length;
|
|
112
95
|
while (_g < _g1) {
|
|
113
96
|
var i = _g++;
|
|
114
|
-
|
|
115
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
116
|
-
if (str.length > 0) {
|
|
117
|
-
str = Path.posix.normalize(str);
|
|
118
|
-
str = StringTools.replace(str, "\\", "/");
|
|
119
|
-
};
|
|
120
|
-
s = str;
|
|
121
|
-
var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
122
|
-
var root = RootDir.fromProject(this.config.hxml.project);
|
|
123
|
-
if (this1.charAt(0) != "/") {
|
|
124
|
-
throw new Error("Badly formed SourceId.");
|
|
125
|
-
};
|
|
126
|
-
result[i] = Path.posix.join(".", root, ".", this1);
|
|
97
|
+
result[i] = Path.posix.join(".", RootDir.fromProject(this.config.hxml.project), ".", _this[i]);
|
|
127
98
|
};
|
|
128
99
|
return Promise.all([this.config.hxml.getHash(), SourceHash.fromFiles(result)]).then(function (r) {
|
|
129
100
|
return SourceHash.merge(...r);
|
|
@@ -3,14 +3,11 @@ import {StoneId_Fields_} from "../../magic/StoneId.js"
|
|
|
3
3
|
import {MaybeArray_Fields_} from "../../magic/MaybeArray.js"
|
|
4
4
|
import {CacheStrategy, CacheDurability} from "../../cache/Cache.js"
|
|
5
5
|
import {Stone} from "../../Stone.js"
|
|
6
|
-
import {SourceId} from "../../SourceId.js"
|
|
7
6
|
import {SourceHash} from "../../SourceHash.js"
|
|
8
7
|
import {SourceData} from "../../Source.js"
|
|
9
8
|
import {Log} from "../../Log.js"
|
|
10
9
|
import * as Path from "path"
|
|
11
10
|
import {Register} from "../../../genes/Register.js"
|
|
12
|
-
import {StringTools} from "../../../StringTools.js"
|
|
13
|
-
import {HxOverrides} from "../../../HxOverrides.js"
|
|
14
11
|
|
|
15
12
|
const $global = Register.$global
|
|
16
13
|
|
|
@@ -139,46 +136,26 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
139
136
|
getBuildExportPath() {
|
|
140
137
|
var dir = this.project.cache.getDir(this.build, this.generateHashSync());
|
|
141
138
|
if (this.isSingleFile()) {
|
|
142
|
-
|
|
139
|
+
var id = this.getBuildFilename();
|
|
140
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
141
|
+
throw new Error("\"" + dir + "\" is not a directory.");
|
|
142
|
+
};
|
|
143
|
+
return Path.posix.join(dir, id);
|
|
143
144
|
} else {
|
|
144
145
|
return dir;
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
getBuildFilename() {
|
|
148
149
|
if (this.isSingleFile()) {
|
|
149
|
-
var filename;
|
|
150
|
-
if (this.build.config.filename != null) {
|
|
151
|
-
var s = this.build.config.filename;
|
|
152
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
153
|
-
if (str.length > 0) {
|
|
154
|
-
str = Path.posix.normalize(str);
|
|
155
|
-
str = StringTools.replace(str, "\\", "/");
|
|
156
|
-
};
|
|
157
|
-
s = str;
|
|
158
|
-
filename = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
159
|
-
} else {
|
|
160
|
-
var s = "build";
|
|
161
|
-
var str = ("build".length > 1 && HxOverrides.cca("build", 0) == 47) ? "build".substring(1) : "build";
|
|
162
|
-
if (str.length > 0) {
|
|
163
|
-
str = Path.posix.normalize(str);
|
|
164
|
-
str = StringTools.replace(str, "\\", "/");
|
|
165
|
-
};
|
|
166
|
-
s = str;
|
|
167
|
-
filename = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
168
|
-
};
|
|
150
|
+
var filename = (this.build.config.filename != null) ? this.build.config.filename : "build";
|
|
169
151
|
if (Path.posix.extname(filename) == "") {
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
152
|
+
var id = filename;
|
|
153
|
+
var ext = this.getBuildExtension();
|
|
154
|
+
if (ext.length > 0 && ext.charCodeAt(0) != 46) {
|
|
155
|
+
ext = "." + ext;
|
|
173
156
|
};
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
if (str.length > 0) {
|
|
177
|
-
str = Path.posix.normalize(str);
|
|
178
|
-
str = StringTools.replace(str, "\\", "/");
|
|
179
|
-
};
|
|
180
|
-
s = str;
|
|
181
|
-
filename = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s) + Path.posix.parse(filename.substring(filename.lastIndexOf("/"))).name + v;
|
|
157
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
158
|
+
filename = Path.posix.join((dir.length == 0) ? "./" : dir, Path.posix.parse(id).name) + ext;
|
|
182
159
|
};
|
|
183
160
|
return filename;
|
|
184
161
|
} else {
|
|
@@ -186,19 +163,8 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
186
163
|
};
|
|
187
164
|
}
|
|
188
165
|
getPlatform() {
|
|
189
|
-
var
|
|
190
|
-
var
|
|
191
|
-
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
192
|
-
if (str.length > 0) {
|
|
193
|
-
str = Path.posix.normalize(str);
|
|
194
|
-
str = StringTools.replace(str, "\\", "/");
|
|
195
|
-
};
|
|
196
|
-
s = str;
|
|
197
|
-
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
198
|
-
if (this1.charAt(0) != "/") {
|
|
199
|
-
throw new Error("Badly formed SourceId.");
|
|
200
|
-
};
|
|
201
|
-
var path = Path.posix.join(".", root, ".", this1);
|
|
166
|
+
var id = this.getBuildExportPath();
|
|
167
|
+
var path = Path.posix.join(".", "./", ".", id);
|
|
202
168
|
var _g = this.config.platform;
|
|
203
169
|
if (_g == null) {
|
|
204
170
|
return [];
|
|
@@ -297,27 +263,15 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
297
263
|
return Promise.resolve([this.filename()]);
|
|
298
264
|
}
|
|
299
265
|
filename() {
|
|
300
|
-
var
|
|
301
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
302
|
-
if (str.length > 0) {
|
|
303
|
-
str = Path.posix.normalize(str);
|
|
304
|
-
str = StringTools.replace(str, "\\", "/");
|
|
305
|
-
};
|
|
306
|
-
s = str;
|
|
307
|
-
var fn = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
266
|
+
var fn = this.id;
|
|
308
267
|
if (Path.posix.extname(fn) == "") {
|
|
309
|
-
var
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
var s = fn.substring(0, fn.lastIndexOf("/") + 1);
|
|
314
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
315
|
-
if (str.length > 0) {
|
|
316
|
-
str = Path.posix.normalize(str);
|
|
317
|
-
str = StringTools.replace(str, "\\", "/");
|
|
268
|
+
var id = fn;
|
|
269
|
+
var ext = "hxml";
|
|
270
|
+
if ("hxml".length > 0 && ext.charCodeAt(0) != 46) {
|
|
271
|
+
ext = "." + ext;
|
|
318
272
|
};
|
|
319
|
-
|
|
320
|
-
fn = ((
|
|
273
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
274
|
+
fn = Path.posix.join((dir.length == 0) ? "./" : dir, Path.posix.parse(id).name) + ext;
|
|
321
275
|
};
|
|
322
276
|
return fn;
|
|
323
277
|
}
|
package/bin/whet.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export {Project} from "./whet/Project"
|
|
|
13
13
|
export {Log} from "./whet/Log"
|
|
14
14
|
export {JsonStoneConfig} from "./whet/stones/JsonStone"
|
|
15
15
|
export {JsonStone} from "./whet/stones/JsonStone"
|
|
16
|
+
export {IdUtils} from "./whet/SourceId"
|
|
16
17
|
export {HxmlConfig} from "./whet/stones/haxe/Hxml"
|
|
17
18
|
export {Hxml} from "./whet/stones/haxe/Hxml"
|
|
18
19
|
export {HaxeBuild} from "./whet/stones/haxe/HaxeBuild"
|
package/bin/whet.js
CHANGED
|
@@ -15,6 +15,7 @@ export {RemoteFile} from "./whet/stones/RemoteFile.js"
|
|
|
15
15
|
export {Project} from "./whet/Project.js"
|
|
16
16
|
export {Log} from "./whet/Log.js"
|
|
17
17
|
export {JsonStone} from "./whet/stones/JsonStone.js"
|
|
18
|
+
export {IdUtils} from "./whet/SourceId.js"
|
|
18
19
|
export {Hxml} from "./whet/stones/haxe/Hxml.js"
|
|
19
20
|
export {HaxeBuild} from "./whet/stones/haxe/HaxeBuild.js"
|
|
20
21
|
export {Files} from "./whet/stones/Files.js"
|