Skip to content

Commit

Permalink
feat: first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Massolari committed Jun 26, 2024
0 parents commit 922bbca
Show file tree
Hide file tree
Showing 29 changed files with 2,368 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
push:
branches:
- master
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: "26.0.2"
gleam-version: "1.2.1"
rebar3-version: "3"
# elixir-version: "1.15.4"
- run: gleam deps download
- run: gleam test
- run: gleam format --check src test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.beam
*.ez
/build
erl_crash.dump
node_modules
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# pink

[![Package Version](https://img.shields.io/hexpm/v/pink)](https://hex.pm/packages/pink)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/pink/)

```sh
gleam add pink
```
```gleam
import pink
pub fn main() {
// TODO: An example of the project in use
}
```

Further documentation can be found at <https://hexdocs.pm/pink>.

## Development

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```
23 changes: 23 additions & 0 deletions birdie_snapshots/box.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
version: 1.1.6
title: box
file: ./test/pink_test.gleam
test_name: box_test
---


This is a box with margin 2


widt
h 4
height 4



┌──────┐ ╔══════╗ ╭─────╮ ┏━━━━┓
│single│ ║double║ │round│ ┃bold┃
└──────┘ ╚══════╝ ╰─────╯ ┗━━━━┛
╓─────────────╖ ╒═════════════╕ +-------+
║single double║ │double single│ |classic|
╙─────────────╜ ╘═════════════╛ +-------+
7 changes: 7 additions & 0 deletions birdie_snapshots/hook_app.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: hook app
file: ./test/pink_test.gleam
test_name: use_app_test
---
Hello, world
7 changes: 7 additions & 0 deletions birdie_snapshots/hook_focus.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: hook focus
file: ./test/pink_test.gleam
test_name: use_focus_test
---
I am focused
7 changes: 7 additions & 0 deletions birdie_snapshots/hook_input.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: hook input
file: ./test/pink_test.gleam
test_name: use_input_test
---
Type something
7 changes: 7 additions & 0 deletions birdie_snapshots/hook_stdin.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: hook stdin
file: ./test/pink_test.gleam
test_name: use_stdin_test
---
is_raw_mode_supported: True
7 changes: 7 additions & 0 deletions birdie_snapshots/hook_stdout.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: hook stdout
file: ./test/pink_test.gleam
test_name: use_stdout_test
---
Hello from stdout
9 changes: 9 additions & 0 deletions birdie_snapshots/newline.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
version: 1.1.6
title: newline
file: ./test/pink_test.gleam
test_name: newline_test
---
Hello

World
18 changes: 18 additions & 0 deletions birdie_snapshots/spacer.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
version: 1.1.6
title: spacer
file: ./test/pink_test.gleam
test_name: spacer_test
---
Left Right

Top








Bottom
7 changes: 7 additions & 0 deletions birdie_snapshots/spinner.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: spinner
file: ./test/pink_test.gleam
test_name: spinner_test
---
18 changes: 18 additions & 0 deletions birdie_snapshots/static.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
version: 1.1.6
title: static
file: ./test/pink_test.gleam
test_name: static_test
---
 Test 1
 Test 2
 Test 3
 Test 4
 Test 5
 Test 6
 Test 7
 Test 8
 Test 9
 Test 10

Completed tests: 10
14 changes: 14 additions & 0 deletions birdie_snapshots/text.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
version: 1.1.6
title: text
file: ./test/pink_test.gleam
test_name: text_test
---
I am green
I am black on white
I am white
I am bold
I am italic
I am underline
I am strikethrough
I am inversed
7 changes: 7 additions & 0 deletions birdie_snapshots/transform.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 1.1.6
title: transform
file: ./test/pink_test.gleam
test_name: transform_test
---
HELLO, WORLD
23 changes: 23 additions & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name = "pink"
version = "1.0.0"
target = "javascript"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
# description = ""
# licences = ["Apache-2.0"]
# repository = { type = "github", user = "username", repo = "project" }
# links = [{ title = "Website", href = "https://gleam.run" }]
#
# For a full reference of all the available options, you can have a look at
# https://gleam.run/writing-gleam/gleam-toml/.

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
gleam_json = ">= 2.0.0 and < 3.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
birdie = ">= 1.1.6 and < 2.0.0"
gleam_javascript = ">= 0.10.0 and < 1.0.0"
28 changes: 28 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file was generated by Gleam
# You typically do not need to edit this file

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "birdie", version = "1.1.6", build_tools = ["gleam"], requirements = ["argv", "filepath", "glance", "gleam_community_ansi", "gleam_erlang", "gleam_stdlib", "justin", "rank", "simplifile", "trie_again"], otp_app = "birdie", source = "hex", outer_checksum = "9DBF73AEF936EAA8D22FFCE2B10CF42E38D62F8A006F89E3FFC1170D5C1E585B" },
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
{ name = "glance", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "8F3314D27773B7C3B9FB58D8C02C634290422CE531988C0394FA0DF8676B964D" },
{ name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
{ name = "gleam_community_colour", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "A49A5E3AE8B637A5ACBA80ECB9B1AFE89FD3D5351FF6410A42B84F666D40D7D5" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_javascript", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "62C31BFFE914FA2AFEE8459353CA1621A66BC10A7AF24B39E1EE15ACF33989B2" },
{ name = "gleam_json", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB10B0E7BF44282FB25162F1A24C1A025F6B93E777CCF238C4017E4EEF2CDE97" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "glexer", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "BD477AD657C2B637FEF75F2405FAEFFA533F277A74EF1A5E17B55B1178C228FB" },
{ name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" },
{ name = "rank", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "rank", source = "hex", outer_checksum = "5660E361F0E49CBB714CC57CC4C89C63415D8986F05B2DA0C719D5642FAD91C9" },
{ name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
{ name = "trie_again", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "trie_again", source = "hex", outer_checksum = "5B19176F52B1BD98831B57FDC97BD1F88C8A403D6D8C63471407E78598E27184" },
]

[requirements]
birdie = { version = ">= 1.1.6 and < 2.0.0" }
gleam_javascript = { version = ">= 0.10.0 and < 1.0.0"}
gleam_json = { version = ">= 2.0.0 and < 3.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "pink",
"version": "1.0.0",
"main": "index.js",
"author": "Douglas M. <douglasmassolari@hotmail.com>",
"license": "MIT",
"dependencies": {
"ink": "^5.0.0",
"ink-spinner": "^5.0.0",
"react": "^18.3.1"
},
"devDependencies": {
"ink-testing-library": "^4.0.0"
}
}
33 changes: 33 additions & 0 deletions src/ink_ffi.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react"
import { Text, Box, Newline, Spacer, useStdin, Static, Transform, useFocus } from "ink";
export { render, useInput, useApp, useStderr, useStdout } from "ink";

export function element(element, props, children) {
const parsedChildren = typeof children === "object" ? children.toArray() : [children]
return React.createElement(element, props, ...parsedChildren);
}

export const text = (props, content) => element(Text, props, content);
export const box = (props, children) => element(Box, props, children);
export const newline = (props) => React.createElement(Newline, props, null);
export const spacer = () => React.createElement(Spacer, null, null);
export const static_ = (items, childFunc) => element(Static, { items: items.toArray() }, childFunc);
export const transform = (transform, children) => element(Transform, { transform }, children);

export const useStdin_ = () => {
const stdin = useStdin()

return {
stdin: stdin.stdin,
is_raw_mode_supported: stdin.isRawModeSupported,
set_raw_mode: stdin.setRawMode,
}
}

export const useFocus_ = (options) => {
const focus = useFocus(options)

return {
is_focused: focus.isFocused,
}
}
4 changes: 4 additions & 0 deletions src/ink_spinner_ffi.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from "react";
import Spinner from "ink-spinner";

export const spinner = ({ type_ }) => React.createElement(Spinner, { type: type_ }, null);
Loading

0 comments on commit 922bbca

Please sign in to comment.