@speedkit/cli 4.43.0-beta.1 → 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.
Files changed (109) hide show
  1. package/CHANGELOG.md +9 -2
  2. package/README.md +12 -2
  3. package/dist/commands/onboarding.d.ts +3 -0
  4. package/dist/commands/onboarding.js +7 -1
  5. package/dist/models/files.d.ts +0 -1
  6. package/dist/models/files.js +0 -1
  7. package/dist/services/bundler/bundle-service-factory.d.ts +1 -6
  8. package/dist/services/bundler/bundle-service-factory.js +2 -9
  9. package/dist/services/bundler/bundle-service.d.ts +1 -10
  10. package/dist/services/bundler/bundle-service.js +1 -16
  11. package/dist/services/bundler/index.d.ts +0 -1
  12. package/dist/services/bundler/index.js +0 -1
  13. package/dist/services/cli/cli-environment.js +0 -1
  14. package/dist/services/cli/cli-settings.d.ts +0 -5
  15. package/dist/services/cli/cli-settings.js +0 -1
  16. package/dist/services/deploy/checks/activation/customer-approval-check.js +1 -1
  17. package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.d.ts +2 -2
  18. package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.js +8 -7
  19. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.d.ts +2 -2
  20. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +11 -7
  21. package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +2 -2
  22. package/dist/services/deploy/checks/post-deploy/save-files-check.js +3 -2
  23. package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +3 -2
  24. package/dist/services/deploy/checks/pre-deploy/split-change-check.js +3 -2
  25. package/dist/services/deploy/deploy-service-factory.js +1 -3
  26. package/dist/services/deploy/deploy-service-model.d.ts +11 -1
  27. package/dist/services/deploy/deploy-service.d.ts +2 -0
  28. package/dist/services/deploy/deploy-service.js +26 -1
  29. package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +1 -1
  30. package/dist/services/deploy/policy/deploy-policy-model.d.ts +1 -5
  31. package/dist/services/deploy/policy/deploy-policy-model.js +0 -4
  32. package/dist/services/deploy/spec/checks/post-deploy/refresh-deployment-job-check.spec.js +5 -12
  33. package/dist/services/deploy/spec/deploy-service.spec.js +64 -0
  34. package/dist/services/deploy/spec/policy/auto-deploy-policy.spec.js +0 -2
  35. package/dist/services/document-handler-runtime/document-handler-runtime-model.d.ts +0 -2
  36. package/dist/services/document-handler-runtime/document-handler-runtime-model.js +0 -2
  37. package/dist/services/document-handler-runtime/document-handler-server.d.ts +0 -17
  38. package/dist/services/document-handler-runtime/document-handler-server.js +20 -82
  39. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +1 -1
  40. package/dist/services/integration-api/integration-api-factory.js +1 -1
  41. package/dist/services/integration-api/integration-api-model.d.ts +1 -2
  42. package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +8 -70
  43. package/dist/services/integration-api/struct/customer-config.d.ts +1 -19
  44. package/dist/services/integration-api/struct/customer-config.js +3 -11
  45. package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +4 -9
  46. package/dist/services/integration-api/struct/speed-kit-config-file.js +10 -30
  47. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +8 -24
  48. package/dist/services/onboarding/error/inject-installation-error.d.ts +6 -0
  49. package/dist/services/onboarding/error/inject-installation-error.js +11 -0
  50. package/dist/services/onboarding/error/inject-target-error.d.ts +6 -0
  51. package/dist/services/onboarding/error/inject-target-error.js +11 -0
  52. package/dist/services/onboarding/error/missing-customer-path-error.d.ts +1 -1
  53. package/dist/services/onboarding/error/missing-customer-path-error.js +2 -1
  54. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +4 -14
  55. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +6 -45
  56. package/dist/services/onboarding/fetch-events/document-rewrite.d.ts +19 -0
  57. package/dist/services/onboarding/fetch-events/document-rewrite.js +47 -0
  58. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +5 -1
  59. package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +7 -2
  60. package/dist/services/onboarding/html-rewrites.d.ts +3 -3
  61. package/dist/services/onboarding/html-rewrites.js +3 -3
  62. package/dist/services/onboarding/index.d.ts +1 -1
  63. package/dist/services/onboarding/index.js +1 -1
  64. package/dist/services/onboarding/inject/content-security-policy.d.ts +14 -0
  65. package/dist/services/onboarding/inject/content-security-policy.js +54 -0
  66. package/dist/services/onboarding/inject/deployed-installation.d.ts +15 -0
  67. package/dist/services/onboarding/inject/deployed-installation.js +32 -0
  68. package/dist/services/onboarding/inject/foreign-install-request.d.ts +27 -0
  69. package/dist/services/onboarding/inject/foreign-install-request.js +50 -0
  70. package/dist/services/onboarding/inject/inject-document-rewrite.d.ts +23 -0
  71. package/dist/services/onboarding/inject/inject-document-rewrite.js +52 -0
  72. package/dist/services/onboarding/inject/inject-service.d.ts +32 -0
  73. package/dist/services/onboarding/inject/inject-service.js +72 -0
  74. package/dist/services/onboarding/inject/injected-installation.d.ts +29 -0
  75. package/dist/services/onboarding/inject/injected-installation.js +37 -0
  76. package/dist/services/onboarding/onboarding-service-build-context.d.ts +15 -1
  77. package/dist/services/onboarding/onboarding-service-build-context.js +31 -2
  78. package/dist/services/onboarding/onboarding-service-factory.d.ts +23 -5
  79. package/dist/services/onboarding/onboarding-service-factory.js +87 -7
  80. package/dist/services/onboarding/spec/inject/content-security-policy.spec.d.ts +1 -0
  81. package/dist/services/onboarding/spec/inject/content-security-policy.spec.js +47 -0
  82. package/dist/services/onboarding/spec/inject/deployed-installation.spec.d.ts +1 -0
  83. package/dist/services/onboarding/spec/inject/deployed-installation.spec.js +49 -0
  84. package/dist/services/onboarding/spec/inject/foreign-install-request.spec.d.ts +1 -0
  85. package/dist/services/onboarding/spec/inject/foreign-install-request.spec.js +47 -0
  86. package/dist/services/onboarding/spec/inject/inject-document-rewrite.spec.d.ts +1 -0
  87. package/dist/services/onboarding/spec/inject/inject-document-rewrite.spec.js +66 -0
  88. package/dist/services/onboarding/spec/inject/injected-installation.spec.d.ts +1 -0
  89. package/dist/services/onboarding/spec/inject/injected-installation.spec.js +24 -0
  90. package/dist/services/onboarding/spec/onboarding-service-build-context.spec.d.ts +1 -0
  91. package/dist/services/onboarding/spec/onboarding-service-build-context.spec.js +22 -0
  92. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +53 -2
  93. package/dist/services/onboarding/templates/install-speed-kit-html-template.js +3 -0
  94. package/dist/services/onboarding/templates/install-speed-kit-js-template.js +0 -5
  95. package/dist/services/query-builder/query-builder-factory.js +3 -3
  96. package/oclif.manifest.json +26 -3
  97. package/package.json +1 -2
  98. package/dist/services/bundler/error/packjockel-error.d.ts +0 -3
  99. package/dist/services/bundler/error/packjockel-error.js +0 -3
  100. package/dist/services/bundler/packjockel-service.d.ts +0 -70
  101. package/dist/services/bundler/packjockel-service.js +0 -171
  102. package/dist/services/bundler/spec/packjockel-service.spec.js +0 -149
  103. package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.d.ts +0 -15
  104. package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.js +0 -70
  105. package/dist/services/deploy/error/check-module-file-error.d.ts +0 -4
  106. package/dist/services/deploy/error/check-module-file-error.js +0 -4
  107. package/dist/services/deploy/error/post-deploy-deployment-detection-error.d.ts +0 -4
  108. package/dist/services/deploy/error/post-deploy-deployment-detection-error.js +0 -4
  109. /package/dist/services/{bundler/spec/packjockel-service.spec.d.ts → deploy/spec/deploy-service.spec.d.ts} +0 -0
@@ -1,149 +0,0 @@
1
- import { expect } from "chai";
2
- import { afterEach, beforeEach, describe, it } from "mocha";
3
- import { chmod, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
4
- import { tmpdir } from "node:os";
5
- import { join } from "node:path";
6
- import { PackjockelService, resolvePackjockelBinary, speedKitConfigBasePath, } from "../packjockel-service.js";
7
- import { PackjockelError } from "../error/packjockel-error.js";
8
- /**
9
- * A packjockel stand-in: it records its arguments and the content of every `file://` input,
10
- * and writes a fixed bundle to `--output`.
11
- */
12
- const FAKE_PACKJOCKEL = `#!/bin/sh
13
- out=""
14
- for arg in "$@"; do
15
- echo "$arg" >> "$RECORD_DIR/args"
16
- case "$arg" in
17
- --output=*) out="\${arg#--output=}" ;;
18
- esac
19
- path=$(echo "$arg" | sed -n 's|.*file://||p')
20
- if [ -n "$path" ]; then
21
- echo "$(basename "$path"): $(cat "$path")" >> "$RECORD_DIR/inputs"
22
- fi
23
- done
24
- if [ -n "$FAIL" ]; then
25
- echo "time=\\"2026\\" level=info msg=starting" >&2
26
- echo "invalid bundle: could not resolve x" >&2
27
- exit 1
28
- fi
29
- echo "bundled" > "$out"
30
- `;
31
- describe("PackjockelService", () => {
32
- let directory;
33
- let service;
34
- beforeEach(async () => {
35
- directory = await mkdtemp(join(tmpdir(), "packjockel-spec-"));
36
- const binary = join(directory, "packjockel");
37
- await writeFile(binary, FAKE_PACKJOCKEL);
38
- await chmod(binary, 0o755);
39
- process.env.RECORD_DIR = directory;
40
- service = new PackjockelService(binary);
41
- });
42
- afterEach(async () => {
43
- delete process.env.RECORD_DIR;
44
- delete process.env.FAIL;
45
- await rm(directory, { recursive: true, force: true });
46
- });
47
- async function recorded() {
48
- const args = (await readFile(join(directory, "args"), "utf8"))
49
- .trim()
50
- .split("\n");
51
- const inputs = (await readFile(join(directory, "inputs"), "utf8"))
52
- .trim()
53
- .split("\n");
54
- return { args, inputs };
55
- }
56
- it("should bundle the entry points in their order", async () => {
57
- const bundle = await service.bundle({
58
- entryPoints: { "rum.js": "rum()", "config.js": "SpeedKit.config = {}" },
59
- basePaths: {
60
- "speed-kit-config": "https://cdn/speed-kit-config/release/",
61
- },
62
- define: { APP: '"shop"' },
63
- platform: "browser",
64
- });
65
- const { args, inputs } = await recorded();
66
- expect(bundle.trim()).to.equal("bundled");
67
- expect(args.slice(0, 5)).to.deep.equal([
68
- "bundle",
69
- "--bundle",
70
- "--platform=browser",
71
- "--target=es5",
72
- '--define=APP="shop"',
73
- ]);
74
- expect(args).to.include("--base-path=speed-kit-config=https://cdn/speed-kit-config/release/");
75
- expect(args).to.include("--embedded");
76
- expect(inputs).to.deep.equal([
77
- "rum.js: rum()",
78
- "config.js: SpeedKit.config = {}",
79
- ]);
80
- });
81
- it("should bundle a document handler with every input it got", async () => {
82
- await service.bundleDocumentHandler({
83
- documentHandler: "var DocumentHandler = 1",
84
- documentHandlerConfig: "export default new DocumentHandler()",
85
- speedKitConfig: "SpeedKit.config = {}",
86
- appName: "shop",
87
- dynamicFetcherConfig: "window.dynamicBlockConfig = {}",
88
- });
89
- const { args, inputs } = await recorded();
90
- expect(args.slice(0, 2)).to.deep.equal(["bundle", "document-handler"]);
91
- expect(args).to.include("--app-name=shop");
92
- expect(args.some((arg) => arg.startsWith("--dynamic-fetcher="))).to.equal(false);
93
- expect(inputs).to.deep.equal([
94
- "DocumentHandler.js: var DocumentHandler = 1",
95
- "documentHandlerConfig.js: export default new DocumentHandler()",
96
- "speedKitConfig.js: SpeedKit.config = {}",
97
- "dynamicFetcherConfig.js: window.dynamicBlockConfig = {}",
98
- ]);
99
- });
100
- it("should report the error of packjockel without its log lines", async () => {
101
- process.env.FAIL = "1";
102
- const failure = await service
103
- .bundle({ entryPoints: { "config.js": "x" } })
104
- .catch((error) => error);
105
- expect(failure).to.be.instanceOf(PackjockelError);
106
- expect(failure.message).to.equal("packjockel failed: invalid bundle: could not resolve x");
107
- });
108
- it("should say how to set the binary when it is missing", async () => {
109
- const failure = await new PackjockelService(join(directory, "missing"))
110
- .bundle({ entryPoints: { "config.js": "x" } })
111
- .catch((error) => error);
112
- expect(failure).to.be.instanceOf(PackjockelError);
113
- expect(failure.message).to.contain("PACKJOCKEL_PATH");
114
- });
115
- });
116
- describe("speedKitConfigBasePath", () => {
117
- it("should use the release channel by default", () => {
118
- expect(speedKitConfigBasePath()).to.equal("https://www.baqend.com/speed-kit-config/release/");
119
- });
120
- it("should read a channel with or without its @", () => {
121
- expect(speedKitConfigBasePath("@latest")).to.equal("https://www.baqend.com/speed-kit-config/latest/");
122
- expect(speedKitConfigBasePath("latest")).to.equal("https://www.baqend.com/speed-kit-config/latest/");
123
- });
124
- it("should read a version", () => {
125
- expect(speedKitConfigBasePath("1.8.0")).to.equal("https://www.baqend.com/speed-kit-config/1.8.0/");
126
- });
127
- });
128
- describe("resolvePackjockelBinary", () => {
129
- const executable = process.platform === "win32" ? "packjockel.exe" : "packjockel";
130
- it("should use the configured binary", () => {
131
- expect(resolvePackjockelBinary("/opt/packjockel")).to.equal("/opt/packjockel");
132
- });
133
- it("should use the binary of the platform package", () => {
134
- const requests = [];
135
- const binary = resolvePackjockelBinary("", (request) => {
136
- requests.push(request);
137
- return `/node_modules/${request}`;
138
- });
139
- const request = `@speedkit/packjockel-${process.platform}-${process.arch}/bin/${executable}`;
140
- expect(requests).to.deep.equal([request]);
141
- expect(binary).to.equal(`/node_modules/${request}`);
142
- });
143
- it("should fall back to the PATH without the package", () => {
144
- const binary = resolvePackjockelBinary("", () => {
145
- throw new Error("Cannot find module");
146
- });
147
- expect(binary).to.equal("packjockel");
148
- });
149
- });
@@ -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
- }
@@ -1,4 +0,0 @@
1
- import ApplicationError from "../../error-handling/error/application-error.js";
2
- export declare class CheckModuleFileError extends ApplicationError {
3
- readonly code = "CHECK_MODULE_ERROR";
4
- }
@@ -1,4 +0,0 @@
1
- import ApplicationError from "../../error-handling/error/application-error.js";
2
- export class CheckModuleFileError extends ApplicationError {
3
- code = "CHECK_MODULE_ERROR";
4
- }
@@ -1,4 +0,0 @@
1
- import ApplicationError from "../../error-handling/error/application-error.js";
2
- export declare class PostDeployDeploymentDetectionError extends ApplicationError {
3
- readonly code = "POST_DEPLOY";
4
- }
@@ -1,4 +0,0 @@
1
- import ApplicationError from "../../error-handling/error/application-error.js";
2
- export class PostDeployDeploymentDetectionError extends ApplicationError {
3
- code = "POST_DEPLOY";
4
- }