arcadible 0.1.10 → 0.1.12
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/arc-deploy.js +21 -6
- package/bin/arc-init.js +1 -1
- package/bin/arc-login.js +1 -1
- package/bin/arc-pack.js +5 -3
- package/package.json +2 -2
- package/src/action/init/tool.js +1 -1
- package/src/action/login/flow.js +13 -9
- package/src/schema/game.js +16 -5
- package/src/schema/workflow.js +3 -3
- package/src/util/delay.js +13 -8
- package/src/util/toml.js +1 -1
package/bin/arc-deploy.js
CHANGED
|
@@ -18,6 +18,7 @@ const output = require("../src/util/output");
|
|
|
18
18
|
const pkg = require("../package.json");
|
|
19
19
|
const rc = require("../src/util/rc");
|
|
20
20
|
const validate = require("../src/cli/validate");
|
|
21
|
+
const whoami = require("../src/cli/whoami");
|
|
21
22
|
|
|
22
23
|
// [use]
|
|
23
24
|
|
|
@@ -45,7 +46,7 @@ const handler = function ({ json, quiet }) {
|
|
|
45
46
|
return {
|
|
46
47
|
onBegin() {
|
|
47
48
|
if (!json && !quiet) {
|
|
48
|
-
log.p("Deploying
|
|
49
|
+
log.p("Deploying...");
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
onInfo({ level, message }) {
|
|
@@ -57,9 +58,15 @@ const handler = function ({ json, quiet }) {
|
|
|
57
58
|
log.pw(`⚠ ${message}`);
|
|
58
59
|
return;
|
|
59
60
|
default:
|
|
60
|
-
log.p(
|
|
61
|
+
log.p(`· ${message}`);
|
|
61
62
|
}
|
|
62
63
|
},
|
|
64
|
+
onRefresh(refresh) {
|
|
65
|
+
if (!json) {
|
|
66
|
+
log.p("Authenticating...");
|
|
67
|
+
}
|
|
68
|
+
return refresh(true);
|
|
69
|
+
},
|
|
63
70
|
};
|
|
64
71
|
};
|
|
65
72
|
|
|
@@ -69,11 +76,19 @@ const start = function (argv) {
|
|
|
69
76
|
const json = argv.json;
|
|
70
77
|
const quiet = argv.quiet;
|
|
71
78
|
const root = resolve(process.cwd(), argv.cwd);
|
|
72
|
-
return
|
|
79
|
+
return whoami({ handler: handler({ json, quiet }) })
|
|
80
|
+
.then((current) => {
|
|
81
|
+
if (!current || !current.profile) {
|
|
82
|
+
throw new Error("Not logged in. Run `arc login` to log in.");
|
|
83
|
+
}
|
|
84
|
+
return validate({ root });
|
|
85
|
+
})
|
|
73
86
|
.then((issues) => {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
throw new Error(
|
|
87
|
+
const count = issues.length;
|
|
88
|
+
if (count) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`${count} ${count === 1 ? "issue" : "issues"} found. Run \`arc validate\` for details.`,
|
|
91
|
+
);
|
|
77
92
|
}
|
|
78
93
|
return deploy({
|
|
79
94
|
git: argv.git,
|
package/bin/arc-init.js
CHANGED
package/bin/arc-login.js
CHANGED
|
@@ -105,7 +105,7 @@ const main = function (argv) {
|
|
|
105
105
|
.option("browser", {
|
|
106
106
|
default: conf.browser,
|
|
107
107
|
describe:
|
|
108
|
-
"Open a web browser automatically (
|
|
108
|
+
"Open a web browser automatically (disable with --no-browser)",
|
|
109
109
|
type: "boolean",
|
|
110
110
|
})
|
|
111
111
|
.help("help")
|
package/bin/arc-pack.js
CHANGED
|
@@ -47,9 +47,11 @@ const start = function (argv) {
|
|
|
47
47
|
const root = resolve(process.cwd(), argv.cwd);
|
|
48
48
|
return validate({ root })
|
|
49
49
|
.then((issues) => {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
throw new Error(
|
|
50
|
+
const count = issues.length;
|
|
51
|
+
if (count) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`${count} ${count === 1 ? "issue" : "issues"} found. Run \`arc validate\` for details.`,
|
|
54
|
+
);
|
|
53
55
|
}
|
|
54
56
|
return pack({ output: argv.output, root });
|
|
55
57
|
})
|
package/package.json
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"arc-whoami": "bin/arc-whoami.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@iarna/toml": "^2.2.5",
|
|
15
14
|
"@inquirer/prompts": "^8.5.2",
|
|
16
15
|
"adm-zip": "^0.5.16",
|
|
17
16
|
"chalk": "^4.1.2",
|
|
@@ -25,6 +24,7 @@
|
|
|
25
24
|
"marked": "^17.0.1",
|
|
26
25
|
"mp4box": "^2.3.0",
|
|
27
26
|
"open": "^8.4.2",
|
|
27
|
+
"pretty-toml": "^1.0.0",
|
|
28
28
|
"rc": "^1.2.8",
|
|
29
29
|
"semver": "^7.7.3",
|
|
30
30
|
"yargs": "^17.7.2",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"license": "Apache-2.0",
|
|
52
52
|
"main": "./src/cli/index.js",
|
|
53
53
|
"name": "arcadible",
|
|
54
|
-
"version": "0.1.
|
|
54
|
+
"version": "0.1.12"
|
|
55
55
|
}
|
package/src/action/init/tool.js
CHANGED
|
@@ -52,7 +52,7 @@ const scaffold = function (src, dest, { onBegin, onInfo }) {
|
|
|
52
52
|
const init = function (dest, { force, template }, handler) {
|
|
53
53
|
return pathExists(dest).then((exists) => {
|
|
54
54
|
if (exists && !force) {
|
|
55
|
-
throw new Error("Directory already exists
|
|
55
|
+
throw new Error("Directory already exists (overwrite with `--force`).");
|
|
56
56
|
}
|
|
57
57
|
return scaffold(template, dest, handler);
|
|
58
58
|
});
|
package/src/action/login/flow.js
CHANGED
|
@@ -16,6 +16,16 @@ const time = require("../../util/time");
|
|
|
16
16
|
const poll = delay.poll;
|
|
17
17
|
const randomUUID = crypto.randomUUID;
|
|
18
18
|
|
|
19
|
+
// [declare]
|
|
20
|
+
|
|
21
|
+
const POLL = {
|
|
22
|
+
delay: time.s(3),
|
|
23
|
+
factor: 2,
|
|
24
|
+
interval: time.s(30),
|
|
25
|
+
maxDelay: time.s(15),
|
|
26
|
+
timeoutError: "Login request expired.",
|
|
27
|
+
};
|
|
28
|
+
|
|
19
29
|
// [function]
|
|
20
30
|
|
|
21
31
|
const postFlow = function ({ expiresAt, token, type }) {
|
|
@@ -56,9 +66,9 @@ const pollFlow = function ({ id, token }, onPoll) {
|
|
|
56
66
|
case "completed":
|
|
57
67
|
return data;
|
|
58
68
|
case "failed":
|
|
59
|
-
throw new Error("Login
|
|
69
|
+
throw new Error("Login request failed.");
|
|
60
70
|
default:
|
|
61
|
-
throw new Error("Login
|
|
71
|
+
throw new Error("Login request expired.");
|
|
62
72
|
}
|
|
63
73
|
});
|
|
64
74
|
};
|
|
@@ -80,13 +90,7 @@ const main = function ({ onCreated, onPoll }) {
|
|
|
80
90
|
return poll(
|
|
81
91
|
(flow) => pollFlow(flow, onPoll),
|
|
82
92
|
{ id, token },
|
|
83
|
-
{
|
|
84
|
-
delay: time.s(3),
|
|
85
|
-
factor: 2,
|
|
86
|
-
interval: time.s(30),
|
|
87
|
-
maxDelay: time.s(15),
|
|
88
|
-
timeout,
|
|
89
|
-
},
|
|
93
|
+
{ ...POLL, timeout },
|
|
90
94
|
);
|
|
91
95
|
});
|
|
92
96
|
};
|
package/src/schema/game.js
CHANGED
|
@@ -22,6 +22,7 @@ const strs = require("../util/strs");
|
|
|
22
22
|
|
|
23
23
|
// [use]
|
|
24
24
|
|
|
25
|
+
const cleanSemver = semver.clean;
|
|
25
26
|
const existsCheck = check.exists;
|
|
26
27
|
const imageCheck = check.image;
|
|
27
28
|
const indentLines = strs.indentLines;
|
|
@@ -301,15 +302,16 @@ const zIconVideo = function (root) {
|
|
|
301
302
|
const zId = function () {
|
|
302
303
|
const field = "id";
|
|
303
304
|
return z
|
|
304
|
-
.
|
|
305
|
+
.string(
|
|
305
306
|
message(field, [
|
|
306
|
-
"Must be
|
|
307
|
-
"Run `arc init` to generate a new
|
|
307
|
+
"Must be defined.",
|
|
308
|
+
"Run `arc init` to generate a new ID.",
|
|
308
309
|
]),
|
|
309
310
|
)
|
|
311
|
+
.uuid(message(field, ["Must be a valid UUID."]))
|
|
310
312
|
.refine(
|
|
311
313
|
(value) => value === value.toLowerCase(),
|
|
312
|
-
message(field, ["Must
|
|
314
|
+
message(field, ["Must be lowercase."]),
|
|
313
315
|
);
|
|
314
316
|
};
|
|
315
317
|
|
|
@@ -403,10 +405,19 @@ const zTrailer = function () {
|
|
|
403
405
|
const zVersion = function () {
|
|
404
406
|
const field = "version";
|
|
405
407
|
return z
|
|
406
|
-
.string(
|
|
408
|
+
.string(
|
|
409
|
+
message(field, [
|
|
410
|
+
"Must be defined.",
|
|
411
|
+
"A version is required unless one can be derived.",
|
|
412
|
+
]),
|
|
413
|
+
)
|
|
407
414
|
.refine(
|
|
408
415
|
(value) => validSemver(value) !== null,
|
|
409
416
|
message(field, ["Must be valid semver."]),
|
|
417
|
+
)
|
|
418
|
+
.refine(
|
|
419
|
+
(value) => cleanSemver(value) === value,
|
|
420
|
+
message(field, ["Must be normalized semver."]),
|
|
410
421
|
);
|
|
411
422
|
};
|
|
412
423
|
|
package/src/schema/workflow.js
CHANGED
|
@@ -54,7 +54,7 @@ const zDeployDir = function (root, { build }) {
|
|
|
54
54
|
const field = "deploy_dir";
|
|
55
55
|
return z
|
|
56
56
|
.string()
|
|
57
|
-
.min(1)
|
|
57
|
+
.min(1, message(field, ["Must be defined."]))
|
|
58
58
|
.refine(
|
|
59
59
|
(file) => isRelativeCheck(root, file),
|
|
60
60
|
message(field, ["Must be a relative path."]),
|
|
@@ -70,8 +70,8 @@ const zDeployDir = function (root, { build }) {
|
|
|
70
70
|
.refine(
|
|
71
71
|
(file) => build || existsCheck(root, file),
|
|
72
72
|
message(field, [
|
|
73
|
-
"Must exist when
|
|
74
|
-
"Run `arc inspect workflow
|
|
73
|
+
"Must exist when no build step is defined.",
|
|
74
|
+
"Run `arc inspect workflow` for details.",
|
|
75
75
|
]),
|
|
76
76
|
);
|
|
77
77
|
};
|
package/src/util/delay.js
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
const time = require("./time");
|
|
6
6
|
|
|
7
|
+
// [declare]
|
|
8
|
+
|
|
9
|
+
const POLL = {
|
|
10
|
+
delay: time.s(1),
|
|
11
|
+
factor: 1,
|
|
12
|
+
interval: time.m(1),
|
|
13
|
+
maxDelay: time.s(1),
|
|
14
|
+
timeout: Infinity,
|
|
15
|
+
timeoutError: "Polling timed out.",
|
|
16
|
+
};
|
|
17
|
+
|
|
7
18
|
// [function]
|
|
8
19
|
|
|
9
20
|
const backoff = function (elapsed, delay, factor, interval, maxDelay) {
|
|
@@ -30,13 +41,7 @@ const wait = function (delay, next) {
|
|
|
30
41
|
const poll = function (
|
|
31
42
|
fn,
|
|
32
43
|
value,
|
|
33
|
-
{
|
|
34
|
-
delay = time.s(1),
|
|
35
|
-
factor = 1,
|
|
36
|
-
interval = time.m(1),
|
|
37
|
-
maxDelay = delay,
|
|
38
|
-
timeout = Infinity,
|
|
39
|
-
} = {},
|
|
44
|
+
{ delay, factor, interval, maxDelay, timeout, timeoutError } = POLL,
|
|
40
45
|
) {
|
|
41
46
|
const started = Date.now();
|
|
42
47
|
const next = function () {
|
|
@@ -46,7 +51,7 @@ const poll = function (
|
|
|
46
51
|
}
|
|
47
52
|
const elapsed = Date.now() - started;
|
|
48
53
|
if (elapsed >= timeout) {
|
|
49
|
-
throw new Error(
|
|
54
|
+
throw new Error(timeoutError);
|
|
50
55
|
}
|
|
51
56
|
return wait(backoff(elapsed, delay, factor, interval, maxDelay), next);
|
|
52
57
|
});
|