Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stackcoderc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"features": {
"commitValidation": false
"commitValidation": true
}
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Changelog

## [Unreleased]

### Added

- feat: 🦺 add system dependency validation - Intelligent validation of required tools before project initialization with helpful installation instructions

## (2025-07-27)

- fix: 🐛 Add missing build script to core package ([abe05e0](https://github.com/YagoBorba/StackCode/commit/abe05e0))
Expand Down
87 changes: 84 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Before contributing, please familiarize yourself with the project architecture:
- **[🛠️ Technology Stacks](docs/STACKS.md)** - Supported frameworks and project templates

Understanding the architecture will help you:

- Choose the right package for your changes
- Follow established patterns and conventions
- Understand cross-package dependencies
Expand Down Expand Up @@ -220,10 +221,33 @@ Update the stack choices in `packages/cli/src/commands/ui.ts`:

#### Step 6: Update Package Manager Logic

If your stack uses a different package manager, update the dependency installation logic in `packages/cli/src/commands/init.ts`:
When adding a new stack, you need to update two areas to handle dependency management:

**A. Add stack dependencies mapping in `packages/core/src/utils.ts`:**

```typescript
export function getStackDependencies(stack: string): string[] {
const stackMap: Record<string, string[]> = {
go: ["go"],
php: ["composer", "php"],
java: ["mvn", "java"],
python: ["pip", "python"],
"your-stack-name": ["your-tool", "another-tool"], // Add your stack here
// Node.js stacks use npm
"node-js": ["npm"],
"node-ts": ["npm"],
react: ["npm"],
vue: ["npm"],
};
return stackMap[stack] || ["npm"];
}
```

**B. Update dependency installation logic in `packages/cli/src/commands/init.ts`:**

```typescript
// Install dependencies based on the stack type
// The validation is now handled automatically, but you still need to
// specify the installation command for your stack
if (answers.stack === "python") {
await runCommand("pip", ["install", "-e", "."], { cwd: projectPath });
} else if (answers.stack === "java") {
Expand All @@ -240,7 +264,63 @@ if (answers.stack === "python") {
}
```

### 3. Best Practices for New Stacks
**C. Add installation instructions in i18n files:**

Add entries to both `packages/i18n/src/locales/en.json` and `packages/i18n/src/locales/pt.json`:

```json
{
"init": {
"dependencies": {
"install_your_tool": " - Your Tool: https://example.com/install"
}
}
}
```

### 3. System Dependency Validation

StackCode now includes intelligent dependency validation that checks if required tools are installed before attempting to create projects. This prevents crashes and provides helpful guidance to users.

#### How It Works

1. **Pre-validation**: Before installing dependencies, StackCode checks if required tools are available in the system PATH
2. **User feedback**: If tools are missing, users see:
- Clear warnings about missing dependencies
- Direct download links for each missing tool
- Option to continue without installing dependencies
3. **Graceful handling**: Even if dependencies fail to install, the project structure is still created successfully

#### Supported Stack Dependencies

| Stack | Required Tools | Validation |
| ------------------------------------ | ----------------- | ---------- |
| `go` | `go` | ✅ |
| `php` | `composer`, `php` | ✅ |
| `java` | `mvn`, `java` | ✅ |
| `python` | `pip`, `python` | ✅ |
| `node-js`, `node-ts`, `react`, `vue` | `npm` | ✅ |

#### Testing Dependency Validation

To test the validation system:

```bash
# Test with missing dependencies (assuming Go is not installed)
stc init
# Choose "Go + Gin" stack
# You should see warnings and installation instructions

# Test validation programmatically
node -e "
const { validateStackDependencies } = require('@stackcode/core');
validateStackDependencies('go').then(result =>
console.log('Result:', result)
);
"
```

### 4. Best Practices for New Stacks

#### Template Structure Guidelines:

Expand Down Expand Up @@ -390,5 +470,6 @@ Thank you again for your interest in contributing!
---

## Documentation

- [Architecture Guide](docs/ARCHITECTURE.md)
- [Self-Hosting Guide](docs/SELF_HOSTING_GUIDE.md)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Our goal is to make best practices the easiest path.
StackCode is a suite of tools designed to work together seamlessly:

- 🚀 **Effortless Project Scaffolding (`init`):**
Generate a complete, production-ready project structure in seconds. Choose from multiple technology stacks including Node.js, React, Vue.js, Python, Java, Go, and PHP—each with best practices and optimal folder structures.
Generate a complete, production-ready project structure in seconds. Choose from multiple technology stacks including Node.js, React, Vue.js, Python, Java, Go, and PHP—each with best practices and optimal folder structures. **Now with intelligent dependency validation** that checks if required tools are installed before proceeding, providing helpful installation instructions when needed.

- 📝 **Intelligent File Generation (`generate`):**
Need a `.gitignore`? Don't just get one—get a perfect one. Our composable template engine combines rules for your stack, IDE, and tools (like Docker) into a single, organized file.
Expand Down Expand Up @@ -114,10 +114,10 @@ For detailed information about the project:

### 🌐 Documentation in Other Languages

- **[🇧🇷 Português (Brasil)](docs/pt-BR/)** - Documentação em português *(em desenvolvimento)*
- **[🇪🇸 Español](docs/es/)** - Documentación en español *(en desarrollo)*
- **[🇧🇷 Português (Brasil)](docs/pt-BR/)** - Documentação em português _(em desenvolvimento)_
- **[🇪🇸 Español](docs/es/)** - Documentación en español _(en desarrollo)_

*Want to help translate the documentation? Check our [contribution guide](docs/CONTRIBUTING.md#internationalization)!*
_Want to help translate the documentation? Check our [contribution guide](docs/CONTRIBUTING.md#internationalization)!_

## 🤝 Want to Contribute?

Expand Down
Loading