Skip to content

Commit

Permalink
chore: move to biome
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Oct 2, 2023
1 parent 6a83d8b commit 7ce5c34
Show file tree
Hide file tree
Showing 410 changed files with 150 additions and 58 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
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ 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:
Expand All @@ -57,10 +57,10 @@ jobs:
run: deno test --allow-read

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

- name: Upload
uses: actions/upload-artifact@v3
with:
name: npm
path: crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz
path: crates/biome_fmt/pkg/wasm-fmt-biome_fmt-*.tgz
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"
]
}
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ resolver = "2"

[workspace.package]
authors = ["magic-akari <[email protected]>"]
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"


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";

// ...
```
2 changes: 1 addition & 1 deletion crates/rome_fmt/Cargo.toml → crates/biome_fmt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 + 2 + <<<ROME_RANGE_START>>>3 + 4<<<ROME_RANGE_END>>> + 5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 + 2 + <<<ROME_RANGE_START>>>3 + 4<<<ROME_RANGE_END>>> + 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function foo() {
return ["1234567890", "1234567890", "1234567890", "1234567890", "1234567890"];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function foo() {
return ["1234567890", "1234567890", "1234567890", "1234567890", "1234567890"];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function foo() {
function bar() {
function foo() {
function bar() {
function foo() {
function bar() {
function foo() {
function bar() {
return ["long", "long", "long", "long", "long"];
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function foo() {
function bar() {
function foo() {
function bar() {
function foo() {
function bar() {
function foo() {
function bar() {
return ["long", "long", "long", "long", "long"];
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
statement_1()
<<<ROME_RANGE_START>>>statement_2()<<<ROME_RANGE_END>>>
statement_3()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
statement_1() <<
<ROME_RANGE_START>>>statement_2()<<<ROME_RANGE_END>>>
statement_3()
;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import React from 'react'; function test() { const AppShelled = () => <<<ROME_RANGE_START>>>(1 + 2)<<<ROME_RANGE_END>>> } function one() {return 1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import React from "react";
function test() { const AppShelled = () => <<<ROME_RANGE_START>>>(1 + 2)<<<ROME_RANGE_END>>> } function one() {return 1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
a?.b
const a = () => {sdasdsa;
kek;
dsad<<<ROME_RANGE_START>>>sa;
123;
("y̆es");
};
console.log("🚀".length);
<<<ROME_RANGE_END>>>
("Jan 1, 2018 – Jan 1, 2019");
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
a?.b;
const a = () => {sdasdsa;
kek;
dsad<<<ROME_RANGE_START>>>sa;
123;
("y̆es");
};
console.log("🚀".length);
<<<ROME_RANGE_END>>>
("Jan 1, 2018 – Jan 1, 2019");
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a?.b
const a = () => {sdasdsa;
kek;
dsad<<<ROME_RANGE_START>>>sa;
123;
("y̆es");
};
console.log("🚀".length);<<<ROME_RANGE_END>>>("Jan 1, 2018 – Jan 1, 2019");
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a?.b;
const a = () => {sdasdsa;
kek;
dsad<<<ROME_RANGE_START>>>sa;
123;
("y̆es");
};
console.log("🚀".length);<<<ROME_RANGE_END>>>("Jan 1, 2018 – Jan 1, 2019");
1 change: 1 addition & 0 deletions crates/biome_fmt/test_data/specs/jsx/parentheses_range.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import React from 'react'; function test() { const AppShelled = () => <<<ROME_RANGE_START>>>(<Component />)<<<ROME_RANGE_END>>> } function lol() {return 1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import React from "react";
function test() { const AppShelled = () => <<<ROME_RANGE_START>>>(<Component />)<<<ROME_RANGE_END>>> } function lol() {return 1}
Loading

0 comments on commit 7ce5c34

Please sign in to comment.