diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml new file mode 100644 index 0000000..4831563 --- /dev/null +++ b/.github/workflows/commit.yml @@ -0,0 +1,76 @@ +name: Validate Commit + +on: + push: + +jobs: + + validate: + runs-on: windows-latest + + strategy: + matrix: + scene: [main] + include: + - name: main + steps: + # Checkout your Git repo + - uses: actions/checkout@v2 + + # Install foreman and all foreman tools + - uses: ok-nick/setup-aftman@v0.4.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Install wally packages + - name: install wally packages + run: wally install + + - name: generate sourcemap + run: rojo sourcemap dev.project.json --output sourcemap.json + + - name: export wally package types + run: wally-package-types --sourcemap sourcemap.json Packages + + - name: Install testing files + shell: bash + run: | + # type definitions + if [ ! -d "types" ]; then + mkdir "types" + fi + curl -L "https://gist.github.com/nightcycle/50ca8f42147077b8f584b503030c8500/raw" > "types/testEZ.d.lua" + curl -L "https://gist.github.com/nightcycle/ae7ea3376337512772d1d2b314ef467b/raw" > "types/remodel.d.lua" + curl -L "https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/main/scripts/globalTypes.d.lua" > "types/globalTypes.d.lua" + + # lint definitions + if [ ! -d "lints" ]; then + mkdir "lints" + fi + curl -L "https://gist.github.com/nightcycle/a57e04de443dfa89bd08c8eb001b03c6/raw" > "lints/lua51.yml" + curl -L "https://gist.github.com/nightcycle/93c4b9af5bbf4ed09f39aa908dffccd0/raw" > "lints/luau.yml" + + # apply code styling + - name: style src scripts + run: stylua src + + # - name: style built scripts + # shell: bash + # run: | + # if [ ! -d "out" ]; then + # mkdir "out" + # fi + # stylua out + + - name: generate sourcemap + run: rojo sourcemap dev.project.json --output sourcemap.json + + # Test validity + - name: typecheck src files + run: luau-lsp analyze --sourcemap="sourcemap.json" --ignore="Packages/**" --ignore="src/Server/NPC/Animate.server.lua" --ignore="**/Packages/**" --ignore="*.spec.luau" --ignore="out/**" --flag:LuauTypeInferIterationLimit=0 --flag:LuauCheckRecursionLimit=0 --flag:LuauTypeInferRecursionLimit=0 --flag:LuauTarjanChildLimit=0 --flag:LuauTypeInferTypePackLoopLimit=0 --flag:LuauVisitRecursionLimit=0 --definitions=types/globalTypes.d.lua src + + - name: lint src files + run: selene src + + # - name: lint built files + # run: selene out \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a6bc939 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,166 @@ +name: Build and Publish + +on: + release: + types: [published] + +jobs: + get_published_release: + runs-on: ubuntu-latest + + outputs: + release_id: ${{ steps.release_info.outputs.release_id }} + upload_url: ${{ steps.release_info.outputs.upload_url }} + tag_name: ${{ steps.release_info.outputs.tag_name }} + repo_desc: ${{ steps.release_info.outputs.repo_desc }} + repo_name: ${{ steps.release_info.outputs.repo_name }} + repo_owner_name: ${{ steps.release_info.outputs.repo_owner_name }} + steps: + - name: Set Release Info + id: release_info + run: | + echo "::set-output name=tag_name::${{ github.event.release.tag_name }}" + echo "::set-output name=release_id::${{ github.event.release.id }}" + echo "::set-output name=upload_url::${{ github.event.release.upload_url }}" + + repo_owner_name=${{ github.repository_owner }} + echo "::set-output name=repo_owner_name::$repo_owner_name" + + repo_name=${{ github.repository }} + forward_repo_pattern="${repo_owner_name}/" + empty_str="" + repo_name="${repo_name/${forward_repo_pattern}/${empty_str}}" + echo "::set-output name=repo_name::$repo_name" + + # Use the GitHub API to fetch the repository description + description_prefix="\"description\":" + curl -L "https://api.github.com/repos/${repo_owner_name}/${repo_name}" > "desc.text" + desc=$( "types/testEZ.d.lua" + curl -L "https://gist.github.com/nightcycle/ae7ea3376337512772d1d2b314ef467b/raw" > "types/remodel.d.lua" + curl -L "https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/main/scripts/globalTypes.d.lua" > "types/globalTypes.d.lua" + + # lint definitions + if [ ! -d "lints" ]; then + mkdir "lints" + fi + curl -L "https://gist.github.com/nightcycle/a57e04de443dfa89bd08c8eb001b03c6/raw" > "lints/lua51.yml" + curl -L "https://gist.github.com/nightcycle/93c4b9af5bbf4ed09f39aa908dffccd0/raw" > "lints/luau.yml" + + # apply code styling + - name: style src scripts + run: stylua src + + - name: style built scripts + shell: bash + run: | + if [ ! -d "out" ]; then + mkdir "out" + fi + stylua out + + - name: generate sourcemap + run: rojo sourcemap dev.project.json --output sourcemap.json + + # Test validity + - name: typecheck src files + run: luau-lsp analyze --sourcemap="sourcemap.json" --ignore="Packages/**" --ignore="**/Packages/**" --ignore="*.spec.luau" --ignore="out/**" --flag:LuauTypeInferIterationLimit=0 --flag:LuauCheckRecursionLimit=0 --flag:LuauTypeInferRecursionLimit=0 --flag:LuauTarjanChildLimit=0 --flag:LuauTypeInferTypePackLoopLimit=0 --flag:LuauVisitRecursionLimit=0 --definitions=types/globalTypes.d.lua src + + - name: lint src files + run: selene src + + - name: Update version and labels + shell: bash + run: | + repo_owner="${{needs.get_published_release.outputs.repo_owner_name}}" + repo_name="${{needs.get_published_release.outputs.repo_name}}" + repo_desc=${{needs.get_published_release.outputs.repo_desc}} + goal_version_str="${{needs.get_published_release.outputs.tag_name}}" + + # remove letters + goal_version_str=$(echo "$goal_version_str" | sed 's/[a-zA-Z]//g') + + # read file + wally_toml_contents=$( "wally.toml" + + # read json file + default_json_contents=$( "default.project.json" + + - name: Build place file + run: | + rojo build dev.project.json -o Package.rbxl + + - name: Upload Package.rbxl file to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ needs.get_published_release.outputs.upload_url }} + asset_path: Package.rbxl + asset_name: Package.rbxl + asset_content_type: application/octet-stream + + - name: Publish release to Wally + shell: bash + run: | + wally login --token "${{secrets.WALLY_TOKEN}}" + wally publish \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a789fdb --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ + + +# Directories +out/** +Packages/** +types +lints +tests/lsp/** +tests/selene/** + +# Files +sourcemap.json +wally.lock +package-lock.json +keys.txt + +# File types +*.lock +*.gitconfig +*.rbxlx +*.lock + diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..cb039b8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + "recommendations": [ + "emeraldwalk.runonsave", + "formulahendry.code-runner", + "tamasfe.even-better-toml", + "johnnymorganz.luau-lsp", + "johnnymorganz.stylua", + "redhat.vscode-yaml", + "ms-toolsai.jupyter" + ] +} \ No newline at end of file diff --git a/.vscode/package-header.code-snippets b/.vscode/package-header.code-snippets new file mode 100644 index 0000000..7358604 --- /dev/null +++ b/.vscode/package-header.code-snippets @@ -0,0 +1,80 @@ +{ + "import scripts": { + "prefix": "import scripts", + "body": [ + "local $name = require(game:GetService(\"ServerStorage\"):WaitForChild(\"Scripts\"):WaitForChild(\"$name\")$0)" + ], + "description": "Imports a scripts module.", + "scope": "lua,luau" + }, + "import sub-scripts": { + "prefix": "import sub-scripts", + "body": [ + "local $name${sub} = require(game:GetService(\"ServerStorage\"):WaitForChild(\"Scripts\"):WaitForChild(\"$name\"):WaitForChild(\"$sub\")$0)" + ], + "description": "Imports a scripts sub-module.", + "scope": "lua,luau" + }, + "import server": { + "prefix": "import server", + "body": [ + "local $name = require(game:GetService(\"ServerScriptService\"):WaitForChild(\"Server\"):WaitForChild(\"$name\")$0)" + ], + "description": "Imports a server module.", + "scope": "lua,luau" + }, + "import child": { + "prefix": "import child", + "body": [ + "local $name = require(script:WaitForChild(\"$name\")$0)" + ], + "description": "Imports a child module.", + "scope": "lua,luau" + }, + "import etype": { + "prefix": "import etype", + "body": [ + "export type $name = $name.$name" + ], + "description": "Unpacks and exports a type.", + "scope": "lua,luau" + }, + "import ptype": { + "prefix": "import ptype", + "body": [ + "type $name = $name.$name" + ], + "description": "Unpacks and a type.", + "scope": "lua,luau" + }, + "import packages": { + "prefix": "import package", + "body": [ + "local $name = require(_Packages:WaitForChild(\"$name\"))" + ], + "description": "Imports a package module.", + "scope": "lua,luau" + }, + "import header": { + "prefix": "import header", + "body": [ + "--!strict", + "--!native", + "local _Package = script", + "local _Packages = _Package.Parent", + "-- Services", + "-- stylua: ignore start", + "-- Packages", + "-- Modules", + "-- stylua: ignore end", + "-- Types", + "-- Constants", + "-- Variables", + "-- References", + "-- Private Functions", + "-- Class", + ], + "description": "A basic header for a file.", + "scope": "lua,luau" + }, +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5b0d831 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,36 @@ +{ + "editor.formatOnSave": true, + "files.autoSave": "onFocusChange", + "luau-lsp.sourcemap.rojoProjectFile": "dev.project.json", + "files.exclude": { + "**lints": true, + "**types": true, + "sourcemap.json": true, + "Packages": true, + }, + "emeraldwalk.runonsave": { + "shell": "C:\\Program Files\\Git\\bin\\bash.exe", + "commands": [ + { + "match": ".lua", + "isAsync": false, + "cmd": "rojo sourcemap dev.project.json --output sourcemap.json" + }, + { + "match": ".luau", + "isAsync": false, + "cmd": "rojo sourcemap dev.project.json --output sourcemap.json" + }, + { + "match": "pseudo-enum.toml", + "isAsync": false, + "cmd": "pseudo-enum build" + }, + { + "match": "wally.toml", + "isAsync": false, + "cmd": "sh scripts/workspace/wally-install.sh" + }, + ] + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b6fd74f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,32 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "rojo-build", + "type": "shell", + "command": "sh scripts/workspace/rojo-build.sh", + "problemMatcher": [], + "runOptions": { + "runOn": "folderOpen" + } + }, + { + "label": "rojo-serve", + "type": "shell", + "command": "rojo serve dev.project.json", + "problemMatcher": [], + "runOptions": { + "runOn": "folderOpen" + } + }, + { + "label": "download types", + "type": "shell", + "command": "sh scripts/test/download.sh", + "problemMatcher": [], + "runOptions": { + "runOn": "folderOpen" + } + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/aftman.toml b/aftman.toml new file mode 100644 index 0000000..e62ef36 --- /dev/null +++ b/aftman.toml @@ -0,0 +1,8 @@ +[tools] +wally = "UpliftGames/wally@0.3.2" +wally-package-types = "JohnnyMorganz/wally-package-types@1.3.1" +selene = "kampfkarren/selene@0.27.1" +rojo = "rojo-rbx/rojo@7.4.1" +luau-lsp = "JohnnyMorganz/luau-lsp@1.32.0" +stylua = "JohnnyMorganz/StyLua@0.20.0" +moonwave = "evaera/moonwave@1.1.3" \ No newline at end of file diff --git a/default.project.json b/default.project.json new file mode 100644 index 0000000..992d664 --- /dev/null +++ b/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "package", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/dev.project.json b/dev.project.json new file mode 100644 index 0000000..859c021 --- /dev/null +++ b/dev.project.json @@ -0,0 +1,15 @@ +{ + "name": "package", + "tree": { + "$className": "DataModel", + "ReplicatedStorage": { + "$className": "ReplicatedStorage", + "Packages": { + "$path": "Packages", + "package": { + "$path": "src" + } + } + } + } + } \ No newline at end of file diff --git a/scripts/testing/all.sh b/scripts/testing/all.sh new file mode 100644 index 0000000..1bb2566 --- /dev/null +++ b/scripts/testing/all.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +sh scripts/testing/download.sh +sh scripts/testing/lsp.sh src +selene src + diff --git a/scripts/testing/download.sh b/scripts/testing/download.sh new file mode 100644 index 0000000..23e75b3 --- /dev/null +++ b/scripts/testing/download.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# type definitions +if [ ! -d "types" ]; then + mkdir "types" +fi +curl -L "https://gist.github.com/nightcycle/50ca8f42147077b8f584b503030c8500/raw" > "types/testEZ.d.lua" +curl -L "https://gist.github.com/nightcycle/ae7ea3376337512772d1d2b314ef467b/raw" > "types/remodel.d.lua" +curl -L "https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/main/scripts/globalTypes.d.lua" > "types/globalTypes.d.lua" + +# lint definitions +if [ ! -d "lints" ]; then + mkdir "lints" +fi +curl -L "https://gist.github.com/nightcycle/a57e04de443dfa89bd08c8eb001b03c6/raw" > "lints/lua51.yml" +curl -L "https://gist.github.com/nightcycle/93c4b9af5bbf4ed09f39aa908dffccd0/raw" > "lints/luau.yml" +# curl -L "https://gist.github.com/nightcycle/e8c4a9a1d71cfd1a1fff59cad84156d1/raw" > "lints/roblox.yml" \ No newline at end of file diff --git a/scripts/testing/lsp.sh b/scripts/testing/lsp.sh new file mode 100644 index 0000000..eb28f45 --- /dev/null +++ b/scripts/testing/lsp.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +luau-lsp analyze --sourcemap="sourcemap.json" --ignore="Packages/**" --ignore="**/Packages/**" --ignore="*.spec.luau" --ignore="out/**" --flag:LuauTypeInferIterationLimit=0 --flag:LuauCheckRecursionLimit=0 --flag:LuauTypeInferRecursionLimit=0 --flag:LuauTarjanChildLimit=0 --flag:LuauTypeInferTypePackLoopLimit=0 --flag:LuauVisitRecursionLimit=0 --definitions=types/globalTypes.d.lua src \ No newline at end of file diff --git a/scripts/testing/test-runner.lua b/scripts/testing/test-runner.lua new file mode 100644 index 0000000..48170f3 --- /dev/null +++ b/scripts/testing/test-runner.lua @@ -0,0 +1,82 @@ +--!strict +-- Services +-- Packages +local TestEZ = require(game:GetService("ReplicatedStorage"):WaitForChild("Packages"):WaitForChild("TestEZ")) +-- Types +-- Constants +-- Variables +-- References +local Client = game:GetService("ReplicatedStorage"):WaitForChild("Client") :: Folder +local Shared = game:GetService("ReplicatedStorage"):WaitForChild("Shared") :: Folder +local Server = game:GetService("ServerScriptService"):WaitForChild("Server") :: Folder + +type TestData = { + children: { [number]: TestData }, + errors: { [number]: string }, + planNode: TestData?, + plan: TestData, + phrase: string?, + status: "Failure" | "Success" | nil, +} + +local result = "test-run result:" + +function parseResults(data: TestData, path: string) + if data.planNode and data.status then + if data.planNode.phrase then + path ..= "/" .. data.planNode.phrase + if #data.children == 0 then + if path then + local pathKeys = path:split("/") + local finalKeys = {} + for i, key in ipairs(pathKeys) do + if finalKeys[#finalKeys] ~= key and key ~= "" then + table.insert(finalKeys, key) + end + end + local finalPath = table.concat(finalKeys, "/") + local basePath = "\n[" .. data.status:lower() .. "]:[" .. finalPath .. "]" + if #data.errors > 0 then + for i, errorMessage in ipairs(data.errors) do + local finalLine = errorMessage:split("\n")[1] + local content = (finalLine:split(":")[3]):sub(2) + content = content:gsub('"', "'") + result ..= basePath .. ':["' .. content .. '"]' + end + else + result ..= basePath + end + end + end + end + end + for i, child in ipairs(data.children) do + parseResults(child, path) + end +end + +-- Class +function test() + local function testDomain(domain: Folder) + local domainPath = domain:GetFullName() + for i, inst in ipairs(domain:GetDescendants()) do + if inst:IsA("ModuleScript") and inst.Name:find(".spec") then + TestEZ.run(inst, function(data: TestData) + local modPath = inst:GetFullName() + local filteredPath = modPath:gsub(domainPath, "") + local path = filteredPath:gsub(inst.Name, ""):gsub("%.", "/"):gsub("//", "/") + -- print(inst.Name, ":", filteredPath, ": ", path) + parseResults(data, domain.Name:lower() .. path) + end) + end + end + end + testDomain(Client) + testDomain(Shared) + testDomain(Server) + + error(result) + -- return result +end + +return test() diff --git a/scripts/testing/unit-test.sh b/scripts/testing/unit-test.sh new file mode 100644 index 0000000..8cd4ca2 --- /dev/null +++ b/scripts/testing/unit-test.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +run-in-roblox --place scene/main/build.rbxl --script "scripts/test/test-runner.lua" > tests/unit-test.txt +failure_count=$(grep -o -w "failure" "tests/unit-test.txt" | wc -l) +success_count=$(grep -o -w "success" "tests/unit-test.txt" | wc -l) +skip_count=$(grep -o -w "skipped" "tests/unit-test.txt" | wc -l) +test_count=$((failure_count + success_count)) +if [ $skip_count -ne 0 ]; then + echo "unit-test results: ${success_count}/${test_count}, ${failure_count} failed, ${skip_count} skipped" +else + echo "unit-test results: ${success_count}/${test_count}, ${failure_count} failed" +fi diff --git a/scripts/workspace/pseudo-enum.sh b/scripts/workspace/pseudo-enum.sh new file mode 100644 index 0000000..a107d7b --- /dev/null +++ b/scripts/workspace/pseudo-enum.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +pseudo-enum build \ No newline at end of file diff --git a/scripts/workspace/rojo-build.sh b/scripts/workspace/rojo-build.sh new file mode 100644 index 0000000..7da9ccc --- /dev/null +++ b/scripts/workspace/rojo-build.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +rojo build --output package.rbxl dev.project.json diff --git a/scripts/workspace/rojo-serve.sh b/scripts/workspace/rojo-serve.sh new file mode 100644 index 0000000..235cfc6 --- /dev/null +++ b/scripts/workspace/rojo-serve.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +rojo serve dev.project.json \ No newline at end of file diff --git a/scripts/workspace/rojo-sourcemap.sh b/scripts/workspace/rojo-sourcemap.sh new file mode 100644 index 0000000..3a30075 --- /dev/null +++ b/scripts/workspace/rojo-sourcemap.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +rojo sourcemap dev.project.json --output sourcemap.json \ No newline at end of file diff --git a/scripts/workspace/wally-install.sh b/scripts/workspace/wally-install.sh new file mode 100644 index 0000000..d230493 --- /dev/null +++ b/scripts/workspace/wally-install.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +wally install +rojo sourcemap dev.project.json --output sourcemap.json +wally-package-types --sourcemap sourcemap.json Packages \ No newline at end of file diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..d8cde46 --- /dev/null +++ b/selene.toml @@ -0,0 +1,17 @@ +std = "lints/luau+roblox" +exclude = [ + "out/*", + "*.spec.lua", + "*.spec.luau", + "*.remodel.lua", + "*.rbxmk.lua", + "*.d.lua", + "*.story.lua", + "*.story.luau", + "gamework/*", + "scripts/*", +] +[lints] +unused_variable = "allow" +empty_if = "allow" +if_same_then_else = "allow" diff --git a/src/init.luau b/src/init.luau new file mode 100644 index 0000000..8ed4aa1 --- /dev/null +++ b/src/init.luau @@ -0,0 +1,15 @@ +--!strict +--!native +local _Package = script +local _Packages = _Package.Parent +-- Services +-- stylua: ignore start +-- Packages +-- Modules +-- stylua: ignore end +-- Types +-- Constants +-- Variables +-- References +-- Private Functions +-- Class diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..350d6a2 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,10 @@ +column_width = 110 +line_endings = "Unix" +indent_type = "Tabs" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = false \ No newline at end of file diff --git a/wally.toml b/wally.toml new file mode 100644 index 0000000..d44db3d --- /dev/null +++ b/wally.toml @@ -0,0 +1,18 @@ +[package] +name = "nightcycle/package" +description = "A package!" +version = "0.1.0" +authors = ["CJ Oyer "] +realm = "shared" +registry = "https://github.com/upliftgames/wally-index" +exclude = ["Packages", ".vscode"] + +[dependencies] +Draw = "nightcycle/draw@1.0.6" +Maid = "nightcycle/maid@2.0.0" +ServiceProxy = "nightcycle/service-proxy@1.0.0" +Signal = "nightcycle/signal@1.0.2" +Spring = "nightcycle/spring@1.0.0" +TableUtil = "nightcycle/table-util@2.0.0" +HashUtil = "boatbomber/hashlib@1.0.0" +Queue = "nightcycle/queue@2.3.0"