@ronas-it/nx-generators 0.10.3 → 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.
Files changed (41) hide show
  1. package/README.md +10 -1
  2. package/package.json +1 -1
  3. package/src/generators/code-checks/files/.eslintrc.json.template +173 -1
  4. package/src/generators/code-checks/generator.ts +2 -6
  5. package/src/generators/code-checks/scripts.ts +4 -4
  6. package/src/generators/entity-api/generator.ts +9 -9
  7. package/src/generators/expo-app/generator.ts +20 -20
  8. package/src/generators/expo-app/scripts.ts +1 -1
  9. package/src/generators/form/generator.ts +17 -9
  10. package/src/generators/form/utils/add-form-usage.ts +24 -11
  11. package/src/generators/form/utils/get-form-utils-directory.ts +19 -6
  12. package/src/generators/form/utils/update-index.ts +2 -1
  13. package/src/generators/lib-move/generator.ts +5 -5
  14. package/src/generators/lib-remove/generator.ts +3 -6
  15. package/src/generators/lib-rename/generator.ts +1 -1
  16. package/src/generators/lib-tags/generator.ts +8 -10
  17. package/src/generators/lib-tags/interfaces/verify-tag-config.ts +6 -6
  18. package/src/generators/lib-tags/utils/check-lib-tags.ts +21 -19
  19. package/src/generators/next-app/generator.ts +17 -12
  20. package/src/generators/react-component/generator.ts +4 -4
  21. package/src/generators/react-lib/generator.ts +6 -6
  22. package/src/generators/repo-config/generator.ts +2 -2
  23. package/src/shared/dependencies.ts +20 -20
  24. package/src/shared/enums/base-generator-type.ts +1 -1
  25. package/src/shared/generators/api-client/generator.ts +6 -12
  26. package/src/shared/generators/app-env/generator.ts +7 -9
  27. package/src/shared/generators/auth/generator.ts +25 -32
  28. package/src/shared/generators/form-utils/generator.ts +4 -5
  29. package/src/shared/generators/rn-styles/generator.ts +8 -13
  30. package/src/shared/generators/storage/generator.ts +6 -11
  31. package/src/shared/generators/store/generator.ts +6 -12
  32. package/src/shared/generators/ui-kitten/generator.ts +10 -14
  33. package/src/shared/templates/config-template.json +2 -12
  34. package/src/shared/utils/cli-utils.ts +37 -22
  35. package/src/shared/utils/config-utils.ts +26 -13
  36. package/src/shared/utils/constants.ts +1 -1
  37. package/src/shared/utils/dynamic-import.ts +3 -4
  38. package/src/shared/utils/format-utils.ts +4 -5
  39. package/src/shared/utils/get-lib-directory-name.ts +1 -0
  40. package/src/shared/utils/ts-utils.ts +7 -4
  41. package/tsconfig.spec.json +1 -6
@@ -10,7 +10,7 @@ import {
10
10
  getLibraryDetailsByName,
11
11
  selectProject,
12
12
  validateLibraryType,
13
- getLibDirectoryName
13
+ getLibDirectoryName,
14
14
  } from '../../shared/utils';
15
15
  import { LibMoveGeneratorSchema } from './schema';
16
16
 
@@ -34,9 +34,9 @@ export async function libMoveGenerator(tree: Tree, options: LibMoveGeneratorSche
34
34
  options.type = options.type
35
35
  ? validateLibraryType(options.type)
36
36
  : await autocomplete({
37
- message: 'Select the library type: ',
38
- source: (input) => filterSource(input as string, Object.values(LibraryType))
39
- });
37
+ message: 'Select the library type: ',
38
+ source: (input) => filterSource(input as string, Object.values(LibraryType)),
39
+ });
40
40
 
41
41
  const libraryName =
42
42
  options.name ||
@@ -49,7 +49,7 @@ export async function libMoveGenerator(tree: Tree, options: LibMoveGeneratorSche
49
49
 
50
50
  execSync(`npx nx g mv --project=${srcLibraryName} --destination=${libPath}`, { stdio: 'inherit' });
51
51
 
52
- return () => {
52
+ return (): void => {
53
53
  execSync('npx nx g lib-tags --skipRepoCheck', { stdio: 'inherit' });
54
54
  };
55
55
  }
@@ -1,12 +1,9 @@
1
+ import { execSync } from 'child_process';
1
2
  import { Tree } from '@nx/devkit';
2
- import { LibRemoveGeneratorSchema } from './schema';
3
3
  import { askQuestion, selectProject } from '../../shared/utils';
4
- import { execSync } from 'child_process';
4
+ import { LibRemoveGeneratorSchema } from './schema';
5
5
 
6
- export async function libRemoveGenerator(
7
- tree: Tree,
8
- options: LibRemoveGeneratorSchema
9
- ) {
6
+ export async function libRemoveGenerator(tree: Tree, options: LibRemoveGeneratorSchema): Promise<void> {
10
7
  const libraryName = options.libName || (await selectProject(tree, 'library', 'Select the library to remove: ')).name;
11
8
 
12
9
  if (!libraryName) {
@@ -3,7 +3,7 @@ import { Tree } from '@nx/devkit';
3
3
  import { askQuestion, getLibraryDetailsByName } from '../../shared/utils';
4
4
  import { LibRenameGeneratorSchema } from './schema';
5
5
 
6
- export async function libRenameGenerator(tree: Tree, options: LibRenameGeneratorSchema) {
6
+ export async function libRenameGenerator(tree: Tree, options: LibRenameGeneratorSchema): Promise<void> {
7
7
  const { name: currentLibraryName, path: currentLibraryPath } = await getLibraryDetailsByName(
8
8
  tree,
9
9
  options.currentLibName,
@@ -1,10 +1,10 @@
1
- import { Tree, getProjects, ProjectConfiguration, formatFiles, output } from '@nx/devkit';
2
- import { LibTagsGeneratorSchema } from './schema';
3
1
  import { execSync } from 'child_process';
4
- import { askQuestion, getNxRules, readESLintConfig, verifyEsLintConfig } from '../../shared/utils';
2
+ import { Tree, getProjects, ProjectConfiguration, formatFiles, output } from '@nx/devkit';
5
3
  import { noop } from 'lodash';
6
- import { checkApplicationTags, checkLibraryTags } from './utils';
4
+ import { askQuestion, getNxRules, readESLintConfig, verifyEsLintConfig } from '../../shared/utils';
7
5
  import { LibTagsContext } from './interfaces';
6
+ import { LibTagsGeneratorSchema } from './schema';
7
+ import { checkApplicationTags, checkLibraryTags } from './utils';
8
8
 
9
9
  const context: LibTagsContext = {
10
10
  config: {},
@@ -13,17 +13,15 @@ const context: LibTagsContext = {
13
13
  reload: (tree: Tree) => {
14
14
  context.config = readESLintConfig(tree).config;
15
15
  context.rules = getNxRules(context.config);
16
- }
16
+ },
17
17
  };
18
18
 
19
- export async function libTagsGenerator(
20
- tree: Tree,
21
- options: LibTagsGeneratorSchema,
22
- ) {
19
+ export async function libTagsGenerator(tree: Tree, options: LibTagsGeneratorSchema): Promise<void> {
23
20
  const hasUnstagedChanges = !options.skipRepoCheck && execSync('git status -s').toString('utf8');
24
21
 
25
22
  if (hasUnstagedChanges) {
26
- const shouldContinue = await askQuestion('You have unstaged changes. Are you sure you want to continue? (y/n): ') === 'y';
23
+ const shouldContinue =
24
+ (await askQuestion('You have unstaged changes. Are you sure you want to continue? (y/n): ')) === 'y';
27
25
 
28
26
  if (!shouldContinue) {
29
27
  return;
@@ -3,10 +3,10 @@ import { TagType } from '../types';
3
3
  import { LibTagsContext } from './context';
4
4
 
5
5
  export interface VerifyTagConfig {
6
- project: ProjectConfiguration,
7
- tree: Tree,
8
- tag?: string,
9
- tagType: TagType,
10
- context: LibTagsContext,
11
- ruleNotFoundCallback?: () => void
6
+ project: ProjectConfiguration;
7
+ tree: Tree;
8
+ tag?: string;
9
+ tagType: TagType;
10
+ context: LibTagsContext;
11
+ ruleNotFoundCallback?: () => void;
12
12
  }
@@ -16,14 +16,7 @@ const getTagFromLibPath = (libPath: string, type: TagType): string => {
16
16
  }
17
17
  };
18
18
 
19
- const verifyLibraryTag = ({
20
- project,
21
- tree,
22
- tag,
23
- tagType,
24
- context,
25
- ruleNotFoundCallback
26
- }: VerifyTagConfig): void => {
19
+ const verifyLibraryTag = ({ project, tree, tag, tagType, context, ruleNotFoundCallback }: VerifyTagConfig): void => {
27
20
  const defaultRuleNotFoundCallback = (): void => {
28
21
  throw new Error(`Missing ${tagType} tag rule for ${tag}. Please add it to the ESLint config file.`);
29
22
  };
@@ -52,16 +45,16 @@ const verifyLibraryTag = ({
52
45
  updateProjectConfiguration(tree, project.name as string, project);
53
46
 
54
47
  if (tagType === 'scope') {
55
- addNxScopeTag(tree, tagFromLibPath);
48
+ addNxScopeTag(tree, tagFromLibPath);
56
49
  context.reload(tree);
57
50
  }
58
51
 
59
52
  verifyLibraryTag({
60
53
  project,
61
54
  tree,
62
- tag:`${tagType}:${tagFromLibPath}`,
55
+ tag: `${tagType}:${tagFromLibPath}`,
63
56
  tagType,
64
- context
57
+ context,
65
58
  });
66
59
  }
67
60
  } else {
@@ -79,10 +72,13 @@ const verifyLibraryTag = ({
79
72
  }
80
73
  }
81
74
 
82
- updateProjectConfiguration(tree, project.name as string, { ...project, tags: [...(project.tags || []), `${tagType}:${tag}`] });
75
+ updateProjectConfiguration(tree, project.name as string, {
76
+ ...project,
77
+ tags: [...(project.tags || []), `${tagType}:${tag}`],
78
+ });
83
79
 
84
80
  if (tagType === 'scope') {
85
- addNxScopeTag(tree, tag);
81
+ addNxScopeTag(tree, tag);
86
82
  context.reload(tree);
87
83
  }
88
84
  }
@@ -106,8 +102,11 @@ export const checkApplicationTags = (project: ProjectConfiguration, tree: Tree,
106
102
 
107
103
  const projectAppTag = project.root.split('/').pop() as string;
108
104
 
109
- updateProjectConfiguration(tree, project.name as string, { ...project, tags: [...(project.tags || []), `app:${projectAppTag}`] });
110
- addNxAppTag(tree, projectAppTag);
105
+ updateProjectConfiguration(tree, project.name as string, {
106
+ ...project,
107
+ tags: [...(project.tags || []), `app:${projectAppTag}`],
108
+ });
109
+ addNxAppTag(tree, projectAppTag);
111
110
  context.reload(tree);
112
111
  }
113
112
 
@@ -116,7 +115,10 @@ export const checkApplicationTags = (project: ProjectConfiguration, tree: Tree,
116
115
 
117
116
  project = readProjectConfiguration(tree, project.name as string);
118
117
 
119
- updateProjectConfiguration(tree, project.name as string, { ...project, tags: [...(project.tags || []), 'type:app'] });
118
+ updateProjectConfiguration(tree, project.name as string, {
119
+ ...project,
120
+ tags: [...(project.tags || []), 'type:app'],
121
+ });
120
122
  }
121
123
  };
122
124
 
@@ -131,13 +133,13 @@ export const checkLibraryTags = (project: ProjectConfiguration, tree: Tree, cont
131
133
  project,
132
134
  tree,
133
135
  tag: scopeTag,
134
- tagType:'scope',
136
+ tagType: 'scope',
135
137
  context,
136
- ruleNotFoundCallback:() => {
138
+ ruleNotFoundCallback: () => {
137
139
  context.log(`Missing scope tag rule for ${scopeTag}. Adding...`);
138
140
  addNxScopeTag(tree, scopeTag?.replace('scope:', '') as string);
139
141
  context.reload(tree);
140
- }
142
+ },
141
143
  });
142
144
  verifyLibraryTag({ project, tree, tag: typeTag, tagType: 'type', context });
143
145
  };
@@ -1,4 +1,6 @@
1
1
  import { execSync } from 'child_process';
2
+ import { existsSync } from 'fs';
3
+ import * as path from 'path';
2
4
  import {
3
5
  addDependenciesToPackageJson,
4
6
  formatFiles,
@@ -8,21 +10,23 @@ import {
8
10
  Tree,
9
11
  writeJson,
10
12
  } from '@nx/devkit';
11
- import { NextAppGeneratorSchema } from './schema';
12
- import { existsSync } from 'fs';
13
13
  import { dependencies } from '../../shared/dependencies';
14
14
  import { BaseGeneratorType } from '../../shared/enums';
15
- import { runApiClientGenerator, runAppEnvGenerator, runFormUtilsGenerator, runStoreGenerator } from '../../shared/generators';
15
+ import {
16
+ runApiClientGenerator,
17
+ runAppEnvGenerator,
18
+ runFormUtilsGenerator,
19
+ runStoreGenerator,
20
+ } from '../../shared/generators';
16
21
  import { addNxAppTag, askQuestion, formatName } from '../../shared/utils';
17
- import * as path from 'path';
22
+ import { NextAppGeneratorSchema } from './schema';
18
23
 
19
- export async function nextAppGenerator(
20
- tree: Tree,
21
- options: NextAppGeneratorSchema,
22
- ) {
23
- const shouldGenerateStoreLib = await askQuestion('Do you want to create store lib? (y/n): ') === 'y';
24
- const shouldGenerateApiClientLib = shouldGenerateStoreLib && await askQuestion('Do you want to create api client lib? (y/n): ') === 'y';
25
- const shouldGenerateFormUtilsLib = await askQuestion('Do you want to create a lib with the form utils? (y/n): ') === 'y';
24
+ export async function nextAppGenerator(tree: Tree, options: NextAppGeneratorSchema) {
25
+ const shouldGenerateStoreLib = (await askQuestion('Do you want to create store lib? (y/n): ')) === 'y';
26
+ const shouldGenerateApiClientLib =
27
+ shouldGenerateStoreLib && (await askQuestion('Do you want to create api client lib? (y/n): ')) === 'y';
28
+ const shouldGenerateFormUtilsLib =
29
+ (await askQuestion('Do you want to create a lib with the form utils? (y/n): ')) === 'y';
26
30
 
27
31
  const appRoot = `apps/${options.directory}`;
28
32
  const tags = [`app:${options.directory}`, 'type:app'];
@@ -40,6 +44,7 @@ export async function nextAppGenerator(
40
44
  // Install @nx/expo to generate libs
41
45
  const packageJson = readJson(tree, 'package.json');
42
46
  const hasNxExpo = !!packageJson.devDependencies['@nx/expo'];
47
+
43
48
  if (!hasNxExpo) {
44
49
  execSync('npx nx add @nx/expo', { stdio: 'inherit' });
45
50
  }
@@ -91,7 +96,7 @@ export async function nextAppGenerator(
91
96
 
92
97
  await formatFiles(tree);
93
98
 
94
- return () => {
99
+ return (): void => {
95
100
  installPackagesTask(tree);
96
101
  };
97
102
  }
@@ -10,11 +10,11 @@ import {
10
10
  formatName,
11
11
  getNxLibsPaths,
12
12
  LibraryType,
13
- searchNxLibsPaths
13
+ searchNxLibsPaths,
14
14
  } from '../../shared/utils';
15
15
  import { ReactComponentGeneratorSchema } from './schema';
16
16
 
17
- export async function reactComponentGenerator(tree: Tree, options: ReactComponentGeneratorSchema) {
17
+ export async function reactComponentGenerator(tree: Tree, options: ReactComponentGeneratorSchema): Promise<void> {
18
18
  const { default: autocomplete } = await dynamicImport<typeof import('inquirer-autocomplete-standalone')>(
19
19
  'inquirer-autocomplete-standalone',
20
20
  );
@@ -27,7 +27,7 @@ export async function reactComponentGenerator(tree: Tree, options: ReactComponen
27
27
  const filteredNxLibsPaths = searchNxLibsPaths(nxLibsPaths, input as string);
28
28
 
29
29
  return filteredNxLibsPaths.map((path) => ({ value: path }));
30
- }
30
+ },
31
31
  });
32
32
 
33
33
  const cliReadline = createCliReadline();
@@ -49,7 +49,7 @@ export async function reactComponentGenerator(tree: Tree, options: ReactComponen
49
49
 
50
50
  generateFiles(tree, path.join(__dirname, `files`), componentPath, {
51
51
  ...options,
52
- name: formatName(options.name, true)
52
+ name: formatName(options.name, true),
53
53
  });
54
54
 
55
55
  const updateIndexes = (): void => {
@@ -13,11 +13,11 @@ import {
13
13
  selectProject,
14
14
  validateLibraryType,
15
15
  getLibDirectoryName,
16
- createCliReadline
16
+ createCliReadline,
17
17
  } from '../../shared/utils';
18
18
  import { ReactLibGeneratorSchema } from './schema';
19
19
 
20
- export async function reactLibGenerator(tree: Tree, options: ReactLibGeneratorSchema) {
20
+ export async function reactLibGenerator(tree: Tree, options: ReactLibGeneratorSchema): Promise<void> {
21
21
  const { default: autocomplete } = await dynamicImport<typeof import('inquirer-autocomplete-standalone')>(
22
22
  'inquirer-autocomplete-standalone',
23
23
  );
@@ -32,9 +32,9 @@ export async function reactLibGenerator(tree: Tree, options: ReactLibGeneratorSc
32
32
  options.type = options.type
33
33
  ? validateLibraryType(options.type)
34
34
  : await autocomplete({
35
- message: 'Select the library type: ',
36
- source: (input) => filterSource(input as string, Object.values(LibraryType))
37
- });
35
+ message: 'Select the library type: ',
36
+ source: (input) => filterSource(input as string, Object.values(LibraryType)),
37
+ });
38
38
 
39
39
  const cliReadline = createCliReadline();
40
40
  options.name =
@@ -78,7 +78,7 @@ export async function reactLibGenerator(tree: Tree, options: ReactLibGeneratorSc
78
78
 
79
79
  if (libDirectoryName !== options.name) {
80
80
  output.warn({
81
- title: `The library directory was changed to ${output.bold(libDirectoryName)} so that it does not start with the scope name.`
81
+ title: `The library directory was changed to ${output.bold(libDirectoryName)} so that it does not start with the scope name.`,
82
82
  });
83
83
  }
84
84
  }
@@ -9,8 +9,8 @@ import {
9
9
  writeJson,
10
10
  } from '@nx/devkit';
11
11
  import { devDependencies } from '../../shared/dependencies';
12
- import scripts from './scripts';
13
12
  import { formatName, getProjectName } from '../../shared/utils';
13
+ import scripts from './scripts';
14
14
 
15
15
  export async function repoConfigGenerator(tree: Tree) {
16
16
  const projectRoot = '.';
@@ -36,7 +36,7 @@ export async function repoConfigGenerator(tree: Tree) {
36
36
 
37
37
  await formatFiles(tree);
38
38
 
39
- return () => {
39
+ return (): void => {
40
40
  installPackagesTask(tree);
41
41
  };
42
42
  }
@@ -1,6 +1,6 @@
1
1
  export const dependencies = {
2
2
  'expo-app': {
3
- "@ronas-it/react-native-common-modules": "^0.6.0",
3
+ '@ronas-it/react-native-common-modules': '^0.6.0',
4
4
  'expo-constants': '~17.0.3',
5
5
  'expo-dev-client': '^5.0.6',
6
6
  'expo-router': '~4.0.14',
@@ -10,12 +10,12 @@ export const dependencies = {
10
10
  'expo-status-bar': '^2.0.0',
11
11
  'expo-updates': '^0.26.10',
12
12
  'expo-insights': '~0.8.1',
13
- "lodash-es": "^4.17.21"
13
+ 'lodash-es': '^4.17.21',
14
14
  },
15
15
  'expo-app-root': {
16
16
  // Need new version to fix this error:
17
17
  // https://github.com/kristerkari/react-native-svg-transformer/issues/329
18
- 'react-native-svg-transformer': '^1.4.0'
18
+ 'react-native-svg-transformer': '^1.4.0',
19
19
  },
20
20
  'next-app': {
21
21
  'next-intl': '^3.17.2',
@@ -23,31 +23,31 @@ export const dependencies = {
23
23
  'api-client': {
24
24
  '@ronas-it/axios-api-client': '^0.1.0',
25
25
  },
26
- 'auth': {
27
- 'luxon': '^3.4.4'
26
+ auth: {
27
+ luxon: '^3.4.4',
28
28
  },
29
29
  'rn-styles': {
30
- 'react-native-extended-stylesheet': '^0.12.0'
30
+ 'react-native-extended-stylesheet': '^0.12.0',
31
31
  },
32
- 'store': {
32
+ store: {
33
33
  '@ronas-it/rtkq-entity-api': '^0.3.1',
34
- 'react-redux': '^9.1.2'
34
+ 'react-redux': '^9.1.2',
35
35
  },
36
36
  'ui-kitten': {
37
37
  '@eva-design/eva': '^2.2.0',
38
- '@ui-kitten/components': '^5.3.1'
38
+ '@ui-kitten/components': '^5.3.1',
39
39
  },
40
- 'form': {
40
+ form: {
41
41
  '@hookform/resolvers': '^3.9.0',
42
42
  'react-hook-form': '^7.53.0',
43
- 'yup': '^1.4.0'
44
- }
43
+ yup: '^1.4.0',
44
+ },
45
45
  };
46
46
 
47
47
  export const devDependencies = {
48
48
  'code-checks': {
49
- 'eslint': '^9.8.0',
50
- 'prettier': '^3.3.2',
49
+ eslint: '^9.8.0',
50
+ prettier: '^3.3.2',
51
51
  'eslint-config-prettier': '^9.1.0',
52
52
  'eslint-import-resolver-typescript': '^3.7.0',
53
53
  'eslint-plugin-import': '^2.29.1',
@@ -55,7 +55,7 @@ export const devDependencies = {
55
55
  'eslint-plugin-react': '^7.34.3',
56
56
  'eslint-plugin-react-hooks': '^5.0.0',
57
57
  'eslint-plugin-unused-imports': '^4.1.4',
58
- 'husky': '^9.1.5',
58
+ husky: '^9.1.5',
59
59
  '@stylistic/eslint-plugin': '^2.12.1',
60
60
  '@typescript-eslint/eslint-plugin': '^8.18.1',
61
61
  '@typescript-eslint/parser': '^8.18.1',
@@ -65,12 +65,12 @@ export const devDependencies = {
65
65
  '@types/lodash': '^4.14.194',
66
66
  },
67
67
  'expo-app-root': {
68
- 'cross-env': '^7.0.3'
68
+ 'cross-env': '^7.0.3',
69
69
  },
70
70
  'repo-config': {
71
- 'syncpack': '^12.3.2',
71
+ syncpack: '^12.3.2',
72
+ },
73
+ auth: {
74
+ '@types/luxon': '3.4.2',
72
75
  },
73
- 'auth': {
74
- '@types/luxon': '3.4.2'
75
- }
76
76
  };
@@ -1,4 +1,4 @@
1
1
  export enum BaseGeneratorType {
2
2
  EXPO_APP = 'expo-app',
3
- NEXT_APP = 'next-app'
3
+ NEXT_APP = 'next-app',
4
4
  }
@@ -1,25 +1,19 @@
1
1
  import { execSync } from 'child_process';
2
2
  import { existsSync } from 'fs';
3
3
  import * as path from 'path';
4
- import {
5
- addDependenciesToPackageJson,
6
- formatFiles,
7
- generateFiles,
8
- Tree
9
- } from '@nx/devkit';
4
+ import { addDependenciesToPackageJson, formatFiles, generateFiles, Tree } from '@nx/devkit';
10
5
  import { dependencies } from '../../dependencies';
11
6
  import { formatName, formatAppIdentifier, getImportPathPrefix } from '../../utils';
12
7
 
13
- export async function runApiClientGenerator(
14
- tree: Tree,
15
- options: { name: string; directory: string }
16
- ) {
8
+ export async function runApiClientGenerator(tree: Tree, options: { name: string; directory: string }): Promise<void> {
17
9
  const appRoot = `apps/${options.directory}`;
18
10
  const libRoot = `libs/${options.directory}`;
19
11
  const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
20
12
 
21
13
  // Generate shared libs
22
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=api-client`, { stdio: 'inherit' });
14
+ execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=api-client`, {
15
+ stdio: 'inherit',
16
+ });
23
17
 
24
18
  const appPackagePath = `${appRoot}/package.json`;
25
19
 
@@ -31,7 +25,7 @@ export async function runApiClientGenerator(
31
25
  ...options,
32
26
  formatName,
33
27
  formatAppIdentifier,
34
- formatDirectory: () => libPath
28
+ formatDirectory: () => libPath,
35
29
  });
36
30
 
37
31
  // Add dependencies
@@ -1,23 +1,21 @@
1
1
  import { execSync } from 'child_process';
2
2
  import * as path from 'path';
3
- import {
4
- formatFiles,
5
- generateFiles,
6
- Tree
7
- } from '@nx/devkit';
3
+ import { formatFiles, generateFiles, Tree } from '@nx/devkit';
8
4
  import { BaseGeneratorType } from '../../enums';
9
5
  import { formatName, formatAppIdentifier, getImportPathPrefix } from '../../utils';
10
6
 
11
7
  export async function runAppEnvGenerator(
12
8
  tree: Tree,
13
- options: { name: string; directory: string, baseGeneratorType: BaseGeneratorType }
14
- ) {
9
+ options: { name: string; directory: string; baseGeneratorType: BaseGeneratorType },
10
+ ): Promise<void> {
15
11
  const libRoot = `libs/${options.directory}`;
16
12
  const appType = options.baseGeneratorType.split('-')[0].toUpperCase();
17
13
  const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
18
14
 
19
15
  // Generate shared libs
20
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=utils --name=app-env`, { stdio: 'inherit' });
16
+ execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=utils --name=app-env`, {
17
+ stdio: 'inherit',
18
+ });
21
19
 
22
20
  // Remove unnecessary files and files that will be replaced
23
21
  tree.delete(`${libRoot}/shared/utils/app-env/src/index.ts`);
@@ -28,7 +26,7 @@ export async function runAppEnvGenerator(
28
26
  formatName,
29
27
  formatAppIdentifier,
30
28
  formatDirectory: () => libPath,
31
- appType
29
+ appType,
32
30
  });
33
31
 
34
32
  await formatFiles(tree);
@@ -1,24 +1,18 @@
1
1
  import { execSync } from 'child_process';
2
+ import { existsSync } from 'fs';
2
3
  import * as path from 'path';
3
- import {
4
- addDependenciesToPackageJson,
5
- formatFiles,
6
- generateFiles,
7
- installPackagesTask,
8
- Tree
9
- } from '@nx/devkit';
4
+ import { addDependenciesToPackageJson, formatFiles, generateFiles, installPackagesTask, Tree } from '@nx/devkit';
5
+ import { IndentationText, Project, QuoteKind, StructureKind, SyntaxKind } from 'ts-morph';
10
6
  import { dependencies, devDependencies } from '../../dependencies';
11
7
  import { formatName, formatAppIdentifier, searchAliasPath, getImportPathPrefix } from '../../utils';
12
- import { existsSync } from 'fs';
13
- import { IndentationText, Project, QuoteKind, StructureKind, SyntaxKind } from 'ts-morph';
14
8
  import { AuthGeneratorSchema } from './schema';
15
9
 
16
10
  const updateStore = (libRoot: string): void => {
17
11
  const project = new Project({
18
12
  manipulationSettings: {
19
13
  indentationText: IndentationText.TwoSpaces,
20
- quoteKind: QuoteKind.Single
21
- }
14
+ quoteKind: QuoteKind.Single,
15
+ },
22
16
  });
23
17
 
24
18
  const storePath = `${libRoot}/shared/data-access/store/src`;
@@ -38,41 +32,40 @@ const updateStore = (libRoot: string): void => {
38
32
 
39
33
  store.addImportDeclarations([
40
34
  { moduleSpecifier: apiAlias, namedImports: ['authApi', 'profileApi'] },
41
- { moduleSpecifier: authAlias, namedImports: [ 'authListenerMiddleware', 'authReducer', 'authReducerPath'] }
35
+ { moduleSpecifier: authAlias, namedImports: ['authListenerMiddleware', 'authReducer', 'authReducerPath'] },
42
36
  ]);
43
37
 
44
38
  const rootReducer = store.getVariableDeclarationOrThrow('rootReducer');
45
39
 
46
- rootReducer.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression)
47
- .addProperties([
48
- { name: '[authApi.reducerPath]', initializer: 'authApi.reducer', kind: StructureKind.PropertyAssignment },
49
- { name: '[authReducerPath]', initializer: 'authReducer', kind: StructureKind.PropertyAssignment },
50
- { name: '[profileApi.reducerPath]', initializer: 'profileApi.reducer', kind: StructureKind.PropertyAssignment }
51
- ]);
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
+ ]);
52
45
 
53
46
  const middlewares = store.getVariableDeclarationOrThrow('middlewares');
54
47
 
55
- middlewares.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)
56
- .addElements([
57
- 'authApi.middleware',
58
- 'authListenerMiddleware.middleware',
59
- 'profileApi.middleware'
60
- ], { useNewLines: true });
48
+ middlewares
49
+ .getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression)
50
+ .addElements(['authApi.middleware', 'authListenerMiddleware.middleware', 'profileApi.middleware'], {
51
+ useNewLines: true,
52
+ });
61
53
 
62
54
  project.saveSync();
63
55
  };
64
56
 
65
- export async function runAuthGenerator(
66
- tree: Tree,
67
- options: AuthGeneratorSchema
68
- ) {
57
+ export async function runAuthGenerator(tree: Tree, options: AuthGeneratorSchema) {
69
58
  const appRoot = `apps/${options.directory}`;
70
59
  const libRoot = `libs/${options.directory}`;
71
60
  const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
72
61
 
73
62
  // Generate shared libs
74
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=api`, { stdio: 'inherit' });
75
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=auth`, { stdio: 'inherit' });
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
+ });
76
69
 
77
70
  const appPackagePath = `${appRoot}/package.json`;
78
71
 
@@ -85,7 +78,7 @@ export async function runAuthGenerator(
85
78
  ...options,
86
79
  formatName,
87
80
  formatAppIdentifier,
88
- formatDirectory: () => libPath
81
+ formatDirectory: () => libPath,
89
82
  });
90
83
 
91
84
  updateStore(libRoot);
@@ -99,7 +92,7 @@ export async function runAuthGenerator(
99
92
 
100
93
  await formatFiles(tree);
101
94
 
102
- return () => {
95
+ return (): void => {
103
96
  installPackagesTask(tree);
104
97
  };
105
98
  }
@@ -2,14 +2,13 @@ import { execSync } from 'child_process';
2
2
  import * as path from 'path';
3
3
  import { formatFiles, generateFiles, Tree } from '@nx/devkit';
4
4
 
5
- export async function runFormUtilsGenerator(
6
- tree: Tree,
7
- options: { directory: string }
8
- ) {
5
+ export async function runFormUtilsGenerator(tree: Tree, options: { directory: string }): Promise<void> {
9
6
  const libRoot = `libs/${options.directory}`;
10
7
 
11
8
  // Generate shared libs
12
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=utils --name=form`, { stdio: 'inherit' });
9
+ execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=utils --name=form`, {
10
+ stdio: 'inherit',
11
+ });
13
12
 
14
13
  // Remove unnecessary files and files that will be replaced
15
14
  tree.delete(`${libRoot}/shared/utils/form/src/index.ts`);