@coalescesoftware/coa 1.0.102 → 1.0.112
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/CLIOperations.js +135 -0
- package/bin/{CommonCLI/CommonCLI.js → Common.js} +9 -28
- package/bin/Profile.js +53 -0
- package/bin/index.js +1 -0
- package/package.json +2 -2
- package/bin/CommonCLI/CommonCLI.test.js +0 -28
- package/bin/Deploy/Deploy.js +0 -70
- package/bin/Plan/Plan.js +0 -41
- package/bin/Refresh/Refresh.js +0 -65
|
@@ -0,0 +1,135 @@
|
|
|
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.DisableNonCLIConsoleLogs = exports.ExitCLISafe = exports.VerifyAllRefreshItems = exports.VerifyAllPlanItems = exports.VerifyAllDeployItems = void 0;
|
|
23
|
+
const Templates = __importStar(require("@coalescesoftware/shared/src/Templates"));
|
|
24
|
+
const R = __importStar(require("runtypes"));
|
|
25
|
+
const Logging = __importStar(require("@coalescesoftware/shared/src/Logging"));
|
|
26
|
+
const Firebase = __importStar(require("@coalescesoftware/shared/src/Firebase"));
|
|
27
|
+
const LogCLI = Logging.GetLogger(Logging.LoggingArea.CLI);
|
|
28
|
+
const UserCredentialsDeployType = R.Record({
|
|
29
|
+
snowflakeUsername: R.String,
|
|
30
|
+
snowflakePassword: R.String.optional(),
|
|
31
|
+
snowflakeRole: R.String.optional(),
|
|
32
|
+
snowflakeWarehouse: R.String.optional(),
|
|
33
|
+
});
|
|
34
|
+
const UserCredentialsRefreshType = R.Record({
|
|
35
|
+
snowflakePassword: R.String.optional(),
|
|
36
|
+
});
|
|
37
|
+
const BaseEnvironmentType = R.Record({
|
|
38
|
+
environmentID: R.Union(R.String, R.Number),
|
|
39
|
+
});
|
|
40
|
+
const EnvironmentRefreshType = BaseEnvironmentType.extend({
|
|
41
|
+
jobID: R.String.optional(),
|
|
42
|
+
});
|
|
43
|
+
const DeployConfig = R.Record({
|
|
44
|
+
token: userCredentials, UserCredentialsDeployType,
|
|
45
|
+
});
|
|
46
|
+
const RefreshConfig = R.Record({
|
|
47
|
+
userCredentials: UserCredentialsRefreshType,
|
|
48
|
+
runDetails: EnvironmentRefreshType,
|
|
49
|
+
});
|
|
50
|
+
const Plan = R.Record({
|
|
51
|
+
version: R.Number,
|
|
52
|
+
targetEnvironment: R.Number,
|
|
53
|
+
plan: R.Unknown,
|
|
54
|
+
environmentState: R.Unknown,
|
|
55
|
+
gitInfo: R.Unknown,
|
|
56
|
+
});
|
|
57
|
+
const PlanConfig = R.Record({
|
|
58
|
+
runDetails: BaseEnvironmentType,
|
|
59
|
+
});
|
|
60
|
+
const Token = R.String;
|
|
61
|
+
const VerifyAllDeployItems = (plan,
|
|
62
|
+
// TODO-AI: move coalesceToken out of usercredentials to one level higher
|
|
63
|
+
config, token) => {
|
|
64
|
+
const runTypesAndObjectsToVerify = [
|
|
65
|
+
{ runType: Plan, object: plan },
|
|
66
|
+
{ runType: DeployConfig, object: config },
|
|
67
|
+
{ runType: Token, object: token },
|
|
68
|
+
];
|
|
69
|
+
return Templates.ValidateMultipleRunTypesAndReturnSuccessOrErrorMessages(runTypesAndObjectsToVerify);
|
|
70
|
+
};
|
|
71
|
+
exports.VerifyAllDeployItems = VerifyAllDeployItems;
|
|
72
|
+
const VerifyAllPlanItems = (config) => {
|
|
73
|
+
const { coalescetoken: token } = config;
|
|
74
|
+
const runTypesAndObjectsToVerify = [
|
|
75
|
+
{ runType: PlanConfig, object: config },
|
|
76
|
+
{ runType: Token, object: token },
|
|
77
|
+
];
|
|
78
|
+
return Templates.ValidateMultipleRunTypesAndReturnSuccessOrErrorMessages(runTypesAndObjectsToVerify);
|
|
79
|
+
};
|
|
80
|
+
exports.VerifyAllPlanItems = VerifyAllPlanItems;
|
|
81
|
+
const VerifyAllRefreshItems = (config, token) => {
|
|
82
|
+
const runTypesAndObjectsToVerify = [
|
|
83
|
+
{ runType: RefreshConfig, object: config },
|
|
84
|
+
{ runType: Token, object: token },
|
|
85
|
+
];
|
|
86
|
+
return Templates.ValidateMultipleRunTypesAndReturnSuccessOrErrorMessages(runTypesAndObjectsToVerify);
|
|
87
|
+
};
|
|
88
|
+
exports.VerifyAllRefreshItems = VerifyAllRefreshItems;
|
|
89
|
+
/**
|
|
90
|
+
* Should be used in place of all process.exit() or process.exitCode = x instances. process.exit() kills all processes immediately and we lose logs and can
|
|
91
|
+
* cause other issues, process.exitCode = x will hang indefinitely if firebase apps aren't deleted first
|
|
92
|
+
* @param exitCode normal nodeJS exit code that would be passed to process.exit or process.exitCode
|
|
93
|
+
*/
|
|
94
|
+
const ExitCLISafe = (exitCode) => {
|
|
95
|
+
// force exit if FB fails to exit (or less likely, logs fail to send) in 5 seconds
|
|
96
|
+
const forceExitTimeout = setTimeout(() => {
|
|
97
|
+
LogCLI.alert("CLI exit timeout");
|
|
98
|
+
// inner timeout is so the above log can be sent to Datadog; proper methods for waiting on winston transports don't work on our datadog transport
|
|
99
|
+
setTimeout(() => process.exit(exitCode), 1000);
|
|
100
|
+
}, 5000);
|
|
101
|
+
try {
|
|
102
|
+
const firebase = Firebase.justFirebase;
|
|
103
|
+
// Firebase Apps is an App[]
|
|
104
|
+
if (firebase.apps.length) {
|
|
105
|
+
firebase.apps.forEach((app) => {
|
|
106
|
+
firebase.app(app.name).delete();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
clearTimeout(forceExitTimeout);
|
|
110
|
+
process.exitCode = exitCode;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
LogCLI.error("Error while attempting to close Firebase apps in CLI");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
exports.ExitCLISafe = ExitCLISafe;
|
|
117
|
+
const DisableNonCLIConsoleLogs = () => {
|
|
118
|
+
const allLoggersConfigs = {};
|
|
119
|
+
Object.values(Logging.LoggingArea).forEach(logArea => {
|
|
120
|
+
if (logArea !== Logging.LoggingArea.CLI) {
|
|
121
|
+
allLoggersConfigs[logArea] = {
|
|
122
|
+
level: Logging.LoggingAreas[logArea].level,
|
|
123
|
+
transports: [Logging.GetHttpTransport(), Logging.GetOurTransport()]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
const CLIAreaInfo = Logging.LoggingAreas[Logging.LoggingArea.CLI];
|
|
128
|
+
allLoggersConfigs[Logging.LoggingArea.CLI] = {
|
|
129
|
+
level: CLIAreaInfo.level,
|
|
130
|
+
transports: Logging.GetDefaultTransports(CLIAreaInfo)
|
|
131
|
+
};
|
|
132
|
+
Logging.ReconfigureLoggers(allLoggersConfigs);
|
|
133
|
+
};
|
|
134
|
+
exports.DisableNonCLIConsoleLogs = DisableNonCLIConsoleLogs;
|
|
135
|
+
//# sourceMappingURL=CLIOperations.js.map
|
|
@@ -19,32 +19,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.GetUserConnectionForCLI = exports.CleanupCLIJob =
|
|
22
|
+
exports.GetUserConnectionForCLI = exports.CleanupCLIJob = void 0;
|
|
23
23
|
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
|
-
const crypto = __importStar(require("crypto"));
|
|
25
24
|
const fs = __importStar(require("fs"));
|
|
25
|
+
const crypto = __importStar(require("crypto"));
|
|
26
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
27
|
const CleanupCLIJob = (runCompletion, firebase, logContext, action) => {
|
|
49
28
|
const cleanupPromise = new Promise((resolve, reject) => {
|
|
50
29
|
let promiseError = null;
|
|
@@ -96,18 +75,20 @@ const GetKeyPairKey = (keyPairPath) => {
|
|
|
96
75
|
const GetUserConnectionForCLI = (userID, runInfo) => {
|
|
97
76
|
return new Promise((resolve, reject) => {
|
|
98
77
|
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
78
|
const output = {
|
|
101
79
|
connectionDetails: {
|
|
102
80
|
userID,
|
|
103
81
|
user: "mx2323",
|
|
104
82
|
role: "SYSADMIN",
|
|
105
83
|
warehouse: "COMPUTE_WH",
|
|
106
|
-
authenticator: (
|
|
84
|
+
authenticator: (_a = runInfo.userCredentials) === null || _a === void 0 ? void 0 : _a.snowflakeAuthType
|
|
107
85
|
},
|
|
108
|
-
connectionType: (
|
|
86
|
+
connectionType: (_b = runInfo.userCredentials) === null || _b === void 0 ? void 0 : _b.snowflakeAuthType
|
|
109
87
|
};
|
|
110
|
-
if (((
|
|
88
|
+
if (!((_c = runInfo.userCredentials) === null || _c === void 0 ? void 0 : _c.snowflakeAuthType)) {
|
|
89
|
+
reject(new Error("ERROR (GetUserConnectionForCLI): no auth type provided"));
|
|
90
|
+
}
|
|
91
|
+
else if (((_d = runInfo.userCredentials) === null || _d === void 0 ? void 0 : _d.snowflakeAuthType) === Shared.ConnectionOperations.EUserConnectionTypes.keyPair) {
|
|
111
92
|
GetKeyPairKey(Shared.Common.getValueSafe(runInfo, ["userCredentials", "snowflakeKeyPairPath"], ""))
|
|
112
93
|
.then((keyPair) => {
|
|
113
94
|
output.connectionDetails.keyPair = keyPair;
|
|
@@ -123,4 +104,4 @@ const GetUserConnectionForCLI = (userID, runInfo) => {
|
|
|
123
104
|
});
|
|
124
105
|
};
|
|
125
106
|
exports.GetUserConnectionForCLI = GetUserConnectionForCLI;
|
|
126
|
-
//# sourceMappingURL=
|
|
107
|
+
//# sourceMappingURL=Common.js.map
|
package/bin/Profile.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable multiline-comment-style */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
6
|
+
}) : (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
o[k2] = m[k];
|
|
9
|
+
}));
|
|
10
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
11
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
12
|
+
}) : function(o, v) {
|
|
13
|
+
o["default"] = v;
|
|
14
|
+
});
|
|
15
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
16
|
+
if (mod && mod.__esModule) return mod;
|
|
17
|
+
var result = {};
|
|
18
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
19
|
+
__setModuleDefault(result, mod);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
|
+
const GetCLIConfigFromCLIProfile = (CLIProfile) => {
|
|
25
|
+
return {
|
|
26
|
+
token: "AIwUaOn1n7RzQXkyx6mwVO7x17s-agEgNHtIROspfSBx-QjsII6O9Kp7Qxpl_7TtjG3a59dq32VBeItGG5X6sN2kKmn54u-RMFxoJnZg0VXh3p1qM-0Palu7hVDiMIFuNdX2dyOQy2DK7WLjwbH6kXFrDQy8zLlDCKFGxzcMMNU3wp2TPtb2uxbZYtVcCqZg3be7Lr3esaKYhJLcKuW5lixc_JCAEhMjQw",
|
|
27
|
+
runDetails: {
|
|
28
|
+
environmentID: 2
|
|
29
|
+
},
|
|
30
|
+
userCredentials: {
|
|
31
|
+
snowflakeAccount: "ww56326.us-central1.gcp",
|
|
32
|
+
snowflakeAuthType: Shared.ConnectionOperations.EUserConnectionTypes.basic,
|
|
33
|
+
snowflakePassword: "ThisIsAPassword1!",
|
|
34
|
+
snowflakeRole: "SYSADMIN",
|
|
35
|
+
snowflakeUsername: "mx2323",
|
|
36
|
+
snowflakeWarehouse: "COMPUTE_WH"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
// TODO: create a profile class that takes the cmd object in the constructor
|
|
41
|
+
// store contents of configuration file
|
|
42
|
+
// if no config file path option
|
|
43
|
+
// check if there's a valid configuration file in the current working directory or home directory
|
|
44
|
+
// if none exists
|
|
45
|
+
// create a configuration file with empty default profile
|
|
46
|
+
// 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
|
|
47
|
+
// if a configuration file exists, but any required property holds a falsy value
|
|
48
|
+
// inform user which fields are missing and prompt to run `coa init` to fill out invalid fields
|
|
49
|
+
// method: validate configuration file
|
|
50
|
+
// method: get final profile for current command
|
|
51
|
+
// create a function getCLIProfile that returns a CLI profile, this should return a promise that resolve in CLI profile
|
|
52
|
+
// hardcode a profile
|
|
53
|
+
//# sourceMappingURL=Profile.js.map
|
package/bin/index.js
CHANGED
|
@@ -220,6 +220,7 @@ AddOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Refresh)
|
|
|
220
220
|
userCredentials: config.userCredentials,
|
|
221
221
|
runTimeParameters: {}
|
|
222
222
|
};
|
|
223
|
+
Shared.Common.CleanupUndefinedValuesFromObject(runInfo);
|
|
223
224
|
LogCLIInternal.infoContext(logContextToUse, "cliOverrides", cliOverrides);
|
|
224
225
|
LogCLIInternal.infoContext(logContextToUse, "got the cli config", config);
|
|
225
226
|
LogCLIInternal.infoContext(logContextToUse, "got the run info", config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coalescesoftware/coa",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.112",
|
|
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.
|
|
15
|
+
"@coalescesoftware/shared": "^1.0.112",
|
|
16
16
|
"chalk": "^4.1.2",
|
|
17
17
|
"commander": "^9.2.0",
|
|
18
18
|
"firebase": "8.2.0",
|
|
@@ -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/Deploy/Deploy.js
DELETED
|
@@ -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/Plan/Plan.js
DELETED
|
@@ -1,41 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.CreatePlan = void 0;
|
|
26
|
-
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
27
|
-
const fs_1 = __importDefault(require("fs"));
|
|
28
|
-
const CreatePlan = (path, environmentID, token, message) => {
|
|
29
|
-
const fsSettings = {
|
|
30
|
-
fs: fs_1.default,
|
|
31
|
-
dir: path,
|
|
32
|
-
};
|
|
33
|
-
return Shared.DeployOperations.CreatePlanCLI(environmentID, fsSettings, token, Shared.Templates.PlatformType.snowflake)
|
|
34
|
-
.then(result => {
|
|
35
|
-
const { plan } = result;
|
|
36
|
-
plan.gitInfo = { commit: { message: message }, oid: "" };
|
|
37
|
-
return result;
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.CreatePlan = CreatePlan;
|
|
41
|
-
//# sourceMappingURL=Plan.js.map
|
package/bin/Refresh/Refresh.js
DELETED
|
@@ -1,65 +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.RefreshWithCLI = 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 token
|
|
34
|
-
* @param runInfo
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
const RefreshWithCLI = (token, runInfo) => {
|
|
38
|
-
let firebase;
|
|
39
|
-
let logContext;
|
|
40
|
-
let RunSQL, teamDetails;
|
|
41
|
-
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(token, undefined)
|
|
42
|
-
.then((teamInfoAndFirebase) => {
|
|
43
|
-
const { teamInfo: { fbUserID: userID, fbTeamID: teamID } } = teamInfoAndFirebase;
|
|
44
|
-
firebase = teamInfoAndFirebase.firebase;
|
|
45
|
-
const environmentID = runInfo.runDetails.environmentID;
|
|
46
|
-
logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID);
|
|
47
|
-
const connectionCache = new Shared.Snowflake.ConnectionStorageClass();
|
|
48
|
-
RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(teamInfoAndFirebase, connectionCache);
|
|
49
|
-
LogCLI.infoContext(logContext, "Starting refresh (CLI)");
|
|
50
|
-
return CommonCLI.GetUserConnectionForCLI(userID, runInfo);
|
|
51
|
-
})
|
|
52
|
-
.then((connection) => {
|
|
53
|
-
return Shared.SchedulerOperations.HandleRefresh(runInfo, teamDetails, RunSQL, connection);
|
|
54
|
-
})
|
|
55
|
-
.then(({ runCounter, runCompletion }) => {
|
|
56
|
-
const cleanupPromise = CommonCLI.CleanupCLIJob(runCompletion, firebase, logContext, "Refresh");
|
|
57
|
-
return {
|
|
58
|
-
runCounter,
|
|
59
|
-
runCompletion: cleanupPromise,
|
|
60
|
-
logContext,
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
exports.RefreshWithCLI = RefreshWithCLI;
|
|
65
|
-
//# sourceMappingURL=Refresh.js.map
|