Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
format with biome
Browse files Browse the repository at this point in the history
  • Loading branch information
mvantellingen committed Sep 2, 2024
1 parent 64f0a66 commit 6757720
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 139 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

# Set up tabs as indent style for a11y reasons
# This will be the default for prettier in >=v3
[*]
indent_style = tab
indent_size = 2

# Yaml does not support tabs
[*.{yml,yaml}]
indent_style = space
indent_size = 2
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release
on: [push]

env:
CI: true

jobs:
lint:
name: Lint codebase
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
run_install: true

- name: Lint
run: pnpm lint

build:
name: Build, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: lint
strategy:
matrix:
node: ["18.x", "20.x", "22.x"]
os: [ubuntu-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: true

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: "pnpm"

- name: Test
run: pnpm run test:ci

- name: Build
run: pnpm build

release:
timeout-minutes: 15
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: true

- name: Install node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Create and publish versions
uses: changesets/action@v1
with:
title: "Release new version"
commit: "update version"
publish: pnpm publish:ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"biomejs.biome",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"GraphQL.vscode-graphql-syntax",
"GraphQL.vscode-graphql"
]
}
33 changes: 33 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"eslint.enable": true,
"prettier.enable": false,
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"eslint.format.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.fixAll.eslint": "never",
"source.organizeImports": "never",
"source.organizeImports.biome": "explicit"
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/build": true,
"**/dist": true
},
"search.exclude": {
"**/node_modules": true,
"**/dist": true
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
21 changes: 21 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"ignore": ["dist/*"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn"
},
"style": {
"noUselessElse": "off"
}
}
}
}
48 changes: 26 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
{
"name": "@labdigital/graphql-codegen-bruno",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "tsup",
"clean": "rm -rf dist"
},
"dependencies": {
"@graphql-codegen/cli": "^2.0.0",
"@graphql-codegen/plugin-helpers": "^2.0.0",
"fs-extra": "^10.0.0",
"graphql": "^16.9.0",
"prettier": "^3.3.3"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/graphql": "^14.5.0",
"@types/node": "^20.0.0",
"tsup": "^8.2.4",
"typescript": "^5.0.0"
},
"packageManager": "pnpm@8.15.8"
"name": "@labdigital/graphql-codegen-bruno",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "tsup",
"lint": "biome ci",
"clean": "rm -rf dist"
},
"dependencies": {
"@biomejs/biome": "^1.8.3",
"@graphql-codegen/cli": "^2.0.0",
"@graphql-codegen/plugin-helpers": "^2.0.0",
"fs-extra": "^10.0.0",
"prettier": "^3.3.3"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/graphql": "^14.5.0",
"@types/node": "^20.0.0",
"tsup": "^8.2.4",
"typescript": "^5.0.0"
},
"peerDependencies": {
"graphql": "^16.9.0"
},
"packageManager": "pnpm@8.15.8"
}
91 changes: 91 additions & 0 deletions pnpm-lock.yaml

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

19 changes: 8 additions & 11 deletions src/bruno.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { FileContent } from "./operations";
import prettier from "prettier";
import fs from "fs-extra";
import type { FileContent } from "./operations";

export const asBruno = async (operation: FileContent, sequence: number) => {
const formattedContent = await prettier.format(operation.content, {
parser: "graphql",
});

const formattedContent = await prettier.format(operation.content, {
parser: "graphql",
});


return `
return `
meta {
name: ${operation.name}
type: graphql
Expand All @@ -27,7 +24,7 @@ body:graphql {
}
body:graphql:vars {
${JSON.stringify(operation.vars, null, 2).split("\n").join("\n ")}
}
`
}

`;
};
Loading

0 comments on commit 6757720

Please sign in to comment.