generator-folklore 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,47 @@
1
+ import path from 'path';
2
+ import babel from '@rollup/plugin-babel';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import json from '@rollup/plugin-json';
5
+ import resolve from '@rollup/plugin-node-resolve';
6
+ import replace from '@rollup/plugin-replace';
7
+
8
+ export const plugins = [
9
+ json(),
10
+ resolve({
11
+ extensions: ['.mjs', '.js', '.jsx', '.json', '.node'],
12
+ jail: path.join(process.cwd(), 'src'),
13
+ preferBuiltins: true,
14
+ }),
15
+ commonjs(),
16
+ babel({
17
+ extensions: ['.mjs', '.js', '.jsx', '.json', '.node'],
18
+ exclude: 'node_modules/**',
19
+ rootMode: 'upward',
20
+ babelHelpers: 'runtime',
21
+ }),
22
+ replace({
23
+ 'process.env.NODE_ENV': JSON.stringify('production'),
24
+ __buildDate__: () => JSON.stringify(new Date()),
25
+ __buildVersion: 15,
26
+ }),
27
+ ];
28
+
29
+ export default [
30
+ {
31
+ input: 'src/index.js',
32
+ output: {
33
+ file: 'index.js',
34
+ format: 'cjs',
35
+ },
36
+ plugins,
37
+ },
38
+ // {
39
+ // input: 'src/cli.js',
40
+ // output: {
41
+ // file: 'cli.js',
42
+ // format: 'cjs',
43
+ // banner: '#!/usr/bin/env node',
44
+ // },
45
+ // plugins,
46
+ // },
47
+ ];
@@ -19,11 +19,6 @@ module.exports = class ScssGenerator extends _generator.default {
19
19
  type: String,
20
20
  defaults: 'src/scss'
21
21
  });
22
- this.option('react', {
23
- type: Boolean,
24
- required: false,
25
- defaults: false
26
- });
27
22
 
28
23
  this.stylesPath = destPath => this.destinationPath(_path.default.join(this.options.path, destPath || ''));
29
24
  }
@@ -61,19 +56,11 @@ module.exports = class ScssGenerator extends _generator.default {
61
56
  };
62
57
  }
63
58
 
64
- configuring() {
65
- this.composeWith('folklore:stylelint', {
66
- quiet: true,
67
- 'camel-case': this.options.react
68
- });
69
- }
70
-
71
59
  get writing() {
72
60
  return {
73
- main() {
74
- const reactSuffix = this.options.react ? '.global' : '';
75
- const srcPath = this.templatePath('main.scss');
76
- const destPath = this.stylesPath(`main${reactSuffix}.scss`);
61
+ styles() {
62
+ const srcPath = this.templatePath('styles.scss');
63
+ const destPath = this.stylesPath('styles.scss');
77
64
  this.fs.copy(srcPath, destPath);
78
65
  },
79
66
 
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
5
+ var _lodash = _interopRequireDefault(require("lodash"));
6
+
7
+ var _path = _interopRequireDefault(require("path"));
8
+
9
+ var _generator = _interopRequireDefault(require("../../lib/generator"));
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ module.exports = class ServerGenerator extends _generator.default {
14
+ // The name `constructor` is important here
15
+ constructor(...args) {
16
+ super(...args);
17
+ this.option('path', {
18
+ type: String,
19
+ defaults: 'src'
20
+ });
21
+ this.option('filename', {
22
+ type: String,
23
+ defaults: 'server.js'
24
+ });
25
+ this.option('socket-io', {
26
+ type: String,
27
+ defaults: false
28
+ });
29
+ }
30
+
31
+ get prompting() {
32
+ return {
33
+ welcome() {
34
+ if (this.options.quiet) {
35
+ return;
36
+ }
37
+
38
+ console.log(_chalk.default.yellow('\n----------------------'));
39
+ console.log('Server Generator');
40
+ console.log(_chalk.default.yellow('----------------------\n'));
41
+ }
42
+
43
+ };
44
+ }
45
+
46
+ get writing() {
47
+ return {
48
+ index() {
49
+ const {
50
+ filename,
51
+ path: serverPath,
52
+ 'socket-io': socketIo
53
+ } = this.options;
54
+ this.fs.copyTpl(this.templatePath('server.js'), this.destinationPath(_path.default.join(serverPath, filename)), {
55
+ socketIo
56
+ });
57
+ },
58
+
59
+ dependencies() {
60
+ const {
61
+ 'socket-io': socketIo
62
+ } = this.options;
63
+ this.addDependencies(['commander', 'debug', 'ejs', 'express']);
64
+
65
+ if (socketIo) {
66
+ this.addDependencies(['socket.io']);
67
+ }
68
+ }
69
+
70
+ };
71
+ }
72
+
73
+ async install() {
74
+ if (this.options['skip-install']) {
75
+ return;
76
+ }
77
+
78
+ await this.spawnCommand('npm', ['install']);
79
+ }
80
+
81
+ };
@@ -0,0 +1,59 @@
1
+ import { program } from 'commander';
2
+ import createDebug from 'debug';
3
+ import { renderFile } from 'ejs';
4
+ import express from 'express';
5
+ import { createServer } from 'http';
6
+ import path from 'path';<% if (socketIo) { %>
7
+ import { Server } from 'socket.io';<% } %>
8
+
9
+ const debug = createDebug('server');
10
+
11
+ program
12
+ .description('Run server')
13
+ .option('-p, --path <path>', 'Path to static', './dist')
14
+ .option('--port <port>', 'Server port', process.env.PORT || 5000);
15
+ program.parse();
16
+
17
+ const { port, path: staticPath } = program.opts();
18
+
19
+ const webPath = path.join(process.cwd(), staticPath);
20
+
21
+ // Express server
22
+ const app = express();
23
+ const httpServer = createServer(app);
24
+ app.set('view engine', 'html');
25
+ app.set('views', webPath);
26
+ app.engine('html', renderFile);
27
+ app.use(express.json());
28
+ app.use(
29
+ express.urlencoded({
30
+ extended: false,
31
+ }),
32
+ );
33
+ app.use(express.static(webPath));
34
+
35
+ app.get('/', async (req, res) =>
36
+ res.render('index.html.ejs', {
37
+ fromServer: true,
38
+ }),
39
+ );
40
+
41
+ app.get('*', async (req, res) => {
42
+ return res.render('index.html.ejs', {
43
+ fromServer: true,
44
+ });
45
+ });<% if (socketIo) { %>
46
+
47
+ // Socket io
48
+ const io = new Server(httpServer, {
49
+ cors: {
50
+ origin: '*',
51
+ methods: ['GET', 'POST'],
52
+ },
53
+ });
54
+ io.on('connection', (socket) => {});<% } %>
55
+
56
+ // Start server
57
+ httpServer.listen(port, () => {
58
+ debug('Listening on port %i', port);
59
+ });
@@ -60,19 +60,13 @@ module.exports = class StorybookGenerator extends _generator.default {
60
60
  },
61
61
 
62
62
  packageJSON() {
63
- const destPath = this.destinationPath('package.json');
64
-
65
- if (!this.fs.exists(destPath)) {
66
- return;
67
- }
68
-
69
63
  const packageJSON = this.fs.exists(destPath) ? this.fs.readJSON(destPath) : {};
70
64
  packageJSON['storybook-deployer'] = {
71
65
  gitUsername: 'Folklore',
72
66
  gitEmail: 'info@folklore.email',
73
67
  commitMessage: 'Deploy Storybook to GitHub Pages'
74
68
  };
75
- this.fs.writeJSON(destPath, packageJSON);
69
+ this.packageJson.merge(packageJSON);
76
70
  }
77
71
 
78
72
  };
@@ -16,29 +16,28 @@ module.exports = class StylelintGenerator extends _generator.default {
16
16
  });
17
17
  }
18
18
 
19
- get prompting() {
20
- return {
21
- welcome() {
22
- if (this.options.quiet) {
23
- return;
24
- }
25
-
26
- console.log(_chalk.default.yellow('\n----------------------'));
27
- console.log('Stylelint Generator');
28
- console.log(_chalk.default.yellow('----------------------\n'));
29
- }
19
+ prompting() {
20
+ if (this.options.quiet) {
21
+ return;
22
+ }
30
23
 
31
- };
24
+ console.log(_chalk.default.yellow('\n----------------------'));
25
+ console.log('Stylelint Generator');
26
+ console.log(_chalk.default.yellow('----------------------\n'));
32
27
  }
33
28
 
34
29
  get writing() {
35
30
  return {
36
- eslintrc() {
31
+ stylelintrc() {
37
32
  const srcPath = this.templatePath('stylelintrc');
38
33
  const destPath = this.destinationPath('.stylelintrc');
39
34
  this.fs.copyTpl(srcPath, destPath, {
40
35
  camelCase: this.options['camel-case']
41
36
  });
37
+ },
38
+
39
+ dependencies() {
40
+ this.addDevDependencies(['stylelint', 'stylelint-config-standard-scss', 'stylelint-config-idiomatic-order', 'stylelint-config-prettier']);
42
41
  }
43
42
 
44
43
  };
@@ -49,7 +48,7 @@ module.exports = class StylelintGenerator extends _generator.default {
49
48
  return;
50
49
  }
51
50
 
52
- await this.addDevDependencies(['stylelint', 'stylelint-config-standard-scss', 'stylelint-config-idiomatic-order', 'stylelint-config-prettier']);
51
+ await this.spawnCommand('npm', ['install']);
53
52
  }
54
53
 
55
54
  };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ensureLeadingDotSlash = ensureLeadingDotSlash;
7
+
8
+ var _lodash = require("lodash");
9
+
10
+ var _path = _interopRequireDefault(require("path"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function ensureLeadingDotSlash(filePath) {
15
+ return (0, _lodash.isString)(filePath) && !_path.default.isAbsolute(filePath) && filePath.match(/^\./) === null ? `./${filePath}` : filePath;
16
+ ;
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-folklore",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Yeoman generator for projects at Folklore",
5
5
  "keywords": [
6
6
  "yeoman-generator"
@@ -39,5 +39,5 @@
39
39
  "yeoman-generator": "^5.6.1",
40
40
  "yeoman-remote": "^1.0.1"
41
41
  },
42
- "gitHead": "cf8f69f622f7ce5476723a2dea46157be2fe5833"
42
+ "gitHead": "19f9dc4807a6f4992e3c0f56b2bb448414d6876b"
43
43
  }
@@ -1,7 +0,0 @@
1
- /* eslint-disable global-require */
2
- /* eslint-disable import/no-extraneous-dependencies, import/no-dynamic-require */
3
- module.exports = () => ({
4
- presets: [
5
- require('babel-preset-react-app'),
6
- ],
7
- });
@@ -1,57 +0,0 @@
1
- <% if(hasCompile) { %>const path = require('path');
2
-
3
- <% } %>const env = process.env.BABEL_ENV || process.env.NODE_ENV;
4
- const isEnvDevelopment = env === 'development';
5
- const isEnvProduction = env === 'production';
6
- const isEnvTest = env === 'test';<% if(hasCompile) { %>
7
- const isCommonJS = env === 'cjs';
8
- const isCompiling = env === 'es' || env === 'cjs';<% } %>
9
-
10
- const presets = [
11
- [require.resolve('@babel/preset-env'), isEnvTest ? {
12
- targets: {
13
- node: 'current',
14
- },
15
- } : {
16
- modules: <% if(hasCompile) { %>isCommonJS ? 'commonjs' : false<% } else { %>false<% } %>,
17
- targets: {
18
- ie: 9,
19
- },
20
- }],
21
- require.resolve('@babel/preset-react'),
22
- ];
23
-
24
- const plugins = [
25
- require.resolve('@babel/plugin-syntax-dynamic-import'),
26
- require.resolve('@babel/plugin-proposal-object-rest-spread'),<% if(hasTransformRuntime) { %>
27
- [require.resolve('@babel/plugin-transform-runtime'), {
28
- helpers: true,
29
- polyfill: false,
30
- regenerator: true,
31
- }],<% } %>
32
- ];
33
-
34
- if (isEnvTest) {
35
- plugins.push(require.resolve('babel-plugin-dynamic-import-node'));
36
- }
37
- <% if(hasCompile) { %>
38
- if (isCompiling) {
39
- plugins.push([require.resolve('babel-plugin-css-modules-transform'), {
40
- preprocessCss: path.join(__dirname, './utils/processScss.js'),
41
- extensions: ['.css', '.scss'],
42
- generateScopedName: path.join(__dirname, './utils/getLocalIdent.js'),
43
- }]);
44
- plugins.push([path.join(__dirname, './utils/transformRequireIgnore'), {
45
- extensions: ['.global.scss'],
46
- }]);
47
- <% if(hasReactIntl) { %> if (isCompiling && !isCommonJS) {
48
- plugins.push([require.resolve('babel-plugin-react-intl'), {
49
- messagesDir: './intl/messages/',
50
- }]);
51
- }<% } %>
52
- }
53
- <% } %>
54
- module.exports = () => ({
55
- presets,
56
- plugins,
57
- });
@@ -1,5 +0,0 @@
1
- {
2
- "presets": [
3
- "<%= presetPath %>"
4
- ]
5
- }
@@ -1,10 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- const sass = require('node-sass');
3
-
4
- module.exports = (data, filename) => {
5
- const result = sass.renderSync({
6
- data,
7
- file: filename,
8
- }).css;
9
- return result.toString('utf8');
10
- };
@@ -1,80 +0,0 @@
1
- /* eslint-disable */
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
-
8
- exports.default = function () {
9
- function extFix(ext) {
10
- return ext.charAt(0) === '.' ? ext : '.' + ext;
11
- }
12
-
13
- return {
14
- visitor: {
15
- CallExpression: {
16
- enter: function enter(nodePath, _ref) {
17
- var opts = _ref.opts;
18
-
19
- var extensionsInput = [].concat(opts.extensions || []);
20
- if (extensionsInput.length === 0) {
21
- return;
22
- }
23
- var extensions = extensionsInput.map(extFix);
24
- var callee = nodePath.get('callee');
25
-
26
- if (callee.isIdentifier() && callee.equals('name', 'require')) {
27
- var arg = nodePath.get('arguments')[0];
28
- if (arg && arg.isStringLiteral() && extensions.indexOf(_path2.default.extname(arg.node.value)) > -1) {
29
- if (nodePath.parentPath.isVariableDeclarator()) {
30
- throw new Error(arg.node.value + ' should not be assign to variable.');
31
- } else {
32
- nodePath.remove();
33
- }
34
- }
35
- }
36
- }
37
- },
38
-
39
- ImportDeclaration: {
40
- enter: function enter(nodePath, _ref2) {
41
- var opts = _ref2.opts;
42
-
43
- var extensionsInput = [].concat(opts.extensions || []);
44
-
45
- if (extensionsInput.length === 0) {
46
- return;
47
- }
48
- var extensions = extensionsInput.map(extFix);
49
- const regExp = new RegExp('('+extensions.join('|')+')$', 'i');
50
-
51
- if (nodePath.node.source.value.match(regExp)) {
52
- var specifiers = nodePath.get('specifiers');
53
-
54
- if (specifiers.length) {
55
- var specifier = specifiers[specifiers.length - 1];
56
-
57
- if (specifier.isImportDefaultSpecifier()) {
58
- throw new Error(nodePath.node.source.value + ' should not be imported using default imports.');
59
- }
60
- if (specifier.isImportSpecifier()) {
61
- throw new Error(nodePath.node.source.value + ' should not be imported using named imports.');
62
- }
63
- if (specifier.isImportNamespaceSpecifier()) {
64
- throw new Error(nodePath.node.source.value + ' should not be imported using namespace imports.');
65
- }
66
- }
67
-
68
- nodePath.remove();
69
- }
70
- }
71
- }
72
- }
73
- };
74
- };
75
-
76
- var _path = require('path');
77
-
78
- var _path2 = _interopRequireDefault(_path);
79
-
80
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
-
4
- import Root from './components/Root';
5
- import rootProps from './data/root';
6
-
7
- const rootEl = document.getElementById('root');
8
- const root = React.createElement(Root, rootProps);
9
- ReactDOM.render(root, rootEl);
@@ -1,23 +0,0 @@
1
- export default {
2
- locale: 'fr',
3
- messages: {
4
- 'meta.title': 'Titre',
5
- 'meta.title_401': 'Error 401',
6
- 'meta.title_403': 'Error 403',
7
- 'meta.title_404': 'Error 404',
8
- 'meta.title_500': 'Error 500',
9
-
10
- 'errors.title_401': 'Error 401',
11
- 'errors.description_401': 'You are not authorized to access this page.',
12
- 'errors.title_403': 'Error 403',
13
- 'errors.description_403': 'Access to this page is forbidden',
14
- 'errors.title_404': 'Error 404',
15
- 'errors.description_404': 'This page doesn’t exists',
16
- 'errors.title_500': 'Error 500',
17
- 'errors.description_500': 'There was an error',
18
- 'errors.goto_home': 'Go to home',
19
- },
20
- routes: {
21
- home: '/',
22
- },
23
- };
@@ -1,7 +0,0 @@
1
- // eslint-disable-next-line import/prefer-default-export
2
- export const getLocaleFromLocation = (locales = ['fr', 'en'], currentLocation = window.location) => {
3
- const { pathname = '/' } = currentLocation;
4
- const localeRegEx = new RegExp(`^/(${locales.join('|')})(/.*)?$`, 'i');
5
- const matches = pathname.match(localeRegEx);
6
- return matches !== null ? matches[1] : locales[0];
7
- };
@@ -1,9 +0,0 @@
1
- [production staging]
2
- last 4 versions
3
- > 1%
4
- ie >= 9
5
-
6
- [development]
7
- last 4 versions
8
- > 1%
9
- ie >= 9
@@ -1,33 +0,0 @@
1
- import get from 'lodash/get';
2
- import set from 'lodash/set';
3
-
4
- class Config {
5
- constructor(config) {
6
- this.config = config || {};
7
- }
8
-
9
- get(str) {
10
- return get(this.config, str);
11
- }
12
-
13
- set(str, val) {
14
- return set(this.config, str, val);
15
- }
16
- }
17
-
18
- const config = new Config();
19
-
20
- // eslint-disable-next-line no-unused-vars
21
- const configFunc = (key, value) => {
22
- if (typeof value !== 'undefined') {
23
- return config.set(key, value);
24
- } else if (typeof key === 'undefined') {
25
- return config.get();
26
- }
27
- return config.get(key);
28
- };
29
-
30
- const root = global || window || null;
31
- if (root !== null) {
32
- root.app_config = configFunc;
33
- }
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import domready from 'domready';<% if (rootPropsImport !== null) { %>
4
- import defaultRootProps from '<%= rootPropsImport %>';<% } %>
5
-
6
- import Root from './components/Root';
7
-
8
- <%
9
- if (rootPropsImport !== null) {
10
- %>const getRootProps = () => defaultRootProps;<%
11
- } else {
12
- %>const getRootProps = () => {
13
- const propsEl = document.getElementById('root-props');
14
- return propsEl !== null ? JSON.parse(propsEl.innerHTML) || {} : {};
15
- };<%
16
- }
17
- %>
18
-
19
- const renderRoot = (props) => {
20
- const rootEl = document.getElementById('root');
21
- const root = React.createElement(Root, props);
22
- ReactDOM.render(root, rootEl);
23
- };
24
-
25
- const boot = () => {
26
- const rootProps = getRootProps();
27
-
28
- if (typeof window.Intl === 'undefined') {
29
- const { locale = 'fr' } = rootProps;
30
- import(`./vendor/polyfills/intl-${locale}`).then(() => renderRoot(rootProps));
31
- } else {
32
- renderRoot(rootProps);
33
- }
34
- };
35
-
36
- const ready = (document.readyState || 'loading') !== 'loading';
37
- if (ready) {
38
- boot();
39
- } else {
40
- domready(boot);
41
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Constants
3
- */
4
- export const SET_SIZE = 'layout@SET_SIZE';
5
-
6
- /**
7
- * Actions creator
8
- */
9
- export const setSize = payload => ({
10
- type: SET_SIZE,
11
- payload,
12
- });
@@ -1,22 +0,0 @@
1
- /**
2
- * Constants
3
- */
4
- export const SET_ERRORS = 'site@SET_ERRORS';
5
- export const RESET_REQUEST = 'site@RESET_REQUEST';
6
-
7
- /**
8
- * Actions creator
9
- */
10
- export const setErrors = payload => ({
11
- type: SET_ERRORS,
12
- payload,
13
- });
14
-
15
- export const resetErrors = () => ({
16
- type: SET_ERRORS,
17
- payload: null,
18
- });
19
-
20
- export const resetRequest = () => ({
21
- type: RESET_REQUEST,
22
- });