generator-folklore 3.0.1 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/lib/generators/app/index.js +3 -51
  2. package/lib/generators/babel/index.js +28 -101
  3. package/lib/generators/babel/templates/config.js +16 -0
  4. package/lib/generators/browserslist/index.js +4 -9
  5. package/lib/generators/build/index.js +40 -29
  6. package/lib/generators/cli/index.js +92 -0
  7. package/lib/generators/cli/templates/cli.js +22 -0
  8. package/lib/generators/cli/templates/commands/default.js +16 -0
  9. package/lib/generators/docs/index.js +1 -2
  10. package/lib/generators/editorconfig/index.js +12 -22
  11. package/lib/generators/eslint/index.js +12 -13
  12. package/lib/generators/{html → html-project}/index.js +60 -73
  13. package/lib/generators/{html → html-project}/templates/folklore.png +0 -0
  14. package/lib/generators/{html → html-project}/templates/gitignore +0 -0
  15. package/lib/generators/{html → html-project}/templates/index.html.ejs +4 -1
  16. package/lib/generators/laravel/index.js +5 -5
  17. package/lib/generators/lerna-package/index.js +1 -3
  18. package/lib/generators/lerna-repository/index.js +1 -3
  19. package/lib/generators/node-project/index.js +164 -0
  20. package/lib/generators/{js/templates/src/lib/.gitkeep → node-project/templates/index.js} +0 -0
  21. package/lib/generators/npm-package/index.js +3 -5
  22. package/lib/generators/prettier/index.js +19 -6
  23. package/lib/generators/prettier/templates/prettierrc.json +3 -1
  24. package/lib/generators/{js → react-app}/index.js +22 -52
  25. package/lib/generators/{js → react-app}/templates/_package.json +0 -0
  26. package/lib/generators/react-app/templates/index.js +22 -0
  27. package/lib/generators/react-app/templates/src/components/App.jsx +42 -0
  28. package/lib/generators/react-app/templates/src/components/Routes.jsx +43 -0
  29. package/lib/generators/{js → react-app}/templates/src/components/buttons/Button.jsx +4 -18
  30. package/lib/generators/react-app/templates/src/components/layouts/Main.jsx +27 -0
  31. package/lib/generators/react-app/templates/src/components/menus/Menu.jsx +62 -0
  32. package/lib/generators/{js → react-app}/templates/src/components/pages/Error.jsx +8 -12
  33. package/lib/generators/react-app/templates/src/components/pages/Home.jsx +32 -0
  34. package/lib/generators/{js → react-app}/templates/src/components/partials/PageMeta.jsx +11 -11
  35. package/lib/generators/{js → react-app}/templates/src/contexts/KeysContext.jsx +0 -0
  36. package/lib/generators/{js/templates/styles → react-app/templates/src/lib}/.gitkeep +0 -0
  37. package/lib/generators/{js → react-app}/templates/src/lib/PropTypes.js +0 -0
  38. package/lib/generators/{js → react-app}/templates/src/lib/utils.js +0 -0
  39. package/lib/generators/react-app/templates/src/polyfills/index.js +6 -0
  40. package/lib/generators/react-app/templates/src/polyfills/intl-en.js +2 -0
  41. package/lib/generators/react-app/templates/src/polyfills/intl-fr.js +2 -0
  42. package/lib/generators/react-app/templates/src/polyfills/should.js +14 -0
  43. package/lib/generators/react-app/templates/styles/.gitkeep +0 -0
  44. package/lib/generators/{js/templates/styles/buttons/button.scss → react-app/templates/styles/buttons/button.module.scss} +1 -0
  45. package/lib/generators/{js/templates/styles/layouts/main.scss → react-app/templates/styles/layouts/main.module.scss} +0 -0
  46. package/lib/generators/{js/templates/styles/menus/menu.scss → react-app/templates/styles/menus/menu.module.scss} +0 -0
  47. package/lib/generators/{js/templates/styles/pages/error.scss → react-app/templates/styles/pages/error.module.scss} +0 -0
  48. package/lib/generators/{js/templates/styles/pages/home.scss → react-app/templates/styles/pages/home.module.scss} +0 -0
  49. package/lib/generators/rollup/index.js +54 -0
  50. package/lib/generators/rollup/templates/config.js +47 -0
  51. package/lib/generators/scss/index.js +3 -16
  52. package/lib/generators/scss/templates/{main.scss → styles.scss} +0 -0
  53. package/lib/generators/server/index.js +81 -0
  54. package/lib/generators/server/templates/server.js +59 -0
  55. package/lib/generators/storybook/index.js +1 -7
  56. package/lib/generators/stylelint/index.js +13 -14
  57. package/lib/lib/utils.js +17 -0
  58. package/package.json +2 -2
  59. package/lib/generators/babel/templates/babel-preset-react.js +0 -7
  60. package/lib/generators/babel/templates/babel-preset.js +0 -57
  61. package/lib/generators/babel/templates/babelrc +0 -5
  62. package/lib/generators/babel/templates/utils/processScss.js +0 -10
  63. package/lib/generators/babel/templates/utils/transformRequireIgnore.js +0 -80
  64. package/lib/generators/html/templates/index.js +0 -9
  65. package/lib/generators/html/templates/root.js +0 -23
  66. package/lib/generators/html/templates/utils.js +0 -7
  67. package/lib/generators/js/templates/browserslistrc +0 -9
  68. package/lib/generators/js/templates/config.js +0 -33
  69. package/lib/generators/js/templates/index.js +0 -41
  70. package/lib/generators/js/templates/src/actions/LayoutActions.js +0 -12
  71. package/lib/generators/js/templates/src/actions/SiteActions.js +0 -22
  72. package/lib/generators/js/templates/src/components/App.jsx +0 -52
  73. package/lib/generators/js/templates/src/components/Root.jsx +0 -70
  74. package/lib/generators/js/templates/src/components/layouts/Main.jsx +0 -52
  75. package/lib/generators/js/templates/src/components/menus/Menu.jsx +0 -60
  76. package/lib/generators/js/templates/src/components/messages/Success.jsx +0 -36
  77. package/lib/generators/js/templates/src/components/pages/Home.jsx +0 -32
  78. package/lib/generators/js/templates/src/components/partials/Label.jsx +0 -32
  79. package/lib/generators/js/templates/src/reducers/LayoutReducer.js +0 -32
  80. package/lib/generators/js/templates/src/reducers/SiteReducer.js +0 -36
  81. package/lib/generators/js/templates/src/reducers/index.js +0 -7
  82. package/lib/generators/js/templates/src/vendor/polyfills/intl-en.js +0 -2
  83. package/lib/generators/js/templates/src/vendor/polyfills/intl-fr.js +0 -2
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
3
5
  var _lodash = _interopRequireDefault(require("lodash"));
4
6
 
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
-
9
9
  var _generator = _interopRequireDefault(require("../../lib/generator"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
 
13
- module.exports = class HTMLGenerator extends _generator.default {
13
+ module.exports = class HTMLProjectGenerator extends _generator.default {
14
14
  // The name `constructor` is important here
15
15
  constructor(...args) {
16
16
  super(...args);
@@ -18,21 +18,11 @@ module.exports = class HTMLGenerator extends _generator.default {
18
18
  type: String,
19
19
  required: false
20
20
  });
21
- this.option('path', {
22
- type: String,
23
- desc: 'Path for the html project',
24
- defaults: './'
25
- });
26
21
  this.option('src-path', {
27
22
  type: String,
28
23
  desc: 'Path for source',
29
24
  defaults: './src'
30
25
  });
31
- this.option('tmp-path', {
32
- type: String,
33
- desc: 'Path for temp files',
34
- defaults: './.tmp'
35
- });
36
26
  this.option('dest-path', {
37
27
  type: String,
38
28
  desc: 'Path for build',
@@ -43,26 +33,11 @@ module.exports = class HTMLGenerator extends _generator.default {
43
33
  desc: 'Path for the javascript',
44
34
  defaults: ''
45
35
  });
46
- this.option('css-path', {
47
- type: String,
48
- desc: 'Path for the css',
49
- defaults: 'css'
50
- });
51
- this.option('scss-path', {
36
+ this.option('styles-path', {
52
37
  type: String,
53
38
  desc: 'Path for the scss',
54
39
  defaults: 'styles'
55
40
  });
56
- this.option('images-path', {
57
- type: String,
58
- desc: 'Path for the images',
59
- defaults: 'img'
60
- });
61
- this.option('build-path', {
62
- type: String,
63
- desc: 'Path for the build tools',
64
- defaults: 'build'
65
- });
66
41
  this.option('server', {
67
42
  type: Boolean,
68
43
  defaults: false,
@@ -70,7 +45,12 @@ module.exports = class HTMLGenerator extends _generator.default {
70
45
  });
71
46
  this.option('server-path', {
72
47
  type: String,
73
- desc: 'Path for the node.js server'
48
+ desc: 'Path for the node.js server',
49
+ defaults: ''
50
+ });
51
+ this.option('server-filename', {
52
+ type: String,
53
+ desc: 'Filename for the node.js server'
74
54
  });
75
55
 
76
56
  this.srcPath = filePath => this.destinationPath(_path.default.join(this.options['src-path'], filePath));
@@ -84,7 +64,7 @@ module.exports = class HTMLGenerator extends _generator.default {
84
64
  }
85
65
 
86
66
  console.log(_chalk.default.yellow('\n----------------------'));
87
- console.log('HTML Generator');
67
+ console.log('HTML Project Generator');
88
68
  console.log(_chalk.default.yellow('----------------------\n'));
89
69
  },
90
70
 
@@ -110,64 +90,75 @@ module.exports = class HTMLGenerator extends _generator.default {
110
90
  }
111
91
 
112
92
  configuring() {
113
- const projectName = _lodash.default.get(this.options, 'project-name');
114
-
115
- const projectPath = this.destinationPath();
116
-
117
- const srcPath = _lodash.default.get(this.options, 'src-path');
118
-
119
- const destPath = _lodash.default.get(this.options, 'dest-path');
120
-
121
- const buildPath = _lodash.default.get(this.options, 'build-path') || `${projectPath}/build`;
122
-
123
- const jsPath = _lodash.default.get(this.options, 'js-path');
124
-
125
- const jsSrcPath = _path.default.join(projectPath, srcPath, jsPath);
93
+ const {
94
+ 'project-name': projectName,
95
+ 'src-path': srcPath,
96
+ 'dest-path': destPath,
97
+ 'js-path': jsPath,
98
+ 'styles-path': stylesPath,
99
+ 'server-path': serverPath,
100
+ 'server-filename': serverFilename
101
+ } = this.options;
126
102
 
127
- const scssPath = _lodash.default.get(this.options, 'scss-path');
103
+ const jsSrcPath = _path.default.join(srcPath, jsPath);
128
104
 
129
- const scssSrcPath = _path.default.join(projectPath, srcPath, scssPath);
105
+ const stylesSrcPath = _path.default.join(srcPath, stylesPath);
130
106
 
131
- const skipInstall = _lodash.default.get(this.options, 'skip-install', false);
107
+ const serverSrcPath = _path.default.join(srcPath, serverPath);
132
108
 
133
- this.composeWith('folklore:js', {
134
- 'project-name': projectName,
135
- 'hot-reload': true,
136
- path: jsSrcPath,
137
- 'root-props-import': './data/root',
138
- 'skip-install': skipInstall,
109
+ this.composeWith('folklore:prettier', {
110
+ 'skip-install': true,
111
+ quiet: true
112
+ });
113
+ this.composeWith('folklore:eslint', {
114
+ 'skip-install': true,
115
+ quiet: true
116
+ });
117
+ this.composeWith('folklore:stylelint', {
118
+ 'skip-install': true,
119
+ quiet: true
120
+ });
121
+ this.composeWith('folklore:browserslist', {
122
+ 'skip-install': true,
139
123
  quiet: true
140
124
  });
141
125
  this.composeWith('folklore:editorconfig', {
142
126
  quiet: true
143
127
  });
128
+ this.composeWith('folklore:react-app', {
129
+ 'project-name': projectName,
130
+ path: jsSrcPath,
131
+ stylesPath: stylesSrcPath,
132
+ 'skip-install': true,
133
+ quiet: true
134
+ });
144
135
  this.composeWith('folklore:scss', {
145
136
  'project-name': projectName,
146
- path: scssSrcPath,
137
+ path: stylesSrcPath,
147
138
  react: true,
148
- 'skip-install': skipInstall,
139
+ 'skip-install': true,
149
140
  quiet: true
150
141
  });
151
142
 
152
143
  if (this.options.server) {
153
144
  this.composeWith('folklore:server', {
154
- 'project-name': projectName,
155
- path: _lodash.default.get(this.options, 'server-path') || `${projectPath}/server`,
156
- 'skip-install': skipInstall,
145
+ path: serverSrcPath,
146
+ filename: serverFilename,
147
+ 'skip-install': true,
157
148
  quiet: true
158
149
  });
159
150
  }
160
151
 
152
+ console.log(srcPath, jsSrcPath, _path.default.join(jsSrcPath, 'index.js'), _path.default.join(srcPath, 'index.html.ejs'));
161
153
  this.composeWith('folklore:build', {
162
- path: buildPath,
163
154
  'src-path': srcPath,
164
- 'entry-path': _path.default.join(srcPath, 'index'),
155
+ 'entry-path': _path.default.join(jsSrcPath, 'index.js'),
165
156
  'html-path': _path.default.join(srcPath, 'index.html.ejs'),
166
157
  'build-path': destPath,
167
158
  'empty-path': destPath,
168
159
  copy: true,
169
160
  'copy-path': _path.default.join(srcPath, '*.{html,ico,txt,png}'),
170
- 'skip-install': skipInstall,
161
+ 'skip-install': true,
171
162
  quiet: true
172
163
  });
173
164
  }
@@ -196,18 +187,6 @@ module.exports = class HTMLGenerator extends _generator.default {
196
187
  this.fs.copy(srcPath, destPath);
197
188
  },
198
189
 
199
- data() {
200
- const srcPath = this.templatePath('root.js');
201
- const destPath = this.srcPath('data/root.js');
202
- this.fs.copy(srcPath, destPath);
203
- },
204
-
205
- utils() {
206
- const srcPath = this.templatePath('utils.js');
207
- const destPath = this.srcPath('lib/utils.js');
208
- this.fs.copy(srcPath, destPath);
209
- },
210
-
211
190
  gitignore() {
212
191
  const srcPath = this.templatePath('gitignore');
213
192
  const destPath = this.destinationPath('.gitignore');
@@ -217,4 +196,12 @@ module.exports = class HTMLGenerator extends _generator.default {
217
196
  };
218
197
  }
219
198
 
199
+ async install() {
200
+ if (this.options['skip-install']) {
201
+ return;
202
+ }
203
+
204
+ await this.spawnCommand('npm', ['install']);
205
+ }
206
+
220
207
  };
@@ -18,6 +18,9 @@
18
18
  <meta property="og:url" content="">
19
19
  </head>
20
20
  <body>
21
- <div id="root"></div>
21
+ <script type="text/javascript">
22
+ var props = {};
23
+ </script>
24
+ <div id="app"></div>
22
25
  </body>
23
26
  </html>
@@ -250,7 +250,7 @@ module.exports = class LaravelGenerator extends _generator.default {
250
250
  project_name: this.options['project-name']
251
251
  }).replace(/^(http)?(s)?(:\/\/)?/, 'http$2://');
252
252
 
253
- this.composeWith('folklore:js', {
253
+ this.composeWith('folklore:react-app', {
254
254
  'project-name': this.options['project-name'],
255
255
  path: jsSrcPath,
256
256
  'styles-path': stylesSrcPath,
@@ -341,11 +341,11 @@ module.exports = class LaravelGenerator extends _generator.default {
341
341
  },
342
342
 
343
343
  packageJSON() {
344
- const jsonPath = this.destinationPath('package.json');
345
344
  const packageJSON = this.fs.exists(jsonPath) ? this.fs.readJSON(jsonPath) : {};
346
- packageJSON.scripts = {};
347
- packageJSON.devDependencies = {};
348
- this.fs.writeJSON(jsonPath, packageJSON);
345
+ this.packageJson.merge(_objectSpread(_objectSpread({}, packageJSON), {}, {
346
+ scripts: {},
347
+ devDependencies: {}
348
+ }));
349
349
  },
350
350
 
351
351
  composerJSON() {
@@ -160,7 +160,6 @@ module.exports = class LernaPackageGenerator extends _generator.default {
160
160
  type
161
161
  } = this.options;
162
162
  const srcPath = this.templatePath('_package.json');
163
- const destPath = this.packagePath('package.json');
164
163
  const packageJSON = this.fs.readJSON(srcPath);
165
164
  packageJSON.name = this.options['package-name'];
166
165
 
@@ -177,8 +176,7 @@ module.exports = class LernaPackageGenerator extends _generator.default {
177
176
  };
178
177
  }
179
178
 
180
- const currentPackageJSON = this.fs.exists(destPath) ? this.fs.readJSON(destPath) : {};
181
- this.fs.writeJSON(destPath, _lodash.default.merge(packageJSON, currentPackageJSON));
179
+ this.packageJson.merge(packageJSON);
182
180
  },
183
181
 
184
182
  webpackConfig() {
@@ -164,11 +164,9 @@ module.exports = class LernaRepositoryGenerator extends _generator.default {
164
164
 
165
165
  packageJSON() {
166
166
  const srcPath = this.templatePath('_package.json');
167
- const destPath = this.destinationPath('package.json');
168
167
  const packageJSON = this.fs.readJSON(srcPath);
169
168
  packageJSON.name = this.options['project-name'];
170
- const currentPackageJSON = this.fs.exists(destPath) ? this.fs.readJSON(destPath) : {};
171
- this.fs.writeJSON(destPath, _lodash.default.merge(packageJSON, currentPackageJSON));
169
+ this.packageJson.merge(packageJSON);
172
170
  },
173
171
 
174
172
  jest() {
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
5
+ var _lodash = _interopRequireDefault(require("lodash"));
6
+
7
+ var _path = _interopRequireDefault(require("path"));
8
+
9
+ var _generator = _interopRequireDefault(require("../../lib/generator"));
10
+
11
+ var _utils = require("../../lib/utils");
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ module.exports = class NodeProjectGenerator extends _generator.default {
16
+ // The name `constructor` is important here
17
+ constructor(...args) {
18
+ super(...args);
19
+ this.argument('project-name', {
20
+ type: String,
21
+ required: false
22
+ });
23
+ this.option('src-path', {
24
+ type: String,
25
+ desc: 'Path for source',
26
+ defaults: './src'
27
+ });
28
+ this.option('dest-path', {
29
+ type: String,
30
+ desc: 'Path for build',
31
+ defaults: './dist'
32
+ });
33
+ this.option('html-path', {
34
+ type: String,
35
+ desc: 'Path for the HTML',
36
+ defaults: './web'
37
+ });
38
+ this.option('server-path', {
39
+ type: String,
40
+ desc: 'Path for the server',
41
+ defaults: ''
42
+ });
43
+ this.option('cli-path', {
44
+ type: String,
45
+ desc: 'Path for the cli',
46
+ defaults: ''
47
+ });
48
+
49
+ this.srcPath = filePath => this.destinationPath(_path.default.join(this.options['src-path'], filePath));
50
+ }
51
+
52
+ get prompting() {
53
+ return {
54
+ welcome() {
55
+ if (this.options.quiet) {
56
+ return;
57
+ }
58
+
59
+ console.log(_chalk.default.yellow('\n----------------------'));
60
+ console.log('Node Project Generator');
61
+ console.log(_chalk.default.yellow('----------------------\n'));
62
+ },
63
+
64
+ prompts() {
65
+ const prompts = [];
66
+
67
+ if (!this.options['project-name']) {
68
+ prompts.push(_generator.default.prompts.project_name);
69
+ }
70
+
71
+ if (!prompts.length) {
72
+ return null;
73
+ }
74
+
75
+ return this.prompt(prompts).then(answers => {
76
+ if (answers['project-name']) {
77
+ this.options['project-name'] = answers['project-name'];
78
+ }
79
+ });
80
+ }
81
+
82
+ };
83
+ }
84
+
85
+ configuring() {
86
+ const {
87
+ 'project-name': projectName,
88
+ 'src-path': srcPath,
89
+ 'dest-path': destPath,
90
+ 'html-path': htmlPath,
91
+ 'server-path': serverPath,
92
+ 'cli-path': cliPath
93
+ } = this.options;
94
+
95
+ const htmlSrcPath = _path.default.join(srcPath, htmlPath);
96
+
97
+ const serverSrcPath = _path.default.join(srcPath, serverPath);
98
+
99
+ const cliSrcPath = _path.default.join(srcPath, cliPath);
100
+
101
+ this.composeWith('folklore:html-project', {
102
+ 'skip-install': true,
103
+ quiet: true,
104
+ 'project-name': projectName,
105
+ 'src-path': htmlSrcPath,
106
+ 'dest-path': destPath
107
+ });
108
+ this.composeWith('folklore:server', {
109
+ 'skip-install': true,
110
+ quiet: true,
111
+ path: serverSrcPath
112
+ });
113
+ this.composeWith('folklore:cli', {
114
+ 'skip-install': true,
115
+ quiet: true,
116
+ path: cliSrcPath
117
+ });
118
+ this.composeWith('folklore:rollup', {
119
+ 'skip-install': true,
120
+ quiet: true
121
+ });
122
+ }
123
+
124
+ get writing() {
125
+ return {
126
+ index() {
127
+ this.fs.copyTpl(this.templatePath('index.js'), this.srcPath('index.js'));
128
+ },
129
+
130
+ packageJson() {
131
+ const {
132
+ 'src-path': srcPath,
133
+ 'html-path': htmlPath,
134
+ 'server-path': serverPath
135
+ } = this.options;
136
+
137
+ const webEntryPath = _path.default.join(srcPath, htmlPath, 'index.js');
138
+
139
+ const serverEntryPath = _path.default.join(srcPath, serverPath, 'server.js');
140
+
141
+ const scripts = {
142
+ 'build:web': `flklr build --load-env ${(0, _utils.ensureLeadingDotSlash)(webEntryPath)}`,
143
+ 'build:rollup': `rollup --config rollup.config.js`,
144
+ 'build': 'npm run build:web && npm run build:rollup',
145
+ 'server': `babel-node ${(0, _utils.ensureLeadingDotSlash)(serverEntryPath)}`,
146
+ 'start': `flklr serve --load-env ${(0, _utils.ensureLeadingDotSlash)(webEntryPath)}`
147
+ };
148
+ this.packageJson.merge({
149
+ scripts
150
+ });
151
+ }
152
+
153
+ };
154
+ }
155
+
156
+ async install() {
157
+ if (this.options['skip-install']) {
158
+ return;
159
+ }
160
+
161
+ await this.spawnCommand('npm', ['install']);
162
+ }
163
+
164
+ };
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
3
5
  var _lodash = _interopRequireDefault(require("lodash"));
4
6
 
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
-
9
9
  var _generator = _interopRequireDefault(require("../../lib/generator"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -225,11 +225,9 @@ module.exports = class NpmPackageGenerator extends _generator.default {
225
225
 
226
226
  packageJSON() {
227
227
  const srcPath = this.templatePath('_package.json');
228
- const destPath = this.destinationPath('package.json');
229
228
  const packageJSON = this.fs.readJSON(srcPath);
230
229
  packageJSON.name = this.options['package-name'];
231
- const currentPackageJSON = this.fs.exists(destPath) ? this.fs.readJSON(destPath) : {};
232
- this.fs.writeJSON(destPath, _lodash.default.merge(packageJSON, currentPackageJSON));
230
+ this.packageJson.merge(packageJSON);
233
231
  }
234
232
 
235
233
  };
@@ -22,14 +22,27 @@ module.exports = class PrettierGenerator extends _generator.default {
22
22
  };
23
23
  }
24
24
 
25
- writing() {
26
- const srcPath = this.templatePath('prettierrc.json');
27
- const destPath = this.destinationPath('.prettierrc.json');
28
- this.fs.copy(srcPath, destPath);
25
+ get writing() {
26
+ return {
27
+ prettierrc() {
28
+ const srcPath = this.templatePath('prettierrc.json');
29
+ const destPath = this.destinationPath('.prettierrc.json');
30
+ this.fs.copy(srcPath, destPath);
31
+ },
32
+
33
+ dependencies() {
34
+ this.addDevDependencies(['prettier', '@prettier/plugin-php', '@trivago/prettier-plugin-sort-imports']);
35
+ }
36
+
37
+ };
29
38
  }
30
39
 
31
- install() {
32
- this.addDevDependencies(['prettier', '@prettier/plugin-php']);
40
+ async install() {
41
+ if (this.options['skip-install']) {
42
+ return;
43
+ }
44
+
45
+ await this.spawnCommand('npm', ['install']);
33
46
  }
34
47
 
35
48
  };
@@ -2,5 +2,7 @@
2
2
  "printWidth": 100,
3
3
  "singleQuote": true,
4
4
  "trailingComma": "all",
5
- "tabWidth": 4
5
+ "tabWidth": 4,
6
+ "importOrder": ["<THIRD_PARTY_MODULES>", "^[./](.*)?\/(utils|hooks|lib)", "^[./].*(?<!(\\.[a-z]+))$", "\\.scss$", "\\.[a-z]+$"],
7
+ "importOrderSeparation": true
6
8
  }