fork-version 1.4.14 → 1.4.50

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.
@@ -1,733 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('path');
4
- var JoyCon = require('joycon');
5
- var bundleRequire = require('bundle-require');
6
- var zod = require('zod');
7
- var conventionalChangelogConfigSpec = require('conventional-changelog-config-spec');
8
- var meow = require('meow');
9
- var fs = require('fs');
10
- var gitSemverTags = require('git-semver-tags');
11
- var semver = require('semver');
12
- var conventionalRecommendedBump = require('conventional-recommended-bump');
13
- var detectIndent = require('detect-indent');
14
- var detectNewLine = require('detect-newline');
15
- var conventionalChangelog = require('conventional-changelog');
16
- var child_process = require('child_process');
17
-
18
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
19
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
-
21
- var path__default = /*#__PURE__*/_interopDefault(path);
22
- var JoyCon__default = /*#__PURE__*/_interopDefault(JoyCon);
23
- var conventionalChangelogConfigSpec__default = /*#__PURE__*/_interopDefault(conventionalChangelogConfigSpec);
24
- var meow__default = /*#__PURE__*/_interopDefault(meow);
25
- var gitSemverTags__default = /*#__PURE__*/_interopDefault(gitSemverTags);
26
- var semver__default = /*#__PURE__*/_interopDefault(semver);
27
- var conventionalRecommendedBump__default = /*#__PURE__*/_interopDefault(conventionalRecommendedBump);
28
- var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
29
- var detectNewLine__default = /*#__PURE__*/_interopDefault(detectNewLine);
30
- var conventionalChangelog__default = /*#__PURE__*/_interopDefault(conventionalChangelog);
31
-
32
- // src/configuration.ts
33
- var ForkConfigSchema = zod.z.object({
34
- /**
35
- * The path where the changes should be calculated from.
36
- * @default
37
- * ```js
38
- * process.cwd()
39
- * ```
40
- */
41
- changePath: zod.z.string(),
42
- /**
43
- * The name of the changelog file.
44
- * @default "CHANGELOG.md"
45
- */
46
- changelog: zod.z.string(),
47
- /**
48
- * Files to be updated.
49
- * @default
50
- * ```js
51
- * ["bower.json", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]
52
- * ```
53
- */
54
- outFiles: zod.z.array(zod.z.string()),
55
- /**
56
- * The header to be used in the changelog.
57
- * @default
58
- * ```markdown
59
- * # Changelog
60
- *
61
- * All notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.
62
- * ```
63
- */
64
- header: zod.z.string(),
65
- /**
66
- * Specify a prefix for the git tag that will be taken into account during the comparison.
67
- *
68
- * For instance if your version tag is prefixed by `version/` instead of `v` you would
69
- * have to specify `tagPrefix: "version/"`.
70
- * @default `v`
71
- */
72
- tagPrefix: zod.z.string(),
73
- /**
74
- * Make a pre-release with optional label to specify a tag id.
75
- * @example true, "alpha", "beta", "rc", etc.
76
- * @default undefined
77
- */
78
- preReleaseTag: zod.z.string().or(zod.z.boolean()).optional(),
79
- /**
80
- * Commit all staged changes, not just files updated by fork-version.
81
- * @default false
82
- */
83
- commitAll: zod.z.boolean(),
84
- /**
85
- * If true, no output will be written to disk or committed.
86
- * @default false
87
- */
88
- dryRun: zod.z.boolean(),
89
- /**
90
- * If true and we cant find a version in an `outFiles`, we'll fallback and attempt
91
- * to use the latest git tag for the current version.
92
- * @default true
93
- */
94
- gitTagFallback: zod.z.boolean(),
95
- /**
96
- * Should we sign the git commit using GPG?
97
- * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}
98
- * @default false
99
- */
100
- sign: zod.z.boolean(),
101
- /**
102
- * If true, no output will be written to stdout.
103
- * @default false
104
- */
105
- silent: zod.z.boolean(),
106
- /**
107
- * If true, allow git to run git commit hooks.
108
- * @default false
109
- */
110
- verify: zod.z.boolean(),
111
- /**
112
- * If set, we'll use this version number instead of trying to find it in an `outFiles`.
113
- * @example "1.0.0"
114
- * @default undefined
115
- */
116
- currentVersion: zod.z.string().optional(),
117
- /**
118
- * If set, we'll attempt to update the version number to this version.
119
- * @example "2.0.0"
120
- * @default undefined
121
- */
122
- nextVersion: zod.z.string().optional(),
123
- /**
124
- * Override the default conventional-changelog preset configuration.
125
- */
126
- changelogPresetConfig: zod.z.object({
127
- /**
128
- * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.
129
- */
130
- types: zod.z.array(
131
- zod.z.object({
132
- type: zod.z.string(),
133
- section: zod.z.string().optional(),
134
- hidden: zod.z.boolean().optional()
135
- })
136
- ).optional(),
137
- /**
138
- * A URL representing a specific commit at a hash.
139
- */
140
- commitUrlFormat: zod.z.string().optional(),
141
- /**
142
- * A URL representing the comparison between two git SHAs.
143
- */
144
- compareUrlFormat: zod.z.string().optional(),
145
- /**
146
- * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).
147
- */
148
- issueUrlFormat: zod.z.string().optional(),
149
- /**
150
- * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used for substituting @bcoe with https://github.com/bcoe in commit messages.
151
- */
152
- userUrlFormat: zod.z.string().optional(),
153
- /**
154
- * A string to be used to format the auto-generated release commit message.
155
- */
156
- releaseCommitMessageFormat: zod.z.string().optional(),
157
- /**
158
- * An array of prefixes used to detect references to issues
159
- */
160
- issuePrefixes: zod.z.array(zod.z.string()).optional()
161
- }),
162
- /**
163
- * Log function, can be used to override the default `console.log` function
164
- * to log to a file or another service.
165
- * @default console.log
166
- */
167
- log: zod.z.function().args(zod.z.string()).returns(zod.z.void()),
168
- /**
169
- * Error logger function, can be used to override the default `console.error`
170
- * function to log to a file or another service.
171
- * @default console.error
172
- */
173
- error: zod.z.function().args(zod.z.string()).returns(zod.z.void()),
174
- /**
175
- * Debug logger function, by default this is a noop function, but can be replaced
176
- * with a custom logger function or `console.info` to print output.
177
- * @default () => {}
178
- */
179
- debug: zod.z.function().args(zod.z.string()).returns(zod.z.void())
180
- });
181
- var DEFAULT_CONFIG = {
182
- changePath: process.cwd(),
183
- changelog: "CHANGELOG.md",
184
- outFiles: [
185
- "bower.json",
186
- "manifest.json",
187
- // Chrome extensions
188
- "npm-shrinkwrap.json",
189
- "package-lock.json",
190
- "package.json"
191
- ],
192
- header: "# Changelog\n\nAll notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.\n",
193
- tagPrefix: "v",
194
- commitAll: false,
195
- dryRun: false,
196
- gitTagFallback: true,
197
- sign: false,
198
- silent: false,
199
- verify: false,
200
- changelogPresetConfig: {},
201
- log: console.log,
202
- // eslint-disable-line no-console
203
- error: console.error,
204
- // eslint-disable-line no-console
205
- debug: () => {
206
- }
207
- };
208
- function defineConfig(config) {
209
- return config;
210
- }
211
- function getPresetDefaults(usersChangelogPresetConfig) {
212
- const preset = {
213
- name: "conventionalcommits"
214
- };
215
- if (typeof conventionalChangelogConfigSpec__default.default.properties === "object") {
216
- Object.entries(conventionalChangelogConfigSpec__default.default.properties).forEach(([key, value]) => {
217
- const _value = value;
218
- if ("default" in _value && _value.default !== void 0) {
219
- preset[key] = _value.default;
220
- }
221
- });
222
- }
223
- if (usersChangelogPresetConfig && typeof usersChangelogPresetConfig === "object") {
224
- Object.entries(usersChangelogPresetConfig).forEach(([key, value]) => {
225
- if (value !== void 0) {
226
- preset[key] = value;
227
- }
228
- });
229
- }
230
- return preset;
231
- }
232
- function getCliArguments() {
233
- return meow__default.default(
234
- `
235
- Usage:
236
- $ fork-version
237
-
238
- Options:
239
- --changelog
240
- Name of the changelog file. [Default: "CHANGELOG.md"]
241
- --outFiles
242
- Files to be updated. [Default: ["bower.json", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]]
243
- --header, -H
244
- The header to be used in the changelog.
245
-
246
- --tagPrefix
247
- Specify a prefix for the git tag that will be taken into account during the comparison. [Default: "v"]
248
- --preReleaseTag
249
- Make a pre-release with optional label to specify a tag id. [Default: undefined]
250
-
251
- --commitAll
252
- Commit all staged changes, not just files updated by fork-version.
253
- --dryRun
254
- If true, no output will be written to disk or committed.
255
- --gitTagFallback
256
- If true and we cant find a version in an outFiles, we'll fallback and attempt to use the latest git tag for the current version. [Default: true]
257
- --sign
258
- Should we sign the git commit using GPG?
259
- --silent
260
- If true, no output will be written to stdout.
261
- --verify
262
- If true, allow git to run git commit hooks.
263
-
264
- --currentVersion
265
- If set, we'll use this current version number instead of trying to find it in an outFiles.
266
- --nextVersion
267
- If set, we'll attempt to update to this version.
268
- `,
269
- {
270
- importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)) }),
271
- flags: {
272
- changelog: {
273
- type: "string"
274
- },
275
- outFiles: {
276
- type: "string",
277
- isMultiple: true
278
- },
279
- header: {
280
- type: "string",
281
- shortFlag: "H"
282
- },
283
- tagPrefix: {
284
- type: "string"
285
- },
286
- preReleaseTag: {
287
- type: "string"
288
- },
289
- commitAll: {
290
- type: "boolean"
291
- },
292
- dryRun: {
293
- type: "boolean"
294
- },
295
- gitTagFallback: {
296
- type: "boolean"
297
- },
298
- sign: {
299
- type: "boolean"
300
- },
301
- silent: {
302
- type: "boolean"
303
- },
304
- verify: {
305
- type: "boolean"
306
- },
307
- currentVersion: {
308
- type: "string"
309
- },
310
- nextVersion: {
311
- type: "string"
312
- }
313
- }
314
- }
315
- );
316
- }
317
- async function getForkConfig() {
318
- const cwd = process.cwd();
319
- const joycon = new JoyCon__default.default.default();
320
- const configPath = await joycon.resolve({
321
- files: ["fork.config.js"],
322
- cwd,
323
- stopDir: path__default.default.parse(cwd).root
324
- });
325
- const cliArguments = getCliArguments();
326
- if (configPath) {
327
- const foundConfig = await bundleRequire.bundleRequire({ filepath: configPath });
328
- const parsedConfig = ForkConfigSchema.partial().safeParse(
329
- foundConfig.mod.default || foundConfig.mod
330
- );
331
- if (parsedConfig.success) {
332
- const usersConfig = Object.assign({}, DEFAULT_CONFIG, parsedConfig.data, cliArguments.flags);
333
- if ("debug" in parsedConfig && typeof parsedConfig.debug === "function") {
334
- usersConfig.debug = parsedConfig.debug;
335
- }
336
- if (usersConfig.silent) {
337
- usersConfig.log = () => {
338
- };
339
- usersConfig.error = () => {
340
- };
341
- usersConfig.debug = () => {
342
- };
343
- }
344
- const mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(
345
- parsedConfig.data?.outFiles || [],
346
- cliArguments.flags?.outFiles || []
347
- );
348
- return Object.assign(usersConfig, {
349
- changelogPresetConfig: getPresetDefaults(usersConfig?.changelogPresetConfig),
350
- outFiles: Array.from(new Set(mergedOutFiles))
351
- });
352
- } else {
353
- throw parsedConfig.error;
354
- }
355
- }
356
- return Object.assign(DEFAULT_CONFIG, cliArguments.flags, {
357
- changelogPresetConfig: getPresetDefaults()
358
- });
359
- }
360
-
361
- // src/libs/stringify-package.ts
362
- var DEFAULT_INDENT = 2;
363
- var CRLF = "\r\n";
364
- var LF = "\n";
365
- function stringifyPackage(data, indent, newline) {
366
- const stringified = JSON.stringify(data, null, indent || (indent === 0 ? 0 : DEFAULT_INDENT));
367
- if (newline === CRLF) {
368
- return stringified.replace(new RegExp(LF, "g"), CRLF);
369
- }
370
- return stringified;
371
- }
372
-
373
- // src/process/version.ts
374
- function getFile(options, fileToGet) {
375
- try {
376
- const fileExtension = path.extname(fileToGet);
377
- if (fileExtension === ".json") {
378
- const filePath = path.resolve(options.changePath, fileToGet);
379
- if (fs.existsSync(filePath)) {
380
- const fileContents = fs.readFileSync(filePath, "utf8");
381
- const parsedJson = JSON.parse(fileContents);
382
- if (parsedJson.version) {
383
- return {
384
- name: fileToGet,
385
- path: filePath,
386
- type: "package-file",
387
- version: parsedJson.version,
388
- isPrivate: "private" in parsedJson && (typeof parsedJson.private === "boolean" ? parsedJson.private : false)
389
- };
390
- } else {
391
- options.log(`Unable to find version in file: ${fileToGet}`);
392
- }
393
- }
394
- }
395
- } catch (error) {
396
- options.error(`Error reading file: ${fileToGet}`, error);
397
- }
398
- }
399
- async function getLatestGitTagVersion(tagPrefix) {
400
- const gitTags = await gitSemverTags__default.default({ tagPrefix });
401
- if (!gitTags.length) {
402
- return "1.0.0";
403
- }
404
- const cleanedTags = [];
405
- for (const tag of gitTags) {
406
- const cleanedTag = semver__default.default.clean(tag.replace(new RegExp(`^${tagPrefix}`), ""));
407
- if (cleanedTag) {
408
- cleanedTags.push(cleanedTag);
409
- }
410
- }
411
- return cleanedTags.sort(semver__default.default.rcompare)[0];
412
- }
413
- async function getCurrentVersion(options) {
414
- const files = [];
415
- const versions = [];
416
- for (const file of options.outFiles) {
417
- const fileState = getFile(options, file);
418
- if (fileState) {
419
- files.push(fileState);
420
- if (options.currentVersion) {
421
- continue;
422
- }
423
- if (!versions.includes(fileState.version)) {
424
- versions.push(fileState.version);
425
- }
426
- }
427
- }
428
- if (options.currentVersion) {
429
- versions.push(options.currentVersion);
430
- }
431
- if (versions.length === 0) {
432
- if (options.gitTagFallback) {
433
- const version = await getLatestGitTagVersion(options.tagPrefix);
434
- if (version) {
435
- return {
436
- files: [],
437
- currentVersion: version
438
- };
439
- }
440
- }
441
- throw new Error("Unable to find current version");
442
- } else if (versions.length > 1) {
443
- throw new Error("Found multiple versions");
444
- }
445
- return {
446
- files,
447
- currentVersion: versions[0]
448
- };
449
- }
450
- function getPriority(type) {
451
- return ["patch", "minor", "major"].indexOf(type || "");
452
- }
453
- function getVersionType(version) {
454
- const parseVersion = semver__default.default.parse(version);
455
- if (parseVersion?.major) {
456
- return "major";
457
- } else if (parseVersion?.minor) {
458
- return "minor";
459
- } else if (parseVersion?.patch) {
460
- return "patch";
461
- }
462
- return void 0;
463
- }
464
- function getReleaseType(releaseType, currentVersion, preReleaseTag) {
465
- if (!preReleaseTag) {
466
- return releaseType;
467
- }
468
- if (Array.isArray(semver__default.default.prerelease(currentVersion))) {
469
- const currentReleaseType = getVersionType(currentVersion);
470
- if (currentReleaseType === releaseType || getPriority(currentReleaseType) > getPriority(releaseType)) {
471
- return "prerelease";
472
- }
473
- }
474
- return `pre${releaseType}`;
475
- }
476
- async function getNextVersion(options, currentVersion) {
477
- if (options.nextVersion && semver__default.default.valid(options.nextVersion)) {
478
- return { nextVersion: options.nextVersion };
479
- }
480
- const preMajor = semver__default.default.lt(currentVersion, "1.0.0");
481
- const recommendedBump = await conventionalRecommendedBump__default.default({
482
- preset: {
483
- name: "conventionalcommits",
484
- ...options.changelogPresetConfig || {},
485
- preMajor
486
- },
487
- path: options.changePath,
488
- tagPrefix: options.tagPrefix,
489
- cwd: options.changePath
490
- });
491
- if (recommendedBump.releaseType) {
492
- const releaseType = getReleaseType(
493
- recommendedBump.releaseType,
494
- currentVersion,
495
- options.preReleaseTag
496
- );
497
- return Object.assign(recommendedBump, {
498
- preMajor,
499
- releaseType,
500
- nextVersion: semver__default.default.inc(
501
- currentVersion,
502
- releaseType,
503
- typeof options.preReleaseTag === "string" ? options.preReleaseTag : void 0
504
- ) || ""
505
- });
506
- }
507
- throw new Error("Unable to find next version");
508
- }
509
- function updateFile(options, fileToUpdate, type, nextVersion) {
510
- try {
511
- if (type === "package-file") {
512
- if (!fs.lstatSync(fileToUpdate).isFile())
513
- return;
514
- const fileContents = fs.readFileSync(fileToUpdate, "utf8");
515
- const indent = detectIndent__default.default(fileContents).indent;
516
- const newline = detectNewLine__default.default(fileContents);
517
- const parsedJson = JSON.parse(fileContents);
518
- parsedJson.version = nextVersion;
519
- if (parsedJson.packages && parsedJson.packages[""]) {
520
- parsedJson.packages[""].version = nextVersion;
521
- }
522
- if (!options.dryRun) {
523
- fs.writeFileSync(fileToUpdate, stringifyPackage(parsedJson, indent, newline), "utf8");
524
- }
525
- }
526
- } catch (error) {
527
- options.error("Error writing: ", error);
528
- }
529
- }
530
- async function bumpVersion(options) {
531
- const current = await getCurrentVersion(options);
532
- const next = await getNextVersion(options, current.currentVersion);
533
- options.log(`Current version: ${current.currentVersion}
534
- Next version: ${next.nextVersion} (${next.releaseType})
535
- Updating Files: `);
536
- for (const outFile of current.files) {
537
- options.log(` ${outFile.path}`);
538
- updateFile(options, outFile.path, outFile.type, next.nextVersion);
539
- }
540
- return {
541
- currentVersion: current.currentVersion,
542
- files: current.files,
543
- nextVersion: next.nextVersion,
544
- level: next.level,
545
- preMajor: next.preMajor,
546
- reason: next.reason,
547
- releaseType: next.releaseType
548
- };
549
- }
550
- function createChangelog(options) {
551
- const changelogPath = path.resolve(options.changelog);
552
- try {
553
- fs.accessSync(changelogPath, fs.constants.F_OK);
554
- } catch (err) {
555
- if (!options.dryRun && err.code === "ENOENT") {
556
- options.log(`Creating Changelog file: ${changelogPath}`);
557
- fs.writeFileSync(changelogPath, "\n", "utf8");
558
- }
559
- }
560
- return {
561
- path: changelogPath,
562
- exists: fs.existsSync(changelogPath)
563
- };
564
- }
565
- var RELEASE_PATTERN = /(^#+ \[?[0-9]+\.[0-9]+\.[0-9]+|<a name=)/m;
566
- function getOldReleaseContent(changelog) {
567
- if (changelog.exists) {
568
- const fileContents = fs.readFileSync(changelog.path, "utf-8");
569
- const oldContentStart = fileContents.search(RELEASE_PATTERN);
570
- if (oldContentStart !== -1) {
571
- return fileContents.substring(oldContentStart);
572
- }
573
- }
574
- return "";
575
- }
576
- function getNewReleaseContent(options, bumpResult) {
577
- return new Promise((resolve3) => {
578
- let newContent = "";
579
- conventionalChangelog__default.default(
580
- {
581
- preset: {
582
- name: "conventionalcommits",
583
- ...options.changelogPresetConfig || {}
584
- },
585
- tagPrefix: options.tagPrefix,
586
- warn: (...message) => options.error("conventional-changelog: ", ...message),
587
- cwd: options.changePath
588
- },
589
- {
590
- version: bumpResult.nextVersion
591
- },
592
- {
593
- merges: null,
594
- path: options.changePath
595
- }
596
- ).on("error", (error) => {
597
- options.error("conventional-changelog: Unable to parse changes");
598
- throw error;
599
- }).on("data", (chunk) => {
600
- newContent += chunk.toString();
601
- }).on("end", () => {
602
- resolve3(newContent);
603
- });
604
- });
605
- }
606
- async function updateChangelog(options, bumpResult) {
607
- if (options.header.search(RELEASE_PATTERN) !== -1) {
608
- throw new Error("Header cannot contain release pattern");
609
- }
610
- const changelog = createChangelog(options);
611
- const oldContent = getOldReleaseContent(changelog);
612
- const newContent = await getNewReleaseContent(options, bumpResult);
613
- options.log(`Updating Changelog:
614
- ${changelog.path}`);
615
- if (!options.dryRun && newContent) {
616
- fs.writeFileSync(changelog.path, `${options.header}
617
- ${newContent}
618
- ${oldContent}`, "utf8");
619
- }
620
- return {
621
- changelog,
622
- oldContent,
623
- newContent
624
- };
625
- }
626
- function createExecute(options) {
627
- async function executeGit(...execArgs) {
628
- const args = execArgs.filter(Boolean);
629
- options.debug(`Executing: git ${args.join(" ")}`);
630
- if (!options.dryRun) {
631
- return new Promise((resolve3) => {
632
- child_process.execFile("git", args, (error, stdout, stderr) => {
633
- if (error) {
634
- options.error(`git ${args[0]}:`);
635
- throw error;
636
- }
637
- resolve3(stdout ? stdout : stderr);
638
- });
639
- });
640
- }
641
- return "";
642
- }
643
- return {
644
- executeGit
645
- };
646
- }
647
-
648
- // src/utils/format-commit-message.ts
649
- function formatCommitMessage(message, newVersion) {
650
- if (!message) {
651
- message = "chore(release): {{currentTag}}";
652
- }
653
- return message.replace(new RegExp("{{currentTag}}", "g"), newVersion);
654
- }
655
-
656
- // src/process/commit.ts
657
- async function commitChanges(options, bumpResult) {
658
- const { executeGit } = createExecute(options);
659
- options.log("Committing changes");
660
- const filesToCommit = [options.changelog];
661
- for (const file of bumpResult.files) {
662
- filesToCommit.push(file.name);
663
- }
664
- if (filesToCommit.length === 0) {
665
- return {
666
- filesToCommit
667
- };
668
- }
669
- const gitAddOutput = await executeGit("add", ...filesToCommit);
670
- const shouldVerify = options.verify ? void 0 : "--no-verify";
671
- const shouldSign = options.sign ? "-S" : void 0;
672
- const shouldCommitAll = options.commitAll ? [] : filesToCommit;
673
- const gitCommitOutput = await executeGit(
674
- "commit",
675
- shouldVerify,
676
- shouldSign,
677
- ...shouldCommitAll,
678
- "-m",
679
- formatCommitMessage(
680
- options.changelogPresetConfig?.releaseCommitMessageFormat,
681
- bumpResult.nextVersion
682
- )
683
- );
684
- return {
685
- filesToCommit,
686
- gitAddOutput,
687
- gitCommitOutput
688
- };
689
- }
690
-
691
- // src/process/tag.ts
692
- async function tagChanges(options, bumpResult) {
693
- const { executeGit } = createExecute(options);
694
- const shouldSign = options.sign ? "-s" : "-a";
695
- const tag = `${options.tagPrefix}${bumpResult.nextVersion}`;
696
- options.log(`Creating Tag: ${tag}`);
697
- const gitTagOutput = await executeGit(
698
- "tag",
699
- shouldSign,
700
- tag,
701
- "-m",
702
- formatCommitMessage(
703
- options.changelogPresetConfig?.releaseCommitMessageFormat,
704
- bumpResult.nextVersion
705
- )
706
- );
707
- const currentBranchName = await executeGit("rev-parse", "--abbrev-ref", "HEAD");
708
- const hasPublicPackageFile = bumpResult.files.some(
709
- (file) => file.name === "package.json" && file.isPrivate === false
710
- );
711
- const isPreRelease = `${bumpResult.releaseType}`.startsWith("pre");
712
- const pushMessage = `Run \`git push --follow-tags origin ${currentBranchName.trim()}\` to push the changes and the tag.`;
713
- const publishMessage = isPreRelease ? `Run \`npm publish --tag ${typeof options.preReleaseTag === "string" ? options.preReleaseTag : "prerelease"}\` to publish the package.` : "Run `npm publish` to publish the package.";
714
- options.log(`
715
- ${pushMessage}
716
- ${hasPublicPackageFile ? publishMessage : ""}`);
717
- return {
718
- gitTagOutput,
719
- currentBranchName,
720
- hasPublicPackageFile,
721
- pushMessage,
722
- publishMessage
723
- };
724
- }
725
-
726
- exports.bumpVersion = bumpVersion;
727
- exports.commitChanges = commitChanges;
728
- exports.defineConfig = defineConfig;
729
- exports.getForkConfig = getForkConfig;
730
- exports.tagChanges = tagChanges;
731
- exports.updateChangelog = updateChangelog;
732
- //# sourceMappingURL=out.js.map
733
- //# sourceMappingURL=chunk-XUNVQAJE.cjs.map