diff --git a/README.md b/README.md index dd66cac..f49b4dd 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ fluentci # Run the pipeline fluentci --help Usage: fluentci [pipeline] [jobs...] -Version: 0.11.1 +Version: 0.11.2 Description: diff --git a/main.ts b/main.ts index b6cbb3a..b614959 100644 --- a/main.ts +++ b/main.ts @@ -222,8 +222,7 @@ export async function main() { }) .command("repl", "Start FluentCI REPL") .arguments("[pipelines...:string]") - .option("--quiet", "Disable verbose output") - .option("--debug", "Enable debug mode") + .option("--debug", "Show more information for debugging") .action(async function (options, ...pipelines: [string, ...Array]) { await repl(options, pipelines); }) diff --git a/src/cmd/repl.ts b/src/cmd/repl.ts index 3596a07..9f6efc9 100644 --- a/src/cmd/repl.ts +++ b/src/cmd/repl.ts @@ -8,10 +8,7 @@ import { import { BASE_URL } from "../consts.ts"; import { extractVersion, fluentciDirExists } from "../utils.ts"; -async function repl( - { quiet, debug }: { quiet?: boolean; debug?: boolean }, - pipelines: string[] -) { +async function repl({ debug }: { debug?: boolean }, pipelines: string[]) { const isFluentciProject = await fluentciDirExists(); const args = []; if (isFluentciProject) { @@ -52,41 +49,23 @@ async function repl( } } - let command = new Deno.Command("dagger", { + const port = Math.floor(Math.random() * (65535 - 1024 + 1)) + 1024; + const dagger = await startDagger(port, debug); + const command = new Deno.Command("deno", { args: [ - "--progress", - "plain", - "run", - "deno", "repl", "-A", "--eval-file=https://cdn.jsdelivr.net/gh/fluentci-io/fluentci@0c8a9aa/src/prelude.ts", ...args, ], + env: { + DAGGER_SESSION_TOKEN: "repl", + DAGGER_SESSION_PORT: port.toString(), + }, stdout: "inherit", stdin: "inherit", stderr: "inherit", }); - let dagger: Deno.ChildProcess | undefined; - - if (quiet) { - dagger = await startDagger(debug); - command = new Deno.Command("deno", { - args: [ - "repl", - "-A", - "--eval-file=https://cdn.jsdelivr.net/gh/fluentci-io/fluentci@0c8a9aa/src/prelude.ts", - ...args, - ], - env: { - DAGGER_SESSION_TOKEN: "repl", - DAGGER_SESSION_PORT: "8080", - }, - stdout: "inherit", - stdin: "inherit", - stderr: "inherit", - }); - } console.log(` . @@ -112,7 +91,7 @@ You can call any ${green("FluentCI Pipeline function")} or any ${green( Deno.exit(0); } -async function startDagger(debug?: boolean) { +async function startDagger(port: number, debug?: boolean) { let ready = false; const terminalSpinner = new TerminalSpinner({ text: `Starting Dagger API ...`, @@ -121,7 +100,7 @@ async function startDagger(debug?: boolean) { terminalSpinner.start(); const command = new Deno.Command("dagger", { - args: ["listen"], + args: ["listen", "--listen", `127.0.0.1:${port}`], env: { DAGGER_SESSION_TOKEN: "repl", }, @@ -147,7 +126,7 @@ async function startDagger(debug?: boolean) { try { // sleep for 1 second await new Promise((resolve) => setTimeout(resolve, 1000)); - const conn = await Deno.connect({ port: 8080 }); + const conn = await Deno.connect({ port }); conn.close(); break; } catch (_) { diff --git a/src/consts.ts b/src/consts.ts index 29ee248..c9c9ee2 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -1,6 +1,6 @@ import { dir } from "../deps.ts"; -export const VERSION = "0.11.1"; +export const VERSION = "0.11.2"; export const BASE_URL = "https://api.fluentci.io/v1"; diff --git a/src/utils.ts b/src/utils.ts index aa6ed2c..d9d3f62 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -78,6 +78,7 @@ export async function getDaggerVersion(): Promise { export async function fluentciDirExists(): Promise { try { const fluentciDir = await Deno.stat(".fluentci"); + await Deno.stat(".fluentci/mod.ts"); return fluentciDir.isDirectory; } catch (_) { return false;