Skip to content

Commit

Permalink
V1.1.6
Browse files Browse the repository at this point in the history
- Fix zip on linux like systems
  • Loading branch information
fakoua committed Feb 20, 2024
1 parent 4b7cbbc commit f32f241
Show file tree
Hide file tree
Showing 5 changed files with 4,952 additions and 4,991 deletions.
4 changes: 2 additions & 2 deletions build-tools/binToTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join } from "https://deno.land/std@0.215.0/path/mod.ts";
import { copy } from "https://deno.land/std@0.215.0/fs/copy.ts";

import { bin, version } from "../wwwzip/ui.ts";
import { decompress } from "./zip.ts";
import { zipDecompress } from "./zip.ts";

export async function initServer(wwwRoot: string): Promise<boolean> {
try {
Expand All @@ -27,7 +27,7 @@ export async function initServer(wwwRoot: string): Promise<boolean> {
const zipFile = await tsToZip(wwwRoot);

//Decompress zip file
await decompress(zipFile, wwwRoot);
await zipDecompress(zipFile, wwwRoot);
await Deno.remove(zipFile);

const spa = join(wwwRoot, "spa");
Expand Down
64 changes: 9 additions & 55 deletions build-tools/zip.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
import { compress, decompress } from "https://deno.land/x/zip@v1.2.5/mod.ts";

import { join } from "https://deno.land/std@0.215.0/path/mod.ts";

export const compress = async (
export const zipCompress = async (
files: string | string[],
archiveName = "./archive.zip",
options?: CompressOptions,
): Promise<number> => {
return await compressProcess(files, archiveName, options);
): Promise<boolean> => {
return await compress(files, archiveName, options);
};

const compressProcess = async (
files: string | string[],
archiveName = "./archive.zip",
options?: CompressOptions,
): Promise<number> => {
const joinType = Deno.build.os === "windows" ? ", " : " ";
const filesList = typeof files === "string" ? files : files.join(joinType);

const p = new Deno.Command("PowerShell", {
args: [
"Compress-Archive",
"-Path",
filesList,
"-DestinationPath",
archiveName,
options?.overwrite ? "-Force" : "",
],
stderr: "piped",
stdout: "piped",
});

const { code } = await p.spawn().status;
return code;
};

export const decompress = async (
export const zipDecompress = async (
filePath: string,
destinationPath: string | null = "./",
options?: DecompressOptions,
Expand All @@ -51,32 +27,10 @@ export const decompress = async (
: destinationPath;

// return the unzipped file path or false whene the unzipping Process failed
return await decompressProcess(filePath, fullDestinationPath, options) === 0
? fullDestinationPath
: false;
};
const decompressProcess = async (
zipSourcePath: string,
destinationPath: string,
options?: DecompressOptions,
): Promise<number> => {
const p = new Deno.Command("PowerShell", {
args: [
"Expand-Archive",
"-Path",
`"${zipSourcePath}"`,
"-DestinationPath",
`"${destinationPath}"`,
options?.overwrite ? "-Force" : "",
],
stderr: "piped",
stdout: "piped",
});

const { code } = await p.spawn().status;
return code;
return await decompress(filePath, fullDestinationPath, options) === false
? false
: fullDestinationPath;
};

interface CompressOptions {
overwrite?: boolean;
flags: string[];
Expand Down
4 changes: 2 additions & 2 deletions prepare-spa.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zipToTs } from "./build-tools/binToTs.ts";
import { compress } from "./build-tools/zip.ts";
import { zipCompress } from "./build-tools/zip.ts";

await increaseUiVersion();
buildQuasar();
Expand All @@ -26,7 +26,7 @@ async function increaseUiVersion() {

async function spaToTypeScript() {
console.log("Compressing [q-manui/dist/spa] ...");
await compress("./q-manui/dist/spa", "./q-manui/dist/ui.zip", {
await zipCompress("./q-manui/dist/spa", "./q-manui/dist/ui.zip", {
overwrite: true,
flags: [],
});
Expand Down
4 changes: 2 additions & 2 deletions q-manui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "q-manui",
"version": "1.1.5",
"description": "DenoMan 1.1.5",
"version": "1.1.6",
"description": "DenoMan 1.1.6",
"productName": "DenoMan",
"author": "Sameh Fakoua <s.fakoua@gmail.com>",
"private": true,
Expand Down
Loading

0 comments on commit f32f241

Please sign in to comment.