@speedkit/cli 2.26.0 → 2.27.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 (144) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/dist/models/files.d.ts +4 -0
  4. package/dist/models/files.js +4 -0
  5. package/dist/services/cli/error/cli-type-error.d.ts +1 -2
  6. package/dist/services/cli/error/cli-type-error.js +1 -3
  7. package/dist/services/config-api/context/config-api-context.d.ts +1 -2
  8. package/dist/services/config-api/factory/config-api-service-factory.js +1 -2
  9. package/dist/services/config-api/interface/config-api-context-interface.d.ts +1 -2
  10. package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +1 -1
  11. package/dist/services/deploy/checks/pre-deploy/split-change-check.d.ts +1 -2
  12. package/dist/services/deploy/deploy-service-factory.js +3 -4
  13. package/dist/services/deploy/deploy-service.d.ts +3 -2
  14. package/dist/services/deploy/deploy-service.js +23 -1
  15. package/dist/services/deploy/handler/customer-config-handler.d.ts +4 -5
  16. package/dist/services/deploy/handler/customer-config-handler.js +2 -2
  17. package/dist/services/deploy/handler/install-resource-handler.d.ts +3 -4
  18. package/dist/services/deploy/handler/install-resource-handler.js +2 -3
  19. package/dist/services/deploy/handler/module-handler.d.ts +8 -5
  20. package/dist/services/deploy/handler/module-handler.js +2 -3
  21. package/dist/services/deploy/handler/server-config-handler.d.ts +9 -6
  22. package/dist/services/deploy/handler/server-config-handler.js +6 -4
  23. package/dist/services/document-handler-runtime/document-handler-runtime-service.d.ts +2 -3
  24. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +2 -6
  25. package/dist/services/document-handler-runtime/document-handler-server.d.ts +1 -2
  26. package/dist/services/document-handler-runtime/document-handler-server.js +2 -5
  27. package/dist/services/document-handler-runtime/error/required-file-not-found-error.d.ts +1 -2
  28. package/dist/services/document-handler-runtime/error/required-file-not-found-error.js +1 -3
  29. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +3 -6
  30. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +9 -18
  31. package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +1 -2
  32. package/dist/services/integration-api/error/customer-config-legacy-error.js +1 -3
  33. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +1 -2
  34. package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +1 -1
  35. package/dist/services/integration-api/error/handler/origin-handler.d.ts +1 -2
  36. package/dist/services/integration-api/error/handler/origin-handler.js +1 -1
  37. package/dist/services/integration-api/error/origin-error.d.ts +1 -2
  38. package/dist/services/integration-api/error/origin-error.js +1 -3
  39. package/dist/services/integration-api/file-list.d.ts +3 -5
  40. package/dist/services/integration-api/file-list.js +6 -10
  41. package/dist/services/integration-api/file-reader.d.ts +14 -6
  42. package/dist/services/integration-api/file-reader.js +8 -8
  43. package/dist/services/integration-api/file-writer.d.ts +10 -2
  44. package/dist/services/integration-api/file-writer.js +9 -6
  45. package/dist/services/integration-api/handler/customer-config-handler.js +6 -8
  46. package/dist/services/integration-api/handler/install-resource-handler.js +3 -4
  47. package/dist/services/integration-api/handler/module-handler.js +2 -2
  48. package/dist/services/integration-api/handler/server-config-handler.js +2 -2
  49. package/dist/services/integration-api/index.d.ts +3 -0
  50. package/dist/services/integration-api/index.js +6 -0
  51. package/dist/services/integration-api/integration-api-factory.d.ts +13 -0
  52. package/dist/services/integration-api/integration-api-factory.js +50 -0
  53. package/dist/services/integration-api/integration-api-model.d.ts +33 -14
  54. package/dist/services/integration-api/integration-api-model.js +37 -0
  55. package/dist/services/integration-api/integration-api-service.d.ts +1 -2
  56. package/dist/services/integration-api/integration-api-service.js +3 -23
  57. package/dist/services/integration-api/spec/customer-config-validator.spec.d.ts +1 -0
  58. package/dist/services/integration-api/spec/customer-config-validator.spec.js +50 -0
  59. package/dist/services/integration-api/spec/file-list.spec.d.ts +1 -0
  60. package/dist/services/integration-api/spec/file-list.spec.js +163 -0
  61. package/dist/services/integration-api/spec/file-reader.spec.d.ts +1 -0
  62. package/dist/services/integration-api/spec/file-reader.spec.js +71 -0
  63. package/dist/services/integration-api/spec/file-writer.spec.d.ts +1 -0
  64. package/dist/services/integration-api/spec/file-writer.spec.js +55 -0
  65. package/dist/services/integration-api/spec/integration-api-service.spec.d.ts +1 -0
  66. package/dist/services/integration-api/spec/integration-api-service.spec.js +122 -0
  67. package/dist/services/integration-api/spec/mandatory-files-validator.spec.d.ts +1 -0
  68. package/dist/services/integration-api/spec/mandatory-files-validator.spec.js +105 -0
  69. package/dist/services/integration-api/struct/customer-config-file.d.ts +3 -4
  70. package/dist/services/integration-api/struct/customer-config-file.js +7 -6
  71. package/dist/services/integration-api/struct/customer-config.d.ts +3 -5
  72. package/dist/services/integration-api/struct/customer-config.js +5 -8
  73. package/dist/services/integration-api/struct/file.d.ts +4 -4
  74. package/dist/services/integration-api/struct/file.js +6 -6
  75. package/dist/services/integration-api/struct/install-resource-file.d.ts +4 -3
  76. package/dist/services/integration-api/struct/install-resource-file.js +7 -5
  77. package/dist/services/integration-api/struct/module-file.d.ts +4 -3
  78. package/dist/services/integration-api/struct/module-file.js +7 -5
  79. package/dist/services/integration-api/struct/ro-file.d.ts +2 -2
  80. package/dist/services/integration-api/struct/ro-file.js +1 -1
  81. package/dist/services/integration-api/struct/server-config-file.d.ts +5 -4
  82. package/dist/services/integration-api/struct/server-config-file.js +7 -5
  83. package/dist/services/integration-api/struct/virtual-file.d.ts +2 -2
  84. package/dist/services/integration-api/struct/virtual-file.js +2 -1
  85. package/dist/services/integration-api/validator/customer-config-validator.d.ts +5 -1
  86. package/dist/services/integration-api/validator/customer-config-validator.js +28 -17
  87. package/dist/services/integration-api/virtual/static-recipe.d.ts +6 -0
  88. package/dist/services/integration-api/virtual/static-recipe.js +14 -0
  89. package/dist/services/integration-api/virtual/virtual-file-handler.js +2 -2
  90. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +1 -2
  91. package/dist/services/onboarding/dashboard/index.d.ts +1 -1
  92. package/dist/services/onboarding/dashboard/parameter-query-builder.d.ts +1 -2
  93. package/dist/services/onboarding/fetch-event-handler.d.ts +1 -1
  94. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +1 -2
  95. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +1 -1
  96. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +1 -1
  97. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +1 -1
  98. package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +1 -2
  99. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +1 -1
  100. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +1 -2
  101. package/dist/services/onboarding/file-events/file-watcher.d.ts +1 -2
  102. package/dist/services/onboarding/file-events/file-watcher.js +3 -3
  103. package/dist/services/onboarding/onboarding-service-factory.js +9 -13
  104. package/dist/services/onboarding/onboarding-service.d.ts +1 -1
  105. package/dist/services/onboarding/todo-collector.js +2 -2
  106. package/dist/services/pull/pull-service-factory.js +3 -4
  107. package/dist/services/pull/pull-service.d.ts +1 -1
  108. package/dist/services/pull/pull-service.js +2 -3
  109. package/oclif.manifest.json +1 -1
  110. package/package.json +5 -5
  111. package/dist/services/context/error/context-runtime-error.d.ts +0 -3
  112. package/dist/services/context/error/context-runtime-error.js +0 -7
  113. package/dist/services/context/interface/context-interface.d.ts +0 -2
  114. package/dist/services/context/interface/context-interface.js +0 -2
  115. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts +0 -6
  116. package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +0 -14
  117. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.d.ts +0 -6
  118. package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +0 -19
  119. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.d.ts +0 -6
  120. package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +0 -18
  121. package/dist/services/error-handling/abstract/abstract-error-handling-factory.d.ts +0 -6
  122. package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +0 -19
  123. package/dist/services/error-handling/abstract/abstract-error-handling-service.d.ts +0 -6
  124. package/dist/services/error-handling/abstract/abstract-error-handling-service.js +0 -19
  125. package/dist/services/error-handling/error/application-error.d.ts +0 -5
  126. package/dist/services/error-handling/error/application-error.js +0 -11
  127. package/dist/services/error-handling/error-handling-service.d.ts +0 -7
  128. package/dist/services/error-handling/error-handling-service.js +0 -27
  129. package/dist/services/error-handling/factory/error-handling-factory.d.ts +0 -5
  130. package/dist/services/error-handling/factory/error-handling-factory.js +0 -22
  131. package/dist/services/error-handling/interface/error-context-interface.d.ts +0 -6
  132. package/dist/services/error-handling/interface/error-context-interface.js +0 -2
  133. package/dist/services/error-handling/interface/error-handler-interface.d.ts +0 -5
  134. package/dist/services/error-handling/interface/error-handler-interface.js +0 -2
  135. package/dist/services/error-handling/interface/error-handling-factory-interface.d.ts +0 -8
  136. package/dist/services/error-handling/interface/error-handling-factory-interface.js +0 -2
  137. package/dist/services/error-handling/interface/error-handling-service-interface.d.ts +0 -8
  138. package/dist/services/error-handling/interface/error-handling-service-interface.js +0 -2
  139. package/dist/services/integration-api/context/integration-api-context.d.ts +0 -9
  140. package/dist/services/integration-api/context/integration-api-context.js +0 -20
  141. package/dist/services/integration-api/error/handler/customer-config-handler.d.ts +0 -5
  142. package/dist/services/integration-api/error/handler/customer-config-handler.js +0 -19
  143. package/dist/services/integration-api/factory/integration-api-service-factory.d.ts +0 -13
  144. package/dist/services/integration-api/factory/integration-api-service-factory.js +0 -55
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chai_1 = require("chai");
5
+ const mocha_1 = require("mocha");
6
+ const customer_config_validator_1 = tslib_1.__importDefault(require("../validator/customer-config-validator"));
7
+ const customer_config_1 = require("../struct/customer-config");
8
+ (0, mocha_1.describe)("customer_config_validator validate", () => {
9
+ (0, mocha_1.it)("should have no errors", () => {
10
+ const validator = new customer_config_validator_1.default();
11
+ const customerConfig = new customer_config_1.CustomerConfig("test", ["https://test.dev"], "test.dev", "/wrapper.sw", "/");
12
+ validator.validate(customerConfig);
13
+ (0, chai_1.expect)(true).to.be.true;
14
+ });
15
+ (0, mocha_1.it)("should throw error hasDuplicates", () => {
16
+ const validator = new customer_config_validator_1.default();
17
+ const customerConfig = new customer_config_1.CustomerConfig("test", ["https://test.dev", "https://test.dev"], "test.dev", "/wrapper.sw", "/");
18
+ (0, chai_1.expect)(() => {
19
+ validator.validate(customerConfig);
20
+ }).to.throw("Duplicate origins found! Remove duplicates and restart deploy!");
21
+ });
22
+ (0, mocha_1.it)("should throw error no origins", () => {
23
+ const validator = new customer_config_validator_1.default();
24
+ const customerConfig = new customer_config_1.CustomerConfig("test", [], "test.dev", "/wrapper.sw", "/");
25
+ (0, chai_1.expect)(() => {
26
+ validator.validate(customerConfig);
27
+ }).to.throw("No origins were found in local config_customer.js! Add origins and restart deploy!");
28
+ });
29
+ (0, mocha_1.it)("should throw error not having a protocol", () => {
30
+ const validator = new customer_config_validator_1.default();
31
+ const customerConfig = new customer_config_1.CustomerConfig("test", ["test.dev", "https://test.dev"], "test.dev", "/wrapper.sw", "/");
32
+ (0, chai_1.expect)(() => {
33
+ validator.validate(customerConfig);
34
+ }).to.throw("There was at least one origin configured in the local customer_config.js not having a protocol.");
35
+ });
36
+ (0, mocha_1.it)("should throw error having a path", () => {
37
+ const validator = new customer_config_validator_1.default();
38
+ const customerConfig = new customer_config_1.CustomerConfig("test", ["https://test.dev/"], "test.dev", "/wrapper.sw", "/");
39
+ (0, chai_1.expect)(() => {
40
+ validator.validate(customerConfig);
41
+ }).to.throw("There was at least one origin having a path. Origin must have the following format: https://domain.tld");
42
+ });
43
+ (0, mocha_1.it)("should throw error appName not start with number", () => {
44
+ const validator = new customer_config_validator_1.default();
45
+ const customerConfig = new customer_config_1.CustomerConfig("99_test", ["https://test.dev"], "test.dev", "/wrapper.sw", "/");
46
+ (0, chai_1.expect)(() => {
47
+ validator.validate(customerConfig);
48
+ }).to.throw("appName can't start with a number");
49
+ });
50
+ });
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chai_1 = require("chai");
5
+ const mocha_1 = require("mocha");
6
+ const file_list_1 = tslib_1.__importDefault(require("../file-list"));
7
+ const __1 = require("../");
8
+ (0, mocha_1.describe)("fileList addFile", () => {
9
+ (0, mocha_1.it)("should have 1 entry", () => {
10
+ const fileList = new file_list_1.default();
11
+ fileList.addFile(new __1.VirtualFile("test", {}));
12
+ // Assert that our function returned the correct value
13
+ (0, chai_1.expect)(fileList.files.length).to.equal(1);
14
+ });
15
+ (0, mocha_1.it)("should have 2 entries", () => {
16
+ const fileList = new file_list_1.default();
17
+ fileList.addFile(new __1.VirtualFile("test", {}));
18
+ fileList.addFile(new __1.VirtualFile("test2", {}));
19
+ // Assert that our function returned the correct value
20
+ (0, chai_1.expect)(fileList.files.length).to.equal(2);
21
+ });
22
+ });
23
+ (0, mocha_1.describe)("fileList hasFile", () => {
24
+ (0, mocha_1.it)("should return true", () => {
25
+ const fileList = new file_list_1.default();
26
+ fileList.addFile(new __1.VirtualFile("test_abcd", {}));
27
+ // Assert that our function returned the correct value
28
+ (0, chai_1.expect)(fileList.hasFile("test_abcd")).to.equal(true);
29
+ });
30
+ (0, mocha_1.it)("should return false", () => {
31
+ const fileList = new file_list_1.default();
32
+ fileList.addFile(new __1.VirtualFile("test_abcd", {}));
33
+ // Assert that our function returned the correct value
34
+ (0, chai_1.expect)(fileList.hasFile("test_xyz")).to.equal(false);
35
+ });
36
+ });
37
+ (0, mocha_1.describe)("fileList getByType", () => {
38
+ (0, mocha_1.it)("should have 1 entry", () => {
39
+ const fileList = new file_list_1.default();
40
+ fileList.addFile(new __1.VirtualFile("test", {}));
41
+ fileList.addFile(new __1.VirtualFile("test2", {}));
42
+ fileList.addFile(new __1.InstallResourceFile("config_test", "/test/config_test.js", "{}", "test"));
43
+ // Assert that our function returned the correct value
44
+ (0, chai_1.expect)(fileList.getByType(__1.FILE_TYPE.VIRTUAL_FILE).length).to.equal(2);
45
+ });
46
+ });
47
+ (0, mocha_1.describe)("fileList getByName", () => {
48
+ (0, mocha_1.it)("shouldn't find entry", () => {
49
+ const fileList = new file_list_1.default();
50
+ const fileToFind = new __1.VirtualFile("test", {});
51
+ fileList.addFile(fileToFind);
52
+ fileList.addFile(new __1.VirtualFile("test2", {}));
53
+ // Assert that our function returned the correct value
54
+ (0, chai_1.expect)(fileList.getByName("test4")).to.equal(undefined);
55
+ });
56
+ (0, mocha_1.it)("should find entry", () => {
57
+ const fileList = new file_list_1.default();
58
+ const fileToFind = new __1.VirtualFile("test", {});
59
+ fileList.addFile(fileToFind);
60
+ fileList.addFile(new __1.VirtualFile("test2", {}));
61
+ // Assert that our function returned the correct value
62
+ (0, chai_1.expect)(fileList.getByName("test")).to.equal(fileToFind);
63
+ });
64
+ });
65
+ (0, mocha_1.describe)("fileList getInstallResources", () => {
66
+ (0, mocha_1.it)("get all installResourceFiles", () => {
67
+ const fileList = new file_list_1.default();
68
+ fileList.addFile(new __1.InstallResourceFile("config_test", "/test/config_test.js", "{}", "test"));
69
+ fileList.addFile(new __1.VirtualFile("custom_sw2.js", {}));
70
+ // Assert that our function returned the correct value
71
+ (0, chai_1.expect)(fileList.getInstallResources().length).to.equal(1);
72
+ });
73
+ });
74
+ (0, mocha_1.describe)("fileList getModules", () => {
75
+ (0, mocha_1.it)("get all ModuleFiles", () => {
76
+ const fileList = new file_list_1.default();
77
+ fileList.addFile(new __1.ModuleFile("deploymentDetection_test", "/test/deploymentDetection_test.es6", "{}", "{}"));
78
+ fileList.addFile(new __1.VirtualFile("custom_sw2.js", {}));
79
+ // Assert that our function returned the correct value
80
+ (0, chai_1.expect)(fileList.getModules().length).to.equal(1);
81
+ });
82
+ });
83
+ (0, mocha_1.describe)("fileList getServerConfig", () => {
84
+ (0, mocha_1.it)("get all ServerConfigFiles", () => {
85
+ const fileList = new file_list_1.default();
86
+ fileList.addFile(new __1.ServerConfigFile("config_orestes.json", "/test/config_orestes.json", "{}", "{}"));
87
+ fileList.addFile(new __1.VirtualFile("custom_sw2.js", {}));
88
+ // Assert that our function returned the correct value
89
+ (0, chai_1.expect)(fileList.getServerConfig().name).to.equal("config_orestes.json");
90
+ });
91
+ });
92
+ (0, mocha_1.describe)("fileList getCustomerConfig", () => {
93
+ (0, mocha_1.it)("get all CustomerConfig files", () => {
94
+ const fileList = new file_list_1.default();
95
+ fileList.addFile(new __1.CustomerConfigFile("config_customer", "/test/config_customer.js", "{}", {}, "test"));
96
+ fileList.addFile(new __1.VirtualFile("custom_sw2.js", {}));
97
+ // Assert that our function returned the correct value
98
+ (0, chai_1.expect)(fileList.getCustomerConfig().configName).to.equal("test");
99
+ });
100
+ });
101
+ (0, mocha_1.describe)("fileList getTypes", () => {
102
+ const fileList = new file_list_1.default();
103
+ fileList.addFile(new __1.CustomerConfigFile("config_customer", "/test/config_customer.js", "{}", {}, "test"));
104
+ fileList.addFile(new __1.VirtualFile("custom_sw.js", {}));
105
+ fileList.addFile(new __1.VirtualFile("custom_sw2.js", {}));
106
+ fileList.addFile(new __1.ModuleFile("deploymentDetection_test", "/test/deploymentDetection_test.es6", "{}", "{}"));
107
+ (0, mocha_1.it)("find 3 types", () => {
108
+ // Assert that our function returned the correct value
109
+ (0, chai_1.expect)(fileList.getTypes().length).to.equal(3);
110
+ });
111
+ (0, mocha_1.it)("has virtualFile", () => {
112
+ // Assert that our function returned the correct value
113
+ (0, chai_1.expect)(fileList.getTypes()).to.includes(__1.FILE_TYPE.VIRTUAL_FILE);
114
+ });
115
+ (0, mocha_1.it)("has CustomerConfigFile", () => {
116
+ // Assert that our function returned the correct value
117
+ (0, chai_1.expect)(fileList.getTypes()).to.includes(__1.FILE_TYPE.CUSTOMER_FILE);
118
+ });
119
+ (0, mocha_1.it)("has ModuleFile", () => {
120
+ // Assert that our function returned the correct value
121
+ (0, chai_1.expect)(fileList.getTypes()).to.includes(__1.FILE_TYPE.MODULE_FILE);
122
+ });
123
+ });
124
+ (0, mocha_1.describe)("fileList filter", () => {
125
+ (0, mocha_1.it)("find all files name start with test", () => {
126
+ const fileList = new file_list_1.default();
127
+ fileList.addFile(new __1.VirtualFile("test1", {}));
128
+ fileList.addFile(new __1.VirtualFile("test2", {}));
129
+ fileList.addFile(new __1.VirtualFile("test3", {}));
130
+ fileList.addFile(new __1.VirtualFile("config", {}));
131
+ fileList.filter((file) => {
132
+ return file.name.startsWith("test");
133
+ });
134
+ // Assert that our function returned the correct value
135
+ (0, chai_1.expect)(fileList.files.length).to.equal(3);
136
+ });
137
+ });
138
+ (0, mocha_1.describe)("fileList concat", () => {
139
+ const fileList = new file_list_1.default();
140
+ fileList.addFile(new __1.VirtualFile("test1", {}));
141
+ fileList.addFile(new __1.VirtualFile("test2", {}));
142
+ const fileList2 = new file_list_1.default();
143
+ fileList2.addFile(new __1.VirtualFile("config1", {}));
144
+ fileList2.addFile(new __1.VirtualFile("config2", {}));
145
+ // eslint-disable-next-line unicorn/prefer-spread
146
+ fileList.concat(fileList2);
147
+ (0, mocha_1.it)("check length of two filelists", () => {
148
+ (0, chai_1.expect)(fileList.files.length).to.equal(4);
149
+ });
150
+ (0, mocha_1.it)("find file in first fileList", () => {
151
+ (0, chai_1.expect)(fileList.hasFile("config2")).to.equal(true);
152
+ });
153
+ });
154
+ (0, mocha_1.describe)("fileList replace", () => {
155
+ (0, mocha_1.it)("check if file was replaced", () => {
156
+ const fileList = new file_list_1.default();
157
+ const file = new __1.VirtualFile("test1", {});
158
+ fileList.addFile(file);
159
+ const replace = new __1.InstallResourceFile("test1", "/test/config_test.js", "replace", "test");
160
+ fileList.replace(replace);
161
+ (0, chai_1.expect)(fileList.getByName("test1").path).to.equal("/test/config_test.js");
162
+ });
163
+ });
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chai_1 = require("chai");
5
+ const mocha_1 = require("mocha");
6
+ const memfs_1 = require("memfs");
7
+ const file_reader_1 = tslib_1.__importDefault(require("../file-reader"));
8
+ const afterTest = () => {
9
+ memfs_1.vol.reset();
10
+ };
11
+ (0, mocha_1.describe)("FileReader getFileList ", () => {
12
+ (0, mocha_1.before)(() => {
13
+ memfs_1.vol.fromNestedJSON({
14
+ "/test_customer": {
15
+ "config_customer.js": "module.export = {production}",
16
+ "config_SpeedKit.js": "skConfig",
17
+ ".local/test.js": "test",
18
+ "magic/test3.js": "test3",
19
+ },
20
+ });
21
+ });
22
+ (0, mocha_1.after)(afterTest);
23
+ /**
24
+ * default behaviour
25
+ */
26
+ (0, mocha_1.it)("fileList should include config_SpeedKit.js", () => {
27
+ // @ts-expect-error fs is not compatible
28
+ const fileReader = new file_reader_1.default(memfs_1.fs, "test", "test_customer", [], []);
29
+ const fileList = fileReader.getFileList("/test_customer");
30
+ (0, chai_1.expect)(fileList).to.include("/test_customer/config_SpeedKit.js");
31
+ });
32
+ /**
33
+ * default behaviour
34
+ */
35
+ (0, mocha_1.it)("fileList should not include test.js", () => {
36
+ // @ts-expect-error fs is not compatible
37
+ const fileReader = new file_reader_1.default(memfs_1.fs, "test", "test_customer", [], []);
38
+ const fileList = fileReader.getFileList("/test_customer");
39
+ (0, chai_1.expect)(fileList).to.not.include("/.local/test.js");
40
+ });
41
+ /**
42
+ * add magic to blocked folders
43
+ */
44
+ (0, mocha_1.it)("fileList should not include magic/test3.js", () => {
45
+ const fileReader = new file_reader_1.default(
46
+ // @ts-expect-error fs is not compatible
47
+ memfs_1.fs, "test", "test_customer", [], ["magic"]);
48
+ const fileList = fileReader.getFileList("/test_customer");
49
+ (0, chai_1.expect)(fileList).to.not.include("/magic/test3.js");
50
+ });
51
+ /**
52
+ * add asdf to whitelist
53
+ */
54
+ (0, mocha_1.it)("fileList should include config_customer.js", () => {
55
+ const fileReader = new file_reader_1.default(
56
+ // @ts-expect-error fs is not compatible
57
+ memfs_1.fs, "test", "test_customer", ["asdf"], ["magic"]);
58
+ const fileList = fileReader.getFileList("/test_customer");
59
+ (0, chai_1.expect)(fileList).to.include("/test_customer/config_customer.js");
60
+ });
61
+ /**
62
+ * if whitelist is set, only files from whitelist or config_SpeedKit.js should be returned
63
+ */
64
+ (0, mocha_1.it)("fileList should not include config_SpeedKit.js", () => {
65
+ const fileReader = new file_reader_1.default(
66
+ // @ts-expect-error fs is not compatible
67
+ memfs_1.fs, "test", "test_customer", ["asdf"], ["magic"]);
68
+ const fileList = fileReader.getFileList("/test_customer");
69
+ (0, chai_1.expect)(fileList).to.not.include("/test_customer/config_SpeedKit.js");
70
+ });
71
+ });
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chai_1 = require("chai");
5
+ const mocha_1 = require("mocha");
6
+ const memfs_1 = require("memfs");
7
+ const file_writer_1 = tslib_1.__importDefault(require("../file-writer"));
8
+ const beforeTest = () => {
9
+ memfs_1.vol.fromNestedJSON({
10
+ "/test_customer/config_SpeedKit.js": "old content",
11
+ });
12
+ };
13
+ const afterTest = () => {
14
+ memfs_1.vol.reset();
15
+ };
16
+ (0, mocha_1.describe)("FileWriter writeFile ", () => {
17
+ (0, mocha_1.before)(beforeTest);
18
+ (0, mocha_1.after)(afterTest);
19
+ (0, mocha_1.it)("content should be written to fileSystem", () => {
20
+ const fileWriter = new file_writer_1.default(memfs_1.fs, "/test_customer/");
21
+ fileWriter.writeFile("config_SpeedKit", "js", "new content");
22
+ const fileContent = memfs_1.fs.readFileSync("/test_customer/config_SpeedKit.js", "utf8");
23
+ (0, chai_1.expect)(fileContent).to.equal("new content");
24
+ });
25
+ });
26
+ (0, mocha_1.describe)("FileWriter mkdir ", () => {
27
+ (0, mocha_1.before)(beforeTest);
28
+ (0, mocha_1.after)(afterTest);
29
+ (0, mocha_1.it)("create subFolder", () => {
30
+ const fileWriter = new file_writer_1.default(memfs_1.fs, "/test_customer/");
31
+ fileWriter.mkdir("tmp");
32
+ (0, chai_1.expect)(memfs_1.fs.existsSync("/test_customer/tmp")).to.equal(true);
33
+ });
34
+ });
35
+ (0, mocha_1.describe)("FileWriter hasFile ", () => {
36
+ (0, mocha_1.before)(beforeTest);
37
+ (0, mocha_1.after)(afterTest);
38
+ (0, mocha_1.it)("check if file exists to be true", () => {
39
+ const fileWriter = new file_writer_1.default(memfs_1.fs, "/test_customer/");
40
+ (0, chai_1.expect)(fileWriter.hasFile("config_SpeedKit", "js")).to.equal(true);
41
+ });
42
+ (0, mocha_1.it)("check if file exists to be false", () => {
43
+ const fileWriter = new file_writer_1.default(memfs_1.fs, "/test_customer/");
44
+ (0, chai_1.expect)(fileWriter.hasFile("custom_documentHandler", "js")).to.equal(false);
45
+ });
46
+ });
47
+ (0, mocha_1.describe)("FileWriter removeFile ", () => {
48
+ (0, mocha_1.before)(beforeTest);
49
+ (0, mocha_1.after)(afterTest);
50
+ (0, mocha_1.it)("check if file exists to be true", () => {
51
+ const fileWriter = new file_writer_1.default(memfs_1.fs, "/test_customer/");
52
+ fileWriter.removeFile("config_SpeedKit", "js");
53
+ (0, chai_1.expect)(memfs_1.fs.existsSync("/test_customer/config_SpeedKit.js")).to.equal(false);
54
+ });
55
+ });
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chai_1 = require("chai");
5
+ const mocha_1 = require("mocha");
6
+ const integration_api_model_1 = require("../integration-api-model");
7
+ const integration_api_service_1 = require("../integration-api-service");
8
+ const file_reader_1 = tslib_1.__importDefault(require("../file-reader"));
9
+ const memfs_1 = require("memfs");
10
+ const cli_1 = require("../../cli");
11
+ const file_writer_1 = tslib_1.__importDefault(require("../file-writer"));
12
+ const mandatory_files_validator_1 = tslib_1.__importDefault(require("../validator/mandatory-files-validator"));
13
+ const customer_config_handler_1 = tslib_1.__importDefault(require("../handler/customer-config-handler"));
14
+ const customer_config_validator_1 = tslib_1.__importDefault(require("../validator/customer-config-validator"));
15
+ const install_resource_handler_1 = tslib_1.__importDefault(require("../handler/install-resource-handler"));
16
+ const static_recipe_1 = require("../virtual/static-recipe");
17
+ const afterTest = () => {
18
+ memfs_1.vol.reset();
19
+ };
20
+ function prepareDependencies() {
21
+ const cli = new cli_1.CliServiceFactory().getService();
22
+ const virtualFileHandler = new integration_api_model_1.VirtualFileHandler(cli);
23
+ // @ts-expect-error fs is not compatible
24
+ const fileReader = new file_reader_1.default(memfs_1.fs, "test", "/test_customer", [], []);
25
+ const fileWriter = new file_writer_1.default(memfs_1.fs, "/test_customer/");
26
+ const validator = new mandatory_files_validator_1.default();
27
+ const customerConfigValidator = new customer_config_validator_1.default();
28
+ const customerConfigHandler = new customer_config_handler_1.default(fileReader, cli, customerConfigValidator, "test", "test");
29
+ const installResourceHandler = new install_resource_handler_1.default(fileReader);
30
+ return {
31
+ virtualFileHandler,
32
+ fileReader,
33
+ fileWriter,
34
+ validator,
35
+ customerConfigHandler,
36
+ installResourceHandler,
37
+ };
38
+ }
39
+ (0, mocha_1.describe)("integration service run", () => {
40
+ (0, mocha_1.before)(() => {
41
+ memfs_1.vol.fromNestedJSON({
42
+ "/test_customer": {
43
+ "config_customer.js": `module.exports = {test:{app:"test",domain:"test.dev",origins:["https://test.dev"],scope:"/",swPath: "/wrapper-sw.js"}}`,
44
+ "config_SpeedKit.js": "",
45
+ "config_dynamicBlocks.js": "",
46
+ "config_dynamicStyles.css": "",
47
+ "config_documentHandler.es6": "",
48
+ "custom_sw.js": "custom serviceWorker content",
49
+ },
50
+ });
51
+ });
52
+ (0, mocha_1.after)(afterTest);
53
+ (0, mocha_1.it)("no handler found for file", (done) => {
54
+ const { virtualFileHandler, fileReader, fileWriter, validator } = prepareDependencies();
55
+ const integrationApiService = new integration_api_service_1.IntegrationApiService(fileReader, virtualFileHandler, validator, [], fileWriter, true);
56
+ integrationApiService
57
+ .run()
58
+ .then((fileList) => {
59
+ // Assert that our function returned the correct value
60
+ (0, chai_1.expect)(fileList.files.length).to.equal(0);
61
+ done();
62
+ })
63
+ .catch((error) => {
64
+ (0, chai_1.expect)(error.message).to.include("No handler found");
65
+ done();
66
+ });
67
+ });
68
+ (0, mocha_1.it)("find 6 files", (done) => {
69
+ const { virtualFileHandler, fileReader, fileWriter, validator, customerConfigHandler, installResourceHandler, } = prepareDependencies();
70
+ const integrationApiService = new integration_api_service_1.IntegrationApiService(fileReader, virtualFileHandler, validator, [customerConfigHandler, installResourceHandler], fileWriter, true);
71
+ integrationApiService
72
+ .run()
73
+ .then((fileList) => {
74
+ // Assert that our function returned the correct value
75
+ (0, chai_1.expect)(fileList.files.length).to.equal(6);
76
+ done();
77
+ })
78
+ .catch((error) => {
79
+ done(error);
80
+ });
81
+ });
82
+ (0, mocha_1.it)("find virtual file", (done) => {
83
+ const { virtualFileHandler, fileReader, fileWriter, validator, customerConfigHandler, installResourceHandler, } = prepareDependencies();
84
+ const integrationApiService = new integration_api_service_1.IntegrationApiService(fileReader, virtualFileHandler, validator, [customerConfigHandler, installResourceHandler], fileWriter, true);
85
+ integrationApiService
86
+ .run([
87
+ {
88
+ name: "my_virtual_file",
89
+ recipe: new static_recipe_1.StaticRecipe("my_virtual_file_content"),
90
+ },
91
+ ])
92
+ .then((fileList) => {
93
+ // Assert that our function returned the correct value
94
+ (0, chai_1.expect)(fileList.getByName("my_virtual_file").getContent()).to.equal("my_virtual_file_content");
95
+ done();
96
+ })
97
+ .catch((error) => {
98
+ done(error);
99
+ });
100
+ });
101
+ (0, mocha_1.it)("override local file with virtual file", (done) => {
102
+ const { virtualFileHandler, fileReader, fileWriter, validator, customerConfigHandler, installResourceHandler, } = prepareDependencies();
103
+ const integrationApiService = new integration_api_service_1.IntegrationApiService(fileReader, virtualFileHandler, validator, [customerConfigHandler, installResourceHandler], fileWriter, true);
104
+ integrationApiService
105
+ .run([
106
+ {
107
+ name: "custom_sw",
108
+ recipe: new static_recipe_1.StaticRecipe("my_virtual_file_content"),
109
+ overrideLocalFile: true,
110
+ },
111
+ ])
112
+ .then((fileList) => {
113
+ // Assert that our function returned the correct value
114
+ (0, chai_1.expect)(fileList.getByName("custom_sw").getContent()).to.equal("my_virtual_file_content");
115
+ (0, chai_1.expect)(fileList.files.length).to.equal(6);
116
+ done();
117
+ })
118
+ .catch((error) => {
119
+ done(error);
120
+ });
121
+ });
122
+ });
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chai_1 = require("chai");
5
+ const mocha_1 = require("mocha");
6
+ const mandatory_files_validator_1 = tslib_1.__importDefault(require("../validator/mandatory-files-validator"));
7
+ const file_list_1 = tslib_1.__importDefault(require("../file-list"));
8
+ const customer_config_file_1 = require("../struct/customer-config-file");
9
+ const install_resource_file_1 = require("../struct/install-resource-file");
10
+ const files_1 = require("../../../models/files");
11
+ function addFileCustomerConfig(fileList) {
12
+ fileList.addFile(new customer_config_file_1.CustomerConfigFile(files_1.INTEGRATION_FILES.CONFIG.CUSTOMER, "", "", {}, "test"));
13
+ }
14
+ function addFileDynamicStyles(fileList) {
15
+ fileList.addFile(new install_resource_file_1.InstallResourceFile(files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES, "", "", ""));
16
+ }
17
+ function addFileAssetHandler(fileList) {
18
+ fileList.addFile(new install_resource_file_1.InstallResourceFile(files_1.INTEGRATION_FILES.DEPRECATED.ASSET_HANDLER, "", "", ""));
19
+ }
20
+ function addFileDynamicBlocks(fileList) {
21
+ fileList.addFile(new install_resource_file_1.InstallResourceFile(files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_BLOCKS, "", "", ""));
22
+ }
23
+ function addFileSpeedKit(fileList) {
24
+ fileList.addFile(new install_resource_file_1.InstallResourceFile(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT, "", "", ""));
25
+ }
26
+ function addFileDocumentHandler(fileList) {
27
+ fileList.addFile(new install_resource_file_1.InstallResourceFile(files_1.INTEGRATION_FILES.CONFIG.DOCUMENT_HANDLER, "", "", ""));
28
+ }
29
+ (0, mocha_1.describe)("mandatory_files_validator validate", () => {
30
+ (0, mocha_1.it)("documentHandler -> should have no errors", () => {
31
+ const validator = new mandatory_files_validator_1.default();
32
+ const fileList = new file_list_1.default();
33
+ addFileCustomerConfig(fileList);
34
+ addFileDynamicStyles(fileList);
35
+ addFileDynamicBlocks(fileList);
36
+ addFileSpeedKit(fileList);
37
+ addFileDocumentHandler(fileList);
38
+ validator.validate(fileList);
39
+ (0, chai_1.expect)(true).to.be.true;
40
+ });
41
+ (0, mocha_1.it)("assetHandler -> should have no errors", () => {
42
+ const validator = new mandatory_files_validator_1.default();
43
+ const fileList = new file_list_1.default();
44
+ addFileCustomerConfig(fileList);
45
+ addFileSpeedKit(fileList);
46
+ addFileAssetHandler(fileList);
47
+ validator.validate(fileList);
48
+ (0, chai_1.expect)(true).to.be.true;
49
+ });
50
+ (0, mocha_1.it)("throw error -> customerConfigMissing", () => {
51
+ const validator = new mandatory_files_validator_1.default();
52
+ const fileList = new file_list_1.default();
53
+ addFileDynamicStyles(fileList);
54
+ addFileAssetHandler(fileList);
55
+ addFileDynamicBlocks(fileList);
56
+ addFileSpeedKit(fileList);
57
+ (0, chai_1.expect)(() => {
58
+ validator.validate(fileList);
59
+ }).to.throw(`Mandatory file "${files_1.INTEGRATION_FILES.CONFIG.CUSTOMER}" is missing`);
60
+ });
61
+ (0, mocha_1.it)("throw error -> skConfigMissing", () => {
62
+ const validator = new mandatory_files_validator_1.default();
63
+ const fileList = new file_list_1.default();
64
+ addFileCustomerConfig(fileList);
65
+ addFileDynamicStyles(fileList);
66
+ addFileAssetHandler(fileList);
67
+ addFileDynamicBlocks(fileList);
68
+ (0, chai_1.expect)(() => {
69
+ validator.validate(fileList);
70
+ }).to.throw(`Mandatory file "${files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT}" is missing`);
71
+ });
72
+ (0, mocha_1.it)("throw error -> skStyles are missing", () => {
73
+ const validator = new mandatory_files_validator_1.default();
74
+ const fileList = new file_list_1.default();
75
+ addFileCustomerConfig(fileList);
76
+ addFileDocumentHandler(fileList);
77
+ addFileDynamicBlocks(fileList);
78
+ addFileSpeedKit(fileList);
79
+ (0, chai_1.expect)(() => {
80
+ validator.validate(fileList);
81
+ }).to.throw(`Please implement config_documentHandler, config_dynamicBlocks, config_dynamicStyles or speedKit.Asset`);
82
+ });
83
+ (0, mocha_1.it)("throw error -> dynamicBlocks are missing", () => {
84
+ const validator = new mandatory_files_validator_1.default();
85
+ const fileList = new file_list_1.default();
86
+ addFileCustomerConfig(fileList);
87
+ addFileDocumentHandler(fileList);
88
+ addFileDynamicStyles(fileList);
89
+ addFileSpeedKit(fileList);
90
+ (0, chai_1.expect)(() => {
91
+ validator.validate(fileList);
92
+ }).to.throw(`Please implement config_documentHandler, config_dynamicBlocks, config_dynamicStyles or speedKit.Asset`);
93
+ });
94
+ (0, mocha_1.it)("throw error -> documentHandler is missing", () => {
95
+ const validator = new mandatory_files_validator_1.default();
96
+ const fileList = new file_list_1.default();
97
+ addFileCustomerConfig(fileList);
98
+ addFileDynamicBlocks(fileList);
99
+ addFileDynamicStyles(fileList);
100
+ addFileSpeedKit(fileList);
101
+ (0, chai_1.expect)(() => {
102
+ validator.validate(fileList);
103
+ }).to.throw(`Please implement config_documentHandler, config_dynamicBlocks, config_dynamicStyles or speedKit.Asset`);
104
+ });
105
+ });
@@ -1,10 +1,9 @@
1
- import { CustomerConfigInterface } from "../integration-api-model";
2
- import CustomerConfig from "./customer-config";
3
- import File from "./file";
4
- export default class CustomerConfigFile extends File implements CustomerConfigInterface {
1
+ import { CustomerConfig, File, CustomerConfigInterface, FILE_TYPE } from "../integration-api-model";
2
+ export declare class CustomerConfigFile extends File implements CustomerConfigInterface {
5
3
  config: CustomerConfig;
6
4
  readonly configName: string;
7
5
  readonly testApp?: string;
6
+ readonly type = FILE_TYPE.CUSTOMER_FILE;
8
7
  constructor(name: string, path: string, content: string, config: CustomerConfig, configName: string, testApp?: string);
9
8
  setContent(content: string): void;
10
9
  private updateConfigByContent;
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomerConfigFile = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const vm = tslib_1.__importStar(require("node:vm"));
5
- const customer_config_1 = tslib_1.__importDefault(require("./customer-config"));
6
- const file_1 = tslib_1.__importDefault(require("./file"));
7
- class CustomerConfigFile extends file_1.default {
6
+ const integration_api_model_1 = require("../integration-api-model");
7
+ class CustomerConfigFile extends integration_api_model_1.File {
8
8
  config;
9
9
  configName;
10
10
  testApp;
11
+ type = integration_api_model_1.FILE_TYPE.CUSTOMER_FILE;
11
12
  constructor(name, path, content, config, configName, testApp) {
12
- super(name, path, content, CustomerConfigFile);
13
+ super(name, path, content);
13
14
  this.config = config;
14
15
  this.configName = configName;
15
16
  this.testApp = testApp;
@@ -30,8 +31,8 @@ class CustomerConfigFile extends file_1.default {
30
31
  displayErrors: true,
31
32
  });
32
33
  if (this.configName in customerConfigContext.module.exports) {
33
- this.config = customer_config_1.default.createFrom(customerConfigContext.module.exports[this.configName], this.configName);
34
+ this.config = integration_api_model_1.CustomerConfig.createFrom(customerConfigContext.module.exports[this.configName], this.configName);
34
35
  }
35
36
  }
36
37
  }
37
- exports.default = CustomerConfigFile;
38
+ exports.CustomerConfigFile = CustomerConfigFile;
@@ -1,4 +1,4 @@
1
- export default class CustomerConfig {
1
+ export declare class CustomerConfig {
2
2
  readonly app: string;
3
3
  readonly origins: string[];
4
4
  readonly domain: string;
@@ -13,10 +13,8 @@ export default class CustomerConfig {
13
13
  readonly dependencies?: {
14
14
  [dependency: string]: string;
15
15
  };
16
- readonly skCliPre?: string;
17
- readonly skCliPost?: string;
18
16
  constructor(app: string, origins: string[], domain: string, swPath: string, scope: string, appDomain?: string, installPath?: string, installParameters?: string, name?: string, forceInstall?: boolean, chromeFlags?: string[], dependencies?: {
19
17
  [dependency: string]: string;
20
- }, skCliPre?: string, skCliPost?: string);
21
- static createFrom(configFile: any, configName?: string): CustomerConfig;
18
+ });
19
+ static createFrom(configFile: Partial<CustomerConfig>, configName?: string): CustomerConfig;
22
20
  }