@speedkit/cli 2.19.0 → 2.21.0
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 +15 -0
- package/README.md +1 -1
- package/dist/services/customer-config/templates/config_documentHandler.js.hbs +2 -2
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +2 -1
- package/dist/services/document-handler-runtime/document-handler-server.js +27 -14
- package/dist/services/integration-api/handler/customer-config-handler.js +6 -3
- package/dist/services/integration-api/struct/customer-config-file.js +4 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [2.21.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.20.0...v2.21.0) (2024-04-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **onboarding:** add filePath to all vm.evalCalls) ([cf2ef00](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/cf2ef009283400b9c490f52f47f8c8000005adea))
|
|
7
|
+
* **onboarding:** enable advanced debugging ([96130c1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/96130c1c7339f991a3c35b2eec7528ba0d26da25))
|
|
8
|
+
|
|
9
|
+
# [2.20.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.19.0...v2.20.0) (2024-04-10)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **customer-config:** adjust default lazy loading removal config to keep data attributes ([9db27c3](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/9db27c38fb18b4c90f61665972e6bd298dbd4212))
|
|
15
|
+
|
|
1
16
|
# [2.19.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.18.0...v2.19.0) (2024-04-09)
|
|
2
17
|
|
|
3
18
|
|
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
{{#if removeLazyLoading}}
|
|
3
3
|
const lazyLoadDefaultConfig = {
|
|
4
4
|
attributes: [
|
|
5
|
-
{ find: 'data-src',
|
|
6
|
-
{ find: 'data-srcset',
|
|
5
|
+
{ find: 'data-src', set: 'src' },
|
|
6
|
+
{ find: 'data-srcset', set: 'srcset' },
|
|
7
7
|
],
|
|
8
8
|
lazyClass: 'lazyload',
|
|
9
9
|
lazyLoad: false,
|
|
@@ -9,6 +9,7 @@ export declare class DocumentHandlerServer {
|
|
|
9
9
|
private cli;
|
|
10
10
|
private verboseLevel;
|
|
11
11
|
private documentHandlerCode;
|
|
12
|
+
private documentHandlerConfigCode;
|
|
12
13
|
private database;
|
|
13
14
|
constructor(customerConfig: CustomerConfig, files: FileListInterface, bundler: BundleService, cli: CliService, verboseLevel?: boolean);
|
|
14
15
|
transform(html: string, variation: string, url: string, headers: {
|
|
@@ -16,7 +17,7 @@ export declare class DocumentHandlerServer {
|
|
|
16
17
|
}): Promise<string>;
|
|
17
18
|
private getTransformFunctionWrapper;
|
|
18
19
|
buildDocumentHandler(): Promise<void>;
|
|
19
|
-
private
|
|
20
|
+
private createDocumentHandlerConfigFile;
|
|
20
21
|
private getDocumentHandler;
|
|
21
22
|
private getDynamicFetcher;
|
|
22
23
|
private getDynamicFetcherConfig;
|
|
@@ -18,6 +18,7 @@ class DocumentHandlerServer {
|
|
|
18
18
|
cli;
|
|
19
19
|
verboseLevel;
|
|
20
20
|
documentHandlerCode;
|
|
21
|
+
documentHandlerConfigCode;
|
|
21
22
|
database;
|
|
22
23
|
constructor(customerConfig, files, bundler, cli, verboseLevel = false) {
|
|
23
24
|
this.customerConfig = customerConfig;
|
|
@@ -44,20 +45,32 @@ class DocumentHandlerServer {
|
|
|
44
45
|
DYNAMIC_FETCHER: await this.getDynamicFetcher(),
|
|
45
46
|
DYNAMIC_FETCHER_CONFIG: await this.getDynamicFetcherConfig(),
|
|
46
47
|
CUSTOM_STYLES: this.getStyles(),
|
|
48
|
+
...this.getContextVars(),
|
|
47
49
|
...this.createNodeVmContext(),
|
|
48
50
|
};
|
|
49
|
-
const
|
|
51
|
+
const customDocumentHandlerFile = this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER);
|
|
52
|
+
if (customDocumentHandlerFile.path) {
|
|
53
|
+
vm.runInNewContext(this.documentHandlerCode, vmContext, {
|
|
54
|
+
filename: customDocumentHandlerFile.path,
|
|
55
|
+
displayErrors: true,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
vm.runInNewContext(this.documentHandlerCode, vmContext);
|
|
60
|
+
}
|
|
61
|
+
const configDocumentHandlerPath = this.files.getByName("config_documentHandler").path;
|
|
62
|
+
const script = new vm.Script(this.documentHandlerConfigCode + this.getTransformFunctionWrapper(), {
|
|
63
|
+
filename: configDocumentHandlerPath,
|
|
64
|
+
});
|
|
50
65
|
try {
|
|
51
66
|
return await (async () => {
|
|
52
67
|
return await new Promise((resolve, reject) => {
|
|
53
|
-
|
|
54
|
-
// @ts-expect-error
|
|
68
|
+
// @ts-expect-error resolve is unknown
|
|
55
69
|
vmContext.resolve = resolve;
|
|
56
|
-
// @ts-expect-error
|
|
70
|
+
// @ts-expect-error reject is unknown
|
|
57
71
|
vmContext.reject = reject;
|
|
58
|
-
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
|
59
72
|
const context = vm.createContext(vmContext);
|
|
60
|
-
script.runInContext(context);
|
|
73
|
+
script.runInContext(context, { displayErrors: true });
|
|
61
74
|
});
|
|
62
75
|
})();
|
|
63
76
|
}
|
|
@@ -72,13 +85,13 @@ class DocumentHandlerServer {
|
|
|
72
85
|
return `\n\ndocumentHandler.transform(db, skInternalRequest).then(result => {resolve(result);}).catch((err)=>{reject(err);});`;
|
|
73
86
|
}
|
|
74
87
|
async buildDocumentHandler() {
|
|
75
|
-
this.documentHandlerCode = await this.
|
|
88
|
+
this.documentHandlerCode = await this.getDocumentHandler();
|
|
89
|
+
this.documentHandlerConfigCode =
|
|
90
|
+
await this.createDocumentHandlerConfigFile();
|
|
76
91
|
this.cli.writeSuccess("rebuild documentHandler");
|
|
77
92
|
}
|
|
78
|
-
async
|
|
79
|
-
|
|
80
|
-
const documentHandlerConfig = this.getDocumentHandlerConfig().replace("export const post", "const post");
|
|
81
|
-
return `${this.getContextVars()} ${documentHandler} ${documentHandlerConfig}`;
|
|
93
|
+
async createDocumentHandlerConfigFile() {
|
|
94
|
+
return this.getDocumentHandlerConfig().replace("export const post", "const post");
|
|
82
95
|
}
|
|
83
96
|
async getDocumentHandler() {
|
|
84
97
|
return this.files
|
|
@@ -113,11 +126,11 @@ class DocumentHandlerServer {
|
|
|
113
126
|
return documentHandlerFile.getContent();
|
|
114
127
|
}
|
|
115
128
|
getContextVars() {
|
|
116
|
-
|
|
129
|
+
const contextVariables = {};
|
|
117
130
|
for (const key in this.customerConfig) {
|
|
118
|
-
|
|
131
|
+
contextVariables[key.toUpperCase()] = this.customerConfig[key];
|
|
119
132
|
}
|
|
120
|
-
return
|
|
133
|
+
return contextVariables;
|
|
121
134
|
}
|
|
122
135
|
async createDataBaseMock() {
|
|
123
136
|
const vmConsole = {
|
|
@@ -25,11 +25,11 @@ class CustomerConfigHandler extends file_handler_1.default {
|
|
|
25
25
|
}
|
|
26
26
|
async handle(filePath) {
|
|
27
27
|
const fileContent = await this.fileReader.getContent(filePath);
|
|
28
|
-
const config = await this.loadConfig(fileContent);
|
|
28
|
+
const config = await this.loadConfig(fileContent, filePath);
|
|
29
29
|
this.validator.validate(config);
|
|
30
30
|
return new customer_config_file_1.default(this.getFileName(filePath), filePath, fileContent, config, this.configName, this.testApp);
|
|
31
31
|
}
|
|
32
|
-
async loadConfig(fileContent) {
|
|
32
|
+
async loadConfig(fileContent, filePath) {
|
|
33
33
|
if ((fileContent.includes("process.env.TEST_APP") && this.testApp === null) ||
|
|
34
34
|
this.testApp.length === 0) {
|
|
35
35
|
throw new customer_config_error_1.default("please specify env TEST_APP in your .env or configFile file");
|
|
@@ -40,7 +40,10 @@ class CustomerConfigHandler extends file_handler_1.default {
|
|
|
40
40
|
env: { TEST_APP: this.testApp }, // make TEST_APP available for vm
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
vm.runInNewContext(fileContent, customerConfigContext
|
|
43
|
+
vm.runInNewContext(fileContent, customerConfigContext, {
|
|
44
|
+
filename: filePath,
|
|
45
|
+
displayErrors: true,
|
|
46
|
+
});
|
|
44
47
|
const configs = customerConfigContext?.module?.exports;
|
|
45
48
|
if (Array.isArray(configs) ||
|
|
46
49
|
typeof configs === "string" ||
|
|
@@ -25,7 +25,10 @@ class CustomerConfigFile extends file_1.default {
|
|
|
25
25
|
env: { TEST_APP: this.testApp }, // make TEST_APP available for vm
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
|
-
vm.runInNewContext(this.getContent(), customerConfigContext
|
|
28
|
+
vm.runInNewContext(this.getContent(), customerConfigContext, {
|
|
29
|
+
filename: this.path,
|
|
30
|
+
displayErrors: true,
|
|
31
|
+
});
|
|
29
32
|
if (this.configName in customerConfigContext.module.exports) {
|
|
30
33
|
this.config = customer_config_1.default.createFrom(customerConfigContext.module.exports[this.configName], this.configName);
|
|
31
34
|
}
|
package/oclif.manifest.json
CHANGED