Skip to content

Commit b7e5045

Browse files
authored
feat: introduce custom transformers (#190)
1 parent 6a06bf7 commit b7e5045

File tree

136 files changed

+10322
-305
lines changed

Some content is hidden

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

136 files changed

+10322
-305
lines changed

.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "rehype-pretty/rehype-pretty-code" }
6+
],
7+
"commit": false,
8+
"fixed": [],
9+
"linked": [],
10+
"access": "restricted",
11+
"baseBranch": "master",
12+
"updateInternalDependencies": "patch",
13+
"ignore": []
14+
}

.git-blame-ignore-revs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# add commit SHA to ignore
2+
3+
# GitHub can use this file to ignore certain commits when calculating the blame for a file.
4+
# This is useful for ignoring commits that are not relevant to the code,
5+
# such as large formatting changes: for example changing quotes from single to double.

.gitattributes

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
* text=auto
22

3-
/test/results/** linguist-generated
4-
/test/fixtures/** linguist-generated text eol=lf
3+
**/test/results/** linguist-generated
4+
**/test/fixtures/** linguist-generated text eol=lf
55

6-
*.lockb binary diff=lockb
76
biome.json linguist-language=JSON-with-Comments
87
.vscode/*.json linguist-language=JSON-with-Comments

.github/workflows/checks.yml

+22-8
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,36 @@ jobs:
2323
- name: 'Checkout'
2424
uses: actions/checkout@v4
2525

26-
- name: '🐰 Setup Bun'
27-
uses: oven-sh/setup-bun@v1
26+
- name: 'Setup pnpm'
27+
uses: pnpm/action-setup@v3
2828
with:
29-
bun-version: 'latest'
29+
version: 9.0.4
30+
31+
- name: 'Setup Node.js'
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: 'lts/*'
35+
cache: 'pnpm'
3036

3137
- name: 'Install Dependencies'
32-
run: bun install --frozen-lockfile
38+
run: pnpm install
3339

3440
- name: 'Lint'
35-
run: bun lint
41+
run: |
42+
pnpm format
43+
pnpm lint
3644
3745
- name: 'Type Check'
38-
run: bun typecheck
46+
run: pnpm typecheck
3947

4048
- name: 'Build'
41-
run: bun run build
49+
run: pnpm build
4250

4351
- name: 'Test'
44-
run: bun run test
52+
run: pnpm test
53+
54+
- name: 'Check Dependencies'
55+
run: pnpm dlx sherif@latest
56+
57+
- name: 'Check Packages'
58+
run: pnpm check-package

.github/workflows/release.yml

+23-38
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,50 @@ permissions:
55

66
on:
77
push:
8-
tags:
9-
- 'v*'
8+
branches: ['main', 'next']
109

1110
defaults:
1211
run:
1312
shell: bash
1413

14+
concurrency: ${{ github.workflow }}-${{ github.ref }}
15+
1516
env:
1617
NODE_OPTIONS: '--no-warnings'
1718
NEXT_TELEMETRY_DISABLED: '1'
1819
ACTIONS_RUNNER_DEBUG: true
1920

2021
jobs:
21-
changelog:
22-
name: 'Generate Changelog'
22+
release:
23+
name: 'Release'
2324
runs-on: ['ubuntu-latest']
2425
steps:
25-
- name: 'Checkout'
26+
- name: 'Checkout Repository'
2627
uses: actions/checkout@v4
27-
with:
28-
fetch-depth: 0
2928

30-
- name: '🐰 Setup Bun'
31-
uses: oven-sh/setup-bun@v1
29+
- name: 'Setup pnpm'
30+
uses: pnpm/action-setup@v3
3231
with:
33-
bun-version: 'latest'
34-
35-
- name: 'Generate Changelog'
36-
run: bunx changelogithub
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
version: 'latest'
3933

40-
publish-npm:
41-
name: 'NPM Registry'
42-
needs: [changelog]
43-
permissions:
44-
id-token: write
45-
contents: write
46-
runs-on: ['ubuntu-latest']
47-
steps:
48-
- name: 'Checkout'
49-
uses: actions/checkout@v4
50-
51-
- name: '🐰 Setup Bun'
52-
uses: oven-sh/setup-bun@v1
34+
- name: 'Setup Node.js'
35+
uses: actions/setup-node@v4
5336
with:
54-
bun-version: 'latest'
37+
cache: 'pnpm'
38+
node-version: 'lts/*'
39+
registry-url: 'https://registry.npmjs.org'
5540

5641
- name: 'Install Dependencies'
57-
run: bun install --frozen-lockfile
42+
run: pnpm install --frozen-lockfile
5843

59-
# this action will take the npm auth token and write it to .npmrc
60-
- uses: actions/setup-node@v4
44+
- name: 'Changesets'
45+
id: changesets
46+
uses: changesets/action@v1
6147
with:
62-
node-version: 'lts/*'
63-
registry-url: 'https://registry.npmjs.org'
64-
65-
- name: 'Publish to NPM'
66-
run: |
67-
npm publish --access='public' --no-git-checks
48+
publish: pnpm release
49+
version: pnpm dlx bun ${{github.workspace }}/scripts/changeset-update-version.ts
6850
env:
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6953
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
NPM_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ out
1717
*.tgz
1818
.astro
1919
_
20+
.turbo
21+
.tsup
22+
.env
23+
!.env.example

.husky/pre-commit

-4
This file was deleted.

.npmrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
shell-emulator=true
2+
shamefully-hoist=true
3+
enable-pre-post-scripts=true
4+
ignore-workspace-root-check=true
5+
@jsr:registry=https://npm.jsr.io
6+
//npm.pkg.github.com/:_authToken=NPM_GITHUB_TOKEN
7+

.vscode/settings.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
"plaintext": "html"
1212
},
1313
"biome.enabled": true,
14-
// "biome.rename": true,
15-
// "biome.searchInPath": true,
1614
// format & lint settings
1715
"editor.formatOnSave": true,
1816
"editor.codeActionsOnSave": {
@@ -27,7 +25,7 @@
2725
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
2826
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
2927
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
30-
"[astro]": { "editor.defaultFormatter": "biomejs.biome" },
28+
"[astro]": { "editor.defaultFormatter": "astro-build.astro-vscode" },
3129
"[svelte]": { "editor.defaultFormatter": "biomejs.biome" },
3230
"files.associations": {
3331
"biome.json": "jsonc",
@@ -38,6 +36,7 @@
3836
"**/dist": true,
3937
"public/*.js": true,
4038
"**/node_modules": true,
39+
"**/pnpm-lock.yaml": true,
4140
"**/package-lock.json": true
4241
}
4342
}

biome.json

+27-34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
2+
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
33
"vcs": {
44
"root": ".",
55
"enabled": true,
@@ -14,13 +14,14 @@
1414
"*.mjs",
1515
"*.jsx",
1616
"*.tsx",
17+
"*.css",
1718
"*.d.ts",
1819
"*.json",
1920
"*.jsonc",
2021
"*.astro",
2122
"*.svelte"
2223
],
23-
"ignore": ["node_modules", "dist", "_"],
24+
"ignore": ["node_modules", "dist", "_", ".turbo"],
2425
"ignoreUnknown": true
2526
},
2627
"organizeImports": {
@@ -30,7 +31,7 @@
3031
"formatter": {
3132
"enabled": true,
3233
"indentWidth": 2,
33-
"lineWidth": 100,
34+
"lineWidth": 80,
3435
"quoteStyle": "double",
3536
"indentStyle": "space"
3637
},
@@ -40,59 +41,42 @@
4041
},
4142
"formatter": {
4243
"enabled": true,
43-
"lineWidth": 100,
44+
"lineWidth": 80,
4445
"indentWidth": 2,
4546
"indentStyle": "space",
46-
"formatWithErrors": true,
47-
"include": [
48-
"*.ts",
49-
"*.js",
50-
"*.cjs",
51-
"*.mjs",
52-
"*.jsx",
53-
"*.tsx",
54-
"*.d.ts",
55-
"*.json",
56-
"*.jsonc",
57-
"*.astro",
58-
"*.svelte"
59-
]
47+
"formatWithErrors": true
6048
},
6149
"linter": {
62-
"include": [
63-
"*.ts",
64-
"*.js",
65-
"*.cjs",
66-
"*.mjs",
67-
"*.jsx",
68-
"*.tsx",
69-
"*.d.ts",
70-
"*.json",
71-
"*.jsonc",
72-
"*.astro",
73-
"*.svelte"
74-
],
7550
"enabled": true,
7651
"rules": {
7752
"all": true,
7853
"style": {
7954
"noDefaultExport": "off",
8055
"useFragmentSyntax": "off",
56+
"noImplicitBoolean": "off",
57+
"noNamespaceImport": "off",
8158
"useBlockStatements": "off",
8259
"useNamingConvention": "off",
8360
"useShorthandArrayType": "off",
8461
"useSelfClosingElements": "off",
8562
"noUnusedTemplateLiteral": "off",
86-
"useConsistentArrayType": { "level": "warn", "options": { "syntax": "generic" } }
63+
"useConsistentArrayType": {
64+
"level": "warn",
65+
"options": { "syntax": "generic" }
66+
}
67+
},
68+
"performance": {
69+
"noBarrelFile": "off",
70+
"noAccumulatingSpread": "off"
8771
},
8872
"a11y": { "noSvgWithoutTitle": "off" },
89-
"performance": { "noAccumulatingSpread": "off" },
9073
"correctness": { "noUndeclaredVariables": "off" },
9174
"nursery": {
9275
"noNodejsModules": "off"
9376
},
9477
"suspicious": {
9578
"useAwait": "off",
79+
"noConsoleLog": "off",
9680
"noExplicitAny": "off",
9781
"noEmptyInterface": "off",
9882
"noConfusingVoidType": "off"
@@ -117,7 +101,14 @@
117101
}
118102
},
119103
"javascript": {
120-
"globals": ["NodeJS", "Astro", "NEXT_TELEMETRY_DISABLED"],
104+
"globals": [
105+
"NodeJS",
106+
"Astro",
107+
"DO_NOT_TRACK",
108+
"NEXT_TELEMETRY_DISABLED",
109+
"ASTRO_TELEMETRY_DISABLED",
110+
"TURBO_TELEMETRY_DISABLED"
111+
],
121112
"parser": {
122113
"unsafeParameterDecoratorsEnabled": true
123114
},
@@ -129,6 +120,8 @@
129120
"quoteStyle": "single",
130121
"trailingComma": "all",
131122
"semicolons": "always",
123+
"bracketSpacing": true,
124+
"bracketSameLine": false,
132125
"jsxQuoteStyle": "double",
133126
"arrowParentheses": "always",
134127
"quoteProperties": "asNeeded"

bun.lockb

-163 KB
Binary file not shown.

examples/astro/astro.config.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@ import tailwind from '@astrojs/tailwind';
33
import { defineConfig } from 'astro/config';
44
import rehypePrettyCode from 'rehype-pretty-code';
55
import moonlightTheme from './public/theme/moonlight-ii.json';
6+
import { copyButtonTransformer } from '@rehype-pretty/transformers';
67

78
export default defineConfig({
89
markdown: {
910
syntaxHighlight: false,
10-
rehypePlugins: [[rehypePrettyCode, { theme: moonlightTheme }]],
11+
rehypePlugins: [
12+
[
13+
rehypePrettyCode,
14+
{
15+
theme: moonlightTheme,
16+
transformers: [
17+
copyButtonTransformer({
18+
visibility: 'hover',
19+
feedbackDuration: 3_500,
20+
}),
21+
],
22+
},
23+
],
24+
],
1125
},
1226
integrations: [mdx(), tailwind()],
1327
});

examples/astro/bun.lockb

-257 KB
Binary file not shown.

0 commit comments

Comments
 (0)