@eik/common 4.0.0-next.7 → 4.0.1

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 (123) hide show
  1. package/CHANGELOG.md +110 -5
  2. package/README.md +9 -5
  3. package/eikjson.d.ts +1 -1
  4. package/{packages/config-loader/src/errors → lib/classes}/custom-error.js +1 -3
  5. package/{packages/config-loader/src → lib/classes}/eik-config.js +19 -17
  6. package/{packages/config-loader/src → lib}/classes/file-mapping.js +4 -6
  7. package/{packages/config-loader/src/errors → lib/classes}/invalid-config-error.js +2 -4
  8. package/{packages/config-loader/src → lib}/classes/local-file-location.js +5 -4
  9. package/{packages/config-loader/src/errors → lib/classes}/missing-config-error.js +2 -4
  10. package/{packages/config-loader/src/errors → lib/classes}/multiple-config-sources-error.js +2 -4
  11. package/{packages/config-loader/src/errors → lib/classes}/no-files-matched-error.js +2 -4
  12. package/{packages/config-loader/src → lib}/classes/read-file.js +4 -3
  13. package/{packages/config-loader/src → lib}/classes/remote-file-location.js +3 -3
  14. package/{packages/config-loader/src → lib}/classes/resolved-files.js +5 -6
  15. package/{packages/config-loader/src/errors → lib/classes}/single-dest-multiple-source-error.js +2 -4
  16. package/{packages/config-loader/src → lib/helpers}/config-store.js +39 -8
  17. package/lib/helpers/get-defaults.js +38 -0
  18. package/lib/helpers/index.js +25 -0
  19. package/{packages/config-loader/src → lib/helpers}/local-assets.js +9 -7
  20. package/{packages/utils/src → lib/helpers}/path-slashes.js +1 -1
  21. package/{packages/config-loader/src/utils → lib/helpers}/resolve-files.js +7 -11
  22. package/{packages/utils/src → lib/helpers}/type-slug.js +4 -1
  23. package/{packages/utils/src → lib/helpers}/type-title.js +4 -1
  24. package/lib/index.js +16 -0
  25. package/{packages/schemas/src → lib/schemas}/assert.js +6 -6
  26. package/lib/schemas/index.js +15 -0
  27. package/{packages/schemas/src → lib/schemas}/validate.js +18 -17
  28. package/{packages/schemas/src → lib/schemas}/validation-error.js +2 -2
  29. package/lib/stream.js +12 -0
  30. package/lib/validators/index.js +65 -0
  31. package/package.json +63 -6
  32. package/types/classes/custom-error.d.ts +6 -0
  33. package/types/classes/eik-config.d.ts +63 -0
  34. package/types/classes/file-mapping.d.ts +21 -0
  35. package/types/classes/invalid-config-error.d.ts +3 -0
  36. package/types/classes/local-file-location.d.ts +36 -0
  37. package/types/classes/missing-config-error.d.ts +3 -0
  38. package/types/classes/multiple-config-sources-error.d.ts +4 -0
  39. package/types/classes/no-files-matched-error.d.ts +3 -0
  40. package/types/classes/read-file.d.ts +15 -0
  41. package/types/classes/remote-file-location.d.ts +21 -0
  42. package/types/classes/resolved-files.d.ts +20 -0
  43. package/types/classes/single-dest-multiple-source-error.d.ts +3 -0
  44. package/types/helpers/config-store.d.ts +28 -0
  45. package/types/helpers/get-defaults.d.ts +9 -0
  46. package/types/helpers/index.d.ts +23 -0
  47. package/types/helpers/local-assets.d.ts +8 -0
  48. package/types/helpers/path-slashes.d.ts +32 -0
  49. package/types/helpers/resolve-files.d.ts +13 -0
  50. package/types/helpers/type-slug.d.ts +2 -0
  51. package/types/helpers/type-title.d.ts +2 -0
  52. package/types/index.d.ts +16 -0
  53. package/types/schemas/assert.d.ts +11 -0
  54. package/types/schemas/index.d.ts +11 -0
  55. package/types/schemas/validate.d.ts +26 -0
  56. package/types/schemas/validation-error.d.ts +8 -0
  57. package/types/stream.d.ts +2 -0
  58. package/types/validators/index.d.ts +8 -0
  59. package/.eslintignore +0 -2
  60. package/.eslintrc +0 -34
  61. package/.github/workflows/publish.yml +0 -69
  62. package/.github/workflows/test.yml +0 -45
  63. package/.prettierignore +0 -17
  64. package/.prettierrc +0 -20
  65. package/fixtures/client-with-bare-imports.js +0 -16
  66. package/fixtures/client.js +0 -6
  67. package/fixtures/client.js.map +0 -0
  68. package/fixtures/folder/client.js +0 -6
  69. package/fixtures/folder/styles.css +0 -0
  70. package/fixtures/icons/checkbox-sprite.svg +0 -46
  71. package/fixtures/nested/client.js.map +0 -0
  72. package/fixtures/nested/styles.css.map +0 -0
  73. package/fixtures/styles.css +0 -0
  74. package/fixtures/styles.css.map +0 -0
  75. package/packages/config-loader/.prettierignore +0 -17
  76. package/packages/config-loader/index.js +0 -13
  77. package/packages/config-loader/package.json +0 -42
  78. package/packages/config-loader/src/get-defaults.js +0 -25
  79. package/packages/config-loader/test/assets/esm.css +0 -0
  80. package/packages/config-loader/test/assets/esm.css.map +0 -0
  81. package/packages/config-loader/test/assets/esm.js +0 -0
  82. package/packages/config-loader/test/assets/esm.js.map +0 -0
  83. package/packages/config-loader/test/config-store.test.js +0 -231
  84. package/packages/config-loader/test/eik-config/cwd.test.js +0 -35
  85. package/packages/config-loader/test/eik-config/map.test.js +0 -31
  86. package/packages/config-loader/test/eik-config/mappings.test.js +0 -507
  87. package/packages/config-loader/test/eik-config/out.test.js +0 -54
  88. package/packages/config-loader/test/eik-config/server.test.js +0 -32
  89. package/packages/config-loader/test/eik-config/toJSON.test.js +0 -19
  90. package/packages/config-loader/test/eik-config/token.test.js +0 -49
  91. package/packages/config-loader/test/eik-config/type.test.js +0 -22
  92. package/packages/config-loader/test/eik-config/validate.test.js +0 -31
  93. package/packages/config-loader/test/eik-config/version.test.js +0 -22
  94. package/packages/config-loader/test/eik.json +0 -10
  95. package/packages/config-loader/test/local-assets.test.js +0 -125
  96. package/packages/config-loader/test/local-file-location/absolute.test.js +0 -35
  97. package/packages/config-loader/test/local-file-location/contentType.test.js +0 -55
  98. package/packages/config-loader/test/local-file-location/extension.test.js +0 -20
  99. package/packages/config-loader/test/local-file-location/mimeType.test.js +0 -43
  100. package/packages/config-loader/test/read-file.test.js +0 -60
  101. package/packages/config-loader/test/resolve-files.test.js +0 -257
  102. package/packages/config-loader/test/resolved-files/iterator.test.js +0 -17
  103. package/packages/config-loader/test/tmp/.gitkeep +0 -0
  104. package/packages/schemas/.prettierignore +0 -17
  105. package/packages/schemas/eikjson.d.ts +0 -41
  106. package/packages/schemas/index.js +0 -7
  107. package/packages/schemas/package.json +0 -40
  108. package/packages/schemas/test/assert.js +0 -207
  109. package/packages/schemas/test/index.js +0 -182
  110. package/packages/utils/.prettierignore +0 -17
  111. package/packages/utils/index.js +0 -20
  112. package/packages/utils/package.json +0 -29
  113. package/packages/utils/src/stream.js +0 -21
  114. package/packages/utils/tests/eik.json +0 -10
  115. package/packages/validators/.prettierignore +0 -17
  116. package/packages/validators/package.json +0 -34
  117. package/packages/validators/src/index.js +0 -53
  118. package/packages/validators/test/index.js +0 -238
  119. package/release/eik-common-4.0.0-next.7.tgz +0 -0
  120. package/release.config.js +0 -27
  121. package/renovate.json +0 -6
  122. package/tsconfig.json +0 -30
  123. /package/{packages/schemas/src → lib/schemas}/eikjson.schema.json +0 -0
@@ -1,507 +0,0 @@
1
- const { test } = require('tap');
2
- const { join } = require('path');
3
-
4
- const EikConfig = require('../../src/eik-config.js');
5
- const FileMapping = require('../../src/classes/file-mapping.js');
6
- const LocalFileLocation = require('../../src/classes/local-file-location.js');
7
- const RemoteFileLocation = require('../../src/classes/remote-file-location.js');
8
-
9
- const validEikConfig = {
10
- name: 'pizza',
11
- server: 'http://server',
12
- files: { '/': 'pizza' },
13
- version: '0.0.0',
14
- };
15
-
16
- const baseDir = join(__dirname, '../../../../fixtures');
17
-
18
- test('mappings - directory given', async (t) => {
19
- const config = new EikConfig(
20
- {
21
- ...validEikConfig,
22
- files: 'folder',
23
- },
24
- null,
25
- baseDir,
26
- );
27
-
28
- const mappings = await config.mappings();
29
- t.equal(mappings.length, 2);
30
- t.ok(mappings[0] instanceof FileMapping);
31
- t.ok(mappings[0].source instanceof LocalFileLocation);
32
- t.ok(mappings[0].destination instanceof RemoteFileLocation);
33
- t.equal(mappings[0].source.relative, 'client.js');
34
- t.match(mappings[0].source.basePath, 'fixtures/folder');
35
- t.notMatch(mappings[0].source.basePath, 'client.js');
36
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
37
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
38
- t.equal(mappings[0].destination.filePathname, '/client.js');
39
- t.equal(
40
- mappings[0].destination.url.href,
41
- 'http://server/pkg/pizza/0.0.0/client.js',
42
- );
43
- t.equal(mappings[1].source.relative, 'styles.css');
44
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
45
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
46
- t.equal(mappings[1].destination.filePathname, '/styles.css');
47
- t.equal(
48
- mappings[1].destination.url.href,
49
- 'http://server/pkg/pizza/0.0.0/styles.css',
50
- );
51
- t.end();
52
- });
53
-
54
- test('mappings - directory given - prefixed by ./', async (t) => {
55
- const config = new EikConfig(
56
- {
57
- ...validEikConfig,
58
- files: './folder',
59
- },
60
- null,
61
- baseDir,
62
- );
63
-
64
- const mappings = await config.mappings();
65
- t.equal(mappings.length, 2);
66
- t.equal(mappings[0].source.relative, 'client.js');
67
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
68
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
69
- t.equal(mappings[0].destination.filePathname, '/client.js');
70
- t.equal(
71
- mappings[0].destination.url.href,
72
- 'http://server/pkg/pizza/0.0.0/client.js',
73
- );
74
- t.equal(mappings[1].source.relative, 'styles.css');
75
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
76
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
77
- t.equal(mappings[1].destination.filePathname, '/styles.css');
78
- t.equal(
79
- mappings[1].destination.url.href,
80
- 'http://server/pkg/pizza/0.0.0/styles.css',
81
- );
82
- t.end();
83
- });
84
-
85
- test('mappings - directory given - trailing /', async (t) => {
86
- const config = new EikConfig(
87
- {
88
- ...validEikConfig,
89
- files: 'folder/',
90
- },
91
- null,
92
- baseDir,
93
- );
94
-
95
- const mappings = await config.mappings();
96
- t.equal(mappings.length, 2);
97
- t.equal(mappings[0].source.relative, 'client.js');
98
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
99
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
100
- t.equal(mappings[0].destination.filePathname, '/client.js');
101
- t.equal(
102
- mappings[0].destination.url.href,
103
- 'http://server/pkg/pizza/0.0.0/client.js',
104
- );
105
- t.equal(mappings[1].source.relative, 'styles.css');
106
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
107
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
108
- t.equal(mappings[1].destination.filePathname, '/styles.css');
109
- t.equal(
110
- mappings[1].destination.url.href,
111
- 'http://server/pkg/pizza/0.0.0/styles.css',
112
- );
113
- t.end();
114
- });
115
-
116
- test('mappings - directory given - prefixed by ./', async (t) => {
117
- const config = new EikConfig(
118
- {
119
- ...validEikConfig,
120
- files: './folder',
121
- },
122
- null,
123
- baseDir,
124
- );
125
-
126
- const mappings = await config.mappings();
127
- t.equal(mappings.length, 2);
128
- t.equal(mappings[0].source.relative, 'client.js');
129
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
130
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
131
- t.equal(mappings[0].destination.filePathname, '/client.js');
132
- t.equal(
133
- mappings[0].destination.url.href,
134
- 'http://server/pkg/pizza/0.0.0/client.js',
135
- );
136
- t.equal(mappings[1].source.relative, 'styles.css');
137
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
138
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
139
- t.equal(mappings[1].destination.filePathname, '/styles.css');
140
- t.equal(
141
- mappings[1].destination.url.href,
142
- 'http://server/pkg/pizza/0.0.0/styles.css',
143
- );
144
- t.end();
145
- });
146
-
147
- test('mappings - recursive glob given', async (t) => {
148
- const config = new EikConfig(
149
- {
150
- ...validEikConfig,
151
- files: 'folder/**/*',
152
- },
153
- null,
154
- baseDir,
155
- );
156
-
157
- const mappings = await config.mappings();
158
- t.equal(mappings.length, 2);
159
- t.equal(mappings[0].source.relative, 'client.js');
160
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
161
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
162
- t.equal(mappings[0].destination.filePathname, '/client.js');
163
- t.equal(
164
- mappings[0].destination.url.href,
165
- 'http://server/pkg/pizza/0.0.0/client.js',
166
- );
167
- t.equal(mappings[1].source.relative, 'styles.css');
168
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
169
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
170
- t.equal(mappings[1].destination.filePathname, '/styles.css');
171
- t.equal(
172
- mappings[1].destination.url.href,
173
- 'http://server/pkg/pizza/0.0.0/styles.css',
174
- );
175
- t.end();
176
- });
177
-
178
- test('mappings - file given', async (t) => {
179
- const config = new EikConfig(
180
- {
181
- ...validEikConfig,
182
- files: 'folder/client.js',
183
- },
184
- null,
185
- baseDir,
186
- );
187
-
188
- const mappings = await config.mappings();
189
- t.equal(mappings.length, 1);
190
- t.equal(mappings[0].source.relative, 'client.js');
191
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
192
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
193
- t.equal(mappings[0].destination.filePathname, '/client.js');
194
- t.equal(
195
- mappings[0].destination.url.href,
196
- 'http://server/pkg/pizza/0.0.0/client.js',
197
- );
198
- t.end();
199
- });
200
-
201
- test('mappings - file given via glob', async (t) => {
202
- const config = new EikConfig(
203
- {
204
- ...validEikConfig,
205
- files: 'folder/*.js',
206
- },
207
- null,
208
- baseDir,
209
- );
210
-
211
- const mappings = await config.mappings();
212
- t.equal(mappings.length, 1);
213
- t.equal(mappings[0].source.relative, 'client.js');
214
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
215
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
216
- t.equal(mappings[0].destination.filePathname, '/client.js');
217
- t.equal(
218
- mappings[0].destination.url.href,
219
- 'http://server/pkg/pizza/0.0.0/client.js',
220
- );
221
- t.end();
222
- });
223
-
224
- test('mappings - files given via glob - nested directories', async (t) => {
225
- const config = new EikConfig(
226
- {
227
- ...validEikConfig,
228
- files: './**/*.js',
229
- },
230
- null,
231
- baseDir,
232
- );
233
-
234
- const mappings = await config.mappings();
235
- t.equal(mappings.length, 3);
236
- t.equal(mappings[0].source.relative, 'client-with-bare-imports.js');
237
- t.equal(mappings[1].source.relative, 'client.js');
238
- t.equal(mappings[2].source.relative, 'folder/client.js');
239
- t.equal(
240
- mappings[0].destination.filePathname,
241
- '/client-with-bare-imports.js',
242
- );
243
- t.equal(mappings[1].destination.filePathname, '/client.js');
244
- t.equal(mappings[2].destination.filePathname, '/folder/client.js');
245
-
246
- t.end();
247
- });
248
-
249
- test('mappings - files is an object - remaps name of file', async (t) => {
250
- const config = new EikConfig(
251
- {
252
- ...validEikConfig,
253
- files: {
254
- 'script.js': 'folder/client.js',
255
- },
256
- },
257
- null,
258
- baseDir,
259
- );
260
-
261
- const mappings = await config.mappings();
262
- t.equal(mappings.length, 1);
263
- t.equal(mappings[0].source.relative, 'client.js');
264
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
265
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
266
- t.equal(mappings[0].destination.filePathname, '/script.js');
267
- t.equal(
268
- mappings[0].destination.url.href,
269
- 'http://server/pkg/pizza/0.0.0/script.js',
270
- );
271
-
272
- t.end();
273
- });
274
-
275
- test('mappings - files is an object - remaps name of file - absolute path to file given', async (t) => {
276
- const config = new EikConfig(
277
- {
278
- ...validEikConfig,
279
- files: {
280
- 'script.js': join(baseDir, 'folder/client.js'),
281
- },
282
- },
283
- null,
284
- baseDir,
285
- );
286
-
287
- const mappings = await config.mappings();
288
- t.equal(mappings.length, 1);
289
- t.equal(mappings[0].source.relative, 'client.js');
290
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
291
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
292
- t.equal(mappings[0].destination.filePathname, '/script.js');
293
- t.equal(
294
- mappings[0].destination.url.href,
295
- 'http://server/pkg/pizza/0.0.0/script.js',
296
- );
297
-
298
- t.end();
299
- });
300
-
301
- test('mappings - files is an object - mapped to folder - absolute path to folder given', async (t) => {
302
- const config = new EikConfig(
303
- {
304
- ...validEikConfig,
305
- files: {
306
- folder: join(baseDir, 'folder'),
307
- },
308
- },
309
- null,
310
- baseDir,
311
- );
312
-
313
- const mappings = await config.mappings();
314
- t.equal(mappings.length, 2);
315
- t.equal(mappings[0].source.relative, 'client.js');
316
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
317
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
318
- t.equal(mappings[0].destination.filePathname, '/folder/client.js');
319
- t.equal(
320
- mappings[0].destination.url.href,
321
- 'http://server/pkg/pizza/0.0.0/folder/client.js',
322
- );
323
- t.equal(mappings[1].source.relative, 'styles.css');
324
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
325
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
326
- t.equal(mappings[1].destination.filePathname, '/folder/styles.css');
327
- t.equal(
328
- mappings[1].destination.url.href,
329
- 'http://server/pkg/pizza/0.0.0/folder/styles.css',
330
- );
331
-
332
- t.end();
333
- });
334
-
335
- test('mappings - files is an object - mapped to folder - relative path to folder given', async (t) => {
336
- const config = new EikConfig(
337
- {
338
- ...validEikConfig,
339
- files: {
340
- folder: './folder',
341
- },
342
- },
343
- null,
344
- baseDir,
345
- );
346
-
347
- const mappings = await config.mappings();
348
- t.equal(mappings.length, 2);
349
- t.equal(mappings[0].source.relative, 'client.js');
350
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
351
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
352
- t.equal(mappings[0].destination.filePathname, '/folder/client.js');
353
- t.equal(
354
- mappings[0].destination.url.href,
355
- 'http://server/pkg/pizza/0.0.0/folder/client.js',
356
- );
357
- t.equal(mappings[1].source.relative, 'styles.css');
358
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
359
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
360
- t.equal(mappings[1].destination.filePathname, '/folder/styles.css');
361
- t.equal(
362
- mappings[1].destination.url.href,
363
- 'http://server/pkg/pizza/0.0.0/folder/styles.css',
364
- );
365
-
366
- t.end();
367
- });
368
-
369
- test('mappings - files is an object - mapped to folder - relative path to folder given - no leading . in path', async (t) => {
370
- const config = new EikConfig(
371
- {
372
- ...validEikConfig,
373
- files: {
374
- folder: 'folder',
375
- },
376
- },
377
- null,
378
- baseDir,
379
- );
380
-
381
- const mappings = await config.mappings();
382
- t.equal(mappings.length, 2);
383
- t.equal(mappings[0].source.relative, 'client.js');
384
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
385
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
386
- t.equal(mappings[0].destination.filePathname, '/folder/client.js');
387
- t.equal(
388
- mappings[0].destination.url.href,
389
- 'http://server/pkg/pizza/0.0.0/folder/client.js',
390
- );
391
- t.equal(mappings[1].source.relative, 'styles.css');
392
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
393
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
394
- t.equal(mappings[1].destination.filePathname, '/folder/styles.css');
395
- t.equal(
396
- mappings[1].destination.url.href,
397
- 'http://server/pkg/pizza/0.0.0/folder/styles.css',
398
- );
399
-
400
- t.end();
401
- });
402
-
403
- test('mappings - files is an object - mapped to folder glob', async (t) => {
404
- const config = new EikConfig(
405
- {
406
- ...validEikConfig,
407
- files: {
408
- folder: 'folder/**/*',
409
- },
410
- },
411
- null,
412
- baseDir,
413
- );
414
-
415
- const mappings = await config.mappings();
416
- t.equal(mappings.length, 2);
417
- t.equal(mappings[0].source.relative, 'client.js');
418
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
419
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
420
- t.equal(mappings[0].destination.filePathname, '/folder/client.js');
421
- t.equal(
422
- mappings[0].destination.url.href,
423
- 'http://server/pkg/pizza/0.0.0/folder/client.js',
424
- );
425
- t.equal(mappings[1].source.relative, 'styles.css');
426
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
427
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
428
- t.equal(mappings[1].destination.filePathname, '/folder/styles.css');
429
- t.equal(
430
- mappings[1].destination.url.href,
431
- 'http://server/pkg/pizza/0.0.0/folder/styles.css',
432
- );
433
-
434
- t.end();
435
- });
436
-
437
- test('mappings - files is an object - mapped to folder glob - no folder recursion', async (t) => {
438
- const config = new EikConfig(
439
- {
440
- ...validEikConfig,
441
- files: {
442
- folder: '*',
443
- },
444
- },
445
- null,
446
- baseDir,
447
- );
448
-
449
- const mappings = await config.mappings();
450
- t.equal(mappings.length, 5);
451
- t.end();
452
- });
453
-
454
- test('mappings - files is an object - mapped to nested folder', async (t) => {
455
- const config = new EikConfig(
456
- {
457
- ...validEikConfig,
458
- files: {
459
- 'path/to/folder': 'folder',
460
- },
461
- },
462
- null,
463
- baseDir,
464
- );
465
-
466
- const mappings = await config.mappings();
467
- t.equal(mappings.length, 2);
468
- t.equal(mappings[0].source.relative, 'client.js');
469
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
470
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
471
- t.equal(mappings[0].destination.filePathname, '/path/to/folder/client.js');
472
- t.equal(
473
- mappings[0].destination.url.href,
474
- 'http://server/pkg/pizza/0.0.0/path/to/folder/client.js',
475
- );
476
- t.equal(mappings[1].source.relative, 'styles.css');
477
- t.match(mappings[1].source.absolute, 'fixtures/folder/styles.css');
478
- t.equal(mappings[1].destination.packagePathname, '/pkg/pizza/0.0.0');
479
- t.equal(mappings[1].destination.filePathname, '/path/to/folder/styles.css');
480
- t.equal(
481
- mappings[1].destination.url.href,
482
- 'http://server/pkg/pizza/0.0.0/path/to/folder/styles.css',
483
- );
484
-
485
- t.end();
486
- });
487
-
488
- test('mappings - files is an object - mapped to folder - absolute path to folder given - non matching cwd', async (t) => {
489
- const config = new EikConfig(
490
- {
491
- ...validEikConfig,
492
- files: {
493
- folder: join(baseDir, 'folder'),
494
- },
495
- },
496
- null,
497
- process.cwd(),
498
- );
499
-
500
- const mappings = await config.mappings();
501
- t.equal(mappings[0].source.relative, 'client.js');
502
- t.match(mappings[0].source.absolute, 'fixtures/folder/client.js');
503
- t.equal(mappings[0].destination.packagePathname, '/pkg/pizza/0.0.0');
504
- t.equal(mappings[0].destination.filePathname, '/folder/client.js');
505
-
506
- t.end();
507
- });
@@ -1,54 +0,0 @@
1
- const { test } = require('tap');
2
- const EikConfig = require('../../src/eik-config.js');
3
-
4
- const validEikConfig = {
5
- name: 'pizza',
6
- server: 'http://server',
7
- files: { '/': 'pizza' },
8
- version: '0.0.0',
9
- };
10
-
11
- test('EikConfig: .out: no value given', (t) => {
12
- t.equal(
13
- new EikConfig(validEikConfig).out,
14
- '.eik',
15
- 'should default to .eik',
16
- );
17
- t.end();
18
- });
19
-
20
- test('EikConfig: .out: value pizza-box given', (t) => {
21
- t.equal(
22
- new EikConfig({
23
- ...validEikConfig,
24
- out: 'pizza-box',
25
- }).out,
26
- 'pizza-box',
27
- 'should be set to ./pizza-box',
28
- );
29
- t.end();
30
- });
31
-
32
- test('EikConfig: .out: value pizza-box/ given', (t) => {
33
- t.equal(
34
- new EikConfig({
35
- ...validEikConfig,
36
- out: 'pizza-box/',
37
- }).out,
38
- 'pizza-box',
39
- 'should have trailing slash removed',
40
- );
41
- t.end();
42
- });
43
-
44
- test('EikConfig: .out: value ./pizza-box given', (t) => {
45
- t.equal(
46
- new EikConfig({
47
- ...validEikConfig,
48
- out: './pizza-box',
49
- }).out,
50
- 'pizza-box',
51
- 'should have leading ./ slash removed',
52
- );
53
- t.end();
54
- });
@@ -1,32 +0,0 @@
1
- const { test } = require('tap');
2
- const EikConfig = require('../../src/eik-config.js');
3
-
4
- const validEikConfig = {
5
- name: 'pizza',
6
- server: 'http://server',
7
- files: { '/': 'pizza' },
8
- version: '0.0.0',
9
- };
10
-
11
- test('EikConfig: .server: accessing property', (t) => {
12
- const config = new EikConfig(validEikConfig);
13
- t.equal(
14
- config.server,
15
- 'http://server',
16
- 'should equal value given to constructor',
17
- );
18
- t.end();
19
- });
20
-
21
- test('EikConfig: .server: accessing property: no config given', (t) => {
22
- const config = new EikConfig(null, [
23
- ['http://bakery', 'muffins'],
24
- ['http://server', 'kumara pie'],
25
- ]);
26
- t.equal(
27
- config.server,
28
- 'http://bakery',
29
- 'should fallback to value given to tokens',
30
- );
31
- t.end();
32
- });
@@ -1,19 +0,0 @@
1
- const { test } = require('tap');
2
- const EikConfig = require('../../src/eik-config.js');
3
-
4
- const validEikConfig = {
5
- name: 'pizza',
6
- server: 'http://server',
7
- files: { '/': 'pizza' },
8
- version: '0.0.0',
9
- };
10
-
11
- test('EikConfig: .toJSON', (t) => {
12
- const config = new EikConfig(validEikConfig);
13
- t.same(
14
- config.toJSON(),
15
- validEikConfig,
16
- 'should serialize config given to constructor',
17
- );
18
- t.end();
19
- });
@@ -1,49 +0,0 @@
1
- const { test } = require('tap');
2
- const EikConfig = require('../../src/eik-config.js');
3
-
4
- const validEikConfig = {
5
- name: 'pizza',
6
- server: 'http://server',
7
- files: { '/': 'pizza' },
8
- version: '0.0.0',
9
- };
10
-
11
- test('EikConfig: .token: no token configured', (t) => {
12
- const config = new EikConfig(validEikConfig, null);
13
- t.same(config.token, null);
14
- t.end();
15
- });
16
-
17
- test('EikConfig: .token: single token present: config given', (t) => {
18
- const config = new EikConfig(validEikConfig, [
19
- ['http://server', 'muffins'],
20
- ]);
21
- t.equal(
22
- config.server,
23
- 'http://server',
24
- 'server should be provided from config',
25
- );
26
- t.equal(config.token, 'muffins', 'token should match given token');
27
- t.end();
28
- });
29
-
30
- test('EikConfig: .token: single token present', (t) => {
31
- const config = new EikConfig(null, [['http://server', 'muffins']]);
32
- t.equal(
33
- config.server,
34
- 'http://server',
35
- 'server should be provided from tokens',
36
- );
37
- t.equal(config.token, 'muffins', 'token should match given token');
38
- t.end();
39
- });
40
-
41
- test('EikConfig: .token: multiple tokens present', (t) => {
42
- const config = new EikConfig(null, [
43
- ['http://server', 'muffins'],
44
- ['http://server2', 'cupcakes'],
45
- ]);
46
- t.equal(config.server, 'http://server');
47
- t.equal(config.token, 'muffins', 'token should match first given token');
48
- t.end();
49
- });
@@ -1,22 +0,0 @@
1
- const { test } = require('tap');
2
- const EikConfig = require('../../src/eik-config.js');
3
-
4
- const validEikConfig = {
5
- name: 'pizza',
6
- server: 'http://server',
7
- files: { '/': 'pizza' },
8
- version: '0.0.0',
9
- type: 'npm',
10
- };
11
-
12
- test('EikConfig: .type: no value given', (t) => {
13
- const config = new EikConfig(null);
14
- t.equal(config.type, 'package', 'should default to "package"');
15
- t.end();
16
- });
17
-
18
- test('EikConfig: .type: value given', (t) => {
19
- const config = new EikConfig(validEikConfig);
20
- t.equal(config.type, 'npm', 'should overwrite default value');
21
- t.end();
22
- });