Skip to content

Commit 56ba413

Browse files
committed
fix(init): call unzip command directly
1 parent acbfab1 commit 56ba413

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

deno.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export {
2424
SpinnerTypes,
2525
TerminalSpinner,
2626
} from "https://cdn.jsdelivr.net/gh/will-weiss/spinners@master/mod.ts";
27-
export { decompress } from "https://cdn.jsdelivr.net/gh/bootoffav/deno-zip@main/mod.ts";
2827
import dir from "https://deno.land/x/dir@1.5.2/mod.ts";
2928
export { dir };
3029
import Logger from "https://deno.land/x/logger@v1.1.3/logger.ts";

src/cmd/init.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import {
2+
brightGreen,
23
cyan,
3-
pkgx,
4+
generateName,
5+
green,
46
magenta,
5-
brightGreen,
6-
TerminalSpinner,
7+
pkgx,
78
SpinnerTypes,
8-
green,
9-
decompress,
10-
generateName,
9+
TerminalSpinner,
1110
} from "../../deps.ts";
1211
import { POCKETENV_CACHE_DIR } from "../consts.ts";
1312
import { existsSync } from "node:fs";
@@ -16,7 +15,7 @@ import { getDefaultGithubBranch } from "../lib.ts";
1615

1716
async function init(
1817
{ template, standalone }: { template?: string; standalone?: boolean },
19-
name?: string
18+
name?: string,
2019
) {
2120
if (!name) {
2221
console.log(`${cyan("?")} Workspace name: `);
@@ -32,7 +31,7 @@ async function init(
3231
console.log(`${cyan("?")} Choose a template: `);
3332
template = await pkgx.run(
3433
`gum choose pkgx nix devbox homebrew devenv flox`,
35-
"piped"
34+
"piped",
3635
);
3736
await Deno.stdout.write(new TextEncoder().encode(magenta(template)));
3837
template = template.trim();
@@ -58,8 +57,9 @@ async function downloadFromGithub(template: string, standalone?: boolean) {
5857
if (existsSync(".pocketenv")) {
5958
console.log(
6059
`🚨 ${brightGreen(
61-
".pocketenv"
62-
)} directory already exists. Please remove it and try again.`
60+
".pocketenv",
61+
)
62+
} directory already exists. Please remove it and try again.`,
6363
);
6464
Deno.exit(1);
6565
}
@@ -74,17 +74,17 @@ async function downloadFromGithub(template: string, standalone?: boolean) {
7474

7575
const filePath = `${POCKETENV_CACHE_DIR}/${template.replaceAll(
7676
"/",
77-
"-"
78-
)}.zip`;
77+
"-",
78+
)
79+
}.zip`;
7980

8081
const branch = await getDefaultGithubBranch(
81-
template.split("/").length === 2 ? template : `pocketenv-io/${template}`
82+
template.split("/").length === 2 ? template : `pocketenv-io/${template}`,
8283
);
8384

84-
const url =
85-
template.split("/").length === 2
86-
? `https://codeload.github.com/${template}/zip/refs/heads/${branch}`
87-
: `https://codeload.github.com/pocketenv-io/${template}/zip/refs/heads/${branch}`;
85+
const url = template.split("/").length === 2
86+
? `https://codeload.github.com/${template}/zip/refs/heads/${branch}`
87+
: `https://codeload.github.com/pocketenv-io/${template}/zip/refs/heads/${branch}`;
8888

8989
if (!existsSync(filePath)) {
9090
const response = await fetch(url);
@@ -100,21 +100,22 @@ async function downloadFromGithub(template: string, standalone?: boolean) {
100100

101101
if (!existsSync(`${cacheDir}/${template.split("/").pop()}-${branch}`)) {
102102
await pkgx.installPackage("unzip");
103-
await decompress(filePath, cacheDir);
103+
await pkgx.run(`unzip ${filePath} -d ${cacheDir}`, "inherit");
104104
await pkgx.run(
105105
`terraform init`,
106106
"inherit",
107-
`${cacheDir}/${template.split("/").pop()}-${branch}`
107+
`${cacheDir}/${template.split("/").pop()}-${branch}`,
108108
);
109109
} else {
110110
console.log(
111-
`💾 Using cached template: ${brightGreen(template)} ${brightGreen("...")}`
111+
`💾 Using cached template: ${brightGreen(template)} ${brightGreen("...")
112+
}`,
112113
);
113114
}
114115

115116
await copyDir(
116117
`${cacheDir}/${template.split("/").pop()}-${branch}`,
117-
standalone ? "." : ".pocketenv"
118+
standalone ? "." : ".pocketenv",
118119
);
119120
}
120121

0 commit comments

Comments
 (0)