@coalescesoftware/coa 1.0.115 → 1.0.118

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coalescesoftware/coa",
3
- "version": "1.0.115",
3
+ "version": "1.0.118",
4
4
  "license": "ISC",
5
5
  "author": "Coalesce Automation, Inc.",
6
6
  "main": "index.js",
@@ -12,7 +12,7 @@
12
12
  "start-cli-debug": "yarn run start --debug"
13
13
  },
14
14
  "dependencies": {
15
- "@coalescesoftware/shared": "^1.0.115",
15
+ "@coalescesoftware/shared": "^1.0.118",
16
16
  "chalk": "^4.1.2",
17
17
  "commander": "^9.2.0",
18
18
  "firebase": "8.2.0",
package/bin/CLIProfile.js DELETED
@@ -1,159 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.GetCLIConfig = exports.ICLIProfileExample = exports.GetDefaultLocationForCoaConfigFile = void 0;
23
- /* eslint-disable multiline-comment-style */
24
- const Shared = __importStar(require("@coalescesoftware/shared"));
25
- const immer = __importStar(require("immer"));
26
- const os = require('os');
27
- const path = require('path');
28
- const ini = require('ini');
29
- const fs = require('fs');
30
- const RemoveCredentialsFromCLIProfile = (cliProfile) => {
31
- return immer.produce(cliProfile, (draft) => {
32
- if (draft.snowflakePassword)
33
- draft.snowflakePassword = '<REDACTED>';
34
- if (draft.snowflakeAccount)
35
- draft.snowflakeAccount = '<REDACTED>';
36
- });
37
- };
38
- const RemoveCredentialsFromCLIProfiles = (cliProfiles) => {
39
- return immer.produce(cliProfiles, (draftState) => {
40
- Object.keys(draftState).forEach((cliProfileName) => {
41
- draftState[cliProfileName] = RemoveCredentialsFromCLIProfile(cliProfiles[cliProfileName]);
42
- });
43
- });
44
- };
45
- const CLILogger = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI_INTERNAL);
46
- const GetDefaultLocationForCoaConfigFile = () => {
47
- const homedir = os.homedir();
48
- const coaConfigLocation = path.join(homedir, ".coa/config");
49
- CLILogger.info("using default location", coaConfigLocation);
50
- return coaConfigLocation;
51
- };
52
- exports.GetDefaultLocationForCoaConfigFile = GetDefaultLocationForCoaConfigFile;
53
- //voodoo typescript magic in order to get runtime and compiletime ICLIProfile code
54
- //https://stackoverflow.com/questions/45670705/iterate-over-interface-properties-in-typescript
55
- exports.ICLIProfileExample = {
56
- profile: "Profile To Use",
57
- environmentID: "Environment ID",
58
- parameters: "Parameters",
59
- snowflakeAccount: "Snowflake Account To Use",
60
- snowflakeAuthType: "Snowflake Auth Type (Basic, KeyPair)",
61
- snowflakeKeyPairPath: "Snowflake Key Pair Path",
62
- snowflakePassword: "Snowflake Password",
63
- snowflakeRole: "Snowflake Role",
64
- snowflakeUsername: "Snowflake Username",
65
- snowflakeWarehouse: "Snowflake Warehouse",
66
- token: "Coalesce Token",
67
- jobID: "Coalesce JobID",
68
- include: "Coalesce Node Selector",
69
- exclude: "Coalesce Node Selector"
70
- };
71
- const ReadCLIProfiles = (filePath) => {
72
- let filePathToUse;
73
- if (!filePath) {
74
- filePathToUse = (0, exports.GetDefaultLocationForCoaConfigFile)();
75
- }
76
- else {
77
- filePathToUse = filePath;
78
- }
79
- return fs.promises.readFile(filePathToUse, 'utf-8')
80
- .then((file) => {
81
- return ini.parse(file);
82
- })
83
- .catch((err) => {
84
- CLILogger.error("unable to read cli profile file filePath:", filePath, err);
85
- if (!filePath) //if no filepath was specified, silently proceed
86
- return {};
87
- else //unable to proceed couldnt read file
88
- throw new Error(`unable to read cli profile:${filePathToUse}`);
89
- });
90
- };
91
- const GetFinalCLIProfile = (commandLineOverrides, configFileLocation) => {
92
- let profileToUseOverride = commandLineOverrides.profile ? commandLineOverrides.profile : null;
93
- return ReadCLIProfiles(configFileLocation)
94
- .then((cliProfiles) => {
95
- const defaultCLIProfile = cliProfiles.default;
96
- let finalCLIProfile = {};
97
- //if theres a default cli profile, start with that
98
- if (defaultCLIProfile) {
99
- finalCLIProfile = defaultCLIProfile;
100
- }
101
- //if a profile has been specified, use that
102
- const profileToUse = profileToUseOverride || //cli override
103
- (!!defaultCLIProfile && defaultCLIProfile.profile) //default profile exists
104
- || "";
105
- CLILogger.info("using profile", profileToUse, "cliProfiles", JSON.stringify(RemoveCredentialsFromCLIProfiles(cliProfiles)));
106
- if (profileToUse) {
107
- if (!(profileToUse in cliProfiles)) {
108
- throw new Error(`unable to find profile ${profileToUse}`);
109
- }
110
- const coaConfigProfile = cliProfiles[profileToUse];
111
- finalCLIProfile = Object.assign(Object.assign({}, finalCLIProfile), coaConfigProfile);
112
- }
113
- finalCLIProfile = Object.assign(Object.assign({}, finalCLIProfile), commandLineOverrides);
114
- return finalCLIProfile;
115
- });
116
- };
117
- //Get CLI Config given command line overrides and a config file
118
- //config file location can be null - which means to use default location
119
- const GetCLIConfig = (commandLineOverrides, configFileLocation) => {
120
- return GetFinalCLIProfile(commandLineOverrides, configFileLocation).then((cliProfile) => {
121
- CLILogger.info("got final cli profile configFileLocation:", configFileLocation, JSON.stringify(RemoveCredentialsFromCLIProfile(cliProfile)));
122
- const cliConfig = {
123
- token: cliProfile.token,
124
- runDetails: {
125
- environmentID: cliProfile.environmentID,
126
- jobID: cliProfile.jobID,
127
- includeNodesSelector: cliProfile.include,
128
- excludeNodesSelector: cliProfile.exclude
129
- },
130
- userCredentials: {
131
- snowflakeAccount: cliProfile.snowflakeAccount,
132
- snowflakeAuthType: cliProfile.snowflakeAuthType,
133
- snowflakePassword: cliProfile.snowflakePassword,
134
- snowflakeKeyPairPath: cliProfile.snowflakeKeyPairPath,
135
- snowflakeRole: cliProfile.snowflakeRole,
136
- snowflakeUsername: cliProfile.snowflakeUsername,
137
- snowflakeWarehouse: cliProfile.snowflakeWarehouse
138
- },
139
- runtimeParameters: cliProfile.parameters
140
- };
141
- Shared.Common.CleanupUndefinedValuesFromObject(cliConfig);
142
- return cliConfig;
143
- });
144
- };
145
- exports.GetCLIConfig = GetCLIConfig;
146
- // TODO: create a profile class that takes the cmd object in the constructor
147
- // store contents of configuration file
148
- // if no config file path option
149
- // check if there's a valid configuration file in the current working directory or home directory
150
- // if none exists
151
- // create a configuration file with empty default profile
152
- // prompt user to either rerun the command with valid config file, per-command flags for all profile values, or run `coa init` to go through prompts for creating a profile
153
- // if a configuration file exists, but any required property holds a falsy value
154
- // inform user which fields are missing and prompt to run `coa init` to fill out invalid fields
155
- // method: validate configuration file
156
- // method: get final profile for current command
157
- // create a function getCLIProfile that returns a CLI profile, this should return a promise that resolve in CLI profile
158
- // hardcode a profile
159
- //# sourceMappingURL=CLIProfile.js.map
@@ -1,126 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.GetUserConnectionForCLI = exports.CleanupCLIJob = exports.GetToken = exports.GetConfig = exports.ConsoleLog = void 0;
23
- const Shared = __importStar(require("@coalescesoftware/shared"));
24
- const crypto = __importStar(require("crypto"));
25
- const fs = __importStar(require("fs"));
26
- const RunnerBackendLogger = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.RunnerBackend);
27
- exports.ConsoleLog = console.log;
28
- const GetConfig = (path) => {
29
- try {
30
- return JSON.parse(fs.readFileSync(path, { encoding: "utf8" }));
31
- }
32
- catch (error) {
33
- (0, exports.ConsoleLog)(`Unable to read or parse config file: ${error}`);
34
- throw error;
35
- }
36
- };
37
- exports.GetConfig = GetConfig;
38
- const GetToken = (path) => {
39
- try {
40
- return fs.readFileSync(path, { encoding: "utf8" }).trim();
41
- }
42
- catch (error) {
43
- (0, exports.ConsoleLog)(`Unable to read token file: ${error}`);
44
- throw error;
45
- }
46
- };
47
- exports.GetToken = GetToken;
48
- const CleanupCLIJob = (runCompletion, firebase, logContext, action) => {
49
- const cleanupPromise = new Promise((resolve, reject) => {
50
- let promiseError = null;
51
- runCompletion
52
- .catch((error) => {
53
- promiseError = error;
54
- })
55
- .finally(() => {
56
- try {
57
- if (firebase) {
58
- Shared.Common.DeleteFirebaseInstance(firebase);
59
- }
60
- }
61
- catch (error) {
62
- RunnerBackendLogger.errorContext(logContext, `Error during ${action}WithCLI Finally cleanup: `, error);
63
- }
64
- if (promiseError) {
65
- reject(promiseError);
66
- }
67
- else {
68
- resolve();
69
- }
70
- });
71
- });
72
- return cleanupPromise;
73
- };
74
- exports.CleanupCLIJob = CleanupCLIJob;
75
- const GetKeyPairKey = (keyPairPath) => {
76
- return new Promise((resolve, reject) => {
77
- Shared.Common.assert(Shared.Logging.LoggingArea.RunnerBackend, !!keyPairPath, "ERROR (GetKeyPairPath): invalid or missing keyPairPath");
78
- const privateKeyFile = fs.readFileSync(keyPairPath);
79
- const privateKeyObject = crypto.createPrivateKey({
80
- key: privateKeyFile,
81
- format: "pem",
82
- passphrase: "passphrase"
83
- });
84
- const privateKey = privateKeyObject.export({
85
- format: "pem",
86
- type: "pkcs8"
87
- });
88
- if (!privateKey) {
89
- reject(new Error("ERROR (GetKeyPairPath): invalid or missing privateKey"));
90
- }
91
- else {
92
- resolve(privateKey);
93
- }
94
- });
95
- };
96
- const GetUserConnectionForCLI = (userID, runInfo) => {
97
- return new Promise((resolve, reject) => {
98
- var _a, _b, _c, _d;
99
- Shared.Common.assert(Shared.Logging.LoggingArea.RunnerBackend, !!((_a = runInfo.userCredentials) === null || _a === void 0 ? void 0 : _a.snowflakeAuthType), "ERROR (GetUserConnectionForCLI): no auth type provided");
100
- const output = {
101
- connectionDetails: {
102
- userID,
103
- user: "mx2323",
104
- role: "SYSADMIN",
105
- warehouse: "COMPUTE_WH",
106
- authenticator: (_b = runInfo.userCredentials) === null || _b === void 0 ? void 0 : _b.snowflakeAuthType
107
- },
108
- connectionType: (_c = runInfo.userCredentials) === null || _c === void 0 ? void 0 : _c.snowflakeAuthType
109
- };
110
- if (((_d = runInfo.userCredentials) === null || _d === void 0 ? void 0 : _d.snowflakeAuthType) === Shared.ConnectionOperations.EUserConnectionTypes.keyPair) {
111
- GetKeyPairKey(Shared.Common.getValueSafe(runInfo, ["userCredentials", "snowflakeKeyPairPath"], ""))
112
- .then((keyPair) => {
113
- output.connectionDetails.keyPair = keyPair;
114
- resolve(output);
115
- })
116
- .catch((err) => {
117
- reject(err);
118
- });
119
- }
120
- else {
121
- resolve(output);
122
- }
123
- });
124
- };
125
- exports.GetUserConnectionForCLI = GetUserConnectionForCLI;
126
- //# sourceMappingURL=CommonCLI.js.map
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- const CommonCLI = __importStar(require("./CommonCLI"));
23
- test("should fail to read and parse invalid JSON", () => {
24
- expect(() => {
25
- CommonCLI.GetConfig("cli/src/__mocks__/invalid.json");
26
- }).toThrow("Unexpected token I in JSON at position 0");
27
- });
28
- //# sourceMappingURL=CommonCLI.test.js.map
package/bin/CommonCLI.js DELETED
@@ -1,139 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.FinishWithOutputFile = exports.ValidateRuntimeParameters = exports.GetRuntimeParametersFromFirestore = exports.GetUserConnectionForCLI = exports.CleanupCLIJob = void 0;
23
- const Shared = __importStar(require("@coalescesoftware/shared"));
24
- const fs = __importStar(require("fs"));
25
- const crypto = __importStar(require("crypto"));
26
- const RunOutput = __importStar(require("./RunOutput"));
27
- const RunnerBackendLogger = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.RunnerBackend);
28
- const LogCLIInternal = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI_INTERNAL);
29
- const CleanupCLIJob = (runCompletion, firebase, logContext, action) => {
30
- const cleanupPromise = new Promise((resolve, reject) => {
31
- let promiseError = null;
32
- runCompletion
33
- .catch((error) => {
34
- promiseError = error;
35
- })
36
- .finally(() => {
37
- try {
38
- if (firebase) {
39
- Shared.Common.DeleteFirebaseInstance(firebase);
40
- }
41
- }
42
- catch (error) {
43
- RunnerBackendLogger.errorContext(logContext, `Error during ${action}WithCLI Finally cleanup: `, error);
44
- }
45
- if (promiseError) {
46
- reject(promiseError);
47
- }
48
- else {
49
- resolve();
50
- }
51
- });
52
- });
53
- return cleanupPromise;
54
- };
55
- exports.CleanupCLIJob = CleanupCLIJob;
56
- const GetKeyPairKey = (keyPairPath) => {
57
- return new Promise((resolve, reject) => {
58
- Shared.Common.assert(Shared.Logging.LoggingArea.RunnerBackend, !!keyPairPath, "ERROR (GetKeyPairPath): invalid or missing keyPairPath");
59
- const privateKeyFile = fs.readFileSync(keyPairPath);
60
- const privateKeyObject = crypto.createPrivateKey({
61
- key: privateKeyFile,
62
- format: "pem",
63
- passphrase: "passphrase"
64
- });
65
- const privateKey = privateKeyObject.export({
66
- format: "pem",
67
- type: "pkcs8"
68
- });
69
- if (!privateKey) {
70
- reject(new Error("ERROR (GetKeyPairPath): invalid or missing privateKey"));
71
- }
72
- else {
73
- resolve(privateKey);
74
- }
75
- });
76
- };
77
- const GetUserConnectionForCLI = (userID, runInfo) => {
78
- return new Promise((resolve, reject) => {
79
- var _a, _b, _c, _d, _e, _f;
80
- const output = {
81
- connectionDetails: {
82
- userID,
83
- user: (_a = runInfo.userCredentials) === null || _a === void 0 ? void 0 : _a.snowflakeUsername,
84
- role: (_b = runInfo.userCredentials) === null || _b === void 0 ? void 0 : _b.snowflakeRole,
85
- warehouse: (_c = runInfo.userCredentials) === null || _c === void 0 ? void 0 : _c.snowflakeWarehouse,
86
- },
87
- connectionType: (_d = runInfo.userCredentials) === null || _d === void 0 ? void 0 : _d.snowflakeAuthType
88
- };
89
- if (!((_e = runInfo.userCredentials) === null || _e === void 0 ? void 0 : _e.snowflakeAuthType)) {
90
- reject(new Error("ERROR (GetUserConnectionForCLI): no auth type provided"));
91
- }
92
- else if (((_f = runInfo.userCredentials) === null || _f === void 0 ? void 0 : _f.snowflakeAuthType) === Shared.ConnectionOperations.EUserConnectionTypes.keyPair) {
93
- GetKeyPairKey(Shared.Common.getValueSafe(runInfo, ["userCredentials", "snowflakeKeyPairPath"], ""))
94
- .then((keyPair) => {
95
- output.connectionDetails.keyPair = keyPair;
96
- resolve(output);
97
- })
98
- .catch((err) => {
99
- reject(err);
100
- });
101
- }
102
- else {
103
- resolve(output);
104
- }
105
- });
106
- };
107
- exports.GetUserConnectionForCLI = GetUserConnectionForCLI;
108
- ////////
109
- // Runtime Parameters
110
- ///////
111
- const GetRuntimeParametersFromFirestore = (firestore, teamID, environmentID) => {
112
- return Shared.CommonOperations.getWorkspaceDocumentRefAdmin(firestore, teamID, environmentID).get().then((workspace) => {
113
- return workspace.get("runTimeParameters");
114
- });
115
- };
116
- exports.GetRuntimeParametersFromFirestore = GetRuntimeParametersFromFirestore;
117
- const ValidateRuntimeParameters = (runtimeParameters) => {
118
- try {
119
- JSON.parse(runtimeParameters);
120
- }
121
- catch (error) {
122
- throw new Error(`Failed to parse runtime parameters: ${error.message}`);
123
- }
124
- };
125
- exports.ValidateRuntimeParameters = ValidateRuntimeParameters;
126
- ////////
127
- // Output File
128
- ///////
129
- const FinishWithOutputFile = (logContextToUse, outputFilePath, runCounter, token) => {
130
- if (!outputFilePath) {
131
- return Promise.resolve();
132
- }
133
- else {
134
- LogCLIInternal.infoContext(logContextToUse, "saving run results to file", outputFilePath);
135
- return RunOutput.SaveRunOutputToFile(outputFilePath, runCounter.toString(), token);
136
- }
137
- };
138
- exports.FinishWithOutputFile = FinishWithOutputFile;
139
- //# sourceMappingURL=CommonCLI.js.map
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.DeployWithCLI = void 0;
23
- const Shared = __importStar(require("@coalescesoftware/shared"));
24
- const CommonCLI = __importStar(require("../CommonCLI/CommonCLI"));
25
- const CryptoJS = require("crypto-js");
26
- const v8 = require("v8");
27
- Shared.Snowflake.CryptoJS = CryptoJS;
28
- Shared.Snowflake.salt = CryptoJS.lib.WordArray.random(128 / 8);
29
- Shared.Snowflake.v8 = v8;
30
- const LogCLI = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI);
31
- /**
32
- *
33
- * @param plan
34
- * @param config
35
- * @param token
36
- * @returns
37
- */
38
- const DeployWithCLI = (plan, config, token) => {
39
- let firebase;
40
- let logContext;
41
- let teamDetailsStored, runInfo, RunSQL;
42
- return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(token, undefined)
43
- .then((teamDetails) => {
44
- var _a;
45
- teamDetailsStored = teamDetails;
46
- const { teamInfo, teamInfo: { fbUserID: userID, fbTeamID: teamID } } = teamDetails;
47
- firebase = teamDetails.firebase;
48
- const environmentID = (_a = config.runDetails) === null || _a === void 0 ? void 0 : _a.environmentID;
49
- logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID);
50
- const connectionCache = new Shared.Snowflake.ConnectionStorageClass();
51
- RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(teamDetails, connectionCache);
52
- runInfo = Shared.DeployOperations.CreateDeployRequestObject(plan.plan, plan.environmentState, teamInfo, plan.gitInfo, plan.targetEnvironment, "");
53
- runInfo.userCredentials = config.userCredentials;
54
- return CommonCLI.GetUserConnectionForCLI(userID, runInfo);
55
- })
56
- .then((connection) => {
57
- LogCLI.infoContext(logContext, "Deploy starting (CLI)");
58
- return Shared.SchedulerOperations.HandleDeploy(runInfo, teamDetailsStored, RunSQL, connection);
59
- })
60
- .then(({ runCounter, runCompletion }) => {
61
- const cleanupPromise = CommonCLI.CleanupCLIJob(runCompletion, firebase, logContext, "Deploy");
62
- return {
63
- runCounter,
64
- runCompletion: cleanupPromise,
65
- logContext,
66
- };
67
- });
68
- };
69
- exports.DeployWithCLI = DeployWithCLI;
70
- //# sourceMappingURL=Deploy.js.map
package/bin/Deploy.js DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.DeployWithCLI = void 0;
23
- const Shared = __importStar(require("@coalescesoftware/shared"));
24
- const CommonCLI = __importStar(require("./CommonCLI"));
25
- const CryptoJS = require("crypto-js");
26
- const v8 = require("v8");
27
- Shared.Snowflake.CryptoJS = CryptoJS;
28
- Shared.Snowflake.salt = CryptoJS.lib.WordArray.random(128 / 8);
29
- Shared.Snowflake.v8 = v8;
30
- const LogCLI = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI);
31
- /**
32
- *
33
- * @param plan
34
- * @param config
35
- * @param token
36
- * @returns
37
- */
38
- const DeployWithCLI = (plan, config, token) => {
39
- let firebase;
40
- let logContext;
41
- let teamDetailsStored;
42
- let RunSQL;
43
- let runInfo;
44
- return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(token, undefined).then((teamDetails) => {
45
- var _a;
46
- teamDetailsStored = teamDetails;
47
- const { teamInfo, teamInfo: { fbUserID: userID, fbTeamID: teamID } } = teamDetails;
48
- firebase = teamDetails.firebase;
49
- const environmentID = +((_a = config.runDetails) === null || _a === void 0 ? void 0 : _a.environmentID);
50
- logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID);
51
- const connectionCache = new Shared.Snowflake.ConnectionStorageClass();
52
- RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(teamDetails, connectionCache);
53
- runInfo = Shared.DeployOperations.CreateDeployRequestObject(plan.plan, plan.environmentState, teamInfo, plan.gitInfo, plan.targetEnvironment, plan.runtimeParameters);
54
- runInfo.userCredentials = config.userCredentials;
55
- return CommonCLI.GetUserConnectionForCLI(userID, runInfo);
56
- })
57
- .then((connection) => {
58
- LogCLI.infoContext(logContext, "Deploy starting (CLI)");
59
- return Shared.SchedulerOperations.BECLI_HandleDeploy(runInfo, teamDetailsStored, RunSQL, connection);
60
- })
61
- .then(({ runCounter, runCompletion }) => {
62
- const cleanupPromise = CommonCLI.CleanupCLIJob(runCompletion, firebase, logContext, "Deploy");
63
- return {
64
- runCounter,
65
- runCompletion: cleanupPromise,
66
- logContext,
67
- };
68
- });
69
- };
70
- exports.DeployWithCLI = DeployWithCLI;
71
- //# sourceMappingURL=Deploy.js.map