Skip to content

Commit

Permalink
Merge pull request #16 from imclerran/non-std-pfs
Browse files Browse the repository at this point in the history
Correct headers for platforms who require something besides `main`
  • Loading branch information
imclerran authored Jun 6, 2024
2 parents 6ee5850 + 557c1f8 commit 1b4efe9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 45 deletions.
4 changes: 3 additions & 1 deletion repository/GET_LISTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ main = \req ->
That's it! Once you have released your package with the required tarball, simply make a PR against this repo, adding your package to the `roc-repo.rvn` file. The format should be as follows:

```roc
{ repo: "your-repo-name", owner: "your-git-username", alias: "sn", platform: <Bool.true/Bool.false> },
{ repo: "your-repo-name", owner: "your-git-username", alias: "sn", platform: <Bool.true/Bool.false>, requires: [] },
# alias: the short name you want to appear in the app header when your package or platform is imported. Should begin with a lowercase letter and include no symbols.
# platform: a roc style Boolean value indicating whether or not your package is a platform.
# requires: *For platforms only* - A `List Str` containing the parameters required by your platform, ie: "main". Should be an empty list for packages.
```

Please ensure that you add your package in alphabetic order, by repo-name first, then by username.
52 changes: 26 additions & 26 deletions repository/roc-repo.rvn
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[
{ repo: "basic-cli", owner: "roc-lang", alias: "cli", platform: Bool.true },
{ repo: "basic-ssg", owner: "lukewilliamboswell", alias: "pf", platform: Bool.true },
{ repo: "basic-webserver", owner: "roc-lang", alias: "pf", platform: Bool.true },
{ repo: "crisp", owner: "KilianVounckx", alias: "crisp", platform: Bool.false },
{ repo: "kingfisher", owner: "ostcar", alias: "pf", platform: Bool.true },
{ repo: "roc_regex", owner: "KilianVounckx", alias: "regex", platform: Bool.false },
{ repo: "roc-ansi", owner: "lukewilliamboswell", alias: "ansi", platform: Bool.false },
{ repo: "roc-array2d", owner: "mulias", alias: "a2d", platform: Bool.false },
{ repo: "roc-ascii", owner: "hasnep", alias: "ascii", platform: Bool.false },
{ repo: "roc-aws-lambda", owner: "isaacvando", alias: "pf", platform: Bool.true },
{ repo: "roc-datetimes", owner: "hasnep", alias: "dt", platform: Bool.false },
{ repo: "roc-fuzz", owner: "bhansconnect", alias: "pf", platform: Bool.true },
{ repo: "roc-glue-code-gen", owner: "lukewilliamboswell", alias: "glue", platform: Bool.false },
{ repo: "roc-html", owner: "hasnep", alias: "html", platform: Bool.false },
{ repo: "roc-image", owner: "shritesh", alias: "img", platform: Bool.false },
{ repo: "roc-isodate", owner: "imclerran", alias: "iso", platform: Bool.false },
{ repo: "roc-json", owner: "lukewilliamboswell", alias: "json", platform: Bool.false },
{ repo: "roc-math", owner: "hasnep", alias: "math", platform: Bool.false },
{ repo: "roc-openrouter", owner: "imclerran", alias: "ai", platform: Bool.false },
{ repo: "roc-parser", owner: "lukewilliamboswell", alias: "parser", platform: Bool.false },
{ repo: "roc-pg", owner: "agu-z", alias: "pg", platform: Bool.false },
{ repo: "roc-random", owner: "lukewilliamboswell", alias: "random", platform: Bool.false },
{ repo: "roc-svg", owner: "hasnep", alias: "svg", platform: Bool.false },
{ repo: "roc-wasm4", owner: "lukewilliamboswell", alias: "pf", platform: Bool.true },
{ repo: "rvn", owner: "jwoudenberg", alias: "rvn", platform: Bool.false },
{ repo: "weaver", owner: "smores56", alias: "weaver", platform: Bool.false },
{ repo: "basic-cli", owner: "roc-lang", alias: "cli", platform: Bool.true, requires: ["main"] },
{ repo: "basic-ssg", owner: "lukewilliamboswell", alias: "pf", platform: Bool.true, requires: ["main"] },
{ repo: "basic-webserver", owner: "roc-lang", alias: "pf", platform: Bool.true, requires: ["main"] },
{ repo: "crisp", owner: "KilianVounckx", alias: "crisp", platform: Bool.false, requires: [] },
{ repo: "kingfisher", owner: "ostcar", alias: "pf", platform: Bool.true, requires: ["main", "Model"] },
{ repo: "roc_regex", owner: "KilianVounckx", alias: "regex", platform: Bool.false, requires: [] },
{ repo: "roc-ansi", owner: "lukewilliamboswell", alias: "ansi", platform: Bool.false, requires: [] },
{ repo: "roc-array2d", owner: "mulias", alias: "a2d", platform: Bool.false, requires: [] },
{ repo: "roc-ascii", owner: "hasnep", alias: "ascii", platform: Bool.false, requires: [] },
{ repo: "roc-aws-lambda", owner: "isaacvando", alias: "pf", platform: Bool.true, requires: ["main"] },
{ repo: "roc-datetimes", owner: "hasnep", alias: "dt", platform: Bool.false, requires: [] },
{ repo: "roc-fuzz", owner: "bhansconnect", alias: "pf", platform: Bool.true, requires: ["main"] },
{ repo: "roc-glue-code-gen", owner: "lukewilliamboswell", alias: "glue", platform: Bool.false, requires: [] },
{ repo: "roc-html", owner: "hasnep", alias: "html", platform: Bool.false, requires: [] },
{ repo: "roc-image", owner: "shritesh", alias: "img", platform: Bool.false, requires: [] },
{ repo: "roc-isodate", owner: "imclerran", alias: "iso", platform: Bool.false, requires: [] },
{ repo: "roc-json", owner: "lukewilliamboswell", alias: "json", platform: Bool.false, requires: [] },
{ repo: "roc-math", owner: "hasnep", alias: "math", platform: Bool.false, requires: [] },
{ repo: "roc-openrouter", owner: "imclerran", alias: "ai", platform: Bool.false, requires: [] },
{ repo: "roc-parser", owner: "lukewilliamboswell", alias: "parser", platform: Bool.false, requires: [] },
{ repo: "roc-pg", owner: "agu-z", alias: "pg", platform: Bool.false, requires: [] },
{ repo: "roc-random", owner: "lukewilliamboswell", alias: "random", platform: Bool.false, requires: [] },
{ repo: "roc-svg", owner: "hasnep", alias: "svg", platform: Bool.false, requires: [] },
{ repo: "roc-wasm4", owner: "lukewilliamboswell", alias: "pf", platform: Bool.true, requires: ["main"] },
{ repo: "rvn", owner: "jwoudenberg", alias: "rvn", platform: Bool.false, requires: [] },
{ repo: "weaver", owner: "smores56", alias: "weaver", platform: Bool.false, requires: [] },
]
2 changes: 1 addition & 1 deletion src/ArgParser.roc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cliParser =
}
|> Cli.finish {
name: "roc-start",
version: "v0.3.2",
version: "v0.3.3",
authors: ["Ian McLerran <[email protected]>"],
description: "A simple CLI tool for starting a new roc project. Specify your platform and packages by name, and roc-start will create a new .roc file with the latest releases.",
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model.roc
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ getSelectedItems : Model -> List Str
getSelectedItems = \model -> model.selected

menuIsFiltered : Model -> Bool
menuIsFiltered = \model ->
menuIsFiltered = \model ->
when model.state is
PlatformSelect _ -> List.len model.fullMenu < List.len model.platformList
PackageSelect _ -> List.len model.fullMenu < List.len model.packageList
Expand Down
6 changes: 3 additions & 3 deletions src/Repo.roc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module [RepositoryEntry, RemoteRepoEntry, CacheRepoEntry]

RepositoryEntry : { alias : Str, version : Str, url : Str }
RemoteRepoEntry : { repo : Str, owner : Str, alias : Str, platform : Bool }
CacheRepoEntry : { repo : Str, owner : Str, alias : Str, version : Str, url : Str, platform : Bool }
RepositoryEntry : { alias : Str, version : Str, url : Str, requires : List Str }
RemoteRepoEntry : { repo : Str, owner : Str, alias : Str, platform : Bool, requires : List Str }
CacheRepoEntry : { repo : Str, owner : Str, alias : Str, version : Str, url : Str, platform : Bool, requires : List Str }
10 changes: 6 additions & 4 deletions src/View.roc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ buildControlPromptStr = \actions, promptsDict ->
|> Str.joinWith " | "

## Render a multi-line text with word wrapping
renderMultiLineText : List Str, { startCol: I32, startRow: I32, maxCol: I32, wrapCol: I32, wordDelim ? Str, fg ? Core.Color } -> List Core.DrawFn
renderMultiLineText : List Str, { startCol : I32, startRow : I32, maxCol : I32, wrapCol : I32, wordDelim ? Str, fg ? Core.Color } -> List Core.DrawFn
renderMultiLineText = \words, { startCol, startRow, maxCol, wrapCol, wordDelim ? " ", fg ? Standard White } ->
firstLineWidth = maxCol - startCol
consecutiveWidths = maxCol - wrapCol
Expand All @@ -90,11 +90,13 @@ renderMultiLineText = \words, { startCol, startRow, maxCol, wrapCol, wordDelim ?
[Str.concat line word]
else
[line, word]

[.. as prevLines, line] ->
if Num.toI32 (Str.countUtf8Bytes line + Str.countUtf8Bytes word) <= consecutiveWidths then
List.concat prevLines [Str.concat line word]
else
List.concat prevLines [line, word]

[] -> [word]
List.mapWithIndex lineList \line, idx ->
if idx == 0 then
Expand Down Expand Up @@ -151,7 +153,7 @@ renderInputAppName = \model ->
renderScreenPrompt "ENTER THE APP NAME:",
Core.drawCursor { fg: Standard Magenta, char: ">" },
Core.drawText (nameBuffer |> Str.fromUtf8 |> Result.withDefault "") { r: model.menuRow, c: 4, fg: Standard White },

],
]

Expand Down Expand Up @@ -197,13 +199,13 @@ renderConfirmation = \model ->
Core.drawText config.platform { r: model.menuRow + 1, c: 12, fg: Standard White },
Core.drawText "Packages:" { r: model.menuRow + 2, c: 2, fg: Standard Magenta },
],
renderMultiLineText config.packages {
renderMultiLineText config.packages {
startCol: 12,
startRow: (model.menuRow + 2),
maxCol: (model.screen.width - 1),
wrapCol: 2,
wordDelim: ", ",
fg: (Standard White)
fg: Standard White,
},
]

Expand Down
23 changes: 14 additions & 9 deletions src/main.roc
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ RepositoryLoopState : { repositoryList : List RemoteRepoEntry, rvnDataStr : Str
reposToRvnStrLoop : RepositoryLoopState -> Task [Step RepositoryLoopState, Done Str] _
reposToRvnStrLoop = \{ repositoryList, rvnDataStr } ->
when List.get repositoryList 0 is
Ok { owner, repo, alias, platform } ->
Ok { owner, repo, alias, platform, requires } ->
updatedList = List.dropFirst repositoryList 1
response = getLatestRelease! owner repo
releaseData = responseToReleaseData response
when releaseData is
Ok { tagName, browserDownloadUrl } ->
updatedStr = Str.concat rvnDataStr (repoDataToRvnEntry { repo, owner, alias, version: tagName, url: browserDownloadUrl, platform })
updatedStr = Str.concat rvnDataStr (repoDataToRvnEntry { repo, owner, alias, version: tagName, url: browserDownloadUrl, platform, requires })
Task.ok (Step { repositoryList: updatedList, rvnDataStr: updatedStr })

Err _ -> Task.ok (Step { repositoryList: updatedList, rvnDataStr })
Expand Down Expand Up @@ -397,10 +397,10 @@ responseToReleaseData = \response ->
## Convert the data for a single repository entry to a string in rvn format.
repoDataToRvnEntry : CacheRepoEntry -> Str
repoDataToRvnEntry = \entry ->
boolStr = if entry.platform then "Bool.true" else "Bool.false"
"""
{ repo: "$(entry.repo)", owner: "$(entry.owner)", alias: "$(entry.alias)", version: "$(entry.version)", url: "$(entry.url)", platform: $(boolStr) },\n
"""
Encode.toBytes entry Rvn.compact
|> Str.fromUtf8
|> Result.withDefault ""
|> \str -> if !(Str.isEmpty str) then " $(str),\n" else str # Str.concat str ",\n" else str

## Convert the raw bytes from pkg-data.rvn to a Dictionary of RepositoryEntry with the repo name as the key.
getRepoDict : List U8 -> Dict Str RepositoryEntry
Expand All @@ -409,8 +409,8 @@ getRepoDict = \bytes ->
Decode.fromBytes bytes Rvn.pretty
|> Result.map \packageList ->
packageList
|> List.walk (Dict.empty {}) \dict, cacheEntry ->
Dict.insert dict cacheEntry.repo { alias: cacheEntry.alias, version: cacheEntry.version, url: cacheEntry.url }
|> List.walk (Dict.empty {}) \dict, entry ->
Dict.insert dict entry.repo { alias: entry.alias, version: entry.version, url: entry.url, requires: entry.requires }
when res is
Ok dict -> dict
Err _ -> Dict.empty {}
Expand Down Expand Up @@ -479,8 +479,13 @@ buildRocFile = \platform, packageList, repos, appStub ->
when Dict.get repos.packages package is
Ok pkg -> Str.concat str " $(pkg.alias): \"$(pkg.url)\",\n"
Err KeyNotFound -> ""
requiresStr =
Dict.get repos.platforms platform
|> Result.withDefault { requires: ["main"], alias: "", url: "", version: "" }
|> \pf -> pf.requires
|> Str.joinWith ", "

"app [main] {\n$(pfStr)$(pkgsStr)}\n" |> Str.toUtf8 |> List.concat appStub
"app [$(requiresStr)] {\n$(pfStr)$(pkgsStr)}\n" |> Str.toUtf8 |> List.concat appStub

## Get the application stub for the platform, if it exists
getAppStub : Str -> Task (List U8) _
Expand Down

0 comments on commit 1b4efe9

Please sign in to comment.