Compare commits

..

No commits in common. "2194bf199e1e478a7788f512c5437418f2530686" and "13bc1b07cd141c6e1cf0c1a69f5ff8349d57987a" have entirely different histories.

5 changed files with 14 additions and 26 deletions

View File

@ -42,27 +42,23 @@ async function runHooks(hooks: undefined | string | string[]) {
}
export default async function publish(options: { dry: boolean }) {
const originalMeta = await getMeta();
if (originalMeta.hooks) {
log("Running prepublish hooks");
await runHooks(originalMeta.hooks.prepublish);
}
const meta = await getMeta();
//TODO: Output Diff between original and result meta
const meta: IMeta = await getMeta();
if (!meta.name) throw new Error("name is not set in meta.json");
if (!meta.version) throw new Error("version is not set in meta.json");
if (!meta.files || !Array.isArray(meta.files) || meta.files.length <= 0)
throw new Error("files is not set or empty in meta.json");
if (meta.hooks) {
log("Running prepublish hooks");
await runHooks(meta.hooks.prepublish);
}
const tmpDir = await Deno.makeTempDir();
const packedFile = (await Deno.makeTempFile()) + ".tar";
try {
const walker = FS.walk(meta.root || ".", {
const walker = FS.walk(".", {
includeDirs: false,
includeFiles: true,
match: meta.files.map((file) => Path.globToRegExp(file)),
@ -70,18 +66,17 @@ export default async function publish(options: { dry: boolean }) {
log("Copying files to package to", tmpDir);
const copy = async (path: string, abs?: boolean) => {
const relative = abs ? path : Path.relative(meta.root || ".", path);
log("Adding file:", path, "as", relative);
const dest = Path.join(tmpDir, relative);
const copy = async (path: string) => {
const dest = Path.join(tmpDir, path);
await FS.ensureDir(Path.dirname(dest));
await FS.copy(path, dest);
};
await copy("meta.json", true);
await copy("meta.json");
for await (const file of walker) {
await copy(file.path);
log("Adding file:", file.path);
}
log("Compressing files into", packedFile);
@ -93,14 +88,9 @@ export default async function publish(options: { dry: boolean }) {
const url = new URL(getConfig("registry"));
url.pathname = "/api/package/" + meta.name;
console.log(
"Pushing version",
Colors.blue(meta.version),
"to repository"
);
if (!options.dry) {
log("Uploading new package version");
await fetch(url, {
method: "POST",
body: await Deno.readFile(packedFile),

View File

@ -9,7 +9,6 @@ export interface IMeta {
contributors?: string[];
deprecated?: boolean;
files: string[];
root?: string;
hooks?: {
prepublish?: string | string[];
postpublish?: string | string[];

View File

@ -1,6 +1,6 @@
{
"name": "@denreg-cli",
"version": "0.2.7",
"version": "0.2.6",
"description": "CLI for the DenReg package registry",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [],

View File

@ -1 +1 @@
export const version = "0.2.7"
export const version = "0.2.6"

View File

@ -145,7 +145,6 @@ async function uploadPackage(ctx: ABC.Context) {
const bucketPath = (bucketBase + relative).replace(/@/g, "§");
const body = await Deno.readAll(await Deno.open(file.path));
console.log("Put Object", bucketPath);
await bucket.putObject(bucketPath, body, {});
}
console.log("Setting new live version");