@nx/react 0.0.0-pr-27957-a99d5ea → 0.0.0-pr-28229-afe192c

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 (60) hide show
  1. package/generators.json +5 -11
  2. package/index.d.ts +0 -1
  3. package/index.js +1 -3
  4. package/package.json +9 -10
  5. package/plugins/storybook/index.js +1 -2
  6. package/src/generators/application/application.js +2 -3
  7. package/src/generators/application/lib/normalize-options.d.ts +1 -1
  8. package/src/generators/application/lib/normalize-options.js +4 -6
  9. package/src/generators/application/lib/show-possible-warnings.js +2 -2
  10. package/src/generators/application/schema.d.ts +2 -5
  11. package/src/generators/application/schema.json +14 -25
  12. package/src/generators/component/component.d.ts +0 -1
  13. package/src/generators/component/component.js +0 -7
  14. package/src/generators/component/lib/normalize-options.js +2 -10
  15. package/src/generators/component/schema.d.ts +4 -22
  16. package/src/generators/component/schema.json +7 -41
  17. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
  18. package/src/generators/federate-module/federate-module.js +12 -22
  19. package/src/generators/federate-module/schema.d.ts +0 -1
  20. package/src/generators/federate-module/schema.json +0 -5
  21. package/src/generators/hook/hook.d.ts +0 -1
  22. package/src/generators/hook/hook.js +10 -44
  23. package/src/generators/hook/schema.d.ts +3 -18
  24. package/src/generators/hook/schema.json +8 -31
  25. package/src/generators/host/host.d.ts +0 -1
  26. package/src/generators/host/host.js +4 -9
  27. package/src/generators/host/lib/add-module-federation-files.js +2 -2
  28. package/src/generators/host/lib/normalize-remote.js +10 -6
  29. package/src/generators/host/schema.d.ts +2 -5
  30. package/src/generators/host/schema.json +8 -20
  31. package/src/generators/library/lib/normalize-options.js +1 -2
  32. package/src/generators/library/library.js +3 -7
  33. package/src/generators/library/schema.d.ts +2 -5
  34. package/src/generators/library/schema.json +13 -22
  35. package/src/generators/redux/redux.d.ts +0 -1
  36. package/src/generators/redux/redux.js +8 -21
  37. package/src/generators/redux/schema.d.ts +3 -7
  38. package/src/generators/redux/schema.json +6 -21
  39. package/src/generators/remote/lib/setup-tspath-for-remote.d.ts +2 -2
  40. package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -2
  41. package/src/generators/remote/remote.d.ts +0 -1
  42. package/src/generators/remote/remote.js +8 -12
  43. package/src/generators/remote/schema.d.ts +2 -5
  44. package/src/generators/remote/schema.json +8 -20
  45. package/src/generators/setup-ssr/setup-ssr.js +6 -0
  46. package/src/generators/setup-tailwind/lib/update-project.js +1 -2
  47. package/src/generators/stories/schema.json +0 -10
  48. package/src/generators/stories/stories.d.ts +1 -3
  49. package/src/generators/stories/stories.js +2 -17
  50. package/src/generators/storybook-configuration/configuration.js +0 -9
  51. package/src/generators/storybook-configuration/schema.d.ts +0 -3
  52. package/src/generators/storybook-configuration/schema.json +0 -15
  53. package/src/utils/ct-utils.js +2 -7
  54. package/src/utils/testing-generators.js +1 -2
  55. package/src/utils/versions.d.ts +1 -1
  56. package/src/utils/versions.js +1 -1
  57. package/src/generators/component-cypress-spec/component-cypress-spec.d.ts +0 -13
  58. package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -104
  59. package/src/generators/component-cypress-spec/files/__componentName__.__fileExt__ +0 -13
  60. package/src/generators/component-cypress-spec/schema.json +0 -45
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hookGenerator = hookGenerator;
4
- exports.hookGeneratorInternal = hookGeneratorInternal;
5
4
  // TODO(jack): Remove inline renderHook function when RTL releases with its own version
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const ast_utils_1 = require("../../utils/ast-utils");
@@ -9,12 +8,6 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
9
8
  const path_1 = require("path");
10
9
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
11
10
  async function hookGenerator(host, schema) {
12
- return hookGeneratorInternal(host, {
13
- nameAndDirectoryFormat: 'derived',
14
- ...schema,
15
- });
16
- }
17
- async function hookGeneratorInternal(host, schema) {
18
11
  const options = await normalizeOptions(host, schema);
19
12
  createFiles(host, options);
20
13
  addExportsToBarrel(host, options);
@@ -57,53 +50,26 @@ function addExportsToBarrel(host, options) {
57
50
  }
58
51
  async function normalizeOptions(host, options) {
59
52
  assertValidOptions(options);
60
- const { artifactName: name, directory: _directory, fileName: _fileName, nameAndDirectoryFormat, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
61
- artifactType: 'hook',
62
- callingGenerator: '@nx/react:hook',
53
+ const { directory, fileName: _fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
54
+ path: options.path,
63
55
  name: options.name,
64
- directory: options.directory,
65
- derivedDirectory: options.directory,
66
- flat: options.flat,
67
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
68
- project: options.project,
69
56
  fileExtension: 'tsx',
70
- pascalCaseFile: options.pascalCaseFiles,
71
- pascalCaseDirectory: options.pascalCaseDirectory,
72
57
  });
73
- let base = _fileName;
74
- if (base.startsWith('use-')) {
75
- base = base.substring(4);
76
- }
77
- else if (base.startsWith('use')) {
78
- base = base.substring(3);
79
- }
80
- const { className, fileName } = (0, devkit_1.names)(base);
58
+ const { className, fileName } = (0, devkit_1.names)(_fileName);
81
59
  // If using `as-provided` file and directory, then don't normalize.
82
60
  // Otherwise, support legacy behavior of prefixing filename with `use-`.
83
- const hookFilename = nameAndDirectoryFormat === 'as-provided'
84
- ? fileName
85
- : options.pascalCaseFiles
86
- ? 'use'.concat(className)
87
- : 'use-'.concat(fileName);
88
- const hookName = 'use'.concat(className);
89
- const hookTypeName = 'Use'.concat(className);
61
+ const hookFilename = fileName;
62
+ const hookName = className.toLocaleLowerCase().startsWith('use')
63
+ ? className
64
+ : 'use'.concat(className);
65
+ const hookTypeName = className.toLocaleLowerCase().startsWith('use')
66
+ ? className
67
+ : 'Use'.concat(className);
90
68
  const project = (0, devkit_1.getProjects)(host).get(projectName);
91
69
  const { sourceRoot: projectSourceRoot, projectType } = project;
92
70
  if (options.export && projectType === 'application') {
93
71
  devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
94
72
  }
95
- // Support legacy behavior of derived directory to prefix with `use-`.
96
- let directory = _directory;
97
- if (nameAndDirectoryFormat === 'derived') {
98
- const parts = directory.split('/');
99
- parts.pop();
100
- if (!options.flat) {
101
- parts.push(options.pascalCaseDirectory
102
- ? 'use'.concat(className)
103
- : 'use-'.concat(fileName));
104
- }
105
- directory = parts.join('/');
106
- }
107
73
  return {
108
74
  ...options,
109
75
  directory,
@@ -1,24 +1,9 @@
1
1
  export interface Schema {
2
- name: string;
3
- /**
4
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
5
- */
6
- project: string;
2
+ path: string;
3
+ name?: string;
7
4
  skipTests?: boolean;
8
5
  directory?: string;
9
6
  export?: boolean;
10
- /**
11
- * @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx v19.
12
- */
13
- pascalCaseFiles?: boolean;
14
- /**
15
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
16
- */
17
- pascalCaseDirectory?: boolean;
18
- /**
19
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
20
- */
21
- flat?: boolean;
22
7
  js?: boolean;
23
- nameAndDirectoryFormat?: 'as-provided' | 'derived';
8
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
24
9
  }
@@ -7,27 +7,24 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g hook my-hook --project=mylib",
11
- "description": "Generate a hook in the `mylib` library"
10
+ "command": "nx g hook mylib/my-hook",
11
+ "description": "Generate a hook `my-hook` in the `mylib` library"
12
12
  }
13
13
  ],
14
14
  "properties": {
15
- "project": {
15
+ "path": {
16
16
  "type": "string",
17
- "description": "The name of the project.",
18
- "alias": "p",
17
+ "description": "Path where the hook will be generated.",
19
18
  "$default": {
20
- "$source": "projectName"
19
+ "$source": "argv",
20
+ "index": 0
21
21
  },
22
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
22
+ "x-prompt": "Where should the hook be generated?",
23
+ "x-priority": "important"
23
24
  },
24
25
  "name": {
25
26
  "type": "string",
26
27
  "description": "The name of the hook.",
27
- "$default": {
28
- "$source": "argv",
29
- "index": 0
30
- },
31
28
  "x-prompt": "What name would you like to use for the hook?",
32
29
  "x-priority": "important"
33
30
  },
@@ -52,32 +49,12 @@
52
49
  "type": "string",
53
50
  "enum": ["as-provided", "derived"]
54
51
  },
55
- "flat": {
56
- "type": "boolean",
57
- "description": "Create hook at the source root rather than its own directory.",
58
- "default": false,
59
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
60
- },
61
52
  "export": {
62
53
  "type": "boolean",
63
54
  "description": "When true, the hook is exported from the project `index.ts` (if it exists).",
64
55
  "alias": "e",
65
56
  "default": false,
66
57
  "x-prompt": "Should this hook be exported in the project?"
67
- },
68
- "pascalCaseFiles": {
69
- "type": "boolean",
70
- "description": "Use pascal case hook file name (e.g. `useHook.ts`).",
71
- "alias": "P",
72
- "default": false,
73
- "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
74
- },
75
- "pascalCaseDirectory": {
76
- "type": "boolean",
77
- "description": "Use pascal case directory name (e.g. `useHook/useHook.ts`).",
78
- "alias": "R",
79
- "default": false,
80
- "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
81
58
  }
82
59
  },
83
60
  "required": ["name"]
@@ -1,5 +1,4 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function hostGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
- export declare function hostGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
5
4
  export default hostGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hostGenerator = hostGenerator;
4
- exports.hostGeneratorInternal = hostGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
7
6
  const application_1 = require("../application/application");
@@ -15,16 +14,11 @@ const update_module_federation_e2e_project_1 = require("./lib/update-module-fede
15
14
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
16
15
  const js_1 = require("@nx/js");
17
16
  const versions_1 = require("../../utils/versions");
17
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
18
18
  async function hostGenerator(host, schema) {
19
- return hostGeneratorInternal(host, {
20
- projectNameAndRootFormat: 'derived',
21
- ...schema,
22
- });
23
- }
24
- async function hostGeneratorInternal(host, schema) {
25
19
  const tasks = [];
26
20
  const options = {
27
- ...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host')),
21
+ ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
28
22
  js: schema.js ?? false,
29
23
  typescriptConfiguration: schema.js
30
24
  ? false
@@ -44,8 +38,10 @@ async function hostGeneratorInternal(host, schema) {
44
38
  }
45
39
  });
46
40
  }
41
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
47
42
  const initTask = await (0, application_1.default)(host, {
48
43
  ...options,
44
+ name: options.projectName,
49
45
  // The target use-case is loading remotes as child routes, thus always enable routing.
50
46
  routing: true,
51
47
  skipFormat: true,
@@ -67,7 +63,6 @@ async function hostGeneratorInternal(host, schema) {
67
63
  devServerPort: remotePort,
68
64
  ssr: options.ssr,
69
65
  skipFormat: true,
70
- projectNameAndRootFormat: options.projectNameAndRootFormat,
71
66
  typescriptConfiguration: options.typescriptConfiguration,
72
67
  js: options.js,
73
68
  dynamic: options.dynamic,
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const maybe_js_1 = require("../../../utils/maybe-js");
6
6
  function addModuleFederationFiles(host, options, defaultRemoteManifest) {
7
7
  const templateVariables = {
8
- ...(0, devkit_1.names)(options.name),
8
+ ...(0, devkit_1.names)(options.projectName),
9
9
  ...options,
10
10
  static: !options?.dynamic,
11
11
  tmpl: '',
@@ -16,7 +16,7 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
16
16
  };
17
17
  }),
18
18
  };
19
- const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.name);
19
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
20
20
  const pathToMFManifest = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'assets/module-federation.manifest.json');
21
21
  // Module federation requires bootstrap code to be dynamically imported.
22
22
  // Renaming original entry file so we can use `import(./bootstrap)` in
@@ -9,19 +9,23 @@ async function normalizeRemoteName(tree, remote, options) {
9
9
  name: remote,
10
10
  projectType: 'application',
11
11
  directory: options.directory,
12
- projectNameAndRootFormat: options.projectNameAndRootFormat,
13
- callingGenerator: '@nx/react:host',
14
12
  });
15
13
  return remoteName;
16
14
  }
17
15
  function normalizeRemoteDirectory(remote, options) {
18
- if (options.projectNameAndRootFormat === 'derived' || !options.directory) {
19
- return options.directory;
20
- }
21
16
  /**
22
17
  * With the `as-provided` format, the provided directory would be the root
23
18
  * of the host application. Append the remote name to the host parent
24
19
  * directory to get the remote directory.
20
+ *
21
+ * If no directory is provided, the remote directory will use the grandparent of the hostRoot 'acme/host/src' -> 'acme'
25
22
  */
26
- return (0, devkit_1.joinPathFragments)(options.directory, '..', remote);
23
+ if (options.directory) {
24
+ return (0, devkit_1.joinPathFragments)(options.directory, '..', remote);
25
+ }
26
+ else {
27
+ return options.appProjectRoot === '.'
28
+ ? remote
29
+ : (0, devkit_1.joinPathFragments)(options.appProjectRoot, '..', remote);
30
+ }
27
31
  }
@@ -1,4 +1,3 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
  import type { SupportedStyles } from '../../../typings/style';
4
3
 
@@ -6,14 +5,12 @@ export interface Schema {
6
5
  classComponent?: boolean;
7
6
  compiler?: 'babel' | 'swc';
8
7
  devServerPort?: number;
9
- directory?: string;
10
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
8
+ directory: string;
11
9
  e2eTestRunner: 'cypress' | 'playwright' | 'none';
12
10
  globalCss?: boolean;
13
11
  js?: boolean;
14
12
  linter: Linter | LinterType;
15
- name: string;
16
- pascalCaseFiles?: boolean;
13
+ name?: string;
17
14
  remotes?: string[];
18
15
  setParserOptionsProject?: boolean;
19
16
  skipFormat?: boolean;
@@ -6,28 +6,22 @@
6
6
  "description": "Create Module Federation configuration files for given React Host Application.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "directory": {
10
+ "description": "The directory of the new application.",
10
11
  "type": "string",
11
- "description": "The name of the host application to generate the Module Federation configuration",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use as the host application?",
17
- "pattern": "^[a-zA-Z][^:]*$",
18
- "x-priority": "important"
17
+ "x-prompt": "Which directory do you want to create the application in?"
19
18
  },
20
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
22
20
  "type": "string",
23
- "alias": "dir",
21
+ "description": "The name of the host application to generate the Module Federation configuration",
22
+ "pattern": "^[a-zA-Z][^:]*$",
24
23
  "x-priority": "important"
25
24
  },
26
- "projectNameAndRootFormat": {
27
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
28
- "type": "string",
29
- "enum": ["as-provided", "derived"]
30
- },
31
25
  "style": {
32
26
  "description": "The file extension to be used for style files.",
33
27
  "type": "string",
@@ -113,12 +107,6 @@
113
107
  "description": "Add tags to the application (used for linting).",
114
108
  "alias": "t"
115
109
  },
116
- "pascalCaseFiles": {
117
- "type": "boolean",
118
- "description": "Use pascal case component file name (e.g. App.tsx).",
119
- "alias": "P",
120
- "default": false
121
- },
122
110
  "classComponent": {
123
111
  "type": "boolean",
124
112
  "description": "Use class components instead of functional component.",
@@ -193,6 +181,6 @@
193
181
  "x-priority": "important"
194
182
  }
195
183
  },
196
- "required": ["name"],
184
+ "required": ["directory"],
197
185
  "additionalProperties": false
198
186
  }
@@ -5,13 +5,12 @@ const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const assertion_1 = require("../../../utils/assertion");
7
7
  async function normalizeOptions(host, options) {
8
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
9
10
  name: options.name,
10
11
  projectType: 'library',
11
12
  directory: options.directory,
12
13
  importPath: options.importPath,
13
- projectNameAndRootFormat: options.projectNameAndRootFormat,
14
- callingGenerator: '@nx/react:library',
15
14
  });
16
15
  const nxJson = (0, devkit_1.readNxJson)(host);
17
16
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -23,7 +23,6 @@ const set_defaults_1 = require("./lib/set-defaults");
23
23
  async function libraryGenerator(host, schema) {
24
24
  return await libraryGeneratorInternal(host, {
25
25
  addPlugin: false,
26
- projectNameAndRootFormat: 'derived',
27
26
  ...schema,
28
27
  });
29
28
  }
@@ -125,6 +124,7 @@ async function libraryGeneratorInternal(host, schema) {
125
124
  skipFormat: true,
126
125
  testEnvironment: 'jsdom',
127
126
  addPlugin: options.addPlugin,
127
+ compiler: options.compiler,
128
128
  });
129
129
  tasks.push(vitestTask);
130
130
  createOrEditViteConfig(host, {
@@ -147,19 +147,15 @@ async function libraryGeneratorInternal(host, schema) {
147
147
  }
148
148
  if (options.component) {
149
149
  const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
150
- const name = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
150
+ const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
151
151
  const componentTask = await (0, component_1.default)(host, {
152
- nameAndDirectoryFormat: 'as-provided',
153
- name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
154
- project: options.name,
155
- flat: true,
152
+ path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
156
153
  style: options.style,
157
154
  skipTests: options.unitTestRunner === 'none' ||
158
155
  (options.unitTestRunner === 'vitest' && options.inSourceTests == true),
159
156
  export: true,
160
157
  routing: options.routing,
161
158
  js: options.js,
162
- pascalCaseFiles: options.pascalCaseFiles,
163
159
  inSourceTests: options.inSourceTests,
164
160
  skipFormat: true,
165
161
  globalCss: options.globalCss,
@@ -1,4 +1,3 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
  import type { SupportedStyles } from '../../../typings/style';
4
3
 
@@ -8,15 +7,13 @@ export interface Schema {
8
7
  bundler?: 'none' | 'rollup' | 'vite';
9
8
  compiler?: 'babel' | 'swc';
10
9
  component?: boolean;
11
- directory?: string;
12
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
10
+ directory: string;
13
11
  globalCss?: boolean;
14
12
  importPath?: string;
15
13
  inSourceTests?: boolean;
16
14
  js?: boolean;
17
15
  linter: Linter | LinterType;
18
- name: string;
19
- pascalCaseFiles?: boolean;
16
+ name?: string;
20
17
  publishable?: boolean;
21
18
  routing?: boolean;
22
19
  setParserOptionsProject?: boolean;
@@ -16,28 +16,21 @@
16
16
  }
17
17
  ],
18
18
  "properties": {
19
- "name": {
19
+ "directory": {
20
20
  "type": "string",
21
- "description": "Library name",
21
+ "description": "A directory where the lib is placed.",
22
+ "alias": "dir",
22
23
  "$default": {
23
24
  "$source": "argv",
24
25
  "index": 0
25
26
  },
26
- "x-prompt": "What name would you like to use for the library?",
27
- "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
28
- "x-priority": "important"
27
+ "x-prompt": "Which directory do you want to create the library in?"
29
28
  },
30
- "directory": {
29
+ "name": {
31
30
  "type": "string",
32
- "description": "A directory where the lib is placed.",
33
- "alias": "dir",
31
+ "description": "Library name",
34
32
  "x-priority": "important"
35
33
  },
36
- "projectNameAndRootFormat": {
37
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
38
- "type": "string",
39
- "enum": ["as-provided", "derived"]
40
- },
41
34
  "style": {
42
35
  "description": "The file extension to be used for style files.",
43
36
  "type": "string",
@@ -47,7 +40,10 @@
47
40
  "message": "Which stylesheet format would you like to use?",
48
41
  "type": "list",
49
42
  "items": [
50
- { "value": "css", "label": "CSS" },
43
+ {
44
+ "value": "css",
45
+ "label": "CSS"
46
+ },
51
47
  {
52
48
  "value": "scss",
53
49
  "label": "SASS(.scss) [ https://sass-lang.com ]"
@@ -83,7 +79,8 @@
83
79
  },
84
80
  "unitTestRunner": {
85
81
  "type": "string",
86
- "enum": ["jest", "vitest", "none"],
82
+ "enum": ["vitest", "jest", "none"],
83
+ "default": "vitest",
87
84
  "description": "Test runner to use for unit tests.",
88
85
  "x-prompt": "What unit test runner should be used?"
89
86
  },
@@ -109,12 +106,6 @@
109
106
  "description": "Do not update `tsconfig.json` for development experience.",
110
107
  "x-priority": "internal"
111
108
  },
112
- "pascalCaseFiles": {
113
- "type": "boolean",
114
- "description": "Use pascal case component file name (e.g. `App.tsx`).",
115
- "alias": "P",
116
- "default": false
117
- },
118
109
  "routing": {
119
110
  "type": "boolean",
120
111
  "description": "Generate library with routes."
@@ -194,5 +185,5 @@
194
185
  "default": false
195
186
  }
196
187
  },
197
- "required": ["name"]
188
+ "required": ["directory"]
198
189
  }
@@ -1,5 +1,4 @@
1
1
  import { Schema } from './schema';
2
2
  import { Tree } from '@nx/devkit';
3
3
  export declare function reduxGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
4
- export declare function reduxGeneratorInternal(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
5
4
  export default reduxGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reduxGenerator = reduxGenerator;
4
- exports.reduxGeneratorInternal = reduxGeneratorInternal;
5
4
  const path = require("path");
6
5
  const ast_utils_1 = require("../../utils/ast-utils");
7
6
  const versions_1 = require("../../utils/versions");
@@ -11,12 +10,6 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
11
10
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
12
11
  let tsModule;
13
12
  async function reduxGenerator(host, schema) {
14
- return reduxGeneratorInternal(host, {
15
- nameAndDirectoryFormat: 'derived',
16
- ...schema,
17
- });
18
- }
19
- async function reduxGeneratorInternal(host, schema) {
20
13
  const options = await normalizeOptions(host, schema);
21
14
  generateReduxFiles(host, options);
22
15
  addExportsToBarrel(host, options);
@@ -27,7 +20,7 @@ async function reduxGeneratorInternal(host, schema) {
27
20
  return installTask;
28
21
  }
29
22
  function generateReduxFiles(host, options) {
30
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.directory, {
23
+ (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.projectDirectory, {
31
24
  ...options,
32
25
  tmpl: '',
33
26
  });
@@ -49,8 +42,8 @@ function addExportsToBarrel(host, options) {
49
42
  const indexSource = host.read(indexFilePath, 'utf-8');
50
43
  if (indexSource !== null) {
51
44
  const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
52
- const statePath = options.directory
53
- ? `./lib/${options.directory}/${options.fileName}`
45
+ const statePath = options.path
46
+ ? `./lib/${options.path}/${options.fileName}`
54
47
  : `./lib/${options.fileName}`;
55
48
  const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${statePath}.slice';`));
56
49
  host.write(indexFilePath, changes);
@@ -85,14 +78,8 @@ function updateReducerConfiguration(host, options) {
85
78
  }
86
79
  async function normalizeOptions(host, options) {
87
80
  const { artifactName: name, directory, fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
88
- artifactType: 'slice',
89
- callingGenerator: '@nx/react:redux',
81
+ path: options.path,
90
82
  name: options.name,
91
- directory: options.directory,
92
- derivedDirectory: options.directory,
93
- flat: true,
94
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
95
- project: options.project,
96
83
  fileExtension: 'tsx',
97
84
  });
98
85
  let appProjectSourcePath;
@@ -106,8 +93,8 @@ async function normalizeOptions(host, options) {
106
93
  ? tsConfigJson.compilerOptions.paths || {}
107
94
  : {};
108
95
  const modulePath = projectType === 'application'
109
- ? options.directory
110
- ? `./app/${options.directory}/${extraNames.fileName}.slice`
96
+ ? options.path
97
+ ? `./app/${options.path}/${extraNames.fileName}.slice`
111
98
  : `./app/${extraNames.fileName}.slice`
112
99
  : Object.keys(tsPaths).find((k) => tsPaths[k].some((s) => s.includes(sourceRoot)));
113
100
  // If --project is set to an app, automatically configure store
@@ -130,8 +117,8 @@ async function normalizeOptions(host, options) {
130
117
  ...options,
131
118
  ...extraNames,
132
119
  fileName,
133
- constantName: (0, devkit_1.names)(options.name).constantName.toUpperCase(),
134
- directory,
120
+ constantName: (0, devkit_1.names)(name).constantName.toUpperCase(),
121
+ projectDirectory: directory,
135
122
  projectType,
136
123
  projectSourcePath: sourceRoot,
137
124
  projectModulePath: modulePath,
@@ -1,17 +1,13 @@
1
1
  export interface Schema {
2
- name: string;
3
- /**
4
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
5
- */
6
- project?: string;
7
- directory?: string;
2
+ path: string;
3
+ name?: string;
8
4
  appProject?: string;
9
5
  js?: string;
10
- nameAndDirectoryFormat?: 'as-provided' | 'derived';
11
6
  }
12
7
 
13
8
  interface NormalizedSchema extends Schema {
14
9
  projectType: string;
10
+ projectDirectory: string;
15
11
  projectSourcePath: string;
16
12
  projectModulePath: string;
17
13
  appProjectSourcePath: string;