cob-cli 2.45.0 → 2.46.0-beta.10
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/handleAutoComplete.js +9 -1
- package/lib/commands/getDefs.js +2 -2
- package/lib/commands/init.js +12 -3
- package/lib/commands/test.js +6 -5
- package/lib/task_lists/common_enviromentHandler.js +10 -3
- package/lib/task_lists/common_helpers.js +8 -1
- package/lib/task_lists/common_syncFiles.js +25 -19
- package/lib/task_lists/test_customUIsContinuosReload.js +38 -7
- package/lib/task_lists/test_otherFilesContiousReload.js +3 -1
- package/package.json +4 -4
|
@@ -15,11 +15,19 @@ completion.init()
|
|
|
15
15
|
|
|
16
16
|
// add to system profiles
|
|
17
17
|
if (~process.argv.indexOf('--setup')) {
|
|
18
|
+
if (process.platform === 'win32') {
|
|
19
|
+
// we exit cleanly so that postinstall completes successfuly
|
|
20
|
+
process.exit(0)
|
|
21
|
+
}
|
|
18
22
|
console.log("Setting up...")
|
|
19
23
|
completion.setupShellInitFile()
|
|
20
24
|
}
|
|
21
25
|
// remove from system profiles
|
|
22
26
|
if (~process.argv.indexOf('--cleanup')) {
|
|
27
|
+
if (process.platform === 'win32') {
|
|
28
|
+
// we exit cleanly so that uninstall completes successfuly
|
|
29
|
+
process.exit(0)
|
|
30
|
+
}
|
|
23
31
|
console.log("Cleaning...")
|
|
24
32
|
completion.cleanupShellInitFile()
|
|
25
|
-
}
|
|
33
|
+
}
|
package/lib/commands/getDefs.js
CHANGED
|
@@ -10,11 +10,11 @@ async function getDefs(args) {
|
|
|
10
10
|
const cmdEnv = await getCurrentCommandEnviroment(args)
|
|
11
11
|
|
|
12
12
|
console.log(`Getting definitions from ${cmdEnv.serverStr} to branch ${cmdEnv.branchStr} ...` );
|
|
13
|
-
const getDefs = spawn(path.resolve(__dirname,"..","task_lists","getDefs.sh"),[cmdEnv.
|
|
13
|
+
const getDefs = spawn(path.resolve(__dirname,"..","task_lists","getDefs.sh"),[cmdEnv.serverHTTPs, cmdEnv.name, path.resolve(__dirname) ])
|
|
14
14
|
getDefs.stdout.on('data', function (data) { console.log(" " + data.toString()); });
|
|
15
15
|
getDefs.on('exit', function () { console.log('Done!'); });
|
|
16
16
|
} catch(err) {
|
|
17
17
|
console.error("\n",err.message);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
module.exports = getDefs;
|
|
20
|
+
module.exports = getDefs;
|
package/lib/commands/init.js
CHANGED
|
@@ -16,7 +16,7 @@ async function init(servername,args) {
|
|
|
16
16
|
let initTasks;
|
|
17
17
|
if(await projectExistsInGitAccount(projectName,args.repoaccount) ) {
|
|
18
18
|
console.log("\nRepo cloned!".green);
|
|
19
|
-
} else if( projectPathOkFor(projectName) && await notInsideGitRepo() && await validCobServer(cmdEnv.
|
|
19
|
+
} else if( projectPathOkFor(projectName) && await notInsideGitRepo() && await validCobServer(cmdEnv.serverHTTPs)) {
|
|
20
20
|
console.log("\nCreating project", projectName.bold.blue );
|
|
21
21
|
initTasks = newProjectTasks(cmdEnv, projectName, repo, args )
|
|
22
22
|
initTasks.run()
|
|
@@ -71,9 +71,18 @@ async function validCobServer(server) {
|
|
|
71
71
|
/* ************************************ */
|
|
72
72
|
async function projectExistsInGitAccount(projectName, repoaccount) {
|
|
73
73
|
try {
|
|
74
|
-
|
|
74
|
+
let cloneConfs = []
|
|
75
|
+
if(process.platform === 'win32'){
|
|
76
|
+
// on windows we force the usage of lf as line-endings
|
|
77
|
+
// so that rsync doesn't think all files have changed
|
|
78
|
+
cloneConfs = [
|
|
79
|
+
'--config', 'core.autocrlf=input',
|
|
80
|
+
'--config', 'core.eol=lf'
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
await git().clone(repoaccount + projectName, cloneConfs);
|
|
75
84
|
return true;
|
|
76
85
|
} catch (e) {
|
|
77
86
|
return false
|
|
78
87
|
}
|
|
79
|
-
}
|
|
88
|
+
}
|
package/lib/commands/test.js
CHANGED
|
@@ -10,6 +10,7 @@ const { checkRepoVersion } = require("../commands/upgradeRepo");
|
|
|
10
10
|
async function test (args) {
|
|
11
11
|
let restoreChanges, error = "";
|
|
12
12
|
let cmdEnv
|
|
13
|
+
let spawned
|
|
13
14
|
try {
|
|
14
15
|
checkRepoVersion()
|
|
15
16
|
console.log("Start testing… ")
|
|
@@ -22,8 +23,8 @@ async function test (args) {
|
|
|
22
23
|
} else {
|
|
23
24
|
await cmdEnv.applyCurrentCommandEnvironmentChanges()
|
|
24
25
|
}
|
|
25
|
-
customUIsContinuosReload(cmdEnv, args.dashboard)
|
|
26
|
-
|
|
26
|
+
spawned = await customUIsContinuosReload(cmdEnv, args.dashboard)
|
|
27
|
+
|
|
27
28
|
let key;
|
|
28
29
|
do {
|
|
29
30
|
key = await getKeypress()
|
|
@@ -36,8 +37,8 @@ async function test (args) {
|
|
|
36
37
|
} finally {
|
|
37
38
|
restoreChanges && await restoreChanges()
|
|
38
39
|
cmdEnv && await cmdEnv.unApplyCurrentCommandEnvironmentChanges() // Repõe as configurações
|
|
39
|
-
|
|
40
|
-
// Dá tempo aos subprocessos para morrer
|
|
40
|
+
spawned && await spawned.stop();
|
|
41
|
+
// Dá tempo aos subprocessos para morrer (acho que já não é preciso)
|
|
41
42
|
setTimeout(() => {
|
|
42
43
|
if(!error) {
|
|
43
44
|
console.log( "\n"
|
|
@@ -49,4 +50,4 @@ async function test (args) {
|
|
|
49
50
|
}, 2000);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
module.exports = test
|
|
53
|
+
module.exports = test
|
|
@@ -15,7 +15,8 @@ async function getCurrentCommandEnviroment(args, newServername) {
|
|
|
15
15
|
|
|
16
16
|
const defaultEnvironmentServerName = newServername ? newServername : _getDefaultServerForEnvironment(environmentName);
|
|
17
17
|
const servername = args.servername ? args.servername : defaultEnvironmentServerName;
|
|
18
|
-
const server =
|
|
18
|
+
const server = _getServerSSHFQDN(servername)
|
|
19
|
+
const serverHTTPs = _getServerHTTPsFQDN(servername)
|
|
19
20
|
const currentBranch = newServername ? "master" : await getCurrentBranch();
|
|
20
21
|
|
|
21
22
|
const lastEnvironmentDeployedToServer = await _getLastEnvironmentDeployed(server)
|
|
@@ -47,6 +48,7 @@ async function getCurrentCommandEnviroment(args, newServername) {
|
|
|
47
48
|
name: environmentName,
|
|
48
49
|
servername: servername,
|
|
49
50
|
server: server,
|
|
51
|
+
serverHTTPs: serverHTTPs,
|
|
50
52
|
serverStr: serverStr,
|
|
51
53
|
currentBranch: currentBranch,
|
|
52
54
|
branchStr: branchStr,
|
|
@@ -117,10 +119,15 @@ function _getDefaultServerForEnvironment(environmentName) {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
/* ************************************ */
|
|
120
|
-
function
|
|
122
|
+
function _getServerSSHFQDN(servername) {
|
|
121
123
|
return servername + ".cultofbits.pt";
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
/* ************************************ */
|
|
127
|
+
function _getServerHTTPsFQDN(servername) {
|
|
128
|
+
return servername + ".cultofbits.com";
|
|
129
|
+
}
|
|
130
|
+
|
|
124
131
|
/* ************************************ */
|
|
125
132
|
async function _getLastEnvironmentDeployed(server) {
|
|
126
133
|
try {
|
|
@@ -140,4 +147,4 @@ async function _setLastEnvironmentDeployed(server, environmentName) {
|
|
|
140
147
|
async function _setupEnvironment(environmentName, servername, server) {
|
|
141
148
|
await fs.mkdirs("environments/" + environmentName);
|
|
142
149
|
await fs.writeFile("environments/" + environmentName + "/server", servername);
|
|
143
|
-
}
|
|
150
|
+
}
|
|
@@ -31,7 +31,14 @@ async function checkWorkingCopyCleanliness(testNotDetached=true) {
|
|
|
31
31
|
/* ************************************ */
|
|
32
32
|
function checkConnectivity(server) {
|
|
33
33
|
const execa = require('execa');
|
|
34
|
-
return execa('ssh', [
|
|
34
|
+
return execa('ssh', [
|
|
35
|
+
"-o", "StrictHostKeyChecking=no",
|
|
36
|
+
"-o", "PreferredAuthentications=publickey",
|
|
37
|
+
"-o", "BatchMode=yes",
|
|
38
|
+
"-o", "ConnectTimeout=15",
|
|
39
|
+
server,
|
|
40
|
+
"test -w /etc/recordm/services/com.cultofbits.web.integration.properties && exit || exit 1"
|
|
41
|
+
])
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
/* ************************************ */
|
|
@@ -5,7 +5,7 @@ const { getKeypress } = require("../task_lists/common_helpers");
|
|
|
5
5
|
|
|
6
6
|
/* ************************************ */
|
|
7
7
|
const COB_PRODUCTS = ["recordm", "integrationm", "recordm-importer", "reportm", "userm", "confm", "others"];
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
_syncFiles.TEST = "Test equality";
|
|
10
10
|
_syncFiles.DIFF = "Get differences";
|
|
11
11
|
_syncFiles.COPY = "Copy";
|
|
@@ -45,29 +45,35 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], ar
|
|
|
45
45
|
while (count < RSYNC_RETRIES) {
|
|
46
46
|
if (args.verbose > 2)
|
|
47
47
|
console.log("rsync".bold +" '" + (product).blue + "': attempt " + (count + 1));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
const rsyncArgs = [
|
|
49
|
+
fromPath,
|
|
50
|
+
toPath,
|
|
51
|
+
"-acvi",
|
|
52
|
+
"--delete",
|
|
53
|
+
"--chmod=g+w",
|
|
54
|
+
"--no-perms",
|
|
55
|
+
"--no-t",
|
|
56
|
+
"--filter='merge " + path.resolve(__dirname,"rsyncFilter-pre.txt") + "'",
|
|
57
|
+
hasRsyncFilter ? "--filter='merge " + cmdEnv.rsyncFilter + "'" : "",
|
|
58
|
+
"--filter='merge " + path.resolve(__dirname,"rsyncFilter-post.txt") + "'",
|
|
59
|
+
executionType == _syncFiles.COPY ? "-v" : "--dry-run"
|
|
60
|
+
].concat(productExtraOptions)
|
|
61
|
+
if (args.verbose > 3) {
|
|
62
|
+
console.log('rsync', rsyncArgs.join(' '))
|
|
63
|
+
}
|
|
64
|
+
await execa('rsync', rsyncArgs, {
|
|
65
|
+
shell: true,
|
|
66
|
+
env: { "RSYNC_RSH": "ssh -o ConnectTimeout=30 -o ServerAliveInterval=30 -o ServerAliveCountMax=30" }
|
|
67
|
+
})
|
|
64
68
|
.then((value) => {
|
|
65
|
-
if (args.verbose >
|
|
69
|
+
if (args.verbose > 3)
|
|
66
70
|
console.log("rsync".bold +" '" + (product).blue + "': " + "success".green + " " + value.stdout);
|
|
67
71
|
|
|
68
72
|
let result = _formatRsyncOutput(product, value.stdout);
|
|
69
73
|
if (args.verbose > 2)
|
|
70
74
|
console.log("rsync '" + product + "': success " + result);
|
|
75
|
+
else if (args.verbose > 1)
|
|
76
|
+
console.log("rsync '" + product + "': success ");
|
|
71
77
|
changes = changes.concat(result);
|
|
72
78
|
count = RSYNC_RETRIES;
|
|
73
79
|
|
|
@@ -92,7 +98,7 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], ar
|
|
|
92
98
|
.filter(line => !/write error: Broken pipe/.test(line) && !fs.existsSync(to)) // quando não existe localmente dir base
|
|
93
99
|
;
|
|
94
100
|
if(relevantErrors.length == 0){
|
|
95
|
-
if (args.verbose >
|
|
101
|
+
if (args.verbose > 1)
|
|
96
102
|
console.log("rsync '" + product + "': success ");
|
|
97
103
|
count = RSYNC_RETRIES;
|
|
98
104
|
resolve();
|
|
@@ -2,12 +2,17 @@ const execa = require('execa');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const concurrently = require('concurrently');
|
|
4
4
|
const fs= require('fs');
|
|
5
|
+
const util = require('util');
|
|
6
|
+
const child_process = require('child_process');
|
|
7
|
+
const exec = util.promisify(child_process.exec);
|
|
8
|
+
|
|
5
9
|
|
|
6
10
|
async function customUIsContinuosReload(cmdEnv, dashboard) {
|
|
7
11
|
process.env.dash_dir = dashboard
|
|
8
|
-
process.env.server = "https://" + cmdEnv.
|
|
12
|
+
process.env.server = "https://" + cmdEnv.serverHTTPs
|
|
9
13
|
|
|
10
14
|
let commands = []
|
|
15
|
+
let isStopping = false;
|
|
11
16
|
|
|
12
17
|
let dashboardPath = path.resolve(".") + "/recordm/customUI/" + dashboard;
|
|
13
18
|
let dashboardPathIsDirectory = false;
|
|
@@ -47,14 +52,40 @@ async function customUIsContinuosReload(cmdEnv, dashboard) {
|
|
|
47
52
|
prefixColor: "blue"
|
|
48
53
|
})
|
|
49
54
|
|
|
50
|
-
concurrently( commands, {
|
|
55
|
+
const conc = concurrently( commands, {
|
|
51
56
|
prefix: 'name',
|
|
52
57
|
inputStream: process.stdin,
|
|
53
58
|
handleInput: false,
|
|
54
59
|
killOthers: ['failure', 'success']
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const stopEverything = async function(){
|
|
63
|
+
isStopping = true;
|
|
64
|
+
for(const spawn of conc.commands) {
|
|
65
|
+
// console.log("\n killing spawn [" + spawn.pid + "] " + spawn.command )
|
|
66
|
+
|
|
67
|
+
// win32 seems to not kill child processes, and concurrently wraps executions with a cmd.exe shell
|
|
68
|
+
if (process.platform === 'win32') {
|
|
69
|
+
try {
|
|
70
|
+
await exec(`taskkill /PID ${spawn.pid} /T /F`)
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error("error trying to taskkill process tree", err)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
} else {
|
|
76
|
+
spawn.kill("SIGINT");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
conc.result.catch( _err => {
|
|
82
|
+
if(isStopping) return;
|
|
83
|
+
|
|
84
|
+
stopEverything();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
stop: stopEverything
|
|
89
|
+
};
|
|
59
90
|
}
|
|
60
|
-
exports.customUIsContinuosReload = customUIsContinuosReload;
|
|
91
|
+
exports.customUIsContinuosReload = customUIsContinuosReload;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const chokidar = require('chokidar');
|
|
2
|
+
const path = require('path');
|
|
2
3
|
const fs = require('fs-extra');
|
|
3
4
|
const execa = require('execa');
|
|
4
5
|
const git = require('simple-git');
|
|
@@ -63,7 +64,8 @@ async function otherFilesContiousReload(cmdEnv) {
|
|
|
63
64
|
usePolling: true,
|
|
64
65
|
ignoreInitial: true
|
|
65
66
|
});
|
|
66
|
-
watcher.process.on('all', async (eventType,
|
|
67
|
+
watcher.process.on('all', async (eventType, changedFileNative) => {
|
|
68
|
+
let changedFile = changedFileNative.split(path.sep).join(path.posix.sep)
|
|
67
69
|
// Não é preciso fazer nada para directorias que só existem no servidor
|
|
68
70
|
let product = changedFile.split("/")[0];
|
|
69
71
|
let productDir = resolveCobPath(cmdEnv.server, "serverLive", product).split(":")[1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cob-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.46.0-beta.10",
|
|
4
4
|
"description": "A command line utility to help Cult of Bits partners develop with higher speed and reusing common code and best practices.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"repository": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"main": "./bin/cob-cli.js",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"postinstall": "bin/cob-cli.js --setup",
|
|
13
|
-
"uninstall": "bin/cob-cli.js --cleanup"
|
|
12
|
+
"postinstall": "node bin/cob-cli.js --setup",
|
|
13
|
+
"uninstall": "node bin/cob-cli.js --cleanup"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"cob-cli": "bin/cob-cli.js"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"cmd-line-importer": "^1.0.0",
|
|
23
23
|
"colors": "^1.4.0",
|
|
24
24
|
"commander": "^5.1.0",
|
|
25
|
-
"concurrently": "^
|
|
25
|
+
"concurrently": "^8.0.0",
|
|
26
26
|
"execa": "^4.0.3",
|
|
27
27
|
"fast-glob": "^3.2.5",
|
|
28
28
|
"file-cookie-store": "^0.2.1",
|