-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from fluentci-io/feat/purescript-sdk
feat: add SDK for purescript language
- Loading branch information
Showing
12 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# FluentCI Purescript SDK | ||
|
||
The FluentCI Purescript SDK is a library that provides a Purescript interface to the FluentCI API. | ||
|
||
Go to the [purescript-fluentci](https://github.com/fluentci-io/purescript-fluentci) repository for more information. | ||
|
||
## 🚚 Installation | ||
|
||
Add `fluentci` to your `spago.dhall` dependencies: | ||
|
||
```dhall | ||
{ name = "demo" | ||
, dependencies = [ "aff", "console", "effect", "prelude", "fluentci" ] | ||
, packages = ./packages.dhall | ||
, sources = [ "src/**/*.purs", "test/**/*.purs" ] | ||
} | ||
``` | ||
|
||
And add the following to your `packages.dhall`: | ||
|
||
```dhall | ||
let upstream = | ||
https://github.com/purescript/package-sets/releases/download/psc-0.15.15-20240812/packages.dhall | ||
sha256:557dc416167543923d0f944fdc0c7bc3e0466b9467a8fc2fba0460f8d5425725 | ||
|
||
in upstream | ||
with fluentci = | ||
{ dependencies = | ||
[ "aff" | ||
, "console" | ||
, "effect" | ||
, "prelude" | ||
] | ||
, repo = | ||
"https://github.com/fluentci-io/purescript-fluentci.git" | ||
, version = | ||
"d0d904915b1eade1f1e72ab541708ad4b43ccd5e" | ||
} | ||
``` | ||
|
||
Then install the package: | ||
|
||
```bash | ||
spago install | ||
``` | ||
|
||
## 🚀 Quick Start | ||
|
||
This is a quick start guide to get you up and running with the FluentCI Purescript SDK. | ||
|
||
```purescript | ||
module Main where | ||
import Prelude | ||
import Effect (Effect) | ||
import Effect.Aff (launchAff_) | ||
import Effect.Class (liftEffect) | ||
import Effect.Class.Console as Console | ||
import FluentCI.Class (asService, id, mise, nix, pkgx, stdout, withExec, withSecretVariable, withService, withWorkdir) | ||
import FluentCI.Client (cache, dag, git, pipeline, setSecret) | ||
import FluentCI.Directory (Directory, entries) | ||
import FluentCI.Git (branch, tree) | ||
import FluentCI.Mise (Mise) | ||
import FluentCI.Pipeline (Pipeline) | ||
import FluentCI.Pkgx (withPackages) | ||
import FluentCI.Secret (Secret, plaintext) | ||
import FluentCI.Service (Service) | ||
main :: Effect Unit | ||
main = launchAff_ do | ||
secret <- liftEffect $ setSecret dag "GITHUB" "my-github-token" | ||
plaintext secret >>= Console.log | ||
p <- liftEffect $ secretDemo secret | ||
stdout p >>= Console.log | ||
m <- liftEffect $ miseDemo | ||
stdout m >>= Console.log | ||
c <- liftEffect $ cache dag "pixi" | ||
id c >>= Console.log | ||
pingService <- liftEffect $ ping | ||
pingGhService <- liftEffect $ pingGh | ||
pingDemoPipeline <- liftEffect $ pingDemo pingService pingGhService | ||
stdout pingDemoPipeline >>= Console.log | ||
git <- liftEffect $ gitDemo | ||
stdout git >>= Console.log | ||
gitEntries <- liftEffect $ gitEntriesDemo | ||
entries gitEntries >>= Console.debugShow | ||
ping :: Effect Service | ||
ping = do | ||
p <- pipeline dag "demo" | ||
p1 <- nix p { impure: true } | ||
p2 <- withWorkdir p1 "./nix-demo" | ||
p3 <- withExec p2 ["nix", "--version"] | ||
p4 <- withExec p3 ["ping", "fluentci.io"] | ||
asService p4 "ping-fluentci" | ||
secretDemo :: Secret -> Effect Pipeline | ||
secretDemo secret = do | ||
p <- pipeline dag "secret-demo" | ||
p1 <- withSecretVariable p "GITHUB" secret | ||
withExec p1 ["echo", "$GITHUB"] | ||
pingGh :: Effect Service | ||
pingGh = do | ||
p <- pipeline dag "demo" | ||
p1 <- pkgx p | ||
p2 <- withPackages p1 ["ping"] | ||
p3 <- withExec p2 ["ping", "github.com"] | ||
asService p3 "ping-github" | ||
miseDemo :: Effect Mise | ||
miseDemo = do | ||
p <- pipeline dag "mise-demo" | ||
m <- mise p | ||
m1 <- withWorkdir m "./mise-demo" | ||
m2 <- withExec m1 ["mise", "--version"] | ||
withExec m2 ["which", "bun"] | ||
pingDemo :: Service -> Service -> Effect Pipeline | ||
pingDemo svc1 svc2 = do | ||
p <- pipeline dag "ping-demo" | ||
p1 <- withService p svc1 | ||
p2 <- withService p1 svc2 | ||
p3 <- withExec p2 ["sleep", "15"] | ||
withExec p3 ["ls", "-ltr", ".fluentci"] | ||
gitDemo :: Effect Directory | ||
gitDemo = do | ||
g <- git dag "https://github.com/tsirysndr/me" | ||
g1 <- branch g "main" | ||
g2 <- tree g1 | ||
g3 <- withExec g2 ["ls", "-ltr"] | ||
withExec g3 ["pwd"] | ||
gitEntriesDemo :: Effect Directory | ||
gitEntriesDemo = do | ||
g <- git dag "https://github.com/tsirysndr/me" | ||
g1 <- branch g "main" | ||
tree g1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/bower_components/ | ||
/node_modules/ | ||
/.pulp-cache/ | ||
/output/ | ||
/generated-docs/ | ||
/.psc-package/ | ||
/.psc* | ||
/.purs* | ||
/.psa* | ||
/.spago | ||
demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@jsr:registry=https://npm.jsr.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# demo | ||
|
||
To install dependencies: | ||
|
||
```bash | ||
bun install | ||
``` | ||
|
||
To run: | ||
|
||
```bash | ||
bun run index.ts | ||
``` | ||
|
||
This project was created using `bun init` in bun v1.1.22. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { main } from "./output/Main"; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "demo", | ||
"module": "index.ts", | ||
"type": "module", | ||
"devDependencies": { | ||
"@types/bun": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@fluentci/sdk": "npm:@jsr/fluentci__sdk" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{- | ||
Welcome to your new Dhall package-set! | ||
Below are instructions for how to edit this file for most use | ||
cases, so that you don't need to know Dhall to use it. | ||
## Use Cases | ||
Most will want to do one or both of these options: | ||
1. Override/Patch a package's dependency | ||
2. Add a package not already in the default package set | ||
This file will continue to work whether you use one or both options. | ||
Instructions for each option are explained below. | ||
### Overriding/Patching a package | ||
Purpose: | ||
- Change a package's dependency to a newer/older release than the | ||
default package set's release | ||
- Use your own modified version of some dependency that may | ||
include new API, changed API, removed API by | ||
using your custom git repo of the library rather than | ||
the package set's repo | ||
Syntax: | ||
where `entityName` is one of the following: | ||
- dependencies | ||
- repo | ||
- version | ||
------------------------------- | ||
let upstream = -- | ||
in upstream | ||
with packageName.entityName = "new value" | ||
------------------------------- | ||
Example: | ||
------------------------------- | ||
let upstream = -- | ||
in upstream | ||
with halogen.version = "master" | ||
with halogen.repo = "https://example.com/path/to/git/repo.git" | ||
with halogen-vdom.version = "v4.0.0" | ||
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies | ||
------------------------------- | ||
### Additions | ||
Purpose: | ||
- Add packages that aren't already included in the default package set | ||
Syntax: | ||
where `<version>` is: | ||
- a tag (i.e. "v4.0.0") | ||
- a branch (i.e. "master") | ||
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977") | ||
------------------------------- | ||
let upstream = -- | ||
in upstream | ||
with new-package-name = | ||
{ dependencies = | ||
[ "dependency1" | ||
, "dependency2" | ||
] | ||
, repo = | ||
"https://example.com/path/to/git/repo.git" | ||
, version = | ||
"<version>" | ||
} | ||
------------------------------- | ||
Example: | ||
------------------------------- | ||
let upstream = -- | ||
in upstream | ||
with benchotron = | ||
{ dependencies = | ||
[ "arrays" | ||
, "exists" | ||
, "profunctor" | ||
, "strings" | ||
, "quickcheck" | ||
, "lcg" | ||
, "transformers" | ||
, "foldable-traversable" | ||
, "exceptions" | ||
, "node-fs" | ||
, "node-buffer" | ||
, "node-readline" | ||
, "datetime" | ||
, "now" | ||
] | ||
, repo = | ||
"https://github.com/hdgarrood/purescript-benchotron.git" | ||
, version = | ||
"v7.0.0" | ||
} | ||
------------------------------- | ||
-} | ||
let upstream = | ||
https://github.com/purescript/package-sets/releases/download/psc-0.15.15-20240812/packages.dhall | ||
sha256:557dc416167543923d0f944fdc0c7bc3e0466b9467a8fc2fba0460f8d5425725 | ||
|
||
in upstream | ||
with fluentci = | ||
{ dependencies = | ||
[ "aff" | ||
, "console" | ||
, "effect" | ||
, "prelude" | ||
] | ||
, repo = | ||
"https://github.com/fluentci-io/purescript-fluentci.git" | ||
, version = | ||
"d0d904915b1eade1f1e72ab541708ad4b43ccd5e" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{- | ||
Welcome to a Spago project! | ||
You can edit this file as you like. | ||
Need help? See the following resources: | ||
- Spago documentation: https://github.com/purescript/spago | ||
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html | ||
When creating a new Spago project, you can use | ||
`spago init --no-comments` or `spago init -C` | ||
to generate this file without the comments in this block. | ||
-} | ||
{ name = "demo" | ||
, dependencies = [ "aff", "console", "effect", "prelude", "fluentci" ] | ||
, packages = ./packages.dhall | ||
, sources = [ "src/**/*.purs", "test/**/*.purs" ] | ||
} |
Oops, something went wrong.