cob-cli 2.54.0-beta-1 → 2.54.0
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/cob-cli.js +8 -1
- package/lib/commands/deploy.js +4 -10
- package/lib/commands/test.js +5 -3
- package/lib/commands/updateFromServer.js +2 -2
- package/lib/task_lists/common_helpers.js +2 -0
- package/lib/task_lists/common_operationState.js +20 -4
- package/lib/task_lists/common_releaseManager.js +1 -9
- package/lib/task_lists/common_syncFiles.js +14 -98
- package/lib/task_lists/deploy_execute.js +5 -14
- package/lib/task_lists/deploy_validate.js +17 -15
- package/lib/task_lists/rsyncFilter-post.txt +5 -5
- package/lib/task_lists/test_otherFilesContiousReload.js +1 -4
- package/lib/task_lists/test_syncFile.js +2 -15
- package/lib/task_lists/test_validate.js +2 -0
- package/package.json +1 -1
package/bin/cob-cli.js
CHANGED
|
@@ -74,7 +74,14 @@ program
|
|
|
74
74
|
.option('-V --verbose', 'verbose execution of tasks', increaseVerbosity, 0)
|
|
75
75
|
.option('-s --servername <servername>', 'use <servername>.cultofbits.pt (i.e. name without the FQDN)')
|
|
76
76
|
.description('Deploy customization to the server')
|
|
77
|
-
.action(
|
|
77
|
+
.action( async (args) => {
|
|
78
|
+
try {
|
|
79
|
+
await deploy(args)
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error("\n", err.message);
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
78
85
|
|
|
79
86
|
program
|
|
80
87
|
.command('cleanup')
|
package/lib/commands/deploy.js
CHANGED
|
@@ -4,24 +4,18 @@ const { confirmExecutionOfChanges } = require("../task_lists/common_syncFiles");
|
|
|
4
4
|
const { validateDeployConditions } = require("../task_lists/deploy_validate");
|
|
5
5
|
const { executeTasks } = require("../task_lists/deploy_execute");
|
|
6
6
|
const { checkRepoVersion } = require("../commands/upgradeRepo");
|
|
7
|
-
const { saveOperationState, clearOperationState
|
|
7
|
+
const { saveOperationState, clearOperationState } = require("../task_lists/common_operationState");
|
|
8
8
|
|
|
9
9
|
async function deploy(args) {
|
|
10
10
|
checkRepoVersion()
|
|
11
11
|
const cmdEnv = await getCurrentCommandEnviroment(args)
|
|
12
|
-
await checkNoInterruptedRun()
|
|
13
|
-
saveOperationState(cmdEnv.name, cmdEnv.servername)
|
|
14
12
|
if(args.resync) args.force = true;
|
|
15
13
|
|
|
16
14
|
console.log(`Checking conditions to deploy ${cmdEnv.branchStr} to ${cmdEnv.serverStr}...` );
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// we should clear the operation state
|
|
22
|
-
clearOperationState();
|
|
23
|
-
throw err
|
|
24
|
-
}
|
|
16
|
+
await validateDeployConditions(cmdEnv,args).run()
|
|
17
|
+
|
|
18
|
+
saveOperationState(cmdEnv.name, cmdEnv.servername)
|
|
25
19
|
|
|
26
20
|
await cmdEnv.applyCurrentCommandEnvironmentChanges()
|
|
27
21
|
let changes = [];
|
package/lib/commands/test.js
CHANGED
|
@@ -25,16 +25,18 @@ async function test (args) {
|
|
|
25
25
|
checkRepoVersion()
|
|
26
26
|
console.log("Start testing… ")
|
|
27
27
|
cmdEnv = await getCurrentCommandEnviroment(args)
|
|
28
|
-
await checkNoInterruptedRun()
|
|
29
|
-
saveOperationState(cmdEnv.name, cmdEnv.servername)
|
|
30
|
-
stateSaved = true
|
|
31
28
|
|
|
32
29
|
if(!args.localOnly) {
|
|
33
30
|
await validateTestingConditions(cmdEnv, args)
|
|
31
|
+
saveOperationState(cmdEnv.name, cmdEnv.servername)
|
|
32
|
+
stateSaved = true
|
|
34
33
|
await cmdEnv.applyCurrentCommandEnvironmentChanges()
|
|
35
34
|
envChangesApplied = true
|
|
36
35
|
restoreChanges = await otherFilesContiousReload(cmdEnv)
|
|
37
36
|
} else {
|
|
37
|
+
await checkNoInterruptedRun()
|
|
38
|
+
saveOperationState(cmdEnv.name, cmdEnv.servername)
|
|
39
|
+
stateSaved = true
|
|
38
40
|
await cmdEnv.applyCurrentCommandEnvironmentChanges()
|
|
39
41
|
envChangesApplied = true
|
|
40
42
|
}
|
|
@@ -27,7 +27,7 @@ async function updateFromServer(args) {
|
|
|
27
27
|
|
|
28
28
|
console.log("\nOk to proceed. Getting files from server's live directories...");
|
|
29
29
|
await cmdEnv.applyCurrentCommandEnvironmentChanges()
|
|
30
|
-
let changes =
|
|
30
|
+
let changes = await copyFiles(cmdEnv, "serverLive", "localCopy", args)
|
|
31
31
|
await cmdEnv.unApplyCurrentCommandEnvironmentChanges()
|
|
32
32
|
|
|
33
33
|
if (changes.length == 0) {
|
|
@@ -91,7 +91,7 @@ async function updateFromServer(args) {
|
|
|
91
91
|
const dataPath = `others/solutionsData/${solution.name}`
|
|
92
92
|
fs.mkdir(dataPath, { recursive: true })
|
|
93
93
|
|
|
94
|
-
if (solution.
|
|
94
|
+
if (solution.permissions) {
|
|
95
95
|
await getGroupsFromServer(
|
|
96
96
|
cmdEnv.servername,
|
|
97
97
|
solution.groups,
|
|
@@ -15,6 +15,7 @@ function getSshArgs(server) {
|
|
|
15
15
|
|
|
16
16
|
if (process.env.COB_SSH_PORT) args.push("-p", process.env.COB_SSH_PORT);
|
|
17
17
|
if (process.env.COB_SSH_IDENTITY) args.push("-i", process.env.COB_SSH_IDENTITY);
|
|
18
|
+
if (process.env.COB_SSH_ARGS) process.env.COB_SSH_ARGS.split(" ").forEach(a => args.push('-o', a))
|
|
18
19
|
|
|
19
20
|
const target = process.env.COB_SSH_USER ? `${process.env.COB_SSH_USER}@${server}` : server;
|
|
20
21
|
args.push(target);
|
|
@@ -33,6 +34,7 @@ function getRsyncSsh() {
|
|
|
33
34
|
|
|
34
35
|
if (process.env.COB_SSH_IDENTITY) cmd += ` -i '${process.env.COB_SSH_IDENTITY}'`;
|
|
35
36
|
if (process.env.COB_SSH_PORT) cmd += ` -p ${process.env.COB_SSH_PORT}`;
|
|
37
|
+
if (process.env.COB_SSH_ARGS) cmd += " " + process.env.COB_SSH_ARGS.split(" ").map(a => `-o ${a}`).join(" ")
|
|
36
38
|
|
|
37
39
|
return cmd;
|
|
38
40
|
}
|
|
@@ -15,12 +15,28 @@ function clearOperationState() {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
async function checkNoInterruptedRun() {
|
|
18
|
-
const
|
|
18
|
+
const savedState = loadOperationState();
|
|
19
19
|
const envBackupFiles = await fg(['**/*.ENV__ORIGINAL_BACKUP__.*', '**/*.ENV__DELETE__.*'], { onlyFiles: false, dot: true });
|
|
20
|
-
if (
|
|
20
|
+
if (savedState || envBackupFiles.length > 0) {
|
|
21
|
+
const details = [];
|
|
22
|
+
if (savedState) {
|
|
23
|
+
details.push(
|
|
24
|
+
" saved state: environment " + (savedState.environment || "?").bold
|
|
25
|
+
+ ", server " + (savedState.servername || "?").bold
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (envBackupFiles.length > 0) {
|
|
29
|
+
details.push(" leftover environment backup files (" + envBackupFiles.length + "):");
|
|
30
|
+
envBackupFiles.slice(0, 5).forEach(f => details.push(" " + f));
|
|
31
|
+
if (envBackupFiles.length > 5) {
|
|
32
|
+
details.push(" ... and " + (envBackupFiles.length - 5) + " more");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
throw new Error(
|
|
22
|
-
"
|
|
23
|
-
+ "
|
|
37
|
+
"Aborted:".red + " found traces of a previous interrupted test/deploy.\n"
|
|
38
|
+
+ details.join("\n") + "\n\n"
|
|
39
|
+
+ "Run " + "cob-cli cleanup".yellow + " to restore the repo to a clean state first."
|
|
24
40
|
);
|
|
25
41
|
}
|
|
26
42
|
}
|
|
@@ -49,7 +49,7 @@ async function registerRelease(cmdEnv) {
|
|
|
49
49
|
// Add deploy tags to repo
|
|
50
50
|
await git().fetch(["--tags","-f"]) // Apenas para ter certeza que temos todas as tags
|
|
51
51
|
try {
|
|
52
|
-
await git().tag([deploySignature, "-d"])
|
|
52
|
+
await git().silent(true).tag([deploySignature, "-d"])
|
|
53
53
|
} catch {}
|
|
54
54
|
|
|
55
55
|
await git().addAnnotatedTag(deploySignature, newDeployText )
|
|
@@ -86,11 +86,3 @@ function getCurrentBranch() {
|
|
|
86
86
|
return git().revparse(["--abbrev-ref", "HEAD"]);
|
|
87
87
|
}
|
|
88
88
|
exports.getCurrentBranch = getCurrentBranch;
|
|
89
|
-
|
|
90
|
-
/* ************************************ */
|
|
91
|
-
async function appendToDeployLog(server, output) {
|
|
92
|
-
await execa('ssh', [...getSshArgs(server),
|
|
93
|
-
`{ echo $'${output.replace(/'/g, "\\'")}' | sed "s/^/\\t /"; } >> ${SERVER_CHANGELOG}`
|
|
94
|
-
]);
|
|
95
|
-
}
|
|
96
|
-
exports.appendToDeployLog = appendToDeployLog;
|
|
@@ -2,7 +2,7 @@ const execa = require('execa');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const { getKeypress } = require("../task_lists/common_helpers");
|
|
5
|
-
const { getRsyncSsh, getServerAddress
|
|
5
|
+
const { getRsyncSsh, getServerAddress } = require("./common_helpers");
|
|
6
6
|
|
|
7
7
|
/* ************************************ */
|
|
8
8
|
const COB_PRODUCTS = ["recordm", "integrationm", "recordm-importer", "reportm", "userm", "confm", "others", "authm", "public"];
|
|
@@ -19,14 +19,13 @@ exports.copyFiles = copyFiles;
|
|
|
19
19
|
|
|
20
20
|
/* ************************************ */
|
|
21
21
|
async function testEquality(cmdEnv, from, to, args) {
|
|
22
|
-
return (await _syncFiles(_syncFiles.TEST, cmdEnv, from, to, [], args)).
|
|
22
|
+
return (await _syncFiles(_syncFiles.TEST, cmdEnv, from, to, [], args)).filter( f => !f.endsWith("/"))
|
|
23
23
|
}
|
|
24
24
|
exports.testEquality = testEquality;
|
|
25
25
|
|
|
26
26
|
/* ************************************ */
|
|
27
27
|
async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], args = []) {
|
|
28
28
|
let changes = [];
|
|
29
|
-
let encFiles = [];
|
|
30
29
|
let products = cmdEnv.products.length ? cmdEnv.products : COB_PRODUCTS;
|
|
31
30
|
// we need to recheck, because it can exist in head but not in the commit we're testing
|
|
32
31
|
let hasRsyncFilter = cmdEnv.rsyncFilter && fs.lstatSync(cmdEnv.rsyncFilter, {throwIfNoEntry: false})?.isFile();
|
|
@@ -47,7 +46,6 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], ar
|
|
|
47
46
|
while (count < RSYNC_RETRIES) {
|
|
48
47
|
if (args.verbose > 2)
|
|
49
48
|
console.log("rsync".bold +" '" + (product).blue + "': attempt " + (count + 1));
|
|
50
|
-
const protectFilters = _getDecryptedEncFilePaths(product).map(p => `--filter='P ${p}'`);
|
|
51
49
|
const rsyncArgs = [
|
|
52
50
|
fromPath,
|
|
53
51
|
toPath,
|
|
@@ -60,7 +58,6 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], ar
|
|
|
60
58
|
"--filter='merge " + path.resolve(__dirname,"rsyncFilter-pre.txt") + "'",
|
|
61
59
|
hasRsyncFilter ? "--filter='merge " + cmdEnv.rsyncFilter + "'" : "",
|
|
62
60
|
"--filter='merge " + path.resolve(__dirname,"rsyncFilter-post.txt") + "'",
|
|
63
|
-
...protectFilters,
|
|
64
61
|
executionType == _syncFiles.COPY ? "-v" : "--dry-run"
|
|
65
62
|
].concat(productExtraOptions)
|
|
66
63
|
if (args.verbose > 3) {
|
|
@@ -74,17 +71,12 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], ar
|
|
|
74
71
|
if (args.verbose > 3)
|
|
75
72
|
console.log("rsync".bold +" '" + (product).blue + "': " + "success".green + " " + value.stdout);
|
|
76
73
|
|
|
77
|
-
let
|
|
78
|
-
if (executionType == _syncFiles.TEST || executionType == _syncFiles.DIFF)
|
|
79
|
-
rsyncOutput = _filterDecryptedEncFiles(product, rsyncOutput);
|
|
80
|
-
let result = _formatRsyncOutput(product, rsyncOutput);
|
|
74
|
+
let result = _formatRsyncOutput(product, value.stdout);
|
|
81
75
|
if (args.verbose > 2)
|
|
82
76
|
console.log("rsync '" + product + "': success " + result);
|
|
83
77
|
else if (args.verbose > 1)
|
|
84
78
|
console.log("rsync '" + product + "': success ");
|
|
85
79
|
changes = changes.concat(result);
|
|
86
|
-
if (executionType == _syncFiles.COPY)
|
|
87
|
-
encFiles = encFiles.concat(_extractEncFilePaths(product, value.stdout));
|
|
88
80
|
count = RSYNC_RETRIES;
|
|
89
81
|
|
|
90
82
|
resolve();
|
|
@@ -128,41 +120,7 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], ar
|
|
|
128
120
|
});
|
|
129
121
|
});
|
|
130
122
|
await Promise.all(requests).catch(err => { throw new Error(err.message); });
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/* ************************************ */
|
|
135
|
-
function _filterDecryptedEncFiles(product, rsyncOutput) {
|
|
136
|
-
return rsyncOutput
|
|
137
|
-
.split("\n")
|
|
138
|
-
.filter(line => {
|
|
139
|
-
// ignore decrypted files:
|
|
140
|
-
// * marked as deleted on local -> server
|
|
141
|
-
// * marked as added on server -> local
|
|
142
|
-
if (line.startsWith("*deleting ") || /^>f\+/.test(line)) {
|
|
143
|
-
const relativePath = line.split(/\s+/)[1];
|
|
144
|
-
if (!relativePath) return true;
|
|
145
|
-
return !fs.existsSync("./" + product + "/" + relativePath + ".enc");
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
})
|
|
149
|
-
.join("\n");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/* ************************************ */
|
|
153
|
-
function _getDecryptedEncFilePaths(product) {
|
|
154
|
-
const productDir = "./" + product;
|
|
155
|
-
if (!fs.existsSync(productDir)) return [];
|
|
156
|
-
const paths = [];
|
|
157
|
-
const walk = (dir, rel) => {
|
|
158
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
159
|
-
const entryRel = rel ? rel + "/" + entry.name : entry.name;
|
|
160
|
-
if (entry.isDirectory()) walk(path.join(dir, entry.name), entryRel);
|
|
161
|
-
else if (entry.name.endsWith(".enc")) paths.push("/" + entryRel.slice(0, -4));
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
walk(productDir, "");
|
|
165
|
-
return paths;
|
|
123
|
+
return changes;
|
|
166
124
|
}
|
|
167
125
|
|
|
168
126
|
/* ************************************ */
|
|
@@ -189,7 +147,7 @@ function _formatRsyncOutput(product, rsyncOutput) {
|
|
|
189
147
|
/* ************************************ */
|
|
190
148
|
async function confirmExecutionOfChanges(cmdEnv, extraOptions = []) {
|
|
191
149
|
console.log("\nChecking changes... ")
|
|
192
|
-
let changes = (await _syncFiles(_syncFiles.DIFF, cmdEnv, "localCopy", "serverLive", extraOptions)).
|
|
150
|
+
let changes = (await _syncFiles(_syncFiles.DIFF, cmdEnv, "localCopy", "serverLive", extraOptions)).filter( f => !f.endsWith("/") )
|
|
193
151
|
if (changes.length) {
|
|
194
152
|
console.log("\nChanges that will be done in " + cmdEnv.serverStr + ":");
|
|
195
153
|
console.log(" " + changes.join("\n "));
|
|
@@ -205,19 +163,6 @@ async function confirmExecutionOfChanges(cmdEnv, extraOptions = []) {
|
|
|
205
163
|
}
|
|
206
164
|
exports.confirmExecutionOfChanges = confirmExecutionOfChanges;
|
|
207
165
|
|
|
208
|
-
/* ************************************ */
|
|
209
|
-
function _getServerLiveBasePath(product) {
|
|
210
|
-
switch (product) {
|
|
211
|
-
case "public":
|
|
212
|
-
return "/usr/share/cob/"
|
|
213
|
-
case "recordm-importer":
|
|
214
|
-
case "others":
|
|
215
|
-
return "/opt/" + product + "/";
|
|
216
|
-
default:
|
|
217
|
-
return "/etc/" + product + "/";
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
166
|
/* ************************************ */
|
|
222
167
|
function resolveCobPath(server, type, product) {
|
|
223
168
|
switch (type) {
|
|
@@ -228,47 +173,18 @@ function resolveCobPath(server, type, product) {
|
|
|
228
173
|
return getServerAddress(server) + ":/opt/" + product + "/etc.default/";
|
|
229
174
|
|
|
230
175
|
case "serverLive":
|
|
231
|
-
|
|
176
|
+
switch (product) {
|
|
177
|
+
case "public":
|
|
178
|
+
return getServerAddress(server) + ":/usr/share/cob/"
|
|
179
|
+
case "recordm-importer":
|
|
180
|
+
case "others":
|
|
181
|
+
return getServerAddress(server) + ':' + "/opt/" + product + "/";
|
|
182
|
+
default:
|
|
183
|
+
return getServerAddress(server) + ':' + "/etc/" + product + "/";
|
|
184
|
+
}
|
|
232
185
|
|
|
233
186
|
case "staging":
|
|
234
187
|
return ".staging/" + product + "/";
|
|
235
188
|
}
|
|
236
189
|
}
|
|
237
190
|
exports.resolveCobPath = resolveCobPath;
|
|
238
|
-
|
|
239
|
-
/* ************************************ */
|
|
240
|
-
function _extractEncFilePaths(product, rsyncOutput) {
|
|
241
|
-
const basePath = _getServerLiveBasePath(product);
|
|
242
|
-
return rsyncOutput
|
|
243
|
-
.split("\n")
|
|
244
|
-
.slice(1, -3)
|
|
245
|
-
.filter(line => /^[<>]f/.test(line))
|
|
246
|
-
.map(line => line.split(/\s+/)[1])
|
|
247
|
-
.filter(filePath => filePath && filePath.endsWith(".enc"))
|
|
248
|
-
.map(filePath => basePath + filePath);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/* ************************************ */
|
|
252
|
-
async function decryptEncFile(server, serverFilePath) {
|
|
253
|
-
await execa('ssh', [...getSshArgs(server), `sudo -u cob-secrets /usr/local/bin/cob-decrypt '${serverFilePath}'`]);
|
|
254
|
-
}
|
|
255
|
-
exports.decryptEncFile = decryptEncFile;
|
|
256
|
-
|
|
257
|
-
/* ************************************ */
|
|
258
|
-
async function decryptEncFiles(cmdEnv, encFiles) {
|
|
259
|
-
for (const f of encFiles) {
|
|
260
|
-
await decryptEncFile(cmdEnv.server, f);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
exports.decryptEncFiles = decryptEncFiles;
|
|
264
|
-
|
|
265
|
-
/* ************************************ */
|
|
266
|
-
async function deploySolutions(server) {
|
|
267
|
-
const result = await execa('ssh', [...getSshArgs(server),
|
|
268
|
-
'/usr/local/bin/cc-install solutions'
|
|
269
|
-
], { reject: false, all: true });
|
|
270
|
-
|
|
271
|
-
return { output: result.all, exitCode: result.exitCode };
|
|
272
|
-
}
|
|
273
|
-
exports.deploySolutions = deploySolutions;
|
|
274
|
-
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
const Listr = require('listr');
|
|
2
2
|
const UpdaterRenderer = require('listr-update-renderer');
|
|
3
3
|
const verboseRenderer = require('listr-verbose-renderer');
|
|
4
|
-
const fs = require('fs');
|
|
5
4
|
const git = require('simple-git');
|
|
6
|
-
const { registerRelease
|
|
7
|
-
const { copyFiles
|
|
5
|
+
const { registerRelease } = require("./common_releaseManager");
|
|
6
|
+
const { copyFiles } = require("./common_syncFiles");
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
function executeTasks(cmdEnv, args) {
|
|
11
10
|
console.log("\nDeploying ...");
|
|
12
|
-
let encFiles = [];
|
|
13
|
-
let ccInstallResult = {};
|
|
14
11
|
|
|
15
12
|
return new Listr([
|
|
16
13
|
{title: "Register release in DEPLOYLOG.md", task: () => registerRelease(cmdEnv)},
|
|
17
14
|
{title: `git push (branch: ${cmdEnv.currentBranch})`, task: () => git().push("origin", cmdEnv.currentBranch, {"--set-upstream": null})},
|
|
18
|
-
{title: "Apply new enviroment specifics", task: () => cmdEnv.applyCurrentCommandEnvironmentChanges() },
|
|
19
|
-
{title: "Deploy files to server's live directories", task:
|
|
20
|
-
{title: "Decrypt .enc files", skip: () => !encFiles.length, task: () => decryptEncFiles(cmdEnv, encFiles)},
|
|
21
|
-
{title: "Deploy data", skip: () => !fs.existsSync('solutions.yml'), task: async () => {
|
|
22
|
-
ccInstallResult = await deploySolutions(cmdEnv.server);
|
|
23
|
-
if (ccInstallResult.exitCode !== 0) throw new Error(`Deploying data failed:\n${ccInstallResult.output}`);
|
|
24
|
-
}},
|
|
25
|
-
{title: "Register solutions deploy output", skip: () => !fs.existsSync('solutions.yml'), task: () => appendToDeployLog(cmdEnv.server, ccInstallResult.output)},
|
|
15
|
+
{title: "Apply new enviroment specifics", task: () => cmdEnv.applyCurrentCommandEnvironmentChanges() },
|
|
16
|
+
{title: "Deploy files to server's live directories", task: () => copyFiles(cmdEnv, "localCopy", "serverLive")},
|
|
26
17
|
{title: "Set last environment deployed", task: () => cmdEnv.setLastEnvironmentDeployed()},
|
|
27
|
-
{title: "Undo new enviroment specifics", task: () => cmdEnv.unApplyCurrentCommandEnvironmentChanges() },
|
|
18
|
+
{title: "Undo new enviroment specifics", task: () => cmdEnv.unApplyCurrentCommandEnvironmentChanges() },
|
|
28
19
|
], {
|
|
29
20
|
renderer: args.verbose ? verboseRenderer : UpdaterRenderer,
|
|
30
21
|
collapse: false
|
|
@@ -7,16 +7,18 @@ const { checkWorkingCopyCleanliness, checkConnectivity } = require("./common_hel
|
|
|
7
7
|
const { getCurrentBranch, getLastDeployedSha } = require("./common_releaseManager");
|
|
8
8
|
const { testEquality } = require("./common_syncFiles");
|
|
9
9
|
const { checkNoTestsRunningOnServer } = require("./test_otherFilesContiousReload")
|
|
10
|
+
const { checkNoInterruptedRun } = require("./common_operationState");
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
function validateDeployConditions(cmdEnv, args) {
|
|
13
14
|
return new Listr([
|
|
15
|
+
{ title: "Check no previous interrupted run".bold, task: () => checkNoInterruptedRun() },
|
|
14
16
|
{ title: "Check connectivity and permissions".bold, task: () => checkConnectivity(cmdEnv.server) },
|
|
15
|
-
{ title: "Check git status".bold, task: () => checkWorkingCopyCleanliness(false) },
|
|
17
|
+
{ title: "Check git status".bold, task: () => checkWorkingCopyCleanliness(false) },
|
|
16
18
|
{ title: "Check there's no 'cob-cli test' running on server".bold, task: () => checkNoTestsRunningOnServer(cmdEnv.server) },
|
|
17
|
-
{ title: "find out branch-for-HEAD", skip: () => args.force, task: (ctx) => getCurrentBranch().then( currentBranch => ctx.currentBranch = currentBranch ) },
|
|
18
|
-
{ title: "find out SHA for last-deploy on specified server", skip: () => args.force, task: (ctx) => getLastDeployedSha(cmdEnv.server).then(lastSha => _handleGetLastDeployedSha(ctx, cmdEnv, lastSha)) },
|
|
19
|
-
{ title: "git checkout SHA-for-last-deploy", skip: ctx => args.force || !ctx.lastSha, task: (ctx) => git().checkout(ctx.lastSha) },
|
|
19
|
+
{ title: "find out branch-for-HEAD", skip: () => args.force, task: (ctx) => getCurrentBranch().then( currentBranch => ctx.currentBranch = currentBranch ) },
|
|
20
|
+
{ title: "find out SHA for last-deploy on specified server", skip: () => args.force, task: (ctx) => getLastDeployedSha(cmdEnv.server).then(lastSha => _handleGetLastDeployedSha(ctx, cmdEnv, lastSha)) },
|
|
21
|
+
{ title: "git checkout SHA-for-last-deploy", skip: ctx => args.force || !ctx.lastSha, task: (ctx) => git().checkout(ctx.lastSha) },
|
|
20
22
|
{ title: "Apply last enviroment specifics".bold, skip: ctx => args.force || !ctx.lastSha, task: () => cmdEnv.applyLastEnvironmentDeployedToServerChanges() },
|
|
21
23
|
{ title: "Check last-deploy == serverLive".bold, skip: ctx => args.force || !ctx.lastSha, task: (ctx) => testEquality(cmdEnv, "localCopy", "serverLive", args).then( changes => _handleTestEquality(ctx, changes)) },
|
|
22
24
|
{ title: "Undo last enviroment specifics".bold, skip: ctx => args.force || !ctx.lastSha, task: () => cmdEnv.unApplyLastEnvironmentDeployedToServerChanges() },
|
|
@@ -32,18 +34,18 @@ exports.validateDeployConditions = validateDeployConditions;
|
|
|
32
34
|
|
|
33
35
|
/* ************************************ */
|
|
34
36
|
function _handleGetLastDeployedSha(ctx, cmdEnv, lastSha) {
|
|
35
|
-
if (lastSha) {
|
|
36
|
-
ctx.lastSha = lastSha
|
|
37
|
-
} else {
|
|
38
|
-
ctx.err =
|
|
39
|
-
"No previous deploy to "
|
|
40
|
-
+ cmdEnv.server.bold
|
|
41
|
-
+ " found.\n If it's a new server do "
|
|
42
|
-
+ ("cob-cli deploy -s " + cmdEnv.servername + " --force").yellow
|
|
43
|
-
+ " first, to initialize the server\n\n "
|
|
44
|
-
+ "Aborted:".bgRed + " no previous deploy detected on this server."
|
|
37
|
+
if (lastSha) {
|
|
38
|
+
ctx.lastSha = lastSha
|
|
39
|
+
} else {
|
|
40
|
+
ctx.err =
|
|
41
|
+
"No previous deploy to "
|
|
42
|
+
+ cmdEnv.server.bold
|
|
43
|
+
+ " found.\n If it's a new server do "
|
|
44
|
+
+ ("cob-cli deploy -s " + cmdEnv.servername + " --force").yellow
|
|
45
|
+
+ " first, to initialize the server\n\n "
|
|
46
|
+
+ "Aborted:".bgRed + " no previous deploy detected on this server."
|
|
45
47
|
+ "\n"
|
|
46
|
-
}
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
/* ************************************ */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
+ /services/com.cultofbits.web.integration.properties
|
|
2
|
-
+ /services/com.cultofbits.genesis.comm.properties
|
|
3
|
-
+ /services/com.cultofbits.confm.interact.properties
|
|
4
|
-
+ /services/com.cultofbits.integrationm.service.properties
|
|
1
|
+
+ /services/com.cultofbits.web.integration.properties
|
|
2
|
+
+ /services/com.cultofbits.genesis.comm.properties
|
|
3
|
+
+ /services/com.cultofbits.confm.interact.properties
|
|
4
|
+
+ /services/com.cultofbits.integrationm.service.properties
|
|
5
5
|
- /services/**
|
|
6
6
|
|
|
7
7
|
- /security
|
|
8
8
|
- /hornetq
|
|
9
9
|
- /elasticsearch
|
|
10
10
|
- /db
|
|
11
|
-
- /reports
|
|
11
|
+
- /reports
|
|
@@ -36,7 +36,7 @@ async function otherFilesContiousReload(cmdEnv) {
|
|
|
36
36
|
}
|
|
37
37
|
/* ************************************ */
|
|
38
38
|
|
|
39
|
-
fs.writeFileSync('.'+IN_PROGRESS_TEST_FILE, "
|
|
39
|
+
fs.writeFileSync('.'+IN_PROGRESS_TEST_FILE, "in progress")
|
|
40
40
|
|
|
41
41
|
changes.length && console.log("\n Making the changes...".yellow);
|
|
42
42
|
for(let change of changes) {
|
|
@@ -44,9 +44,6 @@ async function otherFilesContiousReload(cmdEnv) {
|
|
|
44
44
|
const changedFile = change.split(" ")[1];
|
|
45
45
|
await addFileToCurrentTest(cmdEnv.server, changedFile, changedFiles, changeType, restoreChanges);
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
fs.writeFileSync('.'+IN_PROGRESS_TEST_FILE, "in progress")
|
|
49
|
-
|
|
50
47
|
watcher.process = chokidar.watch('.', {
|
|
51
48
|
//ignored: /(^|[\/\\])\../, // ignore dotfiles
|
|
52
49
|
persistent: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const execa = require('execa');
|
|
2
2
|
const fs = require('fs-extra');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const { resolveCobPath
|
|
4
|
+
const { resolveCobPath } = require("./common_syncFiles");
|
|
5
5
|
const { getSshArgs, getRsyncSsh } = require("./common_helpers");
|
|
6
6
|
|
|
7
7
|
const DEBUG = false;
|
|
@@ -17,7 +17,6 @@ async function syncFile(server, localFile) {
|
|
|
17
17
|
let remoteProductPath = resolveCobPath(server, "serverLive", product);
|
|
18
18
|
let remoteFileDir = remoteProductPath.split(":")[1] + productScopeFilePath.substring(0, productScopeFilePath.lastIndexOf("/"));
|
|
19
19
|
|
|
20
|
-
let fileWasSynced = true;
|
|
21
20
|
let count = 0;
|
|
22
21
|
while (count < RSYNC_RETRIES) {
|
|
23
22
|
await execa('ssh', [...getSshArgs(server), "mkdir -p " + remoteFileDir]).catch({});
|
|
@@ -35,15 +34,7 @@ async function syncFile(server, localFile) {
|
|
|
35
34
|
.catch(async (err) => {
|
|
36
35
|
// exitCode 23 indicam que o ficheiro não existe na origem. Temod de apagar no destino.
|
|
37
36
|
if (err.exitCode == 23) {
|
|
38
|
-
|
|
39
|
-
await execa('ssh', [...getSshArgs(server),
|
|
40
|
-
"rm -fd " + remoteProductPath.split(":")[1] + productScopeFilePath
|
|
41
|
-
]).catch({});
|
|
42
|
-
if (localFile.endsWith(".enc")) {
|
|
43
|
-
await execa('ssh', [ ...getSshArgs(server),
|
|
44
|
-
"rm -fd " + remoteProductPath.split(":")[1] + productScopeFilePath.slice(0, -4)
|
|
45
|
-
]).catch({});
|
|
46
|
-
}
|
|
37
|
+
await execa('ssh', [...getSshArgs(server), "rm -fd " + remoteProductPath.split(":")[1] + productScopeFilePath]).catch({});
|
|
47
38
|
|
|
48
39
|
let localFileDir = localFile.substring(0, localFile.lastIndexOf("/"));
|
|
49
40
|
if (!fs.existsSync(localFileDir)) {
|
|
@@ -60,9 +51,5 @@ async function syncFile(server, localFile) {
|
|
|
60
51
|
});
|
|
61
52
|
count++;
|
|
62
53
|
}
|
|
63
|
-
|
|
64
|
-
if (fileWasSynced && localFile.endsWith(".enc")) {
|
|
65
|
-
await decryptEncFile(server, remoteProductPath.split(":")[1] + productScopeFilePath);
|
|
66
|
-
}
|
|
67
54
|
}
|
|
68
55
|
exports.syncFile = syncFile;
|
|
@@ -10,11 +10,13 @@ const { getCurrentBranch, getLastDeployedSha } = require("./common_releaseManage
|
|
|
10
10
|
const { testEquality } = require("./common_syncFiles");
|
|
11
11
|
const { SERVER_IN_PROGRESS_TEST_FILE } = require("../task_lists/test_otherFilesContiousReload");
|
|
12
12
|
const { getSshArgs } = require("./common_helpers");
|
|
13
|
+
const { checkNoInterruptedRun } = require("./common_operationState");
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
async function validateTestingConditions(cmdEnv, args) {
|
|
16
17
|
console.log("Checking test conditions for", cmdEnv.serverStr );
|
|
17
18
|
let result = await new Listr([
|
|
19
|
+
{ title: "Check no previous interrupted run".bold, task: () => checkNoInterruptedRun() },
|
|
18
20
|
{ title: "Check connectivity and permissions".bold, task: () => checkConnectivity(cmdEnv.server) },
|
|
19
21
|
{ title: "Check there's no other 'cob-cli test' running locally".bold, task: () => _checkNoTestsRunningLocally() },
|
|
20
22
|
{ title: "find out branch-for-HEAD", task: (ctx) => getCurrentBranch().then( currentBranch => ctx.currentBranch = currentBranch) },
|
package/package.json
CHANGED