From e9b68ef2aa44f487969d37c5cd381a5c308a4bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20APLAK?= Date: Fri, 3 Mar 2023 13:16:10 +0300 Subject: [PATCH] fix: add branch support for zip downloads --- package-lock.json | 2 +- package.json | 2 +- src/Helper/download/index.ts | 13 ++++++++++--- src/Helper/source/index.ts | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ce95189..ae96ad18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "superplate-cli", - "version": "1.12.2", + "version": "1.12.3", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 4709719f..d512cdba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "superplate-cli", - "version": "1.12.2", + "version": "1.12.3", "description": "The frontend boilerplate with superpowers", "license": "MIT", "repository": { diff --git a/src/Helper/download/index.ts b/src/Helper/download/index.ts index e1d662fb..7da26e87 100644 --- a/src/Helper/download/index.ts +++ b/src/Helper/download/index.ts @@ -12,7 +12,10 @@ const pipeline = promisify(Stream.pipeline); const TEMP_PREFIX = "superplate-core-plugins.temp"; export const DownloadHelper = { - DownloadAndGetPath: async (path: string): Promise => { + DownloadAndGetPath: async ( + path: string, + branch?: string, + ): Promise => { try { const tempFolder = mkdirSync({ dir: process.cwd(), @@ -20,8 +23,12 @@ export const DownloadHelper = { }); 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({ diff --git a/src/Helper/source/index.ts b/src/Helper/source/index.ts index e2fca09a..1ac7ffd7 100644 --- a/src/Helper/source/index.ts +++ b/src/Helper/source/index.ts @@ -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.");