Skip to content

Commit 45614ff

Browse files
authored
Merge pull request #1 from jsdotlua/setup-npm-package
Setup npm package 🚀
2 parents 0a3ac87 + 6007ee0 commit 45614ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1463
-285
lines changed

.darklua-dev.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"rules": [
3+
{
4+
"rule": "convert_require",
5+
"current": {
6+
"name": "path",
7+
"sources": {
8+
"@pkg": "node_modules/.luau-aliases"
9+
}
10+
},
11+
"target": {
12+
"name": "roblox",
13+
"indexing_style": "wait_for_child",
14+
"rojo_sourcemap": "sourcemap.json"
15+
}
16+
},
17+
{
18+
"rule": "inject_global_value",
19+
"identifier": "__DEV__",
20+
"value": true
21+
},
22+
"compute_expression",
23+
"remove_unused_if_branch",
24+
"remove_unused_while",
25+
"filter_after_early_return",
26+
"remove_nil_declaration",
27+
"remove_empty_do"
28+
]
29+
}

.darklua-tests.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"rules": [
3+
"remove_comments",
4+
"remove_spaces",
5+
{
6+
"rule": "convert_require",
7+
"current": {
8+
"name": "path",
9+
"sources": {
10+
"@pkg": "node_modules/.luau-aliases"
11+
}
12+
},
13+
"target": {
14+
"name": "roblox",
15+
"rojo_sourcemap": "sourcemap.json",
16+
"indexing_style": "wait_for_child"
17+
}
18+
},
19+
{
20+
"rule": "inject_global_value",
21+
"identifier": "LUA_ENV",
22+
"value": "roblox"
23+
},
24+
{
25+
"rule": "inject_global_value",
26+
"identifier": "DEV",
27+
"value": false
28+
},
29+
{
30+
"rule": "inject_global_value",
31+
"identifier": "__DEV__",
32+
"value": false
33+
},
34+
"compute_expression",
35+
"remove_unused_if_branch",
36+
"filter_after_early_return",
37+
"convert_index_to_field",
38+
"remove_unused_while",
39+
"remove_empty_do",
40+
"remove_method_definition"
41+
]
42+
}

.darklua-wally.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"rules": [
3+
{
4+
"rule": "convert_require",
5+
"current": {
6+
"name": "path",
7+
"sources": {
8+
"@pkg": "."
9+
}
10+
},
11+
"target": {
12+
"name": "roblox",
13+
"indexing_style": "wait_for_child",
14+
"rojo_sourcemap": "./sourcemap.json"
15+
}
16+
},
17+
"compute_expression",
18+
"remove_unused_if_branch",
19+
"remove_unused_while",
20+
"filter_after_early_return",
21+
"remove_nil_declaration",
22+
"remove_empty_do"
23+
]
24+
}

.darklua.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"rules": [
3+
{
4+
"rule": "convert_require",
5+
"current": {
6+
"name": "path",
7+
"sources": {
8+
"@pkg": "node_modules/.luau-aliases"
9+
}
10+
},
11+
"target": {
12+
"name": "roblox",
13+
"indexing_style": "wait_for_child",
14+
"rojo_sourcemap": "sourcemap.json"
15+
}
16+
},
17+
{
18+
"rule": "inject_global_value",
19+
"identifier": "__DEV__",
20+
"value": false
21+
},
22+
"compute_expression",
23+
"remove_unused_if_branch",
24+
"remove_unused_while",
25+
"filter_after_early_return",
26+
"remove_nil_declaration",
27+
"remove_empty_do"
28+
]
29+
}

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# * text eol=lf
2+
3+
*.gif binary
4+
*.ico binary
5+
*.jpg binary
6+
*.png binary

.github/pull_request_template.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Closes #[issue number]
2+
3+
<!-- description of the changes -->
4+
5+
- [ ] add entry to the changelog

.github/workflows/release.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Release
2+
3+
"on":
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: The version to release starting with `v`
8+
required: true
9+
type: string
10+
release_ref:
11+
description: The branch, tag or SHA to checkout (default to latest)
12+
default: ""
13+
type: string
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
publish-package:
20+
name: Publish package
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Enable corepack
26+
run: corepack enable
27+
28+
- uses: actions/setup-node@v3
29+
with:
30+
node-version: latest
31+
registry-url: https://registry.npmjs.org
32+
cache: yarn
33+
cache-dependency-path: yarn.lock
34+
35+
- name: Install packages
36+
run: yarn install --immutable
37+
38+
- name: Run npmluau
39+
run: yarn run prepare
40+
41+
- name: Authenticate yarn
42+
run: |-
43+
yarn config set npmAlwaysAuth true
44+
yarn config set npmAuthToken $NPM_AUTH_TOKEN
45+
env:
46+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
- name: Publish to npm
49+
run: yarn npm publish --access public
50+
51+
publish-wally-package:
52+
needs: publish-package
53+
54+
name: Publish wally package
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- uses: Roblox/setup-foreman@v1
61+
with:
62+
token: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Enable corepack
65+
run: corepack enable
66+
67+
- uses: actions/setup-node@v3
68+
with:
69+
node-version: "latest"
70+
cache: "yarn"
71+
cache-dependency-path: "yarn.lock"
72+
73+
- name: Install packages
74+
run: yarn install --immutable
75+
76+
- name: Run npmluau
77+
run: yarn run prepare
78+
79+
- name: Build artifacts
80+
run: yarn run build
81+
82+
- name: Login to wally
83+
run: wally login --project-path build/wally --token ${{ secrets.WALLY_ACCESS_TOKEN }}
84+
85+
- name: Publish to wally
86+
run: wally publish --project-path build/wally
87+
88+
create-release:
89+
needs: publish-package
90+
name: Create release
91+
runs-on: ubuntu-latest
92+
outputs:
93+
upload_url: ${{ steps.create_release.outputs.upload_url }}
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Create tag
98+
run: |
99+
git fetch --tags --no-recurse-submodules
100+
if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then
101+
git tag ${{ inputs.release_tag }}
102+
git push origin ${{ inputs.release_tag }}
103+
fi
104+
105+
- name: Create release
106+
id: create_release
107+
uses: softprops/action-gh-release@v1
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
with:
111+
tag_name: ${{ inputs.release_tag }}
112+
name: ${{ inputs.release_tag }}
113+
draft: false
114+
115+
build-assets:
116+
needs: create-release
117+
name: Add assets
118+
runs-on: ubuntu-latest
119+
strategy:
120+
fail-fast: false
121+
matrix:
122+
include:
123+
- artifact-name: react-testing-library.rbxm
124+
path: build/react-testing-library.rbxm
125+
asset-type: application/octet-stream
126+
127+
- artifact-name: react-testing-library-dev.rbxm
128+
path: build/debug/react-testing-library.rbxm
129+
asset-type: application/octet-stream
130+
steps:
131+
- uses: actions/checkout@v4
132+
133+
- uses: Roblox/setup-foreman@v1
134+
with:
135+
token: ${{ secrets.GITHUB_TOKEN }}
136+
137+
- name: Enable corepack
138+
run: corepack enable
139+
140+
- uses: actions/setup-node@v3
141+
with:
142+
node-version: latest
143+
registry-url: https://registry.npmjs.org
144+
cache: yarn
145+
cache-dependency-path: yarn.lock
146+
147+
- name: Install packages
148+
run: yarn install --immutable
149+
150+
- name: Run npmluau
151+
run: yarn run prepare
152+
153+
- name: Build assets
154+
run: yarn run build
155+
156+
- name: Upload asset
157+
uses: actions/upload-artifact@v3
158+
with:
159+
name: ${{ matrix.artifact-name }}
160+
path: ${{ matrix.path }}
161+
162+
- name: Add asset to Release
163+
uses: actions/upload-release-asset@v1
164+
env:
165+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166+
with:
167+
upload_url: ${{ needs.create-release.outputs.upload_url }}
168+
asset_path: ${{ matrix.path }}
169+
asset_name: ${{ matrix.artifact-name }}
170+
asset_content_type: ${{ matrix.asset-type }}

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
"on":
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
name: Run tests
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: Roblox/setup-foreman@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Enable corepack
23+
run: corepack enable
24+
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: latest
28+
registry-url: https://registry.npmjs.org
29+
cache: yarn
30+
cache-dependency-path: yarn.lock
31+
32+
- name: Install packages
33+
run: yarn install --immutable
34+
35+
- name: Run npmluau
36+
run: yarn run prepare
37+
38+
- name: Run linter
39+
run: yarn run lint
40+
41+
- name: Verify code style
42+
run: yarn run style-check

.gitignore

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
Packages/*
2-
!Packages/.robloxrc
3-
4-
rotriever.lock
5-
roblox.toml
6-
*.rbxmx
7-
*.rbxm
8-
9-
.vscode/launch.json
10-
.vscode/settings.json
11-
.vscode/tasks.json
12-
.idea
1+
/site
2+
3+
/*.rbxl
4+
/*.rbxlx
5+
/*.rbxl.lock
6+
/*.rbxlx.lock
7+
/*.rbxm
8+
/*.rbxmx
9+
10+
/temp
11+
/node_modules
12+
/build
13+
14+
.yarn
15+
16+
/globalTypes.d.lua
17+
18+
**/sourcemap.json

.luau-analyze.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"luau-lsp.require.mode": "relativeToFile",
3+
"luau-lsp.require.directoryAliases": {
4+
"@pkg": "node_modules/.luau-aliases"
5+
}
6+
}

0 commit comments

Comments
 (0)