saturn-core-cli 0.0.1 → 0.0.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/commands/publish.js +146 -8
- package/package.json +6 -5
package/commands/publish.js
CHANGED
|
@@ -12,6 +12,9 @@ let exemptions = null;
|
|
|
12
12
|
const SATURN_URL = "https://managerapi.saturn.gd/api";
|
|
13
13
|
const SATURN_API_TOKEN =
|
|
14
14
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InVzZXItZGM5MGJhN2ItZjY0MS00OGVjLWEwZjgtNDNlZjk3MzA5MTk2IiwiZ3JvdXAiOiJ1c2VyX2dyb3VwLTBiNDNjYjdhLTY5NzgtNGYwMy1iNGRkLTJiODVjMzBkYzVkOSIsImlhdCI6MTY0NzMzNjQzOX0.qigpTkuHyK9ovX-e4JhybxqcGa2Y-7miR29HOp_Vjdg";
|
|
15
|
+
var exec = require("child-process-promise").exec;
|
|
16
|
+
var spawn = require("child-process-promise").spawn;
|
|
17
|
+
const semverInc = require("semver/functions/inc");
|
|
15
18
|
|
|
16
19
|
try {
|
|
17
20
|
exemptions = require(saturnignore);
|
|
@@ -19,25 +22,160 @@ try {
|
|
|
19
22
|
exemptions = [];
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
async function action(
|
|
25
|
+
async function action(release = "patch", options) {
|
|
23
26
|
try {
|
|
24
27
|
const packageObj = await fs.readJson(`package.json`);
|
|
25
|
-
if (version == undefined) {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
28
|
+
//if (version == undefined) {
|
|
29
|
+
//let version = packageObj.version;
|
|
30
|
+
//}
|
|
31
|
+
let version = semverInc(packageObj.version, release);
|
|
32
|
+
packageObj.version = version;
|
|
29
33
|
let map = await new mapper({ exemptions: exemptions }).createMap("./");
|
|
30
34
|
if (options.dry) {
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
37
|
let core = await getCoreId(packageObj.saturn.core);
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
await createInstance(map, core.id, version);
|
|
39
|
+
await doGitAdd();
|
|
40
|
+
await doGitCommit("SC Publish");
|
|
41
|
+
await doGitPush();
|
|
42
|
+
await doCreateGitTag(version);
|
|
43
|
+
await doPushGitTag();
|
|
44
|
+
await fs.writeJson(`package.json`, packageObj, { spaces: 2 });
|
|
36
45
|
} catch (e) {
|
|
37
46
|
console.log(e.stack);
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
|
|
50
|
+
function doGitAdd() {
|
|
51
|
+
status.start();
|
|
52
|
+
console.log("Doing GIT add");
|
|
53
|
+
let promise = spawn("git", ["add", "."], { capture: ["stdout", "stderr"] });
|
|
54
|
+
let childProcess = promise.childProcess;
|
|
55
|
+
|
|
56
|
+
childProcess.stdout.on("data", function (data) {
|
|
57
|
+
console.log(data.toString());
|
|
58
|
+
});
|
|
59
|
+
childProcess.stderr.on("data", function (data) {
|
|
60
|
+
console.log(data.toString());
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
promise
|
|
64
|
+
.then(function () {
|
|
65
|
+
console.log("Done git add");
|
|
66
|
+
status.stop();
|
|
67
|
+
})
|
|
68
|
+
.catch(function (err) {
|
|
69
|
+
console.error(err);
|
|
70
|
+
status.stop();
|
|
71
|
+
});
|
|
72
|
+
return promise;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function doCreateGitTag(tag) {
|
|
76
|
+
status.start();
|
|
77
|
+
console.log("Doing GIT tag", tag);
|
|
78
|
+
let promise = spawn("git", ["tag", tag], { capture: ["stdout", "stderr"] });
|
|
79
|
+
let childProcess = promise.childProcess;
|
|
80
|
+
|
|
81
|
+
childProcess.stdout.on("data", function (data) {
|
|
82
|
+
console.log(data.toString());
|
|
83
|
+
});
|
|
84
|
+
childProcess.stderr.on("data", function (data) {
|
|
85
|
+
console.log(data.toString());
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
promise
|
|
89
|
+
.then(function () {
|
|
90
|
+
console.log("Done git tag");
|
|
91
|
+
status.stop();
|
|
92
|
+
})
|
|
93
|
+
.catch(function (err) {
|
|
94
|
+
console.error(err);
|
|
95
|
+
status.stop();
|
|
96
|
+
});
|
|
97
|
+
return promise;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function doPushGitTag() {
|
|
101
|
+
status.start();
|
|
102
|
+
console.log("Doing GIT tag push");
|
|
103
|
+
let promise = spawn("git", ["push", "origin", "--tags"], {
|
|
104
|
+
capture: ["stdout", "stderr"],
|
|
105
|
+
});
|
|
106
|
+
let childProcess = promise.childProcess;
|
|
107
|
+
|
|
108
|
+
childProcess.stdout.on("data", function (data) {
|
|
109
|
+
console.log(data.toString());
|
|
110
|
+
});
|
|
111
|
+
childProcess.stderr.on("data", function (data) {
|
|
112
|
+
console.log(data.toString());
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
promise
|
|
116
|
+
.then(function () {
|
|
117
|
+
console.log("Done git tag push");
|
|
118
|
+
status.stop();
|
|
119
|
+
})
|
|
120
|
+
.catch(function (err) {
|
|
121
|
+
console.error(err);
|
|
122
|
+
status.stop();
|
|
123
|
+
});
|
|
124
|
+
return promise;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function doGitCommit(message) {
|
|
128
|
+
status.start();
|
|
129
|
+
console.log("Doing GIT Commit");
|
|
130
|
+
let promise = spawn("git", ["commit", "-m", `"${message}"`], {
|
|
131
|
+
capture: ["stdout", "stderr"],
|
|
132
|
+
});
|
|
133
|
+
let childProcess = promise.childProcess;
|
|
134
|
+
|
|
135
|
+
childProcess.stdout.on("data", function (data) {
|
|
136
|
+
console.log(data.toString());
|
|
137
|
+
});
|
|
138
|
+
childProcess.stderr.on("data", function (data) {
|
|
139
|
+
console.log(data.toString());
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
promise
|
|
143
|
+
.then(function () {
|
|
144
|
+
console.log("Done git commit");
|
|
145
|
+
status.stop();
|
|
146
|
+
})
|
|
147
|
+
.catch(function (err) {
|
|
148
|
+
console.error(err);
|
|
149
|
+
status.stop();
|
|
150
|
+
});
|
|
151
|
+
return promise;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function doGitPush() {
|
|
155
|
+
status.start();
|
|
156
|
+
console.log("Doing GIT push");
|
|
157
|
+
let promise = spawn("git", ["push"], { capture: ["stdout", "stderr"] });
|
|
158
|
+
let childProcess = promise.childProcess;
|
|
159
|
+
|
|
160
|
+
childProcess.stdout.on("data", function (data) {
|
|
161
|
+
console.log(data.toString());
|
|
162
|
+
});
|
|
163
|
+
childProcess.stderr.on("data", function (data) {
|
|
164
|
+
console.log(data.toString());
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
promise
|
|
168
|
+
.then(function () {
|
|
169
|
+
console.log("Done git push");
|
|
170
|
+
status.stop();
|
|
171
|
+
})
|
|
172
|
+
.catch(function (err) {
|
|
173
|
+
console.error(err);
|
|
174
|
+
status.stop();
|
|
175
|
+
});
|
|
176
|
+
return promise;
|
|
177
|
+
}
|
|
178
|
+
|
|
41
179
|
async function getCoreId(core) {
|
|
42
180
|
let response = await axios.get(`${SATURN_URL}/cores`, {
|
|
43
181
|
headers: {
|
|
@@ -74,7 +212,7 @@ function command(prog) {
|
|
|
74
212
|
"use strict";
|
|
75
213
|
program = prog;
|
|
76
214
|
program
|
|
77
|
-
.command("publish [
|
|
215
|
+
.command("publish [release]", { isDefault: true })
|
|
78
216
|
.option("-d, --dry <template>", "Dry Run", false)
|
|
79
217
|
.description("Publish Saturn Version")
|
|
80
218
|
.action(action);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "saturn-core-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Saturn Core CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,17 +14,18 @@
|
|
|
14
14
|
"author": "Chad Fraser <chad@sonover.com> (http://sonover.com)",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"axios": "^0.27.2",
|
|
17
18
|
"babel-polyfill": "^6.26.0",
|
|
18
19
|
"child-process-promise": "^2.2.1",
|
|
20
|
+
"chokidar": "^3.5.2",
|
|
19
21
|
"colors": "^1.4.0",
|
|
20
22
|
"commander": "^9.2.0",
|
|
21
|
-
"axios": "^0.27.2",
|
|
22
|
-
"chokidar": "^3.5.2",
|
|
23
23
|
"fs-extra": "^8.1.0",
|
|
24
|
+
"klaw-sync": "^6.0.0",
|
|
25
|
+
"lodash": "^4.17.21",
|
|
24
26
|
"pluralize": "^8.0.0",
|
|
25
27
|
"prompt": "^1.0.0",
|
|
26
|
-
"
|
|
27
|
-
"lodash": "^4.17.21"
|
|
28
|
+
"semver": "^7.3.7"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@babel/core": "^7.8.4",
|