@varlock/bumpy 0.0.0 → 0.0.2

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.
@@ -0,0 +1,135 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __exportAll = (all, no_symbols) => {
10
+ let target = {};
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ return target;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
+ key = keys[i];
21
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
+ get: ((k) => from[k]).bind(null, key),
23
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
+ });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+ //#endregion
33
+ //#region ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
34
+ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
35
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
36
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
37
+ let formatter = (open, close, replace = open) => (input) => {
38
+ let string = "" + input, index = string.indexOf(close, open.length);
39
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
40
+ };
41
+ let replaceClose = (string, close, replace, index) => {
42
+ let result = "", cursor = 0;
43
+ do {
44
+ result += string.substring(cursor, index) + replace;
45
+ cursor = index + close.length;
46
+ index = string.indexOf(close, cursor);
47
+ } while (~index);
48
+ return result + string.substring(cursor);
49
+ };
50
+ let createColors = (enabled = isColorSupported) => {
51
+ let f = enabled ? formatter : () => String;
52
+ return {
53
+ isColorSupported: enabled,
54
+ reset: f("\x1B[0m", "\x1B[0m"),
55
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
56
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
57
+ italic: f("\x1B[3m", "\x1B[23m"),
58
+ underline: f("\x1B[4m", "\x1B[24m"),
59
+ inverse: f("\x1B[7m", "\x1B[27m"),
60
+ hidden: f("\x1B[8m", "\x1B[28m"),
61
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
62
+ black: f("\x1B[30m", "\x1B[39m"),
63
+ red: f("\x1B[31m", "\x1B[39m"),
64
+ green: f("\x1B[32m", "\x1B[39m"),
65
+ yellow: f("\x1B[33m", "\x1B[39m"),
66
+ blue: f("\x1B[34m", "\x1B[39m"),
67
+ magenta: f("\x1B[35m", "\x1B[39m"),
68
+ cyan: f("\x1B[36m", "\x1B[39m"),
69
+ white: f("\x1B[37m", "\x1B[39m"),
70
+ gray: f("\x1B[90m", "\x1B[39m"),
71
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
72
+ bgRed: f("\x1B[41m", "\x1B[49m"),
73
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
74
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
75
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
76
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
77
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
78
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
79
+ blackBright: f("\x1B[90m", "\x1B[39m"),
80
+ redBright: f("\x1B[91m", "\x1B[39m"),
81
+ greenBright: f("\x1B[92m", "\x1B[39m"),
82
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
83
+ blueBright: f("\x1B[94m", "\x1B[39m"),
84
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
85
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
86
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
87
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
88
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
89
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
90
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
91
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
92
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
93
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
94
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
95
+ };
96
+ };
97
+ module.exports = createColors();
98
+ module.exports.createColors = createColors;
99
+ }));
100
+ //#endregion
101
+ //#region src/utils/logger.ts
102
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
103
+ const log = {
104
+ info(msg) {
105
+ console.log(`${import_picocolors.default.blue("info")} ${msg}`);
106
+ },
107
+ success(msg) {
108
+ console.log(`${import_picocolors.default.green("done")} ${msg}`);
109
+ },
110
+ warn(msg) {
111
+ console.log(`${import_picocolors.default.yellow("warn")} ${msg}`);
112
+ },
113
+ error(msg) {
114
+ console.error(`${import_picocolors.default.red("error")} ${msg}`);
115
+ },
116
+ step(msg) {
117
+ console.log(`${import_picocolors.default.cyan("=>")} ${msg}`);
118
+ },
119
+ dim(msg) {
120
+ console.log(import_picocolors.default.dim(msg));
121
+ },
122
+ bold(msg) {
123
+ console.log(import_picocolors.default.bold(msg));
124
+ },
125
+ table(rows) {
126
+ if (rows.length === 0) return;
127
+ const colWidths = rows[0].map((_, i) => Math.max(...rows.map((r) => (r[i] ?? "").length)));
128
+ for (const row of rows) console.log(row.map((cell, i) => cell.padEnd(colWidths[i])).join(" "));
129
+ }
130
+ };
131
+ function colorize(text, color) {
132
+ return import_picocolors.default[color](text);
133
+ }
134
+ //#endregion
135
+ export { __exportAll as a, __commonJSMin as i, log as n, __toESM as o, require_picocolors as r, colorize as t };
@@ -0,0 +1,121 @@
1
+ import { n as log, o as __toESM, r as require_picocolors } from "./logger-C2dEe5Su.mjs";
2
+ import { a as readJson, n as exists, o as readText } from "./fs-0AtnPUUe.mjs";
3
+ import { r as getBumpyDir } from "./config-BkwIEaQg.mjs";
4
+ import { i as writeChangeset } from "./changeset-UCZdSRDv.mjs";
5
+ import { a as fe, c as ot, n as O, o as gt, s as mt, t as unwrap } from "./clack-CDRCHrC-.mjs";
6
+ import { initCommand } from "./init-B0q3wEQW.mjs";
7
+ import { resolve } from "node:path";
8
+ import { readdir } from "node:fs/promises";
9
+ //#region src/commands/migrate.ts
10
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
11
+ async function migrateCommand(rootDir, opts) {
12
+ const changesetDir = resolve(rootDir, ".changeset");
13
+ if (!await exists(changesetDir)) {
14
+ log.error("No .changeset/ directory found. Nothing to migrate.");
15
+ process.exit(1);
16
+ }
17
+ const bumpyDir = getBumpyDir(rootDir);
18
+ if (!await exists(resolve(bumpyDir, "_config.json"))) {
19
+ log.step("Initializing .bumpy/ directory...");
20
+ await initCommand(rootDir);
21
+ }
22
+ const changesetConfigPath = resolve(changesetDir, "config.json");
23
+ if (await exists(changesetConfigPath)) {
24
+ log.step("Migrating config from .changeset/config.json...");
25
+ await migrateConfig(changesetConfigPath, bumpyDir);
26
+ }
27
+ const mdFiles = (await readdir(changesetDir)).filter((f) => f.endsWith(".md") && f !== "README.md");
28
+ if (mdFiles.length > 0) {
29
+ log.step(`Migrating ${mdFiles.length} pending changeset(s)...`);
30
+ let migrated = 0;
31
+ for (const file of mdFiles) {
32
+ const result = parseChangesetFile(await readText(resolve(changesetDir, file)));
33
+ if (!result) {
34
+ log.warn(` Skipped ${file} (could not parse)`);
35
+ continue;
36
+ }
37
+ const name = file.replace(/\.md$/, "");
38
+ if (await exists(resolve(bumpyDir, file))) {
39
+ log.dim(` Skipped ${file} (already exists in .bumpy/)`);
40
+ continue;
41
+ }
42
+ await writeChangeset(rootDir, name, result.releases, result.summary);
43
+ migrated++;
44
+ log.dim(` Migrated ${file}`);
45
+ }
46
+ log.success(`Migrated ${migrated} changeset(s)`);
47
+ } else log.info("No pending changesets to migrate.");
48
+ if (!opts.force) {
49
+ mt(import_picocolors.default.bgCyan(import_picocolors.default.black(" bumpy migrate ")));
50
+ if (unwrap(await ot({
51
+ message: "Remove .changeset/ directory?",
52
+ initialValue: false
53
+ }))) {
54
+ const spin = fe();
55
+ spin.start("Removing .changeset/");
56
+ const { rm } = await import("node:fs/promises");
57
+ await rm(changesetDir, { recursive: true });
58
+ spin.stop("Removed .changeset/ directory");
59
+ } else O.info("Keeping .changeset/ — you can remove it manually when ready.");
60
+ gt(import_picocolors.default.green("Cleanup complete"));
61
+ }
62
+ console.log();
63
+ log.success("Migration complete!");
64
+ log.dim("Review .bumpy/_config.json and adjust settings as needed.");
65
+ log.dim("Key differences from changesets:");
66
+ log.dim(" - peerDependency bumps only propagate on major (not minor)");
67
+ log.dim(" - Use 'patch-isolated'/'minor-isolated' to skip propagation");
68
+ log.dim(" - Per-package config goes in package.json[\"bumpy\"]");
69
+ }
70
+ async function migrateConfig(changesetConfigPath, bumpyDir) {
71
+ const csConfig = await readJson(changesetConfigPath);
72
+ const bumpyConfigPath = resolve(bumpyDir, "_config.json");
73
+ let bumpyConfig = {};
74
+ if (await exists(bumpyConfigPath)) bumpyConfig = await readJson(bumpyConfigPath);
75
+ for (const field of [
76
+ "baseBranch",
77
+ "access",
78
+ "commit",
79
+ "fixed",
80
+ "linked",
81
+ "ignore",
82
+ "updateInternalDependencies",
83
+ "privatePackages"
84
+ ]) if (csConfig[field] !== void 0) bumpyConfig[field] = csConfig[field];
85
+ const { writeJson } = await import("./fs-0AtnPUUe.mjs").then((n) => n.r);
86
+ await writeJson(bumpyConfigPath, bumpyConfig);
87
+ log.dim(" Migrated config fields: " + Object.keys(bumpyConfig).filter((k) => k !== "baseBranch" || bumpyConfig[k] !== "main").join(", "));
88
+ }
89
+ /** Parse a changesets-format markdown file */
90
+ function parseChangesetFile(content) {
91
+ const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
92
+ if (!match) return null;
93
+ const frontmatter = match[1].trim();
94
+ const summary = match[2].trim();
95
+ if (!frontmatter) return null;
96
+ const releases = [];
97
+ for (const line of frontmatter.split("\n")) {
98
+ const trimmed = line.trim();
99
+ if (!trimmed) continue;
100
+ const lineMatch = trimmed.match(/^"?([^"]+)"?\s*:\s*(.+)$/);
101
+ if (!lineMatch) continue;
102
+ const name = lineMatch[1].trim();
103
+ const type = lineMatch[2].trim();
104
+ if (type === "none") continue;
105
+ if ([
106
+ "major",
107
+ "minor",
108
+ "patch"
109
+ ].includes(type)) releases.push({
110
+ name,
111
+ type
112
+ });
113
+ }
114
+ if (releases.length === 0 && !summary) return null;
115
+ return {
116
+ releases,
117
+ summary
118
+ };
119
+ }
120
+ //#endregion
121
+ export { migrateCommand };
@@ -0,0 +1,144 @@
1
+ //#region src/utils/names.ts
2
+ /** Generate a random adjective-noun name for changeset files */
3
+ function randomName() {
4
+ const pick = (arr) => arr[Math.floor(Math.random() * arr.length)];
5
+ return `${pick(ADJECTIVES)}-${pick(ADJECTIVES)}-${pick(NOUNS)}`;
6
+ }
7
+ /** Sanitize a user-provided name into a valid filename slug */
8
+ function slugify(name) {
9
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
10
+ }
11
+ const ADJECTIVES = [
12
+ "brave",
13
+ "calm",
14
+ "dark",
15
+ "eager",
16
+ "fair",
17
+ "gentle",
18
+ "happy",
19
+ "icy",
20
+ "jolly",
21
+ "keen",
22
+ "lively",
23
+ "merry",
24
+ "neat",
25
+ "odd",
26
+ "proud",
27
+ "quiet",
28
+ "rare",
29
+ "shy",
30
+ "tall",
31
+ "warm",
32
+ "young",
33
+ "bold",
34
+ "cool",
35
+ "dry",
36
+ "fast",
37
+ "glad",
38
+ "huge",
39
+ "kind",
40
+ "lazy",
41
+ "mild",
42
+ "new",
43
+ "old",
44
+ "pink",
45
+ "red",
46
+ "safe",
47
+ "thin",
48
+ "vast",
49
+ "wide",
50
+ "witty",
51
+ "zany",
52
+ "bright",
53
+ "clean",
54
+ "deep",
55
+ "fresh",
56
+ "grand",
57
+ "light",
58
+ "pure",
59
+ "rich",
60
+ "sharp",
61
+ "smooth",
62
+ "soft",
63
+ "swift",
64
+ "tough",
65
+ "wild",
66
+ "wise",
67
+ "tidy",
68
+ "silver",
69
+ "golden",
70
+ "copper",
71
+ "amber",
72
+ "coral",
73
+ "jade",
74
+ "violet",
75
+ "rusty"
76
+ ];
77
+ const NOUNS = [
78
+ "ant",
79
+ "bee",
80
+ "cat",
81
+ "dog",
82
+ "elk",
83
+ "fox",
84
+ "gnu",
85
+ "hen",
86
+ "ibis",
87
+ "jay",
88
+ "koi",
89
+ "lark",
90
+ "moth",
91
+ "newt",
92
+ "owl",
93
+ "pug",
94
+ "quail",
95
+ "ram",
96
+ "seal",
97
+ "toad",
98
+ "urchin",
99
+ "vole",
100
+ "wasp",
101
+ "yak",
102
+ "bass",
103
+ "clam",
104
+ "dove",
105
+ "eel",
106
+ "frog",
107
+ "goat",
108
+ "hawk",
109
+ "igloo",
110
+ "jade",
111
+ "kite",
112
+ "lake",
113
+ "moon",
114
+ "nest",
115
+ "oak",
116
+ "pine",
117
+ "reef",
118
+ "star",
119
+ "tree",
120
+ "wave",
121
+ "fern",
122
+ "lily",
123
+ "rose",
124
+ "sage",
125
+ "vine",
126
+ "dawn",
127
+ "dusk",
128
+ "mist",
129
+ "rain",
130
+ "snow",
131
+ "wind",
132
+ "glow",
133
+ "haze",
134
+ "crab",
135
+ "deer",
136
+ "finch",
137
+ "heron",
138
+ "crane",
139
+ "robin",
140
+ "swift",
141
+ "trout"
142
+ ];
143
+ //#endregion
144
+ export { slugify as n, randomName as t };
@@ -0,0 +1,80 @@
1
+ import { a as readJson, n as exists, o as readText } from "./fs-0AtnPUUe.mjs";
2
+ import { t as jsYaml } from "./js-yaml-DpZfOoD4.mjs";
3
+ import { resolve } from "node:path";
4
+ //#region src/utils/package-manager.ts
5
+ /** Detect the package manager, extract workspace globs, and load catalogs */
6
+ async function detectWorkspaces(rootDir) {
7
+ const pm = await detectPackageManager(rootDir);
8
+ return {
9
+ packageManager: pm,
10
+ globs: await getWorkspaceGlobs(rootDir, pm),
11
+ catalogs: await loadCatalogs(rootDir, pm)
12
+ };
13
+ }
14
+ async function detectPackageManager(rootDir) {
15
+ if (await exists(resolve(rootDir, "bun.lock")) || await exists(resolve(rootDir, "bun.lockb"))) return "bun";
16
+ if (await exists(resolve(rootDir, "pnpm-lock.yaml"))) return "pnpm";
17
+ if (await exists(resolve(rootDir, "yarn.lock"))) return "yarn";
18
+ try {
19
+ const pkg = await readJson(resolve(rootDir, "package.json"));
20
+ if (typeof pkg.packageManager === "string") {
21
+ const name = pkg.packageManager.split("@")[0];
22
+ if (name === "pnpm" || name === "yarn" || name === "bun") return name;
23
+ }
24
+ } catch {}
25
+ return "npm";
26
+ }
27
+ async function getWorkspaceGlobs(rootDir, pm) {
28
+ if (pm === "pnpm") {
29
+ const wsFile = resolve(rootDir, "pnpm-workspace.yaml");
30
+ if (await exists(wsFile)) {
31
+ const content = await readText(wsFile);
32
+ const parsed = jsYaml.load(content);
33
+ if (parsed?.packages) return parsed.packages;
34
+ }
35
+ }
36
+ try {
37
+ const workspaces = (await readJson(resolve(rootDir, "package.json"))).workspaces;
38
+ if (Array.isArray(workspaces)) return workspaces;
39
+ if (workspaces && typeof workspaces === "object" && "packages" in workspaces) {
40
+ const pkgs = workspaces.packages;
41
+ if (Array.isArray(pkgs)) return pkgs;
42
+ }
43
+ } catch {}
44
+ return [];
45
+ }
46
+ /** Load catalog definitions from pnpm-workspace.yaml or root package.json */
47
+ async function loadCatalogs(rootDir, pm) {
48
+ const catalogs = /* @__PURE__ */ new Map();
49
+ if (pm === "pnpm") {
50
+ const wsFile = resolve(rootDir, "pnpm-workspace.yaml");
51
+ if (await exists(wsFile)) {
52
+ const content = await readText(wsFile);
53
+ const parsed = jsYaml.load(content);
54
+ if (parsed?.catalog) catalogs.set("", parsed.catalog);
55
+ if (parsed?.catalogs) for (const [name, deps] of Object.entries(parsed.catalogs)) catalogs.set(name, deps);
56
+ }
57
+ }
58
+ try {
59
+ const pkg = await readJson(resolve(rootDir, "package.json"));
60
+ if (pkg.catalog && typeof pkg.catalog === "object") catalogs.set("", pkg.catalog);
61
+ if (pkg.catalogs && typeof pkg.catalogs === "object") for (const [name, deps] of Object.entries(pkg.catalogs)) catalogs.set(name, deps);
62
+ const workspaces = pkg.workspaces;
63
+ if (workspaces && typeof workspaces === "object" && !Array.isArray(workspaces)) {
64
+ const ws = workspaces;
65
+ if (ws.catalog && typeof ws.catalog === "object") catalogs.set("", ws.catalog);
66
+ if (ws.catalogs && typeof ws.catalogs === "object") for (const [name, deps] of Object.entries(ws.catalogs)) catalogs.set(name, deps);
67
+ }
68
+ } catch {}
69
+ return catalogs;
70
+ }
71
+ /** Resolve a specific dependency's catalog: reference */
72
+ function resolveCatalogDep(depName, range, catalogs) {
73
+ if (!range.startsWith("catalog:")) return null;
74
+ const catalogName = range.slice(8).trim() || "";
75
+ const catalog = catalogs.get(catalogName);
76
+ if (!catalog) return null;
77
+ return catalog[depName] ?? null;
78
+ }
79
+ //#endregion
80
+ export { detectWorkspaces as n, resolveCatalogDep as r, detectPackageManager as t };