fork-version 1.4.48 → 1.4.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Fork Version
2
2
 
3
+ ## 1.4.50 (2024-04-18)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * change files function to explicitly check sets size ([cce8489](https://github.com/eglavin/fork-version/commit/cce84894217b95e21db16fc89e31cb60fe75174a))
9
+
10
+
11
+ ## 1.4.49 (2024-04-12)
12
+
13
+
14
+ ### Refactor
15
+
16
+ * trim changelog output conetnt ([fa6b0ff](https://github.com/eglavin/fork-version/commit/fa6b0ff99f9a162c62a710d3de458a9ae167fdc3))
17
+
18
+
3
19
  ## 1.4.48 (2024-04-11)
4
20
 
5
21
 
@@ -407,17 +423,4 @@
407
423
 
408
424
  ### Features
409
425
 
410
- * add conventional bump ([3b8ceef](https://github.com/eglavin/fork-version/commit/3b8ceef27baced317d6d7375dc3dfc2e6b0a58b0))
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
-
426
+ * add conventional bump ([3b8ceef](https://github.com/eglavin/fork-version/commit/3b8ceef27baced317d6d7375dc3dfc2e6b0a58b0))
@@ -336,23 +336,25 @@ async function getUserConfig() {
336
336
  ...parsedConfig.data,
337
337
  ...cliArguments.flags
338
338
  };
339
- const files = mergeFiles(parsedConfig.data?.files, cliArguments.flags?.files);
340
339
  return {
341
340
  ...usersConfig,
342
341
  path: cwd,
343
- files: files.length > 0 ? files : DEFAULT_CONFIG.files,
342
+ files: getFiles(parsedConfig.data?.files, cliArguments.flags?.files),
344
343
  changelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig)
345
344
  };
346
345
  }
347
- function mergeFiles(configFiles, cliFiles) {
348
- return Array.from(
349
- new Set(
350
- [].concat(
351
- Array.isArray(configFiles) ? configFiles : [],
352
- Array.isArray(cliFiles) ? cliFiles : []
353
- )
354
- )
355
- );
346
+ function getFiles(configFiles, cliFiles) {
347
+ const listOfFiles = /* @__PURE__ */ new Set();
348
+ if (Array.isArray(configFiles)) {
349
+ configFiles.forEach((file) => listOfFiles.add(file));
350
+ }
351
+ if (Array.isArray(cliFiles)) {
352
+ cliFiles.forEach((file) => listOfFiles.add(file));
353
+ }
354
+ if (listOfFiles.size) {
355
+ return Array.from(listOfFiles);
356
+ }
357
+ return DEFAULT_CONFIG.files;
356
358
  }
357
359
  async function getLatestGitTagVersion(tagPrefix) {
358
360
  const gitTags = await gitSemverTags({ tagPrefix });
@@ -548,7 +550,7 @@ async function updateChangelog(config, logger, nextVersion) {
548
550
  `${config.header}
549
551
  ${newContent}
550
552
  ${oldContent}
551
- `,
553
+ `.trim(),
552
554
  "utf8"
553
555
  );
554
556
  }
@@ -795,4 +797,4 @@ var FileManager = class {
795
797
 
796
798
  export { FileManager, ForkConfigSchema, Git, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
797
799
  //# sourceMappingURL=out.js.map
798
- //# sourceMappingURL=chunk-S2VPLFG2.js.map
800
+ //# sourceMappingURL=chunk-NKEO7YFB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/schema.ts","../src/config/user-config.ts","../src/config/defaults.ts","../src/config/cli-arguments.ts","../src/config/changelog-preset-config.ts","../src/process/version.ts","../src/utils/git-tag-version.ts","../src/utils/release-type.ts","../src/process/changelog.ts","../src/utils/file-state.ts","../src/process/commit.ts","../src/utils/git.ts","../src/utils/format-commit-message.ts","../src/process/tag.ts","../src/strategies/json-package.ts","../src/libs/stringify-package.ts","../src/strategies/plain-text.ts","../src/strategies/file-manager.ts"],"names":["semver","resolve","readFileSync","writeFileSync"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,8BAA8B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnD,OAAO,EAAE;AAAA,IACR,EAAE,OAAO;AAAA,MACR,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AAM;AAAA,EAC9C;AAAA,EATQ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBD,KAAK,UAAyC;AACpD,QAAI,SAAS,YAAY,EAAE,SAAS,OAAO,GAAG;AAC7C,aAAO,KAAK,YAAY,KAAK,QAAQ;AAAA,IACtC,WAAW,SAAS,YAAY,EAAE,SAAS,aAAa,GAAG;AAC1D,aAAO,KAAK,UAAU,KAAK,QAAQ;AAAA,IACpC;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUO,MAAM,UAAkB,YAA0B;AACxD,QAAI,KAAK,OAAO,QAAQ;AACvB,WAAK,OAAO,IAAI,2BAA2B,QAAQ,EAAE;AACrD;AAAA,IACD;AAEA,QAAI,SAAS,YAAY,EAAE,SAAS,OAAO,GAAG;AAC7C,aAAO,KAAK,YAAY,MAAM,UAAU,UAAU;AAAA,IACnD,WAAW,SAAS,YAAY,EAAE,SAAS,aAAa,GAAG;AAC1D,aAAO,KAAK,UAAU,MAAM,UAAU,UAAU;AAAA,IACjD;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AACD","sourcesContent":["import { z } from \"zod\";\n\nexport const ChangelogPresetConfigSchema = z.object({\n\t/**\n\t * An array of `type` objects representing the explicitly supported commit message types,\n\t * and whether they should show up in generated `CHANGELOG`s.\n\t */\n\ttypes: z.array(\n\t\tz.object({\n\t\t\ttype: z.string(),\n\t\t\tsection: z.string().optional(),\n\t\t\thidden: z.boolean().optional(),\n\t\t}),\n\t),\n\t/**\n\t * A URL representing a specific commit at a hash.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/commit/{{hash}}\"\n\t */\n\tcommitUrlFormat: z.string(),\n\t/**\n\t * A URL representing the comparison between two git SHAs.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}\"\n\t */\n\tcompareUrlFormat: z.string(),\n\t/**\n\t * A URL representing the issue format (allowing a different URL format to be swapped in\n\t * for Gitlab, Bitbucket, etc).\n\t * @default \"{{host}}/{{owner}}/{{repository}}/issues/{{id}}\"\n\t */\n\tissueUrlFormat: z.string(),\n\t/**\n\t * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used\n\t * for substituting @bcoe with https://github.com/bcoe in commit messages.\n\t * @default \"{{host}}/{{user}}\"\n\t */\n\tuserUrlFormat: z.string(),\n\t/**\n\t * A string to be used to format the auto-generated release commit message.\n\t * @default \"chore(release): {{currentTag}}\"\n\t */\n\treleaseCommitMessageFormat: z.string(),\n\t/**\n\t * An array of prefixes used to detect references to issues\n\t * @default [\"#\"]\n\t */\n\tissuePrefixes: z.array(z.string()),\n});\n\nexport type ChangelogPresetConfig = z.infer<typeof ChangelogPresetConfigSchema>;\n\nexport const ForkConfigSchema = z.object({\n\t/**\n\t * The path fork-version will run from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tpath: z.string(),\n\t/**\n\t * Name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: 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 * 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\tfiles: z.array(z.string()),\n\t/**\n\t * Specify a prefix for the git tag fork-version will create.\n\t *\n\t * For instance if your version tag is prefixed by \"version/\" instead of \"v\" you have to specify\n\t * `tagPrefix: \"version/\"`.\n\t *\n\t * `tagPrefix` can also be used for a monorepo environment where you might want to deploy\n\t * multiple package from the same repository. In this case you can specify a prefix for\n\t * each package:\n\t *\n\t * | Value | Tag Created |\n\t * |:-------------------------|:------------------------------|\n\t * | \"\" | `1.2.3` |\n\t * | \"version/\" | `version/1.2.3` |\n\t * | \"@eglavin/fork-version-\" | `@eglavin/fork-version-1.2.3` |\n\t *\n\t * @example \"\", \"version/\", \"@eglavin/fork-version-\"\n\t * @default \"v\"\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label, if value is a string it will be used as the\n\t * pre-release tag.\n\t *\n\t * | Value | Version |\n\t * |:----------|:----------------|\n\t * | true | \"1.2.3-0\" |\n\t * | \"alpha\" | \"1.2.3-alpha-0\" |\n\t * | \"beta\" | \"1.2.3-beta-0\" |\n\t *\n\t * @example true, \"alpha\", \"beta\", \"rc\"\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 set we'll log debug information.\n\t * @default false\n\t */\n\tdebug: 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 the list of `files`, we'll fallback\n\t * and attempt to use the latest git tag to get the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * If set, we'll gather information about the current version and exit.\n\t * @default false\n\t */\n\tinspectVersion: 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 a version from the list of `files`.\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, instead of incrementing\n\t * using \"conventional-commit\".\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: ChangelogPresetConfigSchema.partial(),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema>;\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\treturn config;\n}\n","import { parse, resolve } from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\n\nimport { ForkConfigSchema, type ForkConfig } from \"./schema\";\nimport { DEFAULT_CONFIG } from \"./defaults\";\nimport { getCliArguments } from \"./cli-arguments\";\nimport { getChangelogPresetConfig } from \"./changelog-preset-config\";\n\nexport async function getUserConfig(): Promise<ForkConfig> {\n\tconst cliArguments = getCliArguments();\n\n\tconst cwd = cliArguments.flags.path ? resolve(cliArguments.flags.path) : process.cwd();\n\tconst joycon = new JoyCon();\n\tconst configFilePath = await joycon.resolve({\n\t\tfiles: [\"fork.config.ts\", \"fork.config.js\", \"fork.config.cjs\", \"fork.config.mjs\"],\n\t\tcwd,\n\t\tstopDir: parse(cwd).root,\n\t});\n\n\tif (!configFilePath) {\n\t\treturn {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...cliArguments.flags,\n\t\t\tpath: cwd,\n\t\t\tchangelogPresetConfig: getChangelogPresetConfig(),\n\t\t} as ForkConfig;\n\t}\n\n\tconst foundConfig = await bundleRequire({ filepath: configFilePath });\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\tfoundConfig.mod.default || foundConfig.mod,\n\t);\n\n\tif (!parsedConfig.success) {\n\t\tthrow parsedConfig.error;\n\t}\n\n\tconst usersConfig = {\n\t\t...DEFAULT_CONFIG,\n\t\t...parsedConfig.data,\n\t\t...cliArguments.flags,\n\t} as ForkConfig;\n\n\treturn {\n\t\t...usersConfig,\n\t\tpath: cwd,\n\t\tfiles: getFiles(parsedConfig.data?.files, cliArguments.flags?.files),\n\t\tchangelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig),\n\t};\n}\n\nfunction getFiles(configFiles: string[] | undefined, cliFiles: string[] | undefined): string[] {\n\tconst listOfFiles = new Set<string>();\n\n\t// Add files from the users config file\n\tif (Array.isArray(configFiles)) {\n\t\tconfigFiles.forEach((file) => listOfFiles.add(file));\n\t}\n\n\t// Add files from the cli arguments\n\tif (Array.isArray(cliFiles)) {\n\t\tcliFiles.forEach((file) => listOfFiles.add(file));\n\t}\n\n\t// If the user has defined files use them, otherwise use the default list of files.\n\tif (listOfFiles.size) {\n\t\treturn Array.from(listOfFiles);\n\t}\n\n\treturn DEFAULT_CONFIG.files;\n}\n","import type { ForkConfig } from \"./schema\";\n\nexport const DEFAULT_CONFIG: ForkConfig = {\n\tpath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\tfiles: [\n\t\t\"package.json\",\n\t\t\"package-lock.json\",\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"bower.json\",\n\t],\n\theader: `# 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\tdebug: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tinspectVersion: false,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n};\n","import meow from \"meow\";\n\nexport function getCliArguments() {\n\treturn meow(\n\t\t`\nUsage:\n $ fork-version [options]\n\nOptions:\n --path [Default: process.cwd()]\n The path fork-version will run from.\n --changelog [Default: \"CHANGELOG.md\"]\n Name of the changelog file.\n --header, -H\n The header to be used in the changelog.\n --files, --file, -F [Default: [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]]\n Files to be updated.\n --tag-prefix [Default: \"v\"]\n Specify a prefix for the git tag \"fork-version\" will create.\n --pre-release-tag [Default: undefined]\n Make a pre-release with optional label, If value is a string it\n will be used as the pre-release tag.\n\n --commit-all\n Commit all staged changes, not just files updated by fork-version.\n --debug\n If true, we'll output debug information.\n --dry-run\n If true, no output will be written to disk or committed.\n --git-tag-fallback [Default: true]\n If true and we cant find a version in the given files, we'll fallback\n and attempt to use the latest git tag for the current version.\n --inspect-version\n If set, we'll gather information about the current version and exit.\n --sign\n Should we sign the git commit using GPG?\n --silent\n If true, no output will be written to stdout.\n --verify\n If true, allow git to run git commit hooks.\n\n --current-version\n If set, we'll use this version number instead of trying to find a\n version in a \"file\".\n --next-version\n If set, we'll attempt to update the version number to this version,\n instead of incrementing using \"conventional-commit\".\n`,\n\t\t{\n\t\t\timportMeta: import.meta,\n\t\t\tflags: {\n\t\t\t\tpath: { type: \"string\", default: process.cwd() },\n\t\t\t\tchangelog: { type: \"string\" },\n\t\t\t\theader: { type: \"string\", shortFlag: \"H\" },\n\t\t\t\tfiles: { type: \"string\", isMultiple: true, aliases: [\"file\"], shortFlag: \"F\" },\n\t\t\t\ttagPrefix: { type: \"string\" },\n\t\t\t\tpreReleaseTag: { type: \"string\" },\n\n\t\t\t\tcommitAll: { type: \"boolean\" },\n\t\t\t\tdebug: { type: \"boolean\" },\n\t\t\t\tdryRun: { type: \"boolean\" },\n\t\t\t\tgitTagFallback: { type: \"boolean\" },\n\t\t\t\tinspectVersion: { type: \"boolean\" },\n\t\t\t\tsign: { type: \"boolean\" },\n\t\t\t\tsilent: { type: \"boolean\" },\n\t\t\t\tverify: { type: \"boolean\" },\n\n\t\t\t\tcurrentVersion: { type: \"string\" },\n\t\t\t\tnextVersion: { type: \"string\" },\n\t\t\t},\n\t\t},\n\t);\n}\n","import conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\n\nimport { ChangelogPresetConfigSchema, type ForkConfig } from \"./schema\";\n\nexport function getChangelogPresetConfig(\n\tusersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"],\n) {\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\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 ChangelogPresetConfigSchema.passthrough().parse(preset);\n}\n","import semver, { type ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\n\nimport { getLatestGitTagVersion } from \"../utils/git-tag-version\";\nimport { getReleaseType } from \"../utils/release-type\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { IFileManager, FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface CurrentVersion {\n\tversion: string;\n\tfiles: FileState[];\n}\n\nexport async function getCurrentVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfileManager: IFileManager,\n): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions = new Set<string>();\n\n\tfor (const file of config.files) {\n\t\tconst fileState = fileManager.read(file);\n\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (config.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tversions.add(fileState.version);\n\t\t}\n\t}\n\n\tif (config.currentVersion) {\n\t\tversions.add(config.currentVersion);\n\t}\n\n\tif (versions.size === 0) {\n\t\tif (config.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(config.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tversion: 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.size > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\tconst currentVersion = versions.entries().next().value[0];\n\n\t// If we're just inspecting the version, output the version and exit\n\tif (config.inspectVersion) {\n\t\tconsole.log(currentVersion);\n\t\tprocess.exit(0);\n\t}\n\n\tlogger.log(`Current version: ${currentVersion}`);\n\treturn {\n\t\tfiles,\n\t\tversion: currentVersion,\n\t};\n}\n\nexport interface NextVersion {\n\tversion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n}\n\nexport async function getNextVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tcurrentVersion: string,\n): Promise<NextVersion> {\n\tif (config.nextVersion && semver.valid(config.nextVersion)) {\n\t\tlogger.log(`Next version: ${config.nextVersion}`);\n\t\treturn { version: config.nextVersion };\n\t}\n\n\tconst isPreMajor = semver.lt(currentVersion, \"1.0.0\");\n\n\tlet recommendedBump: Awaited<ReturnType<typeof conventionalRecommendedBump>>;\n\ttry {\n\t\trecommendedBump = await conventionalRecommendedBump({\n\t\t\tpreset: {\n\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t...config.changelogPresetConfig,\n\t\t\t\tpreMajor: isPreMajor,\n\t\t\t},\n\t\t\tpath: config.path,\n\t\t\ttagPrefix: config.tagPrefix,\n\t\t\tcwd: config.path,\n\t\t});\n\t} catch (error) {\n\t\tthrow new Error(`[conventional-recommended-bump] Unable to determine next version`);\n\t}\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\tconfig.preReleaseTag,\n\t\t);\n\n\t\tconst state: NextVersion = {\n\t\t\t...recommendedBump,\n\t\t\tpreMajor: isPreMajor,\n\t\t\treleaseType,\n\t\t\tversion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof config.preReleaseTag === \"string\" ? config.preReleaseTag : undefined,\n\t\t\t\t) ?? \"\",\n\t\t};\n\n\t\tlogger.log(`Next version: ${state.version} (${state.releaseType})`);\n\t\treturn state;\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n","import gitSemverTags from \"git-semver-tags\";\nimport semver from \"semver\";\n\n/**\n * Get the latest git tag version.\n *\n * @example\n * ```ts\n * const tagPrefix = \"v\";\n * await getLatestGitTagVersion(tagPrefix); // 1.2.3\n * ```\n */\nexport async 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","import semver, { type ReleaseType } from \"semver\";\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\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\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 * ```js\n * getReleaseType(\"patch\", \"1.0.0\", false) => \"patch\"\n * getReleaseType(\"major\", \"0.0.0-beta\", \"beta\") => \"premajor\"\n * ```\n */\nexport function 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\tconst currentVersionsIsPreRelease = Array.isArray(semver.prerelease(currentVersion));\n\tif (currentVersionsIsPreRelease) {\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","import { resolve } from \"node:path\";\nimport { writeFileSync, readFileSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\n/**\n * Matches the following changelog header formats:\n * - `## [1.2.3]`\n * - `<a name=\"1.2.3\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Get the existing changelog content from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(filePath: string, exists: boolean): string {\n\tif (exists) {\n\t\tconst fileContents = readFileSync(filePath, \"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\n/**\n * Generate the new changelog content for this release.\n */\nfunction getNewReleaseContent(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<string> {\n\treturn new Promise<string>((onResolve) => {\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...config.changelogPresetConfig,\n\t\t\t\t},\n\t\t\t\ttagPrefix: config.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => logger.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: config.path,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: config.path,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\tlogger.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\tonResolve(newContent);\n\t\t\t});\n\t});\n}\n\ninterface UpdateChangelog {\n\tchangelogPath: string;\n\toldContent: string;\n\tnewContent: string;\n}\n\nexport async function updateChangelog(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<UpdateChangelog> {\n\tif (config.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\t// Create the changelog file if it doesn't exist\n\tconst changelogPath = resolve(config.path, config.changelog);\n\tif (!config.dryRun && !fileExists(changelogPath)) {\n\t\tlogger.log(`Creating Changelog file: ${changelogPath}`);\n\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t}\n\n\tconst oldContent = getOldReleaseContent(changelogPath, fileExists(changelogPath));\n\tconst newContent = await getNewReleaseContent(config, logger, nextVersion);\n\n\tlogger.log(`Updating Changelog: ${changelogPath}`);\n\tif (!config.dryRun && newContent) {\n\t\twriteFileSync(\n\t\t\tchangelogPath,\n\t\t\t`${config.header}\n${newContent}\n${oldContent}\n`.trim(),\n\t\t\t\"utf8\",\n\t\t);\n\t}\n\n\treturn {\n\t\tchangelogPath,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { lstatSync } from \"fs\";\n\n/**\n * Determine if a file exists.\n * @example\n * ```ts\n * fileExists(\"~/.bashrc\"); // true\n * fileExists(\"~/missing-file.txt\"); // false\n * ```\n */\nexport function fileExists(filePath: string): boolean {\n\ttry {\n\t\treturn lstatSync(filePath).isFile();\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n","import { resolve } from \"node:path\";\nimport { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface CommitChanges {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n}\n\nexport async function commitChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfiles: FileState[],\n\tnextVersion: string,\n): Promise<CommitChanges> {\n\tconst git = new Git(config, logger);\n\n\tlogger.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [];\n\tif (fileExists(resolve(config.path, config.changelog))) {\n\t\tfilesToCommit.push(resolve(config.path, config.changelog));\n\t}\n\tfor (const file of files) {\n\t\tfilesToCommit.push(file.path);\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 shouldVerify = config.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = config.sign ? \"--gpg-sign\" : undefined;\n\n\t// If commitAll is set, commit all changed files.\n\tif (config.commitAll) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t\tgitAddOutput: await git.add(\"--all\"),\n\t\t\tgitCommitOutput: await git.commit(\n\t\t\t\tshouldVerify,\n\t\t\t\tshouldSign,\n\t\t\t\t\"--message\",\n\t\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t\t),\n\t\t};\n\t}\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput: await git.add(...filesToCommit),\n\t\tgitCommitOutput: await git.commit(\n\t\t\tshouldVerify,\n\t\t\tshouldSign,\n\t\t\t...filesToCommit,\n\t\t\t\"--message\",\n\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t),\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"./logger\";\n\nexport class Git {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.add = this.add.bind(this);\n\t\tthis.commit = this.commit.bind(this);\n\t\tthis.tag = this.tag.bind(this);\n\t\tthis.revParse = this.revParse.bind(this);\n\t}\n\n\tpublic add(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"add\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic commit(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"commit\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic tag(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"tag\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic revParse(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"rev-parse\", args.filter(Boolean) as string[]);\n\t}\n\n\tprivate execGit(command: string, args: string[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn Promise.resolve(\"\");\n\t\t}\n\n\t\tthis.logger.debug(`Executing: git ${command} ${args.join(\" \")}`);\n\t\treturn new Promise((onResolve, onReject) => {\n\t\t\texecFile(\n\t\t\t\t\"git\",\n\t\t\t\t[command, ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd: this.config.path,\n\t\t\t\t},\n\t\t\t\t(error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthis.logger.error(`git ${command}:`);\n\t\t\t\t\t\tonReject(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tonResolve(stdout ? stdout : stderr);\n\t\t\t\t},\n\t\t\t);\n\t\t});\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, version: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), version);\n}\n","import { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface TagChanges {\n\tgitTagOutput: string;\n}\n\nexport async function tagChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<TagChanges> {\n\tconst git = new Git(config, logger);\n\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${config.tagPrefix}${nextVersion}`;\n\n\tlogger.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await git.tag(\n\t\tconfig.sign ? \"--sign\" : \"--annotate\",\n\t\ttag,\n\t\t\"--message\",\n\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t);\n\n\treturn {\n\t\tgitTagOutput,\n\t};\n}\n","import { resolve } from \"node:path\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport detectIndent from \"detect-indent\";\nimport { detectNewline } from \"detect-newline\";\n\nimport { stringifyPackage } from \"../libs/stringify-package\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A json package file should have a version property, like what can be seen\n * in the package.json file in the root of this project.\n *\n * @example\n * ```json\n * {\n * \"name\": \"fork-version\",\n * \"version\": \"1.2.3\",\n * \"private\": true,\n * }\n * ```\n */\nexport class JSONPackage implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tif (parsedJson.version) {\n\t\t\t\treturn {\n\t\t\t\t\tname: fileName,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t\tversion: parsedJson.version,\n\n\t\t\t\t\tisPrivate: typeof parsedJson?.private === \"boolean\" ? parsedJson.private : true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.logger.warn(`Unable to determine json package file: ${fileName}`);\n\t\t}\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\tparsedJson.version = newVersion;\n\t\tif (parsedJson.packages?.[\"\"]) {\n\t\t\tparsedJson.packages[\"\"].version = newVersion; // package-lock v2 stores version here too.\n\t\t}\n\n\t\twriteFileSync(\n\t\t\tfilePath,\n\t\t\tstringifyPackage(parsedJson, detectIndent(fileContents).amount, detectNewline(fileContents)),\n\t\t\t\"utf8\",\n\t\t);\n\t}\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\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\n/**\n * @param data The object to stringify\n * @param indent `2, 4, \" \", \"\\t\"` Number of spaces a string of spaces or tab character, defaults to 2\n * @param newline `\"\\r\\n\", \"\\n\"` Windows or Unix line endings, defaults to Unix\n */\nexport function stringifyPackage(\n\tdata: object,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent ?? 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 { readFileSync, writeFileSync } from \"node:fs\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A plain text file will have just the version as the content.\n *\n * @example\n * ```txt\n * 1.2.3\n * ```\n */\nexport class PlainText implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\n\t\t\treturn {\n\t\t\t\tname: fileName,\n\t\t\t\tpath: filePath,\n\t\t\t\tversion: fileContents || \"\",\n\t\t\t};\n\t\t}\n\n\t\tthis.logger.warn(`Unable to determine plain text file: ${fileName}`);\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\twriteFileSync(filePath, newVersion, \"utf8\");\n\t}\n}\n","import { JSONPackage } from \"./json-package\";\nimport { PlainText } from \"./plain-text\";\n\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface FileState {\n\tname: string;\n\tpath: string;\n\tversion: string;\n\n\t[other: string]: unknown;\n}\n\nexport interface IFileManager {\n\tread(fileName: string): FileState | undefined;\n\twrite(filePath: string, newVersion: string): void;\n}\n\nexport class FileManager implements IFileManager {\n\tprivate JSONPackage: JSONPackage;\n\tprivate PlainText: PlainText;\n\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.JSONPackage = new JSONPackage(config, logger);\n\t\tthis.PlainText = new PlainText(config, logger);\n\t}\n\n\t/**\n\t * Get the state from the given file name.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.read(\"package.json\");\n\t * ```\n\t *\n\t * @returns\n\t * ```json\n\t * { \"name\": \"package.json\", \"path\": \"/path/to/package.json\", \"version\": \"1.2.3\", \"isPrivate\": true }\n\t * ```\n\t */\n\tpublic read(fileName: string): FileState | undefined {\n\t\tif (fileName.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.read(fileName);\n\t\t} else if (fileName.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.read(fileName);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${fileName}`);\n\t}\n\n\t/**\n\t * Write the new version to the given file path.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.write(\"/path/to/package.json\", \"1.2.3\");\n\t * ```\n\t */\n\tpublic write(filePath: string, newVersion: string): void {\n\t\tif (this.config.dryRun) {\n\t\t\tthis.logger.log(`[Dry run]: Not updating ${filePath}`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (filePath.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.write(filePath, newVersion);\n\t\t} else if (filePath.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.write(filePath, newVersion);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${filePath}`);\n\t}\n}\n"]}
@@ -350,23 +350,25 @@ async function getUserConfig() {
350
350
  ...parsedConfig.data,
351
351
  ...cliArguments.flags
352
352
  };
353
- const files = mergeFiles(parsedConfig.data?.files, cliArguments.flags?.files);
354
353
  return {
355
354
  ...usersConfig,
356
355
  path: cwd,
357
- files: files.length > 0 ? files : DEFAULT_CONFIG.files,
356
+ files: getFiles(parsedConfig.data?.files, cliArguments.flags?.files),
358
357
  changelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig)
359
358
  };
360
359
  }
361
- function mergeFiles(configFiles, cliFiles) {
362
- return Array.from(
363
- new Set(
364
- [].concat(
365
- Array.isArray(configFiles) ? configFiles : [],
366
- Array.isArray(cliFiles) ? cliFiles : []
367
- )
368
- )
369
- );
360
+ function getFiles(configFiles, cliFiles) {
361
+ const listOfFiles = /* @__PURE__ */ new Set();
362
+ if (Array.isArray(configFiles)) {
363
+ configFiles.forEach((file) => listOfFiles.add(file));
364
+ }
365
+ if (Array.isArray(cliFiles)) {
366
+ cliFiles.forEach((file) => listOfFiles.add(file));
367
+ }
368
+ if (listOfFiles.size) {
369
+ return Array.from(listOfFiles);
370
+ }
371
+ return DEFAULT_CONFIG.files;
370
372
  }
371
373
  async function getLatestGitTagVersion(tagPrefix) {
372
374
  const gitTags = await gitSemverTags__default.default({ tagPrefix });
@@ -562,7 +564,7 @@ async function updateChangelog(config, logger, nextVersion) {
562
564
  `${config.header}
563
565
  ${newContent}
564
566
  ${oldContent}
565
- `,
567
+ `.trim(),
566
568
  "utf8"
567
569
  );
568
570
  }
@@ -818,4 +820,4 @@ exports.getUserConfig = getUserConfig;
818
820
  exports.tagChanges = tagChanges;
819
821
  exports.updateChangelog = updateChangelog;
820
822
  //# sourceMappingURL=out.js.map
821
- //# sourceMappingURL=chunk-UJKGEPR3.cjs.map
823
+ //# sourceMappingURL=chunk-OMTZL56J.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/schema.ts","../src/config/user-config.ts","../src/config/defaults.ts","../src/config/cli-arguments.ts","../src/config/changelog-preset-config.ts","../src/process/version.ts","../src/utils/git-tag-version.ts","../src/utils/release-type.ts","../src/process/changelog.ts","../src/utils/file-state.ts","../src/process/commit.ts","../src/utils/git.ts","../src/utils/format-commit-message.ts","../src/process/tag.ts","../src/strategies/json-package.ts","../src/libs/stringify-package.ts","../src/strategies/plain-text.ts","../src/strategies/file-manager.ts"],"names":["semver","resolve","readFileSync","writeFileSync"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,8BAA8B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnD,OAAO,EAAE;AAAA,IACR,EAAE,OAAO;AAAA,MACR,MAAM,EAAE,OAAO;AAAA,MACf,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,MAC7B,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,IAC9B,CAAC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1B,kBAAkB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3B,gBAAgB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMzB,eAAe,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,4BAA4B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,eAAe,EAAE,MAA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I,KAAK,OAAO,QAAQ;AACvB,WAAK,OAAO,IAAI,2BAA2B,QAAQ,EAAE;AACrD;AAAA,IACD;AAEA,QAAI,SAAS,YAAY,EAAE,SAAS,OAAO,GAAG;AAC7C,aAAO,KAAK,YAAY,MAAM,UAAU,UAAU;AAAA,IACnD,WAAW,SAAS,YAAY,EAAE,SAAS,aAAa,GAAG;AAC1D,aAAO,KAAK,UAAU,MAAM,UAAU,UAAU;AAAA,IACjD;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AACD","sourcesContent":["import { z } from \"zod\";\n\nexport const ChangelogPresetConfigSchema = z.object({\n\t/**\n\t * An array of `type` objects representing the explicitly supported commit message types,\n\t * and whether they should show up in generated `CHANGELOG`s.\n\t */\n\ttypes: z.array(\n\t\tz.object({\n\t\t\ttype: z.string(),\n\t\t\tsection: z.string().optional(),\n\t\t\thidden: z.boolean().optional(),\n\t\t}),\n\t),\n\t/**\n\t * A URL representing a specific commit at a hash.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/commit/{{hash}}\"\n\t */\n\tcommitUrlFormat: z.string(),\n\t/**\n\t * A URL representing the comparison between two git SHAs.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}\"\n\t */\n\tcompareUrlFormat: z.string(),\n\t/**\n\t * A URL representing the issue format (allowing a different URL format to be swapped in\n\t * for Gitlab, Bitbucket, etc).\n\t * @default \"{{host}}/{{owner}}/{{repository}}/issues/{{id}}\"\n\t */\n\tissueUrlFormat: z.string(),\n\t/**\n\t * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used\n\t * for substituting @bcoe with https://github.com/bcoe in commit messages.\n\t * @default \"{{host}}/{{user}}\"\n\t */\n\tuserUrlFormat: z.string(),\n\t/**\n\t * A string to be used to format the auto-generated release commit message.\n\t * @default \"chore(release): {{currentTag}}\"\n\t */\n\treleaseCommitMessageFormat: z.string(),\n\t/**\n\t * An array of prefixes used to detect references to issues\n\t * @default [\"#\"]\n\t */\n\tissuePrefixes: z.array(z.string()),\n});\n\nexport type ChangelogPresetConfig = z.infer<typeof ChangelogPresetConfigSchema>;\n\nexport const ForkConfigSchema = z.object({\n\t/**\n\t * The path fork-version will run from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tpath: z.string(),\n\t/**\n\t * Name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: 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 * 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\tfiles: z.array(z.string()),\n\t/**\n\t * Specify a prefix for the git tag fork-version will create.\n\t *\n\t * For instance if your version tag is prefixed by \"version/\" instead of \"v\" you have to specify\n\t * `tagPrefix: \"version/\"`.\n\t *\n\t * `tagPrefix` can also be used for a monorepo environment where you might want to deploy\n\t * multiple package from the same repository. In this case you can specify a prefix for\n\t * each package:\n\t *\n\t * | Value | Tag Created |\n\t * |:-------------------------|:------------------------------|\n\t * | \"\" | `1.2.3` |\n\t * | \"version/\" | `version/1.2.3` |\n\t * | \"@eglavin/fork-version-\" | `@eglavin/fork-version-1.2.3` |\n\t *\n\t * @example \"\", \"version/\", \"@eglavin/fork-version-\"\n\t * @default \"v\"\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label, if value is a string it will be used as the\n\t * pre-release tag.\n\t *\n\t * | Value | Version |\n\t * |:----------|:----------------|\n\t * | true | \"1.2.3-0\" |\n\t * | \"alpha\" | \"1.2.3-alpha-0\" |\n\t * | \"beta\" | \"1.2.3-beta-0\" |\n\t *\n\t * @example true, \"alpha\", \"beta\", \"rc\"\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 set we'll log debug information.\n\t * @default false\n\t */\n\tdebug: 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 the list of `files`, we'll fallback\n\t * and attempt to use the latest git tag to get the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * If set, we'll gather information about the current version and exit.\n\t * @default false\n\t */\n\tinspectVersion: 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 a version from the list of `files`.\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, instead of incrementing\n\t * using \"conventional-commit\".\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: ChangelogPresetConfigSchema.partial(),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema>;\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\treturn config;\n}\n","import { parse, resolve } from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\n\nimport { ForkConfigSchema, type ForkConfig } from \"./schema\";\nimport { DEFAULT_CONFIG } from \"./defaults\";\nimport { getCliArguments } from \"./cli-arguments\";\nimport { getChangelogPresetConfig } from \"./changelog-preset-config\";\n\nexport async function getUserConfig(): Promise<ForkConfig> {\n\tconst cliArguments = getCliArguments();\n\n\tconst cwd = cliArguments.flags.path ? resolve(cliArguments.flags.path) : process.cwd();\n\tconst joycon = new JoyCon();\n\tconst configFilePath = await joycon.resolve({\n\t\tfiles: [\"fork.config.ts\", \"fork.config.js\", \"fork.config.cjs\", \"fork.config.mjs\"],\n\t\tcwd,\n\t\tstopDir: parse(cwd).root,\n\t});\n\n\tif (!configFilePath) {\n\t\treturn {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...cliArguments.flags,\n\t\t\tpath: cwd,\n\t\t\tchangelogPresetConfig: getChangelogPresetConfig(),\n\t\t} as ForkConfig;\n\t}\n\n\tconst foundConfig = await bundleRequire({ filepath: configFilePath });\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\tfoundConfig.mod.default || foundConfig.mod,\n\t);\n\n\tif (!parsedConfig.success) {\n\t\tthrow parsedConfig.error;\n\t}\n\n\tconst usersConfig = {\n\t\t...DEFAULT_CONFIG,\n\t\t...parsedConfig.data,\n\t\t...cliArguments.flags,\n\t} as ForkConfig;\n\n\treturn {\n\t\t...usersConfig,\n\t\tpath: cwd,\n\t\tfiles: getFiles(parsedConfig.data?.files, cliArguments.flags?.files),\n\t\tchangelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig),\n\t};\n}\n\nfunction getFiles(configFiles: string[] | undefined, cliFiles: string[] | undefined): string[] {\n\tconst listOfFiles = new Set<string>();\n\n\t// Add files from the users config file\n\tif (Array.isArray(configFiles)) {\n\t\tconfigFiles.forEach((file) => listOfFiles.add(file));\n\t}\n\n\t// Add files from the cli arguments\n\tif (Array.isArray(cliFiles)) {\n\t\tcliFiles.forEach((file) => listOfFiles.add(file));\n\t}\n\n\t// If the user has defined files use them, otherwise use the default list of files.\n\tif (listOfFiles.size) {\n\t\treturn Array.from(listOfFiles);\n\t}\n\n\treturn DEFAULT_CONFIG.files;\n}\n","import type { ForkConfig } from \"./schema\";\n\nexport const DEFAULT_CONFIG: ForkConfig = {\n\tpath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\tfiles: [\n\t\t\"package.json\",\n\t\t\"package-lock.json\",\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"bower.json\",\n\t],\n\theader: `# 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\tdebug: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tinspectVersion: false,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n};\n","import meow from \"meow\";\n\nexport function getCliArguments() {\n\treturn meow(\n\t\t`\nUsage:\n $ fork-version [options]\n\nOptions:\n --path [Default: process.cwd()]\n The path fork-version will run from.\n --changelog [Default: \"CHANGELOG.md\"]\n Name of the changelog file.\n --header, -H\n The header to be used in the changelog.\n --files, --file, -F [Default: [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]]\n Files to be updated.\n --tag-prefix [Default: \"v\"]\n Specify a prefix for the git tag \"fork-version\" will create.\n --pre-release-tag [Default: undefined]\n Make a pre-release with optional label, If value is a string it\n will be used as the pre-release tag.\n\n --commit-all\n Commit all staged changes, not just files updated by fork-version.\n --debug\n If true, we'll output debug information.\n --dry-run\n If true, no output will be written to disk or committed.\n --git-tag-fallback [Default: true]\n If true and we cant find a version in the given files, we'll fallback\n and attempt to use the latest git tag for the current version.\n --inspect-version\n If set, we'll gather information about the current version and exit.\n --sign\n Should we sign the git commit using GPG?\n --silent\n If true, no output will be written to stdout.\n --verify\n If true, allow git to run git commit hooks.\n\n --current-version\n If set, we'll use this version number instead of trying to find a\n version in a \"file\".\n --next-version\n If set, we'll attempt to update the version number to this version,\n instead of incrementing using \"conventional-commit\".\n`,\n\t\t{\n\t\t\timportMeta: import.meta,\n\t\t\tflags: {\n\t\t\t\tpath: { type: \"string\", default: process.cwd() },\n\t\t\t\tchangelog: { type: \"string\" },\n\t\t\t\theader: { type: \"string\", shortFlag: \"H\" },\n\t\t\t\tfiles: { type: \"string\", isMultiple: true, aliases: [\"file\"], shortFlag: \"F\" },\n\t\t\t\ttagPrefix: { type: \"string\" },\n\t\t\t\tpreReleaseTag: { type: \"string\" },\n\n\t\t\t\tcommitAll: { type: \"boolean\" },\n\t\t\t\tdebug: { type: \"boolean\" },\n\t\t\t\tdryRun: { type: \"boolean\" },\n\t\t\t\tgitTagFallback: { type: \"boolean\" },\n\t\t\t\tinspectVersion: { type: \"boolean\" },\n\t\t\t\tsign: { type: \"boolean\" },\n\t\t\t\tsilent: { type: \"boolean\" },\n\t\t\t\tverify: { type: \"boolean\" },\n\n\t\t\t\tcurrentVersion: { type: \"string\" },\n\t\t\t\tnextVersion: { type: \"string\" },\n\t\t\t},\n\t\t},\n\t);\n}\n","import conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\n\nimport { ChangelogPresetConfigSchema, type ForkConfig } from \"./schema\";\n\nexport function getChangelogPresetConfig(\n\tusersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"],\n) {\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\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 ChangelogPresetConfigSchema.passthrough().parse(preset);\n}\n","import semver, { type ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\n\nimport { getLatestGitTagVersion } from \"../utils/git-tag-version\";\nimport { getReleaseType } from \"../utils/release-type\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { IFileManager, FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface CurrentVersion {\n\tversion: string;\n\tfiles: FileState[];\n}\n\nexport async function getCurrentVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfileManager: IFileManager,\n): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions = new Set<string>();\n\n\tfor (const file of config.files) {\n\t\tconst fileState = fileManager.read(file);\n\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (config.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tversions.add(fileState.version);\n\t\t}\n\t}\n\n\tif (config.currentVersion) {\n\t\tversions.add(config.currentVersion);\n\t}\n\n\tif (versions.size === 0) {\n\t\tif (config.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(config.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tversion: 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.size > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\tconst currentVersion = versions.entries().next().value[0];\n\n\t// If we're just inspecting the version, output the version and exit\n\tif (config.inspectVersion) {\n\t\tconsole.log(currentVersion);\n\t\tprocess.exit(0);\n\t}\n\n\tlogger.log(`Current version: ${currentVersion}`);\n\treturn {\n\t\tfiles,\n\t\tversion: currentVersion,\n\t};\n}\n\nexport interface NextVersion {\n\tversion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n}\n\nexport async function getNextVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tcurrentVersion: string,\n): Promise<NextVersion> {\n\tif (config.nextVersion && semver.valid(config.nextVersion)) {\n\t\tlogger.log(`Next version: ${config.nextVersion}`);\n\t\treturn { version: config.nextVersion };\n\t}\n\n\tconst isPreMajor = semver.lt(currentVersion, \"1.0.0\");\n\n\tlet recommendedBump: Awaited<ReturnType<typeof conventionalRecommendedBump>>;\n\ttry {\n\t\trecommendedBump = await conventionalRecommendedBump({\n\t\t\tpreset: {\n\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t...config.changelogPresetConfig,\n\t\t\t\tpreMajor: isPreMajor,\n\t\t\t},\n\t\t\tpath: config.path,\n\t\t\ttagPrefix: config.tagPrefix,\n\t\t\tcwd: config.path,\n\t\t});\n\t} catch (error) {\n\t\tthrow new Error(`[conventional-recommended-bump] Unable to determine next version`);\n\t}\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\tconfig.preReleaseTag,\n\t\t);\n\n\t\tconst state: NextVersion = {\n\t\t\t...recommendedBump,\n\t\t\tpreMajor: isPreMajor,\n\t\t\treleaseType,\n\t\t\tversion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof config.preReleaseTag === \"string\" ? config.preReleaseTag : undefined,\n\t\t\t\t) ?? \"\",\n\t\t};\n\n\t\tlogger.log(`Next version: ${state.version} (${state.releaseType})`);\n\t\treturn state;\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n","import gitSemverTags from \"git-semver-tags\";\nimport semver from \"semver\";\n\n/**\n * Get the latest git tag version.\n *\n * @example\n * ```ts\n * const tagPrefix = \"v\";\n * await getLatestGitTagVersion(tagPrefix); // 1.2.3\n * ```\n */\nexport async 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","import semver, { type ReleaseType } from \"semver\";\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\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\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 * ```js\n * getReleaseType(\"patch\", \"1.0.0\", false) => \"patch\"\n * getReleaseType(\"major\", \"0.0.0-beta\", \"beta\") => \"premajor\"\n * ```\n */\nexport function 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\tconst currentVersionsIsPreRelease = Array.isArray(semver.prerelease(currentVersion));\n\tif (currentVersionsIsPreRelease) {\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","import { resolve } from \"node:path\";\nimport { writeFileSync, readFileSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\n/**\n * Matches the following changelog header formats:\n * - `## [1.2.3]`\n * - `<a name=\"1.2.3\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Get the existing changelog content from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(filePath: string, exists: boolean): string {\n\tif (exists) {\n\t\tconst fileContents = readFileSync(filePath, \"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\n/**\n * Generate the new changelog content for this release.\n */\nfunction getNewReleaseContent(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<string> {\n\treturn new Promise<string>((onResolve) => {\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...config.changelogPresetConfig,\n\t\t\t\t},\n\t\t\t\ttagPrefix: config.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => logger.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: config.path,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: config.path,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\tlogger.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\tonResolve(newContent);\n\t\t\t});\n\t});\n}\n\ninterface UpdateChangelog {\n\tchangelogPath: string;\n\toldContent: string;\n\tnewContent: string;\n}\n\nexport async function updateChangelog(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<UpdateChangelog> {\n\tif (config.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\t// Create the changelog file if it doesn't exist\n\tconst changelogPath = resolve(config.path, config.changelog);\n\tif (!config.dryRun && !fileExists(changelogPath)) {\n\t\tlogger.log(`Creating Changelog file: ${changelogPath}`);\n\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t}\n\n\tconst oldContent = getOldReleaseContent(changelogPath, fileExists(changelogPath));\n\tconst newContent = await getNewReleaseContent(config, logger, nextVersion);\n\n\tlogger.log(`Updating Changelog: ${changelogPath}`);\n\tif (!config.dryRun && newContent) {\n\t\twriteFileSync(\n\t\t\tchangelogPath,\n\t\t\t`${config.header}\n${newContent}\n${oldContent}\n`.trim(),\n\t\t\t\"utf8\",\n\t\t);\n\t}\n\n\treturn {\n\t\tchangelogPath,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { lstatSync } from \"fs\";\n\n/**\n * Determine if a file exists.\n * @example\n * ```ts\n * fileExists(\"~/.bashrc\"); // true\n * fileExists(\"~/missing-file.txt\"); // false\n * ```\n */\nexport function fileExists(filePath: string): boolean {\n\ttry {\n\t\treturn lstatSync(filePath).isFile();\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n","import { resolve } from \"node:path\";\nimport { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface CommitChanges {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n}\n\nexport async function commitChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfiles: FileState[],\n\tnextVersion: string,\n): Promise<CommitChanges> {\n\tconst git = new Git(config, logger);\n\n\tlogger.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [];\n\tif (fileExists(resolve(config.path, config.changelog))) {\n\t\tfilesToCommit.push(resolve(config.path, config.changelog));\n\t}\n\tfor (const file of files) {\n\t\tfilesToCommit.push(file.path);\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 shouldVerify = config.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = config.sign ? \"--gpg-sign\" : undefined;\n\n\t// If commitAll is set, commit all changed files.\n\tif (config.commitAll) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t\tgitAddOutput: await git.add(\"--all\"),\n\t\t\tgitCommitOutput: await git.commit(\n\t\t\t\tshouldVerify,\n\t\t\t\tshouldSign,\n\t\t\t\t\"--message\",\n\t\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t\t),\n\t\t};\n\t}\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput: await git.add(...filesToCommit),\n\t\tgitCommitOutput: await git.commit(\n\t\t\tshouldVerify,\n\t\t\tshouldSign,\n\t\t\t...filesToCommit,\n\t\t\t\"--message\",\n\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t),\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"./logger\";\n\nexport class Git {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.add = this.add.bind(this);\n\t\tthis.commit = this.commit.bind(this);\n\t\tthis.tag = this.tag.bind(this);\n\t\tthis.revParse = this.revParse.bind(this);\n\t}\n\n\tpublic add(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"add\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic commit(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"commit\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic tag(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"tag\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic revParse(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"rev-parse\", args.filter(Boolean) as string[]);\n\t}\n\n\tprivate execGit(command: string, args: string[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn Promise.resolve(\"\");\n\t\t}\n\n\t\tthis.logger.debug(`Executing: git ${command} ${args.join(\" \")}`);\n\t\treturn new Promise((onResolve, onReject) => {\n\t\t\texecFile(\n\t\t\t\t\"git\",\n\t\t\t\t[command, ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd: this.config.path,\n\t\t\t\t},\n\t\t\t\t(error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthis.logger.error(`git ${command}:`);\n\t\t\t\t\t\tonReject(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tonResolve(stdout ? stdout : stderr);\n\t\t\t\t},\n\t\t\t);\n\t\t});\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, version: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), version);\n}\n","import { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface TagChanges {\n\tgitTagOutput: string;\n}\n\nexport async function tagChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<TagChanges> {\n\tconst git = new Git(config, logger);\n\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${config.tagPrefix}${nextVersion}`;\n\n\tlogger.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await git.tag(\n\t\tconfig.sign ? \"--sign\" : \"--annotate\",\n\t\ttag,\n\t\t\"--message\",\n\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t);\n\n\treturn {\n\t\tgitTagOutput,\n\t};\n}\n","import { resolve } from \"node:path\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport detectIndent from \"detect-indent\";\nimport { detectNewline } from \"detect-newline\";\n\nimport { stringifyPackage } from \"../libs/stringify-package\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A json package file should have a version property, like what can be seen\n * in the package.json file in the root of this project.\n *\n * @example\n * ```json\n * {\n * \"name\": \"fork-version\",\n * \"version\": \"1.2.3\",\n * \"private\": true,\n * }\n * ```\n */\nexport class JSONPackage implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tif (parsedJson.version) {\n\t\t\t\treturn {\n\t\t\t\t\tname: fileName,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t\tversion: parsedJson.version,\n\n\t\t\t\t\tisPrivate: typeof parsedJson?.private === \"boolean\" ? parsedJson.private : true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.logger.warn(`Unable to determine json package file: ${fileName}`);\n\t\t}\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\tparsedJson.version = newVersion;\n\t\tif (parsedJson.packages?.[\"\"]) {\n\t\t\tparsedJson.packages[\"\"].version = newVersion; // package-lock v2 stores version here too.\n\t\t}\n\n\t\twriteFileSync(\n\t\t\tfilePath,\n\t\t\tstringifyPackage(parsedJson, detectIndent(fileContents).amount, detectNewline(fileContents)),\n\t\t\t\"utf8\",\n\t\t);\n\t}\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\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\n/**\n * @param data The object to stringify\n * @param indent `2, 4, \" \", \"\\t\"` Number of spaces a string of spaces or tab character, defaults to 2\n * @param newline `\"\\r\\n\", \"\\n\"` Windows or Unix line endings, defaults to Unix\n */\nexport function stringifyPackage(\n\tdata: object,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent ?? 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 { readFileSync, writeFileSync } from \"node:fs\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A plain text file will have just the version as the content.\n *\n * @example\n * ```txt\n * 1.2.3\n * ```\n */\nexport class PlainText implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\n\t\t\treturn {\n\t\t\t\tname: fileName,\n\t\t\t\tpath: filePath,\n\t\t\t\tversion: fileContents || \"\",\n\t\t\t};\n\t\t}\n\n\t\tthis.logger.warn(`Unable to determine plain text file: ${fileName}`);\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\twriteFileSync(filePath, newVersion, \"utf8\");\n\t}\n}\n","import { JSONPackage } from \"./json-package\";\nimport { PlainText } from \"./plain-text\";\n\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface FileState {\n\tname: string;\n\tpath: string;\n\tversion: string;\n\n\t[other: string]: unknown;\n}\n\nexport interface IFileManager {\n\tread(fileName: string): FileState | undefined;\n\twrite(filePath: string, newVersion: string): void;\n}\n\nexport class FileManager implements IFileManager {\n\tprivate JSONPackage: JSONPackage;\n\tprivate PlainText: PlainText;\n\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.JSONPackage = new JSONPackage(config, logger);\n\t\tthis.PlainText = new PlainText(config, logger);\n\t}\n\n\t/**\n\t * Get the state from the given file name.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.read(\"package.json\");\n\t * ```\n\t *\n\t * @returns\n\t * ```json\n\t * { \"name\": \"package.json\", \"path\": \"/path/to/package.json\", \"version\": \"1.2.3\", \"isPrivate\": true }\n\t * ```\n\t */\n\tpublic read(fileName: string): FileState | undefined {\n\t\tif (fileName.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.read(fileName);\n\t\t} else if (fileName.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.read(fileName);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${fileName}`);\n\t}\n\n\t/**\n\t * Write the new version to the given file path.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.write(\"/path/to/package.json\", \"1.2.3\");\n\t * ```\n\t */\n\tpublic write(filePath: string, newVersion: string): void {\n\t\tif (this.config.dryRun) {\n\t\t\tthis.logger.log(`[Dry run]: Not updating ${filePath}`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (filePath.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.write(filePath, newVersion);\n\t\t} else if (filePath.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.write(filePath, newVersion);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${filePath}`);\n\t}\n}\n"]}
package/dist/cli.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var chunkUJKGEPR3_cjs = require('./chunk-UJKGEPR3.cjs');
4
+ var chunkOMTZL56J_cjs = require('./chunk-OMTZL56J.cjs');
5
5
 
6
6
  // src/utils/logger.ts
7
7
  var Logger = class {
@@ -38,7 +38,7 @@ var Logger = class {
38
38
 
39
39
  // src/process/message.ts
40
40
  async function completedMessage(config, logger, files, releaseType) {
41
- const git = new chunkUJKGEPR3_cjs.Git(config, logger);
41
+ const git = new chunkOMTZL56J_cjs.Git(config, logger);
42
42
  const branchName = (await git.revParse("--abbrev-ref", "HEAD")).trim();
43
43
  logger.log(
44
44
  `Run \`git push --follow-tags origin ${branchName}\` to push the changes and the tag.`
@@ -53,21 +53,21 @@ async function completedMessage(config, logger, files, releaseType) {
53
53
 
54
54
  // src/cli.ts
55
55
  async function runFork() {
56
- const config = await chunkUJKGEPR3_cjs.getUserConfig();
56
+ const config = await chunkOMTZL56J_cjs.getUserConfig();
57
57
  const logger = new Logger(config);
58
- const fileManager = new chunkUJKGEPR3_cjs.FileManager(config, logger);
58
+ const fileManager = new chunkOMTZL56J_cjs.FileManager(config, logger);
59
59
  logger.log(`Running Fork: ${(/* @__PURE__ */ new Date()).toLocaleString()}`);
60
60
  logger.log(config.dryRun ? "Dry run, no changes will be written to disk.\n" : "");
61
- const current = await chunkUJKGEPR3_cjs.getCurrentVersion(config, logger, fileManager);
62
- const next = await chunkUJKGEPR3_cjs.getNextVersion(config, logger, current.version);
61
+ const current = await chunkOMTZL56J_cjs.getCurrentVersion(config, logger, fileManager);
62
+ const next = await chunkOMTZL56J_cjs.getNextVersion(config, logger, current.version);
63
63
  logger.log("Updating Files: ");
64
64
  for (const outFile of current.files) {
65
65
  logger.log(` ${outFile.path}`);
66
66
  fileManager.write(outFile.path, next.version);
67
67
  }
68
- const changelogResult = await chunkUJKGEPR3_cjs.updateChangelog(config, logger, next.version);
69
- const commitResult = await chunkUJKGEPR3_cjs.commitChanges(config, logger, current.files, next.version);
70
- const tagResult = await chunkUJKGEPR3_cjs.tagChanges(config, logger, next.version);
68
+ const changelogResult = await chunkOMTZL56J_cjs.updateChangelog(config, logger, next.version);
69
+ const commitResult = await chunkOMTZL56J_cjs.commitChanges(config, logger, current.files, next.version);
70
+ const tagResult = await chunkOMTZL56J_cjs.tagChanges(config, logger, next.version);
71
71
  completedMessage(config, logger, current.files, next.releaseType);
72
72
  const result = {
73
73
  config,
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { getUserConfig, FileManager, getCurrentVersion, getNextVersion, updateChangelog, commitChanges, tagChanges, Git } from './chunk-S2VPLFG2.js';
2
+ import { getUserConfig, FileManager, getCurrentVersion, getNextVersion, updateChangelog, commitChanges, tagChanges, Git } from './chunk-NKEO7YFB.js';
3
3
 
4
4
  // src/utils/logger.ts
5
5
  var Logger = class {
package/dist/index.cjs CHANGED
@@ -1,44 +1,44 @@
1
1
  'use strict';
2
2
 
3
- var chunkUJKGEPR3_cjs = require('./chunk-UJKGEPR3.cjs');
3
+ var chunkOMTZL56J_cjs = require('./chunk-OMTZL56J.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "FileManager", {
8
8
  enumerable: true,
9
- get: function () { return chunkUJKGEPR3_cjs.FileManager; }
9
+ get: function () { return chunkOMTZL56J_cjs.FileManager; }
10
10
  });
11
11
  Object.defineProperty(exports, "ForkConfigSchema", {
12
12
  enumerable: true,
13
- get: function () { return chunkUJKGEPR3_cjs.ForkConfigSchema; }
13
+ get: function () { return chunkOMTZL56J_cjs.ForkConfigSchema; }
14
14
  });
15
15
  Object.defineProperty(exports, "commitChanges", {
16
16
  enumerable: true,
17
- get: function () { return chunkUJKGEPR3_cjs.commitChanges; }
17
+ get: function () { return chunkOMTZL56J_cjs.commitChanges; }
18
18
  });
19
19
  Object.defineProperty(exports, "defineConfig", {
20
20
  enumerable: true,
21
- get: function () { return chunkUJKGEPR3_cjs.defineConfig; }
21
+ get: function () { return chunkOMTZL56J_cjs.defineConfig; }
22
22
  });
23
23
  Object.defineProperty(exports, "getCurrentVersion", {
24
24
  enumerable: true,
25
- get: function () { return chunkUJKGEPR3_cjs.getCurrentVersion; }
25
+ get: function () { return chunkOMTZL56J_cjs.getCurrentVersion; }
26
26
  });
27
27
  Object.defineProperty(exports, "getNextVersion", {
28
28
  enumerable: true,
29
- get: function () { return chunkUJKGEPR3_cjs.getNextVersion; }
29
+ get: function () { return chunkOMTZL56J_cjs.getNextVersion; }
30
30
  });
31
31
  Object.defineProperty(exports, "getUserConfig", {
32
32
  enumerable: true,
33
- get: function () { return chunkUJKGEPR3_cjs.getUserConfig; }
33
+ get: function () { return chunkOMTZL56J_cjs.getUserConfig; }
34
34
  });
35
35
  Object.defineProperty(exports, "tagChanges", {
36
36
  enumerable: true,
37
- get: function () { return chunkUJKGEPR3_cjs.tagChanges; }
37
+ get: function () { return chunkOMTZL56J_cjs.tagChanges; }
38
38
  });
39
39
  Object.defineProperty(exports, "updateChangelog", {
40
40
  enumerable: true,
41
- get: function () { return chunkUJKGEPR3_cjs.updateChangelog; }
41
+ get: function () { return chunkOMTZL56J_cjs.updateChangelog; }
42
42
  });
43
43
  //# sourceMappingURL=out.js.map
44
44
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { FileManager, ForkConfigSchema, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog } from './chunk-S2VPLFG2.js';
1
+ export { FileManager, ForkConfigSchema, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog } from './chunk-NKEO7YFB.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.48",
3
+ "version": "1.4.50",
4
4
  "license": "ISC",
5
5
  "description": "Replacement for standard version written with modern syntax",
6
6
  "homepage": "https://github.com/eglavin/fork-version",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/config/schema.ts","../src/config/user-config.ts","../src/config/defaults.ts","../src/config/cli-arguments.ts","../src/config/changelog-preset-config.ts","../src/process/version.ts","../src/utils/git-tag-version.ts","../src/utils/release-type.ts","../src/process/changelog.ts","../src/utils/file-state.ts","../src/process/commit.ts","../src/utils/git.ts","../src/utils/format-commit-message.ts","../src/process/tag.ts","../src/strategies/json-package.ts","../src/libs/stringify-package.ts","../src/strategies/plain-text.ts","../src/strategies/file-manager.ts"],"names":["semver","resolve","readFileSync","writeFileSync"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,8BAA8B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnD,OAAO,EAAE;AAAA,IACR,EAAE,OAAO;AAAA,MACR,MAAM,EAAE,OAAO;AAAA,MACf,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,MAC7B,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,IAC9B,CAAC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1B,kBAAkB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3B,gBAAgB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMzB,eAAe,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,4BAA4B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC;AAClC,CAAC;AAIM,IAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxC,MAAM,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKf,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUpB,QAAQ,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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;AAAA,MAC1B;AAAA,IACD;AAEA,SAAK,OAAO,KAAK,wCAAwC,QAAQ,EAAE;AAAA,EACpE;AAAA,EAEO,MAAM,UAAkB,YAAoB;AAClD,IAAAC,eAAc,UAAU,YAAY,MAAM;AAAA,EAC3C;AACD;;;ACtBO,IAAM,cAAN,MAA0C;AAAA,EAIhD,YACS,QACA,QACP;AAFO;AACA;AAER,SAAK,cAAc,IAAI,YAAY,QAAQ,MAAM;AACjD,SAAK,YAAY,IAAI,UAAU,QAAQ,MAAM;AAAA,EAC9C;AAAA,EATQ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBD,KAAK,UAAyC;AACpD,QAAI,SAAS,YAAY,EAAE,SAAS,OAAO,GAAG;AAC7C,aAAO,KAAK,YAAY,KAAK,QAAQ;AAAA,IACtC,WAAW,SAAS,YAAY,EAAE,SAAS,aAAa,GAAG;AAC1D,aAAO,KAAK,UAAU,KAAK,QAAQ;AAAA,IACpC;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUO,MAAM,UAAkB,YAA0B;AACxD,QAAI,KAAK,OAAO,QAAQ;AACvB,WAAK,OAAO,IAAI,2BAA2B,QAAQ,EAAE;AACrD;AAAA,IACD;AAEA,QAAI,SAAS,YAAY,EAAE,SAAS,OAAO,GAAG;AAC7C,aAAO,KAAK,YAAY,MAAM,UAAU,UAAU;AAAA,IACnD,WAAW,SAAS,YAAY,EAAE,SAAS,aAAa,GAAG;AAC1D,aAAO,KAAK,UAAU,MAAM,UAAU,UAAU;AAAA,IACjD;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AACD","sourcesContent":["import { z } from \"zod\";\n\nexport const ChangelogPresetConfigSchema = z.object({\n\t/**\n\t * An array of `type` objects representing the explicitly supported commit message types,\n\t * and whether they should show up in generated `CHANGELOG`s.\n\t */\n\ttypes: z.array(\n\t\tz.object({\n\t\t\ttype: z.string(),\n\t\t\tsection: z.string().optional(),\n\t\t\thidden: z.boolean().optional(),\n\t\t}),\n\t),\n\t/**\n\t * A URL representing a specific commit at a hash.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/commit/{{hash}}\"\n\t */\n\tcommitUrlFormat: z.string(),\n\t/**\n\t * A URL representing the comparison between two git SHAs.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}\"\n\t */\n\tcompareUrlFormat: z.string(),\n\t/**\n\t * A URL representing the issue format (allowing a different URL format to be swapped in\n\t * for Gitlab, Bitbucket, etc).\n\t * @default \"{{host}}/{{owner}}/{{repository}}/issues/{{id}}\"\n\t */\n\tissueUrlFormat: z.string(),\n\t/**\n\t * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used\n\t * for substituting @bcoe with https://github.com/bcoe in commit messages.\n\t * @default \"{{host}}/{{user}}\"\n\t */\n\tuserUrlFormat: z.string(),\n\t/**\n\t * A string to be used to format the auto-generated release commit message.\n\t * @default \"chore(release): {{currentTag}}\"\n\t */\n\treleaseCommitMessageFormat: z.string(),\n\t/**\n\t * An array of prefixes used to detect references to issues\n\t * @default [\"#\"]\n\t */\n\tissuePrefixes: z.array(z.string()),\n});\n\nexport type ChangelogPresetConfig = z.infer<typeof ChangelogPresetConfigSchema>;\n\nexport const ForkConfigSchema = z.object({\n\t/**\n\t * The path fork-version will run from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tpath: z.string(),\n\t/**\n\t * Name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: 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 * 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\tfiles: z.array(z.string()),\n\t/**\n\t * Specify a prefix for the git tag fork-version will create.\n\t *\n\t * For instance if your version tag is prefixed by \"version/\" instead of \"v\" you have to specify\n\t * `tagPrefix: \"version/\"`.\n\t *\n\t * `tagPrefix` can also be used for a monorepo environment where you might want to deploy\n\t * multiple package from the same repository. In this case you can specify a prefix for\n\t * each package:\n\t *\n\t * | Value | Tag Created |\n\t * |:-------------------------|:------------------------------|\n\t * | \"\" | `1.2.3` |\n\t * | \"version/\" | `version/1.2.3` |\n\t * | \"@eglavin/fork-version-\" | `@eglavin/fork-version-1.2.3` |\n\t *\n\t * @example \"\", \"version/\", \"@eglavin/fork-version-\"\n\t * @default \"v\"\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label, if value is a string it will be used as the\n\t * pre-release tag.\n\t *\n\t * | Value | Version |\n\t * |:----------|:----------------|\n\t * | true | \"1.2.3-0\" |\n\t * | \"alpha\" | \"1.2.3-alpha-0\" |\n\t * | \"beta\" | \"1.2.3-beta-0\" |\n\t *\n\t * @example true, \"alpha\", \"beta\", \"rc\"\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 set we'll log debug information.\n\t * @default false\n\t */\n\tdebug: 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 the list of `files`, we'll fallback\n\t * and attempt to use the latest git tag to get the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * If set, we'll gather information about the current version and exit.\n\t * @default false\n\t */\n\tinspectVersion: 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 a version from the list of `files`.\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, instead of incrementing\n\t * using \"conventional-commit\".\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: ChangelogPresetConfigSchema.partial(),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema>;\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\treturn config;\n}\n","import { parse, resolve } from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\n\nimport { ForkConfigSchema, type ForkConfig } from \"./schema\";\nimport { DEFAULT_CONFIG } from \"./defaults\";\nimport { getCliArguments } from \"./cli-arguments\";\nimport { getChangelogPresetConfig } from \"./changelog-preset-config\";\n\nexport async function getUserConfig(): Promise<ForkConfig> {\n\tconst cliArguments = getCliArguments();\n\n\tconst cwd = cliArguments.flags.path ? resolve(cliArguments.flags.path) : process.cwd();\n\tconst joycon = new JoyCon();\n\tconst configFilePath = await joycon.resolve({\n\t\tfiles: [\"fork.config.ts\", \"fork.config.js\", \"fork.config.cjs\", \"fork.config.mjs\"],\n\t\tcwd,\n\t\tstopDir: parse(cwd).root,\n\t});\n\n\tif (!configFilePath) {\n\t\treturn {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...cliArguments.flags,\n\t\t\tpath: cwd,\n\t\t\tchangelogPresetConfig: getChangelogPresetConfig(),\n\t\t} as ForkConfig;\n\t}\n\n\tconst foundConfig = await bundleRequire({ filepath: configFilePath });\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\tfoundConfig.mod.default || foundConfig.mod,\n\t);\n\n\tif (!parsedConfig.success) {\n\t\tthrow parsedConfig.error;\n\t}\n\n\tconst usersConfig = {\n\t\t...DEFAULT_CONFIG,\n\t\t...parsedConfig.data,\n\t\t...cliArguments.flags,\n\t} as ForkConfig;\n\n\tconst files = mergeFiles(parsedConfig.data?.files, cliArguments.flags?.files);\n\n\treturn {\n\t\t...usersConfig,\n\t\tpath: cwd,\n\t\tfiles: files.length > 0 ? files : DEFAULT_CONFIG.files,\n\t\tchangelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig),\n\t};\n}\n\nfunction mergeFiles(configFiles: string[] | undefined, cliFiles: string[] | undefined): string[] {\n\treturn Array.from(\n\t\tnew Set(\n\t\t\t([] as string[]).concat(\n\t\t\t\tArray.isArray(configFiles) ? configFiles : [],\n\t\t\t\tArray.isArray(cliFiles) ? cliFiles : [],\n\t\t\t),\n\t\t),\n\t);\n}\n","import type { ForkConfig } from \"./schema\";\n\nexport const DEFAULT_CONFIG: ForkConfig = {\n\tpath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\tfiles: [\n\t\t\"package.json\",\n\t\t\"package-lock.json\",\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"bower.json\",\n\t],\n\theader: `# 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\tdebug: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tinspectVersion: false,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n};\n","import meow from \"meow\";\n\nexport function getCliArguments() {\n\treturn meow(\n\t\t`\nUsage:\n $ fork-version [options]\n\nOptions:\n --path [Default: process.cwd()]\n The path fork-version will run from.\n --changelog [Default: \"CHANGELOG.md\"]\n Name of the changelog file.\n --header, -H\n The header to be used in the changelog.\n --files, --file, -F [Default: [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]]\n Files to be updated.\n --tag-prefix [Default: \"v\"]\n Specify a prefix for the git tag \"fork-version\" will create.\n --pre-release-tag [Default: undefined]\n Make a pre-release with optional label, If value is a string it\n will be used as the pre-release tag.\n\n --commit-all\n Commit all staged changes, not just files updated by fork-version.\n --debug\n If true, we'll output debug information.\n --dry-run\n If true, no output will be written to disk or committed.\n --git-tag-fallback [Default: true]\n If true and we cant find a version in the given files, we'll fallback\n and attempt to use the latest git tag for the current version.\n --inspect-version\n If set, we'll gather information about the current version and exit.\n --sign\n Should we sign the git commit using GPG?\n --silent\n If true, no output will be written to stdout.\n --verify\n If true, allow git to run git commit hooks.\n\n --current-version\n If set, we'll use this version number instead of trying to find a\n version in a \"file\".\n --next-version\n If set, we'll attempt to update the version number to this version,\n instead of incrementing using \"conventional-commit\".\n`,\n\t\t{\n\t\t\timportMeta: import.meta,\n\t\t\tflags: {\n\t\t\t\tpath: { type: \"string\", default: process.cwd() },\n\t\t\t\tchangelog: { type: \"string\" },\n\t\t\t\theader: { type: \"string\", shortFlag: \"H\" },\n\t\t\t\tfiles: { type: \"string\", isMultiple: true, aliases: [\"file\"], shortFlag: \"F\" },\n\t\t\t\ttagPrefix: { type: \"string\" },\n\t\t\t\tpreReleaseTag: { type: \"string\" },\n\n\t\t\t\tcommitAll: { type: \"boolean\" },\n\t\t\t\tdebug: { type: \"boolean\" },\n\t\t\t\tdryRun: { type: \"boolean\" },\n\t\t\t\tgitTagFallback: { type: \"boolean\" },\n\t\t\t\tinspectVersion: { type: \"boolean\" },\n\t\t\t\tsign: { type: \"boolean\" },\n\t\t\t\tsilent: { type: \"boolean\" },\n\t\t\t\tverify: { type: \"boolean\" },\n\n\t\t\t\tcurrentVersion: { type: \"string\" },\n\t\t\t\tnextVersion: { type: \"string\" },\n\t\t\t},\n\t\t},\n\t);\n}\n","import conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\n\nimport { ChangelogPresetConfigSchema, type ForkConfig } from \"./schema\";\n\nexport function getChangelogPresetConfig(\n\tusersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"],\n) {\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\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 ChangelogPresetConfigSchema.passthrough().parse(preset);\n}\n","import semver, { type ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\n\nimport { getLatestGitTagVersion } from \"../utils/git-tag-version\";\nimport { getReleaseType } from \"../utils/release-type\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { IFileManager, FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface CurrentVersion {\n\tversion: string;\n\tfiles: FileState[];\n}\n\nexport async function getCurrentVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfileManager: IFileManager,\n): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions = new Set<string>();\n\n\tfor (const file of config.files) {\n\t\tconst fileState = fileManager.read(file);\n\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (config.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tversions.add(fileState.version);\n\t\t}\n\t}\n\n\tif (config.currentVersion) {\n\t\tversions.add(config.currentVersion);\n\t}\n\n\tif (versions.size === 0) {\n\t\tif (config.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(config.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tversion: 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.size > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\tconst currentVersion = versions.entries().next().value[0];\n\n\t// If we're just inspecting the version, output the version and exit\n\tif (config.inspectVersion) {\n\t\tconsole.log(currentVersion);\n\t\tprocess.exit(0);\n\t}\n\n\tlogger.log(`Current version: ${currentVersion}`);\n\treturn {\n\t\tfiles,\n\t\tversion: currentVersion,\n\t};\n}\n\nexport interface NextVersion {\n\tversion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n}\n\nexport async function getNextVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tcurrentVersion: string,\n): Promise<NextVersion> {\n\tif (config.nextVersion && semver.valid(config.nextVersion)) {\n\t\tlogger.log(`Next version: ${config.nextVersion}`);\n\t\treturn { version: config.nextVersion };\n\t}\n\n\tconst isPreMajor = semver.lt(currentVersion, \"1.0.0\");\n\n\tlet recommendedBump: Awaited<ReturnType<typeof conventionalRecommendedBump>>;\n\ttry {\n\t\trecommendedBump = await conventionalRecommendedBump({\n\t\t\tpreset: {\n\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t...config.changelogPresetConfig,\n\t\t\t\tpreMajor: isPreMajor,\n\t\t\t},\n\t\t\tpath: config.path,\n\t\t\ttagPrefix: config.tagPrefix,\n\t\t\tcwd: config.path,\n\t\t});\n\t} catch (error) {\n\t\tthrow new Error(`[conventional-recommended-bump] Unable to determine next version`);\n\t}\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\tconfig.preReleaseTag,\n\t\t);\n\n\t\tconst state: NextVersion = {\n\t\t\t...recommendedBump,\n\t\t\tpreMajor: isPreMajor,\n\t\t\treleaseType,\n\t\t\tversion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof config.preReleaseTag === \"string\" ? config.preReleaseTag : undefined,\n\t\t\t\t) ?? \"\",\n\t\t};\n\n\t\tlogger.log(`Next version: ${state.version} (${state.releaseType})`);\n\t\treturn state;\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n","import gitSemverTags from \"git-semver-tags\";\nimport semver from \"semver\";\n\n/**\n * Get the latest git tag version.\n *\n * @example\n * ```ts\n * const tagPrefix = \"v\";\n * await getLatestGitTagVersion(tagPrefix); // 1.2.3\n * ```\n */\nexport async 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","import semver, { type ReleaseType } from \"semver\";\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\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\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 * ```js\n * getReleaseType(\"patch\", \"1.0.0\", false) => \"patch\"\n * getReleaseType(\"major\", \"0.0.0-beta\", \"beta\") => \"premajor\"\n * ```\n */\nexport function 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\tconst currentVersionsIsPreRelease = Array.isArray(semver.prerelease(currentVersion));\n\tif (currentVersionsIsPreRelease) {\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","import { resolve } from \"node:path\";\nimport { writeFileSync, readFileSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\n/**\n * Matches the following changelog header formats:\n * - `## [1.2.3]`\n * - `<a name=\"1.2.3\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Get the existing changelog content from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(filePath: string, exists: boolean): string {\n\tif (exists) {\n\t\tconst fileContents = readFileSync(filePath, \"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\n/**\n * Generate the new changelog content for this release.\n */\nfunction getNewReleaseContent(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<string> {\n\treturn new Promise<string>((onResolve) => {\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...config.changelogPresetConfig,\n\t\t\t\t},\n\t\t\t\ttagPrefix: config.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => logger.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: config.path,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: config.path,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\tlogger.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\tonResolve(newContent);\n\t\t\t});\n\t});\n}\n\ninterface UpdateChangelog {\n\tchangelogPath: string;\n\toldContent: string;\n\tnewContent: string;\n}\n\nexport async function updateChangelog(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<UpdateChangelog> {\n\tif (config.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\t// Create the changelog file if it doesn't exist\n\tconst changelogPath = resolve(config.path, config.changelog);\n\tif (!config.dryRun && !fileExists(changelogPath)) {\n\t\tlogger.log(`Creating Changelog file: ${changelogPath}`);\n\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t}\n\n\tconst oldContent = getOldReleaseContent(changelogPath, fileExists(changelogPath));\n\tconst newContent = await getNewReleaseContent(config, logger, nextVersion);\n\n\tlogger.log(`Updating Changelog: ${changelogPath}`);\n\tif (!config.dryRun && newContent) {\n\t\twriteFileSync(\n\t\t\tchangelogPath,\n\t\t\t`${config.header}\n${newContent}\n${oldContent}\n`,\n\t\t\t\"utf8\",\n\t\t);\n\t}\n\n\treturn {\n\t\tchangelogPath,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { lstatSync } from \"fs\";\n\n/**\n * Determine if a file exists.\n * @example\n * ```ts\n * fileExists(\"~/.bashrc\"); // true\n * fileExists(\"~/missing-file.txt\"); // false\n * ```\n */\nexport function fileExists(filePath: string): boolean {\n\ttry {\n\t\treturn lstatSync(filePath).isFile();\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n","import { resolve } from \"node:path\";\nimport { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface CommitChanges {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n}\n\nexport async function commitChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfiles: FileState[],\n\tnextVersion: string,\n): Promise<CommitChanges> {\n\tconst git = new Git(config, logger);\n\n\tlogger.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [];\n\tif (fileExists(resolve(config.path, config.changelog))) {\n\t\tfilesToCommit.push(resolve(config.path, config.changelog));\n\t}\n\tfor (const file of files) {\n\t\tfilesToCommit.push(file.path);\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 shouldVerify = config.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = config.sign ? \"--gpg-sign\" : undefined;\n\n\t// If commitAll is set, commit all changed files.\n\tif (config.commitAll) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t\tgitAddOutput: await git.add(\"--all\"),\n\t\t\tgitCommitOutput: await git.commit(\n\t\t\t\tshouldVerify,\n\t\t\t\tshouldSign,\n\t\t\t\t\"--message\",\n\t\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t\t),\n\t\t};\n\t}\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput: await git.add(...filesToCommit),\n\t\tgitCommitOutput: await git.commit(\n\t\t\tshouldVerify,\n\t\t\tshouldSign,\n\t\t\t...filesToCommit,\n\t\t\t\"--message\",\n\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t),\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"./logger\";\n\nexport class Git {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.add = this.add.bind(this);\n\t\tthis.commit = this.commit.bind(this);\n\t\tthis.tag = this.tag.bind(this);\n\t\tthis.revParse = this.revParse.bind(this);\n\t}\n\n\tpublic add(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"add\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic commit(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"commit\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic tag(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"tag\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic revParse(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"rev-parse\", args.filter(Boolean) as string[]);\n\t}\n\n\tprivate execGit(command: string, args: string[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn Promise.resolve(\"\");\n\t\t}\n\n\t\tthis.logger.debug(`Executing: git ${command} ${args.join(\" \")}`);\n\t\treturn new Promise((onResolve, onReject) => {\n\t\t\texecFile(\n\t\t\t\t\"git\",\n\t\t\t\t[command, ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd: this.config.path,\n\t\t\t\t},\n\t\t\t\t(error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthis.logger.error(`git ${command}:`);\n\t\t\t\t\t\tonReject(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tonResolve(stdout ? stdout : stderr);\n\t\t\t\t},\n\t\t\t);\n\t\t});\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, version: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), version);\n}\n","import { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface TagChanges {\n\tgitTagOutput: string;\n}\n\nexport async function tagChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<TagChanges> {\n\tconst git = new Git(config, logger);\n\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${config.tagPrefix}${nextVersion}`;\n\n\tlogger.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await git.tag(\n\t\tconfig.sign ? \"--sign\" : \"--annotate\",\n\t\ttag,\n\t\t\"--message\",\n\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t);\n\n\treturn {\n\t\tgitTagOutput,\n\t};\n}\n","import { resolve } from \"node:path\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport detectIndent from \"detect-indent\";\nimport { detectNewline } from \"detect-newline\";\n\nimport { stringifyPackage } from \"../libs/stringify-package\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A json package file should have a version property, like what can be seen\n * in the package.json file in the root of this project.\n *\n * @example\n * ```json\n * {\n * \"name\": \"fork-version\",\n * \"version\": \"1.2.3\",\n * \"private\": true,\n * }\n * ```\n */\nexport class JSONPackage implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tif (parsedJson.version) {\n\t\t\t\treturn {\n\t\t\t\t\tname: fileName,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t\tversion: parsedJson.version,\n\n\t\t\t\t\tisPrivate: typeof parsedJson?.private === \"boolean\" ? parsedJson.private : true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.logger.warn(`Unable to determine json package file: ${fileName}`);\n\t\t}\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\tparsedJson.version = newVersion;\n\t\tif (parsedJson.packages?.[\"\"]) {\n\t\t\tparsedJson.packages[\"\"].version = newVersion; // package-lock v2 stores version here too.\n\t\t}\n\n\t\twriteFileSync(\n\t\t\tfilePath,\n\t\t\tstringifyPackage(parsedJson, detectIndent(fileContents).amount, detectNewline(fileContents)),\n\t\t\t\"utf8\",\n\t\t);\n\t}\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\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\n/**\n * @param data The object to stringify\n * @param indent `2, 4, \" \", \"\\t\"` Number of spaces a string of spaces or tab character, defaults to 2\n * @param newline `\"\\r\\n\", \"\\n\"` Windows or Unix line endings, defaults to Unix\n */\nexport function stringifyPackage(\n\tdata: object,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent ?? 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 { readFileSync, writeFileSync } from \"node:fs\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A plain text file will have just the version as the content.\n *\n * @example\n * ```txt\n * 1.2.3\n * ```\n */\nexport class PlainText implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\n\t\t\treturn {\n\t\t\t\tname: fileName,\n\t\t\t\tpath: filePath,\n\t\t\t\tversion: fileContents || \"\",\n\t\t\t};\n\t\t}\n\n\t\tthis.logger.warn(`Unable to determine plain text file: ${fileName}`);\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\twriteFileSync(filePath, newVersion, \"utf8\");\n\t}\n}\n","import { JSONPackage } from \"./json-package\";\nimport { PlainText } from \"./plain-text\";\n\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface FileState {\n\tname: string;\n\tpath: string;\n\tversion: string;\n\n\t[other: string]: unknown;\n}\n\nexport interface IFileManager {\n\tread(fileName: string): FileState | undefined;\n\twrite(filePath: string, newVersion: string): void;\n}\n\nexport class FileManager implements IFileManager {\n\tprivate JSONPackage: JSONPackage;\n\tprivate PlainText: PlainText;\n\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.JSONPackage = new JSONPackage(config, logger);\n\t\tthis.PlainText = new PlainText(config, logger);\n\t}\n\n\t/**\n\t * Get the state from the given file name.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.read(\"package.json\");\n\t * ```\n\t *\n\t * @returns\n\t * ```json\n\t * { \"name\": \"package.json\", \"path\": \"/path/to/package.json\", \"version\": \"1.2.3\", \"isPrivate\": true }\n\t * ```\n\t */\n\tpublic read(fileName: string): FileState | undefined {\n\t\tif (fileName.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.read(fileName);\n\t\t} else if (fileName.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.read(fileName);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${fileName}`);\n\t}\n\n\t/**\n\t * Write the new version to the given file path.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.write(\"/path/to/package.json\", \"1.2.3\");\n\t * ```\n\t */\n\tpublic write(filePath: string, newVersion: string): void {\n\t\tif (this.config.dryRun) {\n\t\t\tthis.logger.log(`[Dry run]: Not updating ${filePath}`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (filePath.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.write(filePath, newVersion);\n\t\t} else if (filePath.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.write(filePath, newVersion);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${filePath}`);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/config/schema.ts","../src/config/user-config.ts","../src/config/defaults.ts","../src/config/cli-arguments.ts","../src/config/changelog-preset-config.ts","../src/process/version.ts","../src/utils/git-tag-version.ts","../src/utils/release-type.ts","../src/process/changelog.ts","../src/utils/file-state.ts","../src/process/commit.ts","../src/utils/git.ts","../src/utils/format-commit-message.ts","../src/process/tag.ts","../src/strategies/json-package.ts","../src/libs/stringify-package.ts","../src/strategies/plain-text.ts","../src/strategies/file-manager.ts"],"names":["semver","resolve","readFileSync","writeFileSync"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,8BAA8B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnD,OAAO,EAAE;AAAA,IACR,EAAE,OAAO;AAAA,MACR,MAAM,EAAE,OAAO;AAAA,MACf,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,MAC7B,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,IAC9B,CAAC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,EAAE,OAAO;AAAA;AAAA;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,UAAU,KAAK,QAAQ;AAAA,IACpC;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUO,MAAM,UAAkB,YAA0B;AACxD,QAAI,KAAK,OAAO,QAAQ;AACvB,WAAK,OAAO,IAAI,2BAA2B,QAAQ,EAAE;AACrD;AAAA,IACD;AAEA,QAAI,SAAS,YAAY,EAAE,SAAS,OAAO,GAAG;AAC7C,aAAO,KAAK,YAAY,MAAM,UAAU,UAAU;AAAA,IACnD,WAAW,SAAS,YAAY,EAAE,SAAS,aAAa,GAAG;AAC1D,aAAO,KAAK,UAAU,MAAM,UAAU,UAAU;AAAA,IACjD;AAEA,SAAK,OAAO,MAAM,0BAA0B,QAAQ,EAAE;AAAA,EACvD;AACD","sourcesContent":["import { z } from \"zod\";\n\nexport const ChangelogPresetConfigSchema = z.object({\n\t/**\n\t * An array of `type` objects representing the explicitly supported commit message types,\n\t * and whether they should show up in generated `CHANGELOG`s.\n\t */\n\ttypes: z.array(\n\t\tz.object({\n\t\t\ttype: z.string(),\n\t\t\tsection: z.string().optional(),\n\t\t\thidden: z.boolean().optional(),\n\t\t}),\n\t),\n\t/**\n\t * A URL representing a specific commit at a hash.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/commit/{{hash}}\"\n\t */\n\tcommitUrlFormat: z.string(),\n\t/**\n\t * A URL representing the comparison between two git SHAs.\n\t * @default \"{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}\"\n\t */\n\tcompareUrlFormat: z.string(),\n\t/**\n\t * A URL representing the issue format (allowing a different URL format to be swapped in\n\t * for Gitlab, Bitbucket, etc).\n\t * @default \"{{host}}/{{owner}}/{{repository}}/issues/{{id}}\"\n\t */\n\tissueUrlFormat: z.string(),\n\t/**\n\t * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used\n\t * for substituting @bcoe with https://github.com/bcoe in commit messages.\n\t * @default \"{{host}}/{{user}}\"\n\t */\n\tuserUrlFormat: z.string(),\n\t/**\n\t * A string to be used to format the auto-generated release commit message.\n\t * @default \"chore(release): {{currentTag}}\"\n\t */\n\treleaseCommitMessageFormat: z.string(),\n\t/**\n\t * An array of prefixes used to detect references to issues\n\t * @default [\"#\"]\n\t */\n\tissuePrefixes: z.array(z.string()),\n});\n\nexport type ChangelogPresetConfig = z.infer<typeof ChangelogPresetConfigSchema>;\n\nexport const ForkConfigSchema = z.object({\n\t/**\n\t * The path fork-version will run from.\n\t * @default\n\t * ```js\n\t * process.cwd()\n\t * ```\n\t */\n\tpath: z.string(),\n\t/**\n\t * Name of the changelog file.\n\t * @default \"CHANGELOG.md\"\n\t */\n\tchangelog: 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 * 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\tfiles: z.array(z.string()),\n\t/**\n\t * Specify a prefix for the git tag fork-version will create.\n\t *\n\t * For instance if your version tag is prefixed by \"version/\" instead of \"v\" you have to specify\n\t * `tagPrefix: \"version/\"`.\n\t *\n\t * `tagPrefix` can also be used for a monorepo environment where you might want to deploy\n\t * multiple package from the same repository. In this case you can specify a prefix for\n\t * each package:\n\t *\n\t * | Value | Tag Created |\n\t * |:-------------------------|:------------------------------|\n\t * | \"\" | `1.2.3` |\n\t * | \"version/\" | `version/1.2.3` |\n\t * | \"@eglavin/fork-version-\" | `@eglavin/fork-version-1.2.3` |\n\t *\n\t * @example \"\", \"version/\", \"@eglavin/fork-version-\"\n\t * @default \"v\"\n\t */\n\ttagPrefix: z.string(),\n\t/**\n\t * Make a pre-release with optional label, if value is a string it will be used as the\n\t * pre-release tag.\n\t *\n\t * | Value | Version |\n\t * |:----------|:----------------|\n\t * | true | \"1.2.3-0\" |\n\t * | \"alpha\" | \"1.2.3-alpha-0\" |\n\t * | \"beta\" | \"1.2.3-beta-0\" |\n\t *\n\t * @example true, \"alpha\", \"beta\", \"rc\"\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 set we'll log debug information.\n\t * @default false\n\t */\n\tdebug: 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 the list of `files`, we'll fallback\n\t * and attempt to use the latest git tag to get the current version.\n\t * @default true\n\t */\n\tgitTagFallback: z.boolean(),\n\t/**\n\t * If set, we'll gather information about the current version and exit.\n\t * @default false\n\t */\n\tinspectVersion: 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 a version from the list of `files`.\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, instead of incrementing\n\t * using \"conventional-commit\".\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: ChangelogPresetConfigSchema.partial(),\n});\n\nexport type ForkConfig = z.infer<typeof ForkConfigSchema>;\n\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\n\treturn config;\n}\n","import { parse, resolve } from \"node:path\";\nimport JoyCon from \"joycon\";\nimport { bundleRequire } from \"bundle-require\";\n\nimport { ForkConfigSchema, type ForkConfig } from \"./schema\";\nimport { DEFAULT_CONFIG } from \"./defaults\";\nimport { getCliArguments } from \"./cli-arguments\";\nimport { getChangelogPresetConfig } from \"./changelog-preset-config\";\n\nexport async function getUserConfig(): Promise<ForkConfig> {\n\tconst cliArguments = getCliArguments();\n\n\tconst cwd = cliArguments.flags.path ? resolve(cliArguments.flags.path) : process.cwd();\n\tconst joycon = new JoyCon();\n\tconst configFilePath = await joycon.resolve({\n\t\tfiles: [\"fork.config.ts\", \"fork.config.js\", \"fork.config.cjs\", \"fork.config.mjs\"],\n\t\tcwd,\n\t\tstopDir: parse(cwd).root,\n\t});\n\n\tif (!configFilePath) {\n\t\treturn {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...cliArguments.flags,\n\t\t\tpath: cwd,\n\t\t\tchangelogPresetConfig: getChangelogPresetConfig(),\n\t\t} as ForkConfig;\n\t}\n\n\tconst foundConfig = await bundleRequire({ filepath: configFilePath });\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\n\t\tfoundConfig.mod.default || foundConfig.mod,\n\t);\n\n\tif (!parsedConfig.success) {\n\t\tthrow parsedConfig.error;\n\t}\n\n\tconst usersConfig = {\n\t\t...DEFAULT_CONFIG,\n\t\t...parsedConfig.data,\n\t\t...cliArguments.flags,\n\t} as ForkConfig;\n\n\tconst files = mergeFiles(parsedConfig.data?.files, cliArguments.flags?.files);\n\n\treturn {\n\t\t...usersConfig,\n\t\tpath: cwd,\n\t\tfiles: files.length > 0 ? files : DEFAULT_CONFIG.files,\n\t\tchangelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig),\n\t};\n}\n\nfunction mergeFiles(configFiles: string[] | undefined, cliFiles: string[] | undefined): string[] {\n\treturn Array.from(\n\t\tnew Set(\n\t\t\t([] as string[]).concat(\n\t\t\t\tArray.isArray(configFiles) ? configFiles : [],\n\t\t\t\tArray.isArray(cliFiles) ? cliFiles : [],\n\t\t\t),\n\t\t),\n\t);\n}\n","import type { ForkConfig } from \"./schema\";\n\nexport const DEFAULT_CONFIG: ForkConfig = {\n\tpath: process.cwd(),\n\tchangelog: \"CHANGELOG.md\",\n\tfiles: [\n\t\t\"package.json\",\n\t\t\"package-lock.json\",\n\t\t\"npm-shrinkwrap.json\",\n\t\t\"manifest.json\", // Chrome extensions\n\t\t\"bower.json\",\n\t],\n\theader: `# 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\tdebug: false,\n\tdryRun: false,\n\tgitTagFallback: true,\n\tinspectVersion: false,\n\tsign: false,\n\tsilent: false,\n\tverify: false,\n\n\tchangelogPresetConfig: {},\n};\n","import meow from \"meow\";\n\nexport function getCliArguments() {\n\treturn meow(\n\t\t`\nUsage:\n $ fork-version [options]\n\nOptions:\n --path [Default: process.cwd()]\n The path fork-version will run from.\n --changelog [Default: \"CHANGELOG.md\"]\n Name of the changelog file.\n --header, -H\n The header to be used in the changelog.\n --files, --file, -F [Default: [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]]\n Files to be updated.\n --tag-prefix [Default: \"v\"]\n Specify a prefix for the git tag \"fork-version\" will create.\n --pre-release-tag [Default: undefined]\n Make a pre-release with optional label, If value is a string it\n will be used as the pre-release tag.\n\n --commit-all\n Commit all staged changes, not just files updated by fork-version.\n --debug\n If true, we'll output debug information.\n --dry-run\n If true, no output will be written to disk or committed.\n --git-tag-fallback [Default: true]\n If true and we cant find a version in the given files, we'll fallback\n and attempt to use the latest git tag for the current version.\n --inspect-version\n If set, we'll gather information about the current version and exit.\n --sign\n Should we sign the git commit using GPG?\n --silent\n If true, no output will be written to stdout.\n --verify\n If true, allow git to run git commit hooks.\n\n --current-version\n If set, we'll use this version number instead of trying to find a\n version in a \"file\".\n --next-version\n If set, we'll attempt to update the version number to this version,\n instead of incrementing using \"conventional-commit\".\n`,\n\t\t{\n\t\t\timportMeta: import.meta,\n\t\t\tflags: {\n\t\t\t\tpath: { type: \"string\", default: process.cwd() },\n\t\t\t\tchangelog: { type: \"string\" },\n\t\t\t\theader: { type: \"string\", shortFlag: \"H\" },\n\t\t\t\tfiles: { type: \"string\", isMultiple: true, aliases: [\"file\"], shortFlag: \"F\" },\n\t\t\t\ttagPrefix: { type: \"string\" },\n\t\t\t\tpreReleaseTag: { type: \"string\" },\n\n\t\t\t\tcommitAll: { type: \"boolean\" },\n\t\t\t\tdebug: { type: \"boolean\" },\n\t\t\t\tdryRun: { type: \"boolean\" },\n\t\t\t\tgitTagFallback: { type: \"boolean\" },\n\t\t\t\tinspectVersion: { type: \"boolean\" },\n\t\t\t\tsign: { type: \"boolean\" },\n\t\t\t\tsilent: { type: \"boolean\" },\n\t\t\t\tverify: { type: \"boolean\" },\n\n\t\t\t\tcurrentVersion: { type: \"string\" },\n\t\t\t\tnextVersion: { type: \"string\" },\n\t\t\t},\n\t\t},\n\t);\n}\n","import conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\n\nimport { ChangelogPresetConfigSchema, type ForkConfig } from \"./schema\";\n\nexport function getChangelogPresetConfig(\n\tusersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"],\n) {\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\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 ChangelogPresetConfigSchema.passthrough().parse(preset);\n}\n","import semver, { type ReleaseType } from \"semver\";\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\n\nimport { getLatestGitTagVersion } from \"../utils/git-tag-version\";\nimport { getReleaseType } from \"../utils/release-type\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { IFileManager, FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface CurrentVersion {\n\tversion: string;\n\tfiles: FileState[];\n}\n\nexport async function getCurrentVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfileManager: IFileManager,\n): Promise<CurrentVersion> {\n\tconst files: FileState[] = [];\n\tconst versions = new Set<string>();\n\n\tfor (const file of config.files) {\n\t\tconst fileState = fileManager.read(file);\n\n\t\tif (fileState) {\n\t\t\tfiles.push(fileState);\n\n\t\t\tif (config.currentVersion) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tversions.add(fileState.version);\n\t\t}\n\t}\n\n\tif (config.currentVersion) {\n\t\tversions.add(config.currentVersion);\n\t}\n\n\tif (versions.size === 0) {\n\t\tif (config.gitTagFallback) {\n\t\t\tconst version = await getLatestGitTagVersion(config.tagPrefix);\n\t\t\tif (version) {\n\t\t\t\treturn {\n\t\t\t\t\tfiles: [],\n\t\t\t\t\tversion: 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.size > 1) {\n\t\tthrow new Error(\"Found multiple versions\");\n\t}\n\n\tconst currentVersion = versions.entries().next().value[0];\n\n\t// If we're just inspecting the version, output the version and exit\n\tif (config.inspectVersion) {\n\t\tconsole.log(currentVersion);\n\t\tprocess.exit(0);\n\t}\n\n\tlogger.log(`Current version: ${currentVersion}`);\n\treturn {\n\t\tfiles,\n\t\tversion: currentVersion,\n\t};\n}\n\nexport interface NextVersion {\n\tversion: string;\n\tlevel?: number;\n\tpreMajor?: boolean;\n\treason?: string;\n\treleaseType?: ReleaseType;\n}\n\nexport async function getNextVersion(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tcurrentVersion: string,\n): Promise<NextVersion> {\n\tif (config.nextVersion && semver.valid(config.nextVersion)) {\n\t\tlogger.log(`Next version: ${config.nextVersion}`);\n\t\treturn { version: config.nextVersion };\n\t}\n\n\tconst isPreMajor = semver.lt(currentVersion, \"1.0.0\");\n\n\tlet recommendedBump: Awaited<ReturnType<typeof conventionalRecommendedBump>>;\n\ttry {\n\t\trecommendedBump = await conventionalRecommendedBump({\n\t\t\tpreset: {\n\t\t\t\tname: \"conventionalcommits\",\n\t\t\t\t...config.changelogPresetConfig,\n\t\t\t\tpreMajor: isPreMajor,\n\t\t\t},\n\t\t\tpath: config.path,\n\t\t\ttagPrefix: config.tagPrefix,\n\t\t\tcwd: config.path,\n\t\t});\n\t} catch (error) {\n\t\tthrow new Error(`[conventional-recommended-bump] Unable to determine next version`);\n\t}\n\n\tif (recommendedBump.releaseType) {\n\t\tconst releaseType = getReleaseType(\n\t\t\trecommendedBump.releaseType,\n\t\t\tcurrentVersion,\n\t\t\tconfig.preReleaseTag,\n\t\t);\n\n\t\tconst state: NextVersion = {\n\t\t\t...recommendedBump,\n\t\t\tpreMajor: isPreMajor,\n\t\t\treleaseType,\n\t\t\tversion:\n\t\t\t\tsemver.inc(\n\t\t\t\t\tcurrentVersion,\n\t\t\t\t\treleaseType,\n\t\t\t\t\ttypeof config.preReleaseTag === \"string\" ? config.preReleaseTag : undefined,\n\t\t\t\t) ?? \"\",\n\t\t};\n\n\t\tlogger.log(`Next version: ${state.version} (${state.releaseType})`);\n\t\treturn state;\n\t}\n\n\tthrow new Error(\"Unable to find next version\");\n}\n","import gitSemverTags from \"git-semver-tags\";\nimport semver from \"semver\";\n\n/**\n * Get the latest git tag version.\n *\n * @example\n * ```ts\n * const tagPrefix = \"v\";\n * await getLatestGitTagVersion(tagPrefix); // 1.2.3\n * ```\n */\nexport async 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","import semver, { type ReleaseType } from \"semver\";\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\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\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 * ```js\n * getReleaseType(\"patch\", \"1.0.0\", false) => \"patch\"\n * getReleaseType(\"major\", \"0.0.0-beta\", \"beta\") => \"premajor\"\n * ```\n */\nexport function 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\tconst currentVersionsIsPreRelease = Array.isArray(semver.prerelease(currentVersion));\n\tif (currentVersionsIsPreRelease) {\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","import { resolve } from \"node:path\";\nimport { writeFileSync, readFileSync } from \"node:fs\";\nimport conventionalChangelog from \"conventional-changelog\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\n/**\n * Matches the following changelog header formats:\n * - `## [1.2.3]`\n * - `<a name=\"1.2.3\"></a>`\n */\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\n\n/**\n * Get the existing changelog content from the latest release onwards.\n * @see {@link RELEASE_PATTERN}\n */\nfunction getOldReleaseContent(filePath: string, exists: boolean): string {\n\tif (exists) {\n\t\tconst fileContents = readFileSync(filePath, \"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\n/**\n * Generate the new changelog content for this release.\n */\nfunction getNewReleaseContent(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<string> {\n\treturn new Promise<string>((onResolve) => {\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...config.changelogPresetConfig,\n\t\t\t\t},\n\t\t\t\ttagPrefix: config.tagPrefix,\n\t\t\t\twarn: (...message: string[]) => logger.error(\"conventional-changelog: \", ...message),\n\t\t\t\tcwd: config.path,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: nextVersion,\n\t\t\t},\n\t\t\t{\n\t\t\t\tmerges: null,\n\t\t\t\tpath: config.path,\n\t\t\t},\n\t\t)\n\t\t\t.on(\"error\", (error) => {\n\t\t\t\tlogger.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\tonResolve(newContent);\n\t\t\t});\n\t});\n}\n\ninterface UpdateChangelog {\n\tchangelogPath: string;\n\toldContent: string;\n\tnewContent: string;\n}\n\nexport async function updateChangelog(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<UpdateChangelog> {\n\tif (config.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\t// Create the changelog file if it doesn't exist\n\tconst changelogPath = resolve(config.path, config.changelog);\n\tif (!config.dryRun && !fileExists(changelogPath)) {\n\t\tlogger.log(`Creating Changelog file: ${changelogPath}`);\n\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\n\t}\n\n\tconst oldContent = getOldReleaseContent(changelogPath, fileExists(changelogPath));\n\tconst newContent = await getNewReleaseContent(config, logger, nextVersion);\n\n\tlogger.log(`Updating Changelog: ${changelogPath}`);\n\tif (!config.dryRun && newContent) {\n\t\twriteFileSync(\n\t\t\tchangelogPath,\n\t\t\t`${config.header}\n${newContent}\n${oldContent}\n`,\n\t\t\t\"utf8\",\n\t\t);\n\t}\n\n\treturn {\n\t\tchangelogPath,\n\t\toldContent,\n\t\tnewContent,\n\t};\n}\n","import { lstatSync } from \"fs\";\n\n/**\n * Determine if a file exists.\n * @example\n * ```ts\n * fileExists(\"~/.bashrc\"); // true\n * fileExists(\"~/missing-file.txt\"); // false\n * ```\n */\nexport function fileExists(filePath: string): boolean {\n\ttry {\n\t\treturn lstatSync(filePath).isFile();\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n","import { resolve } from \"node:path\";\nimport { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { FileState } from \"../strategies/file-manager\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface CommitChanges {\n\tfilesToCommit: string[];\n\tgitAddOutput?: string;\n\tgitCommitOutput?: string;\n}\n\nexport async function commitChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tfiles: FileState[],\n\tnextVersion: string,\n): Promise<CommitChanges> {\n\tconst git = new Git(config, logger);\n\n\tlogger.log(\"Committing changes\");\n\n\tconst filesToCommit: string[] = [];\n\tif (fileExists(resolve(config.path, config.changelog))) {\n\t\tfilesToCommit.push(resolve(config.path, config.changelog));\n\t}\n\tfor (const file of files) {\n\t\tfilesToCommit.push(file.path);\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 shouldVerify = config.verify ? undefined : \"--no-verify\";\n\tconst shouldSign = config.sign ? \"--gpg-sign\" : undefined;\n\n\t// If commitAll is set, commit all changed files.\n\tif (config.commitAll) {\n\t\treturn {\n\t\t\tfilesToCommit,\n\t\t\tgitAddOutput: await git.add(\"--all\"),\n\t\t\tgitCommitOutput: await git.commit(\n\t\t\t\tshouldVerify,\n\t\t\t\tshouldSign,\n\t\t\t\t\"--message\",\n\t\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t\t),\n\t\t};\n\t}\n\n\treturn {\n\t\tfilesToCommit,\n\t\tgitAddOutput: await git.add(...filesToCommit),\n\t\tgitCommitOutput: await git.commit(\n\t\t\tshouldVerify,\n\t\t\tshouldSign,\n\t\t\t...filesToCommit,\n\t\t\t\"--message\",\n\t\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t\t),\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"./logger\";\n\nexport class Git {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.add = this.add.bind(this);\n\t\tthis.commit = this.commit.bind(this);\n\t\tthis.tag = this.tag.bind(this);\n\t\tthis.revParse = this.revParse.bind(this);\n\t}\n\n\tpublic add(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"add\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic commit(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"commit\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic tag(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"tag\", args.filter(Boolean) as string[]);\n\t}\n\n\tpublic revParse(...args: (string | undefined)[]) {\n\t\treturn this.execGit(\"rev-parse\", args.filter(Boolean) as string[]);\n\t}\n\n\tprivate execGit(command: string, args: string[]): Promise<string> {\n\t\tif (this.config.dryRun) {\n\t\t\treturn Promise.resolve(\"\");\n\t\t}\n\n\t\tthis.logger.debug(`Executing: git ${command} ${args.join(\" \")}`);\n\t\treturn new Promise((onResolve, onReject) => {\n\t\t\texecFile(\n\t\t\t\t\"git\",\n\t\t\t\t[command, ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd: this.config.path,\n\t\t\t\t},\n\t\t\t\t(error, stdout, stderr) => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tthis.logger.error(`git ${command}:`);\n\t\t\t\t\t\tonReject(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tonResolve(stdout ? stdout : stderr);\n\t\t\t\t},\n\t\t\t);\n\t\t});\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, version: string): string {\n\tif (!message) {\n\t\tmessage = \"chore(release): {{currentTag}}\";\n\t}\n\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), version);\n}\n","import { Git } from \"../utils/git\";\nimport { formatCommitMessage } from \"../utils/format-commit-message\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\ninterface TagChanges {\n\tgitTagOutput: string;\n}\n\nexport async function tagChanges(\n\tconfig: ForkConfig,\n\tlogger: Logger,\n\tnextVersion: string,\n): Promise<TagChanges> {\n\tconst git = new Git(config, logger);\n\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\n\tconst tag = `${config.tagPrefix}${nextVersion}`;\n\n\tlogger.log(`Creating Tag: ${tag}`);\n\n\tconst gitTagOutput = await git.tag(\n\t\tconfig.sign ? \"--sign\" : \"--annotate\",\n\t\ttag,\n\t\t\"--message\",\n\t\tformatCommitMessage(config.changelogPresetConfig?.releaseCommitMessageFormat, nextVersion),\n\t);\n\n\treturn {\n\t\tgitTagOutput,\n\t};\n}\n","import { resolve } from \"node:path\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nimport detectIndent from \"detect-indent\";\nimport { detectNewline } from \"detect-newline\";\n\nimport { stringifyPackage } from \"../libs/stringify-package\";\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A json package file should have a version property, like what can be seen\n * in the package.json file in the root of this project.\n *\n * @example\n * ```json\n * {\n * \"name\": \"fork-version\",\n * \"version\": \"1.2.3\",\n * \"private\": true,\n * }\n * ```\n */\nexport class JSONPackage implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\t\tif (parsedJson.version) {\n\t\t\t\treturn {\n\t\t\t\t\tname: fileName,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t\tversion: parsedJson.version,\n\n\t\t\t\t\tisPrivate: typeof parsedJson?.private === \"boolean\" ? parsedJson.private : true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.logger.warn(`Unable to determine json package file: ${fileName}`);\n\t\t}\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\t\tconst parsedJson = JSON.parse(fileContents);\n\n\t\tparsedJson.version = newVersion;\n\t\tif (parsedJson.packages?.[\"\"]) {\n\t\t\tparsedJson.packages[\"\"].version = newVersion; // package-lock v2 stores version here too.\n\t\t}\n\n\t\twriteFileSync(\n\t\t\tfilePath,\n\t\t\tstringifyPackage(parsedJson, detectIndent(fileContents).amount, detectNewline(fileContents)),\n\t\t\t\"utf8\",\n\t\t);\n\t}\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\nconst DEFAULT_INDENT = 2;\nconst CRLF = \"\\r\\n\";\nconst LF = \"\\n\";\n\n/**\n * @param data The object to stringify\n * @param indent `2, 4, \" \", \"\\t\"` Number of spaces a string of spaces or tab character, defaults to 2\n * @param newline `\"\\r\\n\", \"\\n\"` Windows or Unix line endings, defaults to Unix\n */\nexport function stringifyPackage(\n\tdata: object,\n\tindent?: string | number,\n\tnewline?: typeof CRLF | typeof LF,\n): string {\n\tconst stringified = JSON.stringify(data, null, indent ?? 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 { readFileSync, writeFileSync } from \"node:fs\";\n\nimport { fileExists } from \"../utils/file-state\";\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\nimport type { FileState, IFileManager } from \"./file-manager\";\n\n/**\n * A plain text file will have just the version as the content.\n *\n * @example\n * ```txt\n * 1.2.3\n * ```\n */\nexport class PlainText implements IFileManager {\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {}\n\n\tpublic read(fileName: string): FileState | undefined {\n\t\tconst filePath = resolve(this.config.path, fileName);\n\n\t\tif (fileExists(filePath)) {\n\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\n\n\t\t\treturn {\n\t\t\t\tname: fileName,\n\t\t\t\tpath: filePath,\n\t\t\t\tversion: fileContents || \"\",\n\t\t\t};\n\t\t}\n\n\t\tthis.logger.warn(`Unable to determine plain text file: ${fileName}`);\n\t}\n\n\tpublic write(filePath: string, newVersion: string) {\n\t\twriteFileSync(filePath, newVersion, \"utf8\");\n\t}\n}\n","import { JSONPackage } from \"./json-package\";\nimport { PlainText } from \"./plain-text\";\n\nimport type { ForkConfig } from \"../config/schema\";\nimport type { Logger } from \"../utils/logger\";\n\nexport interface FileState {\n\tname: string;\n\tpath: string;\n\tversion: string;\n\n\t[other: string]: unknown;\n}\n\nexport interface IFileManager {\n\tread(fileName: string): FileState | undefined;\n\twrite(filePath: string, newVersion: string): void;\n}\n\nexport class FileManager implements IFileManager {\n\tprivate JSONPackage: JSONPackage;\n\tprivate PlainText: PlainText;\n\n\tconstructor(\n\t\tprivate config: ForkConfig,\n\t\tprivate logger: Logger,\n\t) {\n\t\tthis.JSONPackage = new JSONPackage(config, logger);\n\t\tthis.PlainText = new PlainText(config, logger);\n\t}\n\n\t/**\n\t * Get the state from the given file name.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.read(\"package.json\");\n\t * ```\n\t *\n\t * @returns\n\t * ```json\n\t * { \"name\": \"package.json\", \"path\": \"/path/to/package.json\", \"version\": \"1.2.3\", \"isPrivate\": true }\n\t * ```\n\t */\n\tpublic read(fileName: string): FileState | undefined {\n\t\tif (fileName.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.read(fileName);\n\t\t} else if (fileName.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.read(fileName);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${fileName}`);\n\t}\n\n\t/**\n\t * Write the new version to the given file path.\n\t *\n\t * @example\n\t * ```ts\n\t * fileManager.write(\"/path/to/package.json\", \"1.2.3\");\n\t * ```\n\t */\n\tpublic write(filePath: string, newVersion: string): void {\n\t\tif (this.config.dryRun) {\n\t\t\tthis.logger.log(`[Dry run]: Not updating ${filePath}`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (filePath.toLowerCase().endsWith(\".json\")) {\n\t\t\treturn this.JSONPackage.write(filePath, newVersion);\n\t\t} else if (filePath.toLowerCase().endsWith(\"version.txt\")) {\n\t\t\treturn this.PlainText.write(filePath, newVersion);\n\t\t}\n\n\t\tthis.logger.error(`Unsupported file type: ${filePath}`);\n\t}\n}\n"]}