arcadible 0.1.2 → 0.1.3
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-deploy.js +7 -10
- package/package.json +1 -1
- package/src/action/deploy-git/git.js +12 -59
- package/src/action/deploy-git/tool.js +31 -34
- package/src/cli/deploy.js +2 -2
- package/src/util/schema.js +1 -1
package/bin/arc-deploy.js
CHANGED
|
@@ -33,8 +33,8 @@ const SUBCMD = "deploy";
|
|
|
33
33
|
// [define]
|
|
34
34
|
|
|
35
35
|
const conf = {
|
|
36
|
+
git: false,
|
|
36
37
|
json: false,
|
|
37
|
-
production: false,
|
|
38
38
|
quiet: false,
|
|
39
39
|
...findRc(CMD, SUBCMD, process.argv, ["--cwd", "-C"]),
|
|
40
40
|
};
|
|
@@ -67,7 +67,6 @@ const handler = function ({ json, quiet }) {
|
|
|
67
67
|
|
|
68
68
|
const start = function (argv) {
|
|
69
69
|
const json = argv.json;
|
|
70
|
-
const pre = !argv.production;
|
|
71
70
|
const quiet = argv.quiet;
|
|
72
71
|
const root = resolve(process.cwd(), argv.cwd);
|
|
73
72
|
return validate({ root })
|
|
@@ -77,10 +76,8 @@ const start = function (argv) {
|
|
|
77
76
|
throw new Error("Validate failed. Run `arc validate` for details.");
|
|
78
77
|
}
|
|
79
78
|
return deploy({
|
|
80
|
-
|
|
79
|
+
git: argv.git,
|
|
81
80
|
handler: handler({ json, quiet }),
|
|
82
|
-
pre,
|
|
83
|
-
preId: "rc",
|
|
84
81
|
root,
|
|
85
82
|
});
|
|
86
83
|
})
|
|
@@ -90,7 +87,7 @@ const start = function (argv) {
|
|
|
90
87
|
return;
|
|
91
88
|
}
|
|
92
89
|
if (!quiet) {
|
|
93
|
-
log.p(`✓
|
|
90
|
+
log.p(`✓ Build v${data.to} submitted for release.`);
|
|
94
91
|
log.hs("Deployed.");
|
|
95
92
|
}
|
|
96
93
|
})
|
|
@@ -113,10 +110,10 @@ const main = function (argv) {
|
|
|
113
110
|
yargs(hideBin(argv))
|
|
114
111
|
.scriptName(`${CMD} ${SUBCMD}`)
|
|
115
112
|
.usage("$0 [options]")
|
|
116
|
-
.option("
|
|
117
|
-
alias: "
|
|
118
|
-
default: conf.
|
|
119
|
-
describe: "Deploy
|
|
113
|
+
.option("git", {
|
|
114
|
+
alias: "g",
|
|
115
|
+
default: conf.git,
|
|
116
|
+
describe: "Deploy through Git.",
|
|
120
117
|
type: "boolean",
|
|
121
118
|
})
|
|
122
119
|
.option("json", {
|
package/package.json
CHANGED
|
@@ -8,15 +8,9 @@ const execFile = require("node:child_process").execFile;
|
|
|
8
8
|
|
|
9
9
|
const semver = require("semver");
|
|
10
10
|
|
|
11
|
-
// [import]
|
|
12
|
-
|
|
13
|
-
const strs = require("../../util/strs");
|
|
14
|
-
|
|
15
11
|
// [use]
|
|
16
12
|
|
|
17
|
-
const
|
|
18
|
-
const trimWhitespace = strs.trimWhitespace;
|
|
19
|
-
const validSemver = semver.valid;
|
|
13
|
+
const prereleaseSemver = semver.prerelease;
|
|
20
14
|
|
|
21
15
|
// [declare]
|
|
22
16
|
|
|
@@ -32,8 +26,8 @@ const git = function (root, args, cb) {
|
|
|
32
26
|
|
|
33
27
|
const ensureRepo = function (root, cb) {
|
|
34
28
|
const message = [
|
|
35
|
-
"Unable to find Git repository.",
|
|
36
|
-
"
|
|
29
|
+
"Unable to find a Git repository.",
|
|
30
|
+
"Navigate to a Git repository and try again.",
|
|
37
31
|
];
|
|
38
32
|
git(root, ["rev-parse", "--is-inside-work-tree"], (err) => {
|
|
39
33
|
if (err) {
|
|
@@ -65,7 +59,7 @@ const ensureRemote = function (root, cb) {
|
|
|
65
59
|
const ensureClean = function (root, cb) {
|
|
66
60
|
const message = [
|
|
67
61
|
"Unable to continue with unstaged changes.",
|
|
68
|
-
"Stage, commit, or discard local changes before deploying.",
|
|
62
|
+
"Stage, commit, or discard your local changes before deploying.",
|
|
69
63
|
];
|
|
70
64
|
git(root, ["diff", "--quiet"], (err) => {
|
|
71
65
|
if (err) {
|
|
@@ -92,50 +86,7 @@ const ensureClean = function (root, cb) {
|
|
|
92
86
|
|
|
93
87
|
// [function]
|
|
94
88
|
|
|
95
|
-
const
|
|
96
|
-
const message = [
|
|
97
|
-
"Unable to synchronize Git release tags.",
|
|
98
|
-
"Run `arc deploy` again to retry with the latest release tags.",
|
|
99
|
-
];
|
|
100
|
-
git(
|
|
101
|
-
root,
|
|
102
|
-
["fetch", "origin", `refs/tags/${PREFIX}*:refs/tags/${PREFIX}*`],
|
|
103
|
-
(err) => {
|
|
104
|
-
if (err) {
|
|
105
|
-
cb(new Error(message.join("\n"), { cause: err }));
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
cb();
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// [function]
|
|
114
|
-
|
|
115
|
-
const listTags = function (root, cb) {
|
|
116
|
-
fetchTags(root, (err) => {
|
|
117
|
-
if (err) {
|
|
118
|
-
cb(err);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
git(root, ["tag", "--list", `${PREFIX}*`], (err, stdOut) => {
|
|
122
|
-
if (err) {
|
|
123
|
-
cb(err);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const versions = trimWhitespace(stdOut)
|
|
127
|
-
.split("\n")
|
|
128
|
-
.map((tag) => tag.slice(PREFIX.length))
|
|
129
|
-
.filter(validSemver)
|
|
130
|
-
.sort(compareSemver);
|
|
131
|
-
cb(null, versions.at(-1) || "0.0.0");
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// [function]
|
|
137
|
-
|
|
138
|
-
const createTag = function (root, version, pre, cb) {
|
|
89
|
+
const createTag = function (root, version, cb) {
|
|
139
90
|
const message = [
|
|
140
91
|
"Unable to create Git tag.",
|
|
141
92
|
"Verify the release tag does not already exist locally.",
|
|
@@ -147,7 +98,9 @@ const createTag = function (root, version, pre, cb) {
|
|
|
147
98
|
"-a",
|
|
148
99
|
`${PREFIX}${version}`,
|
|
149
100
|
"-m",
|
|
150
|
-
|
|
101
|
+
prereleaseSemver(version) === null
|
|
102
|
+
? `Release v${version}`
|
|
103
|
+
: `Prerelease v${version}`,
|
|
151
104
|
],
|
|
152
105
|
(err) => {
|
|
153
106
|
if (err) {
|
|
@@ -164,7 +117,7 @@ const createTag = function (root, version, pre, cb) {
|
|
|
164
117
|
const pushTag = function (root, version, cb) {
|
|
165
118
|
const message = [
|
|
166
119
|
"Unable to push Git tag.",
|
|
167
|
-
"
|
|
120
|
+
"Verify the release tag does not already exist on remote 'origin'.",
|
|
168
121
|
];
|
|
169
122
|
git(root, ["push", "origin", `${PREFIX}${version}`], (err) => {
|
|
170
123
|
if (err) {
|
|
@@ -177,8 +130,8 @@ const pushTag = function (root, version, cb) {
|
|
|
177
130
|
|
|
178
131
|
// [function]
|
|
179
132
|
|
|
180
|
-
const release = function (root, version,
|
|
181
|
-
createTag(root, version,
|
|
133
|
+
const release = function (root, version, cb) {
|
|
134
|
+
createTag(root, version, (err) => {
|
|
182
135
|
if (err) {
|
|
183
136
|
cb(err);
|
|
184
137
|
return;
|
|
@@ -189,4 +142,4 @@ const release = function (root, version, pre, cb) {
|
|
|
189
142
|
|
|
190
143
|
// [export]
|
|
191
144
|
|
|
192
|
-
module.exports = { ensureClean, ensureRemote, ensureRepo,
|
|
145
|
+
module.exports = { ensureClean, ensureRemote, ensureRepo, release };
|
|
@@ -2,43 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
// [import]
|
|
4
4
|
|
|
5
|
-
const semver = require("semver");
|
|
6
|
-
|
|
7
|
-
// [import]
|
|
8
|
-
|
|
9
5
|
const git = require("./git");
|
|
6
|
+
const project = require("../../parser/project");
|
|
10
7
|
|
|
11
8
|
// [use]
|
|
12
9
|
|
|
13
10
|
const ensureClean = git.ensureClean;
|
|
14
11
|
const ensureRemote = git.ensureRemote;
|
|
15
12
|
const ensureRepo = git.ensureRepo;
|
|
16
|
-
const incSemver = semver.inc;
|
|
17
|
-
const listTags = git.listTags;
|
|
18
13
|
const release = git.release;
|
|
19
14
|
|
|
20
15
|
// [function]
|
|
21
16
|
|
|
22
|
-
const
|
|
23
|
-
|
|
17
|
+
const deployRelease = function (version, { root }, handler, cb) {
|
|
18
|
+
release(root, version, (err) => {
|
|
24
19
|
if (err) {
|
|
25
20
|
cb(err);
|
|
26
21
|
return;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
release(root, to, pre, (err) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
cb(err);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
cb(null, { from, to });
|
|
35
|
-
});
|
|
23
|
+
cb(null, { to: version });
|
|
36
24
|
});
|
|
37
25
|
};
|
|
38
26
|
|
|
39
27
|
// [function]
|
|
40
28
|
|
|
41
|
-
const
|
|
29
|
+
const deployEnsure = function ({ root }, { onInfo }, cb) {
|
|
42
30
|
ensureRepo(root, (err) => {
|
|
43
31
|
if (err) {
|
|
44
32
|
cb(err);
|
|
@@ -55,32 +43,41 @@ const deploy = function ({ pre, preId, root }, { onInfo }, cb) {
|
|
|
55
43
|
message: "Staged but uncommitted changes will not be deployed.",
|
|
56
44
|
});
|
|
57
45
|
}
|
|
58
|
-
ensureRemote(root,
|
|
59
|
-
if (err) {
|
|
60
|
-
cb(err);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
deployGit({ pre, preId, root }, { onInfo }, cb);
|
|
64
|
-
});
|
|
46
|
+
ensureRemote(root, cb);
|
|
65
47
|
});
|
|
66
48
|
});
|
|
67
49
|
};
|
|
68
50
|
|
|
69
51
|
// [function]
|
|
70
52
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
resolve(data);
|
|
80
|
-
});
|
|
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);
|
|
81
60
|
});
|
|
82
61
|
};
|
|
83
62
|
|
|
63
|
+
// [function]
|
|
64
|
+
|
|
65
|
+
const main = function ({ root }, { onBegin, ...handler }) {
|
|
66
|
+
onBegin({ root });
|
|
67
|
+
return project.parse(root).then(
|
|
68
|
+
({ game }) =>
|
|
69
|
+
new Promise((resolve, reject) => {
|
|
70
|
+
deploy(game.version, { root }, handler, (err, data) => {
|
|
71
|
+
if (err) {
|
|
72
|
+
reject(err);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
resolve(data);
|
|
76
|
+
});
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
84
81
|
// [export]
|
|
85
82
|
|
|
86
83
|
module.exports = main;
|
package/src/cli/deploy.js
CHANGED
|
@@ -7,8 +7,8 @@ const deployTool = require("../action/deploy/tool");
|
|
|
7
7
|
|
|
8
8
|
// [function]
|
|
9
9
|
|
|
10
|
-
const main = function ({
|
|
11
|
-
const tool =
|
|
10
|
+
const main = function ({ git, handler, ...conf }) {
|
|
11
|
+
const tool = git ? deployGitTool : deployTool;
|
|
12
12
|
return tool(conf, handler);
|
|
13
13
|
};
|
|
14
14
|
|
package/src/util/schema.js
CHANGED
|
@@ -11,7 +11,7 @@ const format = function (name, error) {
|
|
|
11
11
|
// [function]
|
|
12
12
|
|
|
13
13
|
const validator = function (name, schema) {
|
|
14
|
-
return
|
|
14
|
+
return (value, conf) => {
|
|
15
15
|
const result = schema(value, conf).safeParse(value);
|
|
16
16
|
if (!result.success) {
|
|
17
17
|
return { issues: format(name, result.error) };
|