@speedkit/cli 2.13.0 → 2.14.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 +8 -0
- package/README.md +1 -1
- package/dist/commands/document-handler.d.ts +1 -1
- package/dist/commands/document-handler.js +4 -4
- package/dist/commands/find-pops.d.ts +1 -1
- package/dist/commands/find-pops.js +21 -18
- package/dist/commands/login.d.ts +1 -1
- package/dist/commands/login.js +4 -4
- package/dist/commands/onboarding.d.ts +1 -1
- package/dist/commands/onboarding.js +12 -4
- package/dist/commands/param-diff.d.ts +2 -2
- package/dist/commands/param-diff.js +16 -16
- package/dist/commands/pop-prewarm.d.ts +2 -2
- package/dist/commands/pop-prewarm.js +20 -13
- package/dist/commands/prewarm.d.ts +2 -2
- package/dist/commands/prewarm.js +35 -19
- package/dist/commands/pull.d.ts +1 -1
- package/dist/commands/pull.js +2 -2
- package/dist/commands/wpt-launcher.d.ts +2 -2
- package/dist/commands/wpt-launcher.js +35 -19
- package/dist/helpers/CustomerConfig.d.ts +1 -1
- package/dist/helpers/CustomerConfig.js +36 -35
- package/dist/helpers/file-helper.js +6 -6
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# [2.14.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.13.0...v2.14.0) (2024-03-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* optimise ci pipelines ([3b3e68c](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/3b3e68ce78579b066b8d84a476e4291179158cb7))
|
|
7
|
+
* optimise ci pipelines ([695f57b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/695f57b52132452341c7d02abe24583a11f25648))
|
|
8
|
+
|
|
1
9
|
# [2.13.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.12.0...v2.13.0) (2024-03-15)
|
|
2
10
|
|
|
3
11
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(requi
|
|
|
7
7
|
const document_handler_runtime_context_1 = tslib_1.__importDefault(require("../services/document-handler-runtime/context/document-handler-runtime-context"));
|
|
8
8
|
const cli_config_1 = require("../helpers/cli-config");
|
|
9
9
|
class DocumentHandler extends core_1.Command {
|
|
10
|
-
static description =
|
|
10
|
+
static description = "Creates testable documentHandler in folder {CUSTOMER_PATH}/test/src/";
|
|
11
11
|
static args = cli_parameters_1.CLI_CUSTOMER_CONFIG;
|
|
12
12
|
static flags = {
|
|
13
13
|
...cli_parameters_1.CLI_CONFIG_NAME,
|
|
@@ -15,7 +15,7 @@ class DocumentHandler extends core_1.Command {
|
|
|
15
15
|
char: cli_parameters_1.CLIParametersChar.CreateTests,
|
|
16
16
|
multiple: true,
|
|
17
17
|
required: false,
|
|
18
|
-
description:
|
|
18
|
+
description: "name of the test to create",
|
|
19
19
|
}),
|
|
20
20
|
};
|
|
21
21
|
static examples = [
|
|
@@ -23,8 +23,8 @@ class DocumentHandler extends core_1.Command {
|
|
|
23
23
|
`$ sk deploy ${cli_parameters_1.CLIParametersExample.CustomerPath} -${cli_parameters_1.CLIParametersChar.ConfigName} ${cli_parameters_1.CLIParametersExample.ConfigName}`,
|
|
24
24
|
];
|
|
25
25
|
async run() {
|
|
26
|
-
const { args: { customerPath }, flags: { configName, CreateTests } } = await this.parse(DocumentHandler);
|
|
27
|
-
const runtime = await
|
|
26
|
+
const { args: { customerPath }, flags: { configName, CreateTests }, } = await this.parse(DocumentHandler);
|
|
27
|
+
const runtime = await new document_handler_runtime_service_factory_1.default(new document_handler_runtime_context_1.default(customerPath, configName, CreateTests), new cli_config_1.CliConfig(this.config).load()).buildService();
|
|
28
28
|
await runtime.run();
|
|
29
29
|
}
|
|
30
30
|
async finally(error) {
|
|
@@ -2,29 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const fetch = require('node-fetch');
|
|
9
|
-
const cli_1 = require("baqend/cli");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
10
7
|
const https = tslib_1.__importStar(require("https"));
|
|
8
|
+
const cli_1 = require("baqend/cli");
|
|
9
|
+
const logging_helper_1 = require("../helpers/logging-helper");
|
|
11
10
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
11
|
+
const airports = tslib_1.__importStar(require("./airports_iata.json"));
|
|
12
12
|
const agent = new https.Agent({
|
|
13
13
|
rejectUnauthorized: false,
|
|
14
14
|
keepAlive: true,
|
|
15
15
|
});
|
|
16
16
|
class FindPops extends core_1.Command {
|
|
17
|
-
static description =
|
|
17
|
+
static description = "Get IPs for all fastly PoPs";
|
|
18
18
|
static args = {
|
|
19
19
|
[cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
|
|
20
20
|
name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
|
|
21
21
|
required: true, // make the arg required with `required: true`
|
|
22
|
-
description:
|
|
22
|
+
description: "The customers appName", // help description
|
|
23
23
|
hidden: false, // hide this arg from help
|
|
24
24
|
}),
|
|
25
25
|
};
|
|
26
26
|
static flags = {
|
|
27
|
-
[cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({
|
|
27
|
+
[cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({
|
|
28
|
+
default: "151.101.x.194",
|
|
29
|
+
char: cli_parameters_1.CLIParametersChar.Ips,
|
|
30
|
+
}),
|
|
28
31
|
};
|
|
29
32
|
static examples = [
|
|
30
33
|
`$ sk find-pops <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.Ips} <${cli_parameters_1.CLIParameters.Ips}>`,
|
|
@@ -32,17 +35,17 @@ class FindPops extends core_1.Command {
|
|
|
32
35
|
];
|
|
33
36
|
pops = {};
|
|
34
37
|
async run() {
|
|
35
|
-
const { args: { app }, flags: { ips } } = await this.parse(FindPops);
|
|
38
|
+
const { args: { app }, flags: { ips }, } = await this.parse(FindPops);
|
|
36
39
|
const db = await cli_1.account.login({ app });
|
|
37
|
-
const ranges = ips.split(
|
|
40
|
+
const ranges = ips.split(",");
|
|
38
41
|
const fetches = [];
|
|
39
42
|
for (const range of ranges) {
|
|
40
43
|
for (let i = 0; i < 255; i++) {
|
|
41
|
-
fetches.push(this.getPop(range.replace(
|
|
44
|
+
fetches.push(this.getPop(range.replace("x", String(i)), app, db.token));
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
const results = await Promise.all(fetches);
|
|
45
|
-
results.forEach(r => {
|
|
48
|
+
results.forEach((r) => {
|
|
46
49
|
if (r) {
|
|
47
50
|
const airport = airports[r.pop];
|
|
48
51
|
let id = r.pop;
|
|
@@ -53,27 +56,27 @@ class FindPops extends core_1.Command {
|
|
|
53
56
|
this.pops[id].push(r.ip);
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
|
-
|
|
57
|
-
(0, logging_helper_1.logInfo)(
|
|
59
|
+
fs_1.default.writeFileSync("pops.json", JSON.stringify(this.pops));
|
|
60
|
+
(0, logging_helper_1.logInfo)("List of POPs was successfully created in pops.json");
|
|
58
61
|
}
|
|
59
62
|
async getPop(ip, app, token) {
|
|
60
63
|
try {
|
|
61
|
-
const resp = await
|
|
64
|
+
const resp = await (0, node_fetch_1.default)(`https://${ip}/`, {
|
|
62
65
|
agent,
|
|
63
|
-
method:
|
|
66
|
+
method: "HEAD",
|
|
64
67
|
headers: {
|
|
65
68
|
Host: `${app}.app.baqend.com`,
|
|
66
69
|
authorization: `BAT ${token}`,
|
|
67
70
|
},
|
|
68
71
|
timeout: 10_000,
|
|
69
72
|
});
|
|
70
|
-
const servedBy = resp.headers.get(
|
|
73
|
+
const servedBy = resp.headers.get("x-served-by");
|
|
71
74
|
if (resp.status !== 200 || !servedBy) {
|
|
72
75
|
return null;
|
|
73
76
|
}
|
|
74
77
|
return {
|
|
75
78
|
ip,
|
|
76
|
-
pop: servedBy.split(
|
|
79
|
+
pop: servedBy.split("-")[2],
|
|
77
80
|
};
|
|
78
81
|
}
|
|
79
82
|
catch (error) {
|
package/dist/commands/login.d.ts
CHANGED
package/dist/commands/login.js
CHANGED
|
@@ -7,18 +7,18 @@ const cli_parameters_1 = require("../models/cli-parameters");
|
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
9
|
class Login extends core_1.Command {
|
|
10
|
-
static description =
|
|
10
|
+
static description = "Login to your app";
|
|
11
11
|
static args = {
|
|
12
12
|
[cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
|
|
13
13
|
name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
|
|
14
14
|
required: false,
|
|
15
|
-
default:
|
|
16
|
-
description:
|
|
15
|
+
default: "bbq",
|
|
16
|
+
description: "The customers appName", // help description
|
|
17
17
|
}),
|
|
18
18
|
};
|
|
19
19
|
static examples = [
|
|
20
20
|
`$ sk login <${cli_parameters_1.CLIParameters.AppName}>`,
|
|
21
|
-
|
|
21
|
+
"$ sk login appName",
|
|
22
22
|
];
|
|
23
23
|
async run() {
|
|
24
24
|
const { app } = (await this.parse(Login)).args;
|
|
@@ -5,11 +5,19 @@ const cli_parameters_1 = require("../models/cli-parameters");
|
|
|
5
5
|
const onboarding_1 = require("../services/onboarding");
|
|
6
6
|
const cli_config_1 = require("../helpers/cli-config");
|
|
7
7
|
class Onboarding extends core_1.Command {
|
|
8
|
-
static description =
|
|
8
|
+
static description = "Start a local dev environment for building and testing the Speed Kit configuration";
|
|
9
9
|
static flags = {
|
|
10
10
|
...cli_parameters_1.CLI_CONFIG_NAME,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
local: core_1.Flags.boolean({
|
|
12
|
+
char: "l",
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Run with local documentHandler",
|
|
15
|
+
}),
|
|
16
|
+
verboseLevel: core_1.Flags.boolean({
|
|
17
|
+
char: "v",
|
|
18
|
+
default: false,
|
|
19
|
+
description: "Show all messages",
|
|
20
|
+
}),
|
|
13
21
|
};
|
|
14
22
|
static args = cli_parameters_1.CLI_CUSTOMER_CONFIG;
|
|
15
23
|
static examples = [
|
|
@@ -17,7 +25,7 @@ class Onboarding extends core_1.Command {
|
|
|
17
25
|
`$ sk onboarding ${cli_parameters_1.CLIParametersExample.CustomerPath} -${cli_parameters_1.CLIParametersChar.ConfigName} ${cli_parameters_1.CLIParametersExample.ConfigName}`,
|
|
18
26
|
];
|
|
19
27
|
async run() {
|
|
20
|
-
const { args: { customerPath }, flags: { configName, local, verboseLevel } } = await this.parse(Onboarding);
|
|
28
|
+
const { args: { customerPath }, flags: { configName, local, verboseLevel }, } = await this.parse(Onboarding);
|
|
21
29
|
const service = await new onboarding_1.OnboardingServiceFactory(new onboarding_1.OnboardingContext(customerPath, configName, local, verboseLevel), new cli_config_1.CliConfig(this.config).load()).getService();
|
|
22
30
|
await service.run();
|
|
23
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Config, Command } from "@oclif/core";
|
|
2
2
|
import { CliService } from "../services/cli";
|
|
3
3
|
export default class ParamDiff extends Command {
|
|
4
4
|
cli: CliService;
|
|
@@ -10,7 +10,7 @@ export default class ParamDiff extends Command {
|
|
|
10
10
|
hideDiff: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
12
|
static examples: string[];
|
|
13
|
-
constructor(argv: string[], config:
|
|
13
|
+
constructor(argv: string[], config: Config);
|
|
14
14
|
logError(message: any): void;
|
|
15
15
|
run(): Promise<void>;
|
|
16
16
|
}
|
|
@@ -10,19 +10,19 @@ const diff_1 = require("../services/diff");
|
|
|
10
10
|
const cli_config_1 = require("../helpers/cli-config");
|
|
11
11
|
class ParamDiff extends core_1.Command {
|
|
12
12
|
cli;
|
|
13
|
-
static description =
|
|
13
|
+
static description = "Shows difference in documents with query parameters on/off";
|
|
14
14
|
static args = {
|
|
15
15
|
[cli_parameters_1.CLIParameters.PageUrl]: core_1.Args.string({
|
|
16
16
|
name: cli_parameters_1.CLIParameters.PageUrl,
|
|
17
17
|
required: true,
|
|
18
|
-
description:
|
|
19
|
-
example: cli_parameters_1.CLIParametersExample.PageUrl
|
|
20
|
-
})
|
|
18
|
+
description: "Link of the page",
|
|
19
|
+
example: cli_parameters_1.CLIParametersExample.PageUrl,
|
|
20
|
+
}),
|
|
21
21
|
};
|
|
22
22
|
static flags = {
|
|
23
23
|
[cli_parameters_1.CLIParameters.HideDiff]: core_1.Flags.boolean({
|
|
24
24
|
char: cli_parameters_1.CLIParametersChar.HideDiff,
|
|
25
|
-
description:
|
|
25
|
+
description: "Hide the code diff in IDE code diff window",
|
|
26
26
|
}),
|
|
27
27
|
};
|
|
28
28
|
static examples = [
|
|
@@ -43,7 +43,7 @@ class ParamDiff extends core_1.Command {
|
|
|
43
43
|
const { pageUrl: originalUrl } = args;
|
|
44
44
|
const originalData = await (0, scrape_1.default)(originalUrl);
|
|
45
45
|
if (!originalData) {
|
|
46
|
-
this.logError(
|
|
46
|
+
this.logError("Failed to fetch original document");
|
|
47
47
|
}
|
|
48
48
|
const parsedUrl = url.parse(originalUrl, true);
|
|
49
49
|
const withoutAnyParamsUrl = url.format({
|
|
@@ -53,13 +53,13 @@ class ParamDiff extends core_1.Command {
|
|
|
53
53
|
});
|
|
54
54
|
const withoutAnyParamsData = await (0, scrape_1.default)(withoutAnyParamsUrl);
|
|
55
55
|
if (!withoutAnyParamsData) {
|
|
56
|
-
this.logError(
|
|
56
|
+
this.logError("Failed to fetch document without any params");
|
|
57
57
|
}
|
|
58
58
|
const userConfig = new cli_config_1.CliConfig(this.config).load();
|
|
59
59
|
const context = new diff_1.DiffContext(userConfig.diffExec, userConfig.diffExecTemplate);
|
|
60
60
|
const diffService = new diff_1.DiffServiceFactory(context).getService();
|
|
61
|
-
const originalFilePath = await diffService.writeContentToTemporalFile(
|
|
62
|
-
const withoutAnyParamsFilePath = await diffService.writeContentToTemporalFile(
|
|
61
|
+
const originalFilePath = await diffService.writeContentToTemporalFile("original.html", originalData);
|
|
62
|
+
const withoutAnyParamsFilePath = await diffService.writeContentToTemporalFile("without-any-params.html", withoutAnyParamsData);
|
|
63
63
|
this.cli.spacer();
|
|
64
64
|
this.cli.write(`Checking any parameter...`);
|
|
65
65
|
this.cli.write(`- with: ${originalUrl}`);
|
|
@@ -69,19 +69,19 @@ class ParamDiff extends core_1.Command {
|
|
|
69
69
|
this.cli.writeSuccess(`✅ No diff found`);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
this.cli.writeWarning(
|
|
72
|
+
this.cli.writeWarning("⚠️ Found diff");
|
|
73
73
|
// If there is more than one query params given &
|
|
74
74
|
// there's a difference in the general check, do a detailed check:
|
|
75
75
|
if (Object.keys(parsedUrl.query).length === 1)
|
|
76
76
|
return;
|
|
77
|
-
for (
|
|
77
|
+
for (const param in parsedUrl.query) {
|
|
78
78
|
const withoutCurrentParamQuery = { ...parsedUrl.query };
|
|
79
79
|
delete withoutCurrentParamQuery[param]; // Remove the current parameter
|
|
80
80
|
const withoutCurrentParamUrl = url.format({
|
|
81
81
|
protocol: parsedUrl.protocol,
|
|
82
82
|
host: parsedUrl.host,
|
|
83
83
|
pathname: parsedUrl.pathname,
|
|
84
|
-
query: withoutCurrentParamQuery
|
|
84
|
+
query: withoutCurrentParamQuery,
|
|
85
85
|
});
|
|
86
86
|
const withoutCurrentParamData = await (0, scrape_1.default)(withoutCurrentParamUrl);
|
|
87
87
|
if (!withoutCurrentParamData) {
|
|
@@ -92,14 +92,14 @@ class ParamDiff extends core_1.Command {
|
|
|
92
92
|
this.cli.write(`Checking "${param}" parameter...`);
|
|
93
93
|
this.cli.write(`- with: ${originalUrl}`);
|
|
94
94
|
this.cli.write(`- without: ${withoutCurrentParamUrl}`);
|
|
95
|
-
const hasSpecificDiff = !await diffService.executeDiff(originalFilePath, withoutCurrentParamFilePath, flags.hideDiff);
|
|
95
|
+
const hasSpecificDiff = !(await diffService.executeDiff(originalFilePath, withoutCurrentParamFilePath, flags.hideDiff));
|
|
96
96
|
if (hasSpecificDiff) {
|
|
97
|
-
const hasDiffWithoutAnyParams = !await diffService.executeDiff(withoutAnyParamsFilePath, withoutCurrentParamFilePath, true);
|
|
97
|
+
const hasDiffWithoutAnyParams = !(await diffService.executeDiff(withoutAnyParamsFilePath, withoutCurrentParamFilePath, true));
|
|
98
98
|
if (hasDiffWithoutAnyParams) {
|
|
99
|
-
this.cli.writeWarning(
|
|
99
|
+
this.cli.writeWarning("⚠️ Found diff");
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
|
-
this.cli.writeWarning(
|
|
102
|
+
this.cli.writeWarning("⚠️ Found diff (identical with having all params removed)");
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
@@ -8,28 +8,34 @@ const prewarm_service_1 = tslib_1.__importDefault(require("../services/prewarm-s
|
|
|
8
8
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
9
9
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
10
10
|
class PopPrewarm extends core_1.Command {
|
|
11
|
-
static description =
|
|
11
|
+
static description = "Pre-warm Fastly PoPs";
|
|
12
12
|
static args = {
|
|
13
13
|
[cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
|
|
14
14
|
name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
|
|
15
15
|
required: true, // make the arg required with `required: true`
|
|
16
|
-
description:
|
|
16
|
+
description: "The customers appName", // help description
|
|
17
17
|
hidden: false, // hide this arg from help
|
|
18
18
|
}),
|
|
19
19
|
};
|
|
20
20
|
static flags = {
|
|
21
|
-
[cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({
|
|
22
|
-
|
|
21
|
+
[cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({
|
|
22
|
+
default: "151.101.120.194",
|
|
23
|
+
char: cli_parameters_1.CLIParametersChar.Ips,
|
|
24
|
+
}),
|
|
25
|
+
[cli_parameters_1.CLIParameters.ContentTypes]: core_1.Flags.string({
|
|
26
|
+
default: "image",
|
|
27
|
+
char: cli_parameters_1.CLIParametersChar.ContentTypes,
|
|
28
|
+
}),
|
|
23
29
|
};
|
|
24
30
|
static examples = [
|
|
25
31
|
`$ sk pop-prewarm <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.ContentTypes} <${cli_parameters_1.CLIParameters.ContentTypes}> -${cli_parameters_1.CLIParametersChar.Ips} <${cli_parameters_1.CLIParameters.Ips}>`,
|
|
26
32
|
`$ sk pop-prewarm decathlon -${cli_parameters_1.CLIParametersChar.ContentTypes} ${cli_parameters_1.CLIParametersExample.ContentTypes} -${cli_parameters_1.CLIParametersChar.Ips} ${cli_parameters_1.CLIParametersExample.Ips}`,
|
|
27
33
|
];
|
|
28
34
|
async run() {
|
|
29
|
-
const { args: { app }, flags: { ips, contentTypes } } = await this.parse(PopPrewarm);
|
|
35
|
+
const { args: { app }, flags: { ips, contentTypes }, } = await this.parse(PopPrewarm);
|
|
30
36
|
const db = await cli_1.account.login({ app });
|
|
31
|
-
const contentTypeArr = contentTypes.split(
|
|
32
|
-
const ipsArr = ips.split(
|
|
37
|
+
const contentTypeArr = contentTypes.split(",");
|
|
38
|
+
const ipsArr = ips.split(",");
|
|
33
39
|
const count = await this.getCount(db, contentTypeArr);
|
|
34
40
|
const progress = core_2.ux.progress();
|
|
35
41
|
progress.start(count * ips.length, 0);
|
|
@@ -37,16 +43,17 @@ class PopPrewarm extends core_1.Command {
|
|
|
37
43
|
progress.stop();
|
|
38
44
|
}
|
|
39
45
|
async getCount(db, contentTypes) {
|
|
40
|
-
return db[
|
|
46
|
+
return db["speedKit.Asset"].find().in("contentType", contentTypes).count();
|
|
41
47
|
}
|
|
42
|
-
async queryDb(db, contentTypes, lastId =
|
|
43
|
-
let qb = db[
|
|
48
|
+
async queryDb(db, contentTypes, lastId = "") {
|
|
49
|
+
let qb = db["speedKit.Asset"].find().in("contentType", contentTypes);
|
|
44
50
|
if (lastId) {
|
|
45
|
-
qb = qb.gt(
|
|
51
|
+
qb = qb.gt("id", lastId);
|
|
46
52
|
}
|
|
47
53
|
return qb.limit(100).sort({ id: 1 }).resultList();
|
|
48
54
|
}
|
|
49
|
-
|
|
55
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
56
|
+
async fetchAssets(db, ips, contentTypes, app, progress, lastId = "") {
|
|
50
57
|
const resultList = await this.queryDb(db, contentTypes, lastId);
|
|
51
58
|
if (resultList.length === 0) {
|
|
52
59
|
return Promise.resolve();
|
|
@@ -58,7 +65,7 @@ class PopPrewarm extends core_1.Command {
|
|
|
58
65
|
for (const asset of assets) {
|
|
59
66
|
let { url } = asset;
|
|
60
67
|
const { origin, variation, extendedURL } = asset;
|
|
61
|
-
url +=
|
|
68
|
+
url += extendedURL || "";
|
|
62
69
|
fetches.push(prewarm_service_1.default.fetchURLByIp(ip, url, origin, variation, app, db.token));
|
|
63
70
|
}
|
|
64
71
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Prewarm extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static args: {
|
|
@@ -35,6 +35,6 @@ export default class Prewarm extends Command {
|
|
|
35
35
|
* Extracts variations line by line from a given file.
|
|
36
36
|
* @param path - path to the csv containing variations
|
|
37
37
|
*/
|
|
38
|
-
loadVariations(path: string):
|
|
38
|
+
loadVariations(path: string): string[];
|
|
39
39
|
sleep(ms: any): Promise<unknown>;
|
|
40
40
|
}
|
package/dist/commands/prewarm.js
CHANGED
|
@@ -7,27 +7,41 @@ const cli_1 = require("baqend/cli");
|
|
|
7
7
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
8
8
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
9
9
|
const prewarm_service_1 = tslib_1.__importDefault(require("../services/prewarm-service"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const url_1 = require("url");
|
|
11
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
12
12
|
class Prewarm extends core_1.Command {
|
|
13
|
-
static description =
|
|
13
|
+
static description = "Pre-warm Fastly";
|
|
14
14
|
static args = {
|
|
15
15
|
[cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
|
|
16
16
|
name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
|
|
17
17
|
required: true, // make the arg required with `required: true`
|
|
18
|
-
description:
|
|
18
|
+
description: "The customer app name", // help description
|
|
19
19
|
}),
|
|
20
20
|
[cli_parameters_1.CLIParameters.Path]: core_1.Args.string({
|
|
21
21
|
name: cli_parameters_1.CLIParameters.Path, // name of arg to show in help and reference with args[name]
|
|
22
22
|
required: true, // make the arg required with `required: true`
|
|
23
|
-
description:
|
|
23
|
+
description: "path to prewarmFile", // help description
|
|
24
24
|
}),
|
|
25
25
|
};
|
|
26
26
|
static flags = {
|
|
27
|
-
[cli_parameters_1.CLIParameters.Variation]: core_1.Flags.string({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
[cli_parameters_1.CLIParameters.Variation]: core_1.Flags.string({
|
|
28
|
+
char: cli_parameters_1.CLIParametersChar.Variation,
|
|
29
|
+
default: "DEFAULT",
|
|
30
|
+
}),
|
|
31
|
+
[cli_parameters_1.CLIParameters.VariationPath]: core_1.Flags.string({
|
|
32
|
+
char: cli_parameters_1.CLIParametersChar.VariationPath,
|
|
33
|
+
exclusive: [cli_parameters_1.CLIParameters.Variation],
|
|
34
|
+
}),
|
|
35
|
+
[cli_parameters_1.CLIParameters.Delay]: core_1.Flags.integer({
|
|
36
|
+
char: cli_parameters_1.CLIParametersChar.Delay,
|
|
37
|
+
default: 0,
|
|
38
|
+
description: "Request delay in ms",
|
|
39
|
+
}),
|
|
40
|
+
[cli_parameters_1.CLIParameters.KeepParameterSorting]: core_1.Flags.boolean({
|
|
41
|
+
char: cli_parameters_1.CLIParametersChar.KeepParameterSorting,
|
|
42
|
+
default: false,
|
|
43
|
+
description: "Prevents alphabetical sorting of the URL parameters",
|
|
44
|
+
}),
|
|
31
45
|
};
|
|
32
46
|
static examples = [
|
|
33
47
|
"for a single variation:",
|
|
@@ -39,11 +53,13 @@ class Prewarm extends core_1.Command {
|
|
|
39
53
|
`$ sk prewarm ${cli_parameters_1.CLIParametersExample.AppName} ${cli_parameters_1.CLIParametersExample.Path} -${cli_parameters_1.CLIParametersChar.Path} ${cli_parameters_1.CLIParametersExample.VariationPath} -${cli_parameters_1.CLIParametersChar.Delay} ${cli_parameters_1.CLIParametersExample.Delay} -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
|
|
40
54
|
];
|
|
41
55
|
async run() {
|
|
42
|
-
const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting } } = await this.parse(Prewarm);
|
|
56
|
+
const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting }, } = await this.parse(Prewarm);
|
|
43
57
|
const sortParameters = !keepParameterSorting;
|
|
44
58
|
const db = await cli_1.account.login({ app });
|
|
45
59
|
const urls = this.loadAssets(path);
|
|
46
|
-
const variations = variationPath
|
|
60
|
+
const variations = variationPath
|
|
61
|
+
? this.loadVariations(variationPath)
|
|
62
|
+
: [variation];
|
|
47
63
|
await this.prewarmVariations(variations, urls, app, db.token, delay, sortParameters);
|
|
48
64
|
}
|
|
49
65
|
/**
|
|
@@ -88,15 +104,15 @@ class Prewarm extends core_1.Command {
|
|
|
88
104
|
}
|
|
89
105
|
progress.stop();
|
|
90
106
|
}
|
|
91
|
-
loadAssets(path, origin =
|
|
92
|
-
const data =
|
|
107
|
+
loadAssets(path, origin = "") {
|
|
108
|
+
const data = fs_1.default.readFileSync(path, "utf8");
|
|
93
109
|
const entries = data.split(/\r?\n/);
|
|
94
|
-
return entries.map(entry => {
|
|
110
|
+
return entries.map((entry) => {
|
|
95
111
|
entry = /^"[^"]+"/.test(entry) ? entry.slice(1, -1) : entry;
|
|
96
112
|
try {
|
|
97
113
|
return {
|
|
98
114
|
url: entry,
|
|
99
|
-
origin: origin || new URL(entry).origin,
|
|
115
|
+
origin: origin || new url_1.URL(entry).origin,
|
|
100
116
|
};
|
|
101
117
|
}
|
|
102
118
|
catch (error) {
|
|
@@ -110,10 +126,10 @@ class Prewarm extends core_1.Command {
|
|
|
110
126
|
* @param path - path to the csv containing variations
|
|
111
127
|
*/
|
|
112
128
|
loadVariations(path) {
|
|
113
|
-
|
|
114
|
-
const data =
|
|
129
|
+
const variations = [];
|
|
130
|
+
const data = fs_1.default.readFileSync(path, "utf8");
|
|
115
131
|
const entries = data.split(/\r?\n/);
|
|
116
|
-
entries.forEach(entry => {
|
|
132
|
+
entries.forEach((entry) => {
|
|
117
133
|
if (entry !== "") {
|
|
118
134
|
variations.push(entry);
|
|
119
135
|
}
|
|
@@ -121,7 +137,7 @@ class Prewarm extends core_1.Command {
|
|
|
121
137
|
return variations;
|
|
122
138
|
}
|
|
123
139
|
async sleep(ms) {
|
|
124
|
-
return new Promise(res => setTimeout(res, ms));
|
|
140
|
+
return new Promise((res) => setTimeout(res, ms));
|
|
125
141
|
}
|
|
126
142
|
}
|
|
127
143
|
exports.default = Prewarm;
|
package/dist/commands/pull.d.ts
CHANGED
package/dist/commands/pull.js
CHANGED
|
@@ -5,7 +5,7 @@ const cli_parameters_1 = require("../models/cli-parameters");
|
|
|
5
5
|
const pull_1 = require("../services/pull");
|
|
6
6
|
const cli_config_1 = require("../helpers/cli-config");
|
|
7
7
|
class Pull extends core_1.Command {
|
|
8
|
-
static description =
|
|
8
|
+
static description = "Pull the specified customer config from orestes";
|
|
9
9
|
static args = cli_parameters_1.CLI_CUSTOMER_CONFIG;
|
|
10
10
|
static flags = {
|
|
11
11
|
...cli_parameters_1.CLI_CONFIG_NAME,
|
|
@@ -15,7 +15,7 @@ class Pull extends core_1.Command {
|
|
|
15
15
|
`$ sk pull ${cli_parameters_1.CLIParametersExample.CustomerPath} -${cli_parameters_1.CLIParametersChar.ConfigName} ${cli_parameters_1.CLIParametersExample.ConfigName}`,
|
|
16
16
|
];
|
|
17
17
|
async run() {
|
|
18
|
-
const { args: { customerPath }, flags: { configName } } = await this.parse(Pull);
|
|
18
|
+
const { args: { customerPath }, flags: { configName }, } = await this.parse(Pull);
|
|
19
19
|
const pullContext = new pull_1.PullContext(customerPath, configName);
|
|
20
20
|
const pullService = await new pull_1.PullServiceFactory(pullContext, new cli_config_1.CliConfig(this.config).load()).buildService();
|
|
21
21
|
await pullService.run();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class WptLauncher extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static args: {
|
|
@@ -17,5 +17,5 @@ export default class WptLauncher extends Command {
|
|
|
17
17
|
getViewPortSize(isMobile: boolean): string;
|
|
18
18
|
allResourceUrls(urls: string): Array<string>;
|
|
19
19
|
getResourceOrigin(urlsArr: Array<string>): string;
|
|
20
|
-
postScript(script: string): Promise<
|
|
20
|
+
postScript(script: string): Promise<NonNullable<unknown>>;
|
|
21
21
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
5
|
const core_2 = require("@oclif/core");
|
|
6
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
5
7
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
6
8
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
7
|
-
const fetch = require('node-fetch');
|
|
8
9
|
class WptLauncher extends core_1.Command {
|
|
9
|
-
static description =
|
|
10
|
+
static description = "Analyze the performance impact that Speed Kit has compared to the original version.";
|
|
10
11
|
static args = {
|
|
11
12
|
[cli_parameters_1.CLIParameters.Urls]: core_1.Args.string({
|
|
12
13
|
name: cli_parameters_1.CLIParameters.Urls, // name of arg to show in help and reference with args[name]
|
|
@@ -18,17 +19,26 @@ class WptLauncher extends core_1.Command {
|
|
|
18
19
|
}),
|
|
19
20
|
};
|
|
20
21
|
static flags = {
|
|
21
|
-
[cli_parameters_1.CLIParameters.Cookies]: core_1.Flags.string({
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
[cli_parameters_1.CLIParameters.Cookies]: core_1.Flags.string({
|
|
23
|
+
default: "",
|
|
24
|
+
char: cli_parameters_1.CLIParametersChar.Cookies,
|
|
25
|
+
}),
|
|
26
|
+
[cli_parameters_1.CLIParameters.Mobile]: core_1.Flags.string({
|
|
27
|
+
default: "no",
|
|
28
|
+
char: cli_parameters_1.CLIParametersChar.Mobile,
|
|
29
|
+
}),
|
|
30
|
+
[cli_parameters_1.CLIParameters.Group]: core_1.Flags.string({
|
|
31
|
+
default: "A",
|
|
32
|
+
char: cli_parameters_1.CLIParametersChar.Group,
|
|
33
|
+
}),
|
|
24
34
|
};
|
|
25
35
|
static examples = [
|
|
26
36
|
`$ sk wpt-launcher <${cli_parameters_1.CLIParameters.Urls}> <${cli_parameters_1.CLIParameters.TestId}> -${cli_parameters_1.CLIParametersChar.Group} <${cli_parameters_1.CLIParameters.Group}> -${cli_parameters_1.CLIParametersChar.Mobile} <${cli_parameters_1.CLIParameters.Mobile}> -${cli_parameters_1.CLIParametersChar.Cookies} <${cli_parameters_1.CLIParameters.Cookies}>`,
|
|
27
37
|
`$ sk wpt-launcher ${cli_parameters_1.CLIParametersExample.Urls} ${cli_parameters_1.CLIParametersExample.TestId} -${cli_parameters_1.CLIParametersChar.Group} ${cli_parameters_1.CLIParametersExample.Group} -${cli_parameters_1.CLIParametersChar.Mobile} ${cli_parameters_1.CLIParametersExample.Mobile} -${cli_parameters_1.CLIParametersChar.Cookies} ${cli_parameters_1.CLIParametersExample.Cookies}`,
|
|
28
38
|
];
|
|
29
|
-
static localhostUrl =
|
|
39
|
+
static localhostUrl = "http://localhost:8888/orange.html";
|
|
30
40
|
async run() {
|
|
31
|
-
const { args: { urls, testId }, flags: { group, mobile, cookies } } = await this.parse(WptLauncher);
|
|
41
|
+
const { args: { urls, testId }, flags: { group, mobile, cookies }, } = await this.parse(WptLauncher);
|
|
32
42
|
const resourceOrigin = this.getResourceOrigin(this.allResourceUrls(urls));
|
|
33
43
|
let script = `setViewportSize ${this.getViewPortSize(this.isMobile(mobile))}
|
|
34
44
|
navigate ${resourceOrigin}/wrapper-sw.js
|
|
@@ -36,43 +46,49 @@ class WptLauncher extends core_1.Command {
|
|
|
36
46
|
exec localStorage.setItem('baqend-speedkit-ab-test-info', encodeURIComponent(JSON.stringify({group:${group},testId:${testId})));
|
|
37
47
|
navigate ${resourceOrigin}
|
|
38
48
|
navigate ${WptLauncher.localhostUrl}`;
|
|
39
|
-
this.allResourceUrls(urls).forEach(url => {
|
|
49
|
+
this.allResourceUrls(urls).forEach((url) => {
|
|
40
50
|
script += `\n navigate ${url}`;
|
|
41
51
|
});
|
|
42
|
-
const postscript = await this.postScript(script);
|
|
52
|
+
const postscript = (await this.postScript(script));
|
|
43
53
|
const currentTestIdUrl = `http://wpt.baqend.com/results.php?test=${postscript.wptTestId}`;
|
|
44
54
|
if (!currentTestIdUrl) {
|
|
45
|
-
(0, logging_helper_1.logError)(
|
|
55
|
+
(0, logging_helper_1.logError)("Getting testId failed, " + currentTestIdUrl);
|
|
46
56
|
core_2.ux.exit(1);
|
|
47
57
|
}
|
|
48
|
-
this.log(
|
|
58
|
+
this.log("testUrl: ", currentTestIdUrl);
|
|
49
59
|
core_2.ux.exit(0);
|
|
50
60
|
}
|
|
51
61
|
// ---------------------- services----------------
|
|
52
62
|
isMobile(mobile) {
|
|
53
|
-
return mobile ===
|
|
63
|
+
return (mobile === "y" ||
|
|
64
|
+
mobile === "Y" ||
|
|
65
|
+
mobile === "yes" ||
|
|
66
|
+
mobile === "Yes" ||
|
|
67
|
+
mobile === "YES");
|
|
54
68
|
}
|
|
55
69
|
getViewPortSize(isMobile) {
|
|
56
70
|
if (isMobile) {
|
|
57
|
-
return
|
|
71
|
+
return "375 667"; // mobile
|
|
58
72
|
}
|
|
59
|
-
return
|
|
73
|
+
return "1500 1300"; // desktop
|
|
60
74
|
}
|
|
61
75
|
allResourceUrls(urls) {
|
|
62
|
-
const urlsArr = urls.split(
|
|
76
|
+
const urlsArr = urls.split(",");
|
|
63
77
|
if (urlsArr.length > 0) {
|
|
64
78
|
return urlsArr;
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
throw new Error('urls must not be null');
|
|
80
|
+
throw new Error("urls must not be null");
|
|
68
81
|
}
|
|
69
82
|
getResourceOrigin(urlsArr) {
|
|
70
83
|
return new URL(urlsArr[0]).origin;
|
|
71
84
|
}
|
|
72
85
|
// ---------------- wpt launcher --------------------------
|
|
73
86
|
async postScript(script) {
|
|
74
|
-
const urlPath =
|
|
75
|
-
const res = await
|
|
87
|
+
const urlPath = "https://makefast.app.baqend.com/v1/code/testAPI";
|
|
88
|
+
const res = await (0, node_fetch_1.default)(urlPath, {
|
|
89
|
+
body: JSON.stringify({ script }),
|
|
90
|
+
method: "POST",
|
|
91
|
+
});
|
|
76
92
|
return res.json();
|
|
77
93
|
}
|
|
78
94
|
}
|
|
@@ -6,17 +6,17 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
6
6
|
const isFile_1 = require("./isFile");
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const logging_helper_1 = require("./logging-helper");
|
|
9
|
-
exports.SPEED_KIT_INSTALL_PATH =
|
|
10
|
-
const CUSTOMER_CONFIG_BASENAME =
|
|
11
|
-
const SK_CONFIG =
|
|
12
|
-
const RUM_CONFIG =
|
|
13
|
-
const DF_CONFIG =
|
|
14
|
-
const DF_STYLES_BASENAME =
|
|
15
|
-
const DOCUMENT_HANDLER_CONFIG =
|
|
16
|
-
const CUSTOM_LOADER =
|
|
17
|
-
const CUSTOM_SERVICE_WORKER =
|
|
18
|
-
const CUSTOM_DOCUMENT_HANDLER =
|
|
19
|
-
const CUSTOM_DYNAMIC_FETCHER =
|
|
9
|
+
exports.SPEED_KIT_INSTALL_PATH = "/speed-kit-install.js";
|
|
10
|
+
const CUSTOMER_CONFIG_BASENAME = "config_customer.js";
|
|
11
|
+
const SK_CONFIG = "config_SpeedKit.js";
|
|
12
|
+
const RUM_CONFIG = "config_loadHandler.js";
|
|
13
|
+
const DF_CONFIG = "config_dynamicBlocks.js";
|
|
14
|
+
const DF_STYLES_BASENAME = "config_dynamicStyles.css";
|
|
15
|
+
const DOCUMENT_HANDLER_CONFIG = "config_documentHandler.js";
|
|
16
|
+
const CUSTOM_LOADER = "custom_loader.js";
|
|
17
|
+
const CUSTOM_SERVICE_WORKER = "custom_sw.js";
|
|
18
|
+
const CUSTOM_DOCUMENT_HANDLER = "custom_documentHandler.js";
|
|
19
|
+
const CUSTOM_DYNAMIC_FETCHER = "custom_dynamicFetcher.js";
|
|
20
20
|
exports.INSTALLATION_PROPERTIES = {
|
|
21
21
|
config: SK_CONFIG,
|
|
22
22
|
custom: RUM_CONFIG,
|
|
@@ -38,16 +38,16 @@ function optional(check, params, name, defaultValue = null) {
|
|
|
38
38
|
if (check(params[name])) {
|
|
39
39
|
return params[name];
|
|
40
40
|
}
|
|
41
|
-
if (typeof params[name] ===
|
|
41
|
+
if (typeof params[name] === "undefined" || params[name] === null) {
|
|
42
42
|
return defaultValue;
|
|
43
43
|
}
|
|
44
44
|
throw new TypeError(`Property "${name}" must be a ${check.name.substring(2)}.`);
|
|
45
45
|
}
|
|
46
46
|
function isString(value) {
|
|
47
|
-
return typeof value ===
|
|
47
|
+
return typeof value === "string";
|
|
48
48
|
}
|
|
49
49
|
function isBoolean(value) {
|
|
50
|
-
return typeof value ===
|
|
50
|
+
return typeof value === "boolean";
|
|
51
51
|
}
|
|
52
52
|
class CustomerConfig {
|
|
53
53
|
name;
|
|
@@ -79,6 +79,7 @@ class CustomerConfig {
|
|
|
79
79
|
if (!mainConfig) {
|
|
80
80
|
throw new Error(`Could not find customer config file "${CUSTOMER_CONFIG_BASENAME}".`);
|
|
81
81
|
}
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
82
83
|
return require(mainConfig.filePath);
|
|
83
84
|
}
|
|
84
85
|
static async loadCustomer(dir, configName) {
|
|
@@ -88,37 +89,37 @@ class CustomerConfig {
|
|
|
88
89
|
params = customerConfig[configName];
|
|
89
90
|
}
|
|
90
91
|
else {
|
|
91
|
-
(0, logging_helper_1.logWarning)(
|
|
92
|
-
(0, logging_helper_1.logWarning)(
|
|
93
|
-
(0, logging_helper_1.logWarning)(
|
|
92
|
+
(0, logging_helper_1.logWarning)("Use legacy customer config loading format.");
|
|
93
|
+
(0, logging_helper_1.logWarning)("Make sure to export the different app configs under their config names like:");
|
|
94
|
+
(0, logging_helper_1.logWarning)("module.exports = { production, staging }");
|
|
94
95
|
params = customerConfig;
|
|
95
96
|
}
|
|
96
97
|
const configs = {};
|
|
97
98
|
for (const [key, path] of Object.entries(exports.INSTALLATION_PROPERTIES)) {
|
|
98
|
-
configs[key] = await ConfigFile.loadFile(dir, path, path.replace(
|
|
99
|
+
configs[key] = await ConfigFile.loadFile(dir, path, path.replace(".js", ".es6"));
|
|
99
100
|
}
|
|
100
101
|
// Parse config
|
|
101
102
|
return new CustomerConfig({ name: configName, ...params }, {
|
|
102
103
|
...configs,
|
|
103
|
-
popConfig: await ConfigFile.loadFile(dir,
|
|
104
|
-
globalWhitelist: await ConfigFile.loadFile(dir,
|
|
105
|
-
globalBlacklist: await ConfigFile.loadFile(dir,
|
|
104
|
+
popConfig: await ConfigFile.loadFile(dir, "config_pops.js"),
|
|
105
|
+
globalWhitelist: await ConfigFile.loadFile(dir, "../../rules/global-whitelist.js"),
|
|
106
|
+
globalBlacklist: await ConfigFile.loadFile(dir, "../../rules/global-blacklist.js"),
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
constructor(params, configFiles) {
|
|
109
|
-
this.domain = required(isString, params,
|
|
110
|
-
this.name = optional(isString, params,
|
|
111
|
-
this.swPath = optional(isString, params,
|
|
112
|
-
this.app = optional(isString, params,
|
|
113
|
-
this.appDomain = optional(isString, params,
|
|
114
|
-
this.chromeFlags = optional(Array.isArray, params,
|
|
115
|
-
this.installPath = optional(isString, params,
|
|
116
|
-
const scope = optional(isString, params,
|
|
117
|
-
this.scope = scope + (scope.endsWith(
|
|
118
|
-
this.origins = optional(Array.isArray, params,
|
|
119
|
-
this.installParams = optional(isString, params,
|
|
120
|
-
this.forceInstall = optional(isBoolean, params,
|
|
121
|
-
this.bypassDeactivation = optional(isBoolean, params,
|
|
110
|
+
this.domain = required(isString, params, "domain");
|
|
111
|
+
this.name = optional(isString, params, "name");
|
|
112
|
+
this.swPath = optional(isString, params, "swPath", "/wrapper-sw.js");
|
|
113
|
+
this.app = optional(isString, params, "app");
|
|
114
|
+
this.appDomain = optional(isString, params, "appDomain", "*.app.baqend.com");
|
|
115
|
+
this.chromeFlags = optional(Array.isArray, params, "chromeFlags", []);
|
|
116
|
+
this.installPath = optional(isString, params, "installPath", exports.SPEED_KIT_INSTALL_PATH);
|
|
117
|
+
const scope = optional(isString, params, "scope", "/");
|
|
118
|
+
this.scope = scope + (scope.endsWith("/") ? "" : "/");
|
|
119
|
+
this.origins = optional(Array.isArray, params, "origins", []);
|
|
120
|
+
this.installParams = optional(isString, params, "installParams", 'async crossorigin="anonymous"');
|
|
121
|
+
this.forceInstall = optional(isBoolean, params, "forceInstall", false);
|
|
122
|
+
this.bypassDeactivation = optional(isBoolean, params, "bypassDeactivation", true);
|
|
122
123
|
// Assign Config Files
|
|
123
124
|
Object.assign(this, configFiles);
|
|
124
125
|
}
|
|
@@ -144,7 +145,7 @@ class ConfigFile {
|
|
|
144
145
|
this.name = name;
|
|
145
146
|
}
|
|
146
147
|
async readContent() {
|
|
147
|
-
return (0, promises_1.readFile)(this.filePath,
|
|
148
|
+
return (0, promises_1.readFile)(this.filePath, "utf-8");
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
exports.ConfigFile = ConfigFile;
|
|
@@ -11,19 +11,19 @@ const CustomerConfig_1 = require("./CustomerConfig");
|
|
|
11
11
|
const logging_helper_1 = require("./logging-helper");
|
|
12
12
|
async function createTemporalDir() {
|
|
13
13
|
try {
|
|
14
|
-
return fs.mkdtemp(path.join(os.tmpdir(),
|
|
14
|
+
return fs.mkdtemp(path.join(os.tmpdir(), "speed-kit-cli-"));
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
|
-
console.error(
|
|
17
|
+
console.error("Error creating temp folder", error);
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.createTemporalDir = createTemporalDir;
|
|
22
22
|
async function createEmptyFile() {
|
|
23
23
|
const tempDir = await createTemporalDir();
|
|
24
|
-
const filePath = path.join(tempDir,
|
|
24
|
+
const filePath = path.join(tempDir, "/empty_FilePath.js");
|
|
25
25
|
const writeFilePromise = new Promise((resolve, reject) => {
|
|
26
|
-
fs.writeFile(filePath,
|
|
26
|
+
fs.writeFile(filePath, "No file was found", (err) => {
|
|
27
27
|
if (err) {
|
|
28
28
|
return reject(err);
|
|
29
29
|
}
|
|
@@ -35,7 +35,7 @@ async function createEmptyFile() {
|
|
|
35
35
|
}
|
|
36
36
|
exports.createEmptyFile = createEmptyFile;
|
|
37
37
|
function trimFileExtension(str) {
|
|
38
|
-
return str.replace(
|
|
38
|
+
return str.replace(".js", "").replace(".es6", "");
|
|
39
39
|
}
|
|
40
40
|
exports.trimFileExtension = trimFileExtension;
|
|
41
41
|
async function readLocalFile(basePath, fileName) {
|
|
@@ -52,7 +52,7 @@ exports.readLocalFile = readLocalFile;
|
|
|
52
52
|
* Returns the local path to the sk-onboarding project.
|
|
53
53
|
*/
|
|
54
54
|
function getLocalPath(path) {
|
|
55
|
-
const fullCustomerPath = path_1.default.resolve(path,
|
|
55
|
+
const fullCustomerPath = path_1.default.resolve(path, "");
|
|
56
56
|
// Check if path is a valid path or not
|
|
57
57
|
if (!fs.existsSync(fullCustomerPath)) {
|
|
58
58
|
(0, logging_helper_1.logError)(`The given path: ${fullCustomerPath} is not a valid path`);
|
package/oclif.manifest.json
CHANGED