Skip to content

Commit

Permalink
Merge pull request #24 from fluentci-io/feat/remove-unnecessary-files
Browse files Browse the repository at this point in the history
feat: remove unnecessary files
  • Loading branch information
tsirysndr authored Feb 7, 2024
2 parents afbb39f + ccfd469 commit 03583ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fluentci # Run the pipeline
fluentci --help

Usage: fluentci [pipeline] [jobs...]
Version: 0.11.6
Version: 0.11.7

Description:

Expand Down
29 changes: 25 additions & 4 deletions src/cmd/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
_,
} from "../../deps.ts";
import { extractVersion } from "../utils.ts";
import { existsSync } from "node:fs";

const BASE_URL = "https://api.fluentci.io/v1";

Expand All @@ -23,9 +24,9 @@ const BASE_URL = "https://api.fluentci.io/v1";
*/
async function init(
{ template, standalone }: { template?: string; standalone?: boolean } = {},
_name?: string
name?: string
) {
const infos = await promptPackageDetails(standalone);
const infos = await promptPackageDetails(standalone, name);
let version = extractVersion(template || "base_pipeline");
template = template?.split("@")[0] || "base_pipeline";

Expand Down Expand Up @@ -177,6 +178,10 @@ async function downloadTemplateFromGithub(

await copyDir(outputDir, standalone ? "." : ".fluentci");

if (!standalone) {
await removeUnnecessaryFiles();
}

if (data.directory) {
outputDir = outputDir.split("/")[0];
}
Expand All @@ -202,6 +207,10 @@ async function downloadTemplateFromRegistry(
const outputDir = `${template}/${version}`;
await copyDir(outputDir, standalone ? "." : ".fluentci");

if (!standalone) {
await removeUnnecessaryFiles();
}

await Deno.remove(template, { recursive: true });

if (!standalone) {
Expand All @@ -212,7 +221,19 @@ async function downloadTemplateFromRegistry(
return false;
}

async function promptPackageDetails(standalone?: boolean) {
async function removeUnnecessaryFiles() {
if (existsSync(".fluentci/.github")) {
await Deno.remove(".fluentci/.github", { recursive: true });
}
if (existsSync(".fluentci/.fluentci")) {
await Deno.remove(".fluentci/.fluentci", { recursive: true });
}
if (existsSync(".fluentci/example")) {
await Deno.remove(".fluentci/example", { recursive: true });
}
}

async function promptPackageDetails(standalone?: boolean, name?: string) {
console.log(`👋 Welcome to ${brightGreen("Fluent CI")}!\n`);
console.log(`This utility will walk you through creating a new pipeline.`);
console.log(
Expand All @@ -232,7 +253,7 @@ async function promptPackageDetails(standalone?: boolean) {
name: "name",
message: "package name",
type: Input,
default: Deno.cwd().split("/").pop(),
default: name || Deno.cwd().split("/").pop(),
},
{
name: "version",
Expand Down
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dir } from "../deps.ts";

export const VERSION = "0.11.6";
export const VERSION = "0.11.7";

export const BASE_URL = "https://api.fluentci.io/v1";

Expand Down

0 comments on commit 03583ec

Please sign in to comment.