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