Skip to content

Commit aa5856a

Browse files
authored
Merge pull request #1 from jsdotlua/setup-npm-package
Setup npm package πŸš€
2 parents 9e76320 + 0bf1fdd commit aa5856a

18 files changed

+644
-5
lines changed

β€Ž.darklua-wally.jsonβ€Ž

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"process": [
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+
"process": [
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+
}
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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+
11+
release_ref:
12+
description: "The branch, tag or SHA to checkout (default to latest)"
13+
default: ""
14+
type: string
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
publish-package:
21+
name: Publish package
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Enable corepack
28+
run: corepack enable
29+
30+
- uses: actions/setup-node@v3
31+
with:
32+
node-version: "latest"
33+
cache: "yarn"
34+
cache-dependency-path: "yarn.lock"
35+
36+
- name: Install packages
37+
run: yarn install --immutable
38+
39+
- name: Run npmluau
40+
run: yarn run prepare
41+
42+
- name: Authenticate yarn
43+
run: |
44+
yarn config set npmAlwaysAuth true
45+
yarn config set npmScopes.jsdotlua.npmAuthToken $NPM_AUTH_TOKEN
46+
env:
47+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
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 assets
80+
run: yarn run build-assets
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+
91+
name: Create release
92+
runs-on: ubuntu-latest
93+
94+
outputs:
95+
upload_url: ${{ steps.create_release.outputs.upload_url }}
96+
97+
steps:
98+
- uses: actions/checkout@v4
99+
100+
- name: Create tag
101+
run: |
102+
git fetch --tags --no-recurse-submodules
103+
if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then
104+
git tag ${{ inputs.release_tag }}
105+
git push origin ${{ inputs.release_tag }}
106+
fi
107+
108+
- name: Create release
109+
id: create_release
110+
uses: softprops/action-gh-release@v1
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
tag_name: ${{ inputs.release_tag }}
115+
name: ${{ inputs.release_tag }}
116+
draft: false
117+
118+
build-assets:
119+
needs: create-release
120+
121+
name: Add assets
122+
runs-on: ubuntu-latest
123+
124+
strategy:
125+
fail-fast: false
126+
matrix:
127+
include:
128+
- artifact-name: chalk.rbxm
129+
path: build/chalk.rbxm
130+
asset-type: application/octet-stream
131+
132+
- artifact-name: chalk.lua
133+
path: build/chalk.lua
134+
asset-type: text/plain
135+
136+
steps:
137+
- uses: actions/checkout@v4
138+
139+
- uses: Roblox/setup-foreman@v1
140+
with:
141+
token: ${{ secrets.GITHUB_TOKEN }}
142+
143+
- name: Enable corepack
144+
run: corepack enable
145+
146+
- uses: actions/setup-node@v3
147+
with:
148+
node-version: "latest"
149+
cache: "yarn"
150+
cache-dependency-path: "yarn.lock"
151+
152+
- name: Install packages
153+
run: yarn install --immutable
154+
155+
- name: Run npmluau
156+
run: yarn run prepare
157+
158+
- name: Build assets
159+
run: yarn run build-assets
160+
161+
- name: Upload asset
162+
uses: actions/upload-artifact@v3
163+
with:
164+
name: ${{ matrix.artifact-name }}
165+
path: ${{ matrix.path }}
166+
167+
- name: Add asset to Release
168+
uses: actions/upload-release-asset@v1
169+
env:
170+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171+
with:
172+
upload_url: ${{ needs.create-release.outputs.upload_url }}
173+
asset_path: ${{ matrix.path }}
174+
asset_name: ${{ matrix.artifact-name }}
175+
asset_content_type: ${{ matrix.asset-type }}

β€Ž.github/workflows/test.ymlβ€Ž

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: Roblox/setup-foreman@v1
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Enable corepack
24+
run: corepack enable
25+
26+
- uses: actions/setup-node@v3
27+
with:
28+
node-version: "latest"
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
43+
44+
- name: Build assets
45+
run: yarn run build-assets

β€Ž.gitignoreβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ roblox.toml
99
# Editor files
1010
.vscode/launch.json
1111
.idea
12+
13+
**/sourcemap.json
14+
**/node_modules
15+
/build
16+
/roblox
17+
.yarn

β€Ž.npmignoreβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/.*
2+
/bin
3+
/Packages
4+
**/.robloxrc
5+
rotriever.toml
6+
7+
/.github/
8+
/.vscode/
9+
10+
/roblox
11+
/build
12+
13+
/*.json
14+
/*.toml
15+
/*.yml
16+
/*.md
17+
/*.js
18+
/*.tgz
19+
20+
/scripts
21+
/globalTypes.d.lua
22+
**/sourcemap.json
23+
**/*.project.json
24+
25+
/test
26+
27+
**/__tests__
28+
**/__tests__
29+
**/__testUtils__
30+
**/__fixtures__
31+
**/TestMatchers
32+
**/*.test.lua
33+
**/*.spec.lua
34+
**/jest.config.lua
35+
36+
**/*.rbxl
37+
**/*.rbxlx
38+
**/*.rbxl.lock
39+
**/*.rbxlx.lock
40+
**/*.rbxm
41+
**/*.rbxmx

β€Ž.vscode/settings.jsonβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"luau-lsp.require.mode": "relativeToFile",
3+
"luau-lsp.types.roblox": true,
4+
"luau-lsp.sourcemap.autogenerate": false,
5+
"luau-lsp.sourcemap.enabled": false,
6+
"luau-lsp.completion.imports.requireStyle": "alwaysRelative",
7+
"luau-lsp.completion.imports.enabled": true,
8+
"luau-lsp.require.directoryAliases": {
9+
"@pkg": "node_modules/.luau-aliases"
10+
}
11+
}

β€Ž.yarnrc.ymlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

β€Ždefault.project.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "LuaChalk",
2+
"name": "chalk",
33
"tree": {
44
"$path": "src"
55
}

β€Žforeman.tomlβ€Ž

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[tools]
2-
rotrieve = { source = "roblox/rotriever", version = "=0.5.4" }
3-
selene = { source = "Roblox/Kampfkarren-selene", version = "0.25.0" }
4-
stylua = { source = "Roblox/JohnnyMorganz-StyLua", version = "0.18.1" }
2+
selene = { source = "Kampfkarren/selene", version = "=0.25.0" }
3+
stylua = { source = "JohnnyMorganz/StyLua", version = "=0.18.1" }
4+
luau-lsp = { github = "johnnymorganz/luau-lsp", version = "=1.27.1"}
5+
darklua = { github = "seaofvoices/darklua", version = "=0.12.1" }
6+
wally = { github = "UpliftGames/wally", version = "=0.3.2" }

0 commit comments

Comments
Β (0)