@yandy-r/ycc-opencode 0.0.0-stage → 6.0.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/AGENTS.md +38 -0
- package/LICENSE +21 -0
- package/README.md +41 -2
- package/agents/ansible-automation-expert.md +115 -0
- package/agents/api-docs-expert.md +146 -0
- package/agents/api-documenter.md +105 -0
- package/agents/architect.md +264 -0
- package/agents/architecture-analyst.md +99 -0
- package/agents/backport-conflict-resolver.md +134 -0
- package/agents/cloudflare-architect.md +85 -0
- package/agents/cloudflare-developer.md +196 -0
- package/agents/code-architect.md +101 -0
- package/agents/code-documenter.md +114 -0
- package/agents/code-explorer.md +99 -0
- package/agents/code-finder.md +83 -0
- package/agents/code-researcher.md +102 -0
- package/agents/code-reviewer.md +268 -0
- package/agents/code-simplifier.md +77 -0
- package/agents/codebase-advisor.md +130 -0
- package/agents/db-modifier.md +235 -0
- package/agents/docs-git-committer.md +220 -0
- package/agents/documentation-writer.md +92 -0
- package/agents/feature-researcher.md +121 -0
- package/agents/feature-writer.md +89 -0
- package/agents/frontend-ui-developer.md +98 -0
- package/agents/git-cleanup.md +173 -0
- package/agents/go-api-architect.md +172 -0
- package/agents/go-expert-architect.md +147 -0
- package/agents/implementor.md +167 -0
- package/agents/library-docs-writer.md +128 -0
- package/agents/nextjs-ux-ui-expert.md +127 -0
- package/agents/nodejs-backend-architect.md +112 -0
- package/agents/nodejs-backend-developer.md +184 -0
- package/agents/planner.md +257 -0
- package/agents/pr-comment-fixer.md +284 -0
- package/agents/practices-researcher.md +80 -0
- package/agents/project-file-cleaner.md +140 -0
- package/agents/prp-researcher.md +231 -0
- package/agents/python-developer.md +171 -0
- package/agents/python-expert-architect.md +188 -0
- package/agents/readme-generator.md +100 -0
- package/agents/release-fix-applier.md +194 -0
- package/agents/releaser.md +147 -0
- package/agents/research-specialist.md +106 -0
- package/agents/reverse-proxy-architect.md +131 -0
- package/agents/review-fixer.md +264 -0
- package/agents/root-cause-analyzer.md +105 -0
- package/agents/rust-build-resolver.md +183 -0
- package/agents/rust-expert-architect.md +149 -0
- package/agents/rust-reviewer.md +126 -0
- package/agents/sql-database-developer.md +195 -0
- package/agents/systems-engineering-expert.md +203 -0
- package/agents/terraform-architect.md +109 -0
- package/agents/terraform-developer.md +229 -0
- package/agents/test-strategy-planner.md +126 -0
- package/agents/turso-database-architect.md +139 -0
- package/agents/typescript-developer.md +170 -0
- package/agents/typescript-expert-architect.md +167 -0
- package/index.js +260 -0
- package/package.json +35 -4
- package/registration.json +4384 -0
- package/shared/references/agent-native-setup.md +121 -0
- package/shared/references/branch-prep.md +31 -0
- package/shared/references/branching-model.md +162 -0
- package/shared/references/ci-monitoring.md +445 -0
- package/shared/references/forge-detection.md +162 -0
- package/shared/references/goal-pairing.md +53 -0
- package/shared/references/pr-base-and-backport.md +143 -0
- package/shared/references/review-artifact-format.md +141 -0
- package/shared/references/review-checklist.md +161 -0
- package/shared/references/review-dispatch.md +71 -0
- package/shared/references/session-state.md +159 -0
- package/shared/references/standalone-dispatch.md +298 -0
- package/shared/references/target-capability-matrix.md +325 -0
- package/shared/references/visual-mode.md +155 -0
- package/shared/references/worktree-strategy.md +310 -0
- package/shared/scripts/backport-audit.sh +283 -0
- package/shared/scripts/ci-monitor.sh +637 -0
- package/shared/scripts/lib/backport-lib.sh +47 -0
- package/shared/scripts/lib/ci-classify.sh +103 -0
- package/shared/scripts/lib/forge.sh +264 -0
- package/shared/scripts/lib/release-state-lib.sh +300 -0
- package/shared/scripts/list-worktrees.sh +178 -0
- package/shared/scripts/merge-children.sh +82 -0
- package/shared/scripts/move-plan-to-worktree.sh +231 -0
- package/shared/scripts/pr-guard.sh +283 -0
- package/shared/scripts/prepare-feature-branch.sh +326 -0
- package/shared/scripts/release-ci-monitor.sh +671 -0
- package/shared/scripts/release-state-update.sh +216 -0
- package/shared/scripts/release-state.sh +178 -0
- package/shared/scripts/report-bundle-drift.sh +343 -0
- package/shared/scripts/require-python.sh +17 -0
- package/shared/scripts/resolve-plans-dir.sh +262 -0
- package/shared/scripts/rules-pointer.sh +20 -0
- package/shared/scripts/rules_pointer.py +267 -0
- package/shared/scripts/setup-worktree.sh +288 -0
- package/shared/scripts/validate-file-paths.sh +249 -0
- package/shared/scripts/visual-egress-guard.sh +303 -0
- package/shared/scripts/visual-recap-collect.sh +247 -0
- package/shared/scripts/worktree-paths.sh +86 -0
- package/skills/backport/SKILL.md +291 -0
- package/skills/backport/scripts/cherry-pick-pr.sh +232 -0
- package/skills/backport/scripts/find-pending.sh +199 -0
- package/skills/blueprint/SKILL.md +410 -0
- package/skills/blueprint/references/bootstrap-mapping.md +87 -0
- package/skills/bundle-author/SKILL.md +119 -0
- package/skills/bundle-author/references/surface-map.md +128 -0
- package/skills/bundle-author/references/templates/agent-template.md +21 -0
- package/skills/bundle-author/references/templates/skill-template.md +36 -0
- package/skills/bundle-author/references/when-not-to-scaffold.md +85 -0
- package/skills/bundle-author/scripts/scaffold-skill.sh +156 -0
- package/skills/bundle-release/SKILL.md +188 -0
- package/skills/bundle-release/references/release-checklist.md +196 -0
- package/skills/bundle-release/references/release-notes-template.md +48 -0
- package/skills/bundle-release/references/version-policy.md +150 -0
- package/skills/bundle-release/scripts/bump-version.sh +97 -0
- package/skills/bundle-release/scripts/draft-notes.sh +222 -0
- package/skills/bundle-release/scripts/preflight.sh +164 -0
- package/skills/bundle-release/scripts/release_versions.py +361 -0
- package/skills/clean/SKILL.md +107 -0
- package/skills/clean/references/agent-prompts.md +199 -0
- package/skills/clean/references/safety-config.md +125 -0
- package/skills/clean/scripts/detect-project-type.sh +423 -0
- package/skills/clean/scripts/generate-report.sh +245 -0
- package/skills/clean/scripts/validate-safety.sh +401 -0
- package/skills/code-report/SKILL.md +375 -0
- package/skills/code-report/scripts/check-prerequisites.sh +65 -0
- package/skills/code-report/templates/report-structure.md +202 -0
- package/skills/code-review/SKILL.md +153 -0
- package/skills/code-review/references/pr-procedure.md +311 -0
- package/skills/compatibility-audit/SKILL.md +226 -0
- package/skills/compatibility-audit/references/reading-the-report.md +159 -0
- package/skills/compatibility-audit/scripts/audit-install-assumptions.sh +372 -0
- package/skills/compatibility-audit/scripts/audit-target-features.sh +558 -0
- package/skills/deep-research/SKILL.md +251 -0
- package/skills/deep-research/references/analysis-prompts.md +702 -0
- package/skills/deep-research/references/completion-summary-template.md +66 -0
- package/skills/deep-research/references/persona-analogical.md +159 -0
- package/skills/deep-research/references/persona-archaeological.md +69 -0
- package/skills/deep-research/references/persona-contrarian.md +155 -0
- package/skills/deep-research/references/persona-futurist.md +70 -0
- package/skills/deep-research/references/persona-historical.md +142 -0
- package/skills/deep-research/references/persona-journalistic.md +69 -0
- package/skills/deep-research/references/persona-negative-space.md +70 -0
- package/skills/deep-research/references/persona-systems.md +69 -0
- package/skills/deep-research/references/synthesis-template.md +569 -0
- package/skills/deep-research/references/verification-log-template.md +32 -0
- package/skills/deep-research/scripts/check-prerequisites.sh +153 -0
- package/skills/deep-research/scripts/validate-research.sh +244 -0
- package/skills/feature-research/SKILL.md +292 -0
- package/skills/feature-research/scripts/validate-research.sh +159 -0
- package/skills/feature-research/scripts/validate-spec.sh +270 -0
- package/skills/feature-research/templates/research-agents.md +569 -0
- package/skills/feature-research/templates/spec-structure.md +437 -0
- package/skills/formatters/SKILL.md +207 -0
- package/skills/formatters/references/best-practices.md +78 -0
- package/skills/formatters/references/flag-reference.md +178 -0
- package/skills/formatters/references/stack-detection.md +119 -0
- package/skills/formatters/references/templates/husky-pre-commit.tmpl +13 -0
- package/skills/formatters/references/templates/justfile-snippet.just.tmpl +31 -0
- package/skills/formatters/references/templates/lefthook.yml.tmpl +22 -0
- package/skills/formatters/references/templates/lint-autofix.yml.tmpl +94 -0
- package/skills/formatters/references/templates/lint.yml.tmpl +85 -0
- package/skills/formatters/references/templates/makefile-snippet.mk.tmpl +34 -0
- package/skills/formatters/references/templates/package-json-scripts.json.tmpl +14 -0
- package/skills/formatters/references/templates/readme-section.md.tmpl +118 -0
- package/skills/formatters/scripts/apply-aliases.sh +245 -0
- package/skills/formatters/scripts/apply-ci.sh +136 -0
- package/skills/formatters/scripts/apply-docs.sh +187 -0
- package/skills/formatters/scripts/apply-hooks.sh +261 -0
- package/skills/formatters/scripts/bundle/format.sh +15 -0
- package/skills/formatters/scripts/bundle/go-tools.sh +119 -0
- package/skills/formatters/scripts/bundle/init-formatters.sh +517 -0
- package/skills/formatters/scripts/bundle/install-shellcheck.sh +85 -0
- package/skills/formatters/scripts/bundle/lib/excludes.sh +179 -0
- package/skills/formatters/scripts/bundle/lib/modified-files.sh +222 -0
- package/skills/formatters/scripts/bundle/lib/shellcheck-resolve.sh +81 -0
- package/skills/formatters/scripts/bundle/lib/shellcheck-version.sh +5 -0
- package/skills/formatters/scripts/bundle/lint.sh +15 -0
- package/skills/formatters/scripts/bundle/style.sh +1410 -0
- package/skills/formatters/scripts/bundle/templates/biome.json +81 -0
- package/skills/formatters/scripts/bundle/templates/clippy.toml +2 -0
- package/skills/formatters/scripts/bundle/templates/markdownlint.json +14 -0
- package/skills/formatters/scripts/bundle/templates/markdownlintignore +38 -0
- package/skills/formatters/scripts/bundle/templates/prettierignore +45 -0
- package/skills/formatters/scripts/bundle/templates/prettierrc.json +11 -0
- package/skills/formatters/scripts/bundle/templates/python-pyproject.toml +80 -0
- package/skills/formatters/scripts/bundle/templates/rustfmt.toml +41 -0
- package/skills/formatters/scripts/bundle/templates/tsconfig.json +21 -0
- package/skills/formatters/scripts/profile-style.sh +264 -0
- package/skills/frontend-design/SKILL.md +151 -0
- package/skills/frontend-patterns/SKILL.md +66 -0
- package/skills/frontend-patterns/references/animation.md +21 -0
- package/skills/frontend-patterns/references/components-and-state.md +40 -0
- package/skills/frontend-patterns/references/data-and-performance.md +34 -0
- package/skills/frontend-patterns/references/forms-errors-a11y.md +35 -0
- package/skills/git-cleanup/SKILL.md +286 -0
- package/skills/git-cleanup/references/active-code-rules.md +318 -0
- package/skills/git-cleanup/references/host-detection.md +217 -0
- package/skills/git-workflow/SKILL.md +130 -0
- package/skills/git-workflow/references/ci-monitoring-phase.md +130 -0
- package/skills/git-workflow/references/commit-phases.md +247 -0
- package/skills/git-workflow/references/examples-and-troubleshooting.md +47 -0
- package/skills/git-workflow/references/goal-pairing.md +23 -0
- package/skills/git-workflow/references/pr-creation.md +269 -0
- package/skills/git-workflow/scripts/analyze-changes.sh +266 -0
- package/skills/git-workflow/scripts/create-pr.sh +464 -0
- package/skills/git-workflow/scripts/validate-commit.sh +235 -0
- package/skills/git-workflow/templates/agent-prompts.md +518 -0
- package/skills/git-workflow/templates/commit-types.md +504 -0
- package/skills/git-workflow/templates/documentation-decision.md +509 -0
- package/skills/git-workflow/templates/pr-template.md +772 -0
- package/skills/go-patterns/SKILL.md +89 -0
- package/skills/go-patterns/references/design-and-tooling.md +336 -0
- package/skills/go-patterns/references/errors-and-concurrency.md +292 -0
- package/skills/go-testing/SKILL.md +133 -0
- package/skills/go-testing/references/advanced-testing.md +349 -0
- package/skills/go-testing/references/test-structure.md +277 -0
- package/skills/hooks-workflow/SKILL.md +232 -0
- package/skills/hooks-workflow/references/support-notes.md +134 -0
- package/skills/hooks-workflow/references/templates/claude-settings.json.tmpl +13 -0
- package/skills/hooks-workflow/references/templates/codex-config-fragment.toml.tmpl +9 -0
- package/skills/hooks-workflow/references/templates/cursor-rule-fragment.mdc.tmpl +16 -0
- package/skills/hooks-workflow/scripts/build-hook-config.sh +487 -0
- package/skills/hooks-workflow/scripts/verify-hooks.sh +257 -0
- package/skills/implement-plan/SKILL.md +221 -0
- package/skills/implement-plan/references/agent-task-prompt.md +214 -0
- package/skills/implement-plan/references/output-formats.md +150 -0
- package/skills/implement-plan/references/plan-inputs.md +126 -0
- package/skills/implement-plan/scripts/check-prerequisites.sh +78 -0
- package/skills/implement-plan/scripts/parse-dependencies.sh +206 -0
- package/skills/init/SKILL.md +272 -0
- package/skills/init/references/conventional-commits.md +114 -0
- package/skills/init/references/flag-reference.md +236 -0
- package/skills/init/references/label-taxonomy.md +115 -0
- package/skills/init/references/project-profile-heuristics.md +156 -0
- package/skills/init/references/template-library.md +129 -0
- package/skills/init/scripts/count-source-files.sh +60 -0
- package/skills/init/scripts/generate-agent-catalog.sh +193 -0
- package/skills/init/scripts/generate-mcp-catalog.sh +214 -0
- package/skills/init/scripts/migrate-rules.py +459 -0
- package/skills/init/scripts/migrate-rules.sh +26 -0
- package/skills/init/scripts/profile-project.sh +453 -0
- package/skills/init/scripts/render-template.py +226 -0
- package/skills/init/scripts/render-template.sh +25 -0
- package/skills/init/scripts/rules-report.sh +31 -0
- package/skills/init/scripts/rules_file_lib.py +41 -0
- package/skills/init/templates/AGENTS.md.tmpl +38 -0
- package/skills/init/templates/CLAUDE.md.tmpl +7 -0
- package/skills/init/templates/ai-rule.md.tmpl +3 -0
- package/skills/init/templates/cursor-rule.mdc.tmpl +7 -0
- package/skills/init/templates/git/commitlint.config.cjs.tmpl +40 -0
- package/skills/init/templates/git/gitignore.tmpl +120 -0
- package/skills/init/templates/git/gitmessage.tmpl +27 -0
- package/skills/init/templates/git/install-lefthook.sh.tmpl +131 -0
- package/skills/init/templates/git/lefthook-usage.md.tmpl +101 -0
- package/skills/init/templates/git/lefthook.yml.tmpl +64 -0
- package/skills/init/templates/github/bug_report.yml.tmpl +78 -0
- package/skills/init/templates/github/config.yml.tmpl +5 -0
- package/skills/init/templates/github/copilot-instructions.md.tmpl +24 -0
- package/skills/init/templates/github/docs_request.yml.tmpl +41 -0
- package/skills/init/templates/github/feature_request.yml.tmpl +59 -0
- package/skills/init/templates/github/labels.md.tmpl +75 -0
- package/skills/init/templates/github/pull_request_template.md.tmpl +66 -0
- package/skills/init/templates/github/workflows/pr-title-autofix.yml.tmpl +101 -0
- package/skills/init/templates/github/workflows/pr-title.yml.tmpl +55 -0
- package/skills/init/templates/workspace-report.md +83 -0
- package/skills/orchestrate/SKILL.md +165 -0
- package/skills/orchestrate/references/agent-catalog.md +601 -0
- package/skills/orchestrate/references/agent-prompts.md +495 -0
- package/skills/orchestrate/references/dispatch-playbook.md +333 -0
- package/skills/orchestrate/references/task-breakdown.md +410 -0
- package/skills/orchestrate/scripts/analyze-task.sh +139 -0
- package/skills/orchestrate/scripts/summarize-results.sh +160 -0
- package/skills/orchestrate/scripts/validate-agents.sh +92 -0
- package/skills/parallel-plan/SKILL.md +124 -0
- package/skills/plan/SKILL.md +134 -0
- package/skills/plan/references/enhanced-personas.md +131 -0
- package/skills/plan/references/personas-and-merge.md +77 -0
- package/skills/plan/references/plan-validation.md +65 -0
- package/skills/plan/references/planner-prompts.md +68 -0
- package/skills/plan/references/planning-tracks.md +73 -0
- package/skills/plan-workflow/SKILL.md +406 -0
- package/skills/plan-workflow/references/checkpoint-messages.md +370 -0
- package/skills/plan-workflow/references/plan-structure.md +238 -0
- package/skills/plan-workflow/references/planning-agents.md +511 -0
- package/skills/plan-workflow/references/research-agents-optimized.md +348 -0
- package/skills/plan-workflow/references/research-agents.md +436 -0
- package/skills/plan-workflow/references/shared-structure.md +152 -0
- package/skills/plan-workflow/references/validation-agents.md +363 -0
- package/skills/plan-workflow/scripts/check-prerequisites.sh +65 -0
- package/skills/plan-workflow/scripts/check-state.sh +190 -0
- package/skills/plan-workflow/scripts/persist-or-fail.sh +135 -0
- package/skills/plan-workflow/scripts/validate-analysis-artifacts.sh +216 -0
- package/skills/plan-workflow/scripts/validate-research-artifacts.sh +225 -0
- package/skills/plan-workflow/scripts/validate-shared.sh +229 -0
- package/skills/plan-workflow/scripts/validate-workflow-plan.sh +256 -0
- package/skills/pr-autofix/SKILL.md +307 -0
- package/skills/pr-autofix/references/ci-loop.md +64 -0
- package/skills/pr-autofix/references/comment-sources.md +197 -0
- package/skills/pr-autofix/references/data-shapes.md +87 -0
- package/skills/pr-autofix/references/goal-example.md +30 -0
- package/skills/pr-autofix/references/output-templates.md +162 -0
- package/skills/pr-autofix/references/prompt-injection-safety.md +165 -0
- package/skills/pr-autofix/references/related-skills.md +11 -0
- package/skills/pr-autofix/references/severity-mapping.md +146 -0
- package/skills/pr-autofix/scripts/fetch-pr-comments.sh +364 -0
- package/skills/pr-autofix/scripts/post-summary.sh +226 -0
- package/skills/pr-autofix/scripts/resolve-thread.sh +251 -0
- package/skills/prp-commit/SKILL.md +128 -0
- package/skills/prp-implement/SKILL.md +177 -0
- package/skills/prp-implement/references/agent-task-prompt.md +36 -0
- package/skills/prp-implement/references/detection.md +49 -0
- package/skills/prp-implement/references/dry-run.md +0 -0
- package/skills/prp-implement/references/report-output.md +204 -0
- package/skills/prp-implement/references/validation-and-failures.md +118 -0
- package/skills/prp-plan/SKILL.md +323 -0
- package/skills/prp-plan/references/enhanced-researchers.md +425 -0
- package/skills/prp-plan/references/parallel-additions.md +56 -0
- package/skills/prp-plan/references/plan-template.md +264 -0
- package/skills/prp-plan/references/synthesis-map.md +25 -0
- package/skills/prp-plan/scripts/preflight-enhanced-agents.sh +111 -0
- package/skills/prp-plan/scripts/validate-prp-plan.sh +368 -0
- package/skills/prp-pr/SKILL.md +402 -0
- package/skills/prp-prd/SKILL.md +442 -0
- package/skills/prp-spec/SKILL.md +274 -0
- package/skills/python-patterns/SKILL.md +103 -0
- package/skills/python-patterns/references/core-idioms.md +304 -0
- package/skills/python-patterns/references/design-and-tooling.md +407 -0
- package/skills/python-testing/SKILL.md +114 -0
- package/skills/python-testing/references/mocking-and-integration.md +395 -0
- package/skills/python-testing/references/pytest-core.md +366 -0
- package/skills/quick-fix/SKILL.md +246 -0
- package/skills/quick-review/SKILL.md +304 -0
- package/skills/release-model/SKILL.md +231 -0
- package/skills/release-model/references/pointer-and-labels.md +83 -0
- package/skills/release-model/references/signals-and-proposal.md +68 -0
- package/skills/release-model/references/template-placeholders.md +42 -0
- package/skills/release-model/references/upgrade-and-audit.md +131 -0
- package/skills/release-model/scripts/collect-signals.sh +459 -0
- package/skills/release-model/scripts/pointer-targets.sh +29 -0
- package/skills/release-model/templates/RELEASING.md.tmpl +151 -0
- package/skills/releaser/SKILL.md +251 -0
- package/skills/releaser/references/ci-optimization-checklist.md +149 -0
- package/skills/releaser/references/ci-templates/docker-release.yml +88 -0
- package/skills/releaser/references/ci-templates/generic-release.yml +69 -0
- package/skills/releaser/references/ci-templates/go-release.yml +50 -0
- package/skills/releaser/references/ci-templates/node-release.yml +126 -0
- package/skills/releaser/references/ci-templates/python-release.yml +95 -0
- package/skills/releaser/references/ci-templates/rust-release.yml +128 -0
- package/skills/releaser/references/ci-workflow-modes.md +42 -0
- package/skills/releaser/references/goal-pairing.md +37 -0
- package/skills/releaser/references/output-templates.md +143 -0
- package/skills/releaser/references/project-type-matrix.md +144 -0
- package/skills/releaser/references/release-branches.md +138 -0
- package/skills/releaser/references/release-ci-loop.md +249 -0
- package/skills/releaser/references/release-notes-template.md +42 -0
- package/skills/releaser/references/release-preparation.md +210 -0
- package/skills/releaser/scripts/check-release-branch.sh +235 -0
- package/skills/releaser/scripts/detect-project.sh +234 -0
- package/skills/releaser/scripts/draft-changelog.sh +387 -0
- package/skills/releaser/scripts/publish-release.sh +302 -0
- package/skills/research-to-issues/SKILL.md +285 -0
- package/skills/research-to-issues/references/label-taxonomy.md +48 -0
- package/skills/research-to-issues/references/parse-deep-research.md +86 -0
- package/skills/research-to-issues/references/parse-feature-spec.md +143 -0
- package/skills/research-to-issues/references/parse-parallel-plan.md +124 -0
- package/skills/research-to-issues/references/parse-prd.md +184 -0
- package/skills/research-to-issues/references/parse-prp-plan.md +237 -0
- package/skills/research-to-issues/references/plan-display-format.md +136 -0
- package/skills/research-to-issues/scripts/validate-prerequisites.sh +312 -0
- package/skills/research-to-issues/templates/feature-issue.md +131 -0
- package/skills/research-to-issues/templates/task-issue.md +104 -0
- package/skills/research-to-issues/templates/tracking-issue.md +126 -0
- package/skills/resume-session/SKILL.md +152 -0
- package/skills/review-fix/SKILL.md +229 -0
- package/skills/review-fix/references/fix-report.md +121 -0
- package/skills/review-fix/references/fixer-dispatch.md +79 -0
- package/skills/review-fix/references/plan.md +119 -0
- package/skills/rust-patterns/SKILL.md +85 -0
- package/skills/rust-patterns/references/concurrency-unsafe-modules.md +243 -0
- package/skills/rust-patterns/references/ownership-errors-types.md +262 -0
- package/skills/rust-testing/SKILL.md +99 -0
- package/skills/rust-testing/references/advanced-testing.md +247 -0
- package/skills/rust-testing/references/unit-and-integration.md +193 -0
- package/skills/save-session/SKILL.md +159 -0
- package/skills/shared-context/SKILL.md +101 -0
- package/skills/ts-patterns/SKILL.md +159 -0
- package/skills/ts-patterns/references/async-runtimes-tooling.md +375 -0
- package/skills/ts-patterns/references/types-errors-modules.md +336 -0
- package/skills/ts-testing/SKILL.md +151 -0
- package/skills/ts-testing/references/advanced-testing.md +350 -0
- package/skills/ts-testing/references/vitest-core.md +318 -0
- package/skills/visual-plan/SKILL.md +221 -0
- package/skills/visual-plan/references/canvas.md +132 -0
- package/skills/visual-plan/references/document-quality.md +178 -0
- package/skills/visual-plan/references/exemplar.md +120 -0
- package/skills/visual-plan/references/wireframe.md +212 -0
- package/skills/visual-plan/scripts/derive-visual-dir.sh +77 -0
- package/skills/visual-recap/SKILL.md +238 -0
- package/skills/visual-recap/references/wireframe.md +237 -0
- package/skills/write-docs/SKILL.md +354 -0
- package/skills/write-docs/scripts/audit-documentation.sh +190 -0
- package/skills/write-docs/scripts/generate-doc-index.sh +125 -0
- package/skills/write-docs/scripts/verify-links.sh +81 -0
- package/skills/write-docs/templates/docs-readme.md +34 -0
- package/skills/write-docs/templates/documentation-strategy.md +91 -0
|
@@ -0,0 +1,1410 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
|
5
|
+
while [[ -L "$SCRIPT_PATH" ]]; do
|
|
6
|
+
SCRIPT_BASE_DIR="$(cd -P "$(dirname "$SCRIPT_PATH")" >/dev/null 2>&1 && pwd)"
|
|
7
|
+
SCRIPT_PATH="$(readlink "$SCRIPT_PATH")"
|
|
8
|
+
|
|
9
|
+
if [[ "$SCRIPT_PATH" != /* ]]; then
|
|
10
|
+
SCRIPT_PATH="${SCRIPT_BASE_DIR}/${SCRIPT_PATH}"
|
|
11
|
+
fi
|
|
12
|
+
done
|
|
13
|
+
SCRIPT_DIR="$(cd -P "$(dirname "$SCRIPT_PATH")" >/dev/null 2>&1 && pwd)"
|
|
14
|
+
|
|
15
|
+
# shellcheck source=bin/lib/modified-files.sh
|
|
16
|
+
source "$SCRIPT_DIR/lib/modified-files.sh"
|
|
17
|
+
# shellcheck source=bin/lib/shellcheck-resolve.sh
|
|
18
|
+
source "$SCRIPT_DIR/lib/shellcheck-resolve.sh"
|
|
19
|
+
|
|
20
|
+
PROJECT_ROOT="$(detect_project_root)"
|
|
21
|
+
readonly PROJECT_ROOT
|
|
22
|
+
style_load_extra_excludes "$PROJECT_ROOT"
|
|
23
|
+
readonly RUST_PROJECT_DIR="${RUST_PROJECT_DIR:-$PROJECT_ROOT}"
|
|
24
|
+
readonly TS_PROJECT_DIR="${TS_PROJECT_DIR:-$PROJECT_ROOT}"
|
|
25
|
+
readonly DOCS_PROJECT_DIR="${DOCS_PROJECT_DIR:-$PROJECT_ROOT}"
|
|
26
|
+
readonly PYTHON_PROJECT_DIR="${PYTHON_PROJECT_DIR:-$PROJECT_ROOT}"
|
|
27
|
+
readonly GO_PROJECT_DIR="${GO_PROJECT_DIR:-$PROJECT_ROOT}"
|
|
28
|
+
readonly BUNDLE_DEST_DIR_NAME="scripts"
|
|
29
|
+
readonly BUNDLE_MANIFEST_FILE=".style-bundle-manifest"
|
|
30
|
+
|
|
31
|
+
BUNDLE_MANAGED_FILES=(
|
|
32
|
+
"style.sh"
|
|
33
|
+
"format.sh"
|
|
34
|
+
"lint.sh"
|
|
35
|
+
"init-formatters.sh"
|
|
36
|
+
"install-shellcheck.sh"
|
|
37
|
+
"go-tools.sh"
|
|
38
|
+
"lib/excludes.sh"
|
|
39
|
+
"lib/modified-files.sh"
|
|
40
|
+
"lib/shellcheck-resolve.sh"
|
|
41
|
+
"lib/shellcheck-version.sh"
|
|
42
|
+
"templates/markdownlint.json"
|
|
43
|
+
"templates/markdownlintignore"
|
|
44
|
+
"templates/prettierrc.json"
|
|
45
|
+
"templates/prettierignore"
|
|
46
|
+
"templates/python-pyproject.toml"
|
|
47
|
+
"templates/rustfmt.toml"
|
|
48
|
+
"templates/clippy.toml"
|
|
49
|
+
"templates/biome.json"
|
|
50
|
+
"templates/tsconfig.json"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
print_skip() {
|
|
54
|
+
local section_name="$1"
|
|
55
|
+
local reason="$2"
|
|
56
|
+
echo "=== ${section_name} ==="
|
|
57
|
+
echo "Skipping: ${reason}"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
print_info() {
|
|
61
|
+
echo "[INFO] $*"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
scope_noun() {
|
|
65
|
+
case "${1:-all}" in
|
|
66
|
+
staged) printf 'staged\n' ;;
|
|
67
|
+
unstaged) printf 'unstaged\n' ;;
|
|
68
|
+
*) printf 'modified\n' ;;
|
|
69
|
+
esac
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
require_command() {
|
|
73
|
+
local command_name="$1"
|
|
74
|
+
|
|
75
|
+
if ! command -v "$command_name" >/dev/null 2>&1; then
|
|
76
|
+
echo "Missing required command: ${command_name}" >&2
|
|
77
|
+
return 1
|
|
78
|
+
fi
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Node CLIs must come from the project's own node_modules so the version the
|
|
82
|
+
# lockfile pins is the version that runs. A bare `npx <tool>` silently falls back
|
|
83
|
+
# to a registry download or a stale ~/.npm/_npx cache entry whenever node_modules
|
|
84
|
+
# is missing, which lints against an arbitrary version and disagrees with CI.
|
|
85
|
+
resolve_node_bin() {
|
|
86
|
+
local start_dir="$1"
|
|
87
|
+
local bin_name="$2"
|
|
88
|
+
local package_name="$3"
|
|
89
|
+
|
|
90
|
+
local search_dir="$start_dir"
|
|
91
|
+
local previous_dir=''
|
|
92
|
+
while [[ -n "$search_dir" && "$search_dir" != "$previous_dir" ]]; do
|
|
93
|
+
if [[ -x "$search_dir/node_modules/.bin/$bin_name" ]]; then
|
|
94
|
+
printf '%s\n' "$search_dir/node_modules/.bin/$bin_name"
|
|
95
|
+
return 0
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
previous_dir="$search_dir"
|
|
99
|
+
search_dir="$(dirname "$search_dir")"
|
|
100
|
+
done
|
|
101
|
+
|
|
102
|
+
echo "Missing local ${bin_name} (package ${package_name}): no node_modules/.bin/${bin_name} in ${start_dir} or any parent directory." >&2
|
|
103
|
+
echo "Run your package manager's install (for example 'pnpm install') so lint and format use the lockfile-pinned version." >&2
|
|
104
|
+
echo "Refusing to fall back to 'npx', which resolves an arbitrary version and disagrees with CI." >&2
|
|
105
|
+
return 1
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# Run a Node CLI out of the project's node_modules/.bin, with that project as cwd.
|
|
109
|
+
run_node_tool() {
|
|
110
|
+
local project_dir="$1"
|
|
111
|
+
local bin_name="$2"
|
|
112
|
+
local package_name="$3"
|
|
113
|
+
shift 3
|
|
114
|
+
|
|
115
|
+
local tool_bin
|
|
116
|
+
tool_bin="$(resolve_node_bin "$project_dir" "$bin_name" "$package_name")" || return 1
|
|
117
|
+
|
|
118
|
+
(cd "$project_dir" && "$tool_bin" "$@")
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
run_biome() {
|
|
122
|
+
local project_dir="$1"
|
|
123
|
+
shift
|
|
124
|
+
run_node_tool "$project_dir" biome "@biomejs/biome" "$@"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
run_prettier() {
|
|
128
|
+
local project_dir="$1"
|
|
129
|
+
shift
|
|
130
|
+
run_node_tool "$project_dir" prettier prettier "$@"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
run_markdownlint() {
|
|
134
|
+
local project_dir="$1"
|
|
135
|
+
shift
|
|
136
|
+
run_node_tool "$project_dir" markdownlint markdownlint-cli "$@"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
run_tsc() {
|
|
140
|
+
local project_dir="$1"
|
|
141
|
+
shift
|
|
142
|
+
run_node_tool "$project_dir" tsc typescript "$@"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
array_contains() {
|
|
146
|
+
local needle="$1"
|
|
147
|
+
shift
|
|
148
|
+
|
|
149
|
+
local value
|
|
150
|
+
for value in "$@"; do
|
|
151
|
+
if [[ "$value" == "$needle" ]]; then
|
|
152
|
+
return 0
|
|
153
|
+
fi
|
|
154
|
+
done
|
|
155
|
+
|
|
156
|
+
return 1
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
relativize_paths() {
|
|
160
|
+
local base_dir="${1%/}"
|
|
161
|
+
shift
|
|
162
|
+
|
|
163
|
+
local path_value
|
|
164
|
+
for path_value in "$@"; do
|
|
165
|
+
if [[ "$path_value" == "$base_dir/"* ]]; then
|
|
166
|
+
printf '%s\n' "${path_value#"$base_dir"/}"
|
|
167
|
+
elif [[ "$path_value" == "$base_dir" ]]; then
|
|
168
|
+
printf '.\n'
|
|
169
|
+
fi
|
|
170
|
+
done
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
path_prefix_for() {
|
|
174
|
+
local target_dir="$1"
|
|
175
|
+
local prefix
|
|
176
|
+
|
|
177
|
+
prefix="$(path_relative_to_root "$PROJECT_ROOT" "$target_dir" || true)"
|
|
178
|
+
if [[ -n "$prefix" ]]; then
|
|
179
|
+
printf '%s/\n' "$prefix"
|
|
180
|
+
else
|
|
181
|
+
printf '\n'
|
|
182
|
+
fi
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
directory_has_suffixes() {
|
|
186
|
+
local target_dir="$1"
|
|
187
|
+
shift
|
|
188
|
+
|
|
189
|
+
# Ignore-aware detection: enumerate the same set the linter operates on
|
|
190
|
+
# (git ls-files honoring .gitignore, or a find fallback for non-git dirs) and
|
|
191
|
+
# skip STYLE_EXCLUDES, so a stray source file inside node_modules/dist/vendor
|
|
192
|
+
# no longer flips a detect_*_project result. dir_has_source_suffix is provided
|
|
193
|
+
# by excludes.sh, sourced transitively via modified-files.sh above.
|
|
194
|
+
dir_has_source_suffix "$target_dir" "$@"
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
detect_docs_project() {
|
|
198
|
+
local target_dir="${1:-$DOCS_PROJECT_DIR}"
|
|
199
|
+
|
|
200
|
+
[[ -f "$target_dir/.markdownlint.json" ]] ||
|
|
201
|
+
[[ -f "$target_dir/.markdownlint.jsonc" ]] ||
|
|
202
|
+
[[ -f "$target_dir/.markdownlint.yaml" ]] ||
|
|
203
|
+
[[ -f "$target_dir/.markdownlint.yml" ]] ||
|
|
204
|
+
[[ -f "$target_dir/.prettierrc" ]] ||
|
|
205
|
+
[[ -f "$target_dir/.prettierrc.json" ]] ||
|
|
206
|
+
[[ -f "$target_dir/.prettierrc.yml" ]] ||
|
|
207
|
+
[[ -f "$target_dir/.prettierrc.yaml" ]] ||
|
|
208
|
+
directory_has_suffixes "$target_dir" ".md" ".mdx" ".yaml" ".yml" ||
|
|
209
|
+
(docs_track_uses_json_files "$target_dir" && directory_has_suffixes "$target_dir" ".json" ".jsonc")
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
detect_python_project() {
|
|
213
|
+
local target_dir="${1:-$PYTHON_PROJECT_DIR}"
|
|
214
|
+
|
|
215
|
+
[[ -f "$target_dir/pyproject.toml" ]] ||
|
|
216
|
+
[[ -f "$target_dir/requirements.txt" ]] ||
|
|
217
|
+
[[ -f "$target_dir/setup.py" ]] ||
|
|
218
|
+
directory_has_suffixes "$target_dir" ".py" ".pyi"
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
can_init_python_project() {
|
|
222
|
+
local target_dir="${1:-$PYTHON_PROJECT_DIR}"
|
|
223
|
+
|
|
224
|
+
[[ ! -f "$target_dir/pyproject.toml" ]] && detect_python_project "$target_dir"
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
detect_rust_project() {
|
|
228
|
+
local target_dir="${1:-$RUST_PROJECT_DIR}"
|
|
229
|
+
|
|
230
|
+
[[ -f "$target_dir/Cargo.toml" ]] ||
|
|
231
|
+
directory_has_suffixes "$target_dir" ".rs"
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
detect_ts_project() {
|
|
235
|
+
local target_dir="${1:-$TS_PROJECT_DIR}"
|
|
236
|
+
|
|
237
|
+
compgen -G "$target_dir/tsconfig*.json" >/dev/null ||
|
|
238
|
+
[[ -f "$target_dir/biome.json" ]] ||
|
|
239
|
+
[[ -f "$target_dir/biome.jsonc" ]] ||
|
|
240
|
+
directory_has_suffixes "$target_dir" ".ts" ".tsx" ".mts" ".cts" ".js" ".jsx" ".mjs" ".cjs"
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
detect_go_project() {
|
|
244
|
+
local target_dir="${1:-$GO_PROJECT_DIR}"
|
|
245
|
+
|
|
246
|
+
[[ -f "$target_dir/go.mod" ]] ||
|
|
247
|
+
directory_has_suffixes "$target_dir" ".go"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
docs_track_uses_json_files() {
|
|
251
|
+
local target_dir="${1:-$DOCS_PROJECT_DIR}"
|
|
252
|
+
|
|
253
|
+
! detect_ts_project "$target_dir"
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
docs_track_label() {
|
|
257
|
+
local target_dir="${1:-$DOCS_PROJECT_DIR}"
|
|
258
|
+
|
|
259
|
+
if docs_track_uses_json_files "$target_dir"; then
|
|
260
|
+
printf 'Docs/JSON/YAML\n'
|
|
261
|
+
else
|
|
262
|
+
printf 'Docs\n'
|
|
263
|
+
fi
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
docs_owned_suffixes() {
|
|
267
|
+
local target_dir="${1:-$DOCS_PROJECT_DIR}"
|
|
268
|
+
|
|
269
|
+
printf '%s\n' ".md" ".mdx" ".yaml" ".yml"
|
|
270
|
+
if docs_track_uses_json_files "$target_dir"; then
|
|
271
|
+
printf '%s\n' ".json" ".jsonc"
|
|
272
|
+
fi
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
detect_shell_project() {
|
|
276
|
+
local target_dir="${1:-$PROJECT_ROOT}"
|
|
277
|
+
|
|
278
|
+
directory_has_suffixes "$target_dir" ".sh"
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
ts_owned_suffixes() {
|
|
282
|
+
printf '%s\n' ".ts" ".tsx" ".js" ".jsx" ".mjs" ".cjs" ".mts" ".cts" ".css" ".json" ".jsonc"
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
run_rust_lint() {
|
|
286
|
+
local fix="$1"
|
|
287
|
+
local git_scope="$2"
|
|
288
|
+
local exit_code=0
|
|
289
|
+
|
|
290
|
+
if [[ ! -f "$RUST_PROJECT_DIR/Cargo.toml" ]]; then
|
|
291
|
+
print_skip "Rust" "no Cargo.toml found in ${RUST_PROJECT_DIR}"
|
|
292
|
+
return 0
|
|
293
|
+
fi
|
|
294
|
+
|
|
295
|
+
if ! require_command cargo; then
|
|
296
|
+
return 1
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
local rust_prefix
|
|
300
|
+
rust_prefix="$(path_prefix_for "$RUST_PROJECT_DIR")"
|
|
301
|
+
|
|
302
|
+
if [[ -n "$git_scope" ]]; then
|
|
303
|
+
local -a rust_files=()
|
|
304
|
+
mapfile -t rust_files < <(list_modified_repo_paths "$git_scope" "$rust_prefix" ".rs")
|
|
305
|
+
|
|
306
|
+
if (( ${#rust_files[@]} == 0 )); then
|
|
307
|
+
echo "=== Rust ==="
|
|
308
|
+
echo "No $(scope_noun "$git_scope") Rust files."
|
|
309
|
+
return 0
|
|
310
|
+
fi
|
|
311
|
+
|
|
312
|
+
echo "=== Rust: rustfmt ==="
|
|
313
|
+
local -a rust_relative_files=()
|
|
314
|
+
mapfile -t rust_relative_files < <(relativize_paths "$RUST_PROJECT_DIR" "${rust_files[@]}")
|
|
315
|
+
|
|
316
|
+
if (( fix )); then
|
|
317
|
+
(cd "$RUST_PROJECT_DIR" && cargo fmt --all -- "${rust_relative_files[@]}") || exit_code=1
|
|
318
|
+
else
|
|
319
|
+
(cd "$RUST_PROJECT_DIR" && cargo fmt --all -- --check "${rust_relative_files[@]}") || exit_code=1
|
|
320
|
+
fi
|
|
321
|
+
|
|
322
|
+
echo "=== Rust: clippy (workspace scope) ==="
|
|
323
|
+
if (( fix )); then
|
|
324
|
+
(cd "$RUST_PROJECT_DIR" && cargo clippy --all-targets --fix --allow-dirty -- -D warnings) || exit_code=1
|
|
325
|
+
else
|
|
326
|
+
(cd "$RUST_PROJECT_DIR" && cargo clippy --all-targets -- -D warnings) || exit_code=1
|
|
327
|
+
fi
|
|
328
|
+
|
|
329
|
+
return "$exit_code"
|
|
330
|
+
fi
|
|
331
|
+
|
|
332
|
+
echo "=== Rust: rustfmt ==="
|
|
333
|
+
if (( fix )); then
|
|
334
|
+
(cd "$RUST_PROJECT_DIR" && cargo fmt --all) || exit_code=1
|
|
335
|
+
else
|
|
336
|
+
(cd "$RUST_PROJECT_DIR" && cargo fmt --all -- --check) || exit_code=1
|
|
337
|
+
fi
|
|
338
|
+
|
|
339
|
+
echo "=== Rust: clippy ==="
|
|
340
|
+
if (( fix )); then
|
|
341
|
+
(cd "$RUST_PROJECT_DIR" && cargo clippy --all-targets --fix --allow-dirty -- -D warnings) || exit_code=1
|
|
342
|
+
else
|
|
343
|
+
(cd "$RUST_PROJECT_DIR" && cargo clippy --all-targets -- -D warnings) || exit_code=1
|
|
344
|
+
fi
|
|
345
|
+
|
|
346
|
+
return "$exit_code"
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
run_ts_lint() {
|
|
350
|
+
local fix="$1"
|
|
351
|
+
local git_scope="$2"
|
|
352
|
+
local exit_code=0
|
|
353
|
+
|
|
354
|
+
if [[ ! -f "$TS_PROJECT_DIR/package.json" ]]; then
|
|
355
|
+
print_skip "TypeScript" "no package.json found in ${TS_PROJECT_DIR}"
|
|
356
|
+
return 0
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
local ts_prefix
|
|
360
|
+
ts_prefix="$(path_prefix_for "$TS_PROJECT_DIR")"
|
|
361
|
+
local -a ts_suffixes=()
|
|
362
|
+
mapfile -t ts_suffixes < <(ts_owned_suffixes)
|
|
363
|
+
|
|
364
|
+
if [[ -n "$git_scope" ]]; then
|
|
365
|
+
local -a ts_biome_files=()
|
|
366
|
+
local -a ts_typecheck_files=()
|
|
367
|
+
mapfile -t ts_biome_files < <(list_modified_repo_paths "$git_scope" "$ts_prefix" "${ts_suffixes[@]}")
|
|
368
|
+
mapfile -t ts_typecheck_files < <(list_modified_repo_paths "$git_scope" "$ts_prefix" \
|
|
369
|
+
".ts" ".tsx" ".mts" ".cts")
|
|
370
|
+
|
|
371
|
+
if (( ${#ts_biome_files[@]} == 0 )); then
|
|
372
|
+
echo "=== TypeScript ==="
|
|
373
|
+
echo "No $(scope_noun "$git_scope") frontend source files."
|
|
374
|
+
else
|
|
375
|
+
echo "=== TypeScript/JavaScript: biome ==="
|
|
376
|
+
local -a ts_relative_biome_files=()
|
|
377
|
+
mapfile -t ts_relative_biome_files < <(relativize_paths "$TS_PROJECT_DIR" "${ts_biome_files[@]}")
|
|
378
|
+
|
|
379
|
+
if (( fix )); then
|
|
380
|
+
run_biome "$TS_PROJECT_DIR" check --fix "${ts_relative_biome_files[@]}" || exit_code=1
|
|
381
|
+
else
|
|
382
|
+
run_biome "$TS_PROJECT_DIR" ci "${ts_relative_biome_files[@]}" || exit_code=1
|
|
383
|
+
fi
|
|
384
|
+
fi
|
|
385
|
+
|
|
386
|
+
if (( ${#ts_typecheck_files[@]} > 0 )); then
|
|
387
|
+
if compgen -G "$TS_PROJECT_DIR/tsconfig*.json" >/dev/null; then
|
|
388
|
+
echo "=== TypeScript: tsc (project scope) ==="
|
|
389
|
+
run_tsc "$TS_PROJECT_DIR" --noEmit || exit_code=1
|
|
390
|
+
else
|
|
391
|
+
print_skip "TypeScript: tsc" "no tsconfig*.json found in ${TS_PROJECT_DIR}"
|
|
392
|
+
fi
|
|
393
|
+
fi
|
|
394
|
+
|
|
395
|
+
return "$exit_code"
|
|
396
|
+
fi
|
|
397
|
+
|
|
398
|
+
local -a ts_biome_files=()
|
|
399
|
+
mapfile -t ts_biome_files < <(list_repo_paths "$ts_prefix" "${ts_suffixes[@]}")
|
|
400
|
+
if (( ${#ts_biome_files[@]} == 0 )); then
|
|
401
|
+
echo "=== TypeScript/JavaScript ==="
|
|
402
|
+
echo "No frontend source or JSON files found."
|
|
403
|
+
else
|
|
404
|
+
echo "=== TypeScript/JavaScript: biome ==="
|
|
405
|
+
local -a ts_relative_biome_files=()
|
|
406
|
+
mapfile -t ts_relative_biome_files < <(relativize_paths "$TS_PROJECT_DIR" "${ts_biome_files[@]}")
|
|
407
|
+
run_biome "$TS_PROJECT_DIR" ci "${ts_relative_biome_files[@]}" || exit_code=1
|
|
408
|
+
fi
|
|
409
|
+
|
|
410
|
+
if compgen -G "$TS_PROJECT_DIR/tsconfig*.json" >/dev/null; then
|
|
411
|
+
echo "=== TypeScript: tsc ==="
|
|
412
|
+
run_tsc "$TS_PROJECT_DIR" --noEmit || exit_code=1
|
|
413
|
+
else
|
|
414
|
+
print_skip "TypeScript: tsc" "no tsconfig*.json found in ${TS_PROJECT_DIR}"
|
|
415
|
+
fi
|
|
416
|
+
|
|
417
|
+
return "$exit_code"
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
run_shell_lint() {
|
|
421
|
+
local git_scope="$1"
|
|
422
|
+
|
|
423
|
+
if ! resolve_shellcheck_bin; then
|
|
424
|
+
return 1
|
|
425
|
+
fi
|
|
426
|
+
|
|
427
|
+
local -a shell_files=()
|
|
428
|
+
if [[ -n "$git_scope" ]]; then
|
|
429
|
+
mapfile -t shell_files < <(list_modified_repo_paths "$git_scope" "" ".sh")
|
|
430
|
+
if (( ${#shell_files[@]} == 0 )); then
|
|
431
|
+
echo "=== Shell ==="
|
|
432
|
+
echo "No $(scope_noun "$git_scope") shell scripts."
|
|
433
|
+
return 0
|
|
434
|
+
fi
|
|
435
|
+
else
|
|
436
|
+
mapfile -t shell_files < <(list_repo_paths "" ".sh")
|
|
437
|
+
if (( ${#shell_files[@]} == 0 )); then
|
|
438
|
+
echo "=== Shell ==="
|
|
439
|
+
echo "No shell scripts found."
|
|
440
|
+
return 0
|
|
441
|
+
fi
|
|
442
|
+
fi
|
|
443
|
+
|
|
444
|
+
echo "=== Shell: shellcheck ==="
|
|
445
|
+
"$SHELLCHECK_BIN" --severity=warning "${shell_files[@]}"
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
run_python_lint() {
|
|
449
|
+
local fix="$1"
|
|
450
|
+
local git_scope="$2"
|
|
451
|
+
local exit_code=0
|
|
452
|
+
|
|
453
|
+
if ! detect_python_project; then
|
|
454
|
+
print_skip "Python" "no Python files or config found in ${PYTHON_PROJECT_DIR}"
|
|
455
|
+
return 0
|
|
456
|
+
fi
|
|
457
|
+
|
|
458
|
+
if ! require_command ruff; then
|
|
459
|
+
return 1
|
|
460
|
+
fi
|
|
461
|
+
if ! require_command black; then
|
|
462
|
+
return 1
|
|
463
|
+
fi
|
|
464
|
+
|
|
465
|
+
local python_prefix
|
|
466
|
+
python_prefix="$(path_prefix_for "$PYTHON_PROJECT_DIR")"
|
|
467
|
+
|
|
468
|
+
# User excludes (.style-excludes / STYLE_EXTRA_EXCLUDES) never reach a bare
|
|
469
|
+
# `ruff check .`, so a full run with any declared uses the filtered file list.
|
|
470
|
+
if [[ -n "$git_scope" ]] || (( ${#STYLE_USER_EXCLUDES[@]} )); then
|
|
471
|
+
local -a python_files=()
|
|
472
|
+
if [[ -n "$git_scope" ]]; then
|
|
473
|
+
mapfile -t python_files < <(list_modified_repo_paths "$git_scope" "$python_prefix" ".py" ".pyi")
|
|
474
|
+
else
|
|
475
|
+
mapfile -t python_files < <(list_repo_paths "$python_prefix" ".py" ".pyi")
|
|
476
|
+
fi
|
|
477
|
+
|
|
478
|
+
if (( ${#python_files[@]} == 0 )); then
|
|
479
|
+
echo "=== Python ==="
|
|
480
|
+
echo "No ${git_scope:+$(scope_noun "$git_scope") }Python files."
|
|
481
|
+
return 0
|
|
482
|
+
fi
|
|
483
|
+
|
|
484
|
+
echo "=== Python: ruff ==="
|
|
485
|
+
local -a python_relative_files=()
|
|
486
|
+
mapfile -t python_relative_files < <(relativize_paths "$PYTHON_PROJECT_DIR" "${python_files[@]}")
|
|
487
|
+
if (( fix )); then
|
|
488
|
+
(cd "$PYTHON_PROJECT_DIR" && ruff check --fix "${python_relative_files[@]}") || exit_code=1
|
|
489
|
+
(cd "$PYTHON_PROJECT_DIR" && black "${python_relative_files[@]}") || exit_code=1
|
|
490
|
+
else
|
|
491
|
+
(cd "$PYTHON_PROJECT_DIR" && ruff check "${python_relative_files[@]}") || exit_code=1
|
|
492
|
+
echo "=== Python: black ==="
|
|
493
|
+
(cd "$PYTHON_PROJECT_DIR" && black --check "${python_relative_files[@]}") || exit_code=1
|
|
494
|
+
fi
|
|
495
|
+
|
|
496
|
+
return "$exit_code"
|
|
497
|
+
fi
|
|
498
|
+
|
|
499
|
+
echo "=== Python: ruff ==="
|
|
500
|
+
if (( fix )); then
|
|
501
|
+
(cd "$PYTHON_PROJECT_DIR" && ruff check --fix .) || exit_code=1
|
|
502
|
+
echo "=== Python: black ==="
|
|
503
|
+
(cd "$PYTHON_PROJECT_DIR" && black .) || exit_code=1
|
|
504
|
+
else
|
|
505
|
+
(cd "$PYTHON_PROJECT_DIR" && ruff check .) || exit_code=1
|
|
506
|
+
echo "=== Python: black ==="
|
|
507
|
+
(cd "$PYTHON_PROJECT_DIR" && black --check .) || exit_code=1
|
|
508
|
+
fi
|
|
509
|
+
|
|
510
|
+
return "$exit_code"
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
run_go_lint() {
|
|
514
|
+
local fix="$1"
|
|
515
|
+
local git_scope="$2"
|
|
516
|
+
|
|
517
|
+
if ! detect_go_project; then
|
|
518
|
+
print_skip "Go" "no Go files or module found in ${GO_PROJECT_DIR}"
|
|
519
|
+
return 0
|
|
520
|
+
fi
|
|
521
|
+
|
|
522
|
+
if ! require_command golangci-lint; then
|
|
523
|
+
return 1
|
|
524
|
+
fi
|
|
525
|
+
|
|
526
|
+
if [[ -n "$git_scope" ]]; then
|
|
527
|
+
local go_prefix
|
|
528
|
+
go_prefix="$(path_prefix_for "$GO_PROJECT_DIR")"
|
|
529
|
+
local -a go_files=()
|
|
530
|
+
mapfile -t go_files < <(list_modified_repo_paths "$git_scope" "$go_prefix" ".go")
|
|
531
|
+
|
|
532
|
+
if (( ${#go_files[@]} == 0 )); then
|
|
533
|
+
echo "=== Go ==="
|
|
534
|
+
echo "No $(scope_noun "$git_scope") Go files."
|
|
535
|
+
return 0
|
|
536
|
+
fi
|
|
537
|
+
fi
|
|
538
|
+
|
|
539
|
+
echo "=== Go: golangci-lint ==="
|
|
540
|
+
if (( fix )); then
|
|
541
|
+
(cd "$GO_PROJECT_DIR" && golangci-lint run --fix ./...)
|
|
542
|
+
else
|
|
543
|
+
(cd "$GO_PROJECT_DIR" && golangci-lint run ./...)
|
|
544
|
+
fi
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
run_docs_lint() {
|
|
548
|
+
local fix="$1"
|
|
549
|
+
local git_scope="$2"
|
|
550
|
+
local exit_code=0
|
|
551
|
+
local docs_label
|
|
552
|
+
docs_label="$(docs_track_label "$DOCS_PROJECT_DIR")"
|
|
553
|
+
|
|
554
|
+
if ! detect_docs_project; then
|
|
555
|
+
print_skip "$docs_label" "no docs-owned files or docs config found in ${DOCS_PROJECT_DIR}"
|
|
556
|
+
return 0
|
|
557
|
+
fi
|
|
558
|
+
|
|
559
|
+
local docs_prefix
|
|
560
|
+
docs_prefix="$(path_prefix_for "$DOCS_PROJECT_DIR")"
|
|
561
|
+
local -a docs_suffixes=()
|
|
562
|
+
mapfile -t docs_suffixes < <(docs_owned_suffixes "$DOCS_PROJECT_DIR")
|
|
563
|
+
|
|
564
|
+
local -a docs_files=()
|
|
565
|
+
if [[ -n "$git_scope" ]]; then
|
|
566
|
+
mapfile -t docs_files < <(list_modified_repo_paths "$git_scope" "$docs_prefix" "${docs_suffixes[@]}")
|
|
567
|
+
if (( ${#docs_files[@]} == 0 )); then
|
|
568
|
+
echo "=== ${docs_label} ==="
|
|
569
|
+
echo "No $(scope_noun "$git_scope") docs files."
|
|
570
|
+
return 0
|
|
571
|
+
fi
|
|
572
|
+
else
|
|
573
|
+
mapfile -t docs_files < <(list_repo_paths "$docs_prefix" "${docs_suffixes[@]}")
|
|
574
|
+
if (( ${#docs_files[@]} == 0 )); then
|
|
575
|
+
echo "=== ${docs_label} ==="
|
|
576
|
+
echo "No docs files found."
|
|
577
|
+
return 0
|
|
578
|
+
fi
|
|
579
|
+
fi
|
|
580
|
+
|
|
581
|
+
local -a docs_relative_files=()
|
|
582
|
+
mapfile -t docs_relative_files < <(relativize_paths "$DOCS_PROJECT_DIR" "${docs_files[@]}")
|
|
583
|
+
|
|
584
|
+
local -a markdownlint_args=()
|
|
585
|
+
if [[ -f "$DOCS_PROJECT_DIR/.markdownlintignore" ]]; then
|
|
586
|
+
markdownlint_args+=(--ignore-path "$DOCS_PROJECT_DIR/.markdownlintignore")
|
|
587
|
+
fi
|
|
588
|
+
|
|
589
|
+
local markdownlint_config=''
|
|
590
|
+
local markdownlint_candidate
|
|
591
|
+
for markdownlint_candidate in \
|
|
592
|
+
.markdownlint.json \
|
|
593
|
+
.markdownlint.jsonc \
|
|
594
|
+
.markdownlint.yaml \
|
|
595
|
+
.markdownlint.yml
|
|
596
|
+
do
|
|
597
|
+
if [[ -f "$DOCS_PROJECT_DIR/$markdownlint_candidate" ]]; then
|
|
598
|
+
markdownlint_config="$DOCS_PROJECT_DIR/$markdownlint_candidate"
|
|
599
|
+
break
|
|
600
|
+
fi
|
|
601
|
+
done
|
|
602
|
+
if [[ -n "$markdownlint_config" ]]; then
|
|
603
|
+
markdownlint_args+=(--config "$markdownlint_config")
|
|
604
|
+
fi
|
|
605
|
+
|
|
606
|
+
local -a prettier_args=()
|
|
607
|
+
if [[ -f "$DOCS_PROJECT_DIR/.prettierignore" ]]; then
|
|
608
|
+
prettier_args+=(--ignore-path "$DOCS_PROJECT_DIR/.prettierignore")
|
|
609
|
+
fi
|
|
610
|
+
if [[ -f "$DOCS_PROJECT_DIR/.prettierrc" ]]; then
|
|
611
|
+
prettier_args+=(--config "$DOCS_PROJECT_DIR/.prettierrc")
|
|
612
|
+
fi
|
|
613
|
+
|
|
614
|
+
echo "=== Markdown: markdownlint ==="
|
|
615
|
+
local -a markdown_relative_files=()
|
|
616
|
+
local docs_relative_file
|
|
617
|
+
for docs_relative_file in "${docs_relative_files[@]}"; do
|
|
618
|
+
case "$docs_relative_file" in
|
|
619
|
+
*.md|*.mdx) markdown_relative_files+=("$docs_relative_file") ;;
|
|
620
|
+
esac
|
|
621
|
+
done
|
|
622
|
+
|
|
623
|
+
if (( ${#markdown_relative_files[@]} == 0 )); then
|
|
624
|
+
echo "No Markdown files to lint."
|
|
625
|
+
elif (( fix )); then
|
|
626
|
+
run_markdownlint "$DOCS_PROJECT_DIR" --fix "${markdownlint_args[@]}" "${markdown_relative_files[@]}" || exit_code=1
|
|
627
|
+
else
|
|
628
|
+
run_markdownlint "$DOCS_PROJECT_DIR" "${markdownlint_args[@]}" "${markdown_relative_files[@]}" || exit_code=1
|
|
629
|
+
fi
|
|
630
|
+
|
|
631
|
+
echo "=== Docs: prettier ==="
|
|
632
|
+
if (( fix )); then
|
|
633
|
+
run_prettier "$DOCS_PROJECT_DIR" --write "${docs_relative_files[@]}" "${prettier_args[@]}" || exit_code=1
|
|
634
|
+
else
|
|
635
|
+
run_prettier "$DOCS_PROJECT_DIR" --check "${docs_relative_files[@]}" "${prettier_args[@]}" || exit_code=1
|
|
636
|
+
fi
|
|
637
|
+
|
|
638
|
+
return "$exit_code"
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
run_rust_format() {
|
|
642
|
+
local git_scope="$1"
|
|
643
|
+
|
|
644
|
+
if [[ ! -f "$RUST_PROJECT_DIR/Cargo.toml" ]]; then
|
|
645
|
+
print_skip "Rust" "no Cargo.toml found in ${RUST_PROJECT_DIR}"
|
|
646
|
+
return 0
|
|
647
|
+
fi
|
|
648
|
+
|
|
649
|
+
if ! require_command cargo; then
|
|
650
|
+
return 1
|
|
651
|
+
fi
|
|
652
|
+
|
|
653
|
+
local rust_prefix
|
|
654
|
+
rust_prefix="$(path_prefix_for "$RUST_PROJECT_DIR")"
|
|
655
|
+
|
|
656
|
+
if [[ -n "$git_scope" ]]; then
|
|
657
|
+
local -a rust_files=()
|
|
658
|
+
mapfile -t rust_files < <(list_modified_repo_paths "$git_scope" "$rust_prefix" ".rs")
|
|
659
|
+
|
|
660
|
+
if (( ${#rust_files[@]} == 0 )); then
|
|
661
|
+
echo "=== Rust ==="
|
|
662
|
+
echo "No $(scope_noun "$git_scope") Rust files."
|
|
663
|
+
return 0
|
|
664
|
+
fi
|
|
665
|
+
|
|
666
|
+
echo "=== Rust: rustfmt ==="
|
|
667
|
+
local -a rust_relative_files=()
|
|
668
|
+
mapfile -t rust_relative_files < <(relativize_paths "$RUST_PROJECT_DIR" "${rust_files[@]}")
|
|
669
|
+
(cd "$RUST_PROJECT_DIR" && cargo fmt --all -- "${rust_relative_files[@]}")
|
|
670
|
+
return 0
|
|
671
|
+
fi
|
|
672
|
+
|
|
673
|
+
echo "=== Rust: rustfmt ==="
|
|
674
|
+
(cd "$RUST_PROJECT_DIR" && cargo fmt --all)
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
run_ts_format() {
|
|
678
|
+
local git_scope="$1"
|
|
679
|
+
|
|
680
|
+
if [[ ! -f "$TS_PROJECT_DIR/package.json" ]]; then
|
|
681
|
+
print_skip "TypeScript/JavaScript" "no package.json found in ${TS_PROJECT_DIR}"
|
|
682
|
+
return 0
|
|
683
|
+
fi
|
|
684
|
+
|
|
685
|
+
local ts_prefix
|
|
686
|
+
ts_prefix="$(path_prefix_for "$TS_PROJECT_DIR")"
|
|
687
|
+
local -a ts_suffixes=()
|
|
688
|
+
mapfile -t ts_suffixes < <(ts_owned_suffixes)
|
|
689
|
+
|
|
690
|
+
if [[ -n "$git_scope" ]]; then
|
|
691
|
+
local -a ts_files=()
|
|
692
|
+
mapfile -t ts_files < <(list_modified_repo_paths "$git_scope" "$ts_prefix" "${ts_suffixes[@]}")
|
|
693
|
+
|
|
694
|
+
if (( ${#ts_files[@]} == 0 )); then
|
|
695
|
+
echo "=== TypeScript/JavaScript ==="
|
|
696
|
+
echo "No $(scope_noun "$git_scope") frontend source files."
|
|
697
|
+
return 0
|
|
698
|
+
fi
|
|
699
|
+
|
|
700
|
+
echo "=== TypeScript/JavaScript: biome ==="
|
|
701
|
+
local -a ts_relative_files=()
|
|
702
|
+
mapfile -t ts_relative_files < <(relativize_paths "$TS_PROJECT_DIR" "${ts_files[@]}")
|
|
703
|
+
run_biome "$TS_PROJECT_DIR" format --write "${ts_relative_files[@]}"
|
|
704
|
+
run_biome "$TS_PROJECT_DIR" check --fix "${ts_relative_files[@]}"
|
|
705
|
+
return 0
|
|
706
|
+
fi
|
|
707
|
+
|
|
708
|
+
local -a ts_files=()
|
|
709
|
+
mapfile -t ts_files < <(list_repo_paths "$ts_prefix" "${ts_suffixes[@]}")
|
|
710
|
+
if (( ${#ts_files[@]} == 0 )); then
|
|
711
|
+
echo "=== TypeScript/JavaScript ==="
|
|
712
|
+
echo "No frontend source or JSON files found."
|
|
713
|
+
return 0
|
|
714
|
+
fi
|
|
715
|
+
|
|
716
|
+
echo "=== TypeScript/JavaScript: biome ==="
|
|
717
|
+
local -a ts_relative_files=()
|
|
718
|
+
mapfile -t ts_relative_files < <(relativize_paths "$TS_PROJECT_DIR" "${ts_files[@]}")
|
|
719
|
+
run_biome "$TS_PROJECT_DIR" format --write "${ts_relative_files[@]}"
|
|
720
|
+
run_biome "$TS_PROJECT_DIR" check --fix "${ts_relative_files[@]}"
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
run_docs_format() {
|
|
724
|
+
local git_scope="$1"
|
|
725
|
+
local docs_label
|
|
726
|
+
docs_label="$(docs_track_label "$DOCS_PROJECT_DIR")"
|
|
727
|
+
|
|
728
|
+
if ! detect_docs_project; then
|
|
729
|
+
print_skip "$docs_label" "no docs-owned files or docs config found in ${DOCS_PROJECT_DIR}"
|
|
730
|
+
return 0
|
|
731
|
+
fi
|
|
732
|
+
|
|
733
|
+
local docs_prefix
|
|
734
|
+
docs_prefix="$(path_prefix_for "$DOCS_PROJECT_DIR")"
|
|
735
|
+
local -a docs_suffixes=()
|
|
736
|
+
mapfile -t docs_suffixes < <(docs_owned_suffixes "$DOCS_PROJECT_DIR")
|
|
737
|
+
|
|
738
|
+
local -a prettier_args=()
|
|
739
|
+
if [[ -f "$DOCS_PROJECT_DIR/.prettierignore" ]]; then
|
|
740
|
+
prettier_args+=(--ignore-path "$DOCS_PROJECT_DIR/.prettierignore")
|
|
741
|
+
fi
|
|
742
|
+
if [[ -f "$DOCS_PROJECT_DIR/.prettierrc" ]]; then
|
|
743
|
+
prettier_args+=(--config "$DOCS_PROJECT_DIR/.prettierrc")
|
|
744
|
+
fi
|
|
745
|
+
|
|
746
|
+
local -a docs_files=()
|
|
747
|
+
if [[ -n "$git_scope" ]]; then
|
|
748
|
+
mapfile -t docs_files < <(list_modified_repo_paths "$git_scope" "$docs_prefix" "${docs_suffixes[@]}")
|
|
749
|
+
if (( ${#docs_files[@]} == 0 )); then
|
|
750
|
+
echo "=== ${docs_label} ==="
|
|
751
|
+
echo "No $(scope_noun "$git_scope") docs files."
|
|
752
|
+
return 0
|
|
753
|
+
fi
|
|
754
|
+
else
|
|
755
|
+
mapfile -t docs_files < <(list_repo_paths "$docs_prefix" "${docs_suffixes[@]}")
|
|
756
|
+
if (( ${#docs_files[@]} == 0 )); then
|
|
757
|
+
echo "=== ${docs_label} ==="
|
|
758
|
+
echo "No docs files found."
|
|
759
|
+
return 0
|
|
760
|
+
fi
|
|
761
|
+
fi
|
|
762
|
+
|
|
763
|
+
echo "=== Docs: prettier ==="
|
|
764
|
+
local -a docs_relative_files=()
|
|
765
|
+
mapfile -t docs_relative_files < <(relativize_paths "$DOCS_PROJECT_DIR" "${docs_files[@]}")
|
|
766
|
+
run_prettier "$DOCS_PROJECT_DIR" --write "${docs_relative_files[@]}" "${prettier_args[@]}"
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
run_python_format() {
|
|
770
|
+
local git_scope="$1"
|
|
771
|
+
|
|
772
|
+
if ! detect_python_project; then
|
|
773
|
+
print_skip "Python" "no Python files or config found in ${PYTHON_PROJECT_DIR}"
|
|
774
|
+
return 0
|
|
775
|
+
fi
|
|
776
|
+
|
|
777
|
+
if ! require_command black; then
|
|
778
|
+
return 1
|
|
779
|
+
fi
|
|
780
|
+
|
|
781
|
+
local python_prefix
|
|
782
|
+
python_prefix="$(path_prefix_for "$PYTHON_PROJECT_DIR")"
|
|
783
|
+
|
|
784
|
+
# User excludes (.style-excludes / STYLE_EXTRA_EXCLUDES) never reach a bare
|
|
785
|
+
# `ruff check .`, so a full run with any declared uses the filtered file list.
|
|
786
|
+
if [[ -n "$git_scope" ]] || (( ${#STYLE_USER_EXCLUDES[@]} )); then
|
|
787
|
+
local -a python_files=()
|
|
788
|
+
if [[ -n "$git_scope" ]]; then
|
|
789
|
+
mapfile -t python_files < <(list_modified_repo_paths "$git_scope" "$python_prefix" ".py" ".pyi")
|
|
790
|
+
else
|
|
791
|
+
mapfile -t python_files < <(list_repo_paths "$python_prefix" ".py" ".pyi")
|
|
792
|
+
fi
|
|
793
|
+
|
|
794
|
+
if (( ${#python_files[@]} == 0 )); then
|
|
795
|
+
echo "=== Python ==="
|
|
796
|
+
echo "No ${git_scope:+$(scope_noun "$git_scope") }Python files."
|
|
797
|
+
return 0
|
|
798
|
+
fi
|
|
799
|
+
|
|
800
|
+
echo "=== Python: black ==="
|
|
801
|
+
local -a python_relative_files=()
|
|
802
|
+
mapfile -t python_relative_files < <(relativize_paths "$PYTHON_PROJECT_DIR" "${python_files[@]}")
|
|
803
|
+
(cd "$PYTHON_PROJECT_DIR" && black "${python_relative_files[@]}")
|
|
804
|
+
return 0
|
|
805
|
+
fi
|
|
806
|
+
|
|
807
|
+
echo "=== Python: black ==="
|
|
808
|
+
(cd "$PYTHON_PROJECT_DIR" && black .)
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
run_go_format() {
|
|
812
|
+
local git_scope="$1"
|
|
813
|
+
|
|
814
|
+
if ! detect_go_project; then
|
|
815
|
+
print_skip "Go" "no Go files or module found in ${GO_PROJECT_DIR}"
|
|
816
|
+
return 0
|
|
817
|
+
fi
|
|
818
|
+
|
|
819
|
+
if ! require_command gofmt; then
|
|
820
|
+
return 1
|
|
821
|
+
fi
|
|
822
|
+
if ! require_command goimports; then
|
|
823
|
+
return 1
|
|
824
|
+
fi
|
|
825
|
+
|
|
826
|
+
local go_prefix
|
|
827
|
+
go_prefix="$(path_prefix_for "$GO_PROJECT_DIR")"
|
|
828
|
+
|
|
829
|
+
local -a go_files=()
|
|
830
|
+
if [[ -n "$git_scope" ]]; then
|
|
831
|
+
mapfile -t go_files < <(list_modified_repo_paths "$git_scope" "$go_prefix" ".go")
|
|
832
|
+
if (( ${#go_files[@]} == 0 )); then
|
|
833
|
+
echo "=== Go ==="
|
|
834
|
+
echo "No $(scope_noun "$git_scope") Go files."
|
|
835
|
+
return 0
|
|
836
|
+
fi
|
|
837
|
+
else
|
|
838
|
+
mapfile -t go_files < <(list_repo_paths "$go_prefix" ".go")
|
|
839
|
+
if (( ${#go_files[@]} == 0 )); then
|
|
840
|
+
echo "=== Go ==="
|
|
841
|
+
echo "No Go files found."
|
|
842
|
+
return 0
|
|
843
|
+
fi
|
|
844
|
+
fi
|
|
845
|
+
|
|
846
|
+
echo "=== Go: gofmt ==="
|
|
847
|
+
local -a go_relative_files=()
|
|
848
|
+
mapfile -t go_relative_files < <(relativize_paths "$GO_PROJECT_DIR" "${go_files[@]}")
|
|
849
|
+
(cd "$GO_PROJECT_DIR" && gofmt -w "${go_relative_files[@]}")
|
|
850
|
+
|
|
851
|
+
echo "=== Go: goimports ==="
|
|
852
|
+
(cd "$GO_PROJECT_DIR" && goimports -w "${go_relative_files[@]}")
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
style_usage() {
|
|
856
|
+
cat <<'EOF'
|
|
857
|
+
Usage: style.sh <command> [options]
|
|
858
|
+
|
|
859
|
+
Commands:
|
|
860
|
+
lint Run linters for the current project root
|
|
861
|
+
format Format files for the current project root
|
|
862
|
+
init Initialize formatter/linter config files and optional local script bundles
|
|
863
|
+
|
|
864
|
+
Init targets:
|
|
865
|
+
docs, rust, ts, ts-node, python, go
|
|
866
|
+
|
|
867
|
+
Init bundle modes:
|
|
868
|
+
--copy Install or update the managed bundle in DIR/scripts/
|
|
869
|
+
--sync Install or update the managed bundle and remove stale previously-managed files
|
|
870
|
+
|
|
871
|
+
Git scope flags (mutually exclusive; accepted by lint and format):
|
|
872
|
+
--modified All modified files: staged + unstaged + untracked
|
|
873
|
+
--staged Only files staged in the git index
|
|
874
|
+
--unstaged Only unstaged working-tree changes + untracked files
|
|
875
|
+
|
|
876
|
+
Run `style.sh init --help` for full init options and target details.
|
|
877
|
+
|
|
878
|
+
Examples:
|
|
879
|
+
style.sh lint --fix --python
|
|
880
|
+
style.sh format --modified --go
|
|
881
|
+
style.sh lint --staged --shell --python
|
|
882
|
+
style.sh format --unstaged --docs
|
|
883
|
+
style.sh init --python --go --target ~/projects/my-app
|
|
884
|
+
style.sh init --copy --rust --ts-node ~/projects/my-app
|
|
885
|
+
EOF
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
lint_usage() {
|
|
889
|
+
cat <<'EOF'
|
|
890
|
+
Usage: style.sh lint [--fix] [--modified|--staged|--unstaged] [--rust] [--ts] [--docs] [--python] [--go] [--shell] [--all]
|
|
891
|
+
|
|
892
|
+
Environment overrides:
|
|
893
|
+
PROJECT_ROOT Explicit project root. Defaults to the git root for $PWD.
|
|
894
|
+
RUST_PROJECT_DIR Directory containing Cargo.toml. Defaults to PROJECT_ROOT.
|
|
895
|
+
TS_PROJECT_DIR Directory for package.json / tsconfig.json / biome runs.
|
|
896
|
+
Defaults to PROJECT_ROOT.
|
|
897
|
+
DOCS_PROJECT_DIR Directory for markdownlint and prettier runs. Defaults to PROJECT_ROOT.
|
|
898
|
+
PYTHON_PROJECT_DIR Directory for Python config and source files. Defaults to PROJECT_ROOT.
|
|
899
|
+
GO_PROJECT_DIR Directory for go.mod and Go source files. Defaults to PROJECT_ROOT.
|
|
900
|
+
|
|
901
|
+
Options:
|
|
902
|
+
--fix Apply auto-fixes where supported
|
|
903
|
+
--modified Limit file-based linting to all modified files (staged + unstaged + untracked)
|
|
904
|
+
--staged Limit file-based linting to files staged in the git index
|
|
905
|
+
--unstaged Limit file-based linting to unstaged working-tree changes + untracked files
|
|
906
|
+
--rust Rust only (clippy + rustfmt check)
|
|
907
|
+
--ts TypeScript / JavaScript / JSON only (biome + tsc when tsconfig exists)
|
|
908
|
+
--docs Docs only (Markdown/YAML; JSON/JSONC when no TS/JS track is detected)
|
|
909
|
+
--python Python only (ruff + black --check)
|
|
910
|
+
--go Go only (golangci-lint)
|
|
911
|
+
--shell Shell scripts only (shellcheck)
|
|
912
|
+
--all All supported lint checks (default)
|
|
913
|
+
|
|
914
|
+
--modified, --staged, and --unstaged are mutually exclusive.
|
|
915
|
+
EOF
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
format_usage() {
|
|
919
|
+
cat <<'EOF'
|
|
920
|
+
Usage: style.sh format [--modified|--staged|--unstaged] [--rust] [--ts] [--docs] [--python] [--go] [--all]
|
|
921
|
+
|
|
922
|
+
Environment overrides:
|
|
923
|
+
PROJECT_ROOT Explicit project root. Defaults to the git root for $PWD.
|
|
924
|
+
RUST_PROJECT_DIR Directory containing Cargo.toml. Defaults to PROJECT_ROOT.
|
|
925
|
+
TS_PROJECT_DIR Directory for package.json / biome runs. Defaults to PROJECT_ROOT.
|
|
926
|
+
DOCS_PROJECT_DIR Directory for prettier runs. Defaults to PROJECT_ROOT.
|
|
927
|
+
PYTHON_PROJECT_DIR Directory for Python config and source files. Defaults to PROJECT_ROOT.
|
|
928
|
+
GO_PROJECT_DIR Directory for go.mod and Go source files. Defaults to PROJECT_ROOT.
|
|
929
|
+
|
|
930
|
+
Options:
|
|
931
|
+
--modified Limit file-based formatting to all modified files (staged + unstaged + untracked)
|
|
932
|
+
--staged Limit file-based formatting to files staged in the git index
|
|
933
|
+
--unstaged Limit file-based formatting to unstaged working-tree changes + untracked files
|
|
934
|
+
--rust Rust only (rustfmt)
|
|
935
|
+
--ts TypeScript / JavaScript / JSON only (biome)
|
|
936
|
+
--docs Docs only (Markdown/YAML; JSON/JSONC when no TS/JS track is detected)
|
|
937
|
+
--python Python only (black)
|
|
938
|
+
--go Go only (gofmt + goimports)
|
|
939
|
+
--all All supported formatters (default)
|
|
940
|
+
|
|
941
|
+
--modified, --staged, and --unstaged are mutually exclusive.
|
|
942
|
+
EOF
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
init_usage() {
|
|
946
|
+
cat <<'EOF'
|
|
947
|
+
Usage: style.sh init [--copy|--sync] [--docs] [--rust] [--ts|--ts-node] [--python] [--go] [--shell] [--all] [--target DIR] [--force] [--yes] [--dry-run] [DIR]
|
|
948
|
+
|
|
949
|
+
Initialize formatter/linter config files for the current project root or a target directory.
|
|
950
|
+
|
|
951
|
+
Options:
|
|
952
|
+
--docs Initialize markdownlint and prettier config files
|
|
953
|
+
--rust Initialize rustfmt and clippy config files
|
|
954
|
+
--ts Initialize Node/TypeScript linting config files
|
|
955
|
+
--ts-node Alias for --ts
|
|
956
|
+
--python Initialize Python Ruff + Black config via pyproject.toml
|
|
957
|
+
--go Initialize .golangci.yml config
|
|
958
|
+
--shell Initialize shell tooling support (.gitignore for /tools/shellcheck)
|
|
959
|
+
--all Initialize docs, Rust, TS, Python, Go, and shell tooling support
|
|
960
|
+
--copy Copy the managed style bundle into DIR/scripts/ before initializing configs
|
|
961
|
+
--sync Copy the managed style bundle and prune stale previously-managed files
|
|
962
|
+
-t, --target <dir> Target directory
|
|
963
|
+
--force Overwrite existing files without prompt
|
|
964
|
+
-y, --yes Non-interactive mode; keep existing files
|
|
965
|
+
--dry-run Show actions without writing files
|
|
966
|
+
|
|
967
|
+
Defaults:
|
|
968
|
+
Without --copy/--sync, the target defaults to PROJECT_ROOT.
|
|
969
|
+
With --copy/--sync, the target defaults to the current directory.
|
|
970
|
+
EOF
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
copy_file_with_policy() {
|
|
974
|
+
local src="$1"
|
|
975
|
+
local dest="$2"
|
|
976
|
+
local force="$3"
|
|
977
|
+
local assume_yes="$4"
|
|
978
|
+
local dry_run="$5"
|
|
979
|
+
local action="create"
|
|
980
|
+
|
|
981
|
+
if [[ -e "$dest" ]]; then
|
|
982
|
+
action="overwrite"
|
|
983
|
+
if (( dry_run )); then
|
|
984
|
+
if (( !force && assume_yes )); then
|
|
985
|
+
print_info "[dry-run] Would keep existing file: $dest"
|
|
986
|
+
return 20
|
|
987
|
+
fi
|
|
988
|
+
print_info "[dry-run] Would ${action}: $dest"
|
|
989
|
+
return 20
|
|
990
|
+
fi
|
|
991
|
+
|
|
992
|
+
if (( !force )); then
|
|
993
|
+
if (( assume_yes )); then
|
|
994
|
+
print_info "Keeping existing file: $dest"
|
|
995
|
+
return 10
|
|
996
|
+
fi
|
|
997
|
+
|
|
998
|
+
local response
|
|
999
|
+
read -r -p "Overwrite existing file ${dest}? [y/N] " response
|
|
1000
|
+
if [[ ! "$response" =~ ^[Yy]$ ]]; then
|
|
1001
|
+
print_info "Keeping existing file: $dest"
|
|
1002
|
+
return 10
|
|
1003
|
+
fi
|
|
1004
|
+
fi
|
|
1005
|
+
fi
|
|
1006
|
+
|
|
1007
|
+
if (( dry_run )); then
|
|
1008
|
+
print_info "[dry-run] Would ${action}: $dest"
|
|
1009
|
+
return 20
|
|
1010
|
+
fi
|
|
1011
|
+
|
|
1012
|
+
mkdir -p "$(dirname "$dest")"
|
|
1013
|
+
cp "$src" "$dest"
|
|
1014
|
+
if [[ "$action" == "overwrite" ]]; then
|
|
1015
|
+
print_info "Overwrote: $dest"
|
|
1016
|
+
else
|
|
1017
|
+
print_info "Created: $dest"
|
|
1018
|
+
fi
|
|
1019
|
+
return 0
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
write_bundle_manifest() {
|
|
1023
|
+
local bundle_dir="$1"
|
|
1024
|
+
local dry_run="$2"
|
|
1025
|
+
local manifest_path="${bundle_dir}/${BUNDLE_MANIFEST_FILE}"
|
|
1026
|
+
|
|
1027
|
+
if (( dry_run )); then
|
|
1028
|
+
print_info "[dry-run] Would write manifest: $manifest_path"
|
|
1029
|
+
return 0
|
|
1030
|
+
fi
|
|
1031
|
+
|
|
1032
|
+
mkdir -p "$bundle_dir"
|
|
1033
|
+
{
|
|
1034
|
+
printf '# Managed by style.sh init\n'
|
|
1035
|
+
local rel_path
|
|
1036
|
+
for rel_path in "${BUNDLE_MANAGED_FILES[@]}"; do
|
|
1037
|
+
printf '%s\n' "$rel_path"
|
|
1038
|
+
done
|
|
1039
|
+
} > "$manifest_path"
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
sync_bundle_removals() {
|
|
1043
|
+
local bundle_dir="$1"
|
|
1044
|
+
local dry_run="$2"
|
|
1045
|
+
local manifest_path="${bundle_dir}/${BUNDLE_MANIFEST_FILE}"
|
|
1046
|
+
|
|
1047
|
+
if [[ ! -f "$manifest_path" ]]; then
|
|
1048
|
+
return 0
|
|
1049
|
+
fi
|
|
1050
|
+
|
|
1051
|
+
local rel_path dest_path
|
|
1052
|
+
while IFS= read -r rel_path; do
|
|
1053
|
+
[[ -z "$rel_path" ]] && continue
|
|
1054
|
+
[[ "$rel_path" == \#* ]] && continue
|
|
1055
|
+
if array_contains "$rel_path" "${BUNDLE_MANAGED_FILES[@]}"; then
|
|
1056
|
+
continue
|
|
1057
|
+
fi
|
|
1058
|
+
|
|
1059
|
+
dest_path="${bundle_dir}/${rel_path}"
|
|
1060
|
+
if [[ ! -e "$dest_path" ]]; then
|
|
1061
|
+
continue
|
|
1062
|
+
fi
|
|
1063
|
+
|
|
1064
|
+
if (( dry_run )); then
|
|
1065
|
+
print_info "[dry-run] Would remove stale managed file: $dest_path"
|
|
1066
|
+
continue
|
|
1067
|
+
fi
|
|
1068
|
+
|
|
1069
|
+
rm -f "$dest_path"
|
|
1070
|
+
print_info "Removed stale managed file: $dest_path"
|
|
1071
|
+
done < "$manifest_path"
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
install_managed_bundle() {
|
|
1075
|
+
local target_dir="$1"
|
|
1076
|
+
local sync_mode="$2"
|
|
1077
|
+
local force="$3"
|
|
1078
|
+
local assume_yes="$4"
|
|
1079
|
+
local dry_run="$5"
|
|
1080
|
+
local bundle_dir="${target_dir}/${BUNDLE_DEST_DIR_NAME}"
|
|
1081
|
+
local exit_code=0
|
|
1082
|
+
|
|
1083
|
+
if (( sync_mode )); then
|
|
1084
|
+
sync_bundle_removals "$bundle_dir" "$dry_run"
|
|
1085
|
+
fi
|
|
1086
|
+
|
|
1087
|
+
local rel_path src_path dest_path
|
|
1088
|
+
local copy_status
|
|
1089
|
+
for rel_path in "${BUNDLE_MANAGED_FILES[@]}"; do
|
|
1090
|
+
src_path="${SCRIPT_DIR}/${rel_path}"
|
|
1091
|
+
dest_path="${bundle_dir}/${rel_path}"
|
|
1092
|
+
|
|
1093
|
+
if [[ ! -f "$src_path" ]]; then
|
|
1094
|
+
echo "Managed bundle source missing: $src_path" >&2
|
|
1095
|
+
exit 1
|
|
1096
|
+
fi
|
|
1097
|
+
|
|
1098
|
+
if copy_file_with_policy "$src_path" "$dest_path" "$force" "$assume_yes" "$dry_run"; then
|
|
1099
|
+
copy_status=0
|
|
1100
|
+
else
|
|
1101
|
+
copy_status=$?
|
|
1102
|
+
fi
|
|
1103
|
+
case "$copy_status" in
|
|
1104
|
+
0|10|20) ;;
|
|
1105
|
+
*) exit_code=1 ;;
|
|
1106
|
+
esac
|
|
1107
|
+
done
|
|
1108
|
+
|
|
1109
|
+
write_bundle_manifest "$bundle_dir" "$dry_run"
|
|
1110
|
+
return "$exit_code"
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
_set_git_scope_or_die() {
|
|
1114
|
+
local -n _scope_ref="$1"
|
|
1115
|
+
local new_scope="$2"
|
|
1116
|
+
local usage_fn="$3"
|
|
1117
|
+
|
|
1118
|
+
if [[ -n "$_scope_ref" ]]; then
|
|
1119
|
+
echo "Cannot combine --modified, --staged, and --unstaged (already set to '${_scope_ref}')." >&2
|
|
1120
|
+
"$usage_fn" >&2
|
|
1121
|
+
exit 1
|
|
1122
|
+
fi
|
|
1123
|
+
_scope_ref="$new_scope"
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
run_lint_command() {
|
|
1127
|
+
local fix=0
|
|
1128
|
+
local git_scope=""
|
|
1129
|
+
local run_rust=0
|
|
1130
|
+
local run_ts=0
|
|
1131
|
+
local run_docs=0
|
|
1132
|
+
local run_python=0
|
|
1133
|
+
local run_go=0
|
|
1134
|
+
local run_shell=0
|
|
1135
|
+
local exit_code=0
|
|
1136
|
+
|
|
1137
|
+
while [[ $# -gt 0 ]]; do
|
|
1138
|
+
case "$1" in
|
|
1139
|
+
--fix) fix=1; shift ;;
|
|
1140
|
+
--modified) _set_git_scope_or_die git_scope all lint_usage; shift ;;
|
|
1141
|
+
--staged) _set_git_scope_or_die git_scope staged lint_usage; shift ;;
|
|
1142
|
+
--unstaged) _set_git_scope_or_die git_scope unstaged lint_usage; shift ;;
|
|
1143
|
+
--rust) run_rust=1; shift ;;
|
|
1144
|
+
--ts) run_ts=1; shift ;;
|
|
1145
|
+
--docs) run_docs=1; shift ;;
|
|
1146
|
+
--python) run_python=1; shift ;;
|
|
1147
|
+
--go) run_go=1; shift ;;
|
|
1148
|
+
--shell) run_shell=1; shift ;;
|
|
1149
|
+
--all) run_rust=1; run_ts=1; run_docs=1; run_python=1; run_go=1; run_shell=1; shift ;;
|
|
1150
|
+
--help|-h) lint_usage; exit 0 ;;
|
|
1151
|
+
*) echo "Unknown arg for lint: $1" >&2; lint_usage >&2; exit 1 ;;
|
|
1152
|
+
esac
|
|
1153
|
+
done
|
|
1154
|
+
|
|
1155
|
+
if (( !run_rust && !run_ts && !run_docs && !run_python && !run_go && !run_shell )); then
|
|
1156
|
+
run_rust=1
|
|
1157
|
+
run_ts=1
|
|
1158
|
+
run_docs=1
|
|
1159
|
+
run_python=1
|
|
1160
|
+
run_go=1
|
|
1161
|
+
run_shell=1
|
|
1162
|
+
fi
|
|
1163
|
+
|
|
1164
|
+
if (( run_rust )); then
|
|
1165
|
+
run_rust_lint "$fix" "$git_scope" || exit_code=1
|
|
1166
|
+
fi
|
|
1167
|
+
if (( run_ts )); then
|
|
1168
|
+
run_ts_lint "$fix" "$git_scope" || exit_code=1
|
|
1169
|
+
fi
|
|
1170
|
+
if (( run_docs )); then
|
|
1171
|
+
run_docs_lint "$fix" "$git_scope" || exit_code=1
|
|
1172
|
+
fi
|
|
1173
|
+
if (( run_python )); then
|
|
1174
|
+
run_python_lint "$fix" "$git_scope" || exit_code=1
|
|
1175
|
+
fi
|
|
1176
|
+
if (( run_go )); then
|
|
1177
|
+
run_go_lint "$fix" "$git_scope" || exit_code=1
|
|
1178
|
+
fi
|
|
1179
|
+
if (( run_shell )); then
|
|
1180
|
+
run_shell_lint "$git_scope" || exit_code=1
|
|
1181
|
+
fi
|
|
1182
|
+
|
|
1183
|
+
exit "$exit_code"
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
run_format_command() {
|
|
1187
|
+
local git_scope=""
|
|
1188
|
+
local run_rust=0
|
|
1189
|
+
local run_ts=0
|
|
1190
|
+
local run_docs=0
|
|
1191
|
+
local run_python=0
|
|
1192
|
+
local run_go=0
|
|
1193
|
+
local exit_code=0
|
|
1194
|
+
|
|
1195
|
+
while [[ $# -gt 0 ]]; do
|
|
1196
|
+
case "$1" in
|
|
1197
|
+
--modified) _set_git_scope_or_die git_scope all format_usage; shift ;;
|
|
1198
|
+
--staged) _set_git_scope_or_die git_scope staged format_usage; shift ;;
|
|
1199
|
+
--unstaged) _set_git_scope_or_die git_scope unstaged format_usage; shift ;;
|
|
1200
|
+
--rust) run_rust=1; shift ;;
|
|
1201
|
+
--ts) run_ts=1; shift ;;
|
|
1202
|
+
--docs) run_docs=1; shift ;;
|
|
1203
|
+
--python) run_python=1; shift ;;
|
|
1204
|
+
--go) run_go=1; shift ;;
|
|
1205
|
+
--all) run_rust=1; run_ts=1; run_docs=1; run_python=1; run_go=1; shift ;;
|
|
1206
|
+
--help|-h) format_usage; exit 0 ;;
|
|
1207
|
+
*) echo "Unknown arg for format: $1" >&2; format_usage >&2; exit 1 ;;
|
|
1208
|
+
esac
|
|
1209
|
+
done
|
|
1210
|
+
|
|
1211
|
+
if (( !run_rust && !run_ts && !run_docs && !run_python && !run_go )); then
|
|
1212
|
+
run_rust=1
|
|
1213
|
+
run_ts=1
|
|
1214
|
+
run_docs=1
|
|
1215
|
+
run_python=1
|
|
1216
|
+
run_go=1
|
|
1217
|
+
fi
|
|
1218
|
+
|
|
1219
|
+
if (( run_rust )); then
|
|
1220
|
+
run_rust_format "$git_scope" || exit_code=1
|
|
1221
|
+
fi
|
|
1222
|
+
if (( run_ts )); then
|
|
1223
|
+
run_ts_format "$git_scope" || exit_code=1
|
|
1224
|
+
fi
|
|
1225
|
+
if (( run_docs )); then
|
|
1226
|
+
run_docs_format "$git_scope" || exit_code=1
|
|
1227
|
+
fi
|
|
1228
|
+
if (( run_python )); then
|
|
1229
|
+
run_python_format "$git_scope" || exit_code=1
|
|
1230
|
+
fi
|
|
1231
|
+
if (( run_go )); then
|
|
1232
|
+
run_go_format "$git_scope" || exit_code=1
|
|
1233
|
+
fi
|
|
1234
|
+
|
|
1235
|
+
if (( exit_code == 0 )); then
|
|
1236
|
+
echo "All formatting complete."
|
|
1237
|
+
fi
|
|
1238
|
+
exit "$exit_code"
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
run_init_command() {
|
|
1242
|
+
local init_docs=0
|
|
1243
|
+
local init_rust=0
|
|
1244
|
+
local init_ts=0
|
|
1245
|
+
local init_python=0
|
|
1246
|
+
local init_go=0
|
|
1247
|
+
local init_shell=0
|
|
1248
|
+
local copy_bundle=0
|
|
1249
|
+
local sync_bundle=0
|
|
1250
|
+
local force=0
|
|
1251
|
+
local dry_run=0
|
|
1252
|
+
local assume_yes=0
|
|
1253
|
+
local target_dir=''
|
|
1254
|
+
local target_set=0
|
|
1255
|
+
|
|
1256
|
+
while [[ $# -gt 0 ]]; do
|
|
1257
|
+
case "$1" in
|
|
1258
|
+
--docs) init_docs=1; shift ;;
|
|
1259
|
+
--rust) init_rust=1; shift ;;
|
|
1260
|
+
--ts|--ts-node) init_ts=1; shift ;;
|
|
1261
|
+
--python) init_python=1; shift ;;
|
|
1262
|
+
--go) init_go=1; shift ;;
|
|
1263
|
+
--shell) init_shell=1; shift ;;
|
|
1264
|
+
--copy) copy_bundle=1; shift ;;
|
|
1265
|
+
--sync) sync_bundle=1; shift ;;
|
|
1266
|
+
--all) init_docs=1; init_rust=1; init_ts=1; init_python=1; init_go=1; init_shell=1; shift ;;
|
|
1267
|
+
-t|--target)
|
|
1268
|
+
if [[ $# -lt 2 ]]; then
|
|
1269
|
+
echo "Missing value for $1" >&2
|
|
1270
|
+
init_usage >&2
|
|
1271
|
+
exit 1
|
|
1272
|
+
fi
|
|
1273
|
+
target_dir="$2"
|
|
1274
|
+
target_set=1
|
|
1275
|
+
shift 2
|
|
1276
|
+
;;
|
|
1277
|
+
--force) force=1; shift ;;
|
|
1278
|
+
--dry-run) dry_run=1; shift ;;
|
|
1279
|
+
-y|--yes) assume_yes=1; shift ;;
|
|
1280
|
+
--help|-h)
|
|
1281
|
+
init_usage
|
|
1282
|
+
exit 0
|
|
1283
|
+
;;
|
|
1284
|
+
*)
|
|
1285
|
+
if (( target_set )); then
|
|
1286
|
+
echo "Unknown arg for init: $1" >&2
|
|
1287
|
+
init_usage >&2
|
|
1288
|
+
exit 1
|
|
1289
|
+
fi
|
|
1290
|
+
target_dir="$1"
|
|
1291
|
+
target_set=1
|
|
1292
|
+
shift
|
|
1293
|
+
;;
|
|
1294
|
+
esac
|
|
1295
|
+
done
|
|
1296
|
+
|
|
1297
|
+
if (( copy_bundle && sync_bundle )); then
|
|
1298
|
+
echo "Use only one of --copy or --sync." >&2
|
|
1299
|
+
init_usage >&2
|
|
1300
|
+
exit 1
|
|
1301
|
+
fi
|
|
1302
|
+
|
|
1303
|
+
if [[ -z "$target_dir" ]]; then
|
|
1304
|
+
if (( copy_bundle || sync_bundle )); then
|
|
1305
|
+
target_dir="$PWD"
|
|
1306
|
+
else
|
|
1307
|
+
target_dir="$PROJECT_ROOT"
|
|
1308
|
+
fi
|
|
1309
|
+
fi
|
|
1310
|
+
|
|
1311
|
+
local resolved_target
|
|
1312
|
+
resolved_target="$(cd "$target_dir" >/dev/null 2>&1 && pwd)" || {
|
|
1313
|
+
echo "Target directory does not exist: $target_dir" >&2
|
|
1314
|
+
exit 1
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
if (( !init_docs && !init_rust && !init_ts && !init_python && !init_go && !init_shell )); then
|
|
1318
|
+
if detect_docs_project "$resolved_target"; then
|
|
1319
|
+
init_docs=1
|
|
1320
|
+
fi
|
|
1321
|
+
if detect_rust_project "$resolved_target"; then
|
|
1322
|
+
init_rust=1
|
|
1323
|
+
fi
|
|
1324
|
+
if detect_ts_project "$resolved_target"; then
|
|
1325
|
+
init_ts=1
|
|
1326
|
+
fi
|
|
1327
|
+
if can_init_python_project "$resolved_target"; then
|
|
1328
|
+
init_python=1
|
|
1329
|
+
fi
|
|
1330
|
+
if detect_go_project "$resolved_target"; then
|
|
1331
|
+
init_go=1
|
|
1332
|
+
fi
|
|
1333
|
+
if detect_shell_project "$resolved_target"; then
|
|
1334
|
+
init_shell=1
|
|
1335
|
+
fi
|
|
1336
|
+
fi
|
|
1337
|
+
|
|
1338
|
+
if (( !init_docs && !init_rust && !init_ts && !init_python && !init_go && !init_shell )); then
|
|
1339
|
+
print_info "No supported config families detected. Defaulting to docs initialization."
|
|
1340
|
+
init_docs=1
|
|
1341
|
+
fi
|
|
1342
|
+
|
|
1343
|
+
if (( copy_bundle || sync_bundle )); then
|
|
1344
|
+
install_managed_bundle "$resolved_target" "$sync_bundle" "$force" "$assume_yes" "$dry_run"
|
|
1345
|
+
fi
|
|
1346
|
+
|
|
1347
|
+
local -a init_args=()
|
|
1348
|
+
if (( init_docs )); then
|
|
1349
|
+
init_args+=(--docs)
|
|
1350
|
+
fi
|
|
1351
|
+
if (( init_rust )); then
|
|
1352
|
+
init_args+=(--rust)
|
|
1353
|
+
fi
|
|
1354
|
+
if (( init_ts )); then
|
|
1355
|
+
init_args+=(--ts)
|
|
1356
|
+
fi
|
|
1357
|
+
if (( init_python )); then
|
|
1358
|
+
init_args+=(--python)
|
|
1359
|
+
fi
|
|
1360
|
+
if (( init_go )); then
|
|
1361
|
+
init_args+=(--go)
|
|
1362
|
+
fi
|
|
1363
|
+
if (( init_shell )); then
|
|
1364
|
+
init_args+=(--shell)
|
|
1365
|
+
fi
|
|
1366
|
+
if (( force )); then
|
|
1367
|
+
init_args+=(--force)
|
|
1368
|
+
fi
|
|
1369
|
+
if (( assume_yes )); then
|
|
1370
|
+
init_args+=(--yes)
|
|
1371
|
+
fi
|
|
1372
|
+
if (( dry_run )); then
|
|
1373
|
+
init_args+=(--dry-run)
|
|
1374
|
+
fi
|
|
1375
|
+
init_args+=(--target "$resolved_target")
|
|
1376
|
+
|
|
1377
|
+
"$SCRIPT_DIR/init-formatters.sh" "${init_args[@]}"
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
main() {
|
|
1381
|
+
if (( $# == 0 )); then
|
|
1382
|
+
style_usage
|
|
1383
|
+
exit 1
|
|
1384
|
+
fi
|
|
1385
|
+
|
|
1386
|
+
local command="$1"
|
|
1387
|
+
shift
|
|
1388
|
+
|
|
1389
|
+
case "$command" in
|
|
1390
|
+
lint)
|
|
1391
|
+
run_lint_command "$@"
|
|
1392
|
+
;;
|
|
1393
|
+
format)
|
|
1394
|
+
run_format_command "$@"
|
|
1395
|
+
;;
|
|
1396
|
+
init)
|
|
1397
|
+
run_init_command "$@"
|
|
1398
|
+
;;
|
|
1399
|
+
--help|-h|help)
|
|
1400
|
+
style_usage
|
|
1401
|
+
;;
|
|
1402
|
+
*)
|
|
1403
|
+
echo "Unknown command: $command" >&2
|
|
1404
|
+
style_usage >&2
|
|
1405
|
+
exit 1
|
|
1406
|
+
;;
|
|
1407
|
+
esac
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
main "$@"
|