Skip to content

Commit

Permalink
Merge pull request #5 from fluentci-io/feat/envs
Browse files Browse the repository at this point in the history
feat: add support for `.env` files (read from `.fluentci/.env`)
  • Loading branch information
tsirysndr authored Nov 9, 2023
2 parents a803448 + bf19c7f commit 76c0820
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fluentci # Run the pipeline
fluentci --help

Usage: fluentci [pipeline] [jobs...]
Version: 0.7.1
Version: 0.8.0

Description:

Expand Down Expand Up @@ -98,6 +98,7 @@ Commands:
ac, aws - AWS CodePipeline integration
docs, man [pipeline] - Show documentation for a pipeline
doctor - Check if FluentCI CLI is installed correctly
env - Show environment variables (read from .fluentci/.env file)
```
## 📚 Documentation
Expand Down
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export {
export { z } from "https://deno.land/x/zod@v3.22.2/mod.ts";
export { decompress } from "https://deno.land/x/zip@v1.2.5/mod.ts";
export { existsSync } from "https://deno.land/std@0.203.0/fs/exists.ts";
export { load } from "https://deno.land/std@0.205.0/dotenv/mod.ts";
13 changes: 12 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import generateCircleCIConfig from "./src/cmd/circleci.ts";
import docs from "./src/cmd/docs.ts";
import cache from "./src/cmd/cache.ts";
import doctor from "./src/cmd/doctor.ts";
import showEnvs from "./src/cmd/env.ts";
import { brightGreen } from "./deps.ts";

export async function main() {
await new Command()
.name("fluentci")
.version("0.7.1")
.version("0.8.0")
.description(
`
.
Expand Down Expand Up @@ -177,6 +179,15 @@ export async function main() {
.action(async function () {
await doctor();
})
.command(
"env",
`Show environment variables (read from ${brightGreen(
".fluentci/.env"
)} file)`
)
.action(async function () {
await showEnvs();
})
.parse(Deno.args);
}

Expand Down
14 changes: 14 additions & 0 deletions src/cmd/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { brightGreen, load } from "../../deps.ts";

async function showEnvs() {
const envs = await load({
envPath: ".fluentci/.env",
export: true,
});

for (const [key, value] of Object.entries(envs)) {
console.log(`${brightGreen(key)} ${brightGreen("=")} ${value}`);
}
}

export default showEnvs;
6 changes: 5 additions & 1 deletion src/cmd/run.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cyan, bold, green, magenta } from "../../deps.ts";
import { cyan, bold, green, magenta, load } from "../../deps.ts";
import { BASE_URL, FLUENTCI_API_URL, FLUENTCI_WS_URL } from "../consts.ts";
import { LogEventSchema } from "../types.ts";

Expand All @@ -14,6 +14,10 @@ async function run(
jobs: [string, ...Array<string>],
options: Record<string, string | number | boolean | undefined>
) {
await load({
envPath: ".fluentci/.env",
export: true,
});
if (pipeline === ".") {
try {
// verify if .fluentci directory exists
Expand Down

0 comments on commit 76c0820

Please sign in to comment.