commitizen 4.3.2 → 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.
- package/.github/workflows/release.yml +7 -5
- package/.husky/pre-commit +1 -0
- package/CONTRIBUTING.md +53 -21
- package/README.md +3 -4
- package/babel.config.js +21 -10
- package/bin/git-cz.js +1 -1
- package/dist/cli/parsers/commitizen.js +7 -1
- package/dist/cli/parsers.js +2 -1
- package/dist/cli/strategies/git-cz.js +3 -3
- package/dist/cli/strategies/git.js +2 -2
- package/dist/commitizen/adapter.js +52 -1411
- package/dist/commitizen/cache.js +6 -237
- package/dist/commitizen/commit.js +14 -562
- package/dist/commitizen/configLoader.js +1 -84
- package/dist/commitizen/init.js +30 -976
- package/dist/commitizen/staging.js +3 -255
- package/dist/commitizen.js +2 -1
- package/dist/common/util.js +49 -444
- package/dist/configLoader/findup.js +7 -312
- package/dist/configLoader/getContent.js +17 -644
- package/dist/configLoader/getNormalizedConfig.js +9 -382
- package/dist/configLoader/loader.js +4 -371
- package/dist/git/add.js +3 -113
- package/dist/git/commit.js +19 -801
- package/dist/git/init.js +2 -74
- package/dist/git/log.js +2 -175
- package/dist/git/whatChanged.js +2 -175
- package/dist/index.js +1 -56
- package/dist/npm.js +1 -32
- package/jobs/build.yml +17 -16
- package/package.json +36 -44
- package/pnpm-workspace.yaml +7 -0
package/dist/common/util.js
CHANGED
|
@@ -3,440 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.findNearestNodeModules = findNearestNodeModules;
|
|
7
|
+
exports.findPackageRoot = findPackageRoot;
|
|
6
8
|
exports.getParsedJsonFromFile = getParsedJsonFromFile;
|
|
7
9
|
exports.getParsedPackageJsonFromPath = getParsedPackageJsonFromPath;
|
|
8
10
|
exports.isFunction = isFunction;
|
|
9
11
|
exports.isInTest = isInTest;
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
13
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
12
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
function cov_pg9gkzupg() {
|
|
14
|
-
var path = "/home/runner/work/cz-cli/cz-cli/src/common/util.js";
|
|
15
|
-
var hash = "443667b7bd63169d3e6fa6f728fc86237eaa590b";
|
|
16
|
-
var global = new Function("return this")();
|
|
17
|
-
var gcv = "__coverage__";
|
|
18
|
-
var coverageData = {
|
|
19
|
-
path: "/home/runner/work/cz-cli/cz-cli/src/common/util.js",
|
|
20
|
-
statementMap: {
|
|
21
|
-
"0": {
|
|
22
|
-
start: {
|
|
23
|
-
line: 15,
|
|
24
|
-
column: 2
|
|
25
|
-
},
|
|
26
|
-
end: {
|
|
27
|
-
line: 20,
|
|
28
|
-
column: 3
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"1": {
|
|
32
|
-
start: {
|
|
33
|
-
line: 16,
|
|
34
|
-
column: 30
|
|
35
|
-
},
|
|
36
|
-
end: {
|
|
37
|
-
line: 16,
|
|
38
|
-
column: 86
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"2": {
|
|
42
|
-
start: {
|
|
43
|
-
line: 17,
|
|
44
|
-
column: 4
|
|
45
|
-
},
|
|
46
|
-
end: {
|
|
47
|
-
line: 17,
|
|
48
|
-
column: 43
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"3": {
|
|
52
|
-
start: {
|
|
53
|
-
line: 19,
|
|
54
|
-
column: 4
|
|
55
|
-
},
|
|
56
|
-
end: {
|
|
57
|
-
line: 19,
|
|
58
|
-
column: 21
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"4": {
|
|
62
|
-
start: {
|
|
63
|
-
line: 27,
|
|
64
|
-
column: 2
|
|
65
|
-
},
|
|
66
|
-
end: {
|
|
67
|
-
line: 27,
|
|
68
|
-
column: 53
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"5": {
|
|
72
|
-
start: {
|
|
73
|
-
line: 34,
|
|
74
|
-
column: 2
|
|
75
|
-
},
|
|
76
|
-
end: {
|
|
77
|
-
line: 43,
|
|
78
|
-
column: 3
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
"6": {
|
|
82
|
-
start: {
|
|
83
|
-
line: 36,
|
|
84
|
-
column: 4
|
|
85
|
-
},
|
|
86
|
-
end: {
|
|
87
|
-
line: 36,
|
|
88
|
-
column: 17
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"7": {
|
|
92
|
-
start: {
|
|
93
|
-
line: 37,
|
|
94
|
-
column: 9
|
|
95
|
-
},
|
|
96
|
-
end: {
|
|
97
|
-
line: 43,
|
|
98
|
-
column: 3
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"8": {
|
|
102
|
-
start: {
|
|
103
|
-
line: 38,
|
|
104
|
-
column: 4
|
|
105
|
-
},
|
|
106
|
-
end: {
|
|
107
|
-
line: 38,
|
|
108
|
-
column: 17
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"9": {
|
|
112
|
-
start: {
|
|
113
|
-
line: 40,
|
|
114
|
-
column: 18
|
|
115
|
-
},
|
|
116
|
-
end: {
|
|
117
|
-
line: 40,
|
|
118
|
-
column: 20
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
"10": {
|
|
122
|
-
start: {
|
|
123
|
-
line: 41,
|
|
124
|
-
column: 23
|
|
125
|
-
},
|
|
126
|
-
end: {
|
|
127
|
-
line: 41,
|
|
128
|
-
column: 61
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
"11": {
|
|
132
|
-
start: {
|
|
133
|
-
line: 42,
|
|
134
|
-
column: 4
|
|
135
|
-
},
|
|
136
|
-
end: {
|
|
137
|
-
line: 42,
|
|
138
|
-
column: 114
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
"12": {
|
|
142
|
-
start: {
|
|
143
|
-
line: 47,
|
|
144
|
-
column: 2
|
|
145
|
-
},
|
|
146
|
-
end: {
|
|
147
|
-
line: 47,
|
|
148
|
-
column: 41
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
fnMap: {
|
|
153
|
-
"0": {
|
|
154
|
-
name: "getParsedJsonFromFile",
|
|
155
|
-
decl: {
|
|
156
|
-
start: {
|
|
157
|
-
line: 14,
|
|
158
|
-
column: 9
|
|
159
|
-
},
|
|
160
|
-
end: {
|
|
161
|
-
line: 14,
|
|
162
|
-
column: 30
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
loc: {
|
|
166
|
-
start: {
|
|
167
|
-
line: 14,
|
|
168
|
-
column: 71
|
|
169
|
-
},
|
|
170
|
-
end: {
|
|
171
|
-
line: 21,
|
|
172
|
-
column: 1
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
line: 14
|
|
176
|
-
},
|
|
177
|
-
"1": {
|
|
178
|
-
name: "getParsedPackageJsonFromPath",
|
|
179
|
-
decl: {
|
|
180
|
-
start: {
|
|
181
|
-
line: 26,
|
|
182
|
-
column: 9
|
|
183
|
-
},
|
|
184
|
-
end: {
|
|
185
|
-
line: 26,
|
|
186
|
-
column: 37
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
loc: {
|
|
190
|
-
start: {
|
|
191
|
-
line: 26,
|
|
192
|
-
column: 45
|
|
193
|
-
},
|
|
194
|
-
end: {
|
|
195
|
-
line: 28,
|
|
196
|
-
column: 1
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
line: 26
|
|
200
|
-
},
|
|
201
|
-
"2": {
|
|
202
|
-
name: "isFunction",
|
|
203
|
-
decl: {
|
|
204
|
-
start: {
|
|
205
|
-
line: 33,
|
|
206
|
-
column: 9
|
|
207
|
-
},
|
|
208
|
-
end: {
|
|
209
|
-
line: 33,
|
|
210
|
-
column: 19
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
loc: {
|
|
214
|
-
start: {
|
|
215
|
-
line: 33,
|
|
216
|
-
column: 38
|
|
217
|
-
},
|
|
218
|
-
end: {
|
|
219
|
-
line: 44,
|
|
220
|
-
column: 1
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
line: 33
|
|
224
|
-
},
|
|
225
|
-
"3": {
|
|
226
|
-
name: "isInTest",
|
|
227
|
-
decl: {
|
|
228
|
-
start: {
|
|
229
|
-
line: 46,
|
|
230
|
-
column: 9
|
|
231
|
-
},
|
|
232
|
-
end: {
|
|
233
|
-
line: 46,
|
|
234
|
-
column: 17
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
loc: {
|
|
238
|
-
start: {
|
|
239
|
-
line: 46,
|
|
240
|
-
column: 21
|
|
241
|
-
},
|
|
242
|
-
end: {
|
|
243
|
-
line: 48,
|
|
244
|
-
column: 1
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
line: 46
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
branchMap: {
|
|
251
|
-
"0": {
|
|
252
|
-
loc: {
|
|
253
|
-
start: {
|
|
254
|
-
line: 14,
|
|
255
|
-
column: 52
|
|
256
|
-
},
|
|
257
|
-
end: {
|
|
258
|
-
line: 14,
|
|
259
|
-
column: 69
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
type: "default-arg",
|
|
263
|
-
locations: [{
|
|
264
|
-
start: {
|
|
265
|
-
line: 14,
|
|
266
|
-
column: 63
|
|
267
|
-
},
|
|
268
|
-
end: {
|
|
269
|
-
line: 14,
|
|
270
|
-
column: 69
|
|
271
|
-
}
|
|
272
|
-
}],
|
|
273
|
-
line: 14
|
|
274
|
-
},
|
|
275
|
-
"1": {
|
|
276
|
-
loc: {
|
|
277
|
-
start: {
|
|
278
|
-
line: 34,
|
|
279
|
-
column: 2
|
|
280
|
-
},
|
|
281
|
-
end: {
|
|
282
|
-
line: 43,
|
|
283
|
-
column: 3
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
type: "if",
|
|
287
|
-
locations: [{
|
|
288
|
-
start: {
|
|
289
|
-
line: 34,
|
|
290
|
-
column: 2
|
|
291
|
-
},
|
|
292
|
-
end: {
|
|
293
|
-
line: 43,
|
|
294
|
-
column: 3
|
|
295
|
-
}
|
|
296
|
-
}, {
|
|
297
|
-
start: {
|
|
298
|
-
line: 37,
|
|
299
|
-
column: 9
|
|
300
|
-
},
|
|
301
|
-
end: {
|
|
302
|
-
line: 43,
|
|
303
|
-
column: 3
|
|
304
|
-
}
|
|
305
|
-
}],
|
|
306
|
-
line: 34
|
|
307
|
-
},
|
|
308
|
-
"2": {
|
|
309
|
-
loc: {
|
|
310
|
-
start: {
|
|
311
|
-
line: 37,
|
|
312
|
-
column: 9
|
|
313
|
-
},
|
|
314
|
-
end: {
|
|
315
|
-
line: 43,
|
|
316
|
-
column: 3
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
type: "if",
|
|
320
|
-
locations: [{
|
|
321
|
-
start: {
|
|
322
|
-
line: 37,
|
|
323
|
-
column: 9
|
|
324
|
-
},
|
|
325
|
-
end: {
|
|
326
|
-
line: 43,
|
|
327
|
-
column: 3
|
|
328
|
-
}
|
|
329
|
-
}, {
|
|
330
|
-
start: {
|
|
331
|
-
line: 39,
|
|
332
|
-
column: 9
|
|
333
|
-
},
|
|
334
|
-
end: {
|
|
335
|
-
line: 43,
|
|
336
|
-
column: 3
|
|
337
|
-
}
|
|
338
|
-
}],
|
|
339
|
-
line: 37
|
|
340
|
-
},
|
|
341
|
-
"3": {
|
|
342
|
-
loc: {
|
|
343
|
-
start: {
|
|
344
|
-
line: 42,
|
|
345
|
-
column: 11
|
|
346
|
-
},
|
|
347
|
-
end: {
|
|
348
|
-
line: 42,
|
|
349
|
-
column: 113
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
type: "binary-expr",
|
|
353
|
-
locations: [{
|
|
354
|
-
start: {
|
|
355
|
-
line: 42,
|
|
356
|
-
column: 11
|
|
357
|
-
},
|
|
358
|
-
end: {
|
|
359
|
-
line: 42,
|
|
360
|
-
column: 26
|
|
361
|
-
}
|
|
362
|
-
}, {
|
|
363
|
-
start: {
|
|
364
|
-
line: 42,
|
|
365
|
-
column: 31
|
|
366
|
-
},
|
|
367
|
-
end: {
|
|
368
|
-
line: 42,
|
|
369
|
-
column: 67
|
|
370
|
-
}
|
|
371
|
-
}, {
|
|
372
|
-
start: {
|
|
373
|
-
line: 42,
|
|
374
|
-
column: 71
|
|
375
|
-
},
|
|
376
|
-
end: {
|
|
377
|
-
line: 42,
|
|
378
|
-
column: 112
|
|
379
|
-
}
|
|
380
|
-
}],
|
|
381
|
-
line: 42
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
s: {
|
|
385
|
-
"0": 0,
|
|
386
|
-
"1": 0,
|
|
387
|
-
"2": 0,
|
|
388
|
-
"3": 0,
|
|
389
|
-
"4": 0,
|
|
390
|
-
"5": 0,
|
|
391
|
-
"6": 0,
|
|
392
|
-
"7": 0,
|
|
393
|
-
"8": 0,
|
|
394
|
-
"9": 0,
|
|
395
|
-
"10": 0,
|
|
396
|
-
"11": 0,
|
|
397
|
-
"12": 0
|
|
398
|
-
},
|
|
399
|
-
f: {
|
|
400
|
-
"0": 0,
|
|
401
|
-
"1": 0,
|
|
402
|
-
"2": 0,
|
|
403
|
-
"3": 0
|
|
404
|
-
},
|
|
405
|
-
b: {
|
|
406
|
-
"0": [0],
|
|
407
|
-
"1": [0, 0],
|
|
408
|
-
"2": [0, 0],
|
|
409
|
-
"3": [0, 0, 0]
|
|
410
|
-
},
|
|
411
|
-
_coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
|
|
412
|
-
hash: "443667b7bd63169d3e6fa6f728fc86237eaa590b"
|
|
413
|
-
};
|
|
414
|
-
var coverage = global[gcv] || (global[gcv] = {});
|
|
415
|
-
if (!coverage[path] || coverage[path].hash !== hash) {
|
|
416
|
-
coverage[path] = coverageData;
|
|
417
|
-
}
|
|
418
|
-
var actualCoverage = coverage[path];
|
|
419
|
-
{
|
|
420
|
-
// @ts-ignore
|
|
421
|
-
cov_pg9gkzupg = function () {
|
|
422
|
-
return actualCoverage;
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
return actualCoverage;
|
|
426
|
-
}
|
|
427
|
-
cov_pg9gkzupg();
|
|
428
15
|
/**
|
|
429
16
|
* Gets the parsed contents of a json file
|
|
430
17
|
*/
|
|
431
|
-
function getParsedJsonFromFile(filePath, fileName, encoding =
|
|
432
|
-
cov_pg9gkzupg().f[0]++;
|
|
433
|
-
cov_pg9gkzupg().s[0]++;
|
|
18
|
+
function getParsedJsonFromFile(filePath, fileName, encoding = 'utf8') {
|
|
434
19
|
try {
|
|
435
|
-
var packageJsonContents =
|
|
436
|
-
cov_pg9gkzupg().s[2]++;
|
|
20
|
+
var packageJsonContents = _nodeFs.default.readFileSync(_nodePath.default.join(filePath, fileName), encoding);
|
|
437
21
|
return JSON.parse(packageJsonContents);
|
|
438
22
|
} catch (e) {
|
|
439
|
-
cov_pg9gkzupg().s[3]++;
|
|
440
23
|
console.error(e);
|
|
441
24
|
}
|
|
442
25
|
}
|
|
@@ -445,8 +28,6 @@ function getParsedJsonFromFile(filePath, fileName, encoding = (cov_pg9gkzupg().b
|
|
|
445
28
|
* A helper method for getting the contents of package.json at a given path
|
|
446
29
|
*/
|
|
447
30
|
function getParsedPackageJsonFromPath(path) {
|
|
448
|
-
cov_pg9gkzupg().f[1]++;
|
|
449
|
-
cov_pg9gkzupg().s[4]++;
|
|
450
31
|
return getParsedJsonFromFile(path, 'package.json');
|
|
451
32
|
}
|
|
452
33
|
|
|
@@ -454,30 +35,54 @@ function getParsedPackageJsonFromPath(path) {
|
|
|
454
35
|
* Test if the passed argument is a function
|
|
455
36
|
*/
|
|
456
37
|
function isFunction(functionToCheck) {
|
|
457
|
-
cov_pg9gkzupg().f[2]++;
|
|
458
|
-
cov_pg9gkzupg().s[5]++;
|
|
459
38
|
if (typeof functionToCheck === "undefined") {
|
|
460
|
-
|
|
461
|
-
|
|
39
|
+
return false;
|
|
40
|
+
} else if (functionToCheck === null) {
|
|
462
41
|
return false;
|
|
463
42
|
} else {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
cov_pg9gkzupg().b[2][0]++;
|
|
468
|
-
cov_pg9gkzupg().s[8]++;
|
|
469
|
-
return false;
|
|
470
|
-
} else {
|
|
471
|
-
cov_pg9gkzupg().b[2][1]++;
|
|
472
|
-
var getType = (cov_pg9gkzupg().s[9]++, {});
|
|
473
|
-
var functionType = (cov_pg9gkzupg().s[10]++, getType.toString.call(functionToCheck));
|
|
474
|
-
cov_pg9gkzupg().s[11]++;
|
|
475
|
-
return (cov_pg9gkzupg().b[3][0]++, functionToCheck) && ((cov_pg9gkzupg().b[3][1]++, functionType === '[object Function]') || (cov_pg9gkzupg().b[3][2]++, functionType === '[object AsyncFunction]'));
|
|
476
|
-
}
|
|
43
|
+
var getType = {};
|
|
44
|
+
var functionType = getType.toString.call(functionToCheck);
|
|
45
|
+
return functionToCheck && (functionType === '[object Function]' || functionType === '[object AsyncFunction]');
|
|
477
46
|
}
|
|
478
47
|
}
|
|
479
48
|
function isInTest() {
|
|
480
|
-
cov_pg9gkzupg().f[3]++;
|
|
481
|
-
cov_pg9gkzupg().s[12]++;
|
|
482
49
|
return typeof global.it === 'function';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Walks up from `start` (inclusive) to the nearest directory containing a
|
|
54
|
+
* package.json and returns it. Throws if there is none.
|
|
55
|
+
*/
|
|
56
|
+
function findPackageRoot(start) {
|
|
57
|
+
let dir = _nodePath.default.resolve(start);
|
|
58
|
+
for (;;) {
|
|
59
|
+
if (_nodeFs.default.existsSync(_nodePath.default.join(dir, 'package.json'))) {
|
|
60
|
+
return dir;
|
|
61
|
+
}
|
|
62
|
+
const parent = _nodePath.default.dirname(dir);
|
|
63
|
+
if (parent === dir) {
|
|
64
|
+
throw new Error('package.json not found in path');
|
|
65
|
+
}
|
|
66
|
+
dir = parent;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Finds the nearest node_modules directory at or above `cwd` and returns it
|
|
72
|
+
* relative to `cwd` (e.g. 'node_modules' or '../node_modules'), or undefined
|
|
73
|
+
* if there is none.
|
|
74
|
+
*/
|
|
75
|
+
function findNearestNodeModules(cwd = process.cwd()) {
|
|
76
|
+
let dir = _nodePath.default.resolve(cwd);
|
|
77
|
+
for (;;) {
|
|
78
|
+
const candidate = _nodePath.default.join(dir, 'node_modules');
|
|
79
|
+
if (_nodeFs.default.existsSync(candidate)) {
|
|
80
|
+
return _nodePath.default.relative(cwd, candidate);
|
|
81
|
+
}
|
|
82
|
+
const parent = _nodePath.default.dirname(dir);
|
|
83
|
+
if (parent === dir) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
dir = parent;
|
|
87
|
+
}
|
|
483
88
|
}
|