fork-version 1.4.8 → 1.4.13
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/README.md +4 -0
- package/dist/{chunk-TNNLN6ZV.cjs → chunk-4VUFHLIF.cjs} +98 -4
- package/dist/chunk-4VUFHLIF.cjs.map +1 -0
- package/dist/{chunk-KCTVR2LJ.js → chunk-Z5YLEJGR.js} +96 -4
- package/dist/chunk-Z5YLEJGR.js.map +1 -0
- package/dist/cli.cjs +6 -6
- package/dist/cli.js +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +1 -1
- package/package.json +4 -3
- package/dist/chunk-KCTVR2LJ.js.map +0 -1
- package/dist/chunk-TNNLN6ZV.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Fork-Version
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/fork-version)
|
|
4
|
+
[](https://github.com/eglavin/fork-version/actions/workflows/version.yml)
|
|
5
|
+
[](https://github.com/eglavin/fork-version/actions/workflows/release.yml)
|
|
6
|
+
|
|
3
7
|
Fork-version is a re-write of [standard-version](https://github.com/conventional-changelog/standard-version) following on from its deprecation in May 15, 2022.
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
@@ -5,6 +5,7 @@ var JoyCon = require('joycon');
|
|
|
5
5
|
var bundleRequire = require('bundle-require');
|
|
6
6
|
var zod = require('zod');
|
|
7
7
|
var conventionalChangelogConfigSpec = require('conventional-changelog-config-spec');
|
|
8
|
+
var meow = require('meow');
|
|
8
9
|
var fs = require('fs');
|
|
9
10
|
var gitSemverTags = require('git-semver-tags');
|
|
10
11
|
var semver = require('semver');
|
|
@@ -14,11 +15,13 @@ var detectNewLine = require('detect-newline');
|
|
|
14
15
|
var conventionalChangelog = require('conventional-changelog');
|
|
15
16
|
var child_process = require('child_process');
|
|
16
17
|
|
|
18
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
17
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
20
|
|
|
19
21
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
20
22
|
var JoyCon__default = /*#__PURE__*/_interopDefault(JoyCon);
|
|
21
23
|
var conventionalChangelogConfigSpec__default = /*#__PURE__*/_interopDefault(conventionalChangelogConfigSpec);
|
|
24
|
+
var meow__default = /*#__PURE__*/_interopDefault(meow);
|
|
22
25
|
var gitSemverTags__default = /*#__PURE__*/_interopDefault(gitSemverTags);
|
|
23
26
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
24
27
|
var conventionalRecommendedBump__default = /*#__PURE__*/_interopDefault(conventionalRecommendedBump);
|
|
@@ -212,6 +215,91 @@ function getPresetDefaults(usersChangelogPresetConfig) {
|
|
|
212
215
|
}
|
|
213
216
|
return preset;
|
|
214
217
|
}
|
|
218
|
+
function getCliArguments() {
|
|
219
|
+
return meow__default.default(
|
|
220
|
+
`
|
|
221
|
+
Usage:
|
|
222
|
+
$ fork-version
|
|
223
|
+
|
|
224
|
+
Options:
|
|
225
|
+
--changelog
|
|
226
|
+
Name of the changelog file. [Default: "CHANGELOG.md"]
|
|
227
|
+
--outFiles
|
|
228
|
+
Files to be updated. [Default: ["bower.json", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]]
|
|
229
|
+
--header, -H
|
|
230
|
+
The header to be used in the changelog.
|
|
231
|
+
|
|
232
|
+
--tagPrefix
|
|
233
|
+
Specify a prefix for the git tag that will be taken into account during the comparison. [Default: "v"]
|
|
234
|
+
--preReleaseTag
|
|
235
|
+
Make a pre-release with optional label to specify a tag id. [Default: undefined]
|
|
236
|
+
|
|
237
|
+
--commitAll
|
|
238
|
+
Commit all staged changes, not just files updated by fork-version.
|
|
239
|
+
--dryRun
|
|
240
|
+
If true, no output will be written to disk or committed.
|
|
241
|
+
--gitTagFallback
|
|
242
|
+
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]
|
|
243
|
+
--sign
|
|
244
|
+
Should we sign the git commit using GPG?
|
|
245
|
+
--silent
|
|
246
|
+
If true, no output will be written to stdout.
|
|
247
|
+
--verify
|
|
248
|
+
If true, allow git to run git commit hooks.
|
|
249
|
+
|
|
250
|
+
--currentVersion
|
|
251
|
+
If set, we'll use this current version number instead of trying to find it in an outFiles.
|
|
252
|
+
--nextVersion
|
|
253
|
+
If set, we'll attempt to update to this version.
|
|
254
|
+
`,
|
|
255
|
+
{
|
|
256
|
+
importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)) }),
|
|
257
|
+
flags: {
|
|
258
|
+
changelog: {
|
|
259
|
+
type: "string"
|
|
260
|
+
},
|
|
261
|
+
outFiles: {
|
|
262
|
+
type: "string",
|
|
263
|
+
isMultiple: true
|
|
264
|
+
},
|
|
265
|
+
header: {
|
|
266
|
+
type: "string",
|
|
267
|
+
shortFlag: "H"
|
|
268
|
+
},
|
|
269
|
+
tagPrefix: {
|
|
270
|
+
type: "string"
|
|
271
|
+
},
|
|
272
|
+
preReleaseTag: {
|
|
273
|
+
type: "string"
|
|
274
|
+
},
|
|
275
|
+
commitAll: {
|
|
276
|
+
type: "boolean"
|
|
277
|
+
},
|
|
278
|
+
dryRun: {
|
|
279
|
+
type: "boolean"
|
|
280
|
+
},
|
|
281
|
+
gitTagFallback: {
|
|
282
|
+
type: "boolean"
|
|
283
|
+
},
|
|
284
|
+
sign: {
|
|
285
|
+
type: "boolean"
|
|
286
|
+
},
|
|
287
|
+
silent: {
|
|
288
|
+
type: "boolean"
|
|
289
|
+
},
|
|
290
|
+
verify: {
|
|
291
|
+
type: "boolean"
|
|
292
|
+
},
|
|
293
|
+
currentVersion: {
|
|
294
|
+
type: "string"
|
|
295
|
+
},
|
|
296
|
+
nextVersion: {
|
|
297
|
+
type: "string"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|
|
215
303
|
async function getForkConfig() {
|
|
216
304
|
const cwd = process.cwd();
|
|
217
305
|
const joycon = new JoyCon__default.default.default();
|
|
@@ -220,14 +308,18 @@ async function getForkConfig() {
|
|
|
220
308
|
cwd,
|
|
221
309
|
stopDir: path__default.default.parse(cwd).root
|
|
222
310
|
});
|
|
311
|
+
const cliArguments = getCliArguments();
|
|
223
312
|
if (configPath) {
|
|
224
313
|
const foundConfig = await bundleRequire.bundleRequire({ filepath: configPath });
|
|
225
314
|
const parsedConfig = ForkConfigSchema.partial().safeParse(
|
|
226
315
|
foundConfig.mod.default || foundConfig.mod
|
|
227
316
|
);
|
|
228
317
|
if (parsedConfig.success) {
|
|
229
|
-
const mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(
|
|
230
|
-
|
|
318
|
+
const mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(
|
|
319
|
+
parsedConfig.data?.outFiles || [],
|
|
320
|
+
cliArguments.flags?.outFiles || []
|
|
321
|
+
);
|
|
322
|
+
const usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, cliArguments.flags, {
|
|
231
323
|
outFiles: Array.from(new Set(mergedOutFiles))
|
|
232
324
|
});
|
|
233
325
|
if (usersConfig.silent) {
|
|
@@ -235,6 +327,8 @@ async function getForkConfig() {
|
|
|
235
327
|
};
|
|
236
328
|
usersConfig.error = () => {
|
|
237
329
|
};
|
|
330
|
+
usersConfig.debug = () => {
|
|
331
|
+
};
|
|
238
332
|
}
|
|
239
333
|
if ("debug" in parsedConfig && typeof parsedConfig.debug === "function") {
|
|
240
334
|
usersConfig.debug = parsedConfig.debug;
|
|
@@ -244,7 +338,7 @@ async function getForkConfig() {
|
|
|
244
338
|
});
|
|
245
339
|
}
|
|
246
340
|
}
|
|
247
|
-
return Object.assign(DEFAULT_CONFIG, {
|
|
341
|
+
return Object.assign(DEFAULT_CONFIG, cliArguments.flags, {
|
|
248
342
|
changelogPresetConfig: getPresetDefaults()
|
|
249
343
|
});
|
|
250
344
|
}
|
|
@@ -621,4 +715,4 @@ exports.getForkConfig = getForkConfig;
|
|
|
621
715
|
exports.tagChanges = tagChanges;
|
|
622
716
|
exports.updateChangelog = updateChangelog;
|
|
623
717
|
//# sourceMappingURL=out.js.map
|
|
624
|
-
//# sourceMappingURL=chunk-
|
|
718
|
+
//# sourceMappingURL=chunk-4VUFHLIF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/configuration.ts","../src/process/version.ts","../src/libs/stringify-package.ts","../src/process/changelog.ts","../src/utils/execute-file.ts","../src/utils/format-commit-message.ts","../src/process/commit.ts","../src/process/tag.ts"],"names":["resolve","writeFileSync","readFileSync","existsSync"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,qCAAqC;AAC5C,OAAO,UAAU;AAGjB,IAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjC,YAAY,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU5B,QAAQ,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnD,WAAW,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,EAAE,QAAQ;AA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;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACzCA,eAAsB,WACrB,SACA,YACsB;AACtB,QAAM,EAAE,WAAW,IAAI,cAAc,OAAO;AAE5C,QAAM,aAAa,QAAQ,OAAO,OAAO;AAEzC,QAAM,MAAM,GAAG,QAAQ,SAAS,GAAG,WAAW,WAAW;AAEzD,UAAQ,IAAI,iBAAiB,GAAG,EAAE;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACC,QAAQ,uBAAuB;AAAA,MAC/B,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,QAAM,oBAAoB,MAAM,WAAW,aAAa,gBAAgB,MAAM;AAE9E,QAAM,uBAAuB,WAAW,MAAM;AAAA,IAC7C,CAAC,SAAS,KAAK,SAAS,kBAAkB,KAAK,cAAc;AAAA,EAC9D;AACA,QAAM,eAAe,GAAG,WAAW,WAAW,GAAG,WAAW,KAAK;AAEjE,QAAM,cAAc,uCAAuC,kBAAkB,KAAK,CAAC;AACnF,QAAM,iBAAiB,eACpB,2BACA,OAAO,QAAQ,kBAAkB,WAAW,QAAQ,gBAAgB,YACpE,+BACA;AAEH,UAAQ,IAAI;AAAA,EAAK,WAAW;AAAA,EAAK,uBAAuB,iBAAiB,EAAE,EAAE;AAE7E,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import path from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\nimport { z } from \"zod\";\nimport conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\nimport meow from \"meow\";\nimport type { JSONSchema7 } from \"json-schema\";\n\nconst ForkConfigSchema = z.object({\n\t/**\n\t * The path where the changes should be calculated from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tchangePath: z.string(),\n\t/**\n\t * The name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: z.string(),\n\t/**\n\t * Files to be updated.\n\t * @default\n\t * ```js\n\t * [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]\n\t * ```\n\t */\n\toutFiles: z.array(z.string()),\n\t/**\n\t * The header to be used in the changelog.\n\t * @default\n\t * ```markdown\n\t * # Changelog\n\t *\n\t * All notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.\n\t * ```\n\t */\n\theader: z.string(),\n\t/**\n\t * Specify a prefix for the git tag that will be taken into account during the comparison.\n\t *\n\t * For instance if your version tag is prefixed by `version/` instead of `v` you would\n\t * have to specify `tagPrefix: \"version/\"`.\n\t * @default `v`\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label to specify a tag id.\n\t * @example true, \"alpha\", \"beta\", \"rc\", etc.\n\t * @default undefined\n\t */\n\tpreReleaseTag: z.string().or(z.boolean()).optional(),\n\n\t/**\n\t * Commit all staged changes, not just files updated by fork-version.\n\t * @default false\n\t */\n\tcommitAll: z.boolean(),\n\t/**\n\t * If true, no output will be written to disk or committed.\n\t * @default false\n\t */\n\tdryRun: z.boolean(),\n\t/**\n\t * If true and we cant find a version in an `outFiles`, we'll fallback and attempt\n\t * to use the latest git tag for the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * Should we sign the git commit using GPG?\n\t * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}\n\t * @default false\n\t */\n\tsign: z.boolean(),\n\t/**\n\t * If true, no output will be written to stdout.\n\t * @default false\n\t */\n\tsilent: z.boolean(),\n\t/**\n\t * If true, allow git to run git commit hooks.\n\t * @default false\n\t */\n\tverify: z.boolean(),\n\n\t/**\n\t * If set, we'll use this version number instead of trying to find it in an `outFiles`.\n\t * @example \"1.0.0\"\n\t * @default undefined\n\t */\n\tcurrentVersion: z.string().optional(),\n\t/**\n\t * If set, we'll attempt to update the version number to this version.\n\t * @example \"2.0.0\"\n\t * @default undefined\n\t */\n\tnextVersion: z.string().optional(),\n\n\t/**\n\t * Override the default conventional-changelog preset configuration.\n\t */\n\tchangelogPresetConfig: z.object({\n\t\t/**\n\t\t * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.\n\t\t */\n\t\ttypes: z\n\t\t\t.array(\n\t\t\t\tz.object({\n\t\t\t\t\ttype: z.string(),\n\t\t\t\t\tsection: z.string().optional(),\n\t\t\t\t\thidden: z.boolean().optional(),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.optional(),\n\t\t/**\n\t\t * A URL representing a specific commit at a hash.\n\t\t */\n\t\tcommitUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the comparison between two git SHAs.\n\t\t */\n\t\tcompareUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).\n\t\t */\n\t\tissueUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * 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.\n\t\t */\n\t\tuserUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A string to be used to format the auto-generated release commit message.\n\t\t */\n\t\treleaseCommitMessageFormat: z.string().optional(),\n\t\t/**\n\t\t * An array of prefixes used to detect references to issues\n\t\t */\n\t\tissuePrefixes: z.array(z.string()).optional(),\n\t}),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema> & {\n\t/**\n\t * Log function, can be used to override the default `console.log` function\n\t * to log to a file or another service.\n\t * @default console.log\n\t */\n\tlog: (...args: unknown[]) => void;\n\t/**\n\t * Error logger function, can be used to override the default `console.error`\n\t * function to log to a file or another service.\n\t * @default console.error\n\t */\n\terror: (...args: unknown[]) => void;\n\t/**\n\t * Debug logger function, by default this is a noop function, but can be replaced\n\t * with a custom logger function or `console.info` to print output.\n\t * @default () => {}\n\t */\n\tdebug: (...args: unknown[]) => void;\n};\n\nconst DEFAULT_CONFIG: ForkConfig = {\n\tchangePath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\toutFiles: [\n\t\t\"bower.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"package-lock.json\",\n\t\t\"package.json\",\n\t],\n\theader:\n\t\t\"# 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\",\n\ttagPrefix: \"v\",\n\n\tcommitAll: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n\n\tlog: console.log, // eslint-disable-line no-console\n\terror: console.error, // eslint-disable-line no-console\n\tdebug: () => {},\n};\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(config);\n\tif (parsedConfig.success) {\n\t\treturn parsedConfig.data;\n\t}\n\treturn DEFAULT_CONFIG;\n}\n\nfunction getPresetDefaults(usersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"]) {\n\tconst preset: { name: string; [_: string]: unknown } = {\n\t\tname: \"conventionalcommits\",\n\t};\n\n\t// First take any default values from the conventional-changelog-config-spec\n\tif (typeof conventionalChangelogConfigSpec.properties === \"object\") {\n\t\tObject.entries(conventionalChangelogConfigSpec.properties).forEach(([key, value]) => {\n\t\t\tconst _value = value as JSONSchema7;\n\t\t\tif (\"default\" in _value && _value.default !== undefined) {\n\t\t\t\tpreset[key] = _value.default;\n\t\t\t}\n\t\t});\n\t}\n\n\t// Then overwrite with any values from the users config\n\tif (usersChangelogPresetConfig && typeof usersChangelogPresetConfig === \"object\") {\n\t\tObject.entries(usersChangelogPresetConfig).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tpreset[key] = value;\n\t\t\t}\n\t\t});\n\t}\n\n\treturn preset;\n}\n\nfunction getCliArguments() {\n\treturn meow(\n\t\t`\nUsage:\n\t$ fork-version\n\nOptions:\n\t--changelog\n\t\tName of the changelog file. [Default: \"CHANGELOG.md\"]\n\t--outFiles\n\t\tFiles to be updated. [Default: [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]]\n\t--header, -H\n\t\tThe header to be used in the changelog.\n\n\t--tagPrefix\n\t\tSpecify a prefix for the git tag that will be taken into account during the comparison. [Default: \"v\"]\n\t--preReleaseTag\n\t\tMake a pre-release with optional label to specify a tag id. [Default: undefined]\n\n\t--commitAll\n\t\tCommit all staged changes, not just files updated by fork-version.\n\t--dryRun\n\t\tIf true, no output will be written to disk or committed.\n\t--gitTagFallback\n\t\tIf 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]\n\t--sign\n\t\tShould we sign the git commit using GPG?\n\t--silent\n\t\tIf true, no output will be written to stdout.\n\t--verify\n\t\tIf true, allow git to run git commit hooks.\n\n\t--currentVersion\n\t\tIf set, we'll use this current version number instead of trying to find it in an outFiles.\n\t--nextVersion\n\t\tIf set, we'll attempt to update to this version.\n`,\n\t\t{\n\t\t\timportMeta: import.meta,\n\t\t\tflags: {\n\t\t\t\tchangelog: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\toutFiles: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tisMultiple: true,\n\t\t\t\t},\n\t\t\t\theader: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tshortFlag: \"H\",\n\t\t\t\t},\n\t\t\t\ttagPrefix: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tpreReleaseTag: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tcommitAll: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tdryRun: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tgitTagFallback: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tsign: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tsilent: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tverify: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tcurrentVersion: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tnextVersion: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t);\n}\n\nexport async function getForkConfig(): Promise<ForkConfig> {\n\tconst cwd = process.cwd();\n\n\tconst joycon = new JoyCon.default();\n\tconst configPath = await joycon.resolve({\n\t\tfiles: [\"fork.config.js\"],\n\t\tcwd: cwd,\n\t\tstopDir: path.parse(cwd).root,\n\t});\n\n\tconst cliArguments = getCliArguments();\n\n\tif (configPath) {\n\t\tconst foundConfig = await bundleRequire({ filepath: configPath });\n\t\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\t\tfoundConfig.mod.default || foundConfig.mod,\n\t\t);\n\n\t\tif (parsedConfig.success) {\n\t\t\t// Allow users to add additional outFiles\n\t\t\tconst mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(\n\t\t\t\tparsedConfig.data?.outFiles || [],\n\t\t\t\tcliArguments.flags?.outFiles || [],\n\t\t\t);\n\n\t\t\tconst usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, cliArguments.flags, {\n\t\t\t\toutFiles: Array.from(new Set(mergedOutFiles)),\n\t\t\t});\n\n\t\t\tif (usersConfig.silent) {\n\t\t\t\tusersConfig.log = () => {};\n\t\t\t\tusersConfig.error = () => {};\n\t\t\t\tusersConfig.debug = () => {};\n\t\t\t}\n\n\t\t\t// Allow users to override the default log function\n\t\t\tif (\"debug\" in parsedConfig && typeof parsedConfig.debug === \"function\") {\n\t\t\t\tusersConfig.debug = parsedConfig.debug as ForkConfig[\"debug\"];\n\t\t\t}\n\n\t\t\treturn Object.assign(usersConfig, {\n\t\t\t\tchangelogPresetConfig: getPresetDefaults(usersConfig?.changelogPresetConfig),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn Object.assign(DEFAULT_CONFIG, cliArguments.flags, {\n\t\tchangelogPresetConfig: getPresetDefaults(),\n\t});\n}\n","import { resolve, extname } from \"node:path\";\nimport { existsSync, readFileSync, writeFileSync, lstatSync } from \"node:fs\";\nimport gitSemverTags from \"git-semver-tags\";\nimport semver, { ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\nimport detectIndent from \"detect-indent\";\nimport detectNewLine from \"detect-newline\";\nimport { stringifyPackage } from \"../libs/stringify-package.js\";\nimport type { ForkConfig } from \"../configuration.js\";\n\ntype FileState = {\n\tname: string;\n\tpath: string;\n\ttype: \"package-file\" | ({} & string); // eslint-disable-line @typescript-eslint/ban-types\n\tversion: string;\n\tisPrivate: boolean;\n};\n\nfunction getFile(options: ForkConfig, fileToGet: string): FileState | undefined {\n\ttry {\n\t\tconst fileExtension = extname(fileToGet);\n\t\tif (fileExtension === \".json\") {\n\t\t\tconst filePath = resolve(options.changePath, fileToGet);\n\t\t\tif (existsSync(filePath)) {\n\t\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\t\t// Return if version property exists\n\t\t\t\tif (parsedJson.version) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: fileToGet,\n\t\t\t\t\t\tpath: filePath,\n\t\t\t\t\t\ttype: \"package-file\",\n\t\t\t\t\t\tversion: parsedJson.version,\n\t\t\t\t\t\tisPrivate:\n\t\t\t\t\t\t\t\"private\" in parsedJson &&\n\t\t\t\t\t\t\t(typeof parsedJson.private === \"boolean\" ? parsedJson.private : false),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\toptions.log(`Unable to find version in file: ${fileToGet}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(`Error reading file: ${fileToGet}`, error);\n\t}\n}\n\nasync function getLatestGitTagVersion(tagPrefix: string | undefined): Promise<string> {\n\tconst gitTags = await gitSemverTags({ tagPrefix });\n\tif (!gitTags.length) {\n\t\treturn \"1.0.0\";\n\t}\n\n\tconst cleanedTags = [];\n\n\tfor (const tag of gitTags) {\n\t\tconst cleanedTag = semver.clean(tag.replace(new RegExp(`^${tagPrefix}`), \"\"));\n\n\t\tif (cleanedTag) {\n\t\t\tcleanedTags.push(cleanedTag);\n\t\t}\n\t}\n\n\treturn cleanedTags.sort(semver.rcompare)[0];\n}\n\ntype CurrentVersion = {\n\tcurrentVersion: string;\n\tfiles: FileState[];\n};\n\n/**\n * Get the current version from the given files and find their locations.\n */\nasync function getCurrentVersion(options: ForkConfig): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions: string[] = [];\n\n\tfor (const file of options.outFiles) {\n\t\tconst fileState = getFile(options, file);\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (options.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!versions.includes(fileState.version)) {\n\t\t\t\tversions.push(fileState.version);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (options.currentVersion) {\n\t\tversions.push(options.currentVersion);\n\t}\n\n\tif (versions.length === 0) {\n\t\tif (options.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(options.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tcurrentVersion: version,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\"Unable to find current version\");\n\t} else if (versions.length > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\treturn {\n\t\tfiles,\n\t\tcurrentVersion: versions[0],\n\t};\n}\n\n/**\n * Get the priority of given type.\n * @example\n * - \"patch\" => 0\n * - \"minor\" => 1\n * - \"major\" => 2\n */\nfunction getPriority(type?: string): number {\n\treturn [\"patch\", \"minor\", \"major\"].indexOf(type || \"\");\n}\n\n/**\n * Get the given versions highest state.\n * @example\n * - \"patch\"\n * - \"minor\"\n * - \"major\"\n */\nfunction getVersionType(version: string): \"patch\" | \"minor\" | \"major\" | undefined {\n\tconst parseVersion = semver.parse(version);\n\tif (parseVersion?.major) {\n\t\treturn \"major\";\n\t} else if (parseVersion?.minor) {\n\t\treturn \"minor\";\n\t} else if (parseVersion?.patch) {\n\t\treturn \"patch\";\n\t}\n\treturn undefined;\n}\n\n/**\n * Get the recommended release type for the given version depending on if\n * the user asks for a prerelease with or without a tag.\n */\nfunction getReleaseType(\n\treleaseType: \"major\" | \"minor\" | \"patch\",\n\tcurrentVersion: string,\n\tpreReleaseTag?: string | boolean,\n): ReleaseType {\n\tif (!preReleaseTag) {\n\t\treturn releaseType;\n\t}\n\n\tif (Array.isArray(semver.prerelease(currentVersion))) {\n\t\tconst currentReleaseType = getVersionType(currentVersion);\n\n\t\tif (\n\t\t\tcurrentReleaseType === releaseType ||\n\t\t\tgetPriority(currentReleaseType) > getPriority(releaseType)\n\t\t) {\n\t\t\treturn \"prerelease\";\n\t\t}\n\t}\n\n\treturn `pre${releaseType}`;\n}\n\ntype NextVersion = {\n\tnextVersion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n};\n\n/**\n * Get the next version from the given files.\n */\nasync function getNextVersion(options: ForkConfig, currentVersion: string): Promise<NextVersion> {\n\tif (options.nextVersion && semver.valid(options.nextVersion)) {\n\t\treturn { nextVersion: options.nextVersion };\n\t}\n\n\tconst preMajor = semver.lt(currentVersion, \"1.0.0\");\n\tconst recommendedBump = await conventionalRecommendedBump({\n\t\tpreset: {\n\t\t\tname: \"conventionalcommits\",\n\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\tpreMajor,\n\t\t},\n\t\tpath: options.changePath,\n\t\ttagPrefix: options.tagPrefix,\n\t\tcwd: options.changePath,\n\t});\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\toptions.preReleaseTag,\n\t\t);\n\n\t\treturn Object.assign(recommendedBump, {\n\t\t\tpreMajor,\n\t\t\treleaseType,\n\t\t\tnextVersion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : undefined,\n\t\t\t\t) || \"\",\n\t\t});\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n\nfunction updateFile(\n\toptions: ForkConfig,\n\tfileToUpdate: string,\n\ttype: string,\n\tnextVersion: string,\n): void {\n\ttry {\n\t\tif (type === \"package-file\") {\n\t\t\tif (!lstatSync(fileToUpdate).isFile()) return;\n\n\t\t\tconst fileContents = readFileSync(fileToUpdate, \"utf8\");\n\t\t\tconst indent = detectIndent(fileContents).indent;\n\t\t\tconst newline = detectNewLine(fileContents);\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tparsedJson.version = nextVersion;\n\t\t\tif (parsedJson.packages && parsedJson.packages[\"\"]) {\n\t\t\t\tparsedJson.packages[\"\"].version = nextVersion; // package-lock v2 stores version there too\n\t\t\t}\n\n\t\t\tif (!options.dryRun) {\n\t\t\t\twriteFileSync(fileToUpdate, stringifyPackage(parsedJson, indent, newline), \"utf8\");\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(\"Error writing: \", error);\n\t}\n}\n\nexport type BumpVersion = CurrentVersion & NextVersion;\n\nexport async function bumpVersion(options: ForkConfig): Promise<BumpVersion> {\n\tconst current = await getCurrentVersion(options);\n\tconst next = await getNextVersion(options, current.currentVersion);\n\n\toptions.log(`Current version: ${current.currentVersion}\nNext version: ${next.nextVersion} (${next.releaseType})\nUpdating Files: `);\n\n\tfor (const outFile of current.files) {\n\t\toptions.log(`\\t${outFile.path}`);\n\n\t\tupdateFile(options, outFile.path, outFile.type, next.nextVersion);\n\t}\n\n\treturn {\n\t\tcurrentVersion: current.currentVersion,\n\t\tfiles: current.files,\n\n\t\tnextVersion: next.nextVersion,\n\t\tlevel: next.level,\n\t\tpreMajor: next.preMajor,\n\t\treason: next.reason,\n\t\treleaseType: next.releaseType,\n\t};\n}\n","/**\n * https://github.com/npm/stringify-package/blob/main/LICENSE\n * Extracted from npm/stringify-package\n *\n * Copyright npm, Inc\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\nexport function stringifyPackage(\n\tdata: string,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent || (indent === 0 ? 0 : DEFAULT_INDENT));\n\n\tif (newline === CRLF) {\n\t\treturn stringified.replace(new RegExp(LF, \"g\"), CRLF);\n\t}\n\n\treturn stringified;\n}\n","import { resolve } from \"node:path\";\nimport { constants, accessSync, writeFileSync, readFileSync, existsSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CreateChangelog = {\n\tpath: string;\n\texists: boolean;\n};\n\nfunction createChangelog(options: ForkConfig): CreateChangelog {\n\tconst changelogPath = resolve(options.changelog);\n\n\ttry {\n\t\taccessSync(changelogPath, constants.F_OK);\n\t} catch (err) {\n\t\tif (!options.dryRun && (err as { code: string }).code === \"ENOENT\") {\n\t\t\toptions.log(`Creating Changelog file: ${changelogPath}`);\n\n\t\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t\t}\n\t}\n\n\treturn {\n\t\tpath: changelogPath,\n\t\texists: existsSync(changelogPath),\n\t};\n}\n\n/**\n * Matches the following formats:\n * @example\n * `## [0.0.0]` or `<a name=\"0.0.0\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Gets the rest of the changelog from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(changelog: CreateChangelog): string {\n\tif (changelog.exists) {\n\t\tconst fileContents = readFileSync(changelog.path, \"utf-8\");\n\t\tconst oldContentStart = fileContents.search(RELEASE_PATTERN);\n\n\t\tif (oldContentStart !== -1) {\n\t\t\treturn fileContents.substring(oldContentStart);\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\nfunction getNewReleaseContent(options: ForkConfig, bumpResult: BumpVersion): Promise<string> {\n\treturn new Promise<string>((resolve) => {\n\t\tlet newContent = \"\";\n\n\t\tconventionalChangelog(\n\t\t\t{\n\t\t\t\tpreset: {\n\t\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\t\t},\n\t\t\t\ttagPrefix: options.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => options.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: options.changePath,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: bumpResult.nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: options.changePath,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\toptions.error(\"conventional-changelog: Unable to parse changes\");\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.on(\"data\", (chunk) => {\n\t\t\t\tnewContent += chunk.toString();\n\t\t\t})\n\t\t\t.on(\"end\", () => {\n\t\t\t\tresolve(newContent);\n\t\t\t});\n\t});\n}\n\ntype UpdateChangelog = {\n\tchangelog: CreateChangelog;\n\toldContent: string;\n\tnewContent: string;\n};\n\nexport async function updateChangelog(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<UpdateChangelog> {\n\tif (options.header.search(RELEASE_PATTERN) !== -1) {\n\t\t// Need to ensure the header doesn't contain the release pattern\n\t\tthrow new Error(\"Header cannot contain release pattern\");\n\t}\n\n\tconst changelog = createChangelog(options);\n\tconst oldContent = getOldReleaseContent(changelog);\n\tconst newContent = await getNewReleaseContent(options, bumpResult);\n\n\toptions.log(`Updating Changelog:\n\\t${changelog.path}`);\n\n\tif (!options.dryRun && newContent) {\n\t\twriteFileSync(changelog.path, `${options.header}\\n${newContent}\\n${oldContent}`, \"utf8\");\n\t}\n\n\treturn {\n\t\tchangelog,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../configuration.js\";\n\nexport function createExecute(options: ForkConfig) {\n\t/**\n\t * Executes a git command with the given arguments and returns the output.\n\t */\n\tasync function executeGit(...execArgs: (string | undefined)[]): Promise<string> {\n\t\tconst args = execArgs.filter(Boolean) as string[];\n\n\t\toptions.debug(`Executing: git ${args.join(\" \")}`);\n\n\t\tif (!options.dryRun) {\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\texecFile(\"git\", args, (error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\toptions.error(`git ${args[0]}:`);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(stdout ? stdout : stderr);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\treturn {\n\t\texecuteGit,\n\t};\n}\n","/**\n * Formats the commit message by replacing the `{{currentTag}}` placeholder\n * globally with the new version.\n *\n * Falls back to `chore(release): {{currentTag}}` if message is argument is falsy.\n */\nexport function formatCommitMessage(message: string | undefined, newVersion: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), newVersion);\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CommitChanges = {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n};\n\nexport async function commitChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<CommitChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\toptions.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [options.changelog];\n\tfor (const file of bumpResult.files) {\n\t\tfilesToCommit.push(file.name);\n\t}\n\n\t// If there are no files to commit don't continue.\n\tif (filesToCommit.length === 0) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t};\n\t}\n\n\tconst gitAddOutput = await executeGit(\"add\", ...filesToCommit);\n\n\tconst shouldVerify = options.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = options.sign ? \"-S\" : undefined;\n\tconst shouldCommitAll = options.commitAll ? [] : filesToCommit;\n\n\tconst gitCommitOutput = await executeGit(\n\t\t\"commit\",\n\t\tshouldVerify,\n\t\tshouldSign,\n\t\t...shouldCommitAll,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput,\n\t\tgitCommitOutput,\n\t};\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype TagChanges = {\n\tgitTagOutput: string;\n\tcurrentBranchName: string;\n\thasPublicPackageFile: boolean;\n\tpushMessage: string;\n\tpublishMessage: string;\n};\n\nexport async function tagChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<TagChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\tconst shouldSign = options.sign ? \"-s\" : \"-a\";\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${options.tagPrefix}${bumpResult.nextVersion}`;\n\n\toptions.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await executeGit(\n\t\t\"tag\",\n\t\tshouldSign,\n\t\ttag,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\tconst currentBranchName = await executeGit(\"rev-parse\", \"--abbrev-ref\", \"HEAD\");\n\n\tconst hasPublicPackageFile = bumpResult.files.some(\n\t\t(file) => file.name === \"package.json\" && file.isPrivate === false,\n\t);\n\tconst isPreRelease = `${bumpResult.releaseType}`.startsWith(\"pre\");\n\n\tconst pushMessage = `Run \\`git push --follow-tags origin ${currentBranchName.trim()}\\` to push the changes and the tag.`;\n\tconst publishMessage = isPreRelease\n\t\t? `Run \\`npm publish --tag ${\n\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : \"prerelease\"\n\t\t }\\` to publish the package.`\n\t\t: \"Run `npm publish` to publish the package.\";\n\n\toptions.log(`\\n${pushMessage}\\n${hasPublicPackageFile ? publishMessage : \"\"}`);\n\n\treturn {\n\t\tgitTagOutput,\n\t\tcurrentBranchName,\n\t\thasPublicPackageFile,\n\t\tpushMessage,\n\t\tpublishMessage,\n\t};\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import JoyCon from 'joycon';
|
|
|
3
3
|
import { bundleRequire } from 'bundle-require';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import conventionalChangelogConfigSpec from 'conventional-changelog-config-spec';
|
|
6
|
+
import meow from 'meow';
|
|
6
7
|
import { writeFileSync, lstatSync, readFileSync, accessSync, constants, existsSync } from 'node:fs';
|
|
7
8
|
import gitSemverTags from 'git-semver-tags';
|
|
8
9
|
import semver from 'semver';
|
|
@@ -198,6 +199,91 @@ function getPresetDefaults(usersChangelogPresetConfig) {
|
|
|
198
199
|
}
|
|
199
200
|
return preset;
|
|
200
201
|
}
|
|
202
|
+
function getCliArguments() {
|
|
203
|
+
return meow(
|
|
204
|
+
`
|
|
205
|
+
Usage:
|
|
206
|
+
$ fork-version
|
|
207
|
+
|
|
208
|
+
Options:
|
|
209
|
+
--changelog
|
|
210
|
+
Name of the changelog file. [Default: "CHANGELOG.md"]
|
|
211
|
+
--outFiles
|
|
212
|
+
Files to be updated. [Default: ["bower.json", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]]
|
|
213
|
+
--header, -H
|
|
214
|
+
The header to be used in the changelog.
|
|
215
|
+
|
|
216
|
+
--tagPrefix
|
|
217
|
+
Specify a prefix for the git tag that will be taken into account during the comparison. [Default: "v"]
|
|
218
|
+
--preReleaseTag
|
|
219
|
+
Make a pre-release with optional label to specify a tag id. [Default: undefined]
|
|
220
|
+
|
|
221
|
+
--commitAll
|
|
222
|
+
Commit all staged changes, not just files updated by fork-version.
|
|
223
|
+
--dryRun
|
|
224
|
+
If true, no output will be written to disk or committed.
|
|
225
|
+
--gitTagFallback
|
|
226
|
+
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]
|
|
227
|
+
--sign
|
|
228
|
+
Should we sign the git commit using GPG?
|
|
229
|
+
--silent
|
|
230
|
+
If true, no output will be written to stdout.
|
|
231
|
+
--verify
|
|
232
|
+
If true, allow git to run git commit hooks.
|
|
233
|
+
|
|
234
|
+
--currentVersion
|
|
235
|
+
If set, we'll use this current version number instead of trying to find it in an outFiles.
|
|
236
|
+
--nextVersion
|
|
237
|
+
If set, we'll attempt to update to this version.
|
|
238
|
+
`,
|
|
239
|
+
{
|
|
240
|
+
importMeta: import.meta,
|
|
241
|
+
flags: {
|
|
242
|
+
changelog: {
|
|
243
|
+
type: "string"
|
|
244
|
+
},
|
|
245
|
+
outFiles: {
|
|
246
|
+
type: "string",
|
|
247
|
+
isMultiple: true
|
|
248
|
+
},
|
|
249
|
+
header: {
|
|
250
|
+
type: "string",
|
|
251
|
+
shortFlag: "H"
|
|
252
|
+
},
|
|
253
|
+
tagPrefix: {
|
|
254
|
+
type: "string"
|
|
255
|
+
},
|
|
256
|
+
preReleaseTag: {
|
|
257
|
+
type: "string"
|
|
258
|
+
},
|
|
259
|
+
commitAll: {
|
|
260
|
+
type: "boolean"
|
|
261
|
+
},
|
|
262
|
+
dryRun: {
|
|
263
|
+
type: "boolean"
|
|
264
|
+
},
|
|
265
|
+
gitTagFallback: {
|
|
266
|
+
type: "boolean"
|
|
267
|
+
},
|
|
268
|
+
sign: {
|
|
269
|
+
type: "boolean"
|
|
270
|
+
},
|
|
271
|
+
silent: {
|
|
272
|
+
type: "boolean"
|
|
273
|
+
},
|
|
274
|
+
verify: {
|
|
275
|
+
type: "boolean"
|
|
276
|
+
},
|
|
277
|
+
currentVersion: {
|
|
278
|
+
type: "string"
|
|
279
|
+
},
|
|
280
|
+
nextVersion: {
|
|
281
|
+
type: "string"
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
201
287
|
async function getForkConfig() {
|
|
202
288
|
const cwd = process.cwd();
|
|
203
289
|
const joycon = new JoyCon.default();
|
|
@@ -206,14 +292,18 @@ async function getForkConfig() {
|
|
|
206
292
|
cwd,
|
|
207
293
|
stopDir: path.parse(cwd).root
|
|
208
294
|
});
|
|
295
|
+
const cliArguments = getCliArguments();
|
|
209
296
|
if (configPath) {
|
|
210
297
|
const foundConfig = await bundleRequire({ filepath: configPath });
|
|
211
298
|
const parsedConfig = ForkConfigSchema.partial().safeParse(
|
|
212
299
|
foundConfig.mod.default || foundConfig.mod
|
|
213
300
|
);
|
|
214
301
|
if (parsedConfig.success) {
|
|
215
|
-
const mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(
|
|
216
|
-
|
|
302
|
+
const mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(
|
|
303
|
+
parsedConfig.data?.outFiles || [],
|
|
304
|
+
cliArguments.flags?.outFiles || []
|
|
305
|
+
);
|
|
306
|
+
const usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, cliArguments.flags, {
|
|
217
307
|
outFiles: Array.from(new Set(mergedOutFiles))
|
|
218
308
|
});
|
|
219
309
|
if (usersConfig.silent) {
|
|
@@ -221,6 +311,8 @@ async function getForkConfig() {
|
|
|
221
311
|
};
|
|
222
312
|
usersConfig.error = () => {
|
|
223
313
|
};
|
|
314
|
+
usersConfig.debug = () => {
|
|
315
|
+
};
|
|
224
316
|
}
|
|
225
317
|
if ("debug" in parsedConfig && typeof parsedConfig.debug === "function") {
|
|
226
318
|
usersConfig.debug = parsedConfig.debug;
|
|
@@ -230,7 +322,7 @@ async function getForkConfig() {
|
|
|
230
322
|
});
|
|
231
323
|
}
|
|
232
324
|
}
|
|
233
|
-
return Object.assign(DEFAULT_CONFIG, {
|
|
325
|
+
return Object.assign(DEFAULT_CONFIG, cliArguments.flags, {
|
|
234
326
|
changelogPresetConfig: getPresetDefaults()
|
|
235
327
|
});
|
|
236
328
|
}
|
|
@@ -602,4 +694,4 @@ ${hasPublicPackageFile ? publishMessage : ""}`);
|
|
|
602
694
|
|
|
603
695
|
export { bumpVersion, commitChanges, defineConfig, getForkConfig, tagChanges, updateChangelog };
|
|
604
696
|
//# sourceMappingURL=out.js.map
|
|
605
|
-
//# sourceMappingURL=chunk-
|
|
697
|
+
//# sourceMappingURL=chunk-Z5YLEJGR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/configuration.ts","../src/process/version.ts","../src/libs/stringify-package.ts","../src/process/changelog.ts","../src/utils/execute-file.ts","../src/utils/format-commit-message.ts","../src/process/commit.ts","../src/process/tag.ts"],"names":["resolve","writeFileSync","readFileSync","existsSync"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,qCAAqC;AAC5C,OAAO,UAAU;AAGjB,IAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjC,YAAY,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU5B,QAAQ,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnD,WAAW,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,gBAAgB,E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,IACA;AAAA,EACD;AACD;;;ACzCA,eAAsB,WACrB,SACA,YACsB;AACtB,QAAM,EAAE,WAAW,IAAI,cAAc,OAAO;AAE5C,QAAM,aAAa,QAAQ,OAAO,OAAO;AAEzC,QAAM,MAAM,GAAG,QAAQ,SAAS,GAAG,WAAW,WAAW;AAEzD,UAAQ,IAAI,iBAAiB,GAAG,EAAE;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACC,QAAQ,uBAAuB;AAAA,MAC/B,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,QAAM,oBAAoB,MAAM,WAAW,aAAa,gBAAgB,MAAM;AAE9E,QAAM,uBAAuB,WAAW,MAAM;AAAA,IAC7C,CAAC,SAAS,KAAK,SAAS,kBAAkB,KAAK,cAAc;AAAA,EAC9D;AACA,QAAM,eAAe,GAAG,WAAW,WAAW,GAAG,WAAW,KAAK;AAEjE,QAAM,cAAc,uCAAuC,kBAAkB,KAAK,CAAC;AACnF,QAAM,iBAAiB,eACpB,2BACA,OAAO,QAAQ,kBAAkB,WAAW,QAAQ,gBAAgB,YACpE,+BACA;AAEH,UAAQ,IAAI;AAAA,EAAK,WAAW;AAAA,EAAK,uBAAuB,iBAAiB,EAAE,EAAE;AAE7E,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import path from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\nimport { z } from \"zod\";\nimport conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\nimport meow from \"meow\";\nimport type { JSONSchema7 } from \"json-schema\";\n\nconst ForkConfigSchema = z.object({\n\t/**\n\t * The path where the changes should be calculated from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tchangePath: z.string(),\n\t/**\n\t * The name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: z.string(),\n\t/**\n\t * Files to be updated.\n\t * @default\n\t * ```js\n\t * [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]\n\t * ```\n\t */\n\toutFiles: z.array(z.string()),\n\t/**\n\t * The header to be used in the changelog.\n\t * @default\n\t * ```markdown\n\t * # Changelog\n\t *\n\t * All notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.\n\t * ```\n\t */\n\theader: z.string(),\n\t/**\n\t * Specify a prefix for the git tag that will be taken into account during the comparison.\n\t *\n\t * For instance if your version tag is prefixed by `version/` instead of `v` you would\n\t * have to specify `tagPrefix: \"version/\"`.\n\t * @default `v`\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label to specify a tag id.\n\t * @example true, \"alpha\", \"beta\", \"rc\", etc.\n\t * @default undefined\n\t */\n\tpreReleaseTag: z.string().or(z.boolean()).optional(),\n\n\t/**\n\t * Commit all staged changes, not just files updated by fork-version.\n\t * @default false\n\t */\n\tcommitAll: z.boolean(),\n\t/**\n\t * If true, no output will be written to disk or committed.\n\t * @default false\n\t */\n\tdryRun: z.boolean(),\n\t/**\n\t * If true and we cant find a version in an `outFiles`, we'll fallback and attempt\n\t * to use the latest git tag for the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * Should we sign the git commit using GPG?\n\t * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}\n\t * @default false\n\t */\n\tsign: z.boolean(),\n\t/**\n\t * If true, no output will be written to stdout.\n\t * @default false\n\t */\n\tsilent: z.boolean(),\n\t/**\n\t * If true, allow git to run git commit hooks.\n\t * @default false\n\t */\n\tverify: z.boolean(),\n\n\t/**\n\t * If set, we'll use this version number instead of trying to find it in an `outFiles`.\n\t * @example \"1.0.0\"\n\t * @default undefined\n\t */\n\tcurrentVersion: z.string().optional(),\n\t/**\n\t * If set, we'll attempt to update the version number to this version.\n\t * @example \"2.0.0\"\n\t * @default undefined\n\t */\n\tnextVersion: z.string().optional(),\n\n\t/**\n\t * Override the default conventional-changelog preset configuration.\n\t */\n\tchangelogPresetConfig: z.object({\n\t\t/**\n\t\t * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.\n\t\t */\n\t\ttypes: z\n\t\t\t.array(\n\t\t\t\tz.object({\n\t\t\t\t\ttype: z.string(),\n\t\t\t\t\tsection: z.string().optional(),\n\t\t\t\t\thidden: z.boolean().optional(),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.optional(),\n\t\t/**\n\t\t * A URL representing a specific commit at a hash.\n\t\t */\n\t\tcommitUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the comparison between two git SHAs.\n\t\t */\n\t\tcompareUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).\n\t\t */\n\t\tissueUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * 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.\n\t\t */\n\t\tuserUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A string to be used to format the auto-generated release commit message.\n\t\t */\n\t\treleaseCommitMessageFormat: z.string().optional(),\n\t\t/**\n\t\t * An array of prefixes used to detect references to issues\n\t\t */\n\t\tissuePrefixes: z.array(z.string()).optional(),\n\t}),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema> & {\n\t/**\n\t * Log function, can be used to override the default `console.log` function\n\t * to log to a file or another service.\n\t * @default console.log\n\t */\n\tlog: (...args: unknown[]) => void;\n\t/**\n\t * Error logger function, can be used to override the default `console.error`\n\t * function to log to a file or another service.\n\t * @default console.error\n\t */\n\terror: (...args: unknown[]) => void;\n\t/**\n\t * Debug logger function, by default this is a noop function, but can be replaced\n\t * with a custom logger function or `console.info` to print output.\n\t * @default () => {}\n\t */\n\tdebug: (...args: unknown[]) => void;\n};\n\nconst DEFAULT_CONFIG: ForkConfig = {\n\tchangePath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\toutFiles: [\n\t\t\"bower.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"package-lock.json\",\n\t\t\"package.json\",\n\t],\n\theader:\n\t\t\"# 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\",\n\ttagPrefix: \"v\",\n\n\tcommitAll: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n\n\tlog: console.log, // eslint-disable-line no-console\n\terror: console.error, // eslint-disable-line no-console\n\tdebug: () => {},\n};\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(config);\n\tif (parsedConfig.success) {\n\t\treturn parsedConfig.data;\n\t}\n\treturn DEFAULT_CONFIG;\n}\n\nfunction getPresetDefaults(usersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"]) {\n\tconst preset: { name: string; [_: string]: unknown } = {\n\t\tname: \"conventionalcommits\",\n\t};\n\n\t// First take any default values from the conventional-changelog-config-spec\n\tif (typeof conventionalChangelogConfigSpec.properties === \"object\") {\n\t\tObject.entries(conventionalChangelogConfigSpec.properties).forEach(([key, value]) => {\n\t\t\tconst _value = value as JSONSchema7;\n\t\t\tif (\"default\" in _value && _value.default !== undefined) {\n\t\t\t\tpreset[key] = _value.default;\n\t\t\t}\n\t\t});\n\t}\n\n\t// Then overwrite with any values from the users config\n\tif (usersChangelogPresetConfig && typeof usersChangelogPresetConfig === \"object\") {\n\t\tObject.entries(usersChangelogPresetConfig).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tpreset[key] = value;\n\t\t\t}\n\t\t});\n\t}\n\n\treturn preset;\n}\n\nfunction getCliArguments() {\n\treturn meow(\n\t\t`\nUsage:\n\t$ fork-version\n\nOptions:\n\t--changelog\n\t\tName of the changelog file. [Default: \"CHANGELOG.md\"]\n\t--outFiles\n\t\tFiles to be updated. [Default: [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]]\n\t--header, -H\n\t\tThe header to be used in the changelog.\n\n\t--tagPrefix\n\t\tSpecify a prefix for the git tag that will be taken into account during the comparison. [Default: \"v\"]\n\t--preReleaseTag\n\t\tMake a pre-release with optional label to specify a tag id. [Default: undefined]\n\n\t--commitAll\n\t\tCommit all staged changes, not just files updated by fork-version.\n\t--dryRun\n\t\tIf true, no output will be written to disk or committed.\n\t--gitTagFallback\n\t\tIf 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]\n\t--sign\n\t\tShould we sign the git commit using GPG?\n\t--silent\n\t\tIf true, no output will be written to stdout.\n\t--verify\n\t\tIf true, allow git to run git commit hooks.\n\n\t--currentVersion\n\t\tIf set, we'll use this current version number instead of trying to find it in an outFiles.\n\t--nextVersion\n\t\tIf set, we'll attempt to update to this version.\n`,\n\t\t{\n\t\t\timportMeta: import.meta,\n\t\t\tflags: {\n\t\t\t\tchangelog: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\toutFiles: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tisMultiple: true,\n\t\t\t\t},\n\t\t\t\theader: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tshortFlag: \"H\",\n\t\t\t\t},\n\t\t\t\ttagPrefix: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tpreReleaseTag: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tcommitAll: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tdryRun: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tgitTagFallback: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tsign: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tsilent: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tverify: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t\tcurrentVersion: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tnextVersion: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t);\n}\n\nexport async function getForkConfig(): Promise<ForkConfig> {\n\tconst cwd = process.cwd();\n\n\tconst joycon = new JoyCon.default();\n\tconst configPath = await joycon.resolve({\n\t\tfiles: [\"fork.config.js\"],\n\t\tcwd: cwd,\n\t\tstopDir: path.parse(cwd).root,\n\t});\n\n\tconst cliArguments = getCliArguments();\n\n\tif (configPath) {\n\t\tconst foundConfig = await bundleRequire({ filepath: configPath });\n\t\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\t\tfoundConfig.mod.default || foundConfig.mod,\n\t\t);\n\n\t\tif (parsedConfig.success) {\n\t\t\t// Allow users to add additional outFiles\n\t\t\tconst mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(\n\t\t\t\tparsedConfig.data?.outFiles || [],\n\t\t\t\tcliArguments.flags?.outFiles || [],\n\t\t\t);\n\n\t\t\tconst usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, cliArguments.flags, {\n\t\t\t\toutFiles: Array.from(new Set(mergedOutFiles)),\n\t\t\t});\n\n\t\t\tif (usersConfig.silent) {\n\t\t\t\tusersConfig.log = () => {};\n\t\t\t\tusersConfig.error = () => {};\n\t\t\t\tusersConfig.debug = () => {};\n\t\t\t}\n\n\t\t\t// Allow users to override the default log function\n\t\t\tif (\"debug\" in parsedConfig && typeof parsedConfig.debug === \"function\") {\n\t\t\t\tusersConfig.debug = parsedConfig.debug as ForkConfig[\"debug\"];\n\t\t\t}\n\n\t\t\treturn Object.assign(usersConfig, {\n\t\t\t\tchangelogPresetConfig: getPresetDefaults(usersConfig?.changelogPresetConfig),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn Object.assign(DEFAULT_CONFIG, cliArguments.flags, {\n\t\tchangelogPresetConfig: getPresetDefaults(),\n\t});\n}\n","import { resolve, extname } from \"node:path\";\nimport { existsSync, readFileSync, writeFileSync, lstatSync } from \"node:fs\";\nimport gitSemverTags from \"git-semver-tags\";\nimport semver, { ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\nimport detectIndent from \"detect-indent\";\nimport detectNewLine from \"detect-newline\";\nimport { stringifyPackage } from \"../libs/stringify-package.js\";\nimport type { ForkConfig } from \"../configuration.js\";\n\ntype FileState = {\n\tname: string;\n\tpath: string;\n\ttype: \"package-file\" | ({} & string); // eslint-disable-line @typescript-eslint/ban-types\n\tversion: string;\n\tisPrivate: boolean;\n};\n\nfunction getFile(options: ForkConfig, fileToGet: string): FileState | undefined {\n\ttry {\n\t\tconst fileExtension = extname(fileToGet);\n\t\tif (fileExtension === \".json\") {\n\t\t\tconst filePath = resolve(options.changePath, fileToGet);\n\t\t\tif (existsSync(filePath)) {\n\t\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\t\t// Return if version property exists\n\t\t\t\tif (parsedJson.version) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: fileToGet,\n\t\t\t\t\t\tpath: filePath,\n\t\t\t\t\t\ttype: \"package-file\",\n\t\t\t\t\t\tversion: parsedJson.version,\n\t\t\t\t\t\tisPrivate:\n\t\t\t\t\t\t\t\"private\" in parsedJson &&\n\t\t\t\t\t\t\t(typeof parsedJson.private === \"boolean\" ? parsedJson.private : false),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\toptions.log(`Unable to find version in file: ${fileToGet}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(`Error reading file: ${fileToGet}`, error);\n\t}\n}\n\nasync function getLatestGitTagVersion(tagPrefix: string | undefined): Promise<string> {\n\tconst gitTags = await gitSemverTags({ tagPrefix });\n\tif (!gitTags.length) {\n\t\treturn \"1.0.0\";\n\t}\n\n\tconst cleanedTags = [];\n\n\tfor (const tag of gitTags) {\n\t\tconst cleanedTag = semver.clean(tag.replace(new RegExp(`^${tagPrefix}`), \"\"));\n\n\t\tif (cleanedTag) {\n\t\t\tcleanedTags.push(cleanedTag);\n\t\t}\n\t}\n\n\treturn cleanedTags.sort(semver.rcompare)[0];\n}\n\ntype CurrentVersion = {\n\tcurrentVersion: string;\n\tfiles: FileState[];\n};\n\n/**\n * Get the current version from the given files and find their locations.\n */\nasync function getCurrentVersion(options: ForkConfig): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions: string[] = [];\n\n\tfor (const file of options.outFiles) {\n\t\tconst fileState = getFile(options, file);\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (options.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!versions.includes(fileState.version)) {\n\t\t\t\tversions.push(fileState.version);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (options.currentVersion) {\n\t\tversions.push(options.currentVersion);\n\t}\n\n\tif (versions.length === 0) {\n\t\tif (options.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(options.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tcurrentVersion: version,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\"Unable to find current version\");\n\t} else if (versions.length > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\treturn {\n\t\tfiles,\n\t\tcurrentVersion: versions[0],\n\t};\n}\n\n/**\n * Get the priority of given type.\n * @example\n * - \"patch\" => 0\n * - \"minor\" => 1\n * - \"major\" => 2\n */\nfunction getPriority(type?: string): number {\n\treturn [\"patch\", \"minor\", \"major\"].indexOf(type || \"\");\n}\n\n/**\n * Get the given versions highest state.\n * @example\n * - \"patch\"\n * - \"minor\"\n * - \"major\"\n */\nfunction getVersionType(version: string): \"patch\" | \"minor\" | \"major\" | undefined {\n\tconst parseVersion = semver.parse(version);\n\tif (parseVersion?.major) {\n\t\treturn \"major\";\n\t} else if (parseVersion?.minor) {\n\t\treturn \"minor\";\n\t} else if (parseVersion?.patch) {\n\t\treturn \"patch\";\n\t}\n\treturn undefined;\n}\n\n/**\n * Get the recommended release type for the given version depending on if\n * the user asks for a prerelease with or without a tag.\n */\nfunction getReleaseType(\n\treleaseType: \"major\" | \"minor\" | \"patch\",\n\tcurrentVersion: string,\n\tpreReleaseTag?: string | boolean,\n): ReleaseType {\n\tif (!preReleaseTag) {\n\t\treturn releaseType;\n\t}\n\n\tif (Array.isArray(semver.prerelease(currentVersion))) {\n\t\tconst currentReleaseType = getVersionType(currentVersion);\n\n\t\tif (\n\t\t\tcurrentReleaseType === releaseType ||\n\t\t\tgetPriority(currentReleaseType) > getPriority(releaseType)\n\t\t) {\n\t\t\treturn \"prerelease\";\n\t\t}\n\t}\n\n\treturn `pre${releaseType}`;\n}\n\ntype NextVersion = {\n\tnextVersion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n};\n\n/**\n * Get the next version from the given files.\n */\nasync function getNextVersion(options: ForkConfig, currentVersion: string): Promise<NextVersion> {\n\tif (options.nextVersion && semver.valid(options.nextVersion)) {\n\t\treturn { nextVersion: options.nextVersion };\n\t}\n\n\tconst preMajor = semver.lt(currentVersion, \"1.0.0\");\n\tconst recommendedBump = await conventionalRecommendedBump({\n\t\tpreset: {\n\t\t\tname: \"conventionalcommits\",\n\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\tpreMajor,\n\t\t},\n\t\tpath: options.changePath,\n\t\ttagPrefix: options.tagPrefix,\n\t\tcwd: options.changePath,\n\t});\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\toptions.preReleaseTag,\n\t\t);\n\n\t\treturn Object.assign(recommendedBump, {\n\t\t\tpreMajor,\n\t\t\treleaseType,\n\t\t\tnextVersion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : undefined,\n\t\t\t\t) || \"\",\n\t\t});\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n\nfunction updateFile(\n\toptions: ForkConfig,\n\tfileToUpdate: string,\n\ttype: string,\n\tnextVersion: string,\n): void {\n\ttry {\n\t\tif (type === \"package-file\") {\n\t\t\tif (!lstatSync(fileToUpdate).isFile()) return;\n\n\t\t\tconst fileContents = readFileSync(fileToUpdate, \"utf8\");\n\t\t\tconst indent = detectIndent(fileContents).indent;\n\t\t\tconst newline = detectNewLine(fileContents);\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tparsedJson.version = nextVersion;\n\t\t\tif (parsedJson.packages && parsedJson.packages[\"\"]) {\n\t\t\t\tparsedJson.packages[\"\"].version = nextVersion; // package-lock v2 stores version there too\n\t\t\t}\n\n\t\t\tif (!options.dryRun) {\n\t\t\t\twriteFileSync(fileToUpdate, stringifyPackage(parsedJson, indent, newline), \"utf8\");\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(\"Error writing: \", error);\n\t}\n}\n\nexport type BumpVersion = CurrentVersion & NextVersion;\n\nexport async function bumpVersion(options: ForkConfig): Promise<BumpVersion> {\n\tconst current = await getCurrentVersion(options);\n\tconst next = await getNextVersion(options, current.currentVersion);\n\n\toptions.log(`Current version: ${current.currentVersion}\nNext version: ${next.nextVersion} (${next.releaseType})\nUpdating Files: `);\n\n\tfor (const outFile of current.files) {\n\t\toptions.log(`\\t${outFile.path}`);\n\n\t\tupdateFile(options, outFile.path, outFile.type, next.nextVersion);\n\t}\n\n\treturn {\n\t\tcurrentVersion: current.currentVersion,\n\t\tfiles: current.files,\n\n\t\tnextVersion: next.nextVersion,\n\t\tlevel: next.level,\n\t\tpreMajor: next.preMajor,\n\t\treason: next.reason,\n\t\treleaseType: next.releaseType,\n\t};\n}\n","/**\n * https://github.com/npm/stringify-package/blob/main/LICENSE\n * Extracted from npm/stringify-package\n *\n * Copyright npm, Inc\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\nexport function stringifyPackage(\n\tdata: string,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent || (indent === 0 ? 0 : DEFAULT_INDENT));\n\n\tif (newline === CRLF) {\n\t\treturn stringified.replace(new RegExp(LF, \"g\"), CRLF);\n\t}\n\n\treturn stringified;\n}\n","import { resolve } from \"node:path\";\nimport { constants, accessSync, writeFileSync, readFileSync, existsSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CreateChangelog = {\n\tpath: string;\n\texists: boolean;\n};\n\nfunction createChangelog(options: ForkConfig): CreateChangelog {\n\tconst changelogPath = resolve(options.changelog);\n\n\ttry {\n\t\taccessSync(changelogPath, constants.F_OK);\n\t} catch (err) {\n\t\tif (!options.dryRun && (err as { code: string }).code === \"ENOENT\") {\n\t\t\toptions.log(`Creating Changelog file: ${changelogPath}`);\n\n\t\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t\t}\n\t}\n\n\treturn {\n\t\tpath: changelogPath,\n\t\texists: existsSync(changelogPath),\n\t};\n}\n\n/**\n * Matches the following formats:\n * @example\n * `## [0.0.0]` or `<a name=\"0.0.0\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Gets the rest of the changelog from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(changelog: CreateChangelog): string {\n\tif (changelog.exists) {\n\t\tconst fileContents = readFileSync(changelog.path, \"utf-8\");\n\t\tconst oldContentStart = fileContents.search(RELEASE_PATTERN);\n\n\t\tif (oldContentStart !== -1) {\n\t\t\treturn fileContents.substring(oldContentStart);\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\nfunction getNewReleaseContent(options: ForkConfig, bumpResult: BumpVersion): Promise<string> {\n\treturn new Promise<string>((resolve) => {\n\t\tlet newContent = \"\";\n\n\t\tconventionalChangelog(\n\t\t\t{\n\t\t\t\tpreset: {\n\t\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\t\t},\n\t\t\t\ttagPrefix: options.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => options.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: options.changePath,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: bumpResult.nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: options.changePath,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\toptions.error(\"conventional-changelog: Unable to parse changes\");\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.on(\"data\", (chunk) => {\n\t\t\t\tnewContent += chunk.toString();\n\t\t\t})\n\t\t\t.on(\"end\", () => {\n\t\t\t\tresolve(newContent);\n\t\t\t});\n\t});\n}\n\ntype UpdateChangelog = {\n\tchangelog: CreateChangelog;\n\toldContent: string;\n\tnewContent: string;\n};\n\nexport async function updateChangelog(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<UpdateChangelog> {\n\tif (options.header.search(RELEASE_PATTERN) !== -1) {\n\t\t// Need to ensure the header doesn't contain the release pattern\n\t\tthrow new Error(\"Header cannot contain release pattern\");\n\t}\n\n\tconst changelog = createChangelog(options);\n\tconst oldContent = getOldReleaseContent(changelog);\n\tconst newContent = await getNewReleaseContent(options, bumpResult);\n\n\toptions.log(`Updating Changelog:\n\\t${changelog.path}`);\n\n\tif (!options.dryRun && newContent) {\n\t\twriteFileSync(changelog.path, `${options.header}\\n${newContent}\\n${oldContent}`, \"utf8\");\n\t}\n\n\treturn {\n\t\tchangelog,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../configuration.js\";\n\nexport function createExecute(options: ForkConfig) {\n\t/**\n\t * Executes a git command with the given arguments and returns the output.\n\t */\n\tasync function executeGit(...execArgs: (string | undefined)[]): Promise<string> {\n\t\tconst args = execArgs.filter(Boolean) as string[];\n\n\t\toptions.debug(`Executing: git ${args.join(\" \")}`);\n\n\t\tif (!options.dryRun) {\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\texecFile(\"git\", args, (error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\toptions.error(`git ${args[0]}:`);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(stdout ? stdout : stderr);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\treturn {\n\t\texecuteGit,\n\t};\n}\n","/**\n * Formats the commit message by replacing the `{{currentTag}}` placeholder\n * globally with the new version.\n *\n * Falls back to `chore(release): {{currentTag}}` if message is argument is falsy.\n */\nexport function formatCommitMessage(message: string | undefined, newVersion: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), newVersion);\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CommitChanges = {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n};\n\nexport async function commitChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<CommitChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\toptions.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [options.changelog];\n\tfor (const file of bumpResult.files) {\n\t\tfilesToCommit.push(file.name);\n\t}\n\n\t// If there are no files to commit don't continue.\n\tif (filesToCommit.length === 0) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t};\n\t}\n\n\tconst gitAddOutput = await executeGit(\"add\", ...filesToCommit);\n\n\tconst shouldVerify = options.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = options.sign ? \"-S\" : undefined;\n\tconst shouldCommitAll = options.commitAll ? [] : filesToCommit;\n\n\tconst gitCommitOutput = await executeGit(\n\t\t\"commit\",\n\t\tshouldVerify,\n\t\tshouldSign,\n\t\t...shouldCommitAll,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput,\n\t\tgitCommitOutput,\n\t};\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype TagChanges = {\n\tgitTagOutput: string;\n\tcurrentBranchName: string;\n\thasPublicPackageFile: boolean;\n\tpushMessage: string;\n\tpublishMessage: string;\n};\n\nexport async function tagChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<TagChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\tconst shouldSign = options.sign ? \"-s\" : \"-a\";\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${options.tagPrefix}${bumpResult.nextVersion}`;\n\n\toptions.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await executeGit(\n\t\t\"tag\",\n\t\tshouldSign,\n\t\ttag,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\tconst currentBranchName = await executeGit(\"rev-parse\", \"--abbrev-ref\", \"HEAD\");\n\n\tconst hasPublicPackageFile = bumpResult.files.some(\n\t\t(file) => file.name === \"package.json\" && file.isPrivate === false,\n\t);\n\tconst isPreRelease = `${bumpResult.releaseType}`.startsWith(\"pre\");\n\n\tconst pushMessage = `Run \\`git push --follow-tags origin ${currentBranchName.trim()}\\` to push the changes and the tag.`;\n\tconst publishMessage = isPreRelease\n\t\t? `Run \\`npm publish --tag ${\n\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : \"prerelease\"\n\t\t }\\` to publish the package.`\n\t\t: \"Run `npm publish` to publish the package.\";\n\n\toptions.log(`\\n${pushMessage}\\n${hasPublicPackageFile ? publishMessage : \"\"}`);\n\n\treturn {\n\t\tgitTagOutput,\n\t\tcurrentBranchName,\n\t\thasPublicPackageFile,\n\t\tpushMessage,\n\t\tpublishMessage,\n\t};\n}\n"]}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk4VUFHLIF_cjs = require('./chunk-4VUFHLIF.cjs');
|
|
5
5
|
|
|
6
6
|
// src/cli.ts
|
|
7
7
|
async function runFork() {
|
|
8
|
-
const options = await
|
|
8
|
+
const options = await chunk4VUFHLIF_cjs.getForkConfig();
|
|
9
9
|
options.log(`Running Fork: ${( new Date()).toLocaleString()}
|
|
10
10
|
${options.dryRun ? "Dry run, no changes will be written to disk.\n" : ""}`);
|
|
11
|
-
const bumpResult = await
|
|
12
|
-
const changelogResult = await
|
|
13
|
-
const commitResult = await
|
|
14
|
-
const tagResult = await
|
|
11
|
+
const bumpResult = await chunk4VUFHLIF_cjs.bumpVersion(options);
|
|
12
|
+
const changelogResult = await chunk4VUFHLIF_cjs.updateChangelog(options, bumpResult);
|
|
13
|
+
const commitResult = await chunk4VUFHLIF_cjs.commitChanges(options, bumpResult);
|
|
14
|
+
const tagResult = await chunk4VUFHLIF_cjs.tagChanges(options, bumpResult);
|
|
15
15
|
const result = {
|
|
16
16
|
options,
|
|
17
17
|
bumpResult,
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getForkConfig, bumpVersion, updateChangelog, commitChanges, tagChanges } from './chunk-
|
|
2
|
+
import { getForkConfig, bumpVersion, updateChangelog, commitChanges, tagChanges } from './chunk-Z5YLEJGR.js';
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
5
|
async function runFork() {
|
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4VUFHLIF_cjs = require('./chunk-4VUFHLIF.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, 'bumpVersion', {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk4VUFHLIF_cjs.bumpVersion; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, 'commitChanges', {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk4VUFHLIF_cjs.commitChanges; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, 'defineConfig', {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk4VUFHLIF_cjs.defineConfig; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, 'tagChanges', {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk4VUFHLIF_cjs.tagChanges; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, 'updateChangelog', {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk4VUFHLIF_cjs.updateChangelog; }
|
|
26
26
|
});
|
|
27
27
|
//# sourceMappingURL=out.js.map
|
|
28
28
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { bumpVersion, commitChanges, defineConfig, tagChanges, updateChangelog } from './chunk-
|
|
1
|
+
export { bumpVersion, commitChanges, defineConfig, tagChanges, updateChangelog } from './chunk-Z5YLEJGR.js';
|
|
2
2
|
//# sourceMappingURL=out.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-version",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.13",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "Replacement for standard version written with modern syntax",
|
|
6
6
|
"homepage": "https://github.com/eglavin/fork-version",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"scripts": {
|
|
42
|
-
"
|
|
42
|
+
"fork-version": "node dist/cli.js",
|
|
43
43
|
"dev": "tsup --watch",
|
|
44
|
-
"
|
|
44
|
+
"build": "tsup",
|
|
45
45
|
"lint:style": "prettier --write \"src/**/*.ts\"",
|
|
46
46
|
"lint:code": "eslint --fix \"src/**/*.ts\""
|
|
47
47
|
},
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"esbuild": "0.19.3",
|
|
57
57
|
"git-semver-tags": "7.0.1",
|
|
58
58
|
"joycon": "3.1.1",
|
|
59
|
+
"meow": "12.1.1",
|
|
59
60
|
"semver": "7.5.4",
|
|
60
61
|
"zod": "3.22.2"
|
|
61
62
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/configuration.ts","../src/process/version.ts","../src/libs/stringify-package.ts","../src/process/changelog.ts","../src/utils/execute-file.ts","../src/utils/format-commit-message.ts","../src/process/commit.ts","../src/process/tag.ts"],"names":["resolve","writeFileSync","readFileSync","existsSync"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,qCAAqC;AAG5C,IAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjC,YAAY,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;A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,OAAO,QAAQ,kBAAkB,WAAW,QAAQ,gBAAgB,YACpE,+BACA;AAEH,UAAQ,IAAI;AAAA,EAAK,WAAW;AAAA,EAAK,uBAAuB,iBAAiB,EAAE,EAAE;AAE7E,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import path from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\nimport { z } from \"zod\";\nimport conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\nimport type { JSONSchema7 } from \"json-schema\";\n\nconst ForkConfigSchema = z.object({\n\t/**\n\t * The path where the changes should be calculated from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tchangePath: z.string(),\n\t/**\n\t * The name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: z.string(),\n\t/**\n\t * Files to be updated.\n\t * @default\n\t * ```js\n\t * [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]\n\t * ```\n\t */\n\toutFiles: z.array(z.string()),\n\t/**\n\t * The header to be used in the changelog.\n\t * @default\n\t * ```markdown\n\t * # Changelog\n\t *\n\t * All notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.\n\t * ```\n\t */\n\theader: z.string(),\n\t/**\n\t * Specify a prefix for the git tag that will be taken into account during the comparison.\n\t *\n\t * For instance if your version tag is prefixed by `version/` instead of `v` you would\n\t * have to specify `tagPrefix: \"version/\"`.\n\t * @default `v`\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label to specify a tag id.\n\t * @example true, \"alpha\", \"beta\", \"rc\", etc.\n\t * @default undefined\n\t */\n\tpreReleaseTag: z.string().or(z.boolean()).optional(),\n\n\t/**\n\t * Commit all staged changes, not just files updated by fork-version.\n\t * @default false\n\t */\n\tcommitAll: z.boolean(),\n\t/**\n\t * If true, no output will be written to disk or committed.\n\t * @default false\n\t */\n\tdryRun: z.boolean(),\n\t/**\n\t * If true and we cant find a version in an `outFiles`, we'll fallback and attempt\n\t * to use the latest git tag for the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * Should we sign the git commit using GPG?\n\t * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}\n\t * @default false\n\t */\n\tsign: z.boolean(),\n\t/**\n\t * If true, no output will be written to stdout.\n\t * @default false\n\t */\n\tsilent: z.boolean(),\n\t/**\n\t * If true, allow git to run git commit hooks.\n\t * @default false\n\t */\n\tverify: z.boolean(),\n\n\t/**\n\t * If set, we'll use this version number instead of trying to find it in an `outFiles`.\n\t * @example \"1.0.0\"\n\t * @default undefined\n\t */\n\tcurrentVersion: z.string().optional(),\n\t/**\n\t * If set, we'll attempt to update the version number to this version.\n\t * @example \"2.0.0\"\n\t * @default undefined\n\t */\n\tnextVersion: z.string().optional(),\n\n\t/**\n\t * Override the default conventional-changelog preset configuration.\n\t */\n\tchangelogPresetConfig: z.object({\n\t\t/**\n\t\t * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.\n\t\t */\n\t\ttypes: z\n\t\t\t.array(\n\t\t\t\tz.object({\n\t\t\t\t\ttype: z.string(),\n\t\t\t\t\tsection: z.string().optional(),\n\t\t\t\t\thidden: z.boolean().optional(),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.optional(),\n\t\t/**\n\t\t * A URL representing a specific commit at a hash.\n\t\t */\n\t\tcommitUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the comparison between two git SHAs.\n\t\t */\n\t\tcompareUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).\n\t\t */\n\t\tissueUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * 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.\n\t\t */\n\t\tuserUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A string to be used to format the auto-generated release commit message.\n\t\t */\n\t\treleaseCommitMessageFormat: z.string().optional(),\n\t\t/**\n\t\t * An array of prefixes used to detect references to issues\n\t\t */\n\t\tissuePrefixes: z.array(z.string()).optional(),\n\t}),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema> & {\n\t/**\n\t * Log function, can be used to override the default `console.log` function\n\t * to log to a file or another service.\n\t * @default console.log\n\t */\n\tlog: (...args: unknown[]) => void;\n\t/**\n\t * Error logger function, can be used to override the default `console.error`\n\t * function to log to a file or another service.\n\t * @default console.error\n\t */\n\terror: (...args: unknown[]) => void;\n\t/**\n\t * Debug logger function, by default this is a noop function, but can be replaced\n\t * with a custom logger function or `console.info` to print output.\n\t * @default () => {}\n\t */\n\tdebug: (...args: unknown[]) => void;\n};\n\nconst DEFAULT_CONFIG: ForkConfig = {\n\tchangePath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\toutFiles: [\n\t\t\"bower.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"package-lock.json\",\n\t\t\"package.json\",\n\t],\n\theader:\n\t\t\"# 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\",\n\ttagPrefix: \"v\",\n\n\tcommitAll: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n\n\tlog: console.log, // eslint-disable-line no-console\n\terror: console.error, // eslint-disable-line no-console\n\tdebug: () => {},\n};\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(config);\n\tif (parsedConfig.success) {\n\t\treturn parsedConfig.data;\n\t}\n\treturn DEFAULT_CONFIG;\n}\n\nfunction getPresetDefaults(usersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"]) {\n\tconst preset: { name: string; [_: string]: unknown } = {\n\t\tname: \"conventionalcommits\",\n\t};\n\n\t// First take any default values from the conventional-changelog-config-spec\n\tif (typeof conventionalChangelogConfigSpec.properties === \"object\") {\n\t\tObject.entries(conventionalChangelogConfigSpec.properties).forEach(([key, value]) => {\n\t\t\tconst _value = value as JSONSchema7;\n\t\t\tif (\"default\" in _value && _value.default !== undefined) {\n\t\t\t\tpreset[key] = _value.default;\n\t\t\t}\n\t\t});\n\t}\n\n\t// Then overwrite with any values from the users config\n\tif (usersChangelogPresetConfig && typeof usersChangelogPresetConfig === \"object\") {\n\t\tObject.entries(usersChangelogPresetConfig).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tpreset[key] = value;\n\t\t\t}\n\t\t});\n\t}\n\n\treturn preset;\n}\n\nexport async function getForkConfig(): Promise<ForkConfig> {\n\tconst cwd = process.cwd();\n\n\tconst joycon = new JoyCon.default();\n\tconst configPath = await joycon.resolve({\n\t\tfiles: [\"fork.config.js\"],\n\t\tcwd: cwd,\n\t\tstopDir: path.parse(cwd).root,\n\t});\n\n\tif (configPath) {\n\t\tconst foundConfig = await bundleRequire({ filepath: configPath });\n\t\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\t\tfoundConfig.mod.default || foundConfig.mod,\n\t\t);\n\n\t\tif (parsedConfig.success) {\n\t\t\t// Allow users to add additional outFiles\n\t\t\tconst mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(parsedConfig.data?.outFiles || []);\n\n\t\t\tconst usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, {\n\t\t\t\toutFiles: Array.from(new Set(mergedOutFiles)),\n\t\t\t});\n\n\t\t\tif (usersConfig.silent) {\n\t\t\t\tusersConfig.log = () => {};\n\t\t\t\tusersConfig.error = () => {};\n\t\t\t}\n\n\t\t\t// Allow users to override the default log function\n\t\t\tif (\"debug\" in parsedConfig && typeof parsedConfig.debug === \"function\") {\n\t\t\t\tusersConfig.debug = parsedConfig.debug as ForkConfig[\"debug\"];\n\t\t\t}\n\n\t\t\treturn Object.assign(usersConfig, {\n\t\t\t\tchangelogPresetConfig: getPresetDefaults(usersConfig?.changelogPresetConfig),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn Object.assign(DEFAULT_CONFIG, {\n\t\tchangelogPresetConfig: getPresetDefaults(),\n\t});\n}\n","import { resolve, extname } from \"node:path\";\nimport { existsSync, readFileSync, writeFileSync, lstatSync } from \"node:fs\";\nimport gitSemverTags from \"git-semver-tags\";\nimport semver, { ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\nimport detectIndent from \"detect-indent\";\nimport detectNewLine from \"detect-newline\";\nimport { stringifyPackage } from \"../libs/stringify-package.js\";\nimport type { ForkConfig } from \"../configuration.js\";\n\ntype FileState = {\n\tname: string;\n\tpath: string;\n\ttype: \"package-file\" | ({} & string); // eslint-disable-line @typescript-eslint/ban-types\n\tversion: string;\n\tisPrivate: boolean;\n};\n\nfunction getFile(options: ForkConfig, fileToGet: string): FileState | undefined {\n\ttry {\n\t\tconst fileExtension = extname(fileToGet);\n\t\tif (fileExtension === \".json\") {\n\t\t\tconst filePath = resolve(options.changePath, fileToGet);\n\t\t\tif (existsSync(filePath)) {\n\t\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\t\t// Return if version property exists\n\t\t\t\tif (parsedJson.version) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: fileToGet,\n\t\t\t\t\t\tpath: filePath,\n\t\t\t\t\t\ttype: \"package-file\",\n\t\t\t\t\t\tversion: parsedJson.version,\n\t\t\t\t\t\tisPrivate:\n\t\t\t\t\t\t\t\"private\" in parsedJson &&\n\t\t\t\t\t\t\t(typeof parsedJson.private === \"boolean\" ? parsedJson.private : false),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\toptions.log(`Unable to find version in file: ${fileToGet}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(`Error reading file: ${fileToGet}`, error);\n\t}\n}\n\nasync function getLatestGitTagVersion(tagPrefix: string | undefined): Promise<string> {\n\tconst gitTags = await gitSemverTags({ tagPrefix });\n\tif (!gitTags.length) {\n\t\treturn \"1.0.0\";\n\t}\n\n\tconst cleanedTags = [];\n\n\tfor (const tag of gitTags) {\n\t\tconst cleanedTag = semver.clean(tag.replace(new RegExp(`^${tagPrefix}`), \"\"));\n\n\t\tif (cleanedTag) {\n\t\t\tcleanedTags.push(cleanedTag);\n\t\t}\n\t}\n\n\treturn cleanedTags.sort(semver.rcompare)[0];\n}\n\ntype CurrentVersion = {\n\tcurrentVersion: string;\n\tfiles: FileState[];\n};\n\n/**\n * Get the current version from the given files and find their locations.\n */\nasync function getCurrentVersion(options: ForkConfig): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions: string[] = [];\n\n\tfor (const file of options.outFiles) {\n\t\tconst fileState = getFile(options, file);\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (options.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!versions.includes(fileState.version)) {\n\t\t\t\tversions.push(fileState.version);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (options.currentVersion) {\n\t\tversions.push(options.currentVersion);\n\t}\n\n\tif (versions.length === 0) {\n\t\tif (options.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(options.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tcurrentVersion: version,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\"Unable to find current version\");\n\t} else if (versions.length > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\treturn {\n\t\tfiles,\n\t\tcurrentVersion: versions[0],\n\t};\n}\n\n/**\n * Get the priority of given type.\n * @example\n * - \"patch\" => 0\n * - \"minor\" => 1\n * - \"major\" => 2\n */\nfunction getPriority(type?: string): number {\n\treturn [\"patch\", \"minor\", \"major\"].indexOf(type || \"\");\n}\n\n/**\n * Get the given versions highest state.\n * @example\n * - \"patch\"\n * - \"minor\"\n * - \"major\"\n */\nfunction getVersionType(version: string): \"patch\" | \"minor\" | \"major\" | undefined {\n\tconst parseVersion = semver.parse(version);\n\tif (parseVersion?.major) {\n\t\treturn \"major\";\n\t} else if (parseVersion?.minor) {\n\t\treturn \"minor\";\n\t} else if (parseVersion?.patch) {\n\t\treturn \"patch\";\n\t}\n\treturn undefined;\n}\n\n/**\n * Get the recommended release type for the given version depending on if\n * the user asks for a prerelease with or without a tag.\n */\nfunction getReleaseType(\n\treleaseType: \"major\" | \"minor\" | \"patch\",\n\tcurrentVersion: string,\n\tpreReleaseTag?: string | boolean,\n): ReleaseType {\n\tif (!preReleaseTag) {\n\t\treturn releaseType;\n\t}\n\n\tif (Array.isArray(semver.prerelease(currentVersion))) {\n\t\tconst currentReleaseType = getVersionType(currentVersion);\n\n\t\tif (\n\t\t\tcurrentReleaseType === releaseType ||\n\t\t\tgetPriority(currentReleaseType) > getPriority(releaseType)\n\t\t) {\n\t\t\treturn \"prerelease\";\n\t\t}\n\t}\n\n\treturn `pre${releaseType}`;\n}\n\ntype NextVersion = {\n\tnextVersion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n};\n\n/**\n * Get the next version from the given files.\n */\nasync function getNextVersion(options: ForkConfig, currentVersion: string): Promise<NextVersion> {\n\tif (options.nextVersion && semver.valid(options.nextVersion)) {\n\t\treturn { nextVersion: options.nextVersion };\n\t}\n\n\tconst preMajor = semver.lt(currentVersion, \"1.0.0\");\n\tconst recommendedBump = await conventionalRecommendedBump({\n\t\tpreset: {\n\t\t\tname: \"conventionalcommits\",\n\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\tpreMajor,\n\t\t},\n\t\tpath: options.changePath,\n\t\ttagPrefix: options.tagPrefix,\n\t\tcwd: options.changePath,\n\t});\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\toptions.preReleaseTag,\n\t\t);\n\n\t\treturn Object.assign(recommendedBump, {\n\t\t\tpreMajor,\n\t\t\treleaseType,\n\t\t\tnextVersion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : undefined,\n\t\t\t\t) || \"\",\n\t\t});\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n\nfunction updateFile(\n\toptions: ForkConfig,\n\tfileToUpdate: string,\n\ttype: string,\n\tnextVersion: string,\n): void {\n\ttry {\n\t\tif (type === \"package-file\") {\n\t\t\tif (!lstatSync(fileToUpdate).isFile()) return;\n\n\t\t\tconst fileContents = readFileSync(fileToUpdate, \"utf8\");\n\t\t\tconst indent = detectIndent(fileContents).indent;\n\t\t\tconst newline = detectNewLine(fileContents);\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tparsedJson.version = nextVersion;\n\t\t\tif (parsedJson.packages && parsedJson.packages[\"\"]) {\n\t\t\t\tparsedJson.packages[\"\"].version = nextVersion; // package-lock v2 stores version there too\n\t\t\t}\n\n\t\t\tif (!options.dryRun) {\n\t\t\t\twriteFileSync(fileToUpdate, stringifyPackage(parsedJson, indent, newline), \"utf8\");\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(\"Error writing: \", error);\n\t}\n}\n\nexport type BumpVersion = CurrentVersion & NextVersion;\n\nexport async function bumpVersion(options: ForkConfig): Promise<BumpVersion> {\n\tconst current = await getCurrentVersion(options);\n\tconst next = await getNextVersion(options, current.currentVersion);\n\n\toptions.log(`Current version: ${current.currentVersion}\nNext version: ${next.nextVersion} (${next.releaseType})\nUpdating Files: `);\n\n\tfor (const outFile of current.files) {\n\t\toptions.log(`\\t${outFile.path}`);\n\n\t\tupdateFile(options, outFile.path, outFile.type, next.nextVersion);\n\t}\n\n\treturn {\n\t\tcurrentVersion: current.currentVersion,\n\t\tfiles: current.files,\n\n\t\tnextVersion: next.nextVersion,\n\t\tlevel: next.level,\n\t\tpreMajor: next.preMajor,\n\t\treason: next.reason,\n\t\treleaseType: next.releaseType,\n\t};\n}\n","/**\n * https://github.com/npm/stringify-package/blob/main/LICENSE\n * Extracted from npm/stringify-package\n *\n * Copyright npm, Inc\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\nexport function stringifyPackage(\n\tdata: string,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent || (indent === 0 ? 0 : DEFAULT_INDENT));\n\n\tif (newline === CRLF) {\n\t\treturn stringified.replace(new RegExp(LF, \"g\"), CRLF);\n\t}\n\n\treturn stringified;\n}\n","import { resolve } from \"node:path\";\nimport { constants, accessSync, writeFileSync, readFileSync, existsSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CreateChangelog = {\n\tpath: string;\n\texists: boolean;\n};\n\nfunction createChangelog(options: ForkConfig): CreateChangelog {\n\tconst changelogPath = resolve(options.changelog);\n\n\ttry {\n\t\taccessSync(changelogPath, constants.F_OK);\n\t} catch (err) {\n\t\tif (!options.dryRun && (err as { code: string }).code === \"ENOENT\") {\n\t\t\toptions.log(`Creating Changelog file: ${changelogPath}`);\n\n\t\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t\t}\n\t}\n\n\treturn {\n\t\tpath: changelogPath,\n\t\texists: existsSync(changelogPath),\n\t};\n}\n\n/**\n * Matches the following formats:\n * @example\n * `## [0.0.0]` or `<a name=\"0.0.0\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Gets the rest of the changelog from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(changelog: CreateChangelog): string {\n\tif (changelog.exists) {\n\t\tconst fileContents = readFileSync(changelog.path, \"utf-8\");\n\t\tconst oldContentStart = fileContents.search(RELEASE_PATTERN);\n\n\t\tif (oldContentStart !== -1) {\n\t\t\treturn fileContents.substring(oldContentStart);\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\nfunction getNewReleaseContent(options: ForkConfig, bumpResult: BumpVersion): Promise<string> {\n\treturn new Promise<string>((resolve) => {\n\t\tlet newContent = \"\";\n\n\t\tconventionalChangelog(\n\t\t\t{\n\t\t\t\tpreset: {\n\t\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\t\t},\n\t\t\t\ttagPrefix: options.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => options.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: options.changePath,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: bumpResult.nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: options.changePath,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\toptions.error(\"conventional-changelog: Unable to parse changes\");\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.on(\"data\", (chunk) => {\n\t\t\t\tnewContent += chunk.toString();\n\t\t\t})\n\t\t\t.on(\"end\", () => {\n\t\t\t\tresolve(newContent);\n\t\t\t});\n\t});\n}\n\ntype UpdateChangelog = {\n\tchangelog: CreateChangelog;\n\toldContent: string;\n\tnewContent: string;\n};\n\nexport async function updateChangelog(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<UpdateChangelog> {\n\tif (options.header.search(RELEASE_PATTERN) !== -1) {\n\t\t// Need to ensure the header doesn't contain the release pattern\n\t\tthrow new Error(\"Header cannot contain release pattern\");\n\t}\n\n\tconst changelog = createChangelog(options);\n\tconst oldContent = getOldReleaseContent(changelog);\n\tconst newContent = await getNewReleaseContent(options, bumpResult);\n\n\toptions.log(`Updating Changelog:\n\\t${changelog.path}`);\n\n\tif (!options.dryRun && newContent) {\n\t\twriteFileSync(changelog.path, `${options.header}\\n${newContent}\\n${oldContent}`, \"utf8\");\n\t}\n\n\treturn {\n\t\tchangelog,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../configuration.js\";\n\nexport function createExecute(options: ForkConfig) {\n\t/**\n\t * Executes a git command with the given arguments and returns the output.\n\t */\n\tasync function executeGit(...execArgs: (string | undefined)[]): Promise<string> {\n\t\tconst args = execArgs.filter(Boolean) as string[];\n\n\t\toptions.debug(`Executing: git ${args.join(\" \")}`);\n\n\t\tif (!options.dryRun) {\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\texecFile(\"git\", args, (error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\toptions.error(`git ${args[0]}:`);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(stdout ? stdout : stderr);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\treturn {\n\t\texecuteGit,\n\t};\n}\n","/**\n * Formats the commit message by replacing the `{{currentTag}}` placeholder\n * globally with the new version.\n *\n * Falls back to `chore(release): {{currentTag}}` if message is argument is falsy.\n */\nexport function formatCommitMessage(message: string | undefined, newVersion: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), newVersion);\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CommitChanges = {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n};\n\nexport async function commitChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<CommitChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\toptions.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [options.changelog];\n\tfor (const file of bumpResult.files) {\n\t\tfilesToCommit.push(file.name);\n\t}\n\n\t// If there are no files to commit don't continue.\n\tif (filesToCommit.length === 0) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t};\n\t}\n\n\tconst gitAddOutput = await executeGit(\"add\", ...filesToCommit);\n\n\tconst shouldVerify = options.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = options.sign ? \"-S\" : undefined;\n\tconst shouldCommitAll = options.commitAll ? [] : filesToCommit;\n\n\tconst gitCommitOutput = await executeGit(\n\t\t\"commit\",\n\t\tshouldVerify,\n\t\tshouldSign,\n\t\t...shouldCommitAll,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput,\n\t\tgitCommitOutput,\n\t};\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype TagChanges = {\n\tgitTagOutput: string;\n\tcurrentBranchName: string;\n\thasPublicPackageFile: boolean;\n\tpushMessage: string;\n\tpublishMessage: string;\n};\n\nexport async function tagChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<TagChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\tconst shouldSign = options.sign ? \"-s\" : \"-a\";\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${options.tagPrefix}${bumpResult.nextVersion}`;\n\n\toptions.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await executeGit(\n\t\t\"tag\",\n\t\tshouldSign,\n\t\ttag,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\tconst currentBranchName = await executeGit(\"rev-parse\", \"--abbrev-ref\", \"HEAD\");\n\n\tconst hasPublicPackageFile = bumpResult.files.some(\n\t\t(file) => file.name === \"package.json\" && file.isPrivate === false,\n\t);\n\tconst isPreRelease = `${bumpResult.releaseType}`.startsWith(\"pre\");\n\n\tconst pushMessage = `Run \\`git push --follow-tags origin ${currentBranchName.trim()}\\` to push the changes and the tag.`;\n\tconst publishMessage = isPreRelease\n\t\t? `Run \\`npm publish --tag ${\n\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : \"prerelease\"\n\t\t }\\` to publish the package.`\n\t\t: \"Run `npm publish` to publish the package.\";\n\n\toptions.log(`\\n${pushMessage}\\n${hasPublicPackageFile ? publishMessage : \"\"}`);\n\n\treturn {\n\t\tgitTagOutput,\n\t\tcurrentBranchName,\n\t\thasPublicPackageFile,\n\t\tpushMessage,\n\t\tpublishMessage,\n\t};\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/configuration.ts","../src/process/version.ts","../src/libs/stringify-package.ts","../src/process/changelog.ts","../src/utils/execute-file.ts","../src/utils/format-commit-message.ts","../src/process/commit.ts","../src/process/tag.ts"],"names":["resolve","writeFileSync","readFileSync","existsSync"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,qCAAqC;AAG5C,IAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjC,YAAY,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU5B,QAAQ,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpB,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnD,WAAW,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,gBAAgB,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1B,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AAA,MAC/B,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACzCA,eAAsB,WACrB,SACA,YACsB;AACtB,QAAM,EAAE,WAAW,IAAI,cAAc,OAAO;AAE5C,QAAM,aAAa,QAAQ,OAAO,OAAO;AAEzC,QAAM,MAAM,GAAG,QAAQ,SAAS,GAAG,WAAW,WAAW;AAEzD,UAAQ,IAAI,iBAAiB,GAAG,EAAE;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACC,QAAQ,uBAAuB;AAAA,MAC/B,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,QAAM,oBAAoB,MAAM,WAAW,aAAa,gBAAgB,MAAM;AAE9E,QAAM,uBAAuB,WAAW,MAAM;AAAA,IAC7C,CAAC,SAAS,KAAK,SAAS,kBAAkB,KAAK,cAAc;AAAA,EAC9D;AACA,QAAM,eAAe,GAAG,WAAW,WAAW,GAAG,WAAW,KAAK;AAEjE,QAAM,cAAc,uCAAuC,kBAAkB,KAAK,CAAC;AACnF,QAAM,iBAAiB,eACpB,2BACA,OAAO,QAAQ,kBAAkB,WAAW,QAAQ,gBAAgB,YACpE,+BACA;AAEH,UAAQ,IAAI;AAAA,EAAK,WAAW;AAAA,EAAK,uBAAuB,iBAAiB,EAAE,EAAE;AAE7E,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import path from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\nimport { z } from \"zod\";\nimport conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\nimport type { JSONSchema7 } from \"json-schema\";\n\nconst ForkConfigSchema = z.object({\n\t/**\n\t * The path where the changes should be calculated from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tchangePath: z.string(),\n\t/**\n\t * The name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: z.string(),\n\t/**\n\t * Files to be updated.\n\t * @default\n\t * ```js\n\t * [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]\n\t * ```\n\t */\n\toutFiles: z.array(z.string()),\n\t/**\n\t * The header to be used in the changelog.\n\t * @default\n\t * ```markdown\n\t * # Changelog\n\t *\n\t * All notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.\n\t * ```\n\t */\n\theader: z.string(),\n\t/**\n\t * Specify a prefix for the git tag that will be taken into account during the comparison.\n\t *\n\t * For instance if your version tag is prefixed by `version/` instead of `v` you would\n\t * have to specify `tagPrefix: \"version/\"`.\n\t * @default `v`\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label to specify a tag id.\n\t * @example true, \"alpha\", \"beta\", \"rc\", etc.\n\t * @default undefined\n\t */\n\tpreReleaseTag: z.string().or(z.boolean()).optional(),\n\n\t/**\n\t * Commit all staged changes, not just files updated by fork-version.\n\t * @default false\n\t */\n\tcommitAll: z.boolean(),\n\t/**\n\t * If true, no output will be written to disk or committed.\n\t * @default false\n\t */\n\tdryRun: z.boolean(),\n\t/**\n\t * If true and we cant find a version in an `outFiles`, we'll fallback and attempt\n\t * to use the latest git tag for the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * Should we sign the git commit using GPG?\n\t * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}\n\t * @default false\n\t */\n\tsign: z.boolean(),\n\t/**\n\t * If true, no output will be written to stdout.\n\t * @default false\n\t */\n\tsilent: z.boolean(),\n\t/**\n\t * If true, allow git to run git commit hooks.\n\t * @default false\n\t */\n\tverify: z.boolean(),\n\n\t/**\n\t * If set, we'll use this version number instead of trying to find it in an `outFiles`.\n\t * @example \"1.0.0\"\n\t * @default undefined\n\t */\n\tcurrentVersion: z.string().optional(),\n\t/**\n\t * If set, we'll attempt to update the version number to this version.\n\t * @example \"2.0.0\"\n\t * @default undefined\n\t */\n\tnextVersion: z.string().optional(),\n\n\t/**\n\t * Override the default conventional-changelog preset configuration.\n\t */\n\tchangelogPresetConfig: z.object({\n\t\t/**\n\t\t * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.\n\t\t */\n\t\ttypes: z\n\t\t\t.array(\n\t\t\t\tz.object({\n\t\t\t\t\ttype: z.string(),\n\t\t\t\t\tsection: z.string().optional(),\n\t\t\t\t\thidden: z.boolean().optional(),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.optional(),\n\t\t/**\n\t\t * A URL representing a specific commit at a hash.\n\t\t */\n\t\tcommitUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the comparison between two git SHAs.\n\t\t */\n\t\tcompareUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).\n\t\t */\n\t\tissueUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * 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.\n\t\t */\n\t\tuserUrlFormat: z.string().optional(),\n\t\t/**\n\t\t * A string to be used to format the auto-generated release commit message.\n\t\t */\n\t\treleaseCommitMessageFormat: z.string().optional(),\n\t\t/**\n\t\t * An array of prefixes used to detect references to issues\n\t\t */\n\t\tissuePrefixes: z.array(z.string()).optional(),\n\t}),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema> & {\n\t/**\n\t * Log function, can be used to override the default `console.log` function\n\t * to log to a file or another service.\n\t * @default console.log\n\t */\n\tlog: (...args: unknown[]) => void;\n\t/**\n\t * Error logger function, can be used to override the default `console.error`\n\t * function to log to a file or another service.\n\t * @default console.error\n\t */\n\terror: (...args: unknown[]) => void;\n\t/**\n\t * Debug logger function, by default this is a noop function, but can be replaced\n\t * with a custom logger function or `console.info` to print output.\n\t * @default () => {}\n\t */\n\tdebug: (...args: unknown[]) => void;\n};\n\nconst DEFAULT_CONFIG: ForkConfig = {\n\tchangePath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\toutFiles: [\n\t\t\"bower.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"package-lock.json\",\n\t\t\"package.json\",\n\t],\n\theader:\n\t\t\"# 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\",\n\ttagPrefix: \"v\",\n\n\tcommitAll: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n\n\tlog: console.log, // eslint-disable-line no-console\n\terror: console.error, // eslint-disable-line no-console\n\tdebug: () => {},\n};\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(config);\n\tif (parsedConfig.success) {\n\t\treturn parsedConfig.data;\n\t}\n\treturn DEFAULT_CONFIG;\n}\n\nfunction getPresetDefaults(usersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"]) {\n\tconst preset: { name: string; [_: string]: unknown } = {\n\t\tname: \"conventionalcommits\",\n\t};\n\n\t// First take any default values from the conventional-changelog-config-spec\n\tif (typeof conventionalChangelogConfigSpec.properties === \"object\") {\n\t\tObject.entries(conventionalChangelogConfigSpec.properties).forEach(([key, value]) => {\n\t\t\tconst _value = value as JSONSchema7;\n\t\t\tif (\"default\" in _value && _value.default !== undefined) {\n\t\t\t\tpreset[key] = _value.default;\n\t\t\t}\n\t\t});\n\t}\n\n\t// Then overwrite with any values from the users config\n\tif (usersChangelogPresetConfig && typeof usersChangelogPresetConfig === \"object\") {\n\t\tObject.entries(usersChangelogPresetConfig).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tpreset[key] = value;\n\t\t\t}\n\t\t});\n\t}\n\n\treturn preset;\n}\n\nexport async function getForkConfig(): Promise<ForkConfig> {\n\tconst cwd = process.cwd();\n\n\tconst joycon = new JoyCon.default();\n\tconst configPath = await joycon.resolve({\n\t\tfiles: [\"fork.config.js\"],\n\t\tcwd: cwd,\n\t\tstopDir: path.parse(cwd).root,\n\t});\n\n\tif (configPath) {\n\t\tconst foundConfig = await bundleRequire({ filepath: configPath });\n\t\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\t\tfoundConfig.mod.default || foundConfig.mod,\n\t\t);\n\n\t\tif (parsedConfig.success) {\n\t\t\t// Allow users to add additional outFiles\n\t\t\tconst mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(parsedConfig.data?.outFiles || []);\n\n\t\t\tconst usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, {\n\t\t\t\toutFiles: Array.from(new Set(mergedOutFiles)),\n\t\t\t});\n\n\t\t\tif (usersConfig.silent) {\n\t\t\t\tusersConfig.log = () => {};\n\t\t\t\tusersConfig.error = () => {};\n\t\t\t}\n\n\t\t\t// Allow users to override the default log function\n\t\t\tif (\"debug\" in parsedConfig && typeof parsedConfig.debug === \"function\") {\n\t\t\t\tusersConfig.debug = parsedConfig.debug as ForkConfig[\"debug\"];\n\t\t\t}\n\n\t\t\treturn Object.assign(usersConfig, {\n\t\t\t\tchangelogPresetConfig: getPresetDefaults(usersConfig?.changelogPresetConfig),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn Object.assign(DEFAULT_CONFIG, {\n\t\tchangelogPresetConfig: getPresetDefaults(),\n\t});\n}\n","import { resolve, extname } from \"node:path\";\nimport { existsSync, readFileSync, writeFileSync, lstatSync } from \"node:fs\";\nimport gitSemverTags from \"git-semver-tags\";\nimport semver, { ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\nimport detectIndent from \"detect-indent\";\nimport detectNewLine from \"detect-newline\";\nimport { stringifyPackage } from \"../libs/stringify-package.js\";\nimport type { ForkConfig } from \"../configuration.js\";\n\ntype FileState = {\n\tname: string;\n\tpath: string;\n\ttype: \"package-file\" | ({} & string); // eslint-disable-line @typescript-eslint/ban-types\n\tversion: string;\n\tisPrivate: boolean;\n};\n\nfunction getFile(options: ForkConfig, fileToGet: string): FileState | undefined {\n\ttry {\n\t\tconst fileExtension = extname(fileToGet);\n\t\tif (fileExtension === \".json\") {\n\t\t\tconst filePath = resolve(options.changePath, fileToGet);\n\t\t\tif (existsSync(filePath)) {\n\t\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\t\t// Return if version property exists\n\t\t\t\tif (parsedJson.version) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname: fileToGet,\n\t\t\t\t\t\tpath: filePath,\n\t\t\t\t\t\ttype: \"package-file\",\n\t\t\t\t\t\tversion: parsedJson.version,\n\t\t\t\t\t\tisPrivate:\n\t\t\t\t\t\t\t\"private\" in parsedJson &&\n\t\t\t\t\t\t\t(typeof parsedJson.private === \"boolean\" ? parsedJson.private : false),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\toptions.log(`Unable to find version in file: ${fileToGet}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(`Error reading file: ${fileToGet}`, error);\n\t}\n}\n\nasync function getLatestGitTagVersion(tagPrefix: string | undefined): Promise<string> {\n\tconst gitTags = await gitSemverTags({ tagPrefix });\n\tif (!gitTags.length) {\n\t\treturn \"1.0.0\";\n\t}\n\n\tconst cleanedTags = [];\n\n\tfor (const tag of gitTags) {\n\t\tconst cleanedTag = semver.clean(tag.replace(new RegExp(`^${tagPrefix}`), \"\"));\n\n\t\tif (cleanedTag) {\n\t\t\tcleanedTags.push(cleanedTag);\n\t\t}\n\t}\n\n\treturn cleanedTags.sort(semver.rcompare)[0];\n}\n\ntype CurrentVersion = {\n\tcurrentVersion: string;\n\tfiles: FileState[];\n};\n\n/**\n * Get the current version from the given files and find their locations.\n */\nasync function getCurrentVersion(options: ForkConfig): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions: string[] = [];\n\n\tfor (const file of options.outFiles) {\n\t\tconst fileState = getFile(options, file);\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (options.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!versions.includes(fileState.version)) {\n\t\t\t\tversions.push(fileState.version);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (options.currentVersion) {\n\t\tversions.push(options.currentVersion);\n\t}\n\n\tif (versions.length === 0) {\n\t\tif (options.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(options.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tcurrentVersion: version,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\"Unable to find current version\");\n\t} else if (versions.length > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\treturn {\n\t\tfiles,\n\t\tcurrentVersion: versions[0],\n\t};\n}\n\n/**\n * Get the priority of given type.\n * @example\n * - \"patch\" => 0\n * - \"minor\" => 1\n * - \"major\" => 2\n */\nfunction getPriority(type?: string): number {\n\treturn [\"patch\", \"minor\", \"major\"].indexOf(type || \"\");\n}\n\n/**\n * Get the given versions highest state.\n * @example\n * - \"patch\"\n * - \"minor\"\n * - \"major\"\n */\nfunction getVersionType(version: string): \"patch\" | \"minor\" | \"major\" | undefined {\n\tconst parseVersion = semver.parse(version);\n\tif (parseVersion?.major) {\n\t\treturn \"major\";\n\t} else if (parseVersion?.minor) {\n\t\treturn \"minor\";\n\t} else if (parseVersion?.patch) {\n\t\treturn \"patch\";\n\t}\n\treturn undefined;\n}\n\n/**\n * Get the recommended release type for the given version depending on if\n * the user asks for a prerelease with or without a tag.\n */\nfunction getReleaseType(\n\treleaseType: \"major\" | \"minor\" | \"patch\",\n\tcurrentVersion: string,\n\tpreReleaseTag?: string | boolean,\n): ReleaseType {\n\tif (!preReleaseTag) {\n\t\treturn releaseType;\n\t}\n\n\tif (Array.isArray(semver.prerelease(currentVersion))) {\n\t\tconst currentReleaseType = getVersionType(currentVersion);\n\n\t\tif (\n\t\t\tcurrentReleaseType === releaseType ||\n\t\t\tgetPriority(currentReleaseType) > getPriority(releaseType)\n\t\t) {\n\t\t\treturn \"prerelease\";\n\t\t}\n\t}\n\n\treturn `pre${releaseType}`;\n}\n\ntype NextVersion = {\n\tnextVersion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n};\n\n/**\n * Get the next version from the given files.\n */\nasync function getNextVersion(options: ForkConfig, currentVersion: string): Promise<NextVersion> {\n\tif (options.nextVersion && semver.valid(options.nextVersion)) {\n\t\treturn { nextVersion: options.nextVersion };\n\t}\n\n\tconst preMajor = semver.lt(currentVersion, \"1.0.0\");\n\tconst recommendedBump = await conventionalRecommendedBump({\n\t\tpreset: {\n\t\t\tname: \"conventionalcommits\",\n\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\tpreMajor,\n\t\t},\n\t\tpath: options.changePath,\n\t\ttagPrefix: options.tagPrefix,\n\t\tcwd: options.changePath,\n\t});\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\toptions.preReleaseTag,\n\t\t);\n\n\t\treturn Object.assign(recommendedBump, {\n\t\t\tpreMajor,\n\t\t\treleaseType,\n\t\t\tnextVersion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : undefined,\n\t\t\t\t) || \"\",\n\t\t});\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n\nfunction updateFile(\n\toptions: ForkConfig,\n\tfileToUpdate: string,\n\ttype: string,\n\tnextVersion: string,\n): void {\n\ttry {\n\t\tif (type === \"package-file\") {\n\t\t\tif (!lstatSync(fileToUpdate).isFile()) return;\n\n\t\t\tconst fileContents = readFileSync(fileToUpdate, \"utf8\");\n\t\t\tconst indent = detectIndent(fileContents).indent;\n\t\t\tconst newline = detectNewLine(fileContents);\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tparsedJson.version = nextVersion;\n\t\t\tif (parsedJson.packages && parsedJson.packages[\"\"]) {\n\t\t\t\tparsedJson.packages[\"\"].version = nextVersion; // package-lock v2 stores version there too\n\t\t\t}\n\n\t\t\tif (!options.dryRun) {\n\t\t\t\twriteFileSync(fileToUpdate, stringifyPackage(parsedJson, indent, newline), \"utf8\");\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\toptions.error(\"Error writing: \", error);\n\t}\n}\n\nexport type BumpVersion = CurrentVersion & NextVersion;\n\nexport async function bumpVersion(options: ForkConfig): Promise<BumpVersion> {\n\tconst current = await getCurrentVersion(options);\n\tconst next = await getNextVersion(options, current.currentVersion);\n\n\toptions.log(`Current version: ${current.currentVersion}\nNext version: ${next.nextVersion} (${next.releaseType})\nUpdating Files: `);\n\n\tfor (const outFile of current.files) {\n\t\toptions.log(`\\t${outFile.path}`);\n\n\t\tupdateFile(options, outFile.path, outFile.type, next.nextVersion);\n\t}\n\n\treturn {\n\t\tcurrentVersion: current.currentVersion,\n\t\tfiles: current.files,\n\n\t\tnextVersion: next.nextVersion,\n\t\tlevel: next.level,\n\t\tpreMajor: next.preMajor,\n\t\treason: next.reason,\n\t\treleaseType: next.releaseType,\n\t};\n}\n","/**\n * https://github.com/npm/stringify-package/blob/main/LICENSE\n * Extracted from npm/stringify-package\n *\n * Copyright npm, Inc\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\nexport function stringifyPackage(\n\tdata: string,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent || (indent === 0 ? 0 : DEFAULT_INDENT));\n\n\tif (newline === CRLF) {\n\t\treturn stringified.replace(new RegExp(LF, \"g\"), CRLF);\n\t}\n\n\treturn stringified;\n}\n","import { resolve } from \"node:path\";\nimport { constants, accessSync, writeFileSync, readFileSync, existsSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CreateChangelog = {\n\tpath: string;\n\texists: boolean;\n};\n\nfunction createChangelog(options: ForkConfig): CreateChangelog {\n\tconst changelogPath = resolve(options.changelog);\n\n\ttry {\n\t\taccessSync(changelogPath, constants.F_OK);\n\t} catch (err) {\n\t\tif (!options.dryRun && (err as { code: string }).code === \"ENOENT\") {\n\t\t\toptions.log(`Creating Changelog file: ${changelogPath}`);\n\n\t\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t\t}\n\t}\n\n\treturn {\n\t\tpath: changelogPath,\n\t\texists: existsSync(changelogPath),\n\t};\n}\n\n/**\n * Matches the following formats:\n * @example\n * `## [0.0.0]` or `<a name=\"0.0.0\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Gets the rest of the changelog from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(changelog: CreateChangelog): string {\n\tif (changelog.exists) {\n\t\tconst fileContents = readFileSync(changelog.path, \"utf-8\");\n\t\tconst oldContentStart = fileContents.search(RELEASE_PATTERN);\n\n\t\tif (oldContentStart !== -1) {\n\t\t\treturn fileContents.substring(oldContentStart);\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\nfunction getNewReleaseContent(options: ForkConfig, bumpResult: BumpVersion): Promise<string> {\n\treturn new Promise<string>((resolve) => {\n\t\tlet newContent = \"\";\n\n\t\tconventionalChangelog(\n\t\t\t{\n\t\t\t\tpreset: {\n\t\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t\t...(options.changelogPresetConfig || {}),\n\t\t\t\t},\n\t\t\t\ttagPrefix: options.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => options.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: options.changePath,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: bumpResult.nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: options.changePath,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\toptions.error(\"conventional-changelog: Unable to parse changes\");\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.on(\"data\", (chunk) => {\n\t\t\t\tnewContent += chunk.toString();\n\t\t\t})\n\t\t\t.on(\"end\", () => {\n\t\t\t\tresolve(newContent);\n\t\t\t});\n\t});\n}\n\ntype UpdateChangelog = {\n\tchangelog: CreateChangelog;\n\toldContent: string;\n\tnewContent: string;\n};\n\nexport async function updateChangelog(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<UpdateChangelog> {\n\tif (options.header.search(RELEASE_PATTERN) !== -1) {\n\t\t// Need to ensure the header doesn't contain the release pattern\n\t\tthrow new Error(\"Header cannot contain release pattern\");\n\t}\n\n\tconst changelog = createChangelog(options);\n\tconst oldContent = getOldReleaseContent(changelog);\n\tconst newContent = await getNewReleaseContent(options, bumpResult);\n\n\toptions.log(`Updating Changelog:\n\\t${changelog.path}`);\n\n\tif (!options.dryRun && newContent) {\n\t\twriteFileSync(changelog.path, `${options.header}\\n${newContent}\\n${oldContent}`, \"utf8\");\n\t}\n\n\treturn {\n\t\tchangelog,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../configuration.js\";\n\nexport function createExecute(options: ForkConfig) {\n\t/**\n\t * Executes a git command with the given arguments and returns the output.\n\t */\n\tasync function executeGit(...execArgs: (string | undefined)[]): Promise<string> {\n\t\tconst args = execArgs.filter(Boolean) as string[];\n\n\t\toptions.debug(`Executing: git ${args.join(\" \")}`);\n\n\t\tif (!options.dryRun) {\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\texecFile(\"git\", args, (error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\toptions.error(`git ${args[0]}:`);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(stdout ? stdout : stderr);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\treturn {\n\t\texecuteGit,\n\t};\n}\n","/**\n * Formats the commit message by replacing the `{{currentTag}}` placeholder\n * globally with the new version.\n *\n * Falls back to `chore(release): {{currentTag}}` if message is argument is falsy.\n */\nexport function formatCommitMessage(message: string | undefined, newVersion: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), newVersion);\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype CommitChanges = {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n};\n\nexport async function commitChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<CommitChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\toptions.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [options.changelog];\n\tfor (const file of bumpResult.files) {\n\t\tfilesToCommit.push(file.name);\n\t}\n\n\t// If there are no files to commit don't continue.\n\tif (filesToCommit.length === 0) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t};\n\t}\n\n\tconst gitAddOutput = await executeGit(\"add\", ...filesToCommit);\n\n\tconst shouldVerify = options.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = options.sign ? \"-S\" : undefined;\n\tconst shouldCommitAll = options.commitAll ? [] : filesToCommit;\n\n\tconst gitCommitOutput = await executeGit(\n\t\t\"commit\",\n\t\tshouldVerify,\n\t\tshouldSign,\n\t\t...shouldCommitAll,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput,\n\t\tgitCommitOutput,\n\t};\n}\n","import { createExecute } from \"../utils/execute-file.js\";\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\nimport type { ForkConfig } from \"../configuration.js\";\nimport type { BumpVersion } from \"./version.js\";\n\ntype TagChanges = {\n\tgitTagOutput: string;\n\tcurrentBranchName: string;\n\thasPublicPackageFile: boolean;\n\tpushMessage: string;\n\tpublishMessage: string;\n};\n\nexport async function tagChanges(\n\toptions: ForkConfig,\n\tbumpResult: BumpVersion,\n): Promise<TagChanges> {\n\tconst { executeGit } = createExecute(options);\n\n\tconst shouldSign = options.sign ? \"-s\" : \"-a\";\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${options.tagPrefix}${bumpResult.nextVersion}`;\n\n\toptions.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await executeGit(\n\t\t\"tag\",\n\t\tshouldSign,\n\t\ttag,\n\t\t\"-m\",\n\t\tformatCommitMessage(\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\n\t\t\tbumpResult.nextVersion,\n\t\t),\n\t);\n\n\tconst currentBranchName = await executeGit(\"rev-parse\", \"--abbrev-ref\", \"HEAD\");\n\n\tconst hasPublicPackageFile = bumpResult.files.some(\n\t\t(file) => file.name === \"package.json\" && file.isPrivate === false,\n\t);\n\tconst isPreRelease = `${bumpResult.releaseType}`.startsWith(\"pre\");\n\n\tconst pushMessage = `Run \\`git push --follow-tags origin ${currentBranchName.trim()}\\` to push the changes and the tag.`;\n\tconst publishMessage = isPreRelease\n\t\t? `Run \\`npm publish --tag ${\n\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : \"prerelease\"\n\t\t }\\` to publish the package.`\n\t\t: \"Run `npm publish` to publish the package.\";\n\n\toptions.log(`\\n${pushMessage}\\n${hasPublicPackageFile ? publishMessage : \"\"}`);\n\n\treturn {\n\t\tgitTagOutput,\n\t\tcurrentBranchName,\n\t\thasPublicPackageFile,\n\t\tpushMessage,\n\t\tpublishMessage,\n\t};\n}\n"]}
|