cob-cli 2.42.2 → 2.43.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 CHANGED
@@ -15,6 +15,10 @@ const getDefs = require("../lib/commands/getDefs");
15
15
  const generateMermaid = require("../lib/commands/generateMermaid");
16
16
  const { upgradeRepo } = require("../lib/commands/upgradeRepo");
17
17
 
18
+ const increaseVerbosity = function(_dummy, previous){
19
+ return previous + 1;
20
+ }
21
+
18
22
  /*******************************************/
19
23
  program
20
24
  .description('CoB Command line to simplify server customizations')
@@ -35,7 +39,7 @@ program
35
39
  .arguments('<servername>')
36
40
  .option('-l --legacy <folder>','import git history from legacy ClientConfs. <folder> should be path to server files inside ClienConfs.')
37
41
  .option('-a --repoaccount <account url>', 'Specify git account to use', "git@gitlab.com:cob/")
38
- .option('-V --verbose', 'verbose execution of tasks')
42
+ .option('-V --verbose', 'verbose execution of tasks', increaseVerbosity, 0)
39
43
  .description('Initializes a server customization repository. Use <servername>.cultofbits.com (i.e. name without the FQDN)')
40
44
  .action( init );
41
45
 
@@ -51,7 +55,7 @@ program
51
55
 
52
56
  program
53
57
  .command('test')
54
- .option('-V --verbose', 'verbose execution of tasks')
58
+ .option('-V --verbose', 'verbose execution of tasks', increaseVerbosity, 0)
55
59
  .option('-e --environment <name>', 'environment to use')
56
60
  .option('-d --dashboard <name>', 'Aditionally specify a VUE dashboard to test')
57
61
  .option('-l --localOnly', 'test only localFiles (customUI)')
@@ -63,7 +67,7 @@ program
63
67
  .command('deploy')
64
68
  .option('-f --force', 'skips comparisons')
65
69
  .option('-e --environment <name>', 'environment to use')
66
- .option('-V --verbose', 'verbose execution of tasks')
70
+ .option('-V --verbose', 'verbose execution of tasks', increaseVerbosity, 0)
67
71
  .option('-s --servername <servername>', 'use <servername>.cultofbits.com (i.e. name without the FQDN)')
68
72
  .description('Deploy customization to the server')
69
73
  .action( deploy );
@@ -73,6 +77,7 @@ program
73
77
  .description('Updates local copy with current files on server, in case of changes made out of standard process.')
74
78
  .option('-e --environment <name>', 'environment to use')
75
79
  .option('-s --servername <servername>', 'use <servername>.cultofbits.com (i.e. name without the FQDN)')
80
+ .option('-V --verbose', 'verbose execution of tasks', increaseVerbosity, 0)
76
81
  .action( updateFromServer );
77
82
 
78
83
  program
@@ -13,7 +13,7 @@ async function updateFromServer(args) {
13
13
 
14
14
  console.log("\nOk to proceed. Getting files from server's live directories...");
15
15
  await cmdEnv.applyCurrentCommandEnvironmentChanges()
16
- let changes = await copyFiles(cmdEnv, "serverLive", "localCopy")
16
+ let changes = await copyFiles(cmdEnv, "serverLive", "localCopy", args)
17
17
  await cmdEnv.unApplyCurrentCommandEnvironmentChanges()
18
18
 
19
19
  if(changes.length == 0) {
@@ -28,4 +28,4 @@ async function updateFromServer(args) {
28
28
  console.error("\n",err.message);
29
29
  }
30
30
  }
31
- module.exports = updateFromServer;
31
+ module.exports = updateFromServer;
@@ -11,19 +11,19 @@ _syncFiles.DIFF = "Get differences";
11
11
  _syncFiles.COPY = "Copy";
12
12
 
13
13
  /* ************************************ */
14
- function copyFiles(cmdEnv, from, to) {
15
- return _syncFiles(_syncFiles.COPY, cmdEnv, from, to);
14
+ function copyFiles(cmdEnv, from, to, args) {
15
+ return _syncFiles(_syncFiles.COPY, cmdEnv, from, to, [], args);
16
16
  }
17
17
  exports.copyFiles = copyFiles;
18
18
 
19
19
  /* ************************************ */
20
- async function testEquality(cmdEnv, from, to) {
21
- return (await _syncFiles(_syncFiles.TEST, cmdEnv, from, to)).filter( f => !f.endsWith("/"))
20
+ async function testEquality(cmdEnv, from, to, args) {
21
+ return (await _syncFiles(_syncFiles.TEST, cmdEnv, from, to, [], args)).filter( f => !f.endsWith("/"))
22
22
  }
23
23
  exports.testEquality = testEquality;
24
24
 
25
25
  /* ************************************ */
26
- async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
26
+ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = [], args = []) {
27
27
  let changes = [];
28
28
  let products = cmdEnv.products.length ? cmdEnv.products : COB_PRODUCTS;
29
29
  let requests = products.map(product => {
@@ -41,8 +41,8 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
41
41
  let count = 0;
42
42
  const RSYNC_RETRIES = 10;
43
43
  while (count < RSYNC_RETRIES) {
44
- if (DEBUG)
45
- console.log("rsync '" + product + "': attempt " + (count + 1));
44
+ if (args.verbose > 2)
45
+ console.log("rsync".bold +" '" + (product).blue + "': attempt " + (count + 1));
46
46
  await execa('rsync',
47
47
  [
48
48
  fromPath,
@@ -59,11 +59,11 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
59
59
  { shell: true, env: { "RSYNC_RSH": "ssh -o ConnectTimeout=30 -o ServerAliveInterval=30 -o ServerAliveCountMax=30" } }
60
60
  )
61
61
  .then((value) => {
62
- if (DEBUG)
63
- console.log("rsync '" + product + "': success " + value.stdout);
62
+ if (args.verbose > 2)
63
+ console.log("rsync".bold +" '" + (product).blue + "': " + "success".green + " " + value.stdout);
64
64
 
65
65
  let result = _formatRsyncOutput(product, value.stdout);
66
- if (DEBUG)
66
+ if (args.verbose > 2)
67
67
  console.log("rsync '" + product + "': success " + result);
68
68
  changes = changes.concat(result);
69
69
  count = RSYNC_RETRIES;
@@ -76,13 +76,21 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
76
76
  * mudar ctime dos ficheiros (que sejam de outro owner)
77
77
  */
78
78
  if (err.exitCode == 23) {
79
+ if(args.verbose > 1){
80
+ console.log("warning".yellow + " :" + (product).blue + ": got some output on stderr: ")
81
+ err.stderr.split("\n").forEach((err) => console.log("warning".yellow + " :" + (product).blue + ": " + err) )
82
+ }
79
83
  const relevantErrors = err.stderr
80
84
  .split("\n")
81
85
  .filter(line => !/^rsync: failed to set times on/.test(line))
82
86
  .filter(line => !/^rsync error: some files/.test(line)) // linha final sempre que há erros
83
87
  .filter(line => !/disabling multiplexing/.test(line)) // output irrelevante do ssh
88
+ .filter(line => !/No such file or directory/.test(line)) // quando dir base remoto não existe
89
+ .filter(line => !/write error: Broken pipe/.test(line) && !fs.existsSync(to)) // quando não existe localmente dir base
84
90
  ;
85
91
  if(relevantErrors.length == 0){
92
+ if (args.verbose > 2)
93
+ console.log("rsync '" + product + "': success ");
86
94
  count = RSYNC_RETRIES;
87
95
  resolve();
88
96
  } else {
@@ -92,8 +100,8 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
92
100
  } else if (count > RSYNC_RETRIES) {
93
101
  reject(new Error(err));;
94
102
  } else {
95
- if (DEBUG)
96
- console.log("rsync '" + product + "': attempt " + (count + 1) + " failed with code " + err.exitCode);
103
+ if (args.verbose > 1)
104
+ console.log("warning".yellow + "rsync '" + (product).blue + "': attempt " + (count + 1) + " failed with code " + err.exitCode);
97
105
  }
98
106
  });
99
107
  count++;
@@ -21,7 +21,7 @@ async function validateTestingConditions(cmdEnv, args) {
21
21
  { title: "git stash --include-untracked", skip: ctx => !ctx.lastSha, task: (ctx) => git().env('LC_ALL', 'C').stash(["--include-untracked"]).then( value => value.indexOf("Saved") == 0 && (ctx.stash = true)) },
22
22
  { title: "git checkout SHA for last-deploy", skip: ctx => !ctx.lastSha, task: (ctx) => git().checkout(ctx.lastSha) },
23
23
  { title: "Apply last enviroment specifics".bold, skip: ctx => !ctx.lastSha, task: () => cmdEnv.applyLastEnvironmentDeployedToServerChanges() },
24
- { title: "Check last-deploy == serverLive".bold, skip: ctx => !ctx.lastSha, task: (ctx) => testEquality(cmdEnv, "serverLive", "localCopy").then( changes => _handleTestEquality(ctx, changes, cmdEnv.server).catch( err => ctx.err = err.message ) ) },
24
+ { title: "Check last-deploy == serverLive".bold, skip: ctx => !ctx.lastSha, task: (ctx) => testEquality(cmdEnv, "serverLive", "localCopy", args).then( changes => _handleTestEquality(ctx, changes, cmdEnv.server).catch( err => ctx.err = err.message ) ) },
25
25
  { title: "Undo last enviroment specifics".bold, skip: ctx => !ctx.lastSha, task: () => cmdEnv.unApplyLastEnvironmentDeployedToServerChanges() },
26
26
  { title: "git checkout branch-for-HEAD", skip: ctx => !ctx.lastSha, task: (ctx) => git().checkout(ctx.currentBranch) },
27
27
  { title: "git stash pop", skip: ctx => !ctx.stash, task: () => git().stash(["pop"]) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cob-cli",
3
- "version": "2.42.2",
3
+ "version": "2.43.0",
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": {