-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from fluentci-io/feat/flu-30-allow-specific-pi…
…peline-version feat: allow user to use a specific pipeline version: `fluentci run pipeline@version`
- Loading branch information
Showing
3 changed files
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
SpinnerTypes, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { green } from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import { extractVersion } from "../utils.ts"; | ||
|
||
const BASE_URL = "https://api.fluentci.io/v1"; | ||
|
||
|
@@ -27,15 +28,16 @@ async function init( | |
_name?: string | ||
) { | ||
const infos = await promptPackageDetails(standalone); | ||
template = template || "base_pipeline"; | ||
let version = extractVersion(template || "base_pipeline"); | ||
template = template?.split("@")[0] || "base_pipeline"; | ||
|
||
let result = await fetch(`${BASE_URL}/pipeline/${template}`); | ||
let data = await result.json(); | ||
|
||
if (data.version) { | ||
if ( | ||
await downloadTemplateFromRegistry(template, data.version, standalone) | ||
) { | ||
version = | ||
version === "latest" ? data.version || data.default_branch : version; | ||
if (await downloadTemplateFromRegistry(template, version, standalone)) { | ||
if (standalone === true) { | ||
await overrideDaggerJson(infos, "."); | ||
return; | ||
|
@@ -53,7 +55,9 @@ async function init( | |
data = await result.json(); | ||
|
||
if (data.github_url) { | ||
await downloadTemplateFromGithub(data, template, standalone); | ||
version = | ||
version === "latest" ? data.version || data.default_branch : version; | ||
await downloadTemplateFromGithub(data, template, version, standalone); | ||
if (standalone === true) { | ||
await overrideDaggerJson(infos, "."); | ||
return; | ||
|
@@ -148,24 +152,25 @@ async function downloadTemplateFromGithub( | |
owner: string; | ||
}, | ||
template: string, | ||
version: string, | ||
standalone?: boolean | ||
) { | ||
const archiveUrl = | ||
data.version && data.version.startsWith("v") | ||
? `${data.github_url.replace( | ||
"https://github.com", | ||
"https://codeload.github.com" | ||
)}/zip/refs/tags/${data.version}` | ||
)}/zip/refs/tags/${version}` | ||
: `${data.github_url.replace( | ||
"https://github.com", | ||
"https://api.github.com/repos" | ||
)}/zipball/${data.version || data.default_branch}`; | ||
)}/zipball/${version}`; | ||
|
||
await download(archiveUrl, template); | ||
|
||
const repoName = data.github_url.split("/").pop(); | ||
|
||
let outputDir = `${repoName}-${data.version.replace("v", "")}`; | ||
let outputDir = `${repoName}-${version.replace("v", "")}`; | ||
|
||
if (data.directory) { | ||
outputDir += `/${data.directory}`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters