@coalescesoftware/coa 1.0.115 → 1.0.116
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/index.js +1 -1
- package/package.json +2 -2
- package/bin/CommonCLI/CommonCLI.js +0 -126
- 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
package/bin/index.js
CHANGED
|
@@ -264,7 +264,7 @@ AddOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Refresh)
|
|
|
264
264
|
});
|
|
265
265
|
});
|
|
266
266
|
}).catch(error => {
|
|
267
|
-
LogCLI.errorContext(logContextToUse, chalk_1.default.redBright(
|
|
267
|
+
LogCLI.errorContext(logContextToUse, chalk_1.default.redBright("Error during refresh!: "), error);
|
|
268
268
|
Shared.CLIOperations.ExitCLISafe(1);
|
|
269
269
|
});
|
|
270
270
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coalescesoftware/coa",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.116",
|
|
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.116",
|
|
16
16
|
"chalk": "^4.1.2",
|
|
17
17
|
"commander": "^9.2.0",
|
|
18
18
|
"firebase": "8.2.0",
|
|
@@ -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/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
|