whet 0.0.19 → 0.0.21
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/whet/Project.js +4 -25
- package/bin/whet/Source.d.ts +3 -2
- package/bin/whet/Source.js +14 -37
- package/bin/whet/SourceId.d.ts +17 -5
- package/bin/whet/SourceId.js +93 -68
- package/bin/whet/Stone.js +14 -26
- package/bin/whet/Whet.js +1 -1
- package/bin/whet/cache/BaseCache.js +6 -23
- package/bin/whet/cache/CacheManager.js +10 -33
- package/bin/whet/cache/FileCache.js +17 -143
- package/bin/whet/magic/MinimatchType.js +1 -11
- package/bin/whet/magic/RoutePathType.js +8 -45
- package/bin/whet/route/Router.d.ts +15 -5
- package/bin/whet/route/Router.js +166 -227
- package/bin/whet/stones/Files.d.ts +6 -0
- package/bin/whet/stones/Files.js +95 -52
- 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 -33
- 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
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Project files define a project, its [stones](#Stones). Their content defines wha
|
|
|
10
10
|
|
|
11
11
|
Stones (named after _whetstone_) are individual building blocks of a project.
|
|
12
12
|
|
|
13
|
-
They represent a single logical asset (can be multiple files) or functionality (e.g. a dev web server). Stones can use other stones (via routes), to achieve their objective, forming a dependency tree. E.g. a
|
|
13
|
+
They represent a single logical asset (can be multiple files) or functionality (e.g. a dev web server). Stones can use other stones (via routes), to achieve their objective, forming a dependency tree. E.g. a CSS file could be made by minifying a file generated from SCSS source, and each step could be individually cached.
|
|
14
14
|
|
|
15
15
|
### Stones Configuration
|
|
16
16
|
|
|
@@ -30,7 +30,7 @@ Some stones might provide helper methods to modify the configuration after it wa
|
|
|
30
30
|
|
|
31
31
|
...
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Routers
|
|
34
34
|
|
|
35
35
|
...
|
|
36
36
|
|
|
@@ -40,8 +40,11 @@ Project files should have no side effects, unless some of their commands are exe
|
|
|
40
40
|
|
|
41
41
|
<!-- TODO: document configuration handlers -->
|
|
42
42
|
|
|
43
|
-
All paths
|
|
43
|
+
All file paths should use `/` as directory separator, regardless of platform.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
Paths should always be relative, and are considered relative to root project directory, or relative to root of the Router/Stone used. For getting sources from Stones/Routers [minimatch](https://github.com/isaacs/minimatch/) is used.
|
|
46
|
+
|
|
47
|
+
Path that is a directory ends with a `/`, otherwise it's considered a file. That means:
|
|
48
|
+
|
|
49
|
+
- `assets/` is a **directory** called `assets`.
|
|
50
|
+
- `assets` is a **file** called `assets`.
|
package/bin/HxOverrides.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
export declare class HxOverrides {
|
|
3
3
|
protected static dateStr(date: Date): string
|
|
4
|
-
protected static cca(s: string, index: number): null | number
|
|
5
4
|
protected static substr(s: string, pos: number, len?: null | number): string
|
|
6
5
|
protected static remove<T>(a: T[], obj: T): boolean
|
|
7
6
|
protected static now(): number
|
package/bin/HxOverrides.js
CHANGED
|
@@ -12,13 +12,6 @@ class HxOverrides {
|
|
|
12
12
|
var s = date.getSeconds();
|
|
13
13
|
return date.getFullYear() + "-" + ((m < 10) ? "0" + m : "" + m) + "-" + ((d < 10) ? "0" + d : "" + d) + " " + ((h < 10) ? "0" + h : "" + h) + ":" + ((mi < 10) ? "0" + mi : "" + mi) + ":" + ((s < 10) ? "0" + s : "" + s);
|
|
14
14
|
}
|
|
15
|
-
static cca(s, index) {
|
|
16
|
-
var x = s.charCodeAt(index);
|
|
17
|
-
if (x != x) {
|
|
18
|
-
return undefined;
|
|
19
|
-
};
|
|
20
|
-
return x;
|
|
21
|
-
}
|
|
22
15
|
static substr(s, pos, len) {
|
|
23
16
|
if (len == null) {
|
|
24
17
|
len = s.length;
|
package/bin/whet/Project.js
CHANGED
|
@@ -5,7 +5,6 @@ import * as Path from "path"
|
|
|
5
5
|
import {Register} from "../genes/Register.js"
|
|
6
6
|
import {Command, Option} from "commander"
|
|
7
7
|
import {StringTools} from "../StringTools.js"
|
|
8
|
-
import {HxOverrides} from "../HxOverrides.js"
|
|
9
8
|
|
|
10
9
|
const $global = Register.$global
|
|
11
10
|
|
|
@@ -37,31 +36,11 @@ class Project extends Register.inherits() {
|
|
|
37
36
|
Error.prepareStackTrace = oldValue;
|
|
38
37
|
file = decodeURI(file);
|
|
39
38
|
file = StringTools.replace(file, "file:///", "");
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
str = Path.posix.normalize(str);
|
|
44
|
-
str = StringTools.replace(str, "\\", "/");
|
|
45
|
-
};
|
|
46
|
-
s = str;
|
|
47
|
-
var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
48
|
-
var s = this1.substring(0, this1.lastIndexOf("/") + 1);
|
|
49
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
50
|
-
if (str.length > 0) {
|
|
51
|
-
str = Path.posix.normalize(str);
|
|
52
|
-
str = StringTools.replace(str, "\\", "/");
|
|
53
|
-
};
|
|
54
|
-
s = str;
|
|
55
|
-
this.rootDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
39
|
+
var id = Path.relative(process.cwd(), file);
|
|
40
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
41
|
+
this.rootDir = (dir.length == 0) ? "./" : dir;
|
|
56
42
|
} else {
|
|
57
|
-
|
|
58
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
59
|
-
if (str.length > 0) {
|
|
60
|
-
str = Path.posix.normalize(str);
|
|
61
|
-
str = StringTools.replace(str, "\\", "/");
|
|
62
|
-
};
|
|
63
|
-
s = str;
|
|
64
|
-
this.rootDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
43
|
+
this.rootDir = config.rootDir;
|
|
65
44
|
};
|
|
66
45
|
this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
|
|
67
46
|
Project.projects.push(this);
|
package/bin/whet/Source.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {MinimatchType} from "./magic/MinimatchType"
|
|
1
2
|
import {AnyStone} from "./Stone"
|
|
2
3
|
import {SourceHash} from "./SourceHash"
|
|
3
4
|
import {Buffer} from "buffer"
|
|
@@ -18,9 +19,9 @@ export declare class Source {
|
|
|
18
19
|
getDirPath(): string
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
* Returns first result if `
|
|
22
|
+
* Returns first result if `pattern` is null, or first one it matches.
|
|
22
23
|
*/
|
|
23
|
-
get(
|
|
24
|
+
get(pattern?: null | MinimatchType): SourceData
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export declare class SourceData {
|
package/bin/whet/Source.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import {MinimatchType_Fields_} from "./magic/MinimatchType.js"
|
|
1
2
|
import {Utils} from "./Utils.js"
|
|
2
|
-
import {
|
|
3
|
+
import {RootDir} from "./SourceId.js"
|
|
3
4
|
import {SourceHash} from "./SourceHash.js"
|
|
4
5
|
import {Log} from "./Log.js"
|
|
5
6
|
import * as Path from "path"
|
|
6
7
|
import {Register} from "../genes/Register.js"
|
|
7
8
|
import * as Fs from "fs"
|
|
8
9
|
import {Buffer} from "buffer"
|
|
9
|
-
import {StringTools} from "../StringTools.js"
|
|
10
10
|
import {Lambda} from "../Lambda.js"
|
|
11
|
-
import {HxOverrides} from "../HxOverrides.js"
|
|
12
11
|
|
|
13
12
|
const $global = Register.$global
|
|
14
13
|
|
|
@@ -39,22 +38,15 @@ class Source extends Register.inherits() {
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
/**
|
|
42
|
-
* Returns first result if `
|
|
41
|
+
* Returns first result if `pattern` is null, or first one it matches.
|
|
43
42
|
*/
|
|
44
|
-
get(
|
|
45
|
-
if (
|
|
43
|
+
get(pattern) {
|
|
44
|
+
if (pattern == null) {
|
|
46
45
|
return this.data[0];
|
|
47
46
|
} else {
|
|
48
|
-
var
|
|
49
|
-
var str = (id.length > 1 && HxOverrides.cca(id, 0) == 47) ? id.substring(1) : id;
|
|
50
|
-
if (str.length > 0) {
|
|
51
|
-
str = Path.posix.normalize(str);
|
|
52
|
-
str = StringTools.replace(str, "\\", "/");
|
|
53
|
-
};
|
|
54
|
-
s = str;
|
|
55
|
-
var sid = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
47
|
+
var filter = MinimatchType_Fields_.makeMinimatch(pattern);
|
|
56
48
|
return Lambda.find(this.data, function (entry) {
|
|
57
|
-
return entry.id
|
|
49
|
+
return filter.match(entry.id);
|
|
58
50
|
});
|
|
59
51
|
};
|
|
60
52
|
}
|
|
@@ -103,13 +95,12 @@ class SourceData extends Register.inherits() {
|
|
|
103
95
|
new Error("Data without source.");
|
|
104
96
|
};
|
|
105
97
|
var dir = this.source.getDirPath();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (this1.charAt(0) != "/") {
|
|
110
|
-
throw new Error("Badly formed SourceId.");
|
|
98
|
+
var name = (idOverride != null && !(idOverride.length == 0 || idOverride.charCodeAt(idOverride.length - 1) == 47)) ? idOverride : this.id;
|
|
99
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
100
|
+
throw new Error("\"" + dir + "\" is not a directory.");
|
|
111
101
|
};
|
|
112
|
-
this.
|
|
102
|
+
this.filePathId = Path.posix.join(dir, name);
|
|
103
|
+
this.filePath = Path.posix.join(".", RootDir.fromProject(this.source.origin.project), ".", this.filePathId);
|
|
113
104
|
return Utils.saveBytes(this.filePath, this.data).then(function (_) {
|
|
114
105
|
return _gthis.filePath;
|
|
115
106
|
});
|
|
@@ -133,14 +124,7 @@ class SourceData extends Register.inherits() {
|
|
|
133
124
|
} else {
|
|
134
125
|
var source = SourceData.fromBytes(id, buffer);
|
|
135
126
|
source.filePath = path;
|
|
136
|
-
|
|
137
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
138
|
-
if (str.length > 0) {
|
|
139
|
-
str = Path.posix.normalize(str);
|
|
140
|
-
str = StringTools.replace(str, "\\", "/");
|
|
141
|
-
};
|
|
142
|
-
s = str;
|
|
143
|
-
source.filePathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
127
|
+
source.filePathId = pathId;
|
|
144
128
|
res(source);
|
|
145
129
|
};
|
|
146
130
|
});
|
|
@@ -150,14 +134,7 @@ class SourceData extends Register.inherits() {
|
|
|
150
134
|
return SourceData.fromBytes(id, Buffer.from(s, "utf-8"));
|
|
151
135
|
}
|
|
152
136
|
static fromBytes(id, data) {
|
|
153
|
-
|
|
154
|
-
var str = (id.length > 1 && HxOverrides.cca(id, 0) == 47) ? id.substring(1) : id;
|
|
155
|
-
if (str.length > 0) {
|
|
156
|
-
str = Path.posix.normalize(str);
|
|
157
|
-
str = StringTools.replace(str, "\\", "/");
|
|
158
|
-
};
|
|
159
|
-
s = str;
|
|
160
|
-
return new SourceData((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, data);
|
|
137
|
+
return new SourceData(id, data);
|
|
161
138
|
}
|
|
162
139
|
static get __name__() {
|
|
163
140
|
return "whet.SourceData"
|
package/bin/whet/SourceId.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import {Project} from "./Project"
|
|
2
2
|
|
|
3
|
-
export declare class
|
|
4
|
-
static
|
|
5
|
-
static
|
|
3
|
+
export declare class IdUtils {
|
|
4
|
+
static toCwdPath(id: string, root: string): string
|
|
5
|
+
static isDir(id: string): boolean
|
|
6
|
+
static isInDir(id: string, directory: string, nested?: boolean): boolean
|
|
7
|
+
static getRelativeTo(id: string, directory: string): string
|
|
8
|
+
static getPutInDir(id: string, dir: string): string
|
|
9
|
+
static compare(a: string, b: string): number
|
|
10
|
+
static assertDir(directory: string): void
|
|
11
|
+
static getWithExt(id: string): string
|
|
12
|
+
static setWithExt(id: string, name: string): string
|
|
13
|
+
static getExt(id: string): string
|
|
14
|
+
static setExt(id: string, ext: string): string
|
|
15
|
+
static getWithoutExt(id: string): string
|
|
16
|
+
static setWithoutExt(id: string, name: string): string
|
|
17
|
+
static getDir(id: string): string
|
|
18
|
+
static setDir(id: string, dir: string): string
|
|
19
|
+
static fromCwdPath(s: string, root: string): string
|
|
6
20
|
}
|
|
7
21
|
|
|
8
22
|
export declare class RootDir {
|
|
9
23
|
static fromProject(p: Project): string
|
|
10
24
|
}
|
|
11
|
-
|
|
12
|
-
export const fromCwdPath: (s: string, root: string) => string
|
package/bin/whet/SourceId.js
CHANGED
|
@@ -1,67 +1,120 @@
|
|
|
1
1
|
import * as Path from "path"
|
|
2
2
|
import {Register} from "../genes/Register.js"
|
|
3
3
|
import {StringTools} from "../StringTools.js"
|
|
4
|
-
import {HxOverrides} from "../HxOverrides.js"
|
|
5
4
|
|
|
6
5
|
const $global = Register.$global
|
|
7
6
|
|
|
8
|
-
export const
|
|
9
|
-
class
|
|
10
|
-
static
|
|
11
|
-
|
|
7
|
+
export const IdUtils = Register.global("$hxClasses")["whet.IdUtils"] =
|
|
8
|
+
class IdUtils {
|
|
9
|
+
static toCwdPath(id, root) {
|
|
10
|
+
return Path.posix.join(".", root, ".", id);
|
|
11
|
+
}
|
|
12
|
+
static isDir(id) {
|
|
13
|
+
if (id.length != 0) {
|
|
14
|
+
return id.charCodeAt(id.length - 1) == 47;
|
|
15
|
+
} else {
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static isInDir(id, directory, nested) {
|
|
20
|
+
if (nested == null) {
|
|
21
|
+
nested = false;
|
|
22
|
+
};
|
|
23
|
+
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
12
24
|
throw new Error("\"" + directory + "\" is not a directory.");
|
|
13
25
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
if (nested) {
|
|
27
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
28
|
+
return ((dir.length == 0) ? "./" : dir).indexOf(directory) == 0;
|
|
29
|
+
} else {
|
|
30
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
31
|
+
return ((dir.length == 0) ? "./" : dir) == directory;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
static getRelativeTo(id, directory) {
|
|
35
|
+
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
36
|
+
throw new Error("\"" + directory + "\" is not a directory.");
|
|
20
37
|
};
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
var tmp;
|
|
39
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
40
|
+
tmp = ((dir.length == 0) ? "./" : dir).indexOf(directory) == 0;
|
|
23
41
|
if (tmp) {
|
|
24
|
-
return
|
|
42
|
+
return id.substring(directory.length);
|
|
25
43
|
} else {
|
|
26
44
|
return null;
|
|
27
45
|
};
|
|
28
46
|
}
|
|
29
|
-
static getPutInDir(
|
|
30
|
-
if (
|
|
47
|
+
static getPutInDir(id, dir) {
|
|
48
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
31
49
|
throw new Error("\"" + dir + "\" is not a directory.");
|
|
32
50
|
};
|
|
33
|
-
|
|
34
|
-
|
|
51
|
+
return Path.posix.join(dir, id);
|
|
52
|
+
}
|
|
53
|
+
static compare(a, b) {
|
|
54
|
+
if (a < b) {
|
|
55
|
+
return -1;
|
|
56
|
+
} else if (a > b) {
|
|
57
|
+
return 1;
|
|
58
|
+
} else {
|
|
59
|
+
return 0;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
static assertDir(directory) {
|
|
63
|
+
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
64
|
+
throw new Error("\"" + directory + "\" is not a directory.");
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
static getWithExt(id) {
|
|
68
|
+
return id.substring(id.lastIndexOf("/") + 1);
|
|
69
|
+
}
|
|
70
|
+
static setWithExt(id, name) {
|
|
71
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
72
|
+
return Path.posix.join((dir.length == 0) ? "./" : dir, name);
|
|
73
|
+
}
|
|
74
|
+
static getExt(id) {
|
|
75
|
+
return Path.posix.extname(id);
|
|
76
|
+
}
|
|
77
|
+
static setExt(id, ext) {
|
|
78
|
+
if (ext.length > 0 && ext.charCodeAt(0) != 46) {
|
|
79
|
+
ext = "." + ext;
|
|
80
|
+
};
|
|
81
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
82
|
+
return Path.posix.join((dir.length == 0) ? "./" : dir, Path.posix.parse(id).name) + ext;
|
|
83
|
+
}
|
|
84
|
+
static getWithoutExt(id) {
|
|
85
|
+
return Path.posix.parse(id).name;
|
|
86
|
+
}
|
|
87
|
+
static setWithoutExt(id, name) {
|
|
88
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
89
|
+
return Path.posix.join((dir.length == 0) ? "./" : dir, name) + Path.posix.extname(id);
|
|
90
|
+
}
|
|
91
|
+
static getDir(id) {
|
|
92
|
+
var dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
93
|
+
if (dir.length == 0) {
|
|
94
|
+
return "./";
|
|
95
|
+
} else {
|
|
96
|
+
return dir;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
static setDir(id, dir) {
|
|
100
|
+
return Path.posix.join(dir, id.substring(id.lastIndexOf("/") + 1));
|
|
101
|
+
}
|
|
102
|
+
static fromCwdPath(s, root) {
|
|
103
|
+
var absPath = Path.posix;
|
|
104
|
+
var str = s;
|
|
35
105
|
if (str.length > 0) {
|
|
36
106
|
str = Path.posix.normalize(str);
|
|
37
107
|
str = StringTools.replace(str, "\\", "/");
|
|
38
108
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var str = (this1.length > 1 && HxOverrides.cca(this1, 0) == 47) ? this1.substring(1) : this1;
|
|
43
|
-
if (str.length > 0) {
|
|
44
|
-
str = Path.posix.normalize(str);
|
|
45
|
-
str = StringTools.replace(str, "\\", "/");
|
|
46
|
-
};
|
|
47
|
-
s = str;
|
|
48
|
-
return (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
49
|
-
} else {
|
|
50
|
-
var s = dir + this1;
|
|
51
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
52
|
-
if (str.length > 0) {
|
|
53
|
-
str = Path.posix.normalize(str);
|
|
54
|
-
str = StringTools.replace(str, "\\", "/");
|
|
55
|
-
};
|
|
56
|
-
s = str;
|
|
57
|
-
return (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
58
|
-
};
|
|
109
|
+
var absPath1 = absPath.resolve(str);
|
|
110
|
+
var rootStr = Path.posix.resolve(root);
|
|
111
|
+
return Path.posix.relative(rootStr, absPath1);
|
|
59
112
|
}
|
|
60
113
|
static get __name__() {
|
|
61
|
-
return "whet.
|
|
114
|
+
return "whet.IdUtils"
|
|
62
115
|
}
|
|
63
116
|
get __class__() {
|
|
64
|
-
return
|
|
117
|
+
return IdUtils
|
|
65
118
|
}
|
|
66
119
|
}
|
|
67
120
|
|
|
@@ -79,31 +132,3 @@ class RootDir {
|
|
|
79
132
|
}
|
|
80
133
|
}
|
|
81
134
|
|
|
82
|
-
|
|
83
|
-
export const SourceId_Fields_ = Register.global("$hxClasses")["whet._SourceId.SourceId_Fields_"] =
|
|
84
|
-
class SourceId_Fields_ {
|
|
85
|
-
static fromCwdPath(s, root) {
|
|
86
|
-
var s1 = Path.posix;
|
|
87
|
-
var str = s;
|
|
88
|
-
if (str.length > 0) {
|
|
89
|
-
str = Path.posix.normalize(str);
|
|
90
|
-
str = StringTools.replace(str, "\\", "/");
|
|
91
|
-
};
|
|
92
|
-
s = s1.resolve(str);
|
|
93
|
-
var rootStr = root;
|
|
94
|
-
if (HxOverrides.cca(rootStr, 0) == 47) {
|
|
95
|
-
rootStr = rootStr.substring(1);
|
|
96
|
-
};
|
|
97
|
-
rootStr = Path.posix.resolve(rootStr);
|
|
98
|
-
return Path.posix.relative(rootStr, s);
|
|
99
|
-
}
|
|
100
|
-
static get __name__() {
|
|
101
|
-
return "whet._SourceId.SourceId_Fields_"
|
|
102
|
-
}
|
|
103
|
-
get __class__() {
|
|
104
|
-
return SourceId_Fields_
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export const fromCwdPath = SourceId_Fields_.fromCwdPath
|
package/bin/whet/Stone.js
CHANGED
|
@@ -2,15 +2,13 @@ import {StoneId_Fields_} from "./magic/StoneId.js"
|
|
|
2
2
|
import {MaybeArray_Fields_} from "./magic/MaybeArray.js"
|
|
3
3
|
import {CacheStrategy, CacheDurability} from "./cache/Cache.js"
|
|
4
4
|
import {Utils} from "./Utils.js"
|
|
5
|
-
import {
|
|
5
|
+
import {RootDir} from "./SourceId.js"
|
|
6
6
|
import {SourceHash} from "./SourceHash.js"
|
|
7
7
|
import {Source} from "./Source.js"
|
|
8
8
|
import {Project} from "./Project.js"
|
|
9
9
|
import {Log} from "./Log.js"
|
|
10
10
|
import * as Path from "path"
|
|
11
11
|
import {Register} from "../genes/Register.js"
|
|
12
|
-
import {StringTools} from "../StringTools.js"
|
|
13
|
-
import {HxOverrides} from "../HxOverrides.js"
|
|
14
12
|
|
|
15
13
|
const $global = Register.$global
|
|
16
14
|
|
|
@@ -255,14 +253,7 @@ class Stone extends Register.inherits() {
|
|
|
255
253
|
if (generate == null) {
|
|
256
254
|
generate = true;
|
|
257
255
|
};
|
|
258
|
-
|
|
259
|
-
var str = (path.length > 1 && HxOverrides.cca(path, 0) == 47) ? path.substring(1) : path;
|
|
260
|
-
if (str.length > 0) {
|
|
261
|
-
str = Path.posix.normalize(str);
|
|
262
|
-
str = StringTools.replace(str, "\\", "/");
|
|
263
|
-
};
|
|
264
|
-
s = str;
|
|
265
|
-
this.cacheStrategy = CacheStrategy.AbsolutePath((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, CacheDurability.LimitCountByAge(1));
|
|
256
|
+
this.cacheStrategy = CacheStrategy.AbsolutePath(path, CacheDurability.LimitCountByAge(1));
|
|
266
257
|
if (generate) {
|
|
267
258
|
return this.getSource();
|
|
268
259
|
} else {
|
|
@@ -278,15 +269,7 @@ class Stone extends Register.inherits() {
|
|
|
278
269
|
exportTo(path) {
|
|
279
270
|
var _gthis = this;
|
|
280
271
|
Log.log(30, ...["Exporting file(s).", {"path": path, "stone": this}]);
|
|
281
|
-
var
|
|
282
|
-
var str = (path.length > 1 && HxOverrides.cca(path, 0) == 47) ? path.substring(1) : path;
|
|
283
|
-
if (str.length > 0) {
|
|
284
|
-
str = Path.posix.normalize(str);
|
|
285
|
-
str = StringTools.replace(str, "\\", "/");
|
|
286
|
-
};
|
|
287
|
-
s = str;
|
|
288
|
-
var pathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
289
|
-
var isDir = HxOverrides.cca(pathId, pathId.length - 1) == 47;
|
|
272
|
+
var isDir = path.length == 0 || path.charCodeAt(path.length - 1) == 47;
|
|
290
273
|
return this.getSource().then(function (src) {
|
|
291
274
|
if (src.data.length > 1 && !isDir) {
|
|
292
275
|
throw new Error("Path is not a directory for multiple source export.");
|
|
@@ -297,12 +280,17 @@ class Stone extends Register.inherits() {
|
|
|
297
280
|
while (_g1 < _g2.length) {
|
|
298
281
|
var data = _g2[_g1];
|
|
299
282
|
++_g1;
|
|
300
|
-
var id
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
283
|
+
var id;
|
|
284
|
+
if (isDir) {
|
|
285
|
+
var id1 = data.id;
|
|
286
|
+
if (!(path.length == 0 || path.charCodeAt(path.length - 1) == 47)) {
|
|
287
|
+
throw new Error("\"" + path + "\" is not a directory.");
|
|
288
|
+
};
|
|
289
|
+
id = Path.posix.join(path, id1);
|
|
290
|
+
} else {
|
|
291
|
+
id = path;
|
|
304
292
|
};
|
|
305
|
-
_g.push(Utils.saveBytes(Path.posix.join(".",
|
|
293
|
+
_g.push(Utils.saveBytes(Path.posix.join(".", RootDir.fromProject(_gthis.project), ".", id), data.data));
|
|
306
294
|
};
|
|
307
295
|
return Promise.all(_g);
|
|
308
296
|
});
|
|
@@ -313,7 +301,7 @@ class Stone extends Register.inherits() {
|
|
|
313
301
|
* Useful for pure JS stones.
|
|
314
302
|
*/
|
|
315
303
|
cwdPath(path) {
|
|
316
|
-
return Path.join("
|
|
304
|
+
return Path.posix.join(".", RootDir.fromProject(this.project), ".", path);
|
|
317
305
|
}
|
|
318
306
|
get_cache() {
|
|
319
307
|
return this.project.cache;
|
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.21", "-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) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {Cache} from "./Cache.js"
|
|
2
|
-
import {SourceId} from "../SourceId.js"
|
|
3
2
|
import {SourceHash} from "../SourceHash.js"
|
|
4
3
|
import {Log} from "../Log.js"
|
|
5
4
|
import * as Path from "path"
|
|
6
5
|
import {Boot} from "../../js/Boot.js"
|
|
7
6
|
import {Register} from "../../genes/Register.js"
|
|
8
|
-
import {StringTools} from "../../StringTools.js"
|
|
9
7
|
import {Std} from "../../Std.js"
|
|
10
8
|
import {Lambda} from "../../Lambda.js"
|
|
11
9
|
import {HxOverrides} from "../../HxOverrides.js"
|
|
@@ -15,7 +13,7 @@ const $global = Register.$global
|
|
|
15
13
|
export const BaseCache = Register.global("$hxClasses")["whet.cache.BaseCache"] =
|
|
16
14
|
class BaseCache extends Register.inherits() {
|
|
17
15
|
new(rootDir, cache) {
|
|
18
|
-
if (
|
|
16
|
+
if (!(rootDir.length == 0 || rootDir.charCodeAt(rootDir.length - 1) == 47)) {
|
|
19
17
|
throw new Error("Root dir is a not a dir.");
|
|
20
18
|
};
|
|
21
19
|
this.rootDir = rootDir;
|
|
@@ -126,31 +124,16 @@ class BaseCache extends Register.inherits() {
|
|
|
126
124
|
};
|
|
127
125
|
var filenames = this.getExistingDirs(stone);
|
|
128
126
|
var maxNum = (filenames != null) ? Lambda.fold(filenames, function (fn, num) {
|
|
129
|
-
var
|
|
130
|
-
var
|
|
131
|
-
if (str.length > 0) {
|
|
132
|
-
str = Path.posix.normalize(str);
|
|
133
|
-
str = StringTools.replace(str, "\\", "/");
|
|
134
|
-
};
|
|
135
|
-
s = str;
|
|
136
|
-
var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
137
|
-
var root = _gthis.rootDir;
|
|
138
|
-
if (this1.charAt(0) != "/") {
|
|
139
|
-
throw new Error("Badly formed SourceId.");
|
|
140
|
-
};
|
|
141
|
-
var parts = Path.posix.join(".", root, ".", this1).split("/");
|
|
127
|
+
var dir = fn.substring(0, fn.lastIndexOf("/") + 1);
|
|
128
|
+
var parts = Path.posix.join(".", _gthis.rootDir, ".", (dir.length == 0) ? "./" : dir).split("/");
|
|
142
129
|
var name = (parts.length > 1) ? parts[parts.length - 2] : "";
|
|
143
130
|
return Math.max(num, (name.charAt(0) == "v") ? Std.parseInt(HxOverrides.substr(name, 1, null)) : 0);
|
|
144
131
|
}, 0) : 0;
|
|
145
132
|
++maxNum;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (str.length > 0) {
|
|
149
|
-
str = Path.posix.normalize(str);
|
|
150
|
-
str = StringTools.replace(str, "\\", "/");
|
|
133
|
+
if (!(baseDir.length == 0 || baseDir.charCodeAt(baseDir.length - 1) == 47)) {
|
|
134
|
+
throw new Error("\"" + baseDir + "\" is not a directory.");
|
|
151
135
|
};
|
|
152
|
-
|
|
153
|
-
return SourceId.getPutInDir((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, baseDir);
|
|
136
|
+
return Path.posix.join(baseDir, "v" + maxNum + "/");
|
|
154
137
|
}
|
|
155
138
|
checkDurability(stone, values, durability, useIndex, ageIndex) {
|
|
156
139
|
Log.log(20, ...["Checking durability.", {"stone": stone, "durability": Std.string(durability)}]);
|