generator-reackt 0.3.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.prettierrc +4 -4
  2. package/.stylelintrc +104 -104
  3. package/LICENSE +9 -7
  4. package/README.md +18 -18
  5. package/generators/app/index.js +1 -309
  6. package/generators/component/index.js +1 -56
  7. package/generators/es.regexp.flags-ccfbed60.js +1 -0
  8. package/generators/module/index.js +1 -117
  9. package/generators/util/fs.js +1 -22
  10. package/package.json +31 -28
  11. package/templates/app/.babelrc +9 -9
  12. package/templates/app/.browserslistrc +3 -3
  13. package/templates/app/.editorconfig +11 -11
  14. package/templates/app/.esdoc.json +23 -23
  15. package/templates/app/.lintstagedrc +4 -4
  16. package/templates/app/.prettierrc +4 -4
  17. package/templates/app/.storybook/addons.js +1 -1
  18. package/templates/app/.storybook/config.js +14 -14
  19. package/templates/app/.storybook/webpack.config.babel.js +7 -7
  20. package/templates/app/.stylelintrc +271 -277
  21. package/templates/app/gitignore +2 -2
  22. package/templates/app/jest.config.js +15 -15
  23. package/templates/app/jsconfig.json +8 -8
  24. package/templates/app/package.json +18 -18
  25. package/templates/app/src/components/{App/App.js → App.js} +14 -14
  26. package/templates/app/src/icons.js +3 -3
  27. package/templates/app/src/index.html +10 -10
  28. package/templates/app/src/index.js +50 -53
  29. package/templates/app/src/index.scss +16 -17
  30. package/templates/app/src/reducers/application.js +21 -21
  31. package/templates/app/src/reducers/index.js +7 -7
  32. package/templates/app/src/sagas/application.js +9 -9
  33. package/templates/app/src/sagas/index.js +7 -7
  34. package/templates/app/src/selectors/application.js +1 -1
  35. package/templates/app/src/selectors/application.test.js +13 -13
  36. package/templates/app/src/utils/index.js +36 -36
  37. package/templates/app/webpack.config.babel.js +103 -109
  38. package/templates/component/index.js +19 -19
  39. package/templates/component/index.test.js +14 -14
  40. package/templates/module/reducer/index.js +20 -20
  41. package/templates/module/saga/index.js +9 -9
package/.prettierrc CHANGED
@@ -1,5 +1,5 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "none",
4
- "endOfLine": "auto"
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "none",
4
+ "endOfLine": "auto"
5
5
  }
package/.stylelintrc CHANGED
@@ -1,104 +1,104 @@
1
- {
2
- "defaultSeverity": "error",
3
- "rules": {
4
- "at-rule-empty-line-before": [
5
- "always",
6
- {
7
- "except": [ "blockless-after-blockless", "first-nested" ],
8
- "ignore": [ "after-comment" ],
9
- "ignoreAtRules": [ "else" ]
10
- }
11
- ],
12
- "at-rule-name-newline-after": "always-multi-line",
13
- "at-rule-name-space-after": "always-single-line",
14
- "at-rule-semicolon-newline-after": "always",
15
- "at-rule-semicolon-space-before": "never",
16
- "block-closing-brace-empty-line-before": "never",
17
- "block-closing-brace-newline-after": [
18
- "always",
19
- {
20
- "ignoreAtRules": [ "else", "if" ]
21
- }
22
- ],
23
- "block-closing-brace-newline-before": "always-multi-line",
24
- "block-closing-brace-space-after": "always-single-line",
25
- "block-closing-brace-space-before": "always-single-line",
26
- "block-no-empty": true,
27
- "block-opening-brace-newline-after": "always",
28
- "block-opening-brace-newline-before": "never-single-line",
29
- "block-opening-brace-space-after": "always-single-line",
30
- "block-opening-brace-space-before": "always",
31
- "comment-empty-line-before": [
32
- "always",
33
- {
34
- "ignore": [ "after-comment", "stylelint-commands" ]
35
- }
36
- ],
37
- "comment-no-empty": true,
38
- "comment-whitespace-inside": "always",
39
- "custom-property-empty-line-before": null,
40
- "declaration-bang-space-after": "never",
41
- "declaration-bang-space-before": "always",
42
- "declaration-block-semicolon-newline-after": "always",
43
- "declaration-block-semicolon-newline-before": null,
44
- "declaration-block-semicolon-space-after": "always-single-line",
45
- "declaration-block-semicolon-space-before": "never",
46
- "declaration-block-single-line-max-declarations": 1,
47
- "declaration-block-trailing-semicolon": "always",
48
- "declaration-colon-newline-after": null,
49
- "declaration-colon-space-after": "always",
50
- "declaration-colon-space-before": "never",
51
- "declaration-empty-line-before": "never",
52
- "function-comma-newline-after": null,
53
- "function-comma-newline-before": null,
54
- "function-comma-space-after": "always",
55
- "function-comma-space-before": null,
56
- "function-max-empty-lines": 0,
57
- "function-whitespace-after": "always",
58
- "indentation": 2,
59
- "max-empty-lines": 2,
60
- "max-line-length": 100,
61
- "max-nesting-depth": 4,
62
- "media-feature-colon-space-after": "always",
63
- "media-feature-colon-space-before": "never",
64
- "media-feature-parentheses-space-inside": "never",
65
- "media-feature-range-operator-space-after": "always",
66
- "media-feature-range-operator-space-before": "always",
67
- "media-query-list-comma-newline-after": null,
68
- "media-query-list-comma-newline-before": null,
69
- "media-query-list-comma-space-after": null,
70
- "media-query-list-comma-space-before": null,
71
- "no-duplicate-at-import-rules": true,
72
- "no-duplicate-selectors": true,
73
- "no-empty-source": true,
74
- "no-eol-whitespace": true,
75
- "no-extra-semicolons": true,
76
- "no-invalid-double-slash-comments": true,
77
- "no-missing-end-of-source-newline": true,
78
- "rule-empty-line-before": [
79
- "always",
80
- {
81
- "except": [ "first-nested" ],
82
- "ignore": [ "after-comment" ]
83
- }
84
- ],
85
- "selector-attribute-brackets-space-inside": "never",
86
- "selector-attribute-operator-space-after": "never",
87
- "selector-attribute-operator-space-before": "never",
88
- "selector-combinator-space-after": "always",
89
- "selector-combinator-space-before": "always",
90
- "selector-descendant-combinator-no-non-space": true,
91
- "selector-list-comma-newline-after": "always",
92
- "selector-list-comma-newline-before": "never-multi-line",
93
- "selector-list-comma-space-after": "always-single-line",
94
- "selector-list-comma-space-before": null,
95
- "selector-max-empty-lines": 0,
96
- "string-no-newline": true,
97
- "string-quotes": "double",
98
- "value-list-comma-newline-after": "always-multi-line",
99
- "value-list-comma-newline-before": null,
100
- "value-list-comma-space-after": null,
101
- "value-list-comma-space-before": "never",
102
- "value-list-max-empty-lines": 0
103
- }
104
- }
1
+ {
2
+ "defaultSeverity": "error",
3
+ "rules": {
4
+ "at-rule-empty-line-before": [
5
+ "always",
6
+ {
7
+ "except": [ "blockless-after-blockless", "first-nested" ],
8
+ "ignore": [ "after-comment" ],
9
+ "ignoreAtRules": [ "else" ]
10
+ }
11
+ ],
12
+ "at-rule-name-newline-after": "always-multi-line",
13
+ "at-rule-name-space-after": "always-single-line",
14
+ "at-rule-semicolon-newline-after": "always",
15
+ "at-rule-semicolon-space-before": "never",
16
+ "block-closing-brace-empty-line-before": "never",
17
+ "block-closing-brace-newline-after": [
18
+ "always",
19
+ {
20
+ "ignoreAtRules": [ "else", "if" ]
21
+ }
22
+ ],
23
+ "block-closing-brace-newline-before": "always-multi-line",
24
+ "block-closing-brace-space-after": "always-single-line",
25
+ "block-closing-brace-space-before": "always-single-line",
26
+ "block-no-empty": true,
27
+ "block-opening-brace-newline-after": "always",
28
+ "block-opening-brace-newline-before": "never-single-line",
29
+ "block-opening-brace-space-after": "always-single-line",
30
+ "block-opening-brace-space-before": "always",
31
+ "comment-empty-line-before": [
32
+ "always",
33
+ {
34
+ "ignore": [ "after-comment", "stylelint-commands" ]
35
+ }
36
+ ],
37
+ "comment-no-empty": true,
38
+ "comment-whitespace-inside": "always",
39
+ "custom-property-empty-line-before": null,
40
+ "declaration-bang-space-after": "never",
41
+ "declaration-bang-space-before": "always",
42
+ "declaration-block-semicolon-newline-after": "always",
43
+ "declaration-block-semicolon-newline-before": null,
44
+ "declaration-block-semicolon-space-after": "always-single-line",
45
+ "declaration-block-semicolon-space-before": "never",
46
+ "declaration-block-single-line-max-declarations": 1,
47
+ "declaration-block-trailing-semicolon": "always",
48
+ "declaration-colon-newline-after": null,
49
+ "declaration-colon-space-after": "always",
50
+ "declaration-colon-space-before": "never",
51
+ "declaration-empty-line-before": "never",
52
+ "function-comma-newline-after": null,
53
+ "function-comma-newline-before": null,
54
+ "function-comma-space-after": "always",
55
+ "function-comma-space-before": null,
56
+ "function-max-empty-lines": 0,
57
+ "function-whitespace-after": "always",
58
+ "indentation": 2,
59
+ "max-empty-lines": 2,
60
+ "max-line-length": 100,
61
+ "max-nesting-depth": 4,
62
+ "media-feature-colon-space-after": "always",
63
+ "media-feature-colon-space-before": "never",
64
+ "media-feature-parentheses-space-inside": "never",
65
+ "media-feature-range-operator-space-after": "always",
66
+ "media-feature-range-operator-space-before": "always",
67
+ "media-query-list-comma-newline-after": null,
68
+ "media-query-list-comma-newline-before": null,
69
+ "media-query-list-comma-space-after": null,
70
+ "media-query-list-comma-space-before": null,
71
+ "no-duplicate-at-import-rules": true,
72
+ "no-duplicate-selectors": true,
73
+ "no-empty-source": true,
74
+ "no-eol-whitespace": true,
75
+ "no-extra-semicolons": true,
76
+ "no-invalid-double-slash-comments": true,
77
+ "no-missing-end-of-source-newline": true,
78
+ "rule-empty-line-before": [
79
+ "always",
80
+ {
81
+ "except": [ "first-nested" ],
82
+ "ignore": [ "after-comment" ]
83
+ }
84
+ ],
85
+ "selector-attribute-brackets-space-inside": "never",
86
+ "selector-attribute-operator-space-after": "never",
87
+ "selector-attribute-operator-space-before": "never",
88
+ "selector-combinator-space-after": "always",
89
+ "selector-combinator-space-before": "always",
90
+ "selector-descendant-combinator-no-non-space": true,
91
+ "selector-list-comma-newline-after": "always",
92
+ "selector-list-comma-newline-before": "never-multi-line",
93
+ "selector-list-comma-space-after": "always-single-line",
94
+ "selector-list-comma-space-before": null,
95
+ "selector-max-empty-lines": 0,
96
+ "string-no-newline": true,
97
+ "string-quotes": "double",
98
+ "value-list-comma-newline-after": "always-multi-line",
99
+ "value-list-comma-newline-before": null,
100
+ "value-list-comma-space-after": null,
101
+ "value-list-comma-space-before": "never",
102
+ "value-list-max-empty-lines": 0
103
+ }
104
+ }
package/LICENSE CHANGED
@@ -1,7 +1,9 @@
1
- Copyright 2018 ayan4m1 <andrew@bulletlogic.com>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License
2
+
3
+ Copyright 2018-2023 ayan4m1 <andrew@bulletlogic.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
- # The Reactor - An Opinionated Generator
2
-
3
- This project scaffolds a modern web application. It is fairly opinionated, but is customizable and extensible.
4
-
5
- Here's the mile-long list of technologies the generated project can leverage:
6
-
7
- - [Babel](https://babeljs.io/) - Compile modern ECMAScript to Node-compatible JS
8
- - [Webpack](https://webpack.js.org/) - Bundle code, styles, markup, and more into a web application
9
- - [husky](https://www.npmjs.com/package/husky) - Execute lint-staged before committing to Git
10
- - [lint-staged](https://www.npmjs.com/package/lint-staged) - Execute linters for specific file types
11
- - [ESLint](https://eslint.org/) - Apply hundreds of style/usage rules to ECMAScript
12
- - [Prettier](https://prettier.io/) - Apply style/formatting rules to code
13
- - [stylelint](https://stylelint.io/) - Apply style/usage rules to Sass
14
- - [Bootstrap](https://getbootstrap.com/) - UI toolkit
15
- - [React](https://reactjs.org/) - UI library
16
- - [Redux](https://redux.js.org/) - Application state container
17
- - [Redux-Saga](https://redux-saga.js.org/) - Redux middleware for action/side-effect interaction
18
- - [Jest](https://jestjs.io/) - Unit, integration, and snapshot testing
1
+ # The Reactor - An Opinionated Generator
2
+
3
+ This project scaffolds a modern web application. It is fairly opinionated, but is customizable and extensible.
4
+
5
+ Here's the mile-long list of technologies the generated project can leverage:
6
+
7
+ - [Babel](https://babeljs.io/) - Compile modern ECMAScript to Node-compatible JS
8
+ - [Webpack](https://webpack.js.org/) - Bundle code, styles, markup, and more into a web application
9
+ - [husky](https://www.npmjs.com/package/husky) - Execute lint-staged before committing to Git
10
+ - [lint-staged](https://www.npmjs.com/package/lint-staged) - Execute linters for specific file types
11
+ - [ESLint](https://eslint.org/) - Apply hundreds of style/usage rules to ECMAScript
12
+ - [Prettier](https://prettier.io/) - Apply style/formatting rules to code
13
+ - [stylelint](https://stylelint.io/) - Apply style/usage rules to Sass
14
+ - [Bootstrap](https://getbootstrap.com/) - UI toolkit
15
+ - [React](https://reactjs.org/) - UI library
16
+ - [Redux](https://redux.js.org/) - Application state container
17
+ - [Redux-Saga](https://redux-saga.js.org/) - Redux middleware for action/side-effect interaction
18
+ - [Jest](https://jestjs.io/) - Unit, integration, and snapshot testing
@@ -1,309 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _got = _interopRequireDefault(require("got"));
9
-
10
- var _path = require("path");
11
-
12
- var _gulpIf = _interopRequireDefault(require("gulp-if"));
13
-
14
- var _dateFns = require("date-fns");
15
-
16
- var _fs = _interopRequireDefault(require("../util/fs"));
17
-
18
- var _gulpPrettier = _interopRequireDefault(require("gulp-prettier"));
19
-
20
- var _jsonfile = require("jsonfile");
21
-
22
- var _yeomanStylelint = _interopRequireDefault(require("yeoman-stylelint"));
23
-
24
- var _spdxLicenseIds = _interopRequireDefault(require("spdx-license-ids"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- _spdxLicenseIds.default.push('SEE LICENSE IN LICENSE');
29
-
30
- _spdxLicenseIds.default.sort(); // we cannot use ES6 imports on this object, as it directly exports a class to
31
- // module.exports - no default export nor a named export is present for us to use
32
-
33
-
34
- const Generator = require('yeoman-generator');
35
-
36
- const src = (...paths) => (0, _path.join)('src', ...paths);
37
-
38
- const getPrettierConfig = () => (0, _jsonfile.readFileSync)((0, _path.join)(__dirname, '..', '..', '.prettierrc'));
39
-
40
- const styleFrameworks = [{
41
- value: null,
42
- name: 'None'
43
- }, {
44
- value: 'bootstrap',
45
- name: 'Bootstrap'
46
- }, {
47
- value: 'bulma',
48
- name: 'Bulma'
49
- }, {
50
- value: 'foundation',
51
- name: 'Foundation'
52
- }, {
53
- value: 'materialize',
54
- name: 'Materialize'
55
- }, {
56
- value: 'uikit',
57
- name: 'UIKit'
58
- }, {
59
- value: 'materialUi',
60
- name: 'Material-UI'
61
- }];
62
- const packages = {
63
- fontAwesome: ['@fortawesome/fontawesome-svg-core', '@fortawesome/free-solid-svg-icons', '@fortawesome/react-fontawesome'],
64
- bootstrap: ['bootstrap'],
65
- uikit: ['uikit', 'uikit-react'],
66
- foundation: ['foundation-sites'],
67
- materialize: ['materialize-css'],
68
- bulma: ['bulma'],
69
- materialUi: ['@material-ui/core'],
70
- lintStaged: ['husky', 'lint-staged'],
71
- redux: ['redux', 'react-redux', 'redux-saga'],
72
- reduxJest: ['redux-mock-store'],
73
- core: ['@babel/runtime', 'core-js', 'normalize-scss', 'prop-types', 'react', 'react-dom', 'react-router-dom', 'reselect', 'classnames'],
74
- storybook: ['@storybook/react', '@storybook/addons', '@storybook/addon-knobs'],
75
- esdoc: ['esdoc', 'esdoc-ecmascript-proposal-plugin', 'esdoc-jsx-plugin', 'esdoc-standard-plugin', 'opener'],
76
- jest: ['babel-jest', 'eslint-plugin-jest', 'jest', 'react-test-renderer', 'opener'],
77
- dev: ['@babel/core', '@babel/eslint-parser', '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-object-rest-spread', '@babel/plugin-transform-regenerator', '@babel/plugin-transform-runtime', '@babel/preset-env', '@babel/preset-react', '@babel/register', 'autoprefixer', 'babel-loader', 'clean-webpack-plugin', 'cross-env', 'css-loader', 'css-minimizer-webpack-plugin', 'eslint-config-prettier', 'eslint-import-resolver-webpack', 'eslint-plugin-import', 'eslint-plugin-jsx-a11y', 'eslint-plugin-prettier', 'eslint-plugin-react-hooks', 'eslint-plugin-react', 'eslint-webpack-plugin', 'eslint', 'html-loader', 'html-webpack-plugin', 'mini-css-extract-plugin', 'postcss-flexbugs-fixes', 'postcss-loader', 'prettier-eslint', 'prettier-stylelint', 'prettier', 'sass-loader', 'sass', 'style-loader', 'stylelint-a11y', 'stylelint-config-recommended', 'stylelint-webpack-plugin', 'stylelint', 'terser-webpack-plugin', 'webpack-cli', 'webpack', 'webpack-dev-server']
78
- };
79
- const files = {
80
- core: ['.babelrc', '.prettierrc', '.stylelintrc', '.editorconfig', 'jsconfig.json', '.browserslistrc', src('utils', 'index.js')],
81
- templated: ['.eslintrc.js', 'package.json', src('index.js'), src('index.html'), src('index.scss'), 'webpack.config.babel.js'],
82
- esdoc: ['.esdoc.json'],
83
- jest: ['jest.config.js'],
84
- lintStaged: ['.lintstagedrc'],
85
- fontAwesome: [src('icons.js')]
86
- };
87
- const directories = {
88
- redux: [src('reducers'), src('sagas'), src('selectors')],
89
- core: [src('components'), src('utils')]
90
- };
91
- const scripts = {
92
- esdoc: {
93
- 'build:documentation': 'esdoc',
94
- 'view:documentation': 'opener ./docs/index.html'
95
- },
96
- jest: {
97
- test: 'jest',
98
- 'view:coverage': 'opener ./coverage/index.html'
99
- }
100
- };
101
-
102
- class _default extends Generator {
103
- constructor(...args) {
104
- super(...args);
105
- this.env.adapter.promptModule.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
106
- this.sourceRoot((0, _path.join)(__dirname, '..', '..', 'templates', 'app'));
107
- this.answers = {};
108
- this.fileSystem = (0, _fs.default)(this);
109
- this.registerTransformStream((0, _gulpIf.default)(/\.js$/, (0, _gulpPrettier.default)(getPrettierConfig())));
110
- this.registerTransformStream((0, _gulpIf.default)(/\.scss$/, (0, _yeomanStylelint.default)({
111
- configFile: (0, _path.join)(__dirname, '..', '..', '.stylelintrc')
112
- })));
113
- }
114
-
115
- async prompting() {
116
- const {
117
- name,
118
- email
119
- } = this.user.git;
120
- this.answers = await this.prompt([{
121
- type: 'input',
122
- name: 'package.name',
123
- message: 'Package name',
124
- default: this.appname.replace(/\s+/g, '-')
125
- }, {
126
- type: 'input',
127
- name: 'package.version',
128
- message: 'Package version',
129
- default: '0.1.0'
130
- }, {
131
- type: 'autocomplete',
132
- name: 'package.license',
133
- message: 'Package license',
134
- source: (_, input) => {
135
- const pattern = new RegExp(`.*${input}.*`, 'i');
136
- return new Promise(resolve => {
137
- resolve(_spdxLicenseIds.default.filter(identifier => pattern.test(identifier)));
138
- });
139
- }
140
- }, {
141
- type: 'input',
142
- name: 'package.description',
143
- message: 'Package description'
144
- }, {
145
- type: 'input',
146
- name: 'author.name',
147
- message: 'Author name',
148
- default: name()
149
- }, {
150
- type: 'input',
151
- name: 'author.email',
152
- message: 'Author email address',
153
- default: email()
154
- }, {
155
- type: 'list',
156
- name: 'styleFramework',
157
- message: 'What CSS framework would you like to use?',
158
- choices: styleFrameworks
159
- }, {
160
- type: 'confirm',
161
- name: 'flags.addLintStaged',
162
- message: 'Force linting before commits?',
163
- default: true
164
- }, {
165
- type: 'confirm',
166
- name: 'flags.addFontAwesome',
167
- message: 'Add Font Awesome?',
168
- default: true
169
- }, {
170
- type: 'confirm',
171
- name: 'flags.addRedux',
172
- message: 'Add Redux?',
173
- default: true
174
- }, {
175
- type: 'confirm',
176
- name: 'flags.addJest',
177
- message: 'Add Jest?',
178
- default: true
179
- }, {
180
- type: 'confirm',
181
- name: 'flags.addStorybook',
182
- message: 'Add Storybook?',
183
- default: false
184
- }, {
185
- type: 'confirm',
186
- name: 'flags.addESDoc',
187
- message: 'Add ESDoc?',
188
- default: false
189
- }]);
190
- }
191
-
192
- async writing() {
193
- const {
194
- flags,
195
- package: {
196
- license
197
- },
198
- author: {
199
- name,
200
- email
201
- }
202
- } = this.answers;
203
- let licenseText = 'Place your license here.\n';
204
-
205
- if (license !== 'SEE LICENSE IN LICENSE') {
206
- this.log(`Downloading ${license} license from spdx/license-list-data...`);
207
- const {
208
- body: rawLicense
209
- } = await (0, _got.default)(`https://raw.githubusercontent.com/spdx/license-list-data/master/text/${license}.txt`);
210
- licenseText = rawLicense.replace('<year>', (0, _dateFns.format)(new Date(), 'yyyy')).replace('<copyright holders>', `${name} <${email}>`);
211
- }
212
-
213
- this.fileSystem.createFile('LICENSE', licenseText); // copy files and directories
214
-
215
- files.core.forEach(this.fileSystem.copy);
216
- files.templated.forEach(this.fileSystem.copyTemplateInPlace);
217
- directories.core.forEach(this.fileSystem.copyDirectory); // this is a workaround for npm not packaging up .gitignore files
218
-
219
- this.fileSystem.copyTo('gitignore', '.gitignore');
220
-
221
- if (flags.addRedux) {
222
- directories.redux.forEach(this.fileSystem.copyDirectory);
223
- }
224
-
225
- if (flags.addJest) {
226
- files.jest.forEach(this.fileSystem.copy);
227
- this.fs.append(this.destinationPath('.gitignore'), 'coverage/');
228
- this.fs.extendJSON(this.destinationPath('package.json'), {
229
- scripts: { ...scripts.jest
230
- }
231
- });
232
- }
233
-
234
- if (flags.addESDoc) {
235
- files.esdoc.forEach(this.fileSystem.copy);
236
- this.fs.append(this.destinationPath('.gitignore'), 'docs/');
237
- this.fs.extendJSON(this.destinationPath('package.json'), {
238
- scripts: { ...scripts.esdoc
239
- }
240
- });
241
- }
242
-
243
- if (flags.addLintStaged) {
244
- files.lintStaged.forEach(this.fileSystem.copy);
245
- }
246
-
247
- if (flags.addFontAwesome) {
248
- files.fontAwesome.forEach(this.fileSystem.copy);
249
- }
250
- }
251
-
252
- install() {
253
- const main = [];
254
- const dev = [];
255
- const {
256
- flags,
257
- styleFramework
258
- } = this.answers;
259
- this.log('Building a list of packages to install');
260
- main.push.apply(main, packages.core);
261
- dev.push.apply(dev, packages.dev);
262
-
263
- if (styleFramework !== null) {
264
- main.push.apply(main, packages[styleFramework]);
265
- }
266
-
267
- if (flags.addLintStaged) {
268
- dev.push.apply(dev, packages.lintStaged);
269
- }
270
-
271
- if (flags.addFontAwesome) {
272
- main.push.apply(main, packages.fontAwesome);
273
- }
274
-
275
- if (flags.addRedux) {
276
- main.push.apply(main, packages.redux);
277
- }
278
-
279
- if (flags.addJest) {
280
- dev.push.apply(dev, packages.jest);
281
- }
282
-
283
- if (flags.addRedux && flags.addJest) {
284
- dev.push.apply(dev, packages.reduxJest);
285
- }
286
-
287
- if (flags.addStorybook) {
288
- dev.push.apply(dev, packages.storybook);
289
- }
290
-
291
- if (flags.addESDoc) {
292
- main.push.apply(main, packages.esdoc);
293
- }
294
-
295
- this.log(`Getting ready to install ${main.length} dependencies and ${dev.length} dev dependencies.`);
296
- this.npmInstall(main, {
297
- save: true
298
- });
299
- this.npmInstall(dev, {
300
- 'save-dev': true
301
- });
302
- this.spawnCommandSync('git', ['init']);
303
- this.spawnCommandSync('npx', ['husky', 'install']);
304
- this.spawnCommandSync('npx', ['husky', 'add', '.husky/pre-commit', 'npx lint-staged']);
305
- }
306
-
307
- }
308
-
309
- exports.default = _default;
1
+ "use strict";var e=require("got"),t=require("path"),s=require("gulp-if"),a=require("date-fns"),i=require("../util/fs.js"),o=require("gulp-prettier"),r=require("jsonfile"),n=require("yeoman-stylelint"),l=require("spdx-license-ids");require("mkdirp"),l.push("SEE LICENSE IN LICENSE"),l.sort();const p=require("yeoman-generator"),c=(...e)=>t.join("src",...e),d=[{value:null,name:"None"},{value:"bootstrap",name:"Bootstrap"},{value:"bulma",name:"Bulma"},{value:"foundation",name:"Foundation"},{value:"materialize",name:"Materialize"},{value:"uikit",name:"UIKit"},{value:"materialUi",name:"Material-UI"}],m={fontAwesome:["@fortawesome/fontawesome-svg-core","@fortawesome/free-solid-svg-icons","@fortawesome/react-fontawesome"],bootstrap:["bootstrap"],uikit:["uikit","uikit-react"],foundation:["foundation-sites"],materialize:["materialize-css"],bulma:["bulma"],materialUi:["@material-ui/core"],lintStaged:["husky","lint-staged"],redux:["redux","react-redux","redux-saga"],reduxJest:["redux-mock-store"],core:["@babel/runtime","core-js","normalize-scss","prop-types","react@17","react-dom@17","react-router-dom","reselect","classnames"],storybook:["@storybook/react","@storybook/addons","@storybook/addon-knobs"],esdoc:["esdoc","esdoc-ecmascript-proposal-plugin","esdoc-jsx-plugin","esdoc-standard-plugin","opener"],jest:["babel-jest","eslint-plugin-jest","jest","react-test-renderer","opener"],dev:["@babel/core","@babel/eslint-parser","@babel/plugin-proposal-class-properties","@babel/plugin-proposal-object-rest-spread","@babel/plugin-transform-regenerator","@babel/plugin-transform-runtime","@babel/preset-env","@babel/preset-react","@babel/register","autoprefixer","babel-loader","clean-webpack-plugin","cross-env","css-loader","css-minimizer-webpack-plugin","eslint-config-prettier","eslint-import-resolver-webpack","eslint-plugin-import","eslint-plugin-jsx-a11y","eslint-plugin-prettier","eslint-plugin-react-hooks","eslint-plugin-react","eslint-webpack-plugin","eslint","html-loader","html-webpack-plugin","mini-css-extract-plugin","postcss-flexbugs-fixes","postcss-loader","postcss-scss","prettier","sass-loader","sass","style-loader","stylelint-config-recommended","stylelint-webpack-plugin","stylelint","terser-webpack-plugin","webpack-cli","webpack","webpack-dev-server"]},u={core:[".babelrc",".prettierrc",".stylelintrc",".editorconfig","jsconfig.json",".browserslistrc",c("utils","index.js")],templated:[".eslintrc.js","package.json",c("index.js"),c("index.html"),c("index.scss"),"webpack.config.babel.js"],esdoc:[".esdoc.json"],jest:["jest.config.js"],lintStaged:[".lintstagedrc"],fontAwesome:[c("icons.js")]},g={redux:[c("reducers"),c("sagas"),c("selectors")],core:[c("components"),c("utils")]},h={"build:documentation":"esdoc","view:documentation":"opener ./docs/index.html"},y={test:"jest","view:coverage":"opener ./coverage/index.html"};module.exports=class extends p{constructor(...e){super(...e),this.env.adapter.promptModule.registerPrompt("autocomplete",require("inquirer-autocomplete-prompt")),this.sourceRoot(t.join(__dirname,"..","..","templates","app")),this.answers={},this.fileSystem=i(this),this.registerTransformStream(s(/\.js$/,o(r.readFileSync(t.join(__dirname,"..","..",".prettierrc"))))),this.registerTransformStream(s(/\.scss$/,n({configFile:t.join(__dirname,"..","..",".stylelintrc")})))}async prompting(){const{name:e,email:t}=this.user.git;this.answers=await this.prompt([{type:"input",name:"package.name",message:"Package name",default:this.appname.replace(/\s+/g,"-")},{type:"input",name:"package.version",message:"Package version",default:"0.1.0"},{type:"autocomplete",name:"package.license",message:"Package license",source:(e,t)=>{const s=new RegExp(`.*${t}.*`,"i");return new Promise((e=>{e(l.filter((e=>s.test(e))))}))}},{type:"input",name:"package.description",message:"Package description"},{type:"input",name:"author.name",message:"Author name",default:e()},{type:"input",name:"author.email",message:"Author email address",default:t()},{type:"list",name:"styleFramework",message:"What CSS framework would you like to use?",choices:d},{type:"confirm",name:"flags.addLintStaged",message:"Force linting before commits?",default:!0},{type:"confirm",name:"flags.addFontAwesome",message:"Add Font Awesome?",default:!0},{type:"confirm",name:"flags.addRedux",message:"Add Redux?",default:!0},{type:"confirm",name:"flags.addJest",message:"Add Jest?",default:!0},{type:"confirm",name:"flags.addStorybook",message:"Add Storybook?",default:!1},{type:"confirm",name:"flags.addESDoc",message:"Add ESDoc?",default:!1}])}async writing(){const{flags:t,package:{license:s},author:{name:i,email:o}}=this.answers;let r="Place your license here.\n";if("SEE LICENSE IN LICENSE"!==s){this.log(`Downloading ${s} license from spdx/license-list-data...`);const{body:t}=await e(`https://raw.githubusercontent.com/spdx/license-list-data/master/text/${s}.txt`);r=t.replace("<year>",a.format(new Date,"yyyy")).replace("<copyright holders>",`${i} <${o}>`)}this.fileSystem.createFile("LICENSE",r),u.core.forEach(this.fileSystem.copy),u.templated.forEach(this.fileSystem.copyTemplateInPlace),g.core.forEach(this.fileSystem.copyDirectory),this.fileSystem.copyTo("gitignore",".gitignore"),t.addRedux&&g.redux.forEach(this.fileSystem.copyDirectory),t.addJest&&(u.jest.forEach(this.fileSystem.copy),this.fs.append(this.destinationPath(".gitignore"),"coverage/"),this.fs.extendJSON(this.destinationPath("package.json"),{scripts:{...y}})),t.addESDoc&&(u.esdoc.forEach(this.fileSystem.copy),this.fs.append(this.destinationPath(".gitignore"),"docs/"),this.fs.extendJSON(this.destinationPath("package.json"),{scripts:{...h}})),t.addLintStaged&&u.lintStaged.forEach(this.fileSystem.copy),t.addFontAwesome&&u.fontAwesome.forEach(this.fileSystem.copy)}install(){const e=[],t=[],{flags:s,styleFramework:a}=this.answers;this.log("Building a list of packages to install"),e.push.apply(e,m.core),t.push.apply(t,m.dev),null!==a&&e.push.apply(e,m[a]),s.addLintStaged&&t.push.apply(t,m.lintStaged),s.addFontAwesome&&e.push.apply(e,m.fontAwesome),s.addRedux&&e.push.apply(e,m.redux),s.addJest&&t.push.apply(t,m.jest),s.addRedux&&s.addJest&&t.push.apply(t,m.reduxJest),s.addStorybook&&t.push.apply(t,m.storybook),s.addESDoc&&e.push.apply(e,m.esdoc),this.log(`Getting ready to install ${e.length} dependencies and ${t.length} dev dependencies.`),this.npmInstall(e,{save:!0}),this.npmInstall(t,{"save-dev":!0}),this.spawnCommandSync("git",["init"]),this.spawnCommandSync("npx",["husky","install"]),this.spawnCommandSync("npx",["husky","add",".husky/pre-commit","npx lint-staged"])}};
@@ -1,56 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _path = require("path");
9
-
10
- var _fs = _interopRequireDefault(require("../util/fs"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- // we cannot use ES6 imports on this object, as it directly exports a class to
15
- // module.exports - no default export nor a named export is present for us to use
16
- const Generator = require('yeoman-generator');
17
-
18
- const src = (...paths) => (0, _path.join)('src', ...paths);
19
-
20
- class _default extends Generator {
21
- constructor(...args) {
22
- super(...args);
23
- this.sourceRoot((0, _path.join)(__dirname, '..', '..', 'templates', 'component'));
24
- this.answers = {};
25
- this.fileSystem = (0, _fs.default)(this);
26
- }
27
-
28
- async prompting() {
29
- this.answers = await this.prompt([{
30
- type: 'input',
31
- name: 'component.name',
32
- message: 'Component name'
33
- }, {
34
- type: 'confirm',
35
- name: 'flags.addRedux',
36
- message: 'Connect this component to the Redux store?',
37
- default: false
38
- }]);
39
- }
40
-
41
- async writing() {
42
- const {
43
- component: {
44
- name
45
- }
46
- } = this.answers;
47
- const fileName = src('components', `${name}.js`);
48
- const testName = src('components', `${name}.test.js`);
49
- this.log(`Creating ${name} component`);
50
- await this.fileSystem.copyTemplate('index.js', fileName);
51
- await this.fileSystem.copyTemplate('index.test.js', testName);
52
- }
53
-
54
- }
55
-
56
- exports.default = _default;
1
+ "use strict";var e=require("path"),t=require("../util/fs.js");require("mkdirp");const s=require("yeoman-generator"),n=(...t)=>e.join("src",...t);module.exports=class extends s{constructor(...s){super(...s),this.sourceRoot(e.join(__dirname,"..","..","templates","component")),this.answers={},this.fileSystem=t(this)}async prompting(){this.answers=await this.prompt([{type:"input",name:"component.name",message:"Component name"},{type:"confirm",name:"flags.addRedux",message:"Connect this component to the Redux store?",default:!1}])}async writing(){const{component:{name:e}}=this.answers,t=n("components",`${e}.js`),s=n("components",`${e}.test.js`);this.log(`Creating ${e} component`),await this.fileSystem.copyTemplate("index.js",t),await this.fileSystem.copyTemplate("index.test.js",s)}};