cob-cli 2.42.3 → 2.43.1

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.
Files changed (25) hide show
  1. package/bin/cob-cli.js +8 -3
  2. package/lib/commands/updateFromServer.js +2 -2
  3. package/lib/task_lists/common_syncFiles.js +21 -13
  4. package/lib/task_lists/deploy_validate.js +1 -1
  5. package/lib/task_lists/test_validate.js +1 -1
  6. package/package.json +1 -1
  7. package/.tap/processinfo/0db03a1d-f054-4ba8-9873-7efb81723721.json +0 -32
  8. package/.tap/processinfo/9d97e24f-ae90-4c49-af20-075bbcc46260.json +0 -38
  9. package/.tap/repl_history +0 -2
  10. package/.tap/test-results/lib/commands/test.js.tap +0 -0
  11. package/.tap/test-results/lib/task_lists/common_enviromentHandler.js.tap +0 -0
  12. package/.tap/test-results/lib/task_lists/common_helpers.js.tap +0 -0
  13. package/.tap/test-results/lib/task_lists/common_releaseManager.js.tap +0 -0
  14. package/.tap/test-results/lib/task_lists/common_syncFiles.js.tap +0 -0
  15. package/.tap/test-results/lib/task_lists/deploy_execute.js.tap +0 -0
  16. package/.tap/test-results/lib/task_lists/deploy_validate.js.tap +0 -0
  17. package/.tap/test-results/lib/task_lists/init_newProject.js.tap +0 -0
  18. package/.tap/test-results/lib/task_lists/test_customUIsContinuosReload.js.tap +0 -0
  19. package/.tap/test-results/lib/task_lists/test_otherFilesContiousReload.js.tap +0 -0
  20. package/.tap/test-results/lib/task_lists/test_syncFile.js.tap +0 -0
  21. package/.tap/test-results/lib/task_lists/test_validate.js.tap +0 -0
  22. package/.tap/test-results/lib/task_lists/updateFromServer_validate.js.tap +0 -0
  23. package/.tap/test-results/lib/webpack/fake_customizations2.js.tap +0 -1
  24. package/.tap/test-results/lib/webpack/webpack.config.js.tap +0 -0
  25. package/.tap/test-results/test/test_common_environmentHandler.js.tap +0 -40
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,21 +11,23 @@ _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
+ // we need to recheck, because it can exist in head but not in the commit we're testing
30
+ let hasRsyncFilter = cmdEnv.rsyncFilter && fs.lstatSync(cmdEnv.rsyncFilter, {throwIfNoEntry: false})?.isFile();
29
31
  let requests = products.map(product => {
30
32
  return new Promise(async (resolve, reject) => {
31
33
  let fromPath = resolveCobPath(cmdEnv.server, from, product);
@@ -41,8 +43,8 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
41
43
  let count = 0;
42
44
  const RSYNC_RETRIES = 10;
43
45
  while (count < RSYNC_RETRIES) {
44
- if (DEBUG)
45
- console.log("rsync '" + product + "': attempt " + (count + 1));
46
+ if (args.verbose > 2)
47
+ console.log("rsync".bold +" '" + (product).blue + "': attempt " + (count + 1));
46
48
  await execa('rsync',
47
49
  [
48
50
  fromPath,
@@ -52,18 +54,18 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
52
54
  "--chmod=g+w",
53
55
  "--perms",
54
56
  "--filter='merge " + path.resolve(__dirname,"rsyncFilter-pre.txt") + "'",
55
- cmdEnv.rsyncFilter ? "--filter='merge " + cmdEnv.rsyncFilter + "'" : "",
57
+ hasRsyncFilter ? "--filter='merge " + cmdEnv.rsyncFilter + "'" : "",
56
58
  "--filter='merge " + path.resolve(__dirname,"rsyncFilter-post.txt") + "'",
57
59
  executionType == _syncFiles.COPY ? "-v" : "--dry-run"
58
60
  ].concat(productExtraOptions),
59
61
  { shell: true, env: { "RSYNC_RSH": "ssh -o ConnectTimeout=30 -o ServerAliveInterval=30 -o ServerAliveCountMax=30" } }
60
62
  )
61
63
  .then((value) => {
62
- if (DEBUG)
63
- console.log("rsync '" + product + "': success " + value.stdout);
64
+ if (args.verbose > 2)
65
+ console.log("rsync".bold +" '" + (product).blue + "': " + "success".green + " " + value.stdout);
64
66
 
65
67
  let result = _formatRsyncOutput(product, value.stdout);
66
- if (DEBUG)
68
+ if (args.verbose > 2)
67
69
  console.log("rsync '" + product + "': success " + result);
68
70
  changes = changes.concat(result);
69
71
  count = RSYNC_RETRIES;
@@ -76,6 +78,10 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
76
78
  * mudar ctime dos ficheiros (que sejam de outro owner)
77
79
  */
78
80
  if (err.exitCode == 23) {
81
+ if(args.verbose > 1){
82
+ console.log("warning".yellow + " :" + (product).blue + ": got some output on stderr: ")
83
+ err.stderr.split("\n").forEach((err) => console.log("warning".yellow + " :" + (product).blue + ": " + err) )
84
+ }
79
85
  const relevantErrors = err.stderr
80
86
  .split("\n")
81
87
  .filter(line => !/^rsync: failed to set times on/.test(line))
@@ -85,6 +91,8 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
85
91
  .filter(line => !/write error: Broken pipe/.test(line) && !fs.existsSync(to)) // quando não existe localmente dir base
86
92
  ;
87
93
  if(relevantErrors.length == 0){
94
+ if (args.verbose > 2)
95
+ console.log("rsync '" + product + "': success ");
88
96
  count = RSYNC_RETRIES;
89
97
  resolve();
90
98
  } else {
@@ -94,8 +102,8 @@ async function _syncFiles(executionType, cmdEnv, from, to, extraOptions = []) {
94
102
  } else if (count > RSYNC_RETRIES) {
95
103
  reject(new Error(err));;
96
104
  } else {
97
- if (DEBUG)
98
- console.log("rsync '" + product + "': attempt " + (count + 1) + " failed with code " + err.exitCode);
105
+ if (args.verbose > 1)
106
+ console.log("warning".yellow + " rsync '" + (product).blue + "': attempt " + (count + 1) + " failed with code " + err.exitCode);
99
107
  }
100
108
  });
101
109
  count++;
@@ -18,7 +18,7 @@ function validateDeployConditions(cmdEnv, args) {
18
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
19
  { title: "git checkout SHA-for-last-deploy", skip: ctx => args.force || !ctx.lastSha, task: (ctx) => git().checkout(ctx.lastSha) },
20
20
  { title: "Apply last enviroment specifics".bold, skip: ctx => args.force || !ctx.lastSha, task: () => cmdEnv.applyLastEnvironmentDeployedToServerChanges() },
21
- { title: "Check last-deploy == serverLive".bold, skip: ctx => args.force || !ctx.lastSha, task: (ctx) => testEquality(cmdEnv, "localCopy", "serverLive").then( changes => _handleTestEquality(ctx, changes)) },
21
+ { 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
22
  { title: "Undo last enviroment specifics".bold, skip: ctx => args.force || !ctx.lastSha, task: () => cmdEnv.unApplyLastEnvironmentDeployedToServerChanges() },
23
23
  { title: "git checkout branch-for-HEAD", skip: ctx => args.force || !ctx.lastSha, task: (ctx) => git().checkout(ctx.currentBranch) },
24
24
  { title: "report problems", enabled: ctx => ctx.err, task: (ctx) => {throw new Error(ctx.err)} },
@@ -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.3",
3
+ "version": "2.43.1",
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": {
@@ -1,32 +0,0 @@
1
- {
2
- "date": "2023-10-19T08:52:33.010Z",
3
- "argv": [
4
- "/Users/jnelas/.nvm/versions/node/v16.18.0/bin/node",
5
- "/Users/jnelas/reps/cob/cob-cli/test/test_common_environmentHandler.js"
6
- ],
7
- "execArgv": [
8
- "--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/esm.mjs",
9
- "--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@tapjs/mock/dist/esm/legacy-loader.mjs",
10
- "--no-warnings",
11
- "--enable-source-maps",
12
- "--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@tapjs/processinfo/dist/esm/loader-legacy.mjs"
13
- ],
14
- "NODE_OPTIONS": "\"--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@tapjs/processinfo/dist/esm/loader-legacy.mjs\" \"--no-warnings\"",
15
- "cwd": "/Users/jnelas/reps/cob/cob-cli",
16
- "pid": 12082,
17
- "ppid": 12080,
18
- "parent": null,
19
- "uuid": "0db03a1d-f054-4ba8-9873-7efb81723721",
20
- "files": [
21
- "/Users/jnelas/reps/cob/cob-cli/test/test_common_environmentHandler.js",
22
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_enviromentHandler.js",
23
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_releaseManager.js",
24
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_helpers.js"
25
- ],
26
- "sources": {},
27
- "root": "0db03a1d-f054-4ba8-9873-7efb81723721",
28
- "externalID": "test/test_common_environmentHandler.js",
29
- "code": 0,
30
- "signal": null,
31
- "runtime": 1840.771843
32
- }
@@ -1,38 +0,0 @@
1
- {
2
- "date": "2023-10-19T08:52:33.000Z",
3
- "argv": [
4
- "/Users/jnelas/.nvm/versions/node/v16.18.0/bin/node",
5
- "/Users/jnelas/reps/cob/cob-cli/lib/commands/test.js"
6
- ],
7
- "execArgv": [
8
- "--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/esm.mjs",
9
- "--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@tapjs/mock/dist/esm/legacy-loader.mjs",
10
- "--no-warnings",
11
- "--enable-source-maps",
12
- "--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@tapjs/processinfo/dist/esm/loader-legacy.mjs"
13
- ],
14
- "NODE_OPTIONS": "\"--loader=file:///Users/jnelas/reps/cob/cob-cli/node_modules/@tapjs/processinfo/dist/esm/loader-legacy.mjs\" \"--no-warnings\"",
15
- "cwd": "/Users/jnelas/reps/cob/cob-cli",
16
- "pid": 12081,
17
- "ppid": 12080,
18
- "parent": null,
19
- "uuid": "9d97e24f-ae90-4c49-af20-075bbcc46260",
20
- "files": [
21
- "/Users/jnelas/reps/cob/cob-cli/lib/commands/test.js",
22
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/test_validate.js",
23
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_helpers.js",
24
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_releaseManager.js",
25
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_syncFiles.js",
26
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/test_otherFilesContiousReload.js",
27
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/test_syncFile.js",
28
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/test_customUIsContinuosReload.js",
29
- "/Users/jnelas/reps/cob/cob-cli/lib/task_lists/common_enviromentHandler.js",
30
- "/Users/jnelas/reps/cob/cob-cli/lib/commands/upgradeRepo.js"
31
- ],
32
- "sources": {},
33
- "root": "9d97e24f-ae90-4c49-af20-075bbcc46260",
34
- "externalID": "lib/commands/test.js",
35
- "code": 0,
36
- "signal": null,
37
- "runtime": 290.537245
38
- }
package/.tap/repl_history DELETED
@@ -1,2 +0,0 @@
1
- f
2
- w
File without changes
@@ -1 +0,0 @@
1
- [CoB] Starting live-reload
@@ -1,40 +0,0 @@
1
- TAP version 14
2
- # Subtest: smoke
3
- ok 1 - should match pattern
4
- 1..1
5
- ok 1 - smoke # time=33.202ms
6
-
7
- # Subtest: there's an ENV file, but no default
8
- ok 1 - should match pattern
9
- ok 2 - should be equal
10
- ok 3 - should match pattern
11
- ok 4 - should match pattern
12
- ok 5 - should be equal
13
- 1..5
14
- ok 2 - there's an ENV file, but no default # time=266.343ms
15
-
16
- # Subtest: there's an ENV and a default
17
- ok 1 - should match pattern
18
- ok 2 - should match pattern
19
- ok 3 - should match pattern
20
- ok 4 - should be equal
21
- 1..4
22
- ok 3 - there's an ENV and a default # time=411.658ms
23
-
24
- # Subtest: there's multiple ENVs but no default
25
- ok 1 - should match pattern
26
- ok 2 - should match pattern
27
- ok 3 - should match pattern
28
- ok 4 - should be equal
29
- 1..4
30
- ok 4 - there's multiple ENVs but no default # time=274.577ms
31
-
32
- # Subtest: there's multiple ENVs and a default
33
- ok 1 - should match pattern
34
- ok 2 - should match pattern
35
- ok 3 - should match pattern
36
- ok 4 - should be equal
37
- 1..4
38
- ok 5 - there's multiple ENVs and a default # time=403.779ms
39
-
40
- 1..5