Skip to content

Commit

Permalink
Merge pull request #42 from fluentci-io/feat/yaml-colors
Browse files Browse the repository at this point in the history
feat: enable syntax highlighting for exported yaml
  • Loading branch information
tsirysndr authored May 26, 2024
2 parents f6fb073 + f8fb7c0 commit 356b8d1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fluentci # Run the pipeline
fluentci --help

Usage: fluentci [pipeline] [jobs...]
Version: 0.14.1
Version: 0.14.2

Description:

Expand Down
17 changes: 10 additions & 7 deletions src/cmd/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "../../deps.ts";
import icons from "../server/icons.ts";
import generate from "../exporter/generate.ts";
import { bash, setupPkgx } from "../utils.ts";

export async function create() {
const projectId = createId();
Expand Down Expand Up @@ -66,7 +67,7 @@ export async function list() {
x.name,
x.path,
dayjs(x.createdAt).fromNow(),
_.first(_.get(x, "recentRuns", [])).status,
_.get(_.first(_.get(x, "recentRuns", [])), "status", ""),
])
);

Expand Down Expand Up @@ -114,37 +115,39 @@ export async function exportActions(

const _actions = await actions.get(result?.id || "");

await setupPkgx();

if (options.github) {
const yaml = await generate("github", _actions || []);
console.log(yaml);
await bash`echo '${yaml}' | pkgx yq`;
return;
}

if (options.azure) {
const yaml = await generate("azure", _actions || []);
console.log(yaml);
await bash`echo '${yaml}' | pkgx yq`;
return;
}

if (options.gitlab) {
const yaml = await generate("gitlab", _actions || []);
console.log(yaml);
await bash`echo '${yaml}' | pkgx yq`;
return;
}

if (options.circleci) {
const yaml = await generate("circleci", _actions || []);
console.log(yaml);
await bash`echo '${yaml}' | pkgx yq`;
return;
}

if (options.aws) {
const yaml = await generate("aws", _actions || []);
console.log(yaml);
await bash`echo '${yaml}' | pkgx yq`;
return;
}

const yaml = await generate("github", _actions || []);
console.log(yaml);
await bash`echo '${yaml}' | pkgx yq`;
return;
}
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.14.1";
export const VERSION = "0.14.2";

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

Expand Down
26 changes: 26 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,29 @@ export function sendSocketMessage(socket: WebSocket, message: string) {
}
socket.send(message);
}

export async function bash(
strings: TemplateStringsArray,
...values: (string | number)[]
) {
let cmd = "";
strings.forEach((string, i) => {
cmd += string;
if (i < values.length) {
cmd += values[i];
}
});
const command = new Deno.Command("bash", {
args: ["-c", cmd],
stdout: "inherit",
stderr: "inherit",
});

const process = await command.spawn();
const { code } = await process.status;

if (code !== 0) {
console.log(`Failed to run command: ${cmd}`);
Deno.exit(1);
}
}

0 comments on commit 356b8d1

Please sign in to comment.