Skip to content

Commit 356b8d1

Browse files
authored
Merge pull request #42 from fluentci-io/feat/yaml-colors
feat: enable syntax highlighting for exported yaml
2 parents f6fb073 + f8fb7c0 commit 356b8d1

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fluentci # Run the pipeline
8181
fluentci --help
8282

8383
Usage: fluentci [pipeline] [jobs...]
84-
Version: 0.14.1
84+
Version: 0.14.2
8585

8686
Description:
8787

src/cmd/project.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "../../deps.ts";
1212
import icons from "../server/icons.ts";
1313
import generate from "../exporter/generate.ts";
14+
import { bash, setupPkgx } from "../utils.ts";
1415

1516
export async function create() {
1617
const projectId = createId();
@@ -66,7 +67,7 @@ export async function list() {
6667
x.name,
6768
x.path,
6869
dayjs(x.createdAt).fromNow(),
69-
_.first(_.get(x, "recentRuns", [])).status,
70+
_.get(_.first(_.get(x, "recentRuns", [])), "status", ""),
7071
])
7172
);
7273

@@ -114,37 +115,39 @@ export async function exportActions(
114115

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

118+
await setupPkgx();
119+
117120
if (options.github) {
118121
const yaml = await generate("github", _actions || []);
119-
console.log(yaml);
122+
await bash`echo '${yaml}' | pkgx yq`;
120123
return;
121124
}
122125

123126
if (options.azure) {
124127
const yaml = await generate("azure", _actions || []);
125-
console.log(yaml);
128+
await bash`echo '${yaml}' | pkgx yq`;
126129
return;
127130
}
128131

129132
if (options.gitlab) {
130133
const yaml = await generate("gitlab", _actions || []);
131-
console.log(yaml);
134+
await bash`echo '${yaml}' | pkgx yq`;
132135
return;
133136
}
134137

135138
if (options.circleci) {
136139
const yaml = await generate("circleci", _actions || []);
137-
console.log(yaml);
140+
await bash`echo '${yaml}' | pkgx yq`;
138141
return;
139142
}
140143

141144
if (options.aws) {
142145
const yaml = await generate("aws", _actions || []);
143-
console.log(yaml);
146+
await bash`echo '${yaml}' | pkgx yq`;
144147
return;
145148
}
146149

147150
const yaml = await generate("github", _actions || []);
148-
console.log(yaml);
151+
await bash`echo '${yaml}' | pkgx yq`;
149152
return;
150153
}

src/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { dir } from "../deps.ts";
22

3-
export const VERSION = "0.14.1";
3+
export const VERSION = "0.14.2";
44

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

src/utils.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,29 @@ export function sendSocketMessage(socket: WebSocket, message: string) {
351351
}
352352
socket.send(message);
353353
}
354+
355+
export async function bash(
356+
strings: TemplateStringsArray,
357+
...values: (string | number)[]
358+
) {
359+
let cmd = "";
360+
strings.forEach((string, i) => {
361+
cmd += string;
362+
if (i < values.length) {
363+
cmd += values[i];
364+
}
365+
});
366+
const command = new Deno.Command("bash", {
367+
args: ["-c", cmd],
368+
stdout: "inherit",
369+
stderr: "inherit",
370+
});
371+
372+
const process = await command.spawn();
373+
const { code } = await process.status;
374+
375+
if (code !== 0) {
376+
console.log(`Failed to run command: ${cmd}`);
377+
Deno.exit(1);
378+
}
379+
}

0 commit comments

Comments
 (0)