@ronas-it/nx-generators 0.10.2 → 0.10.4
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/.eslintrc.json +37 -0
- package/README.md +10 -1
- package/jest.config.ts +10 -0
- package/package.json +2 -2
- package/project.json +61 -0
- package/src/generators/code-checks/config.ts +17 -0
- package/src/generators/code-checks/files/.eslintrc.json.template +173 -1
- package/src/generators/code-checks/generator.ts +68 -0
- package/src/generators/code-checks/scripts.ts +5 -0
- package/src/generators/entity-api/generator.ts +127 -0
- package/src/generators/expo-app/generator.ts +152 -0
- package/src/generators/expo-app/scripts.ts +12 -0
- package/src/generators/form/generator.ts +61 -0
- package/src/generators/form/utils/add-form-usage.ts +99 -0
- package/src/generators/form/utils/get-app-name.ts +3 -0
- package/src/generators/form/utils/get-form-utils-directory.ts +59 -0
- package/src/generators/form/utils/update-index.ts +15 -0
- package/src/generators/lib-move/generator.ts +57 -0
- package/src/generators/lib-remove/generator.ts +22 -0
- package/src/generators/lib-rename/generator.ts +25 -0
- package/src/generators/lib-tags/generator.ts +66 -0
- package/src/generators/lib-tags/interfaces/context.ts +9 -0
- package/src/generators/lib-tags/interfaces/index.ts +2 -0
- package/src/generators/lib-tags/interfaces/verify-tag-config.ts +12 -0
- package/src/generators/lib-tags/types/index.ts +1 -0
- package/src/generators/lib-tags/types/tag.ts +1 -0
- package/src/generators/lib-tags/utils/check-lib-tags.ts +145 -0
- package/src/generators/next-app/generator.ts +104 -0
- package/src/generators/react-component/generator.ts +80 -0
- package/src/generators/react-lib/generator.ts +86 -0
- package/src/generators/repo-config/generator.ts +44 -0
- package/src/generators/repo-config/scripts.ts +3 -0
- package/src/shared/dependencies.ts +76 -0
- package/src/shared/enums/base-generator-type.ts +4 -0
- package/src/shared/generators/api-client/generator.ts +43 -0
- package/src/shared/generators/app-env/generator.ts +35 -0
- package/src/shared/generators/app-env/lib-files/shared/utils/app-env/src/app-env.ts.template +1 -1
- package/src/shared/generators/auth/generator.ts +100 -0
- package/src/shared/generators/form-utils/generator.ts +22 -0
- package/src/shared/generators/rn-styles/generator.ts +44 -0
- package/src/shared/generators/storage/generator.ts +29 -0
- package/src/shared/generators/store/generator.ts +42 -0
- package/src/shared/generators/store/schema.d.ts +1 -1
- package/src/shared/generators/ui-kitten/generator.ts +51 -0
- package/src/shared/templates/config-template.json +2 -12
- package/src/shared/utils/cli-utils.ts +164 -0
- package/src/shared/utils/config-utils.ts +159 -0
- package/src/shared/utils/constants.ts +3 -0
- package/src/shared/utils/dynamic-import.ts +3 -0
- package/src/shared/utils/format-utils.ts +15 -0
- package/src/shared/utils/get-lib-directory-name.ts +13 -0
- package/src/shared/utils/ts-utils.ts +20 -0
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +9 -0
- package/src/generators/code-checks/config.d.ts +0 -18
- package/src/generators/code-checks/config.js +0 -20
- package/src/generators/code-checks/config.js.map +0 -1
- package/src/generators/code-checks/generator.d.ts +0 -4
- package/src/generators/code-checks/generator.js +0 -53
- package/src/generators/code-checks/generator.js.map +0 -1
- package/src/generators/code-checks/scripts.d.ts +0 -6
- package/src/generators/code-checks/scripts.js +0 -8
- package/src/generators/code-checks/scripts.js.map +0 -1
- package/src/generators/entity-api/generator.d.ts +0 -4
- package/src/generators/entity-api/generator.js +0 -84
- package/src/generators/entity-api/generator.js.map +0 -1
- package/src/generators/expo-app/generator.d.ts +0 -4
- package/src/generators/expo-app/generator.js +0 -93
- package/src/generators/expo-app/generator.js.map +0 -1
- package/src/generators/expo-app/scripts.d.ts +0 -13
- package/src/generators/expo-app/scripts.js +0 -15
- package/src/generators/expo-app/scripts.js.map +0 -1
- package/src/generators/form/generator.d.ts +0 -4
- package/src/generators/form/generator.js +0 -48
- package/src/generators/form/generator.js.map +0 -1
- package/src/generators/form/utils/add-form-usage.d.ts +0 -1
- package/src/generators/form/utils/add-form-usage.js +0 -67
- package/src/generators/form/utils/add-form-usage.js.map +0 -1
- package/src/generators/form/utils/get-app-name.d.ts +0 -1
- package/src/generators/form/utils/get-app-name.js +0 -8
- package/src/generators/form/utils/get-app-name.js.map +0 -1
- package/src/generators/form/utils/get-form-utils-directory.d.ts +0 -2
- package/src/generators/form/utils/get-form-utils-directory.js +0 -34
- package/src/generators/form/utils/get-form-utils-directory.js.map +0 -1
- package/src/generators/form/utils/index.js +0 -8
- package/src/generators/form/utils/index.js.map +0 -1
- package/src/generators/form/utils/update-index.d.ts +0 -2
- package/src/generators/form/utils/update-index.js +0 -18
- package/src/generators/form/utils/update-index.js.map +0 -1
- package/src/generators/lib-move/generator.d.ts +0 -4
- package/src/generators/lib-move/generator.js +0 -34
- package/src/generators/lib-move/generator.js.map +0 -1
- package/src/generators/lib-remove/generator.d.ts +0 -4
- package/src/generators/lib-remove/generator.js +0 -22
- package/src/generators/lib-remove/generator.js.map +0 -1
- package/src/generators/lib-rename/generator.d.ts +0 -4
- package/src/generators/lib-rename/generator.js +0 -24
- package/src/generators/lib-rename/generator.js.map +0 -1
- package/src/generators/lib-tags/generator.d.ts +0 -4
- package/src/generators/lib-tags/generator.js +0 -56
- package/src/generators/lib-tags/generator.js.map +0 -1
- package/src/generators/lib-tags/interfaces/context.d.ts +0 -8
- package/src/generators/lib-tags/interfaces/context.js +0 -3
- package/src/generators/lib-tags/interfaces/context.js.map +0 -1
- package/src/generators/lib-tags/interfaces/index.d.ts +0 -1
- package/src/generators/lib-tags/interfaces/index.js +0 -5
- package/src/generators/lib-tags/interfaces/index.js.map +0 -1
- package/src/generators/lib-tags/utils/check-lib-tags.d.ts +0 -4
- package/src/generators/lib-tags/utils/check-lib-tags.js +0 -99
- package/src/generators/lib-tags/utils/check-lib-tags.js.map +0 -1
- package/src/generators/lib-tags/utils/index.js +0 -5
- package/src/generators/lib-tags/utils/index.js.map +0 -1
- package/src/generators/next-app/generator.d.ts +0 -4
- package/src/generators/next-app/generator.js +0 -71
- package/src/generators/next-app/generator.js.map +0 -1
- package/src/generators/react-component/generator.d.ts +0 -4
- package/src/generators/react-component/generator.js +0 -55
- package/src/generators/react-component/generator.js.map +0 -1
- package/src/generators/react-lib/generator.d.ts +0 -4
- package/src/generators/react-lib/generator.js +0 -49
- package/src/generators/react-lib/generator.js.map +0 -1
- package/src/generators/repo-config/generator.d.ts +0 -3
- package/src/generators/repo-config/generator.js +0 -36
- package/src/generators/repo-config/generator.js.map +0 -1
- package/src/generators/repo-config/scripts.d.ts +0 -4
- package/src/generators/repo-config/scripts.js +0 -6
- package/src/generators/repo-config/scripts.js.map +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +0 -1
- package/src/shared/dependencies.d.ts +0 -73
- package/src/shared/dependencies.js +0 -79
- package/src/shared/dependencies.js.map +0 -1
- package/src/shared/enums/base-generator-type.d.ts +0 -4
- package/src/shared/enums/base-generator-type.js +0 -9
- package/src/shared/enums/base-generator-type.js.map +0 -1
- package/src/shared/enums/index.js +0 -5
- package/src/shared/enums/index.js.map +0 -1
- package/src/shared/generators/api-client/generator.d.ts +0 -6
- package/src/shared/generators/api-client/generator.js +0 -35
- package/src/shared/generators/api-client/generator.js.map +0 -1
- package/src/shared/generators/api-client/index.js +0 -5
- package/src/shared/generators/api-client/index.js.map +0 -1
- package/src/shared/generators/app-env/generator.d.ts +0 -6
- package/src/shared/generators/app-env/generator.js +0 -25
- package/src/shared/generators/app-env/generator.js.map +0 -1
- package/src/shared/generators/app-env/index.js +0 -5
- package/src/shared/generators/app-env/index.js.map +0 -1
- package/src/shared/generators/auth/generator.d.ts +0 -4
- package/src/shared/generators/auth/generator.js +0 -74
- package/src/shared/generators/auth/generator.js.map +0 -1
- package/src/shared/generators/auth/index.js +0 -5
- package/src/shared/generators/auth/index.js.map +0 -1
- package/src/shared/generators/form-utils/generator.d.ts +0 -5
- package/src/shared/generators/form-utils/generator.js +0 -22
- package/src/shared/generators/form-utils/generator.js.map +0 -1
- package/src/shared/generators/form-utils/index.js +0 -5
- package/src/shared/generators/form-utils/index.js.map +0 -1
- package/src/shared/generators/index.js +0 -12
- package/src/shared/generators/index.js.map +0 -1
- package/src/shared/generators/rn-styles/generator.d.ts +0 -6
- package/src/shared/generators/rn-styles/generator.js +0 -36
- package/src/shared/generators/rn-styles/generator.js.map +0 -1
- package/src/shared/generators/rn-styles/index.js +0 -5
- package/src/shared/generators/rn-styles/index.js.map +0 -1
- package/src/shared/generators/storage/generator.d.ts +0 -6
- package/src/shared/generators/storage/generator.js +0 -25
- package/src/shared/generators/storage/generator.js.map +0 -1
- package/src/shared/generators/storage/index.js +0 -5
- package/src/shared/generators/storage/index.js.map +0 -1
- package/src/shared/generators/store/generator.d.ts +0 -4
- package/src/shared/generators/store/generator.js +0 -34
- package/src/shared/generators/store/generator.js.map +0 -1
- package/src/shared/generators/store/index.js +0 -5
- package/src/shared/generators/store/index.js.map +0 -1
- package/src/shared/generators/ui-kitten/generator.d.ts +0 -6
- package/src/shared/generators/ui-kitten/generator.js +0 -40
- package/src/shared/generators/ui-kitten/generator.js.map +0 -1
- package/src/shared/generators/ui-kitten/index.js +0 -5
- package/src/shared/generators/ui-kitten/index.js.map +0 -1
- package/src/shared/utils/cli-utils.d.ts +0 -28
- package/src/shared/utils/cli-utils.js +0 -125
- package/src/shared/utils/cli-utils.js.map +0 -1
- package/src/shared/utils/config-utils.d.ts +0 -19
- package/src/shared/utils/config-utils.js +0 -115
- package/src/shared/utils/config-utils.js.map +0 -1
- package/src/shared/utils/constants.d.ts +0 -3
- package/src/shared/utils/constants.js +0 -7
- package/src/shared/utils/constants.js.map +0 -1
- package/src/shared/utils/dynamic-import.d.ts +0 -1
- package/src/shared/utils/dynamic-import.js +0 -5
- package/src/shared/utils/dynamic-import.js.map +0 -1
- package/src/shared/utils/format-utils.d.ts +0 -4
- package/src/shared/utils/format-utils.js +0 -18
- package/src/shared/utils/format-utils.js.map +0 -1
- package/src/shared/utils/get-lib-directory-name.d.ts +0 -1
- package/src/shared/utils/get-lib-directory-name.js +0 -15
- package/src/shared/utils/get-lib-directory-name.js.map +0 -1
- package/src/shared/utils/index.js +0 -11
- package/src/shared/utils/index.js.map +0 -1
- package/src/shared/utils/ts-utils.d.ts +0 -2
- package/src/shared/utils/ts-utils.js +0 -21
- package/src/shared/utils/ts-utils.js.map +0 -1
- /package/src/generators/form/utils/{index.d.ts → index.ts} +0 -0
- /package/src/generators/lib-tags/utils/{index.d.ts → index.ts} +0 -0
- /package/src/{index.d.ts → index.ts} +0 -0
- /package/src/shared/enums/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/api-client/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/app-env/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/auth/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/form-utils/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/rn-styles/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/storage/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/store/{index.d.ts → index.ts} +0 -0
- /package/src/shared/generators/ui-kitten/{index.d.ts → index.ts} +0 -0
- /package/src/shared/utils/{index.d.ts → index.ts} +0 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"files": ["*.json"],
|
|
19
|
+
"parser": "jsonc-eslint-parser",
|
|
20
|
+
"rules": {
|
|
21
|
+
"@nx/dependency-checks": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
"ignoredDependencies": ["@nx/expo"]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"files": ["./package.json", "./generators.json"],
|
|
31
|
+
"parser": "jsonc-eslint-parser",
|
|
32
|
+
"rules": {
|
|
33
|
+
"@nx/nx-plugin-checks": "error"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
package/README.md
CHANGED
|
@@ -85,7 +85,9 @@ Generates and configures an Expo React Native app.
|
|
|
85
85
|
```sh
|
|
86
86
|
npx nx g expo-app --name=my-app --directory=mobile
|
|
87
87
|
```
|
|
88
|
+
|
|
88
89
|
or
|
|
90
|
+
|
|
89
91
|
```sh
|
|
90
92
|
npx nx g expo-app my-app mobile
|
|
91
93
|
```
|
|
@@ -105,7 +107,9 @@ Generates and configures a Next.js app.
|
|
|
105
107
|
```sh
|
|
106
108
|
npx nx g next-app --name=my-app --directory=web
|
|
107
109
|
```
|
|
110
|
+
|
|
108
111
|
or
|
|
112
|
+
|
|
109
113
|
```sh
|
|
110
114
|
npx nx g next-app my-app web
|
|
111
115
|
```
|
|
@@ -141,7 +145,9 @@ Generates a library according to [NX notation](https://nx.dev/concepts/more-conc
|
|
|
141
145
|
```sh
|
|
142
146
|
npx nx g react-lib --app=mobile --scope=account --type=features --name=profile-settings --withComponent --withComponentForwardRef --dryRun
|
|
143
147
|
```
|
|
148
|
+
|
|
144
149
|
or
|
|
150
|
+
|
|
145
151
|
```sh
|
|
146
152
|
npx nx g react-lib --dryRun
|
|
147
153
|
```
|
|
@@ -235,7 +241,9 @@ Creates a React component in particular library.
|
|
|
235
241
|
```sh
|
|
236
242
|
npx nx g react-component --name=AppButton --subcomponent --withForwardRef
|
|
237
243
|
```
|
|
244
|
+
|
|
238
245
|
or
|
|
246
|
+
|
|
239
247
|
```sh
|
|
240
248
|
npx nx g react-component AppButton --subcomponent --withForwardRef
|
|
241
249
|
```
|
|
@@ -256,7 +264,9 @@ Generates a form schema class and adds its usage to a component or a hook.
|
|
|
256
264
|
```sh
|
|
257
265
|
npx nx g form --name=profile-settings --placeOfUse=ProfileSettings
|
|
258
266
|
```
|
|
267
|
+
|
|
259
268
|
or
|
|
269
|
+
|
|
260
270
|
```sh
|
|
261
271
|
npx nx g form profile-settings ProfileSettings
|
|
262
272
|
```
|
|
@@ -286,4 +296,3 @@ Each generator accepts the `--help` argument to see generator instructions.
|
|
|
286
296
|
```sh
|
|
287
297
|
npx nx g react-lib --help
|
|
288
298
|
```
|
|
289
|
-
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: '@ronas-it/nx-generators',
|
|
4
|
+
preset: '../jest.preset.js',
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
7
|
+
},
|
|
8
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
9
|
+
coverageDirectory: '../coverage/plugin',
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ronas-it/nx-generators",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "NX generators for Ronas IT projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ronas IT",
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"main": "./src/index.js",
|
|
36
36
|
"typings": "./src/index.d.ts",
|
|
37
37
|
"generators": "./generators.json"
|
|
38
|
-
}
|
|
38
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ronas-it/nx-generators",
|
|
3
|
+
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "plugin/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"build": {
|
|
8
|
+
"executor": "@nx/js:tsc",
|
|
9
|
+
"outputs": ["{options.outputPath}"],
|
|
10
|
+
"options": {
|
|
11
|
+
"outputPath": "dist/plugin",
|
|
12
|
+
"main": "plugin/src/index.ts",
|
|
13
|
+
"tsConfig": "plugin/tsconfig.lib.json",
|
|
14
|
+
"assets": [
|
|
15
|
+
"plugin/*.md",
|
|
16
|
+
{
|
|
17
|
+
"input": "./plugin/src",
|
|
18
|
+
"glob": "**/!(*.ts)",
|
|
19
|
+
"output": "./src"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"input": "./plugin/src",
|
|
23
|
+
"glob": "**/*.d.ts",
|
|
24
|
+
"output": "./src"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"input": "./plugin",
|
|
28
|
+
"glob": "generators.json",
|
|
29
|
+
"output": "."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"input": "./plugin",
|
|
33
|
+
"glob": "executors.json",
|
|
34
|
+
"output": "."
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"nx-release-publish": {
|
|
40
|
+
"options": {
|
|
41
|
+
"packageRoot": "dist/{projectRoot}"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"test": {
|
|
45
|
+
"executor": "@nx/jest:jest",
|
|
46
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
47
|
+
"options": {
|
|
48
|
+
"jestConfig": "plugin/jest.config.ts"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"tags": ["nx", "generator", "monorepo", "expo", "react-native", "typescript"],
|
|
53
|
+
"release": {
|
|
54
|
+
"version": {
|
|
55
|
+
"generatorOptions": {
|
|
56
|
+
"packageRoot": "dist/{projectRoot}",
|
|
57
|
+
"currentVersionResolver": "git-tag"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
'lint-staged': {
|
|
3
|
+
'*.{ts,tsx}': 'tsc-files --noEmit types.d.ts',
|
|
4
|
+
'*.{ts,tsx,js,html,json,md}': 'prettier --write',
|
|
5
|
+
'*.{ts,tsx,js}': 'eslint --cache --fix',
|
|
6
|
+
},
|
|
7
|
+
tsconfig: {
|
|
8
|
+
jsx: 'react-native',
|
|
9
|
+
allowJs: true,
|
|
10
|
+
noEmit: true,
|
|
11
|
+
strict: true,
|
|
12
|
+
allowSyntheticDefaultImports: true,
|
|
13
|
+
noImplicitAny: true,
|
|
14
|
+
strictPropertyInitialization: false,
|
|
15
|
+
strictNullChecks: true,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -2,5 +2,177 @@
|
|
|
2
2
|
"root": true,
|
|
3
3
|
"plugins": ["@nx"],
|
|
4
4
|
"extends": ["./.eslint.ronasit.json"],
|
|
5
|
-
"overrides": [
|
|
5
|
+
"overrides": [
|
|
6
|
+
{
|
|
7
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
8
|
+
"rules": {
|
|
9
|
+
"@stylistic/array-bracket-newline": "off",
|
|
10
|
+
"@stylistic/array-bracket-spacing": "off",
|
|
11
|
+
"@stylistic/array-element-newline": "off",
|
|
12
|
+
"@stylistic/arrow-parens": "off",
|
|
13
|
+
"@stylistic/arrow-spacing": "off",
|
|
14
|
+
"@stylistic/block-spacing": "off",
|
|
15
|
+
"@stylistic/brace-style": "off",
|
|
16
|
+
"@stylistic/comma-dangle": "off",
|
|
17
|
+
"@stylistic/comma-spacing": "off",
|
|
18
|
+
"@stylistic/comma-style": "off",
|
|
19
|
+
"@stylistic/computed-property-spacing": "off",
|
|
20
|
+
"@stylistic/dot-location": "off",
|
|
21
|
+
"@stylistic/eol-last": "off",
|
|
22
|
+
"@stylistic/func-call-spacing": "off",
|
|
23
|
+
"@stylistic/function-call-argument-newline": "off",
|
|
24
|
+
"@stylistic/function-call-spacing": "off",
|
|
25
|
+
"@stylistic/function-paren-newline": "off",
|
|
26
|
+
"@stylistic/generator-star-spacing": "off",
|
|
27
|
+
"@stylistic/implicit-arrow-linebreak": "off",
|
|
28
|
+
"@stylistic/indent": "off",
|
|
29
|
+
"@stylistic/jsx-quotes": "off",
|
|
30
|
+
"@stylistic/key-spacing": "off",
|
|
31
|
+
"@stylistic/keyword-spacing": "off",
|
|
32
|
+
"@stylistic/linebreak-style": "off",
|
|
33
|
+
"@stylistic/max-statements-per-line": "off",
|
|
34
|
+
"@stylistic/multiline-ternary": "off",
|
|
35
|
+
"@stylistic/new-parens": "off",
|
|
36
|
+
"@stylistic/newline-per-chained-call": "off",
|
|
37
|
+
"@stylistic/no-extra-parens": "off",
|
|
38
|
+
"@stylistic/no-extra-semi": "off",
|
|
39
|
+
"@stylistic/no-floating-decimal": "off",
|
|
40
|
+
"@stylistic/no-mixed-spaces-and-tabs": "off",
|
|
41
|
+
"@stylistic/no-multi-spaces": "off",
|
|
42
|
+
"@stylistic/no-multiple-empty-lines": "off",
|
|
43
|
+
"@stylistic/no-trailing-spaces": "off",
|
|
44
|
+
"@stylistic/no-whitespace-before-property": "off",
|
|
45
|
+
"@stylistic/nonblock-statement-body-position": "off",
|
|
46
|
+
"@stylistic/object-curly-newline": "off",
|
|
47
|
+
"@stylistic/object-curly-spacing": "off",
|
|
48
|
+
"@stylistic/object-property-newline": "off",
|
|
49
|
+
"@stylistic/one-var-declaration-per-line": "off",
|
|
50
|
+
"@stylistic/operator-linebreak": "off",
|
|
51
|
+
"@stylistic/padded-blocks": "off",
|
|
52
|
+
"@stylistic/quote-props": "off",
|
|
53
|
+
"@stylistic/rest-spread-spacing": "off",
|
|
54
|
+
"@stylistic/semi": "off",
|
|
55
|
+
"@stylistic/semi-spacing": "off",
|
|
56
|
+
"@stylistic/semi-style": "off",
|
|
57
|
+
"@stylistic/space-before-blocks": "off",
|
|
58
|
+
"@stylistic/space-before-function-paren": "off",
|
|
59
|
+
"@stylistic/space-in-parens": "off",
|
|
60
|
+
"@stylistic/space-infix-ops": "off",
|
|
61
|
+
"@stylistic/space-unary-ops": "off",
|
|
62
|
+
"@stylistic/switch-colon-spacing": "off",
|
|
63
|
+
"@stylistic/template-curly-spacing": "off",
|
|
64
|
+
"@stylistic/template-tag-spacing": "off",
|
|
65
|
+
"@stylistic/wrap-iife": "off",
|
|
66
|
+
"@stylistic/wrap-regex": "off",
|
|
67
|
+
"@stylistic/yield-star-spacing": "off",
|
|
68
|
+
"@stylistic/member-delimiter-style": "off",
|
|
69
|
+
"@stylistic/type-annotation-spacing": "off",
|
|
70
|
+
"@stylistic/jsx-child-element-spacing": "off",
|
|
71
|
+
"@stylistic/jsx-closing-bracket-location": "off",
|
|
72
|
+
"@stylistic/jsx-closing-tag-location": "off",
|
|
73
|
+
"@stylistic/jsx-curly-newline": "off",
|
|
74
|
+
"@stylistic/jsx-curly-spacing": "off",
|
|
75
|
+
"@stylistic/jsx-equals-spacing": "off",
|
|
76
|
+
"@stylistic/jsx-first-prop-new-line": "off",
|
|
77
|
+
"@stylistic/jsx-indent": "off",
|
|
78
|
+
"@stylistic/jsx-indent-props": "off",
|
|
79
|
+
"@stylistic/jsx-max-props-per-line": "off",
|
|
80
|
+
"@stylistic/jsx-newline": "off",
|
|
81
|
+
"@stylistic/jsx-one-expression-per-line": "off",
|
|
82
|
+
"@stylistic/jsx-props-no-multi-spaces": "off",
|
|
83
|
+
"@stylistic/jsx-tag-spacing": "off",
|
|
84
|
+
"@stylistic/jsx-wrap-multilines": "off",
|
|
85
|
+
"@stylistic/indent-binary-ops": "off",
|
|
86
|
+
"@stylistic/type-generic-spacing": "off",
|
|
87
|
+
"@stylistic/type-named-tuple-spacing": "off",
|
|
88
|
+
"@stylistic/js/array-bracket-newline": "off",
|
|
89
|
+
"@stylistic/js/array-bracket-spacing": "off",
|
|
90
|
+
"@stylistic/js/array-element-newline": "off",
|
|
91
|
+
"@stylistic/js/arrow-parens": "off",
|
|
92
|
+
"@stylistic/js/arrow-spacing": "off",
|
|
93
|
+
"@stylistic/js/block-spacing": "off",
|
|
94
|
+
"@stylistic/js/brace-style": "off",
|
|
95
|
+
"@stylistic/js/comma-dangle": "off",
|
|
96
|
+
"@stylistic/js/comma-spacing": "off",
|
|
97
|
+
"@stylistic/js/comma-style": "off",
|
|
98
|
+
"@stylistic/js/computed-property-spacing": "off",
|
|
99
|
+
"@stylistic/js/dot-location": "off",
|
|
100
|
+
"@stylistic/js/eol-last": "off",
|
|
101
|
+
"@stylistic/js/func-call-spacing": "off",
|
|
102
|
+
"@stylistic/js/function-call-argument-newline": "off",
|
|
103
|
+
"@stylistic/js/function-call-spacing": "off",
|
|
104
|
+
"@stylistic/js/function-paren-newline": "off",
|
|
105
|
+
"@stylistic/js/generator-star-spacing": "off",
|
|
106
|
+
"@stylistic/js/implicit-arrow-linebreak": "off",
|
|
107
|
+
"@stylistic/js/indent": "off",
|
|
108
|
+
"@stylistic/js/jsx-quotes": "off",
|
|
109
|
+
"@stylistic/js/key-spacing": "off",
|
|
110
|
+
"@stylistic/js/keyword-spacing": "off",
|
|
111
|
+
"@stylistic/js/linebreak-style": "off",
|
|
112
|
+
"@stylistic/js/max-statements-per-line": "off",
|
|
113
|
+
"@stylistic/js/multiline-ternary": "off",
|
|
114
|
+
"@stylistic/js/new-parens": "off",
|
|
115
|
+
"@stylistic/js/newline-per-chained-call": "off",
|
|
116
|
+
"@stylistic/js/no-extra-parens": "off",
|
|
117
|
+
"@stylistic/js/no-extra-semi": "off",
|
|
118
|
+
"@stylistic/js/no-floating-decimal": "off",
|
|
119
|
+
"@stylistic/js/no-mixed-spaces-and-tabs": "off",
|
|
120
|
+
"@stylistic/js/no-multi-spaces": "off",
|
|
121
|
+
"@stylistic/js/no-multiple-empty-lines": "off",
|
|
122
|
+
"@stylistic/js/no-trailing-spaces": "off",
|
|
123
|
+
"@stylistic/js/no-whitespace-before-property": "off",
|
|
124
|
+
"@stylistic/js/nonblock-statement-body-position": "off",
|
|
125
|
+
"@stylistic/js/object-curly-newline": "off",
|
|
126
|
+
"@stylistic/js/object-curly-spacing": "off",
|
|
127
|
+
"@stylistic/js/object-property-newline": "off",
|
|
128
|
+
"@stylistic/js/one-var-declaration-per-line": "off",
|
|
129
|
+
"@stylistic/js/operator-linebreak": "off",
|
|
130
|
+
"@stylistic/js/padded-blocks": "off",
|
|
131
|
+
"@stylistic/js/quote-props": "off",
|
|
132
|
+
"@stylistic/js/rest-spread-spacing": "off",
|
|
133
|
+
"@stylistic/js/semi": "off",
|
|
134
|
+
"@stylistic/js/semi-spacing": "off",
|
|
135
|
+
"@stylistic/js/semi-style": "off",
|
|
136
|
+
"@stylistic/js/space-before-blocks": "off",
|
|
137
|
+
"@stylistic/js/space-before-function-paren": "off",
|
|
138
|
+
"@stylistic/js/space-in-parens": "off",
|
|
139
|
+
"@stylistic/js/space-infix-ops": "off",
|
|
140
|
+
"@stylistic/js/space-unary-ops": "off",
|
|
141
|
+
"@stylistic/js/switch-colon-spacing": "off",
|
|
142
|
+
"@stylistic/js/template-curly-spacing": "off",
|
|
143
|
+
"@stylistic/js/template-tag-spacing": "off",
|
|
144
|
+
"@stylistic/js/wrap-iife": "off",
|
|
145
|
+
"@stylistic/js/wrap-regex": "off",
|
|
146
|
+
"@stylistic/js/yield-star-spacing": "off",
|
|
147
|
+
"@stylistic/ts/block-spacing": "off",
|
|
148
|
+
"@stylistic/ts/brace-style": "off",
|
|
149
|
+
"@stylistic/ts/comma-dangle": "off",
|
|
150
|
+
"@stylistic/ts/comma-spacing": "off",
|
|
151
|
+
"@stylistic/ts/func-call-spacing": "off",
|
|
152
|
+
"@stylistic/ts/function-call-spacing": "off",
|
|
153
|
+
"@stylistic/ts/indent": "off",
|
|
154
|
+
"@stylistic/ts/key-spacing": "off",
|
|
155
|
+
"@stylistic/ts/keyword-spacing": "off",
|
|
156
|
+
"@stylistic/ts/member-delimiter-style": "off",
|
|
157
|
+
"@stylistic/ts/no-extra-parens": "off",
|
|
158
|
+
"@stylistic/ts/no-extra-semi": "off",
|
|
159
|
+
"@stylistic/ts/object-curly-spacing": "off",
|
|
160
|
+
"@stylistic/ts/semi": "off",
|
|
161
|
+
"@stylistic/ts/space-before-blocks": "off",
|
|
162
|
+
"@stylistic/ts/space-before-function-paren": "off",
|
|
163
|
+
"@stylistic/ts/space-infix-ops": "off",
|
|
164
|
+
"@stylistic/ts/type-annotation-spacing": "off",
|
|
165
|
+
"@stylistic/jsx/jsx-child-element-spacing": "off",
|
|
166
|
+
"@stylistic/jsx/jsx-closing-bracket-location": "off",
|
|
167
|
+
"@stylistic/jsx/jsx-closing-tag-location": "off",
|
|
168
|
+
"@stylistic/jsx/jsx-curly-newline": "off",
|
|
169
|
+
"@stylistic/jsx/jsx-curly-spacing": "off",
|
|
170
|
+
"@stylistic/jsx/jsx-equals-spacing": "off",
|
|
171
|
+
"@stylistic/jsx/jsx-first-prop-new-line": "off",
|
|
172
|
+
"@stylistic/jsx/jsx-indent": "off",
|
|
173
|
+
"@stylistic/jsx/jsx-indent-props": "off",
|
|
174
|
+
"@stylistic/jsx/jsx-max-props-per-line": "off"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
]
|
|
6
178
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
addDependenciesToPackageJson,
|
|
5
|
+
formatFiles,
|
|
6
|
+
generateFiles,
|
|
7
|
+
installPackagesTask,
|
|
8
|
+
readJson,
|
|
9
|
+
Tree,
|
|
10
|
+
writeJson,
|
|
11
|
+
} from '@nx/devkit';
|
|
12
|
+
import { devDependencies } from '../../shared/dependencies';
|
|
13
|
+
import config from './config';
|
|
14
|
+
import { CodeChecksGeneratorSchema } from './schema';
|
|
15
|
+
import scripts from './scripts';
|
|
16
|
+
|
|
17
|
+
export async function codeChecksGenerator(tree: Tree, options: CodeChecksGeneratorSchema) {
|
|
18
|
+
const projectRoot = '.';
|
|
19
|
+
|
|
20
|
+
// Delete files
|
|
21
|
+
tree.delete('.eslintrc.json');
|
|
22
|
+
tree.delete('eslint.config.cjs');
|
|
23
|
+
tree.delete('.prettierrc');
|
|
24
|
+
|
|
25
|
+
// Configure pre-commit hook
|
|
26
|
+
execSync('npx mrm@2 lint-staged', { stdio: 'inherit' });
|
|
27
|
+
|
|
28
|
+
const packageJson = readJson(tree, 'package.json');
|
|
29
|
+
packageJson['lint-staged'] = config['lint-staged'];
|
|
30
|
+
packageJson.scripts = { ...scripts, ...packageJson.scripts };
|
|
31
|
+
writeJson(tree, 'package.json', packageJson);
|
|
32
|
+
|
|
33
|
+
// Update tsconfig.base.json
|
|
34
|
+
const tsconfigJson = readJson(tree, 'tsconfig.base.json');
|
|
35
|
+
tsconfigJson.compilerOptions = { ...config.tsconfig, ...tsconfigJson.compilerOptions };
|
|
36
|
+
writeJson(tree, 'tsconfig.base.json', tsconfigJson);
|
|
37
|
+
|
|
38
|
+
// Update .gitignore
|
|
39
|
+
const gitignoreContent = tree.read('.gitignore')?.toString() + '\n.eslintcache\n';
|
|
40
|
+
tree.write('.gitignore', gitignoreContent);
|
|
41
|
+
|
|
42
|
+
// Update .eslintignore
|
|
43
|
+
const eslintignoreContent = tree.read('.eslintignore')?.toString() + '\n**/*.js\napps/*/app.config.ts\n';
|
|
44
|
+
tree.write('.eslintignore', eslintignoreContent);
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
47
|
+
const configTemplate = require('../../shared/templates/config-template.json');
|
|
48
|
+
|
|
49
|
+
// Add files
|
|
50
|
+
generateFiles(tree, path.join(__dirname, 'files'), projectRoot, options);
|
|
51
|
+
|
|
52
|
+
// Add rules to .eslintrc.json
|
|
53
|
+
const esLintConfig = readJson(tree, '.eslintrc.json');
|
|
54
|
+
|
|
55
|
+
esLintConfig.overrides.push(configTemplate);
|
|
56
|
+
writeJson(tree, '.eslintrc.json', esLintConfig);
|
|
57
|
+
|
|
58
|
+
// Install necessary dependencies
|
|
59
|
+
addDependenciesToPackageJson(tree, {}, devDependencies['code-checks']);
|
|
60
|
+
|
|
61
|
+
await formatFiles(tree);
|
|
62
|
+
|
|
63
|
+
return (): void => {
|
|
64
|
+
installPackagesTask(tree);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default codeChecksGenerator;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
3
|
+
import { camelCase, kebabCase, startCase } from 'lodash';
|
|
4
|
+
import { IndentationText, Project, QuoteKind, StructureKind, SyntaxKind } from 'ts-morph';
|
|
5
|
+
import {
|
|
6
|
+
addNamedImport,
|
|
7
|
+
appendFileContent,
|
|
8
|
+
askQuestion,
|
|
9
|
+
createCliReadline,
|
|
10
|
+
dynamicImport,
|
|
11
|
+
filterSource,
|
|
12
|
+
getNxLibsPaths,
|
|
13
|
+
LibraryType,
|
|
14
|
+
searchAliasPath,
|
|
15
|
+
searchNxLibsPaths,
|
|
16
|
+
} from '../../shared/utils';
|
|
17
|
+
import { EntityApiGeneratorSchema } from './schema';
|
|
18
|
+
|
|
19
|
+
export async function entityApiGenerator(tree: Tree, options: EntityApiGeneratorSchema): Promise<void> {
|
|
20
|
+
const { default: autocomplete } = await dynamicImport<typeof import('inquirer-autocomplete-standalone')>(
|
|
21
|
+
'inquirer-autocomplete-standalone',
|
|
22
|
+
);
|
|
23
|
+
const nxLibsPaths = getNxLibsPaths([LibraryType.DATA_ACCESS]);
|
|
24
|
+
const apiLibsPaths = searchNxLibsPaths(nxLibsPaths, 'data-access/api/src', 'endsWith');
|
|
25
|
+
const apiClientLibsPaths = searchNxLibsPaths(nxLibsPaths, 'data-access/api-client/src', 'endsWith');
|
|
26
|
+
|
|
27
|
+
if (!apiClientLibsPaths.length) {
|
|
28
|
+
throw new Error('Could not find API Client path.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!apiLibsPaths.length) {
|
|
32
|
+
throw new Error('Could not find API path.');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (apiClientLibsPaths.length > 1) {
|
|
36
|
+
apiClientLibsPaths[0] = await autocomplete({
|
|
37
|
+
message: 'Select the api client library path:',
|
|
38
|
+
source: (input) => filterSource(input as string, apiClientLibsPaths),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (apiLibsPaths.length > 1) {
|
|
43
|
+
apiLibsPaths[0] = await autocomplete({
|
|
44
|
+
message: 'Select the api library path:',
|
|
45
|
+
source: (input) => filterSource(input as string, apiLibsPaths),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const apiDirectory = searchAliasPath(apiLibsPaths[0]) as string;
|
|
50
|
+
const apiClientDirectory = searchAliasPath(apiClientLibsPaths[0]);
|
|
51
|
+
|
|
52
|
+
const libPath = apiLibsPaths[0];
|
|
53
|
+
const libRootPath = `${libPath}/lib`;
|
|
54
|
+
|
|
55
|
+
const cliReadline = createCliReadline();
|
|
56
|
+
options.name =
|
|
57
|
+
options.name || (await askQuestion('Enter the name of the entity (e.g: User): ', undefined, cliReadline));
|
|
58
|
+
|
|
59
|
+
const apiName = kebabCase(options.name);
|
|
60
|
+
|
|
61
|
+
options.baseEndpoint =
|
|
62
|
+
options.baseEndpoint || (await askQuestion('Enter the base endpoint (e.g: /users): ', `/${apiName}`, cliReadline));
|
|
63
|
+
cliReadline.close();
|
|
64
|
+
|
|
65
|
+
const apiPath = `${libRootPath}/${apiName}`;
|
|
66
|
+
const entityName = startCase(camelCase(apiName)).replace(/\s+/g, '');
|
|
67
|
+
|
|
68
|
+
generateFiles(tree, path.join(__dirname, `files`), apiPath, {
|
|
69
|
+
...options,
|
|
70
|
+
apiName: camelCase(options.name),
|
|
71
|
+
entityName,
|
|
72
|
+
entityFileName: apiName,
|
|
73
|
+
apiClientDirectory,
|
|
74
|
+
baseEndpoint: options.baseEndpoint.startsWith('/') ? options.baseEndpoint : `/${options.baseEndpoint}`,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
tree.rename(`${apiPath}/models/entity.ts`, `${apiPath}/models/${apiName}.ts`);
|
|
78
|
+
|
|
79
|
+
appendFileContent(`${libRootPath}/index.ts`, `export * from './${apiName}';\n`, tree);
|
|
80
|
+
|
|
81
|
+
const storeLibsPaths = searchNxLibsPaths(nxLibsPaths, 'data-access/store/src', 'endsWith');
|
|
82
|
+
|
|
83
|
+
if (!storeLibsPaths.length) {
|
|
84
|
+
await formatFiles(tree);
|
|
85
|
+
|
|
86
|
+
throw new Error('Could not find redux store path.');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (storeLibsPaths.length > 1) {
|
|
90
|
+
storeLibsPaths[0] = await autocomplete({
|
|
91
|
+
message: 'Select the store library path:',
|
|
92
|
+
source: (input) => filterSource(input as string, storeLibsPaths),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Update redux store
|
|
97
|
+
const apiNameDeclaration = camelCase(options.name + 'Api');
|
|
98
|
+
const project = new Project({
|
|
99
|
+
manipulationSettings: {
|
|
100
|
+
indentationText: IndentationText.TwoSpaces,
|
|
101
|
+
quoteKind: QuoteKind.Single,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const store = project.addSourceFileAtPath(`${storeLibsPaths[0]}/store.ts`);
|
|
105
|
+
|
|
106
|
+
addNamedImport(apiNameDeclaration, apiDirectory, store);
|
|
107
|
+
|
|
108
|
+
const rootReducer = store.getVariableDeclarationOrThrow('rootReducer');
|
|
109
|
+
|
|
110
|
+
rootReducer.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression).addProperty({
|
|
111
|
+
name: `[${apiNameDeclaration}.reducerPath]`,
|
|
112
|
+
initializer: `${apiNameDeclaration}.reducer`,
|
|
113
|
+
kind: StructureKind.PropertyAssignment,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const middlewares = store.getVariableDeclarationOrThrow('middlewares');
|
|
117
|
+
|
|
118
|
+
middlewares
|
|
119
|
+
.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)
|
|
120
|
+
.addElement(`${apiNameDeclaration}.middleware`);
|
|
121
|
+
|
|
122
|
+
project.saveSync();
|
|
123
|
+
|
|
124
|
+
await formatFiles(tree);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default entityApiGenerator;
|