Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions .github/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
CARGO_FILE = "Cargo.toml"
CARGO_LOCK_FILE = "Cargo.lock"
PACKAGE_JSON_FILE = "stylua-npm-bin/package.json"
PACKAGE_LOCK_JSON_FILE = "stylua-npm-bin/package-lock.json"
WASM_PACKAGE_JSON_FILE = "wasm/package.json"
PLATFORM_PACKAGE_JSON_FILES = [
f"stylua-npm-bin/platforms/{p}/package.json"
for p in ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64", "win32-x64"]
]

assert len(sys.argv) == 2, "Usage: .github/release.py <version number>"
VERSION = sys.argv[1]
Expand Down Expand Up @@ -83,15 +86,23 @@
with open(README_FILE, "w") as file:
file.write(new_readme_text)

# Update version in package.json
package_json_data = None
# Update version in package.json and its optionalDependencies
with open(PACKAGE_JSON_FILE, "r") as t:
package_json_data = json.load(t)
package_json_data["version"] = VERSION

package_json_data["version"] = VERSION
for dep in package_json_data.get("optionalDependencies", {}):
package_json_data["optionalDependencies"][dep] = VERSION
with open(PACKAGE_JSON_FILE, "w") as t:
json.dump(package_json_data, t)

# Update version in platform package.json files
for platform_pkg in PLATFORM_PACKAGE_JSON_FILES:
with open(platform_pkg, "r") as t:
data = json.load(t)
data["version"] = VERSION
with open(platform_pkg, "w") as t:
json.dump(data, t)

# Update version in wasm package.json
package_json_data = None
with open(WASM_PACKAGE_JSON_FILE, "r") as t:
Expand All @@ -101,10 +112,8 @@
with open(WASM_PACKAGE_JSON_FILE, "w") as t:
json.dump(package_json_data, t)

# Update lockfiles
# Update Cargo lockfile
subprocess.run(["cargo", "check"], check=True)
# we expect this command to fail:
subprocess.run(["npm", "install"], cwd="stylua-npm-bin", check=False)

# Run prettier
subprocess.run(
Expand All @@ -116,6 +125,7 @@
CHANGELOG_FILE,
PACKAGE_JSON_FILE,
WASM_PACKAGE_JSON_FILE,
*PLATFORM_PACKAGE_JSON_FILES,
],
check=True,
)
Expand All @@ -128,10 +138,10 @@
CHANGELOG_FILE,
README_FILE,
PACKAGE_JSON_FILE,
PACKAGE_LOCK_JSON_FILE,
WASM_PACKAGE_JSON_FILE,
CARGO_FILE,
CARGO_LOCK_FILE,
*PLATFORM_PACKAGE_JSON_FILES,
],
check=True,
)
Expand Down
54 changes: 47 additions & 7 deletions .github/workflows/npm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,57 @@ jobs:
smoketest:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
platform-dir: linux-x64
gh-artifact: stylua-linux-x86_64
- os: macos-latest
platform-dir: darwin-arm64
gh-artifact: stylua-macos-aarch64
- os: windows-latest
platform-dir: win32-x64
gh-artifact: stylua-windows-x86_64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Attempt install
run: npm install --package-locked
working-directory: stylua-npm-bin
- name: Attempt run
run: npx . --version
working-directory: stylua-npm-bin

- name: Get release version
id: version
shell: bash
run: echo "tag=v$(node -p "require('./stylua-npm-bin/package.json').version")" >> $GITHUB_OUTPUT

- name: Download and extract release binary
shell: bash
run: |
curl -fsSL \
"https://github.com/johnnymorganz/stylua/releases/download/${{ steps.version.outputs.tag }}/${{ matrix.gh-artifact }}.zip" \
-o release.zip
unzip release.zip -d "stylua-npm-bin/platforms/${{ matrix.platform-dir }}/"
rm release.zip

- name: Pack platform and main packages
shell: bash
run: |
cd "$GITHUB_WORKSPACE/stylua-npm-bin/platforms/${{ matrix.platform-dir }}"
npm pack
echo "PLATFORM_TGZ=$(pwd)/$(ls *.tgz)" >> $GITHUB_ENV

cd "$GITHUB_WORKSPACE/stylua-npm-bin"
npm pack
echo "MAIN_TGZ=$(pwd)/$(ls *.tgz)" >> $GITHUB_ENV

- name: Install in fresh test project
shell: bash
run: |
mkdir -p "$GITHUB_WORKSPACE/test-install"
cd "$GITHUB_WORKSPACE/test-install"
npm install --no-save "$PLATFORM_TGZ" "$MAIN_TGZ"

- name: Test via npx
working-directory: ${{ github.workspace }}/test-install
run: npx stylua --version
51 changes: 48 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22.x"
node-version: "24.x"
registry-url: "https://registry.npmjs.org"

- name: Build WASM
Expand All @@ -138,6 +138,7 @@ jobs:

release_npm_bin:
name: Publish binary to npm
needs: [release]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -148,15 +149,59 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22.x"
node-version: "24.x"
registry-url: "https://registry.npmjs.org"

- name: Setup README and LICENSE
run: |
cp README.md stylua-npm-bin/
cp LICENSE.md stylua-npm-bin/

- name: Publish to npm
- name: Download Linux x64 binary
uses: actions/download-artifact@v4
with:
name: stylua-linux-x86_64
path: /tmp/artifacts/linux-x64

- name: Download Linux arm64 binary
uses: actions/download-artifact@v4
with:
name: stylua-linux-aarch64
path: /tmp/artifacts/linux-arm64

- name: Download macOS x64 binary
uses: actions/download-artifact@v4
with:
name: stylua-macos-x86_64
path: /tmp/artifacts/darwin-x64

- name: Download macOS arm64 binary
uses: actions/download-artifact@v4
with:
name: stylua-macos-aarch64
path: /tmp/artifacts/darwin-arm64

- name: Download Windows x64 binary
uses: actions/download-artifact@v4
with:
name: stylua-windows-x86_64
path: /tmp/artifacts/win32-x64

- name: Extract binaries into platform packages
run: |
for PLATFORM in linux-x64 linux-arm64 darwin-x64 darwin-arm64 win32-x64; do
unzip -o /tmp/artifacts/$PLATFORM/release.zip \
-d "$GITHUB_WORKSPACE/stylua-npm-bin/platforms/$PLATFORM/"
done

- name: Publish platform packages to npm
run: |
for PLATFORM in linux-x64 linux-arm64 darwin-x64 darwin-arm64 win32-x64; do
cd "$GITHUB_WORKSPACE/stylua-npm-bin/platforms/$PLATFORM"
npm publish
done

- name: Publish main package to npm
working-directory: stylua-npm-bin
run: npm publish

Expand Down
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.5.2] - 2026-05-16

### Fixed

- Fixed npm publishing failing provenance validation due to normalization of repository URL

## [2.5.1] - 2026-05-16

### Fixed

- Fixed npm publishing by bumping Node.js from 22 to 24 in CI workflows to support npm trusted publishing

## [2.5.0] - 2026-05-16

### Added

- Luau: Added support for `const` variable assignments (`const x = 1`) and `const function` declarations ([#1102](https://github.com/JohnnyMorganz/StyLua/issues/1102))

### Changed

- The npm package `@johnnymorganz/stylua-bin` now ships pre-built binaries via platform-specific optional packages (`@johnnymorganz/stylua-bin-linux-x64`, `-linux-arm64`, `-darwin-x64`, `-darwin-arm64`, `-win32-x64`) instead of downloading the binary at install time. This makes the packages self-contained with no extra dependencies.

### Fixed

- Fixed npm publishing by bumping Node.js from 16 to 22 in CI workflows to support npm trusted publishing
- Luau: Fixed union/intersection type definitions not being hung when the type alone fits within the column width but the full line (including `=`) exceeds it ([#1104](https://github.com/JohnnyMorganz/StyLua/issues/1104))
- Luau: Fixed stray leading newlines not being removed from `local function` and `const function` declarations that have attributes (e.g. `@native`) at the start of a block ([#1109](https://github.com/JohnnyMorganz/StyLua/issues/1109))

## [2.4.1] - 2026-04-06

Expand Down Expand Up @@ -899,7 +919,10 @@ This feature is enabled by default, it can be disabled using `--no-editorconfig`

Initial alpha release

[unreleased]: https://github.com/JohnnyMorganz/StyLua/compare/v2.4.1...HEAD
[unreleased]: https://github.com/JohnnyMorganz/StyLua/compare/v2.5.2...HEAD
[2.5.2]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.5.2
[2.5.1]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.5.1
[2.5.0]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.5.0
[2.4.1]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.4.1
[2.4.0]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.4.0
[2.3.1]: https://github.com/JohnnyMorganz/StyLua/releases/tag/v2.3.1
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stylua"
version = "2.4.1"
version = "2.5.2"
authors = ["JohnnyMorganz <johnnymorganz@outlook.com>"]
description = "A code formatter for Lua"
license = "MPL-2.0"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Add the following to your `.pre-commit-config.yaml` file:

```yaml
- repo: https://github.com/JohnnyMorganz/StyLua
rev: v2.4.1
rev: v2.5.2
hooks:
- id: stylua # or stylua-system / stylua-github
```
Expand All @@ -84,7 +84,7 @@ StyLua is available on the [Docker Hub](https://hub.docker.com/r/johnnymorganz/s
If you are using Docker, the easiest way to install StyLua is:

```dockerfile
COPY --from=JohnnyMorganz/StyLua:2.4.1 /stylua /usr/bin/stylua
COPY --from=JohnnyMorganz/StyLua:2.5.2 /stylua /usr/bin/stylua
```

### Homebrew
Expand All @@ -110,7 +110,7 @@ uv tool install git+https://github.com/johnnymorganz/stylua
- [Aftman](https://github.com/LPGhatguy/aftman)

```sh
aftman add johnnymorganz/stylua@2.4.1
aftman add johnnymorganz/stylua@2.5.2
```

- A community maintained package repository. Please note, these packages are maintained by third-parties and we do not control their packaging manifests.
Expand Down
4 changes: 3 additions & 1 deletion src/formatters/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use full_moon::{
tokenizer::TokenType,
};

#[cfg(feature = "luau")]
use crate::formatters::general::format_symbol;
#[cfg(feature = "lua54")]
use crate::formatters::lua54::format_attribute;
#[cfg(feature = "luau")]
Expand All @@ -21,7 +23,7 @@ use crate::{
formatters::{
expression::{format_expression, format_var, hang_expression},
general::{
format_punctuated, format_punctuated_multiline, format_symbol, format_token_reference,
format_punctuated, format_punctuated_multiline, format_token_reference,
try_format_punctuated,
},
trivia::{
Expand Down
Loading