generator-reackt 0.6.0 → 1.0.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.
- package/.prettierrc +5 -5
- package/.stylelintrc +5 -188
- package/LICENSE +21 -7
- package/README.md +20 -18
- package/generators/app/index.js +1 -392
- package/generators/component/index.js +1 -51
- package/generators/module/index.js +1 -127
- package/generators/util/fs.js +1 -34
- package/package.json +83 -63
- package/templates/app/.browserslistrc +3 -3
- package/templates/app/.editorconfig +11 -11
- package/templates/app/.esdoc.json +23 -23
- package/templates/app/.lintstagedrc +4 -4
- package/templates/app/.prettierrc +5 -5
- package/templates/app/.storybook/main.ts +19 -0
- package/templates/app/.storybook/preview.ts +36 -0
- package/templates/app/.stylelintrc +5 -188
- package/templates/app/.yarnrc.yml +3 -0
- package/templates/app/_eslint.config.mjs +51 -0
- package/templates/app/{package.json → _package.json} +18 -18
- package/templates/app/_stories/SuspenseFallback.stories.tsx +17 -0
- package/templates/app/gitignore +3 -2
- package/templates/app/jest.config.js +15 -15
- package/templates/app/src/components/ErrorBoundary.tsx +45 -0
- package/templates/app/src/components/Layout.tsx +142 -0
- package/templates/app/src/components/SuspenseFallback.tsx +96 -0
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/{index.scss → index.nscss} +17 -16
- package/templates/app/src/index.tsx +60 -0
- package/templates/app/src/pages/index.tsx +3 -0
- package/templates/app/src/reducers/application.ts +36 -0
- package/templates/app/src/reducers/{index.js → index.ts} +8 -7
- package/templates/app/src/sagas/application.ts +9 -0
- package/templates/app/src/sagas/{index.js → index.ts} +8 -7
- package/templates/app/src/selectors/application.test.ts +18 -0
- package/templates/app/src/selectors/application.ts +6 -0
- package/templates/app/src/types/globals.d.ts +1 -0
- package/templates/app/src/types/index.ts +11 -0
- package/templates/app/src/utils/{index.js → index.ts} +36 -36
- package/templates/app/tsconfig.json +18 -0
- package/templates/app/webpack.config.nts +121 -0
- package/templates/component/index.stories.tsx +14 -0
- package/templates/component/{index.test.js → index.test.tsx} +14 -14
- package/templates/{app/src/components/App.js → component/index.tsx} +16 -14
- package/templates/module/reducer/{index.js → index.ts} +20 -20
- package/templates/module/saga/{index.js → index.ts} +9 -9
- package/templates/app/.babelrc +0 -4
- package/templates/app/.eslintrc.js +0 -46
- package/templates/app/.storybook/addons.js +0 -1
- package/templates/app/.storybook/config.js +0 -14
- package/templates/app/.storybook/webpack.config.babel.js +0 -7
- package/templates/app/jsconfig.json +0 -7
- package/templates/app/src/index.js +0 -47
- package/templates/app/src/reducers/application.js +0 -21
- package/templates/app/src/sagas/application.js +0 -9
- package/templates/app/src/selectors/application.js +0 -1
- package/templates/app/src/selectors/application.test.js +0 -13
- package/templates/app/webpack.config.babel.js +0 -103
- package/templates/component/index.js +0 -19
- /package/templates/module/reducer/{index.test.js → index.test.ts} +0 -0
- /package/templates/module/saga/{index.test.js → index.test.ts} +0 -0
- /package/templates/module/selector/{index.js → index.test.ts} +0 -0
- /package/templates/module/selector/{index.test.js → index.ts} +0 -0
package/.prettierrc
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"singleQuote": true,
|
|
3
|
+
"trailingComma": "none",
|
|
4
|
+
"endOfLine": "auto"
|
|
5
|
+
}
|
package/.stylelintrc
CHANGED
|
@@ -1,188 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"at-rule-allowed-list": null,
|
|
7
|
-
"at-rule-disallowed-list": null,
|
|
8
|
-
"at-rule-empty-line-before": [
|
|
9
|
-
"always",
|
|
10
|
-
{
|
|
11
|
-
"except": [
|
|
12
|
-
"blockless-after-blockless",
|
|
13
|
-
"first-nested"
|
|
14
|
-
],
|
|
15
|
-
"ignore": [
|
|
16
|
-
"after-comment"
|
|
17
|
-
],
|
|
18
|
-
"ignoreAtRules": [
|
|
19
|
-
"else"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"at-rule-no-unknown": [
|
|
24
|
-
true,
|
|
25
|
-
{
|
|
26
|
-
"ignoreAtRules": [
|
|
27
|
-
"each",
|
|
28
|
-
"content",
|
|
29
|
-
"else",
|
|
30
|
-
"extend",
|
|
31
|
-
"if",
|
|
32
|
-
"include",
|
|
33
|
-
"mixin",
|
|
34
|
-
"for",
|
|
35
|
-
"elseif",
|
|
36
|
-
"return",
|
|
37
|
-
"function"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"at-rule-no-vendor-prefix": true,
|
|
42
|
-
"block-no-empty": true,
|
|
43
|
-
"color-hex-length": "short",
|
|
44
|
-
"color-named": [
|
|
45
|
-
"never",
|
|
46
|
-
{
|
|
47
|
-
"severity": "error"
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
"color-no-hex": null,
|
|
51
|
-
"color-no-invalid-hex": true,
|
|
52
|
-
"comment-empty-line-before": [
|
|
53
|
-
"always",
|
|
54
|
-
{
|
|
55
|
-
"ignore": [
|
|
56
|
-
"after-comment",
|
|
57
|
-
"stylelint-commands"
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"comment-no-empty": true,
|
|
62
|
-
"comment-whitespace-inside": "always",
|
|
63
|
-
"comment-word-disallowed-list": [
|
|
64
|
-
"/^TODO:/"
|
|
65
|
-
],
|
|
66
|
-
"custom-media-pattern": null,
|
|
67
|
-
"custom-property-empty-line-before": null,
|
|
68
|
-
"custom-property-pattern": null,
|
|
69
|
-
"declaration-block-no-duplicate-properties": true,
|
|
70
|
-
"declaration-block-no-redundant-longhand-properties": true,
|
|
71
|
-
"declaration-block-no-shorthand-property-overrides": true,
|
|
72
|
-
"declaration-block-single-line-max-declarations": 1,
|
|
73
|
-
"declaration-no-important": true,
|
|
74
|
-
"declaration-property-unit-allowed-list": {
|
|
75
|
-
"border": [
|
|
76
|
-
"px"
|
|
77
|
-
],
|
|
78
|
-
"line-height": [],
|
|
79
|
-
"outline-offset": [
|
|
80
|
-
"px"
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
"declaration-property-unit-disallowed-list": {},
|
|
84
|
-
"declaration-property-value-allowed-list": {},
|
|
85
|
-
"declaration-property-value-disallowed-list": {},
|
|
86
|
-
"font-family-name-quotes": "always-unless-keyword",
|
|
87
|
-
"font-family-no-duplicate-names": true,
|
|
88
|
-
"font-family-no-missing-generic-family-keyword": true,
|
|
89
|
-
"font-weight-notation": "numeric",
|
|
90
|
-
"function-allowed-list": null,
|
|
91
|
-
"function-calc-no-unspaced-operator": true,
|
|
92
|
-
"function-disallowed-list": null,
|
|
93
|
-
"function-linear-gradient-no-nonstandard-direction": true,
|
|
94
|
-
"function-url-no-scheme-relative": true,
|
|
95
|
-
"function-url-quotes": "always",
|
|
96
|
-
"function-url-scheme-allowed-list": null,
|
|
97
|
-
"function-url-scheme-disallowed-list": null,
|
|
98
|
-
"keyframe-declaration-no-important": true,
|
|
99
|
-
"length-zero-no-unit": true,
|
|
100
|
-
"max-nesting-depth": 4,
|
|
101
|
-
"media-feature-name-allowed-list": null,
|
|
102
|
-
"media-feature-name-disallowed-list": null,
|
|
103
|
-
"media-feature-name-no-unknown": true,
|
|
104
|
-
"media-feature-name-no-vendor-prefix": true,
|
|
105
|
-
"no-descending-specificity": true,
|
|
106
|
-
"no-duplicate-at-import-rules": true,
|
|
107
|
-
"no-duplicate-selectors": true,
|
|
108
|
-
"no-empty-source": true,
|
|
109
|
-
"no-invalid-double-slash-comments": true,
|
|
110
|
-
"no-unknown-animations": true,
|
|
111
|
-
"number-max-precision": [
|
|
112
|
-
2,
|
|
113
|
-
{
|
|
114
|
-
"ignoreUnits": [
|
|
115
|
-
"em",
|
|
116
|
-
"rem"
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
"property-allowed-list": null,
|
|
121
|
-
"property-disallowed-list": null,
|
|
122
|
-
"property-no-unknown": true,
|
|
123
|
-
"property-no-vendor-prefix": true,
|
|
124
|
-
"rule-empty-line-before": [
|
|
125
|
-
"always",
|
|
126
|
-
{
|
|
127
|
-
"except": [
|
|
128
|
-
"first-nested"
|
|
129
|
-
],
|
|
130
|
-
"ignore": [
|
|
131
|
-
"after-comment"
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
],
|
|
135
|
-
"selector-attribute-operator-allowed-list": null,
|
|
136
|
-
"selector-attribute-operator-disallowed-list": null,
|
|
137
|
-
"selector-attribute-quotes": "always",
|
|
138
|
-
"selector-class-pattern": "[a-z]+",
|
|
139
|
-
"selector-combinator-allowed-list": null,
|
|
140
|
-
"selector-combinator-disallowed-list": null,
|
|
141
|
-
"selector-id-pattern": null,
|
|
142
|
-
"selector-max-attribute": 1,
|
|
143
|
-
"selector-max-class": 3,
|
|
144
|
-
"selector-max-combinators": 2,
|
|
145
|
-
"selector-max-compound-selectors": 3,
|
|
146
|
-
"selector-max-id": 1,
|
|
147
|
-
"selector-max-pseudo-class": 2,
|
|
148
|
-
"selector-max-specificity": [
|
|
149
|
-
"0,5,1",
|
|
150
|
-
{
|
|
151
|
-
"severity": "error"
|
|
152
|
-
}
|
|
153
|
-
],
|
|
154
|
-
"selector-max-type": 2,
|
|
155
|
-
"selector-max-universal": 1,
|
|
156
|
-
"selector-nested-pattern": null,
|
|
157
|
-
"selector-no-qualifying-type": true,
|
|
158
|
-
"selector-no-vendor-prefix": true,
|
|
159
|
-
"selector-pseudo-class-allowed-list": null,
|
|
160
|
-
"selector-pseudo-class-disallowed-list": null,
|
|
161
|
-
"selector-pseudo-class-no-unknown": true,
|
|
162
|
-
"selector-pseudo-element-allowed-list": null,
|
|
163
|
-
"selector-pseudo-element-colon-notation": "double",
|
|
164
|
-
"selector-pseudo-element-disallowed-list": null,
|
|
165
|
-
"selector-pseudo-element-no-unknown": true,
|
|
166
|
-
"selector-type-no-unknown": true,
|
|
167
|
-
"shorthand-property-no-redundant-values": true,
|
|
168
|
-
"string-no-newline": true,
|
|
169
|
-
"time-min-milliseconds": 100,
|
|
170
|
-
"unit-allowed-list": [
|
|
171
|
-
"%",
|
|
172
|
-
"deg",
|
|
173
|
-
"em",
|
|
174
|
-
"ms",
|
|
175
|
-
"px",
|
|
176
|
-
"rem",
|
|
177
|
-
"s",
|
|
178
|
-
"vh",
|
|
179
|
-
"vmax",
|
|
180
|
-
"vmin",
|
|
181
|
-
"vw"
|
|
182
|
-
],
|
|
183
|
-
"unit-disallowed-list": null,
|
|
184
|
-
"unit-no-unknown": true,
|
|
185
|
-
"value-keyword-case": "lower",
|
|
186
|
-
"value-no-vendor-prefix": true
|
|
187
|
-
}
|
|
188
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"customSyntax": "postcss-scss",
|
|
3
|
+
"defaultSeverity": "warning",
|
|
4
|
+
"extends": "stylelint-config-recommended"
|
|
5
|
+
}
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2026 ayan4m1 <andrew@bulletlogic.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is furnished
|
|
10
|
+
to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice (including the next
|
|
13
|
+
paragraph) shall be included in all copies or substantial portions of the
|
|
14
|
+
Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
19
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
21
|
+
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
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
|
-
- [
|
|
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
|
|
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
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [Redux
|
|
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
|
+
- [TypeScript](https://www.typescriptlang.org/) - The language of the modern web
|
|
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 JS/TS
|
|
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
|
+
- [Material-UI](https://mui.com/material-ui/) - UI toolkit
|
|
16
|
+
- [React](https://reactjs.org/) - UI library
|
|
17
|
+
- [Redux](https://redux.js.org/) - Application state container
|
|
18
|
+
- [Redux-Saga](https://redux-saga.js.org/) - Redux middleware for action/side-effect interaction
|
|
19
|
+
- [Jest](https://jestjs.io/) - Unit, integration, and snapshot testing
|
|
20
|
+
- [RTL](https://testing-library.com/docs/react-testing-library/intro/) - Opinionated unit testing for React
|
package/generators/app/index.js
CHANGED
|
@@ -1,392 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import gulpIf from 'gulp-if';
|
|
4
|
-
import jsonfile from 'jsonfile';
|
|
5
|
-
import { format } from 'date-fns';
|
|
6
|
-
import prettier from 'gulp-prettier';
|
|
7
|
-
import { createRequire } from 'module';
|
|
8
|
-
import stylelint from 'yeoman-stylelint';
|
|
9
|
-
import inquirerPrompt from 'inquirer-autocomplete-prompt';
|
|
10
|
-
import spdxIdentifiers from 'spdx-license-ids' assert { type: 'json' };
|
|
11
|
-
|
|
12
|
-
import fileSystem from '../util/fs.js';
|
|
13
|
-
|
|
14
|
-
spdxIdentifiers.push('SEE LICENSE IN LICENSE');
|
|
15
|
-
spdxIdentifiers.sort();
|
|
16
|
-
|
|
17
|
-
const { readFileSync } = jsonfile;
|
|
18
|
-
|
|
19
|
-
// we cannot use ES6 imports on this object, as it directly exports a class to
|
|
20
|
-
// module.exports - no default export nor a named export is present for us to use
|
|
21
|
-
const require = createRequire(import.meta.url);
|
|
22
|
-
const Generator = require('yeoman-generator');
|
|
23
|
-
|
|
24
|
-
const src = (...paths) => join('src', ...paths);
|
|
25
|
-
|
|
26
|
-
const styleFrameworks = [
|
|
27
|
-
{ value: null, name: 'None' },
|
|
28
|
-
{ value: 'bootstrap', name: 'Bootstrap' },
|
|
29
|
-
{ value: 'bulma', name: 'Bulma' },
|
|
30
|
-
{ value: 'foundation', name: 'Foundation' },
|
|
31
|
-
{ value: 'materialize', name: 'Materialize' },
|
|
32
|
-
{ value: 'uikit', name: 'UIKit' },
|
|
33
|
-
{ value: 'materialUi', name: 'Material-UI' }
|
|
34
|
-
];
|
|
35
|
-
const packages = {
|
|
36
|
-
fontAwesome: [
|
|
37
|
-
'@fortawesome/fontawesome-svg-core',
|
|
38
|
-
'@fortawesome/free-solid-svg-icons',
|
|
39
|
-
'@fortawesome/react-fontawesome'
|
|
40
|
-
],
|
|
41
|
-
bootstrap: ['bootstrap', 'react-bootstrap'],
|
|
42
|
-
uikit: ['uikit', 'uikit-react'],
|
|
43
|
-
foundation: ['foundation-sites'],
|
|
44
|
-
materialize: ['materialize-css'],
|
|
45
|
-
bulma: ['bulma'],
|
|
46
|
-
materialUi: ['@material-ui/core'],
|
|
47
|
-
lintStaged: ['husky', 'lint-staged'],
|
|
48
|
-
redux: ['redux', 'react-redux', 'redux-saga'],
|
|
49
|
-
reduxJest: ['redux-mock-store'],
|
|
50
|
-
core: [
|
|
51
|
-
'@babel/runtime-corejs3',
|
|
52
|
-
'core-js@3',
|
|
53
|
-
'normalize-scss',
|
|
54
|
-
'prop-types',
|
|
55
|
-
'react',
|
|
56
|
-
'react-dom',
|
|
57
|
-
'react-router-dom',
|
|
58
|
-
'reselect',
|
|
59
|
-
'classnames'
|
|
60
|
-
],
|
|
61
|
-
storybook: [
|
|
62
|
-
'@storybook/react',
|
|
63
|
-
'@storybook/builder-webpack5',
|
|
64
|
-
'@storybook/manager-webpack5'
|
|
65
|
-
],
|
|
66
|
-
esdoc: [
|
|
67
|
-
'esdoc',
|
|
68
|
-
'esdoc-ecmascript-proposal-plugin',
|
|
69
|
-
'esdoc-jsx-plugin',
|
|
70
|
-
'esdoc-standard-plugin',
|
|
71
|
-
'opener'
|
|
72
|
-
],
|
|
73
|
-
jest: [
|
|
74
|
-
'babel-jest',
|
|
75
|
-
'eslint-plugin-jest',
|
|
76
|
-
'jest',
|
|
77
|
-
'react-test-renderer',
|
|
78
|
-
'opener'
|
|
79
|
-
],
|
|
80
|
-
dev: [
|
|
81
|
-
'@babel/core',
|
|
82
|
-
'@babel/eslint-parser',
|
|
83
|
-
'@babel/plugin-transform-runtime',
|
|
84
|
-
'@babel/preset-env',
|
|
85
|
-
'@babel/preset-react',
|
|
86
|
-
'@babel/register',
|
|
87
|
-
'autoprefixer',
|
|
88
|
-
'babel-loader',
|
|
89
|
-
'clean-webpack-plugin',
|
|
90
|
-
'cross-env',
|
|
91
|
-
'css-loader',
|
|
92
|
-
'css-minimizer-webpack-plugin',
|
|
93
|
-
'eslint-config-prettier',
|
|
94
|
-
'eslint-import-resolver-webpack',
|
|
95
|
-
'eslint-plugin-import',
|
|
96
|
-
'eslint-plugin-jsx-a11y',
|
|
97
|
-
'eslint-plugin-prettier',
|
|
98
|
-
'eslint-plugin-react-hooks',
|
|
99
|
-
'eslint-plugin-react',
|
|
100
|
-
'eslint-webpack-plugin',
|
|
101
|
-
'eslint',
|
|
102
|
-
'html-loader',
|
|
103
|
-
'html-webpack-plugin',
|
|
104
|
-
'mini-css-extract-plugin',
|
|
105
|
-
'postcss-flexbugs-fixes',
|
|
106
|
-
'postcss-loader',
|
|
107
|
-
'postcss-scss',
|
|
108
|
-
'prettier',
|
|
109
|
-
'sass-loader',
|
|
110
|
-
'sass',
|
|
111
|
-
'style-loader',
|
|
112
|
-
'stylelint-config-recommended',
|
|
113
|
-
'stylelint-webpack-plugin',
|
|
114
|
-
'stylelint',
|
|
115
|
-
'terser-webpack-plugin',
|
|
116
|
-
'webpack-cli',
|
|
117
|
-
'webpack',
|
|
118
|
-
'webpack-dev-server'
|
|
119
|
-
]
|
|
120
|
-
};
|
|
121
|
-
const files = {
|
|
122
|
-
core: [
|
|
123
|
-
'.babelrc',
|
|
124
|
-
'.prettierrc',
|
|
125
|
-
'.stylelintrc',
|
|
126
|
-
'.editorconfig',
|
|
127
|
-
'jsconfig.json',
|
|
128
|
-
'.browserslistrc',
|
|
129
|
-
src('utils', 'index.js')
|
|
130
|
-
],
|
|
131
|
-
templated: [
|
|
132
|
-
'.eslintrc.js',
|
|
133
|
-
'package.json',
|
|
134
|
-
src('index.js'),
|
|
135
|
-
src('index.html'),
|
|
136
|
-
src('index.scss'),
|
|
137
|
-
'webpack.config.babel.js'
|
|
138
|
-
],
|
|
139
|
-
esdoc: ['.esdoc.json'],
|
|
140
|
-
jest: ['jest.config.js'],
|
|
141
|
-
lintStaged: ['.lintstagedrc']
|
|
142
|
-
};
|
|
143
|
-
const directories = {
|
|
144
|
-
redux: [src('reducers'), src('sagas'), src('selectors')],
|
|
145
|
-
core: [src('components'), src('utils')]
|
|
146
|
-
};
|
|
147
|
-
const scripts = {
|
|
148
|
-
esdoc: {
|
|
149
|
-
'build:documentation': 'esdoc',
|
|
150
|
-
'view:documentation': 'opener ./docs/index.html'
|
|
151
|
-
},
|
|
152
|
-
jest: {
|
|
153
|
-
test: 'jest',
|
|
154
|
-
'view:coverage': 'opener ./coverage/index.html'
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export default class extends Generator {
|
|
159
|
-
constructor(...args) {
|
|
160
|
-
super(...args);
|
|
161
|
-
|
|
162
|
-
this.env.adapter.promptModule.registerPrompt(
|
|
163
|
-
'autocomplete',
|
|
164
|
-
inquirerPrompt
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
this.answers = {};
|
|
168
|
-
this.fileSystem = fileSystem(this);
|
|
169
|
-
this.sourceRoot(this.fileSystem.resolve('templates', 'app'));
|
|
170
|
-
this.registerTransformStream(
|
|
171
|
-
gulpIf(
|
|
172
|
-
/\.js$/,
|
|
173
|
-
prettier(readFileSync(this.fileSystem.resolve('.prettierrc')))
|
|
174
|
-
)
|
|
175
|
-
);
|
|
176
|
-
this.registerTransformStream(
|
|
177
|
-
gulpIf(
|
|
178
|
-
/\.scss$/,
|
|
179
|
-
stylelint({
|
|
180
|
-
configFile: this.fileSystem.resolve('.stylelintrc')
|
|
181
|
-
})
|
|
182
|
-
)
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async prompting() {
|
|
187
|
-
const { name, email } = this.user.git;
|
|
188
|
-
|
|
189
|
-
this.answers = await this.prompt([
|
|
190
|
-
{
|
|
191
|
-
type: 'input',
|
|
192
|
-
name: 'package.name',
|
|
193
|
-
message: 'Package name',
|
|
194
|
-
default: this.appname.replace(/\s+/g, '-')
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
type: 'input',
|
|
198
|
-
name: 'package.version',
|
|
199
|
-
message: 'Package version',
|
|
200
|
-
default: '0.1.0'
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
type: 'autocomplete',
|
|
204
|
-
name: 'package.license',
|
|
205
|
-
message: 'Package license',
|
|
206
|
-
source: (_, input) => {
|
|
207
|
-
const pattern = new RegExp(`.*${input}.*`, 'i');
|
|
208
|
-
|
|
209
|
-
return new Promise((resolve) => {
|
|
210
|
-
resolve(
|
|
211
|
-
spdxIdentifiers.filter((identifier) => pattern.test(identifier))
|
|
212
|
-
);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
type: 'input',
|
|
218
|
-
name: 'package.description',
|
|
219
|
-
message: 'Package description'
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
type: 'input',
|
|
223
|
-
name: 'author.name',
|
|
224
|
-
message: 'Author name',
|
|
225
|
-
default: name()
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
type: 'input',
|
|
229
|
-
name: 'author.email',
|
|
230
|
-
message: 'Author email address',
|
|
231
|
-
default: email()
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
type: 'list',
|
|
235
|
-
name: 'styleFramework',
|
|
236
|
-
message: 'What CSS framework would you like to use?',
|
|
237
|
-
choices: styleFrameworks
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
type: 'confirm',
|
|
241
|
-
name: 'flags.addLintStaged',
|
|
242
|
-
message: 'Force linting before commits?',
|
|
243
|
-
default: true
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
type: 'confirm',
|
|
247
|
-
name: 'flags.addFontAwesome',
|
|
248
|
-
message: 'Add Font Awesome?',
|
|
249
|
-
default: true
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
type: 'confirm',
|
|
253
|
-
name: 'flags.addRedux',
|
|
254
|
-
message: 'Add Redux?',
|
|
255
|
-
default: true
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
type: 'confirm',
|
|
259
|
-
name: 'flags.addJest',
|
|
260
|
-
message: 'Add Jest?',
|
|
261
|
-
default: true
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
type: 'confirm',
|
|
265
|
-
name: 'flags.addStorybook',
|
|
266
|
-
message: 'Add Storybook?',
|
|
267
|
-
default: false
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
type: 'confirm',
|
|
271
|
-
name: 'flags.addESDoc',
|
|
272
|
-
message: 'Add ESDoc?',
|
|
273
|
-
default: false
|
|
274
|
-
}
|
|
275
|
-
]);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
async writing() {
|
|
279
|
-
const {
|
|
280
|
-
flags,
|
|
281
|
-
package: { license },
|
|
282
|
-
author: { name, email }
|
|
283
|
-
} = this.answers;
|
|
284
|
-
|
|
285
|
-
let licenseText = 'Place your license here.\n';
|
|
286
|
-
|
|
287
|
-
if (license !== 'SEE LICENSE IN LICENSE') {
|
|
288
|
-
this.log(`Downloading ${license} license from spdx/license-list-data...`);
|
|
289
|
-
const { body: rawLicense } = await got(
|
|
290
|
-
`https://raw.githubusercontent.com/spdx/license-list-data/master/text/${license}.txt`
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
licenseText = rawLicense
|
|
294
|
-
.replace('<year>', format(new Date(), 'yyyy'))
|
|
295
|
-
.replace('<copyright holders>', `${name} <${email}>`);
|
|
296
|
-
}
|
|
297
|
-
this.fileSystem.createFile('LICENSE', licenseText);
|
|
298
|
-
|
|
299
|
-
// copy files and directories
|
|
300
|
-
files.core.forEach(this.fileSystem.copy);
|
|
301
|
-
files.templated.forEach(this.fileSystem.copyTemplateInPlace);
|
|
302
|
-
directories.core.forEach(this.fileSystem.copyDirectory);
|
|
303
|
-
|
|
304
|
-
// this is a workaround for npm not packaging up .gitignore files
|
|
305
|
-
this.fileSystem.copyTo('gitignore', '.gitignore');
|
|
306
|
-
|
|
307
|
-
if (flags.addRedux) {
|
|
308
|
-
directories.redux.forEach(this.fileSystem.copyDirectory);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (flags.addJest) {
|
|
312
|
-
files.jest.forEach(this.fileSystem.copy);
|
|
313
|
-
this.fs.append(this.destinationPath('.gitignore'), 'coverage/');
|
|
314
|
-
this.fs.extendJSON(this.destinationPath('package.json'), {
|
|
315
|
-
scripts: {
|
|
316
|
-
...scripts.jest
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (flags.addESDoc) {
|
|
322
|
-
files.esdoc.forEach(this.fileSystem.copy);
|
|
323
|
-
this.fs.append(this.destinationPath('.gitignore'), 'docs/');
|
|
324
|
-
this.fs.extendJSON(this.destinationPath('package.json'), {
|
|
325
|
-
scripts: {
|
|
326
|
-
...scripts.esdoc
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (flags.addLintStaged) {
|
|
332
|
-
files.lintStaged.forEach(this.fileSystem.copy);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
install() {
|
|
337
|
-
const main = [];
|
|
338
|
-
const dev = [];
|
|
339
|
-
const { flags, styleFramework } = this.answers;
|
|
340
|
-
|
|
341
|
-
this.log('Building a list of packages to install');
|
|
342
|
-
|
|
343
|
-
main.push.apply(main, packages.core);
|
|
344
|
-
dev.push.apply(dev, packages.dev);
|
|
345
|
-
|
|
346
|
-
if (styleFramework !== null) {
|
|
347
|
-
main.push.apply(main, packages[styleFramework]);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (flags.addLintStaged) {
|
|
351
|
-
dev.push.apply(dev, packages.lintStaged);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
if (flags.addFontAwesome) {
|
|
355
|
-
main.push.apply(main, packages.fontAwesome);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (flags.addRedux) {
|
|
359
|
-
main.push.apply(main, packages.redux);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (flags.addJest) {
|
|
363
|
-
dev.push.apply(dev, packages.jest);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (flags.addRedux && flags.addJest) {
|
|
367
|
-
dev.push.apply(dev, packages.reduxJest);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (flags.addStorybook) {
|
|
371
|
-
dev.push.apply(dev, packages.storybook);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (flags.addESDoc) {
|
|
375
|
-
main.push.apply(main, packages.esdoc);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
this.log(
|
|
379
|
-
`Getting ready to install ${main.length} dependencies and ${dev.length} dev dependencies.`
|
|
380
|
-
);
|
|
381
|
-
this.log(`Dependencies: ${main.join(' ')}
|
|
382
|
-
Dev dependencies: ${dev.join(' ')}`);
|
|
383
|
-
this.npmInstall(main, { save: true });
|
|
384
|
-
this.npmInstall(dev, { 'save-dev': true });
|
|
385
|
-
this.spawnCommandSync('git', ['init']);
|
|
386
|
-
this.spawnCommandSync('npx', ['husky', 'init']);
|
|
387
|
-
this.spawnCommandSync('bash', [
|
|
388
|
-
'-c',
|
|
389
|
-
'echo "npx lint-staged" > .husky/pre-commit'
|
|
390
|
-
]);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
1
|
+
import{join as e}from"path";import t from"gulp-if";import{format as s}from"date-fns";import a from"gulp-prettier";import{readFileSync as i}from"jsonfile";import o from"yeoman-stylelint";import n from"spdx-license-ids"with{type:"json"};import r from"yeoman-generator";import l,{src as c}from"../util/fs.js";n.push("SEE LICENSE IN LICENSE"),n.sort();const d=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,/^\d/.test(t)?`^${t}`:t])),p=[{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","react-bootstrap","@popperjs/core"],uikit:["uikit","uikit-react"],foundation:["foundation-sites","react-foundation"],materialize:["materialize-css","react-materialize"],bulma:["bulma"],materialUi:["@mui/material","@emotion/react","@emotion/styled"],lintStaged:["husky","lint-staged"],redux:["redux","react-redux","redux-saga"],reduxJest:["redux-mock-store"],rtl:["@testing-library/react","@testing-library/dom"],core:["normalize-scss","react","react-dom","react-router-dom@6","reselect","classnames"],storybook:["storybook@10","@storybook/react-vite@10","@storybook/addon-docs@10","@storybook/addon-a11y@10","@storybook/addon-links@10","@storybook/addon-themes@10","@vitejs/plugin-react","vite"],esdoc:["esdoc","esdoc-ecmascript-proposal-plugin","esdoc-jsx-plugin","esdoc-standard-plugin","opener"],jest:["@types/jest","eslint-plugin-jest","jest","react-test-renderer","opener"],dev:["@eslint/js@9","@types/react","@types/react-dom","autoprefixer","clean-webpack-plugin","cross-env","css-loader","css-minimizer-webpack-plugin","eslint-config-prettier","eslint-import-resolver-typescript","eslint-plugin-import-x","eslint-plugin-prettier","eslint-plugin-react-hooks","eslint-plugin-react","eslint-webpack-plugin","eslint@9","globals","html-loader","html-webpack-plugin","mini-css-extract-plugin","postcss","postcss-flexbugs-fixes","postcss-loader","postcss-scss","prettier","sass-loader","sass","style-loader","stylelint-config-recommended","stylelint-webpack-plugin","stylelint","terser-webpack-plugin","ts-loader","typescript@6","typescript-eslint","webpack-cli","webpack","webpack-dev-server"]},g={foundation:["@types/react-foundation"]},u={core:[".yarnrc.yml",".prettierrc",".stylelintrc",".editorconfig",".browserslistrc"],templated:["tsconfig.json",c("index.tsx"),c("index.html"),c("utils","index.ts")],esdoc:[".esdoc.json"],jest:["jest.config.js"],storybook:[e(".storybook","main.ts"),e(".storybook","preview.ts")],lintStaged:[".lintstagedrc"]},y={redux:[c("reducers"),c("sagas"),c("selectors")],templated:[c("components"),c("pages"),c("types")]},f={"build:documentation":"esdoc","view:documentation":"opener ./docs/index.html"},h={test:"jest","view:coverage":"opener ./coverage/index.html"},k={storybook:"storybook dev -p 6006","build:storybook":"storybook build"};class b extends r{answers;fileSystem;constructor(e,t,s){super(e,t,s),this.answers={component:{},deploy:{},module:{},package:{},author:{},flags:{}},this.fileSystem=l(this),this.sourceRoot(this.fileSystem.resolve("templates","app"))}initializing(){this.env.options.nodePackageManager="yarn",process.env.YARN_NPM_MINIMAL_AGE_GATE="0",this.queueTransformStream({},t(/\.tsx?$/,a(i(this.fileSystem.resolve(".prettierrc")))),t(/\.scss$/,o({configFile:this.fileSystem.resolve(".stylelintrc")})))}async prompting(){const[e,t]=await Promise.all([this.git.name(),this.git.email()]);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:"search",name:"package.license",message:"Package license",source:e=>{const t=new RegExp(`.*${e??""}.*`,"i");return n.filter(e=>t.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:"select",name:"styleFramework",message:"What CSS framework would you like to use?",choices:p},{type:"confirm",name:"flags.addCnamePlugin",message:"Deploying to GitHub Pages with CNAME?",default:!1},{type:"input",name:"deploy.domain",message:"Hostname to use",when:e=>e.flags.addCnamePlugin},{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:!1},{type:"confirm",name:"flags.addJest",message:"Add Jest?",default:!1},{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,styleFramework:a,package:{license:i},author:{name:o,email:n}}=this.answers;let r="Place your license here.\n";if("SEE LICENSE IN LICENSE"!==i){this.log(`Downloading ${i} license from spdx/license-list-data...`);const e=await fetch(`https://raw.githubusercontent.com/spdx/license-list-data/master/text/${i}.txt`);if(200!==e.status)this.log(`License download failed with HTTP ${e.status} - ${e.statusText}`);else{r=(await e.text()).replace("<year>",s(new Date,"yyyy")).replace("<copyright holders>",`${o} <${n}>`)}}this.fileSystem.createFile("LICENSE",r),u.core.forEach(this.fileSystem.copy),u.templated.forEach(this.fileSystem.copyTemplateInPlace),y.templated.forEach(this.fileSystem.copyDirectory),this.fileSystem.copyTemplate("_package.json","package.json"),this.fileSystem.copyTemplate("_eslint.config.mjs","eslint.config.mjs"),this.fileSystem.copyTemplate("webpack.config.nts","webpack.config.ts"),"materialUi"!==this.answers.styleFramework&&this.fileSystem.copyTemplate(c("index.nscss"),c("index.scss")),this.fileSystem.copyTo("gitignore",".gitignore"),t.addRedux&&y.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:{...h}})),t.addStorybook&&(u.storybook.forEach(this.fileSystem.copyTemplateInPlace),this.fileSystem.copyTemplate(e("_stories","SuspenseFallback.stories.tsx"),c("components","SuspenseFallback.stories.tsx")),this.fs.append(this.destinationPath(".gitignore"),"storybook-static/"),this.fs.extendJSON(this.destinationPath("package.json"),{scripts:{...k}})),t.addEsDoc&&(u.esdoc.forEach(this.fileSystem.copy),this.fs.append(this.destinationPath(".gitignore"),"docs/"),this.fs.extendJSON(this.destinationPath("package.json"),{scripts:{...f}})),t.addLintStaged&&(u.lintStaged.forEach(this.fileSystem.copy),this.fileSystem.createFile(".husky/pre-commit","npx lint-staged\n"));const l=[...m.core],p=[...m.dev];a&&(l.push(...m[a]),g[a]&&p.push(...g[a])),t.addLintStaged&&p.push(...m.lintStaged),t.addFontAwesome&&l.push(...m.fontAwesome),t.addRedux&&l.push(...m.redux),t.addJest&&p.push(...m.jest),t.addRedux&&t.addJest&&p.push(...m.reduxJest),t.addStorybook&&p.push(...m.storybook),t.addEsDoc&&l.push(...m.esdoc),this.log(`Resolving ${l.length} dependencies and ${p.length} dev dependencies.`);const[b,w]=await Promise.all([this.addDependencies(l),this.addDevDependencies(p)]);this.packageJson.merge({dependencies:d(b),devDependencies:d(w)})}install(){this.spawnSync("yarn",["set","version","stable"],{stdio:"inherit"})}async end(){const{flags:e}=this.answers;this.spawnSync("git",["init"],{stdio:"inherit"}),e.addLintStaged&&this.spawnSync("npx",["husky"],{stdio:"inherit"})}}export{b as default};
|