@speedkit/cli 4.42.0 → 4.43.0-beta.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/services/bundler/bundle-service-factory.d.ts +6 -1
- package/dist/services/bundler/bundle-service-factory.js +9 -2
- package/dist/services/bundler/bundle-service.d.ts +10 -1
- package/dist/services/bundler/bundle-service.js +16 -1
- package/dist/services/bundler/error/packjockel-error.d.ts +3 -0
- package/dist/services/bundler/error/packjockel-error.js +3 -0
- package/dist/services/bundler/index.d.ts +1 -0
- package/dist/services/bundler/index.js +1 -0
- package/dist/services/bundler/packjockel-service.d.ts +70 -0
- package/dist/services/bundler/packjockel-service.js +171 -0
- package/dist/services/bundler/spec/packjockel-service.spec.d.ts +1 -0
- package/dist/services/bundler/spec/packjockel-service.spec.js +149 -0
- package/dist/services/cli/cli-environment.js +1 -0
- package/dist/services/cli/cli-settings.d.ts +5 -0
- package/dist/services/cli/cli-settings.js +1 -0
- package/dist/services/deploy/checks/activation/customer-approval-check.js +1 -1
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +2 -3
- package/dist/services/deploy/checks/pre-deploy/split-change-check.js +2 -3
- package/dist/services/deploy/deploy-service-factory.js +1 -1
- package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +1 -1
- package/dist/services/document-handler-runtime/document-handler-runtime-model.d.ts +2 -0
- package/dist/services/document-handler-runtime/document-handler-runtime-model.js +2 -0
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +17 -0
- package/dist/services/document-handler-runtime/document-handler-server.js +82 -20
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +1 -1
- package/dist/services/integration-api/integration-api-factory.js +1 -1
- package/dist/services/integration-api/integration-api-model.d.ts +2 -1
- package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +70 -8
- package/dist/services/integration-api/struct/customer-config.d.ts +19 -1
- package/dist/services/integration-api/struct/customer-config.js +11 -3
- package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +9 -4
- package/dist/services/integration-api/struct/speed-kit-config-file.js +30 -10
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +24 -8
- package/dist/services/onboarding/onboarding-service-factory.js +1 -1
- package/dist/services/onboarding/templates/install-speed-kit-js-template.js +5 -0
- package/dist/services/query-builder/query-builder-factory.js +3 -3
- package/oclif.manifest.json +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [4.43.0-beta.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.42.0...v4.43.0-beta.1) (2026-10-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* bundle with packjockel for customers with the configPlugins feature ([32e7ce6](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/32e7ce69a51b7501e32a65e4f38773daffc58a03))
|
|
7
|
+
|
|
1
8
|
# [4.42.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.41.2...v4.42.0) (2026-10-07)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { BundleService } from "./bundle-service.js";
|
|
2
2
|
export declare class BundleServiceFactory {
|
|
3
3
|
private customerFolder?;
|
|
4
|
-
|
|
4
|
+
private packjockelPath;
|
|
5
|
+
/**
|
|
6
|
+
* @param customerFolder the directory bundled code resolves its own imports from
|
|
7
|
+
* @param packjockelPath the `PACKJOCKEL_PATH` setting; empty means the installed npm package
|
|
8
|
+
*/
|
|
9
|
+
constructor(customerFolder?: string, packjockelPath?: string);
|
|
5
10
|
buildService(): BundleService;
|
|
6
11
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { BundleService } from "./bundle-service.js";
|
|
2
|
+
import { PackjockelService, resolvePackjockelBinary, } from "./packjockel-service.js";
|
|
2
3
|
export class BundleServiceFactory {
|
|
3
4
|
customerFolder;
|
|
4
|
-
|
|
5
|
+
packjockelPath;
|
|
6
|
+
/**
|
|
7
|
+
* @param customerFolder the directory bundled code resolves its own imports from
|
|
8
|
+
* @param packjockelPath the `PACKJOCKEL_PATH` setting; empty means the installed npm package
|
|
9
|
+
*/
|
|
10
|
+
constructor(customerFolder, packjockelPath = "") {
|
|
5
11
|
this.customerFolder = customerFolder;
|
|
12
|
+
this.packjockelPath = packjockelPath;
|
|
6
13
|
}
|
|
7
14
|
buildService() {
|
|
8
|
-
return new BundleService(this.customerFolder);
|
|
15
|
+
return new BundleService(this.customerFolder, new PackjockelService(resolvePackjockelBinary(this.packjockelPath)));
|
|
9
16
|
}
|
|
10
17
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PluginBuild, LogLevel } from "esbuild";
|
|
2
|
+
import type { PackjockelService } from "./packjockel-service.js";
|
|
2
3
|
export type BundleEntryPoints = Record<string, string>;
|
|
3
4
|
export type BundleBasePaths = Record<string, string>;
|
|
4
5
|
/**
|
|
@@ -8,10 +9,18 @@ export type BundleBasePaths = Record<string, string>;
|
|
|
8
9
|
export type BundleResolveFallback = (specifier: string) => Promise<string | null>;
|
|
9
10
|
export declare class BundleService {
|
|
10
11
|
private moduleDiscoveryDir;
|
|
12
|
+
private readonly packjockelService?;
|
|
11
13
|
/**
|
|
12
14
|
* @param moduleDiscoveryDir the directory bundled code resolves its own imports from
|
|
15
|
+
* @param packjockelService bundles instead of esbuild for customers with the `configPlugins` feature
|
|
13
16
|
*/
|
|
14
|
-
constructor(moduleDiscoveryDir: string);
|
|
17
|
+
constructor(moduleDiscoveryDir: string, packjockelService?: PackjockelService);
|
|
18
|
+
/**
|
|
19
|
+
* The packjockel bundler for customers with the `configPlugins` feature.
|
|
20
|
+
*
|
|
21
|
+
* @throws ApplicationError when the service was built without one
|
|
22
|
+
*/
|
|
23
|
+
get packjockel(): PackjockelService;
|
|
15
24
|
bundle({ entryPoints, basePaths, define, target, minify, logLevel, alias, platform, resolveFallback, packages, }: {
|
|
16
25
|
entryPoints: BundleEntryPoints;
|
|
17
26
|
basePaths?: BundleBasePaths;
|
|
@@ -4,16 +4,31 @@ import { URL } from "node:url";
|
|
|
4
4
|
import { BundleResolveError } from "./error/bundle-resolve-error.js";
|
|
5
5
|
import { BundleFetchError } from "./error/bundle-fetch-error.js";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
|
+
import ApplicationError from "../error-handling/error/application-error.js";
|
|
7
8
|
const FALLBACK_NAMESPACE = "bundle-resolve-fallback";
|
|
8
9
|
const RELATIVE_SPECIFIER = /^\.{1,2}\//;
|
|
9
10
|
const importCache = {};
|
|
10
11
|
export class BundleService {
|
|
11
12
|
moduleDiscoveryDir;
|
|
13
|
+
packjockelService;
|
|
12
14
|
/**
|
|
13
15
|
* @param moduleDiscoveryDir the directory bundled code resolves its own imports from
|
|
16
|
+
* @param packjockelService bundles instead of esbuild for customers with the `configPlugins` feature
|
|
14
17
|
*/
|
|
15
|
-
constructor(moduleDiscoveryDir) {
|
|
18
|
+
constructor(moduleDiscoveryDir, packjockelService) {
|
|
16
19
|
this.moduleDiscoveryDir = moduleDiscoveryDir;
|
|
20
|
+
this.packjockelService = packjockelService;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The packjockel bundler for customers with the `configPlugins` feature.
|
|
24
|
+
*
|
|
25
|
+
* @throws ApplicationError when the service was built without one
|
|
26
|
+
*/
|
|
27
|
+
get packjockel() {
|
|
28
|
+
if (!this.packjockelService) {
|
|
29
|
+
throw new ApplicationError("This bundler has no packjockel");
|
|
30
|
+
}
|
|
31
|
+
return this.packjockelService;
|
|
17
32
|
}
|
|
18
33
|
async bundle({ entryPoints, basePaths, define, target = "es5", minify = true, logLevel = "silent", alias = {}, platform, resolveFallback, packages = "bundle", }) {
|
|
19
34
|
const plugins = [];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The packjockel binary to run.
|
|
3
|
+
*
|
|
4
|
+
* `@speedkit/packjockel` installs one package per platform, `@speedkit/packjockel-<platform>-<arch>`.
|
|
5
|
+
* The CLI runs its binary directly, not the `bin` script of the meta package, which would start a
|
|
6
|
+
* second node process for every bundle.
|
|
7
|
+
*
|
|
8
|
+
* @param configured the `PACKJOCKEL_PATH` setting; empty means the npm package, else the `PATH`
|
|
9
|
+
* @param resolve resolves a module path, for tests
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolvePackjockelBinary(configured: string, resolve?: (request: string) => string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The base path of the `speed-kit-config` imports for a pinned plugin release.
|
|
14
|
+
*
|
|
15
|
+
* @param configPluginsVersion a version such as `1.8.0`, or a channel such as `@release`;
|
|
16
|
+
* empty means the `release` channel
|
|
17
|
+
*/
|
|
18
|
+
export declare function speedKitConfigBasePath(configPluginsVersion?: string): string;
|
|
19
|
+
export interface PackjockelBundleRequest {
|
|
20
|
+
/** The entry points by file name, in output order. */
|
|
21
|
+
entryPoints: Record<string, string>;
|
|
22
|
+
basePaths?: Record<string, string>;
|
|
23
|
+
define?: Record<string, string>;
|
|
24
|
+
platform?: "browser" | "node";
|
|
25
|
+
target?: "es5" | "es6";
|
|
26
|
+
minify?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface PackjockelDocumentHandlerRequest {
|
|
29
|
+
documentHandler: string;
|
|
30
|
+
documentHandlerConfig: string;
|
|
31
|
+
speedKitConfig: string;
|
|
32
|
+
appName: string;
|
|
33
|
+
dynamicFetcher?: string;
|
|
34
|
+
dynamicFetcherConfig?: string;
|
|
35
|
+
customStyle?: string;
|
|
36
|
+
basePaths?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Bundles with the packjockel binary in embedded mode, so no packjockel server is needed.
|
|
40
|
+
*
|
|
41
|
+
* Every input goes to the binary as a file, because a document handler is too large for one
|
|
42
|
+
* command line argument.
|
|
43
|
+
*/
|
|
44
|
+
export declare class PackjockelService {
|
|
45
|
+
private readonly binaryPath;
|
|
46
|
+
/**
|
|
47
|
+
* @param binaryPath the packjockel binary, a path or a command on the `PATH`
|
|
48
|
+
*/
|
|
49
|
+
constructor(binaryPath: string);
|
|
50
|
+
/**
|
|
51
|
+
* Bundles the entry points in their order into one script. packjockel puts a script before them
|
|
52
|
+
* which exposes the `SpeedKit` global.
|
|
53
|
+
*
|
|
54
|
+
* @returns the bundled code
|
|
55
|
+
*/
|
|
56
|
+
bundle(request: PackjockelBundleRequest): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Bundles a document handler with its config, the embedded Speed Kit config and the default `post`.
|
|
59
|
+
*
|
|
60
|
+
* @returns the code of one CommonJS module, which exports `post`
|
|
61
|
+
*/
|
|
62
|
+
bundleDocumentHandler(request: PackjockelDocumentHandlerRequest): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Runs packjockel in a scratch directory, which is removed afterwards.
|
|
65
|
+
*
|
|
66
|
+
* @param buildArgs writes the inputs into the directory and returns the arguments that read them
|
|
67
|
+
*/
|
|
68
|
+
private run;
|
|
69
|
+
private execute;
|
|
70
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import { PackjockelError } from "./error/packjockel-error.js";
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
/** The binary on the `PATH`, when no npm package of packjockel is installed. */
|
|
10
|
+
const PACKJOCKEL_ON_PATH = "packjockel";
|
|
11
|
+
/**
|
|
12
|
+
* The packjockel binary to run.
|
|
13
|
+
*
|
|
14
|
+
* `@speedkit/packjockel` installs one package per platform, `@speedkit/packjockel-<platform>-<arch>`.
|
|
15
|
+
* The CLI runs its binary directly, not the `bin` script of the meta package, which would start a
|
|
16
|
+
* second node process for every bundle.
|
|
17
|
+
*
|
|
18
|
+
* @param configured the `PACKJOCKEL_PATH` setting; empty means the npm package, else the `PATH`
|
|
19
|
+
* @param resolve resolves a module path, for tests
|
|
20
|
+
*/
|
|
21
|
+
export function resolvePackjockelBinary(configured, resolve = createRequire(import.meta.url).resolve) {
|
|
22
|
+
if (configured) {
|
|
23
|
+
return configured;
|
|
24
|
+
}
|
|
25
|
+
const executable = process.platform === "win32" ? "packjockel.exe" : "packjockel";
|
|
26
|
+
try {
|
|
27
|
+
return resolve(`@speedkit/packjockel-${process.platform}-${process.arch}/bin/${executable}`);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return PACKJOCKEL_ON_PATH;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Where speed-kit-config publishes its plugins, one folder per version and channel. */
|
|
34
|
+
const SPEED_KIT_CONFIG_URL = "https://www.baqend.com/speed-kit-config/";
|
|
35
|
+
/** The channel the plugins in the `export` format are published to. */
|
|
36
|
+
const DEFAULT_CONFIG_PLUGINS_CHANNEL = "release";
|
|
37
|
+
/**
|
|
38
|
+
* The base path of the `speed-kit-config` imports for a pinned plugin release.
|
|
39
|
+
*
|
|
40
|
+
* @param configPluginsVersion a version such as `1.8.0`, or a channel such as `@release`;
|
|
41
|
+
* empty means the `release` channel
|
|
42
|
+
*/
|
|
43
|
+
export function speedKitConfigBasePath(configPluginsVersion) {
|
|
44
|
+
const folder = configPluginsVersion?.trim().replace(/^@/, "") ||
|
|
45
|
+
DEFAULT_CONFIG_PLUGINS_CHANNEL;
|
|
46
|
+
return `${SPEED_KIT_CONFIG_URL}${folder}/`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Bundles with the packjockel binary in embedded mode, so no packjockel server is needed.
|
|
50
|
+
*
|
|
51
|
+
* Every input goes to the binary as a file, because a document handler is too large for one
|
|
52
|
+
* command line argument.
|
|
53
|
+
*/
|
|
54
|
+
export class PackjockelService {
|
|
55
|
+
binaryPath;
|
|
56
|
+
/**
|
|
57
|
+
* @param binaryPath the packjockel binary, a path or a command on the `PATH`
|
|
58
|
+
*/
|
|
59
|
+
constructor(binaryPath) {
|
|
60
|
+
this.binaryPath = binaryPath;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Bundles the entry points in their order into one script. packjockel puts a script before them
|
|
64
|
+
* which exposes the `SpeedKit` global.
|
|
65
|
+
*
|
|
66
|
+
* @returns the bundled code
|
|
67
|
+
*/
|
|
68
|
+
async bundle(request) {
|
|
69
|
+
return this.run(async (directory) => {
|
|
70
|
+
const args = [
|
|
71
|
+
"bundle",
|
|
72
|
+
"--bundle",
|
|
73
|
+
`--platform=${request.platform ?? "browser"}`,
|
|
74
|
+
`--target=${request.target ?? "es5"}`,
|
|
75
|
+
];
|
|
76
|
+
if (request.minify) {
|
|
77
|
+
args.push("--minify");
|
|
78
|
+
}
|
|
79
|
+
args.push(...keyValueFlags("--define", request.define));
|
|
80
|
+
for (const [name, code] of Object.entries(request.entryPoints)) {
|
|
81
|
+
args.push(await writeInput(directory, name, code));
|
|
82
|
+
}
|
|
83
|
+
return args;
|
|
84
|
+
}, request.basePaths);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Bundles a document handler with its config, the embedded Speed Kit config and the default `post`.
|
|
88
|
+
*
|
|
89
|
+
* @returns the code of one CommonJS module, which exports `post`
|
|
90
|
+
*/
|
|
91
|
+
async bundleDocumentHandler(request) {
|
|
92
|
+
return this.run(async (directory) => {
|
|
93
|
+
const args = [
|
|
94
|
+
"bundle",
|
|
95
|
+
"document-handler",
|
|
96
|
+
await writeInput(directory, "DocumentHandler.js", request.documentHandler),
|
|
97
|
+
`--document-handler-config=${await writeInput(directory, "documentHandlerConfig.js", request.documentHandlerConfig)}`,
|
|
98
|
+
`--speed-kit-config=${await writeInput(directory, "speedKitConfig.js", request.speedKitConfig)}`,
|
|
99
|
+
`--app-name=${request.appName}`,
|
|
100
|
+
];
|
|
101
|
+
const optional = {
|
|
102
|
+
"dynamic-fetcher": ["dynamicFetcher.js", request.dynamicFetcher],
|
|
103
|
+
"dynamic-fetcher-config": [
|
|
104
|
+
"dynamicFetcherConfig.js",
|
|
105
|
+
request.dynamicFetcherConfig,
|
|
106
|
+
],
|
|
107
|
+
"custom-style": ["customStyle.css", request.customStyle],
|
|
108
|
+
};
|
|
109
|
+
for (const [flag, [name, value]] of Object.entries(optional)) {
|
|
110
|
+
if (value) {
|
|
111
|
+
args.push(`--${flag}=${await writeInput(directory, name, value)}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return args;
|
|
115
|
+
}, request.basePaths);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Runs packjockel in a scratch directory, which is removed afterwards.
|
|
119
|
+
*
|
|
120
|
+
* @param buildArgs writes the inputs into the directory and returns the arguments that read them
|
|
121
|
+
*/
|
|
122
|
+
async run(buildArgs, basePaths = {}) {
|
|
123
|
+
const directory = await mkdtemp(join(tmpdir(), "sk-packjockel-"));
|
|
124
|
+
try {
|
|
125
|
+
const output = join(directory, "out.js");
|
|
126
|
+
const args = [
|
|
127
|
+
...(await buildArgs(directory)),
|
|
128
|
+
...keyValueFlags("--base-path", basePaths),
|
|
129
|
+
"--embedded",
|
|
130
|
+
`--output=${output}`,
|
|
131
|
+
];
|
|
132
|
+
await this.execute(args);
|
|
133
|
+
return await readFile(output, "utf8");
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
await rm(directory, { recursive: true, force: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async execute(args) {
|
|
140
|
+
try {
|
|
141
|
+
await execFileAsync(this.binaryPath, args, {
|
|
142
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
const failure = error;
|
|
147
|
+
if (failure.code === "ENOENT") {
|
|
148
|
+
throw new PackjockelError(`packjockel not found at "${this.binaryPath}". Install @speedkit/packjockel or set PACKJOCKEL_PATH to the packjockel binary.`);
|
|
149
|
+
}
|
|
150
|
+
throw new PackjockelError(`packjockel failed: ${withoutLogLines(failure.stderr) || failure.message}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Writes one input into the scratch directory and returns the `file://` value that reads it. */
|
|
155
|
+
async function writeInput(directory, name, content) {
|
|
156
|
+
const path = join(directory, name);
|
|
157
|
+
await writeFile(path, content);
|
|
158
|
+
return `file://${path}`;
|
|
159
|
+
}
|
|
160
|
+
function keyValueFlags(flag, values = {}) {
|
|
161
|
+
return Object.entries(values).map(([key, value]) => `${flag}=${key}=${value}`);
|
|
162
|
+
}
|
|
163
|
+
/** packjockel and its cache log to stderr as well; the error is in the remaining lines. */
|
|
164
|
+
function withoutLogLines(stderr = "") {
|
|
165
|
+
return stderr
|
|
166
|
+
.split("\n")
|
|
167
|
+
.filter((line) => line.trim() &&
|
|
168
|
+
!line.startsWith("time=") &&
|
|
169
|
+
!/^\d{4}\/\d{2}\/\d{2} /.test(line))
|
|
170
|
+
.join("\n");
|
|
171
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
});
|
|
@@ -16,6 +16,7 @@ const environmentMapping = {
|
|
|
16
16
|
ideaDirectory: "IDEA_INITIAL_DIRECTORY",
|
|
17
17
|
slackToken: "SLACK_TOKEN",
|
|
18
18
|
testApp: "TEST_APP",
|
|
19
|
+
packjockelPath: "PACKJOCKEL_PATH",
|
|
19
20
|
};
|
|
20
21
|
const CONFIG_FILE_NAME = "config.json";
|
|
21
22
|
/** Variables CI providers set besides `CI`. */
|
|
@@ -24,6 +24,11 @@ export interface CliSettings {
|
|
|
24
24
|
ideaDirectory: string;
|
|
25
25
|
slackToken: string;
|
|
26
26
|
testApp: string;
|
|
27
|
+
/**
|
|
28
|
+
* the packjockel binary, run for customers with the `configPlugins` feature; empty means the one of
|
|
29
|
+
* the installed `@speedkit/packjockel` package
|
|
30
|
+
*/
|
|
31
|
+
packjockelPath: string;
|
|
27
32
|
browserChannel: string;
|
|
28
33
|
browserBuildId: string;
|
|
29
34
|
browserAutoUpdate: boolean;
|
|
@@ -50,7 +50,7 @@ export class CustomerApprovalCheck {
|
|
|
50
50
|
const configFile = await VirtualSpeedKitConfigFile.createRemote(speedKitConfig, this.bundler);
|
|
51
51
|
const splits = [];
|
|
52
52
|
for (const origin of this.customer.origins) {
|
|
53
|
-
const result = await safe(configFile.evaluate(this.customer
|
|
53
|
+
const result = await safe(configFile.evaluate(this.customer, origin));
|
|
54
54
|
if (result.success === false) {
|
|
55
55
|
// An unreadable config is not proof that the split is 0, so keep the
|
|
56
56
|
// approval question rather than skipping it.
|
|
@@ -61,11 +61,10 @@ export class DeviceDetectionChangedCheck {
|
|
|
61
61
|
}
|
|
62
62
|
async checkForChangedDeviceDetection(speedKitConfigFile, activeSpeedKitConfig) {
|
|
63
63
|
const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
|
|
64
|
-
const app = this.customerConfig.app;
|
|
65
64
|
const origin = this.customerConfig.origins[0];
|
|
66
65
|
const changes = [];
|
|
67
|
-
const localSpeedKit = await speedKitConfigFile.evaluate(
|
|
68
|
-
const remoteSpeedKit = await remoteConfigFile.evaluate(
|
|
66
|
+
const localSpeedKit = await speedKitConfigFile.evaluate(this.customerConfig, origin);
|
|
67
|
+
const remoteSpeedKit = await remoteConfigFile.evaluate(this.customerConfig, origin);
|
|
69
68
|
if ((localSpeedKit.detectDevice && !remoteSpeedKit.detectDevice) ||
|
|
70
69
|
(!localSpeedKit.detectDevice && remoteSpeedKit.detectDevice)) {
|
|
71
70
|
changes.push("detectDevice");
|
|
@@ -63,11 +63,10 @@ export class SplitChangeCheck {
|
|
|
63
63
|
}
|
|
64
64
|
async checkSplitsForEachOrigin(speedKitConfigFile, activeSpeedKitConfig) {
|
|
65
65
|
const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
|
|
66
|
-
const app = this.customerConfig.app;
|
|
67
66
|
const changes = [];
|
|
68
67
|
for (const origin of this.customerConfig.origins) {
|
|
69
|
-
const localSpeedKit = await speedKitConfigFile.evaluate(
|
|
70
|
-
const remoteSpeedKit = await remoteConfigFile.evaluate(
|
|
68
|
+
const localSpeedKit = await speedKitConfigFile.evaluate(this.customerConfig, origin);
|
|
69
|
+
const remoteSpeedKit = await remoteConfigFile.evaluate(this.customerConfig, origin);
|
|
71
70
|
// check for split change
|
|
72
71
|
if (localSpeedKit.split !== remoteSpeedKit.split) {
|
|
73
72
|
changes.push({
|
|
@@ -60,7 +60,7 @@ export default class DeployServiceFactory {
|
|
|
60
60
|
})).getService();
|
|
61
61
|
const policy = this.policyOverride ?? new InteractiveDeployPolicy(cliService);
|
|
62
62
|
const installResourceBuilder = new InstallResourceBuilder(configApi);
|
|
63
|
-
const bundler = new BundleServiceFactory("./").buildService();
|
|
63
|
+
const bundler = new BundleServiceFactory("./", this.context.environment.settings.packjockelPath).buildService();
|
|
64
64
|
const deletedFilesChecker = new DeletedFileCheck(cliService, policy, this.context.hasArtifacts);
|
|
65
65
|
this.service = new DeployService(files, [
|
|
66
66
|
new CustomerConfigHandler(customer, configApi, configName, diffService, cliService, installResourceBuilder, policy),
|
|
@@ -63,6 +63,6 @@ export class MergeRequestDeployServiceFactory {
|
|
|
63
63
|
whitelist: [],
|
|
64
64
|
}))
|
|
65
65
|
.buildService()
|
|
66
|
-
.run()), new LiveStateCheck(diffService), new CustomerApprovalCheck(cliService, deployFactory.files.getCustomerConfig().config, policy, new BundleServiceFactory("./").buildService()), deployFactory.configApi, deployFactory.files, deployFactory.configName, deployService);
|
|
66
|
+
.run()), new LiveStateCheck(diffService), new CustomerApprovalCheck(cliService, deployFactory.files.getCustomerConfig().config, policy, new BundleServiceFactory("./", this.context.environment.settings.packjockelPath).buildService()), deployFactory.configApi, deployFactory.files, deployFactory.configName, deployService);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -4,4 +4,6 @@ export declare const LOCAL_DYNAMIC_FETCHER = "custom_dynamicFetcher";
|
|
|
4
4
|
export declare const LOCAL_DYNAMIC_FETCHER_CONFIG = "config_dynamicBlocks";
|
|
5
5
|
export declare const LOCAL_STYLES = "config_dynamicStyles";
|
|
6
6
|
export declare const LATEST_DYNAMIC_FETCHER_URL = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
7
|
+
/** Where the imports of the latest dynamic fetcher resolve. */
|
|
8
|
+
export declare const DYNAMIC_FETCHER_BASE_PATH = "https://www.baqend.com/speed-kit/latest/";
|
|
7
9
|
export declare const LOCAL_TRIGGERED_BY = "STREAM:QA";
|
|
@@ -4,6 +4,8 @@ export const LOCAL_DYNAMIC_FETCHER = "custom_dynamicFetcher";
|
|
|
4
4
|
export const LOCAL_DYNAMIC_FETCHER_CONFIG = "config_dynamicBlocks";
|
|
5
5
|
export const LOCAL_STYLES = "config_dynamicStyles";
|
|
6
6
|
export const LATEST_DYNAMIC_FETCHER_URL = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
7
|
+
/** Where the imports of the latest dynamic fetcher resolve. */
|
|
8
|
+
export const DYNAMIC_FETCHER_BASE_PATH = "https://www.baqend.com/speed-kit/latest/";
|
|
7
9
|
// Local runs have no persistent cache, so an origin HTML is served straight to the developer and may
|
|
8
10
|
// legitimately be older than the default five minutes. STREAM:QA relaxes the document handler's
|
|
9
11
|
// Shopify staleness check to one hour, see ONE_HOUR_STALENESS_TRIGGERS in document-handler.
|