Add dry run upload and adding additional verbose output
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a436a4ecb0
commit
ccc48b0480
@ -1,7 +1,7 @@
|
||||
import { Colors, Path, FS, Compress, Base64 } from "../deps.ts";
|
||||
import { getMeta, IMeta, log, getConfig } from "../global.ts";
|
||||
|
||||
export default async function publish() {
|
||||
export default async function publish(options: { dry: boolean }) {
|
||||
const meta: IMeta = await getMeta();
|
||||
|
||||
if (!meta.name) throw new Error("name is not set in meta.json");
|
||||
@ -10,7 +10,7 @@ export default async function publish() {
|
||||
throw new Error("files is not set or empty in meta.json");
|
||||
|
||||
const tmpDir = await Deno.makeTempDir();
|
||||
const packedFile = await Deno.makeTempFile();
|
||||
const packedFile = (await Deno.makeTempFile()) + ".tar";
|
||||
|
||||
try {
|
||||
const walker = FS.walk(".", {
|
||||
@ -31,9 +31,10 @@ export default async function publish() {
|
||||
|
||||
for await (const file of walker) {
|
||||
await copy(file.path);
|
||||
log("Adding file:", file.path);
|
||||
}
|
||||
|
||||
log("Compressing file");
|
||||
log("Compressing files into", packedFile);
|
||||
|
||||
await Compress.Tar.compress(tmpDir, packedFile, {
|
||||
excludeSrc: true,
|
||||
@ -42,6 +43,7 @@ export default async function publish() {
|
||||
const url = new URL(getConfig("registry"));
|
||||
url.pathname = "/api/package/" + meta.name;
|
||||
|
||||
if (!options.dry) {
|
||||
log("Uploading new package version");
|
||||
|
||||
await fetch(url, {
|
||||
@ -70,6 +72,9 @@ export default async function publish() {
|
||||
.catch((err) => {
|
||||
console.log(Colors.red("Error: " + err.message));
|
||||
});
|
||||
} else {
|
||||
console.log(Colors.yellow("Dry run. Skipping upload"));
|
||||
}
|
||||
} finally {
|
||||
await Deno.remove(tmpDir, { recursive: true });
|
||||
await Deno.remove(packedFile);
|
||||
|
@ -50,6 +50,9 @@ const flags = await new Cliffy.Command()
|
||||
new Cliffy.Command()
|
||||
.description("Upload package")
|
||||
.action(commandWrapper(publishCMD))
|
||||
.option("-d, --dry [dry:boolean]", "Dry run", {
|
||||
default: false,
|
||||
})
|
||||
)
|
||||
.command(
|
||||
"init",
|
||||
|
@ -1,12 +1,8 @@
|
||||
{
|
||||
"name": "@denreg-cli",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.10",
|
||||
"description": "CLI for the DenReg package registry",
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"contributors": [],
|
||||
"files": [
|
||||
"**/*.ts",
|
||||
"**/*.js",
|
||||
"README.md"
|
||||
]
|
||||
"files": ["**/*.ts", "**/*.js", "README.md"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user