@coalescesoftware/coa 1.0.120 → 1.0.123
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/CLIProfile.js +159 -0
- package/bin/CommonCLI.js +139 -0
- package/bin/Deploy.js +71 -0
- package/bin/Package.js +758 -0
- package/bin/Plan.js +41 -0
- package/bin/Refresh.js +66 -0
- package/bin/RunOutput.js +82 -0
- package/bin/index.js +488 -0
- package/package.json +2 -2
- package/coalescesoftware-coa-1.0.120.tgz +0 -0
- package/src/CLIProfile.ts +0 -170
- package/src/CommonCLI.ts +0 -130
- package/src/Deploy.ts +0 -84
- package/src/Package.ts +0 -1018
- package/src/Plan.ts +0 -29
- package/src/Refresh.ts +0 -67
- package/src/RunOutput.ts +0 -90
package/src/Plan.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as Shared from "@coalescesoftware/shared"
|
|
2
|
-
import fs from "fs"
|
|
3
|
-
|
|
4
|
-
export const CreatePlan = (
|
|
5
|
-
path: string,
|
|
6
|
-
environmentID: number,
|
|
7
|
-
token: string,
|
|
8
|
-
message: string,
|
|
9
|
-
runtimeParameters: Shared.Runner.TRunTimeParametersStringType
|
|
10
|
-
) => {
|
|
11
|
-
const fsSettings: Shared.GitOperations.Filesystem = {
|
|
12
|
-
fs: fs,
|
|
13
|
-
dir: path,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return Shared.DeployOperations.CreatePlanCLI(
|
|
17
|
-
environmentID,
|
|
18
|
-
fsSettings,
|
|
19
|
-
token,
|
|
20
|
-
Shared.Templates.PlatformType.snowflake,
|
|
21
|
-
runtimeParameters,
|
|
22
|
-
)
|
|
23
|
-
.then(result => {
|
|
24
|
-
const { plan } = result
|
|
25
|
-
plan.gitInfo = { commit: { message: message }, oid: "" }
|
|
26
|
-
|
|
27
|
-
return result
|
|
28
|
-
})
|
|
29
|
-
}
|
package/src/Refresh.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as Shared from "@coalescesoftware/shared"
|
|
2
|
-
import * as CommonCLI from "./CommonCLI"
|
|
3
|
-
const CryptoJS = require("crypto-js")
|
|
4
|
-
const v8 = require("v8")
|
|
5
|
-
|
|
6
|
-
Shared.Snowflake.CryptoJS = CryptoJS
|
|
7
|
-
Shared.Snowflake.salt = CryptoJS.lib.WordArray.random(128 / 8)
|
|
8
|
-
Shared.Snowflake.v8 = v8
|
|
9
|
-
|
|
10
|
-
const LogCLI = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI)
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param token
|
|
14
|
-
* @param runInfo
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export const RefreshWithCLI = (
|
|
18
|
-
token: string,
|
|
19
|
-
runInfo: Shared.Runner.IRunInfo,
|
|
20
|
-
): Promise<Shared.SchedulerOperations.IRunCounterAndRunCompletion> => {
|
|
21
|
-
let firebase: any
|
|
22
|
-
let logContext: Shared.Logging.LogContext
|
|
23
|
-
let RunSQL: Shared.RunStepHelpers.TRunSQL, teamDetailsStored: Shared.ConnectionOperations.ITeamInfoAndFirebase
|
|
24
|
-
|
|
25
|
-
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(
|
|
26
|
-
token,
|
|
27
|
-
undefined,
|
|
28
|
-
)
|
|
29
|
-
.then((teamInfoAndFirebase: Shared.ConnectionOperations.ITeamInfoAndFirebase) => {
|
|
30
|
-
teamDetailsStored = teamInfoAndFirebase
|
|
31
|
-
const { teamInfo: { fbUserID: userID, fbTeamID: teamID } } = teamInfoAndFirebase
|
|
32
|
-
firebase = teamInfoAndFirebase.firebase
|
|
33
|
-
const environmentID: string = runInfo.runDetails.environmentID!
|
|
34
|
-
logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID)
|
|
35
|
-
const connectionCache: Shared.Snowflake.ConnectionStorageClass =
|
|
36
|
-
new Shared.Snowflake.ConnectionStorageClass()
|
|
37
|
-
|
|
38
|
-
RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(
|
|
39
|
-
teamInfoAndFirebase,
|
|
40
|
-
connectionCache,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
LogCLI.infoContext(logContext, "Starting refresh (CLI)")
|
|
44
|
-
|
|
45
|
-
return CommonCLI.GetUserConnectionForCLI(
|
|
46
|
-
userID,
|
|
47
|
-
runInfo
|
|
48
|
-
)
|
|
49
|
-
})
|
|
50
|
-
.then((connection: Shared.ConnectionOperations.IUserConnection) => {
|
|
51
|
-
return Shared.SchedulerOperations.BECLI_HandleRefresh(
|
|
52
|
-
runInfo,
|
|
53
|
-
teamDetailsStored,
|
|
54
|
-
RunSQL,
|
|
55
|
-
connection,
|
|
56
|
-
)
|
|
57
|
-
})
|
|
58
|
-
.then(({ runCounter, runCompletion }: Shared.SchedulerOperations.IRunCounterAndRunCompletion) => {
|
|
59
|
-
const cleanupPromise = CommonCLI.CleanupCLIJob(runCompletion, firebase, logContext, "Refresh")
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
runCounter,
|
|
63
|
-
runCompletion: cleanupPromise,
|
|
64
|
-
logContext,
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
}
|
package/src/RunOutput.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import * as Shared from '@coalescesoftware/shared'
|
|
2
|
-
import { Firestore } from '@google-cloud/firestore'
|
|
3
|
-
import * as fs from 'fs'
|
|
4
|
-
|
|
5
|
-
const CLILogger = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI)
|
|
6
|
-
|
|
7
|
-
interface RunResultOutput {
|
|
8
|
-
nodeID:string,
|
|
9
|
-
queryResultSequence:Shared.RunnerOperations.QueryResultSequence
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface RunOutput {
|
|
13
|
-
runResults: {
|
|
14
|
-
runStartTime: Date,
|
|
15
|
-
runEndTime: Date,
|
|
16
|
-
runType: Shared.Runner.ERunStatus,
|
|
17
|
-
runStatus: Shared.Runner.ERunStatus,
|
|
18
|
-
runResults: RunResultOutput[],
|
|
19
|
-
runID: Shared.Runs.TRunID
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const cleanRunResult = (nodeID:string,runResult:Shared.RunnerOperations.RunResultInterface):RunResultOutput=> {
|
|
24
|
-
return {
|
|
25
|
-
nodeID,
|
|
26
|
-
queryResultSequence:runResult.queryResultSequence
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const GetRunOutputForRunCounter = (firestore: any, teamID, runID: Shared.Runs.TRunID): Promise<RunOutput> => {
|
|
30
|
-
let runData: Partial<RunOutput>
|
|
31
|
-
return Shared.Runs.getRun(firestore, teamID, runID).get()
|
|
32
|
-
.then((runDataResult/*query snapshot*/) => {
|
|
33
|
-
if (!runDataResult.docs.length) {
|
|
34
|
-
const errorMessage = `wasnt able to get exactly one run for runID ${runID}`
|
|
35
|
-
CLILogger.emergContext({
|
|
36
|
-
orgID: teamID
|
|
37
|
-
}, errorMessage)
|
|
38
|
-
throw new Error(errorMessage)
|
|
39
|
-
}
|
|
40
|
-
const runInfo = runDataResult.docs[0].data()
|
|
41
|
-
runData = {
|
|
42
|
-
runResults: {
|
|
43
|
-
runStartTime: runInfo.runStartTime,
|
|
44
|
-
runEndTime: runInfo.runEndTime,
|
|
45
|
-
runType: runInfo.runType,
|
|
46
|
-
runStatus: runInfo.runStatus,
|
|
47
|
-
runID: runInfo.id,
|
|
48
|
-
runResults: []
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return Shared.Runs.getRunRunResultsCollection(firestore,
|
|
52
|
-
teamID, runID.toString())
|
|
53
|
-
.get().then((queryResult/*querySnapshot*/) => {
|
|
54
|
-
let runResults= {}
|
|
55
|
-
queryResult.docs.forEach((runResultDoc) => {
|
|
56
|
-
const stepCounter = runResultDoc.id
|
|
57
|
-
const runResult = runResultDoc.data()
|
|
58
|
-
runResults[stepCounter] = cleanRunResult(stepCounter,
|
|
59
|
-
runResult.history[0] as Shared.RunnerOperations.RunResultInterface
|
|
60
|
-
)
|
|
61
|
-
})
|
|
62
|
-
runData.runResults!.runResults = runInfo.runHistory.map((stepCounter) => {
|
|
63
|
-
return runResults[stepCounter]
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
}).then(() => {
|
|
67
|
-
return runData as RunOutput;
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const SaveRunOutputToFile = (runOutputFileLocation: string,
|
|
72
|
-
runIDString: string, token: string
|
|
73
|
-
): Promise<void> => {
|
|
74
|
-
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(token,
|
|
75
|
-
undefined
|
|
76
|
-
).then((authInfo: Shared.ConnectionOperations.ITeamInfoAndFirebase) => {
|
|
77
|
-
const { teamInfo, firebase } = authInfo
|
|
78
|
-
const teamID = teamInfo.fbTeamID
|
|
79
|
-
const firestore = firebase.firestore()
|
|
80
|
-
const runID = parseInt(runIDString)
|
|
81
|
-
return GetRunOutputForRunCounter(firestore,
|
|
82
|
-
teamID,
|
|
83
|
-
runID
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
}).then((runOutput: RunOutput) => {
|
|
87
|
-
const runOutputJSON = Shared.Common.StringifyFirestoreObject(runOutput)
|
|
88
|
-
return Shared.Common.WriteFile(runOutputFileLocation , runOutputJSON + "\n")
|
|
89
|
-
})
|
|
90
|
-
}
|