cob-cli 2.54.0-beta-1 → 2.55.0-beta-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.
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( deploy );
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')
@@ -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, checkNoInterruptedRun } = require("../task_lists/common_operationState");
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
- try {
19
- await validateDeployConditions(cmdEnv,args).run()
20
- } catch (err) {
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 = [];
@@ -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
  }
@@ -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 stateExists = !!loadOperationState();
18
+ const savedState = loadOperationState();
19
19
  const envBackupFiles = await fg(['**/*.ENV__ORIGINAL_BACKUP__.*', '**/*.ENV__DELETE__.*'], { onlyFiles: false, dot: true });
20
- if (stateExists || envBackupFiles.length > 0) {
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
- "\nAborted:".red + " found traces of a previous interrupted test/deploy.\n"
23
- + "Run " + "cob-cli cleanup".yellow + " to restore the repo to a clean state first.\n"
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
  }
@@ -7,10 +7,12 @@ 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
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) },
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cob-cli",
3
- "version": "2.54.0-beta-1",
3
+ "version": "2.55.0-beta-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": {