Skip to content

Commit

Permalink
fix: add branch support for zip downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
omeraplak committed Mar 3, 2023
1 parent 85b4c80 commit e9b68ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superplate-cli",
"version": "1.12.2",
"version": "1.12.3",
"description": "The frontend boilerplate with superpowers",
"license": "MIT",
"repository": {
Expand Down
13 changes: 10 additions & 3 deletions src/Helper/download/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@ const pipeline = promisify(Stream.pipeline);
const TEMP_PREFIX = "superplate-core-plugins.temp";

export const DownloadHelper = {
DownloadAndGetPath: async (path: string): Promise<string> => {
DownloadAndGetPath: async (
path: string,
branch?: string,
): Promise<string> => {
try {
const tempFolder = mkdirSync({
dir: process.cwd(),
prefix: ".",
});
const tempFile = join(tempFolder, `${TEMP_PREFIX}-${Date.now()}`);

const { owner, name, branch } = gitHubURLParser(path);
const url = `https://codeload.github.com/${owner}/${name}/tar.gz/${branch}`;
const { owner, name, branch: branchFromURL } = gitHubURLParser(
path,
);
const url = `https://codeload.github.com/${owner}/${name}/tar.gz/${
branch ?? branchFromURL
}`;
await pipeline(got.stream(url), createWriteStream(tempFile));

await tar.x({
Expand Down
1 change: 1 addition & 0 deletions src/Helper/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const get_source: GetSourceFn = async (source, branch, downloadType) => {
try {
const cloneResponse = await DownloadHelper.DownloadAndGetPath(
sourcePath,
branch,
);
if (cloneResponse) {
sourceSpinner.succeed("Downloaded remote source successfully.");
Expand Down

0 comments on commit e9b68ef

Please sign in to comment.