Skip to content

Commit

Permalink
chore(static site) ensure API_ROOT env key overrides app.api_root con…
Browse files Browse the repository at this point in the history
…fig key
  • Loading branch information
goldpbear committed Oct 17, 2017
1 parent 4f1bbba commit 6b7b204
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 20 deletions.
11 changes: 9 additions & 2 deletions build-utils/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ module.exports = function(source) {
}
});

// The API root is defined in the config. In most cases this will be set to
// point to the dev API. If the .env defines a different API root, use that
// value here. Use the API_ROOT key in the .env to set a new API root. Note
// that this replaces the old SITE_URL key.
if (process.env.API_ROOT) {
config.app.api_root = process.env.API_ROOT;
}

// Strip out gettext syntax; we don't perform any localization of the config
// in this loader. Full localization is performed by the production build.
walk(config, (val, prop, obj) => {
Expand All @@ -49,10 +57,9 @@ module.exports = function(source) {
val = val
.replace(configGettextRegex, "")
.replace(/\)$/, "");
obj[prop] = val;
}
}

obj[prop] = val;
});

const templateSource = fs.readFileSync(
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/bogtobay/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/central-puget-sound/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/defaultflavor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/duwamish-watershed/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/duwamish_flavor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# Fallback image to use for sharing on social services if no model image is present
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/greensboropb/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

district:
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/greenways/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/gtopenspace/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/lakewashington/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
5 changes: 5 additions & 0 deletions src/flavors/madrid/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ app:
# Optional. List view is supported by default. Set to false to disable.
# list_enabled: false

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# languages:
# - code: en
# label: I Speak English
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/pboakland/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/pugetsound/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/rail/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/raingardens/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/snoqualmie/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/trees/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/waterfront/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
2 changes: 1 addition & 1 deletion src/flavors/willamette/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app:

# This should be set to the root of an api server from which you'd like to draw
# permissions information for logged-in users. This value can be overridden
# using the SITE_KEY environment variable. Note the trailing slash.
# using the API_ROOT environment variable. Note the trailing slash.
api_root: https://dev-api.heyduwamish.org/api/v2/

# When the map loads, existing places will be loaded in chunks. By default,
Expand Down
9 changes: 8 additions & 1 deletion static-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if (!flavor) {

// This version number is only used for cache-busting on our bundle.js
// and bundle.css files.
const bundleVersion = "0.7.5.7";
const bundleVersion = "0.7.5.9";

const flavorBasePath = path.resolve(
__dirname,
Expand Down Expand Up @@ -266,6 +266,13 @@ activeLanguages.forEach((language) => {
}
});

// The API root is defined in the config. In most cases this will be set to
// point to the dev API. If the .env defines a different API root, use that
// value here. Use the API_ROOT key in the .env to set a new API root. Note
// that this replaces the old SITE_URL key.
if (process.env.API_ROOT) {
thisConfig.app.api_root = process.env.API_ROOT;
}

// (5a) Copy all jstemplates and flavor pages to a working directory from
// which the templates can be localized and precompiled. Also resolve
Expand Down

0 comments on commit 6b7b204

Please sign in to comment.