Skip to content

Commit

Permalink
Use Darklua for string requires (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel authored Apr 23, 2024
1 parent 536fe99 commit d3d90a3
Show file tree
Hide file tree
Showing 110 changed files with 446 additions and 520 deletions.
25 changes: 25 additions & 0 deletions .darklua.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"process": [
{
"rule": "convert_require",
"current": {
"name": "path",
"sources": {
"@pkg": "./Packages",
"@root": "./src"
}
},
"target": {
"name": "roblox",
"rojo_sourcemap": "./sourcemap-darklua.json",
"indexing_style": "property"
}
},
"compute_expression",
"remove_unused_if_branch",
"remove_unused_while",
"filter_after_early_return",
"remove_nil_declaration",
"remove_empty_do"
]
}
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ jobs:
sha=${GITHUB_SHA:0:7}
echo "MODEL_FILE=$name-$sha.rbxm" >> $GITHUB_ENV
- name: Initialize the project
run: just init

- name: Build
run: rojo build -o ${{ env.MODEL_FILE }}
run: just build-here prod ${{ env.MODEL_FILE }}

- uses: actions/upload-artifact@v3
with:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: extractions/setup-just@v1

- uses: Roblox/setup-foreman@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Remove spec files
run: rm -rf **/*.spec.luau

- name: Install packages
run: wally install

- name: Get model file name
run: |
name=$(jq -r .name default.project.json)
echo "MODEL_FILE=$name.rbxm" >> $GITHUB_ENV
- name: Initialize the project
run: just init

- name: Build
run: rojo build -o ${{ env.MODEL_FILE }}
run: just build-here prod ${{ env.MODEL_FILE }}

- uses: softprops/action-gh-release@v1
if: ${{ github.event.release }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Darklua
build

# Rojo
/*.rbxl*
/*.rbxm*
Expand Down
6 changes: 6 additions & 0 deletions .luaurc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"aliases": {
"pkg": "./Packages",
"root": "./src"
}
}
17 changes: 16 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
{
"luau-lsp.sourcemap.rojoProjectFile": "tests.project.json"
"luau-lsp.sourcemap.rojoProjectFile": "analysis.project.json",
"luau-lsp.types.definitionFiles": [
"testez.d.lua"
],
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.ignoreGlobs": [
"**/_Index/**",
"**/build/**"
],
"luau-lsp.require.directoryAliases": {
"@pkg": "./Packages",
"@root": "./src"
},
"files.associations": {
"*.luau": "lua"
}
}
37 changes: 18 additions & 19 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
"label": "Install packages",
"type": "shell",
"problemMatcher": [],
"command": "./bin/wally-install.sh"
"command": "just",
"args": [
"wally-install"
]
},
{
"label": "Build (Development)",
"type": "shell",
"problemMatcher": [],
"windows": {
"command": "rojo build dev.project.json -o $LOCALAPPDATA/Roblox/Plugins/flipbook.rbxm"
},
"osx": {
"command": "rojo build dev.project.json -o ~/Documents/Roblox/Plugins/flipbook.rbxm"
},
"command": "just",
"args": [
"build",
"dev"
],
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -28,12 +30,11 @@
"label": "Build (Production)",
"type": "shell",
"problemMatcher": [],
"windows": {
"command": "rojo build -o $LOCALAPPDATA/Roblox/Plugins/flipbook.rbxm"
},
"osx": {
"command": "rojo build -o ~/Documents/Roblox/Plugins/flipbook.rbxm"
},
"command": "just",
"args": [
"build",
"prod"
],
"group": {
"kind": "build",
}
Expand All @@ -42,12 +43,10 @@
"label": "Build and watch",
"type": "shell",
"problemMatcher": [],
"windows": {
"command": "rojo build dev.project.json -o $LOCALAPPDATA/Roblox/Plugins/flipbook.rbxm --watch"
},
"osx": {
"command": "rojo build dev.project.json -o ~/Documents/Roblox/Plugins/flipbook.rbxm --watch",
}
"command": "just",
"args": [
"build-watch",
]
},
{
"label": "Serve docs",
Expand Down
12 changes: 12 additions & 0 deletions analysis.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "flipbook",
"tree": {
"TestRunner": {
"$path": "tests"
},
"Example": {
"$path": "example"
},
"$path": "build.project.json"
}
}
5 changes: 4 additions & 1 deletion dev.project.json → build.project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "flipbook",
"tree": {
"Packages": {
"$path": "Packages"
},
"Example": {
"$path": "example"
},
"$path": "default.project.json"
"$path": "src"
}
}
4 changes: 2 additions & 2 deletions default.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"Packages": {
"$path": "Packages"
},
"$path": "src"
"$path": "build"
}
}
}
8 changes: 3 additions & 5 deletions example/ArrayControls.story.luau
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local Sift = require(Example.Parent.Packages.Sift)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")
local Sift = require("@pkg/Sift")

local fonts = Sift.Array.sort(Enum.Font:GetEnumItems(), function(a: Enum.Font, z: Enum.Font)
return a.Name < z.Name
Expand Down
4 changes: 1 addition & 3 deletions example/Button.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
local Roact = require("@pkg/Roact")

export type Props = {
text: string,
Expand Down
6 changes: 2 additions & 4 deletions example/Button.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local Button = require(script.Parent.Button)
local Roact = require(Example.Parent.Packages.Roact)
local Button = require("./Button")
local Roact = require("@pkg/Roact")

return {
summary = "A generic button component that can be used anywhere",
Expand Down
4 changes: 1 addition & 3 deletions example/ButtonWithControls.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
local Roact = require("@pkg/Roact")

export type Props = {
text: string,
Expand Down
6 changes: 2 additions & 4 deletions example/ButtonWithControls.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local ButtonWithControls = require(script.Parent.ButtonWithControls)
local Roact = require(Example.Parent.Packages.Roact)
local ButtonWithControls = require("./ButtonWithControls")
local Roact = require("@pkg/Roact")

local controls = {
isDisabled = false,
Expand Down
6 changes: 2 additions & 4 deletions example/CanvasTests/AutomaticSize.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")

return {
summary = "AutoamticSize test for the story preview",
Expand Down
6 changes: 2 additions & 4 deletions example/CanvasTests/AutomaticSizeExceedsBounds.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")

return {
summary = "AutoamticSize test using a height that exceeds the story preview",
Expand Down
6 changes: 2 additions & 4 deletions example/CanvasTests/Offset.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")

return {
summary = "Offset test for the story preview",
Expand Down
6 changes: 2 additions & 4 deletions example/CanvasTests/Resizing.story.luau
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
local Example = script:FindFirstAncestor("Example")

local RunService = game:GetService("RunService")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")

local RESIZE_DURATIOn = 3 -- seconds
local MAX_SIZE = 2000 -- px
Expand Down
6 changes: 2 additions & 4 deletions example/CanvasTests/Scale.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")

return {
summary = "Scale test for the story preview",
Expand Down
6 changes: 2 additions & 4 deletions example/CanvasTests/ScrollingFrame.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactRoblox = require("@pkg/ReactRoblox")

return {
summary = "ScrollingFrame test for the story preview",
Expand Down
4 changes: 1 addition & 3 deletions example/Counter.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
local Roact = require("@pkg/Roact")

local Counter = Roact.Component:extend("Counter")

Expand Down
6 changes: 2 additions & 4 deletions example/Counter.story.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local Example = script:FindFirstAncestor("Example")

local Counter = require(script.Parent.Counter)
local Roact = require(Example.Parent.Packages.Roact)
local Counter = require("./Counter")
local Roact = require("@pkg/Roact")

local controls = {
increment = 1,
Expand Down
4 changes: 1 addition & 3 deletions example/Hoarcekat.story.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
local Roact = require("@pkg/Roact")

return function(target: Instance)
local root = Roact.createElement("TextLabel", {
Expand Down
4 changes: 1 addition & 3 deletions example/ReactCounter.luau
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local React = require("@pkg/React")

export type Props = {
increment: number,
Expand Down
8 changes: 3 additions & 5 deletions example/ReactCounter.story.luau
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
local ReactCounter = require(script.Parent.ReactCounter)
local ReactRoblox = require(Example.Parent.Packages.ReactRoblox)
local React = require("@pkg/React")
local ReactCounter = require("./ReactCounter")
local ReactRoblox = require("@pkg/ReactRoblox")

local controls = {
increment = 1,
Expand Down
1 change: 1 addition & 0 deletions foreman.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tools]
rojo = { source = "rojo-rbx/rojo", version = "7.2.1" }
darklua = { source = "seaofvoices/darklua", version = "0.12.1" }
run-in-roblox = { source = "rojo-rbx/run-in-roblox", version = "0.3.0" }
selene = { source = "kampfkarren/selene", version = "0.25.0" }
stylua = { source = "JohnnyMorganz/StyLua", version = "0.17.1" }
Expand Down
Loading

0 comments on commit d3d90a3

Please sign in to comment.