From 6b4284b988ff5ff13cdf593a5d2544ee52e66bfc Mon Sep 17 00:00:00 2001 From: Alex Reed Date: Tue, 12 Jul 2022 15:12:52 +0200 Subject: [PATCH] Merge pull request #129 from gatsbyjs/chore/update-sanity-env-var-naming update sanity env vars to match expected convention in cloud --- .env.EXAMPLE | 4 ++-- gatsby-config.js | 4 ++-- scripts/setup.js | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.env.EXAMPLE b/.env.EXAMPLE index db4a47b..376bdbf 100644 --- a/.env.EXAMPLE +++ b/.env.EXAMPLE @@ -2,5 +2,5 @@ # with the following keys. # Do NOT check these files into source control SANITY_PROJECT_ID="" -SANITY_DATASET="" -SANITY_TOKEN="" +SANITY_PROJECT_DATASET="" +SANITY_READ_TOKEN="" diff --git a/gatsby-config.js b/gatsby-config.js index 6ea9558..08bf56a 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -9,8 +9,8 @@ module.exports = { resolve: "gatsby-source-sanity", options: { projectId: process.env.SANITY_PROJECT_ID, - dataset: process.env.SANITY_DATASET, - token: process.env.SANITY_TOKEN, + dataset: process.env.SANITY_PROJECT_DATASET, + token: process.env.SANITY_READ_TOKEN, }, }, "gatsby-plugin-sharp", diff --git a/scripts/setup.js b/scripts/setup.js index a3cde05..9526d5b 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -9,8 +9,8 @@ const config = new Configstore( globalConfigPath: true, } ) -const token = process.env.SANITY_TOKEN || config.get("authToken") -const dataset = process.env.SANITY_DATASET || studio.api?.dataset +const token = process.env.SANITY_READ_TOKEN || config.get("authToken") +const dataset = process.env.SANITY_PROJECT_DATASET || studio.api?.dataset const projectId = process.env.SANITY_PROJECT_ID || studio.api?.projectId if (!token) { @@ -29,9 +29,9 @@ const content = [ `# All environment variables will be sourced`, `# and made available to gatsby-config.js, gatsby-node.js, etc.`, `# Do NOT commit this file to source control`, - `SANITY_TOKEN='${token}'`, + `SANITY_READ_TOKEN='${token}'`, `SANITY_PROJECT_ID='${projectId}'`, - `SANITY_DATASET='${dataset}'`, + `SANITY_PROJECT_DATASET='${dataset}'`, ].join("\n") fs.writeFileSync(".env.development", content)