@shirokuma-library/shirokuma-docs 0.1.0-alpha.10
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.
Potentially problematic release.
This version of @shirokuma-library/shirokuma-docs might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.en.md +346 -0
- package/README.md +346 -0
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/bin/shirokuma-docs +2 -0
- package/dist/analyzers/details-test-analysis.d.ts +31 -0
- package/dist/analyzers/details-test-analysis.d.ts.map +1 -0
- package/dist/analyzers/details-test-analysis.js +174 -0
- package/dist/analyzers/details-test-analysis.js.map +1 -0
- package/dist/analyzers/feature-map-builder.d.ts +20 -0
- package/dist/analyzers/feature-map-builder.d.ts.map +1 -0
- package/dist/analyzers/feature-map-builder.js +154 -0
- package/dist/analyzers/feature-map-builder.js.map +1 -0
- package/dist/analyzers/feature-map-references.d.ts +34 -0
- package/dist/analyzers/feature-map-references.d.ts.map +1 -0
- package/dist/analyzers/feature-map-references.js +249 -0
- package/dist/analyzers/feature-map-references.js.map +1 -0
- package/dist/analyzers/reference-analyzer.d.ts +95 -0
- package/dist/analyzers/reference-analyzer.d.ts.map +1 -0
- package/dist/analyzers/reference-analyzer.js +372 -0
- package/dist/analyzers/reference-analyzer.js.map +1 -0
- package/dist/commands/adr.d.ts +26 -0
- package/dist/commands/adr.d.ts.map +1 -0
- package/dist/commands/adr.js +129 -0
- package/dist/commands/adr.js.map +1 -0
- package/dist/commands/api-tools.d.ts +83 -0
- package/dist/commands/api-tools.d.ts.map +1 -0
- package/dist/commands/api-tools.js +775 -0
- package/dist/commands/api-tools.js.map +1 -0
- package/dist/commands/coverage.d.ts +139 -0
- package/dist/commands/coverage.d.ts.map +1 -0
- package/dist/commands/coverage.js +481 -0
- package/dist/commands/coverage.js.map +1 -0
- package/dist/commands/deps.d.ts +24 -0
- package/dist/commands/deps.d.ts.map +1 -0
- package/dist/commands/deps.js +211 -0
- package/dist/commands/deps.js.map +1 -0
- package/dist/commands/details-context.d.ts +38 -0
- package/dist/commands/details-context.d.ts.map +1 -0
- package/dist/commands/details-context.js +195 -0
- package/dist/commands/details-context.js.map +1 -0
- package/dist/commands/details-types.d.ts +315 -0
- package/dist/commands/details-types.d.ts.map +1 -0
- package/dist/commands/details-types.js +7 -0
- package/dist/commands/details-types.js.map +1 -0
- package/dist/commands/details.d.ts +24 -0
- package/dist/commands/details.d.ts.map +1 -0
- package/dist/commands/details.js +299 -0
- package/dist/commands/details.js.map +1 -0
- package/dist/commands/discussion-templates.d.ts +26 -0
- package/dist/commands/discussion-templates.d.ts.map +1 -0
- package/dist/commands/discussion-templates.js +270 -0
- package/dist/commands/discussion-templates.js.map +1 -0
- package/dist/commands/discussions.d.ts +31 -0
- package/dist/commands/discussions.d.ts.map +1 -0
- package/dist/commands/discussions.js +744 -0
- package/dist/commands/discussions.js.map +1 -0
- package/dist/commands/feature-map-types.d.ts +294 -0
- package/dist/commands/feature-map-types.d.ts.map +1 -0
- package/dist/commands/feature-map-types.js +8 -0
- package/dist/commands/feature-map-types.js.map +1 -0
- package/dist/commands/feature-map.d.ts +30 -0
- package/dist/commands/feature-map.d.ts.map +1 -0
- package/dist/commands/feature-map.js +137 -0
- package/dist/commands/feature-map.js.map +1 -0
- package/dist/commands/generate.d.ts +16 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +88 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/gh-discussions.d.ts +31 -0
- package/dist/commands/gh-discussions.d.ts.map +1 -0
- package/dist/commands/gh-discussions.js +743 -0
- package/dist/commands/gh-discussions.js.map +1 -0
- package/dist/commands/gh-issues-pr.d.ts +74 -0
- package/dist/commands/gh-issues-pr.d.ts.map +1 -0
- package/dist/commands/gh-issues-pr.js +417 -0
- package/dist/commands/gh-issues-pr.js.map +1 -0
- package/dist/commands/gh-issues.d.ts +90 -0
- package/dist/commands/gh-issues.d.ts.map +1 -0
- package/dist/commands/gh-issues.js +1297 -0
- package/dist/commands/gh-issues.js.map +1 -0
- package/dist/commands/gh-projects.d.ts +54 -0
- package/dist/commands/gh-projects.d.ts.map +1 -0
- package/dist/commands/gh-projects.js +966 -0
- package/dist/commands/gh-projects.js.map +1 -0
- package/dist/commands/gh-repo.d.ts +18 -0
- package/dist/commands/gh-repo.d.ts.map +1 -0
- package/dist/commands/gh-repo.js +253 -0
- package/dist/commands/gh-repo.js.map +1 -0
- package/dist/commands/github-data.d.ts +67 -0
- package/dist/commands/github-data.d.ts.map +1 -0
- package/dist/commands/github-data.js +361 -0
- package/dist/commands/github-data.js.map +1 -0
- package/dist/commands/i18n.d.ts +102 -0
- package/dist/commands/i18n.d.ts.map +1 -0
- package/dist/commands/i18n.js +829 -0
- package/dist/commands/i18n.js.map +1 -0
- package/dist/commands/impact.d.ts +14 -0
- package/dist/commands/impact.d.ts.map +1 -0
- package/dist/commands/impact.js +263 -0
- package/dist/commands/impact.js.map +1 -0
- package/dist/commands/init.d.ts +53 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +468 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/issues-pr.d.ts +83 -0
- package/dist/commands/issues-pr.d.ts.map +1 -0
- package/dist/commands/issues-pr.js +572 -0
- package/dist/commands/issues-pr.js.map +1 -0
- package/dist/commands/issues.d.ts +78 -0
- package/dist/commands/issues.d.ts.map +1 -0
- package/dist/commands/issues.js +1541 -0
- package/dist/commands/issues.js.map +1 -0
- package/dist/commands/link-docs.d.ts +21 -0
- package/dist/commands/link-docs.d.ts.map +1 -0
- package/dist/commands/link-docs.js +990 -0
- package/dist/commands/link-docs.js.map +1 -0
- package/dist/commands/lint-annotations.d.ts +28 -0
- package/dist/commands/lint-annotations.d.ts.map +1 -0
- package/dist/commands/lint-annotations.js +511 -0
- package/dist/commands/lint-annotations.js.map +1 -0
- package/dist/commands/lint-code.d.ts +26 -0
- package/dist/commands/lint-code.d.ts.map +1 -0
- package/dist/commands/lint-code.js +428 -0
- package/dist/commands/lint-code.js.map +1 -0
- package/dist/commands/lint-coverage.d.ts +33 -0
- package/dist/commands/lint-coverage.d.ts.map +1 -0
- package/dist/commands/lint-coverage.js +379 -0
- package/dist/commands/lint-coverage.js.map +1 -0
- package/dist/commands/lint-docs.d.ts +23 -0
- package/dist/commands/lint-docs.d.ts.map +1 -0
- package/dist/commands/lint-docs.js +338 -0
- package/dist/commands/lint-docs.js.map +1 -0
- package/dist/commands/lint-structure.d.ts +38 -0
- package/dist/commands/lint-structure.d.ts.map +1 -0
- package/dist/commands/lint-structure.js +350 -0
- package/dist/commands/lint-structure.js.map +1 -0
- package/dist/commands/lint-tests.d.ts +25 -0
- package/dist/commands/lint-tests.d.ts.map +1 -0
- package/dist/commands/lint-tests.js +105 -0
- package/dist/commands/lint-tests.js.map +1 -0
- package/dist/commands/lint-workflow.d.ts +36 -0
- package/dist/commands/lint-workflow.d.ts.map +1 -0
- package/dist/commands/lint-workflow.js +255 -0
- package/dist/commands/lint-workflow.js.map +1 -0
- package/dist/commands/overview.d.ts +21 -0
- package/dist/commands/overview.d.ts.map +1 -0
- package/dist/commands/overview.js +1300 -0
- package/dist/commands/overview.js.map +1 -0
- package/dist/commands/packages.d.ts +107 -0
- package/dist/commands/packages.d.ts.map +1 -0
- package/dist/commands/packages.js +308 -0
- package/dist/commands/packages.js.map +1 -0
- package/dist/commands/portal-nextjs.d.ts +23 -0
- package/dist/commands/portal-nextjs.d.ts.map +1 -0
- package/dist/commands/portal-nextjs.js +336 -0
- package/dist/commands/portal-nextjs.js.map +1 -0
- package/dist/commands/portal.d.ts +24 -0
- package/dist/commands/portal.d.ts.map +1 -0
- package/dist/commands/portal.js +16 -0
- package/dist/commands/portal.js.map +1 -0
- package/dist/commands/projects.d.ts +54 -0
- package/dist/commands/projects.d.ts.map +1 -0
- package/dist/commands/projects.js +1191 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/repo-pairs.d.ts +19 -0
- package/dist/commands/repo-pairs.d.ts.map +1 -0
- package/dist/commands/repo-pairs.js +529 -0
- package/dist/commands/repo-pairs.js.map +1 -0
- package/dist/commands/repo.d.ts +18 -0
- package/dist/commands/repo.d.ts.map +1 -0
- package/dist/commands/repo.js +253 -0
- package/dist/commands/repo.js.map +1 -0
- package/dist/commands/schema.d.ts +49 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +830 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/screenshots.d.ts +203 -0
- package/dist/commands/screenshots.d.ts.map +1 -0
- package/dist/commands/screenshots.js +1234 -0
- package/dist/commands/screenshots.js.map +1 -0
- package/dist/commands/search-index.d.ts +83 -0
- package/dist/commands/search-index.d.ts.map +1 -0
- package/dist/commands/search-index.js +389 -0
- package/dist/commands/search-index.js.map +1 -0
- package/dist/commands/search.d.ts +24 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +254 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/session.d.ts +159 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +1274 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/test-cases-types.d.ts +154 -0
- package/dist/commands/test-cases-types.d.ts.map +1 -0
- package/dist/commands/test-cases-types.js +7 -0
- package/dist/commands/test-cases-types.js.map +1 -0
- package/dist/commands/test-cases.d.ts +28 -0
- package/dist/commands/test-cases.d.ts.map +1 -0
- package/dist/commands/test-cases.js +192 -0
- package/dist/commands/test-cases.js.map +1 -0
- package/dist/commands/typedoc.d.ts +21 -0
- package/dist/commands/typedoc.d.ts.map +1 -0
- package/dist/commands/typedoc.js +192 -0
- package/dist/commands/typedoc.js.map +1 -0
- package/dist/commands/update-skills.d.ts +56 -0
- package/dist/commands/update-skills.d.ts.map +1 -0
- package/dist/commands/update-skills.js +626 -0
- package/dist/commands/update-skills.js.map +1 -0
- package/dist/generators/details-entity-pages.d.ts +40 -0
- package/dist/generators/details-entity-pages.d.ts.map +1 -0
- package/dist/generators/details-entity-pages.js +301 -0
- package/dist/generators/details-entity-pages.js.map +1 -0
- package/dist/generators/details-html.d.ts +23 -0
- package/dist/generators/details-html.d.ts.map +1 -0
- package/dist/generators/details-html.js +324 -0
- package/dist/generators/details-html.js.map +1 -0
- package/dist/generators/details-module-page.d.ts +33 -0
- package/dist/generators/details-module-page.d.ts.map +1 -0
- package/dist/generators/details-module-page.js +408 -0
- package/dist/generators/details-module-page.js.map +1 -0
- package/dist/generators/details-styles.d.ts +39 -0
- package/dist/generators/details-styles.d.ts.map +1 -0
- package/dist/generators/details-styles.js +409 -0
- package/dist/generators/details-styles.js.map +1 -0
- package/dist/generators/feature-map-html.d.ts +66 -0
- package/dist/generators/feature-map-html.d.ts.map +1 -0
- package/dist/generators/feature-map-html.js +569 -0
- package/dist/generators/feature-map-html.js.map +1 -0
- package/dist/generators/feature-map-styles.d.ts +39 -0
- package/dist/generators/feature-map-styles.d.ts.map +1 -0
- package/dist/generators/feature-map-styles.js +449 -0
- package/dist/generators/feature-map-styles.js.map +1 -0
- package/dist/generators/test-cases-hierarchy.d.ts +21 -0
- package/dist/generators/test-cases-hierarchy.d.ts.map +1 -0
- package/dist/generators/test-cases-hierarchy.js +336 -0
- package/dist/generators/test-cases-hierarchy.js.map +1 -0
- package/dist/generators/test-cases-main.d.ts +20 -0
- package/dist/generators/test-cases-main.d.ts.map +1 -0
- package/dist/generators/test-cases-main.js +439 -0
- package/dist/generators/test-cases-main.js.map +1 -0
- package/dist/generators/test-cases-styles.d.ts +64 -0
- package/dist/generators/test-cases-styles.d.ts.map +1 -0
- package/dist/generators/test-cases-styles.js +1277 -0
- package/dist/generators/test-cases-styles.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +600 -0
- package/dist/index.js.map +1 -0
- package/dist/lint/annotation-lint.d.ts +198 -0
- package/dist/lint/annotation-lint.d.ts.map +1 -0
- package/dist/lint/annotation-lint.js +510 -0
- package/dist/lint/annotation-lint.js.map +1 -0
- package/dist/lint/annotation-types.d.ts +161 -0
- package/dist/lint/annotation-types.d.ts.map +1 -0
- package/dist/lint/annotation-types.js +31 -0
- package/dist/lint/annotation-types.js.map +1 -0
- package/dist/lint/code-types.d.ts +135 -0
- package/dist/lint/code-types.d.ts.map +1 -0
- package/dist/lint/code-types.js +25 -0
- package/dist/lint/code-types.js.map +1 -0
- package/dist/lint/coverage-types.d.ts +128 -0
- package/dist/lint/coverage-types.d.ts.map +1 -0
- package/dist/lint/coverage-types.js +24 -0
- package/dist/lint/coverage-types.js.map +1 -0
- package/dist/lint/docs-types.d.ts +214 -0
- package/dist/lint/docs-types.d.ts.map +1 -0
- package/dist/lint/docs-types.js +18 -0
- package/dist/lint/docs-types.js.map +1 -0
- package/dist/lint/formatters/index.d.ts +14 -0
- package/dist/lint/formatters/index.d.ts.map +1 -0
- package/dist/lint/formatters/index.js +28 -0
- package/dist/lint/formatters/index.js.map +1 -0
- package/dist/lint/formatters/json.d.ts +11 -0
- package/dist/lint/formatters/json.d.ts.map +1 -0
- package/dist/lint/formatters/json.js +12 -0
- package/dist/lint/formatters/json.js.map +1 -0
- package/dist/lint/formatters/summary.d.ts +11 -0
- package/dist/lint/formatters/summary.d.ts.map +1 -0
- package/dist/lint/formatters/summary.js +37 -0
- package/dist/lint/formatters/summary.js.map +1 -0
- package/dist/lint/formatters/terminal.d.ts +11 -0
- package/dist/lint/formatters/terminal.d.ts.map +1 -0
- package/dist/lint/formatters/terminal.js +99 -0
- package/dist/lint/formatters/terminal.js.map +1 -0
- package/dist/lint/index.d.ts +18 -0
- package/dist/lint/index.d.ts.map +1 -0
- package/dist/lint/index.js +103 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/lint/rules/annotation-required.d.ts +35 -0
- package/dist/lint/rules/annotation-required.d.ts.map +1 -0
- package/dist/lint/rules/annotation-required.js +127 -0
- package/dist/lint/rules/annotation-required.js.map +1 -0
- package/dist/lint/rules/code-rules.d.ts +12 -0
- package/dist/lint/rules/code-rules.d.ts.map +1 -0
- package/dist/lint/rules/code-rules.js +11 -0
- package/dist/lint/rules/code-rules.js.map +1 -0
- package/dist/lint/rules/describe-coverage.d.ts +8 -0
- package/dist/lint/rules/describe-coverage.d.ts.map +1 -0
- package/dist/lint/rules/describe-coverage.js +43 -0
- package/dist/lint/rules/describe-coverage.js.map +1 -0
- package/dist/lint/rules/duplicate-testdoc.d.ts +8 -0
- package/dist/lint/rules/duplicate-testdoc.d.ts.map +1 -0
- package/dist/lint/rules/duplicate-testdoc.js +38 -0
- package/dist/lint/rules/duplicate-testdoc.js.map +1 -0
- package/dist/lint/rules/index.d.ts +29 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lint/rules/index.js +55 -0
- package/dist/lint/rules/index.js.map +1 -0
- package/dist/lint/rules/server-action-structure.d.ts +37 -0
- package/dist/lint/rules/server-action-structure.d.ts.map +1 -0
- package/dist/lint/rules/server-action-structure.js +152 -0
- package/dist/lint/rules/server-action-structure.js.map +1 -0
- package/dist/lint/rules/skipped-test-report.d.ts +11 -0
- package/dist/lint/rules/skipped-test-report.d.ts.map +1 -0
- package/dist/lint/rules/skipped-test-report.js +31 -0
- package/dist/lint/rules/skipped-test-report.js.map +1 -0
- package/dist/lint/rules/structure-rules.d.ts +67 -0
- package/dist/lint/rules/structure-rules.d.ts.map +1 -0
- package/dist/lint/rules/structure-rules.js +617 -0
- package/dist/lint/rules/structure-rules.js.map +1 -0
- package/dist/lint/rules/testdoc-japanese.d.ts +8 -0
- package/dist/lint/rules/testdoc-japanese.d.ts.map +1 -0
- package/dist/lint/rules/testdoc-japanese.js +31 -0
- package/dist/lint/rules/testdoc-japanese.js.map +1 -0
- package/dist/lint/rules/testdoc-min-length.d.ts +8 -0
- package/dist/lint/rules/testdoc-min-length.d.ts.map +1 -0
- package/dist/lint/rules/testdoc-min-length.js +31 -0
- package/dist/lint/rules/testdoc-min-length.js.map +1 -0
- package/dist/lint/rules/testdoc-required.d.ts +8 -0
- package/dist/lint/rules/testdoc-required.d.ts.map +1 -0
- package/dist/lint/rules/testdoc-required.js +27 -0
- package/dist/lint/rules/testdoc-required.js.map +1 -0
- package/dist/lint/rules/workflow-branch-naming.d.ts +20 -0
- package/dist/lint/rules/workflow-branch-naming.d.ts.map +1 -0
- package/dist/lint/rules/workflow-branch-naming.js +85 -0
- package/dist/lint/rules/workflow-branch-naming.js.map +1 -0
- package/dist/lint/rules/workflow-commit-format.d.ts +27 -0
- package/dist/lint/rules/workflow-commit-format.d.ts.map +1 -0
- package/dist/lint/rules/workflow-commit-format.js +92 -0
- package/dist/lint/rules/workflow-commit-format.js.map +1 -0
- package/dist/lint/rules/workflow-issue-fields.d.ts +24 -0
- package/dist/lint/rules/workflow-issue-fields.d.ts.map +1 -0
- package/dist/lint/rules/workflow-issue-fields.js +89 -0
- package/dist/lint/rules/workflow-issue-fields.js.map +1 -0
- package/dist/lint/rules/workflow-main-protection.d.ts +32 -0
- package/dist/lint/rules/workflow-main-protection.d.ts.map +1 -0
- package/dist/lint/rules/workflow-main-protection.js +114 -0
- package/dist/lint/rules/workflow-main-protection.js.map +1 -0
- package/dist/lint/structure-types.d.ts +216 -0
- package/dist/lint/structure-types.d.ts.map +1 -0
- package/dist/lint/structure-types.js +96 -0
- package/dist/lint/structure-types.js.map +1 -0
- package/dist/lint/types.d.ts +154 -0
- package/dist/lint/types.d.ts.map +1 -0
- package/dist/lint/types.js +21 -0
- package/dist/lint/types.js.map +1 -0
- package/dist/lint/workflow-types.d.ts +90 -0
- package/dist/lint/workflow-types.d.ts.map +1 -0
- package/dist/lint/workflow-types.js +7 -0
- package/dist/lint/workflow-types.js.map +1 -0
- package/dist/md/analyzer/index.d.ts +46 -0
- package/dist/md/analyzer/index.d.ts.map +1 -0
- package/dist/md/analyzer/index.js +288 -0
- package/dist/md/analyzer/index.js.map +1 -0
- package/dist/md/builder/index.d.ts +91 -0
- package/dist/md/builder/index.d.ts.map +1 -0
- package/dist/md/builder/index.js +446 -0
- package/dist/md/builder/index.js.map +1 -0
- package/dist/md/cli/analyze.d.ts +11 -0
- package/dist/md/cli/analyze.d.ts.map +1 -0
- package/dist/md/cli/analyze.js +118 -0
- package/dist/md/cli/analyze.js.map +1 -0
- package/dist/md/cli/build.d.ts +11 -0
- package/dist/md/cli/build.d.ts.map +1 -0
- package/dist/md/cli/build.js +74 -0
- package/dist/md/cli/build.js.map +1 -0
- package/dist/md/cli/extract.d.ts +25 -0
- package/dist/md/cli/extract.d.ts.map +1 -0
- package/dist/md/cli/extract.js +230 -0
- package/dist/md/cli/extract.js.map +1 -0
- package/dist/md/cli/index.d.ts +3 -0
- package/dist/md/cli/index.d.ts.map +1 -0
- package/dist/md/cli/index.js +99 -0
- package/dist/md/cli/index.js.map +1 -0
- package/dist/md/cli/lint.d.ts +11 -0
- package/dist/md/cli/lint.d.ts.map +1 -0
- package/dist/md/cli/lint.js +165 -0
- package/dist/md/cli/lint.js.map +1 -0
- package/dist/md/cli/list.d.ts +16 -0
- package/dist/md/cli/list.d.ts.map +1 -0
- package/dist/md/cli/list.js +85 -0
- package/dist/md/cli/list.js.map +1 -0
- package/dist/md/cli/program.d.ts +11 -0
- package/dist/md/cli/program.d.ts.map +1 -0
- package/dist/md/cli/program.js +104 -0
- package/dist/md/cli/program.js.map +1 -0
- package/dist/md/cli/validate.d.ts +8 -0
- package/dist/md/cli/validate.d.ts.map +1 -0
- package/dist/md/cli/validate.js +82 -0
- package/dist/md/cli/validate.js.map +1 -0
- package/dist/md/constants.d.ts +69 -0
- package/dist/md/constants.d.ts.map +1 -0
- package/dist/md/constants.js +69 -0
- package/dist/md/constants.js.map +1 -0
- package/dist/md/extractor/index.d.ts +57 -0
- package/dist/md/extractor/index.d.ts.map +1 -0
- package/dist/md/extractor/index.js +365 -0
- package/dist/md/extractor/index.js.map +1 -0
- package/dist/md/index.d.ts +26 -0
- package/dist/md/index.d.ts.map +1 -0
- package/dist/md/index.js +30 -0
- package/dist/md/index.js.map +1 -0
- package/dist/md/linter/index.d.ts +20 -0
- package/dist/md/linter/index.d.ts.map +1 -0
- package/dist/md/linter/index.js +421 -0
- package/dist/md/linter/index.js.map +1 -0
- package/dist/md/linter/token-optimizer.d.ts +66 -0
- package/dist/md/linter/token-optimizer.d.ts.map +1 -0
- package/dist/md/linter/token-optimizer.js +292 -0
- package/dist/md/linter/token-optimizer.js.map +1 -0
- package/dist/md/lister/index.d.ts +42 -0
- package/dist/md/lister/index.d.ts.map +1 -0
- package/dist/md/lister/index.js +317 -0
- package/dist/md/lister/index.js.map +1 -0
- package/dist/md/parser/heading-numbers.d.ts +43 -0
- package/dist/md/parser/heading-numbers.d.ts.map +1 -0
- package/dist/md/parser/heading-numbers.js +97 -0
- package/dist/md/parser/heading-numbers.js.map +1 -0
- package/dist/md/parser/section-meta.d.ts +50 -0
- package/dist/md/parser/section-meta.d.ts.map +1 -0
- package/dist/md/parser/section-meta.js +212 -0
- package/dist/md/parser/section-meta.js.map +1 -0
- package/dist/md/parser/template.d.ts +56 -0
- package/dist/md/parser/template.d.ts.map +1 -0
- package/dist/md/parser/template.js +122 -0
- package/dist/md/parser/template.js.map +1 -0
- package/dist/md/plugins/loader.d.ts +15 -0
- package/dist/md/plugins/loader.d.ts.map +1 -0
- package/dist/md/plugins/loader.js +80 -0
- package/dist/md/plugins/loader.js.map +1 -0
- package/dist/md/plugins/normalize-headings.d.ts +43 -0
- package/dist/md/plugins/normalize-headings.d.ts.map +1 -0
- package/dist/md/plugins/normalize-headings.js +51 -0
- package/dist/md/plugins/normalize-headings.js.map +1 -0
- package/dist/md/plugins/normalize-whitespace.d.ts +46 -0
- package/dist/md/plugins/normalize-whitespace.d.ts.map +1 -0
- package/dist/md/plugins/normalize-whitespace.js +86 -0
- package/dist/md/plugins/normalize-whitespace.js.map +1 -0
- package/dist/md/plugins/remove-badges.d.ts +36 -0
- package/dist/md/plugins/remove-badges.d.ts.map +1 -0
- package/dist/md/plugins/remove-badges.js +59 -0
- package/dist/md/plugins/remove-badges.js.map +1 -0
- package/dist/md/plugins/remove-comments.d.ts +27 -0
- package/dist/md/plugins/remove-comments.d.ts.map +1 -0
- package/dist/md/plugins/remove-comments.js +40 -0
- package/dist/md/plugins/remove-comments.js.map +1 -0
- package/dist/md/plugins/remove-duplicates.d.ts +40 -0
- package/dist/md/plugins/remove-duplicates.d.ts.map +1 -0
- package/dist/md/plugins/remove-duplicates.js +72 -0
- package/dist/md/plugins/remove-duplicates.js.map +1 -0
- package/dist/md/plugins/remove-internal-links.d.ts +38 -0
- package/dist/md/plugins/remove-internal-links.d.ts.map +1 -0
- package/dist/md/plugins/remove-internal-links.js +66 -0
- package/dist/md/plugins/remove-internal-links.js.map +1 -0
- package/dist/md/plugins/strip-heading-numbers.d.ts +35 -0
- package/dist/md/plugins/strip-heading-numbers.d.ts.map +1 -0
- package/dist/md/plugins/strip-heading-numbers.js +59 -0
- package/dist/md/plugins/strip-heading-numbers.js.map +1 -0
- package/dist/md/plugins/strip-section-meta.d.ts +37 -0
- package/dist/md/plugins/strip-section-meta.d.ts.map +1 -0
- package/dist/md/plugins/strip-section-meta.js +62 -0
- package/dist/md/plugins/strip-section-meta.js.map +1 -0
- package/dist/md/types/config.d.ts +260 -0
- package/dist/md/types/config.d.ts.map +1 -0
- package/dist/md/types/config.js +156 -0
- package/dist/md/types/config.js.map +1 -0
- package/dist/md/types/document.d.ts +37 -0
- package/dist/md/types/document.d.ts.map +1 -0
- package/dist/md/types/document.js +2 -0
- package/dist/md/types/document.js.map +1 -0
- package/dist/md/types/validation.d.ts +107 -0
- package/dist/md/types/validation.d.ts.map +1 -0
- package/dist/md/types/validation.js +2 -0
- package/dist/md/types/validation.js.map +1 -0
- package/dist/md/utils/code-blocks.d.ts +136 -0
- package/dist/md/utils/code-blocks.d.ts.map +1 -0
- package/dist/md/utils/code-blocks.js +178 -0
- package/dist/md/utils/code-blocks.js.map +1 -0
- package/dist/md/utils/config.d.ts +10 -0
- package/dist/md/utils/config.d.ts.map +1 -0
- package/dist/md/utils/config.js +99 -0
- package/dist/md/utils/config.js.map +1 -0
- package/dist/md/utils/file-collector.d.ts +78 -0
- package/dist/md/utils/file-collector.d.ts.map +1 -0
- package/dist/md/utils/file-collector.js +100 -0
- package/dist/md/utils/file-collector.js.map +1 -0
- package/dist/md/utils/markdown.d.ts +18 -0
- package/dist/md/utils/markdown.d.ts.map +1 -0
- package/dist/md/utils/markdown.js +93 -0
- package/dist/md/utils/markdown.js.map +1 -0
- package/dist/md/utils/remark.d.ts +91 -0
- package/dist/md/utils/remark.d.ts.map +1 -0
- package/dist/md/utils/remark.js +125 -0
- package/dist/md/utils/remark.js.map +1 -0
- package/dist/md/utils/tokens.d.ts +9 -0
- package/dist/md/utils/tokens.d.ts.map +1 -0
- package/dist/md/utils/tokens.js +31 -0
- package/dist/md/utils/tokens.js.map +1 -0
- package/dist/md/validator/index.d.ts +40 -0
- package/dist/md/validator/index.d.ts.map +1 -0
- package/dist/md/validator/index.js +299 -0
- package/dist/md/validator/index.js.map +1 -0
- package/dist/parsers/details-jsdoc.d.ts +42 -0
- package/dist/parsers/details-jsdoc.d.ts.map +1 -0
- package/dist/parsers/details-jsdoc.js +256 -0
- package/dist/parsers/details-jsdoc.js.map +1 -0
- package/dist/parsers/details-zod.d.ts +22 -0
- package/dist/parsers/details-zod.d.ts.map +1 -0
- package/dist/parsers/details-zod.js +146 -0
- package/dist/parsers/details-zod.js.map +1 -0
- package/dist/parsers/drizzle-schema.d.ts +92 -0
- package/dist/parsers/drizzle-schema.d.ts.map +1 -0
- package/dist/parsers/drizzle-schema.js +376 -0
- package/dist/parsers/drizzle-schema.js.map +1 -0
- package/dist/parsers/feature-map-tags.d.ts +45 -0
- package/dist/parsers/feature-map-tags.d.ts.map +1 -0
- package/dist/parsers/feature-map-tags.js +292 -0
- package/dist/parsers/feature-map-tags.js.map +1 -0
- package/dist/parsers/feature-map-type-extraction.d.ts +62 -0
- package/dist/parsers/feature-map-type-extraction.d.ts.map +1 -0
- package/dist/parsers/feature-map-type-extraction.js +347 -0
- package/dist/parsers/feature-map-type-extraction.js.map +1 -0
- package/dist/parsers/feature-map-utils.d.ts +34 -0
- package/dist/parsers/feature-map-utils.d.ts.map +1 -0
- package/dist/parsers/feature-map-utils.js +101 -0
- package/dist/parsers/feature-map-utils.js.map +1 -0
- package/dist/parsers/jsdoc-common.d.ts +209 -0
- package/dist/parsers/jsdoc-common.d.ts.map +1 -0
- package/dist/parsers/jsdoc-common.js +650 -0
- package/dist/parsers/jsdoc-common.js.map +1 -0
- package/dist/parsers/jsdoc.d.ts +76 -0
- package/dist/parsers/jsdoc.d.ts.map +1 -0
- package/dist/parsers/jsdoc.js +238 -0
- package/dist/parsers/jsdoc.js.map +1 -0
- package/dist/parsers/screenshot-annotations.d.ts +96 -0
- package/dist/parsers/screenshot-annotations.d.ts.map +1 -0
- package/dist/parsers/screenshot-annotations.js +227 -0
- package/dist/parsers/screenshot-annotations.js.map +1 -0
- package/dist/parsers/test-annotations.d.ts +46 -0
- package/dist/parsers/test-annotations.d.ts.map +1 -0
- package/dist/parsers/test-annotations.js +393 -0
- package/dist/parsers/test-annotations.js.map +1 -0
- package/dist/parsers/test-categorization.d.ts +42 -0
- package/dist/parsers/test-categorization.d.ts.map +1 -0
- package/dist/parsers/test-categorization.js +182 -0
- package/dist/parsers/test-categorization.js.map +1 -0
- package/dist/parsers/zod-schema.d.ts +105 -0
- package/dist/parsers/zod-schema.d.ts.map +1 -0
- package/dist/parsers/zod-schema.js +271 -0
- package/dist/parsers/zod-schema.js.map +1 -0
- package/dist/utils/action-inference.d.ts +23 -0
- package/dist/utils/action-inference.d.ts.map +1 -0
- package/dist/utils/action-inference.js +36 -0
- package/dist/utils/action-inference.js.map +1 -0
- package/dist/utils/app-inference.d.ts +31 -0
- package/dist/utils/app-inference.d.ts.map +1 -0
- package/dist/utils/app-inference.js +41 -0
- package/dist/utils/app-inference.js.map +1 -0
- package/dist/utils/auto-infer.d.ts +93 -0
- package/dist/utils/auto-infer.d.ts.map +1 -0
- package/dist/utils/auto-infer.js +184 -0
- package/dist/utils/auto-infer.js.map +1 -0
- package/dist/utils/config.d.ts +709 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +504 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/file.d.ts +46 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +103 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/formatters.d.ts +123 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +199 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/gh-config.d.ts +99 -0
- package/dist/utils/gh-config.d.ts.map +1 -0
- package/dist/utils/gh-config.js +247 -0
- package/dist/utils/gh-config.js.map +1 -0
- package/dist/utils/github.d.ts +108 -0
- package/dist/utils/github.d.ts.map +1 -0
- package/dist/utils/github.js +320 -0
- package/dist/utils/github.js.map +1 -0
- package/dist/utils/html.d.ts +107 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +376 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/i18n.d.ts +40 -0
- package/dist/utils/i18n.d.ts.map +1 -0
- package/dist/utils/i18n.js +148 -0
- package/dist/utils/i18n.js.map +1 -0
- package/dist/utils/logger.d.ts +20 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +49 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/project-fields.d.ts +71 -0
- package/dist/utils/project-fields.d.ts.map +1 -0
- package/dist/utils/project-fields.js +318 -0
- package/dist/utils/project-fields.js.map +1 -0
- package/dist/utils/repo-pairs.d.ts +94 -0
- package/dist/utils/repo-pairs.d.ts.map +1 -0
- package/dist/utils/repo-pairs.js +196 -0
- package/dist/utils/repo-pairs.js.map +1 -0
- package/dist/utils/route-inference.d.ts +81 -0
- package/dist/utils/route-inference.d.ts.map +1 -0
- package/dist/utils/route-inference.js +137 -0
- package/dist/utils/route-inference.js.map +1 -0
- package/dist/utils/sanitize.d.ts +27 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +38 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/setup-check.d.ts +48 -0
- package/dist/utils/setup-check.d.ts.map +1 -0
- package/dist/utils/setup-check.js +226 -0
- package/dist/utils/setup-check.js.map +1 -0
- package/dist/utils/shirokumaignore.d.ts +55 -0
- package/dist/utils/shirokumaignore.d.ts.map +1 -0
- package/dist/utils/shirokumaignore.js +94 -0
- package/dist/utils/shirokumaignore.js.map +1 -0
- package/dist/utils/skills-repo.d.ts +353 -0
- package/dist/utils/skills-repo.d.ts.map +1 -0
- package/dist/utils/skills-repo.js +793 -0
- package/dist/utils/skills-repo.js.map +1 -0
- package/dist/utils/status-workflow.d.ts +54 -0
- package/dist/utils/status-workflow.d.ts.map +1 -0
- package/dist/utils/status-workflow.js +103 -0
- package/dist/utils/status-workflow.js.map +1 -0
- package/dist/validators/frontmatter.d.ts +41 -0
- package/dist/validators/frontmatter.d.ts.map +1 -0
- package/dist/validators/frontmatter.js +117 -0
- package/dist/validators/frontmatter.js.map +1 -0
- package/dist/validators/link-checker.d.ts +48 -0
- package/dist/validators/link-checker.d.ts.map +1 -0
- package/dist/validators/link-checker.js +108 -0
- package/dist/validators/link-checker.js.map +1 -0
- package/dist/validators/markdown-structure.d.ts +50 -0
- package/dist/validators/markdown-structure.d.ts.map +1 -0
- package/dist/validators/markdown-structure.js +253 -0
- package/dist/validators/markdown-structure.js.map +1 -0
- package/i18n/cli/en.json +164 -0
- package/i18n/cli/ja.json +164 -0
- package/i18n/discussion/en.json +191 -0
- package/i18n/discussion/ja.json +191 -0
- package/package.json +113 -0
- package/portal/app/api-tools/api-tools-client.tsx +411 -0
- package/portal/app/api-tools/api-tools-document.tsx +240 -0
- package/portal/app/api-tools/page.tsx +56 -0
- package/portal/app/api-tools/swagger-view.tsx +114 -0
- package/portal/app/apps/[appId]/[type]/[module]/[item]/item-tabs-client.tsx +71 -0
- package/portal/app/apps/[appId]/[type]/[module]/[item]/page.tsx +1422 -0
- package/portal/app/apps/[appId]/[type]/[module]/page.tsx +373 -0
- package/portal/app/apps/[appId]/feature-map/feature-map-app-document.tsx +298 -0
- package/portal/app/apps/[appId]/feature-map/page.tsx +224 -0
- package/portal/app/apps/[appId]/i18n/page.tsx +139 -0
- package/portal/app/apps/[appId]/test-cases/page.tsx +840 -0
- package/portal/app/apps/[appId]/tools/[tool]/page.tsx +351 -0
- package/portal/app/apps/[appId]/tools/api-tools-client.tsx +429 -0
- package/portal/app/apps/[appId]/tools/page.tsx +119 -0
- package/portal/app/db-schema/[db]/[table]/page.tsx +235 -0
- package/portal/app/db-schema/[db]/diagram/page.tsx +81 -0
- package/portal/app/db-schema/[db]/page.tsx +148 -0
- package/portal/app/db-schema/db-schema-document.tsx +100 -0
- package/portal/app/db-schema/diagram/client.tsx +211 -0
- package/portal/app/db-schema/diagram/page.tsx +20 -0
- package/portal/app/db-schema/page.tsx +145 -0
- package/portal/app/db-schema/table-detail-document.tsx +710 -0
- package/portal/app/db-schema/table-detail.tsx +747 -0
- package/portal/app/db-schema/table-list-document.tsx +224 -0
- package/portal/app/db-schema/table-list.tsx +247 -0
- package/portal/app/details/[type]/[module]/[item]/item-tabs-client.tsx +71 -0
- package/portal/app/details/[type]/[module]/[item]/page.tsx +1286 -0
- package/portal/app/details/[type]/[module]/page.tsx +884 -0
- package/portal/app/feature-map/feature-map-client.tsx +681 -0
- package/portal/app/feature-map/feature-map-document.tsx +313 -0
- package/portal/app/feature-map/page.tsx +438 -0
- package/portal/app/globals.css +205 -0
- package/portal/app/i18n/[...namespace]/page.tsx +190 -0
- package/portal/app/i18n/i18n-client.tsx +369 -0
- package/portal/app/i18n/page.tsx +339 -0
- package/portal/app/layout.tsx +37 -0
- package/portal/app/overview/page.tsx +65 -0
- package/portal/app/packages/[packageId]/page.tsx +201 -0
- package/portal/app/packages/page.tsx +148 -0
- package/portal/app/page.tsx +568 -0
- package/portal/app/test-cases/[file]/[line]/page.tsx +455 -0
- package/portal/app/test-cases/[file]/[line]/test-detail-document.tsx +335 -0
- package/portal/app/test-cases/[file]/page.tsx +323 -0
- package/portal/app/test-cases/[file]/test-file-document.tsx +335 -0
- package/portal/app/test-cases/page.tsx +546 -0
- package/portal/app/test-cases/test-cases-document.tsx +384 -0
- package/portal/components/code-block.tsx +57 -0
- package/portal/components/document/doc-params-table.tsx +71 -0
- package/portal/components/document/doc-section.tsx +133 -0
- package/portal/components/document/doc-table.tsx +119 -0
- package/portal/components/document/index.ts +9 -0
- package/portal/components/drawflow-er-diagram.tsx +607 -0
- package/portal/components/interactive-er-diagram.tsx +228 -0
- package/portal/components/layout/app-sidebar.tsx +490 -0
- package/portal/components/layout/er-sidebar.tsx +116 -0
- package/portal/components/layout/global-header.tsx +117 -0
- package/portal/components/layout/layout-content.tsx +48 -0
- package/portal/components/markdown-content.tsx +120 -0
- package/portal/components/mermaid-diagram.tsx +83 -0
- package/portal/components/reactflow-er-diagram.tsx +475 -0
- package/portal/components/search-dialog.tsx +268 -0
- package/portal/components/shared/coverage-score-bar.tsx +144 -0
- package/portal/components/swagger/endpoint-accordion.tsx +117 -0
- package/portal/components/swagger/index.ts +7 -0
- package/portal/components/swagger/method-badge.tsx +55 -0
- package/portal/components/swagger/params-table.tsx +78 -0
- package/portal/components/tabs-with-hash.tsx +43 -0
- package/portal/components/test/index.ts +2 -0
- package/portal/components/test/test-bdd-card.tsx +192 -0
- package/portal/components/test/test-matrix.tsx +242 -0
- package/portal/components/ui/accordion.tsx +66 -0
- package/portal/components/ui/badge.tsx +46 -0
- package/portal/components/ui/breadcrumb.tsx +109 -0
- package/portal/components/ui/button.tsx +62 -0
- package/portal/components/ui/card.tsx +92 -0
- package/portal/components/ui/collapsible.tsx +33 -0
- package/portal/components/ui/dialog.tsx +118 -0
- package/portal/components/ui/progress.tsx +28 -0
- package/portal/components/ui/scroll-area.tsx +58 -0
- package/portal/components/ui/sheet.tsx +139 -0
- package/portal/components/ui/table.tsx +116 -0
- package/portal/components/ui/tabs.tsx +66 -0
- package/portal/components.json +21 -0
- package/portal/lib/constants/test-categories.ts +186 -0
- package/portal/lib/data-loader.ts +1181 -0
- package/portal/lib/db-schema-utils.ts +182 -0
- package/portal/lib/format.ts +43 -0
- package/portal/lib/hooks/use-hash-tab.ts +144 -0
- package/portal/lib/path-utils.ts +25 -0
- package/portal/lib/search-index-generator.ts +214 -0
- package/portal/lib/search.ts +126 -0
- package/portal/lib/sidebar-context.tsx +111 -0
- package/portal/lib/types.ts +740 -0
- package/portal/lib/utils.ts +6 -0
- package/portal/next.config.ts +18 -0
- package/portal/package.json +45 -0
- package/portal/postcss.config.mjs +8 -0
- package/portal/tsconfig.json +42 -0
- package/portal/types/drawflow.d.ts +80 -0
- package/templates/README.md +73 -0
- package/templates/coverage.html +367 -0
- package/templates/dark-theme.css +443 -0
- package/templates/discussion/adr.yml.hbs +65 -0
- package/templates/discussion/handovers.yml.hbs +57 -0
- package/templates/discussion/knowledge.yml.hbs +60 -0
- package/templates/discussion/reports.yml.hbs +68 -0
- package/templates/discussion/research.yml.hbs +61 -0
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schema コマンド - DB スキーマドキュメント生成 (DBML, SVG)
|
|
3
|
+
*
|
|
4
|
+
* Drizzle ORM スキーマから以下を生成:
|
|
5
|
+
* - schema.dbml - DBML ソースファイル
|
|
6
|
+
* - schema.svg - ER 図 (SVG)
|
|
7
|
+
* - schema-docs.md - テーブル説明 Markdown
|
|
8
|
+
*/
|
|
9
|
+
import { resolve, basename } from "node:path";
|
|
10
|
+
import { spawnSync } from "node:child_process";
|
|
11
|
+
import { loadConfig, getOutputPath, resolvePath } from "../utils/config.js";
|
|
12
|
+
import { ensureDir, fileExists, writeFile, readFile, listFiles, } from "../utils/file.js";
|
|
13
|
+
import { createLogger } from "../utils/logger.js";
|
|
14
|
+
import { extractDbSchemaJsDocs } from "../parsers/jsdoc-common.js";
|
|
15
|
+
import { parseDrizzleSchemaDir, toPortalDbSchema, } from "../parsers/drizzle-schema.js";
|
|
16
|
+
/**
|
|
17
|
+
* パスからDB名を取得
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* getDbNameFromPath("packages/database/src/schema") // -> "database"
|
|
21
|
+
* getDbNameFromPath("packages/analytics-db/src/schema") // -> "analytics-db"
|
|
22
|
+
* getDbNameFromPath("./src/schema") // -> "schema"
|
|
23
|
+
*/
|
|
24
|
+
export function getDbNameFromPath(path) {
|
|
25
|
+
const parts = path.split("/").filter((p) => p && p !== ".");
|
|
26
|
+
// "packages" の次のディレクトリ名を使用
|
|
27
|
+
const packagesIndex = parts.indexOf("packages");
|
|
28
|
+
if (packagesIndex !== -1 && parts[packagesIndex + 1]) {
|
|
29
|
+
return parts[packagesIndex + 1];
|
|
30
|
+
}
|
|
31
|
+
// フォールバック: 最初の意味のあるディレクトリ名
|
|
32
|
+
// src, schema を除外して探す
|
|
33
|
+
const excludeNames = ["src", "schema"];
|
|
34
|
+
const meaningfulPart = parts.find((p) => !excludeNames.includes(p));
|
|
35
|
+
return meaningfulPart || "default";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 設定から正規化されたスキーマ設定リストを取得
|
|
39
|
+
*/
|
|
40
|
+
export function normalizeSchemaConfigs(config, projectPath) {
|
|
41
|
+
const schemaConfig = config.schema;
|
|
42
|
+
const defaultPattern = "*.ts";
|
|
43
|
+
// sources が未定義または空配列の場合
|
|
44
|
+
if (!schemaConfig?.sources || schemaConfig.sources.length === 0) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return schemaConfig.sources.map((src) => {
|
|
48
|
+
const dbName = getDbNameFromPath(src.path);
|
|
49
|
+
const sourcePath = resolvePath(projectPath, src.path);
|
|
50
|
+
const outputPath = resolve(getOutputPath(config, projectPath, "generated"), "schema", dbName);
|
|
51
|
+
return {
|
|
52
|
+
name: dbName,
|
|
53
|
+
description: src.description,
|
|
54
|
+
source: sourcePath,
|
|
55
|
+
output: outputPath,
|
|
56
|
+
pattern: schemaConfig.pattern ?? defaultPattern,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* schema コマンドハンドラ
|
|
62
|
+
*/
|
|
63
|
+
export async function schemaCommand(options) {
|
|
64
|
+
const logger = createLogger(options.verbose);
|
|
65
|
+
const projectPath = resolve(options.project);
|
|
66
|
+
logger.info("DB スキーマドキュメントを生成");
|
|
67
|
+
// 設定読み込み
|
|
68
|
+
const config = loadConfig(projectPath, options.config);
|
|
69
|
+
// 正規化されたスキーマ設定リストを取得
|
|
70
|
+
const schemaConfigs = normalizeSchemaConfigs(config, projectPath);
|
|
71
|
+
if (schemaConfigs.length === 0) {
|
|
72
|
+
logger.warn("スキーマソースが設定されていません");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// パッケージの存在確認
|
|
76
|
+
const packageStatus = checkPackages(projectPath, logger);
|
|
77
|
+
// 複数DB対応: 各DBごとに処理
|
|
78
|
+
const allDatabases = [];
|
|
79
|
+
const allTables = [];
|
|
80
|
+
for (let i = 0; i < schemaConfigs.length; i++) {
|
|
81
|
+
const schemaConfig = schemaConfigs[i];
|
|
82
|
+
const dbLabel = schemaConfigs.length > 1 ? ` [${schemaConfig.name}]` : "";
|
|
83
|
+
logger.info(`\n--- データベース: ${schemaConfig.name}${schemaConfig.description ? ` (${schemaConfig.description})` : ""} ---`);
|
|
84
|
+
// ソースディレクトリ確認
|
|
85
|
+
if (!fileExists(schemaConfig.source)) {
|
|
86
|
+
logger.error(`スキーマソースが見つかりません: ${schemaConfig.source}`);
|
|
87
|
+
continue; // 複数DBの場合は次へ進む
|
|
88
|
+
}
|
|
89
|
+
logger.debug(`スキーマソース: ${schemaConfig.source}`);
|
|
90
|
+
// 出力ディレクトリ
|
|
91
|
+
ensureDir(schemaConfig.output);
|
|
92
|
+
logger.debug(`出力ディレクトリ: ${schemaConfig.output}`);
|
|
93
|
+
// Step 1: DBML 生成
|
|
94
|
+
let dbmlPath = null;
|
|
95
|
+
if (packageStatus.dbmlGenerator) {
|
|
96
|
+
logger.step(1, 3, `DBML 生成${dbLabel}`);
|
|
97
|
+
dbmlPath = await generateDbml(projectPath, schemaConfig.source, schemaConfig.output, logger, options.verbose);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
logger.step(1, 3, `DBML 生成${dbLabel} (スキップ - パッケージ未インストール)`);
|
|
101
|
+
}
|
|
102
|
+
// Step 2: SVG 生成
|
|
103
|
+
if (dbmlPath && fileExists(dbmlPath)) {
|
|
104
|
+
logger.step(2, 3, `SVG ER 図生成${dbLabel}`);
|
|
105
|
+
await generateSvg(projectPath, dbmlPath, schemaConfig.output, packageStatus, logger, options.verbose);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
logger.step(2, 3, `SVG ER 図生成${dbLabel} (スキップ - DBML なし)`);
|
|
109
|
+
}
|
|
110
|
+
// Step 3: スキーマドキュメント生成
|
|
111
|
+
logger.step(3, 3, `スキーマドキュメント生成${dbLabel}`);
|
|
112
|
+
const dbTables = await generateSchemaIndex(schemaConfig.source, schemaConfig.output, dbmlPath, logger, schemaConfig.name);
|
|
113
|
+
// テーブル情報を集約(単一DBでも常に実行)
|
|
114
|
+
if (dbTables) {
|
|
115
|
+
allDatabases.push({
|
|
116
|
+
name: schemaConfig.name,
|
|
117
|
+
description: schemaConfig.description,
|
|
118
|
+
tableCount: dbTables.length,
|
|
119
|
+
});
|
|
120
|
+
// テーブルにデータベース名を付与
|
|
121
|
+
for (const table of dbTables) {
|
|
122
|
+
allTables.push({
|
|
123
|
+
...table,
|
|
124
|
+
database: schemaConfig.name,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
logger.success(`スキーマドキュメント生成完了${dbLabel}`);
|
|
129
|
+
logger.info(`出力: ${schemaConfig.output}`);
|
|
130
|
+
}
|
|
131
|
+
// 統合JSONを出力(単一DBでも常に実行)
|
|
132
|
+
if (allTables.length > 0) {
|
|
133
|
+
const portalDir = resolve(getOutputPath(config, projectPath, "portal"));
|
|
134
|
+
ensureDir(portalDir);
|
|
135
|
+
const combinedSchema = {
|
|
136
|
+
databases: allDatabases,
|
|
137
|
+
tables: allTables,
|
|
138
|
+
generatedAt: new Date().toISOString(),
|
|
139
|
+
};
|
|
140
|
+
const combinedJsonPath = resolve(portalDir, "db-schema.json");
|
|
141
|
+
writeFile(combinedJsonPath, JSON.stringify(combinedSchema, null, 2));
|
|
142
|
+
logger.success(`統合ポータルJSON: ${combinedJsonPath}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* パッケージの存在確認
|
|
147
|
+
*/
|
|
148
|
+
function checkPackages(projectPath, logger) {
|
|
149
|
+
const status = {
|
|
150
|
+
dbmlGenerator: false,
|
|
151
|
+
dbmlRenderer: false,
|
|
152
|
+
};
|
|
153
|
+
// drizzle-dbml-generator 確認
|
|
154
|
+
const dbmlGenResult = spawnSync("npm", ["list", "drizzle-dbml-generator"], {
|
|
155
|
+
cwd: projectPath,
|
|
156
|
+
stdio: "pipe",
|
|
157
|
+
});
|
|
158
|
+
if (dbmlGenResult.status === 0) {
|
|
159
|
+
status.dbmlGenerator = true;
|
|
160
|
+
logger.debug("drizzle-dbml-generator: インストール済み");
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
logger.warn("drizzle-dbml-generator がインストールされていません");
|
|
164
|
+
logger.info(" インストール: pnpm add -D drizzle-dbml-generator");
|
|
165
|
+
}
|
|
166
|
+
// @softwaretechnik/dbml-renderer 確認
|
|
167
|
+
const dbmlRendererResult = spawnSync("npm", ["list", "@softwaretechnik/dbml-renderer"], {
|
|
168
|
+
cwd: projectPath,
|
|
169
|
+
stdio: "pipe",
|
|
170
|
+
});
|
|
171
|
+
if (dbmlRendererResult.status === 0) {
|
|
172
|
+
status.dbmlRenderer = true;
|
|
173
|
+
logger.debug("@softwaretechnik/dbml-renderer: インストール済み");
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// グローバルにインストールされているか確認
|
|
177
|
+
const whichResult = spawnSync("which", ["dbml-renderer"], { stdio: "pipe" });
|
|
178
|
+
if (whichResult.status === 0) {
|
|
179
|
+
status.dbmlRenderer = true;
|
|
180
|
+
logger.debug("dbml-renderer: グローバルインストール済み");
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
logger.warn("@softwaretechnik/dbml-renderer がインストールされていません");
|
|
184
|
+
logger.info(" インストール: pnpm add -D @softwaretechnik/dbml-renderer");
|
|
185
|
+
logger.info(" または: npm install -g @softwaretechnik/dbml-renderer");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return status;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* DBML を生成
|
|
192
|
+
*/
|
|
193
|
+
async function generateDbml(projectPath, schemaSource, outputDir, logger, verbose) {
|
|
194
|
+
const scriptPath = resolve(outputDir, "_generate-dbml.mjs");
|
|
195
|
+
const dbmlPath = resolve(outputDir, "schema.dbml");
|
|
196
|
+
// スキーマの index.ts または index.js を探す
|
|
197
|
+
const indexTs = resolve(schemaSource, "index.ts");
|
|
198
|
+
const indexJs = resolve(schemaSource, "index.js");
|
|
199
|
+
let schemaImportPath;
|
|
200
|
+
if (fileExists(indexTs)) {
|
|
201
|
+
// TypeScript の場合、トランスパイルが必要
|
|
202
|
+
// tsx を使用するか、既にビルドされた js を使用
|
|
203
|
+
schemaImportPath = schemaSource;
|
|
204
|
+
}
|
|
205
|
+
else if (fileExists(indexJs)) {
|
|
206
|
+
schemaImportPath = schemaSource;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
logger.warn(`スキーマの index ファイルが見つかりません: ${schemaSource}`);
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
// 生成スクリプト作成
|
|
213
|
+
const scriptContent = `
|
|
214
|
+
import { pgGenerate } from 'drizzle-dbml-generator';
|
|
215
|
+
|
|
216
|
+
// スキーマをインポート
|
|
217
|
+
// Note: TypeScript の場合は tsx で実行するか、ビルド済みの js を使用
|
|
218
|
+
const schemaModule = await import('${schemaImportPath}/index.js');
|
|
219
|
+
|
|
220
|
+
// default export または named export を取得
|
|
221
|
+
const schema = schemaModule.default || schemaModule;
|
|
222
|
+
|
|
223
|
+
// DBML 生成
|
|
224
|
+
const dbml = pgGenerate({ schema, relational: true });
|
|
225
|
+
console.log(dbml);
|
|
226
|
+
`;
|
|
227
|
+
writeFile(scriptPath, scriptContent);
|
|
228
|
+
logger.debug(`生成スクリプト: ${scriptPath}`);
|
|
229
|
+
// スクリプト実行
|
|
230
|
+
const nodeResult = spawnSync("node", [scriptPath], {
|
|
231
|
+
cwd: projectPath,
|
|
232
|
+
encoding: "utf-8",
|
|
233
|
+
stdio: ["pipe", "pipe", verbose ? "inherit" : "pipe"],
|
|
234
|
+
});
|
|
235
|
+
if (nodeResult.status === 0 && nodeResult.stdout) {
|
|
236
|
+
writeFile(dbmlPath, nodeResult.stdout);
|
|
237
|
+
logger.success(`DBML: ${dbmlPath}`);
|
|
238
|
+
// 一時スクリプト削除
|
|
239
|
+
spawnSync("rm", ["-f", scriptPath], { stdio: "pipe" });
|
|
240
|
+
return dbmlPath;
|
|
241
|
+
}
|
|
242
|
+
// tsx を使って再試行
|
|
243
|
+
logger.debug("node での実行失敗、tsx で再試行");
|
|
244
|
+
const tsxScriptContent = `
|
|
245
|
+
import { pgGenerate } from 'drizzle-dbml-generator';
|
|
246
|
+
import * as schema from '${schemaImportPath}/index.js';
|
|
247
|
+
|
|
248
|
+
// DBML 生成
|
|
249
|
+
const dbml = pgGenerate({ schema, relational: true });
|
|
250
|
+
console.log(dbml);
|
|
251
|
+
`;
|
|
252
|
+
writeFile(scriptPath, tsxScriptContent);
|
|
253
|
+
// npx tsx を使用
|
|
254
|
+
const tsxResult = spawnSync("npx", ["tsx", scriptPath], {
|
|
255
|
+
cwd: projectPath,
|
|
256
|
+
encoding: "utf-8",
|
|
257
|
+
stdio: ["pipe", "pipe", verbose ? "inherit" : "pipe"],
|
|
258
|
+
});
|
|
259
|
+
// 一時スクリプト削除
|
|
260
|
+
spawnSync("rm", ["-f", scriptPath], { stdio: "pipe" });
|
|
261
|
+
if (tsxResult.status === 0 && tsxResult.stdout) {
|
|
262
|
+
writeFile(dbmlPath, tsxResult.stdout);
|
|
263
|
+
logger.success(`DBML: ${dbmlPath}`);
|
|
264
|
+
return dbmlPath;
|
|
265
|
+
}
|
|
266
|
+
logger.warn(`DBML 生成失敗: ${tsxResult.stderr || tsxResult.error}`);
|
|
267
|
+
logger.info("ヒント: TypeScript スキーマの場合は tsx をインストールしてください");
|
|
268
|
+
logger.info(" pnpm add -D tsx");
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* SVG ER 図を生成
|
|
273
|
+
*/
|
|
274
|
+
async function generateSvg(projectPath, dbmlPath, outputDir, packageStatus, logger, verbose) {
|
|
275
|
+
const svgPath = resolve(outputDir, "schema.svg");
|
|
276
|
+
// 方法1: @softwaretechnik/dbml-renderer を使用
|
|
277
|
+
if (packageStatus.dbmlRenderer) {
|
|
278
|
+
logger.debug(`実行: npx dbml-renderer -i "${dbmlPath}" -o "${svgPath}"`);
|
|
279
|
+
const rendererResult = spawnSync("npx", ["dbml-renderer", "-i", dbmlPath, "-o", svgPath], {
|
|
280
|
+
cwd: projectPath,
|
|
281
|
+
stdio: verbose ? "inherit" : "pipe",
|
|
282
|
+
});
|
|
283
|
+
if (rendererResult.status === 0 && fileExists(svgPath)) {
|
|
284
|
+
logger.success(`SVG ER 図: ${svgPath}`);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
logger.debug(`dbml-renderer 失敗: ${rendererResult.stderr || rendererResult.error}`);
|
|
288
|
+
}
|
|
289
|
+
// 方法2: dbml-cli + graphviz を使用
|
|
290
|
+
// まず dbml を dot 形式に変換
|
|
291
|
+
const dotPath = resolve(outputDir, "schema.dot");
|
|
292
|
+
// @dbml/cli がインストールされているか確認
|
|
293
|
+
const dbmlCliResult = spawnSync("npm", ["list", "@dbml/cli"], { cwd: projectPath, stdio: "pipe" });
|
|
294
|
+
if (dbmlCliResult.status === 0) {
|
|
295
|
+
// dbml を dot に変換
|
|
296
|
+
logger.debug(`実行: npx dbml2dot "${dbmlPath}" -o "${dotPath}"`);
|
|
297
|
+
const toDotResult = spawnSync("npx", ["dbml2dot", dbmlPath, "-o", dotPath], {
|
|
298
|
+
cwd: projectPath,
|
|
299
|
+
stdio: verbose ? "inherit" : "pipe",
|
|
300
|
+
});
|
|
301
|
+
// dot を svg に変換
|
|
302
|
+
if (toDotResult.status === 0 && fileExists(dotPath)) {
|
|
303
|
+
logger.debug(`実行: dot -Tsvg "${dotPath}" -o "${svgPath}"`);
|
|
304
|
+
const toSvgResult = spawnSync("dot", ["-Tsvg", dotPath, "-o", svgPath], {
|
|
305
|
+
cwd: projectPath,
|
|
306
|
+
stdio: verbose ? "inherit" : "pipe",
|
|
307
|
+
});
|
|
308
|
+
if (toSvgResult.status === 0 && fileExists(svgPath)) {
|
|
309
|
+
logger.success(`SVG ER 図: ${svgPath}`);
|
|
310
|
+
// dot ファイル削除
|
|
311
|
+
spawnSync("rm", ["-f", dotPath], { stdio: "pipe" });
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
logger.debug("@dbml/cli 未インストールまたは変換失敗");
|
|
318
|
+
}
|
|
319
|
+
// 方法3: 簡易 SVG 生成 (フォールバック)
|
|
320
|
+
logger.warn("SVG 生成ツールが利用できません");
|
|
321
|
+
logger.info("以下のいずれかをインストールしてください:");
|
|
322
|
+
logger.info(" 1. pnpm add -D @softwaretechnik/dbml-renderer (推奨)");
|
|
323
|
+
logger.info(" 2. pnpm add -D @dbml/cli && apt install graphviz");
|
|
324
|
+
logger.info("");
|
|
325
|
+
logger.info("代替手段: DBML を以下のサービスで可視化できます:");
|
|
326
|
+
logger.info(" - https://dbdiagram.io/d (DBML をコピー&ペースト)");
|
|
327
|
+
logger.info(" - https://dbdocs.io/ (DBML ドキュメントホスティング)");
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* スキーマファイルのインデックスとドキュメントを生成
|
|
331
|
+
*
|
|
332
|
+
* @param schemaSource スキーマソースディレクトリ
|
|
333
|
+
* @param outputDir 出力ディレクトリ
|
|
334
|
+
* @param dbmlPath DBMLファイルパス(なければnull)
|
|
335
|
+
* @param logger ロガー
|
|
336
|
+
* @param dbName データベース名
|
|
337
|
+
* @returns ポータル用テーブル情報
|
|
338
|
+
*/
|
|
339
|
+
async function generateSchemaIndex(schemaSource, outputDir, dbmlPath, logger, dbName = "default") {
|
|
340
|
+
const schemaFiles = listFiles(schemaSource, {
|
|
341
|
+
extensions: [".ts"],
|
|
342
|
+
recursive: false,
|
|
343
|
+
}).filter((f) => !f.endsWith(".test.ts") && !f.endsWith(".spec.ts"));
|
|
344
|
+
if (schemaFiles.length === 0) {
|
|
345
|
+
logger.warn("スキーマファイルが見つかりません");
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
// DBML からテーブル情報を抽出、なければ直接パース
|
|
349
|
+
let tables = [];
|
|
350
|
+
let drizzleResult = null;
|
|
351
|
+
if (dbmlPath) {
|
|
352
|
+
tables = parseDbmlTables(dbmlPath, logger);
|
|
353
|
+
}
|
|
354
|
+
// DBML がない場合、または DBML からテーブルが抽出できなかった場合は直接パース
|
|
355
|
+
if (tables.length === 0) {
|
|
356
|
+
logger.info("DBML なし、Drizzle スキーマを直接パース");
|
|
357
|
+
drizzleResult = parseDrizzleSchemaDir(schemaSource, logger);
|
|
358
|
+
// DrizzleSchemaResult を TableInfo[] に変換
|
|
359
|
+
tables = drizzleResult.tables.map((t) => ({
|
|
360
|
+
name: t.name,
|
|
361
|
+
note: t.description,
|
|
362
|
+
columns: t.columns.map((c) => ({
|
|
363
|
+
name: c.name,
|
|
364
|
+
type: c.type,
|
|
365
|
+
pk: c.primaryKey,
|
|
366
|
+
notNull: !c.nullable,
|
|
367
|
+
unique: c.unique,
|
|
368
|
+
default: c.default,
|
|
369
|
+
note: c.description,
|
|
370
|
+
})),
|
|
371
|
+
indexes: t.indexes.map((i) => ({
|
|
372
|
+
name: i.name,
|
|
373
|
+
columns: i.columns,
|
|
374
|
+
unique: i.unique,
|
|
375
|
+
})),
|
|
376
|
+
}));
|
|
377
|
+
logger.success(`${tables.length} テーブルを直接パースで抽出`);
|
|
378
|
+
}
|
|
379
|
+
// スキーマドキュメント Markdown 生成
|
|
380
|
+
const content = [
|
|
381
|
+
"# データベーススキーマ",
|
|
382
|
+
"",
|
|
383
|
+
`> 自動生成: ${new Date().toISOString().split("T")[0]}`,
|
|
384
|
+
"",
|
|
385
|
+
"## 概要",
|
|
386
|
+
"",
|
|
387
|
+
`- スキーマファイル数: ${schemaFiles.length}`,
|
|
388
|
+
`- テーブル数: ${tables.length}`,
|
|
389
|
+
"",
|
|
390
|
+
"## スキーマファイル",
|
|
391
|
+
"",
|
|
392
|
+
"| ファイル | 説明 |",
|
|
393
|
+
"|----------|------|",
|
|
394
|
+
...schemaFiles.map((file) => {
|
|
395
|
+
const name = basename(file);
|
|
396
|
+
const description = inferFileDescription(name);
|
|
397
|
+
return `| \`${name}\` | ${description} |`;
|
|
398
|
+
}),
|
|
399
|
+
"",
|
|
400
|
+
];
|
|
401
|
+
// テーブル一覧
|
|
402
|
+
if (tables.length > 0) {
|
|
403
|
+
content.push("## テーブル一覧", "", "| テーブル名 | カラム数 | 説明 |", "|------------|----------|------|", ...tables.map((t) => `| \`${t.name}\` | ${t.columns.length} | ${t.note || "-"} |`), "");
|
|
404
|
+
// 各テーブルの詳細
|
|
405
|
+
content.push("## テーブル詳細", "");
|
|
406
|
+
for (const table of tables) {
|
|
407
|
+
content.push(`### ${table.name}`, "", table.note ? `${table.note}` : "", "", "| カラム | 型 | 制約 | 説明 |", "|--------|-----|------|------|", ...table.columns.map((col) => {
|
|
408
|
+
const constraints = [];
|
|
409
|
+
if (col.pk)
|
|
410
|
+
constraints.push("PK");
|
|
411
|
+
if (col.notNull)
|
|
412
|
+
constraints.push("NOT NULL");
|
|
413
|
+
if (col.unique)
|
|
414
|
+
constraints.push("UNIQUE");
|
|
415
|
+
if (col.default)
|
|
416
|
+
constraints.push(`DEFAULT: ${col.default}`);
|
|
417
|
+
return `| \`${col.name}\` | ${col.type} | ${constraints.join(", ") || "-"} | ${col.note || "-"} |`;
|
|
418
|
+
}), "");
|
|
419
|
+
// インデックス
|
|
420
|
+
if (table.indexes && table.indexes.length > 0) {
|
|
421
|
+
content.push("**インデックス:**", "", ...table.indexes.map((idx) => `- \`${idx.name}\`: ${idx.columns.join(", ")}${idx.unique ? " (UNIQUE)" : ""}`), "");
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
// 可視化セクション
|
|
426
|
+
content.push("## 可視化", "", "### ローカルファイル", "", dbmlPath ? "- [DBML ソース](./schema.dbml)" : "- DBML: 生成されていません", fileExists(resolve(outputDir, "schema.svg"))
|
|
427
|
+
? "- [ER 図 (SVG)](./schema.svg)"
|
|
428
|
+
: "- SVG: 生成されていません", "", "### オンラインツール", "", "- [dbdiagram.io](https://dbdiagram.io/d) - DBML をコピーして可視化", "- [dbdocs.io](https://dbdocs.io/) - DBML ドキュメントホスティング", "", "## 生成コマンド", "", "```bash", "shirokuma-docs schema", "```", "");
|
|
429
|
+
const docsPath = resolve(outputDir, "schema-docs.md");
|
|
430
|
+
writeFile(docsPath, content.join("\n"));
|
|
431
|
+
logger.success(`スキーマドキュメント: ${docsPath}`);
|
|
432
|
+
// ポータル用 JSON 出力
|
|
433
|
+
let portalSchema;
|
|
434
|
+
if (drizzleResult) {
|
|
435
|
+
// 直接パース結果を使用(より正確)
|
|
436
|
+
portalSchema = toPortalDbSchema(drizzleResult);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
// DBML から生成
|
|
440
|
+
portalSchema = generatePortalDbSchema(tables, schemaFiles, schemaSource, logger);
|
|
441
|
+
}
|
|
442
|
+
// 各DBディレクトリにJSONを出力(参照用)
|
|
443
|
+
const dbJsonPath = resolve(outputDir, "db-schema.json");
|
|
444
|
+
writeFile(dbJsonPath, JSON.stringify(portalSchema, null, 2));
|
|
445
|
+
logger.debug(`DB固有JSON: ${dbJsonPath}`);
|
|
446
|
+
// テーブル情報を返す
|
|
447
|
+
return portalSchema.tables;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* ファイル名から説明を推測
|
|
451
|
+
*/
|
|
452
|
+
function inferFileDescription(filename) {
|
|
453
|
+
const name = filename.replace(/\.ts$/, "");
|
|
454
|
+
const descriptions = {
|
|
455
|
+
index: "エクスポートインデックス",
|
|
456
|
+
auth: "認証関連テーブル (users, sessions, accounts)",
|
|
457
|
+
users: "ユーザーテーブル",
|
|
458
|
+
sessions: "セッションテーブル",
|
|
459
|
+
accounts: "アカウント連携テーブル",
|
|
460
|
+
posts: "投稿テーブル",
|
|
461
|
+
content: "コンテンツ関連テーブル",
|
|
462
|
+
categories: "カテゴリテーブル",
|
|
463
|
+
tags: "タグテーブル",
|
|
464
|
+
comments: "コメントテーブル",
|
|
465
|
+
organizations: "組織テーブル",
|
|
466
|
+
projects: "プロジェクトテーブル",
|
|
467
|
+
members: "メンバーテーブル",
|
|
468
|
+
permissions: "権限テーブル",
|
|
469
|
+
settings: "設定テーブル",
|
|
470
|
+
relations: "リレーション定義",
|
|
471
|
+
};
|
|
472
|
+
return descriptions[name] || "-";
|
|
473
|
+
}
|
|
474
|
+
function parseDbmlTables(dbmlPath, logger) {
|
|
475
|
+
const content = readFile(dbmlPath);
|
|
476
|
+
if (!content) {
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
const tables = [];
|
|
480
|
+
// DBML パース (簡易実装)
|
|
481
|
+
// drizzle-dbml-generator の出力形式: table table_name { ... }
|
|
482
|
+
// Table "table_name" { ... } 形式も対応
|
|
483
|
+
// 改善: マルチラインマッチングでテーブル全体を抽出
|
|
484
|
+
const tableBlocks = content.split(/\n(?=table\s+\w+\s*\{)/i);
|
|
485
|
+
for (const block of tableBlocks) {
|
|
486
|
+
// table table_name { から始まるブロックを解析
|
|
487
|
+
const headerMatch = block.match(/^table\s+(\w+)\s*(?:\[([^\]]*)\])?\s*\{/i);
|
|
488
|
+
if (!headerMatch)
|
|
489
|
+
continue;
|
|
490
|
+
const tableName = headerMatch[1];
|
|
491
|
+
const tableOptions = headerMatch[2] || "";
|
|
492
|
+
const table = {
|
|
493
|
+
name: tableName,
|
|
494
|
+
columns: [],
|
|
495
|
+
indexes: [],
|
|
496
|
+
};
|
|
497
|
+
// テーブルノート抽出
|
|
498
|
+
const noteMatch = tableOptions.match(/note:\s*'([^']+)'/);
|
|
499
|
+
if (noteMatch) {
|
|
500
|
+
table.note = noteMatch[1];
|
|
501
|
+
}
|
|
502
|
+
// カラム解析
|
|
503
|
+
const lines = block.split("\n").slice(1).map((l) => l.trim()).filter((l) => l);
|
|
504
|
+
let inIndexes = false;
|
|
505
|
+
for (const line of lines) {
|
|
506
|
+
// インデックスセクション開始
|
|
507
|
+
if (line.startsWith("indexes")) {
|
|
508
|
+
inIndexes = true;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
// セクション終了
|
|
512
|
+
if (line === "}" && inIndexes) {
|
|
513
|
+
inIndexes = false;
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
// コメント・空行・閉じ括弧をスキップ
|
|
517
|
+
if (line.startsWith("//") || line === "{" || line === "}") {
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
// インデックス行の解析
|
|
521
|
+
if (inIndexes) {
|
|
522
|
+
// (columns) [options] 形式
|
|
523
|
+
const idxMatch = line.match(/\(([^)]+)\)\s*(?:\[([^\]]*)\])?/);
|
|
524
|
+
if (idxMatch) {
|
|
525
|
+
const columns = idxMatch[1].split(",").map((c) => c.trim().replace(/"/g, ""));
|
|
526
|
+
const options = idxMatch[2] || "";
|
|
527
|
+
const nameMatch = options.match(/name:\s*'([^']+)'/);
|
|
528
|
+
table.indexes.push({
|
|
529
|
+
name: nameMatch ? nameMatch[1] : columns.join("_"),
|
|
530
|
+
columns,
|
|
531
|
+
unique: options.includes("unique"),
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
// カラム行: column_name type [options] または column_name "type with spaces" [options]
|
|
537
|
+
const colMatch = line.match(/^(\w+)\s+(?:"([^"]+)"|(\w+(?:\([^)]+\))?))\s*(?:\[([^\]]*)\])?/);
|
|
538
|
+
if (colMatch) {
|
|
539
|
+
// 型は引用符付き (colMatch[2]) または通常 (colMatch[3])
|
|
540
|
+
const columnType = colMatch[2] || colMatch[3] || "unknown";
|
|
541
|
+
const column = {
|
|
542
|
+
name: colMatch[1],
|
|
543
|
+
type: columnType,
|
|
544
|
+
};
|
|
545
|
+
// オプションは4番目のグループ
|
|
546
|
+
const options = colMatch[4] || "";
|
|
547
|
+
if (options.includes("pk"))
|
|
548
|
+
column.pk = true;
|
|
549
|
+
if (options.includes("not null"))
|
|
550
|
+
column.notNull = true;
|
|
551
|
+
if (options.includes("unique") && !options.includes("unique]"))
|
|
552
|
+
column.unique = true;
|
|
553
|
+
const defaultMatch = options.match(/default:\s*`([^`]+)`/);
|
|
554
|
+
if (defaultMatch) {
|
|
555
|
+
column.default = defaultMatch[1];
|
|
556
|
+
}
|
|
557
|
+
const noteMatch = options.match(/note:\s*'([^']+)'/);
|
|
558
|
+
if (noteMatch) {
|
|
559
|
+
column.note = noteMatch[1];
|
|
560
|
+
}
|
|
561
|
+
table.columns.push(column);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
tables.push(table);
|
|
565
|
+
}
|
|
566
|
+
logger.debug(`${tables.length} テーブルを抽出`);
|
|
567
|
+
return tables;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* スキーマファイルからJSDocコメントを抽出(共通パーサー使用)
|
|
571
|
+
*/
|
|
572
|
+
function extractJsDocFromSchemaFiles(schemaFiles, logger) {
|
|
573
|
+
// 全ファイルの内容を結合してパース
|
|
574
|
+
const mergedResult = {
|
|
575
|
+
tables: new Map(),
|
|
576
|
+
columns: new Map(),
|
|
577
|
+
indexes: new Map(),
|
|
578
|
+
parsed: new Map(),
|
|
579
|
+
};
|
|
580
|
+
for (const file of schemaFiles) {
|
|
581
|
+
const content = readFile(file);
|
|
582
|
+
if (!content)
|
|
583
|
+
continue;
|
|
584
|
+
// 共通パーサーでJSDoc抽出
|
|
585
|
+
const fileResult = extractDbSchemaJsDocs(content);
|
|
586
|
+
// 結果をマージ
|
|
587
|
+
for (const [tableName, desc] of fileResult.tables) {
|
|
588
|
+
mergedResult.tables.set(tableName, desc);
|
|
589
|
+
}
|
|
590
|
+
for (const [tableName, columnMap] of fileResult.columns) {
|
|
591
|
+
mergedResult.columns.set(tableName, columnMap);
|
|
592
|
+
}
|
|
593
|
+
for (const [tableName, indexMap] of fileResult.indexes) {
|
|
594
|
+
mergedResult.indexes.set(tableName, indexMap);
|
|
595
|
+
}
|
|
596
|
+
for (const [tableName, parsed] of fileResult.parsed) {
|
|
597
|
+
mergedResult.parsed.set(tableName, parsed);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const indexCount = Array.from(mergedResult.indexes.values()).reduce((sum, m) => sum + m.size, 0);
|
|
601
|
+
logger.debug(`JSDoc抽出: ${mergedResult.tables.size} テーブル, ` +
|
|
602
|
+
`${Array.from(mergedResult.columns.values()).reduce((sum, m) => sum + m.size, 0)} カラム, ` +
|
|
603
|
+
`${indexCount} インデックス`);
|
|
604
|
+
return mergedResult;
|
|
605
|
+
}
|
|
606
|
+
function generatePortalDbSchema(tables, schemaFiles, schemaSource, logger) {
|
|
607
|
+
// JSDocコメントを抽出
|
|
608
|
+
const jsDocInfo = extractJsDocFromSchemaFiles(schemaFiles, logger);
|
|
609
|
+
// ファイル名からカテゴリを推論
|
|
610
|
+
const fileCategories = {};
|
|
611
|
+
for (const file of schemaFiles) {
|
|
612
|
+
const fileName = basename(file).replace(/\.ts$/, "");
|
|
613
|
+
fileCategories[fileName] = inferCategoryFromFileName(fileName);
|
|
614
|
+
}
|
|
615
|
+
// テーブル情報を変換
|
|
616
|
+
const portalTables = tables.map((table) => {
|
|
617
|
+
// テーブル名からファイルを推測
|
|
618
|
+
const possibleFile = guessSchemaFile(table.name, schemaFiles);
|
|
619
|
+
const fileName = possibleFile ? basename(possibleFile).replace(/\.ts$/, "") : undefined;
|
|
620
|
+
const category = fileName ? fileCategories[fileName] : inferCategoryFromTableName(table.name);
|
|
621
|
+
// JSDocからテーブル説明を取得
|
|
622
|
+
const tableDescription = jsDocInfo.tables.get(table.name) || table.note;
|
|
623
|
+
// カラムのJSDocマップ
|
|
624
|
+
const columnJsDocs = jsDocInfo.columns.get(table.name);
|
|
625
|
+
// インデックスのJSDocマップ
|
|
626
|
+
const indexJsDocs = jsDocInfo.indexes.get(table.name);
|
|
627
|
+
// 外部キー情報を抽出(コメントやnoteから推測)
|
|
628
|
+
const foreignKeys = [];
|
|
629
|
+
for (const col of table.columns) {
|
|
630
|
+
if (col.name.endsWith("_id") || col.name.endsWith("Id")) {
|
|
631
|
+
// user_id -> users, project_id -> projects など
|
|
632
|
+
const refTableName = guessReferencedTable(col.name);
|
|
633
|
+
if (refTableName) {
|
|
634
|
+
foreignKeys.push({
|
|
635
|
+
column: col.name,
|
|
636
|
+
references: {
|
|
637
|
+
table: refTableName,
|
|
638
|
+
column: "id",
|
|
639
|
+
},
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
name: table.name,
|
|
646
|
+
file: possibleFile ? basename(possibleFile) : undefined,
|
|
647
|
+
description: tableDescription,
|
|
648
|
+
category,
|
|
649
|
+
columnCount: table.columns.length,
|
|
650
|
+
columns: table.columns.map((col) => ({
|
|
651
|
+
name: col.name,
|
|
652
|
+
type: col.type,
|
|
653
|
+
primaryKey: col.pk,
|
|
654
|
+
nullable: !col.notNull && !col.pk,
|
|
655
|
+
unique: col.unique,
|
|
656
|
+
default: col.default,
|
|
657
|
+
description: columnJsDocs?.get(col.name) || col.note,
|
|
658
|
+
})),
|
|
659
|
+
foreignKeys: foreignKeys.length > 0 ? foreignKeys : undefined,
|
|
660
|
+
indexes: table.indexes?.map((idx) => ({
|
|
661
|
+
name: idx.name,
|
|
662
|
+
columns: idx.columns,
|
|
663
|
+
unique: idx.unique,
|
|
664
|
+
description: indexJsDocs?.get(idx.name),
|
|
665
|
+
})),
|
|
666
|
+
};
|
|
667
|
+
});
|
|
668
|
+
return {
|
|
669
|
+
tables: portalTables,
|
|
670
|
+
generatedAt: new Date().toISOString(),
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* ファイル名からカテゴリを推論
|
|
675
|
+
*/
|
|
676
|
+
function inferCategoryFromFileName(fileName) {
|
|
677
|
+
const categoryMap = {
|
|
678
|
+
auth: "Authentication",
|
|
679
|
+
users: "Authentication",
|
|
680
|
+
sessions: "Authentication",
|
|
681
|
+
accounts: "Authentication",
|
|
682
|
+
verifications: "Authentication",
|
|
683
|
+
organizations: "Organizations",
|
|
684
|
+
projects: "Projects",
|
|
685
|
+
entities: "Content",
|
|
686
|
+
relations: "Content",
|
|
687
|
+
comments: "Content",
|
|
688
|
+
posts: "Content",
|
|
689
|
+
categories: "Content",
|
|
690
|
+
tags: "Content",
|
|
691
|
+
activities: "Activities",
|
|
692
|
+
permissions: "Permissions",
|
|
693
|
+
tokens: "Tokens",
|
|
694
|
+
context: "User Context",
|
|
695
|
+
settings: "Settings",
|
|
696
|
+
audit: "Audit",
|
|
697
|
+
};
|
|
698
|
+
// 複数形/単数形の両方をチェック
|
|
699
|
+
const singular = fileName.replace(/s$/, "");
|
|
700
|
+
return categoryMap[fileName] || categoryMap[singular] || "Other";
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* テーブル名からカテゴリを推論
|
|
704
|
+
*/
|
|
705
|
+
function inferCategoryFromTableName(tableName) {
|
|
706
|
+
const name = tableName.toLowerCase();
|
|
707
|
+
// Authentication
|
|
708
|
+
if (name.includes("user") || name === "sessions" || name === "session" || name.includes("account") || name.includes("verification") || name.includes("rate_limit")) {
|
|
709
|
+
return "Authentication";
|
|
710
|
+
}
|
|
711
|
+
// Organizations
|
|
712
|
+
if (name.includes("organization") || name.includes("org_")) {
|
|
713
|
+
return "Organizations";
|
|
714
|
+
}
|
|
715
|
+
// Projects
|
|
716
|
+
if (name.includes("project") || name.includes("team")) {
|
|
717
|
+
return "Projects";
|
|
718
|
+
}
|
|
719
|
+
// Work Sessions (DevMemory specific)
|
|
720
|
+
if (name.includes("work_session") || name.includes("session_") || name.includes("pause")) {
|
|
721
|
+
return "Work Sessions";
|
|
722
|
+
}
|
|
723
|
+
// Content (Blog CMS + DevMemory)
|
|
724
|
+
if (name.includes("post") ||
|
|
725
|
+
name.includes("category") ||
|
|
726
|
+
name.includes("categories") ||
|
|
727
|
+
name.includes("tag") ||
|
|
728
|
+
name.includes("comment") ||
|
|
729
|
+
name.includes("entity") ||
|
|
730
|
+
name.includes("entities") ||
|
|
731
|
+
name.includes("relation") ||
|
|
732
|
+
name.includes("faq") ||
|
|
733
|
+
name.includes("feedback")) {
|
|
734
|
+
return "Content";
|
|
735
|
+
}
|
|
736
|
+
// Activities
|
|
737
|
+
if (name.includes("activity") || name.includes("activities")) {
|
|
738
|
+
return "Activities";
|
|
739
|
+
}
|
|
740
|
+
// MCP Tokens
|
|
741
|
+
if (name.includes("token") || name.includes("mcp_")) {
|
|
742
|
+
return "MCP Tokens";
|
|
743
|
+
}
|
|
744
|
+
// Permissions
|
|
745
|
+
if (name.includes("permission") || name.includes("member")) {
|
|
746
|
+
return "Permissions";
|
|
747
|
+
}
|
|
748
|
+
// User Context
|
|
749
|
+
if (name.includes("context")) {
|
|
750
|
+
return "User Context";
|
|
751
|
+
}
|
|
752
|
+
// Audit
|
|
753
|
+
if (name.includes("audit") || name.includes("log")) {
|
|
754
|
+
return "Audit";
|
|
755
|
+
}
|
|
756
|
+
return "Other";
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* テーブル名からスキーマファイルを推測
|
|
760
|
+
*/
|
|
761
|
+
function guessSchemaFile(tableName, schemaFiles) {
|
|
762
|
+
const name = tableName.toLowerCase();
|
|
763
|
+
for (const file of schemaFiles) {
|
|
764
|
+
const fileName = basename(file).replace(/\.ts$/, "").toLowerCase();
|
|
765
|
+
// 完全一致
|
|
766
|
+
if (name === fileName || name === fileName + "s" || name + "s" === fileName) {
|
|
767
|
+
return file;
|
|
768
|
+
}
|
|
769
|
+
// 部分一致
|
|
770
|
+
if (name.includes(fileName) || fileName.includes(name.replace(/_/g, ""))) {
|
|
771
|
+
return file;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
// 特殊なマッピング
|
|
775
|
+
const specialMappings = {
|
|
776
|
+
auth: ["users", "sessions", "accounts", "verifications", "rate_limit"],
|
|
777
|
+
organizations: ["organizations", "organization_members"],
|
|
778
|
+
projects: ["projects", "team_members", "project_sequences", "project_members"],
|
|
779
|
+
sessions: ["work_sessions", "session_pause_events", "session_entities", "session_notes"],
|
|
780
|
+
entities: ["entities", "relations"],
|
|
781
|
+
};
|
|
782
|
+
for (const [fileName, tables] of Object.entries(specialMappings)) {
|
|
783
|
+
if (tables.includes(name)) {
|
|
784
|
+
const matchingFile = schemaFiles.find((f) => basename(f).replace(/\.ts$/, "").toLowerCase() === fileName);
|
|
785
|
+
if (matchingFile)
|
|
786
|
+
return matchingFile;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return undefined;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* カラム名から参照先テーブルを推測
|
|
793
|
+
*/
|
|
794
|
+
function guessReferencedTable(columnName) {
|
|
795
|
+
// user_id -> users, project_id -> projects, etc.
|
|
796
|
+
const match = columnName.match(/^(.+?)_?[iI]d$/);
|
|
797
|
+
if (match) {
|
|
798
|
+
const baseName = match[1].toLowerCase().replace(/_/g, "");
|
|
799
|
+
// 特殊なマッピング
|
|
800
|
+
const specialMappings = {
|
|
801
|
+
// Authentication
|
|
802
|
+
user: "users",
|
|
803
|
+
author: "users", // posts.author_id -> users
|
|
804
|
+
// Organizations
|
|
805
|
+
organization: "organizations",
|
|
806
|
+
org: "organizations",
|
|
807
|
+
// Projects
|
|
808
|
+
project: "projects",
|
|
809
|
+
// Work Sessions
|
|
810
|
+
session: "work_sessions",
|
|
811
|
+
worksession: "work_sessions",
|
|
812
|
+
// Content
|
|
813
|
+
entity: "entities",
|
|
814
|
+
category: "categories", // irregular plural: -y -> -ies
|
|
815
|
+
activity: "activities",
|
|
816
|
+
relatedpost: "posts", // self-reference
|
|
817
|
+
// 無視するカラム
|
|
818
|
+
parent: undefined,
|
|
819
|
+
source: undefined,
|
|
820
|
+
target: undefined,
|
|
821
|
+
};
|
|
822
|
+
if (baseName in specialMappings) {
|
|
823
|
+
return specialMappings[baseName] || undefined;
|
|
824
|
+
}
|
|
825
|
+
// デフォルト: 複数形にする
|
|
826
|
+
return baseName + "s";
|
|
827
|
+
}
|
|
828
|
+
return undefined;
|
|
829
|
+
}
|
|
830
|
+
//# sourceMappingURL=schema.js.map
|