@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
@@ -1,27 +1,22 @@
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 runRNStylesGenerator(
14
- tree: Tree,
15
- options: { name: string; directory: string },
16
- ) {
8
+ export async function runRNStylesGenerator(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=ui --name=styles --withComponent=false`, {
23
- stdio: 'inherit',
24
- });
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
+ );
25
20
 
26
21
  const appPackagePath = `${appRoot}/package.json`;
27
22
 
@@ -1,21 +1,16 @@
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 { formatName, formatAppIdentifier, getImportPathPrefix } from '../../utils';
9
5
 
10
- export async function runStorageGenerator(
11
- tree: Tree,
12
- options: { name: string; directory: string }
13
- ) {
6
+ export async function runStorageGenerator(tree: Tree, options: { name: string; directory: string }): Promise<void> {
14
7
  const libRoot = `libs/${options.directory}`;
15
8
  const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
16
9
 
17
10
  // Generate shared libs
18
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=storage`, { stdio: 'inherit' });
11
+ execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=storage`, {
12
+ stdio: 'inherit',
13
+ });
19
14
 
20
15
  // Remove unnecessary files and files that will be replaced
21
16
  tree.delete(`${libRoot}/shared/data-access/storage/src/index.ts`);
@@ -25,7 +20,7 @@ export async function runStorageGenerator(
25
20
  ...options,
26
21
  formatName,
27
22
  formatAppIdentifier,
28
- formatDirectory: () => libPath
23
+ formatDirectory: () => libPath,
29
24
  });
30
25
 
31
26
  await formatFiles(tree);
@@ -1,26 +1,20 @@
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
  import { StoreGeneratorSchema } from './schema';
13
8
 
14
- export async function runStoreGenerator(
15
- tree: Tree,
16
- options: StoreGeneratorSchema
17
- ) {
9
+ export async function runStoreGenerator(tree: Tree, options: StoreGeneratorSchema): Promise<void> {
18
10
  const appRoot = `apps/${options.directory}`;
19
11
  const libRoot = `libs/${options.directory}`;
20
12
  const libPath = `${getImportPathPrefix(tree)}/${options.directory}`;
21
13
 
22
14
  // Generate shared libs
23
- execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=store`, { stdio: 'inherit' });
15
+ execSync(`npx nx g react-lib --app=${options.directory} --scope=shared --type=data-access --name=store`, {
16
+ stdio: 'inherit',
17
+ });
24
18
 
25
19
  const appPackagePath = `${appRoot}/package.json`;
26
20
 
@@ -32,7 +26,7 @@ export async function runStoreGenerator(
32
26
  ...options,
33
27
  formatName,
34
28
  formatAppIdentifier,
35
- formatDirectory: () => libPath
29
+ formatDirectory: () => libPath,
36
30
  });
37
31
 
38
32
  // Add dependencies
@@ -1,27 +1,22 @@
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, LibraryType } from '../../utils';
12
7
 
13
- export async function runUIKittenGenerator(
14
- tree: Tree,
15
- options: { name: string; directory: string }
16
- ) {
8
+ export async function runUIKittenGenerator(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=${LibraryType.FEATURES} --name=user-theme-provider --withComponent=false`, {
23
- stdio: 'inherit',
24
- });
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
+ );
25
20
 
26
21
  const appPackagePath = `${appRoot}/package.json`;
27
22
 
@@ -38,7 +33,8 @@ export async function runUIKittenGenerator(
38
33
 
39
34
  // Update styles lib exports
40
35
  const stylesLibIndexData = tree.read(`${libRoot}/shared/ui/styles/src/lib/index.ts`);
41
- const newStylesLibIndexData = stylesLibIndexData + `export * from './create-adaptive-styles';\nexport * from './eva-theme';\n`;
36
+ const newStylesLibIndexData =
37
+ stylesLibIndexData + `export * from './create-adaptive-styles';\nexport * from './eva-theme';\n`;
42
38
 
43
39
  tree.write(`${libRoot}/shared/ui/styles/src/lib/index.ts`, newStylesLibIndexData);
44
40
 
@@ -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",
@@ -1,15 +1,20 @@
1
- import * as readline from 'readline';
2
1
  import * as fs from 'fs';
2
+ import * as readline from 'readline';
3
3
  import { getProjects, ProjectType, Tree } from '@nx/devkit';
4
- import { dynamicImport } from './dynamic-import';
5
4
  import { constants } from './constants';
5
+ import { dynamicImport } from './dynamic-import';
6
6
 
7
- export const createCliReadline = (): readline.Interface => readline.createInterface({
8
- input: process.stdin,
9
- output: process.stdout,
10
- })
7
+ export const createCliReadline = (): readline.Interface =>
8
+ readline.createInterface({
9
+ input: process.stdin,
10
+ output: process.stdout,
11
+ });
11
12
 
12
- export const askQuestion = (question: string, defaultAnswer?: string, cliReadline?: readline.Interface): Promise<string> => {
13
+ export const askQuestion = (
14
+ question: string,
15
+ defaultAnswer?: string,
16
+ cliReadline?: readline.Interface,
17
+ ): Promise<string> => {
13
18
  const rl = cliReadline || createCliReadline();
14
19
 
15
20
  if (defaultAnswer) {
@@ -55,9 +60,9 @@ export const validateLibraryType = (type: string): string => {
55
60
  }
56
61
 
57
62
  return type;
58
- }
63
+ };
59
64
 
60
- export const getNxLibsPaths = (types: Array<LibraryType>) => {
65
+ export const getNxLibsPaths = (types: Array<LibraryType>): Array<string> => {
61
66
  const libs = parseLibsPaths();
62
67
 
63
68
  return Object.values(libs)
@@ -69,18 +74,18 @@ export const searchNxLibsPaths = (
69
74
  paths: Array<string>,
70
75
  input: string,
71
76
  method: 'includes' | 'startsWith' | 'endsWith' = 'includes',
72
- ) => {
77
+ ): Array<string> => {
73
78
  return paths.filter((path) => path[method](input));
74
79
  };
75
80
 
76
- export const searchAliasPath = (input: string) => {
81
+ export const searchAliasPath = (input: string): string | undefined => {
77
82
  const libs = parseLibsPaths();
78
83
  const path = Object.keys(libs).find((key) => libs[key][0].includes(input));
79
84
 
80
85
  return path;
81
86
  };
82
87
 
83
- export const filterSource = async (input: string, source: Array<string>) => {
88
+ export const filterSource = async (input: string, source: Array<string>): Promise<Array<{ value: string }>> => {
84
89
  const filteredData = input
85
90
  ? source.filter((pathname) => pathname.toLowerCase().includes(input.toLowerCase()))
86
91
  : source;
@@ -88,19 +93,26 @@ export const filterSource = async (input: string, source: Array<string>) => {
88
93
  return filteredData.map((path) => ({ value: path }));
89
94
  };
90
95
 
91
- export const appendFileContent = (path: string, endContent: string, tree: Tree) => {
96
+ export const appendFileContent = (path: string, endContent: string, tree: Tree): void => {
92
97
  const content = tree.read(path, 'utf-8');
93
98
  const contentUpdate = (content || '') + endContent;
94
99
 
95
100
  tree.write(path, contentUpdate);
96
101
  };
97
102
 
98
- export const getProjectsDetails = (tree: Tree, projectType: ProjectType) => Array.from(getProjects(tree))
99
- .filter(([_, project]) => project.projectType === projectType)
100
- .map(([name, project]) => ({ name, path: project.root }));
101
-
102
- export const selectProject = async (tree: Tree, projectType: ProjectType, message: string): Promise<{ name: string, path: string }> => {
103
- const { default: autocomplete } = await dynamicImport<typeof import('inquirer-autocomplete-standalone')>('inquirer-autocomplete-standalone');
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
+ );
104
116
  const projects = getProjectsDetails(tree, projectType);
105
117
 
106
118
  if (!projects.length) {
@@ -112,7 +124,7 @@ export const selectProject = async (tree: Tree, projectType: ProjectType, messag
112
124
  source: async (input) => {
113
125
  const entries = [...projects, { name: constants.sharedValue, path: constants.sharedValue }].map((project) => ({
114
126
  name: `${project.name} (${project.path})`,
115
- value: { ...project, name: projectType === 'application' ? project.path.replace('apps/', '') : project.name }
127
+ value: { ...project, name: projectType === 'application' ? project.path.replace('apps/', '') : project.name },
116
128
  }));
117
129
 
118
130
  if (!input) {
@@ -120,11 +132,14 @@ export const selectProject = async (tree: Tree, projectType: ProjectType, messag
120
132
  }
121
133
 
122
134
  return entries.filter((entry) => entry.name.toLowerCase().includes(input.toLowerCase()));
123
- }
135
+ },
124
136
  });
125
137
  };
126
138
 
127
- export const getLibraryDetailsByName = async (tree: Tree, libraryName?: string): Promise<{ name: string; path: string }> => {
139
+ export const getLibraryDetailsByName = async (
140
+ tree: Tree,
141
+ libraryName?: string,
142
+ ): Promise<{ name: string; path: string }> => {
128
143
  let selectedLibraryName: string;
129
144
  let selectedLibraryPath: string;
130
145
 
@@ -8,10 +8,12 @@ export interface Constraint {
8
8
  onlyDependOnLibsWithTags: Array<string>;
9
9
  }
10
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']);
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
13
 
14
- export const getNxRulesEntryOrThrowError = (config: Record<string, any>): { files: Array<string>, rules: Record<string, any> } => {
14
+ export const getNxRulesEntryOrThrowError = (
15
+ config: Record<string, any>,
16
+ ): { files: Array<string>; rules: Record<string, any> } => {
15
17
  if (!config) {
16
18
  throw new Error('ESLint config not found');
17
19
  }
@@ -23,17 +25,17 @@ export const getNxRulesEntryOrThrowError = (config: Record<string, any>): { file
23
25
  }
24
26
 
25
27
  return entryWithRules;
26
- }
28
+ };
27
29
 
28
30
  export const getNxRulesStatus = (config: Record<string, any>): string => {
29
31
  return getNxRulesEntryOrThrowError(config).rules['@nx/enforce-module-boundaries'][0];
30
- }
32
+ };
31
33
 
32
34
  export const getNxRules = (config: Record<string, any>): Array<Constraint> => {
33
35
  return getNxRulesEntryOrThrowError(config).rules['@nx/enforce-module-boundaries'][1].depConstraints;
34
36
  };
35
37
 
36
- export const readESLintConfig = (tree: Tree): { config: Record<string, any>, path: string } => {
38
+ export const readESLintConfig = (tree: Tree): { config: Record<string, any>; path: string } => {
37
39
  let path = defaultEsLintConfigPath;
38
40
 
39
41
  const checkConfigExists = (path: string): void => {
@@ -62,9 +64,7 @@ export const readESLintConfig = (tree: Tree): { config: Record<string, any>, pat
62
64
  };
63
65
 
64
66
  const getNpmScope = (tree: Tree): string | undefined => {
65
- const { name } = tree.exists('package.json')
66
- ? readJson<{ name?: string }>(tree, 'package.json')
67
- : { name: null };
67
+ const { name } = tree.exists('package.json') ? readJson<{ name?: string }>(tree, 'package.json') : { name: null };
68
68
 
69
69
  return name?.startsWith('@') ? name.split('/')[0].substring(1) : undefined;
70
70
  };
@@ -78,7 +78,10 @@ export const addNxAppTag = (tree: Tree, appDirectory: string): void => {
78
78
  return;
79
79
  }
80
80
 
81
- constraints.push({ sourceTag: `app:${appDirectory}`, onlyDependOnLibsWithTags: [`app:${appDirectory}`, 'app:shared'] });
81
+ constraints.push({
82
+ sourceTag: `app:${appDirectory}`,
83
+ onlyDependOnLibsWithTags: [`app:${appDirectory}`, 'app:shared'],
84
+ });
82
85
 
83
86
  writeJson(tree, path, config);
84
87
  };
@@ -105,7 +108,15 @@ export const getImportPathPrefix = (tree: Tree): string => {
105
108
 
106
109
  export const verifyEsLintConfig = (tree: Tree): Record<string, any> => {
107
110
  const { config, path } = readESLintConfig(tree);
108
- const importantTags = ['app:shared', 'scope:shared', 'type:app', 'type:data-access', 'type:features', 'type:ui', 'type:utils'];
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
+ ];
109
120
 
110
121
  if (!config || isEmpty(config)) {
111
122
  throw new Error(`Failed to load ESLint config: ${path}`);
@@ -114,7 +125,9 @@ export const verifyEsLintConfig = (tree: Tree): Record<string, any> => {
114
125
  try {
115
126
  const rulesEntry = getNxRulesEntryOrThrowError(config).rules['@nx/enforce-module-boundaries'];
116
127
  const tags = rulesEntry[1].depConstraints.map((rule: Constraint) => rule.sourceTag);
117
- const areRulesDisabled = rulesEntry[1].depConstraints.find((rule: Constraint) => rule.sourceTag === '*' && rule.onlyDependOnLibsWithTags.includes('*'));
128
+ const areRulesDisabled = rulesEntry[1].depConstraints.find(
129
+ (rule: Constraint) => rule.sourceTag === '*' && rule.onlyDependOnLibsWithTags.includes('*'),
130
+ );
118
131
  const areRulesBroken = !importantTags.every((tag) => tags.includes(tag));
119
132
 
120
133
  if (rulesEntry[0] !== 'error') {
@@ -125,7 +138,7 @@ export const verifyEsLintConfig = (tree: Tree): Record<string, any> => {
125
138
  // eslint-disable-next-line @typescript-eslint/no-var-requires
126
139
  const esLintConfigTemplate = require('../templates/config-template.json');
127
140
  const templateRules = esLintConfigTemplate.rules['@nx/enforce-module-boundaries'];
128
-
141
+
129
142
  rulesEntry[0] = templateRules[0];
130
143
  rulesEntry[1] = templateRules[1];
131
144
 
@@ -1,3 +1,3 @@
1
1
  export const constants = {
2
- sharedValue: 'shared'
2
+ sharedValue: 'shared',
3
3
  };
@@ -1,4 +1,3 @@
1
- export const dynamicImport = new Function(
2
- 'specifier',
3
- 'return import(specifier)'
4
- ) as <T = never>(specifier: string) => Promise<T>;
1
+ export const dynamicImport = new Function('specifier', 'return import(specifier)') as <T = never>(
2
+ specifier: string,
3
+ ) => Promise<T>;
@@ -1,16 +1,15 @@
1
- export const formatName = (value: string, withoutSpaces = false) =>
1
+ export const formatName = (value: string, withoutSpaces = false): string =>
2
2
  value
3
3
  .split('-')
4
4
  .map((word) => `${word.charAt(0).toUpperCase()}${word.substring(1)}`)
5
5
  .join(withoutSpaces ? '' : ' ');
6
6
 
7
- export const formatAppIdentifier = (value: string) =>
8
- value.toLowerCase().replace(/-/g, '.');
7
+ export const formatAppIdentifier = (value: string): string => value.toLowerCase().replace(/-/g, '.');
9
8
 
10
- export const getProjectName = (str: string) => {
9
+ export const getProjectName = (str: string): string => {
11
10
  const parts = str.split('@');
12
11
 
13
12
  return parts.length > 1 ? parts[1].split('/')[0] : parts[0];
14
13
  };
15
14
 
16
- export const getLibName = (path: string) => path.split('/').pop();
15
+ export const getLibName = (path: string): string | undefined => path.split('/').pop();
@@ -4,6 +4,7 @@ export function getLibDirectoryName(libName: string, scopeName: string): string
4
4
  let newLibWords = libWords;
5
5
 
6
6
  const startsWithScopeWords = scopeWords.every((word, index) => libWords[index] === word);
7
+
7
8
  if (startsWithScopeWords && libWords.length > scopeWords.length) {
8
9
  newLibWords = libWords.slice(scopeWords.length);
9
10
  }
@@ -2,16 +2,19 @@ import { SourceFile } from 'ts-morph';
2
2
 
3
3
  export const addNamedImport = (namedImport: string, moduleSpecifier: string, file: SourceFile): void => {
4
4
  const importDeclaration = file.getImportDeclaration(moduleSpecifier);
5
+
5
6
  if (importDeclaration) {
6
- const hasNamedImport = importDeclaration.getNamedImports()
7
+ const hasNamedImport = importDeclaration
8
+ .getNamedImports()
7
9
  .find((declaration) => declaration.getName() === namedImport);
10
+
8
11
  if (!hasNamedImport) {
9
12
  importDeclaration.addNamedImport(namedImport);
10
13
  }
11
14
  } else {
12
15
  file.addImportDeclaration({
13
16
  namedImports: [namedImport],
14
- moduleSpecifier
15
- })
17
+ moduleSpecifier,
18
+ });
16
19
  }
17
- }
20
+ };
@@ -5,10 +5,5 @@
5
5
  "module": "commonjs",
6
6
  "types": ["jest", "node"]
7
7
  },
8
- "include": [
9
- "jest.config.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.ts",
12
- "src/**/*.d.ts"
13
- ]
8
+ "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
14
9
  }