feat: Add local .forge config file support with named environments#108
Open
StephenBadger wants to merge 1 commit intolaravel:masterfrom
Open
feat: Add local .forge config file support with named environments#108StephenBadger wants to merge 1 commit intolaravel:masterfrom
StephenBadger wants to merge 1 commit intolaravel:masterfrom
Conversation
This adds project-level configuration via a `.forge` file, enabling teams
to commit their Forge server/site mappings directly in their repositories.
Key features:
- Named environments (production, staging, dev) with per-environment config
- Smart deploy detection: `forge deploy staging` auto-detects environment names
- Confirmation prompts for production-like environments (`confirm: true`)
- Interactive `forge init` command for easy setup
- Config management commands: config, config:set, config:remove, config:default
- Zsh shell completion with environment awareness
- Backward compatible with existing global config
Example .forge file:
```json
{
"default": "staging",
"environments": {
"production": { "server": 123, "site": 456, "confirm": true },
"staging": { "server": 123, "site": 789 }
}
}
```
Usage:
- `forge deploy` - deploys to default environment
- `forge deploy production` - deploys to production (prompts for confirmation)
- `forge deploy --force` - skips confirmation prompt
- `forge init` - interactive setup
- `forge config` - display current configuration
Author
|
I made this because I work at an agency, have many clients, each client has potentially a few sites. Juggling the forge cli context was annoying. Now I don't have to. I use this locally every day and though to share it back. Let me know if you want adjustments or have questions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds project-level configuration support via a
.forgefile, enabling teams to commit their Forge server/site mappings directly in their repositories. This eliminates the need to specify server/site IDs for every command and provides a clear, version-controlled deployment configuration.Key features:
forge deploy stagingauto-detects if "staging" is an environment name or a site name"confirm": truesettingforge initguides users through configurationconfig,config:set,config:remove,config:defaultExample Configuration
{ "default": "staging", "environments": { "production": { "server": 123456, "site": 789012, "confirm": true }, "staging": { "server": 123456, "site": 789013 } } }Usage Examples
Implementation Details
.forgefiles, walks up directories to find config (similar to.envresolution)Files Changed
app/Repositories/LocalConfigRepository.php- New repository for local config handlingapp/Commands/Concerns/InteractsWithEnvironments.php- New trait for environment logicapp/Commands/InitCommand.php- Newforge initcommandapp/Commands/ConfigCommand.php- Newforge configdisplay commandapp/Commands/ConfigSetCommand.php- Newforge config:setcommandapp/Commands/ConfigRemoveCommand.php- Newforge config:removecommandapp/Commands/ConfigDefaultCommand.php- Newforge config:defaultcommandapp/Commands/CompletionCommand.php- Newforge completioncommandapp/Commands/DeployCommand.php- Updated with smart environment detectionapp/Commands/Command.php- Integrated local config supportapp/Commands/Concerns/InteractsWithIO.php- Updated for environment-aware site resolutionapp/Providers/ConfigServiceProvider.php- Registered LocalConfigRepositorycompletions/forge.zsh- Zsh completion scriptREADME.md- Documentation for the new featureThis follows the existing pattern of local
.env.forge.{siteId}files for environment variables, extending the concept to full deployment configuration.