Socket
Socket
Sign inDemoInstall

bumpp

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bumpp - npm Package Compare versions

Comparing version 9.5.2 to 9.6.0

dist/chunk-CNEN62NE.mjs

350

dist/cli/index.js

@@ -61,5 +61,5 @@ var __create = Object.create;

// node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
// node_modules/.pnpm/picocolors@1.1.0/node_modules/picocolors/picocolors.js
var require_picocolors = __commonJS({
"node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
"node_modules/.pnpm/picocolors@1.1.0/node_modules/picocolors/picocolors.js"(exports2, module2) {
var argv = process.argv || [];

@@ -111,3 +111,19 @@ var env2 = process.env;

bgCyan: init("\x1B[46m", "\x1B[49m"),
bgWhite: init("\x1B[47m", "\x1B[49m")
bgWhite: init("\x1B[47m", "\x1B[49m"),
blackBright: init("\x1B[90m", "\x1B[39m"),
redBright: init("\x1B[91m", "\x1B[39m"),
greenBright: init("\x1B[92m", "\x1B[39m"),
yellowBright: init("\x1B[93m", "\x1B[39m"),
blueBright: init("\x1B[94m", "\x1B[39m"),
magentaBright: init("\x1B[95m", "\x1B[39m"),
cyanBright: init("\x1B[96m", "\x1B[39m"),
whiteBright: init("\x1B[97m", "\x1B[39m"),
bgBlackBright: init("\x1B[100m", "\x1B[49m"),
bgRedBright: init("\x1B[101m", "\x1B[49m"),
bgGreenBright: init("\x1B[102m", "\x1B[49m"),
bgYellowBright: init("\x1B[103m", "\x1B[49m"),
bgBlueBright: init("\x1B[104m", "\x1B[49m"),
bgMagentaBright: init("\x1B[105m", "\x1B[49m"),
bgCyanBright: init("\x1B[106m", "\x1B[49m"),
bgWhiteBright: init("\x1B[107m", "\x1B[49m")
};

@@ -641,15 +657,113 @@ };

// package.json
var version = "9.5.2";
var version = "9.6.0";
// src/version-bump.ts
var import_node_process5 = __toESM(require("process"));
var ezSpawn3 = __toESM(require("@jsdevtools/ez-spawn"));
var ezSpawn4 = __toESM(require("@jsdevtools/ez-spawn"));
var import_picocolors2 = __toESM(require_picocolors());
var import_prompts2 = __toESM(require("prompts"));
// src/get-current-version.ts
var import_semver = require("semver");
// src/fs.ts
var import_node_fs = __toESM(require("fs"));
var import_node_path = __toESM(require("path"));
var jsonc = __toESM(require("jsonc-parser"));
async function readJsoncFile(name, cwd) {
const file = await readTextFile(name, cwd);
const data = jsonc.parse(file.data);
const modified = [];
return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
}
async function writeJsoncFile(file) {
let newJSON = file.text;
for (const [key, value] of file.modified) {
const edit = jsonc.modify(file.text, key, value, {});
newJSON = jsonc.applyEdits(newJSON, edit);
}
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
}
function readTextFile(name, cwd) {
return new Promise((resolve, reject) => {
const filePath = import_node_path.default.join(cwd, name);
import_node_fs.default.readFile(filePath, "utf8", (err, text) => {
if (err) {
reject(err);
} else {
resolve({
path: filePath,
data: text
});
}
});
});
}
function writeTextFile(file) {
return new Promise((resolve, reject) => {
import_node_fs.default.writeFile(file.path, file.data, (err) => {
if (err)
reject(err);
else
resolve();
});
});
}
// src/manifest.ts
function isManifest(obj) {
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
}
function isPackageLockManifest(manifest) {
var _a, _b;
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
}
function isOptionalString(value) {
const type = typeof value;
return value === null || type === "undefined" || type === "string";
}
// src/get-current-version.ts
async function getCurrentVersion(operation) {
if (operation.state.currentVersion)
return operation;
const { cwd, files } = operation.options;
const filesToCheck = files.filter((file) => file.endsWith(".json"));
if (!filesToCheck.includes("package.json"))
filesToCheck.push("package.json");
if (!filesToCheck.includes("deno.json"))
filesToCheck.push("deno.json");
if (!filesToCheck.includes("deno.jsonc"))
filesToCheck.push("deno.jsonc");
for (const file of filesToCheck) {
const version2 = await readVersion(file, cwd);
if (version2) {
return operation.update({
currentVersionSource: file,
currentVersion: version2
});
}
}
throw new Error(
`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
);
}
async function readVersion(file, cwd) {
try {
const { data: manifest } = await readJsoncFile(file, cwd);
if (isManifest(manifest)) {
if ((0, import_semver.valid)(manifest.version))
return manifest.version;
}
} catch (e) {
return void 0;
}
}
// src/get-new-version.ts
var import_node_process3 = __toESM(require("process"));
var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
var import_picocolors = __toESM(require_picocolors());
var import_prompts = __toESM(require("prompts"));
var import_semver = __toESM(require("semver"));
var import_semver2 = __toESM(require("semver"));

@@ -675,3 +789,3 @@ // src/release-type.ts

return operation.update({
newVersion: new import_semver.SemVer(release.version, true).version
newVersion: new import_semver2.SemVer(release.version, true).version
});

@@ -686,3 +800,3 @@ default:

function getNextVersion(currentVersion, bump) {
const oldSemVer = new import_semver.SemVer(currentVersion);
const oldSemVer = new import_semver2.SemVer(currentVersion);
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;

@@ -698,3 +812,3 @@ const newSemVer = oldSemVer.inc(type, bump.preid);

const next = {};
const parse2 = import_semver.default.parse(currentVersion);
const parse2 = import_semver2.default.parse(currentVersion);
if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")

@@ -711,3 +825,6 @@ preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";

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 configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, import_semver2.default));
if (operation.options.printCommits) {
await printRecentCommits(operation);
}
const PADDING = 13;

@@ -741,7 +858,7 @@ const answers = await (0, import_prompts.default)([

validate: (custom) => {
return (0, import_semver.valid)(custom) ? true : "That's not a valid version number";
return (0, import_semver2.valid)(custom) ? true : "That's not a valid version number";
}
}
]);
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];
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver2.clean)(answers.custom) : answers.release === "config" ? (0, import_semver2.clean)(configCustomVersion) : next[answers.release];
if (!newVersion)

@@ -759,102 +876,96 @@ import_node_process3.default.exit(1);

}
// src/get-current-version.ts
var import_semver2 = require("semver");
// src/fs.ts
var import_node_fs = __toESM(require("fs"));
var import_node_path = __toESM(require("path"));
var jsonc = __toESM(require("jsonc-parser"));
async function readJsoncFile(name, cwd) {
const file = await readTextFile(name, cwd);
const data = jsonc.parse(file.data);
const modified = [];
return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
}
async function writeJsoncFile(file) {
let newJSON = file.text;
for (const [key, value] of file.modified) {
const edit = jsonc.modify(file.text, key, value, {});
newJSON = jsonc.applyEdits(newJSON, edit);
var messageColorMap = {
chore: import_picocolors.default.gray,
fix: import_picocolors.default.yellow,
feat: import_picocolors.default.green,
refactor: import_picocolors.default.cyan,
docs: import_picocolors.default.blue,
doc: import_picocolors.default.blue,
ci: import_picocolors.default.gray,
build: import_picocolors.default.gray
};
async function printRecentCommits(operation) {
let sha;
sha || (sha = await ezSpawn.async(
"git",
["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
{ stdio: "pipe" }
).then((res) => res.stdout.trim()).catch(() => void 0));
sha || (sha = await ezSpawn.async(
"git",
["rev-list", "-n", "1", operation.state.currentVersion],
{ stdio: "pipe" }
).then((res) => res.stdout.trim()).catch(() => void 0));
if (!sha) {
console.log(
import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
);
return;
}
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
}
function readTextFile(name, cwd) {
return new Promise((resolve, reject) => {
const filePath = import_node_path.default.join(cwd, name);
import_node_fs.default.readFile(filePath, "utf8", (err, text) => {
if (err) {
reject(err);
} else {
resolve({
path: filePath,
data: text
});
const message = await ezSpawn.async(
"git",
[
"--no-pager",
"log",
`${sha}..HEAD`,
"--oneline"
],
{ stdio: "pipe" }
);
const lines = message.stdout.toString().trim().split(/\n/g);
if (!lines.length) {
console.log();
console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
console.log();
return;
}
const parsed = lines.map((line) => {
const [hash, ...parts] = line.split(" ");
const message2 = parts.join(" ");
const match = message2.match(/^(\w+)(\([^)]+\))?(!)?:(.*)$/);
if (match) {
let color = messageColorMap[match[1].toLowerCase()] || ((c4) => c4);
if (match[3] === "!") {
color = import_picocolors.default.red;
}
});
const tag = [match[1], match[2], match[3]].filter(Boolean).join("");
return {
hash,
tag,
message: match[4].trim(),
color
};
}
return {
hash,
tag: "",
message: message2,
color: (c4) => c4
};
});
}
function writeTextFile(file) {
return new Promise((resolve, reject) => {
import_node_fs.default.writeFile(file.path, file.data, (err) => {
if (err)
reject(err);
else
resolve();
});
const tagLength = parsed.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
const prettified = parsed.map(({ hash, tag, message: message2, color }) => {
const paddedTag = tag.padStart(tagLength + 2, " ");
return [
import_picocolors.default.dim(hash),
" ",
color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
import_picocolors.default.dim(":"),
" ",
color === import_picocolors.default.gray ? color(message2) : message2
].join("");
});
}
// src/manifest.ts
function isManifest(obj) {
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
}
function isPackageLockManifest(manifest) {
var _a, _b;
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
}
function isOptionalString(value) {
const type = typeof value;
return value === null || type === "undefined" || type === "string";
}
// src/get-current-version.ts
async function getCurrentVersion(operation) {
if (operation.state.currentVersion)
return operation;
const { cwd, files } = operation.options;
const filesToCheck = files.filter((file) => file.endsWith(".json"));
if (!filesToCheck.includes("package.json"))
filesToCheck.push("package.json");
if (!filesToCheck.includes("deno.json"))
filesToCheck.push("deno.json");
if (!filesToCheck.includes("deno.jsonc"))
filesToCheck.push("deno.jsonc");
for (const file of filesToCheck) {
const version2 = await readVersion(file, cwd);
if (version2) {
return operation.update({
currentVersionSource: file,
currentVersion: version2
});
}
}
throw new Error(
`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
console.log();
console.log(
import_picocolors.default.bold(
`${import_picocolors.default.green(lines.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
)
);
console.log();
console.log(prettified.reverse().join("\n"));
console.log();
}
async function readVersion(file, cwd) {
try {
const { data: manifest } = await readJsoncFile(file, cwd);
if (isManifest(manifest)) {
if ((0, import_semver2.valid)(manifest.version))
return manifest.version;
}
} catch (e) {
return void 0;
}
}
// src/git.ts
var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
async function gitCommit(operation) {

@@ -876,3 +987,3 @@ if (!operation.options.commit)

args = args.concat(updatedFiles);
await ezSpawn.async("git", ["commit", ...args]);
await ezSpawn2.async("git", ["commit", ...args]);
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });

@@ -895,3 +1006,3 @@ }

args.push(tagName);
await ezSpawn.async("git", ["tag", ...args]);
await ezSpawn2.async("git", ["tag", ...args]);
return operation.update({ event: "git tag" /* GitTag */, tagName });

@@ -902,5 +1013,5 @@ }

return operation;
await ezSpawn.async("git", "push");
await ezSpawn2.async("git", "push");
if (operation.options.tag) {
await ezSpawn.async("git", ["push", "--tags"]);
await ezSpawn2.async("git", ["push", "--tags"]);
}

@@ -917,9 +1028,9 @@ return operation.update({ event: "git push" /* GitPush */ });

// src/normalize-options.ts
var import_node_fs2 = __toESM(require("fs"));
var import_promises = __toESM(require("fs/promises"));
var import_node_process4 = __toESM(require("process"));
var import_promises = __toESM(require("fs/promises"));
var import_node_fs2 = __toESM(require("fs"));
var import_fast_glob = __toESM(require("fast-glob"));
var import_js_yaml = __toESM(require("js-yaml"));
async function normalizeOptions(raw) {
var _a, _b;
var _a, _b, _d;
const preid = typeof raw.preid === "string" ? raw.preid : "beta";

@@ -1008,2 +1119,3 @@ const push = Boolean(raw.push);

execute,
printCommits: (_d = raw.printCommits) != null ? _d : true,
customVersion: raw.customVersion,

@@ -1079,3 +1191,3 @@ currentVersion: raw.currentVersion

// src/run-npm-script.ts
var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
var ezSpawn3 = __toESM(require("@jsdevtools/ez-spawn"));
async function runNpmScript(script, operation) {

@@ -1086,3 +1198,3 @@ const { cwd, ignoreScripts } = operation.options;

if (isManifest(manifest) && hasScript(manifest, script)) {
await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
await ezSpawn3.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
operation.update({ event: "npm script" /* NpmScript */, script });

@@ -1101,4 +1213,4 @@ }

// src/update-files.ts
var import_node_fs3 = require("fs");
var path2 = __toESM(require("path"));
var import_node_fs3 = require("fs");
async function updateFiles(operation) {

@@ -1192,3 +1304,3 @@ const { files } = operation.options;

console.log(log_symbols_default.info, "Executing script", operation.options.execute);
await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
await ezSpawn4.async(operation.options.execute, { stdio: "inherit" });
console.log(log_symbols_default.success, "Script finished");

@@ -1222,9 +1334,9 @@ }

var import_node_process7 = __toESM(require("process"));
var import_semver3 = require("semver");
var import_cac = __toESM(require("cac"));
var import_picocolors3 = __toESM(require_picocolors());
var import_semver3 = require("semver");
// src/config.ts
var import_node_path2 = require("path");
var import_node_process6 = __toESM(require("process"));
var import_node_path2 = require("path");
var import_c12 = require("c12");

@@ -1301,3 +1413,3 @@ var import_sync = __toESM(require("escalade/sync"));

execute: args.execute,
recursive: !!args.recursive
recursive: args.recursive
})

@@ -1321,3 +1433,3 @@ };

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();
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("--print-commits", "Print recent commits", { default: true }).option("-x, --execute <command>", "Commands to execute after version bumps").help();
const result = cli.parse(argv);

@@ -1324,0 +1436,0 @@ const rawArgs = cli.rawArgs;

@@ -186,2 +186,6 @@ import _semver, { ReleaseType as ReleaseType$1 } from 'semver';

/**
* Print recent commits
*/
printCommits?: boolean;
/**
* Custom function to provide the version number

@@ -272,2 +276,3 @@ */

execute?: string;
printCommits?: boolean;
customVersion?: VersionBumpOptions['customVersion'];

@@ -274,0 +279,0 @@ currentVersion?: string;

@@ -61,5 +61,5 @@ var __create = Object.create;

// node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
// node_modules/.pnpm/picocolors@1.1.0/node_modules/picocolors/picocolors.js
var require_picocolors = __commonJS({
"node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
"node_modules/.pnpm/picocolors@1.1.0/node_modules/picocolors/picocolors.js"(exports2, module2) {
var argv = process.argv || [];

@@ -111,3 +111,19 @@ var env2 = process.env;

bgCyan: init("\x1B[46m", "\x1B[49m"),
bgWhite: init("\x1B[47m", "\x1B[49m")
bgWhite: init("\x1B[47m", "\x1B[49m"),
blackBright: init("\x1B[90m", "\x1B[39m"),
redBright: init("\x1B[91m", "\x1B[39m"),
greenBright: init("\x1B[92m", "\x1B[39m"),
yellowBright: init("\x1B[93m", "\x1B[39m"),
blueBright: init("\x1B[94m", "\x1B[39m"),
magentaBright: init("\x1B[95m", "\x1B[39m"),
cyanBright: init("\x1B[96m", "\x1B[39m"),
whiteBright: init("\x1B[97m", "\x1B[39m"),
bgBlackBright: init("\x1B[100m", "\x1B[49m"),
bgRedBright: init("\x1B[101m", "\x1B[49m"),
bgGreenBright: init("\x1B[102m", "\x1B[49m"),
bgYellowBright: init("\x1B[103m", "\x1B[49m"),
bgBlueBright: init("\x1B[104m", "\x1B[49m"),
bgMagentaBright: init("\x1B[105m", "\x1B[49m"),
bgCyanBright: init("\x1B[106m", "\x1B[49m"),
bgWhiteBright: init("\x1B[107m", "\x1B[49m")
};

@@ -136,4 +152,3 @@ };

var import_node_process5 = __toESM(require("process"));
var ezSpawn3 = __toESM(require("@jsdevtools/ez-spawn"));
var import_picocolors2 = __toESM(require_picocolors());
var ezSpawn4 = __toESM(require("@jsdevtools/ez-spawn"));

@@ -653,9 +668,108 @@ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js

// src/version-bump.ts
var import_picocolors2 = __toESM(require_picocolors());
var import_prompts2 = __toESM(require("prompts"));
// src/get-current-version.ts
var import_semver = require("semver");
// src/fs.ts
var import_node_fs = __toESM(require("fs"));
var import_node_path = __toESM(require("path"));
var jsonc = __toESM(require("jsonc-parser"));
async function readJsoncFile(name, cwd) {
const file = await readTextFile(name, cwd);
const data = jsonc.parse(file.data);
const modified = [];
return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
}
async function writeJsoncFile(file) {
let newJSON = file.text;
for (const [key, value] of file.modified) {
const edit = jsonc.modify(file.text, key, value, {});
newJSON = jsonc.applyEdits(newJSON, edit);
}
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
}
function readTextFile(name, cwd) {
return new Promise((resolve, reject) => {
const filePath = import_node_path.default.join(cwd, name);
import_node_fs.default.readFile(filePath, "utf8", (err, text) => {
if (err) {
reject(err);
} else {
resolve({
path: filePath,
data: text
});
}
});
});
}
function writeTextFile(file) {
return new Promise((resolve, reject) => {
import_node_fs.default.writeFile(file.path, file.data, (err) => {
if (err)
reject(err);
else
resolve();
});
});
}
// src/manifest.ts
function isManifest(obj) {
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
}
function isPackageLockManifest(manifest) {
var _a, _b;
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
}
function isOptionalString(value) {
const type = typeof value;
return value === null || type === "undefined" || type === "string";
}
// src/get-current-version.ts
async function getCurrentVersion(operation) {
if (operation.state.currentVersion)
return operation;
const { cwd, files } = operation.options;
const filesToCheck = files.filter((file) => file.endsWith(".json"));
if (!filesToCheck.includes("package.json"))
filesToCheck.push("package.json");
if (!filesToCheck.includes("deno.json"))
filesToCheck.push("deno.json");
if (!filesToCheck.includes("deno.jsonc"))
filesToCheck.push("deno.jsonc");
for (const file of filesToCheck) {
const version = await readVersion(file, cwd);
if (version) {
return operation.update({
currentVersionSource: file,
currentVersion: version
});
}
}
throw new Error(
`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
);
}
async function readVersion(file, cwd) {
try {
const { data: manifest } = await readJsoncFile(file, cwd);
if (isManifest(manifest)) {
if ((0, import_semver.valid)(manifest.version))
return manifest.version;
}
} catch (e) {
return void 0;
}
}
// src/get-new-version.ts
var import_node_process3 = __toESM(require("process"));
var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
var import_picocolors = __toESM(require_picocolors());
var import_prompts = __toESM(require("prompts"));
var import_semver = __toESM(require("semver"));
var import_semver2 = __toESM(require("semver"));

@@ -681,3 +795,3 @@ // src/release-type.ts

return operation.update({
newVersion: new import_semver.SemVer(release.version, true).version
newVersion: new import_semver2.SemVer(release.version, true).version
});

@@ -692,3 +806,3 @@ default:

function getNextVersion(currentVersion, bump) {
const oldSemVer = new import_semver.SemVer(currentVersion);
const oldSemVer = new import_semver2.SemVer(currentVersion);
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;

@@ -704,3 +818,3 @@ const newSemVer = oldSemVer.inc(type, bump.preid);

const next = {};
const parse2 = import_semver.default.parse(currentVersion);
const parse2 = import_semver2.default.parse(currentVersion);
if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")

@@ -717,3 +831,6 @@ preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";

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 configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, import_semver2.default));
if (operation.options.printCommits) {
await printRecentCommits(operation);
}
const PADDING = 13;

@@ -747,7 +864,7 @@ const answers = await (0, import_prompts.default)([

validate: (custom) => {
return (0, import_semver.valid)(custom) ? true : "That's not a valid version number";
return (0, import_semver2.valid)(custom) ? true : "That's not a valid version number";
}
}
]);
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];
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver2.clean)(answers.custom) : answers.release === "config" ? (0, import_semver2.clean)(configCustomVersion) : next[answers.release];
if (!newVersion)

@@ -765,102 +882,96 @@ import_node_process3.default.exit(1);

}
// src/get-current-version.ts
var import_semver2 = require("semver");
// src/fs.ts
var import_node_fs = __toESM(require("fs"));
var import_node_path = __toESM(require("path"));
var jsonc = __toESM(require("jsonc-parser"));
async function readJsoncFile(name, cwd) {
const file = await readTextFile(name, cwd);
const data = jsonc.parse(file.data);
const modified = [];
return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
}
async function writeJsoncFile(file) {
let newJSON = file.text;
for (const [key, value] of file.modified) {
const edit = jsonc.modify(file.text, key, value, {});
newJSON = jsonc.applyEdits(newJSON, edit);
var messageColorMap = {
chore: import_picocolors.default.gray,
fix: import_picocolors.default.yellow,
feat: import_picocolors.default.green,
refactor: import_picocolors.default.cyan,
docs: import_picocolors.default.blue,
doc: import_picocolors.default.blue,
ci: import_picocolors.default.gray,
build: import_picocolors.default.gray
};
async function printRecentCommits(operation) {
let sha;
sha || (sha = await ezSpawn.async(
"git",
["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
{ stdio: "pipe" }
).then((res) => res.stdout.trim()).catch(() => void 0));
sha || (sha = await ezSpawn.async(
"git",
["rev-list", "-n", "1", operation.state.currentVersion],
{ stdio: "pipe" }
).then((res) => res.stdout.trim()).catch(() => void 0));
if (!sha) {
console.log(
import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
);
return;
}
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
}
function readTextFile(name, cwd) {
return new Promise((resolve, reject) => {
const filePath = import_node_path.default.join(cwd, name);
import_node_fs.default.readFile(filePath, "utf8", (err, text) => {
if (err) {
reject(err);
} else {
resolve({
path: filePath,
data: text
});
const message = await ezSpawn.async(
"git",
[
"--no-pager",
"log",
`${sha}..HEAD`,
"--oneline"
],
{ stdio: "pipe" }
);
const lines = message.stdout.toString().trim().split(/\n/g);
if (!lines.length) {
console.log();
console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
console.log();
return;
}
const parsed = lines.map((line) => {
const [hash, ...parts] = line.split(" ");
const message2 = parts.join(" ");
const match = message2.match(/^(\w+)(\([^)]+\))?(!)?:(.*)$/);
if (match) {
let color = messageColorMap[match[1].toLowerCase()] || ((c3) => c3);
if (match[3] === "!") {
color = import_picocolors.default.red;
}
});
const tag = [match[1], match[2], match[3]].filter(Boolean).join("");
return {
hash,
tag,
message: match[4].trim(),
color
};
}
return {
hash,
tag: "",
message: message2,
color: (c3) => c3
};
});
}
function writeTextFile(file) {
return new Promise((resolve, reject) => {
import_node_fs.default.writeFile(file.path, file.data, (err) => {
if (err)
reject(err);
else
resolve();
});
const tagLength = parsed.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
const prettified = parsed.map(({ hash, tag, message: message2, color }) => {
const paddedTag = tag.padStart(tagLength + 2, " ");
return [
import_picocolors.default.dim(hash),
" ",
color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
import_picocolors.default.dim(":"),
" ",
color === import_picocolors.default.gray ? color(message2) : message2
].join("");
});
}
// src/manifest.ts
function isManifest(obj) {
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
}
function isPackageLockManifest(manifest) {
var _a, _b;
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
}
function isOptionalString(value) {
const type = typeof value;
return value === null || type === "undefined" || type === "string";
}
// src/get-current-version.ts
async function getCurrentVersion(operation) {
if (operation.state.currentVersion)
return operation;
const { cwd, files } = operation.options;
const filesToCheck = files.filter((file) => file.endsWith(".json"));
if (!filesToCheck.includes("package.json"))
filesToCheck.push("package.json");
if (!filesToCheck.includes("deno.json"))
filesToCheck.push("deno.json");
if (!filesToCheck.includes("deno.jsonc"))
filesToCheck.push("deno.jsonc");
for (const file of filesToCheck) {
const version = await readVersion(file, cwd);
if (version) {
return operation.update({
currentVersionSource: file,
currentVersion: version
});
}
}
throw new Error(
`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
console.log();
console.log(
import_picocolors.default.bold(
`${import_picocolors.default.green(lines.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
)
);
console.log();
console.log(prettified.reverse().join("\n"));
console.log();
}
async function readVersion(file, cwd) {
try {
const { data: manifest } = await readJsoncFile(file, cwd);
if (isManifest(manifest)) {
if ((0, import_semver2.valid)(manifest.version))
return manifest.version;
}
} catch (e) {
return void 0;
}
}
// src/git.ts
var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));

@@ -901,3 +1012,3 @@ // src/types/version-bump-progress.ts

args = args.concat(updatedFiles);
await ezSpawn.async("git", ["commit", ...args]);
await ezSpawn2.async("git", ["commit", ...args]);
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });

@@ -920,3 +1031,3 @@ }

args.push(tagName);
await ezSpawn.async("git", ["tag", ...args]);
await ezSpawn2.async("git", ["tag", ...args]);
return operation.update({ event: "git tag" /* GitTag */, tagName });

@@ -927,5 +1038,5 @@ }

return operation;
await ezSpawn.async("git", "push");
await ezSpawn2.async("git", "push");
if (operation.options.tag) {
await ezSpawn.async("git", ["push", "--tags"]);
await ezSpawn2.async("git", ["push", "--tags"]);
}

@@ -942,9 +1053,9 @@ return operation.update({ event: "git push" /* GitPush */ });

// src/normalize-options.ts
var import_node_fs2 = __toESM(require("fs"));
var import_promises = __toESM(require("fs/promises"));
var import_node_process4 = __toESM(require("process"));
var import_promises = __toESM(require("fs/promises"));
var import_node_fs2 = __toESM(require("fs"));
var import_fast_glob = __toESM(require("fast-glob"));
var import_js_yaml = __toESM(require("js-yaml"));
async function normalizeOptions(raw) {
var _a, _b;
var _a, _b, _d;
const preid = typeof raw.preid === "string" ? raw.preid : "beta";

@@ -1033,2 +1144,3 @@ const push = Boolean(raw.push);

execute,
printCommits: (_d = raw.printCommits) != null ? _d : true,
customVersion: raw.customVersion,

@@ -1104,3 +1216,3 @@ currentVersion: raw.currentVersion

// src/run-npm-script.ts
var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
var ezSpawn3 = __toESM(require("@jsdevtools/ez-spawn"));
async function runNpmScript(script, operation) {

@@ -1111,3 +1223,3 @@ const { cwd, ignoreScripts } = operation.options;

if (isManifest(manifest) && hasScript(manifest, script)) {
await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
await ezSpawn3.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
operation.update({ event: "npm script" /* NpmScript */, script });

@@ -1126,4 +1238,4 @@ }

// src/update-files.ts
var import_node_fs3 = require("fs");
var path2 = __toESM(require("path"));
var import_node_fs3 = require("fs");
async function updateFiles(operation) {

@@ -1217,3 +1329,3 @@ const { files } = operation.options;

console.log(log_symbols_default.info, "Executing script", operation.options.execute);
await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
await ezSpawn4.async(operation.options.execute, { stdio: "inherit" });
console.log(log_symbols_default.success, "Script finished");

@@ -1254,4 +1366,4 @@ }

// src/config.ts
var import_node_path2 = require("path");
var import_node_process6 = __toESM(require("process"));
var import_node_path2 = require("path");
var import_c12 = require("c12");

@@ -1258,0 +1370,0 @@ var import_sync = __toESM(require("escalade/sync"));

{
"name": "bumpp",
"version": "9.5.2",
"packageManager": "pnpm@9.8.0",
"version": "9.6.0",
"description": "Bump version, commit changes, tag, and push to Git",

@@ -48,20 +47,7 @@ "author": {

},
"scripts": {
"clean": "rimraf .nyc_output coverage dist",
"lint": "eslint .",
"build": "tsup src/index.ts src/cli/index.ts --format esm,cjs --dts --clean",
"watch": "npm run build -- --watch src",
"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",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@jsdevtools/ez-spawn": "^3.0.4",
"c12": "^1.11.1",
"c12": "^1.11.2",
"cac": "^6.7.14",
"escalade": "^3.1.2",
"escalade": "^3.2.0",
"fast-glob": "^3.3.2",

@@ -74,17 +60,29 @@ "js-yaml": "^4.1.0",

"devDependencies": {
"@antfu/eslint-config": "^2.27.0",
"@antfu/eslint-config": "^3.7.3",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.5.0",
"@types/node": "^22.7.4",
"@types/prompts": "^2.4.9",
"@types/semver": "^7.5.8",
"eslint": "^9.9.0",
"eslint": "^9.11.1",
"esno": "^4.7.0",
"log-symbols": "^6.0.0",
"npm-check": "^6.0.1",
"picocolors": "^1.0.1",
"picocolors": "^1.1.0",
"rimraf": "^6.0.1",
"tsup": "^8.2.4",
"typescript": "^5.5.4",
"vitest": "^2.0.5"
"tsup": "^8.3.0",
"typescript": "^5.6.2",
"vitest": "^2.1.1"
},
"scripts": {
"clean": "rimraf .nyc_output coverage dist",
"lint": "eslint .",
"build": "tsup src/index.ts src/cli/index.ts --format esm,cjs --dts --clean",
"watch": "npm run build -- --watch src",
"start": "esno src/cli/run.ts",
"test": "vitest",
"upgrade": "npm-check -u && npm audit fix",
"bumpp": "esno src/cli/run.ts",
"release": "npm run bumpp && npm publish",
"typecheck": "tsc --noEmit"
}
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc