@sk8metal/michi-cli 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -1
- package/README.md +2 -1
- package/dist/scripts/config/config-schema.d.ts +87 -0
- package/dist/scripts/config/config-schema.d.ts.map +1 -1
- package/dist/scripts/config/config-schema.js +81 -0
- package/dist/scripts/config/config-schema.js.map +1 -1
- package/dist/scripts/confluence-sync.d.ts.map +1 -1
- package/dist/scripts/confluence-sync.js +15 -2
- package/dist/scripts/confluence-sync.js.map +1 -1
- package/dist/scripts/github-actions-client.d.ts +79 -0
- package/dist/scripts/github-actions-client.d.ts.map +1 -0
- package/dist/scripts/github-actions-client.js +182 -0
- package/dist/scripts/github-actions-client.js.map +1 -0
- package/dist/scripts/health-check-service.d.ts +46 -0
- package/dist/scripts/health-check-service.d.ts.map +1 -0
- package/dist/scripts/health-check-service.js +114 -0
- package/dist/scripts/health-check-service.js.map +1 -0
- package/dist/scripts/markdown-to-confluence.d.ts.map +1 -1
- package/dist/scripts/markdown-to-confluence.js +25 -3
- package/dist/scripts/markdown-to-confluence.js.map +1 -1
- package/dist/scripts/mermaid-converter.d.ts +24 -0
- package/dist/scripts/mermaid-converter.d.ts.map +1 -0
- package/dist/scripts/mermaid-converter.js +49 -0
- package/dist/scripts/mermaid-converter.js.map +1 -0
- package/dist/scripts/pr-automation.d.ts.map +1 -1
- package/dist/scripts/pr-automation.js +11 -3
- package/dist/scripts/pr-automation.js.map +1 -1
- package/dist/scripts/spec-impl-workflow.d.ts.map +1 -1
- package/dist/scripts/spec-impl-workflow.js +22 -6
- package/dist/scripts/spec-impl-workflow.js.map +1 -1
- package/dist/scripts/template/multi-repo-renderer.d.ts +67 -0
- package/dist/scripts/template/multi-repo-renderer.d.ts.map +1 -0
- package/dist/scripts/template/multi-repo-renderer.js +123 -0
- package/dist/scripts/template/multi-repo-renderer.js.map +1 -0
- package/dist/scripts/template/renderer.d.ts +4 -0
- package/dist/scripts/template/renderer.d.ts.map +1 -1
- package/dist/scripts/template/renderer.js.map +1 -1
- package/dist/scripts/test-execution-generator.d.ts.map +1 -1
- package/dist/scripts/test-execution-generator.js +94 -11
- package/dist/scripts/test-execution-generator.js.map +1 -1
- package/dist/scripts/test-script-runner.d.ts +33 -0
- package/dist/scripts/test-script-runner.d.ts.map +1 -0
- package/dist/scripts/test-script-runner.js +77 -0
- package/dist/scripts/test-script-runner.js.map +1 -0
- package/dist/scripts/utils/config-loader.d.ts +31 -5
- package/dist/scripts/utils/config-loader.d.ts.map +1 -1
- package/dist/scripts/utils/config-loader.js +363 -50
- package/dist/scripts/utils/config-loader.js.map +1 -1
- package/dist/scripts/utils/env-config.d.ts +1 -1
- package/dist/scripts/utils/env-config.d.ts.map +1 -1
- package/dist/scripts/utils/env-config.js +2 -14
- package/dist/scripts/utils/env-config.js.map +1 -1
- package/dist/scripts/utils/multi-repo-validator.d.ts +30 -0
- package/dist/scripts/utils/multi-repo-validator.d.ts.map +1 -0
- package/dist/scripts/utils/multi-repo-validator.js +105 -0
- package/dist/scripts/utils/multi-repo-validator.js.map +1 -0
- package/dist/scripts/utils/project-meta.d.ts +9 -0
- package/dist/scripts/utils/project-meta.d.ts.map +1 -1
- package/dist/scripts/utils/project-meta.js +22 -0
- package/dist/scripts/utils/project-meta.js.map +1 -1
- package/dist/scripts/utils/security-validator.d.ts +55 -0
- package/dist/scripts/utils/security-validator.d.ts.map +1 -0
- package/dist/scripts/utils/security-validator.js +232 -0
- package/dist/scripts/utils/security-validator.js.map +1 -0
- package/dist/scripts/utils/spec-archiver.d.ts +38 -0
- package/dist/scripts/utils/spec-archiver.d.ts.map +1 -0
- package/dist/scripts/utils/spec-archiver.js +210 -0
- package/dist/scripts/utils/spec-archiver.js.map +1 -0
- package/dist/scripts/utils/spec-updater.d.ts +4 -0
- package/dist/scripts/utils/spec-updater.d.ts.map +1 -1
- package/dist/scripts/utils/spec-updater.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +303 -17
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/config-validate.d.ts +9 -0
- package/dist/src/commands/config-validate.d.ts.map +1 -0
- package/dist/src/commands/config-validate.js +90 -0
- package/dist/src/commands/config-validate.js.map +1 -0
- package/dist/src/commands/init.d.ts +1 -0
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +29 -6
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/migrate.d.ts +25 -0
- package/dist/src/commands/migrate.d.ts.map +1 -0
- package/dist/src/commands/migrate.js +341 -0
- package/dist/src/commands/migrate.js.map +1 -0
- package/dist/src/commands/multi-repo-add-repo.d.ts +26 -0
- package/dist/src/commands/multi-repo-add-repo.d.ts.map +1 -0
- package/dist/src/commands/multi-repo-add-repo.js +56 -0
- package/dist/src/commands/multi-repo-add-repo.js.map +1 -0
- package/dist/src/commands/multi-repo-ci-status.d.ts +46 -0
- package/dist/src/commands/multi-repo-ci-status.d.ts.map +1 -0
- package/dist/src/commands/multi-repo-ci-status.js +285 -0
- package/dist/src/commands/multi-repo-ci-status.js.map +1 -0
- package/dist/src/commands/multi-repo-confluence-sync.d.ts +45 -0
- package/dist/src/commands/multi-repo-confluence-sync.d.ts.map +1 -0
- package/dist/src/commands/multi-repo-confluence-sync.js +135 -0
- package/dist/src/commands/multi-repo-confluence-sync.js.map +1 -0
- package/dist/src/commands/multi-repo-init.d.ts +26 -0
- package/dist/src/commands/multi-repo-init.d.ts.map +1 -0
- package/dist/src/commands/multi-repo-init.js +101 -0
- package/dist/src/commands/multi-repo-init.js.map +1 -0
- package/dist/src/commands/multi-repo-list.d.ts +28 -0
- package/dist/src/commands/multi-repo-list.d.ts.map +1 -0
- package/dist/src/commands/multi-repo-list.js +38 -0
- package/dist/src/commands/multi-repo-list.js.map +1 -0
- package/dist/src/commands/multi-repo-test.d.ts +56 -0
- package/dist/src/commands/multi-repo-test.d.ts.map +1 -0
- package/dist/src/commands/multi-repo-test.js +70 -0
- package/dist/src/commands/multi-repo-test.js.map +1 -0
- package/dist/src/commands/setup-existing.d.ts.map +1 -1
- package/dist/src/commands/setup-existing.js +0 -1
- package/dist/src/commands/setup-existing.js.map +1 -1
- package/dist/src/commands/spec-archive.d.ts +17 -0
- package/dist/src/commands/spec-archive.d.ts.map +1 -0
- package/dist/src/commands/spec-archive.js +40 -0
- package/dist/src/commands/spec-archive.js.map +1 -0
- package/dist/src/commands/spec-list.d.ts +15 -0
- package/dist/src/commands/spec-list.d.ts.map +1 -0
- package/dist/src/commands/spec-list.js +55 -0
- package/dist/src/commands/spec-list.js.map +1 -0
- package/dist/vitest.config.d.ts.map +1 -1
- package/dist/vitest.config.js +32 -8
- package/dist/vitest.config.js.map +1 -1
- package/docs/michi-development/design/config-unification.md +4789 -0
- package/docs/user-guide/getting-started/github-token-setup.md +2 -1
- package/docs/user-guide/getting-started/new-repository-setup.md +1 -1
- package/docs/user-guide/getting-started/quick-start.md +1 -1
- package/docs/user-guide/getting-started/setup.md +4 -11
- package/docs/user-guide/guides/multi-repo-guide.md +591 -0
- package/docs/user-guide/guides/multi-repo-migration-guide.md +516 -0
- package/docs/user-guide/hands-on/claude-agent-setup.md +2 -2
- package/docs/user-guide/hands-on/claude-setup.md +2 -2
- package/docs/user-guide/hands-on/cursor-setup.md +2 -2
- package/docs/user-guide/hands-on/workflow-walkthrough.md +4 -1
- package/docs/user-guide/reference/multi-repo-api.md +771 -0
- package/docs/user-guide/reference/quick-reference.md +22 -37
- package/env.example +1 -1
- package/package.json +2 -5
- package/scripts/__tests__/config-loader-multi-repo.test.ts +342 -0
- package/scripts/__tests__/github-actions-client.test.ts +543 -0
- package/scripts/__tests__/health-check-service.test.ts +142 -0
- package/scripts/__tests__/markdown-to-confluence.test.ts +262 -0
- package/scripts/__tests__/mermaid-converter.test.ts +236 -0
- package/scripts/__tests__/multi-repo-config-schema.test.ts +335 -0
- package/scripts/__tests__/multi-repo-validator.test.ts +524 -0
- package/scripts/__tests__/spec-archiver.test.ts +512 -0
- package/scripts/__tests__/spec-impl-workflow.test.ts +5 -2
- package/scripts/__tests__/test-script-runner.test.ts +217 -0
- package/scripts/config/config-schema.ts +104 -0
- package/scripts/confluence-sync.ts +16 -2
- package/scripts/github-actions-client.ts +258 -0
- package/scripts/health-check-service.ts +171 -0
- package/scripts/markdown-to-confluence.ts +37 -6
- package/scripts/mermaid-converter.ts +56 -0
- package/scripts/pr-automation.ts +15 -5
- package/scripts/spec-impl-workflow.ts +22 -6
- package/scripts/template/__tests__/multi-repo-renderer.test.ts +261 -0
- package/scripts/template/multi-repo-renderer.ts +172 -0
- package/scripts/template/renderer.ts +5 -0
- package/scripts/test-execution-generator.ts +104 -11
- package/scripts/test-script-runner.ts +130 -0
- package/scripts/utils/__tests__/config-loader.test.ts +149 -0
- package/scripts/utils/__tests__/config-validator.test.ts +106 -6
- package/scripts/utils/__tests__/env-config.test.ts +0 -2
- package/scripts/utils/__tests__/multi-repo-validator.test.ts +335 -0
- package/scripts/utils/__tests__/project-meta.test.ts +192 -0
- package/scripts/utils/__tests__/security-validator.test.ts +272 -0
- package/scripts/utils/config-loader.ts +429 -56
- package/scripts/utils/env-config.ts +2 -14
- package/scripts/utils/multi-repo-validator.ts +141 -0
- package/scripts/utils/project-meta.ts +27 -0
- package/scripts/utils/security-validator.ts +286 -0
- package/scripts/utils/spec-archiver.ts +260 -0
- package/scripts/utils/spec-updater.ts +4 -0
- package/templates/claude/agents/pr-size-monitor/AGENT.md +330 -0
- package/templates/claude/commands/kiro/kiro-spec-impl.md +1 -1
- package/templates/claude/commands/michi/spec-impl.md +208 -35
- package/templates/claude-agent/commands/kiro/kiro-spec-impl.md +1 -1
- package/templates/cursor/commands/kiro/kiro-spec-impl.md +1 -1
- package/templates/multi-repo/docs/ci-status.md +51 -0
- package/templates/multi-repo/docs/release-notes.md +99 -0
- package/templates/multi-repo/overview/architecture.md +102 -0
- package/templates/multi-repo/overview/requirements.md +68 -0
- package/templates/multi-repo/overview/sequence.md +79 -0
- package/templates/multi-repo/steering/multi-repo.md +74 -0
- package/templates/multi-repo/tests/strategy.md +89 -0
- package/dist/scripts/__tests__/create-project.test.d.ts +0 -2
- package/dist/scripts/__tests__/create-project.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/create-project.test.js +0 -243
- package/dist/scripts/__tests__/create-project.test.js.map +0 -1
- package/dist/scripts/__tests__/jira-transitions.test.d.ts +0 -5
- package/dist/scripts/__tests__/jira-transitions.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/jira-transitions.test.js +0 -172
- package/dist/scripts/__tests__/jira-transitions.test.js.map +0 -1
- package/dist/scripts/__tests__/multi-project-estimate.test.d.ts +0 -2
- package/dist/scripts/__tests__/multi-project-estimate.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/multi-project-estimate.test.js +0 -118
- package/dist/scripts/__tests__/multi-project-estimate.test.js.map +0 -1
- package/dist/scripts/__tests__/setup-existing-project.test.d.ts +0 -2
- package/dist/scripts/__tests__/setup-existing-project.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/setup-existing-project.test.js +0 -208
- package/dist/scripts/__tests__/setup-existing-project.test.js.map +0 -1
- package/dist/scripts/__tests__/setup-interactive.test.d.ts +0 -2
- package/dist/scripts/__tests__/setup-interactive.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/setup-interactive.test.js +0 -166
- package/dist/scripts/__tests__/setup-interactive.test.js.map +0 -1
- package/dist/scripts/__tests__/spec-impl-workflow.test.d.ts +0 -5
- package/dist/scripts/__tests__/spec-impl-workflow.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/spec-impl-workflow.test.js +0 -321
- package/dist/scripts/__tests__/spec-impl-workflow.test.js.map +0 -1
- package/dist/scripts/__tests__/spec-loader.test.d.ts +0 -5
- package/dist/scripts/__tests__/spec-loader.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/spec-loader.test.js +0 -153
- package/dist/scripts/__tests__/spec-loader.test.js.map +0 -1
- package/dist/scripts/__tests__/validate-phase.test.d.ts +0 -5
- package/dist/scripts/__tests__/validate-phase.test.d.ts.map +0 -1
- package/dist/scripts/__tests__/validate-phase.test.js +0 -249
- package/dist/scripts/__tests__/validate-phase.test.js.map +0 -1
- package/dist/scripts/constants/__tests__/environments.test.d.ts +0 -2
- package/dist/scripts/constants/__tests__/environments.test.d.ts.map +0 -1
- package/dist/scripts/constants/__tests__/environments.test.js +0 -125
- package/dist/scripts/constants/__tests__/environments.test.js.map +0 -1
- package/dist/scripts/constants/__tests__/languages.test.d.ts +0 -2
- package/dist/scripts/constants/__tests__/languages.test.d.ts.map +0 -1
- package/dist/scripts/constants/__tests__/languages.test.js +0 -82
- package/dist/scripts/constants/__tests__/languages.test.js.map +0 -1
- package/dist/scripts/create-project.d.ts +0 -16
- package/dist/scripts/create-project.d.ts.map +0 -1
- package/dist/scripts/create-project.js +0 -334
- package/dist/scripts/create-project.js.map +0 -1
- package/dist/scripts/list-projects.d.ts +0 -7
- package/dist/scripts/list-projects.d.ts.map +0 -1
- package/dist/scripts/list-projects.js +0 -88
- package/dist/scripts/list-projects.js.map +0 -1
- package/dist/scripts/template/__tests__/renderer.test.d.ts +0 -2
- package/dist/scripts/template/__tests__/renderer.test.d.ts.map +0 -1
- package/dist/scripts/template/__tests__/renderer.test.js +0 -165
- package/dist/scripts/template/__tests__/renderer.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/aidlc-parser.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/aidlc-parser.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/aidlc-parser.test.js +0 -315
- package/dist/scripts/utils/__tests__/aidlc-parser.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/business-days.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/business-days.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/business-days.test.js +0 -171
- package/dist/scripts/utils/__tests__/business-days.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/config-loader.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/config-loader.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/config-loader.test.js +0 -201
- package/dist/scripts/utils/__tests__/config-loader.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/config-validator.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/config-validator.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/config-validator.test.js +0 -394
- package/dist/scripts/utils/__tests__/config-validator.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/env-config.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/env-config.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/env-config.test.js +0 -218
- package/dist/scripts/utils/__tests__/env-config.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/feature-name-validator.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/feature-name-validator.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/feature-name-validator.test.js +0 -106
- package/dist/scripts/utils/__tests__/feature-name-validator.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/jira-issue-type-fetcher.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/jira-issue-type-fetcher.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/jira-issue-type-fetcher.test.js +0 -202
- package/dist/scripts/utils/__tests__/jira-issue-type-fetcher.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/spec-updater.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/spec-updater.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/spec-updater.test.js +0 -158
- package/dist/scripts/utils/__tests__/spec-updater.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/tasks-converter.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/tasks-converter.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/tasks-converter.test.js +0 -500
- package/dist/scripts/utils/__tests__/tasks-converter.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/tasks-format-validator.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/tasks-format-validator.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/tasks-format-validator.test.js +0 -314
- package/dist/scripts/utils/__tests__/tasks-format-validator.test.js.map +0 -1
- package/dist/scripts/utils/__tests__/test-runner.test.d.ts +0 -5
- package/dist/scripts/utils/__tests__/test-runner.test.d.ts.map +0 -1
- package/dist/scripts/utils/__tests__/test-runner.test.js +0 -64
- package/dist/scripts/utils/__tests__/test-runner.test.js.map +0 -1
- package/dist/src/__tests__/cli.test.d.ts +0 -5
- package/dist/src/__tests__/cli.test.d.ts.map +0 -1
- package/dist/src/__tests__/cli.test.js +0 -58
- package/dist/src/__tests__/cli.test.js.map +0 -1
- package/dist/src/__tests__/integration/internationalization.test.d.ts +0 -8
- package/dist/src/__tests__/integration/internationalization.test.d.ts.map +0 -1
- package/dist/src/__tests__/integration/internationalization.test.js +0 -333
- package/dist/src/__tests__/integration/internationalization.test.js.map +0 -1
- package/dist/src/__tests__/integration/setup/claude-agent.test.d.ts +0 -5
- package/dist/src/__tests__/integration/setup/claude-agent.test.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/claude-agent.test.js +0 -122
- package/dist/src/__tests__/integration/setup/claude-agent.test.js.map +0 -1
- package/dist/src/__tests__/integration/setup/claude.test.d.ts +0 -5
- package/dist/src/__tests__/integration/setup/claude.test.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/claude.test.js +0 -193
- package/dist/src/__tests__/integration/setup/claude.test.js.map +0 -1
- package/dist/src/__tests__/integration/setup/cursor.test.d.ts +0 -5
- package/dist/src/__tests__/integration/setup/cursor.test.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/cursor.test.js +0 -166
- package/dist/src/__tests__/integration/setup/cursor.test.js.map +0 -1
- package/dist/src/__tests__/integration/setup/helpers/fs-assertions.d.ts +0 -32
- package/dist/src/__tests__/integration/setup/helpers/fs-assertions.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/helpers/fs-assertions.js +0 -72
- package/dist/src/__tests__/integration/setup/helpers/fs-assertions.js.map +0 -1
- package/dist/src/__tests__/integration/setup/helpers/test-project.d.ts +0 -38
- package/dist/src/__tests__/integration/setup/helpers/test-project.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/helpers/test-project.js +0 -83
- package/dist/src/__tests__/integration/setup/helpers/test-project.js.map +0 -1
- package/dist/src/__tests__/integration/setup/init.test.d.ts +0 -5
- package/dist/src/__tests__/integration/setup/init.test.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/init.test.js +0 -352
- package/dist/src/__tests__/integration/setup/init.test.js.map +0 -1
- package/dist/src/__tests__/integration/setup/validation.test.d.ts +0 -5
- package/dist/src/__tests__/integration/setup/validation.test.d.ts.map +0 -1
- package/dist/src/__tests__/integration/setup/validation.test.js +0 -301
- package/dist/src/__tests__/integration/setup/validation.test.js.map +0 -1
- package/scripts/create-project.ts +0 -386
- package/scripts/list-projects.ts +0 -112
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Repo template renderer
|
|
3
|
+
*
|
|
4
|
+
* Provides template rendering functionality for Multi-Repo projects
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { readFileSync } from 'fs';
|
|
8
|
+
import { resolve, relative, isAbsolute } from 'path';
|
|
9
|
+
import { renderTemplate, type TemplateContext } from './renderer.js';
|
|
10
|
+
|
|
11
|
+
export interface MultiRepoTemplateContext {
|
|
12
|
+
PROJECT_NAME: string;
|
|
13
|
+
JIRA_KEY: string;
|
|
14
|
+
CONFLUENCE_SPACE: string;
|
|
15
|
+
CREATED_AT: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create Multi-Repo template context
|
|
20
|
+
*
|
|
21
|
+
* @param projectName - Project name
|
|
22
|
+
* @param jiraKey - JIRA project key
|
|
23
|
+
* @param confluenceSpace - Confluence space key
|
|
24
|
+
* @param createdAt - Created timestamp (ISO 8601 format)
|
|
25
|
+
* @returns Multi-Repo template context
|
|
26
|
+
*/
|
|
27
|
+
export const createMultiRepoTemplateContext = (
|
|
28
|
+
projectName: string,
|
|
29
|
+
jiraKey: string,
|
|
30
|
+
confluenceSpace: string,
|
|
31
|
+
createdAt?: string
|
|
32
|
+
): MultiRepoTemplateContext => ({
|
|
33
|
+
PROJECT_NAME: projectName,
|
|
34
|
+
JIRA_KEY: jiraKey,
|
|
35
|
+
CONFLUENCE_SPACE: confluenceSpace,
|
|
36
|
+
CREATED_AT: createdAt || new Date().toISOString(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Load Multi-Repo template file
|
|
41
|
+
*
|
|
42
|
+
* Security: Path traversal prevention with three-layer validation:
|
|
43
|
+
* 1. Validate template name (no path separators)
|
|
44
|
+
* 2. Resolve absolute paths
|
|
45
|
+
* 3. Verify path containment
|
|
46
|
+
*
|
|
47
|
+
* @param templateName - Template name (e.g., "overview/requirements", "steering/multi-repo")
|
|
48
|
+
* @param projectRoot - Project root directory
|
|
49
|
+
* @returns Template content
|
|
50
|
+
* @throws {Error} If template file not found or path traversal detected
|
|
51
|
+
*/
|
|
52
|
+
export const loadMultiRepoTemplate = (
|
|
53
|
+
templateName: string,
|
|
54
|
+
projectRoot: string = process.cwd()
|
|
55
|
+
): string => {
|
|
56
|
+
// Security Layer 1: Validate template name
|
|
57
|
+
// Reject path traversal characters (../, ..\, absolute paths)
|
|
58
|
+
if (templateName.includes('..') || templateName.includes('\\')) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Invalid template name: ${templateName}\n` +
|
|
61
|
+
'Template name must not contain path traversal characters (\\, ..)'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Security Layer 2: Resolve absolute paths
|
|
66
|
+
const templateDir = resolve(projectRoot, 'templates', 'multi-repo');
|
|
67
|
+
const templatePath = resolve(templateDir, `${templateName}.md`);
|
|
68
|
+
|
|
69
|
+
// Security Layer 3: Verify path containment
|
|
70
|
+
const relativePath = relative(templateDir, templatePath);
|
|
71
|
+
if (relativePath.startsWith('..') || isAbsolute(relativePath)) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Invalid template path: ${templateName}\n` +
|
|
74
|
+
`Template path is outside template directory: ${templateDir}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
return readFileSync(templatePath, 'utf-8');
|
|
80
|
+
} catch (error) {
|
|
81
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Multi-Repo template not found: ${templateName}.md\n` +
|
|
84
|
+
`Path: ${templatePath}\n` +
|
|
85
|
+
`Error: ${errorMessage}`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Render Multi-Repo template with placeholder replacement
|
|
92
|
+
*
|
|
93
|
+
* @param template - Template string
|
|
94
|
+
* @param context - Multi-Repo template context
|
|
95
|
+
* @returns Rendered template string
|
|
96
|
+
*/
|
|
97
|
+
export const renderMultiRepoTemplate = (
|
|
98
|
+
template: string,
|
|
99
|
+
context: MultiRepoTemplateContext
|
|
100
|
+
): string => {
|
|
101
|
+
// Convert MultiRepoTemplateContext to TemplateContext
|
|
102
|
+
const templateContext: TemplateContext = {
|
|
103
|
+
LANG_CODE: 'ja', // Default language
|
|
104
|
+
DEV_GUIDELINES: '', // Not used for Multi-Repo templates
|
|
105
|
+
KIRO_DIR: '.kiro',
|
|
106
|
+
AGENT_DIR: '.claude',
|
|
107
|
+
PROJECT_NAME: context.PROJECT_NAME,
|
|
108
|
+
JIRA_KEY: context.JIRA_KEY,
|
|
109
|
+
CONFLUENCE_SPACE: context.CONFLUENCE_SPACE,
|
|
110
|
+
CREATED_AT: context.CREATED_AT,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return renderTemplate(template, templateContext);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Load and render Multi-Repo template
|
|
118
|
+
*
|
|
119
|
+
* @param templateName - Template name
|
|
120
|
+
* @param context - Multi-Repo template context
|
|
121
|
+
* @param projectRoot - Project root directory
|
|
122
|
+
* @returns Rendered template string
|
|
123
|
+
*/
|
|
124
|
+
export const loadAndRenderMultiRepoTemplate = (
|
|
125
|
+
templateName: string,
|
|
126
|
+
context: MultiRepoTemplateContext,
|
|
127
|
+
projectRoot: string = process.cwd()
|
|
128
|
+
): string => {
|
|
129
|
+
const template = loadMultiRepoTemplate(templateName, projectRoot);
|
|
130
|
+
return renderMultiRepoTemplate(template, context);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Batch render multiple Multi-Repo templates
|
|
135
|
+
*
|
|
136
|
+
* @param templateNames - Array of template names
|
|
137
|
+
* @param context - Multi-Repo template context
|
|
138
|
+
* @param projectRoot - Project root directory
|
|
139
|
+
* @returns Map of template names to rendered strings
|
|
140
|
+
*/
|
|
141
|
+
export const renderMultiRepoTemplates = (
|
|
142
|
+
templateNames: string[],
|
|
143
|
+
context: MultiRepoTemplateContext,
|
|
144
|
+
projectRoot: string = process.cwd()
|
|
145
|
+
): Record<string, string> => {
|
|
146
|
+
const rendered: Record<string, string> = {};
|
|
147
|
+
|
|
148
|
+
for (const templateName of templateNames) {
|
|
149
|
+
rendered[templateName] = loadAndRenderMultiRepoTemplate(
|
|
150
|
+
templateName,
|
|
151
|
+
context,
|
|
152
|
+
projectRoot
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return rendered;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* List of all Multi-Repo template names
|
|
161
|
+
*/
|
|
162
|
+
export const MULTI_REPO_TEMPLATES = [
|
|
163
|
+
'overview/requirements',
|
|
164
|
+
'overview/architecture',
|
|
165
|
+
'overview/sequence',
|
|
166
|
+
'steering/multi-repo',
|
|
167
|
+
'tests/strategy',
|
|
168
|
+
'docs/ci-status',
|
|
169
|
+
'docs/release-notes',
|
|
170
|
+
] as const;
|
|
171
|
+
|
|
172
|
+
export type MultiRepoTemplateName = typeof MULTI_REPO_TEMPLATES[number];
|
|
@@ -14,6 +14,11 @@ export interface TemplateContext {
|
|
|
14
14
|
PROJECT_ID?: string;
|
|
15
15
|
FEATURE_NAME?: string;
|
|
16
16
|
TIMESTAMP?: string;
|
|
17
|
+
// Multi-Repo specific placeholders
|
|
18
|
+
PROJECT_NAME?: string;
|
|
19
|
+
JIRA_KEY?: string;
|
|
20
|
+
CONFLUENCE_SPACE?: string;
|
|
21
|
+
CREATED_AT?: string;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
/**
|
|
@@ -6,6 +6,73 @@
|
|
|
6
6
|
import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync } from 'fs';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* セキュリティ: URLバリデーション
|
|
11
|
+
* HTTP/HTTPS URLのみ許可、特殊文字やコマンドインジェクションを防ぐ
|
|
12
|
+
*/
|
|
13
|
+
function validateUrl(url: string): void {
|
|
14
|
+
// 基本的なURL形式チェック
|
|
15
|
+
try {
|
|
16
|
+
const parsed = new URL(url);
|
|
17
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
18
|
+
throw new Error(`Invalid protocol: ${parsed.protocol}. Only http: and https: are allowed.`);
|
|
19
|
+
}
|
|
20
|
+
} catch (_error) {
|
|
21
|
+
throw new Error(`Invalid URL format: ${url}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// コマンドインジェクション対策: 危険な文字を検出
|
|
25
|
+
const dangerousChars = /[;`$()&|<>]/;
|
|
26
|
+
if (dangerousChars.test(url)) {
|
|
27
|
+
throw new Error(`URL contains dangerous characters: ${url}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* セキュリティ: Bash用文字列エスケープ
|
|
33
|
+
* シェルスクリプト内で安全に使用できる形式にエスケープ
|
|
34
|
+
*/
|
|
35
|
+
function escapeBash(str: string): string {
|
|
36
|
+
// シングルクォートで囲み、シングルクォート自体をエスケープ
|
|
37
|
+
return `'${str.replace(/'/g, '\'\\\'\'')}'`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* セキュリティ: Python用文字列エスケープ
|
|
42
|
+
* Pythonコード内で安全に使用できる形式にエスケープ
|
|
43
|
+
*/
|
|
44
|
+
function escapePython(str: string): string {
|
|
45
|
+
return str
|
|
46
|
+
.replace(/\\/g, '\\\\') // バックスラッシュ
|
|
47
|
+
.replace(/"/g, '\\"') // ダブルクォート
|
|
48
|
+
.replace(/\n/g, '\\n') // 改行
|
|
49
|
+
.replace(/\r/g, '\\r') // キャリッジリターン
|
|
50
|
+
.replace(/\t/g, '\\t'); // タブ
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* セキュリティ: Python識別子バリデーション
|
|
55
|
+
* Pythonのクラス名として有効な形式かチェック
|
|
56
|
+
*/
|
|
57
|
+
function validatePythonIdentifier(name: string): void {
|
|
58
|
+
// Python識別子のルール: 英字またはアンダースコアで始まり、英数字とアンダースコアのみ
|
|
59
|
+
const pythonIdentifierPattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
60
|
+
if (!pythonIdentifierPattern.test(name)) {
|
|
61
|
+
throw new Error(`Invalid Python identifier: ${name}. Must start with letter or underscore, and contain only letters, numbers, and underscores.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Pythonの予約語チェック
|
|
65
|
+
const pythonKeywords = [
|
|
66
|
+
'False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await',
|
|
67
|
+
'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
|
|
68
|
+
'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda',
|
|
69
|
+
'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'
|
|
70
|
+
];
|
|
71
|
+
if (pythonKeywords.includes(name)) {
|
|
72
|
+
throw new Error(`Invalid Python identifier: ${name} is a reserved keyword.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
9
76
|
/**
|
|
10
77
|
* テスト実行ファイルの生成オプション
|
|
11
78
|
*/
|
|
@@ -151,28 +218,47 @@ function generateLocustFile(
|
|
|
151
218
|
endpoint: { endpoint: string; method: string; baseUrl: string },
|
|
152
219
|
perfReqs: { targetRps: string; targetResponseTime: string }
|
|
153
220
|
): string {
|
|
221
|
+
// セキュリティ: URLバリデーション
|
|
222
|
+
validateUrl(endpoint.baseUrl);
|
|
223
|
+
|
|
224
|
+
// セキュリティ: Pythonエスケープ
|
|
225
|
+
const escapedFeature = escapePython(feature);
|
|
226
|
+
const escapedEndpoint = escapePython(endpoint.endpoint);
|
|
227
|
+
const escapedMethod = escapePython(endpoint.method);
|
|
228
|
+
const escapedBaseUrl = escapePython(endpoint.baseUrl);
|
|
229
|
+
const escapedTargetRps = escapePython(perfReqs.targetRps);
|
|
230
|
+
const escapedTargetResponseTime = escapePython(perfReqs.targetResponseTime);
|
|
231
|
+
|
|
232
|
+
// セキュリティ: Pythonクラス名の生成と検証
|
|
233
|
+
let className = feature.replace(/[^a-zA-Z0-9]/g, '_');
|
|
234
|
+
// クラス名は大文字で始まる必要がある(Python慣例)
|
|
235
|
+
if (!/^[A-Z]/.test(className)) {
|
|
236
|
+
className = 'Test' + className.charAt(0).toUpperCase() + className.slice(1);
|
|
237
|
+
}
|
|
238
|
+
// Python識別子として有効かチェック
|
|
239
|
+
validatePythonIdentifier(className);
|
|
240
|
+
|
|
154
241
|
const methodLower = endpoint.method.toLowerCase();
|
|
155
242
|
const hasBody = ['post', 'put', 'patch'].includes(methodLower);
|
|
156
|
-
const className = feature.replace(/[^a-zA-Z0-9]/g, '');
|
|
157
243
|
|
|
158
244
|
let taskCode = '';
|
|
159
245
|
if (hasBody) {
|
|
160
246
|
taskCode = ` self.client.${methodLower}(
|
|
161
|
-
"${
|
|
247
|
+
"${escapedEndpoint}",
|
|
162
248
|
json={},
|
|
163
249
|
headers={"Content-Type": "application/json"}
|
|
164
250
|
)`;
|
|
165
251
|
} else {
|
|
166
|
-
taskCode = ` self.client.${methodLower}("${
|
|
252
|
+
taskCode = ` self.client.${methodLower}("${escapedEndpoint}")`;
|
|
167
253
|
}
|
|
168
254
|
|
|
169
255
|
return `"""
|
|
170
|
-
${
|
|
171
|
-
自動生成: michi phase:run ${
|
|
256
|
+
${escapedFeature} 負荷テスト
|
|
257
|
+
自動生成: michi phase:run ${escapedFeature} phase-b
|
|
172
258
|
|
|
173
259
|
目標:
|
|
174
|
-
- RPS: ${
|
|
175
|
-
- 応答時間: ${
|
|
260
|
+
- RPS: ${escapedTargetRps}
|
|
261
|
+
- 応答時間: ${escapedTargetResponseTime}ms以内
|
|
176
262
|
"""
|
|
177
263
|
|
|
178
264
|
from locust import HttpUser, task, between
|
|
@@ -182,11 +268,11 @@ class ${className}User(HttpUser):
|
|
|
182
268
|
"""テスト対象ユーザーシミュレーション"""
|
|
183
269
|
|
|
184
270
|
wait_time = between(1, 3)
|
|
185
|
-
host = "${
|
|
271
|
+
host = "${escapedBaseUrl}"
|
|
186
272
|
|
|
187
273
|
@task
|
|
188
274
|
def test_endpoint(self):
|
|
189
|
-
"""${
|
|
275
|
+
"""${escapedEndpoint}への${escapedMethod}リクエスト"""
|
|
190
276
|
${taskCode}
|
|
191
277
|
|
|
192
278
|
|
|
@@ -369,14 +455,21 @@ function generateZapScript(
|
|
|
369
455
|
feature: string,
|
|
370
456
|
endpoint: { baseUrl: string }
|
|
371
457
|
): string {
|
|
458
|
+
// セキュリティ: URLバリデーション(コマンドインジェクション対策)
|
|
459
|
+
validateUrl(endpoint.baseUrl);
|
|
460
|
+
|
|
461
|
+
// セキュリティ: Bashエスケープ(追加の防御層)
|
|
462
|
+
const escapedUrl = escapeBash(endpoint.baseUrl);
|
|
463
|
+
const escapedFeature = escapeBash(feature);
|
|
464
|
+
|
|
372
465
|
return `#!/bin/bash
|
|
373
466
|
# OWASP ZAPセキュリティスキャン実行スクリプト
|
|
374
|
-
# 自動生成: michi phase:run ${
|
|
467
|
+
# 自動生成: michi phase:run ${escapedFeature} phase-b
|
|
375
468
|
|
|
376
469
|
set -e
|
|
377
470
|
|
|
378
471
|
# 変数定義
|
|
379
|
-
TARGET_URL
|
|
472
|
+
TARGET_URL=${escapedUrl}
|
|
380
473
|
CONFIG_FILE="zap-config.yaml"
|
|
381
474
|
REPORT_DIR="./reports"
|
|
382
475
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* テストスクリプトランナー
|
|
3
|
+
* Multi-Repoプロジェクトのテストスクリプトを実行
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* テストタイプ
|
|
11
|
+
*/
|
|
12
|
+
export type TestType = 'e2e' | 'integration' | 'performance';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* テスト実行結果
|
|
16
|
+
*/
|
|
17
|
+
export interface TestExecutionResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
exitCode: number;
|
|
20
|
+
executionTime: number; // 秒単位
|
|
21
|
+
outputPath: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* execSync実行時のエラー型
|
|
27
|
+
*/
|
|
28
|
+
interface ExecError extends Error {
|
|
29
|
+
status?: number;
|
|
30
|
+
stderr?: Buffer | string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* テストスクリプトランナー
|
|
35
|
+
*/
|
|
36
|
+
export class TestScriptRunner {
|
|
37
|
+
/**
|
|
38
|
+
* テストスクリプトを実行
|
|
39
|
+
*
|
|
40
|
+
* @param projectName プロジェクト名
|
|
41
|
+
* @param testType テストタイプ (e2e | integration | performance)
|
|
42
|
+
* @param projectRoot プロジェクトルートディレクトリ(デフォルト: process.cwd())
|
|
43
|
+
* @returns テスト実行結果
|
|
44
|
+
*/
|
|
45
|
+
async runTestScript(
|
|
46
|
+
projectName: string,
|
|
47
|
+
testType: TestType,
|
|
48
|
+
projectRoot: string = process.cwd()
|
|
49
|
+
): Promise<TestExecutionResult> {
|
|
50
|
+
// 1. テストスクリプトパスを生成
|
|
51
|
+
const scriptPath = join(
|
|
52
|
+
projectRoot,
|
|
53
|
+
'docs',
|
|
54
|
+
'michi',
|
|
55
|
+
projectName,
|
|
56
|
+
'tests',
|
|
57
|
+
'scripts',
|
|
58
|
+
`run-${testType}.sh`
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// 2. テスト結果の出力先パスを生成(スクリプト側で使用)
|
|
62
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').split('T')[0];
|
|
63
|
+
const outputPath = join(
|
|
64
|
+
projectRoot,
|
|
65
|
+
'docs',
|
|
66
|
+
'michi',
|
|
67
|
+
projectName,
|
|
68
|
+
'tests',
|
|
69
|
+
'results',
|
|
70
|
+
`${testType}-${timestamp}.log`
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// 3. 実行前のログ出力
|
|
74
|
+
console.log('🚀 テストスクリプトを実行中...');
|
|
75
|
+
console.log(` テストタイプ: ${testType}`);
|
|
76
|
+
console.log(` スクリプトパス: ${scriptPath}`);
|
|
77
|
+
console.log(` 実行開始時刻: ${new Date().toLocaleString('ja-JP', { timeZone: 'Asia/Tokyo' })}`);
|
|
78
|
+
|
|
79
|
+
// 4. テストスクリプトを実行
|
|
80
|
+
const startTime = Date.now();
|
|
81
|
+
let exitCode = 0;
|
|
82
|
+
let error: string | undefined;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
execSync(scriptPath, {
|
|
86
|
+
stdio: 'inherit', // リアルタイム出力
|
|
87
|
+
encoding: 'utf-8',
|
|
88
|
+
});
|
|
89
|
+
} catch (err) {
|
|
90
|
+
// スクリプト実行エラー
|
|
91
|
+
const execError = err as ExecError;
|
|
92
|
+
exitCode = execError.status !== undefined ? execError.status : 1;
|
|
93
|
+
error = execError.message;
|
|
94
|
+
|
|
95
|
+
// stderrがある場合は追加
|
|
96
|
+
if (execError.stderr) {
|
|
97
|
+
const stderrStr = execError.stderr.toString();
|
|
98
|
+
error = stderrStr || error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const endTime = Date.now();
|
|
103
|
+
const executionTime = (endTime - startTime) / 1000; // ミリ秒から秒に変換
|
|
104
|
+
|
|
105
|
+
// 5. 実行後のログ出力
|
|
106
|
+
console.log('\n📊 テスト実行結果:');
|
|
107
|
+
console.log(` 終了コード: ${exitCode}`);
|
|
108
|
+
console.log(` 実行時間: ${executionTime.toFixed(2)}秒`);
|
|
109
|
+
console.log(` テスト結果ファイル: ${outputPath}`);
|
|
110
|
+
|
|
111
|
+
const success = exitCode === 0;
|
|
112
|
+
|
|
113
|
+
if (success) {
|
|
114
|
+
console.log('✅ テスト実行が成功しました');
|
|
115
|
+
} else {
|
|
116
|
+
console.log('❌ テスト実行が失敗しました');
|
|
117
|
+
if (error) {
|
|
118
|
+
console.log(` エラー: ${error}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
success,
|
|
124
|
+
exitCode,
|
|
125
|
+
executionTime,
|
|
126
|
+
outputPath,
|
|
127
|
+
error,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
loadConfig,
|
|
11
11
|
getConfig,
|
|
12
12
|
getConfigPath,
|
|
13
|
+
getGlobalEnvPath,
|
|
13
14
|
clearConfigCache
|
|
14
15
|
} from '../config-loader.js';
|
|
15
16
|
|
|
@@ -32,6 +33,9 @@ describe('config-loader', () => {
|
|
|
32
33
|
// 環境変数をバックアップ
|
|
33
34
|
originalEnv = { ...process.env };
|
|
34
35
|
|
|
36
|
+
// HOMEディレクトリをテスト用に変更(グローバル設定の影響を排除)
|
|
37
|
+
process.env.HOME = testProjectRoot;
|
|
38
|
+
|
|
35
39
|
// キャッシュをクリア(クリーンな状態から開始)
|
|
36
40
|
clearConfigCache();
|
|
37
41
|
});
|
|
@@ -250,5 +254,150 @@ describe('config-loader', () => {
|
|
|
250
254
|
consoleWarnSpy.mockRestore();
|
|
251
255
|
});
|
|
252
256
|
});
|
|
257
|
+
|
|
258
|
+
describe('5層階層対応', () => {
|
|
259
|
+
describe('getGlobalEnvPath', () => {
|
|
260
|
+
it('~/.michi/.envのパスを返す', () => {
|
|
261
|
+
const envPath = getGlobalEnvPath();
|
|
262
|
+
expect(envPath).toBe(join(process.env.HOME as string, '.michi', '.env'));
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe('グローバル.envからの設定読み込み', () => {
|
|
267
|
+
it('グローバル.envからAtlassian設定を読み込む', () => {
|
|
268
|
+
clearConfigCache();
|
|
269
|
+
|
|
270
|
+
// ~/.michi/.env を作成
|
|
271
|
+
const globalEnvPath = join(testProjectRoot, '.michi', '.env');
|
|
272
|
+
writeFileSync(globalEnvPath, 'ATLASSIAN_URL=https://test.atlassian.net\n');
|
|
273
|
+
|
|
274
|
+
const config = loadConfig(testProjectRoot);
|
|
275
|
+
|
|
276
|
+
// グローバル.envの値が読み込まれることを確認
|
|
277
|
+
expect(config).toHaveProperty('atlassian');
|
|
278
|
+
// 注: 実装後に具体的なアサーションを追加
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('グローバル.envが存在しない場合でもエラーにならない', () => {
|
|
282
|
+
clearConfigCache();
|
|
283
|
+
|
|
284
|
+
// ~/.michi/.env を削除
|
|
285
|
+
const globalEnvPath = join(testProjectRoot, '.michi', '.env');
|
|
286
|
+
if (existsSync(globalEnvPath)) {
|
|
287
|
+
unlinkSync(globalEnvPath);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
expect(() => {
|
|
291
|
+
loadConfig(testProjectRoot);
|
|
292
|
+
}).not.toThrow();
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
describe('project.jsonからの設定読み込み', () => {
|
|
297
|
+
it('project.jsonからプロジェクトメタデータを読み込む', () => {
|
|
298
|
+
clearConfigCache();
|
|
299
|
+
|
|
300
|
+
// .kiro/project.json を作成
|
|
301
|
+
const projectJsonPath = join(testProjectRoot, '.kiro', 'project.json');
|
|
302
|
+
mkdirSync(join(testProjectRoot, '.kiro'), { recursive: true });
|
|
303
|
+
writeFileSync(projectJsonPath, JSON.stringify({
|
|
304
|
+
projectId: 'test-project',
|
|
305
|
+
projectName: 'Test Project',
|
|
306
|
+
jiraProjectKey: 'TP'
|
|
307
|
+
}));
|
|
308
|
+
|
|
309
|
+
const config = loadConfig(testProjectRoot);
|
|
310
|
+
|
|
311
|
+
// project.jsonの値が読み込まれることを確認
|
|
312
|
+
expect(config).toHaveProperty('project');
|
|
313
|
+
// 注: 実装後に具体的なアサーションを追加
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('project.jsonが存在しない場合でもエラーにならない', () => {
|
|
317
|
+
clearConfigCache();
|
|
318
|
+
|
|
319
|
+
// .kiro/project.json を削除
|
|
320
|
+
const projectJsonPath = join(testProjectRoot, '.kiro', 'project.json');
|
|
321
|
+
if (existsSync(projectJsonPath)) {
|
|
322
|
+
unlinkSync(projectJsonPath);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
expect(() => {
|
|
326
|
+
loadConfig(testProjectRoot);
|
|
327
|
+
}).not.toThrow();
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('優先順位の検証', () => {
|
|
332
|
+
it('プロジェクト.envがグローバル.envより優先される', () => {
|
|
333
|
+
clearConfigCache();
|
|
334
|
+
|
|
335
|
+
// グローバル.env
|
|
336
|
+
const globalEnvPath = join(testProjectRoot, '.michi', '.env');
|
|
337
|
+
writeFileSync(globalEnvPath, 'CONFLUENCE_PRD_SPACE=GLOBAL\n');
|
|
338
|
+
|
|
339
|
+
// プロジェクト.env
|
|
340
|
+
const projectEnvPath = join(testProjectRoot, '.env');
|
|
341
|
+
writeFileSync(projectEnvPath, 'CONFLUENCE_PRD_SPACE=PROJECT\n');
|
|
342
|
+
|
|
343
|
+
const config = loadConfig(testProjectRoot);
|
|
344
|
+
|
|
345
|
+
// プロジェクト.envの値が優先されることを確認
|
|
346
|
+
expect(config.confluence?.spaces?.requirements).toBe('PROJECT');
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
describe('キャッシュ無効化', () => {
|
|
351
|
+
it('グローバル.envを変更するとキャッシュが無効化される', async () => {
|
|
352
|
+
clearConfigCache();
|
|
353
|
+
|
|
354
|
+
// 最初の設定
|
|
355
|
+
const globalEnvPath = join(testProjectRoot, '.michi', '.env');
|
|
356
|
+
writeFileSync(globalEnvPath, 'CONFLUENCE_PRD_SPACE=INITIAL\n');
|
|
357
|
+
|
|
358
|
+
const config1 = getConfig(testProjectRoot);
|
|
359
|
+
|
|
360
|
+
// ファイルシステムのmtime精度を考慮して少し待つ
|
|
361
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
362
|
+
|
|
363
|
+
// 設定を更新
|
|
364
|
+
writeFileSync(globalEnvPath, 'CONFLUENCE_PRD_SPACE=UPDATED\n');
|
|
365
|
+
|
|
366
|
+
const config2 = getConfig(testProjectRoot);
|
|
367
|
+
|
|
368
|
+
// 異なる値が返されることを確認(キャッシュが無効化された)
|
|
369
|
+
expect(config1.confluence?.spaces?.requirements).toBe('INITIAL');
|
|
370
|
+
expect(config2.confluence?.spaces?.requirements).toBe('UPDATED');
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('project.jsonを変更するとキャッシュが無効化される', async () => {
|
|
374
|
+
clearConfigCache();
|
|
375
|
+
|
|
376
|
+
// 最初の設定
|
|
377
|
+
const projectJsonPath = join(testProjectRoot, '.kiro', 'project.json');
|
|
378
|
+
mkdirSync(join(testProjectRoot, '.kiro'), { recursive: true });
|
|
379
|
+
writeFileSync(projectJsonPath, JSON.stringify({
|
|
380
|
+
projectId: 'initial-id',
|
|
381
|
+
projectName: 'Initial Name'
|
|
382
|
+
}));
|
|
383
|
+
|
|
384
|
+
const config1 = getConfig(testProjectRoot);
|
|
385
|
+
|
|
386
|
+
// ファイルシステムのmtime精度を考慮して少し待つ
|
|
387
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
388
|
+
|
|
389
|
+
// 設定を更新
|
|
390
|
+
writeFileSync(projectJsonPath, JSON.stringify({
|
|
391
|
+
projectId: 'updated-id',
|
|
392
|
+
projectName: 'Updated Name'
|
|
393
|
+
}));
|
|
394
|
+
|
|
395
|
+
const config2 = getConfig(testProjectRoot);
|
|
396
|
+
|
|
397
|
+
// 異なるオブジェクトが返されることを確認(キャッシュが無効化された)
|
|
398
|
+
expect(config1).not.toBe(config2);
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
});
|
|
253
402
|
});
|
|
254
403
|
|