whet 0.0.29 → 0.0.31
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/whet/SourceHash.d.ts
CHANGED
|
@@ -15,6 +15,20 @@ export declare class SourceHash {
|
|
|
15
15
|
static fromFiles(paths: MaybeArray<string>, filter?: null | ((arg0: string) => boolean), recursive?: boolean): Promise<SourceHash>
|
|
16
16
|
static fromBytes(data: Buffer): SourceHash
|
|
17
17
|
static fromString(data: string): SourceHash
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Converts `obj` to string via JSON.stringify, defaults to 'null' if undefined to prevent
|
|
21
|
+
* errors. The string is then converted to hash. See also `fromConfig`.
|
|
22
|
+
*/
|
|
23
|
+
static fromStringify(obj: any): SourceHash
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Convert a Stone config into hash by ignoring the base `StoneConfig` fields
|
|
27
|
+
* and anything inside `ignoreList`, getting hash of `Stone` and `Router` instances,
|
|
28
|
+
* and applying `fromStringify` on the rest.
|
|
29
|
+
* Only checks keys at root level, no deep inspection is done.
|
|
30
|
+
*/
|
|
31
|
+
static fromConfig(obj: {[key: string]: any}, ignoreList?: null | string[]): Promise<SourceHash>
|
|
18
32
|
static equals(a: SourceHash, b: SourceHash): boolean
|
|
19
33
|
static toHex(hash: SourceHash): string
|
|
20
34
|
static fromHex(hex: string): SourceHash
|
package/bin/whet/SourceHash.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {Router} from "./route/Router.js"
|
|
1
2
|
import {MaybeArray_Fields_} from "./magic/MaybeArray.js"
|
|
2
3
|
import {Utils} from "./Utils.js"
|
|
4
|
+
import {Stone} from "./Stone.js"
|
|
3
5
|
import {Register} from "../genes/Register.js"
|
|
4
6
|
import * as Fs from "fs"
|
|
5
7
|
import * as Crypto from "crypto"
|
|
6
8
|
import {Buffer} from "buffer"
|
|
9
|
+
import {Reflect as Reflect__1} from "../Reflect.js"
|
|
7
10
|
|
|
8
11
|
const $global = Register.$global
|
|
9
12
|
|
|
@@ -115,6 +118,50 @@ class SourceHash extends Register.inherits() {
|
|
|
115
118
|
static fromString(data) {
|
|
116
119
|
return SourceHash.fromBytes(Buffer.from(data));
|
|
117
120
|
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Converts `obj` to string via JSON.stringify, defaults to 'null' if undefined to prevent
|
|
124
|
+
* errors. The string is then converted to hash. See also `fromConfig`.
|
|
125
|
+
*/
|
|
126
|
+
static fromStringify(obj) {
|
|
127
|
+
let tmp = JSON.stringify(obj);
|
|
128
|
+
return SourceHash.fromBytes(Buffer.from((tmp != null) ? tmp : "null"));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Convert a Stone config into hash by ignoring the base `StoneConfig` fields
|
|
133
|
+
* and anything inside `ignoreList`, getting hash of `Stone` and `Router` instances,
|
|
134
|
+
* and applying `fromStringify` on the rest.
|
|
135
|
+
* Only checks keys at root level, no deep inspection is done.
|
|
136
|
+
*/
|
|
137
|
+
static fromConfig(obj, ignoreList) {
|
|
138
|
+
let keys = [];
|
|
139
|
+
let _g = [];
|
|
140
|
+
let _g_keys = Reflect__1.fields(obj);
|
|
141
|
+
let _g_index = 0;
|
|
142
|
+
while (_g_index < _g_keys.length) {
|
|
143
|
+
let key = _g_keys[_g_index++];
|
|
144
|
+
let _g_value = obj[key];
|
|
145
|
+
let tmp;
|
|
146
|
+
switch (key) {
|
|
147
|
+
case "cacheStrategy":case "dependencies":case "id":case "project":
|
|
148
|
+
continue;
|
|
149
|
+
break
|
|
150
|
+
default:
|
|
151
|
+
if (ignoreList != null && ignoreList.includes(key)) {
|
|
152
|
+
continue;
|
|
153
|
+
} else {
|
|
154
|
+
keys.push(key);
|
|
155
|
+
tmp = (((_g_value) instanceof Stone)) ? _g_value.getHash() : (((_g_value) instanceof Router)) ? _g_value.getHash() : SourceHash.fromStringify(_g_value);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
};
|
|
159
|
+
_g.push(tmp);
|
|
160
|
+
};
|
|
161
|
+
return Promise.all(_g).then(function (hashes) {
|
|
162
|
+
return SourceHash.merge(...hashes);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
118
165
|
static equals(a, b) {
|
|
119
166
|
if (a != null && b != null) {
|
|
120
167
|
return a.bytes.compare(b.bytes) == 0;
|
|
@@ -156,8 +203,8 @@ class SourceHash extends Register.inherits() {
|
|
|
156
203
|
}
|
|
157
204
|
|
|
158
205
|
|
|
159
|
-
SourceHash
|
|
206
|
+
Register.createStatic(SourceHash, "EMPTY", function () { return (function($this) {var $r0
|
|
160
207
|
let bytes = Buffer.alloc(32);
|
|
161
208
|
|
|
162
209
|
$r0 = new SourceHash(bytes)
|
|
163
|
-
return $r0})(this)
|
|
210
|
+
return $r0})(this) })
|
package/bin/whet/Whet.js
CHANGED
|
@@ -12,7 +12,7 @@ const $global = Register.$global
|
|
|
12
12
|
export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
|
|
13
13
|
class Whet_Fields_ {
|
|
14
14
|
static main() {
|
|
15
|
-
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.
|
|
15
|
+
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.31", "-v, --version").allowUnknownOption(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info").option("--no-pretty", "disable pretty logging").exitOverride();
|
|
16
16
|
try {
|
|
17
17
|
Whet_Fields_.program.parse();
|
|
18
18
|
}catch (_g) {
|
|
@@ -14,7 +14,7 @@ import {HxOverrides} from "../../HxOverrides.js"
|
|
|
14
14
|
const $global = Register.$global
|
|
15
15
|
|
|
16
16
|
export const FileCache = Register.global("$hxClasses")["whet.cache.FileCache"] =
|
|
17
|
-
class FileCache extends Register.inherits(BaseCache) {
|
|
17
|
+
class FileCache extends Register.inherits(() => BaseCache, true) {
|
|
18
18
|
new(rootDir) {
|
|
19
19
|
this.flushQueued = false;
|
|
20
20
|
super.new(rootDir, new StringMap());
|
|
@@ -5,7 +5,7 @@ import {Register} from "../../genes/Register.js"
|
|
|
5
5
|
const $global = Register.$global
|
|
6
6
|
|
|
7
7
|
export const MemoryCache = Register.global("$hxClasses")["whet.cache.MemoryCache"] =
|
|
8
|
-
class MemoryCache extends Register.inherits(BaseCache) {
|
|
8
|
+
class MemoryCache extends Register.inherits(() => BaseCache, true) {
|
|
9
9
|
new(rootDir) {
|
|
10
10
|
super.new(rootDir, new ObjectMap());
|
|
11
11
|
}
|
package/bin/whet/stones/Files.js
CHANGED
|
@@ -8,7 +8,7 @@ import {Register} from "../../genes/Register.js"
|
|
|
8
8
|
const $global = Register.$global
|
|
9
9
|
|
|
10
10
|
export const Files = Register.global("$hxClasses")["whet.stones.Files"] =
|
|
11
|
-
class Files extends Register.inherits(Stone) {
|
|
11
|
+
class Files extends Register.inherits(() => Stone, true) {
|
|
12
12
|
new(config) {
|
|
13
13
|
super.new(config);
|
|
14
14
|
}
|
|
@@ -19,13 +19,19 @@ class Files extends Register.inherits(Stone) {
|
|
|
19
19
|
let _gthis = this;
|
|
20
20
|
let onDirFile = function (dir, dirFile) {
|
|
21
21
|
let pathId = IdUtils.fromCwdPath(dirFile, RootDir.fromProject(_gthis.project));
|
|
22
|
-
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
23
|
-
throw new Error("\"" + dir + "\" is not a directory.");
|
|
24
|
-
};
|
|
25
22
|
let inlobj_id;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
if (dir == "/") {
|
|
24
|
+
inlobj_id = pathId;
|
|
25
|
+
} else {
|
|
26
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
27
|
+
throw new Error("\"" + dir + "\" is not a directory.");
|
|
28
|
+
};
|
|
29
|
+
let inlobj_id1;
|
|
30
|
+
let dir1 = pathId.substring(0, pathId.lastIndexOf("/") + 1);
|
|
31
|
+
inlobj_id1 = ((dir1.length == 0) ? "./" : dir1).indexOf(dir) == 0;
|
|
32
|
+
inlobj_id = (inlobj_id1) ? pathId.substring(dir.length) : null;
|
|
33
|
+
};
|
|
34
|
+
return inlobj_id;
|
|
29
35
|
};
|
|
30
36
|
let files = [];
|
|
31
37
|
let dirs = [];
|
|
@@ -51,14 +57,20 @@ class Files extends Register.inherits(Stone) {
|
|
|
51
57
|
generate(hash) {
|
|
52
58
|
let _gthis = this;
|
|
53
59
|
let onDirFile = function (dir, dirFile) {
|
|
60
|
+
let p_id;
|
|
54
61
|
let pathId = IdUtils.fromCwdPath(dirFile, RootDir.fromProject(_gthis.project));
|
|
55
|
-
if (
|
|
56
|
-
|
|
62
|
+
if (dir == "/") {
|
|
63
|
+
p_id = pathId;
|
|
64
|
+
} else {
|
|
65
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
66
|
+
throw new Error("\"" + dir + "\" is not a directory.");
|
|
67
|
+
};
|
|
68
|
+
let p_id1;
|
|
69
|
+
let dir1 = pathId.substring(0, pathId.lastIndexOf("/") + 1);
|
|
70
|
+
p_id1 = ((dir1.length == 0) ? "./" : dir1).indexOf(dir) == 0;
|
|
71
|
+
p_id = (p_id1) ? pathId.substring(dir.length) : null;
|
|
57
72
|
};
|
|
58
|
-
|
|
59
|
-
let dir1 = pathId.substring(0, pathId.lastIndexOf("/") + 1);
|
|
60
|
-
p_id = ((dir1.length == 0) ? "./" : dir1).indexOf(dir) == 0;
|
|
61
|
-
return SourceData.fromFile((p_id) ? pathId.substring(dir.length) : null, dirFile, pathId);
|
|
73
|
+
return SourceData.fromFile(p_id, dirFile, pathId);
|
|
62
74
|
};
|
|
63
75
|
let files = [];
|
|
64
76
|
let dirs = [];
|
|
@@ -106,13 +118,19 @@ class Files extends Register.inherits(Stone) {
|
|
|
106
118
|
}
|
|
107
119
|
fromCwd(file, dir) {
|
|
108
120
|
let pathId = IdUtils.fromCwdPath(file, RootDir.fromProject(this.project));
|
|
109
|
-
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
110
|
-
throw new Error("\"" + dir + "\" is not a directory.");
|
|
111
|
-
};
|
|
112
121
|
let tmp;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
if (dir == "/") {
|
|
123
|
+
tmp = pathId;
|
|
124
|
+
} else {
|
|
125
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
126
|
+
throw new Error("\"" + dir + "\" is not a directory.");
|
|
127
|
+
};
|
|
128
|
+
let tmp1;
|
|
129
|
+
let dir1 = pathId.substring(0, pathId.lastIndexOf("/") + 1);
|
|
130
|
+
tmp1 = ((dir1.length == 0) ? "./" : dir1).indexOf(dir) == 0;
|
|
131
|
+
tmp = (tmp1) ? pathId.substring(dir.length) : null;
|
|
132
|
+
};
|
|
133
|
+
return {"pathId": pathId, "id": tmp};
|
|
116
134
|
}
|
|
117
135
|
static get __name__() {
|
|
118
136
|
return "whet.stones.Files"
|