generator-folklore 3.0.3 → 3.0.6

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 (205) 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/intl/index.js +93 -0
  17. package/lib/generators/laravel/index.js +5 -5
  18. package/lib/generators/laravel-mediatheque/index.js +133 -0
  19. package/lib/generators/laravel-mediatheque/templates/app/Models/Media.php +9 -0
  20. package/lib/generators/laravel-mediatheque/templates/app/Models/MediaFile.php +9 -0
  21. package/lib/generators/laravel-panneau/index.js +49 -28
  22. package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +19 -0
  23. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +10 -0
  24. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Page.php +10 -0
  25. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Pages/Home.php +9 -0
  26. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +37 -0
  27. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +8 -0
  28. package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +47 -0
  29. package/lib/generators/laravel-panneau/templates/app/Http/Resources/PagesCollection.php +10 -0
  30. package/lib/generators/laravel-panneau/templates/app/Models/Block.php +3 -13
  31. package/lib/generators/laravel-panneau/templates/app/Models/Page.php +3 -60
  32. package/lib/generators/laravel-panneau/templates/app/Panneau/Composers/AppComposer.php +50 -0
  33. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Block.php +22 -0
  34. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Blocks.php +87 -0
  35. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Page.php +51 -0
  36. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlug.php +34 -0
  37. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlugLocalized.php +18 -0
  38. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/AccountController.php +41 -0
  39. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/Controller.php +19 -0
  40. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/HomeController.php +16 -0
  41. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/PagesController.php +24 -0
  42. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php +27 -0
  43. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UsersController.php +32 -0
  44. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/AccountUpdateRequest.php +29 -0
  45. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/UploadRequest.php +29 -0
  46. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlockResource.php +39 -0
  47. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +8 -0
  48. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php +56 -0
  49. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PagesCollection.php +10 -0
  50. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UserResource.php +24 -0
  51. package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +48 -0
  52. package/lib/generators/laravel-panneau/templates/app/Panneau/Policies/PanneauPolicy.php +32 -0
  53. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php +110 -0
  54. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +27 -0
  55. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +42 -0
  56. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +28 -0
  57. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +92 -0
  58. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Users.php +57 -0
  59. package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +42 -0
  60. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +14 -0
  61. package/lib/generators/laravel-panneau/templates/app/Resources/Page.php +10 -0
  62. package/lib/generators/laravel-panneau/templates/app/Resources/Pages/HomePage.php +10 -0
  63. package/lib/generators/laravel-panneau/templates/app.blade.php +8 -0
  64. package/lib/generators/laravel-panneau/templates/index.js +32 -0
  65. package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +62 -0
  66. package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +62 -0
  67. package/lib/generators/laravel-panneau/templates/layout.blade.php +17 -48
  68. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/Panneau.jsx +68 -0
  69. package/lib/generators/{js/templates/src/lib/.gitkeep → laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx} +0 -0
  70. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlugLocalized.jsx +43 -0
  71. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/index.js +2 -0
  72. package/lib/generators/laravel-panneau/templates/resources/assets/styles/panneau.scss +2 -0
  73. package/lib/generators/laravel-panneau/templates/routes.php +30 -0
  74. package/lib/generators/laravel-project/index.js +504 -0
  75. package/lib/generators/laravel-project/templates/env +41 -0
  76. package/lib/generators/laravel-project/templates/laravel/app/Composers/AppComposer.php +48 -0
  77. package/lib/generators/laravel-project/templates/laravel/app/Composers/IntlComposer.php +10 -0
  78. package/lib/generators/laravel-project/templates/laravel/app/Composers/MetaComposer.php +48 -0
  79. package/lib/generators/laravel-project/templates/laravel/app/Composers/RoutesComposer.php +19 -0
  80. package/lib/generators/laravel-project/templates/laravel/app/Contracts/Resources/User.php +10 -0
  81. package/lib/generators/laravel-project/templates/laravel/app/Http/Controllers/HomeController.php +18 -0
  82. package/lib/generators/laravel-project/templates/laravel/app/Http/Middleware/TrustProxies.php +28 -0
  83. package/lib/generators/laravel-project/templates/laravel/app/Http/Resources/UserResource.php +21 -0
  84. package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +50 -0
  85. package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +45 -0
  86. package/lib/generators/laravel-project/templates/laravel/app/Providers/RouteServiceProvider.php +64 -0
  87. package/lib/generators/laravel-project/templates/laravel/app/Providers/ViewServiceProvider.php +33 -0
  88. package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +36 -0
  89. package/lib/generators/laravel-project/templates/laravel/app/Resources/User.php +11 -0
  90. package/lib/generators/laravel-project/templates/laravel/config/app.php +216 -0
  91. package/lib/generators/laravel-project/templates/laravel/config/auth.php +116 -0
  92. package/lib/generators/laravel-project/templates/laravel/config/services.php +39 -0
  93. package/lib/generators/laravel-project/templates/laravel/lang/en/content.php +5 -0
  94. package/lib/generators/laravel-project/templates/laravel/lang/en/errors.php +17 -0
  95. package/lib/generators/laravel-project/templates/laravel/lang/en/meta.php +11 -0
  96. package/lib/generators/laravel-project/templates/laravel/lang/en/routes.php +4 -0
  97. package/lib/generators/laravel-project/templates/laravel/lang/fr/auth.php +19 -0
  98. package/lib/generators/laravel-project/templates/laravel/lang/fr/content.php +5 -0
  99. package/lib/generators/laravel-project/templates/laravel/lang/fr/errors.php +17 -0
  100. package/lib/generators/laravel-project/templates/laravel/lang/fr/meta.php +11 -0
  101. package/lib/generators/laravel-project/templates/laravel/lang/fr/pagination.php +19 -0
  102. package/lib/generators/laravel-project/templates/laravel/lang/fr/passwords.php +22 -0
  103. package/lib/generators/laravel-project/templates/laravel/lang/fr/routes.php +12 -0
  104. package/lib/generators/laravel-project/templates/laravel/lang/fr/validation.php +146 -0
  105. package/lib/generators/{js/templates/styles → laravel-project/templates/laravel/resources/assets/fonts}/.gitkeep +0 -0
  106. package/lib/generators/{laravel-panneau/templates/app/Schemas/Fields → laravel-project/templates/laravel/resources/assets/img}/.gitkeep +0 -0
  107. package/lib/generators/laravel-project/templates/laravel/resources/assets/img/folklore.png +0 -0
  108. package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/body.blade.php +3 -0
  109. package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/gpt.blade.php +16 -0
  110. package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/head.blade.php +1 -0
  111. package/lib/generators/laravel-project/templates/laravel/resources/views/app.blade.php +8 -0
  112. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/401.blade.php +8 -0
  113. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/403.blade.php +8 -0
  114. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/404.blade.php +8 -0
  115. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/500.blade.php +8 -0
  116. package/lib/generators/laravel-project/templates/laravel/resources/views/layout.blade.php +33 -0
  117. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/all.blade.php +4 -0
  118. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/base.blade.php +11 -0
  119. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/facebook.blade.php +4 -0
  120. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/opengraph.blade.php +9 -0
  121. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/twitter.blade.php +5 -0
  122. package/lib/generators/laravel-project/templates/laravel/routes/web.php +12 -0
  123. package/lib/generators/lerna-package/index.js +1 -3
  124. package/lib/generators/lerna-repository/index.js +1 -3
  125. package/lib/generators/node-project/index.js +164 -0
  126. package/lib/generators/node-project/templates/index.js +0 -0
  127. package/lib/generators/npm-package/index.js +3 -5
  128. package/lib/generators/prettier/index.js +19 -6
  129. package/lib/generators/prettier/templates/prettierrc.json +3 -1
  130. package/lib/generators/{js → react-app}/index.js +22 -52
  131. package/lib/generators/{js → react-app}/templates/_package.json +0 -0
  132. package/lib/generators/react-app/templates/index.js +23 -0
  133. package/lib/generators/react-app/templates/src/components/App.jsx +46 -0
  134. package/lib/generators/react-app/templates/src/components/Container.jsx +40 -0
  135. package/lib/generators/{js → react-app}/templates/src/components/buttons/Button.jsx +4 -18
  136. package/lib/generators/react-app/templates/src/components/layouts/Main.jsx +27 -0
  137. package/lib/generators/react-app/templates/src/components/menus/Menu.jsx +62 -0
  138. package/lib/generators/{js → react-app}/templates/src/components/pages/Error.jsx +10 -14
  139. package/lib/generators/react-app/templates/src/components/pages/Home.jsx +32 -0
  140. package/lib/generators/{js → react-app}/templates/src/components/partials/PageMeta.jsx +11 -11
  141. package/lib/generators/{js → react-app}/templates/src/contexts/KeysContext.jsx +0 -0
  142. package/lib/generators/react-app/templates/src/lib/.gitkeep +0 -0
  143. package/lib/generators/{js → react-app}/templates/src/lib/PropTypes.js +0 -0
  144. package/lib/generators/{js → react-app}/templates/src/lib/utils.js +0 -0
  145. package/lib/generators/react-app/templates/src/polyfills/index.js +6 -0
  146. package/lib/generators/react-app/templates/src/polyfills/intl-en.js +2 -0
  147. package/lib/generators/react-app/templates/src/polyfills/intl-fr.js +2 -0
  148. package/lib/generators/react-app/templates/src/polyfills/should.js +14 -0
  149. package/lib/generators/react-app/templates/styles/.gitkeep +0 -0
  150. package/lib/generators/{js/templates/styles/buttons/button.scss → react-app/templates/styles/buttons/button.module.scss} +1 -0
  151. package/lib/generators/{js/templates/styles/layouts/main.scss → react-app/templates/styles/layouts/main.module.scss} +0 -0
  152. package/lib/generators/{js/templates/styles/menus/menu.scss → react-app/templates/styles/menus/menu.module.scss} +0 -0
  153. package/lib/generators/{js/templates/styles/pages/error.scss → react-app/templates/styles/pages/error.module.scss} +0 -0
  154. package/lib/generators/{js/templates/styles/pages/home.scss → react-app/templates/styles/pages/home.module.scss} +0 -0
  155. package/lib/generators/rollup/index.js +54 -0
  156. package/lib/generators/rollup/templates/config.js +50 -0
  157. package/lib/generators/scss/index.js +3 -16
  158. package/lib/generators/scss/templates/{main.scss → styles.scss} +0 -0
  159. package/lib/generators/server/index.js +81 -0
  160. package/lib/generators/server/templates/server.js +59 -0
  161. package/lib/generators/storybook/index.js +1 -7
  162. package/lib/generators/stylelint/index.js +13 -14
  163. package/lib/lib/generator.js +9 -0
  164. package/lib/lib/utils.js +17 -0
  165. package/package.json +2 -2
  166. package/lib/generators/babel/templates/babel-preset-react.js +0 -7
  167. package/lib/generators/babel/templates/babel-preset.js +0 -57
  168. package/lib/generators/babel/templates/babelrc +0 -5
  169. package/lib/generators/babel/templates/utils/processScss.js +0 -10
  170. package/lib/generators/babel/templates/utils/transformRequireIgnore.js +0 -80
  171. package/lib/generators/html/templates/index.js +0 -9
  172. package/lib/generators/html/templates/root.js +0 -23
  173. package/lib/generators/html/templates/utils.js +0 -7
  174. package/lib/generators/js/templates/browserslistrc +0 -9
  175. package/lib/generators/js/templates/config.js +0 -33
  176. package/lib/generators/js/templates/index.js +0 -41
  177. package/lib/generators/js/templates/src/actions/LayoutActions.js +0 -12
  178. package/lib/generators/js/templates/src/actions/SiteActions.js +0 -22
  179. package/lib/generators/js/templates/src/components/App.jsx +0 -52
  180. package/lib/generators/js/templates/src/components/Root.jsx +0 -70
  181. package/lib/generators/js/templates/src/components/layouts/Main.jsx +0 -52
  182. package/lib/generators/js/templates/src/components/menus/Menu.jsx +0 -60
  183. package/lib/generators/js/templates/src/components/messages/Success.jsx +0 -36
  184. package/lib/generators/js/templates/src/components/pages/Home.jsx +0 -32
  185. package/lib/generators/js/templates/src/components/partials/Label.jsx +0 -32
  186. package/lib/generators/js/templates/src/reducers/LayoutReducer.js +0 -32
  187. package/lib/generators/js/templates/src/reducers/SiteReducer.js +0 -36
  188. package/lib/generators/js/templates/src/reducers/index.js +0 -7
  189. package/lib/generators/js/templates/src/vendor/polyfills/intl-en.js +0 -2
  190. package/lib/generators/js/templates/src/vendor/polyfills/intl-fr.js +0 -2
  191. package/lib/generators/laravel-panneau/templates/_composer.json +0 -6
  192. package/lib/generators/laravel-panneau/templates/_package.json +0 -11
  193. package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/HomeController.php +0 -14
  194. package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/PagesController.php +0 -11
  195. package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/File.php +0 -13
  196. package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Picture.php +0 -13
  197. package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Video.php +0 -34
  198. package/lib/generators/laravel-panneau/templates/app/Providers/PanneauServiceProvider.php +0 -23
  199. package/lib/generators/laravel-panneau/templates/app/Reducers/SlugExtractReducer.php +0 -18
  200. package/lib/generators/laravel-panneau/templates/app/Resources/Pages.php +0 -54
  201. package/lib/generators/laravel-panneau/templates/app/Schemas/Blocks/Base.php +0 -22
  202. package/lib/generators/laravel-panneau/templates/app/Schemas/Bubbles/Base.php +0 -22
  203. package/lib/generators/laravel-panneau/templates/app/Schemas/Pages/Base.php +0 -36
  204. package/lib/generators/laravel-panneau/templates/resources/lang/en/panneau.php +0 -12
  205. package/lib/generators/laravel-panneau/templates/resources/lang/fr/panneau.php +0 -12
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
3
5
  var _lodash = _interopRequireDefault(require("lodash"));
4
6
 
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
-
9
9
  var _generator = _interopRequireDefault(require("../../lib/generator"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -225,11 +225,9 @@ module.exports = class NpmPackageGenerator extends _generator.default {
225
225
 
226
226
  packageJSON() {
227
227
  const srcPath = this.templatePath('_package.json');
228
- const destPath = this.destinationPath('package.json');
229
228
  const packageJSON = this.fs.readJSON(srcPath);
230
229
  packageJSON.name = this.options['package-name'];
231
- const currentPackageJSON = this.fs.exists(destPath) ? this.fs.readJSON(destPath) : {};
232
- this.fs.writeJSON(destPath, _lodash.default.merge(packageJSON, currentPackageJSON));
230
+ this.packageJson.merge(packageJSON);
233
231
  }
234
232
 
235
233
  };
@@ -22,14 +22,27 @@ module.exports = class PrettierGenerator extends _generator.default {
22
22
  };
23
23
  }
24
24
 
25
- writing() {
26
- const srcPath = this.templatePath('prettierrc.json');
27
- const destPath = this.destinationPath('.prettierrc.json');
28
- this.fs.copy(srcPath, destPath);
25
+ get writing() {
26
+ return {
27
+ prettierrc() {
28
+ const srcPath = this.templatePath('prettierrc.json');
29
+ const destPath = this.destinationPath('.prettierrc.json');
30
+ this.fs.copy(srcPath, destPath);
31
+ },
32
+
33
+ dependencies() {
34
+ this.addDevDependencies(['prettier', '@prettier/plugin-php', '@trivago/prettier-plugin-sort-imports']);
35
+ }
36
+
37
+ };
29
38
  }
30
39
 
31
- install() {
32
- this.addDevDependencies(['prettier', '@prettier/plugin-php']);
40
+ async install() {
41
+ if (this.options['skip-install']) {
42
+ return;
43
+ }
44
+
45
+ await this.spawnCommand('npm', ['install']);
33
46
  }
34
47
 
35
48
  };
@@ -2,5 +2,7 @@
2
2
  "printWidth": 100,
3
3
  "singleQuote": true,
4
4
  "trailingComma": "all",
5
- "tabWidth": 4
5
+ "tabWidth": 4,
6
+ "importOrder": ["<THIRD_PARTY_MODULES>", "^[./](.*)?\/(utils|hooks|lib)", "^[./].*(?<!(\\.[a-z]+))$", "\\.scss$", "\\.[a-z]+$"],
7
+ "importOrderSeparation": true
6
8
  }
@@ -1,16 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
3
5
  var _lodash = _interopRequireDefault(require("lodash"));
4
6
 
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
-
9
9
  var _generator = _interopRequireDefault(require("../../lib/generator"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
 
13
- module.exports = class JsGenerator extends _generator.default {
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+
19
+ module.exports = class ReactAppGenerator extends _generator.default {
14
20
  // The name `constructor` is important here
15
21
  constructor(...args) {
16
22
  super(...args);
@@ -18,20 +24,13 @@ module.exports = class JsGenerator extends _generator.default {
18
24
  type: String,
19
25
  required: false
20
26
  });
21
- this.option('babel-compile', {
22
- type: Boolean,
23
- defaults: false
24
- });
25
27
  this.option('path', {
26
28
  type: String,
27
- defaults: 'src/js'
29
+ defaults: 'src'
28
30
  });
29
31
  this.option('styles-path', {
30
32
  type: String
31
33
  });
32
- this.option('root-props-import', {
33
- type: String
34
- });
35
34
  }
36
35
 
37
36
  initializing() {
@@ -46,7 +45,7 @@ module.exports = class JsGenerator extends _generator.default {
46
45
  }
47
46
 
48
47
  console.log(_chalk.default.yellow('\n----------------------'));
49
- console.log('Javascript Generator');
48
+ console.log('React App Generator');
50
49
  console.log(_chalk.default.yellow('----------------------\n'));
51
50
  },
52
51
 
@@ -71,20 +70,6 @@ module.exports = class JsGenerator extends _generator.default {
71
70
  };
72
71
  }
73
72
 
74
- configuring() {
75
- const skipInstall = this.options['skip-install'];
76
- this.composeWith('folklore:babel', {
77
- 'react-app': !this.options['babel-compile'],
78
- compile: this.options['babel-compile'],
79
- 'skip-install': skipInstall,
80
- quiet: true
81
- });
82
- this.composeWith('folklore:eslint', {
83
- 'skip-install': skipInstall,
84
- quiet: true
85
- });
86
- }
87
-
88
73
  get writing() {
89
74
  return {
90
75
  directory() {
@@ -100,10 +85,7 @@ module.exports = class JsGenerator extends _generator.default {
100
85
 
101
86
  index() {
102
87
  const jsPath = this.options.path;
103
- const rootPropsImport = this.options['root-props-import'] || null;
104
- this.fs.copyTpl(this.templatePath('index.js'), this.destinationPath(_path.default.join(jsPath, 'index.js')), {
105
- rootPropsImport
106
- });
88
+ this.fs.copyTpl(this.templatePath('index.js'), this.destinationPath(_path.default.join(jsPath, 'index.js')));
107
89
  },
108
90
 
109
91
  styles() {
@@ -116,41 +98,29 @@ module.exports = class JsGenerator extends _generator.default {
116
98
  this.fs.copyTpl(srcPath, destPath, templateData);
117
99
  },
118
100
 
119
- config() {
120
- const jsPath = _lodash.default.get(this.options, 'path');
121
-
122
- const srcPath = this.templatePath('config.js');
123
- const destPath = this.destinationPath(_path.default.join(jsPath, 'config.js'));
124
- this.fs.copy(srcPath, destPath);
125
- },
126
-
127
- browserslistrc() {
128
- const srcPath = this.templatePath('browserslistrc');
129
- const destPath = this.destinationPath('.browserslistrc');
130
- this.fs.copy(srcPath, destPath);
131
- },
132
-
133
101
  packageJSON() {
134
102
  const srcPath = this.templatePath('_package.json');
135
103
  const destPath = this.destinationPath('package.json');
136
104
  const packageJSON = this.fs.readJSON(srcPath);
137
- packageJSON.name = this.options['project-name'];
138
- const currentPackageJSON = this.fs.exists(destPath) ? this.fs.readJSON(destPath) : {};
139
- this.fs.writeJSON(destPath, _lodash.default.merge(packageJSON, currentPackageJSON));
105
+ this.packageJson.merge(_objectSpread(_objectSpread({}, packageJSON), {}, {
106
+ name: this.options['project-name']
107
+ }));
108
+ },
109
+
110
+ dependencies() {
111
+ this.addDependencies(['react', 'react-dom', 'prop-types', 'react-intl', 'react-router', 'react-router-dom', 'react-helmet', 'classnames', '@folklore/routes', '@folklore/fonts', '@folklore/forms', '@folklore/fetch', '@folklore/hooks', '@folklore/tracking', // Polyfills
112
+ 'intl', '@formatjs/intl-locale', '@formatjs/intl-pluralrules', 'intersection-observer', 'resize-observer-polyfill']);
140
113
  }
141
114
 
142
115
  };
143
116
  }
144
117
 
145
- install() {
118
+ async install() {
146
119
  if (this.options['skip-install']) {
147
120
  return;
148
121
  }
149
122
 
150
- const dependencies = ['domready@latest', 'fastclick@latest', 'keymirror@latest', 'lodash@latest', 'react@latest', 'prop-types@latest', 'react-dom@latest', 'react-redux@latest', 'react-intl@latest', 'react-router@^5.0.1', 'react-router-dom@latest', 'connected-react-router@latest', 'react-helmet@latest', 'node-polyglot@latest', 'classnames@latest', '@folklore/react-container@latest', '@folklore/fonts@latest', '@folklore/forms@latest', '@folklore/tracking@latest', 'react-loadable@latest', 'webfontloader@latest', 'intl@latest'];
151
- const devDependencies = ['html-webpack-plugin@latest'];
152
- this.addDependencies(dependencies);
153
- this.addDevDependencies(devDependencies);
123
+ await this.spawnCommand('npm', ['install']);
154
124
  }
155
125
 
156
126
  };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+
4
+ import Container from './components/Container';
5
+ import shouldPolyfill from './polyfills/should';
6
+
7
+ function getAppProps() {
8
+ return window.props || {};
9
+ }
10
+
11
+ function renderApp(props) {
12
+ const element = document.getElementById('app');
13
+ const container = React.createElement(Container, props);
14
+ const strictMode = React.createElement(React.StrictMode, {}, container);
15
+ const root = createRoot(element);
16
+ root.render(strictMode);
17
+ }
18
+
19
+ if (shouldPolyfill()) {
20
+ import('./polyfills/index').then(() => renderApp(getAppProps()));
21
+ } else {
22
+ renderApp(getAppProps());
23
+ }
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ // import PropTypes from 'prop-types';
3
+ import { Route, Routes } from 'react-router-dom';
4
+ import { useRoutes } from '@folklore/routes';
5
+
6
+ // import { useUrlGenerator } from '@folklore/routes';
7
+ // import * as AppPropTypes from '../lib/PropTypes';
8
+ import MainLayout from './layouts/Main';
9
+ import ErrorPage from './pages/Error';
10
+ import HomePage from './pages/Home';
11
+
12
+ import '<%= getRelativeStylesPath('components/App.jsx', 'styles.scss') %>';
13
+
14
+ const propTypes = {};
15
+
16
+ const defaultProps = {};
17
+
18
+ function App() {
19
+ const routes = useRoutes() || {};
20
+ return (
21
+ <Routes>
22
+ <Route
23
+ path={routes.home || '/'}
24
+ exact
25
+ element={
26
+ <MainLayout>
27
+ <HomePage />
28
+ </MainLayout>
29
+ }
30
+ />
31
+ <Route
32
+ path="*"
33
+ element={
34
+ <MainLayout>
35
+ <ErrorPage />
36
+ </MainLayout>
37
+ }
38
+ />
39
+ </Routes>
40
+ );
41
+ }
42
+
43
+ App.propTypes = propTypes;
44
+ App.defaultProps = defaultProps;
45
+
46
+ export default App;
@@ -0,0 +1,40 @@
1
+ import { RoutesProvider } from '@folklore/routes';
2
+ import PropTypes from 'prop-types';
3
+ import React from 'react';
4
+ import { IntlProvider } from 'react-intl';
5
+ import { BrowserRouter } from 'react-router-dom';
6
+
7
+ // import * as AppPropTypes from '../lib/PropTypes';
8
+ import App from './App';
9
+
10
+ const propTypes = {
11
+ locale: PropTypes.string,
12
+ messages: PropTypes.oneOfType([
13
+ PropTypes.objectOf(PropTypes.objectOf(PropTypes.string)),
14
+ PropTypes.objectOf(PropTypes.string),
15
+ ]),
16
+ routes: PropTypes.objectOf(PropTypes.string),
17
+ };
18
+
19
+ const defaultProps = {
20
+ locale: 'fr',
21
+ messages: {},
22
+ routes: {},
23
+ };
24
+
25
+ function Container({ locale, messages, routes }) {
26
+ return (
27
+ <IntlProvider locale={locale} messages={messages[locale] || messages}>
28
+ <BrowserRouter>
29
+ <RoutesProvider routes={routes}>
30
+ <App />
31
+ </RoutesProvider>
32
+ </BrowserRouter>
33
+ </IntlProvider>
34
+ );
35
+ }
36
+
37
+ Container.propTypes = propTypes;
38
+ Container.defaultProps = defaultProps;
39
+
40
+ export default Container;
@@ -5,9 +5,8 @@ import classNames from 'classnames';
5
5
  import { Link } from 'react-router-dom';
6
6
 
7
7
  import * as AppPropTypes from '../../lib/PropTypes';
8
- import Label from '../partials/Label';
9
8
 
10
- import styles from '<%= getRelativeStylesPath('components/buttons/Button.jsx', 'buttons/button.scss') %>';
9
+ import styles from '<%= getRelativeStylesPath('components/buttons/Button.jsx', 'buttons/button.module.scss') %>';
11
10
 
12
11
  const propTypes = {
13
12
  type: PropTypes.string,
@@ -22,9 +21,6 @@ const propTypes = {
22
21
  disabled: PropTypes.bool,
23
22
  loading: PropTypes.bool,
24
23
  disableOnLoading: PropTypes.bool,
25
- small: PropTypes.bool,
26
- big: PropTypes.bool,
27
- withShadow: PropTypes.bool,
28
24
  className: PropTypes.string,
29
25
  iconClassName: PropTypes.string,
30
26
  labelClassName: PropTypes.string,
@@ -44,16 +40,13 @@ const defaultProps = {
44
40
  disabled: false,
45
41
  loading: false,
46
42
  disableOnLoading: true,
47
- small: false,
48
- big: false,
49
- withShadow: false,
50
43
  className: null,
51
44
  iconClassName: null,
52
45
  labelClassName: null,
53
46
  onClick: null,
54
47
  };
55
48
 
56
- const Button = ({
49
+ function Button({
57
50
  type,
58
51
  href,
59
52
  external,
@@ -66,16 +59,12 @@ const Button = ({
66
59
  disabled,
67
60
  loading,
68
61
  disableOnLoading,
69
- small,
70
- big,
71
- withShadow,
72
62
  onClick,
73
63
  className,
74
64
  iconClassName,
75
65
  labelClassName,
76
- }) => {
66
+ }) {
77
67
  const finalLabel = label || children;
78
- const text = <Label>{finalLabel}</Label>;
79
68
  const hasChildren = label !== null && children !== null;
80
69
  const hasIcon = icon !== null;
81
70
  const hasInlineIcon = hasIcon && (iconPosition === 'inline' || text === null);
@@ -120,7 +109,7 @@ const Button = ({
120
109
  {hasChildren ? children : null}
121
110
  </>
122
111
  ) : null}
123
- {!hasIcon ? text : null}
112
+ {!hasIcon ? finalLabel : null}
124
113
  {hasChildren ? children : null}
125
114
  </>
126
115
  );
@@ -131,9 +120,6 @@ const Button = ({
131
120
  [styles.withIcon]: hasIcon,
132
121
  [styles.withIconColumns]: hasIconColumns,
133
122
  [styles.withText]: text !== null,
134
- [styles.withShadow]: withShadow,
135
- [styles.isSmall]: small,
136
- [styles.isBig]: big,
137
123
  [styles.isLink]: href !== null,
138
124
  [styles.isDisabled]: disabled,
139
125
  [styles.isLoading]: loading,
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import styles from '<%= getRelativeStylesPath('components/layouts/Main.jsx', 'layouts/main.module.scss') %>';
5
+
6
+ const propTypes = {
7
+ children: PropTypes.node.isRequired,
8
+ };
9
+
10
+ const defaultProps = {
11
+
12
+ };
13
+
14
+ function MainLayout({ children }) {
15
+ return (
16
+ <div className={styles.container}>
17
+ <div className={styles.inner}>
18
+ <div className={styles.content}>{children}</div>
19
+ </div>
20
+ </div>
21
+ );
22
+ };
23
+
24
+ MainLayout.propTypes = propTypes;
25
+ MainLayout.defaultProps = defaultProps;
26
+
27
+ export default MainLayout;
@@ -0,0 +1,62 @@
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.module.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
+ function Menu({ items, className }) {
23
+ return (
24
+ <nav
25
+ className={classNames([
26
+ styles.container,
27
+ {
28
+ [className]: className !== null,
29
+ },
30
+ ])}
31
+ >
32
+ <ul className={styles.items}>
33
+ {items.map(({ label, url, active = false, external = false, target = '_blank' }, index) => (
34
+ <li
35
+ className={classNames([
36
+ styles.item,
37
+ {
38
+ [styles.active]: active,
39
+ },
40
+ ])}
41
+ key={`item-${index}`}
42
+ >
43
+ {external ? (
44
+ <a href={url} target={target} className={styles.link}>
45
+ <Label>{label}</Label>
46
+ </a>
47
+ ) : (
48
+ <Link to={url} className={styles.link}>
49
+ <Label>{label}</Label>
50
+ </Link>
51
+ )}
52
+ </li>
53
+ ))}
54
+ </ul>
55
+ </nav>
56
+ );
57
+ }
58
+
59
+ Menu.propTypes = propTypes;
60
+ Menu.defaultProps = defaultProps;
61
+
62
+ export default Menu;
@@ -1,16 +1,14 @@
1
1
  /* eslint-disable react/jsx-props-no-spreading */
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import { connect } from 'react-redux';
5
4
  import { Link } from 'react-router-dom';
6
- import { defineMessages } from 'react-intl';
7
- import { useUrlGenerator } from '@folklore/react-container';
5
+ import { defineMessages, FormattedMessage } from 'react-intl';
6
+ import { useUrlGenerator } from '@folklore/routes';
8
7
 
9
8
  // import * as AppPropTypes from '../../lib/PropTypes';
10
9
  import PageMeta from '../partials/PageMeta';
11
- import Label from '../partials/Label';
12
10
 
13
- import styles from '<%= getRelativeStylesPath('components/pages/Error.jsx', 'pages/error.scss') %>';
11
+ import styles from '<%= getRelativeStylesPath('components/pages/Error.jsx', 'pages/error.module.scss') %>';
14
12
 
15
13
  export const messages = defineMessages({
16
14
  metaTitle401: {
@@ -79,21 +77,21 @@ const defaultProps = {
79
77
  statusCode: 404,
80
78
  };
81
79
 
82
- const ErrorPage = ({ statusCode }) => {
83
- const urlGenerator = useUrlGenerator();
80
+ function ErrorPage({ statusCode }) {
81
+ const url = useUrlGenerator();
84
82
  return (
85
83
  <div className={styles.container}>
86
84
  <PageMeta title={messages[`metaTitle${statusCode || 404}`]} />
87
85
  <div className={styles.inner}>
88
86
  <h1 className={styles.title}>
89
- <Label>{messages[`title${statusCode || 404}`]}</Label>
87
+ <FormattedMessage {...messages[`title${statusCode || 404}`]} />
90
88
  </h1>
91
89
  <p className={styles.description}>
92
- <Label>{messages[`description${statusCode || 404}`]}</Label>
90
+ <FormattedMessage {...messages[`description${statusCode || 404}`]} />
93
91
  </p>
94
92
  <div className={styles.actions}>
95
- <Link to={urlGenerator.route('home')}>
96
- <Label>{messages.gotoHome}</Label>
93
+ <Link to={url('home')}>
94
+ <FormattedMessage {...messages.gotoHome} />
97
95
  </Link>
98
96
  </div>
99
97
  </div>
@@ -104,6 +102,4 @@ const ErrorPage = ({ statusCode }) => {
104
102
  ErrorPage.propTypes = propTypes;
105
103
  ErrorPage.defaultProps = defaultProps;
106
104
 
107
- export default connect(({ site: { statusCode } }) => ({
108
- statusCode,
109
- }))(ErrorPage);
105
+ export default ErrorPage;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ // import PropTypes from 'prop-types';
3
+ import { defineMessages } 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.module.scss') %>';
9
+
10
+ const messages = defineMessages({
11
+ metaTitle: {
12
+ defaultMessage: 'Home',
13
+ description: 'Page title'
14
+ },
15
+ });
16
+
17
+ const propTypes = {
18
+ // intl: AppPropTypes.intl.isRequired,
19
+ };
20
+
21
+ function HomePage () {
22
+ return (
23
+ <div className={styles.container}>
24
+ <PageMeta title={messages.metaTitle} />
25
+ <div className={styles.logo} />
26
+ </div>
27
+ );
28
+ }
29
+
30
+ HomePage.propTypes = propTypes;
31
+
32
+ export default HomePage;
@@ -1,20 +1,19 @@
1
1
  /* eslint-disable react/no-array-index-key */
2
2
  import React from 'react';
3
3
  import { Helmet } from 'react-helmet';
4
- import { defineMessages, injectIntl } from 'react-intl';
4
+ import { defineMessages, useIntl } from 'react-intl';
5
5
 
6
6
  import * as AppPropTypes from '../../lib/PropTypes';
7
7
  import { isMessage } from '../../lib/utils';
8
8
 
9
9
  const messages = defineMessages({
10
10
  title: {
11
- id: 'meta.title',
12
11
  defaultMessage: 'Title',
12
+ description: 'Page title',
13
13
  },
14
14
  });
15
15
 
16
16
  const propTypes = {
17
- intl: AppPropTypes.intl.isRequired,
18
17
  title: AppPropTypes.message,
19
18
  };
20
19
 
@@ -22,15 +21,16 @@ const defaultProps = {
22
21
  title: messages.title,
23
22
  };
24
23
 
25
- const PageMeta = ({
26
- intl, title,
27
- }) => (
28
- <Helmet>
29
- <title>{isMessage(title) ? intl.formatMessage(title) : title}</title>
30
- </Helmet>
31
- );
24
+ function PageMeta({ title }) {
25
+ const intl = useIntl();
26
+ return (
27
+ <Helmet>
28
+ <title>{isMessage(title) ? intl.formatMessage(title) : title}</title>
29
+ </Helmet>
30
+ );
31
+ }
32
32
 
33
33
  PageMeta.propTypes = propTypes;
34
34
  PageMeta.defaultProps = defaultProps;
35
35
 
36
- export default React.memo(injectIntl(PageMeta));
36
+ export default React.memo(PageMeta);
@@ -0,0 +1,6 @@
1
+ import 'intl';
2
+ import '@formatjs/intl-locale/polyfill';
3
+ import '@formatjs/intl-pluralrules/polyfill';
4
+ import 'intersection-observer';
5
+ import ResizeObserver from 'resize-observer-polyfill';
6
+ window.ResizeObserver = ResizeObserver;
@@ -0,0 +1,2 @@
1
+ import 'intl/locale-data/jsonp/en';
2
+ import '@formatjs/intl-pluralrules/locale-data/en'; // Add locale data for de
@@ -0,0 +1,2 @@
1
+ import 'intl/locale-data/jsonp/fr';
2
+ import '@formatjs/intl-pluralrules/locale-data/fr'; // Add locale data for de
@@ -0,0 +1,14 @@
1
+ import { shouldPolyfill as shouldPolyfillLocale } from '@formatjs/intl-locale/should-polyfill';
2
+ import { shouldPolyfill as shouldPolyfillPlural } from '@formatjs/intl-pluralrules/should-polyfill';
3
+
4
+ function should() {
5
+ return (
6
+ typeof window.Intl === 'undefined' ||
7
+ shouldPolyfillLocale() ||
8
+ shouldPolyfillPlural() ||
9
+ typeof window.IntersectionObserver === 'undefined' ||
10
+ typeof window.ResizeObserver === 'undefined'
11
+ );
12
+ }
13
+
14
+ export default should;