@genesislcap/build-kit 14.162.4-alpha-ea9526e.0 → 14.162.4

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 (46) hide show
  1. package/dist/utils/index.d.ts +0 -1
  2. package/dist/utils/index.d.ts.map +1 -1
  3. package/dist/utils/index.js +0 -1
  4. package/dist/utils/prompts.js +2 -2
  5. package/dist/utils/seed.processing.d.ts.map +1 -1
  6. package/dist/utils/seed.processing.js +3 -4
  7. package/package.json +3 -3
  8. package/src/index.ts +2 -0
  9. package/src/types/build-context.ts +57 -0
  10. package/src/types/config.ts +269 -0
  11. package/src/types/index.ts +3 -0
  12. package/src/types/pwa.ts +67 -0
  13. package/src/utils/archive.ts +18 -0
  14. package/src/utils/args.ts +7 -0
  15. package/src/utils/build-context.ts +42 -0
  16. package/src/utils/child-process.ts +115 -0
  17. package/src/utils/config.ts +45 -0
  18. package/src/utils/console.ts +1 -0
  19. package/src/utils/env.ts +71 -0
  20. package/src/utils/federation.ts +40 -0
  21. package/src/utils/fs.ts +53 -0
  22. package/src/utils/handlebars.ts +61 -0
  23. package/src/utils/https.ts +29 -0
  24. package/src/utils/index.ts +21 -0
  25. package/src/utils/json.ts +12 -0
  26. package/src/utils/npm.ts +155 -0
  27. package/src/utils/object.ts +21 -0
  28. package/src/utils/prompts.ts +160 -0
  29. package/src/utils/proxy.ts +139 -0
  30. package/src/utils/seed.fetching.ts +257 -0
  31. package/src/utils/seed.meta.ts +34 -0
  32. package/src/utils/seed.processing.ts +100 -0
  33. package/src/utils/seed.setup.ts +101 -0
  34. package/src/utils/time.ts +1 -0
  35. package/test/utils/args.test.ts +17 -0
  36. package/test/utils/build-context.test.ts +68 -0
  37. package/test/utils/env.test.ts +212 -0
  38. package/test/utils/handlebars.test.ts +277 -0
  39. package/test/utils/https.test.ts +14 -0
  40. package/test/utils/proxy.test.ts +96 -0
  41. package/test/utils/seed.fetching.test.ts +145 -0
  42. package/test/utils/seed.meta.test.ts +33 -0
  43. package/tsconfig.json +18 -0
  44. package/dist/utils/seed.commands.d.ts +0 -19
  45. package/dist/utils/seed.commands.d.ts.map +0 -1
  46. package/dist/utils/seed.commands.js +0 -58
@@ -0,0 +1,68 @@
1
+ import { basename, resolve } from 'node:path';
2
+ import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
3
+ import { COMMAND } from '../../src/types';
4
+ import { loadBuildContext } from '../../src/utils';
5
+
6
+ const suite = createLogicSuite('Build context utils');
7
+
8
+ suite('returns populated build context', async () => {
9
+ const actual = await loadBuildContext(process.cwd(), COMMAND.DEV, { foo: 'bar' });
10
+
11
+ assert.equal(actual.cli, {
12
+ command: 'dev',
13
+ isDev: true,
14
+ isAnalyze: false,
15
+ isBuild: false,
16
+ isTest: false,
17
+ isRun: false,
18
+ isLint: false,
19
+ options: {
20
+ foo: 'bar',
21
+ },
22
+ });
23
+
24
+ assert.equal(actual.env, {
25
+ isCI: !!process.env.CI,
26
+ });
27
+
28
+ assert.equal(actual.enable, {
29
+ apiExtractor: null,
30
+ cemAnalyzer: null,
31
+ mft: null,
32
+ });
33
+
34
+ assert.equal(actual.config, {
35
+ app: {},
36
+ builder: {
37
+ default: 'webpack',
38
+ dev: 'vite',
39
+ lint: 'eslint-stylelint',
40
+ test: 'uvu-playwright',
41
+ },
42
+ clean: true,
43
+ copyAssets: ['**/*.{css,jpg,png,svg,mp4,ogg,webm}'],
44
+ env: [
45
+ 'API_HOST',
46
+ 'DEFAULT_ORGANISATION',
47
+ 'DEFAULT_USER',
48
+ 'DEFAULT_PASSWORD',
49
+ 'ENABLE_SSO',
50
+ 'GENX.*',
51
+ 'GENX_*',
52
+ 'FORCE_HTTP',
53
+ 'SOCKET_EXT',
54
+ ],
55
+ federation: {
56
+ name: 'buildKit',
57
+ remotes: {},
58
+ shared: {},
59
+ },
60
+ });
61
+
62
+ assert.equal(actual.pkg.name, '@genesislcap/build-kit');
63
+
64
+ assert.equal(basename(actual.dirs.cwd), 'build-kit');
65
+ assert.equal(basename(actual.dirs.workspace || ''), basename(resolve('../../../..')));
66
+ });
67
+
68
+ suite.run();
@@ -0,0 +1,212 @@
1
+ import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
2
+ import type { BuildContext } from '../../src/types';
3
+ import { ENV } from '../../src/types';
4
+ import { setEnvVars, setNodeEnv } from '../../src/utils';
5
+
6
+ const suite1 = createLogicSuite('setNodeEnv');
7
+
8
+ suite1('updates NODE_ENV', () => {
9
+ setNodeEnv(ENV.TEST);
10
+ assert.is(process.env.NODE_ENV, ENV.TEST);
11
+ });
12
+
13
+ suite1('can handle repeated calls', () => {
14
+ setNodeEnv(ENV.DEV);
15
+ setNodeEnv(ENV.DEV);
16
+ assert.is(process.env.NODE_ENV, ENV.DEV);
17
+ });
18
+
19
+ suite1.run();
20
+
21
+ const suite2 = createLogicSuite('setEnvVars');
22
+
23
+ suite2('should handle multiple -e arguments', () => {
24
+ const mockContext = {
25
+ pkg: {},
26
+ cli: {
27
+ options: {
28
+ env: ['KEY1=VAL1', 'KEY2=VAL2'],
29
+ },
30
+ },
31
+ };
32
+ setEnvVars(mockContext as unknown as BuildContext);
33
+ assert.is(process.env.KEY1, 'VAL1');
34
+ assert.is(process.env.KEY2, 'VAL2');
35
+ });
36
+
37
+ suite2('should handle multiple -e arguments with the same key', () => {
38
+ const mockContext = {
39
+ pkg: {},
40
+ cli: {
41
+ options: {
42
+ env: ['KEY1=VAL1', 'KEY1=VAL2'],
43
+ },
44
+ },
45
+ };
46
+ setEnvVars(mockContext as unknown as BuildContext);
47
+ assert.is(process.env.KEY1, 'VAL2');
48
+ });
49
+
50
+ suite2('should handle -e KEY (config[KEY] exists in package.json - string)', () => {
51
+ const mockContext = {
52
+ pkg: {
53
+ config: {
54
+ KEY: 'ABC',
55
+ },
56
+ },
57
+ cli: {
58
+ options: {
59
+ env: 'KEY',
60
+ },
61
+ },
62
+ };
63
+ setEnvVars(mockContext as unknown as BuildContext);
64
+ assert.is(process.env.KEY, mockContext.pkg.config.KEY);
65
+ });
66
+
67
+ suite2('should handle -e KEY (config[KEY] exists in package.json - number)', () => {
68
+ const mockContext = {
69
+ pkg: {
70
+ config: {
71
+ KEY: 5,
72
+ },
73
+ },
74
+ cli: {
75
+ options: {
76
+ env: 'KEY',
77
+ },
78
+ },
79
+ };
80
+ setEnvVars(mockContext as unknown as BuildContext);
81
+ assert.is(process.env.KEY, `${mockContext.pkg.config.KEY}`);
82
+ });
83
+
84
+ suite2('should handle -e KEY (config[KEY] exists in package.json - boolean false)', () => {
85
+ const mockContext = {
86
+ pkg: {
87
+ config: {
88
+ KEY: false,
89
+ },
90
+ },
91
+ cli: {
92
+ options: {
93
+ env: 'KEY',
94
+ },
95
+ },
96
+ };
97
+ setEnvVars(mockContext as unknown as BuildContext);
98
+ assert.is(process.env.KEY, `${mockContext.pkg.config.KEY}`);
99
+ });
100
+
101
+ suite2('should handle -e KEY (config[KEY] exists in package.json - boolean true)', () => {
102
+ const mockContext = {
103
+ pkg: {
104
+ config: {
105
+ KEY: true,
106
+ },
107
+ },
108
+ cli: {
109
+ options: {
110
+ env: 'KEY',
111
+ },
112
+ },
113
+ };
114
+ setEnvVars(mockContext as unknown as BuildContext);
115
+ assert.is(process.env.KEY, `${mockContext.pkg.config.KEY}`);
116
+ });
117
+
118
+ // -e CI
119
+ suite2("should handle -e KEY (config[KEY] doesn't exist in package.json)", () => {
120
+ const mockContext = {
121
+ pkg: {
122
+ config: {},
123
+ },
124
+ cli: {
125
+ options: {
126
+ env: 'KEY',
127
+ },
128
+ },
129
+ };
130
+ setEnvVars(mockContext as unknown as BuildContext);
131
+ assert.is(process.env.KEY, '1');
132
+ });
133
+
134
+ // -e API_HOST=API_HOST_DEV1 (where API_HOST_DEV1 exists in config)
135
+ suite2('should handle -e KEY=VAL (config[VAL] exists in package.json - string)', () => {
136
+ const mockContext = {
137
+ pkg: {
138
+ config: {
139
+ KEY: 'ABC',
140
+ VAL: 'XYZ',
141
+ },
142
+ },
143
+ cli: {
144
+ options: {
145
+ env: 'KEY=VAL',
146
+ },
147
+ },
148
+ };
149
+ setEnvVars(mockContext as unknown as BuildContext);
150
+ assert.is(process.env.KEY, mockContext.pkg.config.VAL);
151
+ });
152
+
153
+ suite2('should handle -e KEY=VAL (config[VAL] exists in package.json - boolean false)', () => {
154
+ const mockContext = {
155
+ pkg: {
156
+ config: {
157
+ KEY: 'ABC',
158
+ VAL: false,
159
+ },
160
+ },
161
+ cli: {
162
+ options: {
163
+ env: 'KEY=VAL',
164
+ },
165
+ },
166
+ };
167
+ setEnvVars(mockContext as unknown as BuildContext);
168
+ assert.is(process.env.KEY, `${mockContext.pkg.config.VAL}`);
169
+ });
170
+
171
+ // referencing enother env var
172
+ suite2(
173
+ "should handle -e KEY=VAL (config[VAL] doesn't exist in package.json, process.env[VAL] exists)",
174
+ () => {
175
+ const mockContext = {
176
+ pkg: {
177
+ config: {},
178
+ },
179
+ cli: {
180
+ options: {
181
+ env: 'KEY=VAL',
182
+ },
183
+ },
184
+ };
185
+ const VAL = 'ABC';
186
+ process.env.VAL = VAL;
187
+ setEnvVars(mockContext as unknown as BuildContext);
188
+ assert.is(process.env.KEY, VAL);
189
+ delete process.env.VAL;
190
+ },
191
+ );
192
+
193
+ // -e KEY=literal e.g. -e API_HOST=ws://host/
194
+ suite2(
195
+ "should handle -e KEY=VAL (config[VAL] doesn't exist in package.json, process.env[VAL] doesn't exist)",
196
+ () => {
197
+ const mockContext = {
198
+ pkg: {
199
+ config: {},
200
+ },
201
+ cli: {
202
+ options: {
203
+ env: 'KEY=VAL',
204
+ },
205
+ },
206
+ };
207
+ setEnvVars(mockContext as unknown as BuildContext);
208
+ assert.is(process.env.KEY, 'VAL');
209
+ },
210
+ );
211
+
212
+ suite2.run();
@@ -0,0 +1,277 @@
1
+ import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
2
+ import { render } from '../../src/utils';
3
+
4
+ const suite = createLogicSuite('Handlebars templating utils');
5
+
6
+ const scenarios = [
7
+ {
8
+ description: 'upperCase',
9
+ template: '{ "name": "{{upperCase name}}" }',
10
+ data: { name: 'Abc' },
11
+ expected: '{ "name": "ABC" }',
12
+ },
13
+ {
14
+ description: 'upperCase (non-existing variable)',
15
+ template: '{ "name": "{{upperCase doesnotexist}}" }',
16
+ data: {},
17
+ expected: '{ "name": "" }',
18
+ },
19
+
20
+ {
21
+ description: 'lowerCase',
22
+ template: '{ "name": "{{lowerCase name}}" }',
23
+ data: { name: 'AbC' },
24
+ expected: '{ "name": "abc" }',
25
+ },
26
+ {
27
+ description: 'lowerCase (non-existing variable)',
28
+ template: '{ "name": "{{lowerCase doesnotexist}}" }',
29
+ data: {},
30
+ expected: '{ "name": "" }',
31
+ },
32
+
33
+ {
34
+ description: 'kebabCase',
35
+ template: '{ "name": "{{kebabCase name}}" }',
36
+ data: { name: 'AbCd' },
37
+ expected: '{ "name": "ab-cd" }',
38
+ },
39
+ {
40
+ description: 'kebabCase',
41
+ template: '{ "name": "{{kebabCase name}}" }',
42
+ data: { name: 'ab.cd' },
43
+ expected: '{ "name": "ab-cd" }',
44
+ },
45
+ {
46
+ description: 'kebabCase',
47
+ template: '{ "name": "{{kebabCase name}}" }',
48
+ data: { name: 'ab cd' },
49
+ expected: '{ "name": "ab-cd" }',
50
+ },
51
+ {
52
+ description: 'kebabCase',
53
+ template: '{ "name": "{{kebabCase doesnotexist}}" }',
54
+ data: { name: 'ab cd' },
55
+ expected: '{ "name": "" }',
56
+ },
57
+
58
+ {
59
+ description: 'camelCase',
60
+ template: '{ "name": "{{camelCase name}}" }',
61
+ data: { name: 'AbCd' },
62
+ expected: '{ "name": "abCd" }',
63
+ },
64
+ {
65
+ description: 'camelCase',
66
+ template: '{ "name": "{{camelCase name}}" }',
67
+ data: { name: 'ab.cd' },
68
+ expected: '{ "name": "abCd" }',
69
+ },
70
+ {
71
+ description: 'camelCase',
72
+ template: '{ "name": "{{camelCase name}}" }',
73
+ data: { name: 'ab cd' },
74
+ expected: '{ "name": "abCd" }',
75
+ },
76
+ {
77
+ description: 'camelCase',
78
+ template: '{ "name": "{{camelCase doesnotexist}}" }',
79
+ data: { name: 'ab cd' },
80
+ expected: '{ "name": "" }',
81
+ },
82
+
83
+ {
84
+ description: 'capitalCase',
85
+ template: '{ "name": "{{capitalCase name}}" }',
86
+ data: { name: 'AbCd' },
87
+ expected: '{ "name": "Ab Cd" }',
88
+ },
89
+ {
90
+ description: 'capitalCase',
91
+ template: '{ "name": "{{capitalCase name}}" }',
92
+ data: { name: 'ab.cd' },
93
+ expected: '{ "name": "Ab Cd" }',
94
+ },
95
+ {
96
+ description: 'capitalCase',
97
+ template: '{ "name": "{{capitalCase name}}" }',
98
+ data: { name: 'ab cd' },
99
+ expected: '{ "name": "Ab Cd" }',
100
+ },
101
+ {
102
+ description: 'capitalCase',
103
+ template: '{ "name": "{{capitalCase doesnotexist}}" }',
104
+ data: { name: 'ab cd' },
105
+ expected: '{ "name": "" }',
106
+ },
107
+
108
+ {
109
+ description: 'snakeCase',
110
+ template: '{ "name": "{{snakeCase name}}" }',
111
+ data: { name: 'AbCd' },
112
+ expected: '{ "name": "ab_cd" }',
113
+ },
114
+ {
115
+ description: 'snakeCase',
116
+ template: '{ "name": "{{snakeCase name}}" }',
117
+ data: { name: 'ab.cd' },
118
+ expected: '{ "name": "ab_cd" }',
119
+ },
120
+ {
121
+ description: 'snakeCase',
122
+ template: '{ "name": "{{snakeCase name}}" }',
123
+ data: { name: 'ab cd' },
124
+ expected: '{ "name": "ab_cd" }',
125
+ },
126
+ {
127
+ description: 'snakeCase',
128
+ template: '{ "name": "{{snakeCase doesnotexist}}" }',
129
+ data: { name: 'ab cd' },
130
+ expected: '{ "name": "" }',
131
+ },
132
+
133
+ {
134
+ description: 'dotCase',
135
+ template: '{ "name": "{{dotCase name}}" }',
136
+ data: { name: 'AbCd' },
137
+ expected: '{ "name": "ab.cd" }',
138
+ },
139
+ {
140
+ description: 'dotCase',
141
+ template: '{ "name": "{{dotCase name}}" }',
142
+ data: { name: 'ab.cd' },
143
+ expected: '{ "name": "ab.cd" }',
144
+ },
145
+ {
146
+ description: 'dotCase',
147
+ template: '{ "name": "{{dotCase name}}" }',
148
+ data: { name: 'ab cd' },
149
+ expected: '{ "name": "ab.cd" }',
150
+ },
151
+ {
152
+ description: 'dotCase',
153
+ template: '{ "name": "{{dotCase doesnotexist}}" }',
154
+ data: { name: 'ab cd' },
155
+ expected: '{ "name": "" }',
156
+ },
157
+
158
+ {
159
+ description: 'pascalCase',
160
+ template: '{ "name": "{{pascalCase name}}" }',
161
+ data: { name: 'AbCd' },
162
+ expected: '{ "name": "AbCd" }',
163
+ },
164
+ {
165
+ description: 'pascalCase',
166
+ template: '{ "name": "{{pascalCase name}}" }',
167
+ data: { name: 'ab.cd' },
168
+ expected: '{ "name": "AbCd" }',
169
+ },
170
+ {
171
+ description: 'pascalCase',
172
+ template: '{ "name": "{{pascalCase name}}" }',
173
+ data: { name: 'ab cd' },
174
+ expected: '{ "name": "AbCd" }',
175
+ },
176
+ {
177
+ description: 'pascalCase',
178
+ template: '{ "name": "{{pascalCase doesnotexist}}" }',
179
+ data: { name: 'ab cd' },
180
+ expected: '{ "name": "" }',
181
+ },
182
+
183
+ {
184
+ description: 'sentenceCase',
185
+ template: '{ "name": "{{sentenceCase name}}" }',
186
+ data: { name: 'AbCd' },
187
+ expected: '{ "name": "Ab cd" }',
188
+ },
189
+ {
190
+ description: 'sentenceCase',
191
+ template: '{ "name": "{{sentenceCase name}}" }',
192
+ data: { name: 'ab.cd' },
193
+ expected: '{ "name": "Ab cd" }',
194
+ },
195
+ {
196
+ description: 'sentenceCase',
197
+ template: '{ "name": "{{sentenceCase name}}" }',
198
+ data: { name: 'ab cd' },
199
+ expected: '{ "name": "Ab cd" }',
200
+ },
201
+ {
202
+ description: 'sentenceCase',
203
+ template: '{ "name": "{{sentenceCase doesnotexist}}" }',
204
+ data: { name: 'ab cd' },
205
+ expected: '{ "name": "" }',
206
+ },
207
+
208
+ {
209
+ description: 'pathCase',
210
+ template: '{ "name": "{{pathCase name}}" }',
211
+ data: { name: 'AbCd' },
212
+ expected: '{ "name": "ab/cd" }',
213
+ },
214
+ {
215
+ description: 'pathCase',
216
+ template: '{ "name": "{{pathCase name}}" }',
217
+ data: { name: 'ab.cd' },
218
+ expected: '{ "name": "ab/cd" }',
219
+ },
220
+ {
221
+ description: 'pathCase',
222
+ template: '{ "name": "{{pathCase name}}" }',
223
+ data: { name: 'ab cd' },
224
+ expected: '{ "name": "ab/cd" }',
225
+ },
226
+ {
227
+ description: 'pathCase',
228
+ template: '{ "name": "{{pathCase doesnotexist}}" }',
229
+ data: { name: 'ab cd' },
230
+ expected: '{ "name": "" }',
231
+ },
232
+
233
+ {
234
+ description: 'constantCase',
235
+ template: '{ "name": "{{constantCase name}}" }',
236
+ data: { name: 'AbCd' },
237
+ expected: '{ "name": "AB_CD" }',
238
+ },
239
+ {
240
+ description: 'constantCase',
241
+ template: '{ "name": "{{constantCase name}}" }',
242
+ data: { name: 'ab.cd' },
243
+ expected: '{ "name": "AB_CD" }',
244
+ },
245
+ {
246
+ description: 'constantCase',
247
+ template: '{ "name": "{{constantCase name}}" }',
248
+ data: { name: 'ab cd' },
249
+ expected: '{ "name": "AB_CD" }',
250
+ },
251
+ {
252
+ description: 'constantCase',
253
+ template: '{ "name": "{{constantCase doesnotexist}}" }',
254
+ data: { name: 'ab cd' },
255
+ expected: '{ "name": "" }',
256
+ },
257
+ {
258
+ description: 'ifEquals',
259
+ template: '{{#ifEquals type "pie"}}true{{/ifEquals}}',
260
+ data: { type: 'pie' },
261
+ expected: 'true',
262
+ },
263
+ {
264
+ description: 'ifEquals',
265
+ template: '{{#ifEquals type "pie"}}true{{else}}false{{/ifEquals}}',
266
+ data: { type: 'line' },
267
+ expected: 'false',
268
+ },
269
+ ];
270
+
271
+ scenarios.forEach((scenario) => {
272
+ suite(scenario.description, () => {
273
+ assert.is(render(scenario.template, scenario.data), scenario.expected);
274
+ });
275
+ });
276
+
277
+ suite.run();
@@ -0,0 +1,14 @@
1
+ import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
2
+ import { getDevCertOptions } from '../../src/utils/https';
3
+
4
+ const suite = createLogicSuite('https dev server');
5
+
6
+ suite('should have default cert options', () => {
7
+ const options = getDevCertOptions();
8
+ assert.ok(
9
+ options,
10
+ 'Dev server cert options could not be created. Please ensure the local cert and key is available in build-kit/cert and is being published.',
11
+ );
12
+ });
13
+
14
+ suite.run();
@@ -0,0 +1,96 @@
1
+ import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
2
+ import type { ServerOptions } from 'http-proxy';
3
+ import type { DevProxies } from '../../src/utils/proxy';
4
+ import { convertWsEndpointToHTTP, createDevProxies, createDevProxy } from '../../src/utils/proxy';
5
+
6
+ const suite = createLogicSuite('dev server proxies');
7
+
8
+ suite('should convert websocket to http endpoints as expected', ({ runCases }) => {
9
+ runCases(convertWsEndpointToHTTP, [
10
+ [
11
+ ['wss://public-foundation.genesislab.global/gwf/', 'gwf'],
12
+ 'https://public-foundation.genesislab.global/',
13
+ ],
14
+ [
15
+ ['wss://public-foundation.genesislab.global/gwf/'],
16
+ 'https://public-foundation.genesislab.global/gwf/',
17
+ ],
18
+ [['wss://public-foundation.genesislab.global'], 'https://public-foundation.genesislab.global'],
19
+ [
20
+ ['ws://public-foundation.genesislab.global/gwf/', 'gwf'],
21
+ 'http://public-foundation.genesislab.global/',
22
+ ],
23
+ [
24
+ ['ws://public-foundation.genesislab.global/gwf/'],
25
+ 'http://public-foundation.genesislab.global/gwf/',
26
+ ],
27
+ [['ws://public-foundation.genesislab.global'], 'http://public-foundation.genesislab.global'],
28
+ [['wss://localhost:6060/gwf/', 'gwf'], 'https://localhost:6060/'],
29
+ [['ws://localhost:6060/gwf/', 'gwf'], 'http://localhost:6060/'],
30
+ [['ws://localhost:6060/gwf/'], 'http://localhost:6060/gwf/'],
31
+ [['ws://localhost:6060'], 'http://localhost:6060'],
32
+ ]);
33
+ });
34
+
35
+ suite('createDevProxy should return the expected proxy for given target', () => {
36
+ const proxy = createDevProxy({
37
+ target: 'https://rte.ie',
38
+ path: '/api',
39
+ options: {
40
+ ws: false,
41
+ cookieDomainRewrite: {
42
+ 'old.domain': 'new.domain',
43
+ '*': '',
44
+ },
45
+ },
46
+ });
47
+ const expectedProxy: DevProxies = {
48
+ ['/api']: {
49
+ target: 'https://rte.ie',
50
+ secure: false,
51
+ changeOrigin: true,
52
+ cookieDomainRewrite: {
53
+ 'old.domain': 'new.domain',
54
+ '*': '',
55
+ },
56
+ ws: false,
57
+ headers: {
58
+ origin: 'https://rte.ie',
59
+ },
60
+ },
61
+ };
62
+ assert.equal(proxy, expectedProxy);
63
+ });
64
+
65
+ suite('createDevProxy should return undefined when no target or API_HOST is set', () => {
66
+ assert.not.ok(createDevProxy({ path: '/api' }));
67
+ assert.not.ok(createDevProxy({}));
68
+ });
69
+
70
+ suite('createDevProxies should return default proxies for given target', () => {
71
+ const proxies = createDevProxies({ target: 'https://rte.ie' });
72
+ const expectedServerOptions: ServerOptions = {
73
+ target: 'https://rte.ie',
74
+ secure: false,
75
+ changeOrigin: true,
76
+ cookieDomainRewrite: 'localhost',
77
+ ws: true,
78
+ headers: {
79
+ origin: 'https://rte.ie',
80
+ },
81
+ };
82
+ const expectedProxies: DevProxies = {
83
+ ['/sm']: expectedServerOptions,
84
+ ['/sso']: expectedServerOptions,
85
+ ['/gwf']: expectedServerOptions,
86
+ };
87
+ assert.equal(proxies, expectedProxies);
88
+ });
89
+
90
+ // TODO: Double-check this one vs API_HOST requirement to not be set (fails on dev machines vs works on CI)
91
+ // suite('createDevProxies should return undefined when no target or API_HOST is set', () => {
92
+ // assert.not.ok(createDevProxies({ paths: ['/sm', '/gwf'] }));
93
+ // assert.not.ok(createDevProxies());
94
+ // });
95
+
96
+ suite.run();