Skip to content

Commit

Permalink
refactor: move to Biome (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari authored Oct 2, 2023
1 parent 93fbea1 commit 1173774
Show file tree
Hide file tree
Showing 419 changed files with 712 additions and 430 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
run: ./crates/rome_fmt/scripts/build.sh
run: ./crates/biome_fmt/scripts/build.sh

- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
registry-url: "https://registry.npmjs.org"

- run: |
cd crates/rome_fmt/pkg
cd crates/biome_fmt/pkg
npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -48,15 +48,15 @@ jobs:
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
run: ./crates/rome_fmt/scripts/build.sh
run: ./crates/biome_fmt/scripts/build.sh

- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
registry-url: "https://npm.pkg.github.com"

- run: |
cd crates/rome_fmt/pkg
cd crates/biome_fmt/pkg
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -75,13 +75,13 @@ jobs:
- name: Build wasm
run: |
# build for JS API
./crates/rome_fmt/scripts/build.sh
./crates/biome_fmt/scripts/build.sh
- name: Package
run: cd crates/rome_fmt/pkg && npm pack
run: cd crates/biome_fmt/pkg && npm pack

- name: Release
uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
with:
files: |
crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz
crates/biome_fmt/pkg/wasm-fmt-biome_fmt-*.tgz
62 changes: 48 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,70 @@ jobs:
- run: cargo check
- run: cargo test

wasm-test:
name: Wasm test
wasm-build:
name: Wasm build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build wasm
run: ./crates/rome_fmt/scripts/build.sh
run: ./crates/biome_fmt/scripts/build.sh

- name: npm pack
run: cd crates/biome_fmt/pkg && npm pack

- name: Upload
uses: actions/upload-artifact@v3
with:
name: build
path: crates/biome_fmt/pkg

node-test:
runs-on: ubuntu-latest
needs: wasm-build
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build
path: crates/biome_fmt/pkg/

- uses: actions/setup-node@v3
with:
node-version-file: ".node-version"

- name: Node Test
run: node --test
- run: node --test

deno-test:
runs-on: ubuntu-latest
needs: wasm-build
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build
path: crates/biome_fmt/pkg/

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Deno Test
run: deno test --allow-read

- name: Package
run: cd crates/rome_fmt/pkg && npm pack
- run: deno test --allow-read

- name: Upload
uses: actions/upload-artifact@v3
bun-test:
runs-on: ubuntu-latest
needs: wasm-build
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: npm
path: crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz
name: build
path: crates/biome_fmt/pkg/

- uses: oven-sh/setup-bun@v1
name: Install bun

- run: bun test test_bun
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/Cargo.lock
.DS_Store
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"deno.enable": true,
"deno.enablePaths": [
"./crates/rome_fmt/test_deno"
"./crates/biome_fmt/test_deno"
]
}
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ resolver = "2"

[workspace.package]
authors = ["magic-akari <akari.ccino@gmail.com>"]
description = "JavaScript/TypeScript formatter powered by wasm ported from Rome"
description = "JavaScript/TypeScript formatter powered by wasm ported from Biome"
edition = "2021"
homepage = "https://github.com/wasm-fmt/rome_fmt"
homepage = "https://github.com/wasm-fmt/biome_fmt"
keywords = [
"wasm",
"JavaScript",
"TypeScript",
"JSX",
"TSX",
"formatter",
"Rome",
"Biome",
]
license = "MIT"
readme = "README.md"
repository = "https://github.com/wasm-fmt/rome_fmt"
repository = "https://github.com/wasm-fmt/biome_fmt"
version = "0.0.2"


[workspace.dependencies]
rome_formatter = { version = "0.0.1" }
rome_js_formatter = { version = "0.0.2" }
rome_js_parser = { version = "0.0.1" }
rome_js_syntax = { version = "0.0.1" }
serde = { version = "1.0" }
serde_json = { version = "1.0" }
wasm-bindgen = "0.2.87"
biome_formatter = "0.1.0"
biome_js_formatter = "0.1.0"
biome_js_parser = "0.1.0"
biome_js_syntax = "0.1.0"
serde = { version = "1.0" }
serde_json = { version = "1.0" }
wasm-bindgen = "0.2.87"

[profile.release]
lto = true
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[![Test](https://github.com/wasm-fmt/rome_fmt/actions/workflows/test.yml/badge.svg)](https://github.com/wasm-fmt/rome_fmt/actions/workflows/test.yml)
[![npm](https://img.shields.io/npm/v/@wasm-fmt/rome_fmt)](https://www.npmjs.com/package/@wasm-fmt/rome_fmt)
[![Test](https://github.com/wasm-fmt/biome_fmt/actions/workflows/test.yml/badge.svg)](https://github.com/wasm-fmt/biome_fmt/actions/workflows/test.yml)
[![npm](https://img.shields.io/npm/v/@wasm-fmt/biome_fmt)](https://www.npmjs.com/package/@wasm-fmt/biome_fmt)

# Install

```bash
npm install @wasm-fmt/rome_fmt
npm install @wasm-fmt/biome_fmt
```

# Usage

```javascript
import init, { format } from "@wasm-fmt/rome_fmt";
import init, { format } from "@wasm-fmt/biome_fmt";

await init();

Expand All @@ -23,7 +23,7 @@ console.log(formatted);
For Vite users:

```JavaScript
import init, { format } from "@wasm-fmt/rome_fmt/vite";
import init, { format } from "@wasm-fmt/biome_fmt/vite";

// ...
```
10 changes: 5 additions & 5 deletions crates/rome_fmt/Cargo.toml → crates/biome_fmt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "rome_fmt"
name = "biome_fmt"
publish = true
repository.workspace = true
version.workspace = true

[dependencies]
rome_formatter = { workspace = true }
rome_js_formatter = { workspace = true }
rome_js_parser = { workspace = true }
rome_js_syntax = { workspace = true }
biome_formatter = { workspace = true }
biome_js_formatter = { workspace = true }
biome_js_parser = { workspace = true }
biome_js_syntax = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde-wasm-bindgen = "0.6"
serde_json = { workspace = true, features = ["preserve_order"] }
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions crates/biome_fmt/extra/vite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import init from "./biome_fmt.js";
import wasm from "./biome_fmt_bg.wasm?url";

export default function __wbg_init(input = wasm) {
return init(input);
}

export * from "./biome_fmt.js";
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/crates/rome_fmt/pkg/rome_fmt.js b/crates/rome_fmt/pkg/rome_fmt.js
index 84a0ed6..46adb67 100644
--- a/crates/rome_fmt/pkg/rome_fmt.js
+++ b/crates/rome_fmt/pkg/rome_fmt.js
@@ -199,11 +199,11 @@ function debugString(val) {
diff --git a/crates/biome_fmt/pkg/biome_fmt.js b/crates/biome_fmt/pkg/biome_fmt.js
index 50397c4..a477bc0 100644
--- a/crates/biome_fmt/pkg/biome_fmt.js
+++ b/crates/biome_fmt/pkg/biome_fmt.js
@@ -190,11 +190,11 @@ function debugString(val) {
}
/**
* @param {string} src
Expand All @@ -17,7 +17,7 @@ index 84a0ed6..46adb67 100644
let deferred4_0;
let deferred4_1;
try {
@@ -503,8 +503,17 @@ async function __wbg_init(input) {
@@ -431,8 +431,17 @@ async function __wbg_init(input) {
}
const imports = __wbg_get_imports();

Expand Down
16 changes: 16 additions & 0 deletions crates/biome_fmt/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cd $(dirname $0)/..
crates_dir=$(pwd)

cd ../..
wasm-pack build --target=web --scope=wasm-fmt crates/biome_fmt
cp README.md LICENSE crates/biome_fmt/pkg/

cd $crates_dir
# backup biome_fmt.js
cp ./pkg/biome_fmt.js ./pkg/biome_fmt.js.bak

git apply ./patch/biome_fmt.patch

cp -R ./extra/. ./pkg/

./scripts/package.mjs ./pkg/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# assert current dir is crates/rome_fmt
# assert current dir is crates/biome_fmt
cd $(dirname $0)/..
crates_dir=$(pwd)

Expand All @@ -10,11 +10,11 @@ tmp_dir=$(mktemp -d)
cd $tmp_dir
git init

cp $crates_dir/pkg/rome_fmt.js.bak $tmp_dir/rome_fmt.js
cp $crates_dir/pkg/biome_fmt.js.bak $tmp_dir/biome_fmt.js
git add -f .
git commit -m "init"

cp $crates_dir/pkg/rome_fmt.js $tmp_dir/rome_fmt.js
cp $crates_dir/pkg/biome_fmt.js $tmp_dir/biome_fmt.js
git add -f .

git diff \
Expand All @@ -24,6 +24,6 @@ git diff \
--no-ext-diff \
--src-prefix=a/$pkg_prefix \
--dst-prefix=b/$pkg_prefix \
>$crates_dir/patch/rome_fmt.patch
>$crates_dir/patch/biome_fmt.patch

rm -rf $tmp_dir
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ pkg_json.publishConfig = {
};
pkg_json.exports = {
".": {
types: "./rome_fmt.d.ts",
default: "./rome_fmt.js",
types: "./biome_fmt.d.ts",
default: "./biome_fmt.js",
},
"./vite": {
types: "./rome_fmt.d.ts",
types: "./biome_fmt.d.ts",
default: "./vite.js",
},
"./package.json": "./package.json",
Expand Down
Loading

0 comments on commit 1173774

Please sign in to comment.