From 7388ea4dabf9f3aec76dc43a86825d73d26f3d1a Mon Sep 17 00:00:00 2001 From: Vadorequest Date: Sat, 21 Nov 2020 13:59:02 +0100 Subject: [PATCH] Migrate "now" to "vercel" (#210) (modified) --- .env | 4 +- .env.local.example | 2 +- .github/WORKFLOW_DISPATCH.md | 4 +- .github/workflows/deploy-zeit-production.yml | 48 ++++++++--------- .github/workflows/deploy-zeit-staging.yml | 52 +++++++++---------- .gitignore | 1 + .nowignore => .vercelignore | 0 next.config.js | 4 ++ now.json | 1 - package.json | 16 +++--- .../examples/built-in-features/hosting.tsx | 4 +- .../built-in-features/manual-deployments.tsx | 2 +- .../built-in-features/stages-and-secrets.tsx | 6 +-- src/utils/i18n/i18nextLocize.ts | 2 +- ...n.json => vercel.customer1.production.json | 0 ...ging.json => vercel.customer1.staging.json | 0 ...n.json => vercel.customer2.production.json | 0 ...ging.json => vercel.customer2.staging.json | 0 vercel.json | 1 + yarn.lock | 40 +++++++------- 20 files changed, 96 insertions(+), 91 deletions(-) rename .nowignore => .vercelignore (100%) delete mode 120000 now.json rename now.customer1.production.json => vercel.customer1.production.json (100%) rename now.customer1.staging.json => vercel.customer1.staging.json (100%) rename now.customer2.production.json => vercel.customer2.production.json (100%) rename now.customer2.staging.json => vercel.customer2.staging.json (100%) create mode 120000 vercel.json diff --git a/.env b/.env index 599753e37..70010fd75 100644 --- a/.env +++ b/.env @@ -6,7 +6,7 @@ # XXX Tips: When is this file being used? # This file is used only when building the Next.js app locally (localhost), whether it's for running `next dev` or `next build`. -# For staging/production stages, the app relies on "now.{NEXT_PUBLIC_CUSTOMER_REF}.{NEXT_PUBLIC_APP_STAGE}.yml:build.env". +# For staging/production stages, the app relies on "vercel.{NEXT_PUBLIC_CUSTOMER_REF}.{NEXT_PUBLIC_APP_STAGE}.yml:build.env". # XXX Tips: What's the difference between env vars starting with "NEXT_PUBLIC_" and the others? # All env variables that DON'T start with "NEXT_PUBLIC_" MUST be manually exposed by ./next.config.js for the project to work locally @@ -18,7 +18,7 @@ # The stage is "how" the application is running. # It can be either "development", "staging" or "production". -# This value is also set in each "now.*.json" files, so that other stages use their own value. +# This value is also set in each "vercel.*.json" files, so that other stages use their own value. # Tip: This value must not be changed. # Tip: You may override it from ".env.local" if you want to simulate another stage, locally. NEXT_PUBLIC_APP_STAGE=development diff --git a/.env.local.example b/.env.local.example index 75b3f79fc..70dc59b32 100644 --- a/.env.local.example +++ b/.env.local.example @@ -8,7 +8,7 @@ # XXX Tips: When is this file being used? # This file is used only when building the Next.js app locally (localhost), whether it's for running `next dev` or `next build`. -# For staging/production stages, the app relies on "now.{NEXT_PUBLIC_CUSTOMER_REF}.{NEXT_PUBLIC_APP_STAGE}.yml:build.env". +# For staging/production stages, the app relies on "vercel.{NEXT_PUBLIC_CUSTOMER_REF}.{NEXT_PUBLIC_APP_STAGE}.yml:build.env". # XXX Tips: What's the difference between env vars starting with "NEXT_PUBLIC_" and the others? # All env variables that DON'T start with "NEXT_PUBLIC_" MUST be manually exposed by ./next.config.js for the project to work locally diff --git a/.github/WORKFLOW_DISPATCH.md b/.github/WORKFLOW_DISPATCH.md index baa7a6c05..f96d165d7 100644 --- a/.github/WORKFLOW_DISPATCH.md +++ b/.github/WORKFLOW_DISPATCH.md @@ -41,10 +41,10 @@ All inputs are available within `${{github}}` variable. Because this input has b In order to use a **fallback** value (useful when the input isn't required, e.g: `required: false`), we can use this bash trick: ```bash -CUSTOMER_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq -r '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" +CUSTOMER_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq -r '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" ``` -If `MANUAL_TRIGGER_CUSTOMER` is empty, then we'll resolve its fallback value from the `now.json` file and extract the `build.env.NEXT_PUBLIC_CUSTOMER_REF` value. +If `MANUAL_TRIGGER_CUSTOMER` is empty, then we'll resolve its fallback value from the `vercel.json` file and extract the `build.env.NEXT_PUBLIC_CUSTOMER_REF` value. ## 3. How to trigger the workflow using an external HTTP request? diff --git a/.github/workflows/deploy-zeit-production.yml b/.github/workflows/deploy-zeit-production.yml index 1032ba062..79640f37c 100644 --- a/.github/workflows/deploy-zeit-production.yml +++ b/.github/workflows/deploy-zeit-production.yml @@ -35,7 +35,7 @@ jobs: node-version: '12.x' # Use the same node.js version as the one Zeit's uses (currently node12.x) # Starts a Zeit deployment, using the production configuration file of the default institution - # The default institution is the one defined in the `now.json` file (which is a symlink to the actual file) + # The default institution is the one defined in the `vercel.json` file (which is a symlink to the actual file) # N.B: It's Zeit that will perform the actual deployment start-production-deployment: name: Starts Zeit deployment (production) (Ubuntu 18.04) @@ -45,30 +45,30 @@ jobs: - uses: actions/checkout@v1 # Get last commit pushed - XXX See https://github.com/actions/checkout - name: Deploying on Zeit (production) # Workflow overview: - # - Resolve customer to deploy from github event input (falls back to resolving it from now.json file) + # - Resolve customer to deploy from github event input (falls back to resolving it from vercel.json file) # - Deploy the customer in production # XXX You can use https://jqplay.org/ if you want to play around with "jq" to manipulate JSON run: | - # Print the version of the "now" CLI being used (helps debugging) - now --version + # Print the version of the "vercel" CLI being used (helps debugging) + vercel --version # Resolving customer to deploy based on the github event input, when using manual deployment triggerer through "workflow_dispatch" event - # Falls back to the customer specified in the now.json file, which is most useful when deployment is triggered through "push" event + # Falls back to the customer specified in the vercel.json file, which is most useful when deployment is triggered through "push" event MANUAL_TRIGGER_CUSTOMER="${{ github.event.inputs.customer}}" echo "MANUAL_TRIGGER_CUSTOMER: " $MANUAL_TRIGGER_CUSTOMER - CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" + CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" echo "Customer to deploy: " $CUSTOMER_REF_TO_DEPLOY - # Deploy the customer on Vercel using the customer specified in now.json + # Deploy the customer on Vercel using the customer specified in vercel.json CUSTOMER_REF=${CUSTOMER_REF_TO_DEPLOY} yarn deploy:customer:production:simple --token $ZEIT_TOKEN - # Find all custom aliases configured in the customer deployment configuration file (now.json) - ZEIT_DEPLOYMENT_ALIASES_JSON=$(cat now.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.alias') + # Find all custom aliases configured in the customer deployment configuration file (vercel.json) + ZEIT_DEPLOYMENT_ALIASES_JSON=$(cat vercel.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.alias') echo "Custom aliases: " $ZEIT_DEPLOYMENT_ALIASES_JSON # Convert the JSON array into a bash array - See https://unix.stackexchange.com/a/615717/60329 - readarray -t ZEIT_DEPLOYMENT_ALIASES < <(jq --raw-output '.alias[]' < now.$CUSTOMER_REF_TO_DEPLOY.production.json) + readarray -t ZEIT_DEPLOYMENT_ALIASES < <(jq --raw-output '.alias[]' < vercel.$CUSTOMER_REF_TO_DEPLOY.production.json) # Count the number of element in the array, will be 0 if it's an empty array, or if the "alias" key wasn't defined ZEIT_DEPLOYMENT_ALIASES_COUNT=${#ZEIT_DEPLOYMENT_ALIASES[@]} @@ -80,12 +80,12 @@ jobs: # For each alias configured, then assign it to the deployed domain for DEPLOYMENT_ALIAS in "${ZEIT_DEPLOYMENT_ALIASES[@]}"; do - echo "npx now alias "$ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS - npx now alias $ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS --token $ZEIT_TOKEN || echo "Aliasing failed for '$DEPLOYMENT_ALIAS', but the build will continue regardless." + echo "npx vercel alias "$ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS + npx vercel alias $ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS --token $ZEIT_TOKEN || echo "Aliasing failed for '$DEPLOYMENT_ALIAS', but the build will continue regardless." done else - # $ZEIT_DEPLOYMENT_ALIASES is null, this happens when it was not defined in the now.json file - echo "There are no more aliases to configure. You can add more aliases from your now.json 'alias' property. See https://vercel.com/docs/configuration?query=alias%20domain#project/alias" + # $ZEIT_DEPLOYMENT_ALIASES is null, this happens when it was not defined in the vercel.json file + echo "There are no more aliases to configure. You can add more aliases from your vercel.json 'alias' property. See https://vercel.com/docs/configuration?query=alias%20domain#project/alias" echo "$ZEIT_DEPLOYMENT_ALIASES" fi env: @@ -103,9 +103,9 @@ jobs: - uses: actions/checkout@v1 # Get last commit pushed - XXX See https://github.com/actions/checkout - name: Resolving deployment url from Zeit # Workflow overview: - # - Resolve customer to deploy from github event input (falls back to resolving it from now.json file) + # - Resolve customer to deploy from github event input (falls back to resolving it from vercel.json file) # - Resolve $ZEIT_DEPLOYMENT_URL - # - Fetch all deployments data (by using the scope in `now.json`) + # - Fetch all deployments data (by using the scope in `vercel.json`) # - Resolve the last url (from `response.deployments[0].url`) # - Remove the `"` character to pre-format url # We need to set env the url for next step, formatted as `https://${$ZEIT_DEPLOYMENT}` @@ -117,17 +117,17 @@ jobs: echo "MANUAL_TRIGGER_CUSTOMER: " $MANUAL_TRIGGER_CUSTOMER echo "MANUAL_TRIGGER_CUSTOMER=$MANUAL_TRIGGER_CUSTOMER" >> $GITHUB_ENV - CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" + CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" echo "Customer that was deployed: " $CUSTOMER_REF_TO_DEPLOY echo "CUSTOMER_REF_TO_DEPLOY=$CUSTOMER_REF_TO_DEPLOY" >> $GITHUB_ENV # Resolve Vercel team ID - VERCEL_TEAM_ID=`cat now.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.scope'` + VERCEL_TEAM_ID=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.scope'` echo "Vercel team ID: " $VERCEL_TEAM_ID echo "VERCEL_TEAM_ID=$VERCEL_TEAM_ID" >> $GITHUB_ENV # Resolve Vercel project name - VERCEL_PROJECT_NAME=`cat now.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.name'` + VERCEL_PROJECT_NAME=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.name'` echo "Vercel project name: " $VERCEL_PROJECT_NAME echo "VERCEL_PROJECT_NAME=$VERCEL_PROJECT_NAME" >> $GITHUB_ENV @@ -183,9 +183,9 @@ jobs: - uses: actions/checkout@v1 # Get last commit pushed - XXX See https://github.com/actions/checkout - name: Resolving deployment url from Zeit # Workflow overview: - # - Resolve customer to deploy from github event input (falls back to resolving it from now.json file) + # - Resolve customer to deploy from github event input (falls back to resolving it from vercel.json file) # - Resolve $ZEIT_DEPLOYMENT_URL - # - Fetch all deployments data (by using the scope in `now.json`) + # - Fetch all deployments data (by using the scope in `vercel.json`) # - Resolve the last url (from `response.deployments[0].url`) # - Remove the `"` character to pre-format url # We need to set env the url for next step, formatted as `https://${$ZEIT_DEPLOYMENT}/en` using /en endpoint to improve perfs by avoiding the url redirect on / @@ -197,17 +197,17 @@ jobs: echo "MANUAL_TRIGGER_CUSTOMER: " $MANUAL_TRIGGER_CUSTOMER echo "MANUAL_TRIGGER_CUSTOMER=$MANUAL_TRIGGER_CUSTOMER" >> $GITHUB_ENV - CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" + CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" echo "Customer that was deployed: " $CUSTOMER_REF_TO_DEPLOY echo "CUSTOMER_REF_TO_DEPLOY=$CUSTOMER_REF_TO_DEPLOY" >> $GITHUB_ENV # Resolve Vercel team ID - VERCEL_TEAM_ID=`cat now.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.scope'` + VERCEL_TEAM_ID=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.scope'` echo "Vercel team ID: " $VERCEL_TEAM_ID echo "VERCEL_TEAM_ID=$VERCEL_TEAM_ID" >> $GITHUB_ENV # Resolve Vercel project name - VERCEL_PROJECT_NAME=`cat now.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.name'` + VERCEL_PROJECT_NAME=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.production.json | jq --raw-output '.name'` echo "Vercel project name: " $VERCEL_PROJECT_NAME echo "VERCEL_PROJECT_NAME=$VERCEL_PROJECT_NAME" >> $GITHUB_ENV diff --git a/.github/workflows/deploy-zeit-staging.yml b/.github/workflows/deploy-zeit-staging.yml index dfac8ff4c..2b2f323c2 100644 --- a/.github/workflows/deploy-zeit-staging.yml +++ b/.github/workflows/deploy-zeit-staging.yml @@ -35,7 +35,7 @@ jobs: node-version: '12.x' # Use the same node.js version as the one Zeit's uses (currently node12.x) # Starts a Zeit deployment, using the staging configuration file of the default institution - # The default institution is the one defined in the `now.json` file (which is a symlink to the actual file) + # The default institution is the one defined in the `vercel.json` file (which is a symlink to the actual file) # N.B: It's Zeit that will perform the actual deployment start-staging-deployment: name: Starts Zeit deployment (staging) (Ubuntu 18.04) @@ -45,23 +45,23 @@ jobs: - uses: actions/checkout@v1 # Get last commit pushed - XXX See https://github.com/actions/checkout - name: Deploying on Zeit (staging) # Workflow overview: - # - Resolve customer to deploy from github event input (falls back to resolving it from now.json file) + # - Resolve customer to deploy from github event input (falls back to resolving it from vercel.json file) # - Resolve $ZEIT_DEPLOYMENT_URL # - Get stdout from deploy command (stderr prints build steps and stdout prints deployment url, which is what we are really looking for) # - Set the deployment url that will be included in the eventual PR comment # - Create a deployment alias based on the branch name, and link it to the deployment (so that each branch has its own domain automatically aliased to the latest commit) # XXX You can use https://jqplay.org/ if you want to play around with "jq" to manipulate JSON run: | - # Print the version of the "now" CLI being used (helps debugging) - now --version + # Print the version of the "vercel" CLI being used (helps debugging) + vercel --version # Resolving customer to deploy based on the github event input, when using manual deployment triggerer through "workflow_dispatch" event - # Falls back to the customer specified in the now.json file, which is most useful when deployment is triggered through "push" event + # Falls back to the customer specified in the vercel.json file, which is most useful when deployment is triggered through "push" event MANUAL_TRIGGER_CUSTOMER="${{ github.event.inputs.customer}}" echo "MANUAL_TRIGGER_CUSTOMER: " $MANUAL_TRIGGER_CUSTOMER echo "MANUAL_TRIGGER_CUSTOMER=$MANUAL_TRIGGER_CUSTOMER" >> $GITHUB_ENV - CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" + CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" echo "Customer to deploy: " $CUSTOMER_REF_TO_DEPLOY echo "CUSTOMER_REF_TO_DEPLOY=$CUSTOMER_REF_TO_DEPLOY" >> $GITHUB_ENV @@ -80,7 +80,7 @@ jobs: if [[ ${CURRENT_BRANCH##*/} =~ ^v[0-9]{1,}- ]]; then # Checking if pattern matches with "vX-" where X is a number ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS=${CURRENT_BRANCH##*/} else - ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS=$(cat now.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.name')-${CURRENT_BRANCH##*/} + ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS=$(cat vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.name')-${CURRENT_BRANCH##*/} fi echo "Resolved domain alias: " $ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS @@ -101,19 +101,19 @@ jobs: echo "ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS=$ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS" >> $GITHUB_ENV echo "Alias domain: "$ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS echo "Aliasing the deployment using the git branch alias:" - echo "npx now alias "$ZEIT_DEPLOYMENT_URL $ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS + echo "npx vercel alias "$ZEIT_DEPLOYMENT_URL $ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS # Create Vercel alias, use "||" to allow failure (keep the build going) even if the alias fails - ZEIT_ALIASING_OUTPUT=`npx now alias $ZEIT_DEPLOYMENT_URL $ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS --token $ZEIT_TOKEN || echo "Aliasing failed for '$ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS', but the build will continue regardless."` + ZEIT_ALIASING_OUTPUT=`npx vercel alias $ZEIT_DEPLOYMENT_URL $ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS --token $ZEIT_TOKEN || echo "Aliasing failed for '$ZEIT_DEPLOYMENT_AUTO_BRANCH_ALIAS', but the build will continue regardless."` echo $ZEIT_ALIASING_OUTPUT # TODO Resolve whether the aliasing has worked and change the GitHub comment "Comment PR (Deployment success)" - # Find all custom aliases configured in the customer deployment configuration file (now.json) - ZEIT_DEPLOYMENT_ALIASES_JSON=$(cat now.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.alias') + # Find all custom aliases configured in the customer deployment configuration file (vercel.json) + ZEIT_DEPLOYMENT_ALIASES_JSON=$(cat vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.alias') echo "Custom aliases: " $ZEIT_DEPLOYMENT_ALIASES_JSON # Convert the JSON array into a bash array - See https://unix.stackexchange.com/a/615717/60329 - readarray -t ZEIT_DEPLOYMENT_ALIASES < <(jq --raw-output '.alias[]' < now.$CUSTOMER_REF_TO_DEPLOY.staging.json) + readarray -t ZEIT_DEPLOYMENT_ALIASES < <(jq --raw-output '.alias[]' < vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json) # Count the number of element in the array, will be 0 if it's an empty array, or if the "alias" key wasn't defined ZEIT_DEPLOYMENT_ALIASES_COUNT=${#ZEIT_DEPLOYMENT_ALIASES[@]} @@ -125,12 +125,12 @@ jobs: # For each alias configured, then assign it to the deployed domain for DEPLOYMENT_ALIAS in "${ZEIT_DEPLOYMENT_ALIASES[@]}"; do - echo "npx now alias "$ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS - npx now alias $ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS --token $ZEIT_TOKEN || echo "Aliasing failed for '$DEPLOYMENT_ALIAS', but the build will continue regardless." + echo "npx vercel alias "$ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS + npx vercel alias $ZEIT_DEPLOYMENT_URL $DEPLOYMENT_ALIAS --token $ZEIT_TOKEN || echo "Aliasing failed for '$DEPLOYMENT_ALIAS', but the build will continue regardless." done else - # $ZEIT_DEPLOYMENT_ALIASES is null, this happens when it was not defined in the now.json file - echo "There are no more aliases to configure. You can add more aliases from your now.json 'alias' property. See https://vercel.com/docs/configuration?query=alias%20domain#project/alias" + # $ZEIT_DEPLOYMENT_ALIASES is null, this happens when it was not defined in the vercel.json file + echo "There are no more aliases to configure. You can add more aliases from your vercel.json 'alias' property. See https://vercel.com/docs/configuration?query=alias%20domain#project/alias" echo "$ZEIT_DEPLOYMENT_ALIASES" fi env: @@ -181,9 +181,9 @@ jobs: - uses: actions/checkout@v1 # Get last commit pushed - XXX See https://github.com/actions/checkout - name: Resolving deployment url from Zeit # Workflow overview: - # - Resolve customer to deploy from github event input (falls back to resolving it from now.json file) + # - Resolve customer to deploy from github event input (falls back to resolving it from vercel.json file) # - Resolve $ZEIT_DEPLOYMENT_URL - # - Fetch all deployments data (by using the scope in `now.json`) + # - Fetch all deployments data (by using the scope in `vercel.json`) # - Resolve the last url (from `response.deployments[0].url`) # - Remove the `"` character to pre-format url # We need to set env the url for next step, formatted as `https://${$ZEIT_DEPLOYMENT}` @@ -195,17 +195,17 @@ jobs: echo "MANUAL_TRIGGER_CUSTOMER: " $MANUAL_TRIGGER_CUSTOMER echo "MANUAL_TRIGGER_CUSTOMER=$MANUAL_TRIGGER_CUSTOMER" >> $GITHUB_ENV - CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" + CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" echo "Customer that was deployed: " $CUSTOMER_REF_TO_DEPLOY echo "CUSTOMER_REF_TO_DEPLOY=$CUSTOMER_REF_TO_DEPLOY" >> $GITHUB_ENV # Resolve Vercel team ID - VERCEL_TEAM_ID=`cat now.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.scope'` + VERCEL_TEAM_ID=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.scope'` echo "Vercel team ID: " $VERCEL_TEAM_ID echo "VERCEL_TEAM_ID=$VERCEL_TEAM_ID" >> $GITHUB_ENV # Resolve Vercel project name - VERCEL_PROJECT_NAME=`cat now.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.name'` + VERCEL_PROJECT_NAME=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.name'` echo "Vercel project name: " $VERCEL_PROJECT_NAME echo "VERCEL_PROJECT_NAME=$VERCEL_PROJECT_NAME" >> $GITHUB_ENV @@ -292,9 +292,9 @@ jobs: - uses: actions/checkout@v1 # Get last commit pushed - XXX See https://github.com/actions/checkout - name: Resolving deployment url from Zeit # Workflow overview: - # - Resolve customer to deploy from github event input (falls back to resolving it from now.json file) + # - Resolve customer to deploy from github event input (falls back to resolving it from vercel.json file) # - Resolve $ZEIT_DEPLOYMENT_URL - # - Fetch all deployments data (by using the scope in `now.json`) + # - Fetch all deployments data (by using the scope in `vercel.json`) # - Resolve the last url (from `response.deployments[0].url`) # - Remove the `"` character to pre-format url # We need to set env the url for next step, formatted as `https://${$ZEIT_DEPLOYMENT}/en` using /en endpoint to improve perfs by avoiding the url redirect on / @@ -306,17 +306,17 @@ jobs: echo "MANUAL_TRIGGER_CUSTOMER: " $MANUAL_TRIGGER_CUSTOMER echo "MANUAL_TRIGGER_CUSTOMER=$MANUAL_TRIGGER_CUSTOMER" >> $GITHUB_ENV - CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat now.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" + CUSTOMER_REF_TO_DEPLOY="${MANUAL_TRIGGER_CUSTOMER:-$(cat vercel.json | jq --raw-output '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}" echo "Customer that was deployed: " $CUSTOMER_REF_TO_DEPLOY echo "CUSTOMER_REF_TO_DEPLOY=$CUSTOMER_REF_TO_DEPLOY" >> $GITHUB_ENV # Resolve Vercel team ID - VERCEL_TEAM_ID=`cat now.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.scope'` + VERCEL_TEAM_ID=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.scope'` echo "Vercel team ID: " $VERCEL_TEAM_ID echo "VERCEL_TEAM_ID=$VERCEL_TEAM_ID" >> $GITHUB_ENV # Resolve Vercel project name - VERCEL_PROJECT_NAME=`cat now.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.name'` + VERCEL_PROJECT_NAME=`cat vercel.$CUSTOMER_REF_TO_DEPLOY.staging.json | jq --raw-output '.name'` echo "Vercel project name: " $VERCEL_PROJECT_NAME echo "VERCEL_PROJECT_NAME=$VERCEL_PROJECT_NAME" >> $GITHUB_ENV diff --git a/.gitignore b/.gitignore index f07fbd8ab..16d256a0a 100644 --- a/.gitignore +++ b/.gitignore @@ -139,6 +139,7 @@ src/svg/*.tsx # Zeit .now +.vercel # Jekyll - Github Pages _site diff --git a/.nowignore b/.vercelignore similarity index 100% rename from .nowignore rename to .vercelignore diff --git a/next.config.js b/next.config.js index 3161e8a54..7c8a610ed 100644 --- a/next.config.js +++ b/next.config.js @@ -54,6 +54,10 @@ module.exports = withBundleAnalyzer(withSourceMaps({ * XXX All env variables defined in ".env*" files that aren't public (those that don't start with "NEXT_PUBLIC_") MUST manually be made available at build time below. * They're necessary on Vercel for runtime execution (SSR, SSG with revalidate, everything that happens server-side will need those). * + * XXX This is a duplication of the environment variables. + * The variables defined below are only used locally, while those in "vercel.*.json:build:env" will be used on the Vercel platform. + * See https://vercel.com/docs/v2/build-step/#providing-environment-variables + * * @see https://nextjs.org/docs/api-reference/next.config.js/environment-variables */ env: { diff --git a/now.json b/now.json deleted file mode 120000 index b2d66da44..000000000 --- a/now.json +++ /dev/null @@ -1 +0,0 @@ -./now.customer1.staging.json \ No newline at end of file diff --git a/package.json b/package.json index b50f035d4..f30242b09 100644 --- a/package.json +++ b/package.json @@ -16,18 +16,18 @@ "deploy:all": "yarn deploy:customer1 && yarn deploy:customer2", "deploy:all:production": "yarn deploy:customer1:production && yarn deploy:customer2:production", "deploy:all:all": "yarn deploy:all && yarn deploy:all:production", - "deploy:customer": "yarn now:cleanup && now --confirm --local-config=now.${CUSTOMER_REF}.staging.json --debug", - "deploy:customer:production:simple": "yarn now:cleanup && now --confirm --local-config=now.${CUSTOMER_REF}.production.json --prod --debug", + "deploy:customer": "yarn vercel:cleanup && vercel --confirm --local-config=vercel.${CUSTOMER_REF}.staging.json --debug", + "deploy:customer:production:simple": "yarn vercel:cleanup && vercel --confirm --local-config=vercel.${CUSTOMER_REF}.production.json --prod --debug", "deploy:customer1:all": "yarn deploy:customer1 && yarn deploy:customer1:production", - "deploy:customer1": "yarn now:cleanup && now --confirm --local-config=now.customer1.staging.json --debug", + "deploy:customer1": "yarn vercel:cleanup && vercel --confirm --local-config=vercel.customer1.staging.json --debug", "deploy:customer1:production": "yarn deploy:customer1:production:simple && yarn e2e:customer1:production", - "deploy:customer1:production:simple": "yarn now:cleanup && now --confirm --local-config=now.customer1.production.json --prod --debug", + "deploy:customer1:production:simple": "yarn vercel:cleanup && vercel --confirm --local-config=vercel.customer1.production.json --prod --debug", "deploy:customer2:all": "yarn deploy:customer2 && yarn deploy:customer2:production", - "deploy:customer2": "yarn now:cleanup && now --confirm --local-config=now.customer2.staging.json --debug", + "deploy:customer2": "yarn vercel:cleanup && vercel --confirm --local-config=vercel.customer2.staging.json --debug", "deploy:customer2:production": "yarn deploy:customer2:production:simple && yarn e2e:customer2:production", - "deploy:customer2:production:simple": "yarn now:cleanup && now --confirm --local-config=now.customer2.production.json --prod --debug", + "deploy:customer2:production:simple": "yarn vercel:cleanup && vercel --confirm --local-config=vercel.customer2.production.json --prod --debug", "deploy:fake": "git commit --allow-empty -m \"Fake empty commit (force CI trigger)\"", - "now:cleanup": "npx del-cli .now/ && npx del-cli .vercel/", + "vercel:cleanup": "npx del-cli .vercel/ && npx del-cli .vercel/", "e2e": "yarn e2e:run", "e2e:all:production": "yarn e2e:customer1:production && yarn e2e:customer2:production", "e2e:customer1:production": "CYPRESS_STAGE=customer1 yarn e2e:run", @@ -196,7 +196,7 @@ "next-unused": "0.0.3", "ngrok": "3.3.0", "node-mocks-http": "1.9.0", - "now": "20.1.0", + "vercel": "21.0.0", "react-test-renderer": "16.13.1", "ts-jest": "26.3.0", "typescript": "4.0.2", diff --git a/src/pages/[locale]/examples/built-in-features/hosting.tsx b/src/pages/[locale]/examples/built-in-features/hosting.tsx index 9052ba8fb..ab0c72e7b 100644 --- a/src/pages/[locale]/examples/built-in-features/hosting.tsx +++ b/src/pages/[locale]/examples/built-in-features/hosting.tsx @@ -80,11 +80,11 @@ const HostingPage: NextPage = (props): JSX.Element => { We are a bit wary about recent changes and decisions made by the Vercel team, in particular regarding their 2020 April Pricing changes, and - we led a discussion about it.
+ we led a discussion about it.

Currently, the most controversial decision they've made is about the 12-24 max serverless functions.
We suggest you - learn heavily about that + learn heavily about that if you're considering Vercel.
diff --git a/src/pages/[locale]/examples/built-in-features/manual-deployments.tsx b/src/pages/[locale]/examples/built-in-features/manual-deployments.tsx index 99677ad8c..04d30c77a 100644 --- a/src/pages/[locale]/examples/built-in-features/manual-deployments.tsx +++ b/src/pages/[locale]/examples/built-in-features/manual-deployments.tsx @@ -103,7 +103,7 @@ const ManualDeploymentsPage: NextPage = (props): JSX.Element => { They're also used by CI/CD scripts.
- Note that when deploying through CI/CD, the deployed customer depends on which file is targeted as symbolic link by the now.json file.
+ Note that when deploying through CI/CD, the deployed customer depends on which file is targeted as symbolic link by the vercel.json file.
Changing the symbolic link, or "hardcoding" the file will change which customer gets deployed by default.
You can also change the way CI/CD works and deploy all your customers at once every time, but we preferred to deploy one customer in particular (our own internal demo) by default, as we judged it was less risky in case anything goes wrong.
diff --git a/src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx b/src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx index 073771cf5..bac3a8d60 100644 --- a/src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx +++ b/src/pages/[locale]/examples/built-in-features/stages-and-secrets.tsx @@ -86,12 +86,12 @@ const StagesAndSecretsPage: NextPage = (props): JSX.Element => {
  • staging and development stages: - Your env vars are configured in the now.*.json files, per customer and per stage.
    + Your env vars are configured in the vercel.*.json files, per customer and per stage.
    Env vars are basically hardcoded in those files, while secrets are referenced there, but nobody can read their value.

  • - Overall, we made it easy to use: Just hardcode your non-sensitive env vars in now.*.json and store your sensitive secrets on Vercel, that's it. + Overall, we made it easy to use: Just hardcode your non-sensitive env vars in vercel.*.json and store your sensitive secrets on Vercel, that's it. @@ -100,7 +100,7 @@ const StagesAndSecretsPage: NextPage = (props): JSX.Element => { Before, only secrets existed, but since now@18 they've introduced the concept of environment variables.
    It can be a bit hard to understand how the 2 should be used together.
    Basically put, secrets are global and shared across all projects, while env vars are scoped by project.
    - There are other differences, though.
    + There are other differences, though.
    diff --git a/src/utils/i18n/i18nextLocize.ts b/src/utils/i18n/i18nextLocize.ts index 688900d4c..a4d45645d 100644 --- a/src/utils/i18n/i18nextLocize.ts +++ b/src/utils/i18n/i18nextLocize.ts @@ -404,7 +404,7 @@ const createI18nextLocizeInstance = (lang: string, i18nTranslations: I18nextReso // If NEXT_PUBLIC_LOCIZE_PROJECT_ID is not defined then we mustn't init i18next or it'll crash the whole app when running in non-production stage // In that case, better crash early with an explicit message if (!process.env.NEXT_PUBLIC_LOCIZE_PROJECT_ID) { - throw new Error('Env var "NEXT_PUBLIC_LOCIZE_PROJECT_ID" is not defined. Please add it to you .env.build file (development) or now*.json (staging/production)'); + throw new Error('Env var "NEXT_PUBLIC_LOCIZE_PROJECT_ID" is not defined. Please add it to you .env.build file (development) or vercel*.json (staging/production)'); } // Plugins will be dynamically added at runtime, depending on the runtime engine (node or browser) diff --git a/now.customer1.production.json b/vercel.customer1.production.json similarity index 100% rename from now.customer1.production.json rename to vercel.customer1.production.json diff --git a/now.customer1.staging.json b/vercel.customer1.staging.json similarity index 100% rename from now.customer1.staging.json rename to vercel.customer1.staging.json diff --git a/now.customer2.production.json b/vercel.customer2.production.json similarity index 100% rename from now.customer2.production.json rename to vercel.customer2.production.json diff --git a/now.customer2.staging.json b/vercel.customer2.staging.json similarity index 100% rename from now.customer2.staging.json rename to vercel.customer2.staging.json diff --git a/vercel.json b/vercel.json new file mode 120000 index 000000000..69d7711ba --- /dev/null +++ b/vercel.json @@ -0,0 +1 @@ +./vercel.customer1.staging.json \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 1eac3c1cc..707bded08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2817,20 +2817,20 @@ resolved "https://registry.yarnpkg.com/@unly/utils/-/utils-1.0.3.tgz#6fd8e361dfb977f0cfdc9ce83d7f0719dd6ae3de" integrity sha512-QTRknIDX56FvzGcIpBum5D/oRSlX3dkZ+l1op1jsFlYCTd925OGUb991V7zsFv3ePcqFfvfqfR5cNVv+w4JAOw== -"@vercel/build-utils@2.5.1": - version "2.5.1" - resolved "https://registry.yarnpkg.com/@vercel/build-utils/-/build-utils-2.5.1.tgz#2f687c2d82464dd85e0ed8130bc01e5dac9b11a4" - integrity sha512-689ov8fGrgVnLwPbJUvgUKdSTseZiOMobR4XoZjmSmeF8+gaOpycsdGuVFzNtdFneUiQWO/k5AkY5diZj8fNgg== +"@vercel/build-utils@2.6.1-canary.0": + version "2.6.1-canary.0" + resolved "https://registry.yarnpkg.com/@vercel/build-utils/-/build-utils-2.6.1-canary.0.tgz#ba549e7817c5a13e9ce271f88db3c3b9432d0d8b" + integrity sha512-lwTNPC4xCTeqzdHSsfIzHD5h/SwwcIemA5MDRUVdFEuYyF9X38i5A01ad1l/WedCQDi7IP3Q1IGOJ9g7XKJXOg== "@vercel/go@1.1.6": version "1.1.6" resolved "https://registry.yarnpkg.com/@vercel/go/-/go-1.1.6.tgz#45ac3a6bd98a15b8bf1028b8c141a51fd971ac15" integrity sha512-swA2crS08fkPmw4UkR9yjmoL8FOCzuNHLFDqj8oM1V9ni610ibJ7Xk57jI8uyS7bTecQVh8VUxihb+SF0GT+aw== -"@vercel/node@1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.8.1.tgz#aa0a04f425638874d19be64f7905018ef6f9b1c5" - integrity sha512-vQsYMrulghMaHEKbqxJCQPfHrGEBmYmQMLYrx+m8kolKDq1LQDWFx2MRh4DyMnGfYSoYoW5PI2HP7NAfbEjzmg== +"@vercel/node@1.8.5": + version "1.8.5" + resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.8.5.tgz#2c8b9532f1bb25734a9964c52973386ed78022d4" + integrity sha512-1iw7FSR8Oau6vZB1MWfBnA5q2a/IqRHiSZSbt8lz0dyTF599q8pc5GcSv/TvmrYaEGzh3+N0S4cbmuMCqVlwJg== dependencies: "@types/node" "*" ts-node "8.9.1" @@ -9670,18 +9670,6 @@ normalize-url@^4.1.0: resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== -now@20.1.0: - version "20.1.0" - resolved "https://registry.yarnpkg.com/now/-/now-20.1.0.tgz#32a69994320675050cce67e696529f0adb2feddb" - integrity sha512-RojyvdioMVE5u+Oa+/E97bJ2OT8w1NZsrt4eBqeKQRB+XJ2DsVS0nor9PXy7oJkCXKJhdmhWoTFsBPVuIsKADQ== - dependencies: - "@vercel/build-utils" "2.5.1" - "@vercel/go" "1.1.6" - "@vercel/node" "1.8.1" - "@vercel/python" "1.2.3" - "@vercel/ruby" "1.2.4" - update-notifier "4.1.0" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -13034,6 +13022,18 @@ vary@~1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= +vercel@21.0.0: + version "21.0.0" + resolved "https://registry.yarnpkg.com/vercel/-/vercel-21.0.0.tgz#4be0218649bd86f781f99a7c4a3ef2f83407f03e" + integrity sha512-xe0rc9Fj+CgT226TAgN0YVMgiHvs6QsPzIR6K5m2Dqc8aQjueaM0a4aTHxPErQAS6h32O7TC0QtTyyEwBtVGNw== + dependencies: + "@vercel/build-utils" "2.6.1-canary.0" + "@vercel/go" "1.1.6" + "@vercel/node" "1.8.5" + "@vercel/python" "1.2.3" + "@vercel/ruby" "1.2.4" + update-notifier "4.1.0" + verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"