Comparing version 9.3.1 to 9.4.0
@@ -63,3 +63,3 @@ var __create = Object.create; | ||
var require_picocolors = __commonJS({ | ||
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports, module2) { | ||
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports2, module2) { | ||
var tty2 = require("tty"); | ||
@@ -632,3 +632,3 @@ var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env); | ||
// package.json | ||
var version = "9.3.1"; | ||
var version = "9.4.0"; | ||
@@ -649,3 +649,3 @@ // src/version-bump.ts | ||
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"]; | ||
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]); | ||
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]); | ||
function isPrerelease(value) { | ||
@@ -661,3 +661,3 @@ return prereleaseTypes.includes(value); | ||
const { release } = operation.options; | ||
const { oldVersion } = operation.state; | ||
const { currentVersion } = operation.state; | ||
switch (release.type) { | ||
@@ -673,9 +673,10 @@ case "prompt": | ||
release: release.type, | ||
newVersion: getNextVersion(oldVersion, release) | ||
newVersion: getNextVersion(currentVersion, release) | ||
}); | ||
} | ||
} | ||
function getNextVersion(oldVersion, bump) { | ||
const oldSemVer = new import_semver.SemVer(oldVersion); | ||
const newSemVer = oldSemVer.inc(bump.type, bump.preid); | ||
function getNextVersion(currentVersion, bump) { | ||
const oldSemVer = new import_semver.SemVer(currentVersion); | ||
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type; | ||
const newSemVer = oldSemVer.inc(type, bump.preid); | ||
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") { | ||
@@ -687,11 +688,9 @@ newSemVer.prerelease[1] = "1"; | ||
} | ||
function getNextVersions(oldVersion, preid) { | ||
var _a; | ||
function getNextVersions(currentVersion, preid) { | ||
const next = {}; | ||
const parse = import_semver.default.parse(oldVersion); | ||
const parse = import_semver.default.parse(currentVersion); | ||
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string") | ||
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid"; | ||
for (const type of releaseTypes) | ||
next[type] = import_semver.default.inc(oldVersion, type, preid); | ||
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver.default.inc(oldVersion, "prerelease", preid) : import_semver.default.inc(oldVersion, "patch"); | ||
next[type] = getNextVersion(currentVersion, { type, preid }); | ||
return next; | ||
@@ -701,6 +700,6 @@ } | ||
var _a, _b; | ||
const { oldVersion } = operation.state; | ||
const { currentVersion } = operation.state; | ||
const release = operation.options.release; | ||
const next = getNextVersions(oldVersion, release.preid); | ||
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, oldVersion, import_semver.default)); | ||
const next = getNextVersions(currentVersion, release.preid); | ||
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, import_semver.default)); | ||
const PADDING = 13; | ||
@@ -711,3 +710,3 @@ const answers = await (0, import_prompts.default)([ | ||
name: "release", | ||
message: `Current version ${import_picocolors.default.green(oldVersion)}`, | ||
message: `Current version ${import_picocolors.default.green(currentVersion)}`, | ||
initial: configCustomVersion ? "config" : "next", | ||
@@ -725,3 +724,3 @@ choices: [ | ||
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` }, | ||
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(oldVersion)}` }, | ||
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` }, | ||
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") } | ||
@@ -734,3 +733,3 @@ ] | ||
message: "Enter the new version number:", | ||
initial: oldVersion, | ||
initial: currentVersion, | ||
validate: (custom) => { | ||
@@ -741,3 +740,3 @@ return (0, import_semver.valid)(custom) ? true : "That's not a valid version number"; | ||
]); | ||
const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? (0, import_semver.clean)(answers.custom) : answers.release === "config" ? (0, import_semver.clean)(configCustomVersion) : next[answers.release]; | ||
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver.clean)(answers.custom) : answers.release === "config" ? (0, import_semver.clean)(configCustomVersion) : next[answers.release]; | ||
if (!newVersion) | ||
@@ -756,3 +755,3 @@ import_node_process3.default.exit(1); | ||
// src/get-old-version.ts | ||
// src/get-current-version.ts | ||
var import_semver2 = require("semver"); | ||
@@ -931,4 +930,6 @@ | ||
// src/get-old-version.ts | ||
async function getOldVersion(operation) { | ||
// src/get-current-version.ts | ||
async function getCurrentVersion(operation) { | ||
if (operation.state.currentVersion) | ||
return operation; | ||
const { cwd, files } = operation.options; | ||
@@ -942,4 +943,4 @@ const filesToCheck = files.filter((file) => file.endsWith(".json")); | ||
return operation.update({ | ||
oldVersionSource: file, | ||
oldVersion: version2 | ||
currentVersionSource: file, | ||
currentVersion: version2 | ||
}); | ||
@@ -1034,3 +1035,3 @@ } | ||
release = { type: "prompt", preid }; | ||
else if (isReleaseType(raw.release)) | ||
else if (isReleaseType(raw.release) || raw.release === "next") | ||
release = { type: raw.release, preid }; | ||
@@ -1084,3 +1085,4 @@ else | ||
execute, | ||
customVersion: raw.customVersion | ||
customVersion: raw.customVersion, | ||
currentVersion: raw.currentVersion | ||
}; | ||
@@ -1100,4 +1102,4 @@ } | ||
release: void 0, | ||
oldVersion: "", | ||
oldVersionSource: "", | ||
currentVersion: "", | ||
currentVersionSource: "", | ||
newVersion: "", | ||
@@ -1111,2 +1113,8 @@ commitMessage: "", | ||
this._progress = progress2; | ||
if (options.currentVersion) { | ||
this.update({ | ||
currentVersion: options.currentVersion, | ||
currentVersionSource: "user" | ||
}); | ||
} | ||
} | ||
@@ -1121,3 +1129,3 @@ /** | ||
release: state.release, | ||
oldVersion: state.oldVersion, | ||
currentVersion: state.currentVersion, | ||
newVersion: state.newVersion, | ||
@@ -1210,5 +1218,4 @@ commit: options.commit ? state.commitMessage : false, | ||
file.data.version = newVersion; | ||
if (isPackageLockManifest(file.data)) { | ||
if (isPackageLockManifest(file.data)) | ||
file.data.packages[""].version = newVersion; | ||
} | ||
await writeJsonFile(file); | ||
@@ -1221,7 +1228,7 @@ modified = true; | ||
const { cwd } = operation.options; | ||
const { oldVersion, newVersion } = operation.state; | ||
const { currentVersion, newVersion } = operation.state; | ||
const modified = false; | ||
const file = await readTextFile(relPath, cwd); | ||
if (file.data.includes(oldVersion)) { | ||
const sanitizedVersion = oldVersion.replace(/(\W)/g, "\\$1"); | ||
if (file.data.includes(currentVersion)) { | ||
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1"); | ||
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g"); | ||
@@ -1240,3 +1247,3 @@ file.data = file.data.replace(replacePattern, `$1${newVersion}`); | ||
const operation = await Operation.start(arg); | ||
await getOldVersion(operation); | ||
await getCurrentVersion(operation); | ||
await getNewVersion(operation); | ||
@@ -1279,3 +1286,3 @@ if (arg.confirm) { | ||
console.log(); | ||
console.log(` from ${import_picocolors2.default.bold(operation.state.oldVersion)}`); | ||
console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`); | ||
console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`); | ||
@@ -1296,3 +1303,5 @@ console.log(); | ||
var import_node_process6 = __toESM(require("process")); | ||
var import_node_path2 = require("path"); | ||
var import_c12 = require("c12"); | ||
var import_sync = __toESM(require("escalade/sync")); | ||
var bumpConfigDefaults = { | ||
@@ -1310,10 +1319,37 @@ commit: true, | ||
async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd()) { | ||
const name = "bump"; | ||
const configFile = findConfigFile(name, cwd); | ||
const { config } = await (0, import_c12.loadConfig)({ | ||
name: "bump", | ||
name, | ||
defaults: bumpConfigDefaults, | ||
overrides: __spreadValues({}, overrides), | ||
cwd | ||
cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd | ||
}); | ||
return config; | ||
} | ||
function findConfigFile(name, cwd) { | ||
let foundRepositoryRoot = false; | ||
try { | ||
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`); | ||
return (0, import_sync.default)(cwd, (_dir, files) => { | ||
const match = files.find((file) => { | ||
if (candidates.includes(file)) | ||
return true; | ||
if (file === ".git") | ||
foundRepositoryRoot = true; | ||
return false; | ||
}); | ||
if (match) | ||
return match; | ||
if (foundRepositoryRoot) { | ||
throw null; | ||
} | ||
return false; | ||
}); | ||
} catch (error) { | ||
if (foundRepositoryRoot) | ||
return null; | ||
throw error; | ||
} | ||
} | ||
@@ -1324,6 +1360,3 @@ // src/cli/parse-args.ts | ||
try { | ||
const cli = (0, import_cac.default)("bumpp"); | ||
cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("-c, --commit [msg]", `Commit message (default: ${bumpConfigDefaults.commit})`).option("--no-commit", "Skip commit").option("-t, --tag [tag]", `Tag name (default: ${bumpConfigDefaults.tag})`).option("--no-tag", "Skip tag").option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("-x, --execute <command>", "Commands to execute after version bumps").help(); | ||
const result = cli.parse(); | ||
const args = result.options; | ||
const { args, resultArgs } = loadCliArgs(); | ||
const parsedArgs = { | ||
@@ -1335,4 +1368,4 @@ help: args.help, | ||
preid: args.preid, | ||
commit: !args.noCommit && args.commit, | ||
tag: !args.noTag && args.tag, | ||
commit: args.commit, | ||
tag: args.tag, | ||
push: args.push, | ||
@@ -1342,4 +1375,5 @@ all: args.all, | ||
noVerify: !args.verify, | ||
files: [...args["--"] || [], ...result.args], | ||
files: [...args["--"] || [], ...resultArgs], | ||
ignoreScripts: args.ignoreScripts, | ||
currentVersion: args.currentVersion, | ||
execute: args.execute, | ||
@@ -1384,2 +1418,19 @@ recursive: !!args.recursive | ||
} | ||
function loadCliArgs(argv = import_node_process7.default.argv) { | ||
const cli = (0, import_cac.default)("bumpp"); | ||
cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("-c, --commit [msg]", "Commit message", { default: true }).option("--no-commit", "Skip commit", { default: false }).option("-t, --tag [tag]", "Tag name", { default: true }).option("--no-tag", "Skip tag", { default: false }).option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("--current-version <version>", "Current version").option("-x, --execute <command>", "Commands to execute after version bumps").help(); | ||
const result = cli.parse(argv); | ||
const rawArgs = cli.rawArgs; | ||
const args = result.options; | ||
const hasCommitFlag = rawArgs.some((arg) => ["-c", "--commit", "--no-commit"].includes(arg)); | ||
const hasTagFlag = rawArgs.some((arg) => ["-t", "--tag", "--no-tag"].includes(arg)); | ||
const _a = args, { tag, commit } = _a, rest = __objRest(_a, ["tag", "commit"]); | ||
return { | ||
args: __spreadProps(__spreadValues({}, rest), { | ||
commit: hasCommitFlag ? commit : void 0, | ||
tag: hasTagFlag ? tag : void 0 | ||
}), | ||
resultArgs: result.args | ||
}; | ||
} | ||
function errorHandler(error) { | ||
@@ -1386,0 +1437,0 @@ console.error(error.message); |
@@ -1,4 +0,5 @@ | ||
import _semver, { ReleaseType } from 'semver'; | ||
export { ReleaseType } from 'semver'; | ||
import _semver, { ReleaseType as ReleaseType$1 } from 'semver'; | ||
type ReleaseType = ReleaseType$1 | 'next'; | ||
/** | ||
@@ -15,3 +16,3 @@ * Information about the work that was performed by the `versionBump()` function. | ||
*/ | ||
oldVersion: string; | ||
currentVersion: string; | ||
/** | ||
@@ -87,2 +88,7 @@ * The new version number. | ||
/** | ||
* The current version number to be bumpped. | ||
* If not provide, it will be read from the first file in the `files` array. | ||
*/ | ||
currentVersion?: string; | ||
/** | ||
* The prerelease type (e.g. "alpha", "beta", "next"). | ||
@@ -170,3 +176,3 @@ * | ||
*/ | ||
progress?(progress: VersionBumpProgress): void; | ||
progress?: (progress: VersionBumpProgress) => void; | ||
/** | ||
@@ -269,2 +275,3 @@ * Excute additional command after bumping and before commiting | ||
customVersion?: VersionBumpOptions['customVersion']; | ||
currentVersion?: string; | ||
} | ||
@@ -274,4 +281,4 @@ | ||
release: ReleaseType | undefined; | ||
oldVersionSource: string; | ||
oldVersion: string; | ||
currentVersionSource: string; | ||
currentVersion: string; | ||
newVersion: string; | ||
@@ -352,2 +359,2 @@ commitMessage: string; | ||
export { type InterfaceOptions, NpmScript, ProgressEvent, type VersionBumpOptions, type VersionBumpProgress, type VersionBumpResults, bumpConfigDefaults, versionBump as default, defineConfig, loadBumpConfig, versionBump, versionBumpInfo }; | ||
export { type InterfaceOptions, NpmScript, ProgressEvent, type ReleaseType, type VersionBumpOptions, type VersionBumpProgress, type VersionBumpResults, bumpConfigDefaults, versionBump as default, defineConfig, loadBumpConfig, versionBump, versionBumpInfo }; |
@@ -63,3 +63,3 @@ var __create = Object.create; | ||
var require_picocolors = __commonJS({ | ||
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports, module2) { | ||
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports2, module2) { | ||
var tty2 = require("tty"); | ||
@@ -653,3 +653,3 @@ var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env); | ||
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"]; | ||
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]); | ||
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]); | ||
function isPrerelease(value) { | ||
@@ -665,3 +665,3 @@ return prereleaseTypes.includes(value); | ||
const { release } = operation.options; | ||
const { oldVersion } = operation.state; | ||
const { currentVersion } = operation.state; | ||
switch (release.type) { | ||
@@ -677,9 +677,10 @@ case "prompt": | ||
release: release.type, | ||
newVersion: getNextVersion(oldVersion, release) | ||
newVersion: getNextVersion(currentVersion, release) | ||
}); | ||
} | ||
} | ||
function getNextVersion(oldVersion, bump) { | ||
const oldSemVer = new import_semver.SemVer(oldVersion); | ||
const newSemVer = oldSemVer.inc(bump.type, bump.preid); | ||
function getNextVersion(currentVersion, bump) { | ||
const oldSemVer = new import_semver.SemVer(currentVersion); | ||
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type; | ||
const newSemVer = oldSemVer.inc(type, bump.preid); | ||
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") { | ||
@@ -691,11 +692,9 @@ newSemVer.prerelease[1] = "1"; | ||
} | ||
function getNextVersions(oldVersion, preid) { | ||
var _a; | ||
function getNextVersions(currentVersion, preid) { | ||
const next = {}; | ||
const parse = import_semver.default.parse(oldVersion); | ||
const parse = import_semver.default.parse(currentVersion); | ||
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string") | ||
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid"; | ||
for (const type of releaseTypes) | ||
next[type] = import_semver.default.inc(oldVersion, type, preid); | ||
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver.default.inc(oldVersion, "prerelease", preid) : import_semver.default.inc(oldVersion, "patch"); | ||
next[type] = getNextVersion(currentVersion, { type, preid }); | ||
return next; | ||
@@ -705,6 +704,6 @@ } | ||
var _a, _b; | ||
const { oldVersion } = operation.state; | ||
const { currentVersion } = operation.state; | ||
const release = operation.options.release; | ||
const next = getNextVersions(oldVersion, release.preid); | ||
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, oldVersion, import_semver.default)); | ||
const next = getNextVersions(currentVersion, release.preid); | ||
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, import_semver.default)); | ||
const PADDING = 13; | ||
@@ -715,3 +714,3 @@ const answers = await (0, import_prompts.default)([ | ||
name: "release", | ||
message: `Current version ${import_picocolors.default.green(oldVersion)}`, | ||
message: `Current version ${import_picocolors.default.green(currentVersion)}`, | ||
initial: configCustomVersion ? "config" : "next", | ||
@@ -729,3 +728,3 @@ choices: [ | ||
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` }, | ||
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(oldVersion)}` }, | ||
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` }, | ||
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") } | ||
@@ -738,3 +737,3 @@ ] | ||
message: "Enter the new version number:", | ||
initial: oldVersion, | ||
initial: currentVersion, | ||
validate: (custom) => { | ||
@@ -745,3 +744,3 @@ return (0, import_semver.valid)(custom) ? true : "That's not a valid version number"; | ||
]); | ||
const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? (0, import_semver.clean)(answers.custom) : answers.release === "config" ? (0, import_semver.clean)(configCustomVersion) : next[answers.release]; | ||
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver.clean)(answers.custom) : answers.release === "config" ? (0, import_semver.clean)(configCustomVersion) : next[answers.release]; | ||
if (!newVersion) | ||
@@ -760,3 +759,3 @@ import_node_process3.default.exit(1); | ||
// src/get-old-version.ts | ||
// src/get-current-version.ts | ||
var import_semver2 = require("semver"); | ||
@@ -935,4 +934,6 @@ | ||
// src/get-old-version.ts | ||
async function getOldVersion(operation) { | ||
// src/get-current-version.ts | ||
async function getCurrentVersion(operation) { | ||
if (operation.state.currentVersion) | ||
return operation; | ||
const { cwd, files } = operation.options; | ||
@@ -946,4 +947,4 @@ const filesToCheck = files.filter((file) => file.endsWith(".json")); | ||
return operation.update({ | ||
oldVersionSource: file, | ||
oldVersion: version | ||
currentVersionSource: file, | ||
currentVersion: version | ||
}); | ||
@@ -1057,3 +1058,3 @@ } | ||
release = { type: "prompt", preid }; | ||
else if (isReleaseType(raw.release)) | ||
else if (isReleaseType(raw.release) || raw.release === "next") | ||
release = { type: raw.release, preid }; | ||
@@ -1107,3 +1108,4 @@ else | ||
execute, | ||
customVersion: raw.customVersion | ||
customVersion: raw.customVersion, | ||
currentVersion: raw.currentVersion | ||
}; | ||
@@ -1123,4 +1125,4 @@ } | ||
release: void 0, | ||
oldVersion: "", | ||
oldVersionSource: "", | ||
currentVersion: "", | ||
currentVersionSource: "", | ||
newVersion: "", | ||
@@ -1134,2 +1136,8 @@ commitMessage: "", | ||
this._progress = progress; | ||
if (options.currentVersion) { | ||
this.update({ | ||
currentVersion: options.currentVersion, | ||
currentVersionSource: "user" | ||
}); | ||
} | ||
} | ||
@@ -1144,3 +1152,3 @@ /** | ||
release: state.release, | ||
oldVersion: state.oldVersion, | ||
currentVersion: state.currentVersion, | ||
newVersion: state.newVersion, | ||
@@ -1233,5 +1241,4 @@ commit: options.commit ? state.commitMessage : false, | ||
file.data.version = newVersion; | ||
if (isPackageLockManifest(file.data)) { | ||
if (isPackageLockManifest(file.data)) | ||
file.data.packages[""].version = newVersion; | ||
} | ||
await writeJsonFile(file); | ||
@@ -1244,7 +1251,7 @@ modified = true; | ||
const { cwd } = operation.options; | ||
const { oldVersion, newVersion } = operation.state; | ||
const { currentVersion, newVersion } = operation.state; | ||
const modified = false; | ||
const file = await readTextFile(relPath, cwd); | ||
if (file.data.includes(oldVersion)) { | ||
const sanitizedVersion = oldVersion.replace(/(\W)/g, "\\$1"); | ||
if (file.data.includes(currentVersion)) { | ||
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1"); | ||
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g"); | ||
@@ -1263,3 +1270,3 @@ file.data = file.data.replace(replacePattern, `$1${newVersion}`); | ||
const operation = await Operation.start(arg); | ||
await getOldVersion(operation); | ||
await getCurrentVersion(operation); | ||
await getNewVersion(operation); | ||
@@ -1302,3 +1309,3 @@ if (arg.confirm) { | ||
console.log(); | ||
console.log(` from ${import_picocolors2.default.bold(operation.state.oldVersion)}`); | ||
console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`); | ||
console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`); | ||
@@ -1311,3 +1318,3 @@ console.log(); | ||
const operation = await Operation.start(arg); | ||
await getOldVersion(operation); | ||
await getCurrentVersion(operation); | ||
await getNewVersion(operation); | ||
@@ -1319,3 +1326,5 @@ return operation; | ||
var import_node_process6 = __toESM(require("process")); | ||
var import_node_path2 = require("path"); | ||
var import_c12 = require("c12"); | ||
var import_sync = __toESM(require("escalade/sync")); | ||
var bumpConfigDefaults = { | ||
@@ -1333,10 +1342,37 @@ commit: true, | ||
async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd()) { | ||
const name = "bump"; | ||
const configFile = findConfigFile(name, cwd); | ||
const { config } = await (0, import_c12.loadConfig)({ | ||
name: "bump", | ||
name, | ||
defaults: bumpConfigDefaults, | ||
overrides: __spreadValues({}, overrides), | ||
cwd | ||
cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd | ||
}); | ||
return config; | ||
} | ||
function findConfigFile(name, cwd) { | ||
let foundRepositoryRoot = false; | ||
try { | ||
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`); | ||
return (0, import_sync.default)(cwd, (_dir, files) => { | ||
const match = files.find((file) => { | ||
if (candidates.includes(file)) | ||
return true; | ||
if (file === ".git") | ||
foundRepositoryRoot = true; | ||
return false; | ||
}); | ||
if (match) | ||
return match; | ||
if (foundRepositoryRoot) { | ||
throw null; | ||
} | ||
return false; | ||
}); | ||
} catch (error) { | ||
if (foundRepositoryRoot) | ||
return null; | ||
throw error; | ||
} | ||
} | ||
function defineConfig(config) { | ||
@@ -1343,0 +1379,0 @@ return config; |
{ | ||
"name": "bumpp", | ||
"version": "9.3.1", | ||
"version": "9.4.0", | ||
"packageManager": "pnpm@8.15.4", | ||
@@ -54,6 +54,8 @@ "description": "Bump version, commit changes, tag, and push to Git", | ||
"start": "esno src/cli/run.ts", | ||
"test": "vitest", | ||
"upgrade": "npm-check -u && npm audit fix", | ||
"bumpp": "esno src/cli/run.ts", | ||
"prepublishOnly": "npm run clean && npm run build", | ||
"release": "npm run bumpp && npm publish" | ||
"release": "npm run bumpp && npm publish", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
@@ -64,2 +66,3 @@ "dependencies": { | ||
"cac": "^6.7.14", | ||
"escalade": "^3.1.2", | ||
"fast-glob": "^3.3.2", | ||
@@ -79,3 +82,3 @@ "js-yaml": "^4.1.0", | ||
"eslint": "^8.57.0", | ||
"esno": "^4.0.0", | ||
"esno": "^4.7.0", | ||
"log-symbols": "^6.0.0", | ||
@@ -86,4 +89,5 @@ "npm-check": "^6.0.1", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.3.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178073
4644
8
16
+ Addedescalade@^3.1.2
+ Addedescalade@3.2.0(transitive)