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,548 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _path = _interopRequireDefault(require("path"));
7
+ var _nodePath = _interopRequireDefault(require("node:path"));
8
8
  var _cachedir = _interopRequireDefault(require("cachedir"));
9
- var _fsExtra = require("fs-extra");
9
+ var _nodeFs = require("node:fs");
10
10
  var _git = require("../git");
11
11
  var cache = _interopRequireWildcard(require("./cache"));
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- function cov_g0ukcvuof() {
16
- var path = "/home/runner/work/cz-cli/cz-cli/src/commitizen/commit.js";
17
- var hash = "4a518579188a2aabf17606ae1fd56644666d7e1b";
18
- var global = new Function("return this")();
19
- var gcv = "__coverage__";
20
- var coverageData = {
21
- path: "/home/runner/work/cz-cli/cz-cli/src/commitizen/commit.js",
22
- statementMap: {
23
- "0": {
24
- start: {
25
- line: 15,
26
- column: 4
27
- },
28
- end: {
29
- line: 17,
30
- column: 7
31
- }
32
- },
33
- "1": {
34
- start: {
35
- line: 16,
36
- column: 6
37
- },
38
- end: {
39
- line: 16,
40
- column: 28
41
- }
42
- },
43
- "2": {
44
- start: {
45
- line: 24,
46
- column: 23
47
- },
48
- end: {
49
- line: 24,
50
- column: 45
51
- }
52
- },
53
- "3": {
54
- start: {
55
- line: 25,
56
- column: 18
57
- },
58
- end: {
59
- line: 25,
60
- column: 62
61
- }
62
- },
63
- "4": {
64
- start: {
65
- line: 27,
66
- column: 2
67
- },
68
- end: {
69
- line: 66,
70
- column: 5
71
- }
72
- },
73
- "5": {
74
- start: {
75
- line: 28,
76
- column: 4
77
- },
78
- end: {
79
- line: 65,
80
- column: 5
81
- }
82
- },
83
- "6": {
84
- start: {
85
- line: 29,
86
- column: 6
87
- },
88
- end: {
89
- line: 29,
90
- column: 75
91
- }
92
- },
93
- "7": {
94
- start: {
95
- line: 32,
96
- column: 6
97
- },
98
- end: {
99
- line: 64,
100
- column: 7
101
- }
102
- },
103
- "8": {
104
- start: {
105
- line: 34,
106
- column: 8
107
- },
108
- end: {
109
- line: 34,
110
- column: 53
111
- }
112
- },
113
- "9": {
114
- start: {
115
- line: 42,
116
- column: 12
117
- },
118
- end: {
119
- line: 42,
120
- column: 56
121
- }
122
- },
123
- "10": {
124
- start: {
125
- line: 43,
126
- column: 8
127
- },
128
- end: {
129
- line: 43,
130
- column: 93
131
- }
132
- },
133
- "11": {
134
- start: {
135
- line: 47,
136
- column: 8
137
- },
138
- end: {
139
- line: 63,
140
- column: 11
141
- }
142
- },
143
- "12": {
144
- start: {
145
- line: 50,
146
- column: 10
147
- },
148
- end: {
149
- line: 54,
150
- column: 11
151
- }
152
- },
153
- "13": {
154
- start: {
155
- line: 51,
156
- column: 12
157
- },
158
- end: {
159
- line: 51,
160
- column: 39
161
- }
162
- },
163
- "14": {
164
- start: {
165
- line: 52,
166
- column: 12
167
- },
168
- end: {
169
- line: 52,
170
- column: 29
171
- }
172
- },
173
- "15": {
174
- start: {
175
- line: 53,
176
- column: 12
177
- },
178
- end: {
179
- line: 53,
180
- column: 25
181
- }
182
- },
183
- "16": {
184
- start: {
185
- line: 56,
186
- column: 10
187
- },
188
- end: {
189
- line: 58,
190
- column: 11
191
- }
192
- },
193
- "17": {
194
- start: {
195
- line: 57,
196
- column: 12
197
- },
198
- end: {
199
- line: 57,
200
- column: 31
201
- }
202
- },
203
- "18": {
204
- start: {
205
- line: 61,
206
- column: 10
207
- },
208
- end: {
209
- line: 61,
210
- column: 95
211
- }
212
- },
213
- "19": {
214
- start: {
215
- line: 62,
216
- column: 10
217
- },
218
- end: {
219
- line: 62,
220
- column: 80
221
- }
222
- }
223
- },
224
- fnMap: {
225
- "0": {
226
- name: "dispatchGitCommit",
227
- decl: {
228
- start: {
229
- line: 13,
230
- column: 9
231
- },
232
- end: {
233
- line: 13,
234
- column: 26
235
- }
236
- },
237
- loc: {
238
- start: {
239
- line: 13,
240
- column: 80
241
- },
242
- end: {
243
- line: 18,
244
- column: 1
245
- }
246
- },
247
- line: 13
248
- },
249
- "1": {
250
- name: "(anonymous_1)",
251
- decl: {
252
- start: {
253
- line: 15,
254
- column: 70
255
- },
256
- end: {
257
- line: 15,
258
- column: 71
259
- }
260
- },
261
- loc: {
262
- start: {
263
- line: 15,
264
- column: 87
265
- },
266
- end: {
267
- line: 17,
268
- column: 5
269
- }
270
- },
271
- line: 15
272
- },
273
- "2": {
274
- name: "commit",
275
- decl: {
276
- start: {
277
- line: 23,
278
- column: 9
279
- },
280
- end: {
281
- line: 23,
282
- column: 15
283
- }
284
- },
285
- loc: {
286
- start: {
287
- line: 23,
288
- column: 62
289
- },
290
- end: {
291
- line: 68,
292
- column: 1
293
- }
294
- },
295
- line: 23
296
- },
297
- "3": {
298
- name: "(anonymous_3)",
299
- decl: {
300
- start: {
301
- line: 27,
302
- column: 28
303
- },
304
- end: {
305
- line: 27,
306
- column: 29
307
- }
308
- },
309
- loc: {
310
- start: {
311
- line: 27,
312
- column: 45
313
- },
314
- end: {
315
- line: 66,
316
- column: 3
317
- }
318
- },
319
- line: 27
320
- },
321
- "4": {
322
- name: "(anonymous_4)",
323
- decl: {
324
- start: {
325
- line: 47,
326
- column: 27
327
- },
328
- end: {
329
- line: 47,
330
- column: 28
331
- }
332
- },
333
- loc: {
334
- start: {
335
- line: 47,
336
- column: 71
337
- },
338
- end: {
339
- line: 63,
340
- column: 9
341
- }
342
- },
343
- line: 47
344
- }
345
- },
346
- branchMap: {
347
- "0": {
348
- loc: {
349
- start: {
350
- line: 28,
351
- column: 4
352
- },
353
- end: {
354
- line: 65,
355
- column: 5
356
- }
357
- },
358
- type: "if",
359
- locations: [{
360
- start: {
361
- line: 28,
362
- column: 4
363
- },
364
- end: {
365
- line: 65,
366
- column: 5
367
- }
368
- }, {
369
- start: {
370
- line: 31,
371
- column: 11
372
- },
373
- end: {
374
- line: 65,
375
- column: 5
376
- }
377
- }],
378
- line: 28
379
- },
380
- "1": {
381
- loc: {
382
- start: {
383
- line: 32,
384
- column: 6
385
- },
386
- end: {
387
- line: 64,
388
- column: 7
389
- }
390
- },
391
- type: "if",
392
- locations: [{
393
- start: {
394
- line: 32,
395
- column: 6
396
- },
397
- end: {
398
- line: 64,
399
- column: 7
400
- }
401
- }, {
402
- start: {
403
- line: 45,
404
- column: 13
405
- },
406
- end: {
407
- line: 64,
408
- column: 7
409
- }
410
- }],
411
- line: 32
412
- },
413
- "2": {
414
- loc: {
415
- start: {
416
- line: 50,
417
- column: 10
418
- },
419
- end: {
420
- line: 54,
421
- column: 11
422
- }
423
- },
424
- type: "if",
425
- locations: [{
426
- start: {
427
- line: 50,
428
- column: 10
429
- },
430
- end: {
431
- line: 54,
432
- column: 11
433
- }
434
- }, {
435
- start: {
436
- line: undefined,
437
- column: undefined
438
- },
439
- end: {
440
- line: undefined,
441
- column: undefined
442
- }
443
- }],
444
- line: 50
445
- },
446
- "3": {
447
- loc: {
448
- start: {
449
- line: 56,
450
- column: 10
451
- },
452
- end: {
453
- line: 58,
454
- column: 11
455
- }
456
- },
457
- type: "if",
458
- locations: [{
459
- start: {
460
- line: 56,
461
- column: 10
462
- },
463
- end: {
464
- line: 58,
465
- column: 11
466
- }
467
- }, {
468
- start: {
469
- line: undefined,
470
- column: undefined
471
- },
472
- end: {
473
- line: undefined,
474
- column: undefined
475
- }
476
- }],
477
- line: 56
478
- }
479
- },
480
- s: {
481
- "0": 0,
482
- "1": 0,
483
- "2": 0,
484
- "3": 0,
485
- "4": 0,
486
- "5": 0,
487
- "6": 0,
488
- "7": 0,
489
- "8": 0,
490
- "9": 0,
491
- "10": 0,
492
- "11": 0,
493
- "12": 0,
494
- "13": 0,
495
- "14": 0,
496
- "15": 0,
497
- "16": 0,
498
- "17": 0,
499
- "18": 0,
500
- "19": 0
501
- },
502
- f: {
503
- "0": 0,
504
- "1": 0,
505
- "2": 0,
506
- "3": 0,
507
- "4": 0
508
- },
509
- b: {
510
- "0": [0, 0],
511
- "1": [0, 0],
512
- "2": [0, 0],
513
- "3": [0, 0]
514
- },
515
- _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
516
- hash: "4a518579188a2aabf17606ae1fd56644666d7e1b"
517
- };
518
- var coverage = global[gcv] || (global[gcv] = {});
519
- if (!coverage[path] || coverage[path].hash !== hash) {
520
- coverage[path] = coverageData;
521
- }
522
- var actualCoverage = coverage[path];
523
- {
524
- // @ts-ignore
525
- cov_g0ukcvuof = function () {
526
- return actualCoverage;
527
- };
528
- }
529
- return actualCoverage;
530
- }
531
- cov_g0ukcvuof();
532
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
533
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
534
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
535
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
536
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
537
- var _default = commit;
12
+ var e;
13
+ function _interopRequireWildcard(t, r) { if (!r && t && t.__esModule) return t; var n, a, o = Object.defineProperty, f = { __proto__: null, default: t }; if (Object(t) !== t) return f; if (e || "function" != typeof WeakMap || (e = new WeakMap()), e) { if (e.has(t)) return e.get(t); e.set(t, f); } for (a in t) "default" !== a && {}.hasOwnProperty.call(t, a) && ((n = o && Object.getOwnPropertyDescriptor(t, a)) && (n.get || n.set) ? o(f, a, n) : f[a] = t[a]); return f; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ var _default = exports.default = commit;
538
16
  /**
539
17
  * Takes all of the final inputs needed in order to make dispatch a git commit
540
18
  */
541
- exports.default = _default;
542
19
  function dispatchGitCommit(repoPath, template, options, overrideOptions, done) {
543
- cov_g0ukcvuof().f[0]++;
544
- cov_g0ukcvuof().s[0]++;
545
20
  // Commit the user input -- side effect that we'll test
546
- (0, _git.commit)(repoPath, template, _objectSpread(_objectSpread({}, options), overrideOptions), function (error) {
547
- cov_g0ukcvuof().f[1]++;
548
- cov_g0ukcvuof().s[1]++;
21
+ (0, _git.commit)(repoPath, template, {
22
+ ...options,
23
+ ...overrideOptions
24
+ }, function (error) {
549
25
  done(error, template);
550
26
  });
551
27
  }
@@ -554,24 +30,16 @@ function dispatchGitCommit(repoPath, template, options, overrideOptions, done) {
554
30
  * Asynchronously commits files using commitizen
555
31
  */
556
32
  function commit(inquirer, repoPath, prompter, options, done) {
557
- cov_g0ukcvuof().f[2]++;
558
- var cacheDirectory = (cov_g0ukcvuof().s[2]++, (0, _cachedir.default)('commitizen'));
559
- var cachePath = (cov_g0ukcvuof().s[3]++, _path.default.join(cacheDirectory, 'commitizen.json'));
560
- cov_g0ukcvuof().s[4]++;
561
- (0, _fsExtra.ensureDir)(cacheDirectory, function (error) {
562
- cov_g0ukcvuof().f[3]++;
563
- cov_g0ukcvuof().s[5]++;
33
+ var cacheDirectory = (0, _cachedir.default)('commitizen');
34
+ var cachePath = _nodePath.default.join(cacheDirectory, 'commitizen.json');
35
+ (0, _nodeFs.mkdir)(cacheDirectory, {
36
+ recursive: true
37
+ }, function (error) {
564
38
  if (error) {
565
- cov_g0ukcvuof().b[0][0]++;
566
- cov_g0ukcvuof().s[6]++;
567
39
  console.error("Couldn't create commitizen cache directory: ", error);
568
40
  // TODO: properly handle error?
569
41
  } else {
570
- cov_g0ukcvuof().b[0][1]++;
571
- cov_g0ukcvuof().s[7]++;
572
42
  if (options.retryLastCommit) {
573
- cov_g0ukcvuof().b[1][0]++;
574
- cov_g0ukcvuof().s[8]++;
575
43
  console.log('Retrying last commit attempt.');
576
44
 
577
45
  // We want to use the last commit instead of the current commit,
@@ -580,46 +48,28 @@ function commit(inquirer, repoPath, prompter, options, done) {
580
48
  options: retryOptions,
581
49
  overrideOptions: retryOverrideOptions,
582
50
  template: retryTemplate
583
- } = (cov_g0ukcvuof().s[9]++, cache.getCacheValueSync(cachePath, repoPath));
584
- cov_g0ukcvuof().s[10]++;
51
+ } = cache.getCacheValueSync(cachePath, repoPath);
585
52
  dispatchGitCommit(repoPath, retryTemplate, retryOptions, retryOverrideOptions, done);
586
53
  } else {
587
- cov_g0ukcvuof().b[1][1]++;
588
- cov_g0ukcvuof().s[11]++;
589
54
  // Get user input -- side effect that is hard to test
590
55
  prompter(inquirer, function (error, template, overrideOptions) {
591
- cov_g0ukcvuof().f[4]++;
592
- cov_g0ukcvuof().s[12]++;
593
56
  // Allow adapters to error out
594
57
  // (error: Error?, template: String, overrideOptions: Object)
595
58
  if (!(error instanceof Error)) {
596
- cov_g0ukcvuof().b[2][0]++;
597
- cov_g0ukcvuof().s[13]++;
598
59
  overrideOptions = template;
599
- cov_g0ukcvuof().s[14]++;
600
60
  template = error;
601
- cov_g0ukcvuof().s[15]++;
602
61
  error = null;
603
- } else {
604
- cov_g0ukcvuof().b[2][1]++;
605
62
  }
606
- cov_g0ukcvuof().s[16]++;
607
63
  if (error) {
608
- cov_g0ukcvuof().b[3][0]++;
609
- cov_g0ukcvuof().s[17]++;
610
64
  return done(error);
611
- } else {
612
- cov_g0ukcvuof().b[3][1]++;
613
65
  }
614
66
 
615
67
  // We don't want to add retries to the cache, only actual commands
616
- cov_g0ukcvuof().s[18]++;
617
68
  cache.setCacheValueSync(cachePath, repoPath, {
618
69
  template,
619
70
  options,
620
71
  overrideOptions
621
72
  });
622
- cov_g0ukcvuof().s[19]++;
623
73
  dispatchGitCommit(repoPath, template, options, overrideOptions, done);
624
74
  });
625
75
  }