arcadible 0.1.35 → 0.1.37
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 +5 -6
- package/package.json +1 -1
- package/src/parser/readme.js +14 -1
- package/src/schema/workflow.js +11 -1
- package/src/util/argv.js +16 -7
- package/src/util/rc.js +33 -8
package/bin/arc-deploy.js
CHANGED
|
@@ -288,13 +288,12 @@ const start = function (argv) {
|
|
|
288
288
|
sw.stop(true);
|
|
289
289
|
sw = new SpinnerWheel("Checking... %s");
|
|
290
290
|
// git deploys need no login: anyone who can push to the repository can
|
|
291
|
-
// release, and the Arcadible GitHub App publishes the release.
|
|
292
|
-
//
|
|
293
|
-
//
|
|
291
|
+
// release, and the Arcadible GitHub App publishes the release. The
|
|
292
|
+
// account, when there is one, checks the owner's repository is
|
|
293
|
+
// connected, and waits for the release, which needs the game's owner,
|
|
294
|
+
// so a git deploy that isn't logged in neither checks nor waits.
|
|
294
295
|
if (git) {
|
|
295
|
-
return
|
|
296
|
-
? whoamiIfAny({ handler: handler({ json, pb, quiet, sw }) })
|
|
297
|
-
: null;
|
|
296
|
+
return whoamiIfAny({ handler: handler({ json, pb, quiet, sw }) });
|
|
298
297
|
}
|
|
299
298
|
return whoami({ handler: handler({ json, pb, quiet, sw }) });
|
|
300
299
|
})
|
package/package.json
CHANGED
package/src/parser/readme.js
CHANGED
|
@@ -12,6 +12,10 @@ const strs = require("../util/strs");
|
|
|
12
12
|
const deepCompact = objs.deepCompact;
|
|
13
13
|
const trimWhitespace = strs.trimWhitespace;
|
|
14
14
|
|
|
15
|
+
// [define]
|
|
16
|
+
|
|
17
|
+
const COMMENT = 8;
|
|
18
|
+
|
|
15
19
|
// [function]
|
|
16
20
|
|
|
17
21
|
// a title with a parenthesized suffix, `Title (Short)`, as its two parts.
|
|
@@ -28,9 +32,18 @@ const text = function (node) {
|
|
|
28
32
|
|
|
29
33
|
// [function]
|
|
30
34
|
|
|
35
|
+
// nodes as HTML. A comment has no `outerHTML`, so it's written back as one,
|
|
36
|
+
// for validation to report, rather than as its text.
|
|
31
37
|
const html = function (nodes) {
|
|
32
38
|
return trimWhitespace(
|
|
33
|
-
nodes
|
|
39
|
+
nodes
|
|
40
|
+
.map((node) => {
|
|
41
|
+
if (node.nodeType === COMMENT) {
|
|
42
|
+
return `<!--${node.textContent}-->`;
|
|
43
|
+
}
|
|
44
|
+
return node.outerHTML ?? node.textContent;
|
|
45
|
+
})
|
|
46
|
+
.join(""),
|
|
34
47
|
);
|
|
35
48
|
};
|
|
36
49
|
|
package/src/schema/workflow.js
CHANGED
|
@@ -33,6 +33,16 @@ const RESERVED = [`${HANDLE}.json`, MEDIA];
|
|
|
33
33
|
|
|
34
34
|
// [function]
|
|
35
35
|
|
|
36
|
+
// whether `build` runs anything: a command that isn't blank, as `arc build`
|
|
37
|
+
// trims and drops blank ones (action/build/tool.js).
|
|
38
|
+
const hasBuild = function (build) {
|
|
39
|
+
return [build]
|
|
40
|
+
.flat()
|
|
41
|
+
.some((cmd) => typeof cmd === "string" && cmd.trim() !== "");
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// [function]
|
|
45
|
+
|
|
36
46
|
const zBuild = function () {
|
|
37
47
|
// const field = "build";
|
|
38
48
|
return z.union([z.string(), z.array(z.string())]);
|
|
@@ -70,7 +80,7 @@ const zDeployDir = function (root, { build }) {
|
|
|
70
80
|
),
|
|
71
81
|
)
|
|
72
82
|
.refine(
|
|
73
|
-
(file) => build || existsCheck(root, file),
|
|
83
|
+
(file) => hasBuild(build) || existsCheck(root, file),
|
|
74
84
|
message(
|
|
75
85
|
field,
|
|
76
86
|
[
|
package/src/util/argv.js
CHANGED
|
@@ -55,20 +55,29 @@ const cwd = function (args) {
|
|
|
55
55
|
|
|
56
56
|
// [function]
|
|
57
57
|
|
|
58
|
+
// whether `argv` passes --json, before the command parses its options.
|
|
59
|
+
const json = function (argv) {
|
|
60
|
+
return parse(normalize(hideBin(argv)), {
|
|
61
|
+
alias: { json: ["j"] },
|
|
62
|
+
boolean: ["json"],
|
|
63
|
+
}).json;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// [function]
|
|
67
|
+
|
|
58
68
|
// yargs' failure handler for a command with --json: an argument error is
|
|
59
69
|
// one JSON document when --json was passed (OUTPUT.md), and yargs' own help
|
|
60
70
|
// and message otherwise.
|
|
61
71
|
const fail = function (argv) {
|
|
62
|
-
const
|
|
63
|
-
alias: { json: ["j"] },
|
|
64
|
-
boolean: ["json"],
|
|
65
|
-
}).json;
|
|
72
|
+
const asJson = json(argv);
|
|
66
73
|
return (message, ex, cli) => {
|
|
67
74
|
if (ex) {
|
|
68
75
|
throw ex;
|
|
69
76
|
}
|
|
70
|
-
if (
|
|
71
|
-
abort("", new ArcError(cfgcode.ARGUMENT_INVALID, message), {
|
|
77
|
+
if (asJson) {
|
|
78
|
+
abort("", new ArcError(cfgcode.ARGUMENT_INVALID, message), {
|
|
79
|
+
json: asJson,
|
|
80
|
+
});
|
|
72
81
|
}
|
|
73
82
|
cli.showHelp("error");
|
|
74
83
|
console.error(`\n${message}`);
|
|
@@ -78,4 +87,4 @@ const fail = function (argv) {
|
|
|
78
87
|
|
|
79
88
|
// [export]
|
|
80
89
|
|
|
81
|
-
module.exports = { CWD, cwd, fail, normalize };
|
|
90
|
+
module.exports = { CWD, cwd, fail, json, normalize };
|
package/src/util/rc.js
CHANGED
|
@@ -13,9 +13,15 @@ const ini = require("ini");
|
|
|
13
13
|
// [import]
|
|
14
14
|
|
|
15
15
|
const args = require("./argv");
|
|
16
|
+
const cfgcode = require("../config/code");
|
|
17
|
+
const error = require("./error");
|
|
18
|
+
const output = require("./output");
|
|
19
|
+
const phrase = require("../phrase");
|
|
16
20
|
|
|
17
21
|
// [use]
|
|
18
22
|
|
|
23
|
+
const abort = output.abort;
|
|
24
|
+
const ArcError = error.ArcError;
|
|
19
25
|
const cwd = args.cwd;
|
|
20
26
|
const dirname = path.dirname;
|
|
21
27
|
const existsSync = fs.existsSync; // eslint-disable-line no-sync
|
|
@@ -60,7 +66,6 @@ const files = function (cmd, argv) {
|
|
|
60
66
|
? []
|
|
61
67
|
: [join("/etc", cmd, "config"), join("/etc", `${cmd}rc`)]),
|
|
62
68
|
join(home, ".config", cmd, "config"),
|
|
63
|
-
join(home, ".config", cmd),
|
|
64
69
|
join(home, `.${cmd}`, "config"),
|
|
65
70
|
join(home, `.${cmd}rc`),
|
|
66
71
|
nearest(cmd),
|
|
@@ -70,7 +75,8 @@ const files = function (cmd, argv) {
|
|
|
70
75
|
|
|
71
76
|
// [function]
|
|
72
77
|
|
|
73
|
-
// a file's sections, INI or JSON, or nothing when it can't be read.
|
|
78
|
+
// a file's sections, INI or JSON, or nothing when it can't be read. JSON
|
|
79
|
+
// that doesn't parse is `parse_failed`, naming the file.
|
|
74
80
|
const read = function (file) {
|
|
75
81
|
let str = null;
|
|
76
82
|
try {
|
|
@@ -78,18 +84,37 @@ const read = function (file) {
|
|
|
78
84
|
} catch (ex) {
|
|
79
85
|
return {};
|
|
80
86
|
}
|
|
81
|
-
|
|
87
|
+
if (!/^\s*\{/u.test(str)) {
|
|
88
|
+
return ini.parse(str);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(str);
|
|
92
|
+
} catch (ex) {
|
|
93
|
+
throw new ArcError(
|
|
94
|
+
cfgcode.PARSE_FAILED,
|
|
95
|
+
phrase.unableToParse(file, ex.message),
|
|
96
|
+
{ cause: ex },
|
|
97
|
+
);
|
|
98
|
+
}
|
|
82
99
|
};
|
|
83
100
|
|
|
84
101
|
// [function]
|
|
85
102
|
|
|
86
103
|
// a command's section of .<cmd>rc, merged from the files `rc` reads. Unlike
|
|
87
|
-
// `rc`, environment variables and `--config` aren't read.
|
|
104
|
+
// `rc`, environment variables and `--config` aren't read. Options are read as
|
|
105
|
+
// the command loads, so a file that doesn't parse aborts the command here,
|
|
106
|
+
// as `<Command> aborted.`.
|
|
88
107
|
const findRc = function (cmd, subcmd, argv) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
try {
|
|
109
|
+
return [...new Set(files(cmd, argv))].reduce(
|
|
110
|
+
(found, file) => ({ ...found, ...read(file)[subcmd] }),
|
|
111
|
+
{},
|
|
112
|
+
);
|
|
113
|
+
} catch (ex) {
|
|
114
|
+
return abort(`${subcmd[0].toUpperCase()}${subcmd.slice(1)} aborted.`, ex, {
|
|
115
|
+
json: args.json(argv),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
93
118
|
};
|
|
94
119
|
|
|
95
120
|
// [export]
|