Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Fix bad exports, including a circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kusold committed Apr 4, 2018
1 parent 6d1fab2 commit 72f77d9
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion api/get_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
3 changes: 1 addition & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
7 changes: 5 additions & 2 deletions lib/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

7 changes: 5 additions & 2 deletions lib/managementAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ class ManagementClientAdapter {
}
}

module.exports = ManagementClientAdapter;
module.exports.getCurrentConfig = getCurrentConfig;
module.exports = {
ManagementClientAdapter,
getCurrentConfig,
};

8 changes: 5 additions & 3 deletions lib/storage.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,6 +46,8 @@ function setLocales(locales) {
}

module.exports = {
STATUS_SUCCESSFUL,
STATUS_ERRORED,
getSettings,
setSettings,
getLocales,
Expand Down
4 changes: 2 additions & 2 deletions templates/utils/auth0widget.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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 => `
<div id="auth0-lock-container-1" class="auth0-lock-container">
<div class="auth0-lock auth0-lock-opened auth0-lock-with-tabs ${lockOutlineClass(
settings.removeOverlay
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ const createToken = (user) => {
return sign(userSub, config('AUTH0_CLIENT_SECRET'), options);
};

module.exports = { startServer, createRequest as request, createServer, createToken };
module.exports = { startServer, request: createRequest, createServer, createToken };
3 changes: 1 addition & 2 deletions test/unit/locale_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-underscore-dangle */

const { expect } = require('chai');
const resolveLocale = require('../../lib/locale');
const { allLocales } = require('../../lib/locale');
const { resolveLocale, allLocales } = require('../../lib/locale');

const sampleLocales = {
en: {
Expand Down
5 changes: 2 additions & 3 deletions test/unit/managementAdapter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

const path = require('path');
const { expect } = require('chai');
const ManagementAdapter = require('../../lib/managementAdapter');
const { getCurrentConfig } = require('../../lib/managementAdapter');
const { ManagementClientAdapter, getCurrentConfig } = require('../../lib/managementAdapter');

const configPath = path.join(__dirname, '../../server/config.test.json');

Expand All @@ -20,7 +19,7 @@ describe('Management API adapter', () => {

it('Adapter initializes correctly', (done) => {
getCurrentConfig(configPath).then((config) => {
const adapter = new ManagementAdapter(config);
const adapter = new ManagementClientAdapter(config);

expect(typeof adapter.client).to.equal('object');

Expand Down

0 comments on commit 72f77d9

Please sign in to comment.