@nx/remix 16.8.2 → 17.0.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 (202) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +32 -89
  3. package/executors.json +0 -12
  4. package/generators.d.ts +14 -0
  5. package/generators.js +31 -0
  6. package/generators.json +14 -19
  7. package/index.d.ts +1 -0
  8. package/index.js +5 -0
  9. package/migrations.json +68 -86
  10. package/package.json +44 -12
  11. package/plugin.d.ts +1 -0
  12. package/plugin.js +6 -0
  13. package/plugins/component-testing/index.js +11 -6
  14. package/src/executors/build/build.impl.js +64 -74
  15. package/src/executors/build/schema.json +1 -1
  16. package/src/executors/serve/serve.impl.js +43 -43
  17. package/src/generators/action/action.impl.js +24 -26
  18. package/src/generators/action/schema.d.ts +7 -1
  19. package/src/generators/action/schema.json +11 -8
  20. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1121 -307
  21. package/src/generators/application/application.impl.d.ts +3 -1
  22. package/src/generators/application/application.impl.js +171 -110
  23. package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
  24. package/src/generators/application/files/common/app/root.tsx__tmpl__ +3 -3
  25. package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
  26. package/src/generators/application/files/common/remix.config.js__tmpl__ +13 -7
  27. package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
  28. package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
  29. package/src/generators/application/files/common/tsconfig.json__tmpl__ +20 -14
  30. package/src/generators/application/files/integrated/package.json__tmpl__ +1 -0
  31. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  32. package/src/generators/application/lib/add-e2e.js +68 -0
  33. package/src/generators/application/lib/index.d.ts +1 -0
  34. package/src/generators/application/lib/index.js +1 -1
  35. package/src/generators/application/lib/normalize-options.d.ts +8 -3
  36. package/src/generators/application/lib/normalize-options.js +52 -14
  37. package/src/generators/application/lib/update-unit-test-config.d.ts +1 -1
  38. package/src/generators/application/lib/update-unit-test-config.js +32 -7
  39. package/src/generators/application/schema.d.ts +7 -1
  40. package/src/generators/application/schema.json +17 -11
  41. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +3 -1
  42. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +26 -17
  43. package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
  44. package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +39 -27
  45. package/src/generators/error-boundary/error-boundary.impl.js +6 -15
  46. package/src/generators/error-boundary/lib/add-v2-error-boundary.js +11 -16
  47. package/src/generators/error-boundary/lib/index.d.ts +0 -1
  48. package/src/generators/error-boundary/lib/index.js +0 -2
  49. package/src/generators/error-boundary/lib/normalize-options.d.ts +1 -1
  50. package/src/generators/error-boundary/lib/normalize-options.js +9 -5
  51. package/src/generators/error-boundary/schema.d.ts +7 -2
  52. package/src/generators/error-boundary/schema.json +14 -16
  53. package/src/generators/init/init.d.ts +5 -0
  54. package/src/generators/init/init.js +60 -0
  55. package/src/generators/init/schema.d.ts +7 -0
  56. package/src/generators/init/schema.json +33 -0
  57. package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
  58. package/src/generators/library/lib/add-tsconfig-entry-points.js +0 -1
  59. package/src/generators/library/lib/add-unit-testing.js +5 -7
  60. package/src/generators/library/lib/index.js +0 -1
  61. package/src/generators/library/lib/normalize-options.d.ts +3 -2
  62. package/src/generators/library/lib/normalize-options.js +21 -12
  63. package/src/generators/library/lib/update-buildable-config.js +5 -2
  64. package/src/generators/library/library.impl.d.ts +3 -1
  65. package/src/generators/library/library.impl.js +38 -34
  66. package/src/generators/library/schema.d.ts +3 -0
  67. package/src/generators/library/schema.json +7 -1
  68. package/src/generators/loader/loader.impl.js +24 -26
  69. package/src/generators/loader/schema.d.ts +7 -1
  70. package/src/generators/loader/schema.json +11 -8
  71. package/src/generators/meta/lib/v2.impl.js +14 -16
  72. package/src/generators/meta/meta.impl.js +2 -17
  73. package/src/generators/meta/schema.d.ts +7 -2
  74. package/src/generators/meta/schema.json +11 -12
  75. package/src/generators/preset/lib/normalize-options.js +5 -3
  76. package/src/generators/preset/preset.impl.js +22 -23
  77. package/src/generators/preset/schema.json +2 -1
  78. package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
  79. package/src/generators/resource-route/resource-route.impl.js +32 -26
  80. package/src/generators/resource-route/schema.d.ts +7 -1
  81. package/src/generators/resource-route/schema.json +11 -8
  82. package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
  83. package/src/generators/route/route.impl.js +56 -43
  84. package/src/generators/route/schema.d.ts +7 -1
  85. package/src/generators/route/schema.json +12 -9
  86. package/src/generators/setup/schema.json +2 -1
  87. package/src/generators/setup/setup.impl.js +23 -23
  88. package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +51 -33
  89. package/src/generators/setup-tailwind/lib/index.js +0 -1
  90. package/src/generators/setup-tailwind/lib/update-remix-config.js +3 -7
  91. package/src/generators/setup-tailwind/schema.json +2 -1
  92. package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
  93. package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +15 -27
  94. package/src/generators/storybook-configuration/schema.d.ts +3 -2
  95. package/src/generators/storybook-configuration/schema.json +5 -12
  96. package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +2 -1
  97. package/src/generators/storybook-configuration/storybook-configuration.impl.js +19 -12
  98. package/src/generators/style/schema.d.ts +7 -1
  99. package/src/generators/style/schema.json +13 -10
  100. package/src/generators/style/style.impl.js +32 -24
  101. package/src/generators/utils/update-dependencies.d.ts +2 -0
  102. package/src/generators/utils/update-dependencies.js +21 -0
  103. package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
  104. package/src/plugins/plugin.d.ts +9 -0
  105. package/src/plugins/plugin.js +134 -0
  106. package/src/utils/create-watch-paths.js +8 -13
  107. package/src/utils/get-default-export-name.js +1 -3
  108. package/src/utils/get-default-export.js +0 -1
  109. package/src/utils/insert-import.js +0 -1
  110. package/src/utils/insert-statement-after-imports.js +0 -1
  111. package/src/utils/insert-statement-in-default-function.js +0 -1
  112. package/src/utils/remix-config.d.ts +2 -2
  113. package/src/utils/remix-config.js +34 -11
  114. package/src/utils/remix-route-utils.d.ts +2 -2
  115. package/src/utils/remix-route-utils.js +23 -17
  116. package/src/utils/testing-config-utils.d.ts +3 -2
  117. package/src/utils/testing-config-utils.js +24 -10
  118. package/src/utils/upsert-links-function.js +0 -1
  119. package/src/utils/versions.d.ts +10 -9
  120. package/src/utils/versions.js +15 -15
  121. package/plugins/component-testing/index.js.map +0 -1
  122. package/src/executors/build/build.impl.js.map +0 -1
  123. package/src/executors/build/compat.d.ts +0 -2
  124. package/src/executors/build/compat.js +0 -6
  125. package/src/executors/build/compat.js.map +0 -1
  126. package/src/executors/serve/compat.d.ts +0 -2
  127. package/src/executors/serve/compat.js +0 -6
  128. package/src/executors/serve/compat.js.map +0 -1
  129. package/src/executors/serve/serve.impl.js.map +0 -1
  130. package/src/generators/action/action.impl.js.map +0 -1
  131. package/src/generators/application/application.impl.js.map +0 -1
  132. package/src/generators/application/files/common/app/routes/index.tsx__tmpl__ +0 -32
  133. package/src/generators/application/lib/index.js.map +0 -1
  134. package/src/generators/application/lib/normalize-options.js.map +0 -1
  135. package/src/generators/application/lib/update-unit-test-config.js.map +0 -1
  136. package/src/generators/cypress/cypress.impl.d.ts +0 -3
  137. package/src/generators/cypress/cypress.impl.js +0 -67
  138. package/src/generators/cypress/cypress.impl.js.map +0 -1
  139. package/src/generators/cypress/schema.d.ts +0 -10
  140. package/src/generators/cypress/schema.json +0 -55
  141. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +0 -1
  142. package/src/generators/error-boundary/error-boundary.impl.js.map +0 -1
  143. package/src/generators/error-boundary/lib/add-v1-error-boundary.d.ts +0 -3
  144. package/src/generators/error-boundary/lib/add-v1-error-boundary.js +0 -21
  145. package/src/generators/error-boundary/lib/add-v1-error-boundary.js.map +0 -1
  146. package/src/generators/error-boundary/lib/add-v2-error-boundary.js.map +0 -1
  147. package/src/generators/error-boundary/lib/index.js.map +0 -1
  148. package/src/generators/error-boundary/lib/normalize-options.js.map +0 -1
  149. package/src/generators/library/lib/add-tsconfig-entry-points.js.map +0 -1
  150. package/src/generators/library/lib/add-unit-testing.js.map +0 -1
  151. package/src/generators/library/lib/index.js.map +0 -1
  152. package/src/generators/library/lib/normalize-options.js.map +0 -1
  153. package/src/generators/library/lib/update-buildable-config.js.map +0 -1
  154. package/src/generators/library/library.impl.js.map +0 -1
  155. package/src/generators/loader/loader.impl.js.map +0 -1
  156. package/src/generators/meta/lib/normalize-options.d.ts +0 -3
  157. package/src/generators/meta/lib/normalize-options.js +0 -15
  158. package/src/generators/meta/lib/normalize-options.js.map +0 -1
  159. package/src/generators/meta/lib/v1.impl.d.ts +0 -3
  160. package/src/generators/meta/lib/v1.impl.js +0 -30
  161. package/src/generators/meta/lib/v1.impl.js.map +0 -1
  162. package/src/generators/meta/lib/v2.impl.js.map +0 -1
  163. package/src/generators/meta/meta.impl.js.map +0 -1
  164. package/src/generators/preset/lib/normalize-options.js.map +0 -1
  165. package/src/generators/preset/preset.impl.js.map +0 -1
  166. package/src/generators/resource-route/resource-route.impl.js.map +0 -1
  167. package/src/generators/route/route.impl.js.map +0 -1
  168. package/src/generators/setup/setup.impl.js.map +0 -1
  169. package/src/generators/setup-tailwind/lib/index.js.map +0 -1
  170. package/src/generators/setup-tailwind/lib/update-remix-config.js.map +0 -1
  171. package/src/generators/setup-tailwind/setup-tailwind.impl.js.map +0 -1
  172. package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +0 -1
  173. package/src/generators/style/style.impl.js.map +0 -1
  174. package/src/index.d.ts +0 -15
  175. package/src/index.js +0 -21
  176. package/src/index.js.map +0 -1
  177. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +0 -6
  178. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +0 -45
  179. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +0 -1
  180. package/src/migrations/update-15-8-6/update-remix-env-d.d.ts +0 -6
  181. package/src/migrations/update-15-8-6/update-remix-env-d.js +0 -27
  182. package/src/migrations/update-15-8-6/update-remix-env-d.js.map +0 -1
  183. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  184. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -13
  185. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  186. package/src/utils/create-watch-paths.js.map +0 -1
  187. package/src/utils/get-default-export-name.js.map +0 -1
  188. package/src/utils/get-default-export.js.map +0 -1
  189. package/src/utils/get-remix-projects.d.ts +0 -2
  190. package/src/utils/get-remix-projects.js +0 -15
  191. package/src/utils/get-remix-projects.js.map +0 -1
  192. package/src/utils/insert-import.js.map +0 -1
  193. package/src/utils/insert-statement-after-imports.js.map +0 -1
  194. package/src/utils/insert-statement-in-default-function.js.map +0 -1
  195. package/src/utils/project.d.ts +0 -2
  196. package/src/utils/project.js +0 -15
  197. package/src/utils/project.js.map +0 -1
  198. package/src/utils/remix-config.js.map +0 -1
  199. package/src/utils/remix-route-utils.js.map +0 -1
  200. package/src/utils/testing-config-utils.js.map +0 -1
  201. package/src/utils/upsert-links-function.js.map +0 -1
  202. package/src/utils/versions.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://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 v19.
8
+ */
9
+ project?: string;
4
10
  }
@@ -1,7 +1,8 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://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,17 +11,19 @@
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",
17
23
  "description": "The name of the project.",
18
- "$default": {
19
- "$source": "projectName"
20
- },
21
- "x-prompt": "What project is this route for?",
22
- "pattern": "^[a-zA-Z].*$"
24
+ "pattern": "^[a-zA-Z].*$",
25
+ "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 v19."
23
26
  }
24
27
  },
25
- "required": ["path", "project"]
28
+ "required": ["path"]
26
29
  }
@@ -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 v19.
8
+ */
9
+ project?: string;
5
10
  }
@@ -1,7 +1,8 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://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,21 +11,19 @@
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')"
14
15
  },
15
- "project": {
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`).",
16
18
  "type": "string",
17
- "description": "The name of the project.",
18
- "$default": {
19
- "$source": "projectName"
20
- },
21
- "x-prompt": "What project is this route for?",
22
- "pattern": "^[a-zA-Z].*$"
19
+ "enum": ["as-provided", "derived"]
23
20
  },
24
- "version": {
21
+ "project": {
25
22
  "type": "string",
26
- "description": "The version of the meta convention to use"
23
+ "description": "The name of the project.",
24
+ "pattern": "^[a-zA-Z].*$",
25
+ "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 v19."
27
26
  }
28
27
  },
29
- "required": ["path", "project"]
28
+ "required": ["path"]
30
29
  }
@@ -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,32 @@
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 nxJson = (0, devkit_1.readNxJson)(tree);
14
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
15
+ nxJson.useInferencePlugins !== false;
16
+ const appGenTask = await (0, application_impl_1.default)(tree, {
17
+ name: options.appName,
18
+ tags: options.tags,
19
+ skipFormat: true,
20
+ rootProject: true,
21
+ unitTestRunner: options.unitTestRunner ?? 'vitest',
22
+ e2eTestRunner: options.e2eTestRunner ?? 'cypress',
23
+ js: options.js ?? false,
24
+ addPlugin: addPluginDefault,
30
25
  });
26
+ tasks.push(appGenTask);
27
+ tree.delete('apps');
28
+ tree.delete('libs');
29
+ await (0, devkit_1.formatFiles)(tree);
30
+ return (0, devkit_2.runTasksInSerial)(...tasks);
31
31
  }
32
32
  exports.default = default_1;
33
- //# sourceMappingURL=preset.impl.js.map
@@ -1,8 +1,9 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
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 v19.
11
+ */
12
+ project?: string;
7
13
  }
@@ -1,8 +1,9 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
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,16 +18,18 @@
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",
24
30
  "description": "The name of the project.",
25
- "$default": {
26
- "$source": "projectName"
27
- },
28
- "x-prompt": "What project is this route for?",
29
- "pattern": "^[a-zA-Z].*$"
31
+ "pattern": "^[a-zA-Z].*$",
32
+ "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 v19."
30
33
  },
31
34
  "action": {
32
35
  "type": "boolean",
@@ -44,5 +47,5 @@
44
47
  "default": false
45
48
  }
46
49
  },
47
- "required": ["project", "path"]
50
+ "required": ["path"]
48
51
  }
@@ -1,14 +1,61 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`route should add route component 1`] = `
4
- "import type {
5
- ActionArgs,
6
- LinksFunction,
7
- LoaderArgs,
3
+ exports[`route --nameAndDirectoryFormat=as-provided should add route component 1`] = `
4
+ "import { useLoaderData, useActionData } from '@remix-run/react';
5
+ import { json } from '@remix-run/node';
6
+ import type {
7
+ LoaderFunctionArgs,
8
8
  MetaFunction,
9
+ ActionFunctionArgs,
10
+ LinksFunction,
9
11
  } from '@remix-run/node';
12
+
13
+ import stylesUrl from '../../../styles/path/to/example.css';
14
+
15
+ export const links: LinksFunction = () => {
16
+ return [{ rel: 'stylesheet', href: stylesUrl }];
17
+ };
18
+
19
+ export const action = async ({ request }: ActionFunctionArgs) => {
20
+ let formData = await request.formData();
21
+
22
+ return json({ message: formData.toString() }, { status: 200 });
23
+ };
24
+
25
+ export const meta: MetaFunction = () => {
26
+ return [{ title: 'Example Route' }];
27
+ };
28
+
29
+ export const loader = async ({ request }: LoaderFunctionArgs) => {
30
+ return json({
31
+ message: 'Hello, world!',
32
+ });
33
+ };
34
+
35
+ export default function Example() {
36
+ const actionMessage = useActionData<typeof action>();
37
+ const data = useLoaderData<typeof loader>();
38
+
39
+ return <p>Message: {data.message}</p>;
40
+ }
41
+ "
42
+ `;
43
+
44
+ exports[`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.]`;
45
+
46
+ exports[`route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 2`] = `[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.]`;
47
+
48
+ exports[`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.]`;
49
+
50
+ exports[`route --nameAndDirectoryFormat=derived should add route component 1`] = `
51
+ "import { useLoaderData, useActionData } from '@remix-run/react';
10
52
  import { json } from '@remix-run/node';
11
- import { useActionData, useLoaderData } from '@remix-run/react';
53
+ import type {
54
+ LoaderFunctionArgs,
55
+ MetaFunction,
56
+ ActionFunctionArgs,
57
+ LinksFunction,
58
+ } from '@remix-run/node';
12
59
 
13
60
  import stylesUrl from '../../../styles/path/to/example.css';
14
61
 
@@ -16,17 +63,17 @@ export const links: LinksFunction = () => {
16
63
  return [{ rel: 'stylesheet', href: stylesUrl }];
17
64
  };
18
65
 
19
- export const action = async ({ request }: ActionArgs) => {
66
+ export const action = async ({ request }: ActionFunctionArgs) => {
20
67
  let formData = await request.formData();
21
68
 
22
69
  return json({ message: formData.toString() }, { status: 200 });
23
70
  };
24
71
 
25
72
  export const meta: MetaFunction = () => {
26
- return { title: 'PathToExample Route' };
73
+ return [{ title: 'PathToExample Route' }];
27
74
  };
28
75
 
29
- export const loader = async ({ request }: LoaderArgs) => {
76
+ export const loader = async ({ request }: LoaderFunctionArgs) => {
30
77
  return json({
31
78
  message: 'Hello, world!',
32
79
  });
@@ -40,3 +87,9 @@ export default function PathToExample() {
40
87
  }
41
88
  "
42
89
  `;
90
+
91
+ exports[`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.]`;
92
+
93
+ exports[`route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 2`] = `[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.]`;
94
+
95
+ exports[`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.]`;