fork-version 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/chunk-2I73SGKO.cjs +624 -0
- package/dist/chunk-2I73SGKO.cjs.map +1 -0
- package/dist/chunk-STAHBMPI.js +605 -0
- package/dist/chunk-STAHBMPI.js.map +1 -0
- package/dist/cli.cjs +27 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +290 -0
- package/dist/index.d.ts +290 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/configuration.ts","../src/process/version.ts","../src/libs/stringify-package.ts","../src/process/changelog.ts","../src/utils/execute-file.ts","../src/utils/format-commit-message.ts","../src/process/commit.ts","../src/process/tag.ts"],"names":["resolve","writeFileSync","readFileSync","existsSync"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS;AAClB,OAAO,qCAAqC;AAG5C,IAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjC,YAAY,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,WAAW,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU5B,QAAQ,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,WAAW,EAAE,OAAO;AA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ACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import path from \"node:path\";\r\nimport JoyCon from \"joycon\";\r\nimport { bundleRequire } from \"bundle-require\";\r\nimport { z } from \"zod\";\r\nimport conventionalChangelogConfigSpec from \"conventional-changelog-config-spec\";\r\nimport type { JSONSchema7 } from \"json-schema\";\r\n\r\nconst ForkConfigSchema = z.object({\r\n\t/**\r\n\t * The path where the changes should be calculated from.\r\n\t * @default\r\n\t * ```js\r\n\t * process.cwd()\r\n\t * ```\r\n\t */\r\n\tchangePath: z.string(),\r\n\t/**\r\n\t * The name of the changelog file.\r\n\t * @default \"CHANGELOG.md\"\r\n\t */\r\n\tchangelog: z.string(),\r\n\t/**\r\n\t * Files to be updated.\r\n\t * @default\r\n\t * ```js\r\n\t * [\"bower.json\", \"manifest.json\", \"npm-shrinkwrap.json\", \"package-lock.json\", \"package.json\"]\r\n\t * ```\r\n\t */\r\n\toutFiles: z.array(z.string()),\r\n\t/**\r\n\t * The header to be used in the changelog.\r\n\t * @default\r\n\t * ```markdown\r\n\t * # Changelog\r\n\t *\r\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.\r\n\t * ```\r\n\t */\r\n\theader: z.string(),\r\n\t/**\r\n\t * Specify a prefix for the git tag that will be taken into account during the comparison.\r\n\t *\r\n\t * For instance if your version tag is prefixed by `version/` instead of `v` you would\r\n\t * have to specify `tagPrefix: \"version/\"`.\r\n\t * @default `v`\r\n\t */\r\n\ttagPrefix: z.string(),\r\n\t/**\r\n\t * Make a pre-release with optional label to specify a tag id.\r\n\t * @example true, \"alpha\", \"beta\", \"rc\", etc.\r\n\t * @default undefined\r\n\t */\r\n\tpreReleaseTag: z.string().or(z.boolean()).optional(),\r\n\r\n\t/**\r\n\t * Commit all staged changes, not just files updated by fork-version.\r\n\t * @default false\r\n\t */\r\n\tcommitAll: z.boolean(),\r\n\t/**\r\n\t * If true, no output will be written to disk or committed.\r\n\t * @default false\r\n\t */\r\n\tdryRun: z.boolean(),\r\n\t/**\r\n\t * If true and we cant find a version in an `outFiles`, we'll fallback and attempt\r\n\t * to use the latest git tag for the current version.\r\n\t * @default true\r\n\t */\r\n\tgitTagFallback: z.boolean(),\r\n\t/**\r\n\t * Should we sign the git commit using GPG?\r\n\t * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}\r\n\t * @default false\r\n\t */\r\n\tsign: z.boolean(),\r\n\t/**\r\n\t * If true, no output will be written to stdout.\r\n\t * @default false\r\n\t */\r\n\tsilent: z.boolean(),\r\n\t/**\r\n\t * If true, allow git to run git commit hooks.\r\n\t * @default false\r\n\t */\r\n\tverify: z.boolean(),\r\n\r\n\t/**\r\n\t * If set, we'll use this version number instead of trying to find it in an `outFiles`.\r\n\t * @example \"1.0.0\"\r\n\t * @default undefined\r\n\t */\r\n\tcurrentVersion: z.string().optional(),\r\n\t/**\r\n\t * If set, we'll attempt to update the version number to this version.\r\n\t * @example \"2.0.0\"\r\n\t * @default undefined\r\n\t */\r\n\tnextVersion: z.string().optional(),\r\n\r\n\t/**\r\n\t * Override the default conventional-changelog preset configuration.\r\n\t */\r\n\tchangelogPresetConfig: z.object({\r\n\t\t/**\r\n\t\t * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.\r\n\t\t */\r\n\t\ttypes: z\r\n\t\t\t.array(\r\n\t\t\t\tz.object({\r\n\t\t\t\t\ttype: z.string(),\r\n\t\t\t\t\tsection: z.string().optional(),\r\n\t\t\t\t\thidden: z.boolean().optional(),\r\n\t\t\t\t}),\r\n\t\t\t)\r\n\t\t\t.optional(),\r\n\t\t/**\r\n\t\t * A URL representing a specific commit at a hash.\r\n\t\t */\r\n\t\tcommitUrlFormat: z.string().optional(),\r\n\t\t/**\r\n\t\t * A URL representing the comparison between two git SHAs.\r\n\t\t */\r\n\t\tcompareUrlFormat: z.string().optional(),\r\n\t\t/**\r\n\t\t * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).\r\n\t\t */\r\n\t\tissueUrlFormat: z.string().optional(),\r\n\t\t/**\r\n\t\t * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used for substituting @bcoe with https://github.com/bcoe in commit messages.\r\n\t\t */\r\n\t\tuserUrlFormat: z.string().optional(),\r\n\t\t/**\r\n\t\t * A string to be used to format the auto-generated release commit message.\r\n\t\t */\r\n\t\treleaseCommitMessageFormat: z.string().optional(),\r\n\t\t/**\r\n\t\t * An array of prefixes used to detect references to issues\r\n\t\t */\r\n\t\tissuePrefixes: z.array(z.string()).optional(),\r\n\t}),\r\n});\r\n\r\nexport type ForkConfig = z.infer<typeof ForkConfigSchema> & {\r\n\t/**\r\n\t * Log function, can be used to override the default `console.log` function\r\n\t * to log to a file or another service.\r\n\t * @default console.log\r\n\t */\r\n\tlog: (...args: unknown[]) => void;\r\n\t/**\r\n\t * Error logger function, can be used to override the default `console.error`\r\n\t * function to log to a file or another service.\r\n\t * @default console.error\r\n\t */\r\n\terror: (...args: unknown[]) => void;\r\n\t/**\r\n\t * Debug logger function, by default this is a noop function, but can be replaced\r\n\t * with a custom logger function or `console.info` to print output.\r\n\t * @default () => {}\r\n\t */\r\n\tdebug: (...args: unknown[]) => void;\r\n};\r\n\r\nconst DEFAULT_CONFIG: ForkConfig = {\r\n\tchangePath: process.cwd(),\r\n\tchangelog: \"CHANGELOG.md\",\r\n\toutFiles: [\r\n\t\t\"bower.json\",\r\n\t\t\"manifest.json\", // Chrome extensions\r\n\t\t\"npm-shrinkwrap.json\",\r\n\t\t\"package-lock.json\",\r\n\t\t\"package.json\",\r\n\t],\r\n\theader:\r\n\t\t\"# Changelog\\n\\nAll notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.\\n\",\r\n\ttagPrefix: \"v\",\r\n\r\n\tcommitAll: false,\r\n\tdryRun: false,\r\n\tgitTagFallback: true,\r\n\tsign: false,\r\n\tsilent: false,\r\n\tverify: false,\r\n\r\n\tchangelogPresetConfig: {},\r\n\r\n\tlog: console.log, // eslint-disable-line no-console\r\n\terror: console.error, // eslint-disable-line no-console\r\n\tdebug: () => {},\r\n};\r\n\r\nexport function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig> {\r\n\tconst parsedConfig = ForkConfigSchema.partial().safeParse(config);\r\n\tif (parsedConfig.success) {\r\n\t\treturn parsedConfig.data;\r\n\t}\r\n\treturn DEFAULT_CONFIG;\r\n}\r\n\r\nfunction getPresetDefaults(usersChangelogPresetConfig?: ForkConfig[\"changelogPresetConfig\"]) {\r\n\tconst preset: { name: string; [_: string]: unknown } = {\r\n\t\tname: \"conventionalcommits\",\r\n\t};\r\n\r\n\t// First take any default values from the conventional-changelog-config-spec\r\n\tif (typeof conventionalChangelogConfigSpec.properties === \"object\") {\r\n\t\tObject.entries(conventionalChangelogConfigSpec.properties).forEach(([key, value]) => {\r\n\t\t\tconst _value = value as JSONSchema7;\r\n\t\t\tif (\"default\" in _value && _value.default !== undefined) {\r\n\t\t\t\tpreset[key] = _value.default;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t// Then overwrite with any values from the users config\r\n\tif (usersChangelogPresetConfig && typeof usersChangelogPresetConfig === \"object\") {\r\n\t\tObject.entries(usersChangelogPresetConfig).forEach(([key, value]) => {\r\n\t\t\tif (value !== undefined) {\r\n\t\t\t\tpreset[key] = value;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\treturn preset;\r\n}\r\n\r\nexport async function getForkConfig(): Promise<ForkConfig> {\r\n\tconst cwd = process.cwd();\r\n\r\n\tconst joycon = new JoyCon.default();\r\n\tconst configPath = await joycon.resolve({\r\n\t\tfiles: [\"fork.config.js\"],\r\n\t\tcwd: cwd,\r\n\t\tstopDir: path.parse(cwd).root,\r\n\t});\r\n\r\n\tif (configPath) {\r\n\t\tconst foundConfig = await bundleRequire({ filepath: configPath });\r\n\t\tconst parsedConfig = ForkConfigSchema.partial().safeParse(\r\n\t\t\tfoundConfig.mod.default || foundConfig.mod,\r\n\t\t);\r\n\r\n\t\tif (parsedConfig.success) {\r\n\t\t\t// Allow users to add additional outFiles\r\n\t\t\tconst mergedOutFiles = DEFAULT_CONFIG.outFiles.concat(parsedConfig.data?.outFiles || []);\r\n\r\n\t\t\tconst usersConfig = Object.assign(DEFAULT_CONFIG, parsedConfig.data, {\r\n\t\t\t\toutFiles: Array.from(new Set(mergedOutFiles)),\r\n\t\t\t});\r\n\r\n\t\t\tif (usersConfig.silent) {\r\n\t\t\t\tusersConfig.log = () => {};\r\n\t\t\t\tusersConfig.error = () => {};\r\n\t\t\t}\r\n\r\n\t\t\t// Allow users to override the default log function\r\n\t\t\tif (\"debug\" in parsedConfig && typeof parsedConfig.debug === \"function\") {\r\n\t\t\t\tusersConfig.debug = parsedConfig.debug as ForkConfig[\"debug\"];\r\n\t\t\t}\r\n\r\n\t\t\treturn Object.assign(usersConfig, {\r\n\t\t\t\tchangelogPresetConfig: getPresetDefaults(usersConfig?.changelogPresetConfig),\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\treturn Object.assign(DEFAULT_CONFIG, {\r\n\t\tchangelogPresetConfig: getPresetDefaults(),\r\n\t});\r\n}\r\n","import { resolve, extname } from \"node:path\";\r\nimport { existsSync, readFileSync, writeFileSync, lstatSync } from \"node:fs\";\r\nimport gitSemverTags from \"git-semver-tags\";\r\nimport semver, { ReleaseType } from \"semver\";\r\nimport conventionalRecommendedBump from \"conventional-recommended-bump\";\r\nimport detectIndent from \"detect-indent\";\r\nimport detectNewLine from \"detect-newline\";\r\nimport { stringifyPackage } from \"../libs/stringify-package.js\";\r\nimport type { ForkConfig } from \"../configuration.js\";\r\n\r\ntype FileState = {\r\n\tname: string;\r\n\tpath: string;\r\n\ttype: \"package-file\" | ({} & string); // eslint-disable-line @typescript-eslint/ban-types\r\n\tversion: string;\r\n\tisPrivate: boolean;\r\n};\r\n\r\nfunction getFile(options: ForkConfig, fileToGet: string): FileState | undefined {\r\n\ttry {\r\n\t\tconst fileExtension = extname(fileToGet);\r\n\t\tif (fileExtension === \".json\") {\r\n\t\t\tconst filePath = resolve(options.changePath, fileToGet);\r\n\t\t\tif (existsSync(filePath)) {\r\n\t\t\t\tconst fileContents = readFileSync(filePath, \"utf8\");\r\n\t\t\t\tconst parsedJson = JSON.parse(fileContents);\r\n\r\n\t\t\t\t// Return if version property exists\r\n\t\t\t\tif (parsedJson.version) {\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tname: fileToGet,\r\n\t\t\t\t\t\tpath: filePath,\r\n\t\t\t\t\t\ttype: \"package-file\",\r\n\t\t\t\t\t\tversion: parsedJson.version,\r\n\t\t\t\t\t\tisPrivate:\r\n\t\t\t\t\t\t\t\"private\" in parsedJson &&\r\n\t\t\t\t\t\t\t(typeof parsedJson.private === \"boolean\" ? parsedJson.private : false),\r\n\t\t\t\t\t};\r\n\t\t\t\t} else {\r\n\t\t\t\t\toptions.log(`Unable to find version in file: ${fileToGet}`);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} catch (error) {\r\n\t\toptions.error(`Error reading file: ${fileToGet}`, error);\r\n\t}\r\n}\r\n\r\nasync function getLatestGitTagVersion(tagPrefix: string | undefined): Promise<string> {\r\n\tconst gitTags = await gitSemverTags({ tagPrefix });\r\n\tif (!gitTags.length) {\r\n\t\treturn \"1.0.0\";\r\n\t}\r\n\r\n\tconst cleanedTags = [];\r\n\r\n\tfor (const tag of gitTags) {\r\n\t\tconst cleanedTag = semver.clean(tag.replace(new RegExp(`^${tagPrefix}`), \"\"));\r\n\r\n\t\tif (cleanedTag) {\r\n\t\t\tcleanedTags.push(cleanedTag);\r\n\t\t}\r\n\t}\r\n\r\n\treturn cleanedTags.sort(semver.rcompare)[0];\r\n}\r\n\r\ntype CurrentVersion = {\r\n\tcurrentVersion: string;\r\n\tfiles: FileState[];\r\n};\r\n\r\n/**\r\n * Get the current version from the given files and find their locations.\r\n */\r\nasync function getCurrentVersion(options: ForkConfig): Promise<CurrentVersion> {\r\n\tconst files: FileState[] = [];\r\n\tconst versions: string[] = [];\r\n\r\n\tfor (const file of options.outFiles) {\r\n\t\tconst fileState = getFile(options, file);\r\n\t\tif (fileState) {\r\n\t\t\tfiles.push(fileState);\r\n\r\n\t\t\tif (options.currentVersion) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (!versions.includes(fileState.version)) {\r\n\t\t\t\tversions.push(fileState.version);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (options.currentVersion) {\r\n\t\tversions.push(options.currentVersion);\r\n\t}\r\n\r\n\tif (versions.length === 0) {\r\n\t\tif (options.gitTagFallback) {\r\n\t\t\tconst version = await getLatestGitTagVersion(options.tagPrefix);\r\n\t\t\tif (version) {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tfiles: [],\r\n\t\t\t\t\tcurrentVersion: version,\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthrow new Error(\"Unable to find current version\");\r\n\t} else if (versions.length > 1) {\r\n\t\tthrow new Error(\"Found multiple versions\");\r\n\t}\r\n\r\n\treturn {\r\n\t\tfiles,\r\n\t\tcurrentVersion: versions[0],\r\n\t};\r\n}\r\n\r\n/**\r\n * Get the priority of given type.\r\n * @example\r\n * - \"patch\" => 0\r\n * - \"minor\" => 1\r\n * - \"major\" => 2\r\n */\r\nfunction getPriority(type?: string): number {\r\n\treturn [\"patch\", \"minor\", \"major\"].indexOf(type || \"\");\r\n}\r\n\r\n/**\r\n * Get the given versions highest state.\r\n * @example\r\n * - \"patch\"\r\n * - \"minor\"\r\n * - \"major\"\r\n */\r\nfunction getVersionType(version: string): \"patch\" | \"minor\" | \"major\" | undefined {\r\n\tconst parseVersion = semver.parse(version);\r\n\tif (parseVersion?.major) {\r\n\t\treturn \"major\";\r\n\t} else if (parseVersion?.minor) {\r\n\t\treturn \"minor\";\r\n\t} else if (parseVersion?.patch) {\r\n\t\treturn \"patch\";\r\n\t}\r\n\treturn undefined;\r\n}\r\n\r\n/**\r\n * Get the recommended release type for the given version depending on if\r\n * the user asks for a prerelease with or without a tag.\r\n */\r\nfunction getReleaseType(\r\n\treleaseType: \"major\" | \"minor\" | \"patch\",\r\n\tcurrentVersion: string,\r\n\tpreReleaseTag?: string | boolean,\r\n): ReleaseType {\r\n\tif (!preReleaseTag) {\r\n\t\treturn releaseType;\r\n\t}\r\n\r\n\tif (Array.isArray(semver.prerelease(currentVersion))) {\r\n\t\tconst currentReleaseType = getVersionType(currentVersion);\r\n\r\n\t\tif (\r\n\t\t\tcurrentReleaseType === releaseType ||\r\n\t\t\tgetPriority(currentReleaseType) > getPriority(releaseType)\r\n\t\t) {\r\n\t\t\treturn \"prerelease\";\r\n\t\t}\r\n\t}\r\n\r\n\treturn `pre${releaseType}`;\r\n}\r\n\r\ntype NextVersion = {\r\n\tnextVersion: string;\r\n\tlevel?: number;\r\n\tpreMajor?: boolean;\r\n\treason?: string;\r\n\treleaseType?: ReleaseType;\r\n};\r\n\r\n/**\r\n * Get the next version from the given files.\r\n */\r\nasync function getNextVersion(options: ForkConfig, currentVersion: string): Promise<NextVersion> {\r\n\tif (options.nextVersion && semver.valid(options.nextVersion)) {\r\n\t\treturn { nextVersion: options.nextVersion };\r\n\t}\r\n\r\n\tconst preMajor = semver.lt(currentVersion, \"1.0.0\");\r\n\tconst recommendedBump = await conventionalRecommendedBump({\r\n\t\tpreset: {\r\n\t\t\tname: \"conventionalcommits\",\r\n\t\t\t...(options.changelogPresetConfig || {}),\r\n\t\t\tpreMajor,\r\n\t\t},\r\n\t\tpath: options.changePath,\r\n\t\ttagPrefix: options.tagPrefix,\r\n\t\tcwd: options.changePath,\r\n\t});\r\n\r\n\tif (recommendedBump.releaseType) {\r\n\t\tconst releaseType = getReleaseType(\r\n\t\t\trecommendedBump.releaseType,\r\n\t\t\tcurrentVersion,\r\n\t\t\toptions.preReleaseTag,\r\n\t\t);\r\n\r\n\t\treturn Object.assign(recommendedBump, {\r\n\t\t\tpreMajor,\r\n\t\t\treleaseType,\r\n\t\t\tnextVersion:\r\n\t\t\t\tsemver.inc(\r\n\t\t\t\t\tcurrentVersion,\r\n\t\t\t\t\treleaseType,\r\n\t\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : undefined,\r\n\t\t\t\t) || \"\",\r\n\t\t});\r\n\t}\r\n\r\n\tthrow new Error(\"Unable to find next version\");\r\n}\r\n\r\nfunction updateFile(\r\n\toptions: ForkConfig,\r\n\tfileToUpdate: string,\r\n\ttype: string,\r\n\tnextVersion: string,\r\n): void {\r\n\ttry {\r\n\t\tif (type === \"package-file\") {\r\n\t\t\tif (!lstatSync(fileToUpdate).isFile()) return;\r\n\r\n\t\t\tconst fileContents = readFileSync(fileToUpdate, \"utf8\");\r\n\t\t\tconst indent = detectIndent(fileContents).indent;\r\n\t\t\tconst newline = detectNewLine(fileContents);\r\n\t\t\tconst parsedJson = JSON.parse(fileContents);\r\n\r\n\t\t\tparsedJson.version = nextVersion;\r\n\t\t\tif (parsedJson.packages && parsedJson.packages[\"\"]) {\r\n\t\t\t\tparsedJson.packages[\"\"].version = nextVersion; // package-lock v2 stores version there too\r\n\t\t\t}\r\n\r\n\t\t\tif (!options.dryRun) {\r\n\t\t\t\twriteFileSync(fileToUpdate, stringifyPackage(parsedJson, indent, newline), \"utf8\");\r\n\t\t\t}\r\n\t\t}\r\n\t} catch (error) {\r\n\t\toptions.error(\"Error writing: \", error);\r\n\t}\r\n}\r\n\r\nexport type BumpVersion = CurrentVersion & NextVersion;\r\n\r\nexport async function bumpVersion(options: ForkConfig): Promise<BumpVersion> {\r\n\tconst current = await getCurrentVersion(options);\r\n\tconst next = await getNextVersion(options, current.currentVersion);\r\n\r\n\toptions.log(`Current version: ${current.currentVersion}\r\nNext version: ${next.nextVersion} (${next.releaseType})\r\nUpdating Files: `);\r\n\r\n\tfor (const outFile of current.files) {\r\n\t\toptions.log(`\\t${outFile.path}`);\r\n\r\n\t\tupdateFile(options, outFile.path, outFile.type, next.nextVersion);\r\n\t}\r\n\r\n\treturn {\r\n\t\tcurrentVersion: current.currentVersion,\r\n\t\tfiles: current.files,\r\n\r\n\t\tnextVersion: next.nextVersion,\r\n\t\tlevel: next.level,\r\n\t\tpreMajor: next.preMajor,\r\n\t\treason: next.reason,\r\n\t\treleaseType: next.releaseType,\r\n\t};\r\n}\r\n","/**\r\n * https://github.com/npm/stringify-package/blob/main/LICENSE\r\n * Extracted from npm/stringify-package\r\n *\r\n * Copyright npm, Inc\r\n *\r\n * Permission to use, copy, modify, and/or distribute this software for any\r\n * purpose with or without fee is hereby granted, provided that the above\r\n * copyright notice and this permission notice appear in all copies.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\r\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\r\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\r\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\r\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\r\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\r\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\r\n */\r\n\r\nconst DEFAULT_INDENT = 2;\r\nconst CRLF = \"\\r\\n\";\r\nconst LF = \"\\n\";\r\n\r\nexport function stringifyPackage(\r\n\tdata: string,\r\n\tindent?: string | number,\r\n\tnewline?: typeof CRLF | typeof LF,\r\n): string {\r\n\tconst stringified = JSON.stringify(data, null, indent || (indent === 0 ? 0 : DEFAULT_INDENT));\r\n\r\n\tif (newline === CRLF) {\r\n\t\treturn stringified.replace(new RegExp(LF, \"g\"), CRLF);\r\n\t}\r\n\r\n\treturn stringified;\r\n}\r\n","import { resolve } from \"node:path\";\r\nimport { constants, accessSync, writeFileSync, readFileSync, existsSync } from \"node:fs\";\r\nimport conventionalChangelog from \"conventional-changelog\";\r\nimport type { ForkConfig } from \"../configuration.js\";\r\nimport type { BumpVersion } from \"./version.js\";\r\n\r\ntype CreateChangelog = {\r\n\tpath: string;\r\n\texists: boolean;\r\n};\r\n\r\nfunction createChangelog(options: ForkConfig): CreateChangelog {\r\n\tconst changelogPath = resolve(options.changelog);\r\n\r\n\ttry {\r\n\t\taccessSync(changelogPath, constants.F_OK);\r\n\t} catch (err) {\r\n\t\tif (!options.dryRun && (err as { code: string }).code === \"ENOENT\") {\r\n\t\t\toptions.log(`Creating Changelog file: ${changelogPath}`);\r\n\r\n\t\t\twriteFileSync(changelogPath, \"\\n\", \"utf8\");\r\n\t\t}\r\n\t}\r\n\r\n\treturn {\r\n\t\tpath: changelogPath,\r\n\t\texists: existsSync(changelogPath),\r\n\t};\r\n}\r\n\r\n/**\r\n * Matches the following formats:\r\n * @example\r\n * `## [0.0.0]` or `<a name=\"0.0.0\"></a>`\r\n */\r\nconst RELEASE_PATTERN = /(^#+ \\[?[0-9]+\\.[0-9]+\\.[0-9]+|<a name=)/m;\r\n\r\n/**\r\n * Gets the rest of the changelog from the latest release onwards.\r\n * @see {@link RELEASE_PATTERN}\r\n */\r\nfunction getOldReleaseContent(changelog: CreateChangelog): string {\r\n\tif (changelog.exists) {\r\n\t\tconst fileContents = readFileSync(changelog.path, \"utf-8\");\r\n\t\tconst oldContentStart = fileContents.search(RELEASE_PATTERN);\r\n\r\n\t\tif (oldContentStart !== -1) {\r\n\t\t\treturn fileContents.substring(oldContentStart);\r\n\t\t}\r\n\t}\r\n\r\n\treturn \"\";\r\n}\r\n\r\nfunction getNewReleaseContent(options: ForkConfig, bumpResult: BumpVersion): Promise<string> {\r\n\treturn new Promise<string>((resolve) => {\r\n\t\tlet newContent = \"\";\r\n\r\n\t\tconventionalChangelog(\r\n\t\t\t{\r\n\t\t\t\tpreset: {\r\n\t\t\t\t\tname: \"conventionalcommits\",\r\n\t\t\t\t\t...(options.changelogPresetConfig || {}),\r\n\t\t\t\t},\r\n\t\t\t\ttagPrefix: options.tagPrefix,\r\n\t\t\t\twarn: (...message: string[]) => options.error(\"conventional-changelog: \", ...message),\r\n\t\t\t\tcwd: options.changePath,\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tversion: bumpResult.nextVersion,\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tmerges: null,\r\n\t\t\t\tpath: options.changePath,\r\n\t\t\t},\r\n\t\t)\r\n\t\t\t.on(\"error\", (error) => {\r\n\t\t\t\toptions.error(\"conventional-changelog: Unable to parse changes\");\r\n\t\t\t\tthrow error;\r\n\t\t\t})\r\n\t\t\t.on(\"data\", (chunk) => {\r\n\t\t\t\tnewContent += chunk.toString();\r\n\t\t\t})\r\n\t\t\t.on(\"end\", () => {\r\n\t\t\t\tresolve(newContent);\r\n\t\t\t});\r\n\t});\r\n}\r\n\r\ntype UpdateChangelog = {\r\n\tchangelog: CreateChangelog;\r\n\toldContent: string;\r\n\tnewContent: string;\r\n};\r\n\r\nexport async function updateChangelog(\r\n\toptions: ForkConfig,\r\n\tbumpResult: BumpVersion,\r\n): Promise<UpdateChangelog> {\r\n\tif (options.header.search(RELEASE_PATTERN) !== -1) {\r\n\t\t// Need to ensure the header doesn't contain the release pattern\r\n\t\tthrow new Error(\"Header cannot contain release pattern\");\r\n\t}\r\n\r\n\tconst changelog = createChangelog(options);\r\n\tconst oldContent = getOldReleaseContent(changelog);\r\n\tconst newContent = await getNewReleaseContent(options, bumpResult);\r\n\r\n\toptions.log(`Updating Changelog:\r\n\\t${changelog.path}`);\r\n\r\n\tif (!options.dryRun && newContent) {\r\n\t\twriteFileSync(changelog.path, `${options.header}\\n${newContent}\\n${oldContent}`, \"utf8\");\r\n\t}\r\n\r\n\treturn {\r\n\t\tchangelog,\r\n\t\toldContent,\r\n\t\tnewContent,\r\n\t};\r\n}\r\n","import { execFile } from \"node:child_process\";\r\nimport type { ForkConfig } from \"../configuration.js\";\r\n\r\nexport function createExecute(options: ForkConfig) {\r\n\t/**\r\n\t * Executes a git command with the given arguments and returns the output.\r\n\t */\r\n\tasync function executeGit(...execArgs: (string | undefined)[]): Promise<string> {\r\n\t\tconst args = execArgs.filter(Boolean) as string[];\r\n\r\n\t\toptions.debug(`Executing: git ${args.join(\" \")}`);\r\n\r\n\t\tif (!options.dryRun) {\r\n\t\t\treturn new Promise((resolve) => {\r\n\t\t\t\texecFile(\"git\", args, (error, stdout, stderr) => {\r\n\t\t\t\t\tif (error) {\r\n\t\t\t\t\t\toptions.error(`git ${args[0]}:`);\r\n\t\t\t\t\t\tthrow error;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tresolve(stdout ? stdout : stderr);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\treturn {\r\n\t\texecuteGit,\r\n\t};\r\n}\r\n","/**\r\n * Formats the commit message by replacing the `{{currentTag}}` placeholder\r\n * globally with the new version.\r\n *\r\n * Falls back to `chore(release): {{currentTag}}` if message is argument is falsy.\r\n */\r\nexport function formatCommitMessage(message: string | undefined, newVersion: string): string {\r\n\tif (!message) {\r\n\t\tmessage = \"chore(release): {{currentTag}}\";\r\n\t}\r\n\r\n\treturn message.replace(new RegExp(\"{{currentTag}}\", \"g\"), newVersion);\r\n}\r\n","import { createExecute } from \"../utils/execute-file.js\";\r\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\r\nimport type { ForkConfig } from \"../configuration.js\";\r\nimport type { BumpVersion } from \"./version.js\";\r\n\r\ntype CommitChanges = {\r\n\tfilesToCommit: string[];\r\n\tgitAddOutput?: string;\r\n\tgitCommitOutput?: string;\r\n};\r\n\r\nexport async function commitChanges(\r\n\toptions: ForkConfig,\r\n\tbumpResult: BumpVersion,\r\n): Promise<CommitChanges> {\r\n\tconst { executeGit } = createExecute(options);\r\n\r\n\toptions.log(\"Committing changes\");\r\n\r\n\tconst filesToCommit: string[] = [options.changelog];\r\n\tfor (const file of bumpResult.files) {\r\n\t\tfilesToCommit.push(file.name);\r\n\t}\r\n\r\n\t// If there are no files to commit don't continue.\r\n\tif (filesToCommit.length === 0) {\r\n\t\treturn {\r\n\t\t\tfilesToCommit,\r\n\t\t};\r\n\t}\r\n\r\n\tconst gitAddOutput = await executeGit(\"add\", ...filesToCommit);\r\n\r\n\tconst shouldVerify = options.verify ? undefined : \"--no-verify\";\r\n\tconst shouldSign = options.sign ? \"-S\" : undefined;\r\n\tconst shouldCommitAll = options.commitAll ? [] : filesToCommit;\r\n\r\n\tconst gitCommitOutput = await executeGit(\r\n\t\t\"commit\",\r\n\t\tshouldVerify,\r\n\t\tshouldSign,\r\n\t\t...shouldCommitAll,\r\n\t\t\"-m\",\r\n\t\tformatCommitMessage(\r\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\r\n\t\t\tbumpResult.nextVersion,\r\n\t\t),\r\n\t);\r\n\r\n\treturn {\r\n\t\tfilesToCommit,\r\n\t\tgitAddOutput,\r\n\t\tgitCommitOutput,\r\n\t};\r\n}\r\n","import { createExecute } from \"../utils/execute-file.js\";\r\nimport { formatCommitMessage } from \"../utils/format-commit-message.js\";\r\nimport type { ForkConfig } from \"../configuration.js\";\r\nimport type { BumpVersion } from \"./version.js\";\r\n\r\ntype TagChanges = {\r\n\tgitTagOutput: string;\r\n\tcurrentBranchName: string;\r\n\thasPublicPackageFile: boolean;\r\n\tpushMessage: string;\r\n\tpublishMessage: string;\r\n};\r\n\r\nexport async function tagChanges(\r\n\toptions: ForkConfig,\r\n\tbumpResult: BumpVersion,\r\n): Promise<TagChanges> {\r\n\tconst { executeGit } = createExecute(options);\r\n\r\n\tconst shouldSign = options.sign ? \"-s\" : \"-a\";\r\n\t/** @example \"v1.2.3\" or \"version/1.2.3\" */\r\n\tconst tag = `${options.tagPrefix}${bumpResult.nextVersion}`;\r\n\r\n\toptions.log(`Creating Tag: ${tag}`);\r\n\r\n\tconst gitTagOutput = await executeGit(\r\n\t\t\"tag\",\r\n\t\tshouldSign,\r\n\t\ttag,\r\n\t\t\"-m\",\r\n\t\tformatCommitMessage(\r\n\t\t\toptions.changelogPresetConfig?.releaseCommitMessageFormat,\r\n\t\t\tbumpResult.nextVersion,\r\n\t\t),\r\n\t);\r\n\r\n\tconst currentBranchName = await executeGit(\"rev-parse\", \"--abbrev-ref\", \"HEAD\");\r\n\r\n\tconst hasPublicPackageFile = bumpResult.files.some(\r\n\t\t(file) => file.name === \"package.json\" && file.isPrivate === false,\r\n\t);\r\n\tconst isPreRelease = `${bumpResult.releaseType}`.startsWith(\"pre\");\r\n\r\n\tconst pushMessage = `Run \\`git push --follow-tags origin ${currentBranchName.trim()}\\` to push the changes and the tag.`;\r\n\tconst publishMessage = isPreRelease\r\n\t\t? `Run \\`npm publish --tag ${\r\n\t\t\t\ttypeof options.preReleaseTag === \"string\" ? options.preReleaseTag : \"prerelease\"\r\n\t\t }\\` to publish the package.`\r\n\t\t: \"Run `npm publish` to publish the package.\";\r\n\r\n\toptions.log(`\\n${pushMessage}\\n${hasPublicPackageFile ? publishMessage : \"\"}`);\r\n\r\n\treturn {\r\n\t\tgitTagOutput,\r\n\t\tcurrentBranchName,\r\n\t\thasPublicPackageFile,\r\n\t\tpushMessage,\r\n\t\tpublishMessage,\r\n\t};\r\n}\r\n"]}
|