Compare commits

..

No commits in common. "e5829d9a4f944e9411a40c4a8be7650378db9df5" and "22a447604b16f79b0faf88a43bbca89805b9f205" have entirely different histories.

9 changed files with 47 additions and 93 deletions

View File

@ -1,8 +1,46 @@
import { Colors, Path, FS, Compress, Base64 } from "../deps.ts"; import { Colors, Path, FS, Compress, Base64 } from "../deps.ts";
import { getMeta, IMeta, log, getConfig } from "../global.ts"; import { getMeta, IMeta, log, getConfig } from "../global.ts";
import { runHooks } from "../helper/run_script.ts";
import { ServerError } from "../helper/server_error.ts"; import { ServerError } from "../helper/server_error.ts";
async function runScript(script: string) {
console.log(Colors.bold(Colors.blue("Running script:")), script);
const runPerm = await Deno.permissions.query({
name: "run",
});
if (runPerm.state !== "granted") {
console.log(
Colors.red("Missing --allow-run permission. Cannot run hooks!")
);
throw new Error("Missing --allow-run permission. Cannot run hooks!");
}
const process = Deno.run({
cmd: ["deno", "run", "-A", "--unstable", script],
});
const status = await process.status();
console.log(Colors.bold(Colors.blue("Finished script:")), script);
if (!status.success) {
throw new Error(
"A hook did not complete sucessfully. This is not a issue of denreg!"
);
}
}
async function runHooks(hooks: undefined | string | string[]) {
if (!hooks) return;
if (typeof hooks === "string") {
hooks = [hooks];
}
for (const hook of hooks) {
await runScript(hook);
}
}
export default async function publish(options: { dry: boolean }) { export default async function publish(options: { dry: boolean }) {
const originalMeta = await getMeta(); const originalMeta = await getMeta();

View File

@ -1,18 +0,0 @@
import { Colors, Path, FS, Compress, Base64 } from "../deps.ts";
import { getMeta, IMeta, log, getConfig } from "../global.ts";
import { ServerError } from "../helper/server_error.ts";
import { runScript } from "../helper/run_script.ts";
export default async function run(options: {}, name: string) {
const { scripts } = await getMeta();
if (!scripts || !scripts[name]) {
console.log(Colors.bold(Colors.red("Script not found:")), name);
} else {
let script = scripts[name];
if (!Array.isArray(script)) script = [script];
for (const s of script) {
await runScript(s);
}
}
}

View File

@ -9,7 +9,6 @@ import bumpCMD from "./commands/bump.ts";
import publishCMD from "./commands/publish.ts"; import publishCMD from "./commands/publish.ts";
import deprecateCMD from "./commands/deprecate.ts"; import deprecateCMD from "./commands/deprecate.ts";
import upgradeCMD from "./commands/upgrade.ts"; import upgradeCMD from "./commands/upgrade.ts";
import runCMD from "./commands/run.ts";
const HOME_FOLDER = Deno.env.get("HOME") || Deno.env.get("USERPROFILE") || ""; const HOME_FOLDER = Deno.env.get("HOME") || Deno.env.get("USERPROFILE") || "";
@ -84,14 +83,6 @@ const flags = await new Cliffy.Command()
.description("Upgrade to latest version of denreg cli") .description("Upgrade to latest version of denreg cli")
.action(commandWrapper(upgradeCMD)) .action(commandWrapper(upgradeCMD))
) )
.command(
"run",
new Cliffy.Command()
.arguments("<name>")
// .complete("name", ()=>) //TODO: add autocomplete?
.description("Run script from meta.json")
.action(commandWrapper(runCMD))
)
.command("completions", new Cliffy.CompletionsCommand()) .command("completions", new Cliffy.CompletionsCommand())
.command("help", new Cliffy.HelpCommand().global()) .command("help", new Cliffy.HelpCommand().global())
.parse(Deno.args); .parse(Deno.args);

View File

@ -1,7 +1,7 @@
export * as Compress from "https://deno.hibas123.de/raw/@denreg-tar/mod.ts"; 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 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 Cliffy from "https://deno.land/x/cliffy@v0.18.2/mod.ts";
export * as Base64 from "https://deno.land/std@0.95.0/encoding/base64.ts"; export * as Base64 from "https://deno.land/std@0.91.0/encoding/base64.ts";
export * as FS from "https://deno.land/std@0.95.0/fs/mod.ts"; export * as FS from "https://deno.land/std@0.91.0/fs/mod.ts";
export * as Colors from "https://deno.land/std@0.95.0/fmt/colors.ts"; export * as Colors from "https://deno.land/std@0.91.0/fmt/colors.ts";
export * as Path from "https://deno.land/std@0.95.0/path/mod.ts"; export * as Path from "https://deno.land/std@0.91.0/path/mod.ts";

View File

@ -1 +0,0 @@
import "./denreg.ts";

View File

@ -14,9 +14,6 @@ export interface IMeta {
prepublish?: string | string[]; prepublish?: string | string[];
postpublish?: string | string[]; postpublish?: string | string[];
}; };
scripts?: {
[key: string]: string | string[];
};
} }
let verbose = false; let verbose = false;

View File

@ -1,46 +0,0 @@
import { Colors } from "../deps.ts";
export async function runScript(script: string) {
console.log(Colors.bold(Colors.blue("Running script:")), script);
const runPerm = await Deno.permissions.query({
name: "run",
});
if (runPerm.state !== "granted") {
console.log(
Colors.red("Missing --allow-run permission. Cannot run hooks!")
);
throw new Error("Missing --allow-run permission. Cannot run hooks!");
}
const process = Deno.run({
cmd: ["deno", "run", "-A", "--unstable", script],
});
const status = await process.status();
console.log(Colors.bold(Colors.blue("Finished script:")), script);
if (!status.success) {
throw new Error(
"A script did not complete sucessfully. This is not a issue of denreg!"
);
}
}
export async function runHooks(hooks: undefined | string | string[]) {
if (!hooks) return;
if (typeof hooks === "string") {
hooks = [hooks];
}
for (const hook of hooks) {
try {
await runScript(hook);
} catch (err) {
throw new Error(
"A hook did not complete sucessfully. This is not a issue of denreg!"
);
}
}
}

View File

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

View File

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