flyee 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/bin/install.js +357 -0
- package/bridge/bridge.py +1780 -0
- package/bridge/local_tracker.py +722 -0
- package/core/agents/backend-specialist.md +266 -0
- package/core/agents/code-archaeologist.md +106 -0
- package/core/agents/database-architect.md +226 -0
- package/core/agents/debugger.md +225 -0
- package/core/agents/devops-engineer.md +323 -0
- package/core/agents/documentation-writer.md +104 -0
- package/core/agents/explorer-agent.md +73 -0
- package/core/agents/frontend-specialist.md +743 -0
- package/core/agents/game-developer.md +162 -0
- package/core/agents/mobile-developer.md +377 -0
- package/core/agents/orchestrator.md +416 -0
- package/core/agents/penetration-tester.md +188 -0
- package/core/agents/performance-optimizer.md +187 -0
- package/core/agents/product-manager.md +112 -0
- package/core/agents/product-owner.md +95 -0
- package/core/agents/project-planner.md +470 -0
- package/core/agents/qa-automation-engineer.md +103 -0
- package/core/agents/security-auditor.md +170 -0
- package/core/agents/seo-specialist.md +111 -0
- package/core/agents/stitch-designer.md +190 -0
- package/core/agents/tdd-reviewer.md +282 -0
- package/core/agents/test-engineer.md +158 -0
- package/core/scripts/auto_preview.py +148 -0
- package/core/scripts/checklist.py +243 -0
- package/core/scripts/cost_report.py +149 -0
- package/core/scripts/doc-sync-check.py +461 -0
- package/core/scripts/parse_user_stories.py +79 -0
- package/core/scripts/prepare_notion_updates.py +172 -0
- package/core/scripts/print_create_payload.py +18 -0
- package/core/scripts/session_manager.py +120 -0
- package/core/scripts/task_complete.py +127 -0
- package/core/scripts/verify_all.py +327 -0
- package/core/skills/analytics-strategy/SKILL.md +128 -0
- package/core/skills/api-patterns/SKILL.md +81 -0
- package/core/skills/api-patterns/api-style.md +42 -0
- package/core/skills/api-patterns/auth.md +24 -0
- package/core/skills/api-patterns/documentation.md +26 -0
- package/core/skills/api-patterns/graphql.md +41 -0
- package/core/skills/api-patterns/rate-limiting.md +31 -0
- package/core/skills/api-patterns/response.md +37 -0
- package/core/skills/api-patterns/rest.md +40 -0
- package/core/skills/api-patterns/scripts/api_validator.py +211 -0
- package/core/skills/api-patterns/security-testing.md +122 -0
- package/core/skills/api-patterns/trpc.md +41 -0
- package/core/skills/api-patterns/versioning.md +22 -0
- package/core/skills/app-builder/SKILL.md +75 -0
- package/core/skills/app-builder/agent-coordination.md +71 -0
- package/core/skills/app-builder/feature-building.md +53 -0
- package/core/skills/app-builder/project-detection.md +34 -0
- package/core/skills/app-builder/scaffolding.md +118 -0
- package/core/skills/app-builder/tech-stack.md +40 -0
- package/core/skills/app-builder/templates/SKILL.md +39 -0
- package/core/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/core/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/core/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/core/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/core/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/core/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/core/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/core/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/core/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/core/skills/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/core/skills/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/core/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/core/skills/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/core/skills/architecture/SKILL.md +55 -0
- package/core/skills/architecture/context-discovery.md +43 -0
- package/core/skills/architecture/examples.md +94 -0
- package/core/skills/architecture/pattern-selection.md +68 -0
- package/core/skills/architecture/patterns-reference.md +50 -0
- package/core/skills/architecture/trade-off-analysis.md +77 -0
- package/core/skills/atomic-design/SKILL.md +282 -0
- package/core/skills/atomic-design/references/classification-guide.md +132 -0
- package/core/skills/atomic-design/references/quality-checklist.md +60 -0
- package/core/skills/atomic-design/references/stacks/stack-blade.md +254 -0
- package/core/skills/atomic-design/references/stacks/stack-nextjs.md +272 -0
- package/core/skills/atomic-design/references/stacks/stack-react.md +239 -0
- package/core/skills/atomic-design/references/stacks/stack-vue.md +224 -0
- package/core/skills/bash-linux/SKILL.md +199 -0
- package/core/skills/behavioral-modes/SKILL.md +242 -0
- package/core/skills/brainstorming/SKILL.md +163 -0
- package/core/skills/brainstorming/dynamic-questioning.md +373 -0
- package/core/skills/checkpointing-patterns/SKILL.md +163 -0
- package/core/skills/clean-code/SKILL.md +201 -0
- package/core/skills/code-review-checklist/SKILL.md +109 -0
- package/core/skills/code-truth-validation/SKILL.md +149 -0
- package/core/skills/component-library-discovery/SKILL.md +154 -0
- package/core/skills/content-strategy/SKILL.md +222 -0
- package/core/skills/context-budget/SKILL.md +155 -0
- package/core/skills/context-gathering-patterns/SKILL.md +278 -0
- package/core/skills/cost-tracking/SKILL.md +206 -0
- package/core/skills/database-design/SKILL.md +52 -0
- package/core/skills/database-design/database-selection.md +43 -0
- package/core/skills/database-design/indexing.md +39 -0
- package/core/skills/database-design/migrations.md +48 -0
- package/core/skills/database-design/optimization.md +36 -0
- package/core/skills/database-design/orm-selection.md +30 -0
- package/core/skills/database-design/schema-design.md +56 -0
- package/core/skills/database-design/scripts/schema_validator.py +172 -0
- package/core/skills/deployment-procedures/SKILL.md +295 -0
- package/core/skills/design-md/README.md +34 -0
- package/core/skills/design-md/SKILL.md +172 -0
- package/core/skills/design-md/examples/DESIGN.md +154 -0
- package/core/skills/design-system-enforcement/SKILL.md +339 -0
- package/core/skills/doc.md +177 -0
- package/core/skills/document-registry/SKILL.md +130 -0
- package/core/skills/documentation-publishing/SKILL.md +174 -0
- package/core/skills/documentation-templates/SKILL.md +194 -0
- package/core/skills/enhance-prompt/README.md +34 -0
- package/core/skills/enhance-prompt/SKILL.md +204 -0
- package/core/skills/enhance-prompt/references/KEYWORDS.md +114 -0
- package/core/skills/frontend-design/SKILL.md +430 -0
- package/core/skills/frontend-design/animation-guide.md +331 -0
- package/core/skills/frontend-design/color-system.md +311 -0
- package/core/skills/frontend-design/decision-trees.md +418 -0
- package/core/skills/frontend-design/motion-graphics.md +306 -0
- package/core/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/core/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/core/skills/frontend-design/typography-system.md +345 -0
- package/core/skills/frontend-design/ux-psychology.md +541 -0
- package/core/skills/frontend-design/visual-effects.md +383 -0
- package/core/skills/game-development/2d-games/SKILL.md +119 -0
- package/core/skills/game-development/3d-games/SKILL.md +135 -0
- package/core/skills/game-development/SKILL.md +167 -0
- package/core/skills/game-development/game-art/SKILL.md +185 -0
- package/core/skills/game-development/game-audio/SKILL.md +190 -0
- package/core/skills/game-development/game-design/SKILL.md +129 -0
- package/core/skills/game-development/mobile-games/SKILL.md +108 -0
- package/core/skills/game-development/multiplayer/SKILL.md +132 -0
- package/core/skills/game-development/pc-games/SKILL.md +144 -0
- package/core/skills/game-development/vr-ar/SKILL.md +123 -0
- package/core/skills/game-development/web-games/SKILL.md +150 -0
- package/core/skills/geo-fundamentals/SKILL.md +156 -0
- package/core/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/core/skills/git-workflow/SKILL.md +263 -0
- package/core/skills/history-check-patterns/SKILL.md +125 -0
- package/core/skills/i18n-localization/SKILL.md +154 -0
- package/core/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/core/skills/integration-completeness/SKILL.md +219 -0
- package/core/skills/intelligent-routing/SKILL.md +370 -0
- package/core/skills/lint-and-validate/SKILL.md +45 -0
- package/core/skills/lint-and-validate/scripts/lint_runner.py +173 -0
- package/core/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/core/skills/local-verification/SKILL.md +195 -0
- package/core/skills/mcp-builder/SKILL.md +176 -0
- package/core/skills/mobile-design/SKILL.md +394 -0
- package/core/skills/mobile-design/decision-trees.md +516 -0
- package/core/skills/mobile-design/mobile-backend.md +491 -0
- package/core/skills/mobile-design/mobile-color-system.md +420 -0
- package/core/skills/mobile-design/mobile-debugging.md +122 -0
- package/core/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/core/skills/mobile-design/mobile-navigation.md +458 -0
- package/core/skills/mobile-design/mobile-performance.md +767 -0
- package/core/skills/mobile-design/mobile-testing.md +356 -0
- package/core/skills/mobile-design/mobile-typography.md +433 -0
- package/core/skills/mobile-design/platform-android.md +666 -0
- package/core/skills/mobile-design/platform-ios.md +561 -0
- package/core/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/core/skills/mobile-design/touch-psychology.md +537 -0
- package/core/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/core/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/core/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/core/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/core/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/core/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/core/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/core/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/core/skills/nextjs-react-expert/SKILL.md +267 -0
- package/core/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/core/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/core/skills/nodejs-best-practices/SKILL.md +333 -0
- package/core/skills/notion-task-patterns/SKILL.md +2529 -0
- package/core/skills/page-specifications/SKILL.md +367 -0
- package/core/skills/parallel-agents/SKILL.md +175 -0
- package/core/skills/performance-profiling/SKILL.md +143 -0
- package/core/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/core/skills/plan-writing/SKILL.md +190 -0
- package/core/skills/powershell-windows/SKILL.md +167 -0
- package/core/skills/project-foundation/SKILL.md +117 -0
- package/core/skills/project-setup/SKILL.md +141 -0
- package/core/skills/project-tracking-patterns/SKILL.md +357 -0
- package/core/skills/project-type-discovery/SKILL.md +239 -0
- package/core/skills/python-patterns/SKILL.md +441 -0
- package/core/skills/qa-test-generation/SKILL.md +156 -0
- package/core/skills/react-components/README.md +36 -0
- package/core/skills/react-components/SKILL.md +47 -0
- package/core/skills/react-components/examples/gold-standard-card.tsx +80 -0
- package/core/skills/react-components/package-lock.json +231 -0
- package/core/skills/react-components/package.json +16 -0
- package/core/skills/react-components/resources/architecture-checklist.md +15 -0
- package/core/skills/react-components/resources/component-template.tsx +37 -0
- package/core/skills/react-components/resources/stitch-api-reference.md +14 -0
- package/core/skills/react-components/resources/style-guide.json +27 -0
- package/core/skills/react-components/scripts/fetch-stitch.sh +30 -0
- package/core/skills/react-components/scripts/validate.js +68 -0
- package/core/skills/red-team-tactics/SKILL.md +199 -0
- package/core/skills/remotion/README.md +105 -0
- package/core/skills/remotion/SKILL.md +393 -0
- package/core/skills/remotion/examples/WalkthroughComposition.tsx +78 -0
- package/core/skills/remotion/examples/screens.json +56 -0
- package/core/skills/remotion/resources/composition-checklist.md +124 -0
- package/core/skills/remotion/resources/screen-slide-template.tsx +123 -0
- package/core/skills/remotion/scripts/download-stitch-asset.sh +38 -0
- package/core/skills/seo-fundamentals/SKILL.md +129 -0
- package/core/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/core/skills/server-management/SKILL.md +161 -0
- package/core/skills/session-resilience/SKILL.md +199 -0
- package/core/skills/shadcn-ui/README.md +248 -0
- package/core/skills/shadcn-ui/SKILL.md +326 -0
- package/core/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
- package/core/skills/shadcn-ui/examples/data-table.tsx +313 -0
- package/core/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
- package/core/skills/shadcn-ui/resources/component-catalog.md +481 -0
- package/core/skills/shadcn-ui/resources/customization-guide.md +516 -0
- package/core/skills/shadcn-ui/resources/migration-guide.md +463 -0
- package/core/skills/shadcn-ui/resources/setup-guide.md +412 -0
- package/core/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
- package/core/skills/state-machine/SKILL.md +264 -0
- package/core/skills/stitch-loop/README.md +54 -0
- package/core/skills/stitch-loop/SKILL.md +203 -0
- package/core/skills/stitch-loop/examples/SITE.md +73 -0
- package/core/skills/stitch-loop/examples/next-prompt.md +25 -0
- package/core/skills/stitch-loop/resources/baton-schema.md +61 -0
- package/core/skills/stitch-loop/resources/site-template.md +104 -0
- package/core/skills/systematic-debugging/SKILL.md +109 -0
- package/core/skills/tailwind-patterns/SKILL.md +284 -0
- package/core/skills/tdd-validation/SKILL.md +243 -0
- package/core/skills/tdd-workflow/SKILL.md +284 -0
- package/core/skills/testing-patterns/SKILL.md +196 -0
- package/core/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/core/skills/ui-ux-discovery/SKILL.md +329 -0
- package/core/skills/ui-validation/SKILL.md +190 -0
- package/core/skills/ui-validation/scripts/ui_antipattern_check.py +317 -0
- package/core/skills/verification-gate/SKILL.md +205 -0
- package/core/skills/vulnerability-scanner/SKILL.md +276 -0
- package/core/skills/vulnerability-scanner/checklists.md +121 -0
- package/core/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/core/skills/web-design-guidelines/SKILL.md +57 -0
- package/core/skills/webapp-testing/SKILL.md +187 -0
- package/core/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/core/templates/ARCHITECTURE.template.md +407 -0
- package/core/templates/project-resources.example.json +71 -0
- package/core/workflows/atomic.md +182 -0
- package/core/workflows/brainstorm.md +134 -0
- package/core/workflows/check-task.md +242 -0
- package/core/workflows/copy-collect.md +306 -0
- package/core/workflows/create-agent.md +33 -0
- package/core/workflows/create-skill.md +39 -0
- package/core/workflows/create-workflow.md +33 -0
- package/core/workflows/create.md +92 -0
- package/core/workflows/debug.md +186 -0
- package/core/workflows/demand.md +443 -0
- package/core/workflows/deploy.md +260 -0
- package/core/workflows/discovery.md +267 -0
- package/core/workflows/document.md +272 -0
- package/core/workflows/ds-components.md +296 -0
- package/core/workflows/ds-init.md +58 -0
- package/core/workflows/ds-refactor.md +245 -0
- package/core/workflows/ds-references.md +197 -0
- package/core/workflows/ds-styleguide.md +237 -0
- package/core/workflows/ds-token-diff.md +103 -0
- package/core/workflows/ds-tokens.md +317 -0
- package/core/workflows/ds-validate.md +309 -0
- package/core/workflows/execute.md +483 -0
- package/core/workflows/extract-template.md +278 -0
- package/core/workflows/fix-failed-tests.md +160 -0
- package/core/workflows/init-project.md +386 -0
- package/core/workflows/legacy-project.md +849 -0
- package/core/workflows/log.md +97 -0
- package/core/workflows/new-project.md +610 -0
- package/core/workflows/new-project.md.bak +3292 -0
- package/core/workflows/new-task.md +404 -0
- package/core/workflows/orchestrate.md +237 -0
- package/core/workflows/page-build.md +296 -0
- package/core/workflows/plan.md +89 -0
- package/core/workflows/prd.md +255 -0
- package/core/workflows/preview.md +81 -0
- package/core/workflows/review-page.md +304 -0
- package/core/workflows/status.md +86 -0
- package/core/workflows/stitch.md +226 -0
- package/core/workflows/task-complete.md +473 -0
- package/core/workflows/task-update.md +163 -0
- package/core/workflows/tdd.md +344 -0
- package/core/workflows/test.md +251 -0
- package/core/workflows/ui-ux-pro-max.md +437 -0
- package/core/workflows/ux-mobile-optimize.md +262 -0
- package/core/workflows/ux-mobile-validate.md +297 -0
- package/engine-files/GEMINI.md +69 -0
- package/package.json +47 -0
- package/runtime-adapters/antigravity.js +26 -0
- package/runtime-adapters/claude.js +57 -0
- package/runtime-adapters/codex.js +51 -0
- package/runtime-adapters/copilot.js +51 -0
- package/runtime-adapters/cursor.js +51 -0
- package/runtime-adapters/gemini-cli.js +30 -0
- package/runtime-adapters/opencode.js +51 -0
- package/runtime-adapters/windsurf.js +51 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Stack Adapter: React (TSX)
|
|
2
|
+
|
|
3
|
+
> For React projects using TypeScript, SCSS, and optionally Storybook.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Folder Structure
|
|
8
|
+
|
|
9
|
+
For a component named `Button` in the **atoms** category:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/components/atoms/Button/
|
|
13
|
+
├── index.ts # Barrel export
|
|
14
|
+
├── Button.tsx # Component implementation
|
|
15
|
+
├── Button.styles.scss # BEM styles with design tokens
|
|
16
|
+
├── Button.types.ts # TypeScript interfaces
|
|
17
|
+
├── Button.test.tsx # Tests (Vitest + RTL)
|
|
18
|
+
└── Button.stories.tsx # Storybook story (optional)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Category paths:**
|
|
22
|
+
- `src/components/atoms/` — Buttons, Inputs, Icons
|
|
23
|
+
- `src/components/molecules/` — SearchBar, FormField
|
|
24
|
+
- `src/components/organisms/` — Header, Card, Modal
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Required Files (5 minimum)
|
|
29
|
+
|
|
30
|
+
### 1. Types — `Button.types.ts` (ALWAYS FIRST)
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
export interface ButtonProps {
|
|
34
|
+
readonly children: React.ReactNode;
|
|
35
|
+
readonly variant?: 'primary' | 'secondary';
|
|
36
|
+
readonly size?: 'sm' | 'md' | 'lg';
|
|
37
|
+
readonly disabled?: boolean;
|
|
38
|
+
readonly onClick?: () => void;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Rules:**
|
|
43
|
+
- Use `Readonly` or `readonly` modifier on all props
|
|
44
|
+
- Export interface separately for consumers
|
|
45
|
+
- Define all variants as union types
|
|
46
|
+
|
|
47
|
+
### 2. Component — `Button.tsx`
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import React from 'react';
|
|
51
|
+
import type { ButtonProps } from './Button.types';
|
|
52
|
+
import './Button.styles.scss';
|
|
53
|
+
|
|
54
|
+
const Button: React.FC<ButtonProps> = ({
|
|
55
|
+
children,
|
|
56
|
+
variant = 'primary',
|
|
57
|
+
size = 'md',
|
|
58
|
+
disabled = false,
|
|
59
|
+
onClick,
|
|
60
|
+
}) => {
|
|
61
|
+
return (
|
|
62
|
+
<button
|
|
63
|
+
className={`button button--${variant} button--${size}`}
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
onClick={onClick}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</button>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default Button;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Rules:**
|
|
76
|
+
- Functional components only (no class components)
|
|
77
|
+
- Default export for the component
|
|
78
|
+
- Import styles directly (NOT CSS Modules)
|
|
79
|
+
- All props with defaults where sensible
|
|
80
|
+
|
|
81
|
+
### 3. Styles — `Button.styles.scss`
|
|
82
|
+
|
|
83
|
+
```scss
|
|
84
|
+
.button {
|
|
85
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
86
|
+
font-size: var(--font-size-md);
|
|
87
|
+
font-weight: var(--font-weight-medium);
|
|
88
|
+
border: 1px solid transparent;
|
|
89
|
+
border-radius: var(--radius-md);
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
transition: background-color 0.2s ease, opacity 0.2s ease;
|
|
92
|
+
|
|
93
|
+
&--primary {
|
|
94
|
+
background-color: var(--color-primary);
|
|
95
|
+
color: var(--color-background);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&--secondary {
|
|
99
|
+
background-color: transparent;
|
|
100
|
+
color: var(--color-primary);
|
|
101
|
+
border-color: var(--color-primary);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&--sm { padding: var(--spacing-xs) var(--spacing-sm); font-size: var(--font-size-sm); }
|
|
105
|
+
&--lg { padding: var(--spacing-md) var(--spacing-lg); font-size: var(--font-size-lg); }
|
|
106
|
+
|
|
107
|
+
&:hover:not(:disabled) { opacity: 0.85; }
|
|
108
|
+
|
|
109
|
+
&:disabled {
|
|
110
|
+
opacity: 0.5;
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Rules:**
|
|
117
|
+
- BEM methodology strictly
|
|
118
|
+
- ALL values from design tokens (CSS variables)
|
|
119
|
+
- ZERO hardcoded hex/px values
|
|
120
|
+
- Import pattern: `import './Button.styles.scss';` (not modules)
|
|
121
|
+
|
|
122
|
+
### 4. Tests — `Button.test.tsx`
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
126
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
127
|
+
import Button from './Button';
|
|
128
|
+
|
|
129
|
+
describe('Button', () => {
|
|
130
|
+
it('renders children correctly', () => {
|
|
131
|
+
render(<Button>Click me</Button>);
|
|
132
|
+
expect(screen.getByText('Click me')).toBeInTheDocument();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('applies variant class', () => {
|
|
136
|
+
render(<Button variant="secondary">Test</Button>);
|
|
137
|
+
expect(screen.getByText('Test')).toHaveClass('button--secondary');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('calls onClick when clicked', () => {
|
|
141
|
+
const handleClick = vi.fn();
|
|
142
|
+
render(<Button onClick={handleClick}>Click me</Button>);
|
|
143
|
+
fireEvent.click(screen.getByText('Click me'));
|
|
144
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('is disabled when disabled prop is true', () => {
|
|
148
|
+
render(<Button disabled>Click me</Button>);
|
|
149
|
+
expect(screen.getByText('Click me')).toBeDisabled();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('does not call onClick when disabled', () => {
|
|
153
|
+
const handleClick = vi.fn();
|
|
154
|
+
render(<Button disabled onClick={handleClick}>Click me</Button>);
|
|
155
|
+
fireEvent.click(screen.getByText('Click me'));
|
|
156
|
+
expect(handleClick).not.toHaveBeenCalled();
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Rules:**
|
|
162
|
+
- Vitest + React Testing Library
|
|
163
|
+
- Test: rendering, props, interactions, disabled state
|
|
164
|
+
- Minimum 80% coverage
|
|
165
|
+
|
|
166
|
+
### 5. Barrel Export — `index.ts`
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
export { default } from './Button';
|
|
170
|
+
export type { ButtonProps } from './Button.types';
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Optional: Storybook Story — `Button.stories.tsx`
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
179
|
+
import Button from './Button';
|
|
180
|
+
|
|
181
|
+
const meta: Meta<typeof Button> = {
|
|
182
|
+
title: 'Atoms/Button',
|
|
183
|
+
component: Button,
|
|
184
|
+
tags: ['autodocs'],
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export default meta;
|
|
188
|
+
type Story = StoryObj<typeof Button>;
|
|
189
|
+
|
|
190
|
+
export const Primary: Story = {
|
|
191
|
+
args: { children: 'Primary Button', variant: 'primary' },
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const Secondary: Story = {
|
|
195
|
+
args: { children: 'Secondary Button', variant: 'secondary' },
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const Disabled: Story = {
|
|
199
|
+
args: { children: 'Disabled', disabled: true },
|
|
200
|
+
};
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Title pattern:** `{Category}/{ComponentName}` (e.g., `Atoms/Button`, `Molecules/SearchBar`)
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Composition with shadcn/ui
|
|
208
|
+
|
|
209
|
+
When the user opts to use shadcn as a base:
|
|
210
|
+
|
|
211
|
+
1. Check `components.json` exists. If not: `npx shadcn@latest init`
|
|
212
|
+
2. Identify matching primitive: `npx shadcn@latest add button`
|
|
213
|
+
3. Import and wrap:
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { Button as ShadcnButton } from '@/components/ui/button';
|
|
217
|
+
import type { ButtonProps } from './Button.types';
|
|
218
|
+
import './Button.styles.scss';
|
|
219
|
+
|
|
220
|
+
const Button: React.FC<ButtonProps> = ({ children, variant, ...props }) => (
|
|
221
|
+
<ShadcnButton className={`button button--${variant}`} {...props}>
|
|
222
|
+
{children}
|
|
223
|
+
</ShadcnButton>
|
|
224
|
+
);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Rule:** Use shadcn for behavior, BEM/tokens for custom visuals.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Infrastructure Detection
|
|
232
|
+
|
|
233
|
+
| Check | File to Scan | Install Command |
|
|
234
|
+
|-------|-------------|----------------|
|
|
235
|
+
| React | `package.json` → `react` | — |
|
|
236
|
+
| TypeScript | `tsconfig.json` | `npm install -D typescript @types/react` |
|
|
237
|
+
| SCSS | `package.json` → `sass` | `npm install -D sass` |
|
|
238
|
+
| Vitest | `vitest.config.*` | `npm install -D vitest @testing-library/react @testing-library/jest-dom` |
|
|
239
|
+
| Storybook | `.storybook/` dir | `npx storybook@latest init` |
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Stack Adapter: Vue 3 (SFC + TypeScript)
|
|
2
|
+
|
|
3
|
+
> For Vue 3 projects using Composition API, TypeScript, and SCSS.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Folder Structure
|
|
8
|
+
|
|
9
|
+
For a component named `BaseButton` in the **atoms** category:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/components/atoms/BaseButton/
|
|
13
|
+
├── index.ts # Barrel export
|
|
14
|
+
├── BaseButton.vue # SFC (template + script + style)
|
|
15
|
+
├── BaseButton.types.ts # TypeScript interfaces
|
|
16
|
+
├── BaseButton.test.ts # Tests (Vitest + Vue Test Utils)
|
|
17
|
+
└── BaseButton.stories.ts # Storybook story (optional)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Naming convention:** Vue components use `Base` prefix for atoms to avoid conflicts with HTML elements.
|
|
21
|
+
|
|
22
|
+
**Category paths:**
|
|
23
|
+
- `src/components/atoms/` — BaseButton, BaseInput, BaseIcon
|
|
24
|
+
- `src/components/molecules/` — SearchBar, FormField
|
|
25
|
+
- `src/components/organisms/` — AppHeader, DataTable, SideBar
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Required Files (4 minimum)
|
|
30
|
+
|
|
31
|
+
### 1. Types — `BaseButton.types.ts` (ALWAYS FIRST)
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
export interface BaseButtonProps {
|
|
35
|
+
variant?: 'primary' | 'secondary';
|
|
36
|
+
size?: 'sm' | 'md' | 'lg';
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface BaseButtonEmits {
|
|
41
|
+
(e: 'click'): void;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Component — `BaseButton.vue`
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<script setup lang="ts">
|
|
49
|
+
import type { BaseButtonProps, BaseButtonEmits } from './BaseButton.types';
|
|
50
|
+
|
|
51
|
+
withDefaults(defineProps<BaseButtonProps>(), {
|
|
52
|
+
variant: 'primary',
|
|
53
|
+
size: 'md',
|
|
54
|
+
disabled: false,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
defineEmits<BaseButtonEmits>();
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<button
|
|
62
|
+
:class="['button', `button--${variant}`, `button--${size}`]"
|
|
63
|
+
:disabled="disabled"
|
|
64
|
+
@click="$emit('click')"
|
|
65
|
+
>
|
|
66
|
+
<slot />
|
|
67
|
+
</button>
|
|
68
|
+
</template>
|
|
69
|
+
|
|
70
|
+
<style lang="scss" scoped>
|
|
71
|
+
.button {
|
|
72
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
73
|
+
font-size: var(--font-size-md);
|
|
74
|
+
font-weight: var(--font-weight-medium);
|
|
75
|
+
border: 1px solid transparent;
|
|
76
|
+
border-radius: var(--radius-md);
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
transition: background-color 0.2s ease, opacity 0.2s ease;
|
|
79
|
+
|
|
80
|
+
&--primary {
|
|
81
|
+
background-color: var(--color-primary);
|
|
82
|
+
color: var(--color-background);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&--secondary {
|
|
86
|
+
background-color: transparent;
|
|
87
|
+
color: var(--color-primary);
|
|
88
|
+
border-color: var(--color-primary);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&--sm { padding: var(--spacing-xs) var(--spacing-sm); font-size: var(--font-size-sm); }
|
|
92
|
+
&--lg { padding: var(--spacing-md) var(--spacing-lg); font-size: var(--font-size-lg); }
|
|
93
|
+
|
|
94
|
+
&:hover:not(:disabled) { opacity: 0.85; }
|
|
95
|
+
|
|
96
|
+
&:disabled {
|
|
97
|
+
opacity: 0.5;
|
|
98
|
+
cursor: not-allowed;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Rules:**
|
|
105
|
+
- `<script setup>` with `lang="ts"` (Composition API)
|
|
106
|
+
- `defineProps<T>()` with `withDefaults()` for typed props
|
|
107
|
+
- `defineEmits<T>()` for typed events
|
|
108
|
+
- `<style lang="scss" scoped>` for scoped BEM styles
|
|
109
|
+
- Slots instead of `children` prop
|
|
110
|
+
|
|
111
|
+
### 3. Tests — `BaseButton.test.ts`
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { mount } from '@vue/test-utils';
|
|
115
|
+
import { describe, it, expect } from 'vitest';
|
|
116
|
+
import BaseButton from './BaseButton.vue';
|
|
117
|
+
|
|
118
|
+
describe('BaseButton', () => {
|
|
119
|
+
it('renders slot content', () => {
|
|
120
|
+
const wrapper = mount(BaseButton, {
|
|
121
|
+
slots: { default: 'Click me' },
|
|
122
|
+
});
|
|
123
|
+
expect(wrapper.text()).toContain('Click me');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('applies variant class', () => {
|
|
127
|
+
const wrapper = mount(BaseButton, {
|
|
128
|
+
props: { variant: 'secondary' },
|
|
129
|
+
slots: { default: 'Test' },
|
|
130
|
+
});
|
|
131
|
+
expect(wrapper.classes()).toContain('button--secondary');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('emits click event', async () => {
|
|
135
|
+
const wrapper = mount(BaseButton, {
|
|
136
|
+
slots: { default: 'Click me' },
|
|
137
|
+
});
|
|
138
|
+
await wrapper.trigger('click');
|
|
139
|
+
expect(wrapper.emitted('click')).toHaveLength(1);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('is disabled when prop is set', () => {
|
|
143
|
+
const wrapper = mount(BaseButton, {
|
|
144
|
+
props: { disabled: true },
|
|
145
|
+
slots: { default: 'Disabled' },
|
|
146
|
+
});
|
|
147
|
+
expect(wrapper.attributes('disabled')).toBeDefined();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 4. Barrel Export — `index.ts`
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
export { default as BaseButton } from './BaseButton.vue';
|
|
156
|
+
export type { BaseButtonProps, BaseButtonEmits } from './BaseButton.types';
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Optional: Storybook Story — `BaseButton.stories.ts`
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
165
|
+
import BaseButton from './BaseButton.vue';
|
|
166
|
+
|
|
167
|
+
const meta: Meta<typeof BaseButton> = {
|
|
168
|
+
title: 'Atoms/BaseButton',
|
|
169
|
+
component: BaseButton,
|
|
170
|
+
tags: ['autodocs'],
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export default meta;
|
|
174
|
+
type Story = StoryObj<typeof BaseButton>;
|
|
175
|
+
|
|
176
|
+
export const Primary: Story = {
|
|
177
|
+
args: { variant: 'primary' },
|
|
178
|
+
render: (args) => ({
|
|
179
|
+
components: { BaseButton },
|
|
180
|
+
setup: () => ({ args }),
|
|
181
|
+
template: '<BaseButton v-bind="args">Primary</BaseButton>',
|
|
182
|
+
}),
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const Secondary: Story = {
|
|
186
|
+
args: { variant: 'secondary' },
|
|
187
|
+
render: (args) => ({
|
|
188
|
+
components: { BaseButton },
|
|
189
|
+
setup: () => ({ args }),
|
|
190
|
+
template: '<BaseButton v-bind="args">Secondary</BaseButton>',
|
|
191
|
+
}),
|
|
192
|
+
};
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Composables Pattern
|
|
198
|
+
|
|
199
|
+
For components with complex logic, extract to composables:
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
src/composables/useButton.ts
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { computed } from 'vue';
|
|
207
|
+
|
|
208
|
+
export function useButton(variant: string) {
|
|
209
|
+
const classes = computed(() => ['button', `button--${variant}`]);
|
|
210
|
+
return { classes };
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Infrastructure Detection
|
|
217
|
+
|
|
218
|
+
| Check | File to Scan | Install Command |
|
|
219
|
+
|-------|-------------|----------------|
|
|
220
|
+
| Vue 3 | `package.json` → `vue` | — |
|
|
221
|
+
| TypeScript | `tsconfig.json` | `npm install -D typescript vue-tsc` |
|
|
222
|
+
| SCSS | `package.json` → `sass` | `npm install -D sass` |
|
|
223
|
+
| Vitest | `vitest.config.*` | `npm install -D vitest @vue/test-utils` |
|
|
224
|
+
| Storybook | `.storybook/` dir | `npx storybook@latest init --type vue3` |
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bash-linux
|
|
3
|
+
description: Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Bash Linux Patterns
|
|
8
|
+
|
|
9
|
+
> Essential patterns for Bash on Linux/macOS.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Operator Syntax
|
|
14
|
+
|
|
15
|
+
### Chaining Commands
|
|
16
|
+
|
|
17
|
+
| Operator | Meaning | Example |
|
|
18
|
+
|----------|---------|---------|
|
|
19
|
+
| `;` | Run sequentially | `cmd1; cmd2` |
|
|
20
|
+
| `&&` | Run if previous succeeded | `npm install && npm run dev` |
|
|
21
|
+
| `\|\|` | Run if previous failed | `npm test \|\| echo "Tests failed"` |
|
|
22
|
+
| `\|` | Pipe output | `ls \| grep ".js"` |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. File Operations
|
|
27
|
+
|
|
28
|
+
### Essential Commands
|
|
29
|
+
|
|
30
|
+
| Task | Command |
|
|
31
|
+
|------|---------|
|
|
32
|
+
| List all | `ls -la` |
|
|
33
|
+
| Find files | `find . -name "*.js" -type f` |
|
|
34
|
+
| File content | `cat file.txt` |
|
|
35
|
+
| First N lines | `head -n 20 file.txt` |
|
|
36
|
+
| Last N lines | `tail -n 20 file.txt` |
|
|
37
|
+
| Follow log | `tail -f log.txt` |
|
|
38
|
+
| Search in files | `grep -r "pattern" --include="*.js"` |
|
|
39
|
+
| File size | `du -sh *` |
|
|
40
|
+
| Disk usage | `df -h` |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 3. Process Management
|
|
45
|
+
|
|
46
|
+
| Task | Command |
|
|
47
|
+
|------|---------|
|
|
48
|
+
| List processes | `ps aux` |
|
|
49
|
+
| Find by name | `ps aux \| grep node` |
|
|
50
|
+
| Kill by PID | `kill -9 <PID>` |
|
|
51
|
+
| Find port user | `lsof -i :3000` |
|
|
52
|
+
| Kill port | `kill -9 $(lsof -t -i :3000)` |
|
|
53
|
+
| Background | `npm run dev &` |
|
|
54
|
+
| Jobs | `jobs -l` |
|
|
55
|
+
| Bring to front | `fg %1` |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 4. Text Processing
|
|
60
|
+
|
|
61
|
+
### Core Tools
|
|
62
|
+
|
|
63
|
+
| Tool | Purpose | Example |
|
|
64
|
+
|------|---------|---------|
|
|
65
|
+
| `grep` | Search | `grep -rn "TODO" src/` |
|
|
66
|
+
| `sed` | Replace | `sed -i 's/old/new/g' file.txt` |
|
|
67
|
+
| `awk` | Extract columns | `awk '{print $1}' file.txt` |
|
|
68
|
+
| `cut` | Cut fields | `cut -d',' -f1 data.csv` |
|
|
69
|
+
| `sort` | Sort lines | `sort -u file.txt` |
|
|
70
|
+
| `uniq` | Unique lines | `sort file.txt \| uniq -c` |
|
|
71
|
+
| `wc` | Count | `wc -l file.txt` |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 5. Environment Variables
|
|
76
|
+
|
|
77
|
+
| Task | Command |
|
|
78
|
+
|------|---------|
|
|
79
|
+
| View all | `env` or `printenv` |
|
|
80
|
+
| View one | `echo $PATH` |
|
|
81
|
+
| Set temporary | `export VAR="value"` |
|
|
82
|
+
| Set in script | `VAR="value" command` |
|
|
83
|
+
| Add to PATH | `export PATH="$PATH:/new/path"` |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 6. Network
|
|
88
|
+
|
|
89
|
+
| Task | Command |
|
|
90
|
+
|------|---------|
|
|
91
|
+
| Download | `curl -O https://example.com/file` |
|
|
92
|
+
| API request | `curl -X GET https://api.example.com` |
|
|
93
|
+
| POST JSON | `curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL` |
|
|
94
|
+
| Check port | `nc -zv localhost 3000` |
|
|
95
|
+
| Network info | `ifconfig` or `ip addr` |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 7. Script Template
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
#!/bin/bash
|
|
103
|
+
set -euo pipefail # Exit on error, undefined var, pipe fail
|
|
104
|
+
|
|
105
|
+
# Colors (optional)
|
|
106
|
+
RED='\033[0;31m'
|
|
107
|
+
GREEN='\033[0;32m'
|
|
108
|
+
NC='\033[0m'
|
|
109
|
+
|
|
110
|
+
# Script directory
|
|
111
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
112
|
+
|
|
113
|
+
# Functions
|
|
114
|
+
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
|
115
|
+
log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
|
|
116
|
+
|
|
117
|
+
# Main
|
|
118
|
+
main() {
|
|
119
|
+
log_info "Starting..."
|
|
120
|
+
# Your logic here
|
|
121
|
+
log_info "Done!"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
main "$@"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 8. Common Patterns
|
|
130
|
+
|
|
131
|
+
### Check if command exists
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
if command -v node &> /dev/null; then
|
|
135
|
+
echo "Node is installed"
|
|
136
|
+
fi
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Default variable value
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
NAME=${1:-"default_value"}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Read file line by line
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
while IFS= read -r line; do
|
|
149
|
+
echo "$line"
|
|
150
|
+
done < file.txt
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Loop over files
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
for file in *.js; do
|
|
157
|
+
echo "Processing $file"
|
|
158
|
+
done
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 9. Differences from PowerShell
|
|
164
|
+
|
|
165
|
+
| Task | PowerShell | Bash |
|
|
166
|
+
|------|------------|------|
|
|
167
|
+
| List files | `Get-ChildItem` | `ls -la` |
|
|
168
|
+
| Find files | `Get-ChildItem -Recurse` | `find . -type f` |
|
|
169
|
+
| Environment | `$env:VAR` | `$VAR` |
|
|
170
|
+
| String concat | `"$a$b"` | `"$a$b"` (same) |
|
|
171
|
+
| Null check | `if ($x)` | `if [ -n "$x" ]` |
|
|
172
|
+
| Pipeline | Object-based | Text-based |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 10. Error Handling
|
|
177
|
+
|
|
178
|
+
### Set options
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
set -e # Exit on error
|
|
182
|
+
set -u # Exit on undefined variable
|
|
183
|
+
set -o pipefail # Exit on pipe failure
|
|
184
|
+
set -x # Debug: print commands
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Trap for cleanup
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
cleanup() {
|
|
191
|
+
echo "Cleaning up..."
|
|
192
|
+
rm -f /tmp/tempfile
|
|
193
|
+
}
|
|
194
|
+
trap cleanup EXIT
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
> **Remember:** Bash is text-based. Use `&&` for success chains, `set -e` for safety, and quote your variables!
|