Skip to content

Commit

Permalink
Use a project variable for most imports (#228)
Browse files Browse the repository at this point in the history
# Problem

Attempting to use the `flipbook` variable to reference our types in the
past has resulted in those types not being recognized by luau-lsp. That
problem is now fixed with #227, so now we're free to use shorter paths

# Solution

This PR updates most `script.Parent` paths to use the `flipbook`
variable (and define it as needed) so that all paths are absolute.

# Checklist

- [ ] Ran `./bin/test.sh` locally before merging
  • Loading branch information
vocksel authored Dec 1, 2023
1 parent eb83794 commit 527c3da
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/Components/App.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ local constants = require(flipbook.constants)
local useStorybooks = require(flipbook.Hooks.useStorybooks)
local useTheme = require(flipbook.Hooks.useTheme)
local PluginContext = require(flipbook.Plugin.PluginContext)
local ResizablePanel = require(script.Parent.ResizablePanel)
local Canvas = require(script.Parent.Canvas)
local Sidebar = require(script.Parent.Sidebar)
local ResizablePanel = require(flipbook.Components.ResizablePanel)
local Canvas = require(flipbook.Components.Canvas)
local Sidebar = require(flipbook.Components.Sidebar)

export type Props = {
plugin: Plugin,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Canvas.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local NoStorySelected = require(flipbook.Components.NoStorySelected)
local StoryView = require(flipbook.Components.StoryView)
local useTheme = require(flipbook.Hooks.useTheme)
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ComponentTree/Component/Directory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local assets = require(flipbook.assets)
local constants = require(flipbook.constants)
local useTheme = require(flipbook.Hooks.useTheme)
local Sprite = require(flipbook.Components.Sprite)
local types = require(script.Parent.Parent.Parent.Parent.types)
local types = require(flipbook.types)

local e = React.createElement

Expand Down
2 changes: 1 addition & 1 deletion src/Components/ComponentTree/Component/Story.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local assets = require(flipbook.assets)
local constants = require(flipbook.constants)
local useTheme = require(flipbook.Hooks.useTheme)
local Sprite = require(flipbook.Components.Sprite)
local types = require(script.Parent.Parent.Parent.Parent.types)
local types = require(flipbook.types)

local e = React.createElement

Expand Down
2 changes: 1 addition & 1 deletion src/Components/ComponentTree/Component/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local Directory = require(script.Directory)
local Story = require(script.Story)
local types = require(script.Parent.Parent.Parent.types)
local types = require(flipbook.types)

local e = React.createElement

Expand Down
2 changes: 1 addition & 1 deletion src/Components/ComponentTree/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local Component = require(script.Component)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)

local e = React.createElement

Expand Down
2 changes: 1 addition & 1 deletion src/Components/DragHandle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local RunService = game:GetService("RunService")
local Sift = require(flipbook.Packages.Sift)
local React = require(flipbook.Packages.React)
local PluginContext = require(flipbook.Plugin.PluginContext)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)

local defaultProps = {
size = 8, -- px
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ResizablePanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local flipbook = script:FindFirstAncestor("flipbook")
local React = require(flipbook.Packages.React)
local Sift = require(flipbook.Packages.Sift)
local DragHandle = require(flipbook.Components.DragHandle)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)

local defaultProps = {
dragHandleSize = 8, -- px
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local ComponentTree = require(flipbook.Components.ComponentTree)
local Searchbar = require(flipbook.Components.Searchbar)
local ScrollingFrame = require(flipbook.Components.ScrollingFrame)
local useTheme = require(flipbook.Hooks.useTheme)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)

local e = React.createElement

Expand Down
2 changes: 1 addition & 1 deletion src/Components/StoryMeta.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local useTheme = require(flipbook.Hooks.useTheme)

local MAX_SUMMARY_SIZE = 600
Expand Down
2 changes: 1 addition & 1 deletion src/Components/StoryPreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local ReactRoblox = require(flipbook.Packages.ReactRoblox)
local Sift = require(flipbook.Packages.Sift)
local StoryError = require(flipbook.Components.StoryError)
local ScrollingFrame = require(flipbook.Components.ScrollingFrame)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local mountStory = require(flipbook.Story.mountStory)

local e = React.createElement
Expand Down
2 changes: 1 addition & 1 deletion src/Components/StoryView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local Selection = game:GetService("Selection")
local Sift = require(flipbook.Packages.Sift)
local React = require(flipbook.Packages.React)
local constants = require(flipbook.constants)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local useStory = require(flipbook.Hooks.useStory)
local useTheme = require(flipbook.Hooks.useTheme)
local useZoom = require(flipbook.Hooks.useZoom)
Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/useStory.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local loadStoryModule = require(flipbook.Story.loadStoryModule)

local function useStory(module: ModuleScript, storybook: types.Storybook, loader: any): (types.Story?, string?)
Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/useStorybooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local constants = require(flipbook.constants)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local isStorybookModule = require(flipbook.Story.isStorybookModule)
local useDescendants = require(flipbook.Hooks.useDescendants)

Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/useTheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local flipbook = script:FindFirstAncestor("flipbook")

local React = require(flipbook.Packages.React)
local themes = require(flipbook.themes)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)

local MOCK_STUDIO = {
ThemeChanged = Instance.new("BindableEvent").Event,
Expand Down
6 changes: 4 additions & 2 deletions src/Story/createStoryNodes.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local isStoryModule = require(script.Parent.isStoryModule)
local types = require(script.Parent.Parent.types)
local flipbook = script:FindFirstAncestor("flipbook")

local isStoryModule = require(flipbook.Story.isStoryModule)
local types = require(flipbook.types)

local function hasStories(instance: Instance): boolean
for _, descendant in ipairs(instance:GetDescendants()) do
Expand Down
2 changes: 1 addition & 1 deletion src/Story/createStoryNodes.spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
return function()
local flipbook = script:FindFirstAncestor("flipbook")

local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)
local newFolder = require(flipbook.TestHelpers.newFolder)
local createStoryNodes = require(script.Parent.createStoryNodes)

Expand Down
2 changes: 1 addition & 1 deletion src/Story/loadStoryModule.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local flipbook = script:FindFirstAncestor("flipbook")

local Sift = require(flipbook.Packages.Sift)
local types = require(script.Parent.Parent.types)
local types = require(flipbook.types)

local Errors = {
MalformedStory = "Story is malformed. Check the source of %q and make sure its properties are correct",
Expand Down
4 changes: 3 additions & 1 deletion src/Story/mountStory.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local types = require(script.Parent.Parent.types)
local flipbook = script:FindFirstAncestor("flipbook")

local types = require(flipbook.types)

local function mountFunctionalStory(story: types.FunctionalStory, props: types.StoryProps, parent: GuiObject)
local cleanup = story.story(parent, props)
Expand Down
2 changes: 1 addition & 1 deletion src/themes.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local flipbook = script:FindFirstAncestor("flipbook")

local types = require(script.Parent.types)
local types = require(flipbook.types)
local tailwind = require(flipbook.tailwind)

return {
Expand Down

0 comments on commit 527c3da

Please sign in to comment.