@zerothreatai/cli 6.0.5 → 6.0.7

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.
@@ -19,6 +19,7 @@ const chalk_1 = __importDefault(require("chalk"));
19
19
  const cli_table3_1 = __importDefault(require("cli-table3"));
20
20
  const app_constants_1 = require("../constants/app-constants");
21
21
  const ora_1 = __importDefault(require("ora"));
22
+ const acr_error_1 = __importDefault(require("../utils/acr-error"));
22
23
  let COMPOSE_FILE = "";
23
24
  const PROJECT = "zerothreat";
24
25
  const NETWORK = "zerothreat-onprem-nw";
@@ -91,13 +92,15 @@ async function firstIgnition(licenseKey, emailId) {
91
92
  console.log(">> Setting up application ...");
92
93
  await ensureNetwork();
93
94
  await pullImages();
94
- await runCompose(["up", "-d"]);
95
- //sleep for 30 seconds to allow sql server to start
96
- console.log("Waiting for SQL Server to start...");
95
+ await runCompose(["up", "-d", "--pull", "never"]);
96
+ //Wait for 10 minutes to allow sql server to start
97
+ const sqlContainerWaitSpinner = (0, ora_1.default)('Waiting for SQL Server to start...').start();
97
98
  const SqlSuccess = await checkSqlSuccess();
98
99
  if (!SqlSuccess) {
99
- throw new Error("Unable to complete database setup. Please try again later.");
100
+ sqlContainerWaitSpinner.fail("Unable to complete database setup.");
101
+ throw new Error("Please try again later.");
100
102
  }
103
+ sqlContainerWaitSpinner.succeed("connected to database.");
101
104
  }
102
105
  catch (error) {
103
106
  if (spinner.isSpinning)
@@ -179,18 +182,25 @@ async function updateSystemService() {
179
182
  console.log(">> Setting up application ...");
180
183
  await ensureNetwork();
181
184
  await pullImages();
182
- await runCompose(["up", "-d"]);
183
- //sleep for 30 seconds to allow sql server to start
184
- console.log("Waiting for SQL Server to start...");
185
+ await runCompose(["up", "-d", "--pull", "never"]);
186
+ //Wait for 10 minutes to allow sql server to start
187
+ const sqlContainerWaitSpinner = (0, ora_1.default)('Waiting for SQL Server to start...').start();
185
188
  const SqlSuccess = await checkSqlSuccess();
186
189
  if (!SqlSuccess) {
190
+ sqlContainerWaitSpinner.fail("Unable to complete database setup.");
187
191
  throw new Error("Unable to complete database setup. Please try again later.");
188
192
  }
193
+ sqlContainerWaitSpinner.succeed("connected to database.");
194
+ console.log(chalk_1.default.greenBright("\nZeroThreat updated successfully.\n"));
189
195
  }
190
196
  catch (error) {
191
197
  if (spinner.isSpinning)
192
- spinner.fail(chalk_1.default.red('Verification failed. Please check your details.'));
193
- throw error;
198
+ spinner.fail(chalk_1.default.red('Verification failed. Please check details.'));
199
+ if (error instanceof acr_error_1.default) {
200
+ console.log(chalk_1.default.red(`Error : ${error.message}`));
201
+ return;
202
+ }
203
+ throw new Error(chalk_1.default.red(error));
194
204
  }
195
205
  finally {
196
206
  COMPOSE_FILE = "";
@@ -40,7 +40,7 @@ async function cleanupContainersFromCompose(composeFilePath) {
40
40
  async function runCompose() {
41
41
  await cleanupContainersFromCompose(app_constants_1.dockerComposeAcr);
42
42
  return new Promise((resolve, reject) => {
43
- const child = (0, child_process_2.spawn)("docker", ["compose", "-f", app_constants_1.dockerComposeAcr, "up", "-d"], {
43
+ const child = (0, child_process_2.spawn)("docker", ["compose", "-f", app_constants_1.dockerComposeAcr, "-p", PROJECT, "up", "-d"], {
44
44
  stdio: ["ignore", "ignore", "pipe"],
45
45
  });
46
46
  child.on("close", code => (code === 0 ? resolve() : reject(new Error("compose failed"))));
@@ -98,14 +98,13 @@ async function restartService() {
98
98
  return;
99
99
  }
100
100
  // Up the docker images
101
+ const TIMEOUT_MS = 2 * 60 * 1000;
102
+ const containerTimeout = setTimeout(() => {
103
+ throw new Error('TIMEOUT: Taking more time to restart, Please try again later');
104
+ }, TIMEOUT_MS);
101
105
  try {
102
- const TIMEOUT_MS = 2 * 60 * 1000;
103
- const containerTimeout = setTimeout(() => {
104
- throw new Error('TIMEOUT: Taking more time to restart, Please try again later');
105
- }, TIMEOUT_MS);
106
106
  dockerUpSpinner.start();
107
107
  await runCompose();
108
- clearTimeout(containerTimeout);
109
108
  dockerUpSpinner.succeed('Containers are up and running. 🐳🚀');
110
109
  console.log(chalk_1.default.gray('➤ You can now continue using ZeroThreat on this url : '));
111
110
  console.log(chalk_1.default.bold.blue('http://localhost:3203'));
@@ -116,6 +115,7 @@ async function restartService() {
116
115
  console.log(chalk_1.default.red(error));
117
116
  }
118
117
  finally {
118
+ clearTimeout(containerTimeout);
119
119
  if (app_constants_1.dockerComposeAcr) {
120
120
  const tempDir = path_1.default.dirname(app_constants_1.dockerComposeAcr);
121
121
  fs_1.default.rmSync(tempDir, { recursive: true, force: true });
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateSystem = updateSystem;
7
+ const fs_1 = __importDefault(require("fs"));
7
8
  const chalk_1 = __importDefault(require("chalk"));
8
- const acr_error_1 = __importDefault(require("../utils/acr-error"));
9
9
  const acr_token_service_1 = __importDefault(require("../services/acr-token-service"));
10
10
  const app_constants_1 = require("../constants/app-constants");
11
11
  const license_service_1 = require("../actions/license-service");
12
12
  const general_api_1 = __importDefault(require("../services/general-api"));
13
+ const path_1 = __importDefault(require("path"));
13
14
  const deleteAcr = async () => {
14
15
  // Acr token Delete
15
16
  const acrTokenService = new acr_token_service_1.default();
@@ -24,22 +25,23 @@ const completeProcess = async () => {
24
25
  return;
25
26
  };
26
27
  async function updateSystem() {
27
- console.log(chalk_1.default.greenBright("\nUpdating Zero Threat...\n"));
28
+ console.log(chalk_1.default.greenBright("\nUpdating ZeroThreat...\n"));
28
29
  try {
29
30
  await (0, license_service_1.updateSystemService)();
30
31
  await completeProcess();
31
32
  }
32
33
  catch (err) {
33
- if (err instanceof acr_error_1.default) {
34
- console.log(chalk_1.default.red(`Error : ${err.message}`));
35
- return;
36
- }
37
34
  console.error(chalk_1.default.redBright(`Error : ${err.message}`));
38
35
  console.error(chalk_1.default.yellowBright(`Please Retry.`));
39
36
  return;
40
37
  }
41
38
  finally {
42
39
  await deleteAcr();
40
+ if (app_constants_1.dockerComposeAcr) {
41
+ const tempDir = path_1.default.dirname(app_constants_1.dockerComposeAcr);
42
+ fs_1.default.rmSync(tempDir, { recursive: true, force: true });
43
+ (0, app_constants_1.setDockerComposeAcr)('');
44
+ }
43
45
  }
44
46
  }
45
47
  ;
@@ -5,7 +5,7 @@ const API_CONFIG = () => {
5
5
  if (!process.env.WORKING_ENVIRONMENT) {
6
6
  return {
7
7
  licenseApi: `http://localhost:3201/api/license`,
8
- onPremLicenseCloudeApi: `https://zt-rc1-1-app-containerapps.agreeablestone-ae5e635a.centralus.azurecontainerapps.io/api/on-prem/license`,
8
+ onPremLicenseCloudeApi: `https://zt-stage-app-containerapps.agreeablestone-ae5e635a.centralus.azurecontainerapps.io/api/on-prem/license`,
9
9
  };
10
10
  }
11
11
  else {
@@ -111,7 +111,6 @@ class LicenseApiService extends api_service_1.default {
111
111
  (0, app_constants_1.setfingerPrint)(identity);
112
112
  }
113
113
  catch (error) {
114
- console.error(error);
115
114
  throw new acr_error_1.default(`${error.message}`);
116
115
  }
117
116
  }
@@ -22,7 +22,8 @@ function displayLicenseTable(response) {
22
22
  0: 'Free Credit Universal',
23
23
  1: 'Free Credit Hostname',
24
24
  2: 'Paid Credit',
25
- 3: 'Subscription'
25
+ 3: 'Subscription',
26
+ 5: 'Promotional Credit',
26
27
  };
27
28
  return map[type] || '❓ Unknown';
28
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerothreatai/cli",
3
- "version": "6.0.5",
3
+ "version": "6.0.7",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "node build.js",