Skip to content

Commit

Permalink
[sdk/purescript] add dagger example
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 17, 2024
1 parent 5fdb9f8 commit b1e2e2a
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sdk/purescript/demo-dagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
/.spago
1 change: 1 addition & 0 deletions sdk/purescript/demo-dagger/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@jsr:registry=https://npm.jsr.io
15 changes: 15 additions & 0 deletions sdk/purescript/demo-dagger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# demo-dagger

To install dependencies:

```bash
bun install
```

To run:

```bash
dagger run 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 added sdk/purescript/demo-dagger/bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions sdk/purescript/demo-dagger/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { main } from "./output/Main";

main();
14 changes: 14 additions & 0 deletions sdk/purescript/demo-dagger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "demo-dagger",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@fluentci/sdk": "npm:@jsr/fluentci__sdk"
}
}
117 changes: 117 additions & 0 deletions sdk/purescript/demo-dagger/packages.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{-
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-20240815/packages.dhall
sha256:24a8c447cfcc2a98c6e5c6988e10d3be1d4829afe4e09b44923dd9228e44ad0f

in upstream
with fluentci =
{ dependencies =
[ "aff"
, "console"
, "effect"
, "prelude"
]
, repo =
"https://github.com/fluentci-io/purescript-fluentci.git"
, version =
"22961269c542b67d8c442829fdba816ef65e1da5"
}
17 changes: 17 additions & 0 deletions sdk/purescript/demo-dagger/spago.dhall
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 = "my-project"
, dependencies = [ "aff", "console", "effect", "prelude", "fluentci" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
21 changes: 21 additions & 0 deletions sdk/purescript/demo-dagger/src/Main.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Main where

import Prelude

import Dagger.Class (id)
import Dagger.Client (container, dag)
import Dagger.Container (from, stdout, withExec)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Class.Console (log)

main :: Effect Unit
main = launchAff_ do
hello <- liftEffect $ do
c <- container dag
c1 <- from c "alpine:latest"
withExec c1 ["echo", "Hello from Dagger!"]

stdout hello >>= log
id hello >>= log
11 changes: 11 additions & 0 deletions sdk/purescript/demo-dagger/test/Main.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Test.Main where

import Prelude

import Effect (Effect)
import Effect.Class.Console (log)

main :: Effect Unit
main = do
log "🍝"
log "You should add some tests."
27 changes: 27 additions & 0 deletions sdk/purescript/demo-dagger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}

0 comments on commit b1e2e2a

Please sign in to comment.