diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e5b6d8d6a67ad0dca8f20117fbfc72e076882d00 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d5e9940e210f2a9fcda378fa18401bc7385a5beb --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/README.md b/README.md index d3f1da9190a3c6bf8a0a74b59d0b8d245c8bc669..8213cddad9d079899a36557a4fa35e7d370b35e5 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ - packages - mini-markdown-ast-parser markdown 编辑器 ast 解析器(采用 rollup + ts 开发) - mini-markdown-editor 编辑器(采用 react + vite 开发、打包) - - mini-markdown-material 编辑器物料组件库(react + vite 开发、打包) - - mini-markdown-play 物料组件库测试项目 + - mini-markdown-play 测试项目 - scripts 脚本 ``` @@ -33,6 +32,21 @@ pnpm build:ast:play pnpm dev:editor # 构建 mini-markdown-editor pnpm build:editor +# 测试 mini-markdown-editor +pnpm test:editor +# 测试 mini-markdown-editor(watch) +pnpm test:editor:watch +# 测试 mini-markdown-editor(coverage) +pnpm test:coverage +# 运行mini-markdown-docs +pnpm dev:docs +# 构建 mini-markdown-docs +pnpm build:docs + +# 发布 npm +pnpm changeset +pnpm changeset version +pnpm changeset publish ``` ## git提交规范 @@ -68,3 +82,64 @@ git cz ```bash git push origin dev_xxx ``` + +## 版本更新 + +使用 `changeset` 进行版本更新 + +### 1. 安装 + +```bash +pnpm add @changesets/cli -D -w +``` + +### 2. 初始化 + +```bash +pnpm changeset init +``` + +### 3. 预发布 + +```bash +pnpm changeset pre enter 「tag」 +# alpha 内部测试版 +# beta 测试版 +# rc 候选版本 +``` + +> 退出预发布 `pnpm changeset pre exit` + +### 4. 正式发布 + +步骤1: + +```bash +pnpm changeset +``` + +```bash +# 更新的子包有哪些 +🦋 Which packages would you like to include? +# 更新主版本号的包 +🦋 Which packages should have a major bump? +# 更新次版本号的包 +🦋 Which packages should have a minor bump? +# 更新补丁版本的包 +🦋 The following packages will be patch bumped: +``` + +当上述命令运行完成后,会在 `.changeset/xxx.md` 文件中生成更新日志,然后提交到git仓库中。 + +步骤2: 消耗版本,变更子包版本 + +```bash +# 更新版本号,并删除 .changeset/xxx.md 文件 +pnpm changeset version +``` + +步骤3: 发布到npm + +```bash +pnpm changeset publish +``` diff --git a/docs/example/index.tsx b/docs/example/index.tsx index 369695de8c2c0f17aa289aeac572356f1da78ae9..d35fb38e370a20a684be1dbb7635260bb3c750fc 100644 --- a/docs/example/index.tsx +++ b/docs/example/index.tsx @@ -1,10 +1,10 @@ import React, { FC, useEffect, useRef, useState } from "react"; -import { Editor, insertContent, ToolbarManager } from "@mini-markdown/editor"; -import type { Callback, EditorRef } from "@mini-markdown/editor"; +import { Editor, insertContent, ToolbarManager } from "@mini-markdown-rc/editor"; +import type { Callback, EditorRef } from "@mini-markdown-rc/editor"; import { Button, message } from "antd"; // 可根据需要引入不同的主题 import "highlight.js/styles/atom-one-dark.css"; -import { ViewUpdate } from "@mini-markdown/editor"; +import { ViewUpdate } from "@mini-markdown-rc/editor"; export const frontmatter = { // 声明布局类型 diff --git a/docs/guide/ast-parser.mdx b/docs/guide/ast-parser.mdx index 11a2268021547b8eabe67367397579e4e26b459e..d31ec274da6a922af2d2dcd2ef26f4101d9816e0 100644 --- a/docs/guide/ast-parser.mdx +++ b/docs/guide/ast-parser.mdx @@ -2,7 +2,7 @@ import { PackageManagerTabs } from '@theme'; # AST 解析 -完成ast解析,有增量构建 +完成ast解析,有增量构建。 ## 安装 diff --git a/docs/package.json b/docs/package.json index c5a6144015827e8dd7922a442090ca531b1aeea9..7fd7a9abcc67f75bd3a0058b99ddafaf63e260b4 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,7 @@ { - "name": "docs", + "name": "@mini-markdown-rc/docs", "version": "1.0.0", + "private": true, "scripts": { "dev": "rspress dev", "build": "rspress build", @@ -13,7 +14,7 @@ "rspress": "^1.41.0" }, "dependencies": { - "@mini-markdown/editor": "workspace:^0.0.0", + "@mini-markdown-rc/editor": "workspace:*", "antd": "^5.23.2" } } \ No newline at end of file diff --git a/package.json b/package.json index 6140241ee6f48ffa692703f0b35c90a4183dd111..fb8600872adc5ff28e201e807fc371bc9270f547 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { - "name": "mini-markdown", + "name": "mini-markdown-rc", "version": "1.0.0", + "private": true, "type": "module", "engines": { "node": ">=18", @@ -8,19 +9,33 @@ }, "engine-strict": true, "packageManager": "pnpm@7.33.5", + "homepage": "https://github.com/xiaotianna/mini-markdown-editor", + "repository": { + "type": "git", + "url": "git+https://github.com/xiaotianna/mini-markdown-editor.git" + }, + "keywords": [ + "markdown-editor", + "react", + "vite", + "markdown-ast", + "ast" + ], "scripts": { "preinstall": "npx only-allow pnpm", "in": "pnpm install -r", "clear": "rimraf --glob ./node_modules ./packages/**/node_modules ./packages/**/dist ./pnpm-lock.yaml", - "dev:ast": "pnpm -F @mini-markdown/ast-parser dev", - "build:ast": "pnpm -F @mini-markdown/ast-parser build", - "build:ast:play": "pnpm -F @mini-markdown/ast-parser build:play", - "dev:editor": "pnpm -F @mini-markdown/editor dev", - "build:editor": "pnpm -F @mini-markdown/editor build", - "test:editor": "pnpm -F @mini-markdown/editor test", - "test:editor:watch": "pnpm -F @mini-markdown/editor test:watch", - "test:coverage": "pnpm -F @mini-markdown/editor coverage", - "dev:play": "pnpm -F @mini-markdown/play dev", + "dev:ast": "pnpm -F @mini-markdown-rc/ast-parser dev", + "build:ast": "pnpm -F @mini-markdown-rc/ast-parser build", + "build:ast:play": "pnpm -F @mini-markdown-rc/ast-parser build:play", + "dev:editor": "pnpm -F @mini-markdown-rc/editor dev", + "build:editor": "pnpm -F @mini-markdown-rc/editor build", + "test:editor": "pnpm -F @mini-markdown-rc/editor test", + "test:editor:watch": "pnpm -F @mini-markdown-rc/editor test:watch", + "test:coverage": "pnpm -F @mini-markdown-rc/editor coverage", + "dev:play": "pnpm -F @mini-markdown-rc/play dev", + "dev:docs": "pnpm -F @mini-markdown-rc/docs dev", + "build:docs": "pnpm -F @mini-markdown-rc/docs build", "prepare": "husky", "lint": "node ./scripts/zx-lint.js", "prettier": "prettier --write ." @@ -37,6 +52,7 @@ } }, "devDependencies": { + "@changesets/cli": "^2.27.12", "@commitlint/cli": "^19.6.1", "@commitlint/config-conventional": "^19.6.0", "cz-vinyl": "1", diff --git a/packages/mini-markdown-ast-parser/README.md b/packages/mini-markdown-ast-parser/README.md index cf9b3df191596fac6f7f11be5905aaba63640588..0798e590e6c1a32510afdea055efa178a95b05e3 100644 --- a/packages/mini-markdown-ast-parser/README.md +++ b/packages/mini-markdown-ast-parser/README.md @@ -1,4 +1,4 @@ -# @mini-markdown/ast-parser markdown 编辑器 ast 解析器 +# @mini-markdown-rc/ast-parser markdown 编辑器 ast 解析器 一个 markdown 编辑器的 ast 解析器,导出了 `parseMarkdown` 和 `transformHtml` 方法 @@ -11,29 +11,29 @@ ```bash # npm -npm install @mini-markdown/ast-parser +npm install @mini-markdown-rc/ast-parser # yarn -yarn add @mini-markdown/ast-parser +yarn add @mini-markdown-rc/ast-parser # pnpm -pnpm add @mini-markdown/ast-parser +pnpm add @mini-markdown-rc/ast-parser ``` ### 开发环境 monorepo 项目中安装 ```bash # 进入到子项目目录终端 -pnpm add @mini-markdown/ast-parser +pnpm add @mini-markdown-rc/ast-parser ``` ## 使用 ```js // esm -import { parseMarkdown, transformHtml } from '@mini-markdown/ast-parser' +import { parseMarkdown, transformHtml } from '@mini-markdown-rc/ast-parser' // commonjs -const { parseMarkdown, transformHtml } = require('@mini-markdown/ast-parser') +const { parseMarkdown, transformHtml } = require('@mini-markdown-rc/ast-parser') // 样式导入 -import '@mini-markdown/ast-parser/style' +import '@mini-markdown-rc/ast-parser/style' // 解析 markdown 内容为 ast 对象 const ast = parseMarkdown(code) @@ -98,5 +98,3 @@ console.log('index.html 生成成功\npath:', path.resolve(__dirname, './index.h - `pnpm dev`:开发模式 - `pnpm build`:打包 - `pnpm demo`:构建案例项目 - - diff --git a/packages/mini-markdown-ast-parser/package.json b/packages/mini-markdown-ast-parser/package.json index 1a8b4ff7d5e7568ac5a52c520c87972648ca3f9d..6bfe7a09f92dbdb55e0ea925c81be63167e52b19 100644 --- a/packages/mini-markdown-ast-parser/package.json +++ b/packages/mini-markdown-ast-parser/package.json @@ -1,5 +1,5 @@ { - "name": "@mini-markdown/ast-parser", + "name": "@mini-markdown-rc/ast-parser", "version": "1.0.0", "type": "module", "main": "./dist/index.cjs", @@ -16,6 +16,19 @@ "require": "./dist/style/index.css" } }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "files": [ + "dist", + "README.md" + ], + "homepage": "https://github.com/xiaotianna/mini-markdown-editor/tree/master/packages/mini-markdown-ast-parser", + "repository": { + "type": "git", + "url": "git+https://github.com/xiaotianna/mini-markdown-editor.git" + }, "scripts": { "watch": "rollup -c rollup.config.ts --configPlugin typescript -w", "start": "nodemon dist/index.js", diff --git a/packages/mini-markdown-editor/package.json b/packages/mini-markdown-editor/package.json index 71f592026c06e8e8f334f8ad7754c8a4e5d012f6..b46433cb8bf25bb194414e5874b37d69cf406dce 100644 --- a/packages/mini-markdown-editor/package.json +++ b/packages/mini-markdown-editor/package.json @@ -1,6 +1,6 @@ { - "name": "@mini-markdown/editor", - "version": "0.0.0", + "name": "@mini-markdown-rc/editor", + "version": "1.0.0", "type": "module", "description": "mini-markdown-editor", "keywords": [ @@ -20,8 +20,21 @@ "require": "./dist/mini-markdown-editor.umd.cjs" } }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "files": [ + "dist", + "README.md" + ], + "homepage": "https://github.com/xiaotianna/mini-markdown-editor/tree/master/packages/mini-markdown-editor", + "repository": { + "type": "git", + "url": "git+https://github.com/xiaotianna/mini-markdown-editor.git" + }, "scripts": { - "build:ast": "pnpm -F @mini-markdown/ast-parser build", + "build:ast": "pnpm -F @mini-markdown-rc/ast-parser build", "dev": "pnpm build:ast && vite", "build": "pnpm build:ast && tsc -b && vite build", "lint": "eslint .", @@ -49,7 +62,7 @@ "@codemirror/lang-markdown": "^6.3.2", "@codemirror/language-data": "^6.5.1", "@eslint/js": "^9.17.0", - "@mini-markdown/ast-parser": "workspace:^1.0.0", + "@mini-markdown-rc/ast-parser": "workspace:*", "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.2.0", diff --git a/packages/mini-markdown-editor/src/components/Preview/index.tsx b/packages/mini-markdown-editor/src/components/Preview/index.tsx index 0c487ab6ad49f37e1786350d93b75ad7b5036914..3fe672652d8db86f98ad495657f96099e9375ce3 100644 --- a/packages/mini-markdown-editor/src/components/Preview/index.tsx +++ b/packages/mini-markdown-editor/src/components/Preview/index.tsx @@ -1,5 +1,5 @@ import React, { FC, useEffect, useRef, useCallback } from "react"; -import { parseMarkdown, transformHtml } from "@mini-markdown/ast-parser"; +import { parseMarkdown, transformHtml } from "@mini-markdown-rc/ast-parser"; import styled from "styled-components"; import { useEditorContentStore } from "@/store/editor"; import { handlePreviewScroll } from "@/utils/handle-scroll"; diff --git a/packages/mini-markdown-play/README.md b/packages/mini-markdown-play/README.md index 74872fd4af60fb8d6cdb7d27e6c587ee0b6e1df7..1496869ab0526d7b60155ee8688304ea10816380 100644 --- a/packages/mini-markdown-play/README.md +++ b/packages/mini-markdown-play/README.md @@ -1,50 +1 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - -- Configure the top-level `parserOptions` property like this: - -```js -export default tseslint.config({ - languageOptions: { - // other options... - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - }, -}) -``` - -- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` -- Optionally add `...tseslint.configs.stylisticTypeChecked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: - -```js -// eslint.config.js -import react from 'eslint-plugin-react' - -export default tseslint.config({ - // Set the react version - settings: { react: { version: '18.3' } }, - plugins: { - // Add the react plugin - react, - }, - rules: { - // other rules... - // Enable its recommended rules - ...react.configs.recommended.rules, - ...react.configs['jsx-runtime'].rules, - }, -}) -``` +# 测试项目(不作限制) \ No newline at end of file diff --git a/packages/mini-markdown-play/package.json b/packages/mini-markdown-play/package.json index b6afbbea262fdfd042c936140f497d46ee1c0b34..6bbe33249927dcedf46a13a84b90fb284a202ca3 100644 --- a/packages/mini-markdown-play/package.json +++ b/packages/mini-markdown-play/package.json @@ -1,5 +1,5 @@ { - "name": "@mini-markdown/play", + "name": "@mini-markdown-rc/play", "private": true, "version": "0.0.0", "type": "module", @@ -10,7 +10,7 @@ "preview": "vite preview" }, "dependencies": { - "@mini-markdown/editor": "workspace:^0.0.0", + "@mini-markdown-rc/editor": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router-dom": "^7.1.3", diff --git a/packages/mini-markdown-play/src/pages/ui-test.tsx b/packages/mini-markdown-play/src/pages/ui-test.tsx index 661c76fde3f2943bbd273ae6e67daa1573099d68..c55931480acba190ff39d7bb6f198b8790d1c746 100644 --- a/packages/mini-markdown-play/src/pages/ui-test.tsx +++ b/packages/mini-markdown-play/src/pages/ui-test.tsx @@ -1,11 +1,11 @@ import { FC, useState } from "react"; import styled from "styled-components"; -import { Editor } from "@mini-markdown/editor"; -import type { Callback } from "@mini-markdown/editor"; +import { Editor } from "@mini-markdown-rc/editor"; +import type { Callback } from "@mini-markdown-rc/editor"; import { Button, message } from "antd"; // 可根据需要引入不同的主题 import "highlight.js/styles/atom-one-dark.css"; -import { ViewUpdate } from "@mini-markdown/editor"; +import { ViewUpdate } from "@mini-markdown-rc/editor"; const AppWrapper = styled.div` width: 100%; diff --git a/scripts/zx-lint.js b/scripts/zx-lint.js index 3e48316b2f633ad4fa837fd8210cb3739338b49c..e04306aaab1fdc56a4ce81f978b0d4601968c8ba 100644 --- a/scripts/zx-lint.js +++ b/scripts/zx-lint.js @@ -1,9 +1,8 @@ #!/usr/bin/env zx -import 'zx/globals' +import "zx/globals"; await Promise.all([ - $`pnpm -F @mini-markdown/editor lint`, - $`pnpm -F @mini-markdown/material lint`, - $`pnpm -F @mini-markdown/ast-parser lint`, -]) + $`pnpm -F @mini-markdown-rc/editor lint`, + $`pnpm -F @mini-markdown-rc/ast-parser lint`, +]);