@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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { addDependenciesToPackageJson, formatFiles, generateFiles, installPackagesTask, Tree } from '@nx/devkit';
|
|
5
|
+
import { IndentationText, Project, QuoteKind, StructureKind, SyntaxKind } from 'ts-morph';
|
|
6
|
+
import { dependencies, devDependencies } from '../../dependencies';
|
|
7
|
+
import { formatName, formatAppIdentifier, searchAliasPath, getImportPathPrefix } from '../../utils';
|
|
8
|
+
import { AuthGeneratorSchema } from './schema';
|
|
9
|
+
|
|
10
|
+
const updateStore = (libRoot: string): void => {
|
|
11
|
+
const project = new Project({
|
|
12
|
+
manipulationSettings: {
|
|
13
|
+
indentationText: IndentationText.TwoSpaces,
|
|
14
|
+
quoteKind: QuoteKind.Single,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const storePath = `${libRoot}/shared/data-access/store/src`;
|
|
19
|
+
const apiPath = `${libRoot}/shared/data-access/api/src`;
|
|
20
|
+
const authPath = `${libRoot}/shared/data-access/auth/src`;
|
|
21
|
+
const store = project.addSourceFileAtPath(`${storePath}/store.ts`);
|
|
22
|
+
const apiAlias = searchAliasPath(apiPath);
|
|
23
|
+
const authAlias = searchAliasPath(authPath);
|
|
24
|
+
|
|
25
|
+
if (!apiAlias) {
|
|
26
|
+
throw new Error('Could not find API library.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!authAlias) {
|
|
30
|
+
throw new Error('Could not find Auth library.');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
store.addImportDeclarations([
|
|
34
|
+
{ moduleSpecifier: apiAlias, namedImports: ['authApi', 'profileApi'] },
|
|
35
|
+
{ moduleSpecifier: authAlias, namedImports: ['authListenerMiddleware', 'authReducer', 'authReducerPath'] },
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const rootReducer = store.getVariableDeclarationOrThrow('rootReducer');
|
|
39
|
+
|
|
40
|
+
rootReducer.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression).addProperties([
|
|
41
|
+
{ name: '[authApi.reducerPath]', initializer: 'authApi.reducer', kind: StructureKind.PropertyAssignment },
|
|
42
|
+
{ name: '[authReducerPath]', initializer: 'authReducer', kind: StructureKind.PropertyAssignment },
|
|
43
|
+
{ name: '[profileApi.reducerPath]', initializer: 'profileApi.reducer', kind: StructureKind.PropertyAssignment },
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
const middlewares = store.getVariableDeclarationOrThrow('middlewares');
|
|
47
|
+
|
|
48
|
+
middlewares
|
|
49
|
+
.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)
|
|
50
|
+
.addElements(['authApi.middleware', 'authListenerMiddleware.middleware', 'profileApi.middleware'], {
|
|
51
|
+
useNewLines: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
project.saveSync();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export async function runAuthGenerator(tree: Tree, options: AuthGeneratorSchema) {
|
|
58
|
+
const appRoot = `apps/${options.directory}`;
|
|
59
|
+
const libRoot = `libs/${options.directory}`;
|
|
60
|
+
const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
|
|
61
|
+
|
|
62
|
+
// Generate shared libs
|
|
63
|
+
execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=api`, {
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
});
|
|
66
|
+
execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=auth`, {
|
|
67
|
+
stdio: 'inherit',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const appPackagePath = `${appRoot}/package.json`;
|
|
71
|
+
|
|
72
|
+
// Remove unnecessary files and files that will be replaced
|
|
73
|
+
tree.delete(`${libRoot}/shared/data-access/api/src/index.ts`);
|
|
74
|
+
tree.delete(`${libRoot}/shared/data-access/auth/src/index.ts`);
|
|
75
|
+
|
|
76
|
+
// Add lib files
|
|
77
|
+
generateFiles(tree, path.join(__dirname, '/lib-files'), libRoot, {
|
|
78
|
+
...options,
|
|
79
|
+
formatName,
|
|
80
|
+
formatAppIdentifier,
|
|
81
|
+
formatDirectory: () => libPath,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
updateStore(libRoot);
|
|
85
|
+
|
|
86
|
+
// Add dependencies
|
|
87
|
+
addDependenciesToPackageJson(tree, dependencies['auth'], devDependencies['auth']);
|
|
88
|
+
|
|
89
|
+
if (existsSync(appPackagePath)) {
|
|
90
|
+
addDependenciesToPackageJson(tree, dependencies['auth'], devDependencies['auth'], appPackagePath);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await formatFiles(tree);
|
|
94
|
+
|
|
95
|
+
return (): void => {
|
|
96
|
+
installPackagesTask(tree);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default runAuthGenerator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
4
|
+
|
|
5
|
+
export async function runFormUtilsGenerator(tree: Tree, options: { directory: string }): Promise<void> {
|
|
6
|
+
const libRoot = `libs/${options.directory}`;
|
|
7
|
+
|
|
8
|
+
// Generate shared libs
|
|
9
|
+
execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=utils --name=form`, {
|
|
10
|
+
stdio: 'inherit',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Remove unnecessary files and files that will be replaced
|
|
14
|
+
tree.delete(`${libRoot}/shared/utils/form/src/index.ts`);
|
|
15
|
+
|
|
16
|
+
// Add lib files
|
|
17
|
+
generateFiles(tree, path.join(__dirname, '/lib-files'), libRoot, {});
|
|
18
|
+
|
|
19
|
+
await formatFiles(tree);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default runFormUtilsGenerator;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { addDependenciesToPackageJson, formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
5
|
+
import { dependencies } from '../../dependencies';
|
|
6
|
+
import { formatName, formatAppIdentifier, getImportPathPrefix } from '../../utils';
|
|
7
|
+
|
|
8
|
+
export async function runRNStylesGenerator(tree: Tree, options: { name: string; directory: string }): Promise<void> {
|
|
9
|
+
const appRoot = `apps/${options.directory}`;
|
|
10
|
+
const libRoot = `libs/${options.directory}`;
|
|
11
|
+
const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
|
|
12
|
+
|
|
13
|
+
// Generate shared libs
|
|
14
|
+
execSync(
|
|
15
|
+
`npx nx g react-lib --app=${options.directory} --scope=shared --type=ui --name=styles --withComponent=false`,
|
|
16
|
+
{
|
|
17
|
+
stdio: 'inherit',
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const appPackagePath = `${appRoot}/package.json`;
|
|
22
|
+
|
|
23
|
+
// Remove unnecessary files and files that will be replaced
|
|
24
|
+
tree.delete(`${libRoot}/shared/ui/styles/src/index.ts`);
|
|
25
|
+
|
|
26
|
+
// Add lib files
|
|
27
|
+
generateFiles(tree, path.join(__dirname, 'lib-files'), libRoot, {
|
|
28
|
+
...options,
|
|
29
|
+
formatName,
|
|
30
|
+
formatAppIdentifier,
|
|
31
|
+
formatDirectory: () => libPath,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Add dependencies
|
|
35
|
+
addDependenciesToPackageJson(tree, dependencies['rn-styles'], {});
|
|
36
|
+
|
|
37
|
+
if (existsSync(appPackagePath)) {
|
|
38
|
+
addDependenciesToPackageJson(tree, dependencies['rn-styles'], {}, appPackagePath);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await formatFiles(tree);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default runRNStylesGenerator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
4
|
+
import { formatName, formatAppIdentifier, getImportPathPrefix } from '../../utils';
|
|
5
|
+
|
|
6
|
+
export async function runStorageGenerator(tree: Tree, options: { name: string; directory: string }): Promise<void> {
|
|
7
|
+
const libRoot = `libs/${options.directory}`;
|
|
8
|
+
const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
|
|
9
|
+
|
|
10
|
+
// Generate shared libs
|
|
11
|
+
execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=storage`, {
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Remove unnecessary files and files that will be replaced
|
|
16
|
+
tree.delete(`${libRoot}/shared/data-access/storage/src/index.ts`);
|
|
17
|
+
|
|
18
|
+
// Add lib files
|
|
19
|
+
generateFiles(tree, path.join(__dirname, '/lib-files'), libRoot, {
|
|
20
|
+
...options,
|
|
21
|
+
formatName,
|
|
22
|
+
formatAppIdentifier,
|
|
23
|
+
formatDirectory: () => libPath,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await formatFiles(tree);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default runStorageGenerator;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { addDependenciesToPackageJson, formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
5
|
+
import { dependencies } from '../../dependencies';
|
|
6
|
+
import { formatName, formatAppIdentifier, getImportPathPrefix } from '../../utils';
|
|
7
|
+
import { StoreGeneratorSchema } from './schema';
|
|
8
|
+
|
|
9
|
+
export async function runStoreGenerator(tree: Tree, options: StoreGeneratorSchema): Promise<void> {
|
|
10
|
+
const appRoot = `apps/${options.directory}`;
|
|
11
|
+
const libRoot = `libs/${options.directory}`;
|
|
12
|
+
const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
|
|
13
|
+
|
|
14
|
+
// Generate shared libs
|
|
15
|
+
execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=store`, {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const appPackagePath = `${appRoot}/package.json`;
|
|
20
|
+
|
|
21
|
+
// Remove unnecessary files and files that will be replaced
|
|
22
|
+
tree.delete(`${libRoot}/shared/data-access/store/src/index.ts`);
|
|
23
|
+
|
|
24
|
+
// Add lib files
|
|
25
|
+
generateFiles(tree, path.join(__dirname, `${options.baseGeneratorType}/lib-files`), libRoot, {
|
|
26
|
+
...options,
|
|
27
|
+
formatName,
|
|
28
|
+
formatAppIdentifier,
|
|
29
|
+
formatDirectory: () => libPath,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Add dependencies
|
|
33
|
+
addDependenciesToPackageJson(tree, dependencies['store'], {});
|
|
34
|
+
|
|
35
|
+
if (existsSync(appPackagePath)) {
|
|
36
|
+
addDependenciesToPackageJson(tree, dependencies['store'], {}, appPackagePath);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await formatFiles(tree);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default runStoreGenerator;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { addDependenciesToPackageJson, formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
5
|
+
import { dependencies } from '../../dependencies';
|
|
6
|
+
import { formatName, formatAppIdentifier, getImportPathPrefix, LibraryType } from '../../utils';
|
|
7
|
+
|
|
8
|
+
export async function runUIKittenGenerator(tree: Tree, options: { name: string; directory: string }): Promise<void> {
|
|
9
|
+
const appRoot = `apps/${options.directory}`;
|
|
10
|
+
const libRoot = `libs/${options.directory}`;
|
|
11
|
+
const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
|
|
12
|
+
|
|
13
|
+
// Generate shared libs
|
|
14
|
+
execSync(
|
|
15
|
+
`npx nx g react-lib --app=${options.directory} --scope=shared --type=${LibraryType.FEATURES} --name=user-theme-provider --withComponent=false`,
|
|
16
|
+
{
|
|
17
|
+
stdio: 'inherit',
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const appPackagePath = `${appRoot}/package.json`;
|
|
22
|
+
|
|
23
|
+
// Remove unnecessary files and files that will be replaced
|
|
24
|
+
tree.delete(`${libRoot}/shared/features/user-theme-provider/src/index.ts`);
|
|
25
|
+
|
|
26
|
+
// Add lib files
|
|
27
|
+
generateFiles(tree, path.join(__dirname, 'lib-files'), libRoot, {
|
|
28
|
+
...options,
|
|
29
|
+
formatName,
|
|
30
|
+
formatAppIdentifier,
|
|
31
|
+
formatDirectory: () => libPath,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Update styles lib exports
|
|
35
|
+
const stylesLibIndexData = tree.read(`${libRoot}/shared/ui/styles/src/lib/index.ts`);
|
|
36
|
+
const newStylesLibIndexData =
|
|
37
|
+
stylesLibIndexData + `export * from './create-adaptive-styles';\nexport * from './eva-theme';\n`;
|
|
38
|
+
|
|
39
|
+
tree.write(`${libRoot}/shared/ui/styles/src/lib/index.ts`, newStylesLibIndexData);
|
|
40
|
+
|
|
41
|
+
// Add dependencies
|
|
42
|
+
addDependenciesToPackageJson(tree, dependencies['ui-kitten'], {});
|
|
43
|
+
|
|
44
|
+
if (existsSync(appPackagePath)) {
|
|
45
|
+
addDependenciesToPackageJson(tree, dependencies['ui-kitten'], {}, appPackagePath);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
await formatFiles(tree);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default runUIKittenGenerator;
|
|
@@ -17,12 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"sourceTag": "type:app",
|
|
20
|
-
"onlyDependOnLibsWithTags": [
|
|
21
|
-
"type:features",
|
|
22
|
-
"type:ui",
|
|
23
|
-
"type:utils",
|
|
24
|
-
"type:data-access"
|
|
25
|
-
]
|
|
20
|
+
"onlyDependOnLibsWithTags": ["type:features", "type:ui", "type:utils", "type:data-access"]
|
|
26
21
|
},
|
|
27
22
|
{
|
|
28
23
|
"sourceTag": "type:utils",
|
|
@@ -34,12 +29,7 @@
|
|
|
34
29
|
},
|
|
35
30
|
{
|
|
36
31
|
"sourceTag": "type:features",
|
|
37
|
-
"onlyDependOnLibsWithTags": [
|
|
38
|
-
"type:features",
|
|
39
|
-
"type:data-access",
|
|
40
|
-
"type:ui",
|
|
41
|
-
"type:utils"
|
|
42
|
-
]
|
|
32
|
+
"onlyDependOnLibsWithTags": ["type:features", "type:data-access", "type:ui", "type:utils"]
|
|
43
33
|
},
|
|
44
34
|
{
|
|
45
35
|
"sourceTag": "type:ui",
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as readline from 'readline';
|
|
3
|
+
import { getProjects, ProjectType, Tree } from '@nx/devkit';
|
|
4
|
+
import { constants } from './constants';
|
|
5
|
+
import { dynamicImport } from './dynamic-import';
|
|
6
|
+
|
|
7
|
+
export const createCliReadline = (): readline.Interface =>
|
|
8
|
+
readline.createInterface({
|
|
9
|
+
input: process.stdin,
|
|
10
|
+
output: process.stdout,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const askQuestion = (
|
|
14
|
+
question: string,
|
|
15
|
+
defaultAnswer?: string,
|
|
16
|
+
cliReadline?: readline.Interface,
|
|
17
|
+
): Promise<string> => {
|
|
18
|
+
const rl = cliReadline || createCliReadline();
|
|
19
|
+
|
|
20
|
+
if (defaultAnswer) {
|
|
21
|
+
rl.write(defaultAnswer);
|
|
22
|
+
// Move cursor to end of the line
|
|
23
|
+
setTimeout(() => rl.write(null, { ctrl: true, name: 'e' }));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return new Promise((resolve) =>
|
|
27
|
+
rl.question(question, (answer) => {
|
|
28
|
+
if (!cliReadline) {
|
|
29
|
+
rl.close();
|
|
30
|
+
}
|
|
31
|
+
resolve(answer);
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export enum LibraryType {
|
|
37
|
+
UI = 'ui',
|
|
38
|
+
DATA_ACCESS = 'data-access',
|
|
39
|
+
FEATURES = 'features',
|
|
40
|
+
UTILS = 'utils',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const parseLibsPaths = (): Record<string, Array<string>> => {
|
|
44
|
+
let tsconfig;
|
|
45
|
+
|
|
46
|
+
if (fs.existsSync('tsconfig.base.json')) {
|
|
47
|
+
tsconfig = JSON.parse(fs.readFileSync('tsconfig.base.json', 'utf8'));
|
|
48
|
+
} else {
|
|
49
|
+
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json', 'utf8'));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return tsconfig.compilerOptions.paths;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const validateLibraryType = (type: string): string => {
|
|
56
|
+
const allLibraryTypes = Object.values(LibraryType);
|
|
57
|
+
|
|
58
|
+
if (!allLibraryTypes.includes(type as LibraryType)) {
|
|
59
|
+
throw new Error(`Invalid library type: ${type}.\nAvailable types: ${allLibraryTypes.join(', ')}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return type;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const getNxLibsPaths = (types: Array<LibraryType>): Array<string> => {
|
|
66
|
+
const libs = parseLibsPaths();
|
|
67
|
+
|
|
68
|
+
return Object.values(libs)
|
|
69
|
+
.map((value) => value[0].replace('/index.ts', ''))
|
|
70
|
+
.filter((value) => types.some((type) => value.includes(type)));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const searchNxLibsPaths = (
|
|
74
|
+
paths: Array<string>,
|
|
75
|
+
input: string,
|
|
76
|
+
method: 'includes' | 'startsWith' | 'endsWith' = 'includes',
|
|
77
|
+
): Array<string> => {
|
|
78
|
+
return paths.filter((path) => path[method](input));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const searchAliasPath = (input: string): string | undefined => {
|
|
82
|
+
const libs = parseLibsPaths();
|
|
83
|
+
const path = Object.keys(libs).find((key) => libs[key][0].includes(input));
|
|
84
|
+
|
|
85
|
+
return path;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const filterSource = async (input: string, source: Array<string>): Promise<Array<{ value: string }>> => {
|
|
89
|
+
const filteredData = input
|
|
90
|
+
? source.filter((pathname) => pathname.toLowerCase().includes(input.toLowerCase()))
|
|
91
|
+
: source;
|
|
92
|
+
|
|
93
|
+
return filteredData.map((path) => ({ value: path }));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const appendFileContent = (path: string, endContent: string, tree: Tree): void => {
|
|
97
|
+
const content = tree.read(path, 'utf-8');
|
|
98
|
+
const contentUpdate = (content || '') + endContent;
|
|
99
|
+
|
|
100
|
+
tree.write(path, contentUpdate);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getProjectsDetails = (tree: Tree, projectType: ProjectType): Array<{ name: string; path: string }> =>
|
|
104
|
+
Array.from(getProjects(tree))
|
|
105
|
+
.filter(([_, project]) => project.projectType === projectType)
|
|
106
|
+
.map(([name, project]) => ({ name, path: project.root }));
|
|
107
|
+
|
|
108
|
+
export const selectProject = async (
|
|
109
|
+
tree: Tree,
|
|
110
|
+
projectType: ProjectType,
|
|
111
|
+
message: string,
|
|
112
|
+
): Promise<{ name: string; path: string }> => {
|
|
113
|
+
const { default: autocomplete } = await dynamicImport<typeof import('inquirer-autocomplete-standalone')>(
|
|
114
|
+
'inquirer-autocomplete-standalone',
|
|
115
|
+
);
|
|
116
|
+
const projects = getProjectsDetails(tree, projectType);
|
|
117
|
+
|
|
118
|
+
if (!projects.length) {
|
|
119
|
+
throw new Error(`No projects of type ${projectType} found.`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return autocomplete({
|
|
123
|
+
message,
|
|
124
|
+
source: async (input) => {
|
|
125
|
+
const entries = [...projects, { name: constants.sharedValue, path: constants.sharedValue }].map((project) => ({
|
|
126
|
+
name: `${project.name} (${project.path})`,
|
|
127
|
+
value: { ...project, name: projectType === 'application' ? project.path.replace('apps/', '') : project.name },
|
|
128
|
+
}));
|
|
129
|
+
|
|
130
|
+
if (!input) {
|
|
131
|
+
return entries;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return entries.filter((entry) => entry.name.toLowerCase().includes(input.toLowerCase()));
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const getLibraryDetailsByName = async (
|
|
140
|
+
tree: Tree,
|
|
141
|
+
libraryName?: string,
|
|
142
|
+
): Promise<{ name: string; path: string }> => {
|
|
143
|
+
let selectedLibraryName: string;
|
|
144
|
+
let selectedLibraryPath: string;
|
|
145
|
+
|
|
146
|
+
if (libraryName) {
|
|
147
|
+
selectedLibraryName = libraryName;
|
|
148
|
+
|
|
149
|
+
const library = getProjectsDetails(tree, 'library').find((library) => library.name === selectedLibraryName);
|
|
150
|
+
|
|
151
|
+
if (!library) {
|
|
152
|
+
throw new Error(`Library ${selectedLibraryName} not found`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
selectedLibraryPath = library.path;
|
|
156
|
+
} else {
|
|
157
|
+
const selectedLibrary = await selectProject(tree, 'library', 'Select the library to move: ');
|
|
158
|
+
|
|
159
|
+
selectedLibraryName = selectedLibrary.name;
|
|
160
|
+
selectedLibraryPath = selectedLibrary.path;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return { name: selectedLibraryName, path: selectedLibraryPath };
|
|
164
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Tree, output, readJson, writeJson } from '@nx/devkit';
|
|
2
|
+
import { isEmpty } from 'lodash';
|
|
3
|
+
|
|
4
|
+
const defaultEsLintConfigPath = '.eslintrc.json';
|
|
5
|
+
|
|
6
|
+
export interface Constraint {
|
|
7
|
+
sourceTag: string;
|
|
8
|
+
onlyDependOnLibsWithTags: Array<string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const getNxRulesEntry = (config: Record<string, any>): { files: Array<string>; rules: Record<string, any> } =>
|
|
12
|
+
config.overrides?.find((entry: { rules: { [x: string]: any } }) => !!entry.rules['@nx/enforce-module-boundaries']);
|
|
13
|
+
|
|
14
|
+
export const getNxRulesEntryOrThrowError = (
|
|
15
|
+
config: Record<string, any>,
|
|
16
|
+
): { files: Array<string>; rules: Record<string, any> } => {
|
|
17
|
+
if (!config) {
|
|
18
|
+
throw new Error('ESLint config not found');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const entryWithRules = getNxRulesEntry(config);
|
|
22
|
+
|
|
23
|
+
if (!entryWithRules) {
|
|
24
|
+
throw new Error(`ESLint: can't find '@nx/enforce-module-boundaries' rule`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return entryWithRules;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getNxRulesStatus = (config: Record<string, any>): string => {
|
|
31
|
+
return getNxRulesEntryOrThrowError(config).rules['@nx/enforce-module-boundaries'][0];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getNxRules = (config: Record<string, any>): Array<Constraint> => {
|
|
35
|
+
return getNxRulesEntryOrThrowError(config).rules['@nx/enforce-module-boundaries'][1].depConstraints;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const readESLintConfig = (tree: Tree): { config: Record<string, any>; path: string } => {
|
|
39
|
+
let path = defaultEsLintConfigPath;
|
|
40
|
+
|
|
41
|
+
const checkConfigExists = (path: string): void => {
|
|
42
|
+
if (!tree.exists(path)) {
|
|
43
|
+
throw new Error(`ESLint config not found: ${path}`);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
checkConfigExists(path);
|
|
48
|
+
|
|
49
|
+
let config = readJson(tree, path);
|
|
50
|
+
|
|
51
|
+
if (getNxRulesEntry(config)) {
|
|
52
|
+
return { config, path };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (config.extends?.length) {
|
|
56
|
+
path = config.extends[0];
|
|
57
|
+
|
|
58
|
+
checkConfigExists(path);
|
|
59
|
+
|
|
60
|
+
config = readJson(tree, config.extends[0]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { config, path };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const getNpmScope = (tree: Tree): string | undefined => {
|
|
67
|
+
const { name } = tree.exists('package.json') ? readJson<{ name?: string }>(tree, 'package.json') : { name: null };
|
|
68
|
+
|
|
69
|
+
return name?.startsWith('@') ? name.split('/')[0].substring(1) : undefined;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const addNxAppTag = (tree: Tree, appDirectory: string): void => {
|
|
73
|
+
const { config, path } = readESLintConfig(tree);
|
|
74
|
+
const constraints = getNxRules(config);
|
|
75
|
+
const doesTagExist = !!constraints.find((constraint) => constraint.sourceTag === `app:${appDirectory}`);
|
|
76
|
+
|
|
77
|
+
if (doesTagExist) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
constraints.push({
|
|
82
|
+
sourceTag: `app:${appDirectory}`,
|
|
83
|
+
onlyDependOnLibsWithTags: [`app:${appDirectory}`, 'app:shared'],
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
writeJson(tree, path, config);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const addNxScopeTag = (tree: Tree, scope: string): void => {
|
|
90
|
+
const { config, path } = readESLintConfig(tree);
|
|
91
|
+
const constraints = getNxRules(config);
|
|
92
|
+
const doesTagExist = !!constraints.find((constraint) => constraint.sourceTag === `scope:${scope}`);
|
|
93
|
+
|
|
94
|
+
if (doesTagExist) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
constraints.push({ sourceTag: `scope:${scope}`, onlyDependOnLibsWithTags: [`scope:${scope}`, 'scope:shared'] });
|
|
99
|
+
|
|
100
|
+
writeJson(tree, path, config);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getImportPathPrefix = (tree: Tree): string => {
|
|
104
|
+
const npmScope = getNpmScope(tree);
|
|
105
|
+
|
|
106
|
+
return npmScope ? `${npmScope === '@' ? '' : '@'}${npmScope}` : '';
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const verifyEsLintConfig = (tree: Tree): Record<string, any> => {
|
|
110
|
+
const { config, path } = readESLintConfig(tree);
|
|
111
|
+
const importantTags = [
|
|
112
|
+
'app:shared',
|
|
113
|
+
'scope:shared',
|
|
114
|
+
'type:app',
|
|
115
|
+
'type:data-access',
|
|
116
|
+
'type:features',
|
|
117
|
+
'type:ui',
|
|
118
|
+
'type:utils',
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
if (!config || isEmpty(config)) {
|
|
122
|
+
throw new Error(`Failed to load ESLint config: ${path}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const rulesEntry = getNxRulesEntryOrThrowError(config).rules['@nx/enforce-module-boundaries'];
|
|
127
|
+
const tags = rulesEntry[1].depConstraints.map((rule: Constraint) => rule.sourceTag);
|
|
128
|
+
const areRulesDisabled = rulesEntry[1].depConstraints.find(
|
|
129
|
+
(rule: Constraint) => rule.sourceTag === '*' && rule.onlyDependOnLibsWithTags.includes('*'),
|
|
130
|
+
);
|
|
131
|
+
const areRulesBroken = !importantTags.every((tag) => tags.includes(tag));
|
|
132
|
+
|
|
133
|
+
if (rulesEntry[0] !== 'error') {
|
|
134
|
+
rulesEntry[0] = 'error';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (areRulesDisabled || areRulesBroken) {
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
139
|
+
const esLintConfigTemplate = require('../templates/config-template.json');
|
|
140
|
+
const templateRules = esLintConfigTemplate.rules['@nx/enforce-module-boundaries'];
|
|
141
|
+
|
|
142
|
+
rulesEntry[0] = templateRules[0];
|
|
143
|
+
rulesEntry[1] = templateRules[1];
|
|
144
|
+
|
|
145
|
+
writeJson(tree, path, config);
|
|
146
|
+
}
|
|
147
|
+
// TODO: use custom errors
|
|
148
|
+
} catch {
|
|
149
|
+
output.warn({ title: output.bold('ESLint config has no @nx/enforce-module-boundaries rule. Updating rules...') });
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
151
|
+
const esLintConfigRulesTemplate = require('../templates/config-template.json');
|
|
152
|
+
|
|
153
|
+
config.overrides.push(esLintConfigRulesTemplate);
|
|
154
|
+
|
|
155
|
+
writeJson(tree, path, config);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return config;
|
|
159
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const formatName = (value: string, withoutSpaces = false): string =>
|
|
2
|
+
value
|
|
3
|
+
.split('-')
|
|
4
|
+
.map((word) => `${word.charAt(0).toUpperCase()}${word.substring(1)}`)
|
|
5
|
+
.join(withoutSpaces ? '' : ' ');
|
|
6
|
+
|
|
7
|
+
export const formatAppIdentifier = (value: string): string => value.toLowerCase().replace(/-/g, '.');
|
|
8
|
+
|
|
9
|
+
export const getProjectName = (str: string): string => {
|
|
10
|
+
const parts = str.split('@');
|
|
11
|
+
|
|
12
|
+
return parts.length > 1 ? parts[1].split('/')[0] : parts[0];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const getLibName = (path: string): string | undefined => path.split('/').pop();
|