generator-folklore 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/generators/intl/index.js +93 -0
- package/lib/generators/laravel-mediatheque/index.js +133 -0
- package/lib/generators/laravel-mediatheque/templates/app/Models/Media.php +9 -0
- package/lib/generators/laravel-mediatheque/templates/app/Models/MediaFile.php +9 -0
- package/lib/generators/laravel-panneau/index.js +49 -28
- package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +19 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Page.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Pages/Home.php +9 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +37 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +8 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +47 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PagesCollection.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Models/Block.php +3 -13
- package/lib/generators/laravel-panneau/templates/app/Models/Page.php +3 -60
- package/lib/generators/laravel-panneau/templates/app/Panneau/Composers/AppComposer.php +50 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Block.php +22 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Blocks.php +87 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Page.php +51 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlug.php +34 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlugLocalized.php +18 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/AccountController.php +41 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/Controller.php +19 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/HomeController.php +16 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/PagesController.php +24 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UploadController.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Controllers/UsersController.php +32 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/AccountUpdateRequest.php +29 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Requests/UploadRequest.php +29 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlockResource.php +39 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +8 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php +56 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PagesCollection.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UserResource.php +24 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +48 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Policies/PanneauPolicy.php +32 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php +110 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +42 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +28 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +92 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Users.php +57 -0
- package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +42 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +14 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Page.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Pages/HomePage.php +10 -0
- package/lib/generators/laravel-panneau/templates/app.blade.php +8 -0
- package/lib/generators/laravel-panneau/templates/index.js +32 -0
- package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +62 -0
- package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +62 -0
- package/lib/generators/laravel-panneau/templates/layout.blade.php +17 -48
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/Panneau.jsx +68 -0
- package/lib/generators/laravel-panneau/templates/{app/Schemas/Fields/.gitkeep → resources/assets/js/components/panneau/fields/PageSlug.jsx} +0 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlugLocalized.jsx +43 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/index.js +2 -0
- package/lib/generators/laravel-panneau/templates/resources/assets/styles/panneau.scss +2 -0
- package/lib/generators/laravel-panneau/templates/routes.php +30 -0
- package/lib/generators/laravel-project/index.js +504 -0
- package/lib/generators/laravel-project/templates/env +41 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/AppComposer.php +48 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/IntlComposer.php +10 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/MetaComposer.php +48 -0
- package/lib/generators/laravel-project/templates/laravel/app/Composers/RoutesComposer.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/app/Contracts/Resources/User.php +10 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Controllers/HomeController.php +18 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Middleware/TrustProxies.php +28 -0
- package/lib/generators/laravel-project/templates/laravel/app/Http/Resources/UserResource.php +21 -0
- package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +50 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +45 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/RouteServiceProvider.php +64 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/ViewServiceProvider.php +33 -0
- package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +36 -0
- package/lib/generators/laravel-project/templates/laravel/app/Resources/User.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/config/app.php +216 -0
- package/lib/generators/laravel-project/templates/laravel/config/auth.php +116 -0
- package/lib/generators/laravel-project/templates/laravel/config/services.php +39 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/content.php +5 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/errors.php +17 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/meta.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/lang/en/routes.php +4 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/auth.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/content.php +5 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/errors.php +17 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/meta.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/pagination.php +19 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/passwords.php +22 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/routes.php +12 -0
- package/lib/generators/laravel-project/templates/laravel/lang/fr/validation.php +146 -0
- package/lib/generators/laravel-project/templates/laravel/resources/assets/fonts/.gitkeep +0 -0
- package/lib/generators/laravel-project/templates/laravel/resources/assets/img/.gitkeep +0 -0
- package/lib/generators/laravel-project/templates/laravel/resources/assets/img/folklore.png +0 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/body.blade.php +3 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/gpt.blade.php +16 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/analytics/head.blade.php +1 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/app.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/401.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/403.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/404.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/errors/500.blade.php +8 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/layout.blade.php +33 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/all.blade.php +4 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/base.blade.php +11 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/facebook.blade.php +4 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/opengraph.blade.php +9 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/twitter.blade.php +5 -0
- package/lib/generators/laravel-project/templates/laravel/routes/web.php +12 -0
- package/lib/generators/react-app/templates/src/components/App.jsx +3 -2
- package/lib/generators/react-app/templates/src/components/pages/Error.jsx +2 -2
- package/lib/lib/generator.js +9 -0
- package/package.json +2 -2
- package/lib/generators/laravel-panneau/templates/_composer.json +0 -6
- package/lib/generators/laravel-panneau/templates/_package.json +0 -11
- package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/HomeController.php +0 -14
- package/lib/generators/laravel-panneau/templates/app/Http/Controllers/Panneau/PagesController.php +0 -11
- package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/File.php +0 -13
- package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Picture.php +0 -13
- package/lib/generators/laravel-panneau/templates/app/Models/Mediatheque/Video.php +0 -34
- package/lib/generators/laravel-panneau/templates/app/Providers/PanneauServiceProvider.php +0 -23
- package/lib/generators/laravel-panneau/templates/app/Reducers/SlugExtractReducer.php +0 -18
- package/lib/generators/laravel-panneau/templates/app/Resources/Pages.php +0 -54
- package/lib/generators/laravel-panneau/templates/app/Schemas/Blocks/Base.php +0 -22
- package/lib/generators/laravel-panneau/templates/app/Schemas/Bubbles/Base.php +0 -22
- package/lib/generators/laravel-panneau/templates/app/Schemas/Pages/Base.php +0 -36
- package/lib/generators/laravel-panneau/templates/resources/lang/en/panneau.php +0 -12
- package/lib/generators/laravel-panneau/templates/resources/lang/fr/panneau.php +0 -12
@@ -0,0 +1,68 @@
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import Panneau from '@panneau/app';
|
4
|
+
import { getCSRFHeaders } from '@folklore/fetch';
|
5
|
+
|
6
|
+
import { FIELDS_NAMESPACE } from '@panneau/core/contexts';
|
7
|
+
import * as fieldsComponents from './panneau/fields';
|
8
|
+
import * as AppPropTypes from '../lib/PropTypes';
|
9
|
+
|
10
|
+
import '../../styles/panneau.scss';
|
11
|
+
|
12
|
+
const propTypes = {
|
13
|
+
definition: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
14
|
+
baseUrl: PropTypes.string.isRequired,
|
15
|
+
uploadEndpoint: PropTypes.string,
|
16
|
+
user: AppPropTypes.user,
|
17
|
+
statusCode: AppPropTypes.statusCode,
|
18
|
+
};
|
19
|
+
|
20
|
+
const defaultProps = {
|
21
|
+
user: null,
|
22
|
+
uploadEndpoint: '/panneau/upload',
|
23
|
+
statusCode: null,
|
24
|
+
};
|
25
|
+
|
26
|
+
const PanneauContainer = ({ definition, user, baseUrl, uploadEndpoint, statusCode }) => {
|
27
|
+
const { routes = {} } = definition;
|
28
|
+
const isAuthorized = statusCode !== 401 && statusCode !== 403;
|
29
|
+
|
30
|
+
const [localeLoaded, setLocaleLoaded] = useState(false);
|
31
|
+
|
32
|
+
useEffect(() => {
|
33
|
+
let canceled = false;
|
34
|
+
import(`@panneau/intl/locale/${definition.intl.locale}`).then(() => {
|
35
|
+
if (!canceled) {
|
36
|
+
setLocaleLoaded(true);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
return () => {
|
40
|
+
canceled = true;
|
41
|
+
};
|
42
|
+
}, [definition]);
|
43
|
+
|
44
|
+
return localeLoaded ? (
|
45
|
+
<Panneau
|
46
|
+
definition={definition}
|
47
|
+
routes={routes}
|
48
|
+
user={isAuthorized ? user : null}
|
49
|
+
baseUrl={baseUrl}
|
50
|
+
uppy={{
|
51
|
+
transport: 'xhr',
|
52
|
+
xhr: {
|
53
|
+
endpoint: uploadEndpoint,
|
54
|
+
headers: getCSRFHeaders(),
|
55
|
+
timeout: 0,
|
56
|
+
},
|
57
|
+
}}
|
58
|
+
components={{
|
59
|
+
[FIELDS_NAMESPACE]: fieldsComponents,
|
60
|
+
}}
|
61
|
+
/>
|
62
|
+
) : null;
|
63
|
+
};
|
64
|
+
|
65
|
+
PanneauContainer.propTypes = propTypes;
|
66
|
+
PanneauContainer.defaultProps = defaultProps;
|
67
|
+
|
68
|
+
export default PanneauContainer;
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
2
|
+
import React, { useMemo } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import get from 'lodash/get';
|
5
|
+
import isEmpty from 'lodash/isEmpty';
|
6
|
+
import slugify from 'slugify';
|
7
|
+
import LocalizedField from '@panneau/field-localized';
|
8
|
+
import { useFormValue } from '@panneau/core/contexts';
|
9
|
+
|
10
|
+
const propTypes = {
|
11
|
+
value: PropTypes.objectOf(PropTypes.string),
|
12
|
+
locales: PropTypes.arrayOf(PropTypes.string),
|
13
|
+
};
|
14
|
+
|
15
|
+
const defaultProps = {
|
16
|
+
value: null,
|
17
|
+
locales: null,
|
18
|
+
};
|
19
|
+
|
20
|
+
const PageSlugField = ({ value, locales, ...props }) => {
|
21
|
+
const page = useFormValue();
|
22
|
+
const { title = null } = page || {};
|
23
|
+
const finalValue = useMemo(
|
24
|
+
() =>
|
25
|
+
locales.reduce(
|
26
|
+
(newValue, key) =>
|
27
|
+
newValue === null || isEmpty(newValue[key])
|
28
|
+
? {
|
29
|
+
...newValue,
|
30
|
+
[key]: slugify(get(title, key, '')),
|
31
|
+
}
|
32
|
+
: newValue,
|
33
|
+
value,
|
34
|
+
),
|
35
|
+
[locales, value, title],
|
36
|
+
);
|
37
|
+
return <LocalizedField value={finalValue} locales={locales} {...props} />;
|
38
|
+
};
|
39
|
+
|
40
|
+
PageSlugField.propTypes = propTypes;
|
41
|
+
PageSlugField.defaultProps = defaultProps;
|
42
|
+
|
43
|
+
export default PageSlugField;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
use Illuminate\Support\Facades\Route;
|
4
|
+
use Panneau\Support\Facade as Panneau;
|
5
|
+
|
6
|
+
Panneau::router()->group(function () {
|
7
|
+
$namePrefix = config('panneau.routes.name_prefix', config('panneau.routes.prefix') . '.');
|
8
|
+
|
9
|
+
Route::any('tus/{any?}', function () {
|
10
|
+
return app('tus-server')->serve();
|
11
|
+
})->where('any', '.*');
|
12
|
+
|
13
|
+
Panneau::router()->auth();
|
14
|
+
|
15
|
+
Route::namespace('\App\Panneau\Http\Controllers')
|
16
|
+
->middleware(['web', 'auth', 'can:view,' . \Panneau\Panneau::class])
|
17
|
+
->group(function () use ($namePrefix) {
|
18
|
+
Route::get('/', 'HomeController@index')->name($namePrefix . 'home');
|
19
|
+
|
20
|
+
Route::post('upload', 'UploadController@upload')->name($namePrefix . 'upload');
|
21
|
+
|
22
|
+
// Account
|
23
|
+
Route::get('account', 'AccountController@index')->name($namePrefix . 'account');
|
24
|
+
Route::post('account', 'AccountController@update')->name(
|
25
|
+
$namePrefix . 'account.update'
|
26
|
+
);
|
27
|
+
|
28
|
+
Panneau::router()->resources();
|
29
|
+
});
|
30
|
+
});
|
@@ -0,0 +1,504 @@
|
|
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
|
+
});
|
294
|
+
} // if (this.options.panneau) {
|
295
|
+
// this.composeWith('folklore:laravel-panneau', {
|
296
|
+
// 'project-name': this.options['project-name'],
|
297
|
+
// 'js-path': jsSrcPath,
|
298
|
+
// 'styles-path': stylesSrcPath,
|
299
|
+
// 'skip-install': skipInstall,
|
300
|
+
// 'install-npm': true,
|
301
|
+
// quiet: true,
|
302
|
+
// });
|
303
|
+
// }
|
304
|
+
// if (this.options.auth) {
|
305
|
+
// this.composeWith('folklore:laravel-auth', {
|
306
|
+
// 'project-name': this.options['project-name'],
|
307
|
+
// 'js-path': jsSrcPath,
|
308
|
+
// 'styles-path': stylesSrcPath,
|
309
|
+
// 'skip-install': skipInstall,
|
310
|
+
// 'install-npm': true,
|
311
|
+
// quiet: true,
|
312
|
+
// });
|
313
|
+
// }
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
get writing() {
|
318
|
+
return {
|
319
|
+
laravel() {
|
320
|
+
const done = this.async();
|
321
|
+
const {
|
322
|
+
'laravel-version': laravelVersion = null,
|
323
|
+
'laravel-branch': laravelBranch = null
|
324
|
+
} = this.options;
|
325
|
+
const versionBranch = laravelVersion !== 'latest' && laravelVersion !== null ? `${laravelVersion.indexOf('.') !== -1 ? laravelVersion : `${laravelVersion}.x`}` : null;
|
326
|
+
const branch = laravelBranch || versionBranch;
|
327
|
+
|
328
|
+
const remoteCallback = (err, cachePath) => {
|
329
|
+
const destinationPath = this.destinationPath();
|
330
|
+
|
331
|
+
const files = _glob.default.sync('**', {
|
332
|
+
dot: true,
|
333
|
+
nodir: true,
|
334
|
+
cwd: cachePath
|
335
|
+
});
|
336
|
+
|
337
|
+
let source;
|
338
|
+
let destination;
|
339
|
+
files.forEach(file => {
|
340
|
+
source = _path.default.join(cachePath, file);
|
341
|
+
destination = _path.default.join(destinationPath, file);
|
342
|
+
|
343
|
+
if (!this.fs.exists(destination)) {
|
344
|
+
this.fs.copy(source, destination);
|
345
|
+
}
|
346
|
+
});
|
347
|
+
done();
|
348
|
+
};
|
349
|
+
|
350
|
+
if (branch !== null) {
|
351
|
+
(0, _yeomanRemote.default)('laravel', 'laravel', branch, remoteCallback);
|
352
|
+
} else {
|
353
|
+
(0, _yeomanRemote.default)('laravel', 'laravel', remoteCallback);
|
354
|
+
}
|
355
|
+
},
|
356
|
+
|
357
|
+
removeFiles() {
|
358
|
+
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'];
|
359
|
+
files.forEach(file => {
|
360
|
+
const filePath = this.destinationPath(file);
|
361
|
+
this.fs.delete(filePath);
|
362
|
+
});
|
363
|
+
},
|
364
|
+
|
365
|
+
composerJSON() {
|
366
|
+
this.composerJson.merge({
|
367
|
+
require: {
|
368
|
+
'folklore/laravel-folklore': 'v1.x-dev',
|
369
|
+
'folklore/laravel-locale': 'v8.x-dev',
|
370
|
+
'folklore/laravel-image': 'v1.x-dev'
|
371
|
+
}
|
372
|
+
});
|
373
|
+
},
|
374
|
+
|
375
|
+
packageJSON() {
|
376
|
+
this.packageJson.merge({
|
377
|
+
scripts: {
|
378
|
+
clean: 'rm -rf public/static && rm -rf public/precache-*',
|
379
|
+
'build:scripts': 'flklr build --load-env ./resources/assets/js/index.js',
|
380
|
+
'build:views': 'php artisan assets:view',
|
381
|
+
build: 'npm run clean && npm run build:scripts && npm run build:views',
|
382
|
+
start: 'npm run server',
|
383
|
+
server: 'flklr serve --load-env ./resources/assets/js/index.js'
|
384
|
+
}
|
385
|
+
});
|
386
|
+
},
|
387
|
+
|
388
|
+
env() {
|
389
|
+
const url = _lodash.default.template(_lodash.default.get(this.options, 'url'))({
|
390
|
+
project_host: this.options['project-host'],
|
391
|
+
project_name: this.options['project-name']
|
392
|
+
}).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
|
393
|
+
|
394
|
+
const urlLocal = _lodash.default.template(_lodash.default.get(this.options, 'local-url'))({
|
395
|
+
project_host: this.options['project-host'],
|
396
|
+
project_name: this.options['project-name']
|
397
|
+
}).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
|
398
|
+
|
399
|
+
const urlProxy = _lodash.default.template(_lodash.default.get(this.options, 'proxy-url', _lodash.default.get(this.options, 'local-url')))({
|
400
|
+
project_host: this.options['project-host'],
|
401
|
+
project_name: this.options['project-name']
|
402
|
+
}).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
|
403
|
+
|
404
|
+
const templateData = {
|
405
|
+
project_name: this.options['project-name'],
|
406
|
+
db_host: this.options['db-host'],
|
407
|
+
db_username: this.options['db-username'],
|
408
|
+
db_password: this.options['db-password'],
|
409
|
+
db_name: this.options['db-name'],
|
410
|
+
url: urlLocal,
|
411
|
+
proxy_url: urlProxy
|
412
|
+
};
|
413
|
+
|
414
|
+
const prodTemplateData = _objectSpread(_objectSpread({}, templateData), {}, {
|
415
|
+
url,
|
416
|
+
db_username: this.options['db-name']
|
417
|
+
});
|
418
|
+
|
419
|
+
const src = this.templatePath('env');
|
420
|
+
const dest = this.destinationPath('.env');
|
421
|
+
this.fs.copyTpl(src, dest, templateData);
|
422
|
+
const srcExample = this.templatePath('env');
|
423
|
+
const destExample = this.destinationPath('.env.example');
|
424
|
+
this.fs.copyTpl(srcExample, destExample, templateData); // const srcProd = this.templatePath('env.prod');
|
425
|
+
// const destProd = this.destinationPath('.env.prod');
|
426
|
+
// this.fs.copyTpl(srcProd, destProd, prodTemplateData);
|
427
|
+
},
|
428
|
+
|
429
|
+
files() {
|
430
|
+
const templatePath = this.templatePath('laravel');
|
431
|
+
const destinationPath = this.destinationPath();
|
432
|
+
|
433
|
+
const files = _glob.default.sync('**', {
|
434
|
+
dot: true,
|
435
|
+
nodir: true,
|
436
|
+
cwd: templatePath
|
437
|
+
});
|
438
|
+
|
439
|
+
files.forEach(file => {
|
440
|
+
const source = _path.default.join(templatePath, file);
|
441
|
+
|
442
|
+
const destination = _path.default.join(destinationPath, file);
|
443
|
+
|
444
|
+
if (file.match(/\.php$/i)) {
|
445
|
+
this.fs.copyTpl(source, destination, {
|
446
|
+
options: this.options
|
447
|
+
});
|
448
|
+
} else {
|
449
|
+
this.fs.copy(source, destination);
|
450
|
+
}
|
451
|
+
});
|
452
|
+
}
|
453
|
+
|
454
|
+
};
|
455
|
+
}
|
456
|
+
|
457
|
+
get install() {
|
458
|
+
return {
|
459
|
+
async npm() {
|
460
|
+
if (this.options['skip-install']) {
|
461
|
+
return;
|
462
|
+
}
|
463
|
+
|
464
|
+
await this.spawnCommand('npm', ['install']);
|
465
|
+
},
|
466
|
+
|
467
|
+
async composer() {
|
468
|
+
if (this.options['skip-install']) {
|
469
|
+
return;
|
470
|
+
}
|
471
|
+
|
472
|
+
await this.spawnCommand('composer', ['install']);
|
473
|
+
},
|
474
|
+
|
475
|
+
async keyGenerate() {
|
476
|
+
if (this.options['skip-install']) {
|
477
|
+
return;
|
478
|
+
}
|
479
|
+
|
480
|
+
await this.spawnCommand('php', ['artisan', 'key:generate']);
|
481
|
+
},
|
482
|
+
|
483
|
+
async vendorPublish() {
|
484
|
+
if (this.options['skip-install']) {
|
485
|
+
return;
|
486
|
+
}
|
487
|
+
|
488
|
+
await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\ServiceProvider']);
|
489
|
+
await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\Locale\\LocaleServiceProvider']);
|
490
|
+
await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\Image\\ServiceProvider']);
|
491
|
+
},
|
492
|
+
|
493
|
+
async valet() {
|
494
|
+
if (this.options['skip-install']) {
|
495
|
+
return;
|
496
|
+
}
|
497
|
+
|
498
|
+
await this.spawnCommand('valet', ['link', '--secure', this.options['project-host']]);
|
499
|
+
}
|
500
|
+
|
501
|
+
};
|
502
|
+
}
|
503
|
+
|
504
|
+
};
|
@@ -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 %>
|