Skip to content

Commit

Permalink
Rename all Lua files to Luau (#238)
Browse files Browse the repository at this point in the history
1. Renamed `.lua` files to `.luau`
2. Updated files that _refer_ to `.lua` files to use `.luau`
3. Added .gitattributes to tell GitHub to use Lua syntax highlighting
for Luau files
  • Loading branch information
vocksel authored Apr 11, 2024
1 parent ba1764f commit 2a742e5
Show file tree
Hide file tree
Showing 118 changed files with 42 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.luau linguist-language=Lua
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Format
run: stylua --check src/

- name: Lint file extensions
run: ./bin/lint.sh

- name: Install dependencies
run: wally install

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

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

- name: Install packages
run: wally install
Expand Down
2 changes: 1 addition & 1 deletion bin/analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ curl -s -O https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/master/scrip

rojo sourcemap tests.project.json -o sourcemap.json

luau-lsp analyze --sourcemap=sourcemap.json --defs=globalTypes.d.lua --defs=testez.d.lua --ignore=**/_Index/** src/
luau-lsp analyze --sourcemap=sourcemap.json --defs=globalTypes.d.lua --defs=testez.d.luau --ignore=**/_Index/** src/
exit_code=$?

rm globalTypes.d.lua
Expand Down
11 changes: 11 additions & 0 deletions bin/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -euo pipefail

echo "Lint file extensions"
files=$(find src example -iname "*.lua")
if [[ -n "$files" ]]; then
echo "Error: one or more files are using the '.lua' extension. Please update these to '.luau' and try again"
echo "$files"
exit 1
fi
2 changes: 1 addition & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rojo build tests.project.json -o tests.rbxl
run-in-roblox --place tests.rbxl --script tests/init.server.lua
run-in-roblox --place tests.rbxl --script tests/init.server.luau
rm tests.rbxl
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Then load a new Baseplate and open the flipbook plugin. Its storybook should now

## Testing

While developing, you should also be writing unit tests. Unit tests are written in `.spec.lua` files. You can see examples of this throughout the repository's codebase.
While developing, you should also be writing unit tests. Unit tests are written in `.spec.luau` files. You can see examples of this throughout the repository's codebase.

To run tests, simply start the experience in Studio. You will see in the output if tests are passing or failing.

Expand Down
16 changes: 8 additions & 8 deletions docs/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ This guide assumes you are using [Rojo](https://github.com/rojo-rbx/rojo/) to ma

The main difference in how flipbook and Hoarcekat handle stories is that flipbook requires a "storybook" file to know where your stories are. As such, to migrate over from Hoarcekat the first thing you should do is create a storybook for your project.

To do this, create a new `ProjectName.storybook.lua` file at the root of your project with the following contents:
To do this, create a new `ProjectName.storybook.luau` file at the root of your project with the following contents:

```lua
-- Make sure to adjust the path to Roact if needed
-- Make sure to adjust the path to Roact if needed
local Roact = require(script.Parent.Parent.Roact)

return {
roact = Roact,
storyRoots = {
storyRoots = {
script.Parent.Components
}
}
Expand All @@ -38,13 +38,13 @@ To fully benefit from the features flipbook has to offer, this section will guid
We will use the following component and story as an example:

```lua
-- HelloWorld.lua
-- HelloWorld.luau
type Props = {
name: string?
}

local function HelloWorld(props: Props)
local name = props.name or "World"
local name = props.name or "World"

return Roact.createElement("TextLabel", {
Text = ("Hello %s!"):format(name),
Expand All @@ -60,7 +60,7 @@ return HelloWorld
```

```lua
-- HelloWorld.story.lua
-- HelloWorld.story.luau
local Roact = require(script.Parent.Parent.Roact)
local HelloWorld = require(script.Parent.HelloWorld)

Expand All @@ -82,7 +82,7 @@ end
Converting a Hoarcekat story like this into one compatible with flipbook is quite easy. In fact, all that's needed from the above story is the call to `Roact.createElement`:

```lua
-- HelloWorld.story.lua
-- HelloWorld.story.luau
local Roact = require(script.Parent.Parent.Roact)
local HelloWorld = require(script.Parent.HelloWorld)

Expand Down Expand Up @@ -137,4 +137,4 @@ You are now equipped to migrate your other Hoarcekat stories over to flipbook!
## Further Reading

- [Writing Stories](writing-stories.md)
- [Story Format](story-format.md)
- [Story Format](story-format.md)
12 changes: 6 additions & 6 deletions docs/story-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The only required prop is the `storyRoots` array, which tells flipbook which Ins
Example:

```lua
-- example/Example.storybook.lua
-- example/Example.storybook.luau
return {
name = "Example Storybook",
storyRoots = {
Expand All @@ -47,7 +47,7 @@ Support for Roblox's [Roact](https://github.com/Roblox/roact) library is built i
Example:

```lua
-- example/Button.story.lua
-- example/Button.story.luau
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
Expand All @@ -68,7 +68,7 @@ return {
Example with controls:

```lua
-- example/ButtonWithControls.story.lua
-- example/ButtonWithControls.story.luau
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
Expand Down Expand Up @@ -116,7 +116,7 @@ You can find React and ReactRoblox as part of the [CorePackages](https://github.
Example:

```lua
-- example/ReactCounter.story.lua
-- example/ReactCounter.story.luau
local Example = script:FindFirstAncestor("Example")

local React = require(Example.Parent.Packages.React)
Expand Down Expand Up @@ -160,7 +160,7 @@ A Functional story uses a function to create and mount UI. This is the most flex
Example:

```lua
-- example/Functional.story.lua
-- example/Functional.story.luau
local controls = {
text = "Functional Story",
}
Expand Down Expand Up @@ -206,7 +206,7 @@ See the [migration guide](migrating.md) for more info.
Example:

```lua
-- example/Hoarcekat.story.lua
-- example/Hoarcekat.story.luau
local Example = script:FindFirstAncestor("Example")

local Roact = require(Example.Parent.Packages.Roact)
Expand Down
16 changes: 8 additions & 8 deletions docs/writing-stories.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ flipbook uses the concept of "storybooks" and "stories." A storybook is used to

## Storybook

Every project needs a storybook, so to get started you will create a new `ProjectName.storybook.lua` file at the root of your project with the following contents:
Every project needs a storybook, so to get started you will create a new `ProjectName.storybook.luau` file at the root of your project with the following contents:

```lua
-- src/ProjectName.storybook.lua
-- src/ProjectName.storybook.luau

-- Make sure to adjust the path to Roact if needed
-- Make sure to adjust the path to Roact if needed
local Roact = require(path.to.Roact)

return {
roact = Roact,
storyRoots = {
storyRoots = {
script.Parent.Components
}
}
Expand All @@ -30,10 +30,10 @@ Right now you should see a single entry in flipbook's sidebar for this storybook

## Story

A story and its associated component should be in two separate files. Both files should share the same name, however the story will end with `.story`. To get started, let's create `Button.lua` and `Button.story.lua`:
A story and its associated component should be in two separate files. Both files should share the same name, however the story will end with `.story`. To get started, let's create `Button.luau` and `Button.story.luau`:

```lua
-- src/Components/Button.lua
-- src/Components/Button.luau

local Roact = require(path.to.Roact)

Expand Down Expand Up @@ -68,7 +68,7 @@ return Button
And now let's write the story to mount the Button component:

```lua
-- src/Components/Button.story.lua
-- src/Components/Button.story.luau

local Roact = require(path.to.Roact)
local Button = require(script.Parent.Button)
Expand Down Expand Up @@ -185,4 +185,4 @@ With this change, a new "Controls" panel will appear where you can toggle the `i

You have just been given an example of how to create a storybook and a story for a Button component that makes use of flipbook's controls feature. This document outlines the biggest features of flipbook, but there are other options you can play around with.

Check out [Story Format](story-format.md) next to learn about all the options you have available.
Check out [Story Format](story-format.md) next to learn about all the options you have available.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tarmac.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "flipbook"
[[inputs]]
glob = "img/**/*.png"
codegen = true
codegen-path = "src/assets.lua"
codegen-path = "src/assets.luau"
codegen-base-path = "img"
packable = true
File renamed without changes.
File renamed without changes.

0 comments on commit 2a742e5

Please sign in to comment.