@nx/remix 16.8.2 → 17.2.5

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 (173) hide show
  1. package/README.md +32 -89
  2. package/executors.json +0 -12
  3. package/generators.d.ts +14 -0
  4. package/generators.js +17 -0
  5. package/generators.json +3 -9
  6. package/index.d.ts +1 -0
  7. package/index.js +5 -0
  8. package/migrations.json +23 -123
  9. package/package.json +42 -12
  10. package/plugins/component-testing/index.js +11 -6
  11. package/src/executors/build/build.impl.js +64 -74
  12. package/src/executors/serve/serve.impl.js +43 -43
  13. package/src/generators/action/action.impl.js +24 -26
  14. package/src/generators/action/schema.d.ts +7 -1
  15. package/src/generators/action/schema.json +10 -3
  16. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +776 -149
  17. package/src/generators/application/application.impl.js +181 -131
  18. package/src/generators/application/files/common/app/root.tsx__tmpl__ +3 -3
  19. package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
  20. package/src/generators/application/files/integrated/package.json__tmpl__ +1 -0
  21. package/src/generators/application/lib/index.js +0 -1
  22. package/src/generators/application/lib/normalize-options.d.ts +5 -3
  23. package/src/generators/application/lib/normalize-options.js +23 -15
  24. package/src/generators/application/lib/update-unit-test-config.js +8 -3
  25. package/src/generators/application/schema.d.ts +5 -0
  26. package/src/generators/application/schema.json +14 -9
  27. package/src/generators/cypress/cypress.impl.js +52 -42
  28. package/src/generators/cypress/schema.d.ts +5 -1
  29. package/src/generators/cypress/schema.json +6 -0
  30. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +13 -18
  31. package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +39 -27
  32. package/src/generators/error-boundary/error-boundary.impl.js +6 -15
  33. package/src/generators/error-boundary/lib/add-v2-error-boundary.js +11 -16
  34. package/src/generators/error-boundary/lib/index.d.ts +0 -1
  35. package/src/generators/error-boundary/lib/index.js +0 -2
  36. package/src/generators/error-boundary/lib/normalize-options.d.ts +1 -1
  37. package/src/generators/error-boundary/lib/normalize-options.js +9 -5
  38. package/src/generators/error-boundary/schema.d.ts +7 -2
  39. package/src/generators/error-boundary/schema.json +14 -12
  40. package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
  41. package/src/generators/library/lib/add-tsconfig-entry-points.js +0 -1
  42. package/src/generators/library/lib/add-unit-testing.js +4 -6
  43. package/src/generators/library/lib/index.js +0 -1
  44. package/src/generators/library/lib/normalize-options.d.ts +2 -1
  45. package/src/generators/library/lib/normalize-options.js +16 -13
  46. package/src/generators/library/lib/update-buildable-config.js +5 -2
  47. package/src/generators/library/library.impl.js +30 -33
  48. package/src/generators/library/schema.d.ts +2 -0
  49. package/src/generators/library/schema.json +6 -0
  50. package/src/generators/loader/loader.impl.js +24 -26
  51. package/src/generators/loader/schema.d.ts +7 -1
  52. package/src/generators/loader/schema.json +10 -3
  53. package/src/generators/meta/lib/v2.impl.js +14 -16
  54. package/src/generators/meta/meta.impl.js +2 -17
  55. package/src/generators/meta/schema.d.ts +7 -2
  56. package/src/generators/meta/schema.json +10 -7
  57. package/src/generators/preset/lib/normalize-options.js +5 -3
  58. package/src/generators/preset/preset.impl.js +18 -23
  59. package/src/generators/preset/schema.json +1 -0
  60. package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
  61. package/src/generators/resource-route/resource-route.impl.js +32 -26
  62. package/src/generators/resource-route/schema.d.ts +7 -1
  63. package/src/generators/resource-route/schema.json +10 -3
  64. package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
  65. package/src/generators/route/route.impl.js +55 -43
  66. package/src/generators/route/schema.d.ts +7 -1
  67. package/src/generators/route/schema.json +11 -4
  68. package/src/generators/setup/schema.json +1 -0
  69. package/src/generators/setup/setup.impl.js +23 -23
  70. package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +27 -23
  71. package/src/generators/setup-tailwind/lib/index.js +0 -1
  72. package/src/generators/setup-tailwind/lib/update-remix-config.js +2 -3
  73. package/src/generators/setup-tailwind/schema.json +1 -0
  74. package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
  75. package/src/generators/storybook-configuration/schema.d.ts +2 -2
  76. package/src/generators/storybook-configuration/schema.json +4 -11
  77. package/src/generators/storybook-configuration/storybook-configuration.impl.js +8 -13
  78. package/src/generators/style/schema.d.ts +7 -1
  79. package/src/generators/style/schema.json +12 -5
  80. package/src/generators/style/style.impl.js +32 -24
  81. package/src/utils/create-watch-paths.js +8 -13
  82. package/src/utils/get-default-export-name.js +1 -3
  83. package/src/utils/get-default-export.js +0 -1
  84. package/src/utils/insert-import.js +0 -1
  85. package/src/utils/insert-statement-after-imports.js +0 -1
  86. package/src/utils/insert-statement-in-default-function.js +0 -1
  87. package/src/utils/remix-config.d.ts +1 -2
  88. package/src/utils/remix-config.js +8 -9
  89. package/src/utils/remix-route-utils.d.ts +2 -2
  90. package/src/utils/remix-route-utils.js +23 -17
  91. package/src/utils/testing-config-utils.js +0 -1
  92. package/src/utils/upsert-links-function.js +0 -1
  93. package/src/utils/versions.d.ts +9 -8
  94. package/src/utils/versions.js +14 -14
  95. package/plugins/component-testing/index.js.map +0 -1
  96. package/src/executors/build/build.impl.js.map +0 -1
  97. package/src/executors/build/compat.d.ts +0 -2
  98. package/src/executors/build/compat.js +0 -6
  99. package/src/executors/build/compat.js.map +0 -1
  100. package/src/executors/serve/compat.d.ts +0 -2
  101. package/src/executors/serve/compat.js +0 -6
  102. package/src/executors/serve/compat.js.map +0 -1
  103. package/src/executors/serve/serve.impl.js.map +0 -1
  104. package/src/generators/action/action.impl.js.map +0 -1
  105. package/src/generators/application/application.impl.js.map +0 -1
  106. package/src/generators/application/lib/index.js.map +0 -1
  107. package/src/generators/application/lib/normalize-options.js.map +0 -1
  108. package/src/generators/application/lib/update-unit-test-config.js.map +0 -1
  109. package/src/generators/cypress/cypress.impl.js.map +0 -1
  110. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +0 -1
  111. package/src/generators/error-boundary/error-boundary.impl.js.map +0 -1
  112. package/src/generators/error-boundary/lib/add-v1-error-boundary.d.ts +0 -3
  113. package/src/generators/error-boundary/lib/add-v1-error-boundary.js +0 -21
  114. package/src/generators/error-boundary/lib/add-v1-error-boundary.js.map +0 -1
  115. package/src/generators/error-boundary/lib/add-v2-error-boundary.js.map +0 -1
  116. package/src/generators/error-boundary/lib/index.js.map +0 -1
  117. package/src/generators/error-boundary/lib/normalize-options.js.map +0 -1
  118. package/src/generators/library/lib/add-tsconfig-entry-points.js.map +0 -1
  119. package/src/generators/library/lib/add-unit-testing.js.map +0 -1
  120. package/src/generators/library/lib/index.js.map +0 -1
  121. package/src/generators/library/lib/normalize-options.js.map +0 -1
  122. package/src/generators/library/lib/update-buildable-config.js.map +0 -1
  123. package/src/generators/library/library.impl.js.map +0 -1
  124. package/src/generators/loader/loader.impl.js.map +0 -1
  125. package/src/generators/meta/lib/normalize-options.d.ts +0 -3
  126. package/src/generators/meta/lib/normalize-options.js +0 -15
  127. package/src/generators/meta/lib/normalize-options.js.map +0 -1
  128. package/src/generators/meta/lib/v1.impl.d.ts +0 -3
  129. package/src/generators/meta/lib/v1.impl.js +0 -30
  130. package/src/generators/meta/lib/v1.impl.js.map +0 -1
  131. package/src/generators/meta/lib/v2.impl.js.map +0 -1
  132. package/src/generators/meta/meta.impl.js.map +0 -1
  133. package/src/generators/preset/lib/normalize-options.js.map +0 -1
  134. package/src/generators/preset/preset.impl.js.map +0 -1
  135. package/src/generators/resource-route/resource-route.impl.js.map +0 -1
  136. package/src/generators/route/route.impl.js.map +0 -1
  137. package/src/generators/setup/setup.impl.js.map +0 -1
  138. package/src/generators/setup-tailwind/lib/index.js.map +0 -1
  139. package/src/generators/setup-tailwind/lib/update-remix-config.js.map +0 -1
  140. package/src/generators/setup-tailwind/setup-tailwind.impl.js.map +0 -1
  141. package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +0 -1
  142. package/src/generators/style/style.impl.js.map +0 -1
  143. package/src/index.d.ts +0 -15
  144. package/src/index.js +0 -21
  145. package/src/index.js.map +0 -1
  146. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +0 -6
  147. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +0 -45
  148. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +0 -1
  149. package/src/migrations/update-15-8-6/update-remix-env-d.d.ts +0 -6
  150. package/src/migrations/update-15-8-6/update-remix-env-d.js +0 -27
  151. package/src/migrations/update-15-8-6/update-remix-env-d.js.map +0 -1
  152. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  153. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -13
  154. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  155. package/src/utils/create-watch-paths.js.map +0 -1
  156. package/src/utils/get-default-export-name.js.map +0 -1
  157. package/src/utils/get-default-export.js.map +0 -1
  158. package/src/utils/get-remix-projects.d.ts +0 -2
  159. package/src/utils/get-remix-projects.js +0 -15
  160. package/src/utils/get-remix-projects.js.map +0 -1
  161. package/src/utils/insert-import.js.map +0 -1
  162. package/src/utils/insert-statement-after-imports.js.map +0 -1
  163. package/src/utils/insert-statement-in-default-function.js.map +0 -1
  164. package/src/utils/project.d.ts +0 -2
  165. package/src/utils/project.js +0 -15
  166. package/src/utils/project.js.map +0 -1
  167. package/src/utils/remix-config.js.map +0 -1
  168. package/src/utils/remix-route-utils.js.map +0 -1
  169. package/src/utils/testing-config-utils.js.map +0 -1
  170. package/src/utils/upsert-links-function.js.map +0 -1
  171. package/src/utils/versions.js.map +0 -1
  172. /package/src/generators/application/files/common/app/routes/{index.tsx__tmpl__ → _index.tsx__tmpl__} +0 -0
  173. /package/src/generators/application/files/common/{remix.config.js__tmpl__ → remix.config.cjs__tmpl__} +0 -0
@@ -2,5 +2,6 @@ import type { Tree } from '@nx/devkit';
2
2
  import type { NxRemixGeneratorSchema } from '../schema';
3
3
  export interface RemixLibraryOptions extends NxRemixGeneratorSchema {
4
4
  projectName: string;
5
+ projectRoot: string;
5
6
  }
6
- export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): RemixLibraryOptions;
7
+ export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): Promise<RemixLibraryOptions>;
@@ -1,20 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
- const devkit_1 = require("@nx/devkit");
4
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
5
  const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
6
- const project_1 = require("../../../utils/project");
7
- function normalizeOptions(tree, options) {
8
- var _a, _b;
9
- const name = (0, devkit_1.names)(options.name).fileName;
10
- const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
11
- const fullProjectDirectory = (0, project_1.normalizeDirectory)(name, projectDirectory);
12
- const { npmScope } = (0, devkit_1.getWorkspaceLayout)(tree);
13
- const importPath = (_a = options.importPath) !== null && _a !== void 0 ? _a : (0, get_import_path_1.getImportPath)(tree, fullProjectDirectory);
14
- const projectName = (0, project_1.normalizeProjectName)(name, projectDirectory);
15
- return Object.assign(Object.assign({}, options), { unitTestRunner: (_b = options.unitTestRunner) !== null && _b !== void 0 ? _b : 'vitest', name,
6
+ async function normalizeOptions(tree, options) {
7
+ const { projectName, projectRoot, projectNameAndRootFormat } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
8
+ name: options.name,
9
+ projectType: 'library',
10
+ directory: options.directory,
11
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
12
+ callingGenerator: '@nx/remix:library',
13
+ });
14
+ const importPath = options.importPath ?? (0, get_import_path_1.getImportPath)(tree, projectRoot);
15
+ return {
16
+ ...options,
17
+ unitTestRunner: options.unitTestRunner ?? 'vitest',
16
18
  importPath,
17
- projectName });
19
+ projectName,
20
+ projectRoot,
21
+ };
18
22
  }
19
23
  exports.normalizeOptions = normalizeOptions;
20
- //# sourceMappingURL=normalize-options.js.map
@@ -5,7 +5,11 @@ const devkit_1 = require("@nx/devkit");
5
5
  function updateBuildableConfig(tree, name) {
6
6
  // Nest dist under project root to we can link it
7
7
  const project = (0, devkit_1.readProjectConfiguration)(tree, name);
8
- project.targets.build.options = Object.assign(Object.assign({}, project.targets.build.options), { format: ['cjs'], outputPath: (0, devkit_1.joinPathFragments)(project.root, 'dist') });
8
+ project.targets.build.options = {
9
+ ...project.targets.build.options,
10
+ format: ['cjs'],
11
+ outputPath: (0, devkit_1.joinPathFragments)(project.root, 'dist'),
12
+ };
9
13
  (0, devkit_1.updateProjectConfiguration)(tree, name, project);
10
14
  // Point to nested dist for yarn/npm/pnpm workspaces
11
15
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(project.root, 'package.json'), (json) => {
@@ -15,4 +19,3 @@ function updateBuildableConfig(tree, name) {
15
19
  });
16
20
  }
17
21
  exports.updateBuildableConfig = updateBuildableConfig;
18
- //# sourceMappingURL=update-buildable-config.js.map
@@ -1,41 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
- const linter_1 = require("@nx/linter");
4
+ const eslint_1 = require("@nx/eslint");
6
5
  const react_1 = require("@nx/react");
7
6
  const lib_1 = require("./lib");
8
- function default_1(tree, schema) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const tasks = [];
11
- const options = (0, lib_1.normalizeOptions)(tree, schema);
12
- const libGenTask = yield (0, react_1.libraryGenerator)(tree, {
13
- name: options.name,
14
- style: options.style,
15
- unitTestRunner: options.unitTestRunner,
16
- tags: options.tags,
17
- importPath: options.importPath,
18
- directory: options.directory,
19
- skipFormat: true,
20
- skipTsConfig: false,
21
- linter: linter_1.Linter.EsLint,
22
- component: true,
23
- buildable: options.buildable,
24
- });
25
- tasks.push(libGenTask);
26
- if (options.unitTestRunner && options.unitTestRunner !== 'none') {
27
- const pkgInstallTask = (0, lib_1.addUnitTestingSetup)(tree, options);
28
- tasks.push(pkgInstallTask);
29
- }
30
- (0, lib_1.addTsconfigEntryPoints)(tree, options);
31
- if (options.buildable) {
32
- (0, lib_1.updateBuildableConfig)(tree, options.projectName);
33
- }
34
- if (!options.skipFormat) {
35
- yield (0, devkit_1.formatFiles)(tree);
36
- }
37
- return (0, devkit_1.runTasksInSerial)(...tasks);
7
+ async function default_1(tree, schema) {
8
+ const tasks = [];
9
+ const options = await (0, lib_1.normalizeOptions)(tree, schema);
10
+ const libGenTask = await (0, react_1.libraryGenerator)(tree, {
11
+ name: options.projectName,
12
+ style: options.style,
13
+ unitTestRunner: options.unitTestRunner,
14
+ tags: options.tags,
15
+ importPath: options.importPath,
16
+ directory: options.projectRoot,
17
+ projectNameAndRootFormat: 'as-provided',
18
+ skipFormat: true,
19
+ skipTsConfig: false,
20
+ linter: eslint_1.Linter.EsLint,
21
+ component: true,
22
+ buildable: options.buildable,
38
23
  });
24
+ tasks.push(libGenTask);
25
+ if (options.unitTestRunner && options.unitTestRunner !== 'none') {
26
+ const pkgInstallTask = (0, lib_1.addUnitTestingSetup)(tree, options);
27
+ tasks.push(pkgInstallTask);
28
+ }
29
+ (0, lib_1.addTsconfigEntryPoints)(tree, options);
30
+ if (options.buildable) {
31
+ (0, lib_1.updateBuildableConfig)(tree, options.projectName);
32
+ }
33
+ if (!options.skipFormat) {
34
+ await (0, devkit_1.formatFiles)(tree);
35
+ }
36
+ return (0, devkit_1.runTasksInSerial)(...tasks);
39
37
  }
40
38
  exports.default = default_1;
41
- //# sourceMappingURL=library.impl.js.map
@@ -1,9 +1,11 @@
1
+ import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
1
2
  import { SupportedStyles } from '@nx/react';
2
3
 
3
4
  export interface NxRemixGeneratorSchema {
4
5
  name: string;
5
6
  style: SupportedStyles;
6
7
  directory?: string;
8
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
7
9
  tags?: string;
8
10
  importPath?: string;
9
11
  buildable?: boolean;
@@ -2,6 +2,7 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "$id": "NxRemixLibrary",
4
4
  "title": "Create a Library",
5
+ "description": "Generate a Remix library to help structure workspace and application.",
5
6
  "type": "object",
6
7
  "examples": [
7
8
  {
@@ -26,6 +27,11 @@
26
27
  "alias": "dir",
27
28
  "x-priority": "important"
28
29
  },
30
+ "projectNameAndRootFormat": {
31
+ "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`).",
32
+ "type": "string",
33
+ "enum": ["as-provided", "derived"]
34
+ },
29
35
  "tags": {
30
36
  "type": "string",
31
37
  "description": "Add tags to the library (used for linting)"
@@ -1,41 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const insert_import_1 = require("../../utils/insert-import");
6
5
  const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
7
6
  const insert_statement_in_default_function_1 = require("../../utils/insert-statement-in-default-function");
8
7
  const remix_route_utils_1 = require("../../utils/remix-route-utils");
9
- function default_1(tree, schema) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
12
- if (!tree.exists(routeFilePath)) {
13
- throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
14
- }
15
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'useLoaderData', '@remix-run/react');
16
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
17
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'LoaderArgs', '@remix-run/node', {
18
- typeOnly: true,
19
- });
20
- (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
- export const loader = async ({request}: LoaderArgs ) => {
8
+ async function default_1(tree, schema) {
9
+ const routeFilePath = schema.nameAndDirectoryFormat === 'as-provided'
10
+ ? schema.path
11
+ : await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
12
+ if (!tree.exists(routeFilePath)) {
13
+ throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
14
+ }
15
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'useLoaderData', '@remix-run/react');
16
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
17
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'LoaderFunctionArgs', '@remix-run/node', {
18
+ typeOnly: true,
19
+ });
20
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
+ export const loader = async ({request}: LoaderFunctionArgs ) => {
22
22
  return json({
23
23
  message: 'Hello, world!',
24
24
  })
25
25
  };
26
26
 
27
27
  `);
28
- const statement = `\nconst data = useLoaderData<typeof loader>();`;
29
- try {
30
- (0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
31
- // eslint-disable-next-line no-empty
32
- }
33
- catch (err) {
34
- }
35
- finally {
36
- yield (0, devkit_1.formatFiles)(tree);
37
- }
38
- });
28
+ const statement = `\nconst data = useLoaderData<typeof loader>();`;
29
+ try {
30
+ (0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
31
+ // eslint-disable-next-line no-empty
32
+ }
33
+ catch (err) {
34
+ }
35
+ finally {
36
+ await (0, devkit_1.formatFiles)(tree);
37
+ }
39
38
  }
40
39
  exports.default = default_1;
41
- //# sourceMappingURL=loader.impl.js.map
@@ -1,4 +1,10 @@
1
+ import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
1
3
  export interface LoaderSchema {
2
- project: string;
3
4
  path: string;
5
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
6
+ /**
7
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v18.
8
+ */
9
+ project?: string;
4
10
  }
@@ -2,6 +2,7 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "$id": "data-loader",
4
4
  "type": "object",
5
+ "description": "Generate an loader for a given route.",
5
6
  "properties": {
6
7
  "path": {
7
8
  "type": "string",
@@ -10,7 +11,12 @@
10
11
  "$source": "argv",
11
12
  "index": 0
12
13
  },
13
- "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
14
+ "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
15
+ },
16
+ "nameAndDirectoryFormat": {
17
+ "description": "Whether to generate the loader in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
18
+ "type": "string",
19
+ "enum": ["as-provided", "derived"]
14
20
  },
15
21
  "project": {
16
22
  "type": "string",
@@ -19,8 +25,9 @@
19
25
  "$source": "projectName"
20
26
  },
21
27
  "x-prompt": "What project is this route for?",
22
- "pattern": "^[a-zA-Z].*$"
28
+ "pattern": "^[a-zA-Z].*$",
29
+ "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
23
30
  }
24
31
  },
25
- "required": ["path", "project"]
32
+ "required": ["path"]
26
33
  }
@@ -1,30 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.v2MetaGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const get_default_export_name_1 = require("../../../utils/get-default-export-name");
7
6
  const insert_import_1 = require("../../../utils/insert-import");
8
7
  const insert_statement_after_imports_1 = require("../../../utils/insert-statement-after-imports");
9
8
  const remix_route_utils_1 = require("../../../utils/remix-route-utils");
10
- function v2MetaGenerator(tree, schema) {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
13
- if (!tree.exists(routeFilePath)) {
14
- throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
15
- }
16
- (0, insert_import_1.insertImport)(tree, routeFilePath, 'V2_MetaFunction', '@remix-run/node', {
17
- typeOnly: true,
18
- });
19
- const defaultExportName = (0, get_default_export_name_1.getDefaultExportName)(tree, routeFilePath);
20
- (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
- export const meta: V2_MetaFunction = () =>{
9
+ async function v2MetaGenerator(tree, schema) {
10
+ const routeFilePath = schema.nameAndDirectoryFormat === 'as-provided'
11
+ ? schema.path
12
+ : await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
13
+ if (!tree.exists(routeFilePath)) {
14
+ throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
15
+ }
16
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'MetaFunction', '@remix-run/node', {
17
+ typeOnly: true,
18
+ });
19
+ const defaultExportName = (0, get_default_export_name_1.getDefaultExportName)(tree, routeFilePath);
20
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
+ export const meta: MetaFunction = () => {
22
22
  return [{ title: '${defaultExportName} Route' }];
23
23
  };
24
24
 
25
25
  `);
26
- yield (0, devkit_1.formatFiles)(tree);
27
- });
26
+ await (0, devkit_1.formatFiles)(tree);
28
27
  }
29
28
  exports.v2MetaGenerator = v2MetaGenerator;
30
- //# sourceMappingURL=v2.impl.js.map
@@ -1,22 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const normalize_options_1 = require("./lib/normalize-options");
5
- const v1_impl_1 = require("./lib/v1.impl");
6
3
  const v2_impl_1 = require("./lib/v2.impl");
7
- function default_1(tree, schema) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const options = (0, normalize_options_1.normalizeOptions)(tree, schema);
10
- if (options.version === '1') {
11
- yield (0, v1_impl_1.v1MetaGenerator)(tree, options);
12
- }
13
- else if (options.version === '2') {
14
- yield (0, v2_impl_1.v2MetaGenerator)(tree, options);
15
- }
16
- else {
17
- throw new Error('Invalid version provided.');
18
- }
19
- });
4
+ async function default_1(tree, schema) {
5
+ await (0, v2_impl_1.v2MetaGenerator)(tree, schema);
20
6
  }
21
7
  exports.default = default_1;
22
- //# sourceMappingURL=meta.impl.js.map
@@ -1,5 +1,10 @@
1
+ import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
1
3
  export interface MetaSchema {
2
4
  path: string;
3
- project: string;
4
- version?: '1' | '2';
5
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
6
+ /**
7
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v18.
8
+ */
9
+ project?: string;
5
10
  }
@@ -2,6 +2,7 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "$id": "meta",
4
4
  "type": "object",
5
+ "description": "Generate a meta function for a given route.",
5
6
  "properties": {
6
7
  "path": {
7
8
  "type": "string",
@@ -10,7 +11,12 @@
10
11
  "$source": "argv",
11
12
  "index": 0
12
13
  },
13
- "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
14
+ "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
15
+ },
16
+ "nameAndDirectoryFormat": {
17
+ "description": "Whether to generate the meta function in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
18
+ "type": "string",
19
+ "enum": ["as-provided", "derived"]
14
20
  },
15
21
  "project": {
16
22
  "type": "string",
@@ -19,12 +25,9 @@
19
25
  "$source": "projectName"
20
26
  },
21
27
  "x-prompt": "What project is this route for?",
22
- "pattern": "^[a-zA-Z].*$"
23
- },
24
- "version": {
25
- "type": "string",
26
- "description": "The version of the meta convention to use"
28
+ "pattern": "^[a-zA-Z].*$",
29
+ "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
27
30
  }
28
31
  },
29
- "required": ["path", "project"]
32
+ "required": ["path"]
30
33
  }
@@ -10,9 +10,11 @@ function normalizeOptions(tree, options) {
10
10
  const parsedTags = options.tags
11
11
  ? options.tags.split(',').map((s) => s.trim())
12
12
  : [];
13
- return Object.assign(Object.assign({}, options), { appName,
13
+ return {
14
+ ...options,
15
+ appName,
14
16
  projectRoot,
15
- parsedTags });
17
+ parsedTags,
18
+ };
16
19
  }
17
20
  exports.normalizeOptions = normalizeOptions;
18
- //# sourceMappingURL=normalize-options.js.map
@@ -1,33 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const devkit_2 = require("@nx/devkit");
6
5
  const application_impl_1 = require("../application/application.impl");
7
6
  const setup_impl_1 = require("../setup/setup.impl");
8
7
  const normalize_options_1 = require("./lib/normalize-options");
9
- function default_1(tree, _options) {
10
- var _a, _b, _c;
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const options = (0, normalize_options_1.normalizeOptions)(tree, _options);
13
- const tasks = [];
14
- const setupGenTask = yield (0, setup_impl_1.default)(tree);
15
- tasks.push(setupGenTask);
16
- const appGenTask = yield (0, application_impl_1.default)(tree, {
17
- name: options.appName,
18
- tags: options.tags,
19
- skipFormat: true,
20
- rootProject: true,
21
- unitTestRunner: (_a = options.unitTestRunner) !== null && _a !== void 0 ? _a : 'vitest',
22
- e2eTestRunner: (_b = options.e2eTestRunner) !== null && _b !== void 0 ? _b : 'cypress',
23
- js: (_c = options.js) !== null && _c !== void 0 ? _c : false,
24
- });
25
- tasks.push(appGenTask);
26
- tree.delete('apps');
27
- tree.delete('libs');
28
- yield (0, devkit_1.formatFiles)(tree);
29
- return (0, devkit_2.runTasksInSerial)(...tasks);
8
+ async function default_1(tree, _options) {
9
+ const options = (0, normalize_options_1.normalizeOptions)(tree, _options);
10
+ const tasks = [];
11
+ const setupGenTask = await (0, setup_impl_1.default)(tree);
12
+ tasks.push(setupGenTask);
13
+ const appGenTask = await (0, application_impl_1.default)(tree, {
14
+ name: options.appName,
15
+ tags: options.tags,
16
+ skipFormat: true,
17
+ rootProject: true,
18
+ unitTestRunner: options.unitTestRunner ?? 'vitest',
19
+ e2eTestRunner: options.e2eTestRunner ?? 'cypress',
20
+ js: options.js ?? false,
30
21
  });
22
+ tasks.push(appGenTask);
23
+ tree.delete('apps');
24
+ tree.delete('libs');
25
+ await (0, devkit_1.formatFiles)(tree);
26
+ return (0, devkit_2.runTasksInSerial)(...tasks);
31
27
  }
32
28
  exports.default = default_1;
33
- //# sourceMappingURL=preset.impl.js.map
@@ -3,6 +3,7 @@
3
3
  "$id": "Remix",
4
4
  "title": "",
5
5
  "type": "object",
6
+ "description": "Generate a Remix application in a standalone workspace. Can be used with `create-nx-workspace --preset=@nx/remix`.",
6
7
  "properties": {
7
8
  "tags": {
8
9
  "type": "string",
@@ -0,0 +1,21 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
4
+
5
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
6
+
7
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 4`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
8
+
9
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 6`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
10
+
11
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
12
+
13
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
14
+
15
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 4`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
16
+
17
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 6`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
18
+
19
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 7`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
20
+
21
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 9`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
@@ -1,35 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
4
+ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
5
5
  const remix_route_utils_1 = require("../../utils/remix-route-utils");
6
6
  const action_impl_1 = require("../action/action.impl");
7
7
  const loader_impl_1 = require("../loader/loader.impl");
8
- function default_1(tree, options) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
11
- throw new Error(`Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.`);
12
- }
13
- const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.path, options.project, '.ts');
14
- if (tree.exists(routeFilePath))
15
- throw new Error(`Path already exists: ${options.path}`);
16
- if (!options.loader && !options.action)
17
- throw new Error('The resource route generator requires either `loader` or `action` to be true');
18
- tree.write(routeFilePath, '');
19
- if (options.loader) {
20
- yield (0, loader_impl_1.default)(tree, {
21
- project: options.project,
22
- path: routeFilePath,
23
- });
24
- }
25
- if (options.action) {
26
- yield (0, action_impl_1.default)(tree, {
27
- path: routeFilePath,
28
- project: options.project,
29
- });
30
- }
31
- yield (0, devkit_1.formatFiles)(tree);
8
+ async function default_1(tree, options) {
9
+ const { artifactName: name, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
10
+ artifactType: 'resource-route',
11
+ callingGenerator: '@nx/remix:resource-route',
12
+ name: options.path.replace(/^\//, '').replace(/\/$/, ''),
13
+ nameAndDirectoryFormat: options.nameAndDirectoryFormat,
14
+ project: options.project,
32
15
  });
16
+ if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
17
+ throw new Error(`Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.`);
18
+ }
19
+ const routeFilePath = await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.nameAndDirectoryFormat === 'as-provided'
20
+ ? (0, devkit_1.joinPathFragments)(directory, name)
21
+ : options.path, options.nameAndDirectoryFormat === 'as-provided' ? undefined : projectName, '.ts');
22
+ if (tree.exists(routeFilePath))
23
+ throw new Error(`Path already exists: ${options.path}`);
24
+ if (!options.loader && !options.action)
25
+ throw new Error('The resource route generator requires either `loader` or `action` to be true');
26
+ tree.write(routeFilePath, '');
27
+ if (options.loader) {
28
+ await (0, loader_impl_1.default)(tree, {
29
+ path: routeFilePath,
30
+ nameAndDirectoryFormat: 'as-provided',
31
+ });
32
+ }
33
+ if (options.action) {
34
+ await (0, action_impl_1.default)(tree, {
35
+ path: routeFilePath,
36
+ nameAndDirectoryFormat: 'as-provided',
37
+ });
38
+ }
39
+ await (0, devkit_1.formatFiles)(tree);
33
40
  }
34
41
  exports.default = default_1;
35
- //# sourceMappingURL=resource-route.impl.js.map
@@ -1,7 +1,13 @@
1
+ import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
1
3
  export interface RemixRouteSchema {
2
- project: string;
3
4
  path: string;
5
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
4
6
  action: boolean;
5
7
  loader: boolean;
6
8
  skipChecks: boolean;
9
+ /**
10
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v18.
11
+ */
12
+ project?: string;
7
13
  }
@@ -3,6 +3,7 @@
3
3
  "$id": "NxRemixResourceRoute",
4
4
  "title": "Create a Resource Route",
5
5
  "type": "object",
6
+ "description": "Generate a resource route.",
6
7
  "examples": [
7
8
  {
8
9
  "command": "g resource-route 'path/to/page'",
@@ -17,7 +18,12 @@
17
18
  "$source": "argv",
18
19
  "index": 0
19
20
  },
20
- "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
21
+ "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar')"
22
+ },
23
+ "nameAndDirectoryFormat": {
24
+ "description": "Whether to generate the styles in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
25
+ "type": "string",
26
+ "enum": ["as-provided", "derived"]
21
27
  },
22
28
  "project": {
23
29
  "type": "string",
@@ -26,7 +32,8 @@
26
32
  "$source": "projectName"
27
33
  },
28
34
  "x-prompt": "What project is this route for?",
29
- "pattern": "^[a-zA-Z].*$"
35
+ "pattern": "^[a-zA-Z].*$",
36
+ "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
30
37
  },
31
38
  "action": {
32
39
  "type": "boolean",
@@ -44,5 +51,5 @@
44
51
  "default": false
45
52
  }
46
53
  },
47
- "required": ["project", "path"]
54
+ "required": ["path"]
48
55
  }