arcadible 0.1.15 → 0.1.16

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-build.js CHANGED
@@ -18,6 +18,7 @@ const output = require("../src/util/output");
18
18
  const phrase = require("../src/phrase");
19
19
  const pkg = require("../package.json");
20
20
  const rc = require("../src/util/rc");
21
+ const spinner = require("../src/util/spinner");
21
22
  const validate = require("../src/cli/validate");
22
23
 
23
24
  // [use]
@@ -25,6 +26,7 @@ const validate = require("../src/cli/validate");
25
26
  const findRc = rc.findRc;
26
27
  const print = output.print;
27
28
  const resolve = path.resolve;
29
+ const SpinnerWheel = spinner.SpinnerWheel;
28
30
 
29
31
  // [declare]
30
32
 
@@ -45,12 +47,16 @@ const start = function (argv) {
45
47
  const json = argv.json;
46
48
  const quiet = argv.quiet;
47
49
  const root = resolve(process.cwd(), argv.cwd);
50
+ let sw = new SpinnerWheel("Validating... %s");
48
51
  return validate({ root })
49
52
  .then((issues) => {
50
53
  const count = issues.length;
51
54
  if (count) {
52
55
  throw new Error(phrase.issuesFound(count));
53
56
  }
57
+ sw.stop();
58
+ sw = new SpinnerWheel("Building... %s");
59
+ sw.start(json || quiet);
54
60
  return build({ root });
55
61
  })
56
62
  .then((artifact) => {
@@ -59,6 +65,7 @@ const start = function (argv) {
59
65
  return;
60
66
  }
61
67
  if (!quiet) {
68
+ sw.stop(true);
62
69
  log.hs("Done.");
63
70
  if (artifact) {
64
71
  print(artifact, { toml: true });
@@ -72,6 +79,7 @@ const start = function (argv) {
72
79
  if (json) {
73
80
  print({ error: { message } });
74
81
  } else {
82
+ sw.stop(true);
75
83
  log.hd("Build aborted.");
76
84
  log.p(message);
77
85
  }
package/bin/arc-deploy.js CHANGED
@@ -19,6 +19,7 @@ const output = require("../src/util/output");
19
19
  const pack = require("../src/cli/pack");
20
20
  const phrase = require("../src/phrase");
21
21
  const pkg = require("../package.json");
22
+ const predeploy = require("../src/cli/predeploy");
22
23
  const progress = require("../src/util/progress");
23
24
  const rc = require("../src/util/rc");
24
25
  const spinner = require("../src/util/spinner");
@@ -49,9 +50,10 @@ const conf = {
49
50
 
50
51
  // [function]
51
52
 
52
- const handler = function ({ json, pb, quiet }) {
53
+ const handler = function ({ git, json, pb, quiet, sw }) {
53
54
  return {
54
55
  onAccountRefresh(refresh) {
56
+ sw.start(git || json || quiet);
55
57
  return refresh(true);
56
58
  },
57
59
  onDeployBegin() {
@@ -66,13 +68,22 @@ const handler = function ({ json, pb, quiet }) {
66
68
  if (!json && !quiet) {
67
69
  switch (level) {
68
70
  case "warn":
71
+ sw.stop(true);
72
+ if (pb) {
73
+ pb.stop();
74
+ }
69
75
  log.pw(`⚠ ${message}`);
70
- return;
71
- default:
72
- log.p(`· ${message}`);
76
+ sw.start(git || json || quiet);
77
+ if (pb) {
78
+ pb.start();
79
+ }
80
+ // no default
73
81
  }
74
82
  }
75
83
  },
84
+ onPredeployBegin() {
85
+ sw.start(git || json || quiet);
86
+ },
76
87
  onUploadProgress(step) {
77
88
  if (!json && !quiet) {
78
89
  if (pb) {
@@ -91,28 +102,37 @@ const start = function (argv) {
91
102
  const quiet = argv.quiet;
92
103
  const root = resolve(process.cwd(), argv.cwd);
93
104
  let pb = null;
94
- let sw = new SpinnerWheel("Checking login... %s");
95
- sw.start(git || json || quiet);
96
- return whoami({ handler: handler({ json, pb, quiet }) })
105
+ let sw = new SpinnerWheel("Validating... %s");
106
+ return validate({ root })
107
+ .then((issues) => {
108
+ const count = issues.length;
109
+ if (count) {
110
+ throw new Error(phrase.issuesFound(count));
111
+ }
112
+ sw.stop();
113
+ sw = new SpinnerWheel("Checking login... %s");
114
+ return whoami({ handler: handler({ git, json, pb, quiet, sw }) });
115
+ })
97
116
  .then((current) => {
98
- if (!current || !current.session) {
117
+ const session = current?.session;
118
+ if (!session) {
99
119
  throw new Error(phrase.notLoggedIn());
100
120
  }
101
121
  sw.stop();
102
- sw = new SpinnerWheel("Validating... %s");
103
- sw.start(git || json || quiet);
122
+ sw = new SpinnerWheel("Preparing... %s");
104
123
  return Promise.all([
105
124
  // whoami
106
- current.session,
107
- // validate
108
- validate({ root }),
125
+ session,
126
+ // predeploy
127
+ predeploy({
128
+ git,
129
+ handler: handler({ git, json, pb, quiet, sw }),
130
+ root,
131
+ session,
132
+ }),
109
133
  ]);
110
134
  })
111
- .then(([session, issues]) => {
112
- const count = issues.length;
113
- if (count) {
114
- throw new Error(phrase.issuesFound(count));
115
- }
135
+ .then(([session]) => {
116
136
  sw.stop();
117
137
  sw = new SpinnerWheel("Building... %s");
118
138
  sw.start(git || json || quiet);
@@ -139,14 +159,13 @@ const start = function (argv) {
139
159
  if (!json && !quiet && !git) {
140
160
  pb = new ProgressBar(artifact.size);
141
161
  }
142
- return git
143
- ? deploy({ handler: handler({ json, pb, quiet }), root })
144
- : deploy({
145
- artifact,
146
- handler: handler({ json, pb, quiet }),
147
- root,
148
- session,
149
- });
162
+ return deploy({
163
+ artifact,
164
+ git,
165
+ handler: handler({ git, json, pb, quiet, sw }),
166
+ root,
167
+ session,
168
+ });
150
169
  })
151
170
  .then((version) => {
152
171
  if (json) {
package/bin/arc-init.js CHANGED
@@ -19,6 +19,7 @@ const log = require("../src/util/log");
19
19
  const output = require("../src/util/output");
20
20
  const pkg = require("../package.json");
21
21
  const rc = require("../src/util/rc");
22
+ const spinner = require("../src/util/spinner");
22
23
  const template = require("../src/prompt/template");
23
24
 
24
25
  // [use]
@@ -29,6 +30,7 @@ const pathExists = fs.pathExists;
29
30
  const print = output.print;
30
31
  const resolve = path.resolve;
31
32
  const select = prompts.select;
33
+ const SpinnerWheel = spinner.SpinnerWheel;
32
34
 
33
35
  // [declare]
34
36
 
@@ -47,21 +49,19 @@ const conf = {
47
49
 
48
50
  // [function]
49
51
 
50
- const handler = function ({ json, quiet }) {
52
+ const handler = function ({ json, quiet, sw }) {
51
53
  return {
52
54
  onInitBegin() {
53
- if (!json && !quiet) {
54
- log.p("Initializing...");
55
- }
55
+ sw.start(json || quiet);
56
56
  },
57
57
  onLogInfo({ level, message }) {
58
58
  if (!json && !quiet) {
59
59
  switch (level) {
60
60
  case "warn":
61
+ sw.stop(true);
61
62
  log.pw(`⚠ ${message}`);
62
- return;
63
- default:
64
- log.p(`· ${message}`);
63
+ sw.start(json || quiet);
64
+ // no default
65
65
  }
66
66
  }
67
67
  },
@@ -74,9 +74,10 @@ const start = function (argv) {
74
74
  const json = argv.json;
75
75
  const quiet = argv.quiet;
76
76
  const root = resolve(process.cwd(), argv.cwd);
77
+ const sw = new SpinnerWheel("Initializing... %s");
77
78
  return init({
78
79
  force: true,
79
- handler: handler({ json, quiet }),
80
+ handler: handler({ json, quiet, sw }),
80
81
  patch: argv.patch,
81
82
  project: argv.project,
82
83
  root,
@@ -88,7 +89,13 @@ const start = function (argv) {
88
89
  return;
89
90
  }
90
91
  if (!quiet) {
92
+ sw.stop(true);
91
93
  log.hs("Done.");
94
+ if (project) {
95
+ print(project, { toml: true });
96
+ return;
97
+ }
98
+ log.p("Nothing to do.");
92
99
  }
93
100
  // degit sometimes hangs
94
101
  process.exit(0);
@@ -98,6 +105,7 @@ const start = function (argv) {
98
105
  if (json) {
99
106
  print({ error: { message } });
100
107
  } else {
108
+ sw.stop(true);
101
109
  log.hd("Init aborted.");
102
110
  log.p(message);
103
111
  }
package/bin/arc-login.js CHANGED
@@ -14,10 +14,12 @@ const log = require("../src/util/log");
14
14
  const login = require("../src/cli/login");
15
15
  const pkg = require("../package.json");
16
16
  const rc = require("../src/util/rc");
17
+ const spinner = require("../src/util/spinner");
17
18
 
18
19
  // [use]
19
20
 
20
21
  const findRc = rc.findRc;
22
+ const SpinnerWheel = spinner.SpinnerWheel;
21
23
 
22
24
  // [declare]
23
25
 
@@ -60,10 +62,12 @@ const onLoginEnter = function (fn) {
60
62
 
61
63
  // [function]
62
64
 
63
- const handler = function ({ browser, qrcode: qr }) {
65
+ const handler = function ({ browser, qrcode: qr, sw }) {
64
66
  return {
65
67
  onLoginCreated({ code: dac, id, url }) {
68
+ sw.stop(true);
66
69
  const link = `${url}/${id}`;
70
+ log.p("Logging in...");
67
71
  qrcode.generate(link, { small: true }, (code) => {
68
72
  if (qr) {
69
73
  log.p(code);
@@ -85,16 +89,19 @@ const handler = function ({ browser, qrcode: qr }) {
85
89
  // [function]
86
90
 
87
91
  const start = function (argv) {
88
- log.p("Logging in...");
92
+ const sw = new SpinnerWheel("Logging in... %s");
93
+ sw.start();
89
94
  return login({
90
- handler: handler({ browser: argv.browser, qrcode: argv.qrcode }),
95
+ handler: handler({ browser: argv.browser, qrcode: argv.qrcode, sw }),
91
96
  })
92
97
  .then(({ profile }) => {
98
+ sw.stop(true);
93
99
  process.stdin.pause();
94
100
  log.nlhs("Logged in.");
95
101
  log.p(profile.display_name);
96
102
  })
97
103
  .catch((ex) => {
104
+ sw.stop(true);
98
105
  process.stdin.pause();
99
106
  log.nlhd("Login aborted.");
100
107
  log.p(ex.message);
package/bin/arc-pack.js CHANGED
@@ -18,6 +18,7 @@ const pack = require("../src/cli/pack");
18
18
  const phrase = require("../src/phrase");
19
19
  const pkg = require("../package.json");
20
20
  const rc = require("../src/util/rc");
21
+ const spinner = require("../src/util/spinner");
21
22
  const validate = require("../src/cli/validate");
22
23
 
23
24
  // [use]
@@ -25,6 +26,7 @@ const validate = require("../src/cli/validate");
25
26
  const findRc = rc.findRc;
26
27
  const print = output.print;
27
28
  const resolve = path.resolve;
29
+ const SpinnerWheel = spinner.SpinnerWheel;
28
30
 
29
31
  // [declare]
30
32
 
@@ -47,12 +49,16 @@ const start = function (argv) {
47
49
  const json = argv.json;
48
50
  const quiet = argv.quiet;
49
51
  const root = resolve(process.cwd(), argv.cwd);
52
+ let sw = new SpinnerWheel("Validating... %s");
50
53
  return validate({ root })
51
54
  .then((issues) => {
52
55
  const count = issues.length;
53
56
  if (count) {
54
57
  throw new Error(phrase.issuesFound(count));
55
58
  }
59
+ sw.stop();
60
+ sw = new SpinnerWheel("Packing... %s");
61
+ sw.start(json || quiet);
56
62
  return pack({ input: argv.input, output: argv.output, root });
57
63
  })
58
64
  .then((artifact) => {
@@ -61,6 +67,7 @@ const start = function (argv) {
61
67
  return;
62
68
  }
63
69
  if (!quiet) {
70
+ sw.stop(true);
64
71
  log.hs("Done.");
65
72
  if (artifact) {
66
73
  print(artifact, { toml: true });
@@ -74,6 +81,7 @@ const start = function (argv) {
74
81
  if (json) {
75
82
  print({ error: { message } });
76
83
  } else {
84
+ sw.stop(true);
77
85
  log.hd("Pack aborted.");
78
86
  log.p(message);
79
87
  }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
package/bin/arc-whoami.js CHANGED
@@ -12,12 +12,14 @@ const log = require("../src/util/log");
12
12
  const output = require("../src/util/output");
13
13
  const pkg = require("../package.json");
14
14
  const rc = require("../src/util/rc");
15
+ const spinner = require("../src/util/spinner");
15
16
  const whoami = require("../src/cli/whoami");
16
17
 
17
18
  // [use]
18
19
 
19
20
  const findRc = rc.findRc;
20
21
  const print = output.print;
22
+ const SpinnerWheel = spinner.SpinnerWheel;
21
23
 
22
24
  // [declare]
23
25
 
@@ -33,12 +35,10 @@ const conf = {
33
35
 
34
36
  // [function]
35
37
 
36
- const handler = function ({ json }) {
38
+ const handler = function ({ json, sw }) {
37
39
  return {
38
40
  onAccountRefresh(refresh) {
39
- if (!json) {
40
- // log.p("Checking login...");
41
- }
41
+ sw.start(json);
42
42
  return refresh(true);
43
43
  },
44
44
  };
@@ -48,20 +48,23 @@ const handler = function ({ json }) {
48
48
 
49
49
  const start = function (argv) {
50
50
  const json = argv.json;
51
- return whoami({ handler: handler({ json }) })
51
+ const sw = new SpinnerWheel("Checking login... %s");
52
+ return whoami({ handler: handler({ json, sw }) })
52
53
  .then((current) => {
53
- if (!current || !current.profile) {
54
+ const profile = current?.profile;
55
+ if (!profile) {
54
56
  if (json) {
55
57
  print({ profile: null });
56
58
  } else {
59
+ sw.stop(true);
57
60
  log.p("Not logged in.");
58
61
  }
59
62
  return;
60
63
  }
61
- const profile = current.profile;
62
64
  if (json) {
63
65
  print({ profile });
64
66
  } else {
67
+ sw.stop(true);
65
68
  log.p(profile.display_name);
66
69
  }
67
70
  })
@@ -70,6 +73,7 @@ const start = function (argv) {
70
73
  if (json) {
71
74
  print({ error: { message } });
72
75
  } else {
76
+ sw.stop(true);
73
77
  log.hd("Whoami aborted.");
74
78
  log.p(message);
75
79
  }
package/package.json CHANGED
@@ -8,6 +8,7 @@
8
8
  "arc-login": "bin/arc-login.js",
9
9
  "arc-logout": "bin/arc-logout.js",
10
10
  "arc-pack": "bin/arc-pack.js",
11
+ "arc-predeploy": "bin/arc-predeploy.js",
11
12
  "arc-validate": "bin/arc-validate.js",
12
13
  "arc-whoami": "bin/arc-whoami.js"
13
14
  },
@@ -46,6 +47,7 @@
46
47
  "./login": "./src/cli/login.js",
47
48
  "./logout": "./src/cli/logout.js",
48
49
  "./pack": "./src/cli/pack.js",
50
+ "./predeploy": "./src/cli/predeploy.js",
49
51
  "./validate": "./src/cli/validate.js",
50
52
  "./whoami": "./src/cli/whoami.js"
51
53
  },
@@ -56,5 +58,5 @@
56
58
  "license": "Apache-2.0",
57
59
  "main": "./src/cli/index.js",
58
60
  "name": "arcadible",
59
- "version": "0.1.15"
61
+ "version": "0.1.16"
60
62
  }
package/src/account.js CHANGED
@@ -56,7 +56,7 @@ const refresh = function ({ session, ...account }) {
56
56
  const form = new FormData();
57
57
  form.append("refresh_token", session.refresh_token);
58
58
  return api
59
- .authRefresh(form)
59
+ .postAuthRefresh(form)
60
60
  .then((data) => save({ ...account, session: data }));
61
61
  };
62
62
 
@@ -2,14 +2,11 @@
2
2
 
3
3
  // [import]
4
4
 
5
- const git = require("./git");
5
+ const git = require("../predeploy/git");
6
6
  const project = require("../../parser/project");
7
7
 
8
8
  // [use]
9
9
 
10
- const ensureClean = git.ensureClean;
11
- const ensureRemote = git.ensureRemote;
12
- const ensureRepo = git.ensureRepo;
13
10
  const release = git.release;
14
11
 
15
12
  // [function]
@@ -26,38 +23,8 @@ const deployRelease = function (version, { root }, handler, cb) {
26
23
 
27
24
  // [function]
28
25
 
29
- const deployEnsure = function ({ root }, { onLogInfo }, cb) {
30
- ensureRepo(root, (err) => {
31
- if (err) {
32
- cb(err);
33
- return;
34
- }
35
- ensureClean(root, (err, diff) => {
36
- if (err) {
37
- cb(err);
38
- return;
39
- }
40
- if (diff.cached && onLogInfo) {
41
- onLogInfo({
42
- level: "warn",
43
- message: "Staged but uncommitted changes will not be included.",
44
- });
45
- }
46
- ensureRemote(root, cb);
47
- });
48
- });
49
- };
50
-
51
- // [function]
52
-
53
26
  const deploy = function ({ version }, { root }, handler, cb) {
54
- deployEnsure({ root }, handler, (err) => {
55
- if (err) {
56
- cb(err);
57
- return;
58
- }
59
- deployRelease(version, { root }, handler, cb);
60
- });
27
+ deployRelease(version, { root }, handler, cb);
61
28
  };
62
29
 
63
30
  // [function]
@@ -2,7 +2,7 @@
2
2
 
3
3
  // [import]
4
4
 
5
- const ac = require("./ac");
5
+ const ac = require("../predeploy/ac");
6
6
  const project = require("../../parser/project");
7
7
 
8
8
  // [use]
@@ -73,7 +73,7 @@ const main = function ({ force, project, root, template }, handler) {
73
73
  .then(() => removeLicense(dest))
74
74
  .then(() => detectVersion(dest))
75
75
  .then((version) => prepare(dest, version))
76
- .then(() => ({ path: dest }));
76
+ .then(() => ({ path: dest, template }));
77
77
  };
78
78
 
79
79
  // [export]
@@ -39,8 +39,8 @@ const postFlow = function ({ expiresAt, secret, type }) {
39
39
 
40
40
  // [function]
41
41
 
42
- const getFlow = function ({ id, secret }) {
43
- return api.getFlow(id, { token: secret });
42
+ const getFlow = function ({ id, secret: token }) {
43
+ return api.getFlow(id, { token });
44
44
  };
45
45
 
46
46
  // [function]
@@ -8,23 +8,8 @@ const s3 = require("../../util/s3");
8
8
 
9
9
  // [function]
10
10
 
11
- const ensureBuild = function (token, { id, version }, cb) {
12
- return api.getGameBuild(id, version, { token }).then(
13
- () => cb(new Error(phrase.versionExists(version))),
14
- (err) => {
15
- if (err.status === 404) {
16
- cb(null);
17
- return;
18
- }
19
- cb(err);
20
- },
21
- );
22
- };
23
-
24
- // [function]
25
-
26
11
  const uploadBuild = function (
27
- token,
12
+ session,
28
13
  artifact,
29
14
  { id, version },
30
15
  onUploadProgress,
@@ -35,6 +20,8 @@ const uploadBuild = function (
35
20
  form.append("version", version);
36
21
  form.append("sha256", artifact.sha256);
37
22
  form.append("size", artifact.size);
23
+ // api
24
+ const token = session?.access_token;
38
25
  return api.postUpload(form, { token }).then((upload) => {
39
26
  s3.upload(upload.upload_url, artifact, onUploadProgress, cb);
40
27
  }, cb);
@@ -42,17 +29,26 @@ const uploadBuild = function (
42
29
 
43
30
  // [function]
44
31
 
45
- const release = function (session, artifact, game, onUploadProgress, cb) {
46
- const token = session.access_token;
47
- ensureBuild(token, game, (err) => {
48
- if (err) {
32
+ const ensureVersion = function (session, { id, version }, cb) {
33
+ const token = session?.access_token;
34
+ return api.getGameBuild(id, version, { token }).then(
35
+ () => cb(new Error(phrase.versionExists(version))),
36
+ (err) => {
37
+ if (err.status === 404) {
38
+ cb(null);
39
+ return;
40
+ }
49
41
  cb(err);
50
- return;
51
- }
52
- uploadBuild(token, artifact, game, onUploadProgress, cb);
53
- });
42
+ },
43
+ );
44
+ };
45
+
46
+ // [function]
47
+
48
+ const release = function (session, artifact, game, onUploadProgress, cb) {
49
+ uploadBuild(session, artifact, game, onUploadProgress, cb);
54
50
  };
55
51
 
56
52
  // [export]
57
53
 
58
- module.exports = { release };
54
+ module.exports = { ensureVersion, release };
@@ -29,13 +29,27 @@ const git = function (root, args, cb) {
29
29
 
30
30
  // [function]
31
31
 
32
- const ensureRepo = function (root, cb) {
33
- git(root, ["rev-parse", "--is-inside-work-tree"], (err) => {
32
+ const ensureClean = function (root, cb) {
33
+ git(root, ["diff", "--quiet"], (err) => {
34
34
  if (err) {
35
- cb(new Error(phrase.gitRepoMissing(), { cause: err }));
35
+ if (err.code === 1) {
36
+ cb(new Error(phrase.gitChangesPresent(), { cause: err }));
37
+ return;
38
+ }
39
+ cb(err);
36
40
  return;
37
41
  }
38
- cb(null);
42
+ git(root, ["diff", "--cached", "--quiet"], (err) => {
43
+ if (!err) {
44
+ cb(null, { cached: false });
45
+ return;
46
+ }
47
+ if (err.code === 1) {
48
+ cb(null, { cached: true });
49
+ return;
50
+ }
51
+ cb(err);
52
+ });
39
53
  });
40
54
  };
41
55
 
@@ -53,27 +67,30 @@ const ensureRemote = function (root, cb) {
53
67
 
54
68
  // [function]
55
69
 
56
- const ensureClean = function (root, cb) {
57
- git(root, ["diff", "--quiet"], (err) => {
70
+ const ensureRepo = function (root, cb) {
71
+ git(root, ["rev-parse", "--is-inside-work-tree"], (err) => {
58
72
  if (err) {
59
- if (err.code === 1) {
60
- cb(new Error(phrase.gitChangesPresent(), { cause: err }));
61
- return;
62
- }
63
- cb(err);
73
+ cb(new Error(phrase.gitRepoMissing(), { cause: err }));
64
74
  return;
65
75
  }
66
- git(root, ["diff", "--cached", "--quiet"], (err) => {
67
- if (!err) {
68
- cb(null, { cached: false });
69
- return;
70
- }
71
- if (err.code === 1) {
72
- cb(null, { cached: true });
73
- return;
74
- }
76
+ cb(null);
77
+ });
78
+ };
79
+
80
+ // [function]
81
+
82
+ const ensureVersion = function (root, version, cb) {
83
+ git(root, ["tag", "--list", `${PREFIX}*`], (err, stdout) => {
84
+ if (err) {
75
85
  cb(err);
76
- });
86
+ return;
87
+ }
88
+ const tags = stdout.trim().split("\n").filter(Boolean);
89
+ if (tags.includes(`${PREFIX}${version}`)) {
90
+ cb(new Error(phrase.gitVersionExists(version)));
91
+ return;
92
+ }
93
+ cb(null);
77
94
  });
78
95
  };
79
96
 
@@ -93,7 +110,7 @@ const createTag = function (root, version, cb) {
93
110
  ],
94
111
  (err) => {
95
112
  if (err) {
96
- cb(new Error(phrase.gitTagCreateFailed(), { cause: err }));
113
+ cb(new Error(phrase.gitTagCreateFailed(version), { cause: err }));
97
114
  return;
98
115
  }
99
116
  cb(null);
@@ -106,7 +123,7 @@ const createTag = function (root, version, cb) {
106
123
  const pushTag = function (root, version, cb) {
107
124
  git(root, ["push", "origin", `${PREFIX}${version}`], (err) => {
108
125
  if (err) {
109
- cb(new Error(phrase.gitTagPushFailed(), { cause: err }));
126
+ cb(new Error(phrase.gitTagPushFailed(version), { cause: err }));
110
127
  return;
111
128
  }
112
129
  cb(null);
@@ -127,4 +144,10 @@ const release = function (root, version, cb) {
127
144
 
128
145
  // [export]
129
146
 
130
- module.exports = { ensureClean, ensureRemote, ensureRepo, release };
147
+ module.exports = {
148
+ ensureClean,
149
+ ensureRemote,
150
+ ensureRepo,
151
+ ensureVersion,
152
+ release,
153
+ };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const git = require("./git");
6
+ const project = require("../../parser/project");
7
+
8
+ // [use]
9
+
10
+ const ensureClean = git.ensureClean;
11
+ const ensureRemote = git.ensureRemote;
12
+ const ensureRepo = git.ensureRepo;
13
+ const ensureVersion = git.ensureVersion;
14
+
15
+ // [function]
16
+
17
+ const deployRelease = function (version, { root }, handler, cb) {
18
+ ensureVersion(root, version, (err) => {
19
+ if (err) {
20
+ cb(err);
21
+ return;
22
+ }
23
+ cb(null, { to: version });
24
+ });
25
+ };
26
+
27
+ // [function]
28
+
29
+ const deployEnsure = function ({ root }, { onLogInfo }, cb) {
30
+ ensureRepo(root, (err) => {
31
+ if (err) {
32
+ cb(err);
33
+ return;
34
+ }
35
+ ensureClean(root, (err, diff) => {
36
+ if (err) {
37
+ cb(err);
38
+ return;
39
+ }
40
+ if (diff.cached && onLogInfo) {
41
+ onLogInfo({
42
+ level: "warn",
43
+ message: "Staged but uncommitted changes will not be included.",
44
+ });
45
+ }
46
+ ensureRemote(root, cb);
47
+ });
48
+ });
49
+ };
50
+
51
+ // [function]
52
+
53
+ const deploy = function ({ version }, { root }, handler, cb) {
54
+ deployEnsure({ root }, handler, (err) => {
55
+ if (err) {
56
+ cb(err);
57
+ return;
58
+ }
59
+ deployRelease(version, { root }, handler, cb);
60
+ });
61
+ };
62
+
63
+ // [function]
64
+
65
+ const main = function ({ root }, { onPredeployBegin, ...handler }) {
66
+ if (onPredeployBegin) {
67
+ onPredeployBegin({ root });
68
+ }
69
+ return project(root).then(
70
+ ({ game }) =>
71
+ new Promise((resolve, reject) => {
72
+ deploy(game, { root }, handler, (err, data) => {
73
+ if (err) {
74
+ reject(err);
75
+ return;
76
+ }
77
+ resolve(data);
78
+ });
79
+ }),
80
+ );
81
+ };
82
+
83
+ // [export]
84
+
85
+ module.exports = main;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const ac = require("./ac");
6
+ const project = require("../../parser/project");
7
+
8
+ // [use]
9
+
10
+ const ensureVersion = ac.ensureVersion;
11
+
12
+ // [function]
13
+
14
+ const deployRelease = function (session, game, handler, cb) {
15
+ ensureVersion(session, game, (err) => {
16
+ if (err) {
17
+ cb(err);
18
+ return;
19
+ }
20
+ cb(null, { to: game.version });
21
+ });
22
+ };
23
+
24
+ // [function]
25
+
26
+ const deploy = function (session, game, handler, cb) {
27
+ deployRelease(session, game, handler, cb);
28
+ };
29
+
30
+ // [function]
31
+
32
+ const main = function (session, { root }, { onPredeployBegin, ...handler }) {
33
+ if (onPredeployBegin) {
34
+ onPredeployBegin({ root });
35
+ }
36
+ return project(root).then(
37
+ ({ game }) =>
38
+ new Promise((resolve, reject) => {
39
+ deploy(session, game, handler, (err, data) => {
40
+ if (err) {
41
+ reject(err);
42
+ return;
43
+ }
44
+ resolve(data);
45
+ });
46
+ }),
47
+ );
48
+ };
49
+
50
+ // [export]
51
+
52
+ module.exports = main;
package/src/api.js CHANGED
@@ -18,34 +18,40 @@ const endpoint = function (path) {
18
18
 
19
19
  // [function]
20
20
 
21
- const authRefresh = function (form, options) {
21
+ const postAuthRefresh = function (form, options) {
22
22
  return request.post(endpoint("/auth/refresh"), form, options);
23
23
  };
24
24
 
25
25
  // [function]
26
26
 
27
- const getFlow = function (flow, options) {
28
- return request.get(endpoint(`/flows/${flow}`), options);
27
+ const postFlow = function (form, options) {
28
+ return request.post(endpoint("/flows"), form, options);
29
29
  };
30
30
 
31
31
  // [function]
32
32
 
33
- const getGameBuild = function (game, version, options) {
34
- return request.get(endpoint(`/games/${game}/builds/${version}`), options);
33
+ const getFlow = function (flow, options) {
34
+ return request.get(endpoint(`/flows/${flow}`), options);
35
35
  };
36
36
 
37
37
  // [function]
38
38
 
39
- const postFlow = function (form, options) {
40
- return request.post(endpoint("/flows"), form, options);
39
+ const postUpload = function (form, options) {
40
+ return request.post(endpoint("/uploads"), form, options);
41
41
  };
42
42
 
43
43
  // [function]
44
44
 
45
- const postUpload = function (form, options) {
46
- return request.post(endpoint("/uploads"), form, options);
45
+ const getGameBuild = function (game, version, options) {
46
+ return request.get(endpoint(`/games/${game}/builds/${version}`), options);
47
47
  };
48
48
 
49
49
  // [export]
50
50
 
51
- module.exports = { authRefresh, getFlow, getGameBuild, postFlow, postUpload };
51
+ module.exports = {
52
+ getFlow,
53
+ getGameBuild,
54
+ postAuthRefresh,
55
+ postFlow,
56
+ postUpload,
57
+ };
package/src/cli/deploy.js CHANGED
@@ -7,10 +7,10 @@ const deployToolGit = require("../action/deploy/tool-git");
7
7
 
8
8
  // [function]
9
9
 
10
- const main = function ({ artifact, handler, session, ...conf }) {
11
- return artifact
12
- ? deployTool(session, artifact, conf, handler)
13
- : deployToolGit(conf, handler);
10
+ const main = function ({ artifact, git, handler, session, ...conf }) {
11
+ return git
12
+ ? deployToolGit(conf, handler)
13
+ : deployTool(session, artifact, conf, handler);
14
14
  };
15
15
 
16
16
  // [export]
package/src/cli/index.js CHANGED
@@ -9,6 +9,7 @@ const inspect = require("./inspect");
9
9
  const login = require("./login");
10
10
  const logout = require("./logout");
11
11
  const pack = require("./pack");
12
+ const predeploy = require("./predeploy");
12
13
  const validate = require("./validate");
13
14
  const whoami = require("./whoami");
14
15
 
@@ -22,6 +23,7 @@ module.exports = {
22
23
  login,
23
24
  logout,
24
25
  pack,
26
+ predeploy,
25
27
  validate,
26
28
  whoami,
27
29
  };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ // [import]
4
+
5
+ const predeployTool = require("../action/predeploy/tool");
6
+ const predeployToolGit = require("../action/predeploy/tool-git");
7
+
8
+ // [function]
9
+
10
+ const main = function ({ git, handler, session, ...conf }) {
11
+ return git
12
+ ? predeployToolGit(conf, handler)
13
+ : predeployTool(session, conf, handler);
14
+ };
15
+
16
+ // [export]
17
+
18
+ module.exports = main;
package/src/phrase.js CHANGED
@@ -47,6 +47,15 @@ const gitTagPushFailed = function () {
47
47
 
48
48
  // [function]
49
49
 
50
+ const gitVersionExists = function () {
51
+ return [
52
+ "Unable to create Git tag.",
53
+ "Ensure the version tag does not already exist locally.",
54
+ ].join("\n");
55
+ };
56
+
57
+ // [function]
58
+
50
59
  const issuesFound = function (count) {
51
60
  return `${count} ${count === 1 ? "issue" : "issues"} found. Run \`arc validate\` for details.`;
52
61
  };
@@ -131,6 +140,7 @@ module.exports = {
131
140
  gitRepoMissing,
132
141
  gitTagCreateFailed,
133
142
  gitTagPushFailed,
143
+ gitVersionExists,
134
144
  issuesFound,
135
145
  loginExpired,
136
146
  loginFailed,