DenReg/cli/commands/bump.ts
Fabian Stamm d56f0bcbea
All checks were successful
continuous-integration/drone/push Build is passing
Add deprecate command to CLI
2020-08-02 23:37:59 +02:00

40 lines
901 B
TypeScript

import { Colors } from "../deps.ts";
import { getMeta, setMeta, log } 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");
}
log(major, minor, 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);
}