DenReg/cli/commands/bump.ts

40 lines
901 B
TypeScript
Raw Normal View History

2020-07-28 17:43:58 +00:00
import { Colors } from "../deps.ts";
2020-08-02 21:37:59 +00:00
import { getMeta, setMeta, log } from "../global.ts";
2020-07-28 17:43:58 +00:00
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");
}
2020-08-02 21:37:59 +00:00
log(major, minor, patch);
2020-07-28 17:43:58 +00:00
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);
}