Skip to content
Permalink
Browse files

remove development stage. Closes #563

it is redundant, and conflicts with dev as the local stage
  • Loading branch information...
tj committed Feb 1, 2018
1 parent bf3014f commit 272a2a61cfe009f37dd26248bbb5b0c94ed2d5a6
@@ -25,17 +25,12 @@ func (s *StageOverrides) Override(c *Config) {

// Stages config.
type Stages struct {
Development *Stage `json:"development"`
Staging *Stage `json:"staging"`
Production *Stage `json:"production"`
Staging *Stage `json:"staging"`
Production *Stage `json:"production"`
}

// Default implementation.
func (s *Stages) Default() error {
if s := s.Development; s != nil {
s.Name = "development"
}

if s := s.Staging; s != nil {
s.Name = "staging"
}
@@ -54,10 +49,6 @@ func (s *Stages) Validate() error {

// List returns configured stages.
func (s *Stages) List() (v []*Stage) {
if s := s.Development; s != nil {
v = append(v, s)
}

if s := s.Staging; s != nil {
v = append(v, s)
}
@@ -79,9 +79,6 @@ func TestStages_Validate(t *testing.T) {

t.Run("some stages", func(t *testing.T) {
s := Stages{
Development: &Stage{
Domain: "gh-polls-dev.com",
},
Staging: &Stage{
Domain: "gh-polls-stage.com",
},
@@ -92,28 +89,27 @@ func TestStages_Validate(t *testing.T) {

assert.NoError(t, s.Default(), "validate")
assert.NoError(t, s.Validate(), "validate")
assert.Equal(t, "development", s.Development.Name)
assert.Equal(t, "staging", s.Staging.Name)
assert.Equal(t, "production", s.Production.Name)
})
}

func TestStages_List(t *testing.T) {
dev := &Stage{
Domain: "gh-polls-dev.com",
stage := &Stage{
Domain: "gh-polls-stage.com",
}

prod := &Stage{
Domain: "gh-polls.com",
}

s := Stages{
Development: dev,
Production: prod,
Staging: stage,
Production: prod,
}

list := []*Stage{
dev,
stage,
prod,
}

@@ -122,19 +118,18 @@ func TestStages_List(t *testing.T) {
}

func TestStages_GetByDomain(t *testing.T) {
dev := &Stage{
Domain: "gh-polls-dev.com",
stage := &Stage{
Domain: "gh-polls-stage.com",
}

prod := &Stage{
Domain: "gh-polls.com",
}

s := Stages{
Development: dev,
Production: prod,
Staging: stage,
Production: prod,
}

stage := s.GetByDomain("gh-polls.com")
assert.Equal(t, prod, stage)
assert.Equal(t, prod, s.GetByDomain("gh-polls.com"))
}
@@ -21,7 +21,7 @@ Next you'll need to let Up know which profile in `~/.aws/credentials` to use. No
$ export AWS_PROFILE=myapp
```

Deploy it to the development stage:
Deploy it to the staging environment:

```
$ up
@@ -202,7 +202,7 @@ These become available to you via `process.env.API_FEATURES_FOO`, `os.Getenv("AP
The following environment variables are provided by Up:

- `PORT` – port number such as "3000"
- `UP_STAGE` – stage name such as "development" or "production"
- `UP_STAGE` – stage name such as "staging" or "production"

## Header Injection

@@ -576,9 +576,6 @@ By defining a stage and its `domain`, Up knows it will need to create a free SSL
},
"staging": {
"domain": "stage.gh-polls.com"
},
"development": {
"domain": "dev.gh-polls.com"
}
}
}
@@ -600,9 +597,8 @@ You may also provide an optional base path, for example to prefix your API with

Plan the changes via `up stack plan` and `up stack apply` to perform the changes. Note that CloudFront can take up to ~40 minutes to distribute this configuration globally, so grab a coffee while these changes are applied.

Custom stages may be supported in the future, for now there are three:
Custom stages may be supported in the future, for now there are two:

- `development`
- `staging`
- `production`

@@ -55,13 +55,13 @@ Commands:
Examples:
Deploy the project to the development stage.
Deploy the project to staging.
$ up
Deploy the project to the production stage.
Deploy the project to production.
$ up deploy production
Show the development endpoint url.
Show the staging endpoint url.
$ up url
Tail project logs.
@@ -82,7 +82,7 @@ Examples:

## Deploy

Deploy the project, by default to the "development" stage. Note that running `up` and `up deploy` are identical, however for staging and production you must run `up deploy <stage>`.
Deploy the project, by default to the "staging" stage. Note that running `up` and `up deploy` are identical, as it is the default command.

```
Usage:
@@ -220,7 +220,7 @@ $ up -e 'path = "/static/*"'
ip: 70.66.179.182
method: GET
path: /static/3.jpg
stage: development
stage: production
version: 5
1:36:34pm INFO response
@@ -230,7 +230,7 @@ $ up -e 'path = "/static/*"'
method: GET
path: /static/3.jpg
size: 0 B
stage: development
stage: production
status: 304
version: 5
@@ -239,7 +239,7 @@ $ up -e 'path = "/static/*"'
ip: 70.66.179.182
method: GET
path: /static/1.png
stage: development
stage: production
version: 5
```

@@ -485,7 +485,7 @@ $ up metrics production -s 15d

## Start

Start development server. The development server runs the same proxy that is used in production for serving, so you can test a static site or application locally with the same feature-set.
Start development server. The development server runs the same proxy that is used in production for serving, so you can test a static site or application locally with the same feature-set. The `UP_STAGE` and `NODE_ENV` environment variables will are set to "development".

See [Stage Overrides](https://up.docs.apex.sh/#configuration.stage_overrides) for an example of overriding the proxy command per-stage, especially useful in development.

@@ -208,7 +208,7 @@ http.createServer((req, res) => {
}).listen(PORT)
```

Now deploy to development and production. Note that `up` is an alias of `up deploy development`.
Now deploy to staging and production. Note that `up` is an alias of `up deploy staging`.

```
$ up
@@ -222,20 +222,20 @@ $ up url -o
$ up url production -o
```

You should see "Hello World from production" and "Hello World from development".
You should see "Hello World from production" and "Hello World from staging".

### Mapping Custom Domains to Stages

Now that you have an application deployed, you probably want a fancy custom domain for it right? You can map these using the `stages` and `domain` properties.

Here we let Up know that we want `up-example.com` for production and `dev.up-example` for development.
Here we let Up know that we want `up-example.com` for production and `dev.up-example` for staging.

```json
{
"name": "up-example",
"profile": "up-tobi",
"stages": {
"development": {
"staging": {
"domain": "dev.up-example.com"
},
"production": {
@@ -373,9 +373,6 @@ Suppose you wanted to map the "staging" stage, you would first add it to `up.jso
"name": "up-example",
"profile": "up-tobi",
"stages": {
"development": {
"domain": "dev.up-example.com"
},
"staging": {
"domain": "stage.up-example.com"
},
@@ -53,7 +53,7 @@ title: FAQ
</details>

<details>
<summary>Can I remove the /development and /production paths?</summary>
<summary>Can I remove the /staging and /production paths?</summary>
<p>Up uses AWS API Gateway, which imposes the stage base paths. Currently there is no way to remove them, however when you use
custom domains these paths are not present.</p>
</details>
@@ -17,10 +17,9 @@ import (

func init() {
cmd := root.Command("deploy", "Deploy the project.").Default()
stage := cmd.Arg("stage", "Target stage name.").Default("development").String()
cmd.Example(`up deploy`, "Deploy the project to the development stage.")
cmd.Example(`up deploy staging`, "Deploy the project to the staging stage.")
cmd.Example(`up deploy production`, "Deploy the project to the production stage.")
stage := cmd.Arg("stage", "Target stage name.").Default("staging").String()
cmd.Example(`up deploy`, "Deploy the project the staging environment.")
cmd.Example(`up deploy production`, "Deploy the project to the production environment.")

cmd.Action(func(_ *kingpin.ParseContext) error {
return deploy(*stage)
@@ -13,10 +13,10 @@ import (

func init() {
cmd := root.Command("metrics", "Show project metrics.")
cmd.Example(`up metrics`, "Show metrics for development stage.")
cmd.Example(`up metrics production`, "Show metrics for production stage.")
cmd.Example(`up metrics`, "Show metrics for staging environment.")
cmd.Example(`up metrics production`, "Show metrics for production environment.")

stage := cmd.Arg("stage", "Name of the stage.").Default("development").String()
stage := cmd.Arg("stage", "Name of the stage.").Default("staging").String()
since := cmd.Flag("since", "Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M).").Short('s').Default("1M").String()

cmd.Action(func(_ *kingpin.ParseContext) error {
@@ -27,9 +27,9 @@ var Init func() (*up.Config, *up.Project, error)
func init() {
log.SetHandler(cli.Default)

Cmd.Example(`up`, "Deploy the project to the development stage.")
Cmd.Example(`up`, "Deploy the project to the staging environment.")
Cmd.Example(`up deploy production`, "Deploy the project to the production stage.")
Cmd.Example(`up url`, "Show the development endpoint url.")
Cmd.Example(`up url`, "Show the staging endpoint url.")
Cmd.Example(`up logs -f`, "Tail project logs.")
Cmd.Example(`up logs 'error or fatal'`, "Show error or fatal level logs.")
Cmd.Example(`up run build`, "Run build command manually.")
@@ -23,7 +23,7 @@ func init() {
cmd.Example(`up start -o`, "Start development server and open in the browser.")
cmd.Example(`up start --address :5000`, "Start development server on port 5000.")
cmd.Example(`up start -c 'go run main.go'`, "Override proxy command.")
cmd.Example(`up start -oc 'go run main.go'`, "Override proxy command and open in the browser.")
cmd.Example(`up start -oc 'gin --port $PORT'`, "Override proxy command and open in the browser.")

command := cmd.Flag("command", "Proxy command override").Short('c').String()
open := cmd.Flag("open", "Open endpoint in the browser.").Short('o').Bool()
@@ -16,14 +16,14 @@ import (
func init() {
cmd := root.Command("url", "Show, open, or copy a stage endpoint.")

cmd.Example(`up url`, "Show the development endpoint.")
cmd.Example(`up url --open`, "Open the development endpoint in the browser.")
cmd.Example(`up url --copy`, "Copy the development endpoint to the clipboard.")
cmd.Example(`up url`, "Show the staging endpoint.")
cmd.Example(`up url --open`, "Open the staging endpoint in the browser.")
cmd.Example(`up url --copy`, "Copy the staging endpoint to the clipboard.")
cmd.Example(`up url production`, "Show the production endpoint.")
cmd.Example(`up url -o production`, "Open the production endpoint in the browser.")
cmd.Example(`up url -c production`, "Copy the production endpoint to the clipboard.")

stage := cmd.Arg("stage", "Name of the stage.").Default("development").String()
stage := cmd.Arg("stage", "Name of the stage.").Default("staging").String()
open := cmd.Flag("open", "Open endpoint in the browser.").Short('o').Bool()
copy := cmd.Flag("copy", "Copy endpoint to the clipboard.").Short('c').Bool()

@@ -77,7 +77,7 @@ func Lists(vals, list []string) error {

// Stage validation.
func Stage(stage string) error {
if err := List(stage, []string{"development", "staging", "production"}); err != nil {
if err := List(stage, []string{"staging", "production"}); err != nil {
return errors.Wrap(err, "stage")
}

Oops, something went wrong.

0 comments on commit 272a2a6

Please sign in to comment.
You can’t perform that action at this time.