Make it modern

This commit is contained in:
Fabian Stamm
2023-11-28 16:10:33 +01:00
parent 22a447604b
commit a14a5b9462
35 changed files with 656 additions and 200 deletions

View File

@ -1,11 +1,11 @@
import { Colors, Cliffy } from "../deps.ts";
import { Colors, CliffyPrompt } from "../deps.ts";
import { getMeta, setMeta, log } from "../global.ts";
export default async function deprecate(options: any) {
const meta = await getMeta();
const res = await Cliffy.Confirm.prompt(
const res = await CliffyPrompt.Confirm.prompt(
"Are you sure you want to deprecat this package?"
);

View File

@ -1,4 +1,4 @@
import { Cliffy, Path, FS } from "../deps.ts";
import { CliffyPrompt, Path, FS } from "../deps.ts";
import {
getMeta,
setMeta,
@ -11,7 +11,7 @@ export default async function init() {
let existing = {};
try {
existing = await getMeta();
} catch (err) {}
} catch (err) { }
let meta: IMeta = {
name: Path.basename(Deno.cwd()).toLowerCase().replace(/\s+/g, "-"),
version: "0.0.1",
@ -23,21 +23,21 @@ export default async function init() {
};
if (isInteractive()) {
meta.name = await Cliffy.Input.prompt({
meta.name = await CliffyPrompt.Input.prompt({
message: "What's the name of your package?",
default: meta.name,
});
meta.description = await Cliffy.Input.prompt({
meta.description = await CliffyPrompt.Input.prompt({
message: "What's the description of your package?",
default: meta.description,
});
meta.author = await Cliffy.Input.prompt({
meta.author = await CliffyPrompt.Input.prompt({
message: "Who's the author of your package?",
default: meta.author,
});
if (!(await FS.exists("README.md"))) {
const res = await Cliffy.Confirm.prompt({
const res = await CliffyPrompt.Confirm.prompt({
message: "Autogenerate README?",
default: true,
});

View File

@ -1,23 +1,23 @@
import { Cliffy } from "../deps.ts";
import { CliffyPrompt } from "../deps.ts";
import { getConfig, setConfig } from "../global.ts";
export default async function setup() {
const registry = await Cliffy.Input.prompt({
const registry = await CliffyPrompt.Input.prompt({
message: "What's your registry?",
default: getConfig("registry"),
});
const username = await Cliffy.Input.prompt({
const username = await CliffyPrompt.Input.prompt({
message: "What's your username?",
default: getConfig("username"),
});
const password = await Cliffy.Secret.prompt({
const password = await CliffyPrompt.Secret.prompt({
message: "What's your password?",
hidden: true,
default: getConfig("password"),
});
const author = await Cliffy.Input.prompt({
const author = await CliffyPrompt.Input.prompt({
message: "Who are you? (optional) Name <email@example.com>",
default: getConfig("author"),
});

View File

@ -1,4 +1,4 @@
import { Cliffy, Colors } from "../deps.ts";
import { CliffyPrompt, Colors } from "../deps.ts";
import { version } from "../version.ts";
export default async function upgrade() {
@ -7,14 +7,14 @@ export default async function upgrade() {
).then((e) => e.json());
if (meta.version === version) {
const res = await Cliffy.Confirm.prompt({
const res = await CliffyPrompt.Confirm.prompt({
message: Colors.yellow("No update available!") + " Continue?",
default: false,
});
if (!res) return;
}
const res = await Cliffy.Confirm.prompt({
const res = await CliffyPrompt.Confirm.prompt({
message: "Are you sure you want to upgrade?",
default: true,
});

View File

@ -1,4 +1,4 @@
import { Cliffy, Path, Colors } from "./deps.ts";
import { CliffyCommand, Path, Colors } from "./deps.ts";
import { init } from "./global.ts";
import { version } from "./version.ts";
@ -26,7 +26,7 @@ const commandWrapper = (cmd: CommandHandler) => {
opts = params;
};
};
const flags = await new Cliffy.Command()
const flags = await new CliffyCommand.Command()
.name("denreg")
.version(version)
.description("CLI for the Open Source DenReg package registry")
@ -44,13 +44,13 @@ const flags = await new Cliffy.Command()
})
.command(
"setup",
new Cliffy.Command()
new CliffyCommand.Command()
.description("Configure cli")
.action(commandWrapper(setupCMD))
)
.command(
"publish",
new Cliffy.Command()
new CliffyCommand.Command()
.description("Upload package")
.action(commandWrapper(publishCMD))
.option("-d, --dry [dry:boolean]", "Dry run", {
@ -59,13 +59,13 @@ const flags = await new Cliffy.Command()
)
.command(
"init",
new Cliffy.Command()
new CliffyCommand.Command()
.description("Create meta.json")
.action(commandWrapper(initCMD))
)
.command(
"bump",
new Cliffy.Command()
new CliffyCommand.Command()
.complete("major|minor|patch", () => ["major", "minor", "patch"])
.arguments("<major|minor|patch>")
.description("Change package version")
@ -73,18 +73,18 @@ const flags = await new Cliffy.Command()
)
.command(
"deprecate",
new Cliffy.Command()
new CliffyCommand.Command()
.description("Deprecate package")
.action(commandWrapper(deprecateCMD))
)
.command(
"upgrade",
new Cliffy.Command()
new CliffyCommand.Command()
.description("Upgrade to latest version of denreg cli")
.action(commandWrapper(upgradeCMD))
)
.command("completions", new Cliffy.CompletionsCommand())
.command("help", new Cliffy.HelpCommand().global())
.command("completions", new CliffyCommand.CompletionsCommand())
.command("help", new CliffyCommand.HelpCommand().global())
.parse(Deno.args);
await init(flags.options);

View File

@ -1,6 +1,7 @@
export * as Compress from "https://deno.hibas123.de/raw/@denreg-tar/mod.ts";
export * as Ini from "https://deno.land/x/ini@v2.1.0/mod.ts";
export * as Cliffy from "https://deno.land/x/cliffy@v0.18.2/mod.ts";
export * as CliffyPrompt from "https://deno.land/x/cliffy@v1.0.0-rc.3/prompt/mod.ts";
export * as CliffyCommand from "https://deno.land/x/cliffy@v1.0.0-rc.3/command/mod.ts";
export * as Base64 from "https://deno.land/std@0.91.0/encoding/base64.ts";
export * as FS from "https://deno.land/std@0.91.0/fs/mod.ts";
export * as Colors from "https://deno.land/std@0.91.0/fmt/colors.ts";

View File

@ -1,11 +1,15 @@
{
"name": "@denreg-cli",
"version": "0.2.11",
"version": "1.0.0",
"description": "CLI for the DenReg package registry",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [],
"files": ["**/*.ts", "**/*.js", "README.md"],
"files": [
"**/*.ts",
"**/*.js",
"README.md"
],
"hooks": {
"prepublish": "pre.ts"
}
}
}

View File

@ -1 +1 @@
export const version = "0.2.11"
export const version = "1.0.0"