diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d567c3fd55..8504a9db25 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -26,5 +26,11 @@ module.exports = { 'vue/one-component-per-file': 'off', }, }, + { + files: ['packages/vuepress/bin/vuepress-*.js'], + rules: { + 'import/no-extraneous-dependencies': 'off', + }, + }, ], } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa91d931ba..e8b829cbdf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,9 +17,7 @@ In the `packages` directory: Here are some wrapper packages that use the above packages: -- `vuepress`: A wrapper of `vuepress-vite`. -- `vuepress-vite`: A wrapper of `@vuepress/cli` + `@vuepress/bundler-vite`. If users want to use vite, they can simply install this package. -- `vuepress-webpack`: A wrapper of `@vuepress/cli` + `@vuepress/bundler-webpack`. If users want to use webpack, they can simply install this package. +- `vuepress`: A wrapper the above packages, and provides `vuepress` command line tool. Users need to choose and install bundler and theme by themselves. ## Development Setup diff --git a/CONTRIBUTING_zh.md b/CONTRIBUTING_zh.md index 2a79131a0b..e5cbdc0f9f 100644 --- a/CONTRIBUTING_zh.md +++ b/CONTRIBUTING_zh.md @@ -17,9 +17,7 @@ 还有一些对上述 Package 进行封装后的 Package : -- `vuepress`: 是 `vuepress-vite` 的封装。 -- `vuepress-vite`: 是 `@vuepress/cli` + `@vuepress/bundler-vite` 的封装。如果用户想使用 Vite ,仅安装这个 Package 就可以了。 -- `vuepress-webpack`: 是 `@vuepress/cli` + `@vuepress/bundler-webpack` 的封装。如果用户想使用 Webpack ,仅安装这个 Package 就可以了。 +- `vuepress`: 是上述包的封装,提供了 `vuepress` 命令行工具。用户需要在此包的基础上自行选择并安装打包工具和主题。 ## 开发配置 diff --git a/e2e/package.json b/e2e/package.json index 7d80a47dd7..c373142499 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -25,7 +25,8 @@ "@vuepress/utils": "workspace:*", "sass": "^1.69.5", "sass-loader": "^13.3.2", - "vue": "^3.3.13" + "vue": "^3.3.13", + "vuepress": "workspace:*" }, "devDependencies": { "anywhere": "^1.6.0", diff --git a/packages/cli/src/config/resolveAppConfig.ts b/packages/cli/src/config/resolveAppConfig.ts index 2d1089d382..a48a12b05d 100644 --- a/packages/cli/src/config/resolveAppConfig.ts +++ b/packages/cli/src/config/resolveAppConfig.ts @@ -6,8 +6,8 @@ import { colors, isChildPath, logger } from '@vuepress/utils' * Resolve app config according to: * * - default options - * - cli options * - user config file + * - cli options */ export const resolveAppConfig = ({ defaultAppConfig, @@ -20,10 +20,10 @@ export const resolveAppConfig = ({ }): AppConfig | null => { const appConfig = { // allow setting default app config via `cli()` - // for example, set different default bundler in `vuepress` and `vuepress-vite` package ...defaultAppConfig, - // use cli options to override config file + // user config from config file ...userConfig, + // allow cli options to override config file ...cliAppConfig, } as AppConfig diff --git a/packages/vuepress-vite/README.md b/packages/vuepress-vite/README.md deleted file mode 100644 index d9bf35b3aa..0000000000 --- a/packages/vuepress-vite/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# vuepress-vite - -[![npm](https://badgen.net/npm/v/vuepress-vite/next)](https://www.npmjs.com/package/vuepress-vite) -[![license](https://badgen.net/github/license/vuepress/vuepress-next)](https://github.com/vuepress/vuepress-next/blob/main/LICENSE) - -## Documentation - -https://v2.vuepress.vuejs.org - -## License - -[MIT](https://github.com/vuepress/vuepress-next/blob/main/LICENSE) diff --git a/packages/vuepress-vite/package.json b/packages/vuepress-vite/package.json deleted file mode 100644 index 2ecbee105f..0000000000 --- a/packages/vuepress-vite/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "vuepress-vite", - "version": "2.0.0-rc.0", - "description": "Vue-powered Static Site Generator", - "keywords": [ - "documentation", - "generator", - "vue", - "vuepress" - ], - "homepage": "https://github.com/vuepress", - "bugs": { - "url": "https://github.com/vuepress/vuepress-next/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vuepress/vuepress-next.git" - }, - "license": "MIT", - "author": "meteorlxy", - "type": "module", - "exports": { - ".": "./dist/index.js", - "./bin": "./bin/vuepress.js", - "./package.json": "./package.json" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "bin": { - "vuepress": "./bin/vuepress.js", - "vuepress-vite": "./bin/vuepress.js" - }, - "files": [ - "bin", - "dist" - ], - "scripts": { - "build": "tsup", - "clean": "rimraf dist" - }, - "dependencies": { - "@vuepress/bundler-vite": "workspace:*", - "@vuepress/cli": "workspace:*", - "@vuepress/core": "workspace:*", - "vue": "^3.3.13" - }, - "devDependencies": { - "@vuepress/client": "workspace:*" - }, - "peerDependencies": { - "@vuepress/client": "workspace:*", - "vue": "^3.3.4" - }, - "engines": { - "node": ">=18.16.0" - }, - "tsup": { - "clean": true, - "dts": "./src/index.ts", - "entry": [ - "./src/index.ts" - ], - "format": [ - "esm" - ], - "outDir": "./dist", - "sourcemap": false, - "target": "es2022", - "tsconfig": "../../tsconfig.dts.json" - } -} diff --git a/packages/vuepress-vite/src/index.ts b/packages/vuepress-vite/src/index.ts deleted file mode 100644 index b69b7b0a55..0000000000 --- a/packages/vuepress-vite/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '@vuepress/bundler-vite' -export * from '@vuepress/cli' -export * from '@vuepress/core' diff --git a/packages/vuepress-webpack/README.md b/packages/vuepress-webpack/README.md deleted file mode 100644 index cb94d8a11f..0000000000 --- a/packages/vuepress-webpack/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# vuepress-webpack - -[![npm](https://badgen.net/npm/v/vuepress-webpack/next)](https://www.npmjs.com/package/vuepress-webpack) -[![license](https://badgen.net/github/license/vuepress/vuepress-next)](https://github.com/vuepress/vuepress-next/blob/main/LICENSE) - -## Documentation - -https://v2.vuepress.vuejs.org - -## License - -[MIT](https://github.com/vuepress/vuepress-next/blob/main/LICENSE) diff --git a/packages/vuepress-webpack/package.json b/packages/vuepress-webpack/package.json deleted file mode 100644 index 674f1613dc..0000000000 --- a/packages/vuepress-webpack/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "vuepress-webpack", - "version": "2.0.0-rc.0", - "description": "Vue-powered Static Site Generator", - "keywords": [ - "documentation", - "generator", - "vue", - "vuepress" - ], - "homepage": "https://github.com/vuepress", - "bugs": { - "url": "https://github.com/vuepress/vuepress-next/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vuepress/vuepress-next.git" - }, - "license": "MIT", - "author": "meteorlxy", - "type": "module", - "exports": { - ".": "./dist/index.js", - "./bin": "./bin/vuepress.js", - "./package.json": "./package.json" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "bin": { - "vuepress": "./bin/vuepress.js", - "vuepress-webpack": "./bin/vuepress.js" - }, - "files": [ - "bin", - "dist" - ], - "scripts": { - "build": "tsup", - "clean": "rimraf dist" - }, - "dependencies": { - "@vuepress/bundler-webpack": "workspace:*", - "@vuepress/cli": "workspace:*", - "@vuepress/core": "workspace:*", - "sass-loader": "^13.3.2", - "vue": "^3.3.13" - }, - "peerDependencies": { - "vue": "^3.3.4" - }, - "engines": { - "node": ">=18.16.0" - }, - "tsup": { - "clean": true, - "dts": "./src/index.ts", - "entry": [ - "./src/index.ts" - ], - "format": [ - "esm" - ], - "outDir": "./dist", - "sourcemap": false, - "target": "es2022", - "tsconfig": "../../tsconfig.dts.json" - } -} diff --git a/packages/vuepress-webpack/src/index.ts b/packages/vuepress-webpack/src/index.ts deleted file mode 100644 index 51c63b1523..0000000000 --- a/packages/vuepress-webpack/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '@vuepress/bundler-webpack' -export * from '@vuepress/cli' -export * from '@vuepress/core' diff --git a/packages/vuepress-vite/bin/vuepress.js b/packages/vuepress/bin/vuepress-vite.js similarity index 86% rename from packages/vuepress-vite/bin/vuepress.js rename to packages/vuepress/bin/vuepress-vite.js index 1753e3f4a1..e53ca2947c 100755 --- a/packages/vuepress-vite/bin/vuepress.js +++ b/packages/vuepress/bin/vuepress-vite.js @@ -3,5 +3,4 @@ import { viteBundler } from '@vuepress/bundler-vite' import { cli } from '@vuepress/cli' -// set default bundler cli({ bundler: viteBundler() }) diff --git a/packages/vuepress-webpack/bin/vuepress.js b/packages/vuepress/bin/vuepress-webpack.js similarity index 86% rename from packages/vuepress-webpack/bin/vuepress.js rename to packages/vuepress/bin/vuepress-webpack.js index 2d0030e132..0985d7decf 100755 --- a/packages/vuepress-webpack/bin/vuepress.js +++ b/packages/vuepress/bin/vuepress-webpack.js @@ -3,5 +3,4 @@ import { webpackBundler } from '@vuepress/bundler-webpack' import { cli } from '@vuepress/cli' -// set default bundler cli({ bundler: webpackBundler() }) diff --git a/packages/vuepress/bin/vuepress.js b/packages/vuepress/bin/vuepress.js index 9cf8b74c1e..fc03ca398b 100755 --- a/packages/vuepress/bin/vuepress.js +++ b/packages/vuepress/bin/vuepress.js @@ -1,3 +1,5 @@ #!/usr/bin/env node -import 'vuepress-vite/bin' +import { cli } from '@vuepress/cli' + +cli() diff --git a/packages/vuepress/package.json b/packages/vuepress/package.json index f983c84190..8f1ed9e6a9 100644 --- a/packages/vuepress/package.json +++ b/packages/vuepress/package.json @@ -22,12 +22,20 @@ "exports": { ".": "./dist/index.js", "./bin": "./bin/vuepress.js", + "./cli": "./dist/cli.js", + "./client": "./dist/client.js", + "./core": "./dist/core.js", + "./markdown": "./dist/markdown.js", + "./shared": "./dist/shared.js", + "./utils": "./dist/utils.js", "./package.json": "./package.json" }, "main": "./dist/index.js", "types": "./dist/index.d.ts", "bin": { - "vuepress": "./bin/vuepress.js" + "vuepress": "./bin/vuepress.js", + "vuepress-vite": "./bin/vuepress-vite.js", + "vuepress-webpack": "./bin/vuepress-webpack.js" }, "files": [ "bin", @@ -38,16 +46,50 @@ "clean": "rimraf dist" }, "dependencies": { - "vuepress-vite": "workspace:*" + "@vuepress/cli": "workspace:*", + "@vuepress/client": "workspace:*", + "@vuepress/core": "workspace:*", + "@vuepress/markdown": "workspace:*", + "@vuepress/shared": "workspace:*", + "@vuepress/utils": "workspace:*", + "vue": "^3.3.13" + }, + "peerDependencies": { + "@vuepress/bundler-vite": "workspace:*", + "@vuepress/bundler-webpack": "workspace:*", + "@vuepress/client": "workspace:*", + "vue": "^3.3.13" + }, + "peerDependenciesMeta": { + "@vuepress/bundler-vite": { + "optional": true + }, + "@vuepress/bundler-webpack": { + "optional": true + } }, "engines": { "node": ">=18.16.0" }, "tsup": { "clean": true, - "dts": "./src/index.ts", + "dts": [ + "./src/index.ts", + "./src/cli.ts", + "./src/client.ts", + "./src/core.ts", + "./src/markdown.ts", + "./src/shared.ts", + "./src/utils.ts" + ], "entry": [ - "./src/index.ts" + "./src/index.ts", + "./src/cli.ts", + "./src/client.ts", + "./src/core.ts", + "./src/markdown.ts", + "./src/shared.ts", + "./src/utils.ts" ], "format": [ "esm" diff --git a/packages/vuepress/src/cli.ts b/packages/vuepress/src/cli.ts new file mode 100644 index 0000000000..fd1e8bdbc7 --- /dev/null +++ b/packages/vuepress/src/cli.ts @@ -0,0 +1 @@ +export * from '@vuepress/cli' diff --git a/packages/vuepress/src/client.ts b/packages/vuepress/src/client.ts new file mode 100644 index 0000000000..57c6b046c4 --- /dev/null +++ b/packages/vuepress/src/client.ts @@ -0,0 +1 @@ +export * from '@vuepress/client' diff --git a/packages/vuepress/src/core.ts b/packages/vuepress/src/core.ts new file mode 100644 index 0000000000..e79b01dffd --- /dev/null +++ b/packages/vuepress/src/core.ts @@ -0,0 +1 @@ +export * from '@vuepress/core' diff --git a/packages/vuepress/src/index.ts b/packages/vuepress/src/index.ts index 99b96bf30a..39195b1858 100644 --- a/packages/vuepress/src/index.ts +++ b/packages/vuepress/src/index.ts @@ -1 +1,2 @@ -export * from 'vuepress-vite' +export * from '@vuepress/cli' +export * from '@vuepress/core' diff --git a/packages/vuepress/src/markdown.ts b/packages/vuepress/src/markdown.ts new file mode 100644 index 0000000000..690b8c35f4 --- /dev/null +++ b/packages/vuepress/src/markdown.ts @@ -0,0 +1 @@ +export * from '@vuepress/markdown' diff --git a/packages/vuepress/src/shared.ts b/packages/vuepress/src/shared.ts new file mode 100644 index 0000000000..89bac4b763 --- /dev/null +++ b/packages/vuepress/src/shared.ts @@ -0,0 +1 @@ +export * from '@vuepress/shared' diff --git a/packages/vuepress/src/utils.ts b/packages/vuepress/src/utils.ts new file mode 100644 index 0000000000..c718701139 --- /dev/null +++ b/packages/vuepress/src/utils.ts @@ -0,0 +1 @@ +export * from '@vuepress/utils' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e128fc7975..27c662e62a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -110,6 +110,9 @@ importers: vue: specifier: ^3.3.13 version: 3.3.13(typescript@5.3.3) + vuepress: + specifier: workspace:* + version: link:../packages/vuepress devDependencies: anywhere: specifier: ^1.6.0 @@ -409,44 +412,31 @@ importers: version: 2.0.1 packages/vuepress: - dependencies: - vuepress-vite: - specifier: workspace:* - version: link:../vuepress-vite - - packages/vuepress-vite: dependencies: '@vuepress/bundler-vite': specifier: workspace:* version: link:../bundler-vite - '@vuepress/cli': - specifier: workspace:* - version: link:../cli - '@vuepress/core': - specifier: workspace:* - version: link:../core - vue: - specifier: ^3.3.13 - version: 3.3.13(typescript@5.3.3) - devDependencies: - '@vuepress/client': - specifier: workspace:* - version: link:../client - - packages/vuepress-webpack: - dependencies: '@vuepress/bundler-webpack': specifier: workspace:* version: link:../bundler-webpack '@vuepress/cli': specifier: workspace:* version: link:../cli + '@vuepress/client': + specifier: workspace:* + version: link:../client '@vuepress/core': specifier: workspace:* version: link:../core - sass-loader: - specifier: ^13.3.2 - version: 13.3.2(sass@1.69.5)(webpack@5.89.0) + '@vuepress/markdown': + specifier: workspace:* + version: link:../markdown + '@vuepress/shared': + specifier: workspace:* + version: link:../shared + '@vuepress/utils': + specifier: workspace:* + version: link:../utils vue: specifier: ^3.3.13 version: 3.3.13(typescript@5.3.3) diff --git a/tsconfig.json b/tsconfig.json index 161cf884dd..208cf5051a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,7 @@ "paths": { "@internal/*": ["./packages/client/src/types/internal/*.d.ts"], "@vuepress/*": ["./packages/*/src"], - "vuepress": ["./packages/vuepress/src"], - "vuepress-vite": ["./packages/vuepress-vite/src"], - "vuepress-webpack": ["./packages/vuepress-webpack/src"] + "vuepress": ["./packages/vuepress/src"] }, "types": ["webpack-env", "vite/client"] }, diff --git a/vitest.config.ts b/vitest.config.ts index a5925acf9f..54eb7ee43b 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -8,9 +8,8 @@ const getSubDirectories = (dir: string): string[] => .readdirSync(dir) .filter((item) => fs.statSync(path.join(dir, item)).isDirectory()) const root = path.dirname(fileURLToPath(import.meta.url)) -const nonScopedPackages = ['vuepress', 'vuepress-vite', 'vuepress-webpack'] const packages = getSubDirectories(path.resolve(root, 'packages')).filter( - (item) => !nonScopedPackages.includes(item), + (item) => item !== 'vuepress', ) export default defineConfig({