arcadible 0.1.28 → 0.1.31
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 +66 -2
- package/bin/arc-build.js +18 -25
- package/bin/arc-default.js +3 -2
- package/bin/arc-deploy.js +198 -58
- package/bin/arc-init.js +32 -51
- package/bin/arc-inspect.js +7 -37
- package/bin/arc-login.js +6 -7
- package/bin/arc-logout.js +7 -8
- package/bin/arc-open.js +21 -21
- package/bin/arc-pack.js +11 -27
- package/bin/arc-play.js +28 -20
- package/bin/arc-validate.js +8 -20
- package/bin/arc-whoami.js +16 -10
- package/bin/arc.js +2 -2
- package/package.json +20 -6
- package/src/account.js +60 -7
- package/src/action/build/tool.js +12 -3
- package/src/action/deploy/tool-git.js +61 -11
- package/src/action/deploy/tool.js +47 -29
- package/src/action/deploy/wait.js +145 -0
- package/src/action/init/tool-patch.js +5 -28
- package/src/action/init/tool.js +8 -21
- package/src/action/inspect/tool.js +3 -38
- package/src/action/login/flow.js +1 -1
- package/src/action/open/tool.js +15 -3
- package/src/action/pack/limits.js +43 -0
- package/src/action/pack/tool.js +3 -7
- package/src/action/play/tool.js +74 -13
- package/src/action/predeploy/ac.js +14 -43
- package/src/action/predeploy/git.js +40 -61
- package/src/action/predeploy/published.js +69 -0
- package/src/action/predeploy/tool-git.js +58 -15
- package/src/action/predeploy/tool.js +5 -11
- package/src/action/validate/tool.js +28 -7
- package/src/api.js +56 -19
- package/src/cli/inspect.js +2 -2
- package/src/config/html.js +2 -1
- package/src/config/image.js +0 -1
- package/src/config/uri.js +1 -0
- package/src/parser/env.js +8 -3
- package/src/parser/manifest.js +16 -3
- package/src/parser/media.js +16 -11
- package/src/parser/project.js +38 -16
- package/src/parser/readme-file.js +69 -0
- package/src/parser/readme.js +37 -109
- package/src/parser/sections.js +107 -0
- package/src/phrase.js +382 -53
- package/src/schema/check/workflow.js +42 -5
- package/src/schema/game.js +164 -99
- package/src/schema/message.js +46 -0
- package/src/schema/readme.js +38 -0
- package/src/schema/workflow.js +27 -26
- package/src/util/argv.js +49 -0
- package/src/util/chars.js +30 -0
- package/src/util/delay.js +1 -1
- package/src/util/doc.js +50 -29
- package/src/util/http.js +5 -3
- package/src/util/image.js +46 -23
- package/src/util/links.js +63 -0
- package/src/util/log.js +36 -51
- package/src/util/md.js +39 -2
- package/src/util/output.js +34 -9
- package/src/util/paths.js +3 -1
- package/src/util/progress.js +19 -5
- package/src/util/rc.js +67 -11
- package/src/util/request.js +36 -32
- package/src/util/schema.js +12 -4
- package/src/util/shell.js +39 -7
- package/src/util/spinner.js +14 -3
- package/src/util/term.js +28 -0
- package/src/util/uris.js +8 -1
- package/src/util/video.js +49 -17
- package/src/util/zip.js +15 -0
- package/.eslintrc +0 -6
- package/src/action/inspect/media.js +0 -34
- package/src/config/game.js +0 -5
- package/src/util/dom.js +0 -46
package/bin/arc-validate.js
CHANGED
|
@@ -12,6 +12,7 @@ const yargs = require("yargs/yargs");
|
|
|
12
12
|
|
|
13
13
|
// [import]
|
|
14
14
|
|
|
15
|
+
const args = require("../src/util/argv");
|
|
15
16
|
const cfgpackage = require("../src/config/package");
|
|
16
17
|
const cfgproduct = require("../src/config/product");
|
|
17
18
|
const log = require("../src/util/log");
|
|
@@ -22,6 +23,7 @@ const validate = require("../src/cli/validate");
|
|
|
22
23
|
|
|
23
24
|
// [use]
|
|
24
25
|
|
|
26
|
+
const abort = output.abort;
|
|
25
27
|
const dereference = schema.dereference;
|
|
26
28
|
const findRc = rc.findRc;
|
|
27
29
|
const print = output.print;
|
|
@@ -38,7 +40,7 @@ const VERSION = cfgpackage.version;
|
|
|
38
40
|
const conf = {
|
|
39
41
|
json: false,
|
|
40
42
|
quiet: false,
|
|
41
|
-
...findRc(TOOL, COMMAND, process.argv
|
|
43
|
+
...findRc(TOOL, COMMAND, process.argv),
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
// [function]
|
|
@@ -54,7 +56,7 @@ const start = function (argv) {
|
|
|
54
56
|
const [probs, refs] = dereference(issues);
|
|
55
57
|
const probcount = probs.length;
|
|
56
58
|
if (probcount) {
|
|
57
|
-
log.
|
|
59
|
+
log.hdo(`${probcount} ${probcount === 1 ? "issue" : "issues"}:`);
|
|
58
60
|
log.p(probs.map((prob) => `✗ ${prob}`));
|
|
59
61
|
}
|
|
60
62
|
const refcount = refs.length;
|
|
@@ -67,23 +69,14 @@ const start = function (argv) {
|
|
|
67
69
|
}
|
|
68
70
|
process.exit(count ? 1 : 0);
|
|
69
71
|
})
|
|
70
|
-
.catch((ex) => {
|
|
71
|
-
const message = ex.message;
|
|
72
|
-
if (json) {
|
|
73
|
-
print({ error: { message } });
|
|
74
|
-
} else {
|
|
75
|
-
log.hd("Validate aborted.");
|
|
76
|
-
log.p(message);
|
|
77
|
-
}
|
|
78
|
-
process.exit(1);
|
|
79
|
-
});
|
|
72
|
+
.catch((ex) => abort("Validate aborted.", ex, { json }));
|
|
80
73
|
};
|
|
81
74
|
|
|
82
75
|
// [function]
|
|
83
76
|
|
|
84
77
|
const main = function (argv) {
|
|
85
78
|
return start(
|
|
86
|
-
yargs(hideBin(argv))
|
|
79
|
+
yargs(args.normalize(hideBin(argv)))
|
|
87
80
|
.scriptName(`${TOOL} ${COMMAND}`)
|
|
88
81
|
.usage("$0 [options]")
|
|
89
82
|
.option("json", {
|
|
@@ -98,12 +91,7 @@ const main = function (argv) {
|
|
|
98
91
|
describe: "Output only errors",
|
|
99
92
|
type: "boolean",
|
|
100
93
|
})
|
|
101
|
-
.option("cwd",
|
|
102
|
-
alias: "C",
|
|
103
|
-
default: ".",
|
|
104
|
-
describe: "Set the working directory",
|
|
105
|
-
type: "string",
|
|
106
|
-
})
|
|
94
|
+
.option("cwd", args.CWD)
|
|
107
95
|
.help("help")
|
|
108
96
|
.alias("help", "h")
|
|
109
97
|
.version(VERSION)
|
|
@@ -113,7 +101,7 @@ const main = function (argv) {
|
|
|
113
101
|
);
|
|
114
102
|
};
|
|
115
103
|
|
|
116
|
-
// [
|
|
104
|
+
// [start]
|
|
117
105
|
|
|
118
106
|
if (require.main === module) {
|
|
119
107
|
main(process.argv);
|
package/bin/arc-whoami.js
CHANGED
|
@@ -8,6 +8,8 @@ const yargs = require("yargs/yargs");
|
|
|
8
8
|
|
|
9
9
|
// [import]
|
|
10
10
|
|
|
11
|
+
const account = require("../src/account");
|
|
12
|
+
const args = require("../src/util/argv");
|
|
11
13
|
const cfgpackage = require("../src/config/package");
|
|
12
14
|
const cfgproduct = require("../src/config/product");
|
|
13
15
|
const log = require("../src/util/log");
|
|
@@ -18,6 +20,7 @@ const whoami = require("../src/cli/whoami");
|
|
|
18
20
|
|
|
19
21
|
// [use]
|
|
20
22
|
|
|
23
|
+
const abort = output.abort;
|
|
21
24
|
const findRc = rc.findRc;
|
|
22
25
|
const print = output.print;
|
|
23
26
|
const SpinnerWheel = spinner.SpinnerWheel;
|
|
@@ -32,7 +35,7 @@ const VERSION = cfgpackage.version;
|
|
|
32
35
|
|
|
33
36
|
const conf = {
|
|
34
37
|
json: false,
|
|
35
|
-
...findRc(TOOL, COMMAND, process.argv
|
|
38
|
+
...findRc(TOOL, COMMAND, process.argv),
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
// [function]
|
|
@@ -72,14 +75,17 @@ const start = function (argv) {
|
|
|
72
75
|
})
|
|
73
76
|
.catch((ex) => {
|
|
74
77
|
const message = ex.message;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
// a session that can't be refreshed is no session: say so, and why.
|
|
79
|
+
if (ex.code === account.SESSION_EXPIRED) {
|
|
80
|
+
if (json) {
|
|
81
|
+
print({ user: null });
|
|
82
|
+
} else {
|
|
83
|
+
sw.stop(true);
|
|
84
|
+
log.p(message);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
81
87
|
}
|
|
82
|
-
|
|
88
|
+
abort("Whoami aborted.", ex, { json, sw });
|
|
83
89
|
});
|
|
84
90
|
};
|
|
85
91
|
|
|
@@ -87,7 +93,7 @@ const start = function (argv) {
|
|
|
87
93
|
|
|
88
94
|
const main = function (argv) {
|
|
89
95
|
return start(
|
|
90
|
-
yargs(hideBin(argv))
|
|
96
|
+
yargs(args.normalize(hideBin(argv)))
|
|
91
97
|
.scriptName(`${TOOL} ${COMMAND}`)
|
|
92
98
|
.usage("$0 [options]")
|
|
93
99
|
.option("json", {
|
|
@@ -105,7 +111,7 @@ const main = function (argv) {
|
|
|
105
111
|
);
|
|
106
112
|
};
|
|
107
113
|
|
|
108
|
-
// [
|
|
114
|
+
// [start]
|
|
109
115
|
|
|
110
116
|
if (require.main === module) {
|
|
111
117
|
main(process.argv);
|
package/bin/arc.js
CHANGED
|
@@ -51,7 +51,7 @@ const main = function (argv, load) {
|
|
|
51
51
|
pathExists(args[1], (err, exists) => {
|
|
52
52
|
if (err || !exists) {
|
|
53
53
|
log.hd("Command aborted.");
|
|
54
|
-
log.
|
|
54
|
+
log.pd(`Unable to find: ${args[1]}`);
|
|
55
55
|
process.exit(1);
|
|
56
56
|
}
|
|
57
57
|
const command = load(args[1]);
|
|
@@ -59,7 +59,7 @@ const main = function (argv, load) {
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
// [
|
|
62
|
+
// [start]
|
|
63
63
|
|
|
64
64
|
if (require.main === module) {
|
|
65
65
|
main(process.argv, require);
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"author": "Offst, Inc.",
|
|
2
3
|
"bin": {
|
|
3
4
|
"arc": "bin/arc.js",
|
|
4
5
|
"arc-build": "bin/arc-build.js",
|
|
@@ -20,27 +21,27 @@
|
|
|
20
21
|
"cli-progress": "^3.12.0",
|
|
21
22
|
"cli-spinner": "^0.2.10",
|
|
22
23
|
"degit": "^2.8.6",
|
|
23
|
-
"dompurify": "^3.3.1",
|
|
24
24
|
"dot-prop": "^6.0.1",
|
|
25
25
|
"fast-json-stable-stringify": "^2.1.0",
|
|
26
26
|
"fs-extra": "^11.3.2",
|
|
27
27
|
"image-size": "^2.0.2",
|
|
28
|
+
"ini": "^6.0.0",
|
|
28
29
|
"jsdom": "^27.3.0",
|
|
29
30
|
"marked": "^17.0.1",
|
|
30
31
|
"mp4box": "^2.3.0",
|
|
31
32
|
"open": "^8.4.2",
|
|
32
33
|
"pretty-toml": "^1.0.0",
|
|
33
34
|
"qrcode-terminal": "^0.12.0",
|
|
34
|
-
"rc": "^1.2.8",
|
|
35
35
|
"semver": "^7.7.3",
|
|
36
36
|
"yargs": "^17.7.2",
|
|
37
37
|
"zod": "^4.1.13"
|
|
38
38
|
},
|
|
39
|
-
"description": "
|
|
39
|
+
"description": "Create, validate, package, and publish games on Arcadible.",
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": ">=24
|
|
41
|
+
"node": ">=24"
|
|
42
42
|
},
|
|
43
43
|
"exports": {
|
|
44
|
+
".": "./src/cli/index.js",
|
|
44
45
|
"./build": "./src/cli/build.js",
|
|
45
46
|
"./deploy": "./src/cli/deploy.js",
|
|
46
47
|
"./init": "./src/cli/init.js",
|
|
@@ -54,12 +55,25 @@
|
|
|
54
55
|
"./validate": "./src/cli/validate.js",
|
|
55
56
|
"./whoami": "./src/cli/whoami.js"
|
|
56
57
|
},
|
|
58
|
+
"files": [
|
|
59
|
+
"bin",
|
|
60
|
+
"product.json",
|
|
61
|
+
"src"
|
|
62
|
+
],
|
|
63
|
+
"homepage": "https://developer.arcadible.com/references/arcadible-cli",
|
|
57
64
|
"keywords": [
|
|
58
65
|
"arcadible",
|
|
59
|
-
"cli"
|
|
66
|
+
"cli",
|
|
67
|
+
"deploy",
|
|
68
|
+
"gamedev",
|
|
69
|
+
"games",
|
|
70
|
+
"publish"
|
|
60
71
|
],
|
|
61
72
|
"license": "Apache-2.0",
|
|
62
73
|
"main": "./src/cli/index.js",
|
|
63
74
|
"name": "arcadible",
|
|
64
|
-
"
|
|
75
|
+
"scripts": {
|
|
76
|
+
"test": "node --test \"test/**/*.test.js\""
|
|
77
|
+
},
|
|
78
|
+
"version": "0.1.31"
|
|
65
79
|
}
|
package/src/account.js
CHANGED
|
@@ -14,12 +14,14 @@ const api = require("./api");
|
|
|
14
14
|
const cfgproduct = require("./config/product");
|
|
15
15
|
const objs = require("./util/objs");
|
|
16
16
|
const os = require("./util/os");
|
|
17
|
+
const phrase = require("./phrase");
|
|
17
18
|
|
|
18
19
|
// [use]
|
|
19
20
|
|
|
20
21
|
const configDir = os.configDir;
|
|
21
22
|
const deepSort = objs.deepSort;
|
|
22
23
|
const join = path.join;
|
|
24
|
+
const chmod = fs.promises.chmod;
|
|
23
25
|
const mkdir = fs.promises.mkdir;
|
|
24
26
|
const readFile = fs.promises.readFile;
|
|
25
27
|
const unlink = fs.promises.unlink;
|
|
@@ -27,7 +29,19 @@ const writeFile = fs.promises.writeFile;
|
|
|
27
29
|
|
|
28
30
|
// [declare]
|
|
29
31
|
|
|
32
|
+
const DIR_MODE = 0o700;
|
|
30
33
|
const FILE = "account.json";
|
|
34
|
+
const FILE_MODE = 0o600;
|
|
35
|
+
|
|
36
|
+
// [declare]
|
|
37
|
+
|
|
38
|
+
// the statuses that mean the refresh token itself was refused.
|
|
39
|
+
const REJECTED = [400, 401, 403];
|
|
40
|
+
const SESSION_EXPIRED = "session-expired";
|
|
41
|
+
|
|
42
|
+
// [declare]
|
|
43
|
+
|
|
44
|
+
const TOKEN_USER = { display_name: `${cfgproduct.title} Token`, id: null }; // eslint-disable-line camelcase
|
|
31
45
|
const TOOL = cfgproduct.tool;
|
|
32
46
|
|
|
33
47
|
// [define]
|
|
@@ -43,27 +57,46 @@ const expired = function (session) {
|
|
|
43
57
|
|
|
44
58
|
// [function]
|
|
45
59
|
|
|
60
|
+
// the session is a credential, so only its owner can read it: the directory
|
|
61
|
+
// is 0700 and the file 0600. `mode` only applies when a file is created, so
|
|
62
|
+
// both are also set on every save, which fixes an older, readable file. The
|
|
63
|
+
// modes are ignored on Windows, where %APPDATA% is already private.
|
|
46
64
|
const save = function (current) {
|
|
47
|
-
return mkdir(dir, { recursive: true })
|
|
65
|
+
return mkdir(dir, { mode: DIR_MODE, recursive: true })
|
|
66
|
+
.then(() => chmod(dir, DIR_MODE))
|
|
48
67
|
.then(() =>
|
|
49
|
-
writeFile(file, JSON.stringify(deepSort(current), null, 2),
|
|
68
|
+
writeFile(file, JSON.stringify(deepSort(current), null, 2), {
|
|
69
|
+
encoding: "utf8",
|
|
70
|
+
mode: FILE_MODE,
|
|
71
|
+
}),
|
|
50
72
|
)
|
|
73
|
+
.then(() => chmod(file, FILE_MODE))
|
|
51
74
|
.then(() => current);
|
|
52
75
|
};
|
|
53
76
|
|
|
54
77
|
// [function]
|
|
55
78
|
|
|
79
|
+
// renews the session. When the refresh token is rejected, the session can't
|
|
80
|
+
// be used again, and the error says to log in.
|
|
56
81
|
const refresh = function ({ session, ...current }) {
|
|
57
82
|
const form = new FormData();
|
|
58
83
|
form.append("refresh_token", session.refresh_token);
|
|
59
|
-
return api
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
return api.postAuthRefresh(form).then(
|
|
85
|
+
(data) => save({ ...current, session: data }),
|
|
86
|
+
(ex) => {
|
|
87
|
+
if (REJECTED.includes(ex.status)) {
|
|
88
|
+
throw Object.assign(new Error(phrase.sessionExpired(), { cause: ex }), {
|
|
89
|
+
code: SESSION_EXPIRED,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
throw ex;
|
|
93
|
+
},
|
|
94
|
+
);
|
|
62
95
|
};
|
|
63
96
|
|
|
64
97
|
// [function]
|
|
65
98
|
|
|
66
|
-
const
|
|
99
|
+
const getSaved = function (onRefresh) {
|
|
67
100
|
return readFile(file, "utf8")
|
|
68
101
|
.then(JSON.parse)
|
|
69
102
|
.catch((ex) => {
|
|
@@ -87,6 +120,26 @@ const get = function (onRefresh) {
|
|
|
87
120
|
|
|
88
121
|
// [function]
|
|
89
122
|
|
|
123
|
+
// the account an ARC_TOKEN stands for. The API doesn't describe a token's
|
|
124
|
+
// user yet, so this is a placeholder with a real user's shape, to be replaced
|
|
125
|
+
// by the API's answer without changing it.
|
|
126
|
+
const fromToken = function (token) {
|
|
127
|
+
return { session: { access_token: token }, token: true, user: TOKEN_USER }; // eslint-disable-line camelcase
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// [function]
|
|
131
|
+
|
|
132
|
+
// the account commands use: ARC_TOKEN when it's set, which takes precedence
|
|
133
|
+
// over the saved session, or else the saved session, refreshed if needed.
|
|
134
|
+
const get = function (onRefresh) {
|
|
135
|
+
if (process.env.ARC_TOKEN) {
|
|
136
|
+
return Promise.resolve(fromToken(process.env.ARC_TOKEN));
|
|
137
|
+
}
|
|
138
|
+
return getSaved(onRefresh);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// [function]
|
|
142
|
+
|
|
90
143
|
const remove = function () {
|
|
91
144
|
return unlink(file).catch((ex) => {
|
|
92
145
|
if (ex.code === "ENOENT") {
|
|
@@ -98,4 +151,4 @@ const remove = function () {
|
|
|
98
151
|
|
|
99
152
|
// [export]
|
|
100
153
|
|
|
101
|
-
module.exports = { get, remove, save };
|
|
154
|
+
module.exports = { SESSION_EXPIRED, get, remove, save };
|
package/src/action/build/tool.js
CHANGED
|
@@ -11,6 +11,7 @@ const fs = require("fs-extra");
|
|
|
11
11
|
|
|
12
12
|
// [import]
|
|
13
13
|
|
|
14
|
+
const phrase = require("../../phrase");
|
|
14
15
|
const project = require("../../parser/project");
|
|
15
16
|
|
|
16
17
|
// [use]
|
|
@@ -23,9 +24,14 @@ const resolvePath = path.resolve;
|
|
|
23
24
|
|
|
24
25
|
const execBuild = function (command, { cwdPath }) {
|
|
25
26
|
return new Promise((resolve, reject) => {
|
|
26
|
-
exec(command, { cwd: cwdPath }, (err) => {
|
|
27
|
+
exec(command, { cwd: cwdPath }, (err, stdout, stderr) => {
|
|
27
28
|
if (err) {
|
|
28
|
-
|
|
29
|
+
const { code, signal } = err;
|
|
30
|
+
reject(
|
|
31
|
+
new Error(phrase.buildFailed({ code, signal, stderr }), {
|
|
32
|
+
cause: err,
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
29
35
|
return;
|
|
30
36
|
}
|
|
31
37
|
resolve();
|
|
@@ -35,11 +41,14 @@ const execBuild = function (command, { cwdPath }) {
|
|
|
35
41
|
|
|
36
42
|
// [function]
|
|
37
43
|
|
|
44
|
+
// runs the build, and resolves with deploy_dir's path. It resolves with null
|
|
45
|
+
// when there's no build to run, and with `{ missing }` when the build ran but
|
|
46
|
+
// didn't create deploy_dir.
|
|
38
47
|
const build = function (command, { cwdPath, outputPath }) {
|
|
39
48
|
return command
|
|
40
49
|
? execBuild(command, { cwdPath })
|
|
41
50
|
.then(() => pathExists(outputPath))
|
|
42
|
-
.then((exists) => (exists ?
|
|
51
|
+
.then((exists) => ({ [exists ? "path" : "missing"]: outputPath }))
|
|
43
52
|
: Promise.resolve(null);
|
|
44
53
|
};
|
|
45
54
|
|
|
@@ -2,46 +2,96 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const semver = require("semver");
|
|
6
|
+
|
|
7
|
+
// [import]
|
|
8
|
+
|
|
9
|
+
const links = require("../../util/links");
|
|
10
|
+
const phrase = require("../../phrase");
|
|
6
11
|
const project = require("../../parser/project");
|
|
12
|
+
const repo = require("../predeploy/git");
|
|
7
13
|
|
|
8
14
|
// [use]
|
|
9
15
|
|
|
10
|
-
const
|
|
16
|
+
const git = repo.git;
|
|
17
|
+
const prereleaseSemver = semver.prerelease;
|
|
18
|
+
const tagOf = repo.tagOf;
|
|
19
|
+
|
|
20
|
+
// [function]
|
|
21
|
+
|
|
22
|
+
const createTag = function (root, version, cb) {
|
|
23
|
+
git(
|
|
24
|
+
root,
|
|
25
|
+
[
|
|
26
|
+
"tag",
|
|
27
|
+
"-a",
|
|
28
|
+
tagOf(version),
|
|
29
|
+
"-m",
|
|
30
|
+
prereleaseSemver(version) === null
|
|
31
|
+
? phrase.versionRelease(version)
|
|
32
|
+
: phrase.versionPrerelease(version),
|
|
33
|
+
],
|
|
34
|
+
(err) => {
|
|
35
|
+
if (err) {
|
|
36
|
+
cb(new Error(phrase.gitTagCreateFailed(version), { cause: err }));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
cb(null);
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
};
|
|
11
43
|
|
|
12
44
|
// [function]
|
|
13
45
|
|
|
14
|
-
|
|
15
|
-
|
|
46
|
+
// the local tag is deleted when the push fails, so trying again isn't
|
|
47
|
+
// blocked by a tag that was never released.
|
|
48
|
+
const pushTag = function (root, version, cb) {
|
|
49
|
+
git(root, ["push", "origin", tagOf(version)], (err) => {
|
|
16
50
|
if (err) {
|
|
17
|
-
|
|
51
|
+
const failed = new Error(phrase.gitTagPushFailed(version), {
|
|
52
|
+
cause: err,
|
|
53
|
+
});
|
|
54
|
+
git(root, ["tag", "-d", tagOf(version)], () => cb(failed));
|
|
18
55
|
return;
|
|
19
56
|
}
|
|
20
|
-
cb(null
|
|
57
|
+
cb(null);
|
|
21
58
|
});
|
|
22
59
|
};
|
|
23
60
|
|
|
24
61
|
// [function]
|
|
25
62
|
|
|
26
|
-
|
|
27
|
-
|
|
63
|
+
// tags the version and pushes the tag: the Arcadible GitHub App publishes
|
|
64
|
+
// the release that the workflow builds from it.
|
|
65
|
+
const release = function (root, version, cb) {
|
|
66
|
+
createTag(root, version, (err) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
cb(err);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
pushTag(root, version, cb);
|
|
72
|
+
});
|
|
28
73
|
};
|
|
29
74
|
|
|
30
75
|
// [function]
|
|
31
76
|
|
|
32
|
-
const main = function ({ root }, { onDeployBegin
|
|
77
|
+
const main = function ({ root }, { onDeployBegin }) {
|
|
33
78
|
if (onDeployBegin) {
|
|
34
79
|
onDeployBegin();
|
|
35
80
|
}
|
|
36
81
|
return project(root).then(
|
|
37
82
|
({ game }) =>
|
|
38
83
|
new Promise((resolve, reject) => {
|
|
39
|
-
|
|
84
|
+
release(root, game.version, (err) => {
|
|
40
85
|
if (err) {
|
|
41
86
|
reject(err);
|
|
42
87
|
return;
|
|
43
88
|
}
|
|
44
|
-
resolve(
|
|
89
|
+
resolve({
|
|
90
|
+
...links.published(game),
|
|
91
|
+
game: game.id,
|
|
92
|
+
tag: tagOf(game.version),
|
|
93
|
+
version: { to: game.version },
|
|
94
|
+
});
|
|
45
95
|
});
|
|
46
96
|
}),
|
|
47
97
|
);
|
|
@@ -2,35 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const api = require("../../api");
|
|
6
|
+
const links = require("../../util/links");
|
|
7
|
+
const phrase = require("../../phrase");
|
|
6
8
|
const project = require("../../parser/project");
|
|
7
|
-
|
|
8
|
-
// [use]
|
|
9
|
-
|
|
10
|
-
const release = ac.release;
|
|
9
|
+
const s3 = require("../../util/s3");
|
|
11
10
|
|
|
12
11
|
// [function]
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const uploadBuild = function (
|
|
15
14
|
current,
|
|
16
15
|
artifact,
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
{ id, version },
|
|
17
|
+
onUploadProgress,
|
|
19
18
|
cb,
|
|
20
19
|
) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
const form = new FormData();
|
|
21
|
+
form.append("artifact", id);
|
|
22
|
+
form.append("version", version);
|
|
23
|
+
form.append("sha256", artifact.sha256);
|
|
24
|
+
form.append("size", artifact.size);
|
|
25
|
+
// api
|
|
26
|
+
return api
|
|
27
|
+
.postUpload(form, null, api.auth(current?.session?.access_token))
|
|
28
|
+
.then(
|
|
29
|
+
(upload) => {
|
|
30
|
+
s3.upload(upload.upload_url, artifact, onUploadProgress, (err) =>
|
|
31
|
+
cb(err, upload),
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
(err) => {
|
|
35
|
+
// the API refuses a game that was deleted or is another account's.
|
|
36
|
+
cb(err.status === 403 ? new Error(phrase.gameUnavailable(id)) : err);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
// [function]
|
|
@@ -39,7 +44,7 @@ const main = function (
|
|
|
39
44
|
current,
|
|
40
45
|
artifact,
|
|
41
46
|
{ root },
|
|
42
|
-
{ onDeployBegin,
|
|
47
|
+
{ onDeployBegin, onUploadProgress },
|
|
43
48
|
) {
|
|
44
49
|
if (onDeployBegin) {
|
|
45
50
|
onDeployBegin({ root });
|
|
@@ -47,13 +52,26 @@ const main = function (
|
|
|
47
52
|
return project(root).then(
|
|
48
53
|
({ game }) =>
|
|
49
54
|
new Promise((resolve, reject) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
uploadBuild(
|
|
56
|
+
current,
|
|
57
|
+
artifact,
|
|
58
|
+
game,
|
|
59
|
+
onUploadProgress,
|
|
60
|
+
(err, upload) => {
|
|
61
|
+
if (err) {
|
|
62
|
+
reject(err);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// a direct deploy's release shares its upload's id, which
|
|
66
|
+
// `--wait` follows.
|
|
67
|
+
resolve({
|
|
68
|
+
...links.published(game),
|
|
69
|
+
game: game.id,
|
|
70
|
+
release: upload.id,
|
|
71
|
+
version: { to: game.version },
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
);
|
|
57
75
|
}),
|
|
58
76
|
);
|
|
59
77
|
};
|