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.
- package/lib/generators/build/index.js +1 -1
- package/lib/generators/eslint/index.js +1 -1
- package/lib/generators/intl/index.js +93 -0
- package/lib/generators/laravel-mediatheque/index.js +151 -0
- package/lib/generators/laravel-mediatheque/instructions/ServiceProvider.php +26 -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 +89 -28
- package/lib/generators/laravel-panneau/instructions/ServiceProvider.php +21 -0
- package/lib/generators/laravel-panneau/instructions/config.php +13 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +19 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Image.php +15 -0
- package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +12 -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 +4 -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/{Schemas → Panneau}/Fields/.gitkeep +0 -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 +10 -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/Http/Resources/UsersCollection.php +10 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +74 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Policies/PanneauPolicy.php +32 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/ImageBlock.php +30 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +28 -0
- package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +45 -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/ImageBlock.php +27 -0
- package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +19 -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/config.php +29 -0
- package/lib/generators/laravel-panneau/templates/index.js +32 -0
- package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +66 -0
- package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +66 -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/resources/assets/js/components/panneau/fields/PageSlug.jsx +68 -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 +519 -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/Repositories/Users.php +17 -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 +20 -0
- package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +120 -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 +37 -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/image.php +204 -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/prettier/index.js +1 -1
- package/lib/generators/react-app/index.js +2 -2
- 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/generators/stylelint/index.js +1 -1
- package/lib/lib/generator.js +9 -0
- package/package.json +5 -4
- 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
@@ -32,7 +32,7 @@ module.exports = class EslintGenerator extends _generator.default {
|
|
32
32
|
},
|
33
33
|
|
34
34
|
dependencies() {
|
35
|
-
this.addDevDependencies(['babel-preset-airbnb', '@babel/eslint-parser', 'eslint', 'eslint-config-airbnb', 'eslint-config-prettier', 'eslint-plugin-prettier', 'eslint-plugin-import', 'eslint-plugin-jsx-a11y', 'eslint-plugin-react', 'eslint-plugin-formatjs']);
|
35
|
+
this.addDevDependencies(['babel-preset-airbnb@^5.0.0', '@babel/eslint-parser@^7.0.0', 'eslint@^8.0.0', 'eslint-config-airbnb@^19.0.0', 'eslint-config-prettier@^8.0.0', 'eslint-plugin-prettier@^4.0.0', 'eslint-plugin-import@^2.0.0', 'eslint-plugin-jsx-a11y@^6.0.0', 'eslint-plugin-react@^7.0.0', 'eslint-plugin-formatjs@^4.0.0']);
|
36
36
|
}
|
37
37
|
|
38
38
|
};
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
4
|
+
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
6
|
+
|
7
|
+
var _generator = _interopRequireDefault(require("../../lib/generator"));
|
8
|
+
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
|
11
|
+
module.exports = class IntlGenerator extends _generator.default {
|
12
|
+
constructor(...args) {
|
13
|
+
super(...args);
|
14
|
+
this.option('translations-path', {
|
15
|
+
type: String,
|
16
|
+
desc: 'Path for to search for translations',
|
17
|
+
defaults: './src/**/*.{js,jsx}'
|
18
|
+
});
|
19
|
+
this.option('locales', {
|
20
|
+
type: String,
|
21
|
+
desc: 'Supported locales',
|
22
|
+
defaults: 'fr,en'
|
23
|
+
});
|
24
|
+
this.option('output-path', {
|
25
|
+
type: String,
|
26
|
+
desc: 'Path to output locale files',
|
27
|
+
defaults: './locale'
|
28
|
+
});
|
29
|
+
this.option('json-path', {
|
30
|
+
type: String,
|
31
|
+
desc: 'Path to copy json files'
|
32
|
+
});
|
33
|
+
this.option('without-id-only', {
|
34
|
+
type: String,
|
35
|
+
desc: 'Extract only messages without id',
|
36
|
+
defaults: false
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
get prompting() {
|
41
|
+
return {
|
42
|
+
welcome() {
|
43
|
+
if (this.options.quiet) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
console.log(_chalk.default.yellow('\n----------------------'));
|
48
|
+
console.log('Intl Generator');
|
49
|
+
console.log(_chalk.default.yellow('----------------------\n'));
|
50
|
+
}
|
51
|
+
|
52
|
+
};
|
53
|
+
}
|
54
|
+
|
55
|
+
get writing() {
|
56
|
+
return {
|
57
|
+
packageJSON() {
|
58
|
+
const {
|
59
|
+
'translations-path': translationsPath = null,
|
60
|
+
'output-path': outputPath = null,
|
61
|
+
'json-path': jsonPath = null,
|
62
|
+
'without-id-only': withoutIdOnly = false,
|
63
|
+
locales
|
64
|
+
} = this.options;
|
65
|
+
const intlCommand = `flklr intl --po${withoutIdOnly ? ' --without-id-only' : ''} --output-path$ '${outputPath}' '${translationsPath}'`;
|
66
|
+
this.packageJson.merge({
|
67
|
+
scripts: jsonPath !== null ? {
|
68
|
+
intl: 'npm run intl:build && npm run intl:copy',
|
69
|
+
'intl:build': intlCommand,
|
70
|
+
'intl:copy': `cp ${_path.default.join(outputPath, '*.json')} ${jsonPath}`
|
71
|
+
} : {
|
72
|
+
intl: intlCommand
|
73
|
+
},
|
74
|
+
supportedLocales: locales.split(',')
|
75
|
+
});
|
76
|
+
},
|
77
|
+
|
78
|
+
dependencies() {
|
79
|
+
this.addDevDependencies(['@folklore/cli@^0.0.47']);
|
80
|
+
}
|
81
|
+
|
82
|
+
};
|
83
|
+
}
|
84
|
+
|
85
|
+
async install() {
|
86
|
+
if (this.options['skip-install']) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
|
90
|
+
await this.spawnCommand('npm', ['install']);
|
91
|
+
}
|
92
|
+
|
93
|
+
};
|
@@ -0,0 +1,151 @@
|
|
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 _path = _interopRequireDefault(require("path"));
|
10
|
+
|
11
|
+
var _generator = _interopRequireDefault(require("../../lib/generator"));
|
12
|
+
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
+
|
15
|
+
module.exports = class LaravelMediathequeGenerator extends _generator.default {
|
16
|
+
constructor(...args) {
|
17
|
+
super(...args);
|
18
|
+
this.argument('project-name', {
|
19
|
+
type: String,
|
20
|
+
required: false
|
21
|
+
});
|
22
|
+
this.argument('overrides', {
|
23
|
+
type: Boolean,
|
24
|
+
required: false,
|
25
|
+
default: false
|
26
|
+
});
|
27
|
+
this.argument('skip-publish', {
|
28
|
+
type: Boolean,
|
29
|
+
required: false,
|
30
|
+
default: false
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
get prompting() {
|
35
|
+
return {
|
36
|
+
welcome() {
|
37
|
+
if (this.options.quiet) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
|
41
|
+
console.log(_chalk.default.yellow('\n----------------------'));
|
42
|
+
console.log('Laravel Mediatheque Generator');
|
43
|
+
console.log(_chalk.default.yellow('----------------------\n'));
|
44
|
+
},
|
45
|
+
|
46
|
+
prompts() {
|
47
|
+
const prompts = [];
|
48
|
+
|
49
|
+
if (!this.options['project-name']) {
|
50
|
+
prompts.push(_generator.default.prompts.project_name);
|
51
|
+
}
|
52
|
+
|
53
|
+
if (!prompts.length) {
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
|
57
|
+
return this.prompt(prompts).then(answers => {
|
58
|
+
if (answers['project-name']) {
|
59
|
+
this.options['project-name'] = answers['project-name'];
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
get writing() {
|
68
|
+
return {
|
69
|
+
composerJSON() {
|
70
|
+
this.composerJson.merge({
|
71
|
+
require: {
|
72
|
+
'folklore/laravel-folklore': 'v1.x-dev',
|
73
|
+
'folklore/laravel-mediatheque': 'v1.1.x-dev'
|
74
|
+
}
|
75
|
+
});
|
76
|
+
},
|
77
|
+
|
78
|
+
files() {
|
79
|
+
if (!this.options.overrides) {
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
|
83
|
+
const folders = ['app'];
|
84
|
+
folders.forEach(folder => {
|
85
|
+
const templatePath = this.templatePath(folder);
|
86
|
+
const destinationPath = this.destinationPath(folder);
|
87
|
+
|
88
|
+
_glob.default.sync('**', {
|
89
|
+
dot: true,
|
90
|
+
nodir: true,
|
91
|
+
cwd: templatePath
|
92
|
+
}).forEach(file => {
|
93
|
+
const source = _path.default.join(templatePath, file);
|
94
|
+
|
95
|
+
const destination = _path.default.join(destinationPath, file);
|
96
|
+
|
97
|
+
if (file.match(/\.(jpg|jpeg|gif|png)$/i)) {
|
98
|
+
this.fs.copy(source, destination);
|
99
|
+
} else {
|
100
|
+
this.fs.copyTpl(source, destination, {
|
101
|
+
project_name: this.options['project-name']
|
102
|
+
});
|
103
|
+
}
|
104
|
+
});
|
105
|
+
});
|
106
|
+
}
|
107
|
+
|
108
|
+
};
|
109
|
+
}
|
110
|
+
|
111
|
+
get install() {
|
112
|
+
return {
|
113
|
+
composer() {
|
114
|
+
if (this.options['skip-install']) {
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
|
118
|
+
const done = this.async();
|
119
|
+
this.spawnCommand('composer', ['install']).on('close', done);
|
120
|
+
},
|
121
|
+
|
122
|
+
async vendorPublish() {
|
123
|
+
if (this.options['skip-publish']) {
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
|
127
|
+
await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Folklore\\Mediatheque\\ServiceProvider']);
|
128
|
+
}
|
129
|
+
|
130
|
+
};
|
131
|
+
}
|
132
|
+
|
133
|
+
end() {
|
134
|
+
if (this.options.quiet) {
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
|
138
|
+
console.log('\n\n');
|
139
|
+
console.log(_chalk.default.yellow('\n----------------------'));
|
140
|
+
console.log(_chalk.default.bold('Instructions'));
|
141
|
+
console.log(_chalk.default.yellow('----------------------\n\n'));
|
142
|
+
console.log(`1. Add to ${_chalk.default.bold.yellow('app/Providers/AppServiceProvider.php')}:`);
|
143
|
+
const serviceProvider = fs.readFileSync(_path.default.join(__dirname, './instructions/ServiceProvider.php'));
|
144
|
+
console.log('---');
|
145
|
+
console.log(highlight(serviceProvider.toString('utf-8'), {
|
146
|
+
language: 'php',
|
147
|
+
ignoreIllegals: true
|
148
|
+
}));
|
149
|
+
}
|
150
|
+
|
151
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class AppServiceProvider extends ServiceProvider
|
4
|
+
{
|
5
|
+
//...
|
6
|
+
public function register()
|
7
|
+
{
|
8
|
+
// ...
|
9
|
+
|
10
|
+
$this->registerMediatheque();
|
11
|
+
}
|
12
|
+
|
13
|
+
protected function registerMediatheque()
|
14
|
+
{
|
15
|
+
$this->app->bind(
|
16
|
+
\Folklore\Mediatheque\Contracts\Models\Media::class,
|
17
|
+
\App\Models\Media::class
|
18
|
+
);
|
19
|
+
|
20
|
+
$this->app->bind(
|
21
|
+
\Folklore\Mediatheque\Contracts\Models\File::class,
|
22
|
+
\App\Models\MediaFile::class
|
23
|
+
);
|
24
|
+
}
|
25
|
+
//...
|
26
|
+
}
|
@@ -1,11 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
4
|
-
|
5
3
|
var _chalk = _interopRequireDefault(require("chalk"));
|
6
4
|
|
5
|
+
var _cliHighlight = require("cli-highlight");
|
6
|
+
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
8
|
+
|
7
9
|
var _glob = _interopRequireDefault(require("glob"));
|
8
10
|
|
11
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
12
|
+
|
9
13
|
var _path = _interopRequireDefault(require("path"));
|
10
14
|
|
11
15
|
var _generator = _interopRequireDefault(require("../../lib/generator"));
|
@@ -19,11 +23,6 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
|
|
19
23
|
type: String,
|
20
24
|
required: false
|
21
25
|
});
|
22
|
-
this.option('install-npm', {
|
23
|
-
type: Boolean,
|
24
|
-
desc: 'Install NPM dependencies',
|
25
|
-
defaults: false
|
26
|
-
});
|
27
26
|
}
|
28
27
|
|
29
28
|
get prompting() {
|
@@ -62,24 +61,42 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
|
|
62
61
|
get writing() {
|
63
62
|
return {
|
64
63
|
composerJSON() {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
this.composerJson.merge({
|
65
|
+
require: {
|
66
|
+
'folklore/laravel-panneau': 'v1.2.x-dev'
|
67
|
+
}
|
68
|
+
});
|
70
69
|
},
|
71
70
|
|
72
71
|
packageJSON() {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
this.
|
72
|
+
this.addDependencies(['@panneau/app@^1.0.3-alpha.1', '@panneau/core@^1.0.3-alpha.1', '@panneau/data@^1.0.3-alpha.1', '@panneau/field-text@^1.0.3-alpha.1', '@panneau/field-localized@^1.0.3-alpha.1']);
|
73
|
+
},
|
74
|
+
|
75
|
+
config() {
|
76
|
+
const source = this.templatePath('config.php');
|
77
|
+
const destination = this.destinationPath('config/panneau.php');
|
78
|
+
|
79
|
+
if (this.fs.exists(destination)) {
|
80
|
+
this.fs.delete(destination);
|
81
|
+
}
|
82
|
+
|
83
|
+
this.fs.copyTpl(source, destination, {});
|
84
|
+
},
|
85
|
+
|
86
|
+
routes() {
|
87
|
+
const source = this.templatePath('routes.php');
|
88
|
+
const destination = this.destinationPath('routes/panneau.php');
|
89
|
+
|
90
|
+
if (this.fs.exists(destination)) {
|
91
|
+
this.fs.delete(destination);
|
92
|
+
}
|
93
|
+
|
94
|
+
this.fs.copyTpl(source, destination, {});
|
78
95
|
},
|
79
96
|
|
80
97
|
layout() {
|
81
98
|
const source = this.templatePath('layout.blade.php');
|
82
|
-
const destination = this.destinationPath('resources/views/vendor/panneau/
|
99
|
+
const destination = this.destinationPath('resources/views/vendor/panneau/layout.blade.php');
|
83
100
|
|
84
101
|
if (this.fs.exists(destination)) {
|
85
102
|
this.fs.delete(destination);
|
@@ -88,8 +105,25 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
|
|
88
105
|
this.fs.copyTpl(source, destination, {});
|
89
106
|
},
|
90
107
|
|
108
|
+
app() {
|
109
|
+
const source = this.templatePath('app.blade.php');
|
110
|
+
const destination = this.destinationPath('resources/views/vendor/panneau/app.blade.php');
|
111
|
+
|
112
|
+
if (this.fs.exists(destination)) {
|
113
|
+
this.fs.delete(destination);
|
114
|
+
}
|
115
|
+
|
116
|
+
this.fs.copyTpl(source, destination, {});
|
117
|
+
},
|
118
|
+
|
119
|
+
indexJs() {
|
120
|
+
const source = this.templatePath('index.js');
|
121
|
+
const destination = this.destinationPath('resources/assets/js/index.js');
|
122
|
+
this.fs.copyTpl(source, destination, {});
|
123
|
+
},
|
124
|
+
|
91
125
|
files() {
|
92
|
-
const folders = ['app', 'resources'];
|
126
|
+
const folders = ['app', 'resources', 'lang'];
|
93
127
|
folders.forEach(folder => {
|
94
128
|
const templatePath = this.templatePath(folder);
|
95
129
|
const destinationPath = this.destinationPath(folder);
|
@@ -119,33 +153,60 @@ module.exports = class LaravelPanneauGenerator extends _generator.default {
|
|
119
153
|
|
120
154
|
get install() {
|
121
155
|
return {
|
122
|
-
|
156
|
+
async npm() {
|
123
157
|
if (this.options['skip-install']) {
|
124
158
|
return;
|
125
159
|
}
|
126
160
|
|
127
|
-
|
128
|
-
this.spawnCommand('composer', ['install']).on('close', done);
|
161
|
+
await this.spawnCommand('npm', ['install']);
|
129
162
|
},
|
130
163
|
|
131
|
-
|
164
|
+
async composer() {
|
132
165
|
if (this.options['skip-install']) {
|
133
166
|
return;
|
134
167
|
}
|
135
168
|
|
136
|
-
|
137
|
-
this.spawnCommand('php', ['artisan', 'vendor:publish', '--all']).on('close', done);
|
169
|
+
await this.spawnCommand('composer', ['install']);
|
138
170
|
},
|
139
171
|
|
140
|
-
|
141
|
-
if (this.options['skip-install']
|
172
|
+
async vendorPublish() {
|
173
|
+
if (this.options['skip-install']) {
|
142
174
|
return;
|
143
175
|
}
|
144
176
|
|
145
|
-
this.
|
177
|
+
await this.spawnCommand('php', ['artisan', 'vendor:publish', '--provider=Panneau\\ServiceProvider']);
|
146
178
|
}
|
147
179
|
|
148
180
|
};
|
149
181
|
}
|
150
182
|
|
183
|
+
end() {
|
184
|
+
if (this.options.quiet) {
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
|
188
|
+
console.log('\n\n');
|
189
|
+
console.log(_chalk.default.yellow('\n----------------------'));
|
190
|
+
console.log(_chalk.default.bold('Instructions'));
|
191
|
+
console.log(_chalk.default.yellow('----------------------\n\n'));
|
192
|
+
console.log(`1. Add to ${_chalk.default.bold.yellow('app/Providers/AppServiceProvider.php')}:`);
|
193
|
+
|
194
|
+
const serviceProvider = _fs.default.readFileSync(_path.default.join(__dirname, './instructions/ServiceProvider.php'));
|
195
|
+
|
196
|
+
console.log('---');
|
197
|
+
console.log((0, _cliHighlight.highlight)(serviceProvider.toString('utf-8'), {
|
198
|
+
language: 'php',
|
199
|
+
ignoreIllegals: true
|
200
|
+
}));
|
201
|
+
console.log(`\n2. Add to ${_chalk.default.bold.yellow('config/app.php')}:`);
|
202
|
+
|
203
|
+
const config = _fs.default.readFileSync(_path.default.join(__dirname, './instructions/config.php'));
|
204
|
+
|
205
|
+
console.log('---');
|
206
|
+
console.log((0, _cliHighlight.highlight)(config.toString('utf-8'), {
|
207
|
+
language: 'php',
|
208
|
+
ignoreIllegals: true
|
209
|
+
}));
|
210
|
+
}
|
211
|
+
|
151
212
|
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class AppServiceProvider extends ServiceProvider
|
4
|
+
{
|
5
|
+
//...
|
6
|
+
protected function registerRepositories()
|
7
|
+
{
|
8
|
+
//...
|
9
|
+
|
10
|
+
$this->app->bind(
|
11
|
+
\Folklore\Contracts\Repositories\Pages::class,
|
12
|
+
\App\Repositories\Pages::class
|
13
|
+
);
|
14
|
+
|
15
|
+
$this->app->bind(
|
16
|
+
\App\Contracts\Repositories\Pages::class,
|
17
|
+
\App\Repositories\Pages::class
|
18
|
+
);
|
19
|
+
}
|
20
|
+
//...
|
21
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Contracts\Repositories;
|
4
|
+
|
5
|
+
use Folklore\Contracts\Repositories\Pages as BasePages;
|
6
|
+
use App\Contracts\Resources\Page as PageResource;
|
7
|
+
|
8
|
+
interface Pages extends BasePages
|
9
|
+
{
|
10
|
+
public function findById(string $id): ?PageResource;
|
11
|
+
|
12
|
+
public function findByHandle(string $handle): ?PageResource;
|
13
|
+
|
14
|
+
public function findBySlug(string $slug, string $locale = null): ?PageResource;
|
15
|
+
|
16
|
+
public function create($data): PageResource;
|
17
|
+
|
18
|
+
public function update(string $id, $data): ?PageResource;
|
19
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Contracts\Resources\Blocks;
|
4
|
+
|
5
|
+
use App\Contracts\Resources\Block as BaseBlock;
|
6
|
+
use Folklore\Contracts\Resources\Image as ImageContract;
|
7
|
+
|
8
|
+
interface Image extends BaseBlock
|
9
|
+
{
|
10
|
+
public function image(): ?ImageContract;
|
11
|
+
|
12
|
+
public function caption(string $locale): ?string;
|
13
|
+
|
14
|
+
public function credits(string $locale): ?string;
|
15
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace App\Http\Resources;
|
4
|
+
|
5
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
6
|
+
use App\Contracts\Resources\HasBlocks;
|
7
|
+
use Folklore\Http\Resources\LocalizedResource;
|
8
|
+
use App\Contracts\Resources\Blocks\Text as TextBlock;
|
9
|
+
|
10
|
+
class BlockResource 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
|
+
$type = $this->type();
|
21
|
+
$locale = $request->locale();
|
22
|
+
return [
|
23
|
+
'id' => $this->id(),
|
24
|
+
'type' => $type,
|
25
|
+
'blocks' => $this->when($this->resource instanceof HasBlocks, function () {
|
26
|
+
$blocks = $this->blocks();
|
27
|
+
return !is_null($blocks) ? new BlocksCollection($blocks) : [];
|
28
|
+
}),
|
29
|
+
|
30
|
+
$this->mergeWhen($this->resource instanceof TextBlock, function () use ($locale) {
|
31
|
+
return [
|
32
|
+
'body' => $this->body($locale),
|
33
|
+
];
|
34
|
+
}),
|
35
|
+
];
|
36
|
+
}
|
37
|
+
}
|