Skip to content

Commit 308881b

Browse files
authored
refactor!: v3.0.0 major overhaul (#59)
* refactor!: v3.0.0 major overhaul - Hook: stabilize useCodeExecution (refs, stable execute, updateCode alias) - Tests: fix TypeScript matchers and marked renderer signature; remove unused vars - Docs: README requirements, hook example, CI/CD notes - CI: Node 18 + PNPM, cache; turbo scripts; gh-pages publish docs/dist - Publish: Changesets + npm provenance (OIDC), remove NODE_AUTH_TOKEN - Misc: align workspace configs * chore(changeset): add v3.0.0 major release notes * docs: add v2→v3 migration guide and clarify usage * chore(changeset): clarify breaking changes for imports/styles/unplugin and Node/PNPM requirements * ci: remove PNPM version from action setup to align with packageManager * ci: use Corepack to pin PNPM from packageManager and fix lockfile mismatch * ci: use Corepack in publish/pages to align PNPM with packageManager * chore: regenerate pnpm lockfile with pnpm 9 * docs: add contributing guide
1 parent f29548b commit 308881b

File tree

180 files changed

+22060
-10176
lines changed

Some content is hidden

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

180 files changed

+22060
-10176
lines changed

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.changeset/v3-major.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
"react-code-view": major
3+
"@react-code-view/react": major
4+
"@react-code-view/core": major
5+
"@react-code-view/unplugin": major
6+
---
7+
8+
Major refactor for v3.0.0:
9+
10+
- Hook: stabilize `useCodeExecution` (refs-based options, stable `execute()`, `updateCode` alias)
11+
- Tests: fix TypeScript matcher types and marked renderer signature; remove unused vars
12+
- Docs: update README with requirements, hook example, CI/CD notes
13+
- CI: Node 18 + PNPM, caching; gh-pages publishes `docs/dist`
14+
- Publish: adopt Changesets + npm provenance (OIDC), drop `NODE_AUTH_TOKEN`
15+
- Config: align workspace tsconfig/turbo/vite
16+
17+
BREAKING CHANGES:
18+
19+
- `useCodeExecution` effect behavior stabilized; consumers relying on previous implicit re-execution may need to explicitly update `code` or pass `dependencies`
20+
- Package structure reorganized across `packages/*`; import paths may need updates according to exports
21+
22+
- Imports: `CodeView` is now also a default export in `@react-code-view/react` and re-exported by `react-code-view`; prefer `import CodeView from 'react-code-view'` or adjust named imports accordingly
23+
- Styles: Less entries were removed; switch to `import 'react-code-view/styles'` and optional `import 'react-code-view/styles/highlight'`
24+
- Build integration: Legacy `webpack-md-loader` is removed; migrate to unified `@react-code-view/unplugin` for Vite/Webpack/Rollup/esbuild/Rspack
25+
- Tooling: Minimum requirements updated to Node >=18 and PNPM >=8 for the monorepo/dev workflow

.eslintrc.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://json.schemastore.org/eslintrc.json",
3+
"root": true,
4+
"env": {
5+
"browser": true,
6+
"es2021": true,
7+
"node": true
8+
},
9+
"extends": [
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:react/recommended",
13+
"plugin:react-hooks/recommended",
14+
"prettier"
15+
],
16+
"parser": "@typescript-eslint/parser",
17+
"parserOptions": {
18+
"ecmaFeatures": {
19+
"jsx": true
20+
},
21+
"ecmaVersion": "latest",
22+
"sourceType": "module"
23+
},
24+
"plugins": ["@typescript-eslint", "react", "react-hooks"],
25+
"settings": {
26+
"react": {
27+
"version": "detect"
28+
}
29+
},
30+
"rules": {
31+
"react/react-in-jsx-scope": "off",
32+
"react/prop-types": "off",
33+
"@typescript-eslint/no-explicit-any": "warn",
34+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
35+
},
36+
"ignorePatterns": ["dist", "node_modules", "*.js", "*.cjs"]
37+
}

.github/workflows/gh-pages.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020

21+
- name: Enable Corepack (PNPM from packageManager)
22+
run: |
23+
corepack enable
24+
2125
- name: Setup node
2226
uses: actions/setup-node@v4
2327
with:
24-
node-version: 'lts/*'
28+
node-version: '18.x'
29+
cache: 'pnpm'
2530

2631
- name: Install
27-
run: npm install
32+
run: pnpm install --frozen-lockfile
2833

2934
- name: Build
30-
run: npm run build:docs
35+
run: pnpm docs:build
3136

3237
- name: Deploy
3338
uses: peaceiris/actions-gh-pages@v3
3439
if: github.ref == 'refs/heads/main'
3540
with:
3641
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
publish_dir: ./docs/assets
42+
publish_dir: ./docs/dist

.github/workflows/nodejs-ci.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,32 @@ on:
1212
- main
1313
jobs:
1414
test:
15-
name: 'Test'
15+
name: 'Build & Test'
1616
runs-on: ubuntu-latest
17-
container: node:16
1817

1918
steps:
20-
- uses: actions/checkout@v2
21-
- env:
19+
- uses: actions/checkout@v4
20+
21+
- name: Enable Corepack (PNPM from packageManager)
22+
run: |
23+
corepack enable
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '18.x'
29+
cache: 'pnpm'
30+
31+
- name: Install dependencies
32+
run: pnpm install --frozen-lockfile
33+
env:
2234
HUSKY: 0
23-
run: npm install
24-
- run: npm test
35+
36+
- name: Typecheck
37+
run: pnpm -w typecheck
38+
39+
- name: Build
40+
run: pnpm -w build
41+
42+
- name: Test
43+
run: pnpm -w test --reporter verbose
Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
11
# see https://help.github.com/cn/actions/language-and-framework-guides/publishing-nodejs-packages
22

3-
name: Node.js Package
3+
name: Release Packages
44

55
on:
6+
workflow_dispatch: {}
67
push:
7-
tags: ['*']
8+
tags:
9+
- 'v*'
810

911
jobs:
1012
publish:
11-
name: 'Publish'
13+
name: 'Publish to npm'
1214
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
id-token: write
1318
steps:
14-
- uses: actions/checkout@v2
15-
# Setup .npmrc file to publish to npm
16-
- uses: actions/setup-node@v1
19+
- uses: actions/checkout@v4
20+
21+
- name: Enable Corepack (PNPM from packageManager)
22+
run: |
23+
corepack enable
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
1727
with:
18-
node-version: '14.x'
28+
node-version: '18.x'
1929
registry-url: 'https://registry.npmjs.org'
30+
cache: 'pnpm'
2031

2132
- name: Install dependencies
22-
run: npm install
33+
run: pnpm install --frozen-lockfile
34+
env:
35+
HUSKY: 0
2336

2437
- name: Build
25-
run: npm run build
38+
run: pnpm -w build
2639

27-
- name: Npm Publish
28-
run: npm publish dist
40+
- name: Publish with Changesets
41+
run: pnpm release
2942
env:
30-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43+
NPM_CONFIG_PROVENANCE: true

.gitignore

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
karma-*
6-
7-
# Runtime data
8-
pids
9-
*.pid
10-
*.seed
1+
# Dependencies
2+
node_modules/
3+
.pnpm-store/
114

12-
# Directory for instrumented libs generated by jscoverage/JSCover
13-
lib-cov
5+
# Build outputs
6+
dist/
7+
*.tsbuildinfo
148

15-
# Coverage directory used by tools like istanbul
16-
coverage
9+
# IDE
10+
.idea/
11+
.vscode/
12+
*.swp
13+
*.swo
1714

18-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19-
.grunt
15+
# OS
16+
.DS_Store
17+
Thumbs.db
2018

21-
# node-waf configuration
22-
.lock-wscript
19+
# Logs
20+
*.log
21+
npm-debug.log*
22+
pnpm-debug.log*
2323

24-
# Compiled binary addons (http://nodejs.org/api/addons.html)
25-
build/Release
24+
# Test coverage
25+
coverage/
2626

27-
# Dependency directory
28-
node_modules
27+
# Turbo
28+
.turbo/
2929

30-
# Optional npm cache directory
30+
# Environment
31+
.env
32+
.env.local
33+
.env.*.local
3134
.npm
3235

3336
# Optional REPL history

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "none",
6+
"printWidth": 100,
7+
"arrowParens": "avoid"
8+
}

CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributing to React Code View
2+
3+
Thanks for helping improve React Code View! This guide keeps contributions consistent and easy to review.
4+
5+
## Prerequisites
6+
- Node.js 18+
7+
- PNPM 9 (Corepack enabled: `corepack enable`)
8+
- Git
9+
10+
## Setup
11+
```bash
12+
corepack enable
13+
pnpm install
14+
```
15+
16+
## Common Tasks
17+
- Typecheck: `pnpm -w typecheck`
18+
- Lint: `pnpm -w lint`
19+
- Test: `pnpm -w test`
20+
- Build: `pnpm -w build`
21+
- Docs dev: `pnpm docs`
22+
- Docs build: `pnpm docs:build`
23+
24+
## Development Notes
25+
- Monorepo is managed with PNPM + Turbo; prefer `pnpm -w <script>` for workspace-wide tasks.
26+
- Avoid committing generated bundles in `dist/`; keep changes to source and configs.
27+
- Ensure tests pass locally before opening a PR.
28+
- Update or add tests for behavior changes (see `packages/**/__tests__`).
29+
30+
## Changesets & Releases
31+
- For user-visible changes, run `pnpm changeset` and follow the prompts (choose the affected packages and bump type).
32+
- Keep the summary short and mention breaking changes clearly.
33+
- Versioning and publishing are handled via CI; tags trigger the publish workflow.
34+
35+
## Pull Requests
36+
- Base your work on the latest `main` (or the active release branch) and keep commits focused.
37+
- Describe the change, rationale, and testing performed.
38+
- If you add a new feature or breaking change, update `README.md` and relevant docs.
39+
40+
## Coding Style
41+
- TypeScript everywhere; prefer explicit types on public APIs.
42+
- React 18 conventions (hooks, function components).
43+
- Keep imports sorted logically; run linters/formatters as needed.
44+
45+
## Need Help?
46+
- Open a discussion or issue in the repo with reproduction steps and context.

0 commit comments

Comments
 (0)