whet 0.0.6 → 0.0.9
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/Project.d.ts +4 -2
- package/bin/whet/Project.js +42 -12
- package/bin/whet/Source.d.ts +8 -1
- package/bin/whet/Source.js +27 -11
- package/bin/whet/SourceId.d.ts +1 -0
- package/bin/whet/SourceId.js +46 -20
- package/bin/whet/Stone.d.ts +9 -3
- package/bin/whet/Stone.js +51 -10
- package/bin/whet/Whet.js +1 -1
- package/bin/whet/cache/BaseCache.js +16 -8
- package/bin/whet/cache/CacheManager.js +30 -13
- package/bin/whet/cache/FileCache.js +64 -29
- package/bin/whet/magic/RoutePathType.js +8 -4
- package/bin/whet/magic/RouteType.d.ts +2 -1
- package/bin/whet/magic/RouteType.js +34 -14
- package/bin/whet/route/Route.js +28 -7
- package/bin/whet/route/Router.js +35 -17
- package/bin/whet/stones/Files.d.ts +7 -2
- package/bin/whet/stones/Files.js +55 -59
- package/bin/whet/stones/JsonStone.js +8 -4
- package/bin/whet/stones/RemoteFile.js +8 -4
- package/bin/whet/stones/Server.d.ts +1 -2
- package/bin/whet/stones/Server.js +40 -16
- package/bin/whet/stones/Zip.js +15 -7
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +1 -2
- package/bin/whet/stones/haxe/HaxeBuild.js +21 -11
- package/bin/whet/stones/haxe/Hxml.js +43 -19
- package/bin/whet.d.ts +1 -0
- package/bin/whet.js +1 -0
- package/package.json +1 -1
package/bin/whet/Project.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare class Project {
|
|
|
12
12
|
stones: AnyStone[]
|
|
13
13
|
onInit: (config: any) => Promise<any>
|
|
14
14
|
protected options: Option[]
|
|
15
|
-
addCommand(
|
|
15
|
+
addCommand(name: string, stone?: null | AnyStone): Command
|
|
16
16
|
toString(): string
|
|
17
17
|
protected static projects: Project[]
|
|
18
18
|
}
|
|
@@ -27,8 +27,10 @@ export type ProjectConfig = {
|
|
|
27
27
|
*/
|
|
28
28
|
onInit?: null | ((config: any) => Promise<any>),
|
|
29
29
|
/**
|
|
30
|
-
* Array of Commander.js options this project supports.
|
|
30
|
+
* Array of Commander.js options this project supports. Use `addOption` to get Option instance.
|
|
31
31
|
*/
|
|
32
32
|
options?: null | Option[],
|
|
33
33
|
rootDir?: null | string
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export const addOption: (flags: string, description: null | string) => Option
|
package/bin/whet/Project.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {CacheManager} from "./cache/CacheManager.js"
|
|
2
2
|
import {Whet_Fields_} from "./Whet.js"
|
|
3
|
-
import {SourceId_Fields_} from "./SourceId.js"
|
|
4
3
|
import {Log} from "./Log.js"
|
|
5
4
|
import * as Path from "path"
|
|
6
5
|
import {Register} from "../genes/Register.js"
|
|
6
|
+
import {Command, Option} from "commander"
|
|
7
7
|
import {StringTools} from "../StringTools.js"
|
|
8
|
+
import {HxOverrides} from "../HxOverrides.js"
|
|
8
9
|
|
|
9
10
|
const $global = Register.$global
|
|
10
11
|
|
|
@@ -37,29 +38,43 @@ class Project extends Register.inherits() {
|
|
|
37
38
|
file = decodeURI(file);
|
|
38
39
|
file = StringTools.replace(file, "file:///", "");
|
|
39
40
|
var s = Path.relative(process.cwd(), file);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
42
|
+
if (str.length > 0) {
|
|
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;
|
|
43
48
|
var s = this1.substring(0, this1.lastIndexOf("/") + 1);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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;
|
|
47
56
|
} else {
|
|
48
57
|
var s = config.rootDir;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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;
|
|
52
65
|
};
|
|
53
66
|
this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
|
|
54
67
|
Project.projects.push(this);
|
|
55
68
|
var this1 = ["New project created.", {"project": this, "projectCount": Project.projects.length}];
|
|
56
69
|
Log.log(30, ...this1);
|
|
57
70
|
}
|
|
58
|
-
addCommand(
|
|
71
|
+
addCommand(name, stone) {
|
|
72
|
+
var cmd = new Command(name);
|
|
59
73
|
if (stone != null) {
|
|
60
74
|
cmd.alias(stone.id + "." + cmd.name());
|
|
61
75
|
};
|
|
62
76
|
Whet_Fields_.program.addCommand(cmd);
|
|
77
|
+
return cmd;
|
|
63
78
|
}
|
|
64
79
|
toString() {
|
|
65
80
|
return "" + this.name + "@" + this.rootDir;
|
|
@@ -73,4 +88,19 @@ class Project extends Register.inherits() {
|
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
|
|
76
|
-
Project.projects = []
|
|
91
|
+
Project.projects = []
|
|
92
|
+
export const Project_Fields_ = Register.global("$hxClasses")["whet._Project.Project_Fields_"] =
|
|
93
|
+
class Project_Fields_ {
|
|
94
|
+
static get __name__() {
|
|
95
|
+
return "whet._Project.Project_Fields_"
|
|
96
|
+
}
|
|
97
|
+
get __class__() {
|
|
98
|
+
return Project_Fields_
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
Project_Fields_.addOption = function (flags, description) {
|
|
104
|
+
return new Option(flags, description);
|
|
105
|
+
}
|
|
106
|
+
export const addOption = Project_Fields_.addOption
|
package/bin/whet/Source.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export declare class Source {
|
|
|
26
26
|
export declare class SourceData {
|
|
27
27
|
protected constructor(id: string, data: Buffer)
|
|
28
28
|
data: Buffer
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Name relative to the stone that generated it.
|
|
32
|
+
*/
|
|
29
33
|
id: string
|
|
30
34
|
hash: SourceHash
|
|
31
35
|
source: Source
|
|
@@ -43,7 +47,10 @@ export declare class SourceData {
|
|
|
43
47
|
protected getFilePath(idOverride?: null | string): Promise<string>
|
|
44
48
|
|
|
45
49
|
/**
|
|
46
|
-
*
|
|
50
|
+
* @param id Path id relative to stone that generates it.
|
|
51
|
+
* @param path Actual path relative to CWD.
|
|
52
|
+
* @param pathId Path Id relative to project.
|
|
53
|
+
* @return Promise<SourceData>
|
|
47
54
|
*/
|
|
48
55
|
static fromFile(id: string, path: string, pathId: string): Promise<SourceData>
|
|
49
56
|
static fromString(id: string, s: string): SourceData
|
package/bin/whet/Source.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Utils} from "./Utils.js"
|
|
2
|
-
import {
|
|
2
|
+
import {SourceId, RootDir} from "./SourceId.js"
|
|
3
3
|
import {SourceHash} from "./SourceHash.js"
|
|
4
4
|
import {Log} from "./Log.js"
|
|
5
5
|
import * as Path from "path"
|
|
@@ -8,6 +8,7 @@ import * as Fs from "fs"
|
|
|
8
8
|
import {Buffer} from "buffer"
|
|
9
9
|
import {StringTools} from "../StringTools.js"
|
|
10
10
|
import {Lambda} from "../Lambda.js"
|
|
11
|
+
import {HxOverrides} from "../HxOverrides.js"
|
|
11
12
|
|
|
12
13
|
const $global = Register.$global
|
|
13
14
|
|
|
@@ -45,9 +46,13 @@ class Source extends Register.inherits() {
|
|
|
45
46
|
return this.data[0];
|
|
46
47
|
} else {
|
|
47
48
|
var s = id;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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;
|
|
51
56
|
return Lambda.find(this.data, function (entry) {
|
|
52
57
|
return entry.id == sid;
|
|
53
58
|
});
|
|
@@ -112,7 +117,10 @@ class SourceData extends Register.inherits() {
|
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
/**
|
|
115
|
-
*
|
|
120
|
+
* @param id Path id relative to stone that generates it.
|
|
121
|
+
* @param path Actual path relative to CWD.
|
|
122
|
+
* @param pathId Path Id relative to project.
|
|
123
|
+
* @return Promise<SourceData>
|
|
116
124
|
*/
|
|
117
125
|
static fromFile(id, path, pathId) {
|
|
118
126
|
return new Promise(function (res, rej) {
|
|
@@ -124,9 +132,13 @@ class SourceData extends Register.inherits() {
|
|
|
124
132
|
var source = SourceData.fromBytes(id, buffer);
|
|
125
133
|
source.filePath = path;
|
|
126
134
|
var s = pathId;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
136
|
+
if (str.length > 0) {
|
|
137
|
+
str = Path.posix.normalize(str);
|
|
138
|
+
str = StringTools.replace(str, "\\", "/");
|
|
139
|
+
};
|
|
140
|
+
s = str;
|
|
141
|
+
source.filePathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
130
142
|
res(source);
|
|
131
143
|
};
|
|
132
144
|
});
|
|
@@ -137,9 +149,13 @@ class SourceData extends Register.inherits() {
|
|
|
137
149
|
}
|
|
138
150
|
static fromBytes(id, data) {
|
|
139
151
|
var s = id;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
var str = (id.length > 1 && HxOverrides.cca(id, 0) == 47) ? id.substring(1) : id;
|
|
153
|
+
if (str.length > 0) {
|
|
154
|
+
str = Path.posix.normalize(str);
|
|
155
|
+
str = StringTools.replace(str, "\\", "/");
|
|
156
|
+
};
|
|
157
|
+
s = str;
|
|
158
|
+
return new SourceData((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, data);
|
|
143
159
|
}
|
|
144
160
|
static get __name__() {
|
|
145
161
|
return "whet.SourceData"
|
package/bin/whet/SourceId.d.ts
CHANGED
package/bin/whet/SourceId.js
CHANGED
|
@@ -8,37 +8,53 @@ const $global = Register.$global
|
|
|
8
8
|
export const SourceId = Register.global("$hxClasses")["whet._SourceId.SourceId"] =
|
|
9
9
|
class SourceId {
|
|
10
10
|
static relativeTo(this1, directory) {
|
|
11
|
-
if (
|
|
11
|
+
if (HxOverrides.cca(directory, directory.length - 1) != 47) {
|
|
12
12
|
throw new Error("\"" + directory + "\" is not a directory.");
|
|
13
13
|
};
|
|
14
14
|
var tmp;
|
|
15
15
|
var s = this1.substring(0, this1.lastIndexOf("/") + 1);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
17
|
+
if (str.length > 0) {
|
|
18
|
+
str = Path.posix.normalize(str);
|
|
19
|
+
str = StringTools.replace(str, "\\", "/");
|
|
20
|
+
};
|
|
21
|
+
s = str;
|
|
22
|
+
tmp = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s).indexOf(directory) == 0;
|
|
19
23
|
if (tmp) {
|
|
20
|
-
return
|
|
24
|
+
return this1.substring(directory.length - 1);
|
|
21
25
|
} else {
|
|
22
26
|
return null;
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
29
|
static getPutInDir(this1, dir) {
|
|
26
|
-
if (
|
|
30
|
+
if (HxOverrides.cca(dir, dir.length - 1) != 47) {
|
|
27
31
|
throw new Error("\"" + dir + "\" is not a directory.");
|
|
28
32
|
};
|
|
29
33
|
var s = "/";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
35
|
+
if (str.length > 0) {
|
|
36
|
+
str = Path.posix.normalize(str);
|
|
37
|
+
str = StringTools.replace(str, "\\", "/");
|
|
38
|
+
};
|
|
39
|
+
s = str;
|
|
40
|
+
if (dir == ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s)) {
|
|
33
41
|
var s = this1;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
37
49
|
} else {
|
|
38
50
|
var s = dir + this1;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
42
58
|
};
|
|
43
59
|
}
|
|
44
60
|
static get __name__() {
|
|
@@ -66,11 +82,20 @@ class RootDir {
|
|
|
66
82
|
|
|
67
83
|
export const SourceId_Fields_ = Register.global("$hxClasses")["whet._SourceId.SourceId_Fields_"] =
|
|
68
84
|
class SourceId_Fields_ {
|
|
69
|
-
static
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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);
|
|
74
99
|
}
|
|
75
100
|
static get __name__() {
|
|
76
101
|
return "whet._SourceId.SourceId_Fields_"
|
|
@@ -81,3 +106,4 @@ class SourceId_Fields_ {
|
|
|
81
106
|
}
|
|
82
107
|
|
|
83
108
|
|
|
109
|
+
export const fromCwdPath = SourceId_Fields_.fromCwdPath
|
package/bin/whet/Stone.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {CacheStrategy} from "./cache/Cache"
|
|
|
4
4
|
import {SourceHash} from "./SourceHash"
|
|
5
5
|
import {Source, SourceData} from "./Source"
|
|
6
6
|
import {Project} from "./Project"
|
|
7
|
-
import {Command} from "commander"
|
|
8
7
|
|
|
9
8
|
export declare class Stone<T extends StoneConfig> {
|
|
10
9
|
constructor(config: T)
|
|
@@ -25,9 +24,9 @@ export declare class Stone<T extends StoneConfig> {
|
|
|
25
24
|
protected initConfig(): void
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
|
-
Override this to register commands.
|
|
27
|
+
Override this to register commands via `this.project.addCommand`.
|
|
29
28
|
*/
|
|
30
|
-
protected
|
|
29
|
+
protected addCommands(): void
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* **Do not override.**
|
|
@@ -77,6 +76,13 @@ export declare class Stone<T extends StoneConfig> {
|
|
|
77
76
|
*/
|
|
78
77
|
setAbsolutePath(path: string, generate?: boolean): Promise<Source>
|
|
79
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Stores this resource in the supplied path, without changing cache strategy.
|
|
81
|
+
* @param path Path relative to this stone's project.
|
|
82
|
+
* Can be a directory or a file path (only if this resource generates single source).
|
|
83
|
+
*/
|
|
84
|
+
exportTo(path: string): Promise<any>
|
|
85
|
+
|
|
80
86
|
/**
|
|
81
87
|
* Convenient function to get CWD-relative path from project-relative one.
|
|
82
88
|
* Useful for pure JS stones.
|
package/bin/whet/Stone.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {StoneId_Fields_} from "./magic/StoneId.js"
|
|
2
2
|
import {CacheStrategy, CacheDurability} from "./cache/Cache.js"
|
|
3
|
-
import {
|
|
3
|
+
import {Utils} from "./Utils.js"
|
|
4
|
+
import {SourceId, RootDir} from "./SourceId.js"
|
|
4
5
|
import {SourceHash} from "./SourceHash.js"
|
|
5
6
|
import {Source} from "./Source.js"
|
|
6
7
|
import {Project} from "./Project.js"
|
|
@@ -8,6 +9,7 @@ import {Log} from "./Log.js"
|
|
|
8
9
|
import * as Path from "path"
|
|
9
10
|
import {Register} from "../genes/Register.js"
|
|
10
11
|
import {StringTools} from "../StringTools.js"
|
|
12
|
+
import {HxOverrides} from "../HxOverrides.js"
|
|
11
13
|
|
|
12
14
|
const $global = Register.$global
|
|
13
15
|
|
|
@@ -28,9 +30,7 @@ class Stone extends Register.inherits() {
|
|
|
28
30
|
this.initConfig();
|
|
29
31
|
this.id = (config.id != null) ? StoneId_Fields_.makeStoneId(config.id) : StoneId_Fields_.makeStoneId(this);
|
|
30
32
|
this.cacheStrategy = (config.cacheStrategy == null) ? this.project.cache.defaultStrategy : config.cacheStrategy;
|
|
31
|
-
|
|
32
|
-
var _g1 = this.getCommands();
|
|
33
|
-
while (_g < _g1.length) this.project.addCommand(_g1[_g++], this);
|
|
33
|
+
this.addCommands();
|
|
34
34
|
}
|
|
35
35
|
get cache() {
|
|
36
36
|
return this.get_cache()
|
|
@@ -43,10 +43,9 @@ class Stone extends Register.inherits() {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
Override this to register commands.
|
|
46
|
+
Override this to register commands via `this.project.addCommand`.
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
return [];
|
|
48
|
+
addCommands() {
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
@@ -142,9 +141,13 @@ class Stone extends Register.inherits() {
|
|
|
142
141
|
generate = true;
|
|
143
142
|
};
|
|
144
143
|
var s = path;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
var str = (path.length > 1 && HxOverrides.cca(path, 0) == 47) ? path.substring(1) : path;
|
|
145
|
+
if (str.length > 0) {
|
|
146
|
+
str = Path.posix.normalize(str);
|
|
147
|
+
str = StringTools.replace(str, "\\", "/");
|
|
148
|
+
};
|
|
149
|
+
s = str;
|
|
150
|
+
this.cacheStrategy = CacheStrategy.AbsolutePath((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, CacheDurability.LimitCountByAge(1));
|
|
148
151
|
if (generate) {
|
|
149
152
|
return this.getSource();
|
|
150
153
|
} else {
|
|
@@ -152,6 +155,44 @@ class Stone extends Register.inherits() {
|
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Stores this resource in the supplied path, without changing cache strategy.
|
|
160
|
+
* @param path Path relative to this stone's project.
|
|
161
|
+
* Can be a directory or a file path (only if this resource generates single source).
|
|
162
|
+
*/
|
|
163
|
+
exportTo(path) {
|
|
164
|
+
var _gthis = this;
|
|
165
|
+
Log.log(30, ...["Exporting file(s).", {"path": path, "stone": this}]);
|
|
166
|
+
var s = path;
|
|
167
|
+
var str = (path.length > 1 && HxOverrides.cca(path, 0) == 47) ? path.substring(1) : path;
|
|
168
|
+
if (str.length > 0) {
|
|
169
|
+
str = Path.posix.normalize(str);
|
|
170
|
+
str = StringTools.replace(str, "\\", "/");
|
|
171
|
+
};
|
|
172
|
+
s = str;
|
|
173
|
+
var pathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
174
|
+
var isDir = HxOverrides.cca(pathId, pathId.length - 1) == 47;
|
|
175
|
+
return this.getSource().then(function (src) {
|
|
176
|
+
if (src.data.length > 1 && !isDir) {
|
|
177
|
+
throw new Error("Path is not a directory for multiple source export.");
|
|
178
|
+
};
|
|
179
|
+
var _g = [];
|
|
180
|
+
var _g1 = 0;
|
|
181
|
+
var _g2 = src.data;
|
|
182
|
+
while (_g1 < _g2.length) {
|
|
183
|
+
var data = _g2[_g1];
|
|
184
|
+
++_g1;
|
|
185
|
+
var id = (isDir) ? SourceId.getPutInDir(data.id, pathId) : pathId;
|
|
186
|
+
var root = RootDir.fromProject(_gthis.project);
|
|
187
|
+
if (id.charAt(0) != "/") {
|
|
188
|
+
throw new Error("Badly formed SourceId.");
|
|
189
|
+
};
|
|
190
|
+
_g.push(Utils.saveBytes(Path.posix.join(".", root, ".", id), data.data));
|
|
191
|
+
};
|
|
192
|
+
return Promise.all(_g);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
155
196
|
/**
|
|
156
197
|
* Convenient function to get CWD-relative path from project-relative one.
|
|
157
198
|
* Useful for pure JS stones.
|
package/bin/whet/Whet.js
CHANGED
|
@@ -10,7 +10,7 @@ const $global = Register.$global
|
|
|
10
10
|
export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
|
|
11
11
|
class Whet_Fields_ {
|
|
12
12
|
static main() {
|
|
13
|
-
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.
|
|
13
|
+
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.9", "-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");
|
|
14
14
|
Whet_Fields_.program.parse();
|
|
15
15
|
var options = Whet_Fields_.program.opts();
|
|
16
16
|
if (options.logLevel != null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Cache} from "./Cache.js"
|
|
2
|
-
import {
|
|
2
|
+
import {SourceId} from "../SourceId.js"
|
|
3
3
|
import {SourceHash} from "../SourceHash.js"
|
|
4
4
|
import {Log} from "../Log.js"
|
|
5
5
|
import * as Path from "path"
|
|
@@ -15,7 +15,7 @@ const $global = Register.$global
|
|
|
15
15
|
export const BaseCache = Register.global("$hxClasses")["whet.cache.BaseCache"] =
|
|
16
16
|
class BaseCache extends Register.inherits() {
|
|
17
17
|
new(rootDir, cache) {
|
|
18
|
-
if (
|
|
18
|
+
if (HxOverrides.cca(rootDir, rootDir.length - 1) != 47) {
|
|
19
19
|
throw new Error("Root dir is a not a dir.");
|
|
20
20
|
};
|
|
21
21
|
this.rootDir = rootDir;
|
|
@@ -125,9 +125,13 @@ class BaseCache extends Register.inherits() {
|
|
|
125
125
|
var filenames = this.getExistingDirs(stone);
|
|
126
126
|
var maxNum = (filenames != null) ? Lambda.fold(filenames, function (fn, num) {
|
|
127
127
|
var s = fn.substring(0, fn.lastIndexOf("/") + 1);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
129
|
+
if (str.length > 0) {
|
|
130
|
+
str = Path.posix.normalize(str);
|
|
131
|
+
str = StringTools.replace(str, "\\", "/");
|
|
132
|
+
};
|
|
133
|
+
s = str;
|
|
134
|
+
var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
131
135
|
var root = _gthis.rootDir;
|
|
132
136
|
if (this1.charAt(0) != "/") {
|
|
133
137
|
throw new Error("Badly formed SourceId.");
|
|
@@ -138,9 +142,13 @@ class BaseCache extends Register.inherits() {
|
|
|
138
142
|
}, 0) : 0;
|
|
139
143
|
++maxNum;
|
|
140
144
|
var s = "v" + maxNum + "/";
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
146
|
+
if (str.length > 0) {
|
|
147
|
+
str = Path.posix.normalize(str);
|
|
148
|
+
str = StringTools.replace(str, "\\", "/");
|
|
149
|
+
};
|
|
150
|
+
s = str;
|
|
151
|
+
return SourceId.getPutInDir((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, baseDir);
|
|
144
152
|
}
|
|
145
153
|
checkDurability(stone, values, durability, useIndex, ageIndex) {
|
|
146
154
|
Log.log(20, ...["Checking durability.", {"stone": stone, "durability": Std.string(durability)}]);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {MemoryCache} from "./MemoryCache.js"
|
|
2
2
|
import {FileCache} from "./FileCache.js"
|
|
3
3
|
import {CacheStrategy, CacheDurability, DurabilityCheck} from "./Cache.js"
|
|
4
|
-
import {RootDir,
|
|
4
|
+
import {RootDir, SourceId} from "../SourceId.js"
|
|
5
5
|
import {Log} from "../Log.js"
|
|
6
6
|
import * as Path from "path"
|
|
7
7
|
import {Register} from "../../genes/Register.js"
|
|
8
8
|
import {StringTools} from "../../StringTools.js"
|
|
9
|
+
import {HxOverrides} from "../../HxOverrides.js"
|
|
9
10
|
|
|
10
11
|
const $global = Register.$global
|
|
11
12
|
|
|
@@ -53,9 +54,13 @@ class CacheManager extends Register.inherits() {
|
|
|
53
54
|
*/
|
|
54
55
|
getDir(stone, hash) {
|
|
55
56
|
var s = stone.id + "/";
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
58
|
+
if (str.length > 0) {
|
|
59
|
+
str = Path.posix.normalize(str);
|
|
60
|
+
str = StringTools.replace(str, "\\", "/");
|
|
61
|
+
};
|
|
62
|
+
s = str;
|
|
63
|
+
var baseDir = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
59
64
|
var tmp;
|
|
60
65
|
switch (stone.cacheStrategy._hx_index) {
|
|
61
66
|
case 0:
|
|
@@ -70,14 +75,22 @@ class CacheManager extends Register.inherits() {
|
|
|
70
75
|
};
|
|
71
76
|
if (tmp) {
|
|
72
77
|
var s = ".temp/";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
var str = (".temp/".length > 1 && HxOverrides.cca(".temp/", 0) == 47) ? ".temp/".substring(1) : ".temp/";
|
|
79
|
+
if (str.length > 0) {
|
|
80
|
+
str = Path.posix.normalize(str);
|
|
81
|
+
str = StringTools.replace(str, "\\", "/");
|
|
82
|
+
};
|
|
83
|
+
s = str;
|
|
84
|
+
baseDir = SourceId.getPutInDir(baseDir, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
|
|
76
85
|
};
|
|
77
86
|
var s = ".whet/";
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
var str = (".whet/".length > 1 && HxOverrides.cca(".whet/", 0) == 47) ? ".whet/".substring(1) : ".whet/";
|
|
88
|
+
if (str.length > 0) {
|
|
89
|
+
str = Path.posix.normalize(str);
|
|
90
|
+
str = StringTools.replace(str, "\\", "/");
|
|
91
|
+
};
|
|
92
|
+
s = str;
|
|
93
|
+
baseDir = SourceId.getPutInDir(baseDir, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
|
|
81
94
|
var id;
|
|
82
95
|
var _g = stone.cacheStrategy;
|
|
83
96
|
switch (_g._hx_index) {
|
|
@@ -93,9 +106,13 @@ class CacheManager extends Register.inherits() {
|
|
|
93
106
|
case 3:
|
|
94
107
|
var _g1 = _g.path;
|
|
95
108
|
var s = _g1.substring(0, _g1.lastIndexOf("/") + 1);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
110
|
+
if (str.length > 0) {
|
|
111
|
+
str = Path.posix.normalize(str);
|
|
112
|
+
str = StringTools.replace(str, "\\", "/");
|
|
113
|
+
};
|
|
114
|
+
s = str;
|
|
115
|
+
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
99
116
|
break
|
|
100
117
|
|
|
101
118
|
};
|