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/bin/arc-default.js
CHANGED
|
@@ -3,10 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
// [import]
|
|
5
5
|
|
|
6
|
-
const path = require("node:path");
|
|
7
|
-
|
|
8
|
-
// [import]
|
|
9
|
-
|
|
10
6
|
const hideBin = require("yargs/helpers").hideBin;
|
|
11
7
|
const yargs = require("yargs/yargs");
|
|
12
8
|
|
|
@@ -14,43 +10,47 @@ const yargs = require("yargs/yargs");
|
|
|
14
10
|
|
|
15
11
|
const pkg = require("../package.json");
|
|
16
12
|
|
|
17
|
-
// [use]
|
|
18
|
-
|
|
19
|
-
const dirname = path.dirname;
|
|
20
|
-
const join = path.join;
|
|
21
|
-
|
|
22
13
|
// [declare]
|
|
23
14
|
|
|
24
15
|
const CMD = "arc";
|
|
25
16
|
|
|
26
17
|
// [function]
|
|
27
18
|
|
|
28
|
-
const
|
|
29
|
-
argv[1] = join(dirname(argv[1]), CMD);
|
|
30
|
-
return hideBin(argv);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// [function]
|
|
34
|
-
|
|
35
|
-
const start = function (cli) {
|
|
19
|
+
const parse = function (cli) {
|
|
36
20
|
const argv = cli.parse();
|
|
37
21
|
if (!argv._.length) {
|
|
38
22
|
cli.showHelp();
|
|
39
23
|
}
|
|
40
24
|
};
|
|
41
25
|
|
|
42
|
-
// [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
26
|
+
// [function]
|
|
27
|
+
|
|
28
|
+
const main = function (argv) {
|
|
29
|
+
return parse(
|
|
30
|
+
yargs(hideBin(argv))
|
|
31
|
+
.scriptName(CMD)
|
|
32
|
+
.usage("$0 <command> [options]")
|
|
33
|
+
.command("deploy", "Deploy to Arcadible")
|
|
34
|
+
.command("init", "Initialize a project")
|
|
35
|
+
.command("inspect", "Inspect project metadata")
|
|
36
|
+
.command("login", "Log in to Arcadible")
|
|
37
|
+
.command("logout", "Log out of Arcadible")
|
|
38
|
+
.command("validate", "Validate workspace")
|
|
39
|
+
.command("whoami", "Show current account")
|
|
40
|
+
.help("help")
|
|
41
|
+
.alias("help", "h")
|
|
42
|
+
.version(pkg.version)
|
|
43
|
+
.alias("version", "v")
|
|
44
|
+
.strict(),
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// [main]
|
|
49
|
+
|
|
50
|
+
if (require.main === module) {
|
|
51
|
+
main(process.argv);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// [export]
|
|
55
|
+
|
|
56
|
+
module.exports = { main };
|
package/bin/arc-deploy.js
CHANGED
|
@@ -12,15 +12,17 @@ const yargs = require("yargs/yargs");
|
|
|
12
12
|
|
|
13
13
|
// [import]
|
|
14
14
|
|
|
15
|
-
const deploy = require("../src/
|
|
15
|
+
const deploy = require("../src/cli/deploy");
|
|
16
|
+
const log = require("../src/util/log");
|
|
17
|
+
const output = require("../src/util/output");
|
|
16
18
|
const pkg = require("../package.json");
|
|
17
19
|
const rc = require("../src/util/rc");
|
|
20
|
+
const validate = require("../src/cli/validate");
|
|
18
21
|
|
|
19
22
|
// [use]
|
|
20
23
|
|
|
21
|
-
const dirname = path.dirname;
|
|
22
24
|
const findRc = rc.findRc;
|
|
23
|
-
const
|
|
25
|
+
const print = output.print;
|
|
24
26
|
const resolve = path.resolve;
|
|
25
27
|
|
|
26
28
|
// [declare]
|
|
@@ -31,6 +33,7 @@ const SUBCMD = "deploy";
|
|
|
31
33
|
// [define]
|
|
32
34
|
|
|
33
35
|
const conf = {
|
|
36
|
+
json: false,
|
|
34
37
|
production: false,
|
|
35
38
|
quiet: false,
|
|
36
39
|
...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
|
|
@@ -38,49 +41,117 @@ const conf = {
|
|
|
38
41
|
|
|
39
42
|
// [function]
|
|
40
43
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const handler = function ({ json, quiet }) {
|
|
45
|
+
return {
|
|
46
|
+
onBegin() {
|
|
47
|
+
if (!json && !quiet) {
|
|
48
|
+
log.p("Deploying project...");
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
onInfo({ level, message }) {
|
|
52
|
+
if (json || quiet) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
switch (level) {
|
|
56
|
+
case "warn":
|
|
57
|
+
log.pw(`⚠ ${message}`);
|
|
58
|
+
return;
|
|
59
|
+
default:
|
|
60
|
+
log.p(`• ${message}`);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
44
64
|
};
|
|
45
65
|
|
|
46
66
|
// [function]
|
|
47
67
|
|
|
48
|
-
const start = function (
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
const start = function (argv) {
|
|
69
|
+
const json = argv.json;
|
|
70
|
+
const pre = !argv.production;
|
|
71
|
+
const quiet = argv.quiet;
|
|
72
|
+
const root = resolve(process.cwd(), argv.cwd);
|
|
73
|
+
return validate({ root })
|
|
74
|
+
.then((issues) => {
|
|
75
|
+
const valid = !issues.length;
|
|
76
|
+
if (!valid) {
|
|
77
|
+
throw new Error("Validate failed. Run `arc validate` for details.");
|
|
78
|
+
}
|
|
79
|
+
return deploy({
|
|
80
|
+
direct: false,
|
|
81
|
+
handler: handler({ json, quiet }),
|
|
82
|
+
pre,
|
|
83
|
+
preId: "rc",
|
|
84
|
+
root,
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
.then((data) => {
|
|
88
|
+
if (json) {
|
|
89
|
+
print({ version: data });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (!quiet) {
|
|
93
|
+
log.p(`✓ ${pre ? "Prerelease" : "Release"} v${data.to} submitted.`);
|
|
94
|
+
log.hs("Deployed.");
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
.catch((ex) => {
|
|
98
|
+
const message = ex.message;
|
|
99
|
+
if (json) {
|
|
100
|
+
print({ error: { message } });
|
|
101
|
+
} else {
|
|
102
|
+
log.hd("Deploy aborted.");
|
|
103
|
+
log.p(message);
|
|
104
|
+
}
|
|
105
|
+
process.exit(1);
|
|
106
|
+
});
|
|
56
107
|
};
|
|
57
108
|
|
|
58
|
-
// [
|
|
109
|
+
// [function]
|
|
59
110
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
const main = function (argv) {
|
|
112
|
+
return start(
|
|
113
|
+
yargs(hideBin(argv))
|
|
114
|
+
.scriptName(`${CMD} ${SUBCMD}`)
|
|
115
|
+
.usage("$0 [options]")
|
|
116
|
+
.option("production", {
|
|
117
|
+
alias: "p",
|
|
118
|
+
default: conf.production,
|
|
119
|
+
describe: "Deploy to production.",
|
|
120
|
+
type: "boolean",
|
|
121
|
+
})
|
|
122
|
+
.option("json", {
|
|
123
|
+
alias: "j",
|
|
124
|
+
default: conf.json,
|
|
125
|
+
describe: "Format output as JSON.",
|
|
126
|
+
type: "boolean",
|
|
127
|
+
})
|
|
128
|
+
.option("quiet", {
|
|
129
|
+
alias: "q",
|
|
130
|
+
default: conf.quiet,
|
|
131
|
+
describe: "Output only errors.",
|
|
132
|
+
type: "boolean",
|
|
133
|
+
})
|
|
134
|
+
.option("cwd", {
|
|
135
|
+
alias: "C",
|
|
136
|
+
default: ".",
|
|
137
|
+
describe: "Set the working directory.",
|
|
138
|
+
type: "string",
|
|
139
|
+
})
|
|
140
|
+
.help("help")
|
|
141
|
+
.alias("help", "h")
|
|
142
|
+
.version(pkg.version)
|
|
143
|
+
.alias("version", "v")
|
|
144
|
+
.strict()
|
|
145
|
+
.parse(),
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// [main]
|
|
150
|
+
|
|
151
|
+
if (require.main === module) {
|
|
152
|
+
main(process.argv);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// [export]
|
|
156
|
+
|
|
157
|
+
module.exports = { main };
|
package/bin/arc-init.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
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 prompts = require("@inquirer/prompts");
|
|
12
|
+
const yargs = require("yargs/yargs");
|
|
13
|
+
|
|
14
|
+
// [import]
|
|
15
|
+
|
|
16
|
+
const cfgurl = require("../src/config/url");
|
|
17
|
+
const init = require("../src/cli/init");
|
|
18
|
+
const log = require("../src/util/log");
|
|
19
|
+
const output = require("../src/util/output");
|
|
20
|
+
const pkg = require("../package.json");
|
|
21
|
+
const project = require("../src/prompt/project");
|
|
22
|
+
const rc = require("../src/util/rc");
|
|
23
|
+
const starter = require("../src/prompt/starter");
|
|
24
|
+
|
|
25
|
+
// [use]
|
|
26
|
+
|
|
27
|
+
const findRc = rc.findRc;
|
|
28
|
+
const input = prompts.input;
|
|
29
|
+
const print = output.print;
|
|
30
|
+
const relative = path.relative;
|
|
31
|
+
const resolve = path.resolve;
|
|
32
|
+
const select = prompts.select;
|
|
33
|
+
|
|
34
|
+
// [declare]
|
|
35
|
+
|
|
36
|
+
const CMD = "arc";
|
|
37
|
+
const SUBCMD = "init";
|
|
38
|
+
|
|
39
|
+
// [define]
|
|
40
|
+
|
|
41
|
+
const conf = {
|
|
42
|
+
force: false,
|
|
43
|
+
json: false,
|
|
44
|
+
quiet: false,
|
|
45
|
+
yes: false,
|
|
46
|
+
...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// [function]
|
|
50
|
+
|
|
51
|
+
const handler = function ({ json, quiet }) {
|
|
52
|
+
return {
|
|
53
|
+
onBegin() {
|
|
54
|
+
if (!json && !quiet) {
|
|
55
|
+
log.p("Initializing project...");
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
onInfo() {},
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// [function]
|
|
63
|
+
|
|
64
|
+
const start = function (argv) {
|
|
65
|
+
const json = argv.json;
|
|
66
|
+
const quiet = argv.quiet;
|
|
67
|
+
const root = resolve(process.cwd(), argv.cwd);
|
|
68
|
+
return init({
|
|
69
|
+
force: argv.force,
|
|
70
|
+
handler: handler({ json, quiet }),
|
|
71
|
+
project: argv.project,
|
|
72
|
+
root,
|
|
73
|
+
starter: argv.starter,
|
|
74
|
+
})
|
|
75
|
+
.then((data) => {
|
|
76
|
+
const dir = relative(root, data.path);
|
|
77
|
+
if (json) {
|
|
78
|
+
print({ project: data });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!quiet) {
|
|
82
|
+
log.hsnl("Initialized.");
|
|
83
|
+
log.h("Next steps:");
|
|
84
|
+
log.pnl(
|
|
85
|
+
[data.path === root ? null : `cd ${dir}`, "npm install", "arc deploy"]
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
.join(" && "),
|
|
88
|
+
);
|
|
89
|
+
log.h("Getting started:");
|
|
90
|
+
log.p(cfgurl.GETTING_STARTED);
|
|
91
|
+
}
|
|
92
|
+
// degit sometimes hangs
|
|
93
|
+
process.exit(0);
|
|
94
|
+
})
|
|
95
|
+
.catch((ex) => {
|
|
96
|
+
const message = ex.message;
|
|
97
|
+
if (json) {
|
|
98
|
+
print({ error: { message } });
|
|
99
|
+
} else {
|
|
100
|
+
log.hd("Init aborted.");
|
|
101
|
+
log.p(message);
|
|
102
|
+
}
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// [function]
|
|
108
|
+
|
|
109
|
+
const prompt = async function ({ yes, ...argv }) {
|
|
110
|
+
const opts = { ...argv };
|
|
111
|
+
if (yes) {
|
|
112
|
+
opts.project ??= project.input.default;
|
|
113
|
+
opts.starter ??= starter.select.default;
|
|
114
|
+
return opts;
|
|
115
|
+
}
|
|
116
|
+
if (!argv.project) {
|
|
117
|
+
opts.project = await input(project.input);
|
|
118
|
+
}
|
|
119
|
+
if (!argv.starter) {
|
|
120
|
+
opts.starter = await select(starter.select);
|
|
121
|
+
}
|
|
122
|
+
return opts;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// [function]
|
|
126
|
+
|
|
127
|
+
const main = function (argv) {
|
|
128
|
+
return prompt(
|
|
129
|
+
yargs(hideBin(argv))
|
|
130
|
+
.scriptName(`${CMD} ${SUBCMD}`)
|
|
131
|
+
.usage("$0 <project> [options]")
|
|
132
|
+
.command("$0 <project>", false, (cli) =>
|
|
133
|
+
cli.positional("project", {
|
|
134
|
+
describe: "Set the project directory.",
|
|
135
|
+
type: "string",
|
|
136
|
+
}),
|
|
137
|
+
)
|
|
138
|
+
.option("starter", {
|
|
139
|
+
alias: "t",
|
|
140
|
+
describe: "Select a project starter.",
|
|
141
|
+
type: "string",
|
|
142
|
+
})
|
|
143
|
+
.option("yes", {
|
|
144
|
+
alias: "y",
|
|
145
|
+
default: conf.yes,
|
|
146
|
+
describe: "Answer prompts using default values.",
|
|
147
|
+
type: "boolean",
|
|
148
|
+
})
|
|
149
|
+
.option("force", {
|
|
150
|
+
alias: "f",
|
|
151
|
+
default: conf.force,
|
|
152
|
+
describe: "Overwrite an existing directory.",
|
|
153
|
+
type: "boolean",
|
|
154
|
+
})
|
|
155
|
+
.option("json", {
|
|
156
|
+
alias: "j",
|
|
157
|
+
default: conf.json,
|
|
158
|
+
describe: "Format output as JSON.",
|
|
159
|
+
type: "boolean",
|
|
160
|
+
})
|
|
161
|
+
.option("quiet", {
|
|
162
|
+
alias: "q",
|
|
163
|
+
default: conf.quiet,
|
|
164
|
+
describe: "Output only errors.",
|
|
165
|
+
type: "boolean",
|
|
166
|
+
})
|
|
167
|
+
.option("cwd", {
|
|
168
|
+
alias: "C",
|
|
169
|
+
default: ".",
|
|
170
|
+
describe: "Set the working directory.",
|
|
171
|
+
type: "string",
|
|
172
|
+
})
|
|
173
|
+
.help("help")
|
|
174
|
+
.alias("help", "h")
|
|
175
|
+
.version(pkg.version)
|
|
176
|
+
.alias("version", "v")
|
|
177
|
+
.strict()
|
|
178
|
+
.parse(),
|
|
179
|
+
)
|
|
180
|
+
.then(start)
|
|
181
|
+
.catch((ex) => {
|
|
182
|
+
if (ex && ex.name === "ExitPromptError") {
|
|
183
|
+
process.exit(0);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// [main]
|
|
189
|
+
|
|
190
|
+
if (require.main === module) {
|
|
191
|
+
main(process.argv);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// [export]
|
|
195
|
+
|
|
196
|
+
module.exports = { main };
|
package/bin/arc-inspect.js
CHANGED
|
@@ -12,15 +12,16 @@ const yargs = require("yargs/yargs");
|
|
|
12
12
|
|
|
13
13
|
// [import]
|
|
14
14
|
|
|
15
|
-
const inspect = require("../src/
|
|
15
|
+
const inspect = require("../src/cli/inspect");
|
|
16
|
+
const log = require("../src/util/log");
|
|
17
|
+
const output = require("../src/util/output");
|
|
16
18
|
const pkg = require("../package.json");
|
|
17
19
|
const rc = require("../src/util/rc");
|
|
18
20
|
|
|
19
21
|
// [use]
|
|
20
22
|
|
|
21
|
-
const dirname = path.dirname;
|
|
22
23
|
const findRc = rc.findRc;
|
|
23
|
-
const
|
|
24
|
+
const print = output.print;
|
|
24
25
|
const resolve = path.resolve;
|
|
25
26
|
|
|
26
27
|
// [declare]
|
|
@@ -32,55 +33,75 @@ const SUBCMD = "inspect";
|
|
|
32
33
|
|
|
33
34
|
const conf = {
|
|
34
35
|
json: false,
|
|
35
|
-
|
|
36
|
+
key: "",
|
|
36
37
|
...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
// [function]
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const start = function (argv) {
|
|
43
|
+
const json = argv.json;
|
|
44
|
+
const key = argv.key;
|
|
45
|
+
return inspect({
|
|
46
|
+
key,
|
|
47
|
+
root: resolve(process.cwd(), argv.cwd),
|
|
48
|
+
})
|
|
49
|
+
.then((data) => {
|
|
50
|
+
print(data, { key, toml: !json });
|
|
51
|
+
})
|
|
52
|
+
.catch((ex) => {
|
|
53
|
+
const message = ex.message;
|
|
54
|
+
if (json) {
|
|
55
|
+
print({ error: { message } });
|
|
56
|
+
} else {
|
|
57
|
+
log.hd("Inspect aborted.");
|
|
58
|
+
log.p(message);
|
|
59
|
+
}
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
44
62
|
};
|
|
45
63
|
|
|
46
64
|
// [function]
|
|
47
65
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
const main = function (argv) {
|
|
67
|
+
return start(
|
|
68
|
+
yargs(hideBin(argv))
|
|
69
|
+
.scriptName(`${CMD} ${SUBCMD}`)
|
|
70
|
+
.usage("$0 [key] [options]")
|
|
71
|
+
.command("$0 [key]", false, (cli) =>
|
|
72
|
+
cli.positional("key", {
|
|
73
|
+
default: conf.key,
|
|
74
|
+
describe: "Select a metadata key.",
|
|
75
|
+
type: "string",
|
|
76
|
+
}),
|
|
77
|
+
)
|
|
78
|
+
.option("json", {
|
|
79
|
+
alias: "j",
|
|
80
|
+
default: conf.json,
|
|
81
|
+
describe: "Format output as JSON.",
|
|
82
|
+
type: "boolean",
|
|
83
|
+
})
|
|
84
|
+
.option("cwd", {
|
|
85
|
+
alias: "C",
|
|
86
|
+
default: ".",
|
|
87
|
+
describe: "Set the working directory.",
|
|
88
|
+
type: "string",
|
|
89
|
+
})
|
|
90
|
+
.help("help")
|
|
91
|
+
.alias("help", "h")
|
|
92
|
+
.version(pkg.version)
|
|
93
|
+
.alias("version", "v")
|
|
94
|
+
.strict()
|
|
95
|
+
.parse(),
|
|
96
|
+
);
|
|
55
97
|
};
|
|
56
98
|
|
|
57
|
-
// [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
describe: "Output details about a topic.",
|
|
67
|
-
type: "string",
|
|
68
|
-
})
|
|
69
|
-
.option("json", {
|
|
70
|
-
alias: "j",
|
|
71
|
-
default: conf.json,
|
|
72
|
-
describe: "Format standard output in JSON.",
|
|
73
|
-
type: "boolean",
|
|
74
|
-
})
|
|
75
|
-
.option("cwd", {
|
|
76
|
-
alias: "C",
|
|
77
|
-
default: ".",
|
|
78
|
-
describe: "Run in the specified path.",
|
|
79
|
-
type: "string",
|
|
80
|
-
})
|
|
81
|
-
.help("help")
|
|
82
|
-
.alias("help", "h")
|
|
83
|
-
.version(pkg.version)
|
|
84
|
-
.alias("version", "v")
|
|
85
|
-
.strict(),
|
|
86
|
-
);
|
|
99
|
+
// [main]
|
|
100
|
+
|
|
101
|
+
if (require.main === module) {
|
|
102
|
+
main(process.argv);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// [export]
|
|
106
|
+
|
|
107
|
+
module.exports = { main };
|