generator-folklore 3.0.8 → 3.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/Readme.md +11 -5
- package/lib/generators/app/index.js +3 -0
- package/lib/generators/intl/index.js +1 -1
- package/lib/generators/laravel-auth/templates/routes/auth.php +2 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Middleware/Authenticate.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +1 -3
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php +5 -5
- package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/ParentPageResource.php +43 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +16 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Users.php +2 -1
- package/lib/generators/laravel-panneau/templates/app/Resources/Block.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/ImageBlock.php +2 -2
- package/lib/generators/laravel-panneau/templates/app/Resources/Page.php +2 -2
- package/lib/generators/laravel-panneau/templates/routes.php +3 -1
- package/lib/generators/laravel-project/index.js +2 -2
- package/lib/generators/laravel-project/templates/laravel/app/Providers/TelescopeServiceProvider.php +67 -0
- package/lib/generators/laravel-project/templates/laravel/resources/views/assets/.gitignore +2 -0
- package/lib/generators/laravel-project/templates/laravel/routes/web.php +4 -1
- package/lib/generators/react-app/templates/src/components/Container.jsx +10 -8
- package/lib/generators/stylelint/index.js +1 -1
- package/package.json +2 -2
package/Readme.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# Folklore Generator
|
2
|
+
|
2
3
|
Yeoman generator to start projects at Folklore
|
3
4
|
|
4
5
|
## Install
|
6
|
+
|
5
7
|
```
|
6
8
|
npm install -g generator-folklore
|
7
9
|
```
|
8
10
|
|
9
11
|
## Usage
|
12
|
+
|
10
13
|
```
|
11
14
|
yo folklore
|
12
15
|
```
|
@@ -14,20 +17,23 @@ yo folklore
|
|
14
17
|
## Sub-Generators
|
15
18
|
|
16
19
|
```
|
17
|
-
yo folklore:laravel
|
20
|
+
yo folklore:laravel-project
|
18
21
|
```
|
19
|
-
|
22
|
+
|
23
|
+
Laravel boilerplate.
|
20
24
|
|
21
25
|
--
|
22
26
|
|
23
27
|
```
|
24
|
-
yo folklore:html
|
28
|
+
yo folklore:html-project
|
25
29
|
```
|
30
|
+
|
26
31
|
HTML static application
|
27
32
|
|
28
33
|
--
|
29
34
|
|
30
35
|
```
|
31
|
-
yo folklore:
|
36
|
+
yo folklore:node-project
|
32
37
|
```
|
33
|
-
|
38
|
+
|
39
|
+
Node package
|
@@ -62,7 +62,7 @@ module.exports = class IntlGenerator extends _generator.default {
|
|
62
62
|
'without-id-only': withoutIdOnly = false,
|
63
63
|
locales
|
64
64
|
} = this.options;
|
65
|
-
const intlCommand = `flklr intl --po${withoutIdOnly ? ' --without-id-only' : ''} --output-path
|
65
|
+
const intlCommand = `flklr intl --po${withoutIdOnly ? ' --without-id-only' : ''} --output-path '${outputPath}' '${translationsPath}'`;
|
66
66
|
this.packageJson.merge({
|
67
67
|
scripts: jsonPath !== null ? {
|
68
68
|
intl: 'npm run intl:build && npm run intl:copy',
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Http\Middleware;
|
4
|
+
|
5
|
+
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
6
|
+
|
7
|
+
class Authenticate extends Middleware
|
8
|
+
{
|
9
|
+
/**
|
10
|
+
* Get the path the user should be redirected to when they are not authenticated.
|
11
|
+
*
|
12
|
+
* @param \Illuminate\Http\Request $request
|
13
|
+
* @return string|null
|
14
|
+
*/
|
15
|
+
protected function redirectTo($request)
|
16
|
+
{
|
17
|
+
if (!$request->expectsJson()) {
|
18
|
+
$routeWithLocale =
|
19
|
+
route('panneau.auth.login') .
|
20
|
+
'?' .
|
21
|
+
http_build_query([
|
22
|
+
'next' => $request->fullUrl(),
|
23
|
+
]);
|
24
|
+
return $request->isPanneau() ? route('panneau.auth.login') : $routeWithLocale;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -30,9 +30,7 @@ class PageResource extends JsonResource
|
|
30
30
|
'slug' => $this->slug($locale),
|
31
31
|
'image' => !is_null($image) ? new MediaResource($image) : null,
|
32
32
|
'parent' =>
|
33
|
-
!is_null($parent) && $parent instanceof Page
|
34
|
-
? new PageResource($parent)
|
35
|
-
: null,
|
33
|
+
!is_null($parent) && $parent instanceof Page ? new PageResource($parent) : null,
|
36
34
|
|
37
35
|
$this->mergeWhen($this->resource instanceof HasBlocks, function () {
|
38
36
|
$blocks = $this->blocks();
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/PageResource.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
namespace App\Panneau\Http\Resources;
|
4
4
|
|
5
5
|
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
-
use
|
6
|
+
use Folklore\Http\Resources\MediaResource;
|
7
7
|
use App\Contracts\Resources\Page;
|
8
|
-
use
|
8
|
+
use Folklore\Contracts\Resources\HasBlocks;
|
9
9
|
use Folklore\Http\Resources\LocalizedResource;
|
10
10
|
use App\Contracts\Resources\Pages\Home as HomePage;
|
11
11
|
|
@@ -19,8 +19,8 @@ class PageResource extends JsonResource
|
|
19
19
|
*/
|
20
20
|
public function toArray($request)
|
21
21
|
{
|
22
|
-
$
|
23
|
-
$
|
22
|
+
$image = $this->image();
|
23
|
+
$parent = $this->parent();
|
24
24
|
|
25
25
|
return [
|
26
26
|
'id' => $this->id(),
|
@@ -35,7 +35,7 @@ class PageResource extends JsonResource
|
|
35
35
|
'slug' => new LocalizedResource(function ($locale) {
|
36
36
|
return $this->slug($locale);
|
37
37
|
}),
|
38
|
-
'image' => !is_null($image) ? new
|
38
|
+
'image' => !is_null($image) ? new MediaResource($image) : null,
|
39
39
|
'parent' =>
|
40
40
|
!is_null($parent) && $parent instanceof Page
|
41
41
|
? new ParentPageResource($parent)
|
package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/ParentPageResource.php
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Panneau\Http\Resources;
|
4
|
+
|
5
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
+
use Folklore\Http\Resources\MediaResource;
|
7
|
+
use App\Contracts\Resources\Page;
|
8
|
+
use Folklore\Http\Resources\LocalizedResource;
|
9
|
+
|
10
|
+
class ParentPageResource extends JsonResource
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* Transform the resource into an array.
|
14
|
+
*
|
15
|
+
* @param \Illuminate\Http\Request $request
|
16
|
+
* @return array
|
17
|
+
*/
|
18
|
+
public function toArray($request)
|
19
|
+
{
|
20
|
+
$image = $this->image();
|
21
|
+
$parent = $this->parent();
|
22
|
+
|
23
|
+
return [
|
24
|
+
'id' => $this->id(),
|
25
|
+
'type' => $this->type(),
|
26
|
+
'published' => $this->published(),
|
27
|
+
'title' => new LocalizedResource(function ($locale) {
|
28
|
+
return $this->title($locale);
|
29
|
+
}),
|
30
|
+
'description' => new LocalizedResource(function ($locale) {
|
31
|
+
return $this->description($locale);
|
32
|
+
}),
|
33
|
+
'slug' => new LocalizedResource(function ($locale) {
|
34
|
+
return $this->slug($locale);
|
35
|
+
}),
|
36
|
+
'image' => !is_null($image) ? new MediaResource($image) : null,
|
37
|
+
'parent' =>
|
38
|
+
!is_null($parent) && $parent instanceof Page
|
39
|
+
? new ParentPageResource($parent)
|
40
|
+
: null,
|
41
|
+
];
|
42
|
+
}
|
43
|
+
}
|
@@ -10,6 +10,11 @@ use Panneau\Support\LocalizedField;
|
|
10
10
|
use Folklore\Panneau\Fields\PageSlug as PageSlugField;
|
11
11
|
use Panneau\Support\Facade as Panneau;
|
12
12
|
|
13
|
+
use Illuminate\Http\Request;
|
14
|
+
use Laravel\Fortify\Fortify;
|
15
|
+
use Illuminate\Support\Facades\Hash;
|
16
|
+
use App\Models\User;
|
17
|
+
|
13
18
|
class PanneauServiceProvider extends BaseServiceProvider
|
14
19
|
{
|
15
20
|
/**
|
@@ -31,6 +36,7 @@ class PanneauServiceProvider extends BaseServiceProvider
|
|
31
36
|
{
|
32
37
|
$this->bootFields();
|
33
38
|
$this->bootViews();
|
39
|
+
$this->bootAuth();
|
34
40
|
}
|
35
41
|
|
36
42
|
protected function bootFields()
|
@@ -71,4 +77,14 @@ class PanneauServiceProvider extends BaseServiceProvider
|
|
71
77
|
$view->composer('errors::*', \App\Panneau\Composers\AppComposer::class);
|
72
78
|
});
|
73
79
|
}
|
80
|
+
|
81
|
+
protected function bootAuth()
|
82
|
+
{
|
83
|
+
Fortify::authenticateUsing(function (Request $request) {
|
84
|
+
$user = User::where('email', $request->email)->first();
|
85
|
+
if (!is_null($user) && Hash::check($request->password, $user->password)) {
|
86
|
+
return $user;
|
87
|
+
}
|
88
|
+
});
|
89
|
+
}
|
74
90
|
}
|
@@ -3,11 +3,11 @@
|
|
3
3
|
namespace App\Resources\Blocks;
|
4
4
|
|
5
5
|
use App\Resources\Block;
|
6
|
-
use App\Contracts\Resources\Blocks\
|
6
|
+
use App\Contracts\Resources\Blocks\Image as ImageBlockContract;
|
7
7
|
use Folklore\Contracts\Resources\Image as ImageContract;
|
8
8
|
use Folklore\Resources\Image;
|
9
9
|
|
10
|
-
class ImageBlock extends Block implements
|
10
|
+
class ImageBlock extends Block implements ImageBlockContract
|
11
11
|
{
|
12
12
|
public function image(): ?ImageContract
|
13
13
|
{
|
@@ -10,7 +10,9 @@ Panneau::router()->group(function () {
|
|
10
10
|
return app('tus-server')->serve();
|
11
11
|
})->where('any', '.*');
|
12
12
|
|
13
|
-
|
13
|
+
Route::middleware(['web'])->group(function () {
|
14
|
+
Panneau::router()->auth();
|
15
|
+
});
|
14
16
|
|
15
17
|
Route::namespace('\App\Panneau\Http\Controllers')
|
16
18
|
->middleware(['web', 'auth', 'can:view,' . \Panneau\Panneau::class])
|
@@ -297,7 +297,7 @@ module.exports = class LaravelProjectGenerator extends _generator.default {
|
|
297
297
|
if (this.options.panneau) {
|
298
298
|
this.composeWith('folklore:laravel-panneau', {
|
299
299
|
'project-name': this.options['project-name'],
|
300
|
-
'skip-install':
|
300
|
+
'skip-install': true,
|
301
301
|
quiet: true
|
302
302
|
});
|
303
303
|
} // if (this.options.auth) {
|
@@ -305,7 +305,7 @@ module.exports = class LaravelProjectGenerator extends _generator.default {
|
|
305
305
|
// 'project-name': this.options['project-name'],
|
306
306
|
// 'js-path': jsSrcPath,
|
307
307
|
// 'styles-path': stylesSrcPath,
|
308
|
-
// 'skip-install':
|
308
|
+
// 'skip-install': true,
|
309
309
|
// 'install-npm': true,
|
310
310
|
// quiet: true,
|
311
311
|
// });
|
package/lib/generators/laravel-project/templates/laravel/app/Providers/TelescopeServiceProvider.php
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Providers;
|
4
|
+
|
5
|
+
use Illuminate\Support\Facades\Gate;
|
6
|
+
use Laravel\Telescope\IncomingEntry;
|
7
|
+
use Laravel\Telescope\Telescope;
|
8
|
+
use Laravel\Telescope\TelescopeApplicationServiceProvider;
|
9
|
+
|
10
|
+
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* Register any application services.
|
14
|
+
*
|
15
|
+
* @return void
|
16
|
+
*/
|
17
|
+
public function register()
|
18
|
+
{
|
19
|
+
// Telescope::night();
|
20
|
+
|
21
|
+
$this->hideSensitiveRequestDetails();
|
22
|
+
|
23
|
+
Telescope::filter(function (IncomingEntry $entry) {
|
24
|
+
if ($this->app->environment('local')) {
|
25
|
+
return true;
|
26
|
+
}
|
27
|
+
|
28
|
+
return $entry->isReportableException() ||
|
29
|
+
$entry->isFailedRequest() ||
|
30
|
+
$entry->isFailedJob() ||
|
31
|
+
$entry->isScheduledTask() ||
|
32
|
+
$entry->hasMonitoredTag();
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Prevent sensitive request details from being logged by Telescope.
|
38
|
+
*
|
39
|
+
* @return void
|
40
|
+
*/
|
41
|
+
protected function hideSensitiveRequestDetails()
|
42
|
+
{
|
43
|
+
if ($this->app->environment('local')) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
Telescope::hideRequestParameters(['_token']);
|
48
|
+
|
49
|
+
Telescope::hideRequestHeaders(['cookie', 'x-csrf-token', 'x-xsrf-token']);
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Register the Telescope gate.
|
54
|
+
*
|
55
|
+
* This gate determines who can access Telescope in non-local environments.
|
56
|
+
*
|
57
|
+
* @return void
|
58
|
+
*/
|
59
|
+
protected function gate()
|
60
|
+
{
|
61
|
+
Gate::define('viewTelescope', function ($user) {
|
62
|
+
return in_array($user->email, [
|
63
|
+
//
|
64
|
+
]);
|
65
|
+
});
|
66
|
+
}
|
67
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<?php
|
2
2
|
|
3
|
+
use Illuminate\Support\Facades\Route;
|
3
4
|
use App\Http\Controllers\HomeController;
|
4
5
|
|
5
6
|
//Redirect to current langage home
|
@@ -8,5 +9,7 @@ Route::get('/', [HomeController::class, 'redirect'])->name('home');
|
|
8
9
|
Route::groupWithLocales(function () {
|
9
10
|
Route::getTrans('/', [HomeController::class, 'index'])->nameWithLocale('home');
|
10
11
|
Route::getTrans('/test', [HomeController::class, 'index'])->nameWithLocale('test');
|
11
|
-
Route::getTrans('/test/{with_param}', [HomeController::class, 'index'])->nameWithLocale(
|
12
|
+
Route::getTrans('/test/{with_param}', [HomeController::class, 'index'])->nameWithLocale(
|
13
|
+
'test_with_param'
|
14
|
+
);
|
12
15
|
});
|
@@ -8,21 +8,23 @@ import { BrowserRouter } from 'react-router-dom';
|
|
8
8
|
import App from './App';
|
9
9
|
|
10
10
|
const propTypes = {
|
11
|
-
|
12
|
-
|
13
|
-
PropTypes.
|
14
|
-
|
15
|
-
|
11
|
+
intl: PropTypes.shape({
|
12
|
+
locale: PropTypes.string,
|
13
|
+
messages: PropTypes.oneOfType([
|
14
|
+
PropTypes.objectOf(PropTypes.objectOf(PropTypes.string)),
|
15
|
+
PropTypes.objectOf(PropTypes.string),
|
16
|
+
]),
|
17
|
+
}),
|
16
18
|
routes: PropTypes.objectOf(PropTypes.string),
|
17
19
|
};
|
18
20
|
|
19
21
|
const defaultProps = {
|
20
|
-
|
21
|
-
messages: {},
|
22
|
+
intl: null,
|
22
23
|
routes: {},
|
23
24
|
};
|
24
25
|
|
25
|
-
function Container({
|
26
|
+
function Container({ intl, routes }) {
|
27
|
+
const { locale = null, messages = null } = intl || {};
|
26
28
|
return (
|
27
29
|
<IntlProvider locale={locale} messages={messages[locale] || messages}>
|
28
30
|
<BrowserRouter>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "generator-folklore",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.10",
|
4
4
|
"description": "Yeoman generator for projects at Folklore",
|
5
5
|
"keywords": [
|
6
6
|
"yeoman-generator"
|
@@ -40,5 +40,5 @@
|
|
40
40
|
"yeoman-generator": "^5.7.0",
|
41
41
|
"yeoman-remote": "^1.0.1"
|
42
42
|
},
|
43
|
-
"gitHead": "
|
43
|
+
"gitHead": "1d7f2e259b004828e208b643fb2d123aad8cc5ec"
|
44
44
|
}
|