Skip to content

Conversation

Copy link

Copilot AI commented Aug 22, 2025

This PR implements dynamic environment detection to allow users to define and use custom environments beyond the hardcoded dev, staging, and production options.

Problem

Previously, the CLI only supported three hardcoded environments defined as a union type:

export type Environment = "dev" | "staging" | "production";

This prevented users from creating additional environments like testing, demo, or local-dev for their specific workflows.

Solution

The CLI now automatically detects available environments by scanning environment variables for common patterns. When users define variables following the pattern {ENVIRONMENT}_SERVER_IP, {ENVIRONMENT}_DATABASE_NAME, etc., the CLI automatically recognizes that environment as valid.

Example Usage

With a .toward file containing:

# Standard environments (still supported)
STAGING_SERVER_IP=192.168.1.10
STAGING_DATABASE_NAME=myapp_staging
# ...

# Custom testing environment
TESTING_SERVER_IP=192.168.1.30  
TESTING_DATABASE_NAME=myapp_testing
# ...

Users can now run:

toward assets push -e testing
toward database pull -e testing

Key Changes

  • Dynamic Detection: New detectEnvironments.ts utility scans environment variables for patterns like {ENV}_SERVER_IP, {ENV}_DATABASE_NAME
  • Flexible Types: Changed Environment type from hardcoded union to string for unlimited flexibility
  • Smart Loading: Environment detection runs after loading .toward file to capture all defined environments
  • Dynamic Validation: Help text and argument validation adapt to show available environments: <dev | production | staging | testing>

Backwards Compatibility

  • All existing dev, staging, production workflows continue to work unchanged
  • No breaking changes to existing commands or configuration
  • Graceful fallback when no custom environments are defined

Fixes #3.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.deno.land
    • Triggering command: curl -s REDACTED (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Aug 22, 2025

@paulgoodfield 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI changed the title [WIP] Currently only allows 'production' and 'staging' environments Add support for custom environments in CLI commands Aug 22, 2025
Copilot AI requested a review from paulgoodfield August 22, 2025 14:57
Copilot finished work on behalf of paulgoodfield August 22, 2025 14:57
@paulgoodfield paulgoodfield marked this pull request as ready for review August 22, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Currently only allows 'production' and 'staging' environments

2 participants