arcadible 0.1.0 → 0.1.2
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-default.js +32 -32
- package/bin/arc-deploy.js +113 -42
- package/bin/arc-init.js +196 -0
- package/bin/arc-inspect.js +65 -44
- package/bin/arc-login.js +127 -0
- package/bin/arc-logout.js +58 -0
- package/bin/arc-pack.js +81 -49
- package/bin/arc-validate.js +115 -0
- package/bin/arc-whoami.js +111 -0
- package/bin/arc.js +20 -15
- package/package.json +22 -9
- package/src/action/deploy/tool.js +11 -0
- package/src/action/deploy-git/git.js +192 -0
- package/src/action/deploy-git/tool.js +86 -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/html.js +27 -0
- package/src/config/uri.js +14 -0
- package/src/config/url.js +17 -0
- package/src/config/workflow.js +6 -1
- package/src/{manifest.js → parser/manifest.js} +5 -6
- package/src/{media.js → parser/media.js} +1 -1
- package/src/parser/pkg.js +56 -0
- package/src/parser/project.js +59 -0
- package/src/{readme.js → parser/readme.js} +25 -15
- package/src/prompt/project.js +10 -0
- package/src/prompt/starter.js +41 -0
- package/src/schema/game.js +38 -15
- package/src/schema/workflow.js +7 -5
- package/src/user.js +91 -0
- package/src/util/dom.js +10 -36
- package/src/util/log.js +44 -3
- package/src/util/md.js +2 -2
- package/src/util/objs.js +14 -2
- package/src/util/os.js +24 -0
- package/src/util/output.js +54 -0
- package/src/util/request.js +62 -0
- package/src/util/schema.js +25 -0
- package/src/util/time.js +79 -0
- package/bin/arc-check.js +0 -74
- package/npm-shrinkwrap.json +0 -988
- package/src/cmd/check.js +0 -26
- package/src/cmd/deploy.js +0 -22
- package/src/cmd/index.js +0 -12
- package/src/cmd/inspect.js +0 -26
- package/src/cmd/pack.js +0 -24
- package/src/cmd-check/index.js +0 -57
- package/src/cmd-deploy/index.js +0 -43
- package/src/cmd-inspect/index.js +0 -53
- package/src/cmd-pack/index.js +0 -83
- package/src/project.js +0 -62
- package/src/util/arc.js +0 -74
- package/src/util/git.js +0 -23
package/src/user.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
9
|
+
const fs = require("fs-extra");
|
|
10
|
+
|
|
11
|
+
// [import]
|
|
12
|
+
|
|
13
|
+
const api = require("./api");
|
|
14
|
+
const os = require("./util/os");
|
|
15
|
+
|
|
16
|
+
// [use]
|
|
17
|
+
|
|
18
|
+
const configDir = os.configDir;
|
|
19
|
+
const join = path.join;
|
|
20
|
+
const mkdir = fs.promises.mkdir;
|
|
21
|
+
const readFile = fs.promises.readFile;
|
|
22
|
+
const unlink = fs.promises.unlink;
|
|
23
|
+
const writeFile = fs.promises.writeFile;
|
|
24
|
+
|
|
25
|
+
// [declare]
|
|
26
|
+
|
|
27
|
+
const CMD = "arc";
|
|
28
|
+
const FILE = "user.json";
|
|
29
|
+
|
|
30
|
+
// [define]
|
|
31
|
+
|
|
32
|
+
const dir = join(configDir(), CMD);
|
|
33
|
+
const file = join(dir, FILE);
|
|
34
|
+
|
|
35
|
+
// [function]
|
|
36
|
+
|
|
37
|
+
const expired = function (session) {
|
|
38
|
+
return session.expires_at <= Math.floor(Date.now() / 1000) + 60;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// [function]
|
|
42
|
+
|
|
43
|
+
const save = function (user) {
|
|
44
|
+
return mkdir(dir, { recursive: true })
|
|
45
|
+
.then(() => writeFile(file, JSON.stringify(user, null, 2), "utf8"))
|
|
46
|
+
.then(() => user);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// [function]
|
|
50
|
+
|
|
51
|
+
const refresh = function ({ session, ...user }) {
|
|
52
|
+
const form = new FormData();
|
|
53
|
+
form.append("refresh_token", session.refresh_token);
|
|
54
|
+
return api.authRefresh(form).then((data) => save({ ...user, session: data }));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// [function]
|
|
58
|
+
|
|
59
|
+
const get = function ({ onRefresh }) {
|
|
60
|
+
return readFile(file, "utf8")
|
|
61
|
+
.then(JSON.parse)
|
|
62
|
+
.catch((ex) => {
|
|
63
|
+
if (ex.code === "ENOENT") {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
throw ex;
|
|
67
|
+
})
|
|
68
|
+
.then((user) => {
|
|
69
|
+
if (!user || !user.session) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return expired(user.session)
|
|
73
|
+
? onRefresh((renew) => (renew ? refresh(user) : null))
|
|
74
|
+
: user;
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// [function]
|
|
79
|
+
|
|
80
|
+
const remove = function () {
|
|
81
|
+
return unlink(file).catch((ex) => {
|
|
82
|
+
if (ex.code === "ENOENT") {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw ex;
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// [export]
|
|
90
|
+
|
|
91
|
+
module.exports = { get, remove, save };
|
package/src/util/dom.js
CHANGED
|
@@ -9,45 +9,19 @@ const jsdom = require("jsdom");
|
|
|
9
9
|
|
|
10
10
|
const DOM = jsdom.JSDOM;
|
|
11
11
|
|
|
12
|
-
// [declare]
|
|
13
|
-
|
|
14
|
-
const AFM_ATTR_WHITELIST = ["href", "target", "rel", "src", "alt", "title"];
|
|
15
|
-
const AFM_TAG_WHITELIST = [
|
|
16
|
-
"h3",
|
|
17
|
-
"h4",
|
|
18
|
-
"h5",
|
|
19
|
-
"h6",
|
|
20
|
-
"hr",
|
|
21
|
-
"p",
|
|
22
|
-
"ul",
|
|
23
|
-
"ol",
|
|
24
|
-
"li",
|
|
25
|
-
"pre",
|
|
26
|
-
"img",
|
|
27
|
-
"a",
|
|
28
|
-
"code",
|
|
29
|
-
"strong",
|
|
30
|
-
"b",
|
|
31
|
-
"em",
|
|
32
|
-
"i",
|
|
33
|
-
"br",
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
// [function]
|
|
37
|
-
|
|
38
|
-
const sanitize = function (html) {
|
|
39
|
-
return dompurify(new DOM().window).sanitize(html);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
12
|
// [function]
|
|
43
13
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
14
|
+
const sanitize = function (str, cfg) {
|
|
15
|
+
const dom = dompurify(new DOM().window);
|
|
16
|
+
if (cfg) {
|
|
17
|
+
return dom.sanitize(str, {
|
|
18
|
+
ALLOWED_ATTR: cfg.ALLOWED_ATTR,
|
|
19
|
+
ALLOWED_TAGS: cfg.ALLOWED_TAGS,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return dom.sanitize(str);
|
|
49
23
|
};
|
|
50
24
|
|
|
51
25
|
// [export]
|
|
52
26
|
|
|
53
|
-
module.exports = { DOM, sanitize
|
|
27
|
+
module.exports = { DOM, sanitize };
|
package/src/util/log.js
CHANGED
|
@@ -61,13 +61,37 @@ const hdnl = function (message) {
|
|
|
61
61
|
// [function]
|
|
62
62
|
|
|
63
63
|
const pd = function (message) {
|
|
64
|
-
log(console.error, message, { color: "
|
|
64
|
+
log(console.error, message, { color: "red" });
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// [function]
|
|
68
68
|
|
|
69
69
|
const pdnl = function (message) {
|
|
70
|
-
log(console.error, message, { color: "
|
|
70
|
+
log(console.error, message, { color: "red", nl: true });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// [function]
|
|
74
|
+
|
|
75
|
+
const hw = function (message) {
|
|
76
|
+
log(console.log, message, { bold: true, color: "yellow" });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// [function]
|
|
80
|
+
|
|
81
|
+
const hwnl = function (message) {
|
|
82
|
+
log(console.log, message, { bold: true, color: "yellow", nl: true });
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// [function]
|
|
86
|
+
|
|
87
|
+
const pw = function (message) {
|
|
88
|
+
log(console.log, message, { color: "yellow" });
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// [function]
|
|
92
|
+
|
|
93
|
+
const pwnl = function (message) {
|
|
94
|
+
log(console.log, message, { color: "yellow", nl: true });
|
|
71
95
|
};
|
|
72
96
|
|
|
73
97
|
// [function]
|
|
@@ -96,4 +120,21 @@ const psnl = function (message) {
|
|
|
96
120
|
|
|
97
121
|
// [export]
|
|
98
122
|
|
|
99
|
-
module.exports = {
|
|
123
|
+
module.exports = {
|
|
124
|
+
h,
|
|
125
|
+
hd,
|
|
126
|
+
hdnl,
|
|
127
|
+
hnl,
|
|
128
|
+
hs,
|
|
129
|
+
hsnl,
|
|
130
|
+
hw,
|
|
131
|
+
hwnl,
|
|
132
|
+
p,
|
|
133
|
+
pd,
|
|
134
|
+
pdnl,
|
|
135
|
+
pnl,
|
|
136
|
+
ps,
|
|
137
|
+
psnl,
|
|
138
|
+
pw,
|
|
139
|
+
pwnl,
|
|
140
|
+
};
|
package/src/util/md.js
CHANGED
|
@@ -15,8 +15,8 @@ const stripLeadingInvisible = strs.stripLeadingInvisible;
|
|
|
15
15
|
|
|
16
16
|
// [function]
|
|
17
17
|
|
|
18
|
-
const parse = function (
|
|
19
|
-
return dom.sanitize(marked.parse(stripLeadingInvisible(
|
|
18
|
+
const parse = function (str) {
|
|
19
|
+
return dom.sanitize(marked.parse(stripLeadingInvisible(str)));
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
// [export]
|
package/src/util/objs.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const stringify = require("fast-json-stable-stringify");
|
|
6
|
+
|
|
3
7
|
// [function]
|
|
4
8
|
|
|
5
9
|
const pruneEmpty = function (value) {
|
|
@@ -22,5 +26,13 @@ const pruneEmpty = function (value) {
|
|
|
22
26
|
return value;
|
|
23
27
|
/* eslint-enable no-undefined */
|
|
24
28
|
};
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
// [function]
|
|
31
|
+
|
|
32
|
+
const sort = function (value) {
|
|
33
|
+
return JSON.parse(stringify(value));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// [export]
|
|
37
|
+
|
|
38
|
+
module.exports = { pruneEmpty, sort };
|
package/src/util/os.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const os = require("node:os");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
// [use]
|
|
9
|
+
|
|
10
|
+
const homedir = os.homedir;
|
|
11
|
+
const join = path.join;
|
|
12
|
+
|
|
13
|
+
// [function]
|
|
14
|
+
|
|
15
|
+
const configDir = function () {
|
|
16
|
+
if (process.platform === "win32") {
|
|
17
|
+
return process.env.APPDATA;
|
|
18
|
+
}
|
|
19
|
+
return join(homedir(), ".config");
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// [export]
|
|
23
|
+
|
|
24
|
+
module.exports = { configDir };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const TOML = require("@iarna/toml");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
9
|
+
const objs = require("./objs");
|
|
10
|
+
|
|
11
|
+
// [use]
|
|
12
|
+
|
|
13
|
+
const sort = objs.sort;
|
|
14
|
+
|
|
15
|
+
// [function]
|
|
16
|
+
|
|
17
|
+
const write = function (data) {
|
|
18
|
+
process.stdout.write(data.trim().concat("\n"));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// [function]
|
|
22
|
+
|
|
23
|
+
const printJson = function (data) {
|
|
24
|
+
write(JSON.stringify(sort(data), null, 2));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// [function]
|
|
28
|
+
|
|
29
|
+
const printToml = function (data, key = "value") {
|
|
30
|
+
const field = key.split(".").at(-1);
|
|
31
|
+
if (data === null) {
|
|
32
|
+
write(`# ${field} = null`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
write(TOML.stringify(sort(data)));
|
|
37
|
+
} catch (ex) {
|
|
38
|
+
write(TOML.stringify({ [field]: data }));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// [function]
|
|
43
|
+
|
|
44
|
+
const print = function (data, { key, toml } = {}) {
|
|
45
|
+
if (toml) {
|
|
46
|
+
printToml(data, key);
|
|
47
|
+
} else {
|
|
48
|
+
printJson(data);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// [export]
|
|
53
|
+
|
|
54
|
+
module.exports = { print, printJson, printToml };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [import]
|
|
4
|
+
|
|
5
|
+
const pkg = require("../../package.json");
|
|
6
|
+
|
|
7
|
+
// [declare]
|
|
8
|
+
|
|
9
|
+
const CLIENT_ID = "cli";
|
|
10
|
+
const CLIENT_VERSION = pkg.version;
|
|
11
|
+
|
|
12
|
+
// [function]
|
|
13
|
+
|
|
14
|
+
const parse = function (resp) {
|
|
15
|
+
return resp.json().then((json) => {
|
|
16
|
+
if (!resp.ok) {
|
|
17
|
+
throw new Error(json.data.message);
|
|
18
|
+
}
|
|
19
|
+
return json.data;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// [function]
|
|
24
|
+
|
|
25
|
+
const send = function (method, url, body, { token } = {}) {
|
|
26
|
+
const headers = {
|
|
27
|
+
"X-Arc-Client-Id": CLIENT_ID,
|
|
28
|
+
"X-Arc-Client-Version": CLIENT_VERSION,
|
|
29
|
+
};
|
|
30
|
+
if (token) {
|
|
31
|
+
headers.authorization = `Bearer ${token}`;
|
|
32
|
+
}
|
|
33
|
+
return fetch(url, { body, headers, method }).then(parse);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// [function]
|
|
37
|
+
|
|
38
|
+
const get = function (url, options) {
|
|
39
|
+
return send("GET", url, null, options);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// [function]
|
|
43
|
+
|
|
44
|
+
const post = function (url, body, options) {
|
|
45
|
+
return send("POST", url, body, options);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// [function]
|
|
49
|
+
|
|
50
|
+
const patch = function (url, body, options) {
|
|
51
|
+
return send("PATCH", url, body, options);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// [function]
|
|
55
|
+
|
|
56
|
+
const del = function (url, options) {
|
|
57
|
+
return send("DELETE", url, null, options);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// [export]
|
|
61
|
+
|
|
62
|
+
module.exports = { del, get, patch, post };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// [function]
|
|
4
|
+
|
|
5
|
+
const format = function (name, error) {
|
|
6
|
+
return error.issues.map(
|
|
7
|
+
(issue) => `${name}.${issue.path.join(".") || "value"}: ${issue.message}`,
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// [function]
|
|
12
|
+
|
|
13
|
+
const validator = function (name, schema) {
|
|
14
|
+
return function (value, conf) {
|
|
15
|
+
const result = schema(value, conf).safeParse(value);
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
return { issues: format(name, result.error) };
|
|
18
|
+
}
|
|
19
|
+
return { issues: [] };
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// [export]
|
|
24
|
+
|
|
25
|
+
module.exports = { validator };
|
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/bin/arc-check.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
// [import]
|
|
5
|
-
|
|
6
|
-
const path = require("node:path");
|
|
7
|
-
|
|
8
|
-
// [import]
|
|
9
|
-
|
|
10
|
-
const hideBin = require("yargs/helpers").hideBin;
|
|
11
|
-
const yargs = require("yargs/yargs");
|
|
12
|
-
|
|
13
|
-
// [import]
|
|
14
|
-
|
|
15
|
-
const check = require("../src/cmd/check");
|
|
16
|
-
const pkg = require("../package.json");
|
|
17
|
-
const rc = require("../src/util/rc");
|
|
18
|
-
|
|
19
|
-
// [use]
|
|
20
|
-
|
|
21
|
-
const dirname = path.dirname;
|
|
22
|
-
const findRc = rc.findRc;
|
|
23
|
-
const join = path.join;
|
|
24
|
-
const resolve = path.resolve;
|
|
25
|
-
|
|
26
|
-
// [declare]
|
|
27
|
-
|
|
28
|
-
const CMD = "arc";
|
|
29
|
-
const SUBCMD = "check";
|
|
30
|
-
|
|
31
|
-
// [define]
|
|
32
|
-
|
|
33
|
-
const conf = {
|
|
34
|
-
quiet: false,
|
|
35
|
-
...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// [function]
|
|
39
|
-
|
|
40
|
-
const fixBin = function (argv) {
|
|
41
|
-
argv[1] = join(dirname(argv[1]), CMD);
|
|
42
|
-
return hideBin(argv);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// [function]
|
|
46
|
-
|
|
47
|
-
const start = function (cli) {
|
|
48
|
-
const argv = cli.parse();
|
|
49
|
-
check({ quiet: argv.quiet, root: resolve(process.cwd(), argv.cwd) });
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// [start]
|
|
53
|
-
|
|
54
|
-
start(
|
|
55
|
-
yargs(fixBin(process.argv))
|
|
56
|
-
.usage(`${CMD} ${SUBCMD} [options]`)
|
|
57
|
-
.option("quiet", {
|
|
58
|
-
alias: "q",
|
|
59
|
-
default: conf.quiet,
|
|
60
|
-
describe: "Suppress standard output and show only errors.",
|
|
61
|
-
type: "boolean",
|
|
62
|
-
})
|
|
63
|
-
.option("cwd", {
|
|
64
|
-
alias: "C",
|
|
65
|
-
default: ".",
|
|
66
|
-
describe: "Run in the specified path.",
|
|
67
|
-
type: "string",
|
|
68
|
-
})
|
|
69
|
-
.help("help")
|
|
70
|
-
.alias("help", "h")
|
|
71
|
-
.version(pkg.version)
|
|
72
|
-
.alias("version", "v")
|
|
73
|
-
.strict(),
|
|
74
|
-
);
|