@ronas-it/nx-generators 0.10.4 → 0.10.6
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/package.json +4 -3
- package/src/generators/code-checks/config.d.ts +18 -0
- package/src/generators/code-checks/config.js +20 -0
- package/src/generators/code-checks/config.js.map +1 -0
- package/src/generators/code-checks/generator.d.ts +4 -0
- package/src/generators/code-checks/generator.js +53 -0
- package/src/generators/code-checks/generator.js.map +1 -0
- package/src/generators/code-checks/scripts.d.ts +6 -0
- package/src/generators/code-checks/scripts.js +8 -0
- package/src/generators/code-checks/scripts.js.map +1 -0
- package/src/generators/entity-api/generator.d.ts +4 -0
- package/src/generators/entity-api/generator.js +87 -0
- package/src/generators/entity-api/generator.js.map +1 -0
- package/src/generators/expo-app/generator.d.ts +4 -0
- package/src/generators/expo-app/generator.js +93 -0
- package/src/generators/expo-app/generator.js.map +1 -0
- package/src/generators/expo-app/scripts.d.ts +13 -0
- package/src/generators/expo-app/scripts.js +15 -0
- package/src/generators/expo-app/scripts.js.map +1 -0
- package/src/generators/form/generator.d.ts +4 -0
- package/src/generators/form/generator.js +55 -0
- package/src/generators/form/generator.js.map +1 -0
- package/src/generators/form/utils/add-form-usage.d.ts +1 -0
- package/src/generators/form/utils/add-form-usage.js +71 -0
- package/src/generators/form/utils/add-form-usage.js.map +1 -0
- package/src/generators/form/utils/get-app-name.d.ts +1 -0
- package/src/generators/form/utils/get-app-name.js +8 -0
- package/src/generators/form/utils/get-app-name.js.map +1 -0
- package/src/generators/form/utils/get-form-utils-directory.d.ts +2 -0
- package/src/generators/form/utils/get-form-utils-directory.js +35 -0
- package/src/generators/form/utils/get-form-utils-directory.js.map +1 -0
- package/src/generators/form/utils/index.js +8 -0
- package/src/generators/form/utils/index.js.map +1 -0
- package/src/generators/form/utils/update-index.d.ts +2 -0
- package/src/generators/form/utils/update-index.js +18 -0
- package/src/generators/form/utils/update-index.js.map +1 -0
- package/src/generators/lib-move/generator.d.ts +4 -0
- package/src/generators/lib-move/generator.js +37 -0
- package/src/generators/lib-move/generator.js.map +1 -0
- package/src/generators/lib-remove/generator.d.ts +4 -0
- package/src/generators/lib-remove/generator.js +22 -0
- package/src/generators/lib-remove/generator.js.map +1 -0
- package/src/generators/lib-rename/generator.d.ts +4 -0
- package/src/generators/lib-rename/generator.js +22 -0
- package/src/generators/lib-rename/generator.js.map +1 -0
- package/src/generators/lib-tags/generator.d.ts +4 -0
- package/src/generators/lib-tags/generator.js +56 -0
- package/src/generators/lib-tags/generator.js.map +1 -0
- package/src/generators/lib-tags/interfaces/context.d.ts +8 -0
- package/src/generators/lib-tags/interfaces/context.js +3 -0
- package/src/generators/lib-tags/interfaces/context.js.map +1 -0
- package/src/generators/lib-tags/interfaces/index.js +6 -0
- package/src/generators/lib-tags/interfaces/index.js.map +1 -0
- package/src/generators/lib-tags/interfaces/{verify-tag-config.ts → verify-tag-config.d.ts} +6 -7
- package/src/generators/lib-tags/interfaces/verify-tag-config.js +3 -0
- package/src/generators/lib-tags/interfaces/verify-tag-config.js.map +1 -0
- package/src/generators/lib-tags/types/index.js +5 -0
- package/src/generators/lib-tags/types/index.js.map +1 -0
- package/src/generators/lib-tags/types/tag.js +3 -0
- package/src/generators/lib-tags/types/tag.js.map +1 -0
- package/src/generators/lib-tags/utils/check-lib-tags.d.ts +4 -0
- package/src/generators/lib-tags/utils/check-lib-tags.js +113 -0
- package/src/generators/lib-tags/utils/check-lib-tags.js.map +1 -0
- package/src/generators/lib-tags/utils/index.js +5 -0
- package/src/generators/lib-tags/utils/index.js.map +1 -0
- package/src/generators/next-app/generator.d.ts +4 -0
- package/src/generators/next-app/generator.js +71 -0
- package/src/generators/next-app/generator.js.map +1 -0
- package/src/generators/react-component/generator.d.ts +4 -0
- package/src/generators/react-component/generator.js +60 -0
- package/src/generators/react-component/generator.js.map +1 -0
- package/src/generators/react-lib/generator.d.ts +4 -0
- package/src/generators/react-lib/generator.js +61 -0
- package/src/generators/react-lib/generator.js.map +1 -0
- package/src/generators/repo-config/generator.d.ts +3 -0
- package/src/generators/repo-config/generator.js +36 -0
- package/src/generators/repo-config/generator.js.map +1 -0
- package/src/generators/repo-config/scripts.d.ts +4 -0
- package/src/generators/repo-config/scripts.js +6 -0
- package/src/generators/repo-config/scripts.js.map +1 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -0
- package/src/shared/dependencies.d.ts +74 -0
- package/src/shared/dependencies.js +80 -0
- package/src/shared/dependencies.js.map +1 -0
- package/src/shared/enums/base-generator-type.d.ts +4 -0
- package/src/shared/enums/base-generator-type.js +9 -0
- package/src/shared/enums/base-generator-type.js.map +1 -0
- package/src/shared/enums/index.js +5 -0
- package/src/shared/enums/index.js.map +1 -0
- package/src/shared/generators/api-client/generator.d.ts +6 -0
- package/src/shared/generators/api-client/generator.js +37 -0
- package/src/shared/generators/api-client/generator.js.map +1 -0
- package/src/shared/generators/api-client/index.js +5 -0
- package/src/shared/generators/api-client/index.js.map +1 -0
- package/src/shared/generators/app-env/generator.d.ts +8 -0
- package/src/shared/generators/app-env/generator.js +28 -0
- package/src/shared/generators/app-env/generator.js.map +1 -0
- package/src/shared/generators/app-env/index.js +5 -0
- package/src/shared/generators/app-env/index.js.map +1 -0
- package/src/shared/generators/auth/generator.d.ts +4 -0
- package/src/shared/generators/auth/generator.js +82 -0
- package/src/shared/generators/auth/generator.js.map +1 -0
- package/src/shared/generators/auth/index.js +5 -0
- package/src/shared/generators/auth/index.js.map +1 -0
- package/src/shared/generators/form-utils/generator.d.ts +5 -0
- package/src/shared/generators/form-utils/generator.js +24 -0
- package/src/shared/generators/form-utils/generator.js.map +1 -0
- package/src/shared/generators/form-utils/index.js +5 -0
- package/src/shared/generators/form-utils/index.js.map +1 -0
- package/src/shared/generators/index.js +12 -0
- package/src/shared/generators/index.js.map +1 -0
- package/src/shared/generators/rn-styles/generator.d.ts +6 -0
- package/src/shared/generators/rn-styles/generator.js +36 -0
- package/src/shared/generators/rn-styles/generator.js.map +1 -0
- package/src/shared/generators/rn-styles/index.js +5 -0
- package/src/shared/generators/rn-styles/index.js.map +1 -0
- package/src/shared/generators/storage/generator.d.ts +6 -0
- package/src/shared/generators/storage/generator.js +27 -0
- package/src/shared/generators/storage/generator.js.map +1 -0
- package/src/shared/generators/storage/index.js +5 -0
- package/src/shared/generators/storage/index.js.map +1 -0
- package/src/shared/generators/store/generator.d.ts +4 -0
- package/src/shared/generators/store/generator.js +36 -0
- package/src/shared/generators/store/generator.js.map +1 -0
- package/src/shared/generators/store/index.js +5 -0
- package/src/shared/generators/store/index.js.map +1 -0
- package/src/shared/generators/ui-kitten/generator.d.ts +6 -0
- package/src/shared/generators/ui-kitten/generator.js +40 -0
- package/src/shared/generators/ui-kitten/generator.js.map +1 -0
- package/src/shared/generators/ui-kitten/index.js +5 -0
- package/src/shared/generators/ui-kitten/index.js.map +1 -0
- package/src/shared/utils/cli-utils.d.ts +31 -0
- package/src/shared/utils/cli-utils.js +129 -0
- package/src/shared/utils/cli-utils.js.map +1 -0
- package/src/shared/utils/config-utils.d.ts +19 -0
- package/src/shared/utils/config-utils.js +124 -0
- package/src/shared/utils/config-utils.js.map +1 -0
- package/src/shared/utils/constants.d.ts +3 -0
- package/src/shared/utils/constants.js +7 -0
- package/src/shared/utils/constants.js.map +1 -0
- package/src/shared/utils/dynamic-import.d.ts +1 -0
- package/src/shared/utils/dynamic-import.js +5 -0
- package/src/shared/utils/dynamic-import.js.map +1 -0
- package/src/shared/utils/format-utils.d.ts +4 -0
- package/src/shared/utils/format-utils.js +18 -0
- package/src/shared/utils/format-utils.js.map +1 -0
- package/src/shared/utils/get-lib-directory-name.d.ts +1 -0
- package/src/shared/utils/get-lib-directory-name.js +15 -0
- package/src/shared/utils/get-lib-directory-name.js.map +1 -0
- package/src/shared/utils/index.js +11 -0
- package/src/shared/utils/index.js.map +1 -0
- package/src/shared/utils/ts-utils.d.ts +2 -0
- package/src/shared/utils/ts-utils.js +22 -0
- package/src/shared/utils/ts-utils.js.map +1 -0
- package/.eslintrc.json +0 -37
- package/jest.config.ts +0 -10
- package/project.json +0 -61
- package/src/generators/code-checks/config.ts +0 -17
- package/src/generators/code-checks/generator.ts +0 -68
- package/src/generators/code-checks/scripts.ts +0 -5
- package/src/generators/entity-api/generator.ts +0 -127
- package/src/generators/expo-app/generator.ts +0 -152
- package/src/generators/expo-app/scripts.ts +0 -12
- package/src/generators/form/generator.ts +0 -61
- package/src/generators/form/utils/add-form-usage.ts +0 -99
- package/src/generators/form/utils/get-app-name.ts +0 -3
- package/src/generators/form/utils/get-form-utils-directory.ts +0 -59
- package/src/generators/form/utils/update-index.ts +0 -15
- package/src/generators/lib-move/generator.ts +0 -57
- package/src/generators/lib-remove/generator.ts +0 -22
- package/src/generators/lib-rename/generator.ts +0 -25
- package/src/generators/lib-tags/generator.ts +0 -66
- package/src/generators/lib-tags/interfaces/context.ts +0 -9
- package/src/generators/lib-tags/utils/check-lib-tags.ts +0 -145
- package/src/generators/next-app/generator.ts +0 -104
- package/src/generators/react-component/generator.ts +0 -80
- package/src/generators/react-lib/generator.ts +0 -86
- package/src/generators/repo-config/generator.ts +0 -44
- package/src/generators/repo-config/scripts.ts +0 -3
- package/src/shared/dependencies.ts +0 -76
- package/src/shared/enums/base-generator-type.ts +0 -4
- package/src/shared/generators/api-client/generator.ts +0 -43
- package/src/shared/generators/app-env/generator.ts +0 -35
- package/src/shared/generators/auth/generator.ts +0 -100
- package/src/shared/generators/form-utils/generator.ts +0 -22
- package/src/shared/generators/rn-styles/generator.ts +0 -44
- package/src/shared/generators/storage/generator.ts +0 -29
- package/src/shared/generators/store/generator.ts +0 -42
- package/src/shared/generators/ui-kitten/generator.ts +0 -51
- package/src/shared/utils/cli-utils.ts +0 -164
- package/src/shared/utils/config-utils.ts +0 -159
- package/src/shared/utils/constants.ts +0 -3
- package/src/shared/utils/dynamic-import.ts +0 -3
- package/src/shared/utils/format-utils.ts +0 -15
- package/src/shared/utils/get-lib-directory-name.ts +0 -13
- package/src/shared/utils/ts-utils.ts +0 -20
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -9
- /package/src/generators/form/utils/{index.ts → index.d.ts} +0 -0
- /package/src/generators/lib-tags/interfaces/{index.ts → index.d.ts} +0 -0
- /package/src/generators/lib-tags/types/{index.ts → index.d.ts} +0 -0
- /package/src/generators/lib-tags/types/{tag.ts → tag.d.ts} +0 -0
- /package/src/generators/lib-tags/utils/{index.ts → index.d.ts} +0 -0
- /package/src/{index.ts → index.d.ts} +0 -0
- /package/src/shared/enums/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/api-client/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/app-env/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/auth/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/form-utils/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/rn-styles/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/storage/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/store/{index.ts → index.d.ts} +0 -0
- /package/src/shared/generators/ui-kitten/{index.ts → index.d.ts} +0 -0
- /package/src/shared/utils/{index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLibDirectoryName(libName: string, scopeName: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLibDirectoryName = void 0;
|
|
4
|
+
function getLibDirectoryName(libName, scopeName) {
|
|
5
|
+
const libWords = libName.split('-');
|
|
6
|
+
const scopeWords = scopeName.split('-');
|
|
7
|
+
let newLibWords = libWords;
|
|
8
|
+
const startsWithScopeWords = scopeWords.every((word, index) => libWords[index] === word);
|
|
9
|
+
if (startsWithScopeWords && libWords.length > scopeWords.length) {
|
|
10
|
+
newLibWords = libWords.slice(scopeWords.length);
|
|
11
|
+
}
|
|
12
|
+
return newLibWords.join('-');
|
|
13
|
+
}
|
|
14
|
+
exports.getLibDirectoryName = getLibDirectoryName;
|
|
15
|
+
//# sourceMappingURL=get-lib-directory-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-lib-directory-name.js","sourceRoot":"","sources":["../../../../../plugin/src/shared/utils/get-lib-directory-name.ts"],"names":[],"mappings":";;;AAAA,SAAgB,mBAAmB,CAAC,OAAe,EAAE,SAAiB;IACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,WAAW,GAAG,QAAQ,CAAC;IAE3B,MAAM,oBAAoB,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAEzF,IAAI,oBAAoB,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;QAChE,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAZD,kDAYC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./format-utils"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./cli-utils"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./dynamic-import"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./config-utils"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./ts-utils"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./get-lib-directory-name"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../plugin/src/shared/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,sDAA4B;AAC5B,2DAAiC;AACjC,yDAA+B;AAC/B,qDAA2B;AAC3B,sDAA4B;AAC5B,mEAAyC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addNamedImport = void 0;
|
|
4
|
+
const addNamedImport = (namedImport, moduleSpecifier, file) => {
|
|
5
|
+
const importDeclaration = file.getImportDeclaration(moduleSpecifier);
|
|
6
|
+
if (importDeclaration) {
|
|
7
|
+
const hasNamedImport = importDeclaration
|
|
8
|
+
.getNamedImports()
|
|
9
|
+
.find((declaration) => declaration.getName() === namedImport);
|
|
10
|
+
if (!hasNamedImport) {
|
|
11
|
+
importDeclaration.addNamedImport(namedImport);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
file.addImportDeclaration({
|
|
16
|
+
namedImports: [namedImport],
|
|
17
|
+
moduleSpecifier,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.addNamedImport = addNamedImport;
|
|
22
|
+
//# sourceMappingURL=ts-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-utils.js","sourceRoot":"","sources":["../../../../../plugin/src/shared/utils/ts-utils.ts"],"names":[],"mappings":";;;AAEO,MAAM,cAAc,GAAG,CAAC,WAAmB,EAAE,eAAuB,EAAE,IAAgB,EAAQ,EAAE;IACrG,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAErE,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,cAAc,GAAG,iBAAiB;aACrC,eAAe,EAAE;aACjB,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,WAAW,CAAC,CAAC;QAEhE,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,iBAAiB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,oBAAoB,CAAC;YACxB,YAAY,EAAE,CAAC,WAAW,CAAC;YAC3B,eAAe;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAjBW,QAAA,cAAc,kBAiBzB"}
|
package/.eslintrc.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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/jest.config.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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/project.json
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
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;
|
|
@@ -1,127 +0,0 @@
|
|
|
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;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
2
|
-
import { existsSync, rmSync } from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import {
|
|
5
|
-
addDependenciesToPackageJson,
|
|
6
|
-
formatFiles,
|
|
7
|
-
generateFiles,
|
|
8
|
-
installPackagesTask,
|
|
9
|
-
readJson,
|
|
10
|
-
readProjectConfiguration,
|
|
11
|
-
Tree,
|
|
12
|
-
updateProjectConfiguration,
|
|
13
|
-
writeJson,
|
|
14
|
-
} from '@nx/devkit';
|
|
15
|
-
import { dependencies, devDependencies } from '../../shared/dependencies';
|
|
16
|
-
import { BaseGeneratorType } from '../../shared/enums';
|
|
17
|
-
import {
|
|
18
|
-
runAppEnvGenerator,
|
|
19
|
-
runApiClientGenerator,
|
|
20
|
-
runStorageGenerator,
|
|
21
|
-
runRNStylesGenerator,
|
|
22
|
-
runFormUtilsGenerator,
|
|
23
|
-
runStoreGenerator,
|
|
24
|
-
runUIKittenGenerator,
|
|
25
|
-
} from '../../shared/generators';
|
|
26
|
-
import { formatName, formatAppIdentifier, addNxAppTag, askQuestion, getImportPathPrefix } from '../../shared/utils';
|
|
27
|
-
import { ExpoAppGeneratorSchema } from './schema';
|
|
28
|
-
import scripts from './scripts';
|
|
29
|
-
|
|
30
|
-
export async function expoAppGenerator(tree: Tree, options: ExpoAppGeneratorSchema) {
|
|
31
|
-
const shouldGenerateStoreLib = (await askQuestion('Do you want to create store lib? (y/n): ')) === 'y';
|
|
32
|
-
const shouldGenerateApiClientLib =
|
|
33
|
-
shouldGenerateStoreLib && (await askQuestion('Do you want to create api client lib? (y/n): ')) === 'y';
|
|
34
|
-
const shouldGenerateAuthLibs =
|
|
35
|
-
shouldGenerateApiClientLib && (await askQuestion('Do you want to create auth lib? (y/n): ')) === 'y';
|
|
36
|
-
const shouldGenerateFormUtilsLib =
|
|
37
|
-
(await askQuestion('Do you want to create a lib with the form utils? (y/n): ')) === 'y';
|
|
38
|
-
const shouldGenerateUIKittenLib = (await askQuestion('Do you want to install @ui-kitten? (y/n): ')) === 'y';
|
|
39
|
-
|
|
40
|
-
const appRoot = `apps/${options.directory}`;
|
|
41
|
-
const i18nRoot = `i18n/${options.directory}`;
|
|
42
|
-
const appTestFolder = `apps/${options.directory}-e2e`;
|
|
43
|
-
const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
|
|
44
|
-
const tags = [`app:${options.directory}`, 'type:app'];
|
|
45
|
-
|
|
46
|
-
// Install @nx/expo plugin
|
|
47
|
-
execSync('npx nx add @nx/expo', { stdio: 'inherit' });
|
|
48
|
-
|
|
49
|
-
if (existsSync(appRoot)) {
|
|
50
|
-
const project = readProjectConfiguration(tree, options.directory);
|
|
51
|
-
|
|
52
|
-
project.tags = [`app:${options.directory}`, 'type:app'];
|
|
53
|
-
|
|
54
|
-
updateProjectConfiguration(tree, project.name as string, project);
|
|
55
|
-
} else {
|
|
56
|
-
execSync(
|
|
57
|
-
`npx nx g @nx/expo:app ${options.name} --directory=apps/${options.directory} --tags="${tags.join(', ')}" --linter=eslint --unitTestRunner=none --e2eTestRunner=none`,
|
|
58
|
-
{ stdio: 'inherit' },
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Generate shared libs
|
|
63
|
-
await runAppEnvGenerator(tree, { ...options, baseGeneratorType: BaseGeneratorType.EXPO_APP });
|
|
64
|
-
await runStorageGenerator(tree, options);
|
|
65
|
-
await runRNStylesGenerator(tree, options);
|
|
66
|
-
|
|
67
|
-
if (shouldGenerateStoreLib) {
|
|
68
|
-
await runStoreGenerator(tree, { ...options, baseGeneratorType: BaseGeneratorType.EXPO_APP });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (shouldGenerateApiClientLib) {
|
|
72
|
-
await runApiClientGenerator(tree, options);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (shouldGenerateFormUtilsLib) {
|
|
76
|
-
await runFormUtilsGenerator(tree, options);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (shouldGenerateUIKittenLib) {
|
|
80
|
-
await runUIKittenGenerator(tree, options);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Workaround: Even with the '--e2eTestRunner=none' parameter, the test folder is created. We delete it manually.
|
|
84
|
-
if (existsSync(appTestFolder)) {
|
|
85
|
-
rmSync(appTestFolder, { recursive: true, force: true });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const appPackagePath = `${appRoot}/package.json`;
|
|
89
|
-
|
|
90
|
-
// Remove unnecessary files and files that will be replaced
|
|
91
|
-
tree.delete(`${appRoot}/src`);
|
|
92
|
-
tree.delete(`${appRoot}/index.js`);
|
|
93
|
-
tree.delete(`${appRoot}/webpack.config.js`);
|
|
94
|
-
tree.delete(`${appRoot}/.eslintrc.json`);
|
|
95
|
-
tree.delete(`${appRoot}/eslint.config.cjs`);
|
|
96
|
-
tree.delete(`${appRoot}/app.json`);
|
|
97
|
-
tree.delete(`${appRoot}/eas.json`);
|
|
98
|
-
tree.delete(`${appRoot}/metro.config.js`);
|
|
99
|
-
tree.delete(`${appRoot}/jest.config.ts`);
|
|
100
|
-
tree.delete(`${appRoot}/tsconfig.app.json`);
|
|
101
|
-
|
|
102
|
-
// Update app package.json
|
|
103
|
-
const appPackageJson = readJson(tree, appPackagePath);
|
|
104
|
-
appPackageJson.main = 'expo-router/entry';
|
|
105
|
-
appPackageJson.scripts = {
|
|
106
|
-
...scripts,
|
|
107
|
-
...appPackageJson.scripts,
|
|
108
|
-
};
|
|
109
|
-
writeJson(tree, appPackagePath, appPackageJson);
|
|
110
|
-
|
|
111
|
-
// Add app files
|
|
112
|
-
generateFiles(tree, path.join(__dirname, 'app-files'), appRoot, {
|
|
113
|
-
...options,
|
|
114
|
-
formatName,
|
|
115
|
-
formatAppIdentifier,
|
|
116
|
-
formatDirectory: () => libPath,
|
|
117
|
-
isUIKittenEnabled: shouldGenerateUIKittenLib,
|
|
118
|
-
isStoreEnabled: shouldGenerateStoreLib,
|
|
119
|
-
appDirectory: options.directory,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
addNxAppTag(tree, options.directory);
|
|
123
|
-
generateFiles(tree, path.join(__dirname, 'i18n'), i18nRoot, {});
|
|
124
|
-
|
|
125
|
-
// Add dependencies
|
|
126
|
-
addDependenciesToPackageJson(
|
|
127
|
-
tree,
|
|
128
|
-
{
|
|
129
|
-
...dependencies['expo-app'],
|
|
130
|
-
...dependencies['expo-app-root'],
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
...devDependencies['expo-app'],
|
|
134
|
-
...devDependencies['expo-app-root'],
|
|
135
|
-
},
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
addDependenciesToPackageJson(tree, dependencies['expo-app'], devDependencies['expo-app'], appPackagePath);
|
|
139
|
-
|
|
140
|
-
await formatFiles(tree);
|
|
141
|
-
|
|
142
|
-
return (): void => {
|
|
143
|
-
installPackagesTask(tree);
|
|
144
|
-
execSync('npx expo install --fix', { stdio: 'inherit' });
|
|
145
|
-
|
|
146
|
-
if (shouldGenerateAuthLibs) {
|
|
147
|
-
execSync(`npx nx g auth ${options.name} ${options.directory}`, { stdio: 'inherit' });
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export default expoAppGenerator;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
start: 'cross-env EXPO_PUBLIC_APP_ENV=development npx expo start',
|
|
3
|
-
'start:prod': 'cross-env EXPO_PUBLIC_APP_ENV=production npx expo start',
|
|
4
|
-
'build:dev': 'eas build --no-wait -p all --profile=development',
|
|
5
|
-
'build:internal': 'npm run build:dev -- --profile=internal',
|
|
6
|
-
'build:debug': 'npm run build:dev -- --profile=debug',
|
|
7
|
-
'build:prod': 'npm run build:dev -- --profile=production',
|
|
8
|
-
'update:dev': 'cross-env EXPO_PUBLIC_APP_ENV=development eas update --branch development',
|
|
9
|
-
'update:prod': 'cross-env EXPO_PUBLIC_APP_ENV=production eas update --branch production',
|
|
10
|
-
'submit:dev': 'cross-env EXPO_PUBLIC_APP_ENV=development eas submit --no-wait --profile=development',
|
|
11
|
-
'submit:prod': 'cross-env EXPO_PUBLIC_APP_ENV=production eas submit --no-wait --profile=production',
|
|
12
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import { addDependenciesToPackageJson, formatFiles, generateFiles, installPackagesTask, Tree } from '@nx/devkit';
|
|
3
|
-
import { dependencies } from '../../shared/dependencies';
|
|
4
|
-
import { dynamicImport, formatName, getNxLibsPaths, LibraryType, searchNxLibsPaths } from '../../shared/utils';
|
|
5
|
-
import { FormGeneratorSchema } from './schema';
|
|
6
|
-
import { addFormUsage, getAppName, getFormUtilsDirectory, updateIndex } from './utils';
|
|
7
|
-
|
|
8
|
-
export async function formGenerator(tree: Tree, options: FormGeneratorSchema) {
|
|
9
|
-
// Get input data
|
|
10
|
-
const { default: autocomplete } = await dynamicImport<typeof import('inquirer-autocomplete-standalone')>(
|
|
11
|
-
'inquirer-autocomplete-standalone',
|
|
12
|
-
);
|
|
13
|
-
const availableLibsPaths = getNxLibsPaths([LibraryType.FEATURES, LibraryType.UI]);
|
|
14
|
-
const libPath = await autocomplete({
|
|
15
|
-
message: 'Enter the library path: ',
|
|
16
|
-
source: async (input) => {
|
|
17
|
-
const filteredNxLibsPaths = searchNxLibsPaths(availableLibsPaths, input as string);
|
|
18
|
-
|
|
19
|
-
return filteredNxLibsPaths.map((path) => ({ value: path }));
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
const fileName = options.name;
|
|
23
|
-
const placeOfUse = options.placeOfUse;
|
|
24
|
-
|
|
25
|
-
if (!fileName) {
|
|
26
|
-
throw new Error('Form name is required');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Generate form class
|
|
30
|
-
const formsPath = `${libPath}/lib/forms`;
|
|
31
|
-
const formFilePath = `${formsPath}/${fileName}.ts`;
|
|
32
|
-
|
|
33
|
-
if (tree.exists(formFilePath)) {
|
|
34
|
-
throw new Error('The form already exists');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const formUtilsDirectory = await getFormUtilsDirectory(tree, getAppName(libPath));
|
|
38
|
-
const formClassName = `${formatName(fileName, true)}FormSchema`;
|
|
39
|
-
generateFiles(tree, path.join(__dirname, `files`), formsPath, {
|
|
40
|
-
className: formClassName,
|
|
41
|
-
fileName,
|
|
42
|
-
formUtilsDirectory,
|
|
43
|
-
});
|
|
44
|
-
updateIndex(formsPath, fileName, tree);
|
|
45
|
-
|
|
46
|
-
// Add form usage
|
|
47
|
-
if (placeOfUse) {
|
|
48
|
-
await addFormUsage(libPath, placeOfUse, formClassName);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
await formatFiles(tree);
|
|
52
|
-
|
|
53
|
-
// Install dependencies
|
|
54
|
-
addDependenciesToPackageJson(tree, dependencies.form, {});
|
|
55
|
-
|
|
56
|
-
return (): void => {
|
|
57
|
-
installPackagesTask(tree);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default formGenerator;
|