@modern-js/main-doc 2.0.0-beta.1 → 2.0.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/build.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/dev.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/lint.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/start.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/test.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/overview.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +17 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/auto-actions.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/connect.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-app.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-store.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/handle-effect.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/model_.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-local-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-static-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +1 -23
- package/en/docusaurus-plugin-content-docs/current/components/command-tip.md +56 -0
- package/en/docusaurus-plugin-content-docs/current/components/reduck-migration.md +1 -0
- package/en/docusaurus-plugin-content-docs/current/components/reduck-tip.md +5 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/asset-prefix.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/hmr.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/https.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/port.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/progress-bar.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/start-url.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/experiments/lazy-compilation.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/app-icon.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/crossorigin.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/disable-html-folder.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/mount-id.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/asset-prefix.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/assets-retry.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/charset.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/clean-dist-path.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/convert-to-rem.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/copy.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/css-module-local-ident-name.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/data-uri-limit.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-extract.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-module-extension.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-filename-hash.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-inline-runtime-chunk.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-minimize.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-source-map.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-ts-checker.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/dist-path.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-fallback.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-manifest.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-css-module-tsdeclaration.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-scripts.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-styles.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-latest-decorators.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/externals.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/filename.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/legal-comments.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/override-browserslist.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/polyfill.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/svg-default-export.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/build-cache.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/bundle-analyze.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/chunk-split.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/print-file-size.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/profile.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-console.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-moment-locale.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/security/sri.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/alias.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/compile-js-data-uri.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/define.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/exclude.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/global-vars.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/include.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/module-scopes.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/pre-entry.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-extension-prefix.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-main-fields.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/autoprefixer.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/babel.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-extract.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-loader.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/dev-server.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/html-plugin.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/inspector.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/less.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/minify-css.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/postcss.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/pug.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/sass.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/style-loader.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/styled-components.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/swc.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/terser.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-checker.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-loader.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack-chain.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/builder.md +46 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/app.md +152 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/ejs.md +56 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/fs.md +54 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/git.md +49 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/handlebars.md +58 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/json.md +59 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/npm.md +49 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/develop.md +52 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/introduce.md +46 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/run-in-js.md +48 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/structure.md +87 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +106 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/module.md +39 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/monorepo.md +28 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/mwa.md +89 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/abstract.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addFile.md +52 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addHelper.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addManyFile.md +58 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addPartial.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/introduce.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/rmDir.md +24 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/rmFile.md +24 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +54 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateModernConfig.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.md +20 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/initGitRepo.md +16 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/isInGitRepo.md +16 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/afterForged.md +35 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/onForged.md +36 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/isFileExit.md +22 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/locale.md +17 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/readDir.md +22 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +57 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +56 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInput.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInputValue.md +30 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/type.md +65 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/introduce.md +91 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/createElement.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/createSubProject.md +35 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/enableFunc.md +44 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/introduce.md +15 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/npm/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/npm/install.md +18 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/develop.md +125 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/use.md +61 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +118 -0
- package/en/docusaurus-plugin-content-docs/current.json +57 -21
- package/package.json +3 -3
- package/scripts/config.ts +2 -2
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/zh/apis/app/commands/new.md +0 -3
- package/zh/apis/app/hooks/server/test.md +2 -2
- package/zh/apis/app/runtime/app/_category_.json +1 -1
- package/zh/apis/app/runtime/bff/_category_.json +1 -1
- package/zh/apis/app/runtime/core/_category_.json +1 -1
- package/zh/apis/app/runtime/core/bootstrap.md +17 -3
- package/zh/apis/app/runtime/model/_category_.json +1 -1
- package/zh/apis/app/runtime/model/create-app.md +1 -1
- package/zh/apis/app/runtime/model/use-store.md +1 -23
- package/zh/apis/app/runtime/router/_category_.json +1 -1
- package/zh/apis/app/runtime/ssr/_category_.json +1 -1
- package/zh/apis/app/runtime/testing/_category_.json +1 -1
- package/zh/apis/app/runtime/utility/_category_.json +1 -1
- package/zh/apis/app/runtime/web-server/_category_.json +1 -1
- package/zh/apis/app/runtime/web-server/hook.md +4 -4
- package/zh/apis/app/runtime/web-server/middleware.md +4 -4
- package/zh/components/reduck-migration.md +1 -0
- package/zh/configure/app/dev/asset-prefix.md +1 -1
- package/zh/configure/app/dev/hmr.md +1 -1
- package/zh/configure/app/dev/https.md +1 -1
- package/zh/configure/app/dev/port.md +1 -1
- package/zh/configure/app/dev/progress-bar.md +1 -1
- package/zh/configure/app/dev/start-url.md +1 -1
- package/zh/configure/app/experiments/_category_.json +4 -0
- package/zh/configure/app/experiments/lazy-compilation.md +1 -1
- package/zh/configure/app/html/_category_.json +4 -0
- package/zh/configure/app/html/app-icon.md +1 -1
- package/zh/configure/app/html/crossorigin.md +1 -1
- package/zh/configure/app/html/disable-html-folder.md +1 -1
- package/zh/configure/app/html/favicon-by-entries.md +1 -1
- package/zh/configure/app/html/favicon.md +1 -1
- package/zh/configure/app/html/inject-by-entries.md +1 -1
- package/zh/configure/app/html/inject.md +1 -1
- package/zh/configure/app/html/meta-by-entries.md +1 -1
- package/zh/configure/app/html/meta.md +1 -1
- package/zh/configure/app/html/mount-id.md +1 -1
- package/zh/configure/app/html/template-by-entries.md +1 -1
- package/zh/configure/app/html/template-parameters-by-entries.md +1 -1
- package/zh/configure/app/html/template-parameters.md +1 -1
- package/zh/configure/app/html/template.md +1 -1
- package/zh/configure/app/html/title-by-entries.md +1 -1
- package/zh/configure/app/html/title.md +1 -1
- package/zh/configure/app/output/asset-prefix.md +1 -1
- package/zh/configure/app/output/assets-retry.md +1 -1
- package/zh/configure/app/output/charset.md +1 -1
- package/zh/configure/app/output/clean-dist-path.md +1 -1
- package/zh/configure/app/output/convert-to-rem.md +1 -1
- package/zh/configure/app/output/copy.md +1 -1
- package/zh/configure/app/output/css-module-local-ident-name.md +1 -1
- package/zh/configure/app/output/data-uri-limit.md +1 -1
- package/zh/configure/app/output/disable-css-extract.md +12 -0
- package/zh/configure/app/output/disable-css-module-extension.md +1 -1
- package/zh/configure/app/output/disable-filename-hash.md +1 -1
- package/zh/configure/app/output/disable-inline-runtime-chunk.md +1 -1
- package/zh/configure/app/output/disable-minimize.md +1 -1
- package/zh/configure/app/output/disable-source-map.md +1 -1
- package/zh/configure/app/output/disable-ts-checker.md +1 -1
- package/zh/configure/app/output/dist-path.md +1 -1
- package/zh/configure/app/output/enable-asset-fallback.md +1 -1
- package/zh/configure/app/output/enable-asset-manifest.md +1 -1
- package/zh/configure/app/output/enable-css-module-tsdeclaration.md +1 -1
- package/zh/configure/app/output/enable-inline-scripts.md +1 -1
- package/zh/configure/app/output/enable-inline-styles.md +1 -1
- package/zh/configure/app/output/enable-latest-decorators.md +1 -1
- package/zh/configure/app/output/externals.md +1 -1
- package/zh/configure/app/output/filename.md +1 -1
- package/zh/configure/app/output/legal-comments.md +1 -1
- package/zh/configure/app/output/override-browserslist.md +1 -1
- package/zh/configure/app/output/polyfill.md +1 -1
- package/zh/configure/app/output/ssg.md +118 -114
- package/zh/configure/app/output/svg-default-export.md +1 -1
- package/zh/configure/app/performance/_category_.json +4 -0
- package/zh/configure/app/performance/build-cache.md +1 -1
- package/zh/configure/app/performance/bundle-analyze.md +1 -1
- package/zh/configure/app/performance/chunk-split.md +1 -1
- package/zh/configure/app/performance/print-file-size.md +1 -1
- package/zh/configure/app/performance/profile.md +1 -1
- package/zh/configure/app/performance/remove-console.md +1 -1
- package/zh/configure/app/performance/remove-moment-locale.md +1 -1
- package/zh/configure/app/plugins.md +1 -1
- package/zh/configure/app/runtime/state.md +13 -0
- package/zh/configure/app/security/_category_.json +4 -0
- package/zh/configure/app/security/sri.md +1 -1
- package/zh/configure/app/server/ssr.md +0 -2
- package/zh/configure/app/source/alias.md +1 -1
- package/zh/configure/app/source/compile-js-data-uri.md +1 -1
- package/zh/configure/app/source/define.md +1 -1
- package/zh/configure/app/source/exclude.md +1 -1
- package/zh/configure/app/source/global-vars.md +1 -1
- package/zh/configure/app/source/include.md +1 -1
- package/zh/configure/app/source/module-scopes.md +1 -1
- package/zh/configure/app/source/pre-entry.md +1 -1
- package/zh/configure/app/source/resolve-extension-prefix.md +1 -1
- package/zh/configure/app/source/resolve-main-fields.md +1 -1
- package/zh/configure/app/tools/autoprefixer.md +1 -1
- package/zh/configure/app/tools/babel.md +1 -1
- package/zh/configure/app/tools/css-extract.md +1 -1
- package/zh/configure/app/tools/css-loader.md +1 -1
- package/zh/configure/app/tools/dev-server.md +1 -1
- package/zh/configure/app/tools/html-plugin.md +1 -1
- package/zh/configure/app/tools/inspector.md +1 -1
- package/zh/configure/app/tools/less.md +1 -1
- package/zh/configure/app/tools/minify-css.md +1 -1
- package/zh/configure/app/tools/postcss.md +1 -1
- package/zh/configure/app/tools/pug.md +1 -1
- package/zh/configure/app/tools/sass.md +1 -1
- package/zh/configure/app/tools/style-loader.md +1 -1
- package/zh/configure/app/tools/styled-components.md +1 -1
- package/zh/configure/app/tools/swc.md +42 -0
- package/zh/configure/app/tools/terser.md +1 -1
- package/zh/configure/app/tools/ts-checker.md +1 -1
- package/zh/configure/app/tools/ts-loader.md +1 -1
- package/zh/configure/app/tools/webpack-chain.md +1 -1
- package/zh/configure/app/tools/webpack.md +1 -1
- package/zh/guides/advanced-features/bff/_category_.json +5 -1
- package/zh/guides/advanced-features/bff/bff-proxy.md +5 -3
- package/zh/guides/advanced-features/bff/frameworks.md +72 -51
- package/zh/guides/advanced-features/bff/function.md +16 -30
- package/zh/guides/advanced-features/bff/index.md +20 -0
- package/zh/guides/advanced-features/bff/type.md +43 -0
- package/zh/guides/advanced-features/custom-app.md +69 -1
- package/zh/guides/advanced-features/ssg.md +74 -63
- package/zh/guides/advanced-features/ssr.md +74 -11
- package/zh/guides/advanced-features/web-server.md +21 -110
- package/zh/guides/basic-features/builder.md +46 -0
- package/zh/guides/basic-features/css/_category_.json +1 -1
- package/zh/guides/basic-features/css/less-sass.md +1 -14
- package/zh/guides/basic-features/data-fetch.md +62 -1
- package/zh/guides/basic-features/env-vars.md +122 -41
- package/zh/guides/basic-features/routes.md +264 -0
- package/zh/guides/concept/entries.md +112 -0
- package/zh/guides/concept/lifecycle.md +10 -0
- package/zh/guides/get-started/quick-start.md +199 -1
- package/zh/guides/get-started/upgrade.md +75 -1
- package/zh/guides/topic-detail/framework-plugin/extend.md +3 -4
- package/zh/{apis/app/runtime/plugin/hook-api.md → guides/topic-detail/framework-plugin/hook-list.md} +42 -135
- package/zh/{apis/app/runtime/plugin → guides/topic-detail/framework-plugin}/hook.md +2 -3
- package/zh/guides/topic-detail/framework-plugin/implement.md +21 -10
- package/zh/guides/topic-detail/framework-plugin/introduction.md +49 -0
- package/{en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin → zh/guides/topic-detail/framework-plugin}/plugin-api.md +3 -4
- package/zh/guides/topic-detail/framework-plugin/relationship.md +2 -3
- package/zh/guides/topic-detail/generator/codesmith/api/_category_.json +4 -0
- package/zh/guides/topic-detail/generator/codesmith/api/app.md +152 -0
- package/zh/guides/topic-detail/generator/codesmith/api/ejs.md +56 -0
- package/zh/guides/topic-detail/generator/codesmith/api/fs.md +54 -0
- package/zh/guides/topic-detail/generator/codesmith/api/git.md +48 -0
- package/zh/guides/topic-detail/generator/codesmith/api/handlebars.md +56 -0
- package/zh/guides/topic-detail/generator/codesmith/api/json.md +58 -0
- package/zh/guides/topic-detail/generator/codesmith/api/npm.md +45 -0
- package/zh/guides/topic-detail/generator/codesmith/develop.md +52 -0
- package/zh/guides/topic-detail/generator/codesmith/introduce.md +42 -1
- package/zh/guides/topic-detail/generator/codesmith/run-in-js.md +48 -0
- package/zh/guides/topic-detail/generator/codesmith/structure.md +86 -0
- package/zh/guides/topic-detail/generator/config/mwa.md +4 -8
- package/zh/guides/topic-detail/generator/plugin/api/file/addFile.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/addHelper.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/addPartial.md +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/rmDir.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/rmFile.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +3 -2
- package/zh/guides/topic-detail/generator/plugin/api/file/updateModernConfig.md +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/hook/afterForged.md +3 -3
- package/zh/guides/topic-detail/generator/plugin/api/hook/onForged.md +3 -3
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/createElement.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/createSubProject.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/npm/install.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/develop.md +11 -7
- package/zh/guides/topic-detail/model/quick-start.md +4 -0
- package/zh/guides/topic-detail/monorepo/sub-project-interface.md +0 -2
- package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +2 -2
- package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +2 -2
- package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +5 -2
- package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +0 -8
- package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +12 -6
- package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +2 -4
- package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +1 -1
- package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +44 -50
- package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +1 -1
- package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +4 -4
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +8 -21
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +37 -13
- package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +3 -13
- package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +1 -21
- package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +9 -9
- package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +9 -14
- package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +7 -7
- package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +1 -1
- package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +2 -2
- package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +8 -17
- package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +24 -19
- package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +31 -35
- package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +4 -9
- package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +66 -63
- package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +35 -33
- package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +28 -102
- package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +4 -6
- package/zh/tutorials/first-app/c10-model/10.2-add-model.md +3 -3
- package/zh/tutorials/first-app/c10-model/10.3-use-model.md +21 -20
- package/zh/tutorials/first-app/c10-model/10.4-testing.md +2 -2
- package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +34 -68
- package/zh/tutorials/first-app/c11-container/11.2-add-container.md +40 -37
- package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +6 -4
- package/zh/tutorials/first-app/c11-container/11.4-testing.md +2 -2
- package/zh/tutorials/foundations/introduction.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/default-alias.md +0 -25
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/env.md +0 -72
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/_category_.json +0 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/abstract.md +0 -26
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook-api.md +0 -896
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook.md +0 -170
- package/zh/apis/app/runtime/default-alias.md +0 -23
- package/zh/apis/app/runtime/env.md +0 -70
- package/zh/apis/app/runtime/plugin/_category_.json +0 -4
- package/zh/apis/app/runtime/plugin/abstract.md +0 -26
- package/zh/apis/app/runtime/plugin/plugin-api.md +0 -117
- package/zh/components/deploy.md +0 -60
- package/zh/components/dev-ide.md +0 -1
- package/zh/components/entry-name.md +0 -15
- package/zh/components/env-prepare.md +0 -1
- package/zh/components/launch-bff-choices.md +0 -6
- package/zh/guides/advanced-features/bff/bff-server.md +0 -142
- package/zh/guides/advanced-features/typescript.md +0 -4
- package/zh/guides/basic-features/image.md +0 -43
- package/zh/guides/concept/integrated.md +0 -4
- package/zh/guides/concept/solutions.md +0 -4
- package/zh/guides/topic-detail/compile-speed.md +0 -182
- package/zh/guides/topic-detail/framework-plugin/abstract.md +0 -27
- package/zh/guides/troubleshooting/compile.md +0 -379
- package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +0 -318
@@ -1,10 +1,9 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
title: 如何编写插件
|
3
|
+
sidebar_position: 3
|
3
4
|
---
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
Modern.js 支持通过自定义插件的方式来实现个性化功能。
|
6
|
+
上一小节介绍了 Modern.js 插件的 Hook 模型,这一小节介绍如何编写插件。
|
8
7
|
|
9
8
|
## 实现插件
|
10
9
|
|
@@ -31,6 +30,8 @@ const MyPlugin = {
|
|
31
30
|
};
|
32
31
|
```
|
33
32
|
|
33
|
+
另外,在插件中,允许配置与其他插件的执行顺序,详情可以参考[插件关系](/docs/guides/topic-detail/framework-plugin/relationship)。
|
34
|
+
|
34
35
|
### 插件类型
|
35
36
|
|
36
37
|
使用 TypeScript 时,可以引入内置的 `CliPlugin` 类型,为插件提供正确的类型推导:
|
@@ -53,9 +54,19 @@ const MyPlugin: CliPlugin = {
|
|
53
54
|
};
|
54
55
|
```
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
Modern.js 导出的 `Plugin` 类型支持泛型扩展。
|
58
|
+
|
59
|
+
在 Modern.js 中,任意插件可以注册自己的 Hook,如果想拥有其他插件注册的 Hook 的类型,可以添加泛型:
|
60
|
+
|
61
|
+
```ts
|
62
|
+
import type { CliPlugin } from '@modern-js/core';
|
63
|
+
import type { MyPluginHook } from 'xxx';
|
64
|
+
|
65
|
+
const MyPlugin: CliPlugin<MyPluginHook> = {};
|
66
|
+
```
|
67
|
+
|
68
|
+
详细说明,请参考 [扩展 Hook](/docs/guides/topic-detail/framework-plugin/extend)。
|
69
|
+
|
59
70
|
|
60
71
|
### 插件配置项
|
61
72
|
|
@@ -79,7 +90,7 @@ const MyPlugin = (options: MyPluginOptions): CliPlugin => ({
|
|
79
90
|
|
80
91
|
### 插件 API
|
81
92
|
|
82
|
-
插件的 setup 函数会接收一个 api 入参,你可以调用 api 上提供的一些方法来获取到配置、应用上下文等信息。
|
93
|
+
插件的 `setup` 函数会接收一个 api 入参,你可以调用 api 上提供的一些方法来获取到配置、应用上下文等信息。
|
83
94
|
|
84
95
|
```ts
|
85
96
|
import type { CliPlugin } from '@modern-js/core';
|
@@ -98,7 +109,7 @@ export default (): CliPlugin => ({
|
|
98
109
|
});
|
99
110
|
```
|
100
111
|
|
101
|
-
插件 API 的详细说明,请参考 [Plugin API](/docs/
|
112
|
+
插件 API 的详细说明,请参考 [Plugin API](/docs/guides/topic-detail/framework-plugin/plugin-api)。
|
102
113
|
|
103
114
|
### 异步 setup
|
104
115
|
|
@@ -149,7 +160,7 @@ export default defineConfig({
|
|
149
160
|
|
150
161
|
### 在 npm 上发布插件
|
151
162
|
|
152
|
-
如果需要将 Modern.js 插件发布到 npm,推荐使用 Modern.js
|
163
|
+
如果需要将 Modern.js 插件发布到 npm,推荐使用 Modern.js 中的模块工程方案来管理和构建。
|
153
164
|
|
154
165
|
首先创建一个空的模块工程方案项目,调整 npm 包名称:
|
155
166
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
title: 介绍
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
## Modern.js 插件系统
|
7
|
+
|
8
|
+
Modern.js 用于扩展项目运行、请求、渲染等不同阶段功能的系统,主要分为三个部分:Hook 模型、管理器,上下文共享机制。
|
9
|
+
|
10
|
+
Hook 模型用于确定当前 Hook 的执行方式,不同 Hook 模型的函数拥有不同的执行逻辑。管理器用于控制 Hook 的执行与调度。上下文共享机制用于在不同 Hook 间传递信息。
|
11
|
+
|
12
|
+
目前 Modern.js 提供几种不同的 Hook 模型:
|
13
|
+
|
14
|
+
- Pipeline
|
15
|
+
- Sync
|
16
|
+
- Async
|
17
|
+
- Waterfall
|
18
|
+
- Sync
|
19
|
+
- Async
|
20
|
+
- Workflow
|
21
|
+
- Sync
|
22
|
+
- Async
|
23
|
+
- Parallel(Async)
|
24
|
+
|
25
|
+
:::note
|
26
|
+
后续章节详细介绍各个模型的执行方式。
|
27
|
+
:::
|
28
|
+
|
29
|
+
基于 Hook 模型和管理器,Modern.js 暴露了三套插件:CLI、Runtime、Server。
|
30
|
+
|
31
|
+
其中 CLI 插件是 Modern.js 中主要的运行流程控制模型,Modern.js 中绝大部分功能都是主要通过这一套模型运行的。Runtime 插件主要负责处理 React 组件渲染逻辑。Server 插件主要用于对服务端的生命周期以及用户请求的控制。
|
32
|
+
|
33
|
+
## 插件可以做什么
|
34
|
+
|
35
|
+
Modern.js 的所有功能都是通过这套插件实现的,这意味着 Modern.js 中的所有能力是都对开发者开放的。开发者可以通过编写插件来扩展更多功能,适配复杂场景,包括但不限于:
|
36
|
+
|
37
|
+
- 注册命令
|
38
|
+
- 修改 Modern.js 配置、配置校验 Schema
|
39
|
+
- 修改编译时的 Webpack/Babel/Less/Sass/Tailwind CSS/... 配置
|
40
|
+
- 修改运行时需要渲染的 React 组件、Element
|
41
|
+
- 修改页面路由
|
42
|
+
- 修改服务器路由
|
43
|
+
- 自定义控制台输出
|
44
|
+
- 自定义动态 HTML 模版
|
45
|
+
- 自定义 Node.js 服务器框架
|
46
|
+
- 自定义 React 组件客户端/服务器端渲染
|
47
|
+
- ...
|
48
|
+
|
49
|
+
当 Modern.js 暂时没有覆盖到你所需要的功能或场景时,可以开发一个自定义插件,来实现适配特殊场景的相关功能。
|
@@ -1,10 +1,9 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
title: 插件 API
|
3
|
+
sidebar_position: 6
|
3
4
|
---
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
插件的 setup 函数会接收一个 api 入参,你可以调用 api 上提供的一些方法来获取到配置、应用上下文等信息。
|
6
|
+
插件的 `setup` 函数会接收一个 `api` 入参,你可以调用 api 上提供的一些方法来获取到配置、应用上下文等信息。
|
8
7
|
|
9
8
|
```ts
|
10
9
|
import type { CliPlugin } from '@modern-js/core';
|
@@ -0,0 +1,152 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 1
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-app
|
6
|
+
|
7
|
+
微生成器开发过程中常用 API 的组合封装,包含 fs、git、npm 等其他包的 API 封装,在能满足需求时,推荐使用该 npm 包的 API。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { AppAPI } from '@modern-js/codesmith-api-app';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const appApi = new AppAPI(context, generator);
|
16
|
+
await appApi.runInstall();
|
17
|
+
}
|
18
|
+
```
|
19
|
+
|
20
|
+
- 创建 AppAPI 实例,参数和微生成器函数参数一致,为 context 和 generator,具体介绍请看[微生成器项目组成](/docs/guides/topic-detail/generator/codesmith/structure)。
|
21
|
+
- 调用其实例上 API 即可。
|
22
|
+
|
23
|
+
## API
|
24
|
+
|
25
|
+
### checkEnvironment
|
26
|
+
|
27
|
+
检查当前生成器运行环境,检查项为:
|
28
|
+
|
29
|
+
1. node 及 node 版本,默认大于 12.22.12,可传递参数执行 node 版本。
|
30
|
+
2. 可使用 yarn、pnpm 或者 npm。
|
31
|
+
|
32
|
+
参数:
|
33
|
+
|
34
|
+
- nodeVersion?: `string` 校验的 node 版本。
|
35
|
+
|
36
|
+
### runInstall
|
37
|
+
|
38
|
+
安装依赖,可传入安装依赖命令,默认根据 config 中的 `packageManager` 值进行。
|
39
|
+
|
40
|
+
参数:
|
41
|
+
|
42
|
+
- command?: `string` 安装依赖命令。
|
43
|
+
|
44
|
+
### runGitAndInstall
|
45
|
+
|
46
|
+
该函数完成以下动作:
|
47
|
+
|
48
|
+
1. 校验当前生成器执行目录是否为一个 git 仓库。
|
49
|
+
2. 如果不是一个 git 仓库,初始化为一个 git 仓库。
|
50
|
+
3. 安装依赖。
|
51
|
+
4. 在非 monorepo 项目(判断条件,config 中 `isMonorepoSubProject` 不存在或者为 false)中提交初始 commit,commit 信息为 feat: init,支持自定义。
|
52
|
+
|
53
|
+
参数:
|
54
|
+
- commitMessage?: `string` 初始化 commit message 信息。
|
55
|
+
- installFunc?: `() => Promise<void>` 安装依赖函数。
|
56
|
+
|
57
|
+
### forgeTemplate
|
58
|
+
|
59
|
+
渲染生成器模板文件。
|
60
|
+
|
61
|
+
参数:
|
62
|
+
|
63
|
+
- templatePattern: string 模板文件匹配正则,例如: `templates/base-templates/**/*` 。
|
64
|
+
- filter?: `(resourceKey: string) => boolean` 过滤函数,参数为 templatePattern 匹配的文件路径,返回 true 表示渲染该文件,返回 false 表示不渲染该文件。
|
65
|
+
- rename?: `(resourceKey: string) => string` 重命名函数,参数为 templatePattern 匹配的文件路径,返回新文件名。默认会替换 resourceKey 开头的 templates 目录和结尾的 .handlebars 后缀。
|
66
|
+
- parameters?: `Record<string, any>` 渲染参数,当模板中存在 handlebars 或者 ejs 变量时,使用其传递对应变量值。
|
67
|
+
- type?: `'handlebars' | 'ejs'` 模板文件类型,默认为 handlebars。
|
68
|
+
|
69
|
+
例如:
|
70
|
+
|
71
|
+
```typescript
|
72
|
+
await appApi.forgeTemplate(
|
73
|
+
'templates/base-templates/**/*',
|
74
|
+
undefined,
|
75
|
+
resourceKey =>
|
76
|
+
resourceKey
|
77
|
+
.replace('templates/base-templates/', '')
|
78
|
+
.replace('.handlebars', ''),
|
79
|
+
);
|
80
|
+
|
81
|
+
await appApi.forgeTemplate(
|
82
|
+
'templates/base-template/**/*',
|
83
|
+
resourceKey => !resourceKey.include('eslintrc.json'),
|
84
|
+
resourceKey =>
|
85
|
+
resourceKey
|
86
|
+
.replace('templates/base-template/', projectPath)
|
87
|
+
.replace('language', language as string)
|
88
|
+
.replace('.handlebars', ''),
|
89
|
+
{
|
90
|
+
name: packageName as string,
|
91
|
+
language,
|
92
|
+
isTs: language === Language.TS,
|
93
|
+
packageManager: getPackageManagerText(packageManager as any),
|
94
|
+
},
|
95
|
+
);
|
96
|
+
```
|
97
|
+
|
98
|
+
### showSuccessInfo
|
99
|
+
|
100
|
+
展示成功信息。
|
101
|
+
|
102
|
+
参数:
|
103
|
+
|
104
|
+
- successInfo?: `string`,默认为 Success || 成功。
|
105
|
+
|
106
|
+
### runSubGenerator
|
107
|
+
|
108
|
+
运行子生成器。
|
109
|
+
|
110
|
+
参数:
|
111
|
+
|
112
|
+
- subGenerator: `string` 子生成器名称或者路径。
|
113
|
+
- relativePwdPath?: `string` 子生成器运行的相对路径。
|
114
|
+
- config?: `Record<string, unknown>` 子生成器运行的默认 config 配置。
|
115
|
+
|
116
|
+
例如:
|
117
|
+
|
118
|
+
```typescript
|
119
|
+
await appApi.runSubGenerator(
|
120
|
+
getGeneratorPath('@modern-js/repo-generator', context.config.distTag),
|
121
|
+
undefined,
|
122
|
+
{ ...context.config, hasPlugin: false },
|
123
|
+
);
|
124
|
+
```
|
125
|
+
|
126
|
+
### getInputBySchema
|
127
|
+
|
128
|
+
通过 schema 完成用户交互输入。
|
129
|
+
|
130
|
+
参数:
|
131
|
+
|
132
|
+
- schema: `FormilySchema | Question[]` 问题列表,支持 Formily schema 和 inquirer 类型。
|
133
|
+
- type: `'formily' | 'inquirer'` 类型,默认值为 formily。
|
134
|
+
- configValue: `Record<string, unknown> = {}` schema 默认值,传入该值的 schema 字段对应的问题将不再和用户交互。
|
135
|
+
- validateMap?: `Record<string, (input: unknown, data?: Record<string, unknown>) => { success: boolean; error?: string }>` schema 中特殊字段的验证函数。
|
136
|
+
- initValue?: `Record<string, any>` schema 中字段的初始化值。
|
137
|
+
|
138
|
+
Formily Schema 类型支持方式可参考[自定义输入相关类型定义](/docs/guides/topic-detail/generator/plugin/api/input/type)。
|
139
|
+
|
140
|
+
### getInputBySchemaFunc
|
141
|
+
|
142
|
+
通过 schema 完成用户交互输入,schema 参数值为函数,用户处理国际化问题,仅支持 Formily schema。
|
143
|
+
|
144
|
+
|
145
|
+
参数:
|
146
|
+
|
147
|
+
- schema: `config?: Record<string, any>) => FormilySchema` 获取问题列表函数,config 参数为当前生成器中的 config 配置信息。
|
148
|
+
- configValue: `Record<string, unknown> = {}` schema 默认值,传入该值的 schema 字段对应的问题将不再和用户交互。
|
149
|
+
- validateMap?: `Record<string, (input: unknown, data?: Record<string, unknown>) => { success: boolean; error?: string }>` schema 中特殊字段的验证函数。
|
150
|
+
- initValue?: `Record<string, any>` schema 中字段的初始化值。
|
151
|
+
|
152
|
+
Formily Schema 类型支持方式可参考[自定义输入相关类型定义](/docs/guides/topic-detail/generator/plugin/api/input/type)。
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 6
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-ejs
|
6
|
+
|
7
|
+
微生成器中使用 [ejs](https://ejs.co/) 进行文件操作的 API 封装,提供渲染单个模板文件和文件夹的方法。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { EjsAPI } from '@modern-js/codesmith-api-ejs';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const ejsAPI = new EjsAPI(generator);
|
16
|
+
await ejsAPI.renderTemplate(
|
17
|
+
material.get('templates/a.js'),
|
18
|
+
target: 'b.js',
|
19
|
+
{ data: "data" }
|
20
|
+
);
|
21
|
+
}
|
22
|
+
```
|
23
|
+
|
24
|
+
- 创建 EjsAPI 实例,参数为微生成器函数参数的 generator,具体介绍请看微生成器项目组成 。
|
25
|
+
- 调用其实例上 API 即可。
|
26
|
+
|
27
|
+
## API
|
28
|
+
|
29
|
+
### renderTemplate
|
30
|
+
|
31
|
+
渲染单个模板文件。
|
32
|
+
|
33
|
+
参数:
|
34
|
+
|
35
|
+
- templateResource: `FsResource` 模板文件资源,通过 `context.materials.get(<filename>)` 使用。
|
36
|
+
- target: `string` 目标文件路径名称。
|
37
|
+
- parameters?: `Record<string, string>` 渲染参数。
|
38
|
+
|
39
|
+
### renderTemplateDir
|
40
|
+
|
41
|
+
渲染模板文件夹。
|
42
|
+
|
43
|
+
参数:
|
44
|
+
|
45
|
+
- material: `FsMaterial` 当前微生成器执行的 material 上下文。
|
46
|
+
- findGlob: `string` 模板文件匹配正则。
|
47
|
+
- target: `(globMatch: string) => string` 目标文件路径生成函数,参数为 `resourceKey。`
|
48
|
+
- options?: `RenderTemplateDirOptions` glob 查找文件配置,具体函数可查看这里 [glob](https://www.npmjs.com/package/glob)。
|
49
|
+
|
50
|
+
```typescript
|
51
|
+
type RenderTemplateDirOptions = {
|
52
|
+
nodir?: boolean;
|
53
|
+
dot?: boolean;
|
54
|
+
ignore?: string | readonly string[];
|
55
|
+
};
|
56
|
+
```
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 3
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-fs
|
6
|
+
|
7
|
+
微生成器中文件操作的 API 封装,提供渲染单个模板文件和文件夹的方法。FsAPI 通常用于处理二进制文件或者不能使用 handlebars、ejs 处理的模板文件。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { FsAPI } from '@modern-js/codesmith-api-fs';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const handlebarApi = new HandlebarsAPI(generator);
|
16
|
+
await handlebarsAPI.renderFile(
|
17
|
+
material.get('templates/a.js'),
|
18
|
+
target: 'b.js'
|
19
|
+
);
|
20
|
+
}
|
21
|
+
```
|
22
|
+
|
23
|
+
- 创建 FsAPI 实例,参数为微生成器函数参数的 generator,具体介绍请看微生成器项目组成 。
|
24
|
+
- 调用其实例上 API 即可。
|
25
|
+
|
26
|
+
## API
|
27
|
+
|
28
|
+
### renderFile
|
29
|
+
|
30
|
+
渲染单个模板文件。
|
31
|
+
|
32
|
+
参数:
|
33
|
+
|
34
|
+
- resource: `FsResource` 模板文件资源,通过 `context.materials.get(<filename>)` 使用。
|
35
|
+
- target: `string` 目标文件路径名称。
|
36
|
+
|
37
|
+
### renderDir
|
38
|
+
|
39
|
+
渲染模板文件夹。
|
40
|
+
|
41
|
+
参数:
|
42
|
+
|
43
|
+
- material: `FsMaterial` 当前微生成器执行的 material 上下文。
|
44
|
+
- findGlob: `string` 模板文件匹配正则。
|
45
|
+
- target: `(globMatch: string) => string` 目标文件路径生成函数,参数为 `resourceKey。`
|
46
|
+
- options?: `RenderTemplateDirOptions` glob 查找文件配置,具体函数可查看这里 [glob](https://www.npmjs.com/package/glob)。
|
47
|
+
|
48
|
+
```typescript
|
49
|
+
type RenderTemplateDirOptions = {
|
50
|
+
nodir?: boolean;
|
51
|
+
dot?: boolean;
|
52
|
+
ignore?: string | readonly string[];
|
53
|
+
};
|
54
|
+
```
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 4
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-git
|
6
|
+
|
7
|
+
微生成器中使用 git 相关操作的 API 封装,提供判断 git 仓库,初始化及提交代码等方法。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { GitAPI } from '@modern-js/codesmith-api-git';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const gitApi = new GitAPI(generatorCore, generatorContext);
|
16
|
+
await gitApi.initGitRepo();
|
17
|
+
}
|
18
|
+
```
|
19
|
+
|
20
|
+
- 创建 GitAPI 实例,参数和微生成器函数参数一致,为 context 和 generator,具体介绍请看微生成器项目组成
|
21
|
+
- 调用其实例上 API 即可。
|
22
|
+
|
23
|
+
## API
|
24
|
+
|
25
|
+
### isInGitRepo
|
26
|
+
|
27
|
+
当前目录是否为 git 仓库。
|
28
|
+
|
29
|
+
参数:
|
30
|
+
|
31
|
+
- cwd?: `string` git 命令的执行目录,默认为微生成器 `outputPath`。
|
32
|
+
|
33
|
+
### initGitRepo
|
34
|
+
|
35
|
+
初始化为 git 仓库。init 的默认分支名可通过生成器 config 中的 defaultBranch 进行配置。
|
36
|
+
|
37
|
+
参数:
|
38
|
+
|
39
|
+
- cwd?: `string` git 命令的执行目录,默认为微生成器 `outputPath`。
|
40
|
+
- force?: `boolean` 当前目录已经为 git 仓库时使用该参数会强制执行 git init。
|
41
|
+
|
42
|
+
### addAndCommit
|
43
|
+
|
44
|
+
执行 `git add .` 和 `git commit` 提交当前变更。
|
45
|
+
|
46
|
+
参数:
|
47
|
+
- commitMessage: `string` commit 信息。
|
48
|
+
- cwd?: `string` git 命令的执行目录,默认为微生成器 `outputPath`。
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 5
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-handlebars
|
6
|
+
|
7
|
+
微生成器中使用 [handlebars](https://handlebarsjs.com/) 进行文件操作的 API 封装,提供渲染单个模板文件和文件夹的方法。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { HandlebarsAPI } from '@modern-js/codesmith-api-handlebars';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const handlebarApi = new HandlebarsAPI(generator);
|
16
|
+
await handlebarsAPI.renderTemplate(
|
17
|
+
material.get('templates/a.js'),
|
18
|
+
target: 'b.js',
|
19
|
+
{ data: "data" }
|
20
|
+
);
|
21
|
+
}
|
22
|
+
```
|
23
|
+
|
24
|
+
- 创建 HandlebarsAPI 实例,参数为微生成器函数参数的 generator,具体介绍请看微生成器项目组成 。
|
25
|
+
- 调用其实例上 API 即可。
|
26
|
+
|
27
|
+
## API
|
28
|
+
|
29
|
+
### renderTemplate
|
30
|
+
|
31
|
+
渲染单个模板文件。
|
32
|
+
|
33
|
+
参数:
|
34
|
+
|
35
|
+
- templateResource: `FsResource` 模板文件资源,通过 `context.materials.get(<filename>)` 使用。
|
36
|
+
- target: `string` 目标文件路径名称。
|
37
|
+
- parameters?: `Record<string, string>` 渲染参数。
|
38
|
+
|
39
|
+
### renderTemplateDir
|
40
|
+
|
41
|
+
渲染模板文件夹。
|
42
|
+
|
43
|
+
参数:
|
44
|
+
|
45
|
+
- material: `FsMaterial` 当前微生成器执行的 material 上下文。
|
46
|
+
- findGlob: `string` 模板文件匹配正则。
|
47
|
+
- target: `(globMatch: string) => string` 目标文件路径生成函数,参数为 `resourceKey。`
|
48
|
+
- options?: `RenderTemplateDirOptions` glob 查找文件配置,具体函数可查看这里 [glob](https://www.npmjs.com/package/glob)。
|
49
|
+
|
50
|
+
```typescript
|
51
|
+
type RenderTemplateDirOptions = {
|
52
|
+
nodir?: boolean;
|
53
|
+
dot?: boolean;
|
54
|
+
ignore?: string | readonly string[];
|
55
|
+
};
|
56
|
+
```
|
@@ -0,0 +1,58 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 2
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-json
|
6
|
+
|
7
|
+
微生成器中 JSON API 封装,提供常见的 JSON 文件操作方法。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { JsonAPI } from '@modern-js/codesmith-api-json';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const jsonAPI = new JsonAPI(generator);
|
16
|
+
await jsonAPI.update(
|
17
|
+
context.materials.default.get('package.json'),
|
18
|
+
{
|
19
|
+
query: {},
|
20
|
+
update: {
|
21
|
+
$set: {
|
22
|
+
'dependencies.@modern-js/plugin-bff': `^2.0.0`,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
},
|
26
|
+
);
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
- 创建 JsonAPI 实例,参数为微生成器函数参数的 generator,具体介绍请看[微生成器项目组成](/docs/guides/topic-detail/generator/codesmith/structure)。
|
31
|
+
- 调用其实例上 API 即可。
|
32
|
+
|
33
|
+
## API
|
34
|
+
|
35
|
+
### get
|
36
|
+
|
37
|
+
获取 JSON 文件内容。
|
38
|
+
|
39
|
+
参数:
|
40
|
+
- resource: `FsResource`,文件资源,通过 `context.materials.default.get(<filename>)` 获取。
|
41
|
+
|
42
|
+
### extend
|
43
|
+
|
44
|
+
合并对象至 JSON 文件。
|
45
|
+
|
46
|
+
参数:
|
47
|
+
|
48
|
+
- resource: `FsResource` 通过 `context.materials.default.get(<filename>)` 获取。
|
49
|
+
- obj: `Record<string, any>` 需合并对象。
|
50
|
+
|
51
|
+
### update
|
52
|
+
|
53
|
+
更新对象字段至 JSON 文件。
|
54
|
+
|
55
|
+
参数:
|
56
|
+
|
57
|
+
- resource: `FsResource` 通过 `context.materials.default.get(<filename>)` 获取。
|
58
|
+
- operation: `{ query: Record<string, any>; update: Record<string, any> }` 更新操作,详细使用姿势查看 [declaration-update](https://www.npmjs.com/package/declaration-update)。
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 7
|
3
|
+
---
|
4
|
+
|
5
|
+
# @modern-js/codesmith-api-npm
|
6
|
+
|
7
|
+
微生成器中 NPM API 封装,提供常见的 NPM 不同包管理工具安装依赖的方法。
|
8
|
+
|
9
|
+
## 使用姿势
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import { NpmAPI } from '@modern-js/codesmith-api-npm';
|
13
|
+
|
14
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
+
const npmApi = new NpmAPI(generator);
|
16
|
+
await npmApi.pnpmInstall();
|
17
|
+
}
|
18
|
+
```
|
19
|
+
|
20
|
+
- 创建 NpmAPI 实例,参数为微生成器函数参数的 generator,具体介绍请看微生成器项目组成 。
|
21
|
+
- 调用其实例上 API 即可。
|
22
|
+
|
23
|
+
## API
|
24
|
+
|
25
|
+
### npmInstall
|
26
|
+
|
27
|
+
使用 npm 安装依赖。
|
28
|
+
|
29
|
+
参数:
|
30
|
+
|
31
|
+
- cwd?: `string` install 命令的执行目录,默认为微生成器 `outputPath`。
|
32
|
+
|
33
|
+
### yarnInstall
|
34
|
+
|
35
|
+
使用 yarn 安装依赖。
|
36
|
+
|
37
|
+
参数:
|
38
|
+
- cwd?: `string` install 命令的执行目录,默认为微生成器 `outputPath`。
|
39
|
+
|
40
|
+
### pnpmInstall
|
41
|
+
|
42
|
+
使用 pnpm 安装依赖。
|
43
|
+
|
44
|
+
参数:
|
45
|
+
- cwd?: `string` install 命令的执行目录,默认为微生成器 `outputPath`。
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 3
|
3
|
+
---
|
4
|
+
|
5
|
+
# 开发微生成器项目
|
6
|
+
|
7
|
+
## 创建项目
|
8
|
+
|
9
|
+
Modern.js 提供了创建微生成器项目的微生成器,可以直接通过以下命令创建微生成器项目:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
$ mkdir <projectDir>
|
13
|
+
$ npx @modern-js/codesmith-cli @modern-js/generator-generator
|
14
|
+
|
15
|
+
? 请填写项目名称 <generatorName>
|
16
|
+
? 请选择包管理工具 pnpm
|
17
|
+
? 请选择开发语言 TS
|
18
|
+
```
|
19
|
+
|
20
|
+
## 添加模板文件
|
21
|
+
|
22
|
+
在项目目录的 templates 文件夹,用于存放生成器需要的模板文件,如果没有模板文件,该步骤可跳过。
|
23
|
+
|
24
|
+
## 开发生成器核心逻辑
|
25
|
+
|
26
|
+
默认生成的的项目中,已经实现直接拷贝 templates 目录文件至目标项目,可直接在 `handleTemplateFile` 函数中完成生成器的核心逻辑开发。
|
27
|
+
|
28
|
+
## 测试微生成器
|
29
|
+
|
30
|
+
微生成器开发完成后,需要执行 `pnpm run build` 对代码进行编译,在开发模式下可以使用 `pnpm run build --watch`
|
31
|
+
|
32
|
+
codesmith 提供了 cli 工具用于运行和测试微生成器,在目标目录执行使用如下命令执行即可:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
npx @modern-js/codesmith-cli <generatorPath>
|
36
|
+
```
|
37
|
+
|
38
|
+
其中 generatorPath 为上述生成器项目的绝对路径。
|
39
|
+
|
40
|
+
## 运行微生成器
|
41
|
+
|
42
|
+
生成器发布 npm 包之后,使用如下命令执行:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
npx @modern-js/codesmith-cli <generatorName>
|
46
|
+
```
|
47
|
+
|
48
|
+
其中 generatorName 为生成器包名。
|
49
|
+
|
50
|
+
:::info
|
51
|
+
`@modern-js/create` 也支持运行微生成器,可以使用 `npx @modern-js/create --generator <generatorName>` 运行自定义的微生成器。
|
52
|
+
:::
|