Skip to content

Commit

Permalink
remove deprecated config support
Browse files Browse the repository at this point in the history
  • Loading branch information
bbetts-godaddy committed Jan 11, 2024
1 parent 232d81c commit 01edf0d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 31 deletions.
23 changes: 3 additions & 20 deletions packages/gasket-plugin-intl/lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ function getIntlConfig(gasket) {
return intl;
}

/**
* Destructure deprecated options as fallbacks and log warnings if used.
*
* @param {Gasket} gasket - Gasket API
* @param {object} intlConfig - User intl config
* @returns {object} config
*/
function deprecatedOptions(gasket, intlConfig) {
const { logger } = gasket;
const { languageMap, defaultLanguage, assetPrefix } = intlConfig;
if (isDefined(languageMap)) logger.warning('DEPRECATED intl config `languageMap` - use `localesMap`');
if (isDefined(defaultLanguage)) logger.warning('DEPRECATED intl config `defaultLanguage` - use `defaultLocale`');
if (isDefined(assetPrefix)) logger.warning('DEPRECATED intl config `assetPrefix` - use `basePath`');
return { languageMap, defaultLanguage, assetPrefix };
}

/**
* Sets up the Intl config for the Gasket session and add process env variables
* to access to certain config results where gasket.config is not accessible.
Expand All @@ -50,22 +34,21 @@ module.exports = function configureHook(gasket, config) {
const { root } = config;
const intlConfig = { ...getIntlConfig({ config }) };

const { languageMap, defaultLanguage, assetPrefix } = deprecatedOptions(gasket, intlConfig);
const { nextConfig = {} } = config;

// get user defined config and apply defaults
const {
defaultPath = '/locales',
defaultLocale = defaultLanguage || 'en',
localesMap = languageMap || {},
defaultLocale = 'en',
localesMap = {},
localesDir,
manifestFilename = 'locales-manifest.json',
preloadLocales = false
} = intlConfig;

const fullLocalesDir = path.join(root, localesDir);

const basePath = [intlConfig.basePath, assetPrefix,
const basePath = [intlConfig.basePath,
nextConfig.assetPrefix, nextConfig.basePath,
config.basePath, ''].find(isDefined);

Expand Down
11 changes: 0 additions & 11 deletions packages/gasket-plugin-intl/test/configure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,6 @@ describe('configure', function () {
);
});

it('logs deprecation warnings', function () {
configure(mockGasket, { root, intl: { languageMap: { foo: 'bar' } } });
expect(mockGasket.logger.warning).toHaveBeenCalledWith(expect.stringContaining('languageMap'));

configure(mockGasket, { root, intl: { defaultLanguage: 'fake' } });
expect(mockGasket.logger.warning).toHaveBeenCalledWith(expect.stringContaining('defaultLanguage'));

configure(mockGasket, { root, intl: { assetPrefix: 'fake' } });
expect(mockGasket.logger.warning).toHaveBeenCalledWith(expect.stringContaining('assetPrefix'));
});

describe('getIntlConfig', function () {

it('returns intl config from gasket.config.js', function () {
Expand Down

0 comments on commit 01edf0d

Please sign in to comment.