Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add plugin for fluentci 97 #98

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ Currently available plugins:
- [Grunt](https://gruntjs.com/)
- [Rtx](https://github.com/jdx/rtx)
- [Nx](https://nx.dev/)
- [Fluent CI](https://docs.fluentci.io/reference/)
64 changes: 64 additions & 0 deletions plugins/fluentci.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { evaluateSystemCommand, spawn } from "../src/helpers.ts";
import Plugin from "../src/plugin.ts";
import Dagger from "./dagger.ts";
import Deno from "./deno.ts";

class Fluentci implements Plugin {
name = "fluentci";
commands: Record<string, (params: string[]) => Promise<void>>;

constructor() {
this.commands = {
aws: (args: string[]) => spawn(this.name, ["aws", ...args]),
azure: (args: string[]) => spawn(this.name, ["azure", ...args]),
circleci: (args: string[]) => spawn(this.name, ["circleci", ...args]),
docs: (args: string[]) => spawn(this.name, ["docs", ...args]),
github: (args: string[]) => spawn(this.name, ["github", ...args]),
gitlab: (args: string[]) => spawn(this.name, ["gitlab", ...args]),
init: (args: string[]) => spawn(this.name, ["init", ...args]),
list: (args: string[]) => spawn(this.name, ["list", ...args]),
run: (args: string[]) => spawn(this.name, ["run", ...args]),
search: (args: string[]) => spawn(this.name, ["search", ...args]),
upgrade: (args: string[]) => spawn(this.name, ["upgrade", ...args]),
help: () => {
console.log(` Commands:
aws Generate AWS Codepipeline buildspec.yml file for your project
azure Generate Azure Pipelines azure-pipelines.yml file for your project
circleci Generate CircleCI .circle/config.yml file for your project
docs Show the Pipeline documentation in the terminal
github Generate a Github Actions workflow file for your project
gitlab Generate Gitlab CI .gitlab-ci.yml file for your project
init Initialize a new pipeline in the current directory
list List all available jobs in a pipeline
run Run pipeline using Dagger and pre-built pipelines from the Fluent CI, a collection of pre-built pipelines for common CI/CD workflows written in TypeScript
search Search for pre-built pipelines in the Fluent CI registry
upgrade Upgrade the Fluent CI CLI to the latest version
help Print this message or the help of the given subcommand(s)`);
return Promise.resolve();
},
};
}

async evaluate(command: string): Promise<void> {
const [cmd, ...params] = command.split(" ");
if (this.commands[cmd]) {
await this.commands[cmd](params);
return;
}
if (cmd === "") {
return;
}
await evaluateSystemCommand(command);
}

async install(): Promise<void> {
await new Deno().install();
await new Dagger().install();
await spawn("sh", [
"-c",
"type fluentci > /dev/null || deno install -A -r https://cli.fluentci.io -n fluentci",
]);
}
}

export default Fluentci;
2 changes: 2 additions & 0 deletions plugins/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Pscale from "./pscale.ts";
import Grunt from "./grunt.ts";
import Rtx from "./rtx.ts";
import Nx from "./nx.ts";
import Fluentci from "./fluentci.ts";

export const plugins = [
new Docker(),
Expand Down Expand Up @@ -74,4 +75,5 @@ export const plugins = [
new Grunt(),
new Rtx(),
new Nx(),
new Fluentci(),
];