@speedkit/cli 2.18.0 → 2.19.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +36 -5
  3. package/dist/commands/build-parameter-query.js +5 -5
  4. package/dist/commands/build-prewarm-query.js +4 -4
  5. package/dist/commands/{param-diff.d.ts → diff-url-parameters.d.ts} +3 -1
  6. package/dist/commands/{param-diff.js → diff-url-parameters.js} +26 -24
  7. package/dist/commands/find-pops.js +9 -9
  8. package/dist/commands/generate-customer-config.d.ts +1 -1
  9. package/dist/commands/generate-customer-config.js +7 -7
  10. package/dist/commands/generate-pop-config.js +2 -2
  11. package/dist/commands/login.js +5 -4
  12. package/dist/commands/pop-prewarm.d.ts +3 -3
  13. package/dist/commands/pop-prewarm.js +19 -16
  14. package/dist/commands/prewarm.js +10 -10
  15. package/dist/commands/wpt-launcher.d.ts +1 -1
  16. package/dist/commands/wpt-launcher.js +9 -9
  17. package/dist/helpers/build-query-helper.d.ts +3 -3
  18. package/dist/helpers/build-query-helper.js +70 -69
  19. package/dist/helpers/cli-config.js +6 -5
  20. package/dist/helpers/{CustomerConfig.d.ts → customer-config.d.ts} +6 -6
  21. package/dist/helpers/{CustomerConfig.js → customer-config.js} +39 -39
  22. package/dist/helpers/file-helper.d.ts +1 -1
  23. package/dist/helpers/file-helper.js +5 -5
  24. package/dist/helpers/{getChromePath.js → get-chrome-path.js} +8 -8
  25. package/dist/helpers/get-parsed-config.d.ts +1 -1
  26. package/dist/helpers/get-parsed-config.js +7 -7
  27. package/dist/helpers/is-directory.d.ts +1 -0
  28. package/dist/helpers/{isDirectory.js → is-directory.js} +6 -6
  29. package/dist/helpers/{isExecutable.js → is-executable.js} +3 -3
  30. package/dist/helpers/{isFile.js → is-file.js} +4 -4
  31. package/dist/helpers/logging-helper.d.ts +3 -3
  32. package/dist/helpers/logging-helper.js +6 -6
  33. package/dist/helpers/normalize.d.ts +6 -6
  34. package/dist/helpers/normalize.js +35 -33
  35. package/dist/helpers/safe.d.ts +1 -1
  36. package/dist/helpers/safe.js +12 -12
  37. package/dist/helpers/{speedKitRuleToRegExp.js → speed-kit-rule-to-reg-exp.js} +3 -3
  38. package/dist/helpers/{watchFiles.js → watch-files.js} +2 -2
  39. package/dist/models/cli-parameters.d.ts +3 -3
  40. package/dist/models/cli-parameters.js +3 -3
  41. package/dist/services/athena/athena-service.js +2 -2
  42. package/dist/services/bundler/bundle-service.js +14 -14
  43. package/dist/services/cli/cli-service.js +8 -4
  44. package/dist/services/cli/hooks.js +3 -3
  45. package/dist/services/config-api/client.js +7 -6
  46. package/dist/services/config-api/factory/config-api-service-factory.js +4 -4
  47. package/dist/services/config-api/factory/entity-manager-factory.js +1 -1
  48. package/dist/services/config-api-service.d.ts +1 -1
  49. package/dist/services/config-api-service.js +7 -7
  50. package/dist/services/customer-config/customer-config-service-context.d.ts +2 -2
  51. package/dist/services/customer-config/customer-config-service-context.js +4 -4
  52. package/dist/services/customer-config/customer-config-service.js +45 -44
  53. package/dist/services/deploy/builder/install-resource-builder.d.ts +2 -2
  54. package/dist/services/deploy/builder/install-resource-builder.js +7 -7
  55. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +1 -1
  56. package/dist/services/deploy/checks/post-deploy/save-files-check.js +4 -4
  57. package/dist/services/deploy/deploy-service.js +2 -4
  58. package/dist/services/deploy/error/create-find-temporary-directory-error.d.ts +4 -0
  59. package/dist/services/deploy/error/{create-find-temp-directory-error.js → create-find-temporary-directory-error.js} +2 -2
  60. package/dist/services/deploy/handler/customer-config-handler.js +1 -1
  61. package/dist/services/deploy/handler/install-resource-handler.js +8 -11
  62. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +2 -2
  63. package/dist/services/deploy/handler/module-handler.js +8 -8
  64. package/dist/services/deploy/handler/server-config-handler.js +4 -4
  65. package/dist/services/diff/diff-service.d.ts +2 -2
  66. package/dist/services/diff/diff-service.js +22 -22
  67. package/dist/services/diff-service.d.ts +1 -1
  68. package/dist/services/diff-service.js +13 -13
  69. package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +10 -8
  70. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +10 -10
  71. package/dist/services/document-handler-runtime/document-handler-server.js +12 -12
  72. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +2 -2
  73. package/dist/services/document-handler-runtime/interface/template-interface.d.ts +2 -2
  74. package/dist/services/document-handler-runtime/interface/{template-param-interface.d.ts → template-parameter-interface.d.ts} +1 -1
  75. package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +2 -2
  76. package/dist/services/document-handler-runtime/templates/abstract-template.js +3 -3
  77. package/dist/services/error-handling/factory/error-handling-factory.d.ts +1 -4
  78. package/dist/services/error-handling/factory/error-handling-factory.js +2 -1
  79. package/dist/services/integration-api/factory/integration-api-service-factory.js +1 -1
  80. package/dist/services/integration-api/file-list.js +4 -3
  81. package/dist/services/integration-api/file-reader.d.ts +1 -1
  82. package/dist/services/integration-api/file-reader.js +29 -26
  83. package/dist/services/integration-api/file-writer.js +3 -3
  84. package/dist/services/integration-api/handler/file-handler.js +1 -1
  85. package/dist/services/integration-api/handler/install-resource-handler.js +1 -1
  86. package/dist/services/integration-api/handler/module-handler.js +1 -1
  87. package/dist/services/integration-api/handler/server-config-handler.js +1 -1
  88. package/dist/services/integration-api/integration-api-service.js +2 -3
  89. package/dist/services/integration-api/struct/customer-config.d.ts +1 -1
  90. package/dist/services/integration-api/struct/customer-config.js +4 -4
  91. package/dist/services/integration-api/struct/file.js +1 -1
  92. package/dist/services/integration-api/validator/customer-config-validator.js +2 -2
  93. package/dist/services/integration-api/validator/mandatory-files-validator.js +7 -6
  94. package/dist/services/integration-api/virtual/external-recipe.js +2 -1
  95. package/dist/services/onboarding/browser/baqend-response.js +1 -2
  96. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +1 -1
  97. package/dist/services/onboarding/dashboard/index.d.ts +3 -3
  98. package/dist/services/onboarding/dashboard/index.js +12 -12
  99. package/dist/services/onboarding/dashboard/{param-query-builder.d.ts → parameter-query-builder.d.ts} +1 -1
  100. package/dist/services/onboarding/dashboard/{param-query-builder.js → parameter-query-builder.js} +6 -6
  101. package/dist/services/onboarding/dashboard/request-diff-service.js +24 -22
  102. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +8 -8
  103. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +7 -7
  104. package/dist/services/onboarding/onboarding-model.js +4 -4
  105. package/dist/services/onboarding/onboarding-service-factory.js +3 -3
  106. package/dist/services/onboarding/onboarding-service.js +2 -1
  107. package/dist/services/onboarding/todo-collector.js +1 -1
  108. package/dist/services/prewarm-service.d.ts +1 -1
  109. package/dist/services/prewarm-service.js +8 -7
  110. package/dist/services/pull/pull-service.js +2 -2
  111. package/oclif.manifest.json +45 -42
  112. package/package.json +2 -1
  113. package/dist/helpers/isDirectory.d.ts +0 -1
  114. package/dist/services/context/app-context.d.ts +0 -1
  115. package/dist/services/deploy/error/create-find-temp-directory-error.d.ts +0 -4
  116. package/dist/services/document-handler-runtime/interface/template-param-interface.js +0 -2
  117. /package/dist/helpers/{getChromePath.d.ts → get-chrome-path.d.ts} +0 -0
  118. /package/dist/helpers/{isExecutable.d.ts → is-executable.d.ts} +0 -0
  119. /package/dist/helpers/{isFile.d.ts → is-file.d.ts} +0 -0
  120. /package/dist/helpers/{speedKitRuleToRegExp.d.ts → speed-kit-rule-to-reg-exp.d.ts} +0 -0
  121. /package/dist/helpers/{watchFiles.d.ts → watch-files.d.ts} +0 -0
  122. /package/dist/services/{context/app-context.js → document-handler-runtime/interface/template-parameter-interface.js} +0 -0
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomerConfigService = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs"));
6
- const path = tslib_1.__importStar(require("path"));
5
+ const fs = tslib_1.__importStar(require("node:fs"));
6
+ const path = tslib_1.__importStar(require("node:path"));
7
7
  const Handlebars = tslib_1.__importStar(require("handlebars"));
8
8
  const axios_1 = tslib_1.__importDefault(require("axios"));
9
9
  const cli_1 = require("../cli");
@@ -40,53 +40,55 @@ class CustomerConfigService {
40
40
  this.appName = appName;
41
41
  this.cli = cli;
42
42
  }
43
- getOutputDirPath(dirName = "") {
44
- return path.join(process.cwd(), this.context.customersDir, dirName);
43
+ getOutputDirPath(directoryName = "") {
44
+ return path.join(process.cwd(), this.context.customersDirectory, directoryName);
45
45
  }
46
46
  getHandlebarsOutputFileName(fileName) {
47
47
  return fileName.replace(".hbs", "");
48
48
  }
49
- getPathWithChangedDir(dirPath, newDir) {
50
- return path.join(path.dirname(dirPath), newDir);
49
+ getPathWithChangedDir(directoryPath, newDirectory) {
50
+ return path.join(path.dirname(directoryPath), newDirectory);
51
51
  }
52
- isDirNotEmpty(dirPath) {
53
- return fs.existsSync(dirPath) && fs.readdirSync(dirPath).length > 0;
52
+ isDirNotEmpty(directoryPath) {
53
+ return (fs.existsSync(directoryPath) && fs.readdirSync(directoryPath).length > 0);
54
54
  }
55
- async chooseNewOutputDirectoryName(dirPath) {
56
- const dirName = path.basename(dirPath);
57
- let proposedNewDirName;
55
+ async chooseNewOutputDirectoryName(directoryPath) {
56
+ const directoryName = path.basename(directoryPath);
57
+ let proposedNewDirectoryName;
58
58
  const regExFollowingNumber = /-(\d+)$/;
59
- const match = dirName.match(regExFollowingNumber);
59
+ const match = directoryName.match(regExFollowingNumber);
60
60
  if (match && match.length > 1) {
61
- const numberAtTheEndOfDirName = Number(match[1]);
62
- proposedNewDirName = dirName.replace(regExFollowingNumber, `-${String(numberAtTheEndOfDirName + 1)}`);
61
+ const numberAtTheEndOfDirectoryName = Number(match[1]);
62
+ proposedNewDirectoryName = directoryName.replace(regExFollowingNumber, `-${String(numberAtTheEndOfDirectoryName + 1)}`);
63
63
  }
64
64
  else {
65
- proposedNewDirName = `${dirName}-2`;
65
+ proposedNewDirectoryName = `${directoryName}-2`;
66
66
  }
67
- const newDirName = await this.cli.prompt(`Please enter new output directory name:`, {
68
- defaultAnswer: proposedNewDirName,
67
+ const newDirectoryName = await this.cli.prompt(`Please enter new output directory name:`, {
68
+ defaultAnswer: proposedNewDirectoryName,
69
69
  });
70
- return this.selectOutputDirectory(this.getPathWithChangedDir(dirPath, newDirName));
70
+ return this.selectOutputDirectory(this.getPathWithChangedDir(directoryPath, newDirectoryName));
71
71
  }
72
- async selectOutputDirectory(dirPath) {
72
+ async selectOutputDirectory(directoryPath) {
73
73
  // protect output directory if already existing and not empty:
74
- if (this.isDirNotEmpty(dirPath)) {
74
+ if (this.isDirNotEmpty(directoryPath)) {
75
75
  this.cli.spacer();
76
- const selectedDirectoryOverwriteOption = await this.cli.select(`Output directory ${dirPath} is not empty. How to proceed?`, Object.values(customer_config_service_model_1.DirectoryOverwriteOption).map((option) => ({
76
+ const selectedDirectoryOverwriteOption = await this.cli.select(`Output directory ${directoryPath} is not empty. How to proceed?`, Object.values(customer_config_service_model_1.DirectoryOverwriteOption).map((option) => ({
77
77
  name: option,
78
78
  value: option,
79
79
  })));
80
80
  switch (selectedDirectoryOverwriteOption) {
81
- case customer_config_service_model_1.DirectoryOverwriteOption.OVERWRITE_COMPLETELY:
82
- fs.rmSync(dirPath, { recursive: true, force: true });
83
- fs.mkdirSync(dirPath, { recursive: true });
81
+ case customer_config_service_model_1.DirectoryOverwriteOption.OVERWRITE_COMPLETELY: {
82
+ fs.rmSync(directoryPath, { recursive: true, force: true });
83
+ fs.mkdirSync(directoryPath, { recursive: true });
84
84
  break;
85
- case customer_config_service_model_1.DirectoryOverwriteOption.NEW_NAME:
86
- return await this.chooseNewOutputDirectoryName(dirPath);
85
+ }
86
+ case customer_config_service_model_1.DirectoryOverwriteOption.NEW_NAME: {
87
+ return await this.chooseNewOutputDirectoryName(directoryPath);
88
+ }
87
89
  }
88
90
  }
89
- return dirPath;
91
+ return directoryPath;
90
92
  }
91
93
  async compileHandlebarsFiles(configSettings) {
92
94
  // overwriting protection for output directory:
@@ -110,7 +112,7 @@ class CustomerConfigService {
110
112
  fs.writeFileSync(outputFilePath, result);
111
113
  this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
112
114
  }
113
- catch (error) {
115
+ catch {
114
116
  this.cli.endAction(cli_1.CliActionStatus.FAILED);
115
117
  }
116
118
  }
@@ -154,14 +156,14 @@ class CustomerConfigService {
154
156
  fs.writeFileSync(outputFilePath, contentWithBanner);
155
157
  this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
156
158
  }
157
- catch (error) {
159
+ catch {
158
160
  this.cli.endAction(cli_1.CliActionStatus.FAILED);
159
161
  }
160
162
  }
161
163
  async getConfigSettings() {
162
164
  let { production, staging, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, activateRumTracking, useGATracking, withGoogleOptimize, activateCfRocketLoaderWorkaround, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
163
165
  this.appName = await this.cli.prompt(`Enter SK App Name:`, {
164
- validator: (input) => /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(input) ? "" : "No valid kebab-case",
166
+ validator: (input) => /^[\da-z]+(?:-[\da-z]+)*$/.test(input) ? "" : "No valid kebab-case",
165
167
  defaultAnswer: this.appName,
166
168
  });
167
169
  const selectedShopSystem = await this.cli.select("Which Shop System is in use?", Object.values(customer_config_service_model_1.ShopSystem).map((option) => ({
@@ -169,17 +171,21 @@ class CustomerConfigService {
169
171
  value: option,
170
172
  })));
171
173
  switch (selectedShopSystem) {
172
- case customer_config_service_model_1.ShopSystem.SHOPIFY:
174
+ case customer_config_service_model_1.ShopSystem.SHOPIFY: {
173
175
  isShopify = true;
174
176
  break;
175
- case customer_config_service_model_1.ShopSystem.SHOPWARE:
177
+ }
178
+ case customer_config_service_model_1.ShopSystem.SHOPWARE: {
176
179
  isShopware = true;
177
180
  break;
178
- case customer_config_service_model_1.ShopSystem.SALESFORCE:
181
+ }
182
+ case customer_config_service_model_1.ShopSystem.SALESFORCE: {
179
183
  isSalesforce = true;
180
184
  break;
181
- case customer_config_service_model_1.ShopSystem.PLENTYMARKETS:
185
+ }
186
+ case customer_config_service_model_1.ShopSystem.PLENTYMARKETS: {
182
187
  isPlentymarkets = true;
188
+ }
183
189
  }
184
190
  production = await this.getEnvironmentConfig(customer_config_service_model_1.EnvironmentType.PRODUCTION, `www.${this.appName}.de`);
185
191
  if (isShopify) {
@@ -200,18 +206,13 @@ class CustomerConfigService {
200
206
  removeLazyLoading = await this.cli.confirm("Remove Lazy-Loading?");
201
207
  addPreRendering = await this.cli.confirm("Add Pre-Rendering? This requires a set-up Lambda function to work. Also requires a DOM-based DocumentHandler.", false);
202
208
  activateRumTracking = await this.cli.confirm("Activate RUM Tracking?");
203
- if (activateRumTracking) {
204
- if (!isShopify) {
205
- useGATracking = await this.cli.confirm("Add Tracking based on Google Analytics' DataLayer?");
206
- }
209
+ if (activateRumTracking && !isShopify) {
210
+ useGATracking = await this.cli.confirm("Add Tracking based on Google Analytics' DataLayer?");
207
211
  }
208
212
  withGoogleOptimize = await this.cli.confirm("Is Google Optimize being used?", false);
209
- if (isShopify) {
210
- activateCfRocketLoaderWorkaround = true;
211
- }
212
- else {
213
- activateCfRocketLoaderWorkaround = await this.cli.confirm("Activate Workaround for Cloudflare's Rocket Loader?", false);
214
- }
213
+ activateCfRocketLoaderWorkaround = isShopify
214
+ ? true
215
+ : await this.cli.confirm("Activate Workaround for Cloudflare's Rocket Loader?", false);
215
216
  return {
216
217
  appName: this.appName,
217
218
  production,
@@ -6,8 +6,8 @@ export default class InstallResourceBuilder {
6
6
  configApi: ConfigApi;
7
7
  constructor(configApi: ConfigApi);
8
8
  init(configName: string): Promise<Install>;
9
- merge(installParams: Install): void;
10
- updateFromRemote(remoteParams: Install): Install;
9
+ merge(installParameters: Install): void;
10
+ updateFromRemote(remoteParameters: Install): Install;
11
11
  hasChanges(): boolean;
12
12
  getInstallResource(): Install;
13
13
  private deepMerge;
@@ -22,16 +22,16 @@ class InstallResourceBuilder {
22
22
  };
23
23
  return this.resource;
24
24
  }
25
- merge(installParams) {
25
+ merge(installParameters) {
26
26
  this.changed = true;
27
- this.resource = this.deepMerge(this.resource, installParams);
27
+ this.resource = this.deepMerge(this.resource, installParameters);
28
28
  }
29
- updateFromRemote(remoteParams) {
29
+ updateFromRemote(remoteParameters) {
30
30
  this.changed = true;
31
- this.resource = this.deepMerge(remoteParams, this.resource);
32
- this.resource.id = remoteParams.id;
33
- this.resource.version = remoteParams.version;
34
- this.resource.configVersion = remoteParams.configVersion;
31
+ this.resource = this.deepMerge(remoteParameters, this.resource);
32
+ this.resource.id = remoteParameters.id;
33
+ this.resource.version = remoteParameters.version;
34
+ this.resource.configVersion = remoteParameters.configVersion;
35
35
  this.resource.status = "inactive";
36
36
  return this.resource;
37
37
  }
@@ -17,7 +17,7 @@ class RevalidatedModuleCheck {
17
17
  this.showMessage();
18
18
  }
19
19
  }
20
- catch (error) {
20
+ catch {
21
21
  this.showMessage();
22
22
  }
23
23
  }
@@ -11,14 +11,14 @@ class SaveFilesCheck {
11
11
  const fileList = this.fileList.files.filter((file) => {
12
12
  return file.isUpdated();
13
13
  });
14
- if (fileList.length < 1) {
14
+ if (fileList.length === 0) {
15
15
  return;
16
16
  }
17
17
  if (await this.cli.confirm(`Changes to localFiles will be saved now. Proceed?`)) {
18
- fileList.forEach((file) => {
19
- file.updateIfChanged();
18
+ for (const file of fileList) {
19
+ await file.updateIfChanged();
20
20
  this.cli.writeSuccess(`${file.name} saved`);
21
- });
21
+ }
22
22
  }
23
23
  }
24
24
  }
@@ -22,16 +22,14 @@ class DeployService extends abstract_async_error_handling_service_1.default {
22
22
  this.cli.write(`App: "${this.fileList.getCustomerConfig().config.app}", Install: "${this.fileList.getCustomerConfig().config.name}"`);
23
23
  this.cli.write("Preparing deployment...");
24
24
  this.cli.spacer();
25
- for (let iterator = 0; iterator < types.length; iterator++) {
26
- const type = types[iterator];
25
+ for (const type of types) {
27
26
  await this.handleType(type);
28
27
  }
29
28
  if (this.dryRun) {
30
29
  this.cli.comment("dryRunFlag -d is set, skip upload");
31
30
  }
32
31
  else {
33
- for (let iterator = 0; iterator < types.length; iterator++) {
34
- const type = types[iterator];
32
+ for (const type of types) {
35
33
  await this.uploadType(type);
36
34
  }
37
35
  }
@@ -0,0 +1,4 @@
1
+ import DeployAppError from "./deploy-app-error";
2
+ export default class CreateFindTemporaryDirectoryError extends DeployAppError {
3
+ constructor();
4
+ }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const deploy_app_error_1 = tslib_1.__importDefault(require("./deploy-app-error"));
5
- class CreateFindTempDirectoryError extends deploy_app_error_1.default {
5
+ class CreateFindTemporaryDirectoryError extends deploy_app_error_1.default {
6
6
  constructor() {
7
7
  super(`No temporary Directory found and unable to create a new temporary Directory`);
8
8
  }
9
9
  }
10
- exports.default = CreateFindTempDirectoryError;
10
+ exports.default = CreateFindTemporaryDirectoryError;
@@ -31,7 +31,7 @@ class CustomerConfigHandler {
31
31
  this.cli.code(JSON.stringify(config.origins), true);
32
32
  return;
33
33
  }
34
- if (!installResource.origins || installResource.origins.length < 1) {
34
+ if (!installResource.origins || installResource.origins.length === 0) {
35
35
  this.cli.write("with origins:", true);
36
36
  this.cli.code(JSON.stringify(config.origins), true);
37
37
  return;
@@ -24,14 +24,13 @@ class InstallResourceHandler {
24
24
  }
25
25
  async handle(files) {
26
26
  const installResource = await this.configApi.getActiveInstall(this.configName);
27
- for (let iterator = 0; iterator < files.length; iterator++) {
28
- const file = files[iterator];
27
+ for (const file of files) {
29
28
  await this.processFile(file, installResource);
30
29
  }
31
30
  }
32
31
  async upload(files) {
33
- for (let iterator = 0; iterator < files.length; iterator++) {
34
- const file = files[iterator];
32
+ for (const file_ of files) {
33
+ const file = file_;
35
34
  if (file.shouldSkipFile()) {
36
35
  continue;
37
36
  }
@@ -72,10 +71,7 @@ class InstallResourceHandler {
72
71
  }
73
72
  async confirm(file, isNew = false) {
74
73
  const confirm = await this.cli.confirm(`${isNew ? "Create" : "Update"} ${file.name}?`);
75
- if (!confirm) {
76
- file.skipFile();
77
- }
78
- else {
74
+ if (confirm) {
79
75
  if (isNew) {
80
76
  this.cli.write(`consider new ${file.name}`, true);
81
77
  }
@@ -83,15 +79,16 @@ class InstallResourceHandler {
83
79
  this.cli.write(`consider changed ${file.name}`, true);
84
80
  }
85
81
  }
82
+ else {
83
+ file.skipFile();
84
+ }
86
85
  }
87
86
  async getInstallResource() {
88
87
  let install = await this.builder.init(this.configName);
89
88
  const remoteClone = await this.prepareRemoteInstallResource(install);
90
89
  install = this.builder.updateFromRemote(remoteClone);
91
90
  install.description = await this.cli.prompt("Describe new configuration:", {
92
- defaultAnswer: install.description
93
- ? install.description
94
- : this.configName,
91
+ defaultAnswer: install.description ?? this.configName,
95
92
  validator: (input) => (input.trim() ? "" : "Please enter something"),
96
93
  });
97
94
  return install;
@@ -35,9 +35,9 @@ class DeletedFileCheck {
35
35
  }
36
36
  }
37
37
  async checkForDeletedLocalFiles(installResource) {
38
- this.keysToDelete.forEach((key) => {
38
+ for (const key of this.keysToDelete) {
39
39
  installResource[key] = null;
40
- });
40
+ }
41
41
  }
42
42
  getFileByRemoteKey(key, files) {
43
43
  const filteredFiles = files.filter((file) => {
@@ -17,8 +17,8 @@ class ModuleHandler {
17
17
  return type === module_file_1.default;
18
18
  }
19
19
  async handle(files) {
20
- for (let iterator = 0; iterator < files.length; iterator++) {
21
- const file = files[iterator];
20
+ for (const file_ of files) {
21
+ const file = file_;
22
22
  const remote = await this.configApi.getModule(file.name);
23
23
  for (let iterator = 0; iterator < this.modifiers.length; iterator++) {
24
24
  const modifier = this.modifiers[iterator];
@@ -51,8 +51,8 @@ class ModuleHandler {
51
51
  this.cli.write("Summary");
52
52
  this.cli.writeBuffer();
53
53
  if (await this.cli.confirm(`${filesToUpload.length} Module(s) will be uploaded now. Proceed?`)) {
54
- for (let iterator = 0; iterator < files.length; iterator++) {
55
- const file = files[iterator];
54
+ for (const file_ of files) {
55
+ const file = file_;
56
56
  await this.configApi.setModule(file.getContent(), file.name);
57
57
  for (let iterator = 0; iterator < this.modifiers.length; iterator++) {
58
58
  const modifier = this.modifiers[iterator];
@@ -65,10 +65,7 @@ class ModuleHandler {
65
65
  }
66
66
  async confirm(file, isNew = false) {
67
67
  const confirm = await this.cli.confirm(`${isNew ? "Create" : "Update"} ${file.name}?`);
68
- if (!confirm) {
69
- file.skipFile();
70
- }
71
- else {
68
+ if (confirm) {
72
69
  if (isNew) {
73
70
  this.cli.write(`consider new ${file.name}`, true);
74
71
  }
@@ -76,6 +73,9 @@ class ModuleHandler {
76
73
  this.cli.write(`consider changed ${file.name}`, true);
77
74
  }
78
75
  }
76
+ else {
77
+ file.skipFile();
78
+ }
79
79
  }
80
80
  }
81
81
  exports.default = ModuleHandler;
@@ -47,10 +47,7 @@ class ServerConfigHandler {
47
47
  }
48
48
  async confirm(file, isNew = false) {
49
49
  const confirm = await this.cli.confirm(`Deploy ${file.name}?`, true);
50
- if (!confirm) {
51
- file.skipFile();
52
- }
53
- else {
50
+ if (confirm) {
54
51
  if (isNew) {
55
52
  this.cli.writeSuccess(`${file.name} is new`, true);
56
53
  }
@@ -58,6 +55,9 @@ class ServerConfigHandler {
58
55
  this.cli.writeSuccess(`${file.name} has changed`, true);
59
56
  }
60
57
  }
58
+ else {
59
+ file.skipFile();
60
+ }
61
61
  }
62
62
  }
63
63
  exports.default = ServerConfigHandler;
@@ -5,7 +5,7 @@ export declare class DiffService {
5
5
  private diffExecutableTemplate?;
6
6
  private tempPath;
7
7
  constructor(cli: CliService, diffExecutablePath?: string, diffExecutableTemplate?: string);
8
- diff(localPath: string, fileName: string, tmpContent: string): Promise<boolean>;
8
+ diff(localPath: string, fileName: string, temporaryContent: string): Promise<boolean>;
9
9
  diffContent(fileName: string, localContent: string, remoteContent: string): Promise<{
10
10
  changedFile: string;
11
11
  diff: boolean;
@@ -14,7 +14,7 @@ export declare class DiffService {
14
14
  * Returns a temporal directory path.
15
15
  */
16
16
  getTemporalDirectoryPath(): Promise<string>;
17
- writeContentToTemporalFile(tempFileName: string, content: string): Promise<string>;
17
+ writeContentToTemporalFile(temporaryFileName: string, content: string): Promise<string>;
18
18
  /**
19
19
  * @param localContent local file content.
20
20
  * @param remoteContent remote content.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DiffService = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const promises_1 = tslib_1.__importStar(require("fs/promises"));
7
- const child_process_1 = require("child_process");
5
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
+ const promises_1 = tslib_1.__importStar(require("node:fs/promises"));
7
+ const node_child_process_1 = require("node:child_process");
8
8
  const file_helper_1 = require("../../helpers/file-helper");
9
9
  class DiffService {
10
10
  cli;
@@ -16,15 +16,15 @@ class DiffService {
16
16
  this.diffExecutablePath = diffExecutablePath;
17
17
  this.diffExecutableTemplate = diffExecutableTemplate;
18
18
  }
19
- async diff(localPath, fileName, tmpContent) {
20
- const tmpFilePath = await this.writeContentToTemporalFile(fileName, tmpContent);
21
- return await this.executeDiff(tmpFilePath, localPath);
19
+ async diff(localPath, fileName, temporaryContent) {
20
+ const temporaryFilePath = await this.writeContentToTemporalFile(fileName, temporaryContent);
21
+ return await this.executeDiff(temporaryFilePath, localPath);
22
22
  }
23
23
  async diffContent(fileName, localContent, remoteContent) {
24
- const tmpLocalFilePath = await this.writeContentToTemporalFile(`${fileName}-local`, localContent);
25
- const tmpRemoteFilePath = await this.writeContentToTemporalFile(`${fileName}-remote`, remoteContent);
26
- const diff = await this.executeDiff(tmpLocalFilePath, tmpRemoteFilePath);
27
- const changedFile = await (0, promises_1.readFile)(tmpLocalFilePath, "utf-8");
24
+ const temporaryLocalFilePath = await this.writeContentToTemporalFile(`${fileName}-local`, localContent);
25
+ const temporaryRemoteFilePath = await this.writeContentToTemporalFile(`${fileName}-remote`, remoteContent);
26
+ const diff = await this.executeDiff(temporaryLocalFilePath, temporaryRemoteFilePath);
27
+ const changedFile = await (0, promises_1.readFile)(temporaryLocalFilePath, "utf-8");
28
28
  return { changedFile, diff };
29
29
  }
30
30
  /**
@@ -33,7 +33,7 @@ class DiffService {
33
33
  async getTemporalDirectoryPath() {
34
34
  // create temporal directory for remote installationFiles so the diff can be generated
35
35
  if (!this.tempPath) {
36
- this.tempPath = await (0, file_helper_1.createTemporalDir)();
36
+ this.tempPath = await (0, file_helper_1.createTemporalDirectory)();
37
37
  }
38
38
  if (!this.tempPath) {
39
39
  this.cli.writeError("No temporary Directory found and unable to create a new temporary Directory");
@@ -41,12 +41,12 @@ class DiffService {
41
41
  }
42
42
  return this.tempPath;
43
43
  }
44
- async writeContentToTemporalFile(tempFileName, content) {
44
+ async writeContentToTemporalFile(temporaryFileName, content) {
45
45
  if (!content) {
46
46
  content = "No file was found";
47
47
  }
48
- const resolveFilePath = path_1.default.join((await this.getTemporalDirectoryPath()) + `/${tempFileName}`);
49
- await promises_1.default.writeFile(resolveFilePath, content.replace(/\r?\n/gm, "\n"));
48
+ const resolveFilePath = node_path_1.default.join((await this.getTemporalDirectoryPath()) + `/${temporaryFileName}`);
49
+ await promises_1.default.writeFile(resolveFilePath, content.replaceAll(/\r?\n/gm, "\n"));
50
50
  return resolveFilePath;
51
51
  }
52
52
  /**
@@ -56,8 +56,8 @@ class DiffService {
56
56
  * @return returns true if both localContent and remoteContent are equal otherwise returns false.
57
57
  */
58
58
  isContentEqual(localContent = "", remoteContent = "") {
59
- const trimLocalContent = localContent.replace(/[\n\r\s]/g, "");
60
- const trimRemoteContent = remoteContent.replace(/[\n\r\s]/g, "");
59
+ const trimLocalContent = localContent.replaceAll(/\s/g, "");
60
+ const trimRemoteContent = remoteContent.replaceAll(/\s/g, "");
61
61
  return trimLocalContent === trimRemoteContent;
62
62
  }
63
63
  /**
@@ -77,7 +77,7 @@ class DiffService {
77
77
  flag: "r",
78
78
  });
79
79
  }
80
- catch (error) {
80
+ catch {
81
81
  return false;
82
82
  }
83
83
  try {
@@ -106,7 +106,7 @@ class DiffService {
106
106
  .replace("$exec", this.diffExecutablePath)
107
107
  .replace("$file1", localPath)
108
108
  .replace("$file2", remotePath);
109
- (0, child_process_1.execSync)(command, { stdio: "pipe" });
109
+ (0, node_child_process_1.execSync)(command, { stdio: "pipe" });
110
110
  }
111
111
  catch (error) {
112
112
  this.cli.code(error.stdout.toString());
@@ -116,19 +116,19 @@ class DiffService {
116
116
  const isWindows = process.platform.startsWith("win");
117
117
  let ideaCommandAvailable;
118
118
  try {
119
- (0, child_process_1.execSync)(`idea diff "${localPath}" "${remotePath}"`);
119
+ (0, node_child_process_1.execSync)(`idea diff "${localPath}" "${remotePath}"`);
120
120
  ideaCommandAvailable = true;
121
121
  }
122
- catch (error) {
122
+ catch {
123
123
  ideaCommandAvailable = false;
124
124
  }
125
125
  try {
126
126
  if (!ideaCommandAvailable) {
127
127
  if (isWindows) {
128
- (0, child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
128
+ (0, node_child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
129
129
  }
130
130
  else {
131
- (0, child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
131
+ (0, node_child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
132
132
  }
133
133
  }
134
134
  return false;
@@ -7,7 +7,7 @@ export declare class DiffService {
7
7
  * Returns a temporal directory path.
8
8
  */
9
9
  getTemporalDirectoryPath(): Promise<string>;
10
- writeContentToTemporalFile(tempFileName: string, content: string): Promise<string>;
10
+ writeContentToTemporalFile(temporaryFileName: string, content: string): Promise<string>;
11
11
  /**
12
12
  * @description removes whitespaces, newlines and compares both params content for equality.
13
13
  * @param content
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DiffService = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs/promises"));
6
- const child_process_1 = require("child_process");
7
- const path_1 = tslib_1.__importDefault(require("path"));
5
+ const fs = tslib_1.__importStar(require("node:fs/promises"));
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
8
  const file_helper_1 = require("../helpers/file-helper");
9
9
  class DiffService {
10
10
  cli;
@@ -18,7 +18,7 @@ class DiffService {
18
18
  async getTemporalDirectoryPath() {
19
19
  // create temporal directory for remote installationFiles so the diff can be generated
20
20
  if (!this.tempPath) {
21
- this.tempPath = await (0, file_helper_1.createTemporalDir)();
21
+ this.tempPath = await (0, file_helper_1.createTemporalDirectory)();
22
22
  }
23
23
  if (!this.tempPath) {
24
24
  this.cli.writeError("No temporary Directory found and unable to create a new temporary Directory");
@@ -26,12 +26,12 @@ class DiffService {
26
26
  }
27
27
  return this.tempPath;
28
28
  }
29
- async writeContentToTemporalFile(tempFileName, content) {
29
+ async writeContentToTemporalFile(temporaryFileName, content) {
30
30
  if (!content) {
31
31
  content = "No file was found";
32
32
  }
33
- const resolveFilePath = path_1.default.join((await this.getTemporalDirectoryPath()) + `/${tempFileName}`);
34
- await fs.writeFile(resolveFilePath, content.replace(/\r?\n/gm, "\n"));
33
+ const resolveFilePath = node_path_1.default.join((await this.getTemporalDirectoryPath()) + `/${temporaryFileName}`);
34
+ await fs.writeFile(resolveFilePath, content.replaceAll(/\r?\n/gm, "\n"));
35
35
  return resolveFilePath;
36
36
  }
37
37
  /**
@@ -39,7 +39,7 @@ class DiffService {
39
39
  * @param content
40
40
  */
41
41
  trimContent(content) {
42
- return content.replace(/[\n\r\s]/g, "");
42
+ return content.replaceAll(/\s/g, "");
43
43
  }
44
44
  /**
45
45
  * @param content1
@@ -66,14 +66,14 @@ class DiffService {
66
66
  content1 = await fs.readFile(filePath1, { encoding: "utf8", flag: "r" });
67
67
  }
68
68
  catch (error) {
69
- this.cli.writeError(`Error reading ${path_1.default.basename(filePath1)}: ${error.message}`);
69
+ this.cli.writeError(`Error reading ${node_path_1.default.basename(filePath1)}: ${error.message}`);
70
70
  this.cli.exit(1);
71
71
  }
72
72
  try {
73
73
  content2 = await fs.readFile(filePath2, { encoding: "utf8", flag: "r" });
74
74
  }
75
75
  catch (error) {
76
- this.cli.writeError(`Error reading ${path_1.default.basename(filePath2)}: ${error.message}`);
76
+ this.cli.writeError(`Error reading ${node_path_1.default.basename(filePath2)}: ${error.message}`);
77
77
  this.cli.exit(1);
78
78
  }
79
79
  // Returning if no difference
@@ -86,7 +86,7 @@ class DiffService {
86
86
  const isWindows = process.platform.startsWith("win");
87
87
  let ideaCommandAvailable;
88
88
  try {
89
- (0, child_process_1.execSync)(`idea diff "${filePath1}" "${filePath2}"`, { stdio: "pipe" });
89
+ (0, node_child_process_1.execSync)(`idea diff "${filePath1}" "${filePath2}"`, { stdio: "pipe" });
90
90
  ideaCommandAvailable = true;
91
91
  }
92
92
  catch {
@@ -95,10 +95,10 @@ class DiffService {
95
95
  try {
96
96
  if (!ideaCommandAvailable) {
97
97
  if (isWindows) {
98
- (0, child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
98
+ (0, node_child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
99
99
  }
100
100
  else {
101
- (0, child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
101
+ (0, node_child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
102
102
  }
103
103
  }
104
104
  }