39 lines
867 B
TypeScript
39 lines
867 B
TypeScript
import { Colors } from "../deps.ts";
|
|
|
|
import { getMeta, setMeta } from "../global.ts";
|
|
|
|
export default async function bump(
|
|
options: any,
|
|
type: "minor" | "major" | "patch"
|
|
) {
|
|
const meta = await getMeta();
|
|
|
|
let [major = 0, minor = 0, patch = 0] = meta.version.split(".").map(Number);
|
|
|
|
switch (type) {
|
|
case "major":
|
|
major++;
|
|
minor = 0;
|
|
patch = 0;
|
|
break;
|
|
case "minor":
|
|
minor++;
|
|
patch = 0;
|
|
break;
|
|
case "patch":
|
|
patch++;
|
|
break;
|
|
default:
|
|
throw new Error("type must be either major, minor or patch");
|
|
}
|
|
const newVersion = [major, minor, patch].join(".");
|
|
console.log(
|
|
"Bumping version from",
|
|
Colors.blue(meta.version),
|
|
"to",
|
|
Colors.blue(newVersion)
|
|
);
|
|
meta.version = newVersion;
|
|
await setMeta(meta);
|
|
}
|