arcadible 0.0.1 → 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/README.md +3 -0
- package/bin/arc-default.js +57 -0
- package/bin/arc-deploy.js +117 -0
- package/bin/arc-init.js +196 -0
- package/bin/arc-inspect.js +107 -0
- package/bin/arc-login.js +127 -0
- package/bin/arc-logout.js +58 -0
- package/bin/arc-pack.js +126 -0
- package/bin/arc-validate.js +114 -0
- package/bin/arc-whoami.js +111 -0
- package/bin/arc.js +64 -0
- package/package.json +49 -1
- package/src/action/deploy/tool.js +11 -0
- package/src/action/deploy-git/git.js +23 -0
- package/src/action/deploy-git/release.js +74 -0
- package/src/action/deploy-git/tool.js +11 -0
- package/src/action/init/tool.js +44 -0
- package/src/action/inspect/tool.js +25 -0
- package/src/action/login/flow.js +94 -0
- package/src/action/login/tool.js +16 -0
- package/src/action/logout/tool.js +15 -0
- package/src/action/pack/tool.js +60 -0
- package/src/action/validate/tool.js +39 -0
- package/src/action/whoami/tool.js +15 -0
- package/src/api.js +39 -0
- package/src/cli/deploy.js +17 -0
- package/src/cli/index.js +25 -0
- package/src/cli/init.js +15 -0
- package/src/cli/inspect.js +15 -0
- package/src/cli/login.js +15 -0
- package/src/cli/logout.js +15 -0
- package/src/cli/pack.js +15 -0
- package/src/cli/validate.js +15 -0
- package/src/cli/whoami.js +15 -0
- package/src/config/audience.js +5 -0
- package/src/config/game.js +5 -0
- package/src/config/genre.js +22 -0
- package/src/config/html.js +27 -0
- package/src/config/input.js +14 -0
- package/src/config/orientation.js +14 -0
- package/src/config/uri.js +14 -0
- package/src/config/url.js +17 -0
- package/src/config/visibility.js +5 -0
- package/src/config/workflow.js +5 -0
- package/src/parser/manifest.js +46 -0
- package/src/parser/media.js +96 -0
- package/src/parser/project.js +55 -0
- package/src/parser/readme.js +144 -0
- package/src/prompt/project.js +10 -0
- package/src/prompt/template.js +37 -0
- package/src/schema/game.js +324 -0
- package/src/schema/workflow.js +119 -0
- package/src/user.js +91 -0
- package/src/util/dom.js +27 -0
- package/src/util/log.js +99 -0
- package/src/util/md.js +24 -0
- package/src/util/objs.js +28 -0
- package/src/util/os.js +24 -0
- package/src/util/output.js +46 -0
- package/src/util/promise.js +29 -0
- package/src/util/rc.js +41 -0
- package/src/util/request.js +62 -0
- package/src/util/schema.js +25 -0
- package/src/util/strs.js +21 -0
- package/src/util/time.js +79 -0
- package/src/util/zip.js +59 -0
package/src/util/time.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [function]
|
|
4
|
+
|
|
5
|
+
const ms = function (value) {
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// [function]
|
|
10
|
+
|
|
11
|
+
const s = function (value) {
|
|
12
|
+
return value * 1000;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// [function]
|
|
16
|
+
|
|
17
|
+
const m = function (value) {
|
|
18
|
+
return s(value * 60);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// [function]
|
|
22
|
+
|
|
23
|
+
const h = function (value) {
|
|
24
|
+
return m(value * 60);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// [function]
|
|
28
|
+
|
|
29
|
+
const backoff = function (elapsed, delay, factor, interval, maxDelay) {
|
|
30
|
+
const step = Math.floor(elapsed / interval);
|
|
31
|
+
return Math.min(delay * factor ** step, maxDelay);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// [function]
|
|
35
|
+
|
|
36
|
+
const sleep = function (delay) {
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
setTimeout(resolve, delay);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// [function]
|
|
43
|
+
|
|
44
|
+
const wait = function (delay, next) {
|
|
45
|
+
return sleep(delay).then(next);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// [function]
|
|
49
|
+
|
|
50
|
+
const poll = function (
|
|
51
|
+
fn,
|
|
52
|
+
value,
|
|
53
|
+
{
|
|
54
|
+
delay = s(1),
|
|
55
|
+
factor = 1,
|
|
56
|
+
interval = m(1),
|
|
57
|
+
maxDelay = delay,
|
|
58
|
+
timeout = Infinity,
|
|
59
|
+
} = {},
|
|
60
|
+
) {
|
|
61
|
+
const started = Date.now();
|
|
62
|
+
const next = function () {
|
|
63
|
+
return fn(value).then((result) => {
|
|
64
|
+
if (result !== null) {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
const elapsed = Date.now() - started;
|
|
68
|
+
if (elapsed >= timeout) {
|
|
69
|
+
throw new Error("Timed out.");
|
|
70
|
+
}
|
|
71
|
+
return wait(backoff(elapsed, delay, factor, interval, maxDelay), next);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return next();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// [export]
|
|
78
|
+
|
|
79
|
+
module.exports = { h, m, ms, poll, s };
|
package/src/util/zip.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const crypto = require("node:crypto");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
// [import]
|
|
9
|
+
|
|
10
|
+
const AdmZip = require("adm-zip");
|
|
11
|
+
|
|
12
|
+
// [use]
|
|
13
|
+
|
|
14
|
+
const createHash = crypto.createHash;
|
|
15
|
+
const join = path.join;
|
|
16
|
+
|
|
17
|
+
// [class]
|
|
18
|
+
|
|
19
|
+
const Main = class {
|
|
20
|
+
|
|
21
|
+
// [constructor]
|
|
22
|
+
|
|
23
|
+
constructor(prefix) {
|
|
24
|
+
this.prefix = prefix;
|
|
25
|
+
this.zip = new AdmZip();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// [method]
|
|
29
|
+
|
|
30
|
+
addDir(dir, name = "") {
|
|
31
|
+
this.zip.addLocalFolder(dir, name ? join(this.prefix, name) : this.prefix);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// [method]
|
|
35
|
+
|
|
36
|
+
addJson(name, value) {
|
|
37
|
+
const entry = join(this.prefix, name);
|
|
38
|
+
const content = Buffer.from(JSON.stringify(value, null, 2), "utf8");
|
|
39
|
+
this.zip.addFile(entry, content);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// [method]
|
|
43
|
+
|
|
44
|
+
stat() {
|
|
45
|
+
const buffer = this.zip.toBuffer();
|
|
46
|
+
const hash = createHash("sha256").update(buffer).digest("hex");
|
|
47
|
+
return { sha256: hash, size: buffer.length };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// [method]
|
|
51
|
+
|
|
52
|
+
write(outPath) {
|
|
53
|
+
this.zip.writeZip(outPath);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// [export]
|
|
58
|
+
|
|
59
|
+
module.exports = Main;
|