Skip to content

Commit d55e2a2

Browse files
authored
Merge pull request #72 from jaredwray/chore-migrating-from-xo-to-biome
chore: migrating from xo to biome
2 parents a443122 + 42084e9 commit d55e2a2

67 files changed

Lines changed: 1996 additions & 1605 deletions

Some content is hidden

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

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: pnpm build
2828

2929
- name: Testing
30-
run: pnpm test
30+
run: pnpm test:ci
3131

3232
- name: Publish
3333
run: |

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ jobs:
3333
run: pnpm build
3434

3535
- name: Testing
36-
run: pnpm test
36+
run: pnpm test:ci
3737

biome.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
3+
"vcs": {
4+
"enabled": false,
5+
"clientKind": "git",
6+
"useIgnoreFile": false
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"includes": ["src/**/*.ts", "test/**/*.ts"]
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "tab"
15+
},
16+
"linter": {
17+
"enabled": true,
18+
"rules": {
19+
"recommended": true
20+
}
21+
},
22+
"javascript": {
23+
"formatter": {
24+
"quoteStyle": "double"
25+
}
26+
},
27+
"assist": {
28+
"enabled": true,
29+
"actions": {
30+
"source": {
31+
"organizeImports": "on"
32+
}
33+
}
34+
}
35+
}

package.json

Lines changed: 77 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,79 @@
11
{
2-
"name": "@jaredwray/mockhttp",
3-
"version": "0.6.1",
4-
"description": "Mock Http - Easy way to mock http with httpbin replacement",
5-
"type": "module",
6-
"main": "dist/index.js",
7-
"directories": {
8-
"test": "test"
9-
},
10-
"scripts": {
11-
"test": "xo --fix && vitest run --coverage",
12-
"dev": "xo --fix && tsx src/index.ts --watch",
13-
"build": "rimraf ./dist && tsup src/index.ts --format esm --dts --clean",
14-
"docker:build": "docker build -t jaredwray/mockhttp .",
15-
"docker:run": "docker run -p 3000:3000 jaredwray/mockhttp",
16-
"docker:push": "docker push jaredwray/mockhttp",
17-
"docker:stop": "docker stop $(docker ps -a -q --filter ancestor=jaredwray/mockhttp --format=\"{{.ID}}\")",
18-
"docker:readme": "tsx ./scripts/create-docker-readme.ts",
19-
"docker:compose:up": "docker-compose up -d",
20-
"docker:compose:down": "docker-compose down",
21-
"prepare": "pnpm run build",
22-
"start": "node dist/index.js"
23-
},
24-
"repository": {
25-
"type": "git",
26-
"url": "git+https://github.com/jaredwray/mockhttp.git"
27-
},
28-
"keywords": [
29-
"mock",
30-
"http",
31-
"httpbin",
32-
"test"
33-
],
34-
"author": "Jared Wray <me@jaredwray.com>",
35-
"license": "MIT",
36-
"bugs": {
37-
"url": "https://github.com/jaredwray/mockhttp/issues"
38-
},
39-
"homepage": "https://github.com/jaredwray/mockhttp#readme",
40-
"devDependencies": {
41-
"@swc/core": "^1.13.4",
42-
"@types/html-escaper": "^3.0.4",
43-
"@vitest/coverage-v8": "^3.2.4",
44-
"rimraf": "^6.0.1",
45-
"tsup": "^8.5.0",
46-
"tsx": "^4.20.4",
47-
"typescript": "^5.9.2",
48-
"vitest": "^3.2.4",
49-
"xo": "^1.2.1"
50-
},
51-
"dependencies": {
52-
"@fastify/cookie": "^11.0.2",
53-
"@fastify/helmet": "^13.0.1",
54-
"@fastify/static": "^8.2.0",
55-
"@fastify/swagger": "^9.5.1",
56-
"@fastify/swagger-ui": "^5.2.3",
57-
"@scalar/api-reference": "^1.34.4",
58-
"detect-port": "^2.1.0",
59-
"fastify": "^5.5.0",
60-
"hookified": "^1.12.0",
61-
"html-escaper": "^3.0.3",
62-
"pino": "^9.9.0",
63-
"pino-pretty": "^13.1.1"
64-
},
65-
"files": [
66-
"dist",
67-
"public",
68-
"LICENCE"
69-
],
70-
"pnpm": {
71-
"onlyBuiltDependencies": [
72-
"@swc/core",
73-
"esbuild",
74-
"unrs-resolver",
75-
"vue-demi"
76-
]
77-
},
78-
"xo": {
79-
"rules": {
80-
"@typescript-eslint/no-unsafe-call": "off",
81-
"@typescript-eslint/no-unsafe-assignment": "off"
82-
}
83-
}
2+
"name": "@jaredwray/mockhttp",
3+
"version": "0.6.1",
4+
"description": "Mock Http - Easy way to mock http with httpbin replacement",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"directories": {
8+
"test": "test"
9+
},
10+
"scripts": {
11+
"lint": "biome check --write",
12+
"test": "pnpm lint && vitest run --coverage",
13+
"test:ci": "biome check && vitest run --coverage",
14+
"dev": "pnpm lint && tsx src/index.ts --watch",
15+
"build": "rimraf ./dist && tsup src/index.ts --format esm --dts --clean",
16+
"docker:build": "docker build -t jaredwray/mockhttp .",
17+
"docker:run": "docker run -p 3000:3000 jaredwray/mockhttp",
18+
"docker:push": "docker push jaredwray/mockhttp",
19+
"docker:stop": "docker stop $(docker ps -a -q --filter ancestor=jaredwray/mockhttp --format=\"{{.ID}}\")",
20+
"docker:readme": "tsx ./scripts/create-docker-readme.ts",
21+
"docker:compose:up": "docker-compose up -d",
22+
"docker:compose:down": "docker-compose down",
23+
"prepare": "pnpm run build",
24+
"start": "node dist/index.js"
25+
},
26+
"repository": {
27+
"type": "git",
28+
"url": "git+https://github.com/jaredwray/mockhttp.git"
29+
},
30+
"keywords": [
31+
"mock",
32+
"http",
33+
"httpbin",
34+
"test"
35+
],
36+
"author": "Jared Wray <me@jaredwray.com>",
37+
"license": "MIT",
38+
"bugs": {
39+
"url": "https://github.com/jaredwray/mockhttp/issues"
40+
},
41+
"homepage": "https://github.com/jaredwray/mockhttp#readme",
42+
"devDependencies": {
43+
"@biomejs/biome": "^2.2.2",
44+
"@swc/core": "^1.13.4",
45+
"@types/html-escaper": "^3.0.4",
46+
"@vitest/coverage-v8": "^3.2.4",
47+
"rimraf": "^6.0.1",
48+
"tsup": "^8.5.0",
49+
"tsx": "^4.20.4",
50+
"typescript": "^5.9.2",
51+
"vitest": "^3.2.4"
52+
},
53+
"dependencies": {
54+
"@fastify/cookie": "^11.0.2",
55+
"@fastify/helmet": "^13.0.1",
56+
"@fastify/static": "^8.2.0",
57+
"@fastify/swagger": "^9.5.1",
58+
"@fastify/swagger-ui": "^5.2.3",
59+
"@scalar/api-reference": "^1.34.4",
60+
"detect-port": "^2.1.0",
61+
"fastify": "^5.5.0",
62+
"hookified": "^1.12.0",
63+
"html-escaper": "^3.0.3",
64+
"pino": "^9.9.0",
65+
"pino-pretty": "^13.1.1"
66+
},
67+
"files": [
68+
"dist",
69+
"public",
70+
"LICENCE"
71+
],
72+
"pnpm": {
73+
"onlyBuiltDependencies": [
74+
"@swc/core",
75+
"unrs-resolver",
76+
"vue-demi"
77+
]
78+
}
8479
}

scripts/create-docker-readme.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
import fs from 'node:fs';
1+
import fs from "node:fs";
22

3-
async function copyAndReplaceText(originalFile: string, newFile: string, searchValue: string, replaceValue: string) {
3+
async function copyAndReplaceText(
4+
originalFile: string,
5+
newFile: string,
6+
searchValue: string,
7+
replaceValue: string,
8+
) {
49
try {
510
// Ensure the original file exists
611
if (!fs.existsSync(originalFile)) {
712
throw new Error(`Original file "${originalFile}" does not exist.`);
813
}
914

1015
// Read the content of the original file
11-
const fileContent = await fs.promises.readFile(originalFile, 'utf8');
16+
const fileContent = await fs.promises.readFile(originalFile, "utf8");
1217

1318
// Replace the text
14-
const updatedContent = fileContent.replaceAll(new RegExp(searchValue, 'g'), replaceValue);
19+
const updatedContent = fileContent.replaceAll(
20+
new RegExp(searchValue, "g"),
21+
replaceValue,
22+
);
1523

1624
// Write the updated content to the new file
17-
await fs.promises.writeFile(newFile, updatedContent, 'utf8');
25+
await fs.promises.writeFile(newFile, updatedContent, "utf8");
1826

1927
console.log(`File copied and text replaced: ${newFile}`);
2028
} catch (error) {
@@ -23,10 +31,10 @@ async function copyAndReplaceText(originalFile: string, newFile: string, searchV
2331
}
2432

2533
// File paths and replacement values
26-
const originalFile = 'README.md';
27-
const newFile = 'DOCKER.md';
34+
const originalFile = "README.md";
35+
const newFile = "DOCKER.md";
2836
const searchValue = String.raw`\[\!\[public/logo\.svg\]\(public/logo\.svg\)\]\(https://mockhttp\.org\)`;
29-
const replaceValue = '';
37+
const replaceValue = "";
3038

3139
// Run
3240
await copyAndReplaceText(originalFile, newFile, searchValue, replaceValue);

src/fastify-config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
21
export const fastifyConfig = {
32
logger: {
43
transport: {
5-
target: 'pino-pretty',
4+
target: "pino-pretty",
65
options: {
76
colorize: true,
87
translateTime: true,
9-
ignore: 'pid,hostname',
8+
ignore: "pid,hostname",
109
singleLine: true,
1110
},
1211
},

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import process from 'node:process';
2-
import {MockHttp} from './mock-http.js';
1+
import process from "node:process";
2+
import { MockHttp } from "./mock-http.js";
33

44
// Start the Fastify server
55
export const start = async () => {
@@ -23,6 +23,7 @@ export const start = async () => {
2323
if (import.meta.url === `file://${process.argv[1]}`) {
2424
await start();
2525
}
26+
2627
/* c8 ignore end */
2728

28-
export {MockHttp as default, MockHttp as mockhttp} from './mock-http.js';
29+
export { MockHttp as default, MockHttp as mockhttp } from "./mock-http.js";

0 commit comments

Comments
 (0)