From 72f77d9f11ca5f24e1920b6345a78b7913019d01 Mon Sep 17 00:00:00 2001 From: Mike Kusold Date: Wed, 4 Apr 2018 13:18:49 -0600 Subject: [PATCH] Fix bad exports, including a circular dependency --- api/get_index.js | 2 +- gulpfile.js | 3 +-- lib/locale.js | 7 +++++-- lib/managementAdapter.js | 7 +++++-- lib/storage.js | 8 +++++--- templates/utils/auth0widget.js | 4 ++-- test/test_helper.js | 2 +- test/unit/locale_test.js | 3 +-- test/unit/managementAdapter_test.js | 5 ++--- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/api/get_index.js b/api/get_index.js index be6ac060..171ac56d 100644 --- a/api/get_index.js +++ b/api/get_index.js @@ -6,7 +6,7 @@ const logger = require('../lib/logger'); const stylesheet = require('../lib/stylesheet'); const getIdentityProviderPublicName = require('../lib/idProviders'); const humanizeArray = require('../lib/humanize'); -const resolveLocale = require('../lib/locale'); +const { resolveLocale } = require('../lib/locale'); const { getSettings } = require('../lib/storage'); const decodeToken = token => diff --git a/gulpfile.js b/gulpfile.js index f0ac2008..7755d180 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,8 +7,7 @@ const nodemon = require('gulp-nodemon'); const { install } = require('./modifyRule'); const managementAdapter = require('./lib/managementAdapter'); -const ManagementClientAdapter = managementAdapter.default; -const { getCurrentConfig } = managementAdapter; +const { ManagementClientAdapter, getCurrentConfig } = managementAdapter; gulp.task('run', () => { ngrok.connect(3001, (ngrokError, url) => { diff --git a/lib/locale.js b/lib/locale.js index 20d62baf..046fee3b 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -19,5 +19,8 @@ function resolveLocale(locale = 'en', overrideLocales) { return action.then(returnableFunction).catch(() => allLocales); } -module.exports = resolveLocale; -module.exports.allLocales = allLocales; +module.exports = { + allLocales, + resolveLocale, +}; + diff --git a/lib/managementAdapter.js b/lib/managementAdapter.js index e9112e2b..2fbb7efc 100644 --- a/lib/managementAdapter.js +++ b/lib/managementAdapter.js @@ -53,5 +53,8 @@ class ManagementClientAdapter { } } -module.exports = ManagementClientAdapter; -module.exports.getCurrentConfig = getCurrentConfig; +module.exports = { + ManagementClientAdapter, + getCurrentConfig, +}; + diff --git a/lib/storage.js b/lib/storage.js index 2e6412d1..54010252 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -1,9 +1,9 @@ const getStorage = require('./db').get; -const { allLocales } = require('./locale'); +const allLocales = require('../locales.json'); const defTemplate = require('../templates/utils/defaultTemplate'); -export const STATUS_SUCCESSFUL = 'ok'; -export const STATUS_ERRORED = 'error'; +const STATUS_SUCCESSFUL = 'ok'; +const STATUS_ERRORED = 'error'; const DEFAULT_LOCALE = 'en'; // Temporal dummy storage accessor methods @@ -46,6 +46,8 @@ function setLocales(locales) { } module.exports = { + STATUS_SUCCESSFUL, + STATUS_ERRORED, getSettings, setSettings, getLocales, diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index 9b060ca0..be7567d3 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -1,5 +1,5 @@ /* eslint-disable arrow-parens */ -const getCurrentLocale = require('../../lib/locale'); +const { resolveLocale } = require('../../lib/locale'); const { getSettings } = require('../../lib/storage'); const svgDimensions = require('../../lib/svgDimensions'); const lockOverlay = require('./lockOverlay'); @@ -55,7 +55,7 @@ const getSubmitButton = (settings, t) => { module.exports = (dynamicSettings, identities, locale = 'en') => getSettings().then(storedSettings => { const settings = Object.assign(storedSettings, dynamicSettings); - return getCurrentLocale(locale).then(t => ` + return resolveLocale(locale).then(t => `