@wrikka/create-docs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/bin/cli.js +408 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +475 -0
- package/dist/index.d.ts +475 -0
- package/dist/index.js +20 -0
- package/docs/_dir.yml +2 -0
- package/docs/config.md +75 -0
- package/docs/data-sources.md +88 -0
- package/docs/deploy.md +38 -0
- package/docs/features.md +51 -0
- package/docs/getting-started.md +42 -0
- package/docs/index.md +34 -0
- package/docs/markdown.md +154 -0
- package/docs/theming.md +53 -0
- package/package.json +142 -0
- package/scripts/generate-docs-index.ts +111 -0
- package/scripts/github-pull.ts +124 -0
- package/src/adapters/config/index.ts +1 -0
- package/src/adapters/config/node-config-loader.ts +36 -0
- package/src/adapters/fs/fs-docs-loader.ts +31 -0
- package/src/adapters/fs/index.ts +12 -0
- package/src/adapters/fs/memory-fs.ts +60 -0
- package/src/adapters/fs/node-fs.ts +116 -0
- package/src/adapters/git/index.ts +164 -0
- package/src/adapters/github/github-pull.ts +340 -0
- package/src/adapters/index.ts +6 -0
- package/src/adapters/velite.ts +112 -0
- package/src/adapters/vite/docs-watcher.ts +36 -0
- package/src/adapters/vite/index.ts +2 -0
- package/src/adapters/vite/polling-watcher.ts +89 -0
- package/src/code-block-enhancements/index.ts +3 -0
- package/src/config/index.ts +15 -0
- package/src/content/index.ts +11 -0
- package/src/content-validation/index.ts +5 -0
- package/src/index.ts +174 -0
- package/src/live-editor/index.ts +7 -0
- package/src/modules/analytics/application/plausible-adapter.ts +103 -0
- package/src/modules/analytics/application/umami-adapter.ts +109 -0
- package/src/modules/analytics/domain/events/index.ts +37 -0
- package/src/modules/analytics/domain/models/index.ts +35 -0
- package/src/modules/analytics/domain/operations/analytics-operations.ts +67 -0
- package/src/modules/analytics/domain/validators/index.ts +50 -0
- package/src/modules/analytics/index.ts +9 -0
- package/src/modules/analytics/ports/analytics-port.ts +17 -0
- package/src/modules/analytics/types/analytics.ts +16 -0
- package/src/modules/api-docs/application/type-docs-adapter.ts +34 -0
- package/src/modules/api-docs/domain/events/index.ts +42 -0
- package/src/modules/api-docs/domain/models/index.ts +40 -0
- package/src/modules/api-docs/domain/operations/api-docs-operations.ts +59 -0
- package/src/modules/api-docs/domain/validators/index.ts +56 -0
- package/src/modules/api-docs/index.ts +8 -0
- package/src/modules/api-docs/ports/api-docs-port.ts +21 -0
- package/src/modules/api-docs/types/api-docs.ts +15 -0
- package/src/modules/api-reference/openapi.ts +166 -0
- package/src/modules/api-reference/orpc.ts +94 -0
- package/src/modules/code-block-enhancements/application/usecases/index.ts +39 -0
- package/src/modules/code-block-enhancements/domain/code-operations.ts +72 -0
- package/src/modules/code-block-enhancements/domain/events/index.ts +58 -0
- package/src/modules/code-block-enhancements/domain/index.ts +11 -0
- package/src/modules/code-block-enhancements/domain/models/index.ts +36 -0
- package/src/modules/code-block-enhancements/domain/validators/index.ts +50 -0
- package/src/modules/code-block-enhancements/index.ts +10 -0
- package/src/modules/code-block-enhancements/ports/index.ts +18 -0
- package/src/modules/code-block-enhancements/types/index.ts +37 -0
- package/src/modules/code-execution/application/sandbox-adapter.ts +44 -0
- package/src/modules/code-execution/domain/events/index.ts +58 -0
- package/src/modules/code-execution/domain/models/index.ts +33 -0
- package/src/modules/code-execution/domain/operations/execution-operations.ts +60 -0
- package/src/modules/code-execution/domain/validators/index.ts +50 -0
- package/src/modules/code-execution/index.ts +8 -0
- package/src/modules/code-execution/ports/execution-port.ts +15 -0
- package/src/modules/code-execution/types/execution.ts +15 -0
- package/src/modules/comments/application/giscus-adapter.ts +55 -0
- package/src/modules/comments/domain/events/index.ts +55 -0
- package/src/modules/comments/domain/models/index.ts +30 -0
- package/src/modules/comments/domain/operations/comment-operations.ts +46 -0
- package/src/modules/comments/domain/validators/index.ts +50 -0
- package/src/modules/comments/index.ts +8 -0
- package/src/modules/comments/ports/comment-port.ts +18 -0
- package/src/modules/comments/types/comments.ts +19 -0
- package/src/modules/config/application/usecases/index.ts +1 -0
- package/src/modules/config/application/usecases/loadConfig.ts +38 -0
- package/src/modules/config/application/workflows/index.ts +1 -0
- package/src/modules/config/application/workflows/validateConfig.ts +14 -0
- package/src/modules/config/domain/events/index.ts +50 -0
- package/src/modules/config/domain/models/index.ts +9 -0
- package/src/modules/config/domain/operations/defaults.ts +74 -0
- package/src/modules/config/domain/operations/index.ts +2 -0
- package/src/modules/config/domain/operations/resolve.ts +40 -0
- package/src/modules/config/domain/validators/index.ts +152 -0
- package/src/modules/config/index.ts +23 -0
- package/src/modules/config/ports/index.ts +15 -0
- package/src/modules/config/types/index.ts +113 -0
- package/src/modules/config/types/public.ts +19 -0
- package/src/modules/content/application/cache/index.ts +6 -0
- package/src/modules/content/application/cache/parse-cache.ts +6 -0
- package/src/modules/content/application/cache/parseCache.ts +56 -0
- package/src/modules/content/application/usecases/index.ts +2 -0
- package/src/modules/content/application/usecases/load-doc-page.ts +1 -0
- package/src/modules/content/application/usecases/loadDocPage.ts +111 -0
- package/src/modules/content/application/usecases/scanDocsDir.ts +105 -0
- package/src/modules/content/application/workflows/index.ts +1 -0
- package/src/modules/content/application/workflows/processDocs.ts +51 -0
- package/src/modules/content/domain/events/index.ts +61 -0
- package/src/modules/content/domain/models/index.ts +13 -0
- package/src/modules/content/domain/operations/build-page.ts +146 -0
- package/src/modules/content/domain/operations/buildPage.ts +93 -0
- package/src/modules/content/domain/operations/index.ts +17 -0
- package/src/modules/content/domain/operations/parse.ts +241 -0
- package/src/modules/content/domain/validators/frontmatter.ts +82 -0
- package/src/modules/content/domain/validators/index.ts +6 -0
- package/src/modules/content/index.ts +27 -0
- package/src/modules/content/ports/index.ts +45 -0
- package/src/modules/content/ports/velite.ts +134 -0
- package/src/modules/content/types/index.ts +76 -0
- package/src/modules/content/types/public.ts +1 -0
- package/src/modules/content-linting/application/builtin-linting-adapter.ts +82 -0
- package/src/modules/content-linting/domain/events/index.ts +58 -0
- package/src/modules/content-linting/domain/models/index.ts +46 -0
- package/src/modules/content-linting/domain/operations/linting-operations.ts +82 -0
- package/src/modules/content-linting/domain/validators/index.ts +50 -0
- package/src/modules/content-linting/index.ts +8 -0
- package/src/modules/content-linting/ports/linting-port.ts +21 -0
- package/src/modules/content-linting/types/linting.ts +18 -0
- package/src/modules/content-validation/application/usecases/index.ts +18 -0
- package/src/modules/content-validation/domain/events/index.ts +7 -0
- package/src/modules/content-validation/domain/index.ts +16 -0
- package/src/modules/content-validation/domain/models/index.ts +33 -0
- package/src/modules/content-validation/domain/operations/index.ts +157 -0
- package/src/modules/content-validation/domain/types/index.ts +17 -0
- package/src/modules/content-validation/domain/validators/index.ts +8 -0
- package/src/modules/content-validation/index.ts +9 -0
- package/src/modules/content-validation/ports/index.ts +15 -0
- package/src/modules/content-validation/types/index.ts +5 -0
- package/src/modules/export/application/puppeteer-export-adapter.ts +63 -0
- package/src/modules/export/domain/events/index.ts +55 -0
- package/src/modules/export/domain/models/index.ts +38 -0
- package/src/modules/export/domain/operations/export-operations.ts +56 -0
- package/src/modules/export/domain/validators/index.ts +52 -0
- package/src/modules/export/index.ts +8 -0
- package/src/modules/export/ports/export-port.ts +15 -0
- package/src/modules/export/types/export.ts +15 -0
- package/src/modules/external-search/application/algolia-adapter.ts +182 -0
- package/src/modules/external-search/application/meilisearch-adapter.ts +161 -0
- package/src/modules/external-search/domain/events/index.ts +42 -0
- package/src/modules/external-search/domain/models/index.ts +42 -0
- package/src/modules/external-search/domain/operations/search-operations.ts +53 -0
- package/src/modules/external-search/domain/validators/index.ts +55 -0
- package/src/modules/external-search/index.ts +9 -0
- package/src/modules/external-search/ports/external-search-port.ts +23 -0
- package/src/modules/external-search/types/search.ts +19 -0
- package/src/modules/git-history/application/simple-git-adapter.ts +46 -0
- package/src/modules/git-history/domain/events/index.ts +34 -0
- package/src/modules/git-history/domain/models/index.ts +25 -0
- package/src/modules/git-history/domain/operations/git-history-operations.ts +56 -0
- package/src/modules/git-history/domain/validators/index.ts +52 -0
- package/src/modules/git-history/index.ts +8 -0
- package/src/modules/git-history/ports/git-history-port.ts +21 -0
- package/src/modules/git-history/types/git-history.ts +15 -0
- package/src/modules/i18n/application/fs-locale-loader.ts +39 -0
- package/src/modules/i18n/domain/events/index.ts +34 -0
- package/src/modules/i18n/domain/models/index.ts +34 -0
- package/src/modules/i18n/domain/operations/locale-operations.ts +74 -0
- package/src/modules/i18n/domain/validators/index.ts +52 -0
- package/src/modules/i18n/index.ts +8 -0
- package/src/modules/i18n/ports/locale-loader-port.ts +18 -0
- package/src/modules/i18n/types/locale.ts +17 -0
- package/src/modules/image-optimization/application/sharp-adapter.ts +58 -0
- package/src/modules/image-optimization/domain/events/index.ts +39 -0
- package/src/modules/image-optimization/domain/models/index.ts +27 -0
- package/src/modules/image-optimization/domain/operations/image-operations.ts +65 -0
- package/src/modules/image-optimization/domain/validators/index.ts +52 -0
- package/src/modules/image-optimization/index.ts +8 -0
- package/src/modules/image-optimization/ports/image-optimizer-port.ts +15 -0
- package/src/modules/image-optimization/types/image.ts +17 -0
- package/src/modules/live-editor/application/usecases/index.ts +60 -0
- package/src/modules/live-editor/domain/events/index.ts +37 -0
- package/src/modules/live-editor/domain/gitOperations.ts +110 -0
- package/src/modules/live-editor/domain/index.ts +15 -0
- package/src/modules/live-editor/domain/models/index.ts +21 -0
- package/src/modules/live-editor/domain/validators/index.ts +55 -0
- package/src/modules/live-editor/index.ts +14 -0
- package/src/modules/live-editor/ports/index.ts +49 -0
- package/src/modules/live-editor/types/index.ts +80 -0
- package/src/modules/live-preview/application/vite-preview-adapter.ts +20 -0
- package/src/modules/live-preview/domain/operations/preview-operations.ts +56 -0
- package/src/modules/live-preview/index.ts +8 -0
- package/src/modules/live-preview/ports/preview-port.ts +20 -0
- package/src/modules/live-preview/types/preview.ts +16 -0
- package/src/modules/mdx/application/mdx-js-adapter.ts +38 -0
- package/src/modules/mdx/domain/operations/parse-mdx.ts +43 -0
- package/src/modules/mdx/index.ts +8 -0
- package/src/modules/mdx/ports/mdx-parser-port.ts +15 -0
- package/src/modules/mdx/types/mdx.ts +14 -0
- package/src/modules/navigation/application/usecases/buildNav.ts +15 -0
- package/src/modules/navigation/application/usecases/buildSidebar.ts +45 -0
- package/src/modules/navigation/application/usecases/index.ts +2 -0
- package/src/modules/navigation/domain/events/index.ts +30 -0
- package/src/modules/navigation/domain/models/index.ts +7 -0
- package/src/modules/navigation/domain/operations/group.ts +79 -0
- package/src/modules/navigation/domain/operations/index.ts +10 -0
- package/src/modules/navigation/domain/operations/sort.ts +27 -0
- package/src/modules/navigation/domain/shared/utils/array.ts +39 -0
- package/src/modules/navigation/domain/validators/index.ts +88 -0
- package/src/modules/navigation/index.ts +15 -0
- package/src/modules/navigation/ports/index.ts +9 -0
- package/src/modules/navigation/types/index.ts +38 -0
- package/src/modules/navigation/types/public.ts +9 -0
- package/src/modules/openapi/application/swagger-parser-adapter.ts +178 -0
- package/src/modules/openapi/domain/operations/parse-openapi.ts +46 -0
- package/src/modules/openapi/index.ts +8 -0
- package/src/modules/openapi/ports/openapi-parser-port.ts +15 -0
- package/src/modules/openapi/types/openapi.ts +37 -0
- package/src/modules/plugin/application/usecases/build-virtual-modules.ts +53 -0
- package/src/modules/plugin/application/usecases/index.ts +1 -0
- package/src/modules/plugin/application/workflows/build-docs.ts +79 -0
- package/src/modules/plugin/application/workflows/index.ts +1 -0
- package/src/modules/plugin/domain/events/index.ts +62 -0
- package/src/modules/plugin/domain/models/index.ts +1 -0
- package/src/modules/plugin/domain/operations/build-virtual.ts +76 -0
- package/src/modules/plugin/domain/operations/index.ts +11 -0
- package/src/modules/plugin/domain/validators/index.ts +30 -0
- package/src/modules/plugin/index.ts +14 -0
- package/src/modules/plugin/ports/index.ts +21 -0
- package/src/modules/plugin/types/index.ts +27 -0
- package/src/modules/plugin/types/public.ts +1 -0
- package/src/modules/search/application/usecases/index.ts +1 -0
- package/src/modules/search/application/usecases/indexPages.ts +15 -0
- package/src/modules/search/domain/events/index.ts +32 -0
- package/src/modules/search/domain/models/index.ts +1 -0
- package/src/modules/search/domain/operations/build-index.ts +6 -0
- package/src/modules/search/domain/operations/buildIndex.ts +70 -0
- package/src/modules/search/domain/operations/index.ts +7 -0
- package/src/modules/search/domain/operations/query.ts +186 -0
- package/src/modules/search/domain/validators/index.ts +32 -0
- package/src/modules/search/index.ts +9 -0
- package/src/modules/search/types/index.ts +22 -0
- package/src/modules/search/types/public.ts +1 -0
- package/src/modules/search-analytics/application/local-storage-adapter.ts +68 -0
- package/src/modules/search-analytics/domain/operations/search-analytics-operations.ts +74 -0
- package/src/modules/search-analytics/index.ts +8 -0
- package/src/modules/search-analytics/ports/search-analytics-port.ts +20 -0
- package/src/modules/search-analytics/types/search-analytics.ts +16 -0
- package/src/modules/search-highlighting/application/dom-highlighting-adapter.ts +36 -0
- package/src/modules/search-highlighting/domain/operations/highlighting-operations.ts +72 -0
- package/src/modules/search-highlighting/index.ts +8 -0
- package/src/modules/search-highlighting/ports/highlighting-port.ts +14 -0
- package/src/modules/search-highlighting/types/highlighting.ts +15 -0
- package/src/modules/seo-optimization/application/usecases/index.ts +18 -0
- package/src/modules/seo-optimization/domain/index.ts +12 -0
- package/src/modules/seo-optimization/domain/seoOperations.ts +92 -0
- package/src/modules/seo-optimization/index.ts +8 -0
- package/src/modules/seo-optimization/ports/index.ts +18 -0
- package/src/modules/seo-optimization/types/index.ts +41 -0
- package/src/modules/theme/application/css-theme-adapter.ts +50 -0
- package/src/modules/theme/domain/operations/theme-operations.ts +68 -0
- package/src/modules/theme/index.ts +8 -0
- package/src/modules/theme/ports/theme-port.ts +8 -0
- package/src/modules/theme/types/theme.ts +12 -0
- package/src/modules/toc/application/markdown-toc-adapter.ts +106 -0
- package/src/modules/toc/domain/operations/toc-operations.ts +92 -0
- package/src/modules/toc/index.ts +8 -0
- package/src/modules/toc/ports/toc-port.ts +21 -0
- package/src/modules/toc/types/toc.ts +17 -0
- package/src/modules/toc-generator/application/usecases/index.ts +30 -0
- package/src/modules/toc-generator/domain/index.ts +12 -0
- package/src/modules/toc-generator/domain/tocOperations.ts +104 -0
- package/src/modules/toc-generator/index.ts +9 -0
- package/src/modules/toc-generator/ports/index.ts +20 -0
- package/src/modules/toc-generator/types/index.ts +50 -0
- package/src/modules/version-control/domain/events/index.ts +39 -0
- package/src/modules/version-control/domain/models/index.ts +25 -0
- package/src/modules/version-control/domain/validators/index.ts +50 -0
- package/src/modules/versioning/application/fs-version-loader.ts +44 -0
- package/src/modules/versioning/domain/operations/versioning-operations.ts +80 -0
- package/src/modules/versioning/index.ts +8 -0
- package/src/modules/versioning/ports/version-loader-port.ts +18 -0
- package/src/modules/versioning/types/versioning.ts +17 -0
- package/src/modules/workflow/domain/events/index.ts +55 -0
- package/src/modules/workflow/domain/models/index.ts +40 -0
- package/src/modules/workflow/domain/validators/index.ts +50 -0
- package/src/modules/yaml-parser/application/js-yaml-adapter.ts +34 -0
- package/src/modules/yaml-parser/domain/operations/parse-yaml.ts +58 -0
- package/src/modules/yaml-parser/index.ts +7 -0
- package/src/modules/yaml-parser/ports/yaml-parser-port.ts +18 -0
- package/src/navigation/index.ts +9 -0
- package/src/plugin/index.ts +4 -0
- package/src/presentation/index.ts +1 -0
- package/src/presentation/live-editor/index.ts +22 -0
- package/src/presentation/live-editor/live-editor-component.ts +219 -0
- package/src/presentation/live-editor/virtual-module.ts +16 -0
- package/src/presentation/solid/CodeBlock.tsx +120 -0
- package/src/presentation/solid/Toc.tsx +58 -0
- package/src/presentation/solid/index.ts +11 -0
- package/src/presentation/vite-plugin/docs-plugin.ts +212 -0
- package/src/presentation/vite-plugin/index.ts +9 -0
- package/src/presentation/vite-plugin/transform-markdown.ts +26 -0
- package/src/runtime/analytics.ts +59 -0
- package/src/runtime/api-diff.ts +115 -0
- package/src/runtime/app.tsx +32 -0
- package/src/runtime/components/AccentPicker.tsx +114 -0
- package/src/runtime/components/ApiPlayground.tsx +332 -0
- package/src/runtime/components/AskAiDialog.tsx +127 -0
- package/src/runtime/components/BackToTop.tsx +38 -0
- package/src/runtime/components/Banner.tsx +75 -0
- package/src/runtime/components/Breadcrumbs.tsx +42 -0
- package/src/runtime/components/CollectionDropdown.tsx +85 -0
- package/src/runtime/components/CustomizeDrawer.tsx +195 -0
- package/src/runtime/components/DocMarkdown.tsx +579 -0
- package/src/runtime/components/DocPrevNext.tsx +54 -0
- package/src/runtime/components/DocToc.tsx +147 -0
- package/src/runtime/components/DocsDropdown.tsx +184 -0
- package/src/runtime/components/Footer.tsx +52 -0
- package/src/runtime/components/GitHubAuth.tsx +82 -0
- package/src/runtime/components/GitHubStats.tsx +73 -0
- package/src/runtime/components/Head.tsx +225 -0
- package/src/runtime/components/LocaleDropdown.tsx +75 -0
- package/src/runtime/components/MobileBottomNav.tsx +111 -0
- package/src/runtime/components/NotFound.tsx +139 -0
- package/src/runtime/components/PageActions.tsx +144 -0
- package/src/runtime/components/RelatedDocs.tsx +50 -0
- package/src/runtime/components/ScrollProgress.tsx +32 -0
- package/src/runtime/components/SearchPalette.tsx +333 -0
- package/src/runtime/components/ShowcaseCard.tsx +87 -0
- package/src/runtime/components/SidebarNav.tsx +237 -0
- package/src/runtime/components/Skeleton.tsx +39 -0
- package/src/runtime/components/ThemeToggle.tsx +26 -0
- package/src/runtime/components/TopNav.tsx +270 -0
- package/src/runtime/components/VersionDropdown.tsx +189 -0
- package/src/runtime/components/markdown/components.ts +280 -0
- package/src/runtime/config.ts +225 -0
- package/src/runtime/content.ts +451 -0
- package/src/runtime/context.tsx +30 -0
- package/src/runtime/data.ts +93 -0
- package/src/runtime/github.ts +226 -0
- package/src/runtime/icons.ts +32 -0
- package/src/runtime/index.ts +153 -0
- package/src/runtime/layouts/DocsLayout.tsx +144 -0
- package/src/runtime/markdown-content.css +996 -0
- package/src/runtime/pages/AbTestPage.tsx +88 -0
- package/src/runtime/pages/AnalyticsPage.tsx +90 -0
- package/src/runtime/pages/ApiDiffPage.tsx +86 -0
- package/src/runtime/pages/ApiEndpointPage.tsx +248 -0
- package/src/runtime/pages/BuilderPage.tsx +150 -0
- package/src/runtime/pages/ChangelogPage.tsx +210 -0
- package/src/runtime/pages/CollectionPage.tsx +140 -0
- package/src/runtime/pages/CommunityPage.tsx +384 -0
- package/src/runtime/pages/CreatePage.tsx +448 -0
- package/src/runtime/pages/DocPage.tsx +193 -0
- package/src/runtime/pages/EditPage.tsx +201 -0
- package/src/runtime/pages/HomePage.tsx +187 -0
- package/src/runtime/pages/IssuesPage.tsx +140 -0
- package/src/runtime/pages/OAuthCallbackPage.tsx +80 -0
- package/src/runtime/pages/PluginsPage.tsx +249 -0
- package/src/runtime/pages/ShowcasePage.tsx +202 -0
- package/src/runtime/pwa.ts +39 -0
- package/src/runtime/router.tsx +192 -0
- package/src/runtime/seo.ts +192 -0
- package/src/runtime/theme.css +175 -0
- package/src/runtime/theme.ts +224 -0
- package/src/runtime/types.ts +217 -0
- package/src/search/index.ts +6 -0
- package/src/seo-optimization/index.ts +4 -0
- package/src/shared/constants/index.ts +26 -0
- package/src/shared/errors/index.ts +195 -0
- package/src/shared/index.ts +27 -0
- package/src/shared/types/brand.ts +14 -0
- package/src/shared/types/client.d.ts +45 -0
- package/src/shared/types/either.ts +38 -0
- package/src/shared/types/index.ts +42 -0
- package/src/shared/types/option.ts +52 -0
- package/src/shared/types/result.ts +81 -0
- package/src/shared/utils/array.ts +97 -0
- package/src/shared/utils/index.ts +46 -0
- package/src/shared/utils/object.ts +47 -0
- package/src/shared/utils/string.ts +74 -0
- package/src/toc-generator/index.ts +1 -0
- package/src/types/js-yaml.d.ts +42 -0
- package/src/worker.ts +462 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
> 
|
|
2
|
+
|
|
3
|
+
# @wrikka/create-docs
|
|
4
|
+
|
|
5
|
+
Vite plugin for documentation sites built on Functional Clean Architecture with SolidJS support. Parse markdown and MDX, build navigation, generate search indexes, and render beautiful docs with live editing.
|
|
6
|
+
|
|
7
|
+
Source: [github.com/wrikka/create-docs](https://github.com/wrikka/create-docs)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
┌──────────────────────────────────────────────────────────┐
|
|
15
|
+
│ create-docs — Vite Docs Plugin │
|
|
16
|
+
│ │
|
|
17
|
+
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
|
|
18
|
+
│ │ Markdown │→ │ Parse │→ │ Virtual │ │
|
|
19
|
+
│ │ + MDX │ │ Frontmatter│ │ Modules │ │
|
|
20
|
+
│ └────────────┘ └────────────┘ └────────────┘ │
|
|
21
|
+
│ ↓ │
|
|
22
|
+
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
|
|
23
|
+
│ │ SolidJS │← │ Search │← │ Sidebar │ │
|
|
24
|
+
│ │ Render │ │ Index │ │ + Nav │ │
|
|
25
|
+
│ └────────────┘ └────────────┘ └────────────┘ │
|
|
26
|
+
└──────────────────────────────────────────────────────────┘
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Get Started
|
|
30
|
+
|
|
31
|
+
1. Install — `bun add @wrikka/create-docs vite`
|
|
32
|
+
```bash
|
|
33
|
+
bun add @wrikka/create-docs vite
|
|
34
|
+
```
|
|
35
|
+
2. Add Plugin — configure in `vite.config.ts`
|
|
36
|
+
```typescript
|
|
37
|
+
import { defineConfig } from 'vite';
|
|
38
|
+
import { docsPlugin } from '@wrikka/create-docs';
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
plugins: [docsPlugin({ site: { title: 'My Docs' } })],
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
3. Build — `bunup`
|
|
45
|
+
```bash
|
|
46
|
+
bun run build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
| Icon | Feature | Description |
|
|
52
|
+
|:---:|---------|-------------|
|
|
53
|
+
|  | Markdown And MDX Parsing | Parse frontmatter, code blocks, and MDX components |
|
|
54
|
+
|  | Navigation Builder | Auto-generate sidebar and nav from folder structure |
|
|
55
|
+
|  | Search Index | Build full-text search index from doc pages |
|
|
56
|
+
|  | Table Of Contents | Generate TOC from markdown headings |
|
|
57
|
+
|  | Code Block Enhancements | Syntax highlighting and copy buttons for code blocks |
|
|
58
|
+
|  | Live Editor | Edit docs in-browser with git commit and push |
|
|
59
|
+
|  | SEO Optimization | Generate meta tags and optimize for search engines |
|
|
60
|
+
|  | File Watcher | Hot reload on markdown file changes |
|
|
61
|
+
|  | Content Validation | Validate frontmatter and content structure |
|
|
62
|
+
|  | Virtual Modules | Inject parsed content as virtual Vite modules |
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### Usage via Vite Plugin
|
|
67
|
+
|
|
68
|
+
Add the plugin to your Vite config and point it at your docs directory.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { defineConfig } from 'vite';
|
|
72
|
+
import { docsPlugin } from '@wrikka/create-docs';
|
|
73
|
+
|
|
74
|
+
export default defineConfig({
|
|
75
|
+
plugins: [docsPlugin({
|
|
76
|
+
site: { title: 'My Docs', description: 'Project documentation' },
|
|
77
|
+
docsDir: './docs',
|
|
78
|
+
search: { enabled: true },
|
|
79
|
+
})],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
┌──────────────────────────────────────────────────────────┐
|
|
85
|
+
│ $ vite dev │
|
|
86
|
+
│ │
|
|
87
|
+
│ VITE v8.2 ready in 320 ms │
|
|
88
|
+
│ │
|
|
89
|
+
│ ➜ Local: http://localhost:5173/ │
|
|
90
|
+
│ ➜ Network: use --host to expose │
|
|
91
|
+
│ │
|
|
92
|
+
│ [create-docs] Watching ./docs/**/*.md │
|
|
93
|
+
│ [create-docs] Indexed 24 pages │
|
|
94
|
+
│ [create-docs] Search index built (186 entries) │
|
|
95
|
+
└──────────────────────────────────────────────────────────┘
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| option | description | options | default |
|
|
99
|
+
|--------|-------------|---------|---------|
|
|
100
|
+
| `site` | Site title and description | `title`, `description` | — |
|
|
101
|
+
| `docsDir` | Documentation directory path | string | `./docs` |
|
|
102
|
+
| `search` | Search configuration | `enabled` | `enabled: true` |
|
|
103
|
+
| `watchMode` | File watcher mode | `native`, `polling` | `native` |
|
|
104
|
+
| `fullReload` | Force full browser reload | boolean | `false` |
|
|
105
|
+
|
|
106
|
+
### Usage via SDK
|
|
107
|
+
|
|
108
|
+
Import parsing, navigation, and search utilities programmatically.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { buildDocPage, buildSidebar, buildSearchIndex } from '@wrikka/create-docs';
|
|
112
|
+
|
|
113
|
+
const page = buildDocPage(rawMarkdown);
|
|
114
|
+
const sidebar = buildSidebar(pages);
|
|
115
|
+
const searchIndex = buildSearchIndex(pages);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
┌──────────────────────────────────────────────────────────┐
|
|
120
|
+
│ > buildDocPage('# Hello\n\nContent here...') │
|
|
121
|
+
│ │
|
|
122
|
+
│ { │
|
|
123
|
+
│ slug: 'hello', │
|
|
124
|
+
│ title: 'Hello', │
|
|
125
|
+
│ body: 'Content here...', │
|
|
126
|
+
│ toc: [{ level: 1, text: 'Hello', slug: 'hello' }] │
|
|
127
|
+
│ } │
|
|
128
|
+
└──────────────────────────────────────────────────────────┘
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| api | description | options | default |
|
|
132
|
+
|-----|-------------|---------|---------|
|
|
133
|
+
| `docsPlugin(config)` | Create Vite plugin | `site`, `docsDir`, `search` | — |
|
|
134
|
+
| `buildDocPage(raw)` | Parse markdown to doc page | `raw` string | — |
|
|
135
|
+
| `buildSidebar(pages)` | Build sidebar from pages | `pages` array | — |
|
|
136
|
+
| `buildSearchIndex(pages)` | Build search index | `pages` array | — |
|
|
137
|
+
| `generateToc(page)` | Generate table of contents | `page` object | — |
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* create @wrikka/docs — scaffold a new documentation site.
|
|
4
|
+
*
|
|
5
|
+
* bun create @wrikka/docs my-docs
|
|
6
|
+
* npm create @wrikka/docs my-docs
|
|
7
|
+
* pnpm create @wrikka/docs my-docs
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { join, resolve } from "node:path";
|
|
11
|
+
import { createInterface } from "node:readline";
|
|
12
|
+
|
|
13
|
+
const PKG = "@wrikka/create-docs";
|
|
14
|
+
|
|
15
|
+
async function ask(question, fallback) {
|
|
16
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
17
|
+
return new Promise((res) => {
|
|
18
|
+
rl.question(question, (answer) => {
|
|
19
|
+
rl.close();
|
|
20
|
+
res(answer.trim() || fallback);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const templates = {
|
|
26
|
+
"package.json": (name) =>
|
|
27
|
+
JSON.stringify(
|
|
28
|
+
{
|
|
29
|
+
name,
|
|
30
|
+
version: "0.1.0",
|
|
31
|
+
private: true,
|
|
32
|
+
type: "module",
|
|
33
|
+
scripts: {
|
|
34
|
+
dev: "vite",
|
|
35
|
+
build: "vite build",
|
|
36
|
+
preview: "vite preview",
|
|
37
|
+
typecheck: "tsc --noEmit",
|
|
38
|
+
},
|
|
39
|
+
dependencies: {
|
|
40
|
+
[PKG]: "^0.1.0",
|
|
41
|
+
"@tanstack/solid-router": "^1.170.30",
|
|
42
|
+
"solid-js": "^1.9.15",
|
|
43
|
+
},
|
|
44
|
+
devDependencies: {
|
|
45
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
46
|
+
typescript: "^7.0.0",
|
|
47
|
+
unocss: "^66.10.0",
|
|
48
|
+
vite: "^8.0.0",
|
|
49
|
+
"vite-plugin-solid": "^2.11.0",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
null,
|
|
53
|
+
"\t",
|
|
54
|
+
) + "\n",
|
|
55
|
+
|
|
56
|
+
"vite.config.ts": () => `import UnoCSS from "unocss/vite";
|
|
57
|
+
import { defineConfig } from "vite";
|
|
58
|
+
import solid from "vite-plugin-solid";
|
|
59
|
+
|
|
60
|
+
export default defineConfig({
|
|
61
|
+
plugins: [UnoCSS(), solid()],
|
|
62
|
+
resolve: {
|
|
63
|
+
dedupe: ["solid-js", "@tanstack/solid-router"],
|
|
64
|
+
},
|
|
65
|
+
build: {
|
|
66
|
+
target: "esnext",
|
|
67
|
+
sourcemap: true,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
`,
|
|
71
|
+
|
|
72
|
+
"uno.config.ts": () => `import {
|
|
73
|
+
defineConfig,
|
|
74
|
+
presetIcons,
|
|
75
|
+
presetWind4,
|
|
76
|
+
transformerDirectives,
|
|
77
|
+
transformerVariantGroup,
|
|
78
|
+
} from "unocss";
|
|
79
|
+
|
|
80
|
+
export default defineConfig({
|
|
81
|
+
presets: [
|
|
82
|
+
presetWind4({
|
|
83
|
+
preflights: { reset: true, theme: "on-demand", property: true },
|
|
84
|
+
dark: "class",
|
|
85
|
+
}),
|
|
86
|
+
presetIcons({
|
|
87
|
+
scale: 1.1,
|
|
88
|
+
collections: {
|
|
89
|
+
mdi: () =>
|
|
90
|
+
import("@iconify-json/mdi/icons.json").then((i) => i.default),
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
transformers: [transformerVariantGroup(), transformerDirectives()],
|
|
95
|
+
theme: {
|
|
96
|
+
colors: {
|
|
97
|
+
primary: {
|
|
98
|
+
DEFAULT: "hsl(var(--color-primary))",
|
|
99
|
+
hover: "hsl(var(--color-primary-hover))",
|
|
100
|
+
foreground: "hsl(var(--color-primary-foreground))",
|
|
101
|
+
},
|
|
102
|
+
background: "hsl(var(--color-background))",
|
|
103
|
+
foreground: "hsl(var(--color-foreground))",
|
|
104
|
+
surface: "hsl(var(--color-surface))",
|
|
105
|
+
muted: "hsl(var(--color-muted))",
|
|
106
|
+
border: "hsl(var(--color-border))",
|
|
107
|
+
focus: "hsl(var(--color-focus))",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
content: {
|
|
111
|
+
filesystem: [
|
|
112
|
+
"./index.html",
|
|
113
|
+
"./src/**/*.{ts,tsx,html}",
|
|
114
|
+
"./node_modules/${PKG}/src/runtime/**/*.{ts,tsx}",
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
`,
|
|
119
|
+
|
|
120
|
+
"index.html": (name) => `<!doctype html>
|
|
121
|
+
<html lang="en" class="dark">
|
|
122
|
+
<head>
|
|
123
|
+
<meta charset="UTF-8" />
|
|
124
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
125
|
+
<meta name="color-scheme" content="dark light" />
|
|
126
|
+
<title>${name}</title>
|
|
127
|
+
</head>
|
|
128
|
+
<body>
|
|
129
|
+
<div id="root"></div>
|
|
130
|
+
<script type="module" src="/src/index.tsx"></script>
|
|
131
|
+
</body>
|
|
132
|
+
</html>
|
|
133
|
+
`,
|
|
134
|
+
|
|
135
|
+
"tsconfig.json": () =>
|
|
136
|
+
JSON.stringify(
|
|
137
|
+
{
|
|
138
|
+
compilerOptions: {
|
|
139
|
+
target: "ESNext",
|
|
140
|
+
module: "ESNext",
|
|
141
|
+
moduleResolution: "bundler",
|
|
142
|
+
jsx: "preserve",
|
|
143
|
+
jsxImportSource: "solid-js",
|
|
144
|
+
strict: true,
|
|
145
|
+
skipLibCheck: true,
|
|
146
|
+
types: ["vite/client"],
|
|
147
|
+
noEmit: true,
|
|
148
|
+
},
|
|
149
|
+
include: ["src", "vite.config.ts", "uno.config.ts"],
|
|
150
|
+
},
|
|
151
|
+
null,
|
|
152
|
+
"\t",
|
|
153
|
+
) + "\n",
|
|
154
|
+
|
|
155
|
+
".gitignore": () => `node_modules
|
|
156
|
+
dist
|
|
157
|
+
.wrangler
|
|
158
|
+
`,
|
|
159
|
+
|
|
160
|
+
"src/index.tsx":
|
|
161
|
+
() => `import { initTheme, mountDocsApp } from "${PKG}/solid";
|
|
162
|
+
import "${PKG}/theme.css";
|
|
163
|
+
import "${PKG}/markdown-content.css";
|
|
164
|
+
import "virtual:uno.css";
|
|
165
|
+
import { docsAppConfig } from "./app-config";
|
|
166
|
+
|
|
167
|
+
initTheme();
|
|
168
|
+
mountDocsApp(docsAppConfig);
|
|
169
|
+
`,
|
|
170
|
+
|
|
171
|
+
"src/data-source.ts": () => `import type {
|
|
172
|
+
CollectionMeta,
|
|
173
|
+
DocContent,
|
|
174
|
+
DocEntry,
|
|
175
|
+
DocsDataSource,
|
|
176
|
+
SearchResult,
|
|
177
|
+
} from "${PKG}/solid";
|
|
178
|
+
|
|
179
|
+
// Bundles every markdown file under ./docs into the app at build time.
|
|
180
|
+
const files = import.meta.glob("../docs/**/*.md", {
|
|
181
|
+
query: "?raw",
|
|
182
|
+
import: "default",
|
|
183
|
+
eager: true,
|
|
184
|
+
}) as Record<string, string>;
|
|
185
|
+
|
|
186
|
+
function titleOf(id: string): string {
|
|
187
|
+
return id
|
|
188
|
+
.split("-")
|
|
189
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
190
|
+
.join(" ");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const entries: (DocEntry & { body: string })[] = Object.entries(files).map(
|
|
194
|
+
([path, body]) => {
|
|
195
|
+
const id = path
|
|
196
|
+
.replace(/^.*docs\\//, "")
|
|
197
|
+
.replace(/\\.md$/, "")
|
|
198
|
+
.replace(/\\//g, "--");
|
|
199
|
+
return {
|
|
200
|
+
id,
|
|
201
|
+
label: titleOf(id.split("--").pop() ?? id),
|
|
202
|
+
category: "Docs",
|
|
203
|
+
description: body.split("\\n").find((l) => l.trim() && !l.startsWith("#")) ?? "",
|
|
204
|
+
path,
|
|
205
|
+
type: "md",
|
|
206
|
+
body,
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
export const staticDataSource: DocsDataSource = {
|
|
212
|
+
async collections(): Promise<CollectionMeta[]> {
|
|
213
|
+
return [
|
|
214
|
+
{
|
|
215
|
+
id: "docs",
|
|
216
|
+
label: "Docs",
|
|
217
|
+
icon: "i-mdi:book-open-page-variant",
|
|
218
|
+
description: "Documentation",
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
},
|
|
222
|
+
async list(): Promise<DocEntry[]> {
|
|
223
|
+
return entries;
|
|
224
|
+
},
|
|
225
|
+
async get(_collection: string, id: string): Promise<DocContent> {
|
|
226
|
+
const doc = entries.find((d) => d.id === id);
|
|
227
|
+
if (!doc) throw new Error("Document not found: " + id);
|
|
228
|
+
return { content: doc.body };
|
|
229
|
+
},
|
|
230
|
+
async search(q: string): Promise<SearchResult[]> {
|
|
231
|
+
const needle = q.toLowerCase();
|
|
232
|
+
return entries
|
|
233
|
+
.filter(
|
|
234
|
+
(d) =>
|
|
235
|
+
d.label.toLowerCase().includes(needle) ||
|
|
236
|
+
d.body.toLowerCase().includes(needle),
|
|
237
|
+
)
|
|
238
|
+
.map((d) => ({
|
|
239
|
+
collection: "docs",
|
|
240
|
+
id: d.id,
|
|
241
|
+
title: d.label,
|
|
242
|
+
snippet: d.description,
|
|
243
|
+
score: 1,
|
|
244
|
+
}));
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
`,
|
|
248
|
+
|
|
249
|
+
"src/app-config.ts": () => `import type { DocsAppConfig } from "${PKG}/solid";
|
|
250
|
+
import { staticDataSource } from "./data-source";
|
|
251
|
+
|
|
252
|
+
export const docsAppConfig: DocsAppConfig = {
|
|
253
|
+
site: {
|
|
254
|
+
title: "My Docs",
|
|
255
|
+
description: "Documentation built with @wrikka/create-docs",
|
|
256
|
+
},
|
|
257
|
+
dataSource: staticDataSource,
|
|
258
|
+
defaultCollection: "docs",
|
|
259
|
+
home: {
|
|
260
|
+
hero: {
|
|
261
|
+
name: "My Docs",
|
|
262
|
+
text: "documentation",
|
|
263
|
+
tagline: "Beautiful docs, zero config.",
|
|
264
|
+
actions: [
|
|
265
|
+
{ text: "Get started", link: "/docs", theme: "brand" },
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
features: {
|
|
270
|
+
search: true,
|
|
271
|
+
themeToggle: true,
|
|
272
|
+
breadcrumbs: true,
|
|
273
|
+
lastUpdated: true,
|
|
274
|
+
pwa: true,
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
`,
|
|
278
|
+
|
|
279
|
+
"docs/getting-started.md": () => `# Getting Started
|
|
280
|
+
|
|
281
|
+
Welcome to your new documentation site, powered by **@wrikka/create-docs**.
|
|
282
|
+
|
|
283
|
+
## What's included
|
|
284
|
+
|
|
285
|
+
- VitePress-style layout with sidebar, TOC, and breadcrumbs
|
|
286
|
+
- Full-text search (Ctrl+K)
|
|
287
|
+
- Dark / light theme
|
|
288
|
+
- Callouts, code groups, Mermaid, and math support
|
|
289
|
+
|
|
290
|
+
> [!TIP]
|
|
291
|
+
> Add markdown files to the \`docs/\` folder — they appear automatically.
|
|
292
|
+
|
|
293
|
+
## Next steps
|
|
294
|
+
|
|
295
|
+
1. Edit \`src/app-config.ts\` to customise the site.
|
|
296
|
+
2. Add pages under \`docs/\`.
|
|
297
|
+
3. Run \`bun run build\` (or \`npm run build\`) and deploy \`dist/\` anywhere.
|
|
298
|
+
`,
|
|
299
|
+
|
|
300
|
+
"docs/markdown-features.md": () => `# Markdown Features
|
|
301
|
+
|
|
302
|
+
## Callouts
|
|
303
|
+
|
|
304
|
+
> [!NOTE]
|
|
305
|
+
> Useful information.
|
|
306
|
+
|
|
307
|
+
> [!WARNING]
|
|
308
|
+
> Something to watch out for.
|
|
309
|
+
|
|
310
|
+
## Code groups
|
|
311
|
+
|
|
312
|
+
<code-group>
|
|
313
|
+
|
|
314
|
+
\`\`\`bash [bun]
|
|
315
|
+
bun create @wrikka/docs my-docs
|
|
316
|
+
\`\`\`
|
|
317
|
+
|
|
318
|
+
\`\`\`bash [npm]
|
|
319
|
+
npm create @wrikka/docs my-docs
|
|
320
|
+
\`\`\`
|
|
321
|
+
|
|
322
|
+
</code-group>
|
|
323
|
+
|
|
324
|
+
## Math
|
|
325
|
+
|
|
326
|
+
$$e^{i\\pi} + 1 = 0$$
|
|
327
|
+
|
|
328
|
+
## Mermaid
|
|
329
|
+
|
|
330
|
+
\`\`\`mermaid
|
|
331
|
+
graph TD
|
|
332
|
+
A[Write markdown] --> B[Ship docs]
|
|
333
|
+
\`\`\`
|
|
334
|
+
`,
|
|
335
|
+
|
|
336
|
+
"public/manifest.webmanifest": (name) =>
|
|
337
|
+
JSON.stringify(
|
|
338
|
+
{
|
|
339
|
+
name,
|
|
340
|
+
short_name: name,
|
|
341
|
+
start_url: "/",
|
|
342
|
+
display: "standalone",
|
|
343
|
+
background_color: "#0b0d12",
|
|
344
|
+
theme_color: "#0b0d12",
|
|
345
|
+
},
|
|
346
|
+
null,
|
|
347
|
+
"\t",
|
|
348
|
+
) + "\n",
|
|
349
|
+
|
|
350
|
+
"public/sw.js": () => `const CACHE = "docs-v1";
|
|
351
|
+
self.addEventListener("install", (e) => {
|
|
352
|
+
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(["/"])).then(() => self.skipWaiting()));
|
|
353
|
+
});
|
|
354
|
+
self.addEventListener("activate", (e) => {
|
|
355
|
+
e.waitUntil(self.clients.claim());
|
|
356
|
+
});
|
|
357
|
+
self.addEventListener("fetch", (e) => {
|
|
358
|
+
const { request } = e;
|
|
359
|
+
if (request.method !== "GET" || new URL(request.url).origin !== location.origin) return;
|
|
360
|
+
if (request.mode === "navigate") {
|
|
361
|
+
e.respondWith(fetch(request).catch(() => caches.match("/")));
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
e.respondWith(
|
|
365
|
+
caches.match(request).then((cached) => cached || fetch(request).then((res) => {
|
|
366
|
+
if (res.ok) {
|
|
367
|
+
const copy = res.clone();
|
|
368
|
+
caches.open(CACHE).then((c) => c.put(request, copy));
|
|
369
|
+
}
|
|
370
|
+
return res;
|
|
371
|
+
})),
|
|
372
|
+
);
|
|
373
|
+
});
|
|
374
|
+
`,
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
async function main() {
|
|
378
|
+
let name = process.argv[2];
|
|
379
|
+
if (!name) name = await ask("Project name: ", "my-docs");
|
|
380
|
+
const target = resolve(process.cwd(), name);
|
|
381
|
+
|
|
382
|
+
if (existsSync(target)) {
|
|
383
|
+
console.error("Error: directory already exists:", target);
|
|
384
|
+
process.exit(1);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
for (const [file, render] of Object.entries(templates)) {
|
|
388
|
+
const dest = join(target, file);
|
|
389
|
+
mkdirSync(join(dest, ".."), { recursive: true });
|
|
390
|
+
writeFileSync(dest, render(name), "utf8");
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const pm = process.env.npm_config_user_agent?.startsWith("bun")
|
|
394
|
+
? "bun"
|
|
395
|
+
: process.env.npm_config_user_agent?.startsWith("pnpm")
|
|
396
|
+
? "pnpm"
|
|
397
|
+
: "npm";
|
|
398
|
+
|
|
399
|
+
console.log("\nDone! Next steps:\n");
|
|
400
|
+
console.log(" cd " + name);
|
|
401
|
+
console.log(" " + pm + " install");
|
|
402
|
+
console.log(" " + pm + " run dev\n");
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
main().catch((err) => {
|
|
406
|
+
console.error(err);
|
|
407
|
+
process.exit(1);
|
|
408
|
+
});
|