Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 8db0b1c

Browse files
authored
Update terra-base and terra-i18n packages (#2288)
1 parent 60ade88 commit 8db0b1c

File tree

69 files changed

+110
-1265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+110
-1265
lines changed

jestconfig.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
'packages/**/src/*.js',
44
'packages/**/src/*.jsx',
55
],
6+
globalSetup: './jestglobalsetup.js',
67
setupFiles: [
78
'raf/polyfill',
89
'./jestsetup.js',
@@ -18,5 +19,9 @@ module.exports = {
1819
'\\.(svg|jpg|png|md)$': '<rootDir>/__mocks__/fileMock.js',
1920
'\\.(css|scss)$': 'identity-obj-proxy',
2021
},
22+
moduleDirectories: [
23+
'aggregated-translations',
24+
'node_modules',
25+
],
2126
testURL: 'http://localhost',
2227
};

jestglobalsetup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable-next-line import/no-extraneous-dependencies */
2+
const aggregateTranslations = require('terra-toolkit/scripts/aggregate-translations/aggregate-translations');
3+
4+
module.exports = () => {
5+
aggregateTranslations();
6+
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"eslint": "^5.0.0",
7676
"eslint-config-terra": "^2.0.0",
7777
"gh-pages": "^1.1.0",
78-
"glob": "^7.1.1",
78+
"glob": "^7.1.2",
7979
"identity-obj-proxy": "^3.0.0",
8080
"jest": "^23.1.0",
8181
"lerna": "^2.1.2",
@@ -84,7 +84,7 @@
8484
"react": "^16.8.5",
8585
"react-dom": "^16.8.5",
8686
"react-router-dom": "^4.0.0",
87-
"react-test-renderer": "^16.4.2",
87+
"react-test-renderer": "^16.5.2",
8888
"stylelint": "^9.0.0",
8989
"stylelint-config-terra": "^2.0.0",
9090
"terra-dev-site": "^3.0.0",

packages/terra-base/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Changelog
33

44
Unreleased
55
----------
6+
### Breaking Changes
7+
* Locale prop is now required
8+
* This package no longer provides the `injectIntl`, `intlShape`, `FormattedMessage`, `IntlProvider` exports from react-intl
9+
* Removed div that wrapped children passed into the base component. The base component now uses a `<React.Fragment>` wrapper around children
610

711
4.5.0 - (March 26, 2019)
812
------------------

packages/terra-base/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"homepage": "https://github.com/cerner/terra-core#readme",
2323
"peerDependencies": {
2424
"react": "^16.8.5",
25-
"react-dom": "^16.8.5"
25+
"react-dom": "^16.8.5",
26+
"react-intl": "^2.8.0"
2627
},
2728
"dependencies": {
2829
"classnames": "^2.2.5",

packages/terra-base/src/Base.jsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import {
4-
I18nProvider, i18nLoader, injectIntl, intlShape, FormattedMessage, IntlProvider,
5-
} from 'terra-i18n';
3+
import { I18nProvider, i18nLoader } from 'terra-i18n';
64
import './baseStyles';
75

86
const propTypes = {
@@ -13,7 +11,7 @@ const propTypes = {
1311
/**
1412
* The locale name.
1513
*/
16-
locale: PropTypes.string,
14+
locale: PropTypes.string.isRequired,
1715
/**
1816
* Customized translations provided by consuming application only for current locale.
1917
*/
@@ -86,17 +84,9 @@ class Base extends React.Component {
8684
const messages = Object.assign({}, this.state.messages, customMessages);
8785
const renderChildren = strictMode ? (<React.StrictMode>{children}</React.StrictMode>) : children;
8886

89-
if (locale === undefined) {
90-
return (
91-
<div {...customProps} data-terra-base>
92-
{renderChildren}
93-
</div>
94-
);
95-
}
96-
9787
if (!this.state.areTranslationsLoaded) return <div>{this.props.translationsLoadingPlaceholder}</div>;
9888
return (
99-
<I18nProvider {...customProps} locale={this.state.locale} messages={messages} data-terra-base>
89+
<I18nProvider {...customProps} locale={this.state.locale} messages={messages}>
10090
{renderChildren}
10191
</I18nProvider>
10292
);
@@ -107,6 +97,3 @@ Base.propTypes = propTypes;
10797
Base.defaultProps = defaultProps;
10898

10999
export default Base;
110-
export {
111-
injectIntl, intlShape, FormattedMessage, IntlProvider,
112-
};

packages/terra-base/src/terra-dev-site/test/base/DefaultBase.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import Base from '../../../Base';
33

44
const BaseDefault = () => (
5-
<Base>
5+
<Base locale="en">
66
<h1>Heading 1</h1>
77
<h2>Heading 2</h2>
88
<h3>Heading 3</h3>

packages/terra-base/src/terra-dev-site/test/base/SwitchLocaleBase.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { FormattedMessage } from 'terra-i18n';
2+
import { FormattedMessage } from 'react-intl';
33
import Base from '../../../Base';
44

55
const customMessages = {
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
import React from 'react';
22
import Base from '../../src/Base';
33

4+
// Missing locale test
5+
it('throws error for missing required locale', () => {
6+
const messages = { Terra: 'Terra' };
7+
8+
try {
9+
shallow(<Base customMessages={messages}>String</Base>);
10+
} catch (e) {
11+
expect(e.message).toContain('The prop `locale` is marked as required in `Base`');
12+
}
13+
});
14+
415
// Snapshot Tests
5-
it('should support rendering a string without translation', () => {
16+
it('should support rendering a string', () => {
617
const base = shallow(<Base>String</Base>);
718
expect(base).toMatchSnapshot();
819
});
920

10-
it('should support rendering an array of children without translation', () => {
21+
it('should support rendering an array of children', () => {
1122
/* eslint-disable comma-dangle */
1223
const base = shallow(
1324
<Base>
@@ -19,18 +30,7 @@ it('should support rendering an array of children without translation', () => {
1930
/* eslint-enable comma-dangle */
2031
});
2132

22-
// Snapshot Tests
23-
it('should render with stict mode when strict mode enabled', () => {
33+
it('should render with strict mode when strict mode enabled', () => {
2434
const base = shallow(<Base strictMode>String</Base>);
2535
expect(base).toMatchSnapshot();
2636
});
27-
28-
it('throws error for missing required locale', () => {
29-
const messages = { Terra: 'Terra' };
30-
31-
try {
32-
shallow(<Base customMessages={messages}>String</Base>);
33-
} catch (e) {
34-
expect(e.message).toContain('Missing locale prop');
35-
}
36-
});
Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`should render with stict mode when strict mode enabled 1`] = `
4-
<div
5-
data-terra-base={true}
6-
>
7-
<StrictMode>
8-
String
9-
</StrictMode>
10-
</div>
11-
`;
3+
exports[`should render with strict mode when strict mode enabled 1`] = `<div />`;
124

13-
exports[`should support rendering a string without translation 1`] = `
14-
<div
15-
data-terra-base={true}
16-
>
17-
String
18-
</div>
19-
`;
5+
exports[`should support rendering a string 1`] = `<div />`;
206

21-
exports[`should support rendering an array of children without translation 1`] = `
22-
<div
23-
data-terra-base={true}
24-
>
25-
<div>
26-
1
27-
</div>
28-
<div>
29-
2
30-
</div>
31-
</div>
32-
`;
7+
exports[`should support rendering an array of children 1`] = `<div />`;

packages/terra-i18n/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ Changelog
33

44
Unreleased
55
----------
6+
### Breaking Changes
7+
* Removed post-install script which wrote default loaders
8+
* Removed aggregate-translations pre-build tool
9+
* Removed `src/defaultIntlLoaders.js`
10+
* Removed `src/defaultTranslationsLoaders.js`
11+
* Removed `require.ensure` syntax for loading Intl polyfill
12+
* Removed `injectIntl`, `intlShape`, `FormattedMessage`, `IntlProvider` exports from react-intl
13+
* Removed div that wrapped children passed into the I18nProvider component. The I18nProvider component now uses a `<React.Fragment>` wrapper around children
14+
* Removed run time check for supported locales. This is provide at build time with terra-toolkits aggregate-translations script
615

716
3.5.0 - (March 26, 2019)
817
------------------

packages/terra-i18n/bin/aggregate-translations.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/terra-i18n/docs/AggregateTranslations.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/terra-i18n/docs/UPGRADEGUIDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Terra i18n Upgrade Guide
22

3+
## Changes from 3.0 to 4.0
4+
5+
The terra-i18n `aggregate-translations` pre-build tool has been removed from this package.
6+
7+
Along with this, the post-install script which wrote default intl and translation loaders has been removed.
8+
9+
Use the [`aggregate-translations` pre-build tool from terra-toolkit instead.](https://github.com/cerner/terra-toolkit/blob/master/docs/AggregateTranslations.md)
10+
311
## Changes from 2.0 to 3.0
412

513
### Changes to CSS Custom Properties

packages/terra-i18n/package.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,15 @@
2020
"url": "https://github.com/cerner/terra-core/issues"
2121
},
2222
"homepage": "https://github.com/cerner/terra-core#readme",
23-
"devDependencies": {
24-
"babel-jest": "^19.0.0",
25-
"memory-fs": "^0.4.1"
26-
},
27-
"bin": {
28-
"aggregate-translations": "./bin/aggregate-translations.js"
29-
},
3023
"peerDependencies": {
3124
"react": "^16.8.5",
32-
"react-dom": "^16.8.5"
25+
"react-dom": "^16.8.5",
26+
"react-intl": "^2.8.0"
3327
},
3428
"dependencies": {
3529
"classnames": "^2.2.5",
36-
"commander": "^2.9.0",
37-
"fs-extra": "^7.0.0",
38-
"glob": "^7.1.1",
3930
"intl": "^1.2.5",
40-
"lodash.startcase": "^4.4.0",
4131
"prop-types": "^15.5.8",
42-
"react-intl": "^2.8.0",
4332
"terra-doc-template": "^2.7.0"
4433
},
4534
"scripts": {
@@ -48,7 +37,6 @@
4837
"compile:build": "babel src --out-dir lib --copy-files",
4938
"lint": "npm run lint:js",
5039
"lint:js": "eslint --ext .js,.jsx . --ignore-path ../../.eslintignore",
51-
"postinstall": "node scripts/post-install/write-default-loaders.js",
5240
"test": "npm run test:jest && npm run test:wdio",
5341
"test:jest": "jest --config ../../jestconfig.js",
5442
"test:wdio": "../../node_modules/.bin/wdio ../../node_modules/terra-dev-site/config/wdio/wdio.conf.js"

packages/terra-i18n/scripts/aggregate-translations/aggregate-messages.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/terra-i18n/scripts/aggregate-translations/aggregate-translations-cli.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)