generator-folklore 3.0.5 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. package/lib/generators/build/index.js +1 -1
  2. package/lib/generators/eslint/index.js +1 -1
  3. package/lib/generators/intl/index.js +93 -0
  4. package/lib/generators/laravel-mediatheque/index.js +151 -0
  5. package/lib/generators/laravel-mediatheque/instructions/ServiceProvider.php +26 -0
  6. package/lib/generators/laravel-mediatheque/templates/app/Models/Media.php +9 -0
  7. package/lib/generators/laravel-mediatheque/templates/app/Models/MediaFile.php +9 -0
  8. package/lib/generators/laravel-panneau/index.js +89 -28
  9. package/lib/generators/laravel-panneau/instructions/ServiceProvider.php +21 -0
  10. package/lib/generators/laravel-panneau/instructions/config.php +13 -0
  11. package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +19 -0
  12. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Image.php +15 -0
  13. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +12 -0
  14. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Page.php +10 -0
  15. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Pages/Home.php +9 -0
  16. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +37 -0
  17. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +8 -0
  18. package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +47 -0
  19. package/lib/generators/laravel-panneau/templates/app/Http/Resources/PagesCollection.php +10 -0
  20. package/lib/generators/laravel-panneau/templates/app/Models/Block.php +4 -13
  21. package/lib/generators/laravel-panneau/templates/app/Models/Page.php +3 -60
  22. package/lib/generators/laravel-panneau/templates/app/Panneau/Composers/AppComposer.php +50 -0
  23. package/lib/generators/laravel-panneau/templates/app/{Schemas → Panneau}/Fields/.gitkeep +0 -0
  24. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/AccountController.php +41 -0
  25. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/Controller.php +19 -0
  26. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/HomeController.php +16 -0
  27. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/PagesController.php +24 -0
  28. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php +27 -0
  29. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UsersController.php +32 -0
  30. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/AccountUpdateRequest.php +29 -0
  31. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/UploadRequest.php +29 -0
  32. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlockResource.php +39 -0
  33. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +10 -0
  34. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php +56 -0
  35. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PagesCollection.php +10 -0
  36. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UserResource.php +24 -0
  37. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UsersCollection.php +10 -0
  38. package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +74 -0
  39. package/lib/generators/laravel-panneau/templates/app/Panneau/Policies/PanneauPolicy.php +32 -0
  40. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/ImageBlock.php +30 -0
  41. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +28 -0
  42. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +45 -0
  43. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +28 -0
  44. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +92 -0
  45. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Users.php +57 -0
  46. package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +42 -0
  47. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/ImageBlock.php +27 -0
  48. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +19 -0
  49. package/lib/generators/laravel-panneau/templates/app/Resources/Page.php +10 -0
  50. package/lib/generators/laravel-panneau/templates/app/Resources/Pages/HomePage.php +10 -0
  51. package/lib/generators/laravel-panneau/templates/app.blade.php +8 -0
  52. package/lib/generators/laravel-panneau/templates/config.php +29 -0
  53. package/lib/generators/laravel-panneau/templates/index.js +32 -0
  54. package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +66 -0
  55. package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +66 -0
  56. package/lib/generators/laravel-panneau/templates/layout.blade.php +17 -48
  57. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/Panneau.jsx +68 -0
  58. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx +68 -0
  59. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlugLocalized.jsx +43 -0
  60. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/index.js +2 -0
  61. package/lib/generators/laravel-panneau/templates/resources/assets/styles/panneau.scss +2 -0
  62. package/lib/generators/laravel-panneau/templates/routes.php +30 -0
  63. package/lib/generators/laravel-project/index.js +519 -0
  64. package/lib/generators/laravel-project/templates/env +41 -0
  65. package/lib/generators/laravel-project/templates/laravel/app/Composers/AppComposer.php +48 -0
  66. package/lib/generators/laravel-project/templates/laravel/app/Composers/IntlComposer.php +10 -0
  67. package/lib/generators/laravel-project/templates/laravel/app/Composers/MetaComposer.php +48 -0
  68. package/lib/generators/laravel-project/templates/laravel/app/Composers/RoutesComposer.php +19 -0
  69. package/lib/generators/laravel-project/templates/laravel/app/Contracts/Repositories/Users.php +17 -0
  70. package/lib/generators/laravel-project/templates/laravel/app/Contracts/Resources/User.php +10 -0
  71. package/lib/generators/laravel-project/templates/laravel/app/Http/Controllers/HomeController.php +18 -0
  72. package/lib/generators/laravel-project/templates/laravel/app/Http/Middleware/TrustProxies.php +28 -0
  73. package/lib/generators/laravel-project/templates/laravel/app/Http/Resources/UserResource.php +21 -0
  74. package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +20 -0
  75. package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +120 -0
  76. package/lib/generators/laravel-project/templates/laravel/app/Providers/RouteServiceProvider.php +64 -0
  77. package/lib/generators/laravel-project/templates/laravel/app/Providers/ViewServiceProvider.php +33 -0
  78. package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +37 -0
  79. package/lib/generators/laravel-project/templates/laravel/app/Resources/User.php +11 -0
  80. package/lib/generators/laravel-project/templates/laravel/config/app.php +216 -0
  81. package/lib/generators/laravel-project/templates/laravel/config/auth.php +116 -0
  82. package/lib/generators/laravel-project/templates/laravel/config/image.php +204 -0
  83. package/lib/generators/laravel-project/templates/laravel/config/services.php +39 -0
  84. package/lib/generators/laravel-project/templates/laravel/lang/en/content.php +5 -0
  85. package/lib/generators/laravel-project/templates/laravel/lang/en/errors.php +17 -0
  86. package/lib/generators/laravel-project/templates/laravel/lang/en/meta.php +11 -0
  87. package/lib/generators/laravel-project/templates/laravel/lang/en/routes.php +4 -0
  88. package/lib/generators/laravel-project/templates/laravel/lang/fr/auth.php +19 -0
  89. package/lib/generators/laravel-project/templates/laravel/lang/fr/content.php +5 -0
  90. package/lib/generators/laravel-project/templates/laravel/lang/fr/errors.php +17 -0
  91. package/lib/generators/laravel-project/templates/laravel/lang/fr/meta.php +11 -0
  92. package/lib/generators/laravel-project/templates/laravel/lang/fr/pagination.php +19 -0
  93. package/lib/generators/laravel-project/templates/laravel/lang/fr/passwords.php +22 -0
  94. package/lib/generators/laravel-project/templates/laravel/lang/fr/routes.php +12 -0
  95. package/lib/generators/laravel-project/templates/laravel/lang/fr/validation.php +146 -0
  96. package/lib/generators/laravel-project/templates/laravel/resources/assets/fonts/.gitkeep +0 -0
  97. package/lib/generators/laravel-project/templates/laravel/resources/assets/img/.gitkeep +0 -0
  98. package/lib/generators/laravel-project/templates/laravel/resources/assets/img/folklore.png +0 -0
  99. package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/body.blade.php +3 -0
  100. package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/gpt.blade.php +16 -0
  101. package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/head.blade.php +1 -0
  102. package/lib/generators/laravel-project/templates/laravel/resources/views/app.blade.php +8 -0
  103. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/401.blade.php +8 -0
  104. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/403.blade.php +8 -0
  105. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/404.blade.php +8 -0
  106. package/lib/generators/laravel-project/templates/laravel/resources/views/errors/500.blade.php +8 -0
  107. package/lib/generators/laravel-project/templates/laravel/resources/views/layout.blade.php +33 -0
  108. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/all.blade.php +4 -0
  109. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/base.blade.php +11 -0
  110. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/facebook.blade.php +4 -0
  111. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/opengraph.blade.php +9 -0
  112. package/lib/generators/laravel-project/templates/laravel/resources/views/meta/twitter.blade.php +5 -0
  113. package/lib/generators/laravel-project/templates/laravel/routes/web.php +12 -0
  114. package/lib/generators/prettier/index.js +1 -1
  115. package/lib/generators/react-app/index.js +2 -2
  116. package/lib/generators/react-app/templates/src/components/App.jsx +3 -2
  117. package/lib/generators/react-app/templates/src/components/pages/Error.jsx +2 -2
  118. package/lib/generators/stylelint/index.js +1 -1
  119. package/lib/lib/generator.js +9 -0
  120. package/package.json +5 -4
  121. package/lib/generators/laravel-panneau/templates/_composer.json +0 -6
  122. package/lib/generators/laravel-panneau/templates/_package.json +0 -11
  123. package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/HomeController.php +0 -14
  124. package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/PagesController.php +0 -11
  125. package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/File.php +0 -13
  126. package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Picture.php +0 -13
  127. package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Video.php +0 -34
  128. package/lib/generators/laravel-panneau/templates/app/Providers/PanneauServiceProvider.php +0 -23
  129. package/lib/generators/laravel-panneau/templates/app/Reducers/SlugExtractReducer.php +0 -18
  130. package/lib/generators/laravel-panneau/templates/app/Resources/Pages.php +0 -54
  131. package/lib/generators/laravel-panneau/templates/app/Schemas/Blocks/Base.php +0 -22
  132. package/lib/generators/laravel-panneau/templates/app/Schemas/Bubbles/Base.php +0 -22
  133. package/lib/generators/laravel-panneau/templates/app/Schemas/Pages/Base.php +0 -36
  134. package/lib/generators/laravel-panneau/templates/resources/lang/en/panneau.php +0 -12
  135. package/lib/generators/laravel-panneau/templates/resources/lang/fr/panneau.php +0 -12
@@ -0,0 +1,519 @@
1
+ "use strict";
2
+
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
5
+ var _glob = _interopRequireDefault(require("glob"));
6
+
7
+ var _lodash = _interopRequireDefault(require("lodash"));
8
+
9
+ var _passwordGenerator = _interopRequireDefault(require("password-generator"));
10
+
11
+ var _path = _interopRequireDefault(require("path"));
12
+
13
+ var _yeomanRemote = _interopRequireDefault(require("yeoman-remote"));
14
+
15
+ var _generator = _interopRequireDefault(require("../../lib/generator"));
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
19
+ 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; }
20
+
21
+ 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; }
22
+
23
+ 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; }
24
+
25
+ module.exports = class LaravelProjectGenerator extends _generator.default {
26
+ static safeDbString(str) {
27
+ return str.replace(/[-s.]+/gi, '_').replace(/[^a-z0-9]+/gi, '');
28
+ }
29
+
30
+ static getPassword() {
31
+ return (0, _passwordGenerator.default)(20, false);
32
+ }
33
+
34
+ constructor(...args) {
35
+ super(...args);
36
+ this.argument('project-name', {
37
+ type: String,
38
+ required: false
39
+ });
40
+ this.argument('project-host', {
41
+ type: String,
42
+ required: false
43
+ });
44
+ this.option('laravel-version', {
45
+ type: String,
46
+ desc: 'Laravel version',
47
+ defaults: '9'
48
+ });
49
+ this.option('laravel-branch', {
50
+ type: String,
51
+ desc: 'Laravel repository branch'
52
+ });
53
+ this.option('url', {
54
+ type: String,
55
+ desc: 'Project url',
56
+ defaults: 'https://<%= project_host %>'
57
+ });
58
+ this.option('local-url', {
59
+ type: String,
60
+ desc: 'Project local url',
61
+ defaults: 'https://<%= project_host %>.test:8080'
62
+ });
63
+ this.option('proxy-url', {
64
+ type: String,
65
+ desc: 'Project proxy url',
66
+ defaults: 'https://<%= project_host %>.test'
67
+ });
68
+ this.option('assets-path', {
69
+ type: String,
70
+ desc: 'Path for assets',
71
+ defaults: 'resources/assets'
72
+ });
73
+ this.option('public-path', {
74
+ type: String,
75
+ desc: 'Path for build',
76
+ defaults: 'public'
77
+ });
78
+ this.option('js-path', {
79
+ type: String,
80
+ desc: 'Path for the javascript',
81
+ defaults: 'js'
82
+ });
83
+ this.option('styles-path', {
84
+ type: String,
85
+ desc: 'Path for the styles',
86
+ defaults: 'styles'
87
+ });
88
+ this.option('db-host', {
89
+ type: String,
90
+ desc: 'Database host',
91
+ defaults: 'localhost'
92
+ });
93
+ this.option('db-username', {
94
+ type: String,
95
+ desc: 'Database username',
96
+ defaults: 'homestead'
97
+ });
98
+ this.option('db-password', {
99
+ type: String,
100
+ desc: 'Database password',
101
+ defaults: 'secret'
102
+ });
103
+ this.option('db-name', {
104
+ type: String,
105
+ desc: 'Database name'
106
+ });
107
+ this.option('panneau', {
108
+ type: Boolean,
109
+ desc: 'Add panneau',
110
+ defaults: false
111
+ });
112
+ this.option('mediatheque', {
113
+ type: Boolean,
114
+ desc: 'Add mediatheque',
115
+ defaults: false
116
+ });
117
+ this.option('auth', {
118
+ type: Boolean,
119
+ desc: 'Add auth',
120
+ defaults: false
121
+ });
122
+ }
123
+
124
+ get prompting() {
125
+ return {
126
+ welcome() {
127
+ if (this.options.quiet) {
128
+ return;
129
+ }
130
+
131
+ console.log(_chalk.default.yellow('\n----------------------'));
132
+ console.log('Laravel Generator');
133
+ console.log(_chalk.default.yellow('----------------------\n'));
134
+ },
135
+
136
+ prompts() {
137
+ const prompts = [];
138
+
139
+ if (!this.options['project-name']) {
140
+ prompts.push(_generator.default.prompts.project_name);
141
+ }
142
+
143
+ if (!this.options['project-host']) {
144
+ prompts.push({
145
+ type: 'input',
146
+ name: 'project-host',
147
+ message: 'What is the host of the project?',
148
+ default: answers => {
149
+ const projectName = this.options['project-name'] || answers['project-name'];
150
+ return projectName.match(/.[^.]+$/) ? projectName : `${projectName}.com`;
151
+ }
152
+ });
153
+ }
154
+
155
+ if (!this.options['db-name']) {
156
+ prompts.push({
157
+ type: 'input',
158
+ name: 'db-name',
159
+ message: 'What is the name of the database?',
160
+ default: answers => {
161
+ const projectName = this.options['project-name'] || answers['project-name'];
162
+ return projectName.match(/^([^.]+)/)[1];
163
+ }
164
+ });
165
+ }
166
+
167
+ const featuresChoices = [!this.options.mediatheque && {
168
+ name: 'Mediatheque',
169
+ value: 'mediatheque',
170
+ checked: true
171
+ }, !this.options.panneau && {
172
+ name: 'Panneau',
173
+ value: 'panneau',
174
+ checked: false
175
+ }, !this.options.auth && {
176
+ name: 'Auth',
177
+ value: 'auth',
178
+ checked: false
179
+ }].filter(Boolean);
180
+
181
+ if (featuresChoices.length) {
182
+ prompts.push({
183
+ type: 'checkbox',
184
+ name: 'features',
185
+ choices: featuresChoices,
186
+ message: 'Which features?',
187
+ default: featuresChoices.filter(it => it.checked || false).map(it => it.name)
188
+ });
189
+ }
190
+
191
+ if (!prompts.length) {
192
+ return null;
193
+ }
194
+
195
+ return this.prompt(prompts).then(answers => {
196
+ if (answers['project-name']) {
197
+ this.options['project-name'] = answers['project-name'];
198
+ }
199
+
200
+ if (answers['project-host']) {
201
+ this.options['project-host'] = answers['project-host'];
202
+ }
203
+
204
+ if (answers['db-name']) {
205
+ this.options['db-name'] = answers['db-name'];
206
+ }
207
+
208
+ const features = answers.features || [];
209
+
210
+ if (features.indexOf('panneau') !== -1) {
211
+ this.options.panneau = true;
212
+ }
213
+
214
+ if (features.indexOf('auth') !== -1) {
215
+ this.options.auth = true;
216
+ }
217
+
218
+ if (features.indexOf('mediatheque') !== -1) {
219
+ this.options.mediatheque = true;
220
+ }
221
+ });
222
+ }
223
+
224
+ };
225
+ }
226
+
227
+ configuring() {
228
+ const assetsPath = _lodash.default.get(this.options, 'assets-path', '').replace(/\/$/, '');
229
+
230
+ const publicPath = _lodash.default.get(this.options, 'public-path');
231
+
232
+ const jsPath = _lodash.default.get(this.options, 'js-path');
233
+
234
+ const jsSrcPath = _path.default.join(assetsPath, jsPath);
235
+
236
+ const stylesPath = _lodash.default.get(this.options, 'styles-path');
237
+
238
+ const stylesSrcPath = _path.default.join(assetsPath, stylesPath);
239
+
240
+ this.composeWith('folklore:prettier', {
241
+ 'skip-install': true,
242
+ quiet: true
243
+ });
244
+ this.composeWith('folklore:eslint', {
245
+ 'skip-install': true,
246
+ quiet: true
247
+ });
248
+ this.composeWith('folklore:stylelint', {
249
+ 'skip-install': true,
250
+ quiet: true
251
+ });
252
+ this.composeWith('folklore:browserslist', {
253
+ 'skip-install': true,
254
+ quiet: true
255
+ });
256
+ this.composeWith('folklore:editorconfig', {
257
+ quiet: true,
258
+ 'skip-install': true
259
+ });
260
+ this.composeWith('folklore:react-app', {
261
+ 'project-name': this.options['project-name'],
262
+ path: jsSrcPath,
263
+ 'styles-path': stylesSrcPath,
264
+ quiet: true,
265
+ 'skip-install': true
266
+ });
267
+ this.composeWith('folklore:scss', {
268
+ 'project-name': this.options['project-name'],
269
+ path: stylesSrcPath,
270
+ react: true,
271
+ quiet: true,
272
+ 'skip-install': true
273
+ });
274
+ this.composeWith('folklore:build', {
275
+ 'src-path': assetsPath,
276
+ 'entry-path': _path.default.join(jsSrcPath, 'index.js'),
277
+ 'build-path': publicPath,
278
+ quiet: true,
279
+ 'skip-install': true
280
+ });
281
+ this.composeWith('folklore:intl', {
282
+ 'translations-path': _path.default.join(jsSrcPath, '**/*.{js,jsx}'),
283
+ 'output-path': './lang',
284
+ 'without-id-only': true,
285
+ quiet: true,
286
+ 'skip-install': true
287
+ });
288
+
289
+ if (this.options.mediatheque) {
290
+ this.composeWith('folklore:laravel-mediatheque', {
291
+ 'project-name': this.options['project-name'],
292
+ 'skip-install': true,
293
+ quiet: true
294
+ });
295
+ }
296
+
297
+ if (this.options.panneau) {
298
+ this.composeWith('folklore:laravel-panneau', {
299
+ 'project-name': this.options['project-name'],
300
+ 'skip-install': skipInstall,
301
+ quiet: true
302
+ });
303
+ } // if (this.options.auth) {
304
+ // this.composeWith('folklore:laravel-auth', {
305
+ // 'project-name': this.options['project-name'],
306
+ // 'js-path': jsSrcPath,
307
+ // 'styles-path': stylesSrcPath,
308
+ // 'skip-install': skipInstall,
309
+ // 'install-npm': true,
310
+ // quiet: true,
311
+ // });
312
+ // }
313
+
314
+ }
315
+
316
+ get writing() {
317
+ return {
318
+ laravel() {
319
+ const done = this.async();
320
+ const {
321
+ 'laravel-version': laravelVersion = null,
322
+ 'laravel-branch': laravelBranch = null
323
+ } = this.options;
324
+ const versionBranch = laravelVersion !== 'latest' && laravelVersion !== null ? `${laravelVersion.indexOf('.') !== -1 ? laravelVersion : `${laravelVersion}.x`}` : null;
325
+ const branch = laravelBranch || versionBranch;
326
+
327
+ const remoteCallback = (err, cachePath) => {
328
+ const destinationPath = this.destinationPath();
329
+
330
+ const files = _glob.default.sync('**', {
331
+ dot: true,
332
+ nodir: true,
333
+ cwd: cachePath
334
+ });
335
+
336
+ let source;
337
+ let destination;
338
+ files.forEach(file => {
339
+ source = _path.default.join(cachePath, file);
340
+ destination = _path.default.join(destinationPath, file);
341
+
342
+ if (!this.fs.exists(destination)) {
343
+ this.fs.copy(source, destination);
344
+ }
345
+ });
346
+ done();
347
+ };
348
+
349
+ if (branch !== null) {
350
+ (0, _yeomanRemote.default)('laravel', 'laravel', branch, remoteCallback);
351
+ } else {
352
+ (0, _yeomanRemote.default)('laravel', 'laravel', remoteCallback);
353
+ }
354
+ },
355
+
356
+ removeFiles() {
357
+ const files = ['package.json', 'config/app.php', 'config/auth.php', 'routes/web.php', 'vite.config.js', 'resources/css', 'resources/js', 'resources/views/welcome.blade.php', 'app/Http/Controllers/HomeController.php', 'app/Http/Middleware/TrustProxies.php', 'app/Models/User.php'];
358
+ files.forEach(file => {
359
+ const filePath = this.destinationPath(file);
360
+ this.fs.delete(filePath);
361
+ });
362
+ },
363
+
364
+ composerJSON() {
365
+ this.composerJson.merge({
366
+ require: {
367
+ 'folklore/laravel-folklore': 'v1.x-dev',
368
+ 'folklore/laravel-locale': 'v8.x-dev',
369
+ 'folklore/laravel-image': 'v1.x-dev'
370
+ },
371
+ 'require-dev': {
372
+ 'laravel/telescope': '^4.0.0'
373
+ },
374
+ extra: {
375
+ laravel: {
376
+ 'dont-discover': ['laravel/telescope']
377
+ }
378
+ }
379
+ });
380
+ },
381
+
382
+ packageJSON() {
383
+ this.packageJson.merge({
384
+ scripts: {
385
+ clean: 'rm -rf public/static && rm -rf public/precache-*',
386
+ 'build:scripts': 'flklr build --load-env ./resources/assets/js/index.js',
387
+ 'build:views': 'php artisan assets:view',
388
+ build: 'npm run clean && npm run build:scripts && npm run build:views',
389
+ start: 'npm run server',
390
+ server: 'flklr serve --load-env ./resources/assets/js/index.js'
391
+ }
392
+ });
393
+ },
394
+
395
+ env() {
396
+ const url = _lodash.default.template(_lodash.default.get(this.options, 'url'))({
397
+ project_host: this.options['project-host'],
398
+ project_name: this.options['project-name']
399
+ }).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
400
+
401
+ const urlLocal = _lodash.default.template(_lodash.default.get(this.options, 'local-url'))({
402
+ project_host: this.options['project-host'],
403
+ project_name: this.options['project-name']
404
+ }).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
405
+
406
+ const urlProxy = _lodash.default.template(_lodash.default.get(this.options, 'proxy-url', _lodash.default.get(this.options, 'local-url')))({
407
+ project_host: this.options['project-host'],
408
+ project_name: this.options['project-name']
409
+ }).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
410
+
411
+ const templateData = {
412
+ project_name: this.options['project-name'],
413
+ db_host: this.options['db-host'],
414
+ db_username: this.options['db-username'],
415
+ db_password: this.options['db-password'],
416
+ db_name: this.options['db-name'],
417
+ url: urlLocal,
418
+ proxy_url: urlProxy
419
+ };
420
+
421
+ const prodTemplateData = _objectSpread(_objectSpread({}, templateData), {}, {
422
+ url,
423
+ db_username: this.options['db-name']
424
+ });
425
+
426
+ const src = this.templatePath('env');
427
+ const dest = this.destinationPath('.env');
428
+ this.fs.copyTpl(src, dest, templateData);
429
+ const srcExample = this.templatePath('env');
430
+ const destExample = this.destinationPath('.env.example');
431
+ this.fs.copyTpl(srcExample, destExample, templateData); // const srcProd = this.templatePath('env.prod');
432
+ // const destProd = this.destinationPath('.env.prod');
433
+ // this.fs.copyTpl(srcProd, destProd, prodTemplateData);
434
+ },
435
+
436
+ files() {
437
+ const templatePath = this.templatePath('laravel');
438
+ const destinationPath = this.destinationPath();
439
+
440
+ const files = _glob.default.sync('**', {
441
+ dot: true,
442
+ nodir: true,
443
+ cwd: templatePath
444
+ });
445
+
446
+ files.forEach(file => {
447
+ const source = _path.default.join(templatePath, file);
448
+
449
+ const destination = _path.default.join(destinationPath, file);
450
+
451
+ if (file.match(/\.php$/i)) {
452
+ this.fs.copyTpl(source, destination, {
453
+ options: this.options
454
+ });
455
+ } else {
456
+ this.fs.copy(source, destination);
457
+ }
458
+ });
459
+ }
460
+
461
+ };
462
+ }
463
+
464
+ get install() {
465
+ return {
466
+ async npm() {
467
+ if (this.options['skip-install']) {
468
+ return;
469
+ }
470
+
471
+ await this.spawnCommand('npm', ['install']);
472
+ },
473
+
474
+ async composer() {
475
+ if (this.options['skip-install']) {
476
+ return;
477
+ }
478
+
479
+ await this.spawnCommand('composer', ['install']);
480
+ },
481
+
482
+ async keyGenerate() {
483
+ if (this.options['skip-install']) {
484
+ return;
485
+ }
486
+
487
+ await this.spawnCommand('php', ['artisan', 'key:generate']);
488
+ },
489
+
490
+ async vendorPublish() {
491
+ if (this.options['skip-install']) {
492
+ return;
493
+ }
494
+
495
+ await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\ServiceProvider']);
496
+ await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\Locale\\LocaleServiceProvider']);
497
+ await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\Image\\ServiceProvider']);
498
+ },
499
+
500
+ async telescope() {
501
+ if (this.options['skip-install']) {
502
+ return;
503
+ }
504
+
505
+ await this.spawnCommand('php', ['artisan', 'telescope:install']);
506
+ },
507
+
508
+ async valet() {
509
+ if (this.options['skip-install']) {
510
+ return;
511
+ }
512
+
513
+ await this.spawnCommand('valet', ['link', '--secure', this.options['project-host']]);
514
+ }
515
+
516
+ };
517
+ }
518
+
519
+ };
@@ -0,0 +1,41 @@
1
+ APP_NAME=Laravel
2
+ APP_ENV=local
3
+ APP_KEY=
4
+ APP_DEBUG=true
5
+ APP_URL=<%= url %>
6
+
7
+ LOG_CHANNEL=stack
8
+ LOG_DEPRECATIONS_CHANNEL=null
9
+ LOG_LEVEL=debug
10
+
11
+ DB_CONNECTION=mysql
12
+ DB_HOST=127.0.0.1
13
+ DB_PORT=3306
14
+ DB_DATABASE=<%= db_name %>
15
+ DB_USERNAME=<%= db_username %>
16
+ DB_PASSWORD=<%= db_password %>
17
+
18
+ BROADCAST_DRIVER=log
19
+ CACHE_DRIVER=file
20
+ FILESYSTEM_DISK=local
21
+ QUEUE_CONNECTION=sync
22
+ SESSION_DRIVER=file
23
+ SESSION_LIFETIME=120
24
+
25
+ MEMCACHED_HOST=127.0.0.1
26
+
27
+ REDIS_HOST=127.0.0.1
28
+ REDIS_PASSWORD=null
29
+ REDIS_PORT=6379
30
+
31
+ MAIL_MAILER=smtp
32
+ MAIL_HOST=mailhog
33
+ MAIL_PORT=1025
34
+ MAIL_USERNAME=null
35
+ MAIL_PASSWORD=null
36
+ MAIL_ENCRYPTION=null
37
+ MAIL_FROM_ADDRESS="dev@folklore.email"
38
+ MAIL_FROM_NAME="${APP_NAME}"
39
+
40
+ # react-scripts variables
41
+ FLKLR_PROXY=<%= proxy_url %>
@@ -0,0 +1,48 @@
1
+ <?php
2
+
3
+ namespace App\Composers;
4
+
5
+ use Illuminate\Http\Request;
6
+ use Illuminate\View\View;
7
+ use App\Http\Resources\UserResource;
8
+
9
+ class AppComposer
10
+ {
11
+
12
+ /**
13
+ * The request
14
+ *
15
+ * @var \Illuminate\Http\Request
16
+ */
17
+ protected $request;
18
+
19
+ /**
20
+ * Create a new profile composer.
21
+ *
22
+ * @param \Illuminate\Http\Request $request
23
+ * @return void
24
+ */
25
+ public function __construct(Request $request)
26
+ {
27
+ $this->request = $request;
28
+ }
29
+
30
+ /**
31
+ * Bind data to the view.
32
+ *
33
+ * @param View $view
34
+ * @return void
35
+ */
36
+ public function compose(View $view)
37
+ {
38
+ $site = $this->request->site();
39
+ $user = $this->request->user();
40
+
41
+ $view->props = [
42
+ 'routes' => $view->routes,
43
+ 'intl' => $view->intl,
44
+ 'user' => !is_null($user) ? new UserResource($user) : null,
45
+ 'site' => $site,
46
+ ];
47
+ }
48
+ }
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ namespace App\Composers;
4
+
5
+ use Folklore\Composers\IntlComposer as BaseIntlComposer;
6
+
7
+ class IntlComposer extends BaseIntlComposer
8
+ {
9
+ protected $namespaces = ['*'];
10
+ }
@@ -0,0 +1,48 @@
1
+ <?php
2
+
3
+ namespace App\Composers;
4
+
5
+ use Illuminate\Http\Request;
6
+ use Illuminate\View\View;
7
+ use Illuminate\Http\Resources\Json\JsonResource;
8
+
9
+ class MetaComposer
10
+ {
11
+ /**
12
+ * The request
13
+ *
14
+ * @var \Illuminate\Http\Request
15
+ */
16
+ protected $request;
17
+
18
+ /**
19
+ * Create a new profile composer.
20
+ *
21
+ * @param \Illuminate\Http\Request $request
22
+ * @return void
23
+ */
24
+ public function __construct(Request $request)
25
+ {
26
+ $this->request = $request;
27
+ }
28
+
29
+ /**
30
+ * Bind data to the view.
31
+ *
32
+ * @param View $view
33
+ * @return void
34
+ */
35
+ public function compose(View $view)
36
+ {
37
+ $locale = $this->request->locale();
38
+ $view->title = trans('meta.title');
39
+ $view->description = trans('meta.description');
40
+ $view->image = asset(trans('meta.image'));
41
+ $view->url = $this->request->url();
42
+ $view->canonical = $this->request->url();
43
+ $view->siteName = trans('meta.siteName');
44
+ $view->appId = config('services.facebook.client_id');
45
+
46
+ $page = $view->page instanceof JsonResource ? $view->page->resource : $view->page;
47
+ }
48
+ }
@@ -0,0 +1,19 @@
1
+ <?php
2
+
3
+ namespace App\Composers;
4
+
5
+ use Illuminate\View\View;
6
+ use Illuminate\Http\Request;
7
+ use Illuminate\Routing\Router;
8
+ use Folklore\Composers\RoutesComposer as BaseRoutesComposer;
9
+
10
+ class RoutesComposer extends BaseRoutesComposer
11
+ {
12
+ protected $routes = [];
13
+
14
+ protected $routesLocalized = [
15
+ 'home',
16
+ ];
17
+
18
+ protected $withoutParametersPatterns = true;
19
+ }
@@ -0,0 +1,17 @@
1
+ <?php
2
+
3
+ namespace App\Contracts\Repositories;
4
+
5
+ use Folklore\Contracts\Repositories\Users as BaseUsers;
6
+ use App\Contracts\Resources\User as UserResource;
7
+
8
+ interface Users extends BaseUsers
9
+ {
10
+ public function findById(string $id): ?UserResource;
11
+
12
+ public function findByEmail(string $email): ?UserResource;
13
+
14
+ public function create($data): UserResource;
15
+
16
+ public function update(string $id, $data): ?UserResource;
17
+ }