@speedkit/cli 4.43.0 → 4.43.1
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/CHANGELOG.md +7 -0
- package/dist/models/files.d.ts +0 -1
- package/dist/models/files.js +0 -1
- package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.js +8 -7
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +11 -7
- package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/save-files-check.js +3 -2
- package/dist/services/deploy/deploy-service-factory.js +0 -2
- package/dist/services/deploy/deploy-service-model.d.ts +11 -1
- package/dist/services/deploy/deploy-service.d.ts +2 -0
- package/dist/services/deploy/deploy-service.js +26 -1
- package/dist/services/deploy/policy/deploy-policy-model.d.ts +1 -5
- package/dist/services/deploy/policy/deploy-policy-model.js +0 -4
- package/dist/services/deploy/spec/checks/post-deploy/refresh-deployment-job-check.spec.js +5 -12
- package/dist/services/deploy/spec/deploy-service.spec.d.ts +1 -0
- package/dist/services/deploy/spec/deploy-service.spec.js +64 -0
- package/dist/services/deploy/spec/policy/auto-deploy-policy.spec.js +0 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.d.ts +0 -15
- package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.js +0 -70
- package/dist/services/deploy/error/check-module-file-error.d.ts +0 -4
- package/dist/services/deploy/error/check-module-file-error.js +0 -4
- package/dist/services/deploy/error/post-deploy-deployment-detection-error.d.ts +0 -4
- package/dist/services/deploy/error/post-deploy-deployment-detection-error.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.43.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.43.0...v4.43.1) (2026-10-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deploy:** post deploy checks don't throw errors ([887747b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/887747be797ec13afa691a80cd312782bbcabdd1))
|
|
7
|
+
|
|
1
8
|
# [4.43.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.42.0...v4.43.0) (2026-10-09)
|
|
2
9
|
|
|
3
10
|
|
package/dist/models/files.d.ts
CHANGED
package/dist/models/files.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EntityManager } from "baqend";
|
|
2
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
2
|
+
import { PostDeployCheckInterface, PostDeployCheckResult } from "../../deploy-service-model.js";
|
|
3
3
|
import { CliServiceInterface } from "../../../cli/index.js";
|
|
4
4
|
export declare class RefreshDeploymentJobCheck implements PostDeployCheckInterface {
|
|
5
5
|
private entityManager;
|
|
6
6
|
private cli;
|
|
7
7
|
constructor(entityManager: EntityManager, cli: CliServiceInterface);
|
|
8
|
-
check(): Promise<
|
|
8
|
+
check(): Promise<PostDeployCheckResult>;
|
|
9
9
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ApplicationError from "../../../error-handling/error/application-error.js";
|
|
2
1
|
export class RefreshDeploymentJobCheck {
|
|
3
2
|
entityManager;
|
|
4
3
|
cli;
|
|
@@ -21,12 +20,14 @@ export class RefreshDeploymentJobCheck {
|
|
|
21
20
|
this.cli.writeWarning(" Deployment jobs are missing. These are normally created on first deployment run.");
|
|
22
21
|
}
|
|
23
22
|
if (missingRequiredJobs.length > 0) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
" ",
|
|
29
|
-
|
|
23
|
+
return {
|
|
24
|
+
success: false,
|
|
25
|
+
error: `Missing required jobs: ${missingRequiredJobs.join(", ")}`,
|
|
26
|
+
suggestions: [
|
|
27
|
+
"To create missing jobs, follow the steps here: https://www.notion.so/baqend/How-to-create-missing-Jobs-306de49f8a9980f397c2ebe693da4aac?v=fcdbfc994dca4aa6be42228b37609d48&source=copy_link",
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
30
|
}
|
|
31
|
+
return { success: true };
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CliServiceInterface } from "../../../cli/index.js";
|
|
2
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
2
|
+
import { PostDeployCheckInterface, PostDeployCheckResult } from "../../deploy-service-model.js";
|
|
3
3
|
import { ConfigApiService } from "../../../config-api/index.js";
|
|
4
4
|
export default class RevalidatedModuleCheck implements PostDeployCheckInterface {
|
|
5
5
|
private readonly configApi;
|
|
6
6
|
private cli;
|
|
7
7
|
private readonly app;
|
|
8
8
|
constructor(configApi: ConfigApiService, cli: CliServiceInterface, app: string);
|
|
9
|
-
check(): Promise<
|
|
9
|
+
check(): Promise<PostDeployCheckResult>;
|
|
10
10
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { safe } from "../../../../helpers/safe.js";
|
|
2
2
|
import { DeployModuleFileError } from "../../error/deploy-module-file-error.js";
|
|
3
|
-
import { CheckModuleFileError } from "../../error/check-module-file-error.js";
|
|
4
3
|
const REVALIDATED_MODULE_NAME = "speedKit.Revalidated";
|
|
5
4
|
export default class RevalidatedModuleCheck {
|
|
6
5
|
configApi;
|
|
@@ -14,14 +13,19 @@ export default class RevalidatedModuleCheck {
|
|
|
14
13
|
async check() {
|
|
15
14
|
this.cli.startAction("POST:CHECK:REVALIDATED_MODULE", "[postDeployCheck] check for revalidated module");
|
|
16
15
|
const result = await safe(this.configApi.getModule(REVALIDATED_MODULE_NAME));
|
|
17
|
-
if (result.success === true && result.data) {
|
|
18
|
-
this.cli.successAction("POST:CHECK:REVALIDATED_MODULE");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.cli.failAction("POST:CHECK:REVALIDATED_MODULE");
|
|
22
16
|
if (result.success === false) {
|
|
17
|
+
this.cli.failAction("POST:CHECK:REVALIDATED_MODULE");
|
|
23
18
|
throw new DeployModuleFileError(result.error);
|
|
24
19
|
}
|
|
25
|
-
|
|
20
|
+
if (result.data) {
|
|
21
|
+
this.cli.successAction("POST:CHECK:REVALIDATED_MODULE");
|
|
22
|
+
return { success: true };
|
|
23
|
+
}
|
|
24
|
+
this.cli.failAction("POST:CHECK:REVALIDATED_MODULE");
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
error: `${REVALIDATED_MODULE_NAME} does not exist in the app ${this.app}`,
|
|
28
|
+
suggestions: [`sk generate-pop-config ${this.app}`],
|
|
29
|
+
};
|
|
26
30
|
}
|
|
27
31
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CliServiceInterface } from "../../../cli/index.js";
|
|
2
2
|
import { FileListInterface, InstallResourceFile } from "../../../integration-api/index.js";
|
|
3
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
3
|
+
import { PostDeployCheckInterface, PostDeployCheckResult } from "../../deploy-service-model.js";
|
|
4
4
|
import { DeployPolicyInterface } from "../../policy/index.js";
|
|
5
5
|
export default class SaveFilesCheck implements PostDeployCheckInterface {
|
|
6
6
|
private policy;
|
|
7
7
|
private fileList;
|
|
8
8
|
private readonly cli;
|
|
9
9
|
constructor(fileList: FileListInterface, cli: CliServiceInterface, policy: DeployPolicyInterface);
|
|
10
|
-
check(): Promise<
|
|
10
|
+
check(): Promise<PostDeployCheckResult>;
|
|
11
11
|
safeFiles(fileList: InstallResourceFile[]): Promise<void>;
|
|
12
12
|
}
|
|
@@ -15,10 +15,10 @@ export default class SaveFilesCheck {
|
|
|
15
15
|
return file.isUpdated();
|
|
16
16
|
});
|
|
17
17
|
if (fileList.length === 0) {
|
|
18
|
-
return;
|
|
18
|
+
return { success: true };
|
|
19
19
|
}
|
|
20
20
|
if (!(await this.policy.confirm(DeployQuestion.SaveLocalFiles, `Changes to localFiles will be saved now. Proceed?`))) {
|
|
21
|
-
return;
|
|
21
|
+
return { success: true };
|
|
22
22
|
}
|
|
23
23
|
this.cli.startAction("POST:DEPLOY:SAVE_FILES", "safe changed files");
|
|
24
24
|
const result = await safe(this.safeFiles(fileList));
|
|
@@ -27,6 +27,7 @@ export default class SaveFilesCheck {
|
|
|
27
27
|
throw new SafeFileError(result.error);
|
|
28
28
|
}
|
|
29
29
|
this.cli.successAction("POST:DEPLOY:SAVE_FILES");
|
|
30
|
+
return { success: true };
|
|
30
31
|
}
|
|
31
32
|
async safeFiles(fileList) {
|
|
32
33
|
for (const file of fileList) {
|
|
@@ -11,7 +11,6 @@ import ServerConfigHandler from "./handler/server-config-handler.js";
|
|
|
11
11
|
import { IntegrationApiFactory, IntegrationApiServiceBuildContext, FILE_TYPE, DEFAULT_BLOCKED_FOLDERS, } from "../integration-api/index.js";
|
|
12
12
|
import { SplitChangeCheck } from "./checks/pre-deploy/split-change-check.js";
|
|
13
13
|
import { ConfigApiContext, ConfigApiServiceFactory, } from "../config-api/index.js";
|
|
14
|
-
import { DeprecatedDeploymentDetectionCheck } from "./checks/post-deploy/deprecated-deployment-detection-check.js";
|
|
15
14
|
import { DeviceDetectionChangedCheck } from "./checks/pre-deploy/device-detection-changed-check.js";
|
|
16
15
|
import { RefreshDeploymentJobCheck } from "./checks/post-deploy/refresh-deployment-job-check.js";
|
|
17
16
|
import { CustomerApprovalCheck } from "./checks/activation/customer-approval-check.js";
|
|
@@ -99,7 +98,6 @@ export default class DeployServiceFactory {
|
|
|
99
98
|
return [
|
|
100
99
|
new SaveFilesCheck(files, cliService, policy),
|
|
101
100
|
new RevalidatedModuleCheck(configApi, cliService, app),
|
|
102
|
-
new DeprecatedDeploymentDetectionCheck(files, cliService, configApi, app, policy),
|
|
103
101
|
new RefreshDeploymentJobCheck(await configApi.client.getEntityManager(), cliService),
|
|
104
102
|
];
|
|
105
103
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a post-deploy check found. The deploy is already uploaded when the checks
|
|
3
|
+
* run, so a finding is reported rather than thrown; a check throws only when it
|
|
4
|
+
* could not do its job.
|
|
5
|
+
*/
|
|
6
|
+
export interface PostDeployCheckResult {
|
|
7
|
+
readonly success: boolean;
|
|
8
|
+
readonly error?: string;
|
|
9
|
+
readonly suggestions?: string[];
|
|
10
|
+
}
|
|
1
11
|
export interface PostDeployCheckInterface {
|
|
2
|
-
check(): Promise<
|
|
12
|
+
check(): Promise<PostDeployCheckResult>;
|
|
3
13
|
}
|
|
4
14
|
export interface PreDeployCheckInterface {
|
|
5
15
|
check(): Promise<void>;
|
|
@@ -15,5 +15,7 @@ export default class DeployService {
|
|
|
15
15
|
private uploadType;
|
|
16
16
|
private runPreDeployChecks;
|
|
17
17
|
private runPostDeployChecks;
|
|
18
|
+
/** Lays a result out the way oclif prints an error: message, then suggestions. */
|
|
19
|
+
private reportFailedPostDeployChecks;
|
|
18
20
|
private filterFilesToProcess;
|
|
19
21
|
}
|
|
@@ -55,9 +55,34 @@ export default class DeployService {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async runPostDeployChecks() {
|
|
58
|
+
const failed = [];
|
|
58
59
|
for (const postDeployCheck of this.postDeployChecks) {
|
|
59
|
-
await postDeployCheck.check();
|
|
60
|
+
const result = await postDeployCheck.check();
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
failed.push(result);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.reportFailedPostDeployChecks(failed);
|
|
66
|
+
}
|
|
67
|
+
/** Lays a result out the way oclif prints an error: message, then suggestions. */
|
|
68
|
+
reportFailedPostDeployChecks(failed) {
|
|
69
|
+
if (failed.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.cli.spacer();
|
|
73
|
+
this.cli.writeWarning(`${failed.length} post-deploy check(s) failed:`);
|
|
74
|
+
for (const { error, suggestions = [] } of failed) {
|
|
75
|
+
const lines = [`› ${error}`];
|
|
76
|
+
if (suggestions.length === 1) {
|
|
77
|
+
lines.push(` Try this: ${suggestions[0]}`);
|
|
78
|
+
}
|
|
79
|
+
else if (suggestions.length > 1) {
|
|
80
|
+
lines.push(" Try this:", ...suggestions.map((s) => ` * ${s}`));
|
|
81
|
+
}
|
|
82
|
+
this.cli.spacer();
|
|
83
|
+
this.cli.writeWarning(lines.join("\n"));
|
|
60
84
|
}
|
|
85
|
+
this.cli.spacer();
|
|
61
86
|
}
|
|
62
87
|
filterFilesToProcess() {
|
|
63
88
|
this.fileList.filter((file) => {
|
|
@@ -32,11 +32,7 @@ export declare enum DeployQuestion {
|
|
|
32
32
|
/** Deploy although the device detection changes. */
|
|
33
33
|
DeviceDetectionChange = "deviceDetectionChange",
|
|
34
34
|
/** Write the content taken over from the installation to the local files. */
|
|
35
|
-
SaveLocalFiles = "saveLocalFiles"
|
|
36
|
-
/** Delete the job of the deprecated deployment detection. */
|
|
37
|
-
DeleteDeprecatedJob = "deleteDeprecatedJob",
|
|
38
|
-
/** Delete the module of the deprecated deployment detection. */
|
|
39
|
-
DeleteDeprecatedModule = "deleteDeprecatedModule"
|
|
35
|
+
SaveLocalFiles = "saveLocalFiles"
|
|
40
36
|
}
|
|
41
37
|
export interface DeployPolicyInterface {
|
|
42
38
|
/**
|
|
@@ -34,8 +34,4 @@ export var DeployQuestion;
|
|
|
34
34
|
DeployQuestion["DeviceDetectionChange"] = "deviceDetectionChange";
|
|
35
35
|
/** Write the content taken over from the installation to the local files. */
|
|
36
36
|
DeployQuestion["SaveLocalFiles"] = "saveLocalFiles";
|
|
37
|
-
/** Delete the job of the deprecated deployment detection. */
|
|
38
|
-
DeployQuestion["DeleteDeprecatedJob"] = "deleteDeprecatedJob";
|
|
39
|
-
/** Delete the module of the deprecated deployment detection. */
|
|
40
|
-
DeployQuestion["DeleteDeprecatedModule"] = "deleteDeprecatedModule";
|
|
41
37
|
})(DeployQuestion || (DeployQuestion = {}));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { RefreshDeploymentJobCheck } from "../../../checks/post-deploy/refresh-deployment-job-check.js";
|
|
4
|
-
import ApplicationError from "../../../../error-handling/error/application-error.js";
|
|
5
4
|
function entityManagerWithJobs(names) {
|
|
6
5
|
const jobs = names.map((name) => ({ data: { name }, type: "Refreshjob" }));
|
|
7
6
|
return {
|
|
@@ -12,22 +11,16 @@ function entityManagerWithJobs(names) {
|
|
|
12
11
|
}
|
|
13
12
|
const cli = { writeWarning: () => undefined };
|
|
14
13
|
async function runCheck(names) {
|
|
15
|
-
|
|
16
|
-
await new RefreshDeploymentJobCheck(entityManagerWithJobs(names), cli).check();
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
return error;
|
|
20
|
-
}
|
|
21
|
-
return undefined;
|
|
14
|
+
return new RefreshDeploymentJobCheck(entityManagerWithJobs(names), cli).check();
|
|
22
15
|
}
|
|
23
16
|
describe("RefreshDeploymentJobCheck", () => {
|
|
24
17
|
it("accepts jobs whose names carry a suffix", async () => {
|
|
25
18
|
// As used by zeg and tectake.
|
|
26
|
-
expect(await runCheck(["HTML", "Landing Page (RegExp)", "CSS, JS, Font"])).to.equal(
|
|
19
|
+
expect(await runCheck(["HTML", "Landing Page (RegExp)", "CSS, JS, Font"])).to.deep.equal({ success: true });
|
|
27
20
|
});
|
|
28
21
|
it("reports jobs that are missing entirely", async () => {
|
|
29
|
-
const
|
|
30
|
-
expect(
|
|
31
|
-
expect(error
|
|
22
|
+
const result = await runCheck(["HTML", "Images"]);
|
|
23
|
+
expect(result.success).to.equal(false);
|
|
24
|
+
expect(result.error).to.equal("Missing required jobs: Landing Page, CSS, JS, Font");
|
|
32
25
|
});
|
|
33
26
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import DeployService from "../deploy-service.js";
|
|
4
|
+
const fileList = {
|
|
5
|
+
filter: () => undefined,
|
|
6
|
+
getTypes: () => [],
|
|
7
|
+
getCustomerConfig: () => ({ config: { app: "app", name: "production" } }),
|
|
8
|
+
};
|
|
9
|
+
function recordingCli(warnings) {
|
|
10
|
+
return {
|
|
11
|
+
spacer: () => undefined,
|
|
12
|
+
write: () => undefined,
|
|
13
|
+
comment: () => undefined,
|
|
14
|
+
writeWarning: (message) => warnings.push(message),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function check(run) {
|
|
18
|
+
return { check: run };
|
|
19
|
+
}
|
|
20
|
+
function deploy(warnings, postDeployChecks) {
|
|
21
|
+
return new DeployService(fileList, [], recordingCli(warnings), [], postDeployChecks).run();
|
|
22
|
+
}
|
|
23
|
+
describe("DeployService", () => {
|
|
24
|
+
it("runs every post-deploy check and reports the failed ones after", async () => {
|
|
25
|
+
const warnings = [];
|
|
26
|
+
let laterCheckRan = false;
|
|
27
|
+
await deploy(warnings, [
|
|
28
|
+
check(async () => ({
|
|
29
|
+
success: false,
|
|
30
|
+
error: "Missing required jobs: HTML",
|
|
31
|
+
suggestions: ["create them", "or not"],
|
|
32
|
+
})),
|
|
33
|
+
check(async () => {
|
|
34
|
+
laterCheckRan = true;
|
|
35
|
+
return { success: true };
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
expect(laterCheckRan).to.equal(true);
|
|
39
|
+
expect(warnings).to.deep.equal([
|
|
40
|
+
"1 post-deploy check(s) failed:",
|
|
41
|
+
"› Missing required jobs: HTML\n Try this:\n * create them\n * or not",
|
|
42
|
+
]);
|
|
43
|
+
});
|
|
44
|
+
it("stays quiet when every post-deploy check passes", async () => {
|
|
45
|
+
const warnings = [];
|
|
46
|
+
await deploy(warnings, [check(async () => ({ success: true }))]);
|
|
47
|
+
expect(warnings).to.deep.equal([]);
|
|
48
|
+
});
|
|
49
|
+
it("lets an error thrown by a post-deploy check fail the deploy", async () => {
|
|
50
|
+
const failure = new Error("could not reach the app");
|
|
51
|
+
let laterCheckRan = false;
|
|
52
|
+
const error = await deploy([], [
|
|
53
|
+
check(async () => {
|
|
54
|
+
throw failure;
|
|
55
|
+
}),
|
|
56
|
+
check(async () => {
|
|
57
|
+
laterCheckRan = true;
|
|
58
|
+
return { success: true };
|
|
59
|
+
}),
|
|
60
|
+
]).catch((e) => e);
|
|
61
|
+
expect(error).to.equal(failure);
|
|
62
|
+
expect(laterCheckRan).to.equal(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -26,8 +26,6 @@ const NOT_IN_A_MERGE_REQUEST = [
|
|
|
26
26
|
DeployQuestion.SplitChange,
|
|
27
27
|
DeployQuestion.DeviceDetectionChange,
|
|
28
28
|
DeployQuestion.SaveLocalFiles,
|
|
29
|
-
DeployQuestion.DeleteDeprecatedJob,
|
|
30
|
-
DeployQuestion.DeleteDeprecatedModule,
|
|
31
29
|
];
|
|
32
30
|
function policy(approval) {
|
|
33
31
|
return new AutoDeployPolicy("!42 a reviewed change", approval);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
2
|
-
import { FileListInterface } from "../../../integration-api/index.js";
|
|
3
|
-
import { CliServiceInterface } from "../../../cli/index.js";
|
|
4
|
-
import { ConfigApiService } from "../../../config-api/index.js";
|
|
5
|
-
import { DeployPolicyInterface } from "../../policy/index.js";
|
|
6
|
-
export declare class DeprecatedDeploymentDetectionCheck implements PostDeployCheckInterface {
|
|
7
|
-
private fileList;
|
|
8
|
-
private cli;
|
|
9
|
-
private configApi;
|
|
10
|
-
private app;
|
|
11
|
-
private policy;
|
|
12
|
-
constructor(fileList: FileListInterface, cli: CliServiceInterface, configApi: ConfigApiService, app: string, policy: DeployPolicyInterface);
|
|
13
|
-
check(): Promise<void>;
|
|
14
|
-
private deleteDeploymentJobDefinition;
|
|
15
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { INTEGRATION_FILES } from "../../../../models/files.js";
|
|
2
|
-
import { safe } from "../../../../helpers/safe.js";
|
|
3
|
-
import { PostDeployDeploymentDetectionError } from "../../error/post-deploy-deployment-detection-error.js";
|
|
4
|
-
import { DeployQuestion } from "../../policy/index.js";
|
|
5
|
-
export class DeprecatedDeploymentDetectionCheck {
|
|
6
|
-
fileList;
|
|
7
|
-
cli;
|
|
8
|
-
configApi;
|
|
9
|
-
app;
|
|
10
|
-
policy;
|
|
11
|
-
constructor(fileList, cli, configApi, app, policy) {
|
|
12
|
-
this.fileList = fileList;
|
|
13
|
-
this.cli = cli;
|
|
14
|
-
this.configApi = configApi;
|
|
15
|
-
this.app = app;
|
|
16
|
-
this.policy = policy;
|
|
17
|
-
}
|
|
18
|
-
async check() {
|
|
19
|
-
this.cli.startAction("POST:CHECK:DEPLOYMENT_DETECTION", "[postDeployCheck] deploymentDetection");
|
|
20
|
-
const configFile = this.fileList.getByName(INTEGRATION_FILES.CONFIG.DOCUMENT_HANDLER);
|
|
21
|
-
const moduleFile = this.fileList.getByName(INTEGRATION_FILES.DEPRECATED.DEPLOYMENT_DETECTION);
|
|
22
|
-
// no config_documentHandler or module: deploymentDetection found
|
|
23
|
-
if (!configFile || moduleFile) {
|
|
24
|
-
this.cli.successAction("POST:CHECK:DEPLOYMENT_DETECTION");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const content = configFile.getContent();
|
|
28
|
-
if (!content.includes("executeDeploymentDetection: true") &&
|
|
29
|
-
!content.includes("executeDeploymentDetection: {")) {
|
|
30
|
-
this.cli.successAction("POST:CHECK:DEPLOYMENT_DETECTION");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const entityManager = await this.configApi.client.getEntityManager();
|
|
34
|
-
const deployCheckJob = await entityManager["jobs.Definition"]
|
|
35
|
-
.find()
|
|
36
|
-
.eq("id", "/db/jobs.Definition/deployment-check")
|
|
37
|
-
.singleResult();
|
|
38
|
-
const moduleResult = await safe(this.configApi.getModule(INTEGRATION_FILES.DEPRECATED.DEPLOYMENT_DETECTION));
|
|
39
|
-
this.cli.successAction("POST:CHECK:DEPLOYMENT_DETECTION");
|
|
40
|
-
if (deployCheckJob) {
|
|
41
|
-
this.cli.writeWarning(`Found active Job for ${this.cli.style.bold("deprecated")} deploymentDetection in app: ${this.app}`);
|
|
42
|
-
if (await this.policy.confirm(DeployQuestion.DeleteDeprecatedJob, "Delete job for deploymentDetection?")) {
|
|
43
|
-
await this.deleteDeploymentJobDefinition(deployCheckJob);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (moduleResult.success &&
|
|
47
|
-
moduleResult.data &&
|
|
48
|
-
moduleResult.data.length > 0) {
|
|
49
|
-
this.cli.writeWarning(`Found ${this.cli.style.bold("deprecated")} module deploymentDetection in app: ${this.app}`);
|
|
50
|
-
if (await this.policy.confirm(DeployQuestion.DeleteDeprecatedModule, "Delete module deploymentDetection?")) {
|
|
51
|
-
this.cli.startAction("POST:CHECK:DEPLOYMENT_DETECTION:DELETE", "Delete module deploymentDetection");
|
|
52
|
-
await this.configApi.deleteModule(INTEGRATION_FILES.DEPRECATED.DEPLOYMENT_DETECTION);
|
|
53
|
-
this.cli.successAction("POST:CHECK:DEPLOYMENT_DETECTION:DELETE");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async deleteDeploymentJobDefinition(deployCheckJob) {
|
|
58
|
-
this.cli.startAction("POST:CHECK:DEPLOYMENT_DETECTION:DELETE_CRON", "Delete job deploymentDetection-check");
|
|
59
|
-
const result = await safe(deployCheckJob.delete());
|
|
60
|
-
if (result.success === true) {
|
|
61
|
-
this.cli.successAction("POST:CHECK:DEPLOYMENT_DETECTION:DELETE_CRON");
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.cli.failAction("POST:CHECK:DEPLOYMENT_DETECTION:DELETE_CRON");
|
|
65
|
-
throw new PostDeployDeploymentDetectionError(result.error, [
|
|
66
|
-
`check https://dashboard.baqend.com/app/${this.app}/db/jobs.Definition`,
|
|
67
|
-
"delete entry manual",
|
|
68
|
-
]);
|
|
69
|
-
}
|
|
70
|
-
}
|