commitizen 4.3.1 → 5.0.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.
@@ -4,609 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _path = _interopRequireDefault(require("path"));
7
+ var _nodeFs = _interopRequireDefault(require("node:fs"));
8
+ var _nodePath = _interopRequireDefault(require("node:path"));
9
9
  var _stripJsonComments = _interopRequireDefault(require("strip-json-comments"));
10
- var _isUtf = _interopRequireDefault(require("is-utf8"));
11
- var _stripBom = _interopRequireDefault(require("strip-bom"));
10
+ var _nodeBuffer = require("node:buffer");
12
11
  var _configLoader = require("../configLoader");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- function cov_1jep83s2x2() {
15
- var path = "/home/runner/work/cz-cli/cz-cli/src/configLoader/getContent.js";
16
- var hash = "403573c0a0b7b4db0113fca9d9beb1098d95eac2";
17
- var global = new Function("return this")();
18
- var gcv = "__coverage__";
19
- var coverageData = {
20
- path: "/home/runner/work/cz-cli/cz-cli/src/configLoader/getContent.js",
21
- statementMap: {
22
- "0": {
23
- start: {
24
- line: 20,
25
- column: 23
26
- },
27
- end: {
28
- line: 20,
29
- column: 45
30
- }
31
- },
32
- "1": {
33
- start: {
34
- line: 21,
35
- column: 21
36
- },
37
- end: {
38
- line: 21,
39
- column: 75
40
- }
41
- },
42
- "2": {
43
- start: {
44
- line: 22,
45
- column: 23
46
- },
47
- end: {
48
- line: 22,
49
- column: 56
50
- }
51
- },
52
- "3": {
53
- start: {
54
- line: 23,
55
- column: 18
56
- },
57
- end: {
58
- line: 25,
59
- column: 40
60
- }
61
- },
62
- "4": {
63
- start: {
64
- line: 24,
65
- column: 20
66
- },
67
- end: {
68
- line: 24,
69
- column: 59
70
- }
71
- },
72
- "5": {
73
- start: {
74
- line: 25,
75
- column: 20
76
- },
77
- end: {
78
- line: 25,
79
- column: 40
80
- }
81
- },
82
- "6": {
83
- start: {
84
- line: 27,
85
- column: 4
86
- },
87
- end: {
88
- line: 42,
89
- column: 5
90
- }
91
- },
92
- "7": {
93
- start: {
94
- line: 28,
95
- column: 23
96
- },
97
- end: {
98
- line: 28,
99
- column: 40
100
- }
101
- },
102
- "8": {
103
- start: {
104
- line: 30,
105
- column: 8
106
- },
107
- end: {
108
- line: 32,
109
- column: 11
110
- }
111
- },
112
- "9": {
113
- start: {
114
- line: 34,
115
- column: 8
116
- },
117
- end: {
118
- line: 34,
119
- column: 22
120
- }
121
- },
122
- "10": {
123
- start: {
124
- line: 36,
125
- column: 8
126
- },
127
- end: {
128
- line: 39,
129
- column: 21
130
- }
131
- },
132
- "11": {
133
- start: {
134
- line: 41,
135
- column: 8
136
- },
137
- end: {
138
- line: 41,
139
- column: 20
140
- }
141
- },
142
- "12": {
143
- start: {
144
- line: 52,
145
- column: 4
146
- },
147
- end: {
148
- line: 54,
149
- column: 5
150
- }
151
- },
152
- "13": {
153
- start: {
154
- line: 53,
155
- column: 6
156
- },
157
- end: {
158
- line: 53,
159
- column: 13
160
- }
161
- },
162
- "14": {
163
- start: {
164
- line: 56,
165
- column: 25
166
- },
167
- end: {
168
- line: 56,
169
- column: 64
170
- }
171
- },
172
- "15": {
173
- start: {
174
- line: 57,
175
- column: 27
176
- },
177
- end: {
178
- line: 57,
179
- column: 54
180
- }
181
- },
182
- "16": {
183
- start: {
184
- line: 59,
185
- column: 4
186
- },
187
- end: {
188
- line: 61,
189
- column: 5
190
- }
191
- },
192
- "17": {
193
- start: {
194
- line: 60,
195
- column: 6
196
- },
197
- end: {
198
- line: 60,
199
- column: 47
200
- }
201
- },
202
- "18": {
203
- start: {
204
- line: 63,
205
- column: 20
206
- },
207
- end: {
208
- line: 63,
209
- column: 51
210
- }
211
- },
212
- "19": {
213
- start: {
214
- line: 64,
215
- column: 4
216
- },
217
- end: {
218
- line: 64,
219
- column: 56
220
- }
221
- },
222
- "20": {
223
- start: {
224
- line: 75,
225
- column: 22
226
- },
227
- end: {
228
- line: 75,
229
- column: 49
230
- }
231
- },
232
- "21": {
233
- start: {
234
- line: 77,
235
- column: 2
236
- },
237
- end: {
238
- line: 79,
239
- column: 3
240
- }
241
- },
242
- "22": {
243
- start: {
244
- line: 78,
245
- column: 4
246
- },
247
- end: {
248
- line: 78,
249
- column: 96
250
- }
251
- },
252
- "23": {
253
- start: {
254
- line: 81,
255
- column: 2
256
- },
257
- end: {
258
- line: 81,
259
- column: 50
260
- }
261
- }
262
- },
263
- fnMap: {
264
- "0": {
265
- name: "readConfigContent",
266
- decl: {
267
- start: {
268
- line: 19,
269
- column: 9
270
- },
271
- end: {
272
- line: 19,
273
- column: 26
274
- }
275
- },
276
- loc: {
277
- start: {
278
- line: 19,
279
- column: 40
280
- },
281
- end: {
282
- line: 43,
283
- column: 1
284
- }
285
- },
286
- line: 19
287
- },
288
- "1": {
289
- name: "(anonymous_1)",
290
- decl: {
291
- start: {
292
- line: 24,
293
- column: 6
294
- },
295
- end: {
296
- line: 24,
297
- column: 7
298
- }
299
- },
300
- loc: {
301
- start: {
302
- line: 24,
303
- column: 20
304
- },
305
- end: {
306
- line: 24,
307
- column: 59
308
- }
309
- },
310
- line: 24
311
- },
312
- "2": {
313
- name: "(anonymous_2)",
314
- decl: {
315
- start: {
316
- line: 25,
317
- column: 6
318
- },
319
- end: {
320
- line: 25,
321
- column: 7
322
- }
323
- },
324
- loc: {
325
- start: {
326
- line: 25,
327
- column: 20
328
- },
329
- end: {
330
- line: 25,
331
- column: 40
332
- }
333
- },
334
- line: 25
335
- },
336
- "3": {
337
- name: "getConfigContent",
338
- decl: {
339
- start: {
340
- line: 51,
341
- column: 9
342
- },
343
- end: {
344
- line: 51,
345
- column: 25
346
- }
347
- },
348
- loc: {
349
- start: {
350
- line: 51,
351
- column: 54
352
- },
353
- end: {
354
- line: 65,
355
- column: 1
356
- }
357
- },
358
- line: 51
359
- },
360
- "4": {
361
- name: "readConfigFileContent",
362
- decl: {
363
- start: {
364
- line: 73,
365
- column: 9
366
- },
367
- end: {
368
- line: 73,
369
- column: 30
370
- }
371
- },
372
- loc: {
373
- start: {
374
- line: 73,
375
- column: 44
376
- },
377
- end: {
378
- line: 82,
379
- column: 1
380
- }
381
- },
382
- line: 73
383
- }
384
- },
385
- branchMap: {
386
- "0": {
387
- loc: {
388
- start: {
389
- line: 21,
390
- column: 21
391
- },
392
- end: {
393
- line: 21,
394
- column: 75
395
- }
396
- },
397
- type: "binary-expr",
398
- locations: [{
399
- start: {
400
- line: 21,
401
- column: 21
402
- },
403
- end: {
404
- line: 21,
405
- column: 45
406
- }
407
- }, {
408
- start: {
409
- line: 21,
410
- column: 49
411
- },
412
- end: {
413
- line: 21,
414
- column: 75
415
- }
416
- }],
417
- line: 21
418
- },
419
- "1": {
420
- loc: {
421
- start: {
422
- line: 23,
423
- column: 18
424
- },
425
- end: {
426
- line: 25,
427
- column: 40
428
- }
429
- },
430
- type: "cond-expr",
431
- locations: [{
432
- start: {
433
- line: 24,
434
- column: 6
435
- },
436
- end: {
437
- line: 24,
438
- column: 59
439
- }
440
- }, {
441
- start: {
442
- line: 25,
443
- column: 6
444
- },
445
- end: {
446
- line: 25,
447
- column: 40
448
- }
449
- }],
450
- line: 23
451
- },
452
- "2": {
453
- loc: {
454
- start: {
455
- line: 52,
456
- column: 4
457
- },
458
- end: {
459
- line: 54,
460
- column: 5
461
- }
462
- },
463
- type: "if",
464
- locations: [{
465
- start: {
466
- line: 52,
467
- column: 4
468
- },
469
- end: {
470
- line: 54,
471
- column: 5
472
- }
473
- }, {
474
- start: {
475
- line: undefined,
476
- column: undefined
477
- },
478
- end: {
479
- line: undefined,
480
- column: undefined
481
- }
482
- }],
483
- line: 52
484
- },
485
- "3": {
486
- loc: {
487
- start: {
488
- line: 59,
489
- column: 4
490
- },
491
- end: {
492
- line: 61,
493
- column: 5
494
- }
495
- },
496
- type: "if",
497
- locations: [{
498
- start: {
499
- line: 59,
500
- column: 4
501
- },
502
- end: {
503
- line: 61,
504
- column: 5
505
- }
506
- }, {
507
- start: {
508
- line: undefined,
509
- column: undefined
510
- },
511
- end: {
512
- line: undefined,
513
- column: undefined
514
- }
515
- }],
516
- line: 59
517
- },
518
- "4": {
519
- loc: {
520
- start: {
521
- line: 77,
522
- column: 2
523
- },
524
- end: {
525
- line: 79,
526
- column: 3
527
- }
528
- },
529
- type: "if",
530
- locations: [{
531
- start: {
532
- line: 77,
533
- column: 2
534
- },
535
- end: {
536
- line: 79,
537
- column: 3
538
- }
539
- }, {
540
- start: {
541
- line: undefined,
542
- column: undefined
543
- },
544
- end: {
545
- line: undefined,
546
- column: undefined
547
- }
548
- }],
549
- line: 77
550
- }
551
- },
552
- s: {
553
- "0": 0,
554
- "1": 0,
555
- "2": 0,
556
- "3": 0,
557
- "4": 0,
558
- "5": 0,
559
- "6": 0,
560
- "7": 0,
561
- "8": 0,
562
- "9": 0,
563
- "10": 0,
564
- "11": 0,
565
- "12": 0,
566
- "13": 0,
567
- "14": 0,
568
- "15": 0,
569
- "16": 0,
570
- "17": 0,
571
- "18": 0,
572
- "19": 0,
573
- "20": 0,
574
- "21": 0,
575
- "22": 0,
576
- "23": 0
577
- },
578
- f: {
579
- "0": 0,
580
- "1": 0,
581
- "2": 0,
582
- "3": 0,
583
- "4": 0
584
- },
585
- b: {
586
- "0": [0, 0],
587
- "1": [0, 0],
588
- "2": [0, 0],
589
- "3": [0, 0],
590
- "4": [0, 0]
591
- },
592
- _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
593
- hash: "403573c0a0b7b4db0113fca9d9beb1098d95eac2"
594
- };
595
- var coverage = global[gcv] || (global[gcv] = {});
596
- if (!coverage[path] || coverage[path].hash !== hash) {
597
- coverage[path] = coverageData;
598
- }
599
- var actualCoverage = coverage[path];
600
- {
601
- // @ts-ignore
602
- cov_1jep83s2x2 = function () {
603
- return actualCoverage;
604
- };
605
- }
606
- return actualCoverage;
607
- }
608
- cov_1jep83s2x2();
609
- var _default = getConfigContent;
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ var _default = exports.default = getConfigContent;
610
14
  /**
611
15
  * Read the content of a configuration file
612
16
  * - if not js or json: strip any comments
@@ -614,34 +18,19 @@ var _default = getConfigContent;
614
18
  * @param {String} configPath - full path to configuration file
615
19
  * @return {Object}
616
20
  */
617
- exports.default = _default;
618
21
  function readConfigContent(configPath) {
619
- cov_1jep83s2x2().f[0]++;
620
- const parsedPath = (cov_1jep83s2x2().s[0]++, _path.default.parse(configPath));
621
- const isRcFile = (cov_1jep83s2x2().s[1]++, (cov_1jep83s2x2().b[0][0]++, parsedPath.ext !== '.js') && (cov_1jep83s2x2().b[0][1]++, parsedPath.ext !== '.json'));
622
- const jsonString = (cov_1jep83s2x2().s[2]++, readConfigFileContent(configPath));
623
- const parse = (cov_1jep83s2x2().s[3]++, isRcFile ? (cov_1jep83s2x2().b[1][0]++, contents => {
624
- cov_1jep83s2x2().f[1]++;
625
- cov_1jep83s2x2().s[4]++;
626
- return JSON.parse((0, _stripJsonComments.default)(contents));
627
- }) : (cov_1jep83s2x2().b[1][1]++, contents => {
628
- cov_1jep83s2x2().f[2]++;
629
- cov_1jep83s2x2().s[5]++;
630
- return JSON.parse(contents);
631
- }));
632
- cov_1jep83s2x2().s[6]++;
22
+ const parsedPath = _nodePath.default.parse(configPath);
23
+ const isRcFile = parsedPath.ext !== '.js' && parsedPath.ext !== '.json';
24
+ const jsonString = readConfigFileContent(configPath);
25
+ const parse = isRcFile ? contents => JSON.parse((0, _stripJsonComments.default)(contents)) : contents => JSON.parse(contents);
633
26
  try {
634
- const parsed = (cov_1jep83s2x2().s[7]++, parse(jsonString));
635
- cov_1jep83s2x2().s[8]++;
27
+ const parsed = parse(jsonString);
636
28
  Object.defineProperty(parsed, 'configPath', {
637
29
  value: configPath
638
30
  });
639
- cov_1jep83s2x2().s[9]++;
640
31
  return parsed;
641
32
  } catch (error) {
642
- cov_1jep83s2x2().s[10]++;
643
33
  error.message = [`Parsing JSON at ${configPath} for commitizen config failed:`, error.mesasge].join('\n');
644
- cov_1jep83s2x2().s[11]++;
645
34
  throw error;
646
35
  }
647
36
  }
@@ -653,27 +42,15 @@ function readConfigContent(configPath) {
653
42
  * @return {Object}
654
43
  */
655
44
  function getConfigContent(configPath, baseDirectory) {
656
- cov_1jep83s2x2().f[3]++;
657
- cov_1jep83s2x2().s[12]++;
658
45
  if (!configPath) {
659
- cov_1jep83s2x2().b[2][0]++;
660
- cov_1jep83s2x2().s[13]++;
661
46
  return;
662
- } else {
663
- cov_1jep83s2x2().b[2][1]++;
664
47
  }
665
- const resolvedPath = (cov_1jep83s2x2().s[14]++, _path.default.resolve(baseDirectory, configPath));
666
- const configBasename = (cov_1jep83s2x2().s[15]++, _path.default.basename(resolvedPath));
667
- cov_1jep83s2x2().s[16]++;
668
- if (!_fs.default.existsSync(resolvedPath)) {
669
- cov_1jep83s2x2().b[3][0]++;
670
- cov_1jep83s2x2().s[17]++;
48
+ const resolvedPath = _nodePath.default.resolve(baseDirectory, configPath);
49
+ const configBasename = _nodePath.default.basename(resolvedPath);
50
+ if (!_nodeFs.default.existsSync(resolvedPath)) {
671
51
  return (0, _configLoader.getNormalizedConfig)(resolvedPath);
672
- } else {
673
- cov_1jep83s2x2().b[3][1]++;
674
52
  }
675
- const content = (cov_1jep83s2x2().s[18]++, readConfigContent(resolvedPath));
676
- cov_1jep83s2x2().s[19]++;
53
+ const content = readConfigContent(resolvedPath);
677
54
  return (0, _configLoader.getNormalizedConfig)(configBasename, content);
678
55
  }
679
56
  ;
@@ -685,16 +62,11 @@ function getConfigContent(configPath, baseDirectory) {
685
62
  * @return {String}
686
63
  */
687
64
  function readConfigFileContent(configPath) {
688
- cov_1jep83s2x2().f[4]++;
689
- let rawBufContent = (cov_1jep83s2x2().s[20]++, _fs.default.readFileSync(configPath));
690
- cov_1jep83s2x2().s[21]++;
691
- if (!(0, _isUtf.default)(rawBufContent)) {
692
- cov_1jep83s2x2().b[4][0]++;
693
- cov_1jep83s2x2().s[22]++;
65
+ let rawBufContent = _nodeFs.default.readFileSync(configPath);
66
+ if (!(0, _nodeBuffer.isUtf8)(rawBufContent)) {
694
67
  throw new Error(`The config file at "${configPath}" contains invalid charset, expect utf8`);
695
- } else {
696
- cov_1jep83s2x2().b[4][1]++;
697
68
  }
698
- cov_1jep83s2x2().s[23]++;
699
- return (0, _stripBom.default)(rawBufContent.toString("utf8"));
69
+ const content = rawBufContent.toString("utf8");
70
+ // Strip a UTF-8 byte order mark, if present.
71
+ return content.charCodeAt(0) === 0xFEFF ? content.slice(1) : content;
700
72
  }