whet 0.0.34 → 0.1.1
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/bin/Reflect.d.ts +31 -12
- package/bin/Reflect.js +46 -19
- package/bin/commander/LiteralUnion.d.ts +2 -0
- package/bin/commander/OptionValueSource.d.ts +2 -1
- package/bin/commander/OutputConfiguration.d.ts +3 -0
- package/bin/genes/Register.d.ts +2 -0
- package/bin/genes/Register.js +15 -11
- package/bin/genes/util/EsMap.js +2 -1
- package/bin/haxe/Exception.js +6 -1
- package/bin/haxe/ValueException.js +3 -2
- package/bin/haxe/ds/List.js +7 -2
- package/bin/haxe/ds/ObjectMap.js +2 -2
- package/bin/haxe/ds/StringMap.js +2 -2
- package/bin/haxe/exceptions/NotImplementedException.js +2 -2
- package/bin/haxe/exceptions/PosException.js +3 -2
- package/bin/haxe/io/Bytes.js +3 -1
- package/bin/haxe/io/BytesBuffer.js +6 -1
- package/bin/haxe/io/BytesOutput.js +2 -1
- package/bin/haxe/io/Output.js +1 -0
- package/bin/haxe/iterators/ArrayIterator.js +3 -1
- package/bin/haxe/zip/Writer.js +3 -1
- package/bin/js/lib/ConcatArray.d.ts +6 -0
- package/bin/js/lib/IRegExp.d.ts +53 -0
- package/bin/js/lib/IterableIterator.d.ts +8 -0
- package/bin/js/lib/IteratorResult.d.ts +2 -0
- package/bin/js/lib/IteratorReturnResult.d.ts +5 -0
- package/bin/js/lib/IteratorYieldResult.d.ts +5 -0
- package/bin/js/lib/RegExpExecArray.d.ts +137 -0
- package/bin/minimatch/MMRegExp.d.ts +55 -0
- package/bin/minimatch/MinimatchOptions.d.ts +102 -0
- package/bin/minimatch/ParseReturn.d.ts +2 -0
- package/bin/minimatch/ParseReturnFiltered.d.ts +2 -0
- package/bin/minimatch/Platform.d.ts +2 -0
- package/bin/pino_pretty/PrettyOptions.d.ts +2 -2
- package/bin/pino_pretty/default_/MessageFormatFunc.d.ts +1 -2
- package/bin/pino_pretty/default_/Prettifier.d.ts +2 -0
- package/bin/pino_pretty/pinopretty/PrettyOptions.d.ts +118 -0
- package/bin/sys/FileStat.d.ts +50 -0
- package/bin/whet/ConfigStore.d.ts +32 -0
- package/bin/whet/ConfigStore.js +342 -0
- package/bin/whet/Project.d.ts +41 -4
- package/bin/whet/Project.js +191 -3
- package/bin/whet/Source.d.ts +7 -1
- package/bin/whet/Source.js +40 -3
- package/bin/whet/SourceHash.js +18 -10
- package/bin/whet/Stone.d.ts +60 -9
- package/bin/whet/Stone.js +180 -18
- package/bin/whet/Whet.d.ts +0 -1
- package/bin/whet/Whet.js +23 -12
- package/bin/whet/cache/BaseCache.d.ts +23 -0
- package/bin/whet/cache/BaseCache.js +93 -1
- package/bin/whet/cache/CacheManager.d.ts +2 -0
- package/bin/whet/cache/CacheManager.js +38 -2
- package/bin/whet/cache/FileCache.d.ts +10 -2
- package/bin/whet/cache/FileCache.js +144 -42
- package/bin/whet/cache/HashCache.js +2 -1
- package/bin/whet/cache/MemoryCache.d.ts +3 -0
- package/bin/whet/cache/MemoryCache.js +53 -2
- package/bin/whet/magic/MinimatchType.d.ts +1 -1
- package/bin/whet/magic/MinimatchType.js +3 -3
- package/bin/whet/magic/RoutePathType.js +1 -1
- package/bin/whet/route/OutputFilterMatcher.js +2 -2
- package/bin/whet/route/RouteResult.d.ts +16 -0
- package/bin/whet/route/RouteResult.js +37 -4
- package/bin/whet/route/Router.d.ts +27 -1
- package/bin/whet/route/Router.js +151 -40
- package/bin/whet/stones/Files.d.ts +6 -1
- package/bin/whet/stones/Files.js +3 -2
- package/bin/whet/stones/JsonStone.d.ts +6 -1
- package/bin/whet/stones/JsonStone.js +3 -2
- package/bin/whet/stones/RemoteFile.d.ts +7 -2
- package/bin/whet/stones/RemoteFile.js +7 -4
- package/bin/whet/stones/Zip.d.ts +6 -1
- package/bin/whet/stones/Zip.js +2 -2
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +7 -1
- package/bin/whet/stones/haxe/HaxeBuild.js +8 -6
- package/bin/whet/stones/haxe/Hxml.d.ts +7 -1
- package/bin/whet/stones/haxe/Hxml.js +7 -5
- package/bin/whet.d.ts +1 -2
- package/bin/whet.js +1 -1
- package/package.json +9 -10
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import {Router} from "./route/Router.js"
|
|
2
|
+
import {Utils} from "./Utils.js"
|
|
3
|
+
import {Stone} from "./Stone.js"
|
|
4
|
+
import * as Path from "path"
|
|
5
|
+
import {Register} from "../genes/Register.js"
|
|
6
|
+
import * as Fs from "fs"
|
|
7
|
+
import {Reflect as Reflect__1} from "../Reflect.js"
|
|
8
|
+
|
|
9
|
+
const $global = Register.$global
|
|
10
|
+
|
|
11
|
+
export const ConfigStore = Register.global("$hxClasses")["whet.ConfigStore"] =
|
|
12
|
+
class ConfigStore extends Register.inherits() {
|
|
13
|
+
[Register.new](path) {
|
|
14
|
+
this.appliedPatches = new WeakMap();
|
|
15
|
+
this.baselines = new WeakMap();
|
|
16
|
+
this.loadPromise = null;
|
|
17
|
+
this.size = null;
|
|
18
|
+
this.mtimeMs = null;
|
|
19
|
+
this.persistedData = null;
|
|
20
|
+
this.data = null;
|
|
21
|
+
this.path = path;
|
|
22
|
+
}
|
|
23
|
+
ensureApplied(stone) {
|
|
24
|
+
let _gthis = this;
|
|
25
|
+
return this.reload().then(function (_) {
|
|
26
|
+
if (!_gthis.baselines.has(stone)) {
|
|
27
|
+
_gthis.captureBaseline(stone);
|
|
28
|
+
};
|
|
29
|
+
let entry = _gthis.getEntry(stone);
|
|
30
|
+
let lastApplied = _gthis.appliedPatches.get(stone);
|
|
31
|
+
if (entry == lastApplied) {
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
if (entry != null && lastApplied != null && JSON.stringify(entry) == JSON.stringify(lastApplied)) {
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
_gthis.applyPatch(stone);
|
|
38
|
+
return null;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
setPatch(stone, patch) {
|
|
42
|
+
let _gthis = this;
|
|
43
|
+
return this.reload().then(function (_) {
|
|
44
|
+
if (_gthis.data == null) {
|
|
45
|
+
_gthis.data = {};
|
|
46
|
+
};
|
|
47
|
+
_gthis.data[stone.id] = patch;
|
|
48
|
+
return _gthis.writeFile();
|
|
49
|
+
}).then(function (_) {
|
|
50
|
+
_gthis.applyPatch(stone);
|
|
51
|
+
return null;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getEntryById(stoneId) {
|
|
55
|
+
if (this.data == null) {
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
return this.data[stoneId];
|
|
59
|
+
}
|
|
60
|
+
setEntry(stoneId, patch) {
|
|
61
|
+
if (this.data == null) {
|
|
62
|
+
this.data = {};
|
|
63
|
+
};
|
|
64
|
+
this.data[stoneId] = patch;
|
|
65
|
+
}
|
|
66
|
+
clearEntry(stoneId) {
|
|
67
|
+
if (this.data == null) {
|
|
68
|
+
return;
|
|
69
|
+
};
|
|
70
|
+
if (this.persistedData != null && Object.prototype.hasOwnProperty.call(this.persistedData, stoneId)) {
|
|
71
|
+
this.data[stoneId] = ConfigStore.deepClone(this.persistedData[stoneId]);
|
|
72
|
+
} else {
|
|
73
|
+
Reflect__1.deleteField(this.data, stoneId);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
flush() {
|
|
77
|
+
return this.writeFile();
|
|
78
|
+
}
|
|
79
|
+
isDirty(stoneId) {
|
|
80
|
+
if (stoneId != null) {
|
|
81
|
+
let current = (this.data != null) ? this.data[stoneId] : null;
|
|
82
|
+
let persisted = (this.persistedData != null) ? this.persistedData[stoneId] : null;
|
|
83
|
+
if (current == persisted) {
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
if (current == null || persisted == null) {
|
|
87
|
+
return true;
|
|
88
|
+
};
|
|
89
|
+
return JSON.stringify(current) != JSON.stringify(persisted);
|
|
90
|
+
};
|
|
91
|
+
return ((this.data != null) ? JSON.stringify(this.data) : "{}") != ((this.persistedData != null) ? JSON.stringify(this.persistedData) : "{}");
|
|
92
|
+
}
|
|
93
|
+
reload() {
|
|
94
|
+
if (this.loadPromise != null) {
|
|
95
|
+
return this.loadPromise;
|
|
96
|
+
};
|
|
97
|
+
let _gthis = this;
|
|
98
|
+
this.loadPromise = this.doReload().then(function (result) {
|
|
99
|
+
_gthis.loadPromise = null;
|
|
100
|
+
return result;
|
|
101
|
+
})["catch"](function (e) {
|
|
102
|
+
_gthis.loadPromise = null;
|
|
103
|
+
return Promise.reject(e);
|
|
104
|
+
});
|
|
105
|
+
return this.loadPromise;
|
|
106
|
+
}
|
|
107
|
+
doReload() {
|
|
108
|
+
let _gthis = this;
|
|
109
|
+
return this.statFile().then(function (stats) {
|
|
110
|
+
if (stats == null) {
|
|
111
|
+
if (_gthis.data == null) {
|
|
112
|
+
_gthis.data = {};
|
|
113
|
+
_gthis.persistedData = {};
|
|
114
|
+
};
|
|
115
|
+
return Promise.resolve(null);
|
|
116
|
+
};
|
|
117
|
+
let newMtime = stats.mtimeMs;
|
|
118
|
+
let newSize = stats.size;
|
|
119
|
+
if (newMtime == _gthis.mtimeMs && newSize == _gthis.size) {
|
|
120
|
+
return Promise.resolve(null);
|
|
121
|
+
};
|
|
122
|
+
return _gthis.readAndParse().then(function (_) {
|
|
123
|
+
_gthis.mtimeMs = newMtime;
|
|
124
|
+
_gthis.size = newSize;
|
|
125
|
+
return null;
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
statFile() {
|
|
130
|
+
let _gthis = this;
|
|
131
|
+
return new Promise(function (res, rej) {
|
|
132
|
+
Fs.stat(_gthis.path, function (err, stats) {
|
|
133
|
+
if (err != null) {
|
|
134
|
+
let code = err.code;
|
|
135
|
+
if (code == "ENOENT") {
|
|
136
|
+
res(null);
|
|
137
|
+
} else {
|
|
138
|
+
rej(err);
|
|
139
|
+
};
|
|
140
|
+
} else {
|
|
141
|
+
res(stats);
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
readAndParse() {
|
|
147
|
+
let _gthis = this;
|
|
148
|
+
return new Promise(function (res, rej) {
|
|
149
|
+
Fs.readFile(_gthis.path, {"encoding": "utf-8"}, function (err, content) {
|
|
150
|
+
if (err != null) {
|
|
151
|
+
rej(err);
|
|
152
|
+
} else {
|
|
153
|
+
_gthis.data = JSON.parse(content);
|
|
154
|
+
_gthis.persistedData = ConfigStore.deepClone(_gthis.data);
|
|
155
|
+
res(null);
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
writeFile() {
|
|
161
|
+
let _gthis = this;
|
|
162
|
+
return Utils.ensureDirExist(Path.dirname(this.path)).then(function (_) {
|
|
163
|
+
let content = JSON.stringify(_gthis.data, null, " ");
|
|
164
|
+
return new Promise(function (res, rej) {
|
|
165
|
+
Fs.writeFile(_gthis.path, content, function (err) {
|
|
166
|
+
if (err != null) {
|
|
167
|
+
rej(err);
|
|
168
|
+
} else {
|
|
169
|
+
Fs.stat(_gthis.path, function (err, stats) {
|
|
170
|
+
if (err != null) {
|
|
171
|
+
rej(err);
|
|
172
|
+
} else {
|
|
173
|
+
_gthis.mtimeMs = stats.mtimeMs;
|
|
174
|
+
_gthis.size = stats.size;
|
|
175
|
+
_gthis.persistedData = ConfigStore.deepClone(_gthis.data);
|
|
176
|
+
res(null);
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
getEntry(stone) {
|
|
185
|
+
if (this.data == null) {
|
|
186
|
+
return null;
|
|
187
|
+
};
|
|
188
|
+
return this.data[stone.id];
|
|
189
|
+
}
|
|
190
|
+
captureBaseline(stone) {
|
|
191
|
+
let baseline = {};
|
|
192
|
+
let configObj = stone.config;
|
|
193
|
+
let _g_keys = Reflect__1.fields(configObj);
|
|
194
|
+
let _g_index = 0;
|
|
195
|
+
while (_g_index < _g_keys.length) {
|
|
196
|
+
let key = _g_keys[_g_index++];
|
|
197
|
+
let _g_value = configObj[key];
|
|
198
|
+
if (ConfigStore.BASE_CONFIG_KEYS.includes(key)) {
|
|
199
|
+
continue;
|
|
200
|
+
};
|
|
201
|
+
if (ConfigStore.isJsonSerializable(_g_value)) {
|
|
202
|
+
baseline[key] = ConfigStore.deepClone(_g_value);
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
this.baselines.set(stone, baseline);
|
|
206
|
+
}
|
|
207
|
+
applyPatch(stone) {
|
|
208
|
+
let baseline = this.baselines.get(stone);
|
|
209
|
+
if (baseline == null) {
|
|
210
|
+
return;
|
|
211
|
+
};
|
|
212
|
+
let entry = this.getEntry(stone);
|
|
213
|
+
let configObj = stone.config;
|
|
214
|
+
let _g_keys = Reflect__1.fields(baseline);
|
|
215
|
+
let _g_index = 0;
|
|
216
|
+
while (_g_index < _g_keys.length) {
|
|
217
|
+
let key = _g_keys[_g_index++];
|
|
218
|
+
let _g_value = baseline[key];
|
|
219
|
+
if (entry != null && Object.prototype.hasOwnProperty.call(entry, key)) {
|
|
220
|
+
configObj[key] = ConfigStore.deepMerge(ConfigStore.deepClone(_g_value), entry[key]);
|
|
221
|
+
} else {
|
|
222
|
+
configObj[key] = ConfigStore.deepClone(_g_value);
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
if (entry != null) {
|
|
226
|
+
let _g_keys = Reflect__1.fields(entry);
|
|
227
|
+
let _g_index = 0;
|
|
228
|
+
while (_g_index < _g_keys.length) {
|
|
229
|
+
let key = _g_keys[_g_index++];
|
|
230
|
+
let _g_value = entry[key];
|
|
231
|
+
if (!Object.prototype.hasOwnProperty.call(baseline, key)) {
|
|
232
|
+
configObj[key] = ConfigStore.deepClone(_g_value);
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
let prevApplied = this.appliedPatches.get(stone);
|
|
237
|
+
if (prevApplied != null) {
|
|
238
|
+
let _g_keys = Reflect__1.fields(prevApplied);
|
|
239
|
+
let _g_index = 0;
|
|
240
|
+
while (_g_index < _g_keys.length) {
|
|
241
|
+
let key = _g_keys[_g_index++];
|
|
242
|
+
if (!Object.prototype.hasOwnProperty.call(baseline, key) && (entry == null || !Object.prototype.hasOwnProperty.call(entry, key))) {
|
|
243
|
+
Reflect__1.deleteField(configObj, key);
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
this.appliedPatches.set(stone, (entry != null) ? ConfigStore.deepClone(entry) : null);
|
|
248
|
+
}
|
|
249
|
+
static isJsonSerializable(val) {
|
|
250
|
+
if (val == null) {
|
|
251
|
+
return true;
|
|
252
|
+
};
|
|
253
|
+
if (((val) instanceof Stone)) {
|
|
254
|
+
return false;
|
|
255
|
+
};
|
|
256
|
+
if (((val) instanceof Router)) {
|
|
257
|
+
return false;
|
|
258
|
+
};
|
|
259
|
+
if (typeof val === "function") {
|
|
260
|
+
return false;
|
|
261
|
+
};
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
static deepClone(val) {
|
|
265
|
+
if (val == null) {
|
|
266
|
+
return null;
|
|
267
|
+
};
|
|
268
|
+
if (!ConfigStore.isJsonSerializable(val)) {
|
|
269
|
+
return null;
|
|
270
|
+
};
|
|
271
|
+
if (((val) instanceof Array)) {
|
|
272
|
+
let arr = val;
|
|
273
|
+
let result = new Array(arr.length);
|
|
274
|
+
let _g = 0;
|
|
275
|
+
let _g1 = arr.length;
|
|
276
|
+
while (_g < _g1) {
|
|
277
|
+
let i = _g++;
|
|
278
|
+
result[i] = ConfigStore.deepClone(arr[i]);
|
|
279
|
+
};
|
|
280
|
+
return result;
|
|
281
|
+
};
|
|
282
|
+
if (typeof val === "object") {
|
|
283
|
+
let obj = val;
|
|
284
|
+
let result = {};
|
|
285
|
+
let _g_keys = Reflect__1.fields(obj);
|
|
286
|
+
let _g_index = 0;
|
|
287
|
+
while (_g_index < _g_keys.length) {
|
|
288
|
+
let key = _g_keys[_g_index++];
|
|
289
|
+
result[key] = ConfigStore.deepClone(obj[key]);
|
|
290
|
+
};
|
|
291
|
+
return result;
|
|
292
|
+
};
|
|
293
|
+
return val;
|
|
294
|
+
}
|
|
295
|
+
static deepMerge(base, patch) {
|
|
296
|
+
if (patch == null) {
|
|
297
|
+
return null;
|
|
298
|
+
};
|
|
299
|
+
if (base == null) {
|
|
300
|
+
return ConfigStore.deepClone(patch);
|
|
301
|
+
};
|
|
302
|
+
if (((patch) instanceof Array)) {
|
|
303
|
+
return ConfigStore.deepClone(patch);
|
|
304
|
+
};
|
|
305
|
+
if (typeof patch === "object" && typeof base === "object" && !((base) instanceof Array)) {
|
|
306
|
+
let baseObj = base;
|
|
307
|
+
let patchObj = patch;
|
|
308
|
+
let result = {};
|
|
309
|
+
let _g_keys = Reflect__1.fields(baseObj);
|
|
310
|
+
let _g_index = 0;
|
|
311
|
+
while (_g_index < _g_keys.length) {
|
|
312
|
+
let key = _g_keys[_g_index++];
|
|
313
|
+
result[key] = baseObj[key];
|
|
314
|
+
};
|
|
315
|
+
let _g_keys1 = Reflect__1.fields(patchObj);
|
|
316
|
+
let _g_index1 = 0;
|
|
317
|
+
while (_g_index1 < _g_keys1.length) {
|
|
318
|
+
let key = _g_keys1[_g_index1++];
|
|
319
|
+
result[key] = ConfigStore.deepMerge(result[key], patchObj[key]);
|
|
320
|
+
};
|
|
321
|
+
return result;
|
|
322
|
+
};
|
|
323
|
+
return ConfigStore.deepClone(patch);
|
|
324
|
+
}
|
|
325
|
+
static get __name__() {
|
|
326
|
+
return "whet.ConfigStore"
|
|
327
|
+
}
|
|
328
|
+
get __class__() {
|
|
329
|
+
return ConfigStore
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
ConfigStore.prototype.path = null;
|
|
333
|
+
ConfigStore.prototype.data = null;
|
|
334
|
+
ConfigStore.prototype.persistedData = null;
|
|
335
|
+
ConfigStore.prototype.mtimeMs = null;
|
|
336
|
+
ConfigStore.prototype.size = null;
|
|
337
|
+
ConfigStore.prototype.loadPromise = null;
|
|
338
|
+
ConfigStore.prototype.baselines = null;
|
|
339
|
+
ConfigStore.prototype.appliedPatches = null;
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
ConfigStore.BASE_CONFIG_KEYS = ["cacheStrategy", "id", "project", "dependencies", "configStore"]
|
package/bin/whet/Project.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {CacheManager} from "./cache/CacheManager"
|
|
2
|
-
import {
|
|
2
|
+
import {CacheStrategy} from "./cache/Cache"
|
|
3
|
+
import {AnyStone, OutputFilter} from "./Stone"
|
|
4
|
+
import {Source} from "./Source"
|
|
5
|
+
import {ConfigStore} from "./ConfigStore"
|
|
3
6
|
import {Option, Command} from "commander"
|
|
4
7
|
|
|
5
8
|
export declare class Project {
|
|
@@ -9,6 +12,7 @@ export declare class Project {
|
|
|
9
12
|
description: string
|
|
10
13
|
rootDir: string
|
|
11
14
|
cache: CacheManager
|
|
15
|
+
configStore: ConfigStore
|
|
12
16
|
stones: AnyStone[]
|
|
13
17
|
onInit: (config: any) => Promise<any>
|
|
14
18
|
|
|
@@ -17,13 +21,26 @@ export declare class Project {
|
|
|
17
21
|
*/
|
|
18
22
|
config: any
|
|
19
23
|
protected options: Option[]
|
|
24
|
+
getStone(id: string): null | AnyStone
|
|
25
|
+
describeStones(): StoneDescription[]
|
|
26
|
+
listStoneOutputs(id: string): Promise<null | string[]>
|
|
27
|
+
getStoneSource(id: string, sourceId?: null | string): Promise<null | Source>
|
|
28
|
+
refreshStoneSource(id: string): Promise<null | Source>
|
|
29
|
+
getStoneConfig(id: string): Promise<null | StoneConfigView>
|
|
30
|
+
setStoneConfig(id: string, patch: any, mode: string): Promise<boolean>
|
|
31
|
+
clearStoneConfigPreview(id: string): Promise<boolean>
|
|
20
32
|
addCommand(name: string, stone?: null | AnyStone): Command
|
|
33
|
+
protected isCommandNameTaken(name: string): boolean
|
|
21
34
|
toString(): string
|
|
22
35
|
protected static projects: Project[]
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
export type ProjectConfig = {
|
|
26
39
|
cache?: null | CacheManager,
|
|
40
|
+
/**
|
|
41
|
+
Project-level ConfigStore, applies to any stone without an explicit configStore.
|
|
42
|
+
*/
|
|
43
|
+
configStore?: null | ConfigStore,
|
|
27
44
|
description?: null | string,
|
|
28
45
|
id?: null | string,
|
|
29
46
|
name: string,
|
|
@@ -31,11 +48,31 @@ export type ProjectConfig = {
|
|
|
31
48
|
* Called before first command is executed, but after configuration was parsed.
|
|
32
49
|
*/
|
|
33
50
|
onInit?: null | ((config: any) => Promise<any>),
|
|
34
|
-
/**
|
|
35
|
-
* Array of Commander.js options this project supports. Use `addOption` to get Option instance.
|
|
36
|
-
*/
|
|
37
51
|
options?: null | Option[],
|
|
38
52
|
rootDir?: null | string
|
|
39
53
|
}
|
|
40
54
|
|
|
55
|
+
export type StoneDescription = {
|
|
56
|
+
cacheStrategy?: null | CacheStrategy,
|
|
57
|
+
className: string,
|
|
58
|
+
id: string,
|
|
59
|
+
outputFilter?: null | OutputFilter
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type StoneConfigView = {
|
|
63
|
+
editable: any,
|
|
64
|
+
fixed: any,
|
|
65
|
+
id: string,
|
|
66
|
+
meta: StoneConfigMeta
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type StoneConfigMeta = {
|
|
70
|
+
cacheStrategy: CacheStrategy,
|
|
71
|
+
className: string,
|
|
72
|
+
dependencyIds: string[],
|
|
73
|
+
hasProjectConfigStore: boolean,
|
|
74
|
+
hasStoneConfigStore: boolean,
|
|
75
|
+
uiHints?: null | any
|
|
76
|
+
}
|
|
77
|
+
|
|
41
78
|
export const addOption: (flags: string, description: null | string) => Option
|
package/bin/whet/Project.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import {Router} from "./route/Router.js"
|
|
2
|
+
import {StoneId_Fields_} from "./magic/StoneId.js"
|
|
3
|
+
import {MaybeArray_Fields_} from "./magic/MaybeArray.js"
|
|
1
4
|
import {CacheManager} from "./cache/CacheManager.js"
|
|
2
5
|
import {Whet_Fields_} from "./Whet.js"
|
|
6
|
+
import {Stone} from "./Stone.js"
|
|
3
7
|
import {Log} from "./Log.js"
|
|
8
|
+
import {ConfigStore} from "./ConfigStore.js"
|
|
4
9
|
import * as Path from "path"
|
|
5
10
|
import {Register} from "../genes/Register.js"
|
|
6
11
|
import {Command, Option} from "commander"
|
|
7
12
|
import {StringTools} from "../StringTools.js"
|
|
13
|
+
import {Reflect as Reflect__1} from "../Reflect.js"
|
|
8
14
|
|
|
9
15
|
const $global = Register.$global
|
|
10
16
|
|
|
11
17
|
export const Project = Register.global("$hxClasses")["whet.Project"] =
|
|
12
18
|
class Project extends Register.inherits() {
|
|
13
|
-
new(config) {
|
|
19
|
+
[Register.new](config) {
|
|
14
20
|
this.stones = [];
|
|
21
|
+
this.configStore = null;
|
|
15
22
|
this.cache = null;
|
|
16
23
|
Log.log(20, ...["Instantiating new Project."]);
|
|
17
24
|
if (config == null || config.name == null) {
|
|
@@ -46,18 +53,189 @@ class Project extends Register.inherits() {
|
|
|
46
53
|
} else {
|
|
47
54
|
this.rootDir = config.rootDir;
|
|
48
55
|
};
|
|
56
|
+
this.configStore = config.configStore;
|
|
49
57
|
this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
|
|
50
58
|
Project.projects.push(this);
|
|
51
59
|
Log.log(30, ...["New project created.", {"project": this, "projectCount": Project.projects.length}]);
|
|
52
60
|
}
|
|
61
|
+
getStone(id) {
|
|
62
|
+
let _g = 0;
|
|
63
|
+
let _g1 = this.stones;
|
|
64
|
+
while (_g < _g1.length) {
|
|
65
|
+
let stone = _g1[_g];
|
|
66
|
+
++_g;
|
|
67
|
+
if (stone.id == id) {
|
|
68
|
+
return stone;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
describeStones() {
|
|
74
|
+
let _g = [];
|
|
75
|
+
let _g1 = 0;
|
|
76
|
+
let _g2 = this.stones;
|
|
77
|
+
while (_g1 < _g2.length) {
|
|
78
|
+
let stone = _g2[_g1];
|
|
79
|
+
++_g1;
|
|
80
|
+
_g.push({"id": stone.id, "className": StoneId_Fields_.getTypeName(stone), "outputFilter": stone.getOutputFilter(), "cacheStrategy": stone.cacheStrategy});
|
|
81
|
+
};
|
|
82
|
+
return _g;
|
|
83
|
+
}
|
|
84
|
+
listStoneOutputs(id) {
|
|
85
|
+
let stone = this.getStone(id);
|
|
86
|
+
if (stone == null) {
|
|
87
|
+
return Promise.resolve(null);
|
|
88
|
+
} else {
|
|
89
|
+
return stone.listIds();
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
getStoneSource(id, sourceId) {
|
|
93
|
+
let stone = this.getStone(id);
|
|
94
|
+
if (stone == null) {
|
|
95
|
+
return Promise.resolve(null);
|
|
96
|
+
} else if (sourceId != null) {
|
|
97
|
+
return stone.getPartialSource(sourceId);
|
|
98
|
+
} else {
|
|
99
|
+
return stone.getSource();
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
refreshStoneSource(id) {
|
|
103
|
+
let stone = this.getStone(id);
|
|
104
|
+
if (stone == null) {
|
|
105
|
+
return Promise.resolve(null);
|
|
106
|
+
} else {
|
|
107
|
+
return this.cache.refreshSource(stone);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
getStoneConfig(id) {
|
|
111
|
+
let stone = this.getStone(id);
|
|
112
|
+
if (stone == null) {
|
|
113
|
+
return Promise.resolve(null);
|
|
114
|
+
};
|
|
115
|
+
let tmp = stone.config.configStore;
|
|
116
|
+
let store = (tmp != null) ? tmp : this.configStore;
|
|
117
|
+
let init = (store != null) ? store.ensureApplied(stone) : Promise.resolve(null);
|
|
118
|
+
let _gthis = this;
|
|
119
|
+
return init.then(function (_) {
|
|
120
|
+
let editable = {};
|
|
121
|
+
let configObj = stone.config;
|
|
122
|
+
let _g_keys = Reflect__1.fields(configObj);
|
|
123
|
+
let _g_index = 0;
|
|
124
|
+
while (_g_index < _g_keys.length) {
|
|
125
|
+
let key = _g_keys[_g_index++];
|
|
126
|
+
let _g_value = configObj[key];
|
|
127
|
+
if (ConfigStore.BASE_CONFIG_KEYS.includes(key)) {
|
|
128
|
+
continue;
|
|
129
|
+
};
|
|
130
|
+
if (ConfigStore.isJsonSerializable(_g_value)) {
|
|
131
|
+
editable[key] = ConfigStore.deepClone(_g_value);
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
let depIds = [];
|
|
135
|
+
if (stone.config.dependencies != null) {
|
|
136
|
+
let deps = MaybeArray_Fields_.makeArray(stone.config.dependencies);
|
|
137
|
+
let _g = [];
|
|
138
|
+
let _g1 = 0;
|
|
139
|
+
while (_g1 < deps.length) _g.push(deps[_g1++].id);
|
|
140
|
+
depIds = _g;
|
|
141
|
+
};
|
|
142
|
+
let fixed = {};
|
|
143
|
+
let _g_keys1 = Reflect__1.fields(configObj);
|
|
144
|
+
let _g_index1 = 0;
|
|
145
|
+
while (_g_index1 < _g_keys1.length) {
|
|
146
|
+
let key = _g_keys1[_g_index1++];
|
|
147
|
+
let _g_value = configObj[key];
|
|
148
|
+
if (ConfigStore.BASE_CONFIG_KEYS.includes(key)) {
|
|
149
|
+
continue;
|
|
150
|
+
};
|
|
151
|
+
if (ConfigStore.isJsonSerializable(_g_value)) {
|
|
152
|
+
continue;
|
|
153
|
+
};
|
|
154
|
+
if (((_g_value) instanceof Stone)) {
|
|
155
|
+
fixed[key] = {"type": "stone", "stoneId": _g_value.id};
|
|
156
|
+
} else if (((_g_value) instanceof Router)) {
|
|
157
|
+
fixed[key] = {"type": "stones", "stoneIds": _g_value.collectStoneIds()};
|
|
158
|
+
} else if (((_g_value) instanceof Array)) {
|
|
159
|
+
let arr = _g_value;
|
|
160
|
+
if (arr.length > 0 && ((arr[0]) instanceof Stone)) {
|
|
161
|
+
let _g = [];
|
|
162
|
+
let _g1 = 0;
|
|
163
|
+
let _g2 = arr;
|
|
164
|
+
while (_g1 < _g2.length) _g.push(_g2[_g1++].id);
|
|
165
|
+
fixed[key] = {"type": "stones", "stoneIds": _g};
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
return {"id": stone.id, "editable": editable, "fixed": fixed, "meta": {"className": StoneId_Fields_.getTypeName(stone), "cacheStrategy": stone.cacheStrategy, "dependencyIds": depIds, "hasStoneConfigStore": stone.config.configStore != null, "hasProjectConfigStore": _gthis.configStore != null}};
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
setStoneConfig(id, patch, mode) {
|
|
173
|
+
let stone = this.getStone(id);
|
|
174
|
+
if (stone == null) {
|
|
175
|
+
return Promise.resolve(false);
|
|
176
|
+
};
|
|
177
|
+
let tmp = stone.config.configStore;
|
|
178
|
+
let store = (tmp != null) ? tmp : this.configStore;
|
|
179
|
+
if (store == null) {
|
|
180
|
+
return Promise.resolve(false);
|
|
181
|
+
};
|
|
182
|
+
store.setEntry(stone.id, patch);
|
|
183
|
+
if (mode == "persist") {
|
|
184
|
+
return store.flush().then(function (_) {
|
|
185
|
+
return true;
|
|
186
|
+
});
|
|
187
|
+
} else {
|
|
188
|
+
return Promise.resolve(true);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
clearStoneConfigPreview(id) {
|
|
192
|
+
let stone = this.getStone(id);
|
|
193
|
+
if (stone == null) {
|
|
194
|
+
return Promise.resolve(false);
|
|
195
|
+
};
|
|
196
|
+
let tmp = stone.config.configStore;
|
|
197
|
+
let store = (tmp != null) ? tmp : this.configStore;
|
|
198
|
+
if (store == null) {
|
|
199
|
+
return Promise.resolve(false);
|
|
200
|
+
};
|
|
201
|
+
store.clearEntry(stone.id);
|
|
202
|
+
return Promise.resolve(true);
|
|
203
|
+
}
|
|
53
204
|
addCommand(name, stone) {
|
|
54
|
-
let
|
|
205
|
+
let cmdName = name;
|
|
206
|
+
let cmdAlias = null;
|
|
55
207
|
if (stone != null) {
|
|
56
|
-
|
|
208
|
+
let alias = stone.id + "." + name;
|
|
209
|
+
if (this.isCommandNameTaken(name)) {
|
|
210
|
+
cmdName = alias;
|
|
211
|
+
} else {
|
|
212
|
+
cmdAlias = alias;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
let cmd = new Command(cmdName);
|
|
216
|
+
if (cmdAlias != null) {
|
|
217
|
+
cmd.alias(cmdAlias);
|
|
57
218
|
};
|
|
58
219
|
Whet_Fields_.program.addCommand(cmd);
|
|
59
220
|
return cmd;
|
|
60
221
|
}
|
|
222
|
+
isCommandNameTaken(name) {
|
|
223
|
+
let _g = 0;
|
|
224
|
+
let _g1 = Whet_Fields_.program.commands;
|
|
225
|
+
while (_g < _g1.length) {
|
|
226
|
+
let cmd = _g1[_g];
|
|
227
|
+
++_g;
|
|
228
|
+
if (cmd.name() == name) {
|
|
229
|
+
return true;
|
|
230
|
+
};
|
|
231
|
+
let _g2 = 0;
|
|
232
|
+
let _g3 = cmd.aliases();
|
|
233
|
+
while (_g2 < _g3.length) if (_g3[_g2++] == name) {
|
|
234
|
+
return true;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
61
239
|
toString() {
|
|
62
240
|
return "" + this.name + "@" + this.rootDir;
|
|
63
241
|
}
|
|
@@ -68,6 +246,16 @@ class Project extends Register.inherits() {
|
|
|
68
246
|
return Project
|
|
69
247
|
}
|
|
70
248
|
}
|
|
249
|
+
Project.prototype.name = null;
|
|
250
|
+
Project.prototype.id = null;
|
|
251
|
+
Project.prototype.description = null;
|
|
252
|
+
Project.prototype.rootDir = null;
|
|
253
|
+
Project.prototype.cache = null;
|
|
254
|
+
Project.prototype.configStore = null;
|
|
255
|
+
Project.prototype.stones = null;
|
|
256
|
+
Project.prototype.onInit = null;
|
|
257
|
+
Project.prototype.config = null;
|
|
258
|
+
Project.prototype.options = null;
|
|
71
259
|
|
|
72
260
|
|
|
73
261
|
Project.projects = []
|
package/bin/whet/Source.d.ts
CHANGED
|
@@ -4,12 +4,18 @@ import {SourceHash} from "./SourceHash"
|
|
|
4
4
|
import {Buffer} from "buffer"
|
|
5
5
|
|
|
6
6
|
export declare class Source {
|
|
7
|
-
protected constructor(data: SourceData[], hash: SourceHash, origin: AnyStone, ctime: number)
|
|
7
|
+
protected constructor(data: SourceData[], hash: SourceHash, origin: AnyStone, ctime: number, complete?: boolean)
|
|
8
8
|
data: SourceData[]
|
|
9
9
|
hash: SourceHash
|
|
10
10
|
origin: AnyStone
|
|
11
11
|
ctime: number
|
|
12
|
+
complete: boolean
|
|
12
13
|
protected dirPath: string
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
Filter to a single sourceId. Returns null if sourceId not found.
|
|
17
|
+
*/
|
|
18
|
+
filterTo(sourceId: string): null | Source
|
|
13
19
|
tryDirPath(): null | string
|
|
14
20
|
|
|
15
21
|
/**
|