generator-reackt 0.3.3 → 0.6.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 +3 -3
- package/.stylelintrc +155 -71
- package/generators/app/index.js +392 -309
- package/generators/component/index.js +51 -56
- package/generators/module/index.js +127 -117
- package/generators/util/fs.js +34 -22
- package/package.json +63 -66
- package/templates/app/.babelrc +1 -6
- package/templates/app/.eslintrc.js +46 -185
- package/templates/app/.stylelintrc +57 -146
- package/templates/app/jsconfig.json +1 -2
- package/templates/app/src/components/{App/App.js → App.js} +1 -1
- package/templates/app/src/index.js +7 -13
- package/templates/app/src/index.scss +0 -1
- package/templates/app/webpack.config.babel.js +2 -8
- package/templates/app/src/icons.js +0 -4
|
@@ -1,56 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
exports.default = _default;
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
import fileSystem from '../util/fs.js';
|
|
6
|
+
|
|
7
|
+
// we cannot use ES6 imports on this object, as it directly exports a class to
|
|
8
|
+
// module.exports - no default export nor a named export is present for us to use
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const __dirname = fileURLToPath(import.meta.url);
|
|
11
|
+
const Generator = require('yeoman-generator');
|
|
12
|
+
|
|
13
|
+
const src = (...paths) => join('src', ...paths);
|
|
14
|
+
|
|
15
|
+
export default class extends Generator {
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super(...args);
|
|
18
|
+
|
|
19
|
+
this.sourceRoot(join(__dirname, '..', '..', 'templates', 'component'));
|
|
20
|
+
this.answers = {};
|
|
21
|
+
this.fileSystem = fileSystem(this);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async prompting() {
|
|
25
|
+
this.answers = await this.prompt([
|
|
26
|
+
{
|
|
27
|
+
type: 'input',
|
|
28
|
+
name: 'component.name',
|
|
29
|
+
message: 'Component name'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'confirm',
|
|
33
|
+
name: 'flags.addRedux',
|
|
34
|
+
message: 'Connect this component to the Redux store?',
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async writing() {
|
|
41
|
+
const {
|
|
42
|
+
component: { name }
|
|
43
|
+
} = this.answers;
|
|
44
|
+
const fileName = src('components', `${name}.js`);
|
|
45
|
+
const testName = src('components', `${name}.test.js`);
|
|
46
|
+
|
|
47
|
+
this.log(`Creating ${name} component`);
|
|
48
|
+
await this.fileSystem.copyTemplate('index.js', fileName);
|
|
49
|
+
await this.fileSystem.copyTemplate('index.test.js', testName);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,117 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (flags.
|
|
100
|
-
this.fileSystem.copyTemplate(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
import { join, dirname } from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
import fileSystem from '../util/fs.js';
|
|
6
|
+
|
|
7
|
+
// we cannot use ES6 imports on this object, as it directly exports a class to
|
|
8
|
+
// module.exports - no default export nor a named export is present for us to use
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const __dirname = fileURLToPath(import.meta.url);
|
|
11
|
+
const Generator = require('yeoman-generator');
|
|
12
|
+
|
|
13
|
+
const src = (...paths) => join('src', ...paths);
|
|
14
|
+
|
|
15
|
+
export default class extends Generator {
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super(...args);
|
|
18
|
+
|
|
19
|
+
this.sourceRoot(join(__dirname, '..', '..', 'templates', 'module'));
|
|
20
|
+
this.answers = {};
|
|
21
|
+
this.fileSystem = fileSystem(this);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async prompting() {
|
|
25
|
+
this.answers = await this.prompt([
|
|
26
|
+
{
|
|
27
|
+
type: 'input',
|
|
28
|
+
name: 'module.name',
|
|
29
|
+
message: 'Module name'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'list',
|
|
33
|
+
name: 'directoryMode',
|
|
34
|
+
message: 'Choose a way of structuring the module.',
|
|
35
|
+
choices: [
|
|
36
|
+
{
|
|
37
|
+
name: 'Create a directory with the module name and an index.js file inside that.',
|
|
38
|
+
value: 'dir',
|
|
39
|
+
short: 'Directory'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Create a file with the module name.',
|
|
43
|
+
value: 'file',
|
|
44
|
+
short: 'File'
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
name: 'flags.createReducer',
|
|
51
|
+
message: 'Generate a reducer?',
|
|
52
|
+
default: true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'confirm',
|
|
56
|
+
name: 'flags.createSaga',
|
|
57
|
+
message: 'Generate a saga?',
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
name: 'flags.createSelector',
|
|
63
|
+
message: 'Generate a selector?',
|
|
64
|
+
default: true
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'confirm',
|
|
68
|
+
name: 'flags.addJest',
|
|
69
|
+
message: 'Generate test files?',
|
|
70
|
+
default: true
|
|
71
|
+
}
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async writing() {
|
|
76
|
+
const {
|
|
77
|
+
directoryMode,
|
|
78
|
+
module: { name },
|
|
79
|
+
flags
|
|
80
|
+
} = this.answers;
|
|
81
|
+
|
|
82
|
+
this.log(`Creating module ${name}`);
|
|
83
|
+
|
|
84
|
+
const buildPaths = (ext) => {
|
|
85
|
+
const namePath = `${name}${ext}`;
|
|
86
|
+
const indexPath = `index${ext}`;
|
|
87
|
+
const destPath = [];
|
|
88
|
+
|
|
89
|
+
switch (directoryMode) {
|
|
90
|
+
default:
|
|
91
|
+
case 'file':
|
|
92
|
+
destPath.push(namePath);
|
|
93
|
+
break;
|
|
94
|
+
case 'dir':
|
|
95
|
+
destPath.push(name, indexPath);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (flags.createReducer) {
|
|
100
|
+
this.fileSystem.copyTemplate(
|
|
101
|
+
join('reducer', indexPath),
|
|
102
|
+
src('reducers', ...destPath)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (flags.createSaga) {
|
|
107
|
+
this.fileSystem.copyTemplate(
|
|
108
|
+
join('saga', indexPath),
|
|
109
|
+
src('sagas', ...destPath)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (flags.createSelector) {
|
|
114
|
+
this.fileSystem.copyTemplate(
|
|
115
|
+
join('selector', indexPath),
|
|
116
|
+
src('selectors', ...destPath)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
buildPaths('.js');
|
|
122
|
+
|
|
123
|
+
if (flags.addJest) {
|
|
124
|
+
buildPaths('.test.js');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
package/generators/util/fs.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { mkdirp } from 'mkdirp';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = fileURLToPath(import.meta.url);
|
|
6
|
+
|
|
7
|
+
export default (gen) => ({
|
|
8
|
+
copy: (file) =>
|
|
9
|
+
gen.fs.copy(gen.templatePath(file), gen.destinationPath(file)),
|
|
10
|
+
copyTo: (src, dst) =>
|
|
11
|
+
gen.fs.copy(gen.templatePath(src), gen.destinationPath(dst)),
|
|
12
|
+
copyDirectory: (dir) =>
|
|
13
|
+
gen.fs.copyTpl(
|
|
14
|
+
gen.templatePath(`${dir}/**/*`),
|
|
15
|
+
gen.destinationPath(dir),
|
|
16
|
+
gen.answers
|
|
17
|
+
),
|
|
18
|
+
copyTemplate: (source, destination) =>
|
|
19
|
+
gen.fs.copyTpl(
|
|
20
|
+
gen.templatePath(source),
|
|
21
|
+
gen.destinationPath(destination),
|
|
22
|
+
gen.answers
|
|
23
|
+
),
|
|
24
|
+
copyTemplateInPlace: (file) =>
|
|
25
|
+
gen.fs.copyTpl(
|
|
26
|
+
gen.templatePath(file),
|
|
27
|
+
gen.destinationPath(file),
|
|
28
|
+
gen.answers
|
|
29
|
+
),
|
|
30
|
+
createFile: (file, contents) =>
|
|
31
|
+
gen.fs.write(gen.destinationPath(file), contents),
|
|
32
|
+
makeDirectory: mkdirp,
|
|
33
|
+
resolve: (...paths) => join(__dirname, '..', '..', '..', ...paths)
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -1,66 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "generator-reackt",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Create an opinionated React-based web applcication",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
".
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"generator",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"gulp-
|
|
40
|
-
"
|
|
41
|
-
"inquirer-autocomplete-prompt": "^
|
|
42
|
-
"jsonfile": "^6.1.0",
|
|
43
|
-
"mkdirp": "^
|
|
44
|
-
"spdx-license-ids": "^3.0.
|
|
45
|
-
"yeoman-generator": "^4.13.0",
|
|
46
|
-
"yeoman-stylelint": "^0.
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@babel/
|
|
50
|
-
"@babel/
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"prettier-eslint": "^13.0.0"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "generator-reackt",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Create an opinionated React-based web applcication",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"generators",
|
|
8
|
+
"templates",
|
|
9
|
+
".prettierrc",
|
|
10
|
+
".stylelintrc"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "ssh://git@git.codecube.xyz:7999/web/generator-reackt.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"yeoman-generator",
|
|
18
|
+
"generator",
|
|
19
|
+
"scaffold",
|
|
20
|
+
"frontend",
|
|
21
|
+
"reactjs",
|
|
22
|
+
"webpack",
|
|
23
|
+
"redux"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"version": "auto-changelog -l false -p --hide-credit && git add CHANGELOG.md",
|
|
27
|
+
"prepare": "husky"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=16"
|
|
31
|
+
},
|
|
32
|
+
"author": "ayan4m1 <andrew@bulletlogic.com>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"chalk": "^5.3.0",
|
|
36
|
+
"date-fns": "^3.6.0",
|
|
37
|
+
"got": "^14.4.1",
|
|
38
|
+
"gulp-if": "^3.0.0",
|
|
39
|
+
"gulp-prettier": "^6.0.0",
|
|
40
|
+
"inquirer": "9.3.5",
|
|
41
|
+
"inquirer-autocomplete-prompt": "^3.0.1",
|
|
42
|
+
"jsonfile": "^6.1.0",
|
|
43
|
+
"mkdirp": "^3.0.1",
|
|
44
|
+
"spdx-license-ids": "^3.0.18",
|
|
45
|
+
"yeoman-generator": "^4.13.0",
|
|
46
|
+
"yeoman-stylelint": "^1.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
50
|
+
"@babel/plugin-syntax-import-assertions": "^7.24.7",
|
|
51
|
+
"auto-changelog": "^2.4.0",
|
|
52
|
+
"eslint": "8.57.0",
|
|
53
|
+
"eslint-config-prettier": "^9.1.0",
|
|
54
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
55
|
+
"husky": "^9.0.11",
|
|
56
|
+
"lint-staged": "^15.2.7",
|
|
57
|
+
"postcss": "^8.4.39",
|
|
58
|
+
"postcss-scss": "^4.0.9",
|
|
59
|
+
"prettier": "^3.3.2",
|
|
60
|
+
"stylelint": "^16.6.1",
|
|
61
|
+
"stylelint-config-recommended": "^14.0.1"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/templates/app/.babelrc
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
{
|
|
2
2
|
"presets": ["@babel/preset-env", ["@babel/preset-react", { "runtime": "automatic" }]],
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@babel/plugin-proposal-class-properties",
|
|
5
|
-
"@babel/plugin-proposal-object-rest-spread",
|
|
6
|
-
"@babel/plugin-transform-runtime",
|
|
7
|
-
"@babel/plugin-transform-regenerator"
|
|
8
|
-
]
|
|
3
|
+
"plugins": ["@babel/plugin-transform-runtime"]
|
|
9
4
|
}
|