From 21ab95f382ad9528ef067ff6087ad498a82d7144 Mon Sep 17 00:00:00 2001 From: jeparlefrancais Date: Thu, 21 Mar 2024 14:57:49 -0400 Subject: [PATCH 1/5] Convert Roblox requires to path requires --- src/.robloxrc | 8 ------- src/DOMElementFilter.lua | 9 ++++--- src/__tests__/config.spec.lua | 6 ++--- src/__tests__/element-queries.spec.lua | 12 ++++------ src/__tests__/events.spec.lua | 24 +++++++++---------- src/__tests__/example.spec.lua | 12 ++++------ src/__tests__/get-node-text.spec.lua | 8 +++---- .../get-queries-for-element.spec.lua | 12 ++++------ src/__tests__/get-user-code-frame.spec.lua | 12 ++++------ src/__tests__/helpers.spec.lua | 12 ++++------ src/__tests__/helpers/test-utils.lua | 8 +++---- src/__tests__/matches.spec.lua | 10 ++++---- src/__tests__/pretty-dom.spec.lua | 14 +++++------ src/__tests__/query-helper.spec.lua | 8 +++---- src/__tests__/screen.spec.lua | 16 ++++++------- src/__tests__/suggestions.spec.lua | 22 ++++++++--------- .../wait-for-element-to-be-removed.spec.lua | 14 +++++------ src/__tests__/wait-for.spec.lua | 21 ++++++++-------- src/config.lua | 10 ++++---- src/events.lua | 12 ++++------ src/get-node-test-id.lua | 5 ++-- src/get-queries-for-element.lua | 6 ++--- src/get-user-code-frame.lua | 9 ++++--- src/helpers.lua | 11 ++++----- src/init.lua | 20 +++++++--------- src/jest.config.lua | 5 ++-- src/jsHelpers/InputValidation.roblox.lua | 1 - .../__tests__/InputValidation.roblox.spec.lua | 9 +++---- .../__tests__/babel-code-frame.spec.lua | 12 ++++------ .../__tests__/dispatchEvent.spec.lua | 6 ++--- .../__tests__/querySelectors.spec.lua | 6 ++--- src/jsHelpers/babel-code-frame.lua | 6 ++--- src/jsHelpers/dispatchEvent.lua | 7 ++---- src/jsHelpers/fs.lua | 4 +--- src/jsHelpers/jest-dom.lua | 5 ++-- src/jsHelpers/querySelectors.lua | 5 ++-- src/jsHelpers/typeError.lua | 3 +-- src/matches.lua | 8 +++---- src/pretty-dom.lua | 15 ++++++------ src/queries/all-utils.lua | 4 +--- src/queries/display-value.lua | 14 +++++------ src/queries/init.lua | 4 +--- src/queries/placeholder-text.lua | 12 ++++------ src/queries/test-id.lua | 12 ++++------ src/queries/text.lua | 14 +++++------ src/query-helpers.lua | 18 +++++++------- src/screen.lua | 20 +++++++--------- src/suggestions.lua | 22 ++++++++--------- src/types/config.lua | 4 +--- src/types/get-queries-for-element.lua | 6 ++--- src/types/init.lua | 24 +++++++++---------- src/types/matches.lua | 6 ++--- src/types/pretty-dom.lua | 4 +--- src/types/queries.lua | 12 ++++------ src/types/query-helpers.lua | 7 +++--- src/types/screen.lua | 10 ++++---- src/types/suggestions.lua | 6 ++--- src/types/wait-for-element-to-be-removed.lua | 6 ++--- src/types/wait-for.lua | 3 +-- src/wait-for-element-to-be-removed.lua | 10 ++++---- src/wait-for.lua | 17 +++++++------ 61 files changed, 260 insertions(+), 368 deletions(-) delete mode 100644 src/.robloxrc diff --git a/src/.robloxrc b/src/.robloxrc deleted file mode 100644 index 4231d32..0000000 --- a/src/.robloxrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "language": { - "mode": "strict" - }, - "lint": { - "*": "enabled" - } -} diff --git a/src/DOMElementFilter.lua b/src/DOMElementFilter.lua index 1406f7f..3297881 100644 --- a/src/DOMElementFilter.lua +++ b/src/DOMElementFilter.lua @@ -1,11 +1,10 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/DOMElementFilter.ts -- ROBLOX comment: replaced with https://github.com/Roblox/jest-roblox/blob/v2.4.1/src/pretty-format/src/plugins/RobloxInstance.lua ---[[ ROBLOX comment: +--[[ ROBLOX comment: this plugin serializes Roblox Instance objects https://developer.roblox.com/en-us/api-reference/class/Instance ]] -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Object = LuauPolyfill.Object local instanceof = LuauPolyfill.instanceof @@ -13,10 +12,10 @@ type Object = LuauPolyfill.Object local exports = {} -local JestGetType = require(Packages.JestGetType) +local JestGetType = require("@pkg/@jsdotlua/jest-get-type") local getType = JestGetType.getType -local RobloxInstance = require(Packages.RobloxShared).RobloxInstance +local RobloxInstance = require("@pkg/@jsdotlua/jest-roblox-shared").RobloxInstance local getRobloxProperties = RobloxInstance.getRobloxProperties local InstanceSubset = RobloxInstance.InstanceSubset diff --git a/src/__tests__/config.spec.lua b/src/__tests__/config.spec.lua index 19a65cf..fb3eaad 100644 --- a/src/__tests__/config.spec.lua +++ b/src/__tests__/config.spec.lua @@ -1,15 +1,13 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/config.js -local Packages = script.Parent.Parent.Parent - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local describe = JestGlobals.describe local beforeEach = JestGlobals.beforeEach local afterEach = JestGlobals.afterEach -local configModule = require(script.Parent.Parent.config) +local configModule = require("../config") local configure = configModule.configure local getConfig = configModule.getConfig diff --git a/src/__tests__/element-queries.spec.lua b/src/__tests__/element-queries.spec.lua index b3a6a8e..7934689 100644 --- a/src/__tests__/element-queries.spec.lua +++ b/src/__tests__/element-queries.spec.lua @@ -1,9 +1,7 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/element-queries.js -local Packages = script.Parent.Parent.Parent +local RegExp = require("@pkg/luau-regexp") -local RegExp = require(Packages.LuauRegExp) - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local describe = JestGlobals.describe @@ -11,13 +9,13 @@ local afterEach = JestGlobals.afterEach local CollectionService = game:GetService("CollectionService") -local configure = require(script.Parent.Parent.config).configure +local configure = require("../config").configure -- ROBLOX deviation START: to restore config -local getConfig = require(script.Parent.Parent.config).getConfig +local getConfig = require("../config").getConfig -- ROBLOX deviation START -local test_utilsModule = require(script.Parent.helpers["test-utils"]) +local test_utilsModule = require("./helpers/test-utils") local render = test_utilsModule.render local renderIntoDocument = test_utilsModule.renderIntoDocument test("query can return null", function() diff --git a/src/__tests__/events.spec.lua b/src/__tests__/events.spec.lua index 19097b1..386b88d 100644 --- a/src/__tests__/events.spec.lua +++ b/src/__tests__/events.spec.lua @@ -1,21 +1,19 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/events.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local describe = JestGlobals.describe local jest = JestGlobals.jest -local document = require(script.Parent.Parent.jsHelpers.document) +local document = require("../jsHelpers/document") -local event_mapModule = require(script.Parent.Parent["event-map"]) +local event_mapModule = require("../event-map") local _eventMap = event_mapModule.eventMap local _eventAliasMap = event_mapModule.eventAliasMap -local ParentModule = require(script.Parent.Parent) +local ParentModule = require("..") local fireEvent = ParentModule.fireEvent local _createEvent = ParentModule.createEvent @@ -114,15 +112,15 @@ local eventTypes = { Array.forEach(eventTypes, function(ref) local type_, events = ref.type, ref.events describe(("%s Events"):format(type_), function() - Array.forEach(events, function(event) + for _, event in events do -- ROBLOX deviation START: adjust to deviated events test(("fires %s"):format(event.name), function() - Array.forEach(event.tests, function(test) + for _, test in event.tests do local node = Instance.new(test.element) local connection - Array.forEach(test.props, function(prop) + for _, prop in test.props do node[prop] = test.props[prop] - end) + end local spy = jest.fn() connection = node[test.listener]:Connect(function(...) local args = { ... } @@ -133,10 +131,10 @@ Array.forEach(eventTypes, function(ref) fireEvent[event.name](node, test.eventProps) expect(spy).toHaveBeenCalledTimes(1) connection:Disconnect() - end) + end end) -- ROBLOX deviation END - end) + end end) end) test("fires resize", function() diff --git a/src/__tests__/example.spec.lua b/src/__tests__/example.spec.lua index 6e6ca3a..c12d779 100644 --- a/src/__tests__/example.spec.lua +++ b/src/__tests__/example.spec.lua @@ -1,18 +1,16 @@ -- ROBLOX upstream: no upstream -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local setTimeout = LuauPolyfill.setTimeout -local Promise = require(Packages.Promise) +local Promise = require("@pkg/@jsdotlua/promise") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local CollectionService = game:GetService("CollectionService") -local domTestingModule = require(script.Parent.Parent) +local domTestingModule = require("..") local fireEvent, getByPlaceholderText, getByText, getByTestId, queryByTestId, waitFor = domTestingModule.fireEvent, domTestingModule.getByPlaceholderText, @@ -21,7 +19,7 @@ local fireEvent, getByPlaceholderText, getByText, getByTestId, queryByTestId, wa domTestingModule.queryByTestId, domTestingModule.waitFor -local querySelector = require(script.Parent.Parent.jsHelpers.querySelectors).querySelector +local querySelector = require("../jsHelpers/querySelectors").querySelector local function getExampleDOM() local div = Instance.new("Frame") diff --git a/src/__tests__/get-node-text.spec.lua b/src/__tests__/get-node-text.spec.lua index 9a282cf..09a2d24 100644 --- a/src/__tests__/get-node-text.spec.lua +++ b/src/__tests__/get-node-text.spec.lua @@ -1,12 +1,10 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/get-node-text.js - -local Packages = script.Parent.Parent.Parent -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test -local getNodeText = require(script.Parent.Parent["get-node-text"]).getNodeText -local render = require(script.Parent.helpers["test-utils"]).render +local getNodeText = require("../get-node-text").getNodeText +local render = require("./helpers/test-utils").render --[[ ROBLOX deviation START: diff --git a/src/__tests__/get-queries-for-element.spec.lua b/src/__tests__/get-queries-for-element.spec.lua index 0196c29..7859a27 100644 --- a/src/__tests__/get-queries-for-element.spec.lua +++ b/src/__tests__/get-queries-for-element.spec.lua @@ -1,19 +1,17 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/get-queries-for-element.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Object = LuauPolyfill.Object -local document = require(script.Parent.Parent.jsHelpers.document) +local document = require("../jsHelpers/document") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local jest = JestGlobals.jest -local getQueriesForElement = require(script.Parent.Parent["get-queries-for-element"]).getQueriesForElement -local queries = require(script.Parent.Parent.queries) +local getQueriesForElement = require("../get-queries-for-element").getQueriesForElement +local queries = require("../queries") test("uses default queries", function() local container = Instance.new("Frame") container.Parent = document diff --git a/src/__tests__/get-user-code-frame.spec.lua b/src/__tests__/get-user-code-frame.spec.lua index 5a11483..28b5023 100644 --- a/src/__tests__/get-user-code-frame.spec.lua +++ b/src/__tests__/get-user-code-frame.spec.lua @@ -1,20 +1,18 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/get-user-code-frame.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Error = LuauPolyfill.Error -local stripAnsi = require(script.Parent.Parent.jsHelpers["strip-ansi"]) +local stripAnsi = require("../jsHelpers/strip-ansi") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local beforeEach = JestGlobals.beforeEach local afterEach = JestGlobals.afterEach local jest = JestGlobals.jest -local fs = require(script.Parent.Parent.jsHelpers.fs) -local codeFrame = require(script.Parent.Parent["get-user-code-frame"]) +local fs = require("../jsHelpers/fs") +local codeFrame = require("../get-user-code-frame") -- ROBLOX deviation START: different error format, doesn't contain column info -- local userStackFrame = "at somethingWrong (/sample-error/error-example.js:7:14)" diff --git a/src/__tests__/helpers.spec.lua b/src/__tests__/helpers.spec.lua index 0560d61..a52f053 100644 --- a/src/__tests__/helpers.spec.lua +++ b/src/__tests__/helpers.spec.lua @@ -1,27 +1,25 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/helpers.js -local Packages = script.Parent.Parent.Parent +local Promise = require("@pkg/@jsdotlua/promise") -local Promise = require(Packages.Promise) - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local describe = JestGlobals.describe local jest = JestGlobals.jest -- ROBLOX deviation START: assume constant document -local document = require(script.Parent.Parent.jsHelpers.document) +local document = require("../jsHelpers/document") -- ROBLOX deviation END -- ROBLOX TODO START: not ported yet. Mocked --- local screen = require(script.Parent.Parent).screen +-- local screen = require("..").screen local screen = { debug = function() end, logTestingPlaygroundURL = function() end, } -- ROBLOX TODO END -local helpersModule = require(script.Parent.Parent.helpers) +local helpersModule = require("../helpers") local getDocument = helpersModule.getDocument local getWindowFromNode = helpersModule.getWindowFromNode local checkContainerType = helpersModule.checkContainerType diff --git a/src/__tests__/helpers/test-utils.lua b/src/__tests__/helpers/test-utils.lua index 763c20b..d6ff50e 100644 --- a/src/__tests__/helpers/test-utils.lua +++ b/src/__tests__/helpers/test-utils.lua @@ -1,17 +1,17 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/helpers/test-utils.js local Packages = script.Parent.Parent.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Object = LuauPolyfill.Object type Array = LuauPolyfill.Array type Object = LuauPolyfill.Object -local afterEach = require(Packages.JestGlobals).afterEach +local afterEach = require("@pkg/@jsdotlua/jest-globals").afterEach -local document = require(script.Parent.Parent.Parent.jsHelpers.document) +local document = require("../../jsHelpers/document") local exports = {} -local getQueriesForElement = require(script.Parent.Parent.Parent["get-queries-for-element"]).getQueriesForElement +local getQueriesForElement = require("../../get-queries-for-element").getQueriesForElement local function render(html: Array, ref_: Object?) local ref = (if ref_ == nil then {} else ref_) :: Object diff --git a/src/__tests__/matches.spec.lua b/src/__tests__/matches.spec.lua index 752b897..ea097f2 100644 --- a/src/__tests__/matches.spec.lua +++ b/src/__tests__/matches.spec.lua @@ -1,17 +1,15 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/matches.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local console = LuauPolyfill.console -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local jest = JestGlobals.jest -local matchesModule = require(script.Parent.Parent.matches) +local matchesModule = require("../matches") local fuzzyMatches = matchesModule.fuzzyMatches local matches = matchesModule.matches diff --git a/src/__tests__/pretty-dom.spec.lua b/src/__tests__/pretty-dom.spec.lua index e718b89..a80f03a 100644 --- a/src/__tests__/pretty-dom.spec.lua +++ b/src/__tests__/pretty-dom.spec.lua @@ -1,10 +1,8 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/pretty-dom.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local console = LuauPolyfill.console -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local describe = JestGlobals.describe @@ -12,13 +10,13 @@ local beforeEach = JestGlobals.beforeEach local afterEach = JestGlobals.afterEach local jest = JestGlobals.jest -local document = require(script.Parent.Parent.jsHelpers.document) +local document = require("../jsHelpers/document") -local pretty_domModule = require(script.Parent.Parent["pretty-dom"]) +local pretty_domModule = require("../pretty-dom") local prettyDOM = pretty_domModule.prettyDOM local logDOM = pretty_domModule.logDOM -local getUCDModule = require(script.Parent.Parent["get-user-code-frame"]) -local test_utilsModule = require(script.Parent.helpers["test-utils"]) +local getUCDModule = require("../get-user-code-frame") +local test_utilsModule = require("./helpers/test-utils") local render = test_utilsModule.render local renderIntoDocument = test_utilsModule.renderIntoDocument diff --git a/src/__tests__/query-helper.spec.lua b/src/__tests__/query-helper.spec.lua index cff73df..3c65fe3 100644 --- a/src/__tests__/query-helper.spec.lua +++ b/src/__tests__/query-helper.spec.lua @@ -1,15 +1,13 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/query-helper.js -local Packages = script.Parent.Parent.Parent - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local beforeEach = JestGlobals.beforeEach local afterEach = JestGlobals.afterEach local jest = JestGlobals.jest -local queryHelpers = require(script.Parent.Parent["query-helpers"]) -local configModule = require(script.Parent.Parent.config) +local queryHelpers = require("../query-helpers") +local configModule = require("../config") local configure = configModule.configure local getConfig = configModule.getConfig diff --git a/src/__tests__/screen.spec.lua b/src/__tests__/screen.spec.lua index 01d9161..7b5d9d8 100644 --- a/src/__tests__/screen.spec.lua +++ b/src/__tests__/screen.spec.lua @@ -1,23 +1,21 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/screen.js -local Packages = script.Parent.Parent.Parent - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local beforeEach = JestGlobals.beforeEach local afterEach = JestGlobals.afterEach local jest = JestGlobals.jest -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local console = LuauPolyfill.console -local Promise = require(Packages.Promise) -local RegExp = require(Packages.LuauRegExp) +local Promise = require("@pkg/@jsdotlua/promise") +local RegExp = require("@pkg/luau-regexp") -local getUCDModule = require(script.Parent.Parent["get-user-code-frame"]) +local getUCDModule = require("../get-user-code-frame") -local screen = require(script.Parent.Parent.screen).screen -local test_utilsModule = require(script.Parent.helpers["test-utils"]) +local screen = require("../screen").screen +local test_utilsModule = require("./helpers/test-utils") local _render = test_utilsModule.render local renderIntoDocument = test_utilsModule.renderIntoDocument diff --git a/src/__tests__/suggestions.spec.lua b/src/__tests__/suggestions.spec.lua index 82217c0..4d99a17 100644 --- a/src/__tests__/suggestions.spec.lua +++ b/src/__tests__/suggestions.spec.lua @@ -1,29 +1,27 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/suggestions.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local console = LuauPolyfill.console -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local beforeAll = JestGlobals.beforeAll local afterAll = JestGlobals.afterAll local afterEach = JestGlobals.afterEach -local typesModule = require(script.Parent.Parent.types) +local typesModule = require("../types") type Suggestion = typesModule.Suggestion -local querySelector = require(script.Parent.Parent.jsHelpers.querySelectors).querySelector -local querySelectorAll = require(script.Parent.Parent.jsHelpers.querySelectors).querySelectorAll +local querySelector = require("../jsHelpers/querySelectors").querySelector +local querySelectorAll = require("../jsHelpers/querySelectors").querySelectorAll local CollectionService = game:GetService("CollectionService") -local configure = require(script.Parent.Parent.config).configure -local screen = require(script.Parent.Parent.screen).screen -local getSuggestedQuery = require(script.Parent.Parent.suggestions).getSuggestedQuery -local test_utilsModule = require(script.Parent.helpers["test-utils"]) +local configure = require("../config").configure +local screen = require("../screen").screen +local getSuggestedQuery = require("../suggestions").getSuggestedQuery +local test_utilsModule = require("./helpers/test-utils") local renderIntoDocument = test_utilsModule.renderIntoDocument local render = test_utilsModule.render diff --git a/src/__tests__/wait-for-element-to-be-removed.spec.lua b/src/__tests__/wait-for-element-to-be-removed.spec.lua index 4f58ac2..71afdcd 100644 --- a/src/__tests__/wait-for-element-to-be-removed.spec.lua +++ b/src/__tests__/wait-for-element-to-be-removed.spec.lua @@ -1,24 +1,22 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/wait-for-element-to-be-removed.js -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Error = LuauPolyfill.Error local setTimeout = LuauPolyfill.setTimeout -local Promise = require(Packages.Promise) +local Promise = require("@pkg/@jsdotlua/promise") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local CollectionService = game:GetService("CollectionService") local waitForElementToBeRemoved = - require(script.Parent.Parent["wait-for-element-to-be-removed"]).waitForElementToBeRemoved -local renderIntoDocument = require(script.Parent.helpers["test-utils"]).renderIntoDocument + require("../wait-for-element-to-be-removed").waitForElementToBeRemoved +local renderIntoDocument = require("./helpers/test-utils").renderIntoDocument -local document = require(script.Parent.Parent.jsHelpers.document) +local document = require("../jsHelpers/document") test("resolves on mutation only when the element is removed", function() return Promise.resolve() :andThen(function() diff --git a/src/__tests__/wait-for.spec.lua b/src/__tests__/wait-for.spec.lua index 5d91097..63a7b31 100644 --- a/src/__tests__/wait-for.spec.lua +++ b/src/__tests__/wait-for.spec.lua @@ -1,12 +1,11 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/wait-for.js -local Packages = script.Parent.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Error = LuauPolyfill.Error local setTimeout = LuauPolyfill.setTimeout -local Promise = require(Packages.Promise) +local Promise = require("@pkg/@jsdotlua/promise") -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local beforeEach = JestGlobals.beforeEach @@ -19,11 +18,11 @@ local CollectionService = game:GetService("CollectionService") local __dirname = "wait%-for%.spec" -- ROBLOX deviation END -local waitFor = require(script.Parent.Parent["wait-for"]).waitFor -local configModule = require(script.Parent.Parent.config) +local waitFor = require("../wait-for").waitFor +local configModule = require("../config") local configure = configModule.configure local getConfig = configModule.getConfig -local renderIntoDocument = require(script.Parent.helpers["test-utils"]).renderIntoDocument +local renderIntoDocument = require("./helpers/test-utils").renderIntoDocument local function deferred() local resolve, reject @@ -409,13 +408,15 @@ test("does not work after it resolves", function() -- we return a real promise here. As far as I can tell, it -- doesn't affect what this is testing return Promise.new(function(resolve, reject) - thenable:andThen(function(returnValue) + local function andThenFn(returnValue) context = originalContext resolve(returnValue) - end, function(error_) + end + local function onError(error_) context = originalContext reject(error_) - end) + end + thenable:andThen(andThenFn, onError) end) -- ROBLOX deviation END else diff --git a/src/config.lua b/src/config.lua index af7452e..3008ae6 100644 --- a/src/config.lua +++ b/src/config.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/config.ts -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean local Error = LuauPolyfill.Error @@ -10,7 +8,7 @@ type Object = LuauPolyfill.Object type Promise = LuauPolyfill.Promise -- ROBLOX deviation START: extracted to avoid circular dependency -local defaultIgnore = require(script.Parent["config-default-ignore"]) +local defaultIgnore = require("./config-default-ignore") -- ROBLOX deviation END -- ROBLOX deviation START: unknown types @@ -19,10 +17,10 @@ type Partial = Object local exports = {} -local configModule = require(script.Parent.types.config) +local configModule = require("./types/config") type Config = configModule.Config type ConfigFn = configModule.ConfigFn -local prettyDOM = require(script.Parent["pretty-dom"]).prettyDOM +local prettyDOM = require("./pretty-dom").prettyDOM type Callback = () -> T type InternalConfig = Config & { _disableExpensiveErrorDiagnostics: boolean } diff --git a/src/events.lua b/src/events.lua index c283d62..e334f1b 100644 --- a/src/events.lua +++ b/src/events.lua @@ -1,19 +1,17 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/events.js -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Error = LuauPolyfill.Error local Object = LuauPolyfill.Object type Object = LuauPolyfill.Object -local dispatchEvent = require(script.Parent.jsHelpers.dispatchEvent) +local dispatchEvent = require("./jsHelpers/dispatchEvent") local exports = {} -local getConfig = require(script.Parent.config).getConfig -local _getWindowFromNode = require(script.Parent.helpers).getWindowFromNode -local event_mapModule = require(script.Parent["event-map"]) +local getConfig = require("./config").getConfig +local _getWindowFromNode = require("./helpers").getWindowFromNode +local event_mapModule = require("./event-map") local eventMap = event_mapModule.eventMap local _eventAliasMap = event_mapModule.eventAliasMap diff --git a/src/get-node-test-id.lua b/src/get-node-test-id.lua index fb589e4..a991312 100644 --- a/src/get-node-test-id.lua +++ b/src/get-node-test-id.lua @@ -1,11 +1,10 @@ -- ROBLOX upstream: no upstream -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local String = LuauPolyfill.String type Array = LuauPolyfill.Array -local getConfig = require(script.Parent.config).getConfig +local getConfig = require("./config").getConfig local exports = {} diff --git a/src/get-queries-for-element.lua b/src/get-queries-for-element.lua index a9c8dea..dba25fe 100644 --- a/src/get-queries-for-element.lua +++ b/src/get-queries-for-element.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/get-queries-for-element.js -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Object = LuauPolyfill.Object type Array = LuauPolyfill.Array @@ -9,7 +7,7 @@ type Object = LuauPolyfill.Object local exports = {} -local defaultQueries = require(script.Parent.queries) +local defaultQueries = require("./queries") --[[* * @typedef {{[key: string]: Function}} FuncMap diff --git a/src/get-user-code-frame.lua b/src/get-user-code-frame.lua index b277c80..54751da 100644 --- a/src/get-user-code-frame.lua +++ b/src/get-user-code-frame.lua @@ -1,6 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/get-user-code-frame.js -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean type Object = LuauPolyfill.Object @@ -9,9 +8,9 @@ local exports = {} -- We try to load node dependencies -- ROBLOX deviation START: upstream a check is made if we're running in the browser or not to load these -local chalk = require(Packages.Chalk) -local fs = require(script.Parent.jsHelpers.fs) -local codeFrameColumns = require(script.Parent.jsHelpers["babel-code-frame"]).codeFrameColumns +local chalk = require("@pkg/@jsdotlua/chalk") +local fs = require("./jsHelpers/fs") +local codeFrameColumns = require("./jsHelpers/babel-code-frame").codeFrameColumns -- ROBLOX deviation END -- frame has the form "at myMethod (location/to/my/file.js:10:2)" diff --git a/src/helpers.lua b/src/helpers.lua index 2bbd938..9d160be 100644 --- a/src/helpers.lua +++ b/src/helpers.lua @@ -1,13 +1,12 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/helpers.js -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean local Error = LuauPolyfill.Error type Object = LuauPolyfill.Object -local TypeError = require(script.Parent.jsHelpers.typeError) -local document = require(script.Parent.jsHelpers.document) +local TypeError = require("./jsHelpers/typeError") +local document = require("./jsHelpers/document") local exports = {} @@ -19,9 +18,9 @@ local TEXT_NODE = 3 Lua implentation may be different, and require a different check ]] local function jestFakeTimersAreEnabled() - local jest = require(Packages.JestGlobals).jest + local jest = require("@pkg/@jsdotlua/jest-globals").jest -- ROBLOX deviation START: workaround to determine if fake timers are running - -- local setTimeout = require(Packages.LuauPolyfill).setTimeout :: any + -- local setTimeout = require("@pkg/@jsdotlua/luau-polyfill").setTimeout :: any --[[ istanbul ignore else ]] if jest ~= nil then -- stylua: ignore diff --git a/src/init.lua b/src/init.lua index 81d8c0c..94c4c8d 100644 --- a/src/init.lua +++ b/src/init.lua @@ -1,30 +1,28 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/index.js -local Packages = script.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Object = LuauPolyfill.Object local exports = {} :: { [string]: any } -local getQueriesForElement = require(script["get-queries-for-element"]).getQueriesForElement -local queries = require(script.queries) -local queryHelpers = require(script["query-helpers"]) +local getQueriesForElement = require("./get-queries-for-element").getQueriesForElement +local queries = require("./queries") +local queryHelpers = require("./query-helpers") Object.assign(exports, require(script.queries)) Object.assign(exports, require(script["wait-for"])) Object.assign(exports, require(script["wait-for-element-to-be-removed"])) -exports.getDefaultNormalizer = require(script.matches).getDefaultNormalizer +exports.getDefaultNormalizer = require("./matches").getDefaultNormalizer Object.assign(exports, require(script["get-node-text"])) Object.assign(exports, require(script.events)) Object.assign(exports, require(script["get-queries-for-element"])) Object.assign(exports, require(script.screen)) Object.assign(exports, require(script["query-helpers"])) --- local role_helpersModule = require(script["role-helpers"]) +-- local role_helpersModule = require("./role-helpers") -- exports.getRoles = role_helpersModule.getRoles -- exports.logRoles = role_helpersModule.logRoles -- exports.isInaccessible = role_helpersModule.isInaccessible Object.assign(exports, require(script["pretty-dom"])) -local configModule = require(script.config) +local configModule = require("./config") exports.configure = configModule.configure exports.getConfig = configModule.getConfig Object.assign(exports, require(script.suggestions)) @@ -36,10 +34,10 @@ exports.within = getQueriesForElement -- export query utils under a namespace for convenience: exports.queries = queries exports.queryHelpers = queryHelpers -exports.document = require(script.jsHelpers.document) +exports.document = require("./jsHelpers/document") -- ROBLOX deviation START: reexport types -local typesModule = require(script.types) +local typesModule = require("./types") export type within = typesModule.within export type QueryByBoundAttribute = typesModule.QueryByBoundAttribute export type AllByBoundAttribute = typesModule.AllByBoundAttribute diff --git a/src/jest.config.lua b/src/jest.config.lua index 8b0c065..3840ed0 100644 --- a/src/jest.config.lua +++ b/src/jest.config.lua @@ -1,6 +1,7 @@ -local Packages = script.Parent.Parent +local ServerScriptService = game:GetService("ServerScriptService") + return { displayName = "Jest", - setupFilesAfterEnv = { Packages.TestsSetup["setup-env"] }, + setupFilesAfterEnv = { ServerScriptService:FindFirstChild("TestsSetup"):FindFirstChild("setup-env") }, testMatch = { "**/__tests__/**/*.spec" }, } diff --git a/src/jsHelpers/InputValidation.roblox.lua b/src/jsHelpers/InputValidation.roblox.lua index 621fa04..ff78462 100644 --- a/src/jsHelpers/InputValidation.roblox.lua +++ b/src/jsHelpers/InputValidation.roblox.lua @@ -1,4 +1,3 @@ ---!strict local VirtualInputManager = game:GetService("VirtualInputManager") local INPUT_VALIDATION_PREFIX = "[Testing Library] input validation" diff --git a/src/jsHelpers/__tests__/InputValidation.roblox.spec.lua b/src/jsHelpers/__tests__/InputValidation.roblox.spec.lua index d78b999..14497e0 100644 --- a/src/jsHelpers/__tests__/InputValidation.roblox.spec.lua +++ b/src/jsHelpers/__tests__/InputValidation.roblox.spec.lua @@ -1,18 +1,15 @@ -- ROBLOX upstream: No upstream ---!strict local CoreGui = game:GetService("CoreGui") local VirtualInputManager = game:GetService("VirtualInputManager") -local Packages = script.Parent.Parent.Parent.Parent - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local test = JestGlobals.test local describe = JestGlobals.describe local beforeEach = JestGlobals.beforeEach local afterEach = JestGlobals.afterEach -local InputValidation = require(script.Parent.Parent["InputValidation.roblox"]) +local InputValidation = require("../InputValidation.roblox.lua") local assertMounted = InputValidation.assertMounted local assertCanActivate = InputValidation.assertCanActivate local assertVisibleWithinAncestors = InputValidation.assertVisibleWithinAncestors @@ -20,7 +17,7 @@ local assertFirstInputTarget = InputValidation.assertFirstInputTarget local validateInput = InputValidation.validateInput local getCenter = InputValidation.getCenter -local dispatchEvent = require(script.Parent.Parent.dispatchEvent) +local dispatchEvent = require("../dispatchEvent") describe("input validation", function() local MountedRoot diff --git a/src/jsHelpers/__tests__/babel-code-frame.spec.lua b/src/jsHelpers/__tests__/babel-code-frame.spec.lua index 71562d1..1aed092 100644 --- a/src/jsHelpers/__tests__/babel-code-frame.spec.lua +++ b/src/jsHelpers/__tests__/babel-code-frame.spec.lua @@ -1,19 +1,17 @@ -- ROBLOX upstream: https://github.com/babel/babel/blob/v7.18.5/packages/babel-code-frame/test/index.js -local Packages = script.Parent.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local describe = JestGlobals.describe local test = JestGlobals.test local HttpService = game:GetService("HttpService") -local chalk = require(Packages.Chalk) -local stripAnsi = require(script.Parent.Parent["strip-ansi"]) -local babelCodeFrame = require(script.Parent.Parent["babel-code-frame"]) +local chalk = require("@pkg/@jsdotlua/chalk") +local stripAnsi = require("../strip-ansi") +local babelCodeFrame = require("../babel-code-frame") local _codeFrame = babelCodeFrame.default local codeFrameColumns = babelCodeFrame.codeFrameColumns -- ROBLOX deviation START: functions do not have props in Lua diff --git a/src/jsHelpers/__tests__/dispatchEvent.spec.lua b/src/jsHelpers/__tests__/dispatchEvent.spec.lua index a6b8d8e..ea074bb 100644 --- a/src/jsHelpers/__tests__/dispatchEvent.spec.lua +++ b/src/jsHelpers/__tests__/dispatchEvent.spec.lua @@ -1,13 +1,11 @@ -- ROBLOX upstream: No upstream -local Packages = script.Parent.Parent.Parent.Parent - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local describe = JestGlobals.describe local test = JestGlobals.test local jest = JestGlobals.jest -local dispatchEvent = require(script.Parent.Parent.dispatchEvent) +local dispatchEvent = require("../dispatchEvent") describe("dispatchEvent", function() test("should trigger click event", function() local element = Instance.new("TextButton") diff --git a/src/jsHelpers/__tests__/querySelectors.spec.lua b/src/jsHelpers/__tests__/querySelectors.spec.lua index 3513a38..c6953c1 100644 --- a/src/jsHelpers/__tests__/querySelectors.spec.lua +++ b/src/jsHelpers/__tests__/querySelectors.spec.lua @@ -1,12 +1,10 @@ -- ROBLOX upstream: no upstream -local Packages = script.Parent.Parent.Parent.Parent - -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local expect = JestGlobals.expect local describe = JestGlobals.describe local test = JestGlobals.test -local querySelectorsModule = require(script.Parent.Parent.querySelectors) +local querySelectorsModule = require("../querySelectors") local querySelector = querySelectorsModule.querySelector local querySelectorAll = querySelectorsModule.querySelectorAll diff --git a/src/jsHelpers/babel-code-frame.lua b/src/jsHelpers/babel-code-frame.lua index a53d1cd..31a1040 100644 --- a/src/jsHelpers/babel-code-frame.lua +++ b/src/jsHelpers/babel-code-frame.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/babel/babel/blob/v7.18.5/packages/babel-code-frame/src/index.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean local Error = LuauPolyfill.Error @@ -23,7 +21,7 @@ local exports = {} -- local shouldHighlight = highlightModule.shouldHighlight -- local getChalk = highlightModule.getChalk local getChalk = function(...) - return require(Packages.Chalk) + return require("@pkg/@jsdotlua/chalk") end -- ROBLOX deviation END diff --git a/src/jsHelpers/dispatchEvent.lua b/src/jsHelpers/dispatchEvent.lua index 12af014..168c0c7 100644 --- a/src/jsHelpers/dispatchEvent.lua +++ b/src/jsHelpers/dispatchEvent.lua @@ -1,13 +1,10 @@ ---!strict -- ROBLOX upstream: no upstream local virtualInput = game:GetService("VirtualInputManager") -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Error = LuauPolyfill.Error -local InputValidation = require(script.Parent["InputValidation.roblox"]) +local InputValidation = require("./InputValidation.roblox.lua") local getGuiObject = InputValidation.getGuiObject local validateInput = InputValidation.validateInput diff --git a/src/jsHelpers/fs.lua b/src/jsHelpers/fs.lua index 410e738..ab5c625 100644 --- a/src/jsHelpers/fs.lua +++ b/src/jsHelpers/fs.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: no upstream -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Error = LuauPolyfill.Error local FileSystemService = nil diff --git a/src/jsHelpers/jest-dom.lua b/src/jsHelpers/jest-dom.lua index 7f185c6..963f966 100644 --- a/src/jsHelpers/jest-dom.lua +++ b/src/jsHelpers/jest-dom.lua @@ -1,10 +1,9 @@ -- ROBLOX upstream: no upstream --[[ - ROBLOX comment: + ROBLOX comment: reduce deviations by adding matchers based on testing-library/jest-dom ]] -local Packages = script.Parent.Parent.Parent -local document = require(Packages.DomTestingLibrary).document +local document = require("./document") local exports = {} diff --git a/src/jsHelpers/querySelectors.lua b/src/jsHelpers/querySelectors.lua index 13eda40..2590b1c 100644 --- a/src/jsHelpers/querySelectors.lua +++ b/src/jsHelpers/querySelectors.lua @@ -1,11 +1,10 @@ -- ROBLOX upstream: no upstream -local Packages = script.Parent.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array type Array = LuauPolyfill.Array -- ROBLOX deviation START: helper method -local getNodeTestId = require(script.Parent.Parent["get-node-test-id"]).getNodeTestId +local getNodeTestId = require("../get-node-test-id").getNodeTestId -- ROBLOX deviation END local exports = {} diff --git a/src/jsHelpers/typeError.lua b/src/jsHelpers/typeError.lua index 29d2319..fbbf7d0 100644 --- a/src/jsHelpers/typeError.lua +++ b/src/jsHelpers/typeError.lua @@ -1,6 +1,5 @@ -- ROBLOX upstream: no upstream -local Packages = script.Parent.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Error = LuauPolyfill.Error type TypeError = LuauPolyfill.Error diff --git a/src/matches.lua b/src/matches.lua index 50a8f33..e876d88 100644 --- a/src/matches.lua +++ b/src/matches.lua @@ -1,13 +1,11 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/matches.ts -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Error = LuauPolyfill.Error local String = LuauPolyfill.String local instanceOf = LuauPolyfill.instanceof type Object = LuauPolyfill.Object -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") type RegExp = RegExp.RegExp local exports = {} @@ -16,7 +14,7 @@ local exports = {} local matchRegExp -- ROBLOX deviation END -local typesModule = require(script.Parent.types) +local typesModule = require("./types") type Matcher = typesModule.Matcher type NormalizerFn = typesModule.NormalizerFn type NormalizerOptions = typesModule.NormalizerOptions diff --git a/src/pretty-dom.lua b/src/pretty-dom.lua index b91b13c..22faf5e 100644 --- a/src/pretty-dom.lua +++ b/src/pretty-dom.lua @@ -1,22 +1,21 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/pretty-dom.js -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean local Object = LuauPolyfill.Object local console = LuauPolyfill.console type Object = LuauPolyfill.Object -local TypeError = require(script.Parent.jsHelpers.typeError) +local TypeError = require("./jsHelpers/typeError") local exports = {} -local prettyFormat = require(Packages.PrettyFormat) -local createDOMElementFilter = require(script.Parent.DOMElementFilter).default -local getUCFModule = require(script.Parent["get-user-code-frame"]) -local getDocument = require(script.Parent.helpers).getDocument +local prettyFormat = require("@pkg/@jsdotlua/pretty-format") +local createDOMElementFilter = require("./DOMElementFilter").default +local getUCFModule = require("./get-user-code-frame") +local getDocument = require("./helpers").getDocument -- ROBLOX deviation START: avoid circular dependency -local defaultIgnore = require(script.Parent["config-default-ignore"]) +local defaultIgnore = require("./config-default-ignore") -- ROBLOX deviation END local function inNode() diff --git a/src/queries/all-utils.lua b/src/queries/all-utils.lua index 4ac5992..62d9961 100644 --- a/src/queries/all-utils.lua +++ b/src/queries/all-utils.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/queries/all-utils.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Object = LuauPolyfill.Object local exports = {} :: { [string]: any } diff --git a/src/queries/display-value.lua b/src/queries/display-value.lua index 7780c51..8b9de2c 100644 --- a/src/queries/display-value.lua +++ b/src/queries/display-value.lua @@ -1,22 +1,20 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/queries/display-value.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array type Object = LuauPolyfill.Object -local querySelectorAll = require(script.Parent.Parent.jsHelpers.querySelectors).querySelectorAll +local querySelectorAll = require("../jsHelpers/querySelectors").querySelectorAll local exports = {} -local wrapAllByQueryWithSuggestion = require(script.Parent.Parent["query-helpers"]).wrapAllByQueryWithSuggestion -local checkContainerType = require(script.Parent.Parent.helpers).checkContainerType -local typesModule = require(script.Parent.Parent.types) +local wrapAllByQueryWithSuggestion = require("../query-helpers").wrapAllByQueryWithSuggestion +local checkContainerType = require("../helpers").checkContainerType +local typesModule = require("../types") type AllByBoundAttribute = typesModule.AllByBoundAttribute type GetErrorFunction = typesModule.GetErrorFunction type Matcher = typesModule.Matcher type MatcherOptions = typesModule.MatcherOptions -local all_utilsModule = require(script.Parent["all-utils"]) +local all_utilsModule = require("./all-utils") local _getNodeText = all_utilsModule.getNodeText local matches = all_utilsModule.matches local fuzzyMatches = all_utilsModule.fuzzyMatches diff --git a/src/queries/init.lua b/src/queries/init.lua index c4c5cb5..2fd1afa 100644 --- a/src/queries/init.lua +++ b/src/queries/init.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/queries/index.ts -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Object = LuauPolyfill.Object local exports = {} diff --git a/src/queries/placeholder-text.lua b/src/queries/placeholder-text.lua index 8d25b67..6c5237e 100644 --- a/src/queries/placeholder-text.lua +++ b/src/queries/placeholder-text.lua @@ -1,17 +1,15 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/queries/placeholder-text.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array local exports = {} -local wrapAllByQueryWithSuggestion = require(script.Parent.Parent["query-helpers"]).wrapAllByQueryWithSuggestion -local checkContainerType = require(script.Parent.Parent.helpers).checkContainerType -local typesModule = require(script.Parent.Parent.types) +local wrapAllByQueryWithSuggestion = require("../query-helpers").wrapAllByQueryWithSuggestion +local checkContainerType = require("../helpers").checkContainerType +local typesModule = require("../types") type AllByBoundAttribute = typesModule.AllByBoundAttribute type GetErrorFunction = typesModule.GetErrorFunction -local all_utilsModule = require(script.Parent["all-utils"]) +local all_utilsModule = require("./all-utils") local queryAllByAttribute = all_utilsModule.queryAllByAttribute local buildQueries = all_utilsModule.buildQueries diff --git a/src/queries/test-id.lua b/src/queries/test-id.lua index bc7724f..04cca3f 100644 --- a/src/queries/test-id.lua +++ b/src/queries/test-id.lua @@ -1,17 +1,15 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/queries/test-id.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array local exports = {} -local checkContainerType = require(script.Parent.Parent.helpers).checkContainerType -local wrapAllByQueryWithSuggestion = require(script.Parent.Parent["query-helpers"]).wrapAllByQueryWithSuggestion -local typesModule = require(script.Parent.Parent.types) +local checkContainerType = require("../helpers").checkContainerType +local wrapAllByQueryWithSuggestion = require("../query-helpers").wrapAllByQueryWithSuggestion +local typesModule = require("../types") type AllByBoundAttribute = typesModule.AllByBoundAttribute type GetErrorFunction = typesModule.GetErrorFunction -local all_utilsModule = require(script.Parent["all-utils"]) +local all_utilsModule = require("./all-utils") local queryAllByAttribute = all_utilsModule.queryAllByAttribute local getConfig = all_utilsModule.getConfig local buildQueries = all_utilsModule.buildQueries diff --git a/src/queries/text.lua b/src/queries/text.lua index 1b3c71f..20eed6e 100644 --- a/src/queries/text.lua +++ b/src/queries/text.lua @@ -1,25 +1,23 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/queries/text.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array type Array = LuauPolyfill.Array type Object = LuauPolyfill.Object -local querySelectorsModule = require(script.Parent.Parent.jsHelpers.querySelectors) +local querySelectorsModule = require("../jsHelpers/querySelectors") local matchesInstance = querySelectorsModule.matches local querySelectorAll = querySelectorsModule.querySelectorAll local exports = {} -local wrapAllByQueryWithSuggestion = require(script.Parent.Parent["query-helpers"]).wrapAllByQueryWithSuggestion -local checkContainerType = require(script.Parent.Parent.helpers).checkContainerType -local typesModule = require(script.Parent.Parent.types) +local wrapAllByQueryWithSuggestion = require("../query-helpers").wrapAllByQueryWithSuggestion +local checkContainerType = require("../helpers").checkContainerType +local typesModule = require("../types") type AllByText = typesModule.AllByText type GetErrorFunction = typesModule.GetErrorFunction type SelectorMatcherOptions = typesModule.SelectorMatcherOptions type Matcher = typesModule.Matcher -local all_utilsModule = require(script.Parent["all-utils"]) +local all_utilsModule = require("./all-utils") local fuzzyMatches = all_utilsModule.fuzzyMatches local matches = all_utilsModule.matches local makeNormalizer = all_utilsModule.makeNormalizer diff --git a/src/query-helpers.lua b/src/query-helpers.lua index 95ec58b..cce08bb 100644 --- a/src/query-helpers.lua +++ b/src/query-helpers.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/query-helpers.ts -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Object = LuauPolyfill.Object local Set = LuauPolyfill.Set @@ -9,7 +7,7 @@ local String = LuauPolyfill.String type Array = LuauPolyfill.Array type Object = LuauPolyfill.Object -local querySelectorAll = require(script.Parent.jsHelpers.querySelectors).querySelectorAll +local querySelectorAll = require("./jsHelpers/querySelectors").querySelectorAll local exports = {} @@ -19,7 +17,7 @@ local matchAsProperties = { } -- ROBLOX deviation END -local typesModule = require(script.Parent.types) +local typesModule = require("./types") type GetErrorFunction = typesModule.GetErrorFunction type Matcher = typesModule.Matcher type MatcherOptions = typesModule.MatcherOptions @@ -27,17 +25,17 @@ type QueryMethod = typesModule.QueryMethod type Variant = typesModule.Variant type WaitForOptions = typesModule.waitForOptions type WithSuggest = typesModule.WithSuggest -local getSuggestedQuery = require(script.Parent.suggestions).getSuggestedQuery +local getSuggestedQuery = require("./suggestions").getSuggestedQuery -local matchesModule = require(script.Parent.matches) +local matchesModule = require("./matches") local fuzzyMatches = matchesModule.fuzzyMatches local matches = matchesModule.matches local makeNormalizer = matchesModule.makeNormalizer -local waitFor = require(script.Parent["wait-for"]).waitFor -local getConfig = require(script.Parent.config).getConfig +local waitFor = require("./wait-for").waitFor +local getConfig = require("./config").getConfig -- ROBLOX deviation START: helper fn -local getNodeTestId = require(script.Parent["get-node-test-id"]).getNodeTestId +local getNodeTestId = require("./get-node-test-id").getNodeTestId -- ROBLOX deviation END local function getElementError(message: string | nil, container: Instance) diff --git a/src/screen.lua b/src/screen.lua index 98ca28a..0b067af 100644 --- a/src/screen.lua +++ b/src/screen.lua @@ -1,28 +1,26 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/screen.ts -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Object = LuauPolyfill.Object local console = LuauPolyfill.console type Array = LuauPolyfill.Array type Object = LuauPolyfill.Object -local document = require(script.Parent.jsHelpers.document) -local TypeError = require(script.Parent.jsHelpers.typeError) +local document = require("./jsHelpers/document") +local TypeError = require("./jsHelpers/typeError") local exports = {} -- ROBLOX deviation START: not required --- local compressToEncodedURIComponent = require(Packages["lz-string"]).compressToEncodedURIComponent +-- local compressToEncodedURIComponent = require("@pkg/lz-string").compressToEncodedURIComponent -- ROBLOX deviation END -local pretty_formatModule = require(Packages.PrettyFormat) +local pretty_formatModule = require("@pkg/@jsdotlua/pretty-format") type OptionsReceived = pretty_formatModule.OptionsReceived -local getQueriesForElement = require(script.Parent["get-queries-for-element"]).getQueriesForElement -local getDocument = require(script.Parent.helpers).getDocument -local logDOM = require(script.Parent["pretty-dom"]).logDOM -local queries = require(script.Parent.queries) +local getQueriesForElement = require("./get-queries-for-element").getQueriesForElement +local getDocument = require("./helpers").getDocument +local logDOM = require("./pretty-dom").logDOM +local queries = require("./queries") -- ROBLOX deviation START: Testing playground not available -- local function unindent(string_: string) diff --git a/src/suggestions.lua b/src/suggestions.lua index 197fec2..033ae15 100644 --- a/src/suggestions.lua +++ b/src/suggestions.lua @@ -1,32 +1,30 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/suggestions.js -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean local Object = LuauPolyfill.Object local console = LuauPolyfill.console -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") -- ROBLOX deviation START: helper fn -local getNodeTestId = require(script.Parent["get-node-test-id"]).getNodeTestId +local getNodeTestId = require("./get-node-test-id").getNodeTestId -- ROBLOX deviation END -local SuggestionTypes = require(script.Parent.types.suggestions) +local SuggestionTypes = require("./types/suggestions") type Suggestion = SuggestionTypes.Suggestion type Method = SuggestionTypes.Method local exports = {} --- local computeAccessibleName = require(Packages["dom-accessibility-api"]).computeAccessibleName -local getDefaultNormalizer = require(script.Parent.matches).getDefaultNormalizer -local getNodeText = require(script.Parent["get-node-text"]).getNodeText -local getConfig = require(script.Parent.config).getConfig --- local role_helpersModule = require(script.Parent["role-helpers"]) +-- local computeAccessibleName = require("@pkg/dom-accessibility-api").computeAccessibleName +local getDefaultNormalizer = require("./matches").getDefaultNormalizer +local getNodeText = require("./get-node-text").getNodeText +local getConfig = require("./config").getConfig +-- local role_helpersModule = require("./role-helpers") -- local getImplicitAriaRoles = role_helpersModule.getImplicitAriaRoles -- local isInaccessible = role_helpersModule.isInaccessible --- local getLabels = require(script.Parent["label-helpers"]).getLabels +-- local getLabels = require("./label-helpers").getLabels local normalize = getDefaultNormalizer() diff --git a/src/types/config.lua b/src/types/config.lua index 9b88bf5..9b85b92 100644 --- a/src/types/config.lua +++ b/src/types/config.lua @@ -1,7 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/config.d.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Error = LuauPolyfill.Error type Object = LuauPolyfill.Object type Promise = LuauPolyfill.Promise diff --git a/src/types/get-queries-for-element.lua b/src/types/get-queries-for-element.lua index 731fc85..44a31eb 100644 --- a/src/types/get-queries-for-element.lua +++ b/src/types/get-queries-for-element.lua @@ -1,14 +1,12 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/get-queries-for-element.d.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array type Error = LuauPolyfill.Error type Promise = LuauPolyfill.Promise local exports = {} --- local _queries = require(script.Parent.queries) +-- local _queries = require("./queries") -- ROBLOX deviation START: some contraints for types not available, inline return types export type BoundFunction = (container: Instance, ...any) -> any diff --git a/src/types/init.lua b/src/types/init.lua index b1f9011..b1c94f0 100644 --- a/src/types/init.lua +++ b/src/types/init.lua @@ -3,9 +3,9 @@ local exports = {} -- TypeScript Version: 3.8 -local getQueriesForElementModule = require(script["get-queries-for-element"]) -local queriesModule = require(script.queries) -local queryHelpersModule = require(script["query-helpers"]) +local getQueriesForElementModule = require("./get-queries-for-element") +local queriesModule = require("./queries") +local queryHelpersModule = require("./query-helpers") export type within = getQueriesForElementModule.getQueriesForElement @@ -97,18 +97,18 @@ export type FindBy = queryHelpersModule.FindBy export type BuiltQueryMethods = queryHelpersModule.BuiltQueryMethods export type buildQueries = queryHelpersModule.buildQueries -local screenModule = require(script.screen) +local screenModule = require("./screen") export type Screen = screenModule.Screen export type screen = screenModule.screen -local waitForModule = require(script["wait-for"]) +local waitForModule = require("./wait-for") export type waitForOptions = waitForModule.waitForOptions export type waitFor = waitForModule.waitFor -local waitForElementToBeRemovedModule = require(script["wait-for-element-to-be-removed"]) +local waitForElementToBeRemovedModule = require("./wait-for-element-to-be-removed") export type waitForElementToBeRemoved = waitForElementToBeRemovedModule.waitForElementToBeRemoved -local matchesModule = require(script.matches) +local matchesModule = require("./matches") export type MatcherFunction = matchesModule.MatcherFunction export type Matcher = matchesModule.Matcher export type ByRoleMatcher = matchesModule.ByRoleMatcher @@ -119,10 +119,10 @@ export type Match = matchesModule.Match export type DefaultNormalizerOptions = matchesModule.DefaultNormalizerOptions export type getDefaultNormalizer = matchesModule.getDefaultNormalizer -local getNodeTextModule = require(script["get-node-text"]) +local getNodeTextModule = require("./get-node-text") export type getNodeText = getNodeTextModule.getNodeText -local eventsModule = require(script.events) +local eventsModule = require("./events") export type EventType = eventsModule.EventType export type FireFunction = eventsModule.FireFunction export type FireObject = eventsModule.FireObject @@ -137,7 +137,7 @@ export type Query = getQueriesForElementModule.Query export type Queries = getQueriesForElementModule.Queries export type getQueriesForElement = getQueriesForElementModule.getQueriesForElement -local prettyDomModule = require(script["pretty-dom"]) +local prettyDomModule = require("./pretty-dom") export type PrettyDOMOptions = prettyDomModule.PrettyDOMOptions export type prettyDOM = (dom: Instance?, maxLength: number?, options: PrettyDOMOptions?) -> string | false export type logDOM = (dom: Instance?, maxLength: number?, options: PrettyDOMOptions?) -> () @@ -159,13 +159,13 @@ export type prettyFormat_Theme = prettyDomModule.prettyFormat_Theme -- Object.assign(exports, require(script["role-helpers"])) -- ROBLOX deviation END -local configModule = require(script.config) +local configModule = require("./config") export type Config = configModule.Config export type ConfigFn = configModule.ConfigFn export type configure = configModule.configure export type getConfig = configModule.getConfig -local suggestionsModule = require(script.suggestions) +local suggestionsModule = require("./suggestions") export type QueryOptions = suggestionsModule.QueryOptions export type QueryArgs = suggestionsModule.QueryArgs export type Suggestion = suggestionsModule.Suggestion diff --git a/src/types/matches.lua b/src/types/matches.lua index 42ee577..1d8cf04 100644 --- a/src/types/matches.lua +++ b/src/types/matches.lua @@ -1,13 +1,11 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/matches.d.ts -local Packages = script.Parent.Parent.Parent - -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") type RegExp = RegExp.RegExp local exports = {} -- ROBLOX deviation START: Package not available --- type ARIARole = require(Packages["aria-query"]).ARIARole +-- type ARIARole = require("@pkg/aria-query").ARIARole type ARIARole = { [string]: any } -- ROBLOX deviation END diff --git a/src/types/pretty-dom.lua b/src/types/pretty-dom.lua index 1f57d0a..69a6065 100644 --- a/src/types/pretty-dom.lua +++ b/src/types/pretty-dom.lua @@ -1,9 +1,7 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/pretty-dom.d.ts -local Packages = script.Parent.Parent.Parent - local exports = {} -local prettyFormat = require(Packages.PrettyFormat) +local prettyFormat = require("@pkg/@jsdotlua/pretty-format") export type PrettyDOMOptions = prettyFormat_OptionsReceived & { --[[* diff --git a/src/types/queries.lua b/src/types/queries.lua index fdd297e..88a6d1f 100644 --- a/src/types/queries.lua +++ b/src/types/queries.lua @@ -1,25 +1,23 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/queries.d.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array type Object = LuauPolyfill.Object type Promise = LuauPolyfill.Promise -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") type RegExp = RegExp.RegExp local exports = {} -local matchesModule = require(script.Parent.matches) +local matchesModule = require("./matches") type ByRoleMatcher = matchesModule.ByRoleMatcher type Matcher = matchesModule.Matcher type MatcherOptions = matchesModule.MatcherOptions -local queryHelpersModule = require(script.Parent["query-helpers"]) +local queryHelpersModule = require("./query-helpers") type SelectorMatcherOptions = queryHelpersModule.SelectorMatcherOptions -local waitForModule = require(script.Parent["wait-for"]) +local waitForModule = require("./wait-for") type waitForOptions = waitForModule.waitForOptions export type QueryByBoundAttribute = ( diff --git a/src/types/query-helpers.lua b/src/types/query-helpers.lua index 2051391..db29705 100644 --- a/src/types/query-helpers.lua +++ b/src/types/query-helpers.lua @@ -1,6 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/query-helpers.d.ts -local Packages = script.Parent.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array type Object = LuauPolyfill.Object type Promise = LuauPolyfill.Promise @@ -8,10 +7,10 @@ type Error = LuauPolyfill.Error local exports = {} -local matchesModule = require(script.Parent.matches) +local matchesModule = require("./matches") type Matcher = matchesModule.Matcher type MatcherOptions = matchesModule.MatcherOptions -local waitForModule = require(script.Parent["wait-for"]) +local waitForModule = require("./wait-for") type waitForOptions = waitForModule.waitForOptions export type WithSuggest = { suggest: boolean? } diff --git a/src/types/screen.lua b/src/types/screen.lua index cd43c4e..1857cf3 100644 --- a/src/types/screen.lua +++ b/src/types/screen.lua @@ -1,17 +1,15 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/screen.d.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array local exports = {} -local prettyFormatModule = require(Packages.PrettyFormat) +local prettyFormatModule = require("@pkg/@jsdotlua/pretty-format") type OptionsReceived = prettyFormatModule.OptionsReceived -local get_queries_for_elementModule = require(script.Parent["get-queries-for-element"]) +local get_queries_for_elementModule = require("./get-queries-for-element") type BoundFunctions = get_queries_for_elementModule.BoundFunctions type Queries = get_queries_for_elementModule.Queries --- local queries = require(script.Parent.queries) +-- local queries = require("./queries") -- ROBLOX comment: can't express typeof queries export type Screen = BoundFunctions & { diff --git a/src/types/suggestions.lua b/src/types/suggestions.lua index e5e9f8e..bef1af0 100644 --- a/src/types/suggestions.lua +++ b/src/types/suggestions.lua @@ -1,10 +1,8 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/suggestions.d.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Array = LuauPolyfill.Array -local RegExp = require(Packages.LuauRegExp) +local RegExp = require("@pkg/luau-regexp") type RegExp = RegExp.RegExp local exports = {} diff --git a/src/types/wait-for-element-to-be-removed.lua b/src/types/wait-for-element-to-be-removed.lua index c0f7e5c..8152e10 100644 --- a/src/types/wait-for-element-to-be-removed.lua +++ b/src/types/wait-for-element-to-be-removed.lua @@ -1,12 +1,10 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/types/wait-for-element-to-be-removed.d.ts -local Packages = script.Parent.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Promise = LuauPolyfill.Promise local exports = {} -local waitForModule = require(script.Parent["wait-for"]) +local waitForModule = require("./wait-for") type waitForOptions = waitForModule.waitForOptions export type waitForElementToBeRemoved = (callback: T | (() -> T), options: waitForOptions?) -> Promise diff --git a/src/types/wait-for.lua b/src/types/wait-for.lua index 12e0919..a91cf52 100644 --- a/src/types/wait-for.lua +++ b/src/types/wait-for.lua @@ -1,5 +1,4 @@ -local Packages = script.Parent.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") type Error = LuauPolyfill.Error type Object = LuauPolyfill.Object type Promise = LuauPolyfill.Promise diff --git a/src/wait-for-element-to-be-removed.lua b/src/wait-for-element-to-be-removed.lua index ad22003..1b81550 100644 --- a/src/wait-for-element-to-be-removed.lua +++ b/src/wait-for-element-to-be-removed.lua @@ -1,19 +1,17 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/wait-for-element-to-be-removed.js -local Packages = script.Parent.Parent - -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean local Error = LuauPolyfill.Error type Promise = LuauPolyfill.Promise -local Promise = require(Packages.Promise) +local Promise = require("@pkg/@jsdotlua/promise") -local isCallable = require(script.Parent.jsHelpers.isCallable) +local isCallable = require("./jsHelpers/isCallable") local exports = {} -local waitFor = require(script.Parent["wait-for"]).waitFor +local waitFor = require("./wait-for").waitFor local function isRemoved(result): boolean return not Boolean.toJSBoolean(result) diff --git a/src/wait-for.lua b/src/wait-for.lua index a0be624..99abce6 100644 --- a/src/wait-for.lua +++ b/src/wait-for.lua @@ -1,6 +1,5 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/wait-for.js -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local Boolean = LuauPolyfill.Boolean local Error = LuauPolyfill.Error local Object = LuauPolyfill.Object @@ -11,16 +10,16 @@ local setTimeout = LuauPolyfill.setTimeout type Error = LuauPolyfill.Error type Promise = LuauPolyfill.Promise -local Promise = require(Packages.Promise) +local Promise = require("@pkg/@jsdotlua/promise") -local isCallable = require(script.Parent.jsHelpers.isCallable) -local TypeError = require(script.Parent.jsHelpers.typeError) -local waitForTypes = require(script.Parent.types["wait-for"]) +local isCallable = require("./jsHelpers/isCallable") +local TypeError = require("./jsHelpers/typeError") +local waitForTypes = require("./types/wait-for") type waitForOptions = waitForTypes.waitForOptions local exports = {} -local helpersModule = require(script.Parent.helpers) +local helpersModule = require("./helpers") local _getWindowFromNode = helpersModule.getWindowFromNode local getDocument = helpersModule.getDocument local jestFakeTimersAreEnabled = helpersModule.jestFakeTimersAreEnabled @@ -28,7 +27,7 @@ local jestFakeTimersAreEnabled = helpersModule.jestFakeTimersAreEnabled -- because these will be *real* timers, regardless of whether we're in -- an environment that's faked the timers out. local checkContainerType = helpersModule.checkContainerType -local configModule = require(script.Parent.config) +local configModule = require("./config") local getConfig = configModule.getConfig local runWithExpensiveErrorDiagnosticsDisabled = configModule.runWithExpensiveErrorDiagnosticsDisabled @@ -155,7 +154,7 @@ local function waitFor(callback, ref) if usingJestFakeTimers then -- ROBLOX deviation: import jest here instead of expecting a global - local jest = require(Packages.JestGlobals).jest + local jest = require("@pkg/@jsdotlua/jest-globals").jest local advanceTimersWrapper = getConfig().unstable_advanceTimersWrapper checkCallback() From efd4ab4059b2f64716af3654c473b1e079f43fe6 Mon Sep 17 00:00:00 2001 From: jeparlefrancais Date: Thu, 21 Mar 2024 14:59:34 -0400 Subject: [PATCH 2/5] Setup repository and npm package --- .darklua-bundle-dev.json | 27 ++ .darklua-bundle.json | 27 ++ .darklua-dev.json | 29 ++ .darklua-wally.json | 24 ++ .darklua.json | 29 ++ .github/workflows/release.yml | 175 ++++++++++ .github/workflows/test.yml | 45 +++ .gitignore | 14 +- .npmignore | 39 +++ .yarnrc.yml | 1 + Packages/.robloxrc | 8 - default.project.json | 15 - foreman.toml | 11 +- model.project.json | 9 + package.json | 49 +++ scripts/build-assets.sh | 9 + scripts/build-roblox-model.sh | 36 ++ scripts/build-single-file.sh | 12 + scripts/build-wally-package.sh | 31 ++ scripts/npm-to-wally.js | 144 ++++++++ scripts/remove-tests.sh | 14 + scripts/roblox-test.sh | 25 ++ test-place.project.json | 29 ++ tests.project.json | 25 -- tests/roblox-test.server.lua | 14 + tests/setup-env.lua | 7 +- yarn.lock | 618 +++++++++++++++++++++++++++++++++ 27 files changed, 1407 insertions(+), 59 deletions(-) create mode 100644 .darklua-bundle-dev.json create mode 100644 .darklua-bundle.json create mode 100644 .darklua-dev.json create mode 100644 .darklua-wally.json create mode 100644 .darklua.json create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .npmignore create mode 100644 .yarnrc.yml delete mode 100644 Packages/.robloxrc delete mode 100644 default.project.json create mode 100644 model.project.json create mode 100644 package.json create mode 100755 scripts/build-assets.sh create mode 100755 scripts/build-roblox-model.sh create mode 100755 scripts/build-single-file.sh create mode 100755 scripts/build-wally-package.sh create mode 100644 scripts/npm-to-wally.js create mode 100755 scripts/remove-tests.sh create mode 100644 scripts/roblox-test.sh create mode 100644 test-place.project.json delete mode 100644 tests.project.json create mode 100644 tests/roblox-test.server.lua create mode 100644 yarn.lock diff --git a/.darklua-bundle-dev.json b/.darklua-bundle-dev.json new file mode 100644 index 0000000..fb4fe3a --- /dev/null +++ b/.darklua-bundle-dev.json @@ -0,0 +1,27 @@ +{ + "bundle": { + "require_mode": { + "name": "path", + "sources": { + "@pkg": "node_modules/.luau-aliases" + } + } + }, + "generator": "dense", + "process": [ + { + "rule": "inject_global_value", + "identifier": "__DEV__", + "value": true + }, + "remove_types", + "remove_comments", + "remove_spaces", + "compute_expression", + "remove_unused_if_branch", + "remove_unused_while", + "filter_after_early_return", + "remove_nil_declaration", + "remove_empty_do" + ] +} diff --git a/.darklua-bundle.json b/.darklua-bundle.json new file mode 100644 index 0000000..a4a6e2c --- /dev/null +++ b/.darklua-bundle.json @@ -0,0 +1,27 @@ +{ + "bundle": { + "require_mode": { + "name": "path", + "sources": { + "@pkg": "node_modules/.luau-aliases" + } + } + }, + "generator": "dense", + "process": [ + { + "rule": "inject_global_value", + "identifier": "__DEV__", + "value": false + }, + "remove_types", + "remove_comments", + "remove_spaces", + "compute_expression", + "remove_unused_if_branch", + "remove_unused_while", + "filter_after_early_return", + "remove_nil_declaration", + "remove_empty_do" + ] +} diff --git a/.darklua-dev.json b/.darklua-dev.json new file mode 100644 index 0000000..319945e --- /dev/null +++ b/.darklua-dev.json @@ -0,0 +1,29 @@ +{ + "process": [ + { + "rule": "convert_require", + "current": { + "name": "path", + "sources": { + "@pkg": "node_modules/.luau-aliases" + } + }, + "target": { + "name": "roblox", + "indexing_style": "wait_for_child", + "rojo_sourcemap": "sourcemap.json" + } + }, + { + "rule": "inject_global_value", + "identifier": "__DEV__", + "value": true + }, + "compute_expression", + "remove_unused_if_branch", + "remove_unused_while", + "filter_after_early_return", + "remove_nil_declaration", + "remove_empty_do" + ] +} diff --git a/.darklua-wally.json b/.darklua-wally.json new file mode 100644 index 0000000..b6101b9 --- /dev/null +++ b/.darklua-wally.json @@ -0,0 +1,24 @@ +{ + "process": [ + { + "rule": "convert_require", + "current": { + "name": "path", + "sources": { + "@pkg": "." + } + }, + "target": { + "name": "roblox", + "indexing_style": "wait_for_child", + "rojo_sourcemap": "./sourcemap.json" + } + }, + "compute_expression", + "remove_unused_if_branch", + "remove_unused_while", + "filter_after_early_return", + "remove_nil_declaration", + "remove_empty_do" + ] +} diff --git a/.darklua.json b/.darklua.json new file mode 100644 index 0000000..a703a19 --- /dev/null +++ b/.darklua.json @@ -0,0 +1,29 @@ +{ + "process": [ + { + "rule": "convert_require", + "current": { + "name": "path", + "sources": { + "@pkg": "node_modules/.luau-aliases" + } + }, + "target": { + "name": "roblox", + "indexing_style": "wait_for_child", + "rojo_sourcemap": "sourcemap.json" + } + }, + { + "rule": "inject_global_value", + "identifier": "__DEV__", + "value": false + }, + "compute_expression", + "remove_unused_if_branch", + "remove_unused_while", + "filter_after_early_return", + "remove_nil_declaration", + "remove_empty_do" + ] +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b7fed2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,175 @@ +name: Release + +on: + workflow_dispatch: + inputs: + release_tag: + description: "The version to release starting with `v`" + required: true + type: string + + release_ref: + description: "The branch, tag or SHA to checkout (default to latest)" + default: "" + type: string + +permissions: + contents: write + +jobs: + publish-package: + name: Publish package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Enable corepack + run: corepack enable + + - uses: actions/setup-node@v3 + with: + node-version: "latest" + cache: "yarn" + cache-dependency-path: "yarn.lock" + + - name: Install packages + run: yarn install --immutable + + - name: Run npmluau + run: yarn run prepare + + - name: Authenticate yarn + run: | + yarn config set npmAlwaysAuth true + yarn config set npmScopes.jsdotlua.npmAuthToken $NPM_AUTH_TOKEN + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - run: yarn npm publish --access public + + publish-wally-package: + needs: publish-package + + name: Publish wally package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Enable corepack + run: corepack enable + + - uses: Roblox/setup-foreman@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/setup-node@v3 + with: + node-version: "latest" + cache: "yarn" + cache-dependency-path: "yarn.lock" + + - name: Install packages + run: yarn install --immutable + + - name: Run npmluau + run: yarn run prepare + + - name: Build assets + run: yarn run build-assets + + - name: Login to wally + run: wally login --project-path build/wally --token ${{ secrets.WALLY_ACCESS_TOKEN }} + + - name: Publish to wally + run: wally publish --project-path build/wally + + create-release: + needs: publish-package + + name: Create release + runs-on: ubuntu-latest + + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + + steps: + - uses: actions/checkout@v4 + + - name: Create tag + run: | + git fetch --tags --no-recurse-submodules + if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then + git tag ${{ inputs.release_tag }} + git push origin ${{ inputs.release_tag }} + fi + + - name: Create release + id: create_release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ inputs.release_tag }} + name: ${{ inputs.release_tag }} + draft: false + + build-assets: + needs: create-release + + name: Add assets + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - artifact-name: dom-testing-library.rbxm + path: build/dom-testing-library.rbxm + asset-type: application/octet-stream + + - artifact-name: dom-testing-library-dev.rbxm + path: build/debug/dom-testing-library.rbxm + asset-type: application/octet-stream + + steps: + - uses: actions/checkout@v4 + + - name: Enable corepack + run: corepack enable + + - uses: Roblox/setup-foreman@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/setup-node@v3 + with: + node-version: "latest" + cache: "yarn" + cache-dependency-path: "yarn.lock" + + - name: Install packages + run: yarn install --immutable + + - name: Run npmluau + run: yarn run prepare + + - name: Build assets + run: yarn run build-assets + + - name: Upload asset + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.artifact-name }} + path: ${{ matrix.path }} + + - name: Add asset to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ matrix.path }} + asset_name: ${{ matrix.artifact-name }} + asset_content_type: ${{ matrix.asset-type }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4d2c8ee --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Enable corepack + run: corepack enable + + - uses: Roblox/setup-foreman@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/setup-node@v3 + with: + node-version: "latest" + cache: "yarn" + cache-dependency-path: "yarn.lock" + + - name: Install packages + run: yarn install --immutable + + - name: Run npmluau + run: yarn run prepare + + - name: Run linter + run: yarn run lint + + - name: Verify code style + run: yarn run style-check + + - name: Build assets + run: yarn run build-assets diff --git a/.gitignore b/.gitignore index 0f2ecf7..91d2b9d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,20 @@ Packages/* rotriever.lock roblox.toml -*.rbxmx -*.rbxm +/*.rbxl +/*.rbxl.lock +/*.rbxlx +/*.rbxlx.lock +/*.rbxm +/*.rbxmx .vscode/launch.json .vscode/settings.json .vscode/tasks.json .idea + +**/sourcemap.json +**/node_modules +/build +/roblox +.yarn diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..54f2e27 --- /dev/null +++ b/.npmignore @@ -0,0 +1,39 @@ +/.* +/bin +/Packages +**/.robloxrc +rotriever.toml +/js-to-lua.config.js + +/.github/ +/.vscode/ + +/roblox +/build +/tests + +/*.json +/*.toml +/*.yml +/*.md +/*.tgz + +/scripts +/globalTypes.d.lua +**/sourcemap.json +**/*.project.json + +/test + +**/__tests__ +**/tests +**/*.test.lua +**/*.spec.lua +**/jest.config.lua + +**/*.rbxl +**/*.rbxlx +**/*.rbxl.lock +**/*.rbxlx.lock +**/*.rbxm +**/*.rbxmx diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..3186f3f --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/Packages/.robloxrc b/Packages/.robloxrc deleted file mode 100644 index fb31f2e..0000000 --- a/Packages/.robloxrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "language": { - "mode": "nocheck" - }, - "lint": { - "*": "disabled" - } -} \ No newline at end of file diff --git a/default.project.json b/default.project.json deleted file mode 100644 index f861cfd..0000000 --- a/default.project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "DomTestingLibrary", - "tree": { - "$className": "Folder", - "Packages": { - "$path": "Packages", - "DomTestingLibrary": { - "$path": "src" - }, - "TestsSetup": { - "$path": "tests" - } - } - } -} diff --git a/foreman.toml b/foreman.toml index 5d27541..cac0995 100644 --- a/foreman.toml +++ b/foreman.toml @@ -1,6 +1,7 @@ [tools] -rojo = { source = "Roblox/rojo-rbx-rojo", version = "7.2.1" } -rotrieve = { source = "roblox/rotriever", version = "0.5.4" } -selene = { source = "Roblox/Kampfkarren-selene", version = "0.25.0" } -stylua = { source = "Roblox/JohnnyMorganz-StyLua", version = "=0.14.3" } -rbx-aged-cli = { source = "Roblox/rbx-aged-tool", version = "=5.8.0" } +rojo = { source = "rojo-rbx/rojo", version = "=7.4.0" } +selene = { source = "Kampfkarren/selene", version = "=0.25.0" } +stylua = { source = "JohnnyMorganz/StyLua", version = "=0.14.3" } +darklua = { github = "seaofvoices/darklua", version = "=0.13.0" } +wally = { github = "UpliftGames/wally", version = "=0.3.2" } +run-in-roblox = { github = "rojo-rbx/run-in-roblox", version = "=0.3.0" } diff --git a/model.project.json b/model.project.json new file mode 100644 index 0000000..66a1329 --- /dev/null +++ b/model.project.json @@ -0,0 +1,9 @@ +{ + "name": "DomTestingLibrary", + "tree": { + "$path": "src", + "node_modules": { + "$path": "node_modules" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..992b336 --- /dev/null +++ b/package.json @@ -0,0 +1,49 @@ +{ + "name": "@jsdotlua/dom-testing-library", + "version": "8.14.2-rc.1", + "repository": { + "type": "git", + "url": "https://github.com/jsdotlua/dom-testing-library-lua.git" + }, + "contributors": [ + { + "name": "Ignacio Falk", + "email": "flakolefluk@gmail.com" + }, + { + "name": "Allan Jeremy", + "email": "dev@allanjeremy.com" + }, + { + "name": "Paul Doyle", + "email": "pdoyle@roblox.com" + } + ], + "license": "MIT", + "main": "src/init.lua", + "scripts": { + "prepare": "npmluau", + "build-assets": "sh ./scripts/build-assets.sh", + "lint": "selene src", + "format": "stylua src", + "style-check": "stylua --check src", + "test:roblox": "sh ./scripts/roblox-test.sh", + "verify-pack": "yarn pack --dry-run", + "clean": "rm -rf roblox build node_modules" + }, + "dependencies": { + "@jsdotlua/chalk": "^0.2.1", + "@jsdotlua/jest-get-type": "^3.6.1-rc.2", + "@jsdotlua/jest-globals": "^3.6.1-rc.2", + "@jsdotlua/jest-roblox-shared": "^3.6.1-rc.2", + "@jsdotlua/luau-polyfill": "^1.2.6", + "@jsdotlua/pretty-format": "^3.6.1-rc.2", + "@jsdotlua/promise": "^3.5.0", + "luau-regexp": "^0.2.1" + }, + "devDependencies": { + "@jsdotlua/jest": "^3.6.1-rc.2", + "npmluau": "^0.1.1" + }, + "packageManager": "yarn@4.0.2" +} diff --git a/scripts/build-assets.sh b/scripts/build-assets.sh new file mode 100755 index 0000000..b36b9c5 --- /dev/null +++ b/scripts/build-assets.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +./scripts/build-roblox-model.sh +./scripts/build-wally-package.sh +# bundling currently stack overflows, re-enable when full-moon +# re-write is published and updated in darklua +# ./scripts/build-single-file.sh diff --git a/scripts/build-roblox-model.sh b/scripts/build-roblox-model.sh new file mode 100755 index 0000000..bf99b39 --- /dev/null +++ b/scripts/build-roblox-model.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e + +build_with_darklua_config () { + DARKLUA_CONFIG=$1 + OUTPUT=build/$2 + + rm -rf roblox + + mkdir -p roblox + + cp -r src/ roblox/ + ./scripts/remove-tests.sh roblox + + rojo sourcemap model.project.json -o sourcemap.json + + darklua process --config $DARKLUA_CONFIG node_modules roblox/node_modules + + cp $DARKLUA_CONFIG roblox/ + cp sourcemap.json roblox/ + + darklua process --config roblox/$DARKLUA_CONFIG roblox/src roblox/src + + ./scripts/remove-tests.sh roblox + + cp model.project.json roblox/ + + mkdir -p build + mkdir -p $(dirname $OUTPUT) + + rojo build roblox/model.project.json -o $OUTPUT +} + +build_with_darklua_config .darklua.json dom-testing-library.rbxm +build_with_darklua_config .darklua-dev.json debug/dom-testing-library.rbxm diff --git a/scripts/build-single-file.sh b/scripts/build-single-file.sh new file mode 100755 index 0000000..a57b0ba --- /dev/null +++ b/scripts/build-single-file.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +mkdir -p build +mkdir -p build/debug + +rm -f build/dom-testing-library.lua +rm -f build/debug/dom-testing-library.lua + +darklua process --config .darklua-bundle.json src/init.lua build/dom-testing-library.lua +darklua process --config .darklua-bundle-dev.json src/init.lua build/debug/dom-testing-library.lua diff --git a/scripts/build-wally-package.sh b/scripts/build-wally-package.sh new file mode 100755 index 0000000..9996020 --- /dev/null +++ b/scripts/build-wally-package.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +rm -rf roblox + +mkdir -p roblox + +cp -r src roblox/src + +./scripts/remove-tests.sh roblox + +wally_package=build/wally +rm -rf $wally_package + +echo Process package + +mkdir -p $wally_package +cp LICENSE $wally_package/LICENSE + +node ./scripts/npm-to-wally.js package.json $wally_package/wally.toml roblox/wally-package.project.json + +cp .darklua-wally.json roblox +cp -r node_modules/.luau-aliases/* roblox + +rojo sourcemap roblox/wally-package.project.json --output roblox/sourcemap.json + +darklua process --config roblox/.darklua-wally.json roblox/src $wally_package/src + +cp default.project.json $wally_package +wally package --project-path $wally_package --list diff --git a/scripts/npm-to-wally.js b/scripts/npm-to-wally.js new file mode 100644 index 0000000..232e742 --- /dev/null +++ b/scripts/npm-to-wally.js @@ -0,0 +1,144 @@ +#!/usr/bin/env node + +const { Command } = require("commander"); + +const fs = require("fs").promises; +const path = require("path"); +const process = require("process"); + +const readPackageConfig = async (packagePath) => { + const packageContent = await fs.readFile(packagePath).catch((err) => { + console.error(`unable to read package.json at '${packagePath}': ${err}`); + return null; + }); + + if (packageContent !== null) { + try { + const packageData = JSON.parse(packageContent); + return packageData; + } catch (error) { + console.error(`unable to parse package.json at '${packagePath}': ${err}`); + } + } + + return null; +}; + +const main = async ( + packageJsonPath, + wallyOutputPath, + rojoConfigPath, + { workspacePath } +) => { + const packageData = await readPackageConfig(packageJsonPath); + + const { name: scopedName, version, license, dependencies = [] } = packageData; + + const tomlLines = [ + "[package]", + `name = "${scopedName.substring(1)}"`, + `version = "${version}"`, + 'registry = "https://github.com/UpliftGames/wally-index"', + 'realm = "shared"', + `license = "${license}"`, + "", + "[dependencies]", + ]; + + const rojoConfig = { + name: "WallyPackage", + tree: { + $className: "Folder", + Package: { + $path: "src", + }, + }, + }; + + for (const [dependencyName, specifiedVersion] of Object.entries( + dependencies + )) { + const name = dependencyName.startsWith("@") + ? dependencyName.substring(dependencyName.indexOf("/") + 1) + : dependencyName; + + rojoConfig.tree[name] = { + $path: dependencyName + ".luau", + }; + + const wallyPackageName = name.indexOf("-") !== -1 ? `"${name}"` : name; + + if (specifiedVersion == "workspace:^") { + const dependentPackage = + workspacePath && + (await readPackageConfig( + path.join(workspacePath, name, "package.json") + )); + + if (dependentPackage) { + tomlLines.push( + `${wallyPackageName} = "jsdotlua/${name}@${dependentPackage.version}"` + ); + } else { + console.error(`unable to find version for package '${name}'`); + } + } else { + tomlLines.push( + `${wallyPackageName} = "jsdotlua/${name}@${specifiedVersion}"` + ); + } + } + + tomlLines.push(""); + + await Promise.all([ + fs.writeFile(wallyOutputPath, tomlLines.join("\n")).catch((err) => { + console.error( + `unable to write wally config at '${wallyOutputPath}': ${err}` + ); + }), + fs + .writeFile(rojoConfigPath, JSON.stringify(rojoConfig, null, 2)) + .catch((err) => { + console.error( + `unable to write rojo config at '${rojoConfigPath}': ${err}` + ); + }), + ]); +}; + +const createCLI = () => { + const program = new Command(); + + program + .name("npm-to-wally") + .description("a utility to convert npm packages to wally packages") + .argument("") + .argument("") + .argument("") + .option( + "--workspace-path ", + "the path containing all workspace members" + ) + .action( + async (packageJson, wallyToml, rojoConfig, { workspacePath = null }) => { + const cwd = process.cwd(); + main( + path.join(cwd, packageJson), + path.join(cwd, wallyToml), + path.join(cwd, rojoConfig), + { + workspacePath: workspacePath && path.join(cwd, workspacePath), + } + ); + } + ); + + return (args) => { + program.parse(args); + }; +}; + +const run = createCLI(); + +run(process.argv); diff --git a/scripts/remove-tests.sh b/scripts/remove-tests.sh new file mode 100755 index 0000000..305c98d --- /dev/null +++ b/scripts/remove-tests.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +FOLDER=$1 + +find $FOLDER -name '__tests__' -type d -exec rm -r {} + +find $FOLDER -name '__tests__' -type d -exec rm -r {} + +find $FOLDER -name '__fixtures__' -type d -exec rm -r {} + +find $FOLDER -name '__testUtils__' -type d -exec rm -r {} + +find $FOLDER -name 'TestMatchers' -type d -exec rm -r {} + +find $FOLDER -name '.robloxrc' -type f -exec rm -r {} + +find $FOLDER -name '*.spec.lua' -type f -exec rm -r {} + +find $FOLDER -name 'jest.config.lua' -type f -exec rm -r {} + diff --git a/scripts/roblox-test.sh b/scripts/roblox-test.sh new file mode 100644 index 0000000..bb0d8dd --- /dev/null +++ b/scripts/roblox-test.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -xe + +if [ ! -d node_modules ]; then + rm -rf roblox + yarn install + yarn prepare +fi + +if [ -d "roblox" ]; then + ls -d roblox/* | grep -v node_modules | xargs rm -rf +fi + +rojo sourcemap test-place.project.json -o sourcemap.json + +darklua process src roblox/src +darklua process tests roblox/tests +darklua process node_modules roblox/node_modules + +cp test-place.project.json roblox/ + +rojo build roblox/test-place.project.json -o place.rbxl + +run-in-roblox --place place.rbxl --script roblox/tests/roblox-test.server.lua diff --git a/test-place.project.json b/test-place.project.json new file mode 100644 index 0000000..92cefbb --- /dev/null +++ b/test-place.project.json @@ -0,0 +1,29 @@ +{ + "name": "test-place", + "tree": { + "$className": "DataModel", + "HttpService": { + "$properties": { + "HttpEnabled": true + } + }, + "Players": { + "$properties": { + "CharacterAutoLoads": false + } + }, + "ReplicatedStorage": { + "node_modules": { + "$path": "./node_modules" + }, + "DomTestingLibrary": { + "$path": "./src" + } + }, + "ServerScriptService": { + "TestsSetup": { + "$path": "tests" + } + } + } +} diff --git a/tests.project.json b/tests.project.json deleted file mode 100644 index 0197825..0000000 --- a/tests.project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "DomTestingLibraryTestModel", - "tree": { - "$className": "DataModel", - - "HttpService": { - "$className": "HttpService", - "$properties": { - "HttpEnabled": true - } - }, - "ReplicatedStorage": { - "$className": "ReplicatedStorage", - "Packages": { - "$path": "Packages", - "DomTestingLibrary": { - "$path": "src" - }, - "TestsSetup": { - "$path": "tests" - } - } - } - } -} diff --git a/tests/roblox-test.server.lua b/tests/roblox-test.server.lua new file mode 100644 index 0000000..30f3a91 --- /dev/null +++ b/tests/roblox-test.server.lua @@ -0,0 +1,14 @@ +local ReplicatedStorage = game:GetService('ReplicatedStorage') + +local jest = require('@pkg/@jsdotlua/jest') + +local success, result = jest.runCLI(ReplicatedStorage, { + color = false, + colors = false, +}, { ReplicatedStorage:FindFirstChild('DomTestingLibrary') }):await() + +if not success then + error(result) +end + +task.wait(0.5) diff --git a/tests/setup-env.lua b/tests/setup-env.lua index fa7caf4..682f407 100644 --- a/tests/setup-env.lua +++ b/tests/setup-env.lua @@ -1,12 +1,11 @@ -- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/tests/setup-env.js -local Packages = script.Parent.Parent -local LuauPolyfill = require(Packages.LuauPolyfill) +local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill") local console = LuauPolyfill.console local Array = LuauPolyfill.Array local Boolean = LuauPolyfill.Boolean -local JestGlobals = require(Packages.JestGlobals) +local JestGlobals = require("@pkg/@jsdotlua/jest-globals") local jest = JestGlobals.jest local expect = JestGlobals.expect local afterAll = JestGlobals.afterAll @@ -14,7 +13,7 @@ local afterEach = JestGlobals.afterEach local beforeAll = JestGlobals.beforeAll -- ROBLOX deviation START: explicitly extend expect -local jestDomMatchers = require(Packages.DomTestingLibrary.jsHelpers["jest-dom"]) +local jestDomMatchers = require("../src/jsHelpers/jest-dom") expect.extend(jestDomMatchers) -- ROBLOX deviation END diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..a7b9a90 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,618 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 8 + cacheKey: 10c0 + +"@jsdotlua/boolean@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/boolean@npm:1.2.6" + dependencies: + "@jsdotlua/number": "npm:^1.2.6" + checksum: 5f567e556bb7c56102327a97468571522ce939be6cdc1b51591afc3dfc1dff4b2c9ec5462e7809bd9a515b3bdfc1c3eaabb4f631892cb5f471b4fc8da188cb84 + languageName: node + linkType: hard + +"@jsdotlua/chalk@npm:^0.2.1": + version: 0.2.1 + resolution: "@jsdotlua/chalk@npm:0.2.1" + checksum: 4db0d7de47dae83daa8be4cb4acbb8cc54e81aa598a686529bd95e95900f365edab65fc354c6114be942cfc8c2f3efc47b78aebc528cd2079e0c67f7e4aeba8d + languageName: node + linkType: hard + +"@jsdotlua/collections@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/collections@npm:1.2.6" + dependencies: + "@jsdotlua/es7-types": "npm:^1.2.6" + "@jsdotlua/instance-of": "npm:^1.2.6" + checksum: a4b3fe826358484528f10e8ca61a80d841a6515a22277a003117449da66ea1fb891c7b4103b952b01bd7d75666f26cb41c8efb852672aa8aaaaebbcd656dca79 + languageName: node + linkType: hard + +"@jsdotlua/console@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/console@npm:1.2.6" + dependencies: + "@jsdotlua/collections": "npm:^1.2.6" + checksum: eff658d9e8d23f932893facf18400a29ada54d1a24748b751aac1e4df48e92ff70b3b2ccd1ab6a4f2490dd709f826fe39427fb80f01a7574265fdd4e8af9187a + languageName: node + linkType: hard + +"@jsdotlua/diff-sequences@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/diff-sequences@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 8131dfffd336cfd7a2d38d974145156163c85c13bfc5dc4d36cb9d3735ffaa977751782dfca2d119dccc00badbf1120eef2d399586a5748329da7137030dda01 + languageName: node + linkType: hard + +"@jsdotlua/dom-testing-library@workspace:.": + version: 0.0.0-use.local + resolution: "@jsdotlua/dom-testing-library@workspace:." + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-globals": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + "@jsdotlua/promise": "npm:^3.5.0" + luau-regexp: "npm:^0.2.1" + npmluau: "npm:^0.1.1" + languageName: unknown + linkType: soft + +"@jsdotlua/emittery@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/emittery@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + checksum: b7093886298b74837a4fa265c197419579cab06e2d9353ce752f5013bd8a05e29be35865a6ef66258ea2d45af046c7c98e24520489ba54729b5ea682c22a8466 + languageName: node + linkType: hard + +"@jsdotlua/es7-types@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/es7-types@npm:1.2.6" + checksum: e5710f5f6de0608aec22744845e3a24acc47e2bda6cfc0b1fe4040935039b73e8467da90c3a6c9d75b08c9f39d2b98e9d72d54f3f630012538a7d53ad828a0d6 + languageName: node + linkType: hard + +"@jsdotlua/expect@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/expect@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-matcher-utils": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-snapshot": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + luau-regexp: "npm:^0.2.1" + checksum: 7733242b925f053095321427bf082a387c4d2220ea6f64830d8849837792c362cc7dc81ef8563905733aa4811ffb1dc6764f3093dc5bc2eb5a7850e53e8e5a84 + languageName: node + linkType: hard + +"@jsdotlua/instance-of@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/instance-of@npm:1.2.6" + checksum: 0958caf214bb0556c1dcf94096410c367f413af4b02ef3adbd733e47435d8734b583217804bed5aec8308d56ccfb39032bb12fd4337e01ec5ae2db690b2ca9ce + languageName: node + linkType: hard + +"@jsdotlua/jest-circus@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-circus@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/expect": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-each": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-environment": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-matcher-utils": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-runtime": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-snapshot": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-test-result": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + "@jsdotlua/promise": "npm:^3.5.0" + "@jsdotlua/throat": "npm:^3.6.1-rc.2" + luau-regexp: "npm:^0.2.1" + checksum: 9afc7a29c871fd5e6ebf330dd9e428e3570b4d9581e248c24edae93a1e54fa917e41173cbd7672c1fea8fd6d7e4ee06b23fb8199bd5f87e726b50fd4d652fe49 + languageName: node + linkType: hard + +"@jsdotlua/jest-config@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-config@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-each": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-environment-roblox": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-validate": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + luau-regexp: "npm:^0.2.1" + checksum: 91cdb06da5681c05328cd1e0796c98b0685a7bc766fc5d3190718a79d6755b717598aee8189511947629e903568776e66fffc01bf4b2436c7df2a4fc611ee359 + languageName: node + linkType: hard + +"@jsdotlua/jest-console@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-console@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-each": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: b3430756752f1b9df7682fe1bb8c4343e4638ebc0cff0251276049138232045f20f06ef2f3a029758c9d4c40c001b70904b80ebb798c5d251a2fabd90d5866a4 + languageName: node + linkType: hard + +"@jsdotlua/jest-core@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-core@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/emittery": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-config": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-console": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-reporters": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-runner": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-runtime": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-snapshot": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-test-result": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + "@jsdotlua/promise": "npm:^3.5.0" + luau-regexp: "npm:^0.2.1" + checksum: 8294c3bd8328445ebced024d0094f11e427ffdcc3f4e19b4b0728d963ff44864edf90572d53d2f0d922554b72282439df76e2e74ce8357b98607c51483440c90 + languageName: node + linkType: hard + +"@jsdotlua/jest-diff@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-diff@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/diff-sequences": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + checksum: e7bd52319e178212ca696bd3c47c3ced5251bf4e62ac57a0e4bfdda79c648c2ce815da34b0423ddcbe0fc260bc595ee5ea4ac1300e1052c8a60e0d3d23217ac5 + languageName: node + linkType: hard + +"@jsdotlua/jest-each@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-each@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + luau-regexp: "npm:^0.2.1" + checksum: 91d37f0a6e2fb291f229aabc5f7b0e839827e8751f3fd33a4754ffda51b325d9dd814d518753cb47c8dcad3ae249e3b881d0ffd0aa21a6af74afdb27a67a779d + languageName: node + linkType: hard + +"@jsdotlua/jest-environment-roblox@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-environment-roblox@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-environment": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-fake-timers": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + checksum: 0ad8b4fb6a140577091d188c4c441109532b638054380c6cd102276fcd835c771d807d6017d72aaa486ca390294adbc42afa6d8471c3ea826bec7914668bfe06 + languageName: node + linkType: hard + +"@jsdotlua/jest-environment@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-environment@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-fake-timers": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 9174d88955fd68380bae0118e8600547c62816d006ba070a7397a7d0cd70a88403e3d7c1407d5da1da0e5b6aa8799ca12e4c2ec92ec9796de29201a4c9e4acba + languageName: node + linkType: hard + +"@jsdotlua/jest-fake-timers@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-fake-timers@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 5650e726c80be8fe04fa1b6bcd2a3aee66b146ebbccd102b1c5416516bee5dff284e13f098aba163e01672a82f4cd6a3254d0fb208b65dd9529258b437a8c43e + languageName: node + linkType: hard + +"@jsdotlua/jest-get-type@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-get-type@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + luau-regexp: "npm:^0.2.1" + checksum: 6216f048dc17275a321ff1f8c96788ec3bab39bb9c8894b216a2419fe7e468448e970a820751a2b64b2a60bb8ebbd5105425927a9895332c234744203659419f + languageName: node + linkType: hard + +"@jsdotlua/jest-globals@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-globals@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/expect": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-environment": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: d9324045c7adc930db71f586e7c886ec9b3165978b271e93d07ee0537dcb22126a414ed2efbf6b62f6aa1f7cedd687ce5b3d6f5ad55ff0470b6562421dee658d + languageName: node + linkType: hard + +"@jsdotlua/jest-matcher-utils@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-matcher-utils@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-diff": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + luau-regexp: "npm:^0.2.1" + checksum: 156c6fa299c10eb1bda2f1e15f4a9de8e1f9a3a0d8982a012b7e51c17dbd3a668c882bdfb07a6910f19018cb6610700289b83736d2a8ff6c9296d50777ab7081 + languageName: node + linkType: hard + +"@jsdotlua/jest-message-util@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-message-util@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + luau-regexp: "npm:^0.2.1" + checksum: 48d942b4de4f6b904851e7f2e74d41a211028209d2825cef8061f14d9d0c7c760f2de62037f1b5e7c84540919c30ddd4ae333a4b1d3f72bacf28fdf7ea9c1c59 + languageName: node + linkType: hard + +"@jsdotlua/jest-mock@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-mock@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: e77f12ac35925cb79ac7831fcf332ff3bd5dbafb016d53d77c0efa16098732a2b14f3a5b34b2be20d903ce683773dbd39ba57cde4bad7130d9fafd0931586625 + languageName: node + linkType: hard + +"@jsdotlua/jest-reporters@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-reporters@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-console": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-test-result": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/path": "npm:^3.6.1-rc.2" + checksum: 90e0d034084085ed873bd10b1a5742d08b0807da1bcfe380043e7dbdfcc3f4ad0048472c65ca73a13c40d182baa5e6596dea0ec6c2898df99a413b561864ea3d + languageName: node + linkType: hard + +"@jsdotlua/jest-roblox-shared@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-roblox-shared@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 61c13286784a247ec8a0f17bd4f6a7740bd1f41277569e5dfad60072f6cdf40d5d163b67d0cbd5d1d0ca4a1c705a4eaa09e87a624709ff494c0b2c4e7af374ff + languageName: node + linkType: hard + +"@jsdotlua/jest-runner@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-runner@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/emittery": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-circus": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-console": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-environment": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-message-util": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-runtime": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-test-result": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-util": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + "@jsdotlua/promise": "npm:^3.5.0" + "@jsdotlua/throat": "npm:^3.6.1-rc.2" + checksum: 3615ea2cd7056731911bfea5d82f2e133fd6fb93676867d0850ccbb1cb23d1720fddbcd7e3436d3229fc159d592d32892472b8ce622c06e677abf08d57cc2c1a + languageName: node + linkType: hard + +"@jsdotlua/jest-runtime@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-runtime@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/emittery": "npm:^3.6.1-rc.2" + "@jsdotlua/expect": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-fake-timers": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-mock": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-snapshot": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + checksum: 280a8142a0aec3b86446b456764f536f9bf71523f564d17e4f65a6ea13d3da1fa820eeac181101370d725e3233aa22968ad4311a2c21df7db776655dbdffa444 + languageName: node + linkType: hard + +"@jsdotlua/jest-snapshot@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-snapshot@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-diff": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-matcher-utils": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/pretty-format": "npm:^3.6.1-rc.2" + "@jsdotlua/promise": "npm:^3.5.0" + checksum: e6fef6faf7a2696aa9f032805eebb8b82c72742bdb423c9c91bea8c6ddd7ea625554d990c2ade294a108f87bea8cd7e9ad4d59f3283a97dd72087ec99833960c + languageName: node + linkType: hard + +"@jsdotlua/jest-test-result@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-test-result@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: f43d418941805671415c4f68581f068803079f73d4cc4757fb72f717783540c04ac02d0856d7faa7c28873d17898cf84417b695c7ca4b939bf5aa75e0353ef3f + languageName: node + linkType: hard + +"@jsdotlua/jest-types@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-types@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + luau-regexp: "npm:^0.2.1" + checksum: 8777716c40e76d7bab203db368af2b67cfba7fccef9acc36c91150b4c25628da06e85f99b5bf207449cb3d51ea5bd9cc9fb8ede5102afa9ea3f9854a7a66570e + languageName: node + linkType: hard + +"@jsdotlua/jest-util@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-util@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-types": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/picomatch": "npm:^0.4.0" + "@jsdotlua/promise": "npm:^3.5.0" + luau-regexp: "npm:^0.2.1" + checksum: b9a5d7ba8fe9f104922f84b493efe28a0f4622658c625a4b97d7fceb8e07651dd9b0fd20c9195c2c13c47e9569e9c6e60e081ed5cb17165d2fb51f28a7ac8ea3 + languageName: node + linkType: hard + +"@jsdotlua/jest-validate@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest-validate@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 50e51e5d3ae790bd51132d82797d0931ab8866b945fa64b5890649074bd4fc06c6e4f6afe207ab0c4817a90d8fd2159504e5c9acb2328396de7715cea4e5a854 + languageName: node + linkType: hard + +"@jsdotlua/jest@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/jest@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/jest-core": "npm:^3.6.1-rc.2" + checksum: 3359aca93518fa2b66c6f98034db4a6026b278a973256949ccd9cf3f8ae7f614976de79b7863d7387188bf3322036d2b4497ed35fc74801ece5099352fa079bb + languageName: node + linkType: hard + +"@jsdotlua/luau-polyfill@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/luau-polyfill@npm:1.2.6" + dependencies: + "@jsdotlua/boolean": "npm:^1.2.6" + "@jsdotlua/collections": "npm:^1.2.6" + "@jsdotlua/console": "npm:^1.2.6" + "@jsdotlua/es7-types": "npm:^1.2.6" + "@jsdotlua/instance-of": "npm:^1.2.6" + "@jsdotlua/math": "npm:^1.2.6" + "@jsdotlua/number": "npm:^1.2.6" + "@jsdotlua/string": "npm:^1.2.6" + "@jsdotlua/timers": "npm:^1.2.6" + symbol-luau: "npm:^1.0.0" + checksum: 63265f9fde3b895400d12802929ddab5daed79efc4e2aa90325b2eea0e2b7addcf351d35ad8bb19955956e913c212408944d73b6f3126223893d17cecd24de61 + languageName: node + linkType: hard + +"@jsdotlua/math@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/math@npm:1.2.6" + checksum: 06137df2a6352d4f5c730a7cf9e2902509d36de08415a3c70d470a05669dfeaf48e4aff2d5b6885a92b8f4d19fd0294a40f147a3f39c8558e887a09eb3ccd9e0 + languageName: node + linkType: hard + +"@jsdotlua/number@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/number@npm:1.2.6" + checksum: 74541fce86f80c52f05e5d4ca774d94f08ed21619af7b575c2bb7284e24fc2b178626c9888e286459a344d662cafab74d839ec8b95dcdab551fd14754911a292 + languageName: node + linkType: hard + +"@jsdotlua/path@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/path@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 60868d5161f3bfc263ebcddac8cbe83f6787f85409fc1a563ff350b9ccab05c88e934ccd7e3627ea77bd73f5e30b21dbe7d85e7a4d8445d3baf96cd42bab4877 + languageName: node + linkType: hard + +"@jsdotlua/picomatch@npm:^0.4.0": + version: 0.4.0 + resolution: "@jsdotlua/picomatch@npm:0.4.0" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + luau-regexp: "npm:^0.2.1" + checksum: 7ccc76cfe19974a91758adf62fc69529d05815575488c1ba31af052b0f25de24a9614fd47c6e5bf67f6c28aa8e84f3f32bb59f6cb59143bb05d41b925b3a2b0e + languageName: node + linkType: hard + +"@jsdotlua/pretty-format@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/pretty-format@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/chalk": "npm:^0.2.1" + "@jsdotlua/jest-get-type": "npm:^3.6.1-rc.2" + "@jsdotlua/jest-roblox-shared": "npm:^3.6.1-rc.2" + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/react-is": "npm:^17.1.0" + luau-regexp: "npm:^0.2.1" + checksum: c82724cf7d9f84e4a12dd24fa8a13238649a76182537cc02e973a88720bf007a538d6ffea6fdb771cae6421ceea7aa221d58f126e1ab0b54f617294e7c455dfd + languageName: node + linkType: hard + +"@jsdotlua/promise@npm:^3.5.0": + version: 3.5.0 + resolution: "@jsdotlua/promise@npm:3.5.0" + checksum: 8771dac525b8d608ad319040b742cdde8f4cbbd4a075ae02dad4d510c8ab739dabf7de40ae1b15211e3890331cf3e7d9454fdcb3ec9a08471663436c0e9ec977 + languageName: node + linkType: hard + +"@jsdotlua/react-is@npm:^17.1.0": + version: 17.1.0 + resolution: "@jsdotlua/react-is@npm:17.1.0" + dependencies: + "@jsdotlua/shared": "npm:^17.1.0" + checksum: 0133682ec6ab337f2e9e3983be484f994abe8303857dd77c351fc0f9fb7d154ba115ba5ca29460f90bd482c6bbe57a28b7ddea0f4954745aaf09d682b2939560 + languageName: node + linkType: hard + +"@jsdotlua/shared@npm:^17.1.0": + version: 17.1.0 + resolution: "@jsdotlua/shared@npm:17.1.0" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + checksum: 23e0d4fec494e7059b116db3b89e9655cc772e19fe06f9ad92bc97a324cf8862b0f2e7aaffee89d0627c9a1abb793b254573f09860fa35caf21925a33b332376 + languageName: node + linkType: hard + +"@jsdotlua/string@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/string@npm:1.2.6" + dependencies: + "@jsdotlua/es7-types": "npm:^1.2.6" + "@jsdotlua/number": "npm:^1.2.6" + checksum: de51c662439110642b699e4196240aa45ec4b8814f99bc606acb84dbb3f1c6889099bb722b3370f5873e06bd65c76779b5d94694309c9bdc63d324f40add2b0f + languageName: node + linkType: hard + +"@jsdotlua/throat@npm:^3.6.1-rc.2": + version: 3.6.1-rc.2 + resolution: "@jsdotlua/throat@npm:3.6.1-rc.2" + dependencies: + "@jsdotlua/luau-polyfill": "npm:^1.2.6" + "@jsdotlua/promise": "npm:^3.5.0" + checksum: 306215bdc4d7baf8ff79cece3b6038123ea7b9d4fa41eaaba4ec9f0c9c48a8ed2e82bdbc1a256b16257188a8236d84deac4131a9a15e0a40c48aa51e93e285a6 + languageName: node + linkType: hard + +"@jsdotlua/timers@npm:^1.2.6": + version: 1.2.6 + resolution: "@jsdotlua/timers@npm:1.2.6" + dependencies: + "@jsdotlua/collections": "npm:^1.2.6" + checksum: f3ec2753894e4939f7dfdf0072517f1e769e4009b4bd882c9c6878526372753ac4b08b531e1a32c96b7bccb5bf10bb8e2f5730cbc70534da7eddc620fbccaaca + languageName: node + linkType: hard + +"commander@npm:^11.0.0": + version: 11.1.0 + resolution: "commander@npm:11.1.0" + checksum: 13cc6ac875e48780250f723fb81c1c1178d35c5decb1abb1b628b3177af08a8554e76b2c0f29de72d69eef7c864d12613272a71fabef8047922bc622ab75a179 + languageName: node + linkType: hard + +"luau-regexp@npm:^0.2.1": + version: 0.2.1 + resolution: "luau-regexp@npm:0.2.1" + checksum: 7badc4e6f9ab7753d77e49db3012c525fb85dff70930c806754edd86893a39c1afb1aba51aba00b2f456f72d7f02c6a8812a160646a05986bc6d1bfae6251494 + languageName: node + linkType: hard + +"npmluau@npm:^0.1.1": + version: 0.1.1 + resolution: "npmluau@npm:0.1.1" + dependencies: + commander: "npm:^11.0.0" + walkdir: "npm:^0.4.1" + bin: + npmluau: main.js + checksum: 9ae22c0dcff9e85c90b4da4e8c17bc51e9b567b4a417c9767d355ff68faca4f99a2934b581743ebc8729f6851d1ba5b64597312151747252e040517d1794fbca + languageName: node + linkType: hard + +"symbol-luau@npm:^1.0.0": + version: 1.0.1 + resolution: "symbol-luau@npm:1.0.1" + checksum: ab51a77331b2d5e4666528bada17e67b26aea355257bba9e97351016cd1836bd19f372355a14cf5bef2f4d5bc6b32fe91aeb09698d7bdc079d2c61330bedf251 + languageName: node + linkType: hard + +"walkdir@npm:^0.4.1": + version: 0.4.1 + resolution: "walkdir@npm:0.4.1" + checksum: 88e635aa9303e9196e4dc15013d2bd4afca4c8c8b4bb27722ca042bad213bb882d3b9141b3b0cca6bfb274f7889b30cf58d6374844094abec0016f335c5414dc + languageName: node + linkType: hard From b55243bc20f0121677164102353875ac8744eb0f Mon Sep 17 00:00:00 2001 From: jeparlefrancais Date: Thu, 21 Mar 2024 15:06:59 -0400 Subject: [PATCH 3/5] add selene configuration --- selene.toml | 2 +- selene_definitions.yml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 selene_definitions.yml diff --git a/selene.toml b/selene.toml index c440167..162c35f 100644 --- a/selene.toml +++ b/selene.toml @@ -1,4 +1,4 @@ -std = "roblox" +std = "selene_definitions" [config] empty_if = { comments_count = true } diff --git a/selene_definitions.yml b/selene_definitions.yml new file mode 100644 index 0000000..95cabdf --- /dev/null +++ b/selene_definitions.yml @@ -0,0 +1,7 @@ +base: roblox +name: selene_defs +globals: + # override Roblox require style with string requires + require: + args: + - type: string From 76648c19388f17107151f85c9bf439628ddbfd59 Mon Sep 17 00:00:00 2001 From: jeparlefrancais Date: Thu, 21 Mar 2024 15:09:06 -0400 Subject: [PATCH 4/5] fix style --- src/__tests__/wait-for-element-to-be-removed.spec.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/__tests__/wait-for-element-to-be-removed.spec.lua b/src/__tests__/wait-for-element-to-be-removed.spec.lua index 71afdcd..9ed35be 100644 --- a/src/__tests__/wait-for-element-to-be-removed.spec.lua +++ b/src/__tests__/wait-for-element-to-be-removed.spec.lua @@ -12,8 +12,7 @@ local test = JestGlobals.test local CollectionService = game:GetService("CollectionService") -local waitForElementToBeRemoved = - require("../wait-for-element-to-be-removed").waitForElementToBeRemoved +local waitForElementToBeRemoved = require("../wait-for-element-to-be-removed").waitForElementToBeRemoved local renderIntoDocument = require("./helpers/test-utils").renderIntoDocument local document = require("../jsHelpers/document") From 20e6456d79ccc52cf2b35ca5890a7cb880da566e Mon Sep 17 00:00:00 2001 From: jeparlefrancais Date: Thu, 21 Mar 2024 15:31:17 -0400 Subject: [PATCH 5/5] fix wally build --- scripts/build-wally-package.sh | 3 +- scripts/npm-to-wally.js | 110 ++++++++++++++++++++++++++++----- 2 files changed, 96 insertions(+), 17 deletions(-) diff --git a/scripts/build-wally-package.sh b/scripts/build-wally-package.sh index 9996020..f1c7384 100755 --- a/scripts/build-wally-package.sh +++ b/scripts/build-wally-package.sh @@ -18,7 +18,7 @@ echo Process package mkdir -p $wally_package cp LICENSE $wally_package/LICENSE -node ./scripts/npm-to-wally.js package.json $wally_package/wally.toml roblox/wally-package.project.json +node ./scripts/npm-to-wally.js package.json $wally_package/wally.toml $wally_package/default.project.json roblox/wally-package.project.json cp .darklua-wally.json roblox cp -r node_modules/.luau-aliases/* roblox @@ -27,5 +27,4 @@ rojo sourcemap roblox/wally-package.project.json --output roblox/sourcemap.json darklua process --config roblox/.darklua-wally.json roblox/src $wally_package/src -cp default.project.json $wally_package wally package --project-path $wally_package --list diff --git a/scripts/npm-to-wally.js b/scripts/npm-to-wally.js index 232e742..ee86564 100644 --- a/scripts/npm-to-wally.js +++ b/scripts/npm-to-wally.js @@ -6,6 +6,11 @@ const fs = require("fs").promises; const path = require("path"); const process = require("process"); +const extractPackageNameWhenScoped = (packageName) => + packageName.startsWith("@") + ? packageName.substring(packageName.indexOf("/") + 1) + : packageName; + const readPackageConfig = async (packagePath) => { const packageContent = await fs.readFile(packagePath).catch((err) => { console.error(`unable to read package.json at '${packagePath}': ${err}`); @@ -24,26 +29,80 @@ const readPackageConfig = async (packagePath) => { return null; }; +const fileExists = async (filePath) => { + return await fs + .stat(filePath) + .then((stat) => stat.isFile()) + .catch((err) => { + if (err.code === "ENOENT") { + return false; + } + }); +}; + +const findPackagePath = async (workspacePath, packageName) => { + const trivialPath = path.join( + workspacePath, + extractPackageNameWhenScoped(packageName) + ); + + if (await fileExists(path.join(trivialPath, "package.json"))) { + return path.join(trivialPath); + } + + const workspaceMembers = await fs.readdir(workspacePath); + + for (const member of workspaceMembers) { + const memberPath = path.join(workspacePath, member); + + const packageData = await fs + .readFile(path.join(memberPath, "package.json")) + .then((packageContent) => { + return JSON.parse(packageContent); + }) + .catch(() => { + return null; + }); + + if (packageData?.name === packageName) { + return memberPath; + } + } + + return null; +}; + const main = async ( packageJsonPath, wallyOutputPath, + wallyRojoConfigPath, rojoConfigPath, { workspacePath } ) => { const packageData = await readPackageConfig(packageJsonPath); - const { name: scopedName, version, license, dependencies = [] } = packageData; + const { + name: scopedName, + version, + license, + dependencies = [], + private, + } = packageData; + + const tomlLines = ["[package]", `name = "${scopedName.substring(1)}"`]; + + if (private) { + tomlLines.push("private = true"); + } - const tomlLines = [ - "[package]", - `name = "${scopedName.substring(1)}"`, + tomlLines.push( `version = "${version}"`, 'registry = "https://github.com/UpliftGames/wally-index"', 'realm = "shared"', `license = "${license}"`, "", - "[dependencies]", - ]; + "[dependencies]" + ); const rojoConfig = { name: "WallyPackage", @@ -58,9 +117,7 @@ const main = async ( for (const [dependencyName, specifiedVersion] of Object.entries( dependencies )) { - const name = dependencyName.startsWith("@") - ? dependencyName.substring(dependencyName.indexOf("/") + 1) - : dependencyName; + const name = extractPackageNameWhenScoped(dependencyName); rojoConfig.tree[name] = { $path: dependencyName + ".luau", @@ -69,11 +126,12 @@ const main = async ( const wallyPackageName = name.indexOf("-") !== -1 ? `"${name}"` : name; if (specifiedVersion == "workspace:^") { + const packagePath = + workspacePath && (await findPackagePath(workspacePath, dependencyName)); + const dependentPackage = - workspacePath && - (await readPackageConfig( - path.join(workspacePath, name, "package.json") - )); + packagePath && + (await readPackageConfig(path.join(packagePath, "package.json"))); if (dependentPackage) { tomlLines.push( @@ -91,6 +149,13 @@ const main = async ( tomlLines.push(""); + const wallyRojoConfig = { + name: scopedName.substring(scopedName.indexOf("/") + 1), + tree: { + $path: "src", + }, + }; + await Promise.all([ fs.writeFile(wallyOutputPath, tomlLines.join("\n")).catch((err) => { console.error( @@ -104,6 +169,13 @@ const main = async ( `unable to write rojo config at '${rojoConfigPath}': ${err}` ); }), + fs + .writeFile(wallyRojoConfigPath, JSON.stringify(wallyRojoConfig, null, 2)) + .catch((err) => { + console.error( + `unable to write rojo config at '${wallyRojoConfigPath}': ${err}` + ); + }), ]); }; @@ -115,17 +187,25 @@ const createCLI = () => { .description("a utility to convert npm packages to wally packages") .argument("") .argument("") + .argument("") .argument("") .option( "--workspace-path ", "the path containing all workspace members" ) .action( - async (packageJson, wallyToml, rojoConfig, { workspacePath = null }) => { + async ( + packageJson, + wallyToml, + wallyRojoConfig, + rojoConfig, + { workspacePath = null } + ) => { const cwd = process.cwd(); - main( + await main( path.join(cwd, packageJson), path.join(cwd, wallyToml), + path.join(cwd, wallyRojoConfig), path.join(cwd, rojoConfig), { workspacePath: workspacePath && path.join(cwd, workspacePath),