@grafana/create-plugin 2.11.2 → 2.12.0-canary.658.dabaee1.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 (62) hide show
  1. package/dist/bin/run.js +13 -18
  2. package/dist/commands/generate/prettify-files.js +15 -70
  3. package/dist/commands/generate/print-success-message.js +28 -31
  4. package/dist/commands/generate/prompt-user.js +23 -91
  5. package/dist/commands/generate/update-go-sdk-and-packages.js +36 -105
  6. package/dist/commands/generate.command.js +122 -240
  7. package/dist/commands/index.js +5 -21
  8. package/dist/commands/migrate.command.js +71 -134
  9. package/dist/commands/provisioning.command.js +30 -85
  10. package/dist/commands/types.js +1 -2
  11. package/dist/commands/update.command.js +44 -97
  12. package/dist/commands/version.command.js +16 -57
  13. package/dist/constants.js +37 -32
  14. package/dist/utils/tests/utils.files.test.js +21 -23
  15. package/dist/utils/tests/utils.handlebars.test.js +24 -26
  16. package/dist/utils/tests/utils.npm.test.js +103 -95
  17. package/dist/utils/tests/utils.plugin.test.js +11 -13
  18. package/dist/utils/tests/utils.templates.test.js +16 -18
  19. package/dist/utils/utils.config.js +30 -32
  20. package/dist/utils/utils.console.js +25 -31
  21. package/dist/utils/utils.files.js +38 -104
  22. package/dist/utils/utils.handlebars.js +30 -65
  23. package/dist/utils/utils.npm.js +75 -118
  24. package/dist/utils/utils.os.js +3 -7
  25. package/dist/utils/utils.packageManager.js +31 -37
  26. package/dist/utils/utils.packagejson.js +13 -22
  27. package/dist/utils/utils.path.js +7 -14
  28. package/dist/utils/utils.plugin.js +6 -13
  29. package/dist/utils/utils.templates.js +58 -80
  30. package/dist/utils/utils.version.js +9 -11
  31. package/package.json +20 -6
  32. package/src/bin/run.ts +2 -2
  33. package/src/commands/generate/prettify-files.ts +1 -1
  34. package/src/commands/generate/print-success-message.ts +4 -4
  35. package/src/commands/generate/prompt-user.ts +2 -2
  36. package/src/commands/generate/update-go-sdk-and-packages.ts +2 -2
  37. package/src/commands/generate.command.ts +15 -15
  38. package/src/commands/index.ts +5 -5
  39. package/src/commands/migrate.command.ts +6 -6
  40. package/src/commands/provisioning.command.ts +6 -6
  41. package/src/commands/types.ts +1 -1
  42. package/src/commands/update.command.ts +5 -5
  43. package/src/commands/version.command.ts +5 -2
  44. package/src/constants.ts +4 -1
  45. package/src/utils/tests/utils.files.test.ts +2 -2
  46. package/src/utils/tests/utils.handlebars.test.ts +2 -2
  47. package/src/utils/tests/utils.npm.test.ts +43 -34
  48. package/src/utils/tests/utils.plugin.test.ts +2 -2
  49. package/src/utils/tests/utils.templates.test.ts +2 -2
  50. package/src/utils/utils.config.ts +3 -3
  51. package/src/utils/utils.console.ts +16 -11
  52. package/src/utils/utils.files.ts +3 -3
  53. package/src/utils/utils.handlebars.ts +3 -3
  54. package/src/utils/utils.npm.ts +3 -3
  55. package/src/utils/utils.packageManager.ts +3 -3
  56. package/src/utils/utils.packagejson.ts +5 -5
  57. package/src/utils/utils.path.ts +3 -3
  58. package/src/utils/utils.plugin.ts +2 -3
  59. package/src/utils/utils.templates.ts +10 -10
  60. package/src/utils/utils.version.ts +5 -2
  61. package/tsconfig.json +5 -0
  62. package/vitest.config.ts +10 -0
@@ -1,15 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var utils_npm_1 = require("../utils.npm");
4
- var utils_packagejson_1 = require("../utils.packagejson");
5
- jest.mock('../utils.packagejson.ts');
6
- var getPackageJsonMock = utils_packagejson_1.getPackageJson;
7
- var getLatestPackageJsonMock = utils_packagejson_1.getLatestPackageJson;
8
- var writePackageJsonMock = utils_packagejson_1.writePackageJson;
9
- describe('Utils / NPM', function () {
10
- describe('getUpdatableNpmDependencies()', function () {
11
- test('it should return a summary of dependencies to be updated', function () {
12
- expect((0, utils_npm_1.getUpdatableNpmDependencies)({
1
+ import { vi } from 'vitest';
2
+ import { updateNpmDependencies, getUpdatableNpmDependencies, hasNpmDependenciesToUpdate, getPackageJsonUpdatesAsText, updatePackageJson, } from '../utils.npm.js';
3
+ const mocks = vi.hoisted(() => {
4
+ return {
5
+ getPackageJson: vi.fn(),
6
+ getLatestPackageJson: vi.fn(),
7
+ writePackageJson: vi.fn(),
8
+ };
9
+ });
10
+ vi.mock('../utils.packagejson.js', async () => {
11
+ return {
12
+ getPackageJson: mocks.getPackageJson,
13
+ getLatestPackageJson: mocks.getLatestPackageJson,
14
+ writePackageJson: mocks.writePackageJson,
15
+ };
16
+ });
17
+ describe('Utils / NPM', () => {
18
+ describe('getUpdatableNpmDependencies()', () => {
19
+ test('it should return a summary of dependencies to be updated', () => {
20
+ expect(getUpdatableNpmDependencies({
13
21
  '@grafana/tsconfig': '^1.2.0-rc1',
14
22
  '@swc/core': '^1.2.162',
15
23
  '@types/minimist': '^1.6.2',
@@ -27,8 +35,8 @@ describe('Utils / NPM', function () {
27
35
  '@types/minimist': { prev: '^1.6.2', next: '^1.4.2' },
28
36
  });
29
37
  });
30
- test('it should be possible to only update dependencies that are outdated', function () {
31
- expect((0, utils_npm_1.getUpdatableNpmDependencies)({
38
+ test('it should be possible to only update dependencies that are outdated', () => {
39
+ expect(getUpdatableNpmDependencies({
32
40
  '@grafana/tsconfig': '^1.2.0-rc1',
33
41
  '@swc/core': '^1.2.162',
34
42
  '@types/minimist': '^1.6.2',
@@ -45,8 +53,8 @@ describe('Utils / NPM', function () {
45
53
  '@grafana/tsconfig': { prev: '^1.2.0-rc1', next: '^2.0.0' },
46
54
  });
47
55
  });
48
- test('it should be able to override with using release channels like "latest"', function () {
49
- expect((0, utils_npm_1.getUpdatableNpmDependencies)({
56
+ test('it should be able to override with using release channels like "latest"', () => {
57
+ expect(getUpdatableNpmDependencies({
50
58
  '@grafana/tsconfig': 'latest',
51
59
  '@swc/core': '^1.2.162',
52
60
  '@types/minimist': '^1.6.2',
@@ -66,9 +74,9 @@ describe('Utils / NPM', function () {
66
74
  });
67
75
  });
68
76
  });
69
- describe('updateNpmDependencies()', function () {
70
- test('it should update existing dependencies', function () {
71
- expect((0, utils_npm_1.updateNpmDependencies)({
77
+ describe('updateNpmDependencies()', () => {
78
+ test('it should update existing dependencies', () => {
79
+ expect(updateNpmDependencies({
72
80
  '@grafana/tsconfig': '^1.2.0-rc1',
73
81
  '@swc/core': '^1.2.162',
74
82
  '@types/minimist': '^1.2.2',
@@ -87,8 +95,8 @@ describe('Utils / NPM', function () {
87
95
  'node-plop': '0.26.3',
88
96
  });
89
97
  });
90
- test('it should add new depdendencies', function () {
91
- expect((0, utils_npm_1.updateNpmDependencies)({
98
+ test('it should add new depdendencies', () => {
99
+ expect(updateNpmDependencies({
92
100
  '@grafana/tsconfig': '^1.2.0-rc1',
93
101
  '@swc/core': '^1.2.162',
94
102
  }, {
@@ -101,8 +109,8 @@ describe('Utils / NPM', function () {
101
109
  '@types/minimist': '^1.4.2',
102
110
  });
103
111
  });
104
- test('it should override `latest` and other release channels', function () {
105
- expect((0, utils_npm_1.updateNpmDependencies)({
112
+ test('it should override `latest` and other release channels', () => {
113
+ expect(updateNpmDependencies({
106
114
  '@grafana/tsconfig': 'latest',
107
115
  '@swc/core': '^1.2.162',
108
116
  '@types/minimist': '^1.2.2',
@@ -120,8 +128,8 @@ describe('Utils / NPM', function () {
120
128
  'node-plop': '0.26.3',
121
129
  });
122
130
  });
123
- test('it should be able to override with using release channels like "latest"', function () {
124
- expect((0, utils_npm_1.updateNpmDependencies)({
131
+ test('it should be able to override with using release channels like "latest"', () => {
132
+ expect(updateNpmDependencies({
125
133
  '@grafana/tsconfig': '^2.0.0',
126
134
  '@swc/core': '^1.2.162',
127
135
  '@types/minimist': '^1.2.2',
@@ -140,9 +148,9 @@ describe('Utils / NPM', function () {
140
148
  });
141
149
  });
142
150
  });
143
- describe('hasNpmDependenciesToUpdate()', function () {
144
- test('It should return false when there are no npm dependencies to update', function () {
145
- var packageJson = {
151
+ describe('hasNpmDependenciesToUpdate()', () => {
152
+ test('It should return false when there are no npm dependencies to update', () => {
153
+ const packageJson = {
146
154
  dependencies: {
147
155
  '@grafana/ui': '10.0.0',
148
156
  react: '18.2.0',
@@ -153,13 +161,13 @@ describe('Utils / NPM', function () {
153
161
  },
154
162
  scripts: {},
155
163
  };
156
- getPackageJsonMock.mockReturnValue(packageJson);
157
- getLatestPackageJsonMock.mockReturnValue(packageJson);
158
- var result = (0, utils_npm_1.hasNpmDependenciesToUpdate)();
164
+ mocks.getPackageJson.mockReturnValue(packageJson);
165
+ mocks.getLatestPackageJson.mockReturnValue(packageJson);
166
+ const result = hasNpmDependenciesToUpdate();
159
167
  expect(result).toBe(false);
160
168
  });
161
- test('It should return true when there are npm dependencies to update', function () {
162
- var packageJson = {
169
+ test('It should return true when there are npm dependencies to update', () => {
170
+ const packageJson = {
163
171
  dependencies: {
164
172
  '@grafana/ui': '10.0.0',
165
173
  react: '18.2.0',
@@ -170,7 +178,7 @@ describe('Utils / NPM', function () {
170
178
  },
171
179
  scripts: {},
172
180
  };
173
- var latestPackageJson = {
181
+ const latestPackageJson = {
174
182
  dependencies: {
175
183
  '@grafana/ui': '10.0.0',
176
184
  react: '18.2.1',
@@ -181,13 +189,13 @@ describe('Utils / NPM', function () {
181
189
  },
182
190
  scripts: {},
183
191
  };
184
- getPackageJsonMock.mockReturnValue(packageJson);
185
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
186
- var result = (0, utils_npm_1.hasNpmDependenciesToUpdate)();
192
+ mocks.getPackageJson.mockReturnValue(packageJson);
193
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
194
+ const result = hasNpmDependenciesToUpdate();
187
195
  expect(result).toBe(true);
188
196
  });
189
- test('It should return false when there are no dev dependencies to update in devOnly mode', function () {
190
- var packageJson = {
197
+ test('It should return false when there are no dev dependencies to update in devOnly mode', () => {
198
+ const packageJson = {
191
199
  dependencies: {
192
200
  '@grafana/ui': '10.0.0',
193
201
  react: '18.2.0',
@@ -198,7 +206,7 @@ describe('Utils / NPM', function () {
198
206
  },
199
207
  scripts: {},
200
208
  };
201
- var latestPackageJson = {
209
+ const latestPackageJson = {
202
210
  dependencies: {
203
211
  '@grafana/ui': '10.0.0',
204
212
  react: '18.2.1',
@@ -209,15 +217,15 @@ describe('Utils / NPM', function () {
209
217
  },
210
218
  scripts: {},
211
219
  };
212
- getPackageJsonMock.mockReturnValue(packageJson);
213
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
214
- var result = (0, utils_npm_1.hasNpmDependenciesToUpdate)({ devOnly: true });
220
+ mocks.getPackageJson.mockReturnValue(packageJson);
221
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
222
+ const result = hasNpmDependenciesToUpdate({ devOnly: true });
215
223
  expect(result).toBe(false);
216
224
  });
217
225
  });
218
- describe('getPackageJsonUpdatesAsText', function () {
219
- test("It should return an empty text when there's nothing to update", function () {
220
- var packageJson = {
226
+ describe('getPackageJsonUpdatesAsText', () => {
227
+ test("It should return an empty text when there's nothing to update", () => {
228
+ const packageJson = {
221
229
  dependencies: {
222
230
  '@grafana/ui': '10.0.0',
223
231
  react: '18.2.0',
@@ -228,13 +236,13 @@ describe('Utils / NPM', function () {
228
236
  },
229
237
  scripts: {},
230
238
  };
231
- getPackageJsonMock.mockReturnValue(packageJson);
232
- getLatestPackageJsonMock.mockReturnValue(packageJson);
233
- var result = (0, utils_npm_1.getPackageJsonUpdatesAsText)();
239
+ mocks.getPackageJson.mockReturnValue(packageJson);
240
+ mocks.getLatestPackageJson.mockReturnValue(packageJson);
241
+ const result = getPackageJsonUpdatesAsText();
234
242
  expect(result).toBe('');
235
243
  });
236
- test("It should return the related text when there's an update", function () {
237
- var packageJson = {
244
+ test("It should return the related text when there's an update", () => {
245
+ const packageJson = {
238
246
  dependencies: {
239
247
  '@grafana/ui': '10.0.0',
240
248
  react: '18.2.0',
@@ -245,7 +253,7 @@ describe('Utils / NPM', function () {
245
253
  },
246
254
  scripts: {},
247
255
  };
248
- var latestPackageJson = {
256
+ const latestPackageJson = {
249
257
  dependencies: {
250
258
  '@grafana/ui': '10.0.0',
251
259
  react: '18.2.1',
@@ -256,14 +264,14 @@ describe('Utils / NPM', function () {
256
264
  },
257
265
  scripts: {},
258
266
  };
259
- getPackageJsonMock.mockReturnValue(packageJson);
260
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
261
- var result = (0, utils_npm_1.getPackageJsonUpdatesAsText)();
267
+ mocks.getPackageJson.mockReturnValue(packageJson);
268
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
269
+ const result = getPackageJsonUpdatesAsText();
262
270
  expect(result).toContain('sass');
263
271
  expect(result).toContain('react');
264
272
  });
265
- test('It should not return the related text when devOnly and only dependencies to update', function () {
266
- var packageJson = {
273
+ test('It should not return the related text when devOnly and only dependencies to update', () => {
274
+ const packageJson = {
267
275
  dependencies: {
268
276
  '@grafana/ui': '10.0.0',
269
277
  react: '18.2.0',
@@ -274,7 +282,7 @@ describe('Utils / NPM', function () {
274
282
  },
275
283
  scripts: {},
276
284
  };
277
- var latestPackageJson = {
285
+ const latestPackageJson = {
278
286
  dependencies: {
279
287
  '@grafana/ui': '10.0.0',
280
288
  react: '18.2.1',
@@ -285,13 +293,13 @@ describe('Utils / NPM', function () {
285
293
  },
286
294
  scripts: {},
287
295
  };
288
- getPackageJsonMock.mockReturnValue(packageJson);
289
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
290
- var result = (0, utils_npm_1.getPackageJsonUpdatesAsText)({ devOnly: true });
296
+ mocks.getPackageJson.mockReturnValue(packageJson);
297
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
298
+ const result = getPackageJsonUpdatesAsText({ devOnly: true });
291
299
  expect(result).toBe('');
292
300
  });
293
- test('It should return the related text when devOnly and only dev dependencies to update', function () {
294
- var packageJson = {
301
+ test('It should return the related text when devOnly and only dev dependencies to update', () => {
302
+ const packageJson = {
295
303
  dependencies: {
296
304
  '@grafana/ui': '10.0.0',
297
305
  react: '18.2.0',
@@ -302,7 +310,7 @@ describe('Utils / NPM', function () {
302
310
  },
303
311
  scripts: {},
304
312
  };
305
- var latestPackageJson = {
313
+ const latestPackageJson = {
306
314
  dependencies: {
307
315
  '@grafana/ui': '10.0.0',
308
316
  react: '18.2.0',
@@ -313,15 +321,15 @@ describe('Utils / NPM', function () {
313
321
  },
314
322
  scripts: {},
315
323
  };
316
- getPackageJsonMock.mockReturnValue(packageJson);
317
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
318
- var result = (0, utils_npm_1.getPackageJsonUpdatesAsText)({ devOnly: true });
324
+ mocks.getPackageJson.mockReturnValue(packageJson);
325
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
326
+ const result = getPackageJsonUpdatesAsText({ devOnly: true });
319
327
  expect(result).toContain('sass');
320
328
  });
321
329
  });
322
- describe('updatePackageJson()', function () {
323
- test('It should not change the package.json if nothing was updated', function () {
324
- var packageJson = {
330
+ describe('updatePackageJson()', () => {
331
+ test('It should not change the package.json if nothing was updated', () => {
332
+ const packageJson = {
325
333
  dependencies: {
326
334
  '@grafana/ui': '10.0.0',
327
335
  react: '18.2.0',
@@ -332,10 +340,10 @@ describe('Utils / NPM', function () {
332
340
  },
333
341
  scripts: {},
334
342
  };
335
- getPackageJsonMock.mockReturnValue(packageJson);
336
- getLatestPackageJsonMock.mockReturnValue(packageJson);
337
- (0, utils_npm_1.updatePackageJson)();
338
- expect(writePackageJsonMock).toHaveBeenCalledWith({
343
+ mocks.getPackageJson.mockReturnValue(packageJson);
344
+ mocks.getLatestPackageJson.mockReturnValue(packageJson);
345
+ updatePackageJson();
346
+ expect(mocks.writePackageJson).toHaveBeenCalledWith({
339
347
  dependencies: {
340
348
  '@grafana/ui': '10.0.0',
341
349
  react: '18.2.0',
@@ -347,8 +355,8 @@ describe('Utils / NPM', function () {
347
355
  scripts: {},
348
356
  });
349
357
  });
350
- test('It should change the package.json when something was updated', function () {
351
- var packageJson = {
358
+ test('It should change the package.json when something was updated', () => {
359
+ const packageJson = {
352
360
  dependencies: {
353
361
  '@grafana/ui': '10.0.0',
354
362
  react: '18.2.0',
@@ -359,7 +367,7 @@ describe('Utils / NPM', function () {
359
367
  },
360
368
  scripts: {},
361
369
  };
362
- var latestPackageJson = {
370
+ const latestPackageJson = {
363
371
  dependencies: {
364
372
  '@grafana/ui': '10.0.0',
365
373
  react: '18.2.1',
@@ -370,10 +378,10 @@ describe('Utils / NPM', function () {
370
378
  },
371
379
  scripts: {},
372
380
  };
373
- getPackageJsonMock.mockReturnValue(packageJson);
374
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
375
- (0, utils_npm_1.updatePackageJson)();
376
- expect(writePackageJsonMock).toHaveBeenCalledWith({
381
+ mocks.getPackageJson.mockReturnValue(packageJson);
382
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
383
+ updatePackageJson();
384
+ expect(mocks.writePackageJson).toHaveBeenCalledWith({
377
385
  dependencies: {
378
386
  '@grafana/ui': '10.0.0',
379
387
  react: '18.2.1',
@@ -385,8 +393,8 @@ describe('Utils / NPM', function () {
385
393
  scripts: {},
386
394
  });
387
395
  });
388
- test('It should not change the package.json when devOnly is true and only non dev dependencies changed', function () {
389
- var packageJson = {
396
+ test('It should not change the package.json when devOnly is true and only non dev dependencies changed', () => {
397
+ const packageJson = {
390
398
  dependencies: {
391
399
  '@grafana/ui': '10.0.0',
392
400
  react: '18.2.0',
@@ -397,7 +405,7 @@ describe('Utils / NPM', function () {
397
405
  },
398
406
  scripts: {},
399
407
  };
400
- var latestPackageJson = {
408
+ const latestPackageJson = {
401
409
  dependencies: {
402
410
  '@grafana/ui': '10.0.0',
403
411
  react: '18.2.1',
@@ -408,10 +416,10 @@ describe('Utils / NPM', function () {
408
416
  },
409
417
  scripts: {},
410
418
  };
411
- getPackageJsonMock.mockReturnValue(packageJson);
412
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
413
- (0, utils_npm_1.updatePackageJson)({ devOnly: true });
414
- expect(writePackageJsonMock).toHaveBeenCalledWith({
419
+ mocks.getPackageJson.mockReturnValue(packageJson);
420
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
421
+ updatePackageJson({ devOnly: true });
422
+ expect(mocks.writePackageJson).toHaveBeenCalledWith({
415
423
  dependencies: {
416
424
  '@grafana/ui': '10.0.0',
417
425
  react: '18.2.0',
@@ -423,8 +431,8 @@ describe('Utils / NPM', function () {
423
431
  scripts: {},
424
432
  });
425
433
  });
426
- test('It should change the package.json when devOnly is true but only update dev dependencies', function () {
427
- var packageJson = {
434
+ test('It should change the package.json when devOnly is true but only update dev dependencies', () => {
435
+ const packageJson = {
428
436
  dependencies: {
429
437
  '@grafana/ui': '10.0.0',
430
438
  react: '18.2.0',
@@ -435,7 +443,7 @@ describe('Utils / NPM', function () {
435
443
  },
436
444
  scripts: {},
437
445
  };
438
- var latestPackageJson = {
446
+ const latestPackageJson = {
439
447
  dependencies: {
440
448
  '@grafana/ui': '10.0.0',
441
449
  react: '18.2.1',
@@ -446,10 +454,10 @@ describe('Utils / NPM', function () {
446
454
  },
447
455
  scripts: {},
448
456
  };
449
- getPackageJsonMock.mockReturnValue(packageJson);
450
- getLatestPackageJsonMock.mockReturnValue(latestPackageJson);
451
- (0, utils_npm_1.updatePackageJson)({ devOnly: true });
452
- expect(writePackageJsonMock).toHaveBeenCalledWith({
457
+ mocks.getPackageJson.mockReturnValue(packageJson);
458
+ mocks.getLatestPackageJson.mockReturnValue(latestPackageJson);
459
+ updatePackageJson({ devOnly: true });
460
+ expect(mocks.writePackageJson).toHaveBeenCalledWith({
453
461
  dependencies: {
454
462
  '@grafana/ui': '10.0.0',
455
463
  react: '18.2.0',
@@ -1,19 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var constants_1 = require("../../constants");
4
- var utils_plugin_1 = require("../utils.plugin");
5
- describe('Utils / Plugins', function () {
6
- describe('getPluginJson()', function () {
7
- test('should return the parsed plugin JSON if the file exits', function () {
8
- var srcDir = "".concat(constants_1.FIXTURES_PATH, "/test-template/src");
9
- var pluginJson = (0, utils_plugin_1.getPluginJson)(srcDir);
1
+ import { FIXTURES_PATH, TEMPLATE_PATHS } from '../../constants.js';
2
+ import { getPluginJson } from '../utils.plugin.js';
3
+ describe('Utils / Plugins', () => {
4
+ describe('getPluginJson()', () => {
5
+ test('should return the parsed plugin JSON if the file exits', () => {
6
+ const srcDir = `${FIXTURES_PATH}/test-template/src`;
7
+ const pluginJson = getPluginJson(srcDir);
10
8
  expect(pluginJson).toBeDefined();
11
9
  expect(pluginJson.type).toBe('app');
12
10
  });
13
- test('should throw an error if the plugin.json is not found', function () {
14
- var srcDir = "".concat(constants_1.TEMPLATE_PATHS.app, "/src/unknown");
15
- expect(function () {
16
- (0, utils_plugin_1.getPluginJson)(srcDir);
11
+ test('should throw an error if the plugin.json is not found', () => {
12
+ const srcDir = `${TEMPLATE_PATHS.app}/src/unknown`;
13
+ expect(() => {
14
+ getPluginJson(srcDir);
17
15
  }).toThrow();
18
16
  });
19
17
  });
@@ -1,30 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var constants_1 = require("../../constants");
4
- var utils_templates_1 = require("../utils.templates");
5
- describe('Utils / Templates', function () {
6
- describe('getTemplateFiles()', function () {
7
- test('should return with a list of files', function () {
8
- expect((0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app).length).toBeGreaterThan(0);
1
+ import { PLUGIN_TYPES } from '../../constants.js';
2
+ import { getTemplateFiles } from '../utils.templates.js';
3
+ describe('Utils / Templates', () => {
4
+ describe('getTemplateFiles()', () => {
5
+ test('should return with a list of files', () => {
6
+ expect(getTemplateFiles(PLUGIN_TYPES.app).length).toBeGreaterThan(0);
9
7
  });
10
- test('should be possible to filter templates by a sub-folder', function () {
11
- var templateFiles = (0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app, '.config/types');
8
+ test('should be possible to filter templates by a sub-folder', () => {
9
+ const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, '.config/types');
12
10
  expect(templateFiles.length).toBeGreaterThan(0);
13
- expect(templateFiles.find(function (t) { return t.includes('custom.d.ts'); })).not.toBeUndefined();
14
- expect(templateFiles.find(function (t) { return t.includes('Dockerfile'); })).toBeUndefined();
11
+ expect(templateFiles.find((t) => t.includes('custom.d.ts'))).not.toBeUndefined();
12
+ expect(templateFiles.find((t) => t.includes('Dockerfile'))).toBeUndefined();
15
13
  });
16
- test('should return an empty array when filtering by a non-existing sub-folder', function () {
17
- var templateFiles = (0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app, '.config/types/foo/bar/unknown');
14
+ test('should return an empty array when filtering by a non-existing sub-folder', () => {
15
+ const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, '.config/types/foo/bar/unknown');
18
16
  expect(Array.isArray(templateFiles)).toBe(true);
19
17
  expect(templateFiles.length).toBe(0);
20
18
  });
21
- test('should be possible to filter for multiple different files', function () {
22
- var templateFiles = (0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app, ['.prettierrc.js', 'cypress.json', 'tsconfig.json']);
19
+ test('should be possible to filter for multiple different files', () => {
20
+ const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, ['.prettierrc.js', 'cypress.json', 'tsconfig.json']);
23
21
  expect(Array.isArray(templateFiles)).toBe(true);
24
22
  expect(templateFiles.length).toBe(3);
25
23
  });
26
- test('should be possible to filter for a single file', function () {
27
- var templateFiles = (0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app, '.config/types/custom.d.ts');
24
+ test('should be possible to filter for a single file', () => {
25
+ const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, '.config/types/custom.d.ts');
28
26
  expect(Array.isArray(templateFiles)).toBe(true);
29
27
  expect(templateFiles.length).toBe(1);
30
28
  });
@@ -1,43 +1,38 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getConfig = void 0;
18
- var fs_1 = __importDefault(require("fs"));
19
- var path_1 = __importDefault(require("path"));
20
- var utils_version_1 = require("./utils.version");
21
- function getConfig() {
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { getVersion } from './utils.version.js';
4
+ export function getConfig() {
22
5
  try {
23
- var rootPath = path_1.default.resolve(process.cwd(), '.config/.cprc.json');
24
- var rootConfig = readRCFileSync(rootPath);
25
- var userConfig = getUserConfig();
26
- return __assign(__assign(__assign({}, rootConfig), userConfig), { version: rootConfig.version, features: createFeatureFlags(__assign(__assign({}, rootConfig.features), userConfig.features)) });
6
+ const rootPath = path.resolve(process.cwd(), '.config/.cprc.json');
7
+ const rootConfig = readRCFileSync(rootPath);
8
+ const userConfig = getUserConfig();
9
+ return {
10
+ ...rootConfig,
11
+ ...userConfig,
12
+ version: rootConfig.version,
13
+ features: createFeatureFlags({
14
+ ...rootConfig.features,
15
+ ...userConfig.features,
16
+ }),
17
+ };
27
18
  }
28
19
  catch (error) {
29
20
  return {
30
- version: (0, utils_version_1.getVersion)(),
21
+ version: getVersion(),
31
22
  features: createFeatureFlags(),
32
23
  };
33
24
  }
34
25
  }
35
- exports.getConfig = getConfig;
36
26
  function getUserConfig() {
37
27
  try {
38
- var userPath = path_1.default.resolve(process.cwd(), '.cprc.json');
39
- var userConfig = readRCFileSync(userPath);
40
- return __assign(__assign({}, userConfig), { features: createFeatureFlags(__assign({}, userConfig.features)) });
28
+ const userPath = path.resolve(process.cwd(), '.cprc.json');
29
+ const userConfig = readRCFileSync(userPath);
30
+ return {
31
+ ...userConfig,
32
+ features: createFeatureFlags({
33
+ ...userConfig.features,
34
+ }),
35
+ };
41
36
  }
42
37
  catch (error) {
43
38
  return {
@@ -47,7 +42,7 @@ function getUserConfig() {
47
42
  }
48
43
  function readRCFileSync(path) {
49
44
  try {
50
- var data = fs_1.default.readFileSync(path);
45
+ const data = fs.readFileSync(path);
51
46
  return JSON.parse(data.toString());
52
47
  }
53
48
  catch (error) {
@@ -55,5 +50,8 @@ function readRCFileSync(path) {
55
50
  }
56
51
  }
57
52
  function createFeatureFlags(flags) {
58
- return __assign({ bundleGrafanaUI: false }, flags);
53
+ return {
54
+ bundleGrafanaUI: false,
55
+ ...flags,
56
+ };
59
57
  }