generator-folklore 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/lib/generators/app/index.js +3 -51
  2. package/lib/generators/babel/index.js +28 -101
  3. package/lib/generators/babel/templates/config.js +16 -0
  4. package/lib/generators/browserslist/index.js +4 -9
  5. package/lib/generators/build/index.js +40 -29
  6. package/lib/generators/cli/index.js +92 -0
  7. package/lib/generators/cli/templates/cli.js +22 -0
  8. package/lib/generators/cli/templates/commands/default.js +16 -0
  9. package/lib/generators/docs/index.js +1 -2
  10. package/lib/generators/editorconfig/index.js +12 -22
  11. package/lib/generators/eslint/index.js +12 -13
  12. package/lib/generators/{html → html-project}/index.js +60 -73
  13. package/lib/generators/{html → html-project}/templates/folklore.png +0 -0
  14. package/lib/generators/{html → html-project}/templates/gitignore +0 -0
  15. package/lib/generators/{html → html-project}/templates/index.html.ejs +4 -1
  16. package/lib/generators/laravel/index.js +5 -5
  17. package/lib/generators/lerna-package/index.js +1 -3
  18. package/lib/generators/lerna-repository/index.js +1 -3
  19. package/lib/generators/node-project/index.js +164 -0
  20. package/lib/generators/{js/templates/src/lib/.gitkeep → node-project/templates/index.js} +0 -0
  21. package/lib/generators/npm-package/index.js +3 -5
  22. package/lib/generators/prettier/index.js +19 -6
  23. package/lib/generators/prettier/templates/prettierrc.json +3 -1
  24. package/lib/generators/{js → react-app}/index.js +22 -52
  25. package/lib/generators/{js → react-app}/templates/_package.json +0 -0
  26. package/lib/generators/react-app/templates/index.js +22 -0
  27. package/lib/generators/react-app/templates/src/components/App.jsx +42 -0
  28. package/lib/generators/react-app/templates/src/components/Routes.jsx +43 -0
  29. package/lib/generators/{js → react-app}/templates/src/components/buttons/Button.jsx +4 -18
  30. package/lib/generators/react-app/templates/src/components/layouts/Main.jsx +27 -0
  31. package/lib/generators/react-app/templates/src/components/menus/Menu.jsx +62 -0
  32. package/lib/generators/{js → react-app}/templates/src/components/pages/Error.jsx +8 -12
  33. package/lib/generators/react-app/templates/src/components/pages/Home.jsx +32 -0
  34. package/lib/generators/{js → react-app}/templates/src/components/partials/PageMeta.jsx +11 -11
  35. package/lib/generators/{js → react-app}/templates/src/contexts/KeysContext.jsx +0 -0
  36. package/lib/generators/{js/templates/styles → react-app/templates/src/lib}/.gitkeep +0 -0
  37. package/lib/generators/{js → react-app}/templates/src/lib/PropTypes.js +0 -0
  38. package/lib/generators/{js → react-app}/templates/src/lib/utils.js +0 -0
  39. package/lib/generators/react-app/templates/src/polyfills/index.js +6 -0
  40. package/lib/generators/react-app/templates/src/polyfills/intl-en.js +2 -0
  41. package/lib/generators/react-app/templates/src/polyfills/intl-fr.js +2 -0
  42. package/lib/generators/react-app/templates/src/polyfills/should.js +14 -0
  43. package/lib/generators/react-app/templates/styles/.gitkeep +0 -0
  44. package/lib/generators/{js/templates/styles/buttons/button.scss → react-app/templates/styles/buttons/button.module.scss} +1 -0
  45. package/lib/generators/{js/templates/styles/layouts/main.scss → react-app/templates/styles/layouts/main.module.scss} +0 -0
  46. package/lib/generators/{js/templates/styles/menus/menu.scss → react-app/templates/styles/menus/menu.module.scss} +0 -0
  47. package/lib/generators/{js/templates/styles/pages/error.scss → react-app/templates/styles/pages/error.module.scss} +0 -0
  48. package/lib/generators/{js/templates/styles/pages/home.scss → react-app/templates/styles/pages/home.module.scss} +0 -0
  49. package/lib/generators/rollup/index.js +54 -0
  50. package/lib/generators/rollup/templates/config.js +47 -0
  51. package/lib/generators/scss/index.js +3 -16
  52. package/lib/generators/scss/templates/{main.scss → styles.scss} +0 -0
  53. package/lib/generators/server/index.js +81 -0
  54. package/lib/generators/server/templates/server.js +59 -0
  55. package/lib/generators/storybook/index.js +1 -7
  56. package/lib/generators/stylelint/index.js +13 -14
  57. package/lib/lib/utils.js +17 -0
  58. package/package.json +2 -2
  59. package/lib/generators/babel/templates/babel-preset-react.js +0 -7
  60. package/lib/generators/babel/templates/babel-preset.js +0 -57
  61. package/lib/generators/babel/templates/babelrc +0 -5
  62. package/lib/generators/babel/templates/utils/processScss.js +0 -10
  63. package/lib/generators/babel/templates/utils/transformRequireIgnore.js +0 -80
  64. package/lib/generators/html/templates/index.js +0 -9
  65. package/lib/generators/html/templates/root.js +0 -23
  66. package/lib/generators/html/templates/utils.js +0 -7
  67. package/lib/generators/js/templates/browserslistrc +0 -9
  68. package/lib/generators/js/templates/config.js +0 -33
  69. package/lib/generators/js/templates/index.js +0 -41
  70. package/lib/generators/js/templates/src/actions/LayoutActions.js +0 -12
  71. package/lib/generators/js/templates/src/actions/SiteActions.js +0 -22
  72. package/lib/generators/js/templates/src/components/App.jsx +0 -52
  73. package/lib/generators/js/templates/src/components/Root.jsx +0 -70
  74. package/lib/generators/js/templates/src/components/layouts/Main.jsx +0 -52
  75. package/lib/generators/js/templates/src/components/menus/Menu.jsx +0 -60
  76. package/lib/generators/js/templates/src/components/messages/Success.jsx +0 -36
  77. package/lib/generators/js/templates/src/components/pages/Home.jsx +0 -32
  78. package/lib/generators/js/templates/src/components/partials/Label.jsx +0 -32
  79. package/lib/generators/js/templates/src/reducers/LayoutReducer.js +0 -32
  80. package/lib/generators/js/templates/src/reducers/SiteReducer.js +0 -36
  81. package/lib/generators/js/templates/src/reducers/index.js +0 -7
  82. package/lib/generators/js/templates/src/vendor/polyfills/intl-en.js +0 -2
  83. package/lib/generators/js/templates/src/vendor/polyfills/intl-fr.js +0 -2
@@ -1,52 +0,0 @@
1
- import React, { useEffect } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { connect } from 'react-redux';
4
- import { Route, Switch, useHistory } from 'react-router';
5
- import { useUrlGenerator } from '@folklore/react-container';
6
-
7
- // import * as AppPropTypes from '../lib/PropTypes';
8
- import { resetRequest as resetRequestAction } from '../actions/SiteActions';
9
- import MainLayout from './layouts/Main';
10
- import HomePage from './pages/Home';
11
- import ErrorPage from './pages/Error';
12
-
13
- import '<%= getRelativeStylesPath('components/App.jsx', 'main.global.scss') %>';
14
-
15
- const propTypes = {
16
- resetRequest: PropTypes.func.isRequired,
17
- };
18
-
19
- const defaultProps = {};
20
-
21
- const App = ({ resetRequest }) => {
22
- const history = useHistory();
23
- const urlGenerator = useUrlGenerator();
24
-
25
- // Reset request on history change
26
- useEffect(() => {
27
- const unlisten = history.listen(() => resetRequest());
28
- return () => {
29
- unlisten();
30
- };
31
- }, [history]);
32
-
33
- return (
34
- <MainLayout>
35
- <Switch>
36
- <Route exact path={urlGenerator.route('home')} component={HomePage} />
37
- <Route path="*" component={ErrorPage} />
38
- </Switch>
39
- </MainLayout>
40
- );
41
- };
42
-
43
- App.propTypes = propTypes;
44
- App.defaultProps = defaultProps;
45
-
46
- const WithStateContainer = connect(
47
- null,
48
- dispatch => ({
49
- resetRequest: () => dispatch(resetRequestAction()),
50
- }),
51
- )(App);
52
- export default WithStateContainer;
@@ -1,70 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { UrlGeneratorProvider, createStore } from '@folklore/react-container';
4
- import { TrackingContainer } from '@folklore/tracking';
5
- import { IntlProvider } from 'react-intl';
6
- import { BrowserRouter } from 'react-router-dom';
7
- import { Provider as ReduxProvider } from 'react-redux';
8
-
9
- import reducers from '../reducers/index';
10
- import * as AppPropTypes from '../lib/PropTypes';
11
- import { KeysProvider } from '../contexts/KeysContext';
12
-
13
- import App from './App';
14
-
15
- const propTypes = {
16
- locale: PropTypes.string,
17
- messages: PropTypes.oneOfType([
18
- PropTypes.objectOf(PropTypes.objectOf(PropTypes.string)),
19
- PropTypes.objectOf(PropTypes.string),
20
- ]),
21
- routes: PropTypes.objectOf(PropTypes.string),
22
- statusCode: AppPropTypes.statusCode,
23
- googleApiKey: PropTypes.string,
24
- };
25
-
26
- const defaultProps = {
27
- locale: 'fr',
28
- messages: {},
29
- routes: {},
30
- statusCode: null,
31
- googleApiKey: null,
32
- };
33
-
34
- const Root = ({ locale, messages, routes, statusCode, googleApiKey }) => {
35
- const store = useMemo(
36
- () =>
37
- createStore(reducers, {
38
- site: {
39
- statusCode,
40
- },
41
- }),
42
- [statusCode],
43
- );
44
- const keys = useMemo(
45
- () => ({
46
- googleApiKey,
47
- }),
48
- [googleApiKey],
49
- );
50
- return (
51
- <ReduxProvider store={store}>
52
- <IntlProvider locale={locale} messages={messages[locale] || messages}>
53
- <BrowserRouter>
54
- <UrlGeneratorProvider routes={routes}>
55
- <KeysProvider keys={keys}>
56
- <TrackingContainer>
57
- <App />
58
- </TrackingContainer>
59
- </KeysProvider>
60
- </UrlGeneratorProvider>
61
- </BrowserRouter>
62
- </IntlProvider>
63
- </ReduxProvider>
64
- );
65
- };
66
-
67
- Root.propTypes = propTypes;
68
- Root.defaultProps = defaultProps;
69
-
70
- export default Root;
@@ -1,52 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { connect } from 'react-redux';
4
- import { useFonts } from '@folklore/fonts';
5
-
6
- import styles from '<%= getRelativeStylesPath('components/layouts/Main.jsx', 'layouts/main.scss') %>';
7
-
8
- const propTypes = {
9
- children: PropTypes.node.isRequired,
10
- isPrerender: PropTypes.bool,
11
- fonts: PropTypes.shape({
12
- google: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
13
- custom: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
14
- }),
15
- };
16
-
17
- const defaultProps = {
18
- isPrerender: false,
19
- fonts: {
20
- google: {
21
- families: ['Open Sans:400,600,700'],
22
- },
23
- custom: {
24
- families: ['Garage Gothic', 'Brandon Grotesque', 'Sina Nova:400,700,400i,700i'],
25
- },
26
- },
27
- };
28
-
29
- const MainLayout = ({ fonts, children, isPrerender }) => {
30
- const { loaded: fontsLoaded } = useFonts(fonts);
31
-
32
- const innerStyle = {
33
- opacity: fontsLoaded || isPrerender ? 1 : 0,
34
- };
35
-
36
- return (
37
- <div className={styles.container}>
38
- <div className={styles.inner} style={innerStyle}>
39
- <div className={styles.content}>{children}</div>
40
- </div>
41
- </div>
42
- );
43
- };
44
-
45
- MainLayout.propTypes = propTypes;
46
- MainLayout.defaultProps = defaultProps;
47
-
48
- const WithStateContainer = connect(({ site }) => ({
49
- isPrerender: site.isPrerender || false,
50
- }))(MainLayout);
51
-
52
- export default WithStateContainer;
@@ -1,60 +0,0 @@
1
- /* eslint-disable react/no-array-index-key */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
- import { Link } from 'react-router-dom';
6
-
7
- import * as AppPropTypes from '../../lib/PropTypes';
8
- import Label from '../partials/Label';
9
-
10
- import styles from '<%= getRelativeStylesPath('components/menus/Menu.jsx', 'menus/menu.scss') %>';
11
-
12
- const propTypes = {
13
- items: AppPropTypes.menuItems,
14
- className: PropTypes.string,
15
- };
16
-
17
- const defaultProps = {
18
- items: [],
19
- className: null,
20
- };
21
-
22
- const Menu = ({ items, className }) => (
23
- <nav
24
- className={classNames([
25
- styles.container,
26
- {
27
- [className]: className !== null,
28
- },
29
- ])}
30
- >
31
- <ul className={styles.items}>
32
- {items.map(({ label, url, active = false, external = false }, index) => (
33
- <li
34
- className={classNames([
35
- styles.item,
36
- {
37
- [styles.active]: active,
38
- },
39
- ])}
40
- key={`item-${index}`}
41
- >
42
- {external ? (
43
- <a href={url} className={styles.link}>
44
- <Label>{label}</Label>
45
- </a>
46
- ) : (
47
- <Link to={url} className={styles.link}>
48
- <Label>{label}</Label>
49
- </Link>
50
- )}
51
- </li>
52
- ))}
53
- </ul>
54
- </nav>
55
- );
56
-
57
- Menu.propTypes = propTypes;
58
- Menu.defaultProps = defaultProps;
59
-
60
- export default Menu;
@@ -1,36 +0,0 @@
1
- /* eslint-disable react/jsx-props-no-spreading */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
-
6
- import * as AppPropTypes from '../../lib/PropTypes';
7
- import Label from '../partials/Label';
8
-
9
- import styles from '<%= getRelativeStylesPath('components/messages/Success.jsx', 'messages/success.scss') %>';
10
-
11
- const propTypes = {
12
- children: AppPropTypes.text.isRequired,
13
- className: PropTypes.string,
14
- };
15
-
16
- const defaultProps = {
17
- className: null,
18
- };
19
-
20
- const SuccessMessage = ({ children, className }) => (
21
- <div
22
- className={classNames([
23
- styles.container,
24
- {
25
- [className]: className !== null,
26
- },
27
- ])}
28
- >
29
- <Label>{children}</Label>
30
- </div>
31
- );
32
-
33
- SuccessMessage.propTypes = propTypes;
34
- SuccessMessage.defaultProps = defaultProps;
35
-
36
- export default SuccessMessage;
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- // import PropTypes from 'prop-types';
3
- import { defineMessages, injectIntl } from 'react-intl';
4
-
5
- // import * as AppPropTypes from '../../lib/PropTypes';
6
- import PageMeta from '../partials/PageMeta';
7
-
8
- import styles from '<%= getRelativeStylesPath('components/pages/Home.jsx', 'pages/home.scss') %>';
9
-
10
- const messages = defineMessages({
11
- metaTitle: {
12
- id: 'meta.title',
13
- defaultMessage: 'Title',
14
- },
15
- });
16
-
17
- const propTypes = {
18
- // intl: AppPropTypes.intl.isRequired,
19
- };
20
-
21
- const HomePage = () => (
22
- <div className={styles.container}>
23
- <PageMeta title={messages.metaTitle} />
24
- <div className={styles.logo} />
25
- </div>
26
- );
27
-
28
- HomePage.propTypes = propTypes;
29
-
30
- const WithIntlContainer = injectIntl(HomePage);
31
-
32
- export default WithIntlContainer;
@@ -1,32 +0,0 @@
1
- /* eslint-disable react/jsx-props-no-spreading */
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import { FormattedMessage, FormattedHTMLMessage } from 'react-intl';
5
-
6
- import { label as labelPropTypes } from '../../lib/PropTypes';
7
- import { isMessage } from '../../lib/utils';
8
-
9
- const propTypes = {
10
- children: labelPropTypes.isRequired,
11
- isHtml: PropTypes.bool,
12
- values: PropTypes.object, // eslint-disable-line react/forbid-prop-types
13
- };
14
-
15
- const defaultProps = {
16
- isHtml: false,
17
- values: {},
18
- };
19
-
20
- const Label = ({ children, isHtml, values }) => {
21
- const Message = isHtml ? FormattedHTMLMessage : FormattedMessage;
22
- return isMessage(children) ? (
23
- <Message values={values} {...children} />
24
- ) : (
25
- children
26
- )
27
- };
28
-
29
- Label.propTypes = propTypes;
30
- Label.defaultProps = defaultProps;
31
-
32
- export default Label;
@@ -1,32 +0,0 @@
1
- import { SET_SIZE } from '../actions/LayoutActions';
2
-
3
- const initialState = {
4
- size: {
5
- width: window.innerWidth || 0,
6
- height: window.innerHeight || 0,
7
- },
8
- };
9
-
10
- const LayoutReducer = (previousState, action) => {
11
- let state = previousState || initialState;
12
- if (typeof state.hydrated === 'undefined' || !state.hydrated) {
13
- state = {
14
- ...initialState,
15
- ...previousState,
16
- hydrated: true,
17
- };
18
- }
19
- switch (action.type) {
20
- case SET_SIZE:
21
- return {
22
- ...state,
23
- size: {
24
- ...action.payload,
25
- },
26
- };
27
- default:
28
- return state;
29
- }
30
- };
31
-
32
- export default LayoutReducer;
@@ -1,36 +0,0 @@
1
- import { SET_ERRORS, RESET_REQUEST } from '../actions/SiteActions';
2
-
3
- const initialState = {
4
- errors: null,
5
- statusCode: null,
6
- messages: null,
7
- };
8
-
9
- const SiteReducer = (previousState, action) => {
10
- let state = previousState || initialState;
11
- if (typeof state.hydrated === 'undefined' || !state.hydrated) {
12
- state = {
13
- ...initialState,
14
- ...previousState,
15
- hydrated: true,
16
- };
17
- }
18
- switch (action.type) {
19
- case SET_ERRORS:
20
- return {
21
- ...state,
22
- errors: action.payload,
23
- };
24
- case RESET_REQUEST:
25
- return {
26
- ...state,
27
- errors: null,
28
- statusCode: null,
29
- messages: null,
30
- };
31
- default:
32
- return state;
33
- }
34
- };
35
-
36
- export default SiteReducer;
@@ -1,7 +0,0 @@
1
- import SiteReducer from './SiteReducer';
2
- import LayoutReducer from './LayoutReducer';
3
-
4
- export default {
5
- site: SiteReducer,
6
- layout: LayoutReducer,
7
- };
@@ -1,2 +0,0 @@
1
- import 'intl';
2
- import 'intl/locale-data/jsonp/en';
@@ -1,2 +0,0 @@
1
- import 'intl';
2
- import 'intl/locale-data/jsonp/fr';