laymos 0.0.1 → 0.0.2
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 -710
- package/bin/laymos.mjs +2 -0
- package/dist/architecture/analyze-project/analyze-project.d.ts +9 -0
- package/dist/architecture/analyze-project/analyze-project.d.ts.map +1 -0
- package/dist/architecture/analyze-project/analyze-project.js +47 -0
- package/dist/architecture/analyze-project/index.d.ts +3 -0
- package/dist/architecture/analyze-project/index.d.ts.map +1 -0
- package/dist/architecture/analyze-project/index.js +1 -0
- package/dist/architecture/build-report/build-report.d.ts +7 -0
- package/dist/architecture/build-report/build-report.d.ts.map +1 -0
- package/dist/{engine/4-emit/emit.js → architecture/build-report/build-report.js} +12 -9
- package/dist/architecture/build-report/index.d.ts +2 -0
- package/dist/architecture/build-report/index.d.ts.map +1 -0
- package/dist/architecture/build-report/index.js +1 -0
- package/dist/architecture/errors.d.ts +11 -0
- package/dist/architecture/errors.d.ts.map +1 -0
- package/dist/{engine → architecture}/errors.js +0 -2
- package/dist/{engine/1-extract/extract.d.ts → architecture/extract-dependencies/extract-dependencies.d.ts} +1 -1
- package/dist/architecture/extract-dependencies/extract-dependencies.d.ts.map +1 -0
- package/dist/{engine/1-extract/extract.js → architecture/extract-dependencies/extract-dependencies.js} +13 -11
- package/dist/architecture/extract-dependencies/index.d.ts +3 -0
- package/dist/architecture/extract-dependencies/index.d.ts.map +1 -0
- package/dist/architecture/extract-dependencies/index.js +1 -0
- package/dist/architecture/resolve-architecture/index.d.ts +3 -0
- package/dist/architecture/resolve-architecture/index.d.ts.map +1 -0
- package/dist/architecture/resolve-architecture/index.js +1 -0
- package/dist/{engine/2-resolve/resolve.d.ts → architecture/resolve-architecture/resolve-architecture.d.ts} +2 -2
- package/dist/architecture/resolve-architecture/resolve-architecture.d.ts.map +1 -0
- package/dist/{engine/2-resolve/resolve.js → architecture/resolve-architecture/resolve-architecture.js} +1 -1
- package/dist/architecture/validate-rules/index.d.ts +3 -0
- package/dist/architecture/validate-rules/index.d.ts.map +1 -0
- package/dist/architecture/validate-rules/index.js +1 -0
- package/dist/{engine/3-evaluate/evaluate.d.ts → architecture/validate-rules/validate-rules.d.ts} +4 -4
- package/dist/architecture/validate-rules/validate-rules.d.ts.map +1 -0
- package/dist/{engine/3-evaluate/evaluate.js → architecture/validate-rules/validate-rules.js} +2 -2
- package/dist/architecture-analysis-schema/architecture-analysis-schema.d.ts +109 -0
- package/dist/architecture-analysis-schema/architecture-analysis-schema.d.ts.map +1 -0
- package/dist/architecture-analysis-schema/architecture-analysis-schema.js +10 -0
- package/dist/architecture-analysis-schema/index.d.ts +7 -0
- package/dist/architecture-analysis-schema/index.d.ts.map +1 -0
- package/dist/architecture-analysis-schema/index.js +3 -0
- package/dist/architecture-analysis-schema/layer-analysis-schema.d.ts +27 -0
- package/dist/architecture-analysis-schema/layer-analysis-schema.d.ts.map +1 -0
- package/dist/architecture-analysis-schema/layer-analysis-schema.js +18 -0
- package/dist/architecture-analysis-schema/module-analysis-schema.d.ts +150 -0
- package/dist/architecture-analysis-schema/module-analysis-schema.d.ts.map +1 -0
- package/dist/architecture-analysis-schema/module-analysis-schema.js +96 -0
- package/dist/architecture-analysis-schema/module-source-schema.d.ts +16 -0
- package/dist/architecture-analysis-schema/module-source-schema.d.ts.map +1 -0
- package/dist/architecture-analysis-schema/module-source-schema.js +10 -0
- package/dist/architecture-analysis-schema/project-config-schema.d.ts +51 -0
- package/dist/architecture-analysis-schema/project-config-schema.d.ts.map +1 -0
- package/dist/architecture-analysis-schema/project-config-schema.js +110 -0
- package/dist/change-set-schema/change-set-schema.d.ts +55 -0
- package/dist/change-set-schema/change-set-schema.d.ts.map +1 -0
- package/dist/change-set-schema/change-set-schema.js +43 -0
- package/dist/change-set-schema/index.d.ts +3 -0
- package/dist/change-set-schema/index.d.ts.map +1 -0
- package/dist/change-set-schema/index.js +2 -0
- package/dist/cli/cli.js +6 -1
- package/dist/cli/deps/dependency-tree.d.ts +3 -0
- package/dist/cli/deps/dependency-tree.d.ts.map +1 -0
- package/dist/cli/deps/dependency-tree.js +39 -0
- package/dist/cli/deps/deps.d.ts +7 -0
- package/dist/cli/deps/deps.d.ts.map +1 -0
- package/dist/cli/deps/deps.js +26 -0
- package/dist/cli/deps/index.d.ts +2 -0
- package/dist/cli/deps/index.d.ts.map +1 -0
- package/dist/cli/deps/index.js +2 -0
- package/dist/cli/errors.d.ts +2 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +34 -0
- package/dist/cli/inspect/file/file.d.ts +8 -0
- package/dist/cli/inspect/file/file.d.ts.map +1 -0
- package/dist/cli/inspect/file/file.js +16 -0
- package/dist/cli/inspect/file/index.d.ts +2 -0
- package/dist/cli/inspect/file/index.d.ts.map +1 -0
- package/dist/cli/inspect/file/index.js +1 -0
- package/dist/cli/inspect/file/report.d.ts +3 -0
- package/dist/cli/inspect/file/report.d.ts.map +1 -0
- package/dist/cli/inspect/file/report.js +26 -0
- package/dist/cli/inspect/index.d.ts +2 -0
- package/dist/cli/inspect/index.d.ts.map +1 -0
- package/dist/cli/inspect/index.js +1 -0
- package/dist/cli/inspect/inspect.d.ts +4 -0
- package/dist/cli/inspect/inspect.d.ts.map +1 -0
- package/dist/cli/inspect/inspect.js +14 -0
- package/dist/cli/inspect/json.d.ts +4 -0
- package/dist/cli/inspect/json.d.ts.map +1 -0
- package/dist/cli/inspect/json.js +5 -0
- package/dist/cli/inspect/layer/index.d.ts +2 -0
- package/dist/cli/inspect/layer/index.d.ts.map +1 -0
- package/dist/cli/inspect/layer/index.js +1 -0
- package/dist/cli/inspect/layer/layer.d.ts +7 -0
- package/dist/cli/inspect/layer/layer.d.ts.map +1 -0
- package/dist/cli/inspect/layer/layer.js +13 -0
- package/dist/cli/inspect/layer/report.d.ts +3 -0
- package/dist/cli/inspect/layer/report.d.ts.map +1 -0
- package/dist/cli/inspect/layer/report.js +21 -0
- package/dist/cli/inspect/module/index.d.ts +2 -0
- package/dist/cli/inspect/module/index.d.ts.map +1 -0
- package/dist/cli/inspect/module/index.js +1 -0
- package/dist/cli/inspect/module/module.d.ts +7 -0
- package/dist/cli/inspect/module/module.d.ts.map +1 -0
- package/dist/cli/inspect/module/module.js +15 -0
- package/dist/cli/inspect/module/report.d.ts +3 -0
- package/dist/cli/inspect/module/report.d.ts.map +1 -0
- package/dist/cli/inspect/module/report.js +38 -0
- package/dist/cli/inspect/path-tree.d.ts +7 -0
- package/dist/cli/inspect/path-tree.d.ts.map +1 -0
- package/dist/cli/inspect/path-tree.js +62 -0
- package/dist/cli/inspect/path.d.ts +5 -0
- package/dist/cli/inspect/path.d.ts.map +1 -0
- package/dist/cli/inspect/path.js +10 -0
- package/dist/cli/inspect/project/index.d.ts +2 -0
- package/dist/cli/inspect/project/index.d.ts.map +1 -0
- package/dist/cli/inspect/project/index.js +1 -0
- package/dist/cli/inspect/project/project.d.ts +8 -0
- package/dist/cli/inspect/project/project.d.ts.map +1 -0
- package/dist/cli/inspect/project/project.js +19 -0
- package/dist/cli/inspect/project/report.d.ts +3 -0
- package/dist/cli/inspect/project/report.d.ts.map +1 -0
- package/dist/cli/inspect/project/report.js +16 -0
- package/dist/cli/lint/index.d.ts +2 -0
- package/dist/cli/lint/index.d.ts.map +1 -0
- package/dist/cli/lint/index.js +2 -0
- package/dist/cli/lint/layers/index.d.ts +3 -0
- package/dist/cli/lint/layers/index.d.ts.map +1 -0
- package/dist/cli/lint/layers/index.js +4 -0
- package/dist/cli/lint/layers/layers.d.ts +5 -0
- package/dist/cli/lint/layers/layers.d.ts.map +1 -0
- package/dist/cli/lint/layers/layers.js +18 -0
- package/dist/cli/lint/layers/report.d.ts +5 -0
- package/dist/cli/lint/layers/report.d.ts.map +1 -0
- package/dist/cli/lint/layers/report.js +60 -0
- package/dist/cli/lint/lint.d.ts +4 -0
- package/dist/cli/lint/lint.d.ts.map +1 -0
- package/dist/cli/lint/lint.js +26 -0
- package/dist/cli/lint/modules/index.d.ts +5 -0
- package/dist/cli/lint/modules/index.d.ts.map +1 -0
- package/dist/cli/lint/modules/index.js +4 -0
- package/dist/cli/lint/modules/modules.d.ts +5 -0
- package/dist/cli/lint/modules/modules.d.ts.map +1 -0
- package/dist/cli/lint/modules/modules.js +15 -0
- package/dist/cli/lint/modules/report.d.ts +5 -0
- package/dist/cli/lint/modules/report.d.ts.map +1 -0
- package/dist/cli/lint/modules/report.js +69 -0
- package/dist/cli/run.d.ts +1 -8
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +14 -242
- package/dist/cli/stories/index.d.ts +2 -0
- package/dist/cli/stories/index.d.ts.map +1 -0
- package/dist/cli/stories/index.js +1 -0
- package/dist/cli/stories/progress.d.ts +7 -0
- package/dist/cli/stories/progress.d.ts.map +1 -0
- package/dist/cli/stories/progress.js +45 -0
- package/dist/cli/stories/report.d.ts +9 -0
- package/dist/cli/stories/report.d.ts.map +1 -0
- package/dist/cli/stories/report.js +63 -0
- package/dist/cli/stories/stories.d.ts +6 -0
- package/dist/cli/stories/stories.d.ts.map +1 -0
- package/dist/cli/stories/stories.js +30 -0
- package/dist/config/define-config.d.ts +5 -0
- package/dist/config/define-config.d.ts.map +1 -1
- package/dist/config/define-config.js +152 -7
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -0
- package/dist/config/layer-graph.d.ts +2 -2
- package/dist/config/layer-graph.d.ts.map +1 -1
- package/dist/config/layer-graph.js +2 -29
- package/dist/config/layer.d.ts +2 -2
- package/dist/config/layer.d.ts.map +1 -1
- package/dist/config/layer.js +2 -15
- package/dist/config/load-config/index.d.ts +2 -0
- package/dist/config/load-config/index.d.ts.map +1 -0
- package/dist/config/load-config/index.js +1 -0
- package/dist/config/load-config/load-config.d.ts +34 -0
- package/dist/config/load-config/load-config.d.ts.map +1 -0
- package/dist/config/load-config/load-config.js +127 -0
- package/dist/config/module.d.ts +4 -2
- package/dist/config/module.d.ts.map +1 -1
- package/dist/config/module.js +5 -12
- package/dist/config/project-narrative.d.ts +15 -0
- package/dist/config/project-narrative.d.ts.map +1 -0
- package/dist/config/project-narrative.js +11 -0
- package/dist/config/types.d.ts +5 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/domain/architecture-analysis/architecture-analysis.d.ts +4 -0
- package/dist/domain/architecture-analysis/architecture-analysis.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/architecture-analysis.js +13 -0
- package/dist/domain/architecture-analysis/index.d.ts +3 -0
- package/dist/domain/architecture-analysis/index.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/index.js +2 -0
- package/dist/domain/architecture-analysis/layer-rules.d.ts +3 -0
- package/dist/domain/architecture-analysis/layer-rules.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layer-rules.js +15 -0
- package/dist/domain/architecture-analysis/layers/allowed-dependencies.d.ts +3 -0
- package/dist/domain/architecture-analysis/layers/allowed-dependencies.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/allowed-dependencies.js +20 -0
- package/dist/domain/architecture-analysis/layers/coverage-violations.d.ts +2 -0
- package/dist/domain/architecture-analysis/layers/coverage-violations.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/coverage-violations.js +5 -0
- package/dist/domain/architecture-analysis/layers/dependency-violations.d.ts +5 -0
- package/dist/domain/architecture-analysis/layers/dependency-violations.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/dependency-violations.js +18 -0
- package/dist/domain/architecture-analysis/layers/index.d.ts +9 -0
- package/dist/domain/architecture-analysis/layers/index.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/index.js +4 -0
- package/dist/domain/architecture-analysis/layers/layer-membership.d.ts +3 -0
- package/dist/domain/architecture-analysis/layers/layer-membership.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/layer-membership.js +13 -0
- package/dist/domain/architecture-analysis/layers/layers.d.ts +11 -0
- package/dist/domain/architecture-analysis/layers/layers.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/layers.js +22 -0
- package/dist/domain/architecture-analysis/layers/module-coverage-violations.d.ts +4 -0
- package/dist/domain/architecture-analysis/layers/module-coverage-violations.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/layers/module-coverage-violations.js +9 -0
- package/dist/domain/architecture-analysis/modules/dependency-graph.d.ts +2 -0
- package/dist/domain/architecture-analysis/modules/dependency-graph.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/dependency-graph.js +45 -0
- package/dist/domain/architecture-analysis/modules/dependency-permissions.d.ts +4 -0
- package/dist/domain/architecture-analysis/modules/dependency-permissions.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/dependency-permissions.js +35 -0
- package/dist/domain/architecture-analysis/modules/index.d.ts +12 -0
- package/dist/domain/architecture-analysis/modules/index.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/index.js +3 -0
- package/dist/domain/architecture-analysis/modules/module-descriptors.d.ts +5 -0
- package/dist/domain/architecture-analysis/modules/module-descriptors.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/module-descriptors.js +37 -0
- package/dist/domain/architecture-analysis/modules/module-membership.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/module-membership.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/module-membership.js +12 -0
- package/dist/domain/architecture-analysis/modules/modules.d.ts +16 -0
- package/dist/domain/architecture-analysis/modules/modules.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/modules.js +35 -0
- package/dist/domain/architecture-analysis/modules/public-entry-points.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/public-entry-points.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/public-entry-points.js +11 -0
- package/dist/domain/architecture-analysis/modules/unexposed-modules.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/unexposed-modules.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/unexposed-modules.js +10 -0
- package/dist/domain/architecture-analysis/modules/violations/boundaries.d.ts +8 -0
- package/dist/domain/architecture-analysis/modules/violations/boundaries.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/boundaries.js +47 -0
- package/dist/domain/architecture-analysis/modules/violations/coverage.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/coverage.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/coverage.js +7 -0
- package/dist/domain/architecture-analysis/modules/violations/cycles.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/cycles.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/cycles.js +7 -0
- package/dist/domain/architecture-analysis/modules/violations/dead-modules.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/dead-modules.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/dead-modules.js +23 -0
- package/dist/domain/architecture-analysis/modules/violations/dependencies.d.ts +4 -0
- package/dist/domain/architecture-analysis/modules/violations/dependencies.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/dependencies.js +7 -0
- package/dist/domain/architecture-analysis/modules/violations/entry-points.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/entry-points.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/entry-points.js +17 -0
- package/dist/domain/architecture-analysis/modules/violations/graph-coverage.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/graph-coverage.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/graph-coverage.js +16 -0
- package/dist/domain/architecture-analysis/modules/violations/index.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/index.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/index.js +2 -0
- package/dist/domain/architecture-analysis/modules/violations/unused-shared.d.ts +3 -0
- package/dist/domain/architecture-analysis/modules/violations/unused-shared.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/unused-shared.js +9 -0
- package/dist/domain/architecture-analysis/modules/violations/violations.d.ts +9 -0
- package/dist/domain/architecture-analysis/modules/violations/violations.d.ts.map +1 -0
- package/dist/domain/architecture-analysis/modules/violations/violations.js +22 -0
- package/dist/domain/file-graph/file-graph.d.ts +10 -0
- package/dist/domain/file-graph/file-graph.d.ts.map +1 -0
- package/dist/domain/file-graph/file-graph.js +37 -0
- package/dist/domain/file-graph/index.d.ts +4 -0
- package/dist/domain/file-graph/index.d.ts.map +1 -0
- package/dist/domain/file-graph/index.js +1 -0
- package/dist/domain/project-config/index.d.ts +10 -0
- package/dist/domain/project-config/index.d.ts.map +1 -0
- package/dist/domain/project-config/index.js +12 -0
- package/dist/domain/project-config/project-config.d.ts +52 -0
- package/dist/domain/project-config/project-config.d.ts.map +1 -0
- package/dist/domain/project-config/project-config.js +39 -0
- package/dist/domain/project-config/resolve.d.ts +8 -0
- package/dist/domain/project-config/resolve.d.ts.map +1 -0
- package/dist/domain/project-config/resolve.js +29 -0
- package/dist/domain/project-config/validation/containment.d.ts +4 -0
- package/dist/domain/project-config/validation/containment.d.ts.map +1 -0
- package/dist/domain/project-config/validation/containment.js +21 -0
- package/dist/domain/project-config/validation/index.d.ts +3 -0
- package/dist/domain/project-config/validation/index.d.ts.map +1 -0
- package/dist/domain/project-config/validation/index.js +2 -0
- package/dist/domain/project-config/validation/layers/cycles.d.ts +3 -0
- package/dist/domain/project-config/validation/layers/cycles.d.ts.map +1 -0
- package/dist/domain/project-config/validation/layers/cycles.js +64 -0
- package/dist/domain/project-config/validation/layers/index.d.ts +3 -0
- package/dist/domain/project-config/validation/layers/index.d.ts.map +1 -0
- package/dist/domain/project-config/validation/layers/index.js +2 -0
- package/dist/domain/project-config/validation/layers/layers.d.ts +3 -0
- package/dist/domain/project-config/validation/layers/layers.d.ts.map +1 -0
- package/dist/domain/project-config/validation/layers/layers.js +9 -0
- package/dist/domain/project-config/validation/layers/overlaps.d.ts +3 -0
- package/dist/domain/project-config/validation/layers/overlaps.d.ts.map +1 -0
- package/dist/domain/project-config/validation/layers/overlaps.js +26 -0
- package/dist/domain/project-config/validation/layers/references.d.ts +3 -0
- package/dist/domain/project-config/validation/layers/references.d.ts.map +1 -0
- package/dist/domain/project-config/validation/layers/references.js +21 -0
- package/dist/domain/project-config/validation/modules/containment.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/containment.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/containment.js +24 -0
- package/dist/domain/project-config/validation/modules/graphs.d.ts +4 -0
- package/dist/domain/project-config/validation/modules/graphs.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/graphs.js +96 -0
- package/dist/domain/project-config/validation/modules/index.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/index.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/index.js +2 -0
- package/dist/domain/project-config/validation/modules/kinds.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/kinds.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/kinds.js +18 -0
- package/dist/domain/project-config/validation/modules/modules.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/modules.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/modules.js +16 -0
- package/dist/domain/project-config/validation/modules/nested.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/nested.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/nested.js +34 -0
- package/dist/domain/project-config/validation/modules/overlaps.d.ts +4 -0
- package/dist/domain/project-config/validation/modules/overlaps.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/overlaps.js +43 -0
- package/dist/domain/project-config/validation/modules/paths.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/paths.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/paths.js +27 -0
- package/dist/domain/project-config/validation/modules/scopes.d.ts +4 -0
- package/dist/domain/project-config/validation/modules/scopes.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/scopes.js +28 -0
- package/dist/domain/project-config/validation/modules/subpaths.d.ts +3 -0
- package/dist/domain/project-config/validation/modules/subpaths.d.ts.map +1 -0
- package/dist/domain/project-config/validation/modules/subpaths.js +40 -0
- package/dist/domain/project-config/validation/paths.d.ts +3 -0
- package/dist/domain/project-config/validation/paths.d.ts.map +1 -0
- package/dist/domain/project-config/validation/paths.js +39 -0
- package/dist/domain/project-config/validation/validation.d.ts +3 -0
- package/dist/domain/project-config/validation/validation.d.ts.map +1 -0
- package/dist/domain/project-config/validation/validation.js +12 -0
- package/dist/entrypoints/cli/cli.d.ts +3 -0
- package/dist/entrypoints/cli/cli.d.ts.map +1 -0
- package/dist/entrypoints/cli/cli.js +6 -0
- package/dist/entrypoints/cli/run.d.ts +13 -0
- package/dist/entrypoints/cli/run.d.ts.map +1 -0
- package/dist/entrypoints/cli/run.js +155 -0
- package/dist/entrypoints/cli/test-output.d.ts +17 -0
- package/dist/entrypoints/cli/test-output.d.ts.map +1 -0
- package/dist/entrypoints/cli/test-output.js +244 -0
- package/dist/entrypoints/node/index.d.ts +24 -0
- package/dist/entrypoints/node/index.d.ts.map +1 -0
- package/dist/entrypoints/node/index.js +27 -0
- package/dist/entrypoints/report/index.d.ts +2 -0
- package/dist/entrypoints/report/index.d.ts.map +1 -0
- package/dist/entrypoints/report/index.js +1 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -1
- package/dist/markdown/index.d.ts +3 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +1 -0
- package/dist/markdown/markdown.d.ts +7 -0
- package/dist/markdown/markdown.d.ts.map +1 -0
- package/dist/markdown/markdown.js +13 -0
- package/dist/orchestrator/analyze-project/analyze-project.d.ts +119 -0
- package/dist/orchestrator/analyze-project/analyze-project.d.ts.map +1 -0
- package/dist/orchestrator/analyze-project/analyze-project.js +9 -0
- package/dist/orchestrator/analyze-project/index.d.ts +2 -0
- package/dist/orchestrator/analyze-project/index.d.ts.map +1 -0
- package/dist/orchestrator/analyze-project/index.js +2 -0
- package/dist/orchestrator/inspect/index.d.ts +4 -0
- package/dist/orchestrator/inspect/index.d.ts.map +1 -0
- package/dist/orchestrator/inspect/index.js +1 -0
- package/dist/orchestrator/inspect/inspect.d.ts +269 -0
- package/dist/orchestrator/inspect/inspect.d.ts.map +1 -0
- package/dist/orchestrator/inspect/inspect.js +147 -0
- package/dist/orchestrator/load-changes/index.d.ts +2 -0
- package/dist/orchestrator/load-changes/index.d.ts.map +1 -0
- package/dist/orchestrator/load-changes/index.js +2 -0
- package/dist/orchestrator/load-changes/load-changes.d.ts +6 -0
- package/dist/orchestrator/load-changes/load-changes.d.ts.map +1 -0
- package/dist/orchestrator/load-changes/load-changes.js +18 -0
- package/dist/orchestrator/load-module-source/errors.d.ts +17 -0
- package/dist/orchestrator/load-module-source/errors.d.ts.map +1 -0
- package/dist/orchestrator/load-module-source/errors.js +5 -0
- package/dist/orchestrator/load-module-source/index.d.ts +2 -0
- package/dist/orchestrator/load-module-source/index.d.ts.map +1 -0
- package/dist/orchestrator/load-module-source/index.js +1 -0
- package/dist/orchestrator/load-module-source/load-module-source.d.ts +12 -0
- package/dist/orchestrator/load-module-source/load-module-source.d.ts.map +1 -0
- package/dist/orchestrator/load-module-source/load-module-source.js +39 -0
- package/dist/orchestrator/load-project/index.d.ts +3 -0
- package/dist/orchestrator/load-project/index.d.ts.map +1 -0
- package/dist/orchestrator/load-project/index.js +2 -0
- package/dist/orchestrator/load-project/load-project.d.ts +54 -0
- package/dist/orchestrator/load-project/load-project.d.ts.map +1 -0
- package/dist/orchestrator/load-project/load-project.js +30 -0
- package/dist/orchestrator/query-dependencies/index.d.ts +3 -0
- package/dist/orchestrator/query-dependencies/index.d.ts.map +1 -0
- package/dist/orchestrator/query-dependencies/index.js +4 -0
- package/dist/orchestrator/query-dependencies/query-dependencies.d.ts +12 -0
- package/dist/orchestrator/query-dependencies/query-dependencies.d.ts.map +1 -0
- package/dist/orchestrator/query-dependencies/query-dependencies.js +20 -0
- package/dist/orchestrator/run-stories/errors.d.ts +11 -0
- package/dist/orchestrator/run-stories/errors.d.ts.map +1 -0
- package/dist/orchestrator/run-stories/errors.js +3 -0
- package/dist/orchestrator/run-stories/extract-snippets.d.ts +12 -0
- package/dist/orchestrator/run-stories/extract-snippets.d.ts.map +1 -0
- package/dist/orchestrator/run-stories/extract-snippets.js +181 -0
- package/dist/orchestrator/run-stories/index.d.ts +3 -0
- package/dist/orchestrator/run-stories/index.d.ts.map +1 -0
- package/dist/orchestrator/run-stories/index.js +3 -0
- package/dist/orchestrator/run-stories/run-stories.d.ts +16 -0
- package/dist/orchestrator/run-stories/run-stories.d.ts.map +1 -0
- package/dist/orchestrator/run-stories/run-stories.js +290 -0
- package/dist/report/architecture.d.ts +1 -1
- package/dist/report/architecture.d.ts.map +1 -1
- package/dist/report/index.d.ts +2 -1
- package/dist/report/index.d.ts.map +1 -1
- package/dist/report/index.js +1 -1
- package/dist/report/tests.d.ts +411 -0
- package/dist/report/tests.d.ts.map +1 -0
- package/dist/report/tests.js +102 -0
- package/dist/services/config/config.d.ts +12 -0
- package/dist/services/config/config.d.ts.map +1 -0
- package/dist/services/config/config.js +46 -0
- package/dist/services/config/errors.d.ts +13 -0
- package/dist/services/config/errors.d.ts.map +1 -0
- package/dist/services/config/errors.js +3 -0
- package/dist/services/config/index.d.ts +4 -0
- package/dist/services/config/index.d.ts.map +1 -0
- package/dist/services/config/index.js +7 -0
- package/dist/services/file-cruiser/errors.d.ts +10 -0
- package/dist/services/file-cruiser/errors.d.ts.map +1 -0
- package/dist/services/file-cruiser/errors.js +3 -0
- package/dist/services/file-cruiser/file-cruiser.d.ts +11 -0
- package/dist/services/file-cruiser/file-cruiser.d.ts.map +1 -0
- package/dist/services/file-cruiser/file-cruiser.js +7 -0
- package/dist/services/file-cruiser/index.d.ts +4 -0
- package/dist/services/file-cruiser/index.d.ts.map +1 -0
- package/dist/services/file-cruiser/index.js +6 -0
- package/dist/services/file-cruiser/oxc/file-scanner.d.ts +5 -0
- package/dist/services/file-cruiser/oxc/file-scanner.d.ts.map +1 -0
- package/dist/services/file-cruiser/oxc/file-scanner.js +54 -0
- package/dist/services/file-cruiser/oxc/import-resolver.d.ts +5 -0
- package/dist/services/file-cruiser/oxc/import-resolver.d.ts.map +1 -0
- package/dist/services/file-cruiser/oxc/import-resolver.js +44 -0
- package/dist/services/file-cruiser/oxc/index.d.ts +2 -0
- package/dist/services/file-cruiser/oxc/index.d.ts.map +1 -0
- package/dist/services/file-cruiser/oxc/index.js +2 -0
- package/dist/services/file-cruiser/oxc/oxc.d.ts +5 -0
- package/dist/services/file-cruiser/oxc/oxc.d.ts.map +1 -0
- package/dist/services/file-cruiser/oxc/oxc.js +29 -0
- package/dist/services/git/changed-paths.d.ts +4 -0
- package/dist/services/git/changed-paths.d.ts.map +1 -0
- package/dist/services/git/changed-paths.js +85 -0
- package/dist/services/git/errors.d.ts +11 -0
- package/dist/services/git/errors.d.ts.map +1 -0
- package/dist/services/git/errors.js +3 -0
- package/dist/services/git/git.d.ts +12 -0
- package/dist/services/git/git.d.ts.map +1 -0
- package/dist/services/git/git.js +23 -0
- package/dist/services/git/index.d.ts +4 -0
- package/dist/services/git/index.d.ts.map +1 -0
- package/dist/services/git/index.js +6 -0
- package/dist/services/git/parse-patch.d.ts +3 -0
- package/dist/services/git/parse-patch.d.ts.map +1 -0
- package/dist/services/git/parse-patch.js +53 -0
- package/dist/services/git/run-git.d.ts +9 -0
- package/dist/services/git/run-git.d.ts.map +1 -0
- package/dist/services/git/run-git.js +22 -0
- package/dist/story/index.d.ts +3 -0
- package/dist/story/index.d.ts.map +1 -0
- package/dist/story/index.js +2 -0
- package/dist/story/schema/index.d.ts +6 -0
- package/dist/story/schema/index.d.ts.map +1 -0
- package/dist/story/schema/index.js +4 -0
- package/dist/story/schema/slug.d.ts +2 -0
- package/dist/story/schema/slug.d.ts.map +1 -0
- package/dist/story/schema/slug.js +6 -0
- package/dist/story/schema/story-report-schema.d.ts +408 -0
- package/dist/story/schema/story-report-schema.d.ts.map +1 -0
- package/dist/story/schema/story-report-schema.js +94 -0
- package/dist/story/schema/story-tree-schema.d.ts +42 -0
- package/dist/story/schema/story-tree-schema.d.ts.map +1 -0
- package/dist/story/schema/story-tree-schema.js +40 -0
- package/dist/story/story.d.ts +38 -0
- package/dist/story/story.d.ts.map +1 -0
- package/dist/story/story.js +56 -0
- package/dist/tests/authoring/index.d.ts +72 -0
- package/dist/tests/authoring/index.d.ts.map +1 -0
- package/dist/tests/authoring/index.js +312 -0
- package/dist/tests/run-tests/index.d.ts +3 -0
- package/dist/tests/run-tests/index.d.ts.map +1 -0
- package/dist/tests/run-tests/index.js +1 -0
- package/dist/tests/run-tests/run-tests.d.ts +26 -0
- package/dist/tests/run-tests/run-tests.d.ts.map +1 -0
- package/dist/tests/run-tests/run-tests.js +284 -0
- package/package.json +36 -24
- package/schema.json +212 -0
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -1
- package/dist/engine/1-extract/extract.d.ts.map +0 -1
- package/dist/engine/1-extract/index.d.ts +0 -3
- package/dist/engine/1-extract/index.d.ts.map +0 -1
- package/dist/engine/1-extract/index.js +0 -1
- package/dist/engine/2-resolve/index.d.ts +0 -3
- package/dist/engine/2-resolve/index.d.ts.map +0 -1
- package/dist/engine/2-resolve/index.js +0 -1
- package/dist/engine/2-resolve/resolve.d.ts.map +0 -1
- package/dist/engine/3-evaluate/evaluate.d.ts.map +0 -1
- package/dist/engine/3-evaluate/index.d.ts +0 -3
- package/dist/engine/3-evaluate/index.d.ts.map +0 -1
- package/dist/engine/3-evaluate/index.js +0 -1
- package/dist/engine/4-emit/emit.d.ts +0 -7
- package/dist/engine/4-emit/emit.d.ts.map +0 -1
- package/dist/engine/4-emit/index.d.ts +0 -2
- package/dist/engine/4-emit/index.d.ts.map +0 -1
- package/dist/engine/4-emit/index.js +0 -1
- package/dist/engine/errors.d.ts +0 -19
- package/dist/engine/errors.d.ts.map +0 -1
- package/dist/node.d.ts +0 -24
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -139
- package/dist/report/stories.d.ts +0 -22
- package/dist/report/stories.d.ts.map +0 -1
- package/dist/report/stories.js +0 -1
- package/dist/story/artifact/artifact.d.ts +0 -57
- package/dist/story/artifact/artifact.d.ts.map +0 -1
- package/dist/story/artifact/artifact.js +0 -234
- package/dist/story/artifact/index.d.ts +0 -2
- package/dist/story/artifact/index.d.ts.map +0 -1
- package/dist/story/artifact/index.js +0 -1
- package/dist/story/artifact/storage.d.ts +0 -10
- package/dist/story/artifact/storage.d.ts.map +0 -1
- package/dist/story/artifact/storage.js +0 -162
- package/dist/story/artifact/types.d.ts +0 -74
- package/dist/story/artifact/types.d.ts.map +0 -1
- package/dist/story/artifact/types.js +0 -1
- package/dist/story/core/blocks.d.ts +0 -20
- package/dist/story/core/blocks.d.ts.map +0 -1
- package/dist/story/core/blocks.js +0 -104
- package/dist/story/core/declare.d.ts +0 -63
- package/dist/story/core/declare.d.ts.map +0 -1
- package/dist/story/core/declare.js +0 -62
- package/dist/story/core/index.d.ts +0 -4
- package/dist/story/core/index.d.ts.map +0 -1
- package/dist/story/core/index.js +0 -1
- package/dist/story/core/recorder.d.ts +0 -38
- package/dist/story/core/recorder.d.ts.map +0 -1
- package/dist/story/core/recorder.js +0 -28
- package/dist/story/core/runtime-context.d.ts +0 -14
- package/dist/story/core/runtime-context.d.ts.map +0 -1
- package/dist/story/core/runtime-context.js +0 -19
- package/dist/story/core/types.d.ts +0 -21
- package/dist/story/core/types.d.ts.map +0 -1
- package/dist/story/core/types.js +0 -1
- package/dist/story/effect/effect.d.ts +0 -52
- package/dist/story/effect/effect.d.ts.map +0 -1
- package/dist/story/effect/effect.js +0 -99
- package/dist/story/effect/index.d.ts +0 -3
- package/dist/story/effect/index.d.ts.map +0 -1
- package/dist/story/effect/index.js +0 -1
- package/dist/story/runner/index.d.ts +0 -3
- package/dist/story/runner/index.d.ts.map +0 -1
- package/dist/story/runner/index.js +0 -1
- package/dist/story/runner/runner.d.ts +0 -44
- package/dist/story/runner/runner.d.ts.map +0 -1
- package/dist/story/runner/runner.js +0 -476
- package/dist/story/story-runtime/index.d.ts +0 -2
- package/dist/story/story-runtime/index.d.ts.map +0 -1
- package/dist/story/story-runtime/index.js +0 -1
- package/dist/story/story-runtime/story-runtime.d.ts +0 -52
- package/dist/story/story-runtime/story-runtime.d.ts.map +0 -1
- package/dist/story/story-runtime/story-runtime.js +0 -194
- package/dist/story/vanilla/index.d.ts +0 -29
- package/dist/story/vanilla/index.d.ts.map +0 -1
- package/dist/story/vanilla/index.js +0 -78
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as colors from 'yoctocolors';
|
|
2
|
+
export const emptyTally = { passed: 0, failed: 0, errored: 0 };
|
|
3
|
+
export function countVerdict(tally, verdict) {
|
|
4
|
+
return { ...tally, [verdict]: tally[verdict] + 1 };
|
|
5
|
+
}
|
|
6
|
+
export function tallyReports(reports) {
|
|
7
|
+
return reports.reduce((tally, report) => countVerdict(tally, report.verdict), emptyTally);
|
|
8
|
+
}
|
|
9
|
+
export function renderTally(tally, total) {
|
|
10
|
+
const done = tally.passed + tally.failed + tally.errored;
|
|
11
|
+
const parts = [`${done}/${total} ${total === 1 ? 'story' : 'stories'}`];
|
|
12
|
+
for (const verdict of verdicts) {
|
|
13
|
+
if (tally[verdict] > 0) {
|
|
14
|
+
parts.push(verdictColors[verdict](`${tally[verdict]} ${verdict}`));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return parts.join(colors.dim(' · '));
|
|
18
|
+
}
|
|
19
|
+
export function renderSummary(reports, total) {
|
|
20
|
+
const tally = tallyReports(reports);
|
|
21
|
+
const mark = tally.passed === total ? verdictMarks.passed : verdictMarks.failed;
|
|
22
|
+
return `${mark} ${renderTally(tally, total)}`;
|
|
23
|
+
}
|
|
24
|
+
export function renderStoryReports(reports) {
|
|
25
|
+
return reports.map(renderStoryReport).join('\n');
|
|
26
|
+
}
|
|
27
|
+
const verdicts = ['passed', 'failed', 'errored'];
|
|
28
|
+
const verdictColors = {
|
|
29
|
+
passed: colors.green,
|
|
30
|
+
failed: colors.red,
|
|
31
|
+
errored: colors.yellow,
|
|
32
|
+
};
|
|
33
|
+
const verdictMarks = {
|
|
34
|
+
passed: colors.green('✓'),
|
|
35
|
+
failed: colors.red('✗'),
|
|
36
|
+
errored: colors.yellow('!'),
|
|
37
|
+
};
|
|
38
|
+
function renderStoryReport(report) {
|
|
39
|
+
const path = report.id.split('/');
|
|
40
|
+
const pad = ' '.repeat(path.length - 1);
|
|
41
|
+
const title = path.at(-1) ?? report.id;
|
|
42
|
+
const questions = report.questions.length;
|
|
43
|
+
return [
|
|
44
|
+
`${pad}${verdictMarks[report.verdict]} ${title} — ${report.verdict} (${questions} question${questions === 1 ? '' : 's'})`,
|
|
45
|
+
...report.questions.map((question) => renderQuestion(question, `${pad} `)),
|
|
46
|
+
].join('\n');
|
|
47
|
+
}
|
|
48
|
+
function renderQuestion(question, pad) {
|
|
49
|
+
const lines = [
|
|
50
|
+
`${pad}${verdictMarks[question.verdict]} ${question.slug}`,
|
|
51
|
+
...question.assertions.map((assertion) => `${pad} ${assertion.passed ? verdictMarks.passed : verdictMarks.failed} ${assertion.description}`),
|
|
52
|
+
];
|
|
53
|
+
if (question.error !== undefined) {
|
|
54
|
+
lines.push(indent(question.error, `${pad} `));
|
|
55
|
+
}
|
|
56
|
+
return lines.join('\n');
|
|
57
|
+
}
|
|
58
|
+
function indent(text, pad) {
|
|
59
|
+
return text
|
|
60
|
+
.split('\n')
|
|
61
|
+
.map((line) => `${pad}${line}`)
|
|
62
|
+
.join('\n');
|
|
63
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { Command } from 'effect/unstable/cli';
|
|
3
|
+
export declare function makeStoriesCommand<R>(configPath: Effect.Effect<string, never, R>): Command.Command<"stories", {
|
|
4
|
+
readonly concurrency: number;
|
|
5
|
+
}, {}, import("../../index.js").ConfigError | import("../../orchestrator/run-stories/errors.js").StoriesError, Exclude<R, "effect/unstable/cli/GlobalFlag/log-level">>;
|
|
6
|
+
//# sourceMappingURL=stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stories.d.ts","sourceRoot":"","sources":["../../../src/cli/stories/stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAU,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,OAAO,EAAQ,MAAM,qBAAqB,CAAC;AAapD,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;;uKAc5C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Console, Effect, Stream } from 'effect';
|
|
2
|
+
import { Command, Flag } from 'effect/unstable/cli';
|
|
3
|
+
import { planStories } from '../../orchestrator/run-stories/index.js';
|
|
4
|
+
import { startProgress } from './progress.js';
|
|
5
|
+
import { renderStoryReports, renderSummary } from './report.js';
|
|
6
|
+
const concurrencyFlag = Flag.integer('concurrency').pipe(Flag.withAlias('c'), Flag.withDefault(16), Flag.withDescription('How many Stories run at once.'));
|
|
7
|
+
export function makeStoriesCommand(configPath) {
|
|
8
|
+
return Command.make('stories', { concurrency: concurrencyFlag }, ({ concurrency }) => configPath.pipe(Effect.flatMap((path) => runAllStories(path, concurrency)))).pipe(Command.withDescription('Run every Story in the Story tree and report each verdict.'));
|
|
9
|
+
}
|
|
10
|
+
function runAllStories(configPath, concurrency) {
|
|
11
|
+
return Effect.gen(function* () {
|
|
12
|
+
const { total, reports } = yield* planStories(configPath, { concurrency });
|
|
13
|
+
const collected = yield* collectReports(reports, total);
|
|
14
|
+
yield* Console.log(renderStoryReports(collected));
|
|
15
|
+
yield* Console.log(`\n${renderSummary(collected, total)}`);
|
|
16
|
+
if (collected.some((report) => report.verdict !== 'passed')) {
|
|
17
|
+
process.exitCode = 1;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function collectReports(reports, total) {
|
|
22
|
+
return Effect.suspend(() => {
|
|
23
|
+
const collected = [];
|
|
24
|
+
const progress = startProgress(total);
|
|
25
|
+
return reports.pipe(Stream.runForEach((report) => Effect.sync(() => {
|
|
26
|
+
collected.push(report);
|
|
27
|
+
progress.record(report.verdict);
|
|
28
|
+
})), Effect.ensuring(Effect.sync(progress.stop)), Effect.as(collected));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { LaymosConfig } from './types.js';
|
|
2
2
|
export declare function defineConfig(config: LaymosConfig): LaymosConfig;
|
|
3
|
+
export interface ConfigValidation {
|
|
4
|
+
readonly config: LaymosConfig;
|
|
5
|
+
readonly issues: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function validateConfig(config: LaymosConfig): ConfigValidation;
|
|
3
8
|
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../src/config/define-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../src/config/define-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAS,YAAY,EAA0B,MAAM,YAAY,CAAC;AAK9E,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CAuFrE"}
|
|
@@ -1,25 +1,170 @@
|
|
|
1
|
+
import { Option, Schema } from 'effect';
|
|
1
2
|
import { normalizeConfigPath, pathContains } from './path.js';
|
|
3
|
+
const ErrorMessageSchema = Schema.Struct({ message: Schema.String });
|
|
2
4
|
export function defineConfig(config) {
|
|
5
|
+
return config;
|
|
6
|
+
}
|
|
7
|
+
export function validateConfig(config) {
|
|
8
|
+
const normalizationIssues = [];
|
|
9
|
+
const normalizePath = (subject, path) => {
|
|
10
|
+
try {
|
|
11
|
+
return normalizeConfigPath(path);
|
|
12
|
+
}
|
|
13
|
+
catch (cause) {
|
|
14
|
+
const error = Schema.decodeUnknownOption(ErrorMessageSchema)(cause);
|
|
15
|
+
normalizationIssues.push(`${subject}: ${Option.isSome(error) ? error.value.message : String(cause)}`);
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const layers = new Map();
|
|
20
|
+
const normalizeLayer = (layer) => {
|
|
21
|
+
const existing = layers.get(layer);
|
|
22
|
+
if (existing !== undefined)
|
|
23
|
+
return existing;
|
|
24
|
+
const normalized = {
|
|
25
|
+
...layer,
|
|
26
|
+
paths: layer.paths.map((path) => normalizePath(`Layer "${layer.name}" path`, path)),
|
|
27
|
+
};
|
|
28
|
+
layers.set(layer, normalized);
|
|
29
|
+
return normalized;
|
|
30
|
+
};
|
|
31
|
+
const modules = new Map();
|
|
32
|
+
const normalizeModule = (module) => {
|
|
33
|
+
const existing = modules.get(module);
|
|
34
|
+
if (existing !== undefined)
|
|
35
|
+
return existing;
|
|
36
|
+
const normalized = {
|
|
37
|
+
...module,
|
|
38
|
+
path: normalizePath('Module path', module.path),
|
|
39
|
+
};
|
|
40
|
+
modules.set(module, normalized);
|
|
41
|
+
return normalized;
|
|
42
|
+
};
|
|
43
|
+
const normalizedModules = config.modules?.map(normalizeModule);
|
|
44
|
+
const normalizedRules = config.moduleRules?.map((rule) => ({
|
|
45
|
+
...rule,
|
|
46
|
+
module: normalizeModule(rule.module),
|
|
47
|
+
...(rule.canImport === undefined
|
|
48
|
+
? {}
|
|
49
|
+
: { canImport: rule.canImport.map(normalizeModule) }),
|
|
50
|
+
...(rule.canImportedBy === undefined
|
|
51
|
+
? {}
|
|
52
|
+
: { canImportedBy: rule.canImportedBy.map(normalizeModule) }),
|
|
53
|
+
}));
|
|
3
54
|
const normalizedConfig = {
|
|
4
55
|
...config,
|
|
5
|
-
sourceRoots: config.sourceRoots.map(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
:
|
|
56
|
+
sourceRoots: config.sourceRoots.map((path) => normalizePath('Source root', path)),
|
|
57
|
+
graphs: config.graphs.map((graph) => ({
|
|
58
|
+
...graph,
|
|
59
|
+
layers: graph.layers.map(normalizeLayer),
|
|
60
|
+
edges: graph.edges.map((edge) => ({
|
|
61
|
+
from: normalizeLayer(edge.from),
|
|
62
|
+
to: normalizeLayer(edge.to),
|
|
63
|
+
})),
|
|
64
|
+
})),
|
|
65
|
+
...(normalizedModules === undefined ? {} : { modules: normalizedModules }),
|
|
66
|
+
...(normalizedRules === undefined ? {} : { moduleRules: normalizedRules }),
|
|
67
|
+
...(config.ignore === undefined
|
|
68
|
+
? {}
|
|
69
|
+
: {
|
|
70
|
+
ignore: config.ignore.map((path) => normalizePath('Ignored path', path)),
|
|
71
|
+
}),
|
|
9
72
|
};
|
|
10
73
|
const issues = [
|
|
74
|
+
...normalizationIssues,
|
|
75
|
+
...builderIssues(normalizedConfig),
|
|
11
76
|
...sourceRootIssues(normalizedConfig),
|
|
12
77
|
...duplicateGraphNames(normalizedConfig),
|
|
13
78
|
...duplicateLayerNames(normalizedConfig),
|
|
14
79
|
...duplicateLayerPaths(normalizedConfig),
|
|
15
80
|
...duplicateIgnoredPaths(normalizedConfig),
|
|
16
81
|
...unionCycles(normalizedConfig),
|
|
82
|
+
...architectureIntentIssues(normalizedConfig),
|
|
17
83
|
...moduleIssues(normalizedConfig),
|
|
84
|
+
...projectNarrativeIssues(normalizedConfig),
|
|
18
85
|
];
|
|
19
|
-
|
|
20
|
-
|
|
86
|
+
return { config: normalizedConfig, issues };
|
|
87
|
+
}
|
|
88
|
+
function builderIssues(config) {
|
|
89
|
+
const issues = [];
|
|
90
|
+
for (const graph of config.graphs) {
|
|
91
|
+
if (graph.name.trim().length === 0) {
|
|
92
|
+
issues.push('Layer Graph name must not be empty');
|
|
93
|
+
}
|
|
94
|
+
const edges = new Set();
|
|
95
|
+
for (const edge of graph.edges) {
|
|
96
|
+
if (edge.from === edge.to || edge.from.name === edge.to.name) {
|
|
97
|
+
issues.push(`Layer Graph "${graph.name}" contains self-edge "${edge.from.name} -> ${edge.to.name}"`);
|
|
98
|
+
}
|
|
99
|
+
const key = `${edge.from.name}\0${edge.to.name}`;
|
|
100
|
+
if (edges.has(key)) {
|
|
101
|
+
issues.push(`Layer Graph "${graph.name}" contains duplicate edge "${edge.from.name} -> ${edge.to.name}"`);
|
|
102
|
+
}
|
|
103
|
+
edges.add(key);
|
|
104
|
+
}
|
|
105
|
+
for (const layer of graph.layers) {
|
|
106
|
+
if (layer.name.trim().length === 0) {
|
|
107
|
+
issues.push('Layer name must not be empty');
|
|
108
|
+
}
|
|
109
|
+
if (layer.paths.length === 0) {
|
|
110
|
+
issues.push(`Layer "${layer.name}" must have at least 1 path`);
|
|
111
|
+
}
|
|
112
|
+
if (new Set(layer.paths).size !== layer.paths.length) {
|
|
113
|
+
issues.push(`Layer "${layer.name}" contains duplicate paths`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (const module of config.modules ?? []) {
|
|
118
|
+
if (module.path.trim().length === 0) {
|
|
119
|
+
issues.push('Module path must not be empty');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for (const rule of config.moduleRules ?? []) {
|
|
123
|
+
if (rule.canImport === undefined && rule.canImportedBy === undefined) {
|
|
124
|
+
issues.push(`Rules for module "${rule.module.path}" must declare canImport or canImportedBy`);
|
|
125
|
+
}
|
|
21
126
|
}
|
|
22
|
-
return
|
|
127
|
+
return issues;
|
|
128
|
+
}
|
|
129
|
+
function architectureIntentIssues(config) {
|
|
130
|
+
const issues = [];
|
|
131
|
+
for (const graph of config.graphs) {
|
|
132
|
+
if (typeof graph.description !== 'string' ||
|
|
133
|
+
graph.description.trim().length === 0) {
|
|
134
|
+
issues.push(`Layer Graph "${graph.name}" description must not be empty`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const layers = new Set(config.graphs.flatMap((graph) => graph.layers));
|
|
138
|
+
for (const layer of layers) {
|
|
139
|
+
if (typeof layer.description !== 'string' ||
|
|
140
|
+
layer.description.trim().length === 0) {
|
|
141
|
+
issues.push(`Layer "${layer.name}" description must not be empty`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const moduleDef of config.modules ?? []) {
|
|
145
|
+
if (typeof moduleDef.description !== 'string' ||
|
|
146
|
+
moduleDef.description.trim().length === 0) {
|
|
147
|
+
issues.push(`Module "${moduleDef.path}" description must not be empty`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return issues;
|
|
151
|
+
}
|
|
152
|
+
function projectNarrativeIssues(config) {
|
|
153
|
+
if (config.project === undefined)
|
|
154
|
+
return [];
|
|
155
|
+
const project = config.project;
|
|
156
|
+
const issues = [];
|
|
157
|
+
if (project.kind !== 'project-narrative') {
|
|
158
|
+
issues.push('Project Narrative has an invalid kind');
|
|
159
|
+
}
|
|
160
|
+
if (project.name.trim().length === 0) {
|
|
161
|
+
issues.push('Project Narrative name must not be empty');
|
|
162
|
+
}
|
|
163
|
+
if (project.content.kind !== 'markdown' ||
|
|
164
|
+
project.content.content.trim().length === 0) {
|
|
165
|
+
issues.push('Project Narrative Markdown content must not be empty');
|
|
166
|
+
}
|
|
167
|
+
return issues;
|
|
23
168
|
}
|
|
24
169
|
function sourceRootIssues(config) {
|
|
25
170
|
const issues = [];
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { defineConfig } from './define-config.js';
|
|
2
|
+
export type { ConfigValidation } from './define-config.js';
|
|
3
|
+
export type { Layer, LayerEdge, LayerGraph, LaymosConfig, ModuleDef, ModuleRules, } from './types.js';
|
|
2
4
|
export { edge, layerGraph } from './layer-graph.js';
|
|
3
5
|
export { layer } from './layer.js';
|
|
4
6
|
export { module, rules } from './module.js';
|
|
7
|
+
export { markdown } from '../markdown/index.js';
|
|
8
|
+
export type { MarkdownContent } from '../markdown/index.js';
|
|
9
|
+
export { projectNarrative } from './project-narrative.js';
|
|
10
|
+
export type { ProjectNarrativeDef } from './project-narrative.js';
|
|
5
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EACV,KAAK,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EACT,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -2,3 +2,5 @@ export { defineConfig } from './define-config.js';
|
|
|
2
2
|
export { edge, layerGraph } from './layer-graph.js';
|
|
3
3
|
export { layer } from './layer.js';
|
|
4
4
|
export { module, rules } from './module.js';
|
|
5
|
+
export { markdown } from '../markdown/index.js';
|
|
6
|
+
export { projectNarrative } from './project-narrative.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Layer, LayerEdge, LayerGraph } from './types.js';
|
|
2
2
|
export declare function edge(from: Layer, to: Layer): LayerEdge;
|
|
3
3
|
export declare function edge(from: Layer, to: readonly Layer[]): LayerEdge[];
|
|
4
|
-
export declare function layerGraph(name: string, edges: ReadonlyArray<LayerEdge | LayerEdge[]>, options
|
|
5
|
-
description
|
|
4
|
+
export declare function layerGraph(name: string, edges: ReadonlyArray<LayerEdge | LayerEdge[]>, options: {
|
|
5
|
+
readonly description: string;
|
|
6
6
|
}): LayerGraph;
|
|
7
7
|
//# sourceMappingURL=layer-graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-graph.d.ts","sourceRoot":"","sources":["../../src/config/layer-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,SAAS,CAAC;AACxD,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"layer-graph.d.ts","sourceRoot":"","sources":["../../src/config/layer-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,SAAS,CAAC;AACxD,wBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;AAerE,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC,EAC7C,OAAO,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACxC,UAAU,CAkBZ"}
|
|
@@ -1,53 +1,26 @@
|
|
|
1
1
|
export function edge(from, to) {
|
|
2
2
|
if (Array.isArray(to)) {
|
|
3
|
-
if (to.length === 0) {
|
|
4
|
-
throw new Error(`Edge from "${from.name}" must have at least 1 target`);
|
|
5
|
-
}
|
|
6
3
|
return to.map((target) => singleEdge(from, target));
|
|
7
4
|
}
|
|
8
5
|
return singleEdge(from, to);
|
|
9
6
|
}
|
|
10
7
|
function singleEdge(from, to) {
|
|
11
|
-
if (from === to || from.name === to.name) {
|
|
12
|
-
throw new Error(`Edge "${from.name} -> ${to.name}" is a self-edge`);
|
|
13
|
-
}
|
|
14
8
|
return { from, to };
|
|
15
9
|
}
|
|
16
10
|
export function layerGraph(name, edges, options) {
|
|
17
|
-
if (name.length === 0) {
|
|
18
|
-
throw new Error('Graph name must not be empty');
|
|
19
|
-
}
|
|
20
11
|
const flatEdges = edges.flat();
|
|
21
|
-
if (flatEdges.length === 0) {
|
|
22
|
-
throw new Error(`Graph "${name}" must have at least 1 edge`);
|
|
23
|
-
}
|
|
24
12
|
const layers = [];
|
|
25
|
-
const seen = new Map();
|
|
26
|
-
const seenEdges = new Set();
|
|
27
13
|
for (const e of flatEdges) {
|
|
28
14
|
for (const l of [e.from, e.to]) {
|
|
29
|
-
|
|
30
|
-
if (existing && existing !== l) {
|
|
31
|
-
throw new Error(`Graph "${name}" has duplicate layer name "${l.name}" with different definitions`);
|
|
32
|
-
}
|
|
33
|
-
if (!existing) {
|
|
34
|
-
seen.set(l.name, l);
|
|
15
|
+
if (!layers.includes(l))
|
|
35
16
|
layers.push(l);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const key = `${e.from.name}\0${e.to.name}`;
|
|
39
|
-
if (seenEdges.has(key)) {
|
|
40
|
-
throw new Error(`Graph "${name}" has duplicate edge "${e.from.name} -> ${e.to.name}"`);
|
|
41
17
|
}
|
|
42
|
-
seenEdges.add(key);
|
|
43
18
|
}
|
|
44
19
|
return {
|
|
45
20
|
kind: 'layer-graph',
|
|
46
21
|
name,
|
|
47
22
|
layers,
|
|
48
23
|
edges: flatEdges,
|
|
49
|
-
|
|
50
|
-
? { description: options.description }
|
|
51
|
-
: {}),
|
|
24
|
+
description: options.description,
|
|
52
25
|
};
|
|
53
26
|
}
|
package/dist/config/layer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Layer } from './types.js';
|
|
2
|
-
export declare function layer(name: string, paths: readonly string[], options
|
|
3
|
-
description
|
|
2
|
+
export declare function layer(name: string, paths: readonly string[], options: {
|
|
3
|
+
readonly description: string;
|
|
4
4
|
}): Layer;
|
|
5
5
|
//# sourceMappingURL=layer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../../src/config/layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../../src/config/layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACxC,KAAK,CAOP"}
|
package/dist/config/layer.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { normalizeConfigPath } from './path.js';
|
|
2
1
|
export function layer(name, paths, options) {
|
|
3
|
-
if (name.length === 0) {
|
|
4
|
-
throw new Error('Layer name must not be empty');
|
|
5
|
-
}
|
|
6
|
-
if (paths.length === 0) {
|
|
7
|
-
throw new Error(`Layer "${name}" must have at least 1 path`);
|
|
8
|
-
}
|
|
9
|
-
const normalizedPaths = paths.map(normalizeConfigPath);
|
|
10
|
-
if (new Set(normalizedPaths).size !== normalizedPaths.length) {
|
|
11
|
-
throw new Error(`Layer "${name}" contains duplicate paths`);
|
|
12
|
-
}
|
|
13
2
|
return {
|
|
14
3
|
kind: 'layer',
|
|
15
4
|
name,
|
|
16
|
-
paths
|
|
17
|
-
|
|
18
|
-
? { description: options.description }
|
|
19
|
-
: {}),
|
|
5
|
+
paths,
|
|
6
|
+
description: options.description,
|
|
20
7
|
};
|
|
21
8
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/load-config/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './load-config.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import type { LaymosConfig } from '../types.js';
|
|
3
|
+
declare const ConfigNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "ConfigNotFoundError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
export declare class ConfigNotFoundError extends ConfigNotFoundError_base<{
|
|
7
|
+
readonly path: string;
|
|
8
|
+
}> {
|
|
9
|
+
}
|
|
10
|
+
declare const ConfigImportError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
11
|
+
readonly _tag: "ConfigImportError";
|
|
12
|
+
} & Readonly<A>;
|
|
13
|
+
export declare class ConfigImportError extends ConfigImportError_base<{
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
18
|
+
declare const ConfigValidationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
19
|
+
readonly _tag: "ConfigValidationError";
|
|
20
|
+
} & Readonly<A>;
|
|
21
|
+
export declare class ConfigValidationError extends ConfigValidationError_base<{
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly issues: readonly string[];
|
|
24
|
+
readonly message: string;
|
|
25
|
+
}> {
|
|
26
|
+
}
|
|
27
|
+
export type LoadConfigError = ConfigNotFoundError | ConfigImportError | ConfigValidationError;
|
|
28
|
+
export interface LoadConfigRequest {
|
|
29
|
+
readonly projectDir: string;
|
|
30
|
+
}
|
|
31
|
+
/** Loads and validates the Laymos config at the project root. */
|
|
32
|
+
export declare const loadConfig: ({ projectDir, }: LoadConfigRequest) => Effect.Effect<LaymosConfig, LoadConfigError>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=load-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../../src/config/load-config/load-config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,MAAM,EAAyB,MAAM,QAAQ,CAAC;AAI7D,OAAO,KAAK,EAIV,YAAY,EAGb,MAAM,aAAa,CAAC;;;;AAKrB,qBAAa,mBAAoB,SAAQ,yBAEvC;IACA,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;CAAG;;;;AAEL,qBAAa,iBAAkB,SAAQ,uBAAsC;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;;;;AAEL,qBAAa,qBAAsB,SAAQ,2BAEzC;IACA,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;AAEL,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,iBAAiB,GACjB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,iEAAiE;AACjE,eAAO,MAAM,UAAU,oBAEpB,iBAAiB,KAAG,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,eAAe,CAcjE,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { Data, Effect, Match, Option, Schema } from 'effect';
|
|
4
|
+
import { createJiti } from 'jiti';
|
|
5
|
+
import { validateConfig } from '../define-config.js';
|
|
6
|
+
const ErrorMessageSchema = Schema.Struct({ message: Schema.String });
|
|
7
|
+
const UnknownRecordSchema = Schema.Record(Schema.String, Schema.Unknown);
|
|
8
|
+
export class ConfigNotFoundError extends Data.TaggedError('ConfigNotFoundError') {
|
|
9
|
+
}
|
|
10
|
+
export class ConfigImportError extends Data.TaggedError('ConfigImportError') {
|
|
11
|
+
}
|
|
12
|
+
export class ConfigValidationError extends Data.TaggedError('ConfigValidationError') {
|
|
13
|
+
}
|
|
14
|
+
/** Loads and validates the Laymos config at the project root. */
|
|
15
|
+
export const loadConfig = ({ projectDir, }) => {
|
|
16
|
+
return Effect.gen(function* () {
|
|
17
|
+
const located = yield* Effect.sync(() => {
|
|
18
|
+
const path = resolve(projectDir, 'laymos.config.ts');
|
|
19
|
+
return { path, exists: existsSync(path) };
|
|
20
|
+
});
|
|
21
|
+
return yield* Match.value(located.exists).pipe(Match.when(false, () => Effect.fail(new ConfigNotFoundError({ path: located.path }))), Match.when(true, () => importAndValidateConfig(located.path)), Match.exhaustive);
|
|
22
|
+
}).pipe(Effect.withSpan('config.load'));
|
|
23
|
+
};
|
|
24
|
+
const importAndValidateConfig = (path) => Effect.gen(function* () {
|
|
25
|
+
const config = yield* Effect.tryPromise({
|
|
26
|
+
try: async () => {
|
|
27
|
+
const jiti = createJiti(import.meta.url, {
|
|
28
|
+
interopDefault: true,
|
|
29
|
+
moduleCache: false,
|
|
30
|
+
});
|
|
31
|
+
const imported = (await jiti.import(path));
|
|
32
|
+
return imported.default;
|
|
33
|
+
},
|
|
34
|
+
catch: (cause) => new ConfigImportError({
|
|
35
|
+
path,
|
|
36
|
+
message: errorMessage(cause),
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
return yield* Match.value(isLaymosConfig(config)).pipe(Match.when(false, () => Effect.fail(new ConfigValidationError({
|
|
40
|
+
path,
|
|
41
|
+
issues: [
|
|
42
|
+
'Config must default-export a value created with defineConfig()',
|
|
43
|
+
],
|
|
44
|
+
message: `Invalid Laymos config at "${path}"`,
|
|
45
|
+
}))), Match.when(true, () => validateConfigurationSemantics(path, config)), Match.exhaustive);
|
|
46
|
+
});
|
|
47
|
+
const validateConfigurationSemantics = (path, config) => {
|
|
48
|
+
const validation = validateConfig(config);
|
|
49
|
+
return Match.value(validation.issues.length > 0).pipe(Match.when(true, () => Effect.fail(new ConfigValidationError({
|
|
50
|
+
path,
|
|
51
|
+
issues: validation.issues,
|
|
52
|
+
message: `Invalid Laymos config at "${path}":\n${validation.issues.map((issue) => `- ${issue}`).join('\n')}`,
|
|
53
|
+
}))), Match.when(false, () => Effect.succeed(validation.config)), Match.exhaustive);
|
|
54
|
+
};
|
|
55
|
+
function isLaymosConfig(value) {
|
|
56
|
+
if (!isRecord(value))
|
|
57
|
+
return false;
|
|
58
|
+
return (isStringArray(value.sourceRoots) &&
|
|
59
|
+
Array.isArray(value.graphs) &&
|
|
60
|
+
value.graphs.every(isLayerGraph) &&
|
|
61
|
+
(value.modules === undefined ||
|
|
62
|
+
(Array.isArray(value.modules) && value.modules.every(isModule))) &&
|
|
63
|
+
(value.moduleRules === undefined ||
|
|
64
|
+
(Array.isArray(value.moduleRules) &&
|
|
65
|
+
value.moduleRules.every(isModuleRules))) &&
|
|
66
|
+
(value.ignore === undefined || isStringArray(value.ignore)) &&
|
|
67
|
+
(value.project === undefined || isProjectNarrative(value.project)));
|
|
68
|
+
}
|
|
69
|
+
function isLayerGraph(value) {
|
|
70
|
+
return (isRecord(value) &&
|
|
71
|
+
value.kind === 'layer-graph' &&
|
|
72
|
+
typeof value.name === 'string' &&
|
|
73
|
+
typeof value.description === 'string' &&
|
|
74
|
+
Array.isArray(value.layers) &&
|
|
75
|
+
value.layers.every(isLayer) &&
|
|
76
|
+
Array.isArray(value.edges) &&
|
|
77
|
+
value.edges.every(isLayerEdge));
|
|
78
|
+
}
|
|
79
|
+
function isLayer(value) {
|
|
80
|
+
return (isRecord(value) &&
|
|
81
|
+
value.kind === 'layer' &&
|
|
82
|
+
typeof value.name === 'string' &&
|
|
83
|
+
typeof value.description === 'string' &&
|
|
84
|
+
isStringArray(value.paths));
|
|
85
|
+
}
|
|
86
|
+
function isLayerEdge(value) {
|
|
87
|
+
return isRecord(value) && isLayer(value.from) && isLayer(value.to);
|
|
88
|
+
}
|
|
89
|
+
function isModule(value) {
|
|
90
|
+
return (isRecord(value) &&
|
|
91
|
+
value.kind === 'module' &&
|
|
92
|
+
typeof value.path === 'string' &&
|
|
93
|
+
typeof value.description === 'string' &&
|
|
94
|
+
(value.documentation === undefined ||
|
|
95
|
+
isMarkdownContent(value.documentation)));
|
|
96
|
+
}
|
|
97
|
+
function isModuleRules(value) {
|
|
98
|
+
return (isRecord(value) &&
|
|
99
|
+
value.kind === 'module-rules' &&
|
|
100
|
+
isModule(value.module) &&
|
|
101
|
+
(value.canImport === undefined ||
|
|
102
|
+
(Array.isArray(value.canImport) && value.canImport.every(isModule))) &&
|
|
103
|
+
(value.canImportedBy === undefined ||
|
|
104
|
+
(Array.isArray(value.canImportedBy) &&
|
|
105
|
+
value.canImportedBy.every(isModule))));
|
|
106
|
+
}
|
|
107
|
+
function isProjectNarrative(value) {
|
|
108
|
+
return (isRecord(value) &&
|
|
109
|
+
value.kind === 'project-narrative' &&
|
|
110
|
+
typeof value.name === 'string' &&
|
|
111
|
+
isMarkdownContent(value.content));
|
|
112
|
+
}
|
|
113
|
+
function isMarkdownContent(value) {
|
|
114
|
+
return (isRecord(value) &&
|
|
115
|
+
value.kind === 'markdown' &&
|
|
116
|
+
typeof value.content === 'string');
|
|
117
|
+
}
|
|
118
|
+
function isStringArray(value) {
|
|
119
|
+
return (Array.isArray(value) && value.every((item) => typeof item === 'string'));
|
|
120
|
+
}
|
|
121
|
+
function isRecord(value) {
|
|
122
|
+
return Schema.is(UnknownRecordSchema)(value);
|
|
123
|
+
}
|
|
124
|
+
function errorMessage(cause) {
|
|
125
|
+
const decoded = Schema.decodeUnknownOption(ErrorMessageSchema)(cause);
|
|
126
|
+
return Option.isSome(decoded) ? decoded.value.message : String(cause);
|
|
127
|
+
}
|
package/dist/config/module.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ModuleDef, ModuleRules } from './types.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { MarkdownContent } from '../markdown/index.js';
|
|
3
|
+
export declare function module(path: string, options: {
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly documentation?: MarkdownContent;
|
|
4
6
|
}): ModuleDef;
|
|
5
7
|
export declare function rules(module: ModuleDef, constraints: {
|
|
6
8
|
canImport?: readonly ModuleDef[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,eAAe,CAAC;CAC1C,GACA,SAAS,CASX;AAED,wBAAgB,KAAK,CACnB,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE;IACX,SAAS,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC,GACA,WAAW,CAWb"}
|