arcadible 1.0.23 → 1.0.25
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 +1 -0
- package/bin/arc.js +1 -85
- package/dist/account.js +197 -0
- package/dist/action/build/tool.js +61 -0
- package/dist/action/delete/tool.js +47 -0
- package/dist/action/deploy/rebuilt.js +25 -0
- package/dist/action/deploy/result.js +36 -0
- package/dist/action/deploy/timeout.js +18 -0
- package/dist/action/deploy/tool-git.js +49 -0
- package/dist/action/deploy/tool.js +49 -0
- package/dist/action/deploy/wait.js +104 -0
- package/dist/action/function/tool.js +127 -0
- package/dist/action/game.js +62 -0
- package/dist/action/init/manifest.js +64 -0
- package/dist/action/init/tool-patch.js +15 -0
- package/dist/action/init/tool.js +64 -0
- package/dist/action/inspect/tool.js +13 -0
- package/dist/action/key/tool.js +88 -0
- package/dist/action/login/flow.js +69 -0
- package/dist/action/login/tool.js +8 -0
- package/dist/action/logout/tool.js +8 -0
- package/dist/action/open/tool.js +30 -0
- package/dist/action/pack/limits.js +46 -0
- package/dist/action/pack/tool.js +148 -0
- package/dist/action/pack/unsound.js +51 -0
- package/dist/action/play/tool.js +84 -0
- package/dist/action/predeploy/ac.js +75 -0
- package/dist/action/predeploy/game.js +6 -0
- package/dist/action/predeploy/git.js +151 -0
- package/dist/action/predeploy/pm.js +20 -0
- package/dist/action/predeploy/published.js +54 -0
- package/dist/action/predeploy/secrets.js +35 -0
- package/dist/action/predeploy/tool-git.js +103 -0
- package/dist/action/predeploy/tool.js +14 -0
- package/dist/action/secret/tool.js +91 -0
- package/dist/action/serve/tool.js +270 -0
- package/dist/action/validate/checked.js +28 -0
- package/dist/action/validate/tool.js +56 -0
- package/dist/action/validate/unknown.js +58 -0
- package/dist/action/validate/unsound.js +99 -0
- package/dist/action/value/tool.js +216 -0
- package/dist/action/whoami/tool.js +7 -0
- package/dist/api.js +312 -0
- package/dist/arc.js +41 -0
- package/dist/cli/argv.js +61 -0
- package/dist/cli/channel.js +29 -0
- package/dist/cli/command.js +163 -0
- package/dist/cli/confirm.js +39 -0
- package/dist/cli/options.js +62 -0
- package/dist/cli/rc.js +103 -0
- package/dist/cli/yargs.js +40 -0
- package/dist/command/build.js +68 -0
- package/dist/command/delete.js +66 -0
- package/dist/command/deploy.js +308 -0
- package/dist/command/function/index.js +17 -0
- package/dist/command/function/pause.js +18 -0
- package/dist/command/function/resume.js +18 -0
- package/dist/command/function/run.js +41 -0
- package/dist/command/function/secret/index.js +15 -0
- package/dist/command/function/secret/list.js +27 -0
- package/dist/command/function/secret/name.js +8 -0
- package/dist/command/function/secret/remove.js +26 -0
- package/dist/command/function/secret/run.js +52 -0
- package/dist/command/function/secret/set.js +48 -0
- package/dist/command/function/status.js +40 -0
- package/dist/command/init.js +128 -0
- package/dist/command/inspect.js +39 -0
- package/dist/command/login.js +108 -0
- package/dist/command/logout.js +24 -0
- package/dist/command/open.js +49 -0
- package/dist/command/pack.js +90 -0
- package/dist/command/play.js +81 -0
- package/dist/command/serve.js +177 -0
- package/dist/command/server/index.js +17 -0
- package/dist/command/server/key/create.js +36 -0
- package/dist/command/server/key/index.js +15 -0
- package/dist/command/server/key/list.js +34 -0
- package/dist/command/server/key/revoke.js +24 -0
- package/dist/command/server/key/run.js +54 -0
- package/dist/command/validate.js +47 -0
- package/dist/command/value/get.js +21 -0
- package/dist/command/value/index.js +19 -0
- package/dist/command/value/key.js +8 -0
- package/dist/command/value/list.js +41 -0
- package/dist/command/value/remove.js +26 -0
- package/dist/command/value/set.js +62 -0
- package/dist/command/value/usage.js +69 -0
- package/dist/command/whoami.js +55 -0
- package/dist/commands.js +100 -0
- package/dist/config/ai.js +2 -0
- package/dist/config/art.js +13 -0
- package/dist/config/audience.js +2 -0
- package/dist/config/code.js +129 -0
- package/dist/config/file.js +13 -0
- package/dist/config/genre.js +19 -0
- package/{src → dist}/config/html.js +2 -7
- package/dist/config/image.js +5 -0
- package/dist/config/input.js +11 -0
- package/dist/config/json.js +23 -0
- package/dist/config/limit.js +14 -0
- package/dist/config/orientation.js +11 -0
- package/dist/config/package.js +8 -0
- package/dist/config/product.js +14 -0
- package/dist/config/template.js +37 -0
- package/dist/config/uri.js +18 -0
- package/dist/config/url.js +11 -0
- package/dist/config/video.js +5 -0
- package/dist/config/visibility.js +2 -0
- package/dist/config/workflow.js +7 -0
- package/dist/parser/env.js +61 -0
- package/dist/parser/given.js +8 -0
- package/dist/parser/manifest.js +45 -0
- package/dist/parser/media.js +57 -0
- package/dist/parser/project.js +129 -0
- package/dist/parser/readme-file.js +44 -0
- package/dist/parser/readme.js +70 -0
- package/dist/parser/sections.js +92 -0
- package/dist/parser/self.js +16 -0
- package/dist/phrase/account.js +35 -0
- package/dist/phrase/common.js +139 -0
- package/dist/phrase/deploy.js +192 -0
- package/dist/phrase/function.js +139 -0
- package/dist/phrase/game.js +27 -0
- package/dist/phrase/index.js +16 -0
- package/dist/phrase/init.js +53 -0
- package/dist/phrase/internal.js +61 -0
- package/dist/phrase/manifest.js +120 -0
- package/dist/phrase/media.js +90 -0
- package/dist/phrase/pack.js +69 -0
- package/dist/phrase/serve.js +84 -0
- package/dist/phrase/server.js +38 -0
- package/dist/phrase/value.js +55 -0
- package/dist/runner/bundle.js +45 -0
- package/dist/runner/entry.js +57 -0
- package/dist/runner/outbound.js +69 -0
- package/dist/schema/check/game.js +29 -0
- package/dist/schema/check/workflow.js +57 -0
- package/dist/schema/game.js +462 -0
- package/dist/schema/message.js +61 -0
- package/dist/schema/readme.js +27 -0
- package/dist/schema/runner.js +43 -0
- package/dist/schema/server.js +91 -0
- package/dist/schema/workflow.js +99 -0
- package/dist/serve/files.js +39 -0
- package/dist/serve/game.js +172 -0
- package/dist/serve/page.js +689 -0
- package/dist/serve/reload.js +55 -0
- package/dist/serve/remote.js +114 -0
- package/dist/serve/runner.js +303 -0
- package/dist/serve/server.js +169 -0
- package/dist/serve/ticket.js +232 -0
- package/dist/serve/values.js +317 -0
- package/dist/util/bytes.js +16 -0
- package/dist/util/chars.js +19 -0
- package/dist/util/command.js +11 -0
- package/dist/util/delay.js +36 -0
- package/dist/util/doc.js +59 -0
- package/dist/util/error.js +35 -0
- package/dist/util/http.js +13 -0
- package/dist/util/image.js +64 -0
- package/dist/util/links.js +45 -0
- package/dist/util/lockfile.js +17 -0
- package/dist/util/log.js +101 -0
- package/dist/util/md.js +37 -0
- package/dist/util/media.js +27 -0
- package/dist/util/objs.js +46 -0
- package/dist/util/os.js +13 -0
- package/dist/util/output.js +133 -0
- package/dist/util/paths.js +8 -0
- package/dist/util/progress.js +57 -0
- package/dist/util/promise.js +18 -0
- package/dist/util/request.js +103 -0
- package/dist/util/s3.js +67 -0
- package/dist/util/schema.js +151 -0
- package/dist/util/screenshot.js +24 -0
- package/dist/util/shape.js +49 -0
- package/dist/util/shell.js +64 -0
- package/dist/util/size.js +32 -0
- package/dist/util/spinner.js +35 -0
- package/dist/util/strs.js +46 -0
- package/dist/util/table.js +18 -0
- package/dist/util/term.js +21 -0
- package/dist/util/time.js +16 -0
- package/dist/util/toml.js +28 -0
- package/{src → dist}/util/uris.js +8 -14
- package/dist/util/video.js +113 -0
- package/dist/util/zip.js +62 -0
- package/npm-shrinkwrap.json +3256 -0
- package/package.json +41 -39
- package/bin/arc-build.js +0 -139
- package/bin/arc-default.js +0 -65
- package/bin/arc-deploy.js +0 -456
- package/bin/arc-init.js +0 -187
- package/bin/arc-inspect.js +0 -97
- package/bin/arc-login.js +0 -165
- package/bin/arc-logout.js +0 -75
- package/bin/arc-open.js +0 -104
- package/bin/arc-pack.js +0 -146
- package/bin/arc-play.js +0 -140
- package/bin/arc-serve.js +0 -214
- package/bin/arc-validate.js +0 -112
- package/bin/arc-whoami.js +0 -119
- package/src/account.js +0 -249
- package/src/action/build/tool.js +0 -80
- package/src/action/deploy/tool-git.js +0 -90
- package/src/action/deploy/tool.js +0 -88
- package/src/action/deploy/wait.js +0 -151
- package/src/action/init/manifest.js +0 -83
- package/src/action/init/tool-patch.js +0 -32
- package/src/action/init/tool.js +0 -97
- package/src/action/inspect/tool.js +0 -26
- package/src/action/login/flow.js +0 -101
- package/src/action/login/tool.js +0 -16
- package/src/action/logout/tool.js +0 -15
- package/src/action/open/tool.js +0 -38
- package/src/action/pack/limits.js +0 -51
- package/src/action/pack/tool.js +0 -171
- package/src/action/pack/unsound.js +0 -69
- package/src/action/play/tool.js +0 -109
- package/src/action/predeploy/ac.js +0 -112
- package/src/action/predeploy/git.js +0 -223
- package/src/action/predeploy/pm.js +0 -37
- package/src/action/predeploy/published.js +0 -82
- package/src/action/predeploy/tool-git.js +0 -154
- package/src/action/predeploy/tool.js +0 -29
- package/src/action/serve/tool.js +0 -209
- package/src/action/validate/checked.js +0 -37
- package/src/action/validate/tool.js +0 -67
- package/src/action/validate/unknown.js +0 -86
- package/src/action/validate/unsound.js +0 -138
- package/src/action/whoami/tool.js +0 -15
- package/src/api.js +0 -163
- package/src/cli/build.js +0 -15
- package/src/cli/deploy.js +0 -21
- package/src/cli/init.js +0 -17
- package/src/cli/inspect.js +0 -15
- package/src/cli/login.js +0 -15
- package/src/cli/logout.js +0 -15
- package/src/cli/open.js +0 -15
- package/src/cli/pack.js +0 -15
- package/src/cli/play.js +0 -15
- package/src/cli/predeploy.js +0 -21
- package/src/cli/serve.js +0 -15
- package/src/cli/validate.js +0 -15
- package/src/cli/whoami.js +0 -15
- package/src/config/ai.js +0 -5
- package/src/config/art.js +0 -16
- package/src/config/audience.js +0 -5
- package/src/config/code.js +0 -142
- package/src/config/file.js +0 -23
- package/src/config/genre.js +0 -22
- package/src/config/image.js +0 -7
- package/src/config/input.js +0 -14
- package/src/config/limit.js +0 -21
- package/src/config/orientation.js +0 -14
- package/src/config/package.js +0 -5
- package/src/config/product.js +0 -5
- package/src/config/template.js +0 -45
- package/src/config/uri.js +0 -27
- package/src/config/url.js +0 -20
- package/src/config/video.js +0 -7
- package/src/config/visibility.js +0 -5
- package/src/config/workflow.js +0 -18
- package/src/parser/env.js +0 -84
- package/src/parser/given.js +0 -17
- package/src/parser/manifest.js +0 -80
- package/src/parser/media.js +0 -90
- package/src/parser/project.js +0 -166
- package/src/parser/readme-file.js +0 -76
- package/src/parser/readme.js +0 -96
- package/src/parser/sections.js +0 -107
- package/src/parser/self.js +0 -27
- package/src/phrase.js +0 -1294
- package/src/schema/check/game.js +0 -61
- package/src/schema/check/workflow.js +0 -99
- package/src/schema/game.js +0 -649
- package/src/schema/message.js +0 -85
- package/src/schema/readme.js +0 -44
- package/src/schema/workflow.js +0 -150
- package/src/serve/files.js +0 -61
- package/src/serve/game.js +0 -191
- package/src/serve/page.js +0 -345
- package/src/serve/reload.js +0 -68
- package/src/serve/remote.js +0 -121
- package/src/serve/server.js +0 -128
- package/src/util/argv.js +0 -116
- package/src/util/bytes.js +0 -25
- package/src/util/chars.js +0 -30
- package/src/util/command.js +0 -18
- package/src/util/delay.js +0 -52
- package/src/util/doc.js +0 -72
- package/src/util/error.js +0 -50
- package/src/util/http.js +0 -25
- package/src/util/image.js +0 -93
- package/src/util/links.js +0 -78
- package/src/util/lockfile.js +0 -35
- package/src/util/log.js +0 -149
- package/src/util/md.js +0 -61
- package/src/util/media.js +0 -40
- package/src/util/objs.js +0 -45
- package/src/util/os.js +0 -27
- package/src/util/output.js +0 -174
- package/src/util/paths.js +0 -21
- package/src/util/progress.js +0 -85
- package/src/util/promise.js +0 -29
- package/src/util/rc.js +0 -144
- package/src/util/request.js +0 -89
- package/src/util/s3.js +0 -92
- package/src/util/schema.js +0 -189
- package/src/util/screenshot.js +0 -37
- package/src/util/shell.js +0 -84
- package/src/util/size.js +0 -53
- package/src/util/spinner.js +0 -52
- package/src/util/strs.js +0 -73
- package/src/util/term.js +0 -28
- package/src/util/time.js +0 -29
- package/src/util/toml.js +0 -14
- package/src/util/video.js +0 -157
- package/src/util/zip.js +0 -88
- /package/{src/serve → assets}/favicon.ico +0 -0
package/src/parser/project.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
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 cfgcode = require("../config/code");
|
|
14
|
-
const cfgfile = require("../config/file");
|
|
15
|
-
const cfgworkflow = require("../config/workflow");
|
|
16
|
-
const env = require("./env");
|
|
17
|
-
const error = require("../util/error");
|
|
18
|
-
const gameSchema = require("../schema/game");
|
|
19
|
-
const manifest = require("./manifest");
|
|
20
|
-
const media = require("./media");
|
|
21
|
-
const phrase = require("../phrase");
|
|
22
|
-
const promise = require("../util/promise");
|
|
23
|
-
const readme = require("./readme");
|
|
24
|
-
const workflowSchema = require("../schema/workflow");
|
|
25
|
-
|
|
26
|
-
// [use]
|
|
27
|
-
|
|
28
|
-
const ArcError = error.ArcError;
|
|
29
|
-
const dirname = path.dirname;
|
|
30
|
-
const isAbsolute = path.isAbsolute;
|
|
31
|
-
const join = path.join;
|
|
32
|
-
const pathExists = fs.pathExists;
|
|
33
|
-
const relative = path.relative;
|
|
34
|
-
const sep = path.sep;
|
|
35
|
-
|
|
36
|
-
// [declare]
|
|
37
|
-
|
|
38
|
-
const MANIFEST = cfgfile.MANIFEST;
|
|
39
|
-
|
|
40
|
-
// [function]
|
|
41
|
-
|
|
42
|
-
const configGame = function (readmeGame, mediaGame, envGame, manifestGame) {
|
|
43
|
-
return {
|
|
44
|
-
...(readmeGame ?? {}),
|
|
45
|
-
...(mediaGame ?? {}),
|
|
46
|
-
...(envGame ?? {}),
|
|
47
|
-
...(manifestGame ?? {}),
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// [function]
|
|
52
|
-
|
|
53
|
-
// the fields of `values` that `schema` knows. Arcadible ignores the rest, so
|
|
54
|
-
// they're left out of what's packed and inspected; arc validate warns about
|
|
55
|
-
// each (action/validate/unknown.js).
|
|
56
|
-
const known = function (values, schema, root) {
|
|
57
|
-
const fields = Object.keys(schema({}, { root }).shape);
|
|
58
|
-
return Object.fromEntries(
|
|
59
|
-
Object.entries(values).filter(([field]) => fields.includes(field)),
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// [function]
|
|
64
|
-
|
|
65
|
-
const configWorkflow = function (envWorkflow, manifestWorkflow) {
|
|
66
|
-
return {
|
|
67
|
-
...cfgworkflow,
|
|
68
|
-
...(envWorkflow ?? {}),
|
|
69
|
-
...(manifestWorkflow ?? {}),
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// [function]
|
|
74
|
-
|
|
75
|
-
// a directory as the developer would type it: relative to where arc runs
|
|
76
|
-
// when it's there, below it, or above it (`..`), or else its full path.
|
|
77
|
-
const shown = function (dir) {
|
|
78
|
-
const rel = relative(process.cwd(), dir);
|
|
79
|
-
const above = rel.split(sep).every((part) => part === "..");
|
|
80
|
-
return isAbsolute(rel) || (rel.startsWith("..") && !above) ? dir : rel || ".";
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// [function]
|
|
84
|
-
|
|
85
|
-
// the nearest directory above `dir` with a manifest, or null. It's only
|
|
86
|
-
// named in the error's hint: arc never reads a project it wasn't given.
|
|
87
|
-
const nearestAbove = function (dir) {
|
|
88
|
-
const parent = dirname(dir);
|
|
89
|
-
if (parent === dir) {
|
|
90
|
-
return Promise.resolve(null);
|
|
91
|
-
}
|
|
92
|
-
return pathExists(join(parent, MANIFEST)).then((exists) => {
|
|
93
|
-
if (exists) {
|
|
94
|
-
return parent;
|
|
95
|
-
}
|
|
96
|
-
return nearestAbove(parent);
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// [function]
|
|
101
|
-
|
|
102
|
-
// fails when `root` has no manifest. A game's id is only ever in it, so a
|
|
103
|
-
// project without one can't be deployed, and the likeliest cause is running
|
|
104
|
-
// arc from inside a project: the hint names the project above, if any.
|
|
105
|
-
const ensureManifest = function (root) {
|
|
106
|
-
return pathExists(join(root, MANIFEST))
|
|
107
|
-
.then((exists) => (exists ? false : nearestAbove(root)))
|
|
108
|
-
.then((found) => {
|
|
109
|
-
if (found !== false) {
|
|
110
|
-
throw new ArcError(
|
|
111
|
-
cfgcode.MANIFEST_MISSING,
|
|
112
|
-
phrase.manifestMissing(MANIFEST, shown(root), found && shown(found)),
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// [function]
|
|
119
|
-
|
|
120
|
-
// the other sources, once arcadible.toml is read: the README's title is read
|
|
121
|
-
// word for word when arcadible.toml sets the short title.
|
|
122
|
-
const parseSources = function (root, manifestData) {
|
|
123
|
-
const literalTitle = Object.hasOwn(manifestData.game ?? {}, "short_title");
|
|
124
|
-
const parsers = [
|
|
125
|
-
() => readme(root, { literalTitle }),
|
|
126
|
-
() => media(root),
|
|
127
|
-
() => env(root),
|
|
128
|
-
];
|
|
129
|
-
return promise.serial(parsers).then(([readmeData, mediaData, envData]) => ({
|
|
130
|
-
game: known(
|
|
131
|
-
configGame(
|
|
132
|
-
readmeData.game,
|
|
133
|
-
mediaData.game,
|
|
134
|
-
envData.game,
|
|
135
|
-
manifestData.game,
|
|
136
|
-
),
|
|
137
|
-
gameSchema,
|
|
138
|
-
root,
|
|
139
|
-
),
|
|
140
|
-
workflow: known(
|
|
141
|
-
configWorkflow(envData.workflow, manifestData.workflow),
|
|
142
|
-
workflowSchema,
|
|
143
|
-
root,
|
|
144
|
-
),
|
|
145
|
-
}));
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// [function]
|
|
149
|
-
|
|
150
|
-
// the project at `root`, which must exist, with its manifest: a mistyped
|
|
151
|
-
// -C would otherwise read as an empty project.
|
|
152
|
-
const main = function (root) {
|
|
153
|
-
return pathExists(root)
|
|
154
|
-
.then((exists) => {
|
|
155
|
-
if (!exists) {
|
|
156
|
-
throw new ArcError(cfgcode.PATH_NOT_FOUND, phrase.unableToFind(root));
|
|
157
|
-
}
|
|
158
|
-
return ensureManifest(root);
|
|
159
|
-
})
|
|
160
|
-
.then(() => manifest(root))
|
|
161
|
-
.then((manifestData) => parseSources(root, manifestData));
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// [export]
|
|
165
|
-
|
|
166
|
-
module.exports = main;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
|
-
const fs = require("fs-extra");
|
|
10
|
-
const jsdom = require("jsdom");
|
|
11
|
-
|
|
12
|
-
// [import]
|
|
13
|
-
|
|
14
|
-
const cfgcode = require("../config/code");
|
|
15
|
-
const cfgproduct = require("../config/product");
|
|
16
|
-
const error = require("../util/error");
|
|
17
|
-
const MD = require("../util/md");
|
|
18
|
-
const phrase = require("../phrase");
|
|
19
|
-
|
|
20
|
-
// [use]
|
|
21
|
-
|
|
22
|
-
const ArcError = error.ArcError;
|
|
23
|
-
const join = path.join;
|
|
24
|
-
const JSDOM = jsdom.JSDOM;
|
|
25
|
-
const pathExists = fs.pathExists;
|
|
26
|
-
const readFile = fs.readFile;
|
|
27
|
-
|
|
28
|
-
// [declare]
|
|
29
|
-
|
|
30
|
-
const HANDLE = cfgproduct.handle;
|
|
31
|
-
const README = [`${HANDLE}.md`, "README.md"];
|
|
32
|
-
|
|
33
|
-
// [function]
|
|
34
|
-
|
|
35
|
-
const find = function (root) {
|
|
36
|
-
return Promise.all(
|
|
37
|
-
README.map((file) =>
|
|
38
|
-
pathExists(join(root, file)).then((exists) => (exists ? file : null)),
|
|
39
|
-
),
|
|
40
|
-
).then((files) => files.find(Boolean) ?? null);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// [function]
|
|
44
|
-
|
|
45
|
-
const render = function (buf, file) {
|
|
46
|
-
try {
|
|
47
|
-
return new JSDOM(MD.parse(buf)).window.document;
|
|
48
|
-
} catch (ex) {
|
|
49
|
-
throw new ArcError(
|
|
50
|
-
cfgcode.PARSE_FAILED,
|
|
51
|
-
phrase.unableToParse(file, ex.message),
|
|
52
|
-
{ cause: ex },
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// [function]
|
|
58
|
-
|
|
59
|
-
const load = function (root, file) {
|
|
60
|
-
return readFile(join(root, file), "utf8").then((buf) => ({
|
|
61
|
-
doc: render(buf, file),
|
|
62
|
-
file,
|
|
63
|
-
}));
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// [function]
|
|
67
|
-
|
|
68
|
-
// the project's store page Markdown, `arcadible.md` or else `README.md`,
|
|
69
|
-
// rendered to a document: `{ doc, file }`, or null when there's neither.
|
|
70
|
-
const read = function (root) {
|
|
71
|
-
return find(root).then((file) => (file ? load(root, file) : null));
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// [export]
|
|
75
|
-
|
|
76
|
-
module.exports = { read };
|
package/src/parser/readme.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const objs = require("../util/objs");
|
|
6
|
-
const readmeFile = require("./readme-file");
|
|
7
|
-
const sections = require("./sections");
|
|
8
|
-
const strs = require("../util/strs");
|
|
9
|
-
|
|
10
|
-
// [use]
|
|
11
|
-
|
|
12
|
-
const deepCompact = objs.deepCompact;
|
|
13
|
-
const trimWhitespace = strs.trimWhitespace;
|
|
14
|
-
|
|
15
|
-
// [declare]
|
|
16
|
-
|
|
17
|
-
const COMMENT = 8;
|
|
18
|
-
|
|
19
|
-
// [function]
|
|
20
|
-
|
|
21
|
-
// a title with a parenthesized suffix, `Title (Short)`, as its two parts.
|
|
22
|
-
const splitTitle = function (str) {
|
|
23
|
-
const m = str.match(/^(?<title>\S.*?)(?:\s*\((?<shortTitle>[^)]*)\))?$/u);
|
|
24
|
-
return [m?.groups.title ?? "", m?.groups.shortTitle ?? ""];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// [function]
|
|
28
|
-
|
|
29
|
-
const text = function (node) {
|
|
30
|
-
return trimWhitespace(node?.textContent ?? "");
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// [function]
|
|
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.
|
|
37
|
-
const html = function (nodes) {
|
|
38
|
-
return trimWhitespace(
|
|
39
|
-
nodes
|
|
40
|
-
.map((node) => {
|
|
41
|
-
if (node.nodeType === COMMENT) {
|
|
42
|
-
return `<!--${node.textContent}-->`;
|
|
43
|
-
}
|
|
44
|
-
return node.outerHTML ?? node.textContent;
|
|
45
|
-
})
|
|
46
|
-
.join(""),
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// [function]
|
|
51
|
-
|
|
52
|
-
// the title and short title. With `literal`, when arcadible.toml sets the
|
|
53
|
-
// short title, the heading is the title word for word.
|
|
54
|
-
const extractTitle = function (node, literal) {
|
|
55
|
-
const heading = text(node);
|
|
56
|
-
if (literal) {
|
|
57
|
-
return [heading, ""];
|
|
58
|
-
}
|
|
59
|
-
return splitTitle(heading).map(trimWhitespace);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// [function]
|
|
63
|
-
|
|
64
|
-
const extract = function (doc, { literalTitle }) {
|
|
65
|
-
const parts = sections.split(doc);
|
|
66
|
-
const [title, shortTitle] = extractTitle(parts.title, literalTitle);
|
|
67
|
-
/* eslint-disable camelcase */
|
|
68
|
-
const game = {
|
|
69
|
-
bio: text(parts.bio),
|
|
70
|
-
description: html(parts.description),
|
|
71
|
-
short_title: shortTitle,
|
|
72
|
-
tagline: text(parts.tagline),
|
|
73
|
-
title,
|
|
74
|
-
};
|
|
75
|
-
/* eslint-enable camelcase */
|
|
76
|
-
// what isn't found is left out, not set to "".
|
|
77
|
-
return Object.fromEntries(
|
|
78
|
-
Object.entries(game).filter(([, value]) => value !== ""),
|
|
79
|
-
);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// [function]
|
|
83
|
-
|
|
84
|
-
// the store text from the README. `literalTitle` reads the title heading
|
|
85
|
-
// without splitting off a short title.
|
|
86
|
-
const main = function (root, { literalTitle = false } = {}) {
|
|
87
|
-
return readmeFile
|
|
88
|
-
.read(root)
|
|
89
|
-
.then((readme) => (readme ? extract(readme.doc, { literalTitle }) : null))
|
|
90
|
-
.then(deepCompact)
|
|
91
|
-
.then((game) => ({ game: game ?? null }));
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// [export]
|
|
95
|
-
|
|
96
|
-
module.exports = main;
|
package/src/parser/sections.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [declare]
|
|
4
|
-
|
|
5
|
-
const ELEMENT = 1;
|
|
6
|
-
const TEXT = 3;
|
|
7
|
-
|
|
8
|
-
// [function]
|
|
9
|
-
|
|
10
|
-
const isContent = function (node) {
|
|
11
|
-
return (
|
|
12
|
-
node.nodeType === ELEMENT ||
|
|
13
|
-
(node.nodeType === TEXT && node.textContent.trim() !== "")
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// [function]
|
|
18
|
-
|
|
19
|
-
const isRule = function (node) {
|
|
20
|
-
return node.nodeName === "HR";
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// [function]
|
|
24
|
-
|
|
25
|
-
// images only, such as a banner or a row of badges, which may sit between the
|
|
26
|
-
// title and the tagline.
|
|
27
|
-
const isImages = function (node) {
|
|
28
|
-
return (
|
|
29
|
-
node.nodeType === ELEMENT &&
|
|
30
|
-
node.textContent.trim() === "" &&
|
|
31
|
-
(node.nodeName === "IMG" || node.querySelector("img") !== null)
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// [function]
|
|
36
|
-
|
|
37
|
-
// the index of the first content node after `from`, or -1.
|
|
38
|
-
const nextContent = function (nodes, from) {
|
|
39
|
-
for (let i = from + 1; i < nodes.length; i += 1) {
|
|
40
|
-
if (isContent(nodes[i])) {
|
|
41
|
-
return i;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return -1;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// [function]
|
|
48
|
-
|
|
49
|
-
// the tagline: the `##` heading right after the title, with only images
|
|
50
|
-
// between them. Without a title there's none, so a README's own section
|
|
51
|
-
// headings, such as `## Install`, are never read as one.
|
|
52
|
-
const findTagline = function (nodes, title, end) {
|
|
53
|
-
if (!title) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
for (let i = nodes.indexOf(title) + 1; i < end; i += 1) {
|
|
57
|
-
const node = nodes[i];
|
|
58
|
-
if (isContent(node) && !isImages(node)) {
|
|
59
|
-
return node.nodeName === "H2" ? node : null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// [function]
|
|
66
|
-
|
|
67
|
-
// the bio: the paragraph directly after the tagline, before the first rule.
|
|
68
|
-
const findBio = function (nodes, tagline, end) {
|
|
69
|
-
if (!tagline) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
const i = nextContent(nodes, nodes.indexOf(tagline));
|
|
73
|
-
return i !== -1 && i < end && nodes[i].nodeName === "P" ? nodes[i] : null;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// [function]
|
|
77
|
-
|
|
78
|
-
// splits a README, rendered to a document, into the parts Arcadible Markdown
|
|
79
|
-
// defines. The title, tagline, and bio come only from before the first `---`
|
|
80
|
-
// rule. The description is what's between the first and last rules, and
|
|
81
|
-
// anything after the last one isn't read. `trailing` says whether anything
|
|
82
|
-
// follows the title, tagline, and bio, which then needs two rules around the
|
|
83
|
-
// description. A README without a title reads none of them.
|
|
84
|
-
const split = function (doc) {
|
|
85
|
-
const nodes = [...doc.body.childNodes];
|
|
86
|
-
const rules = nodes.flatMap((node, i) => (isRule(node) ? [i] : []));
|
|
87
|
-
const end = rules.length ? rules[0] : nodes.length;
|
|
88
|
-
const header = nodes.slice(0, end);
|
|
89
|
-
const title = header.find((node) => node.nodeName === "H1") ?? null;
|
|
90
|
-
const tagline = findTagline(nodes, title, end);
|
|
91
|
-
const bio = findBio(nodes, tagline, end);
|
|
92
|
-
const anchor = bio ?? tagline ?? title;
|
|
93
|
-
const after = anchor ? nodes.slice(nodes.indexOf(anchor) + 1) : [];
|
|
94
|
-
return {
|
|
95
|
-
bio,
|
|
96
|
-
description:
|
|
97
|
-
rules.length >= 2 ? nodes.slice(rules[0] + 1, rules.at(-1)) : [],
|
|
98
|
-
rules: rules.length,
|
|
99
|
-
tagline,
|
|
100
|
-
title,
|
|
101
|
-
trailing: after.some((node) => isContent(node) && !isRule(node)),
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// [export]
|
|
106
|
-
|
|
107
|
-
module.exports = { split };
|
package/src/parser/self.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// [import]
|
|
4
|
-
|
|
5
|
-
const cfgcode = require("../config/code");
|
|
6
|
-
const project = require("./project");
|
|
7
|
-
|
|
8
|
-
// [function]
|
|
9
|
-
|
|
10
|
-
// the game of the project at `root`, for `arc play` and `arc open` with no
|
|
11
|
-
// game named; null outside a project, so they ask for a game
|
|
12
|
-
// (game_id_missing) rather than for a project.
|
|
13
|
-
const main = function (root) {
|
|
14
|
-
return project(root).then(
|
|
15
|
-
({ game }) => game,
|
|
16
|
-
(ex) => {
|
|
17
|
-
if (ex.code === cfgcode.MANIFEST_MISSING) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
throw ex;
|
|
21
|
-
},
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// [export]
|
|
26
|
-
|
|
27
|
-
module.exports = main;
|