@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
@@ -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.]`;
@@ -1,65 +1,77 @@
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
+ const path_1 = require("path");
5
6
  const remix_route_utils_1 = require("../../utils/remix-route-utils");
6
7
  const action_impl_1 = require("../action/action.impl");
7
8
  const loader_impl_1 = require("../loader/loader.impl");
8
9
  const meta_impl_1 = require("../meta/meta.impl");
9
10
  const style_impl_1 = require("../style/style.impl");
10
- function default_1(tree, options) {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
13
- if (!project)
14
- throw new Error(`Project does not exist: ${options.project}`);
15
- if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
16
- 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.`);
17
- }
18
- const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.path, options.project, '.tsx');
19
- const { className: componentName } = (0, devkit_1.names)(options.path.replace(/^\//, '').replace(/\/$/, '').replace('.tsx', ''));
20
- if (tree.exists(routeFilePath))
21
- throw new Error(`Path already exists: ${routeFilePath}`);
22
- tree.write(routeFilePath, (0, devkit_1.stripIndents) `
11
+ async function default_1(tree, options) {
12
+ const { artifactName: name, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
13
+ artifactType: 'route',
14
+ callingGenerator: '@nx/remix:route',
15
+ name: options.path.replace(/^\//, '').replace(/\/$/, ''),
16
+ nameAndDirectoryFormat: options.nameAndDirectoryFormat,
17
+ project: options.project,
18
+ });
19
+ const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
20
+ if (!project)
21
+ throw new Error(`Project does not exist: ${projectName}`);
22
+ if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
23
+ 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.`);
24
+ }
25
+ const routeFilePath = await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.nameAndDirectoryFormat === 'as-provided'
26
+ ? (0, devkit_1.joinPathFragments)(directory, name)
27
+ : options.path, options.nameAndDirectoryFormat === 'as-provided' ? undefined : projectName, '.tsx');
28
+ const nameToUseForComponent = options.nameAndDirectoryFormat === 'as-provided'
29
+ ? name.replace('.tsx', '')
30
+ : options.path.replace(/^\//, '').replace(/\/$/, '').replace('.tsx', '');
31
+ const { className: componentName } = (0, devkit_1.names)(nameToUseForComponent === '.' || nameToUseForComponent === ''
32
+ ? (0, path_1.basename)((0, path_1.dirname)(routeFilePath))
33
+ : nameToUseForComponent);
34
+ if (tree.exists(routeFilePath))
35
+ throw new Error(`Path already exists: ${routeFilePath}`);
36
+ tree.write(routeFilePath, (0, devkit_1.stripIndents) `
23
37
 
24
38
 
25
39
  export default function ${componentName}() {
26
40
  ${options.loader
27
- ? `
41
+ ? `
28
42
  return (
29
43
  <p>
30
44
  Message: {data.message}
31
45
  </p>
32
46
  );
33
47
  `
34
- : `return (<p>${componentName} works!</p>)`}
48
+ : `return (<p>${componentName} works!</p>)`}
35
49
  }
36
50
  `);
37
- if (options.loader) {
38
- yield (0, loader_impl_1.default)(tree, {
39
- project: options.project,
40
- path: routeFilePath,
41
- });
42
- }
43
- if (options.meta) {
44
- yield (0, meta_impl_1.default)(tree, {
45
- path: routeFilePath,
46
- project: options.project,
47
- });
48
- }
49
- if (options.action) {
50
- yield (0, action_impl_1.default)(tree, {
51
- path: routeFilePath,
52
- project: options.project,
53
- });
54
- }
55
- if (options.style === 'css') {
56
- yield (0, style_impl_1.default)(tree, {
57
- project: options.project,
58
- path: options.path,
59
- });
60
- }
61
- yield (0, devkit_1.formatFiles)(tree);
62
- });
51
+ if (options.loader) {
52
+ await (0, loader_impl_1.default)(tree, {
53
+ path: routeFilePath,
54
+ nameAndDirectoryFormat: 'as-provided',
55
+ });
56
+ }
57
+ if (options.meta) {
58
+ await (0, meta_impl_1.default)(tree, {
59
+ path: routeFilePath,
60
+ nameAndDirectoryFormat: 'as-provided',
61
+ });
62
+ }
63
+ if (options.action) {
64
+ await (0, action_impl_1.default)(tree, {
65
+ path: routeFilePath,
66
+ nameAndDirectoryFormat: 'as-provided',
67
+ });
68
+ }
69
+ if (options.style === 'css') {
70
+ await (0, style_impl_1.default)(tree, {
71
+ project: projectName,
72
+ path: routeFilePath,
73
+ });
74
+ }
75
+ await (0, devkit_1.formatFiles)(tree);
63
76
  }
64
77
  exports.default = default_1;
65
- //# sourceMappingURL=route.impl.js.map
@@ -1,9 +1,15 @@
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
  style: 'css' | 'none';
5
7
  action: boolean;
6
8
  meta: boolean;
7
9
  loader: boolean;
8
10
  skipChecks: boolean;
11
+ /**
12
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v18.
13
+ */
14
+ project?: string;
9
15
  }
@@ -2,6 +2,7 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "$id": "NxRemixRoute",
4
4
  "title": "Create a Route",
5
+ "description": "Generate a route.",
5
6
  "type": "object",
6
7
  "examples": [
7
8
  {
@@ -12,12 +13,17 @@
12
13
  "properties": {
13
14
  "path": {
14
15
  "type": "string",
15
- "description": "The route path or path to the filename of the route.",
16
+ "description": "The route path or path to the filename of the route. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
16
17
  "$default": {
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 route in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and path 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
  "style": {
32
39
  "type": "string",
@@ -55,5 +62,5 @@
55
62
  "default": false
56
63
  }
57
64
  },
58
- "required": ["project", "path"]
65
+ "required": ["path"]
59
66
  }
@@ -3,6 +3,7 @@
3
3
  "$id": "NxRemixSetup",
4
4
  "title": "",
5
5
  "type": "object",
6
+ "description": "Generate initial files required for Remix to work within the workspace.",
6
7
  "properties": {
7
8
  "packageManager": {
8
9
  "type": "string",
@@ -1,34 +1,34 @@
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 js_1 = require("@nx/js");
6
- function default_1(tree) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- const tasks = [];
9
- const jsInitTask = yield (0, js_1.initGenerator)(tree, {
10
- skipFormat: true,
11
- });
12
- tasks.push(jsInitTask);
13
- // Ignore nested project files
14
- let ignoreFile = tree.read('.gitignore').toString();
15
- if (ignoreFile.indexOf('/dist') !== -1) {
16
- ignoreFile = ignoreFile.replace('/dist', 'dist');
17
- }
18
- if (ignoreFile.indexOf('/node_modules') !== -1) {
19
- ignoreFile = ignoreFile.replace('/node_modules', 'node_modules');
20
- }
21
- if (ignoreFile.indexOf('# Remix files') === -1) {
22
- ignoreFile = `${ignoreFile}
5
+ async function default_1(tree) {
6
+ const tasks = [];
7
+ const jsInitTask = await (0, js_1.initGenerator)(tree, {
8
+ skipFormat: true,
9
+ });
10
+ tasks.push(jsInitTask);
11
+ // Ignore nested project files
12
+ let ignoreFile = tree.read('.gitignore').toString();
13
+ if (ignoreFile.indexOf('/dist') !== -1) {
14
+ ignoreFile = ignoreFile.replace('/dist', 'dist');
15
+ }
16
+ if (ignoreFile.indexOf('/node_modules') !== -1) {
17
+ ignoreFile = ignoreFile.replace('/node_modules', 'node_modules');
18
+ }
19
+ if (ignoreFile.indexOf('# Remix files') === -1) {
20
+ ignoreFile = `${ignoreFile}
23
21
  # Remix files
24
22
  apps/**/build
25
23
  apps/**/.cache
26
24
  `;
27
- }
28
- tree.write('.gitignore', ignoreFile);
29
- yield (0, devkit_1.formatFiles)(tree);
30
- return (0, devkit_1.runTasksInSerial)(...tasks);
25
+ }
26
+ tree.write('.gitignore', ignoreFile);
27
+ (0, devkit_1.updateJson)(tree, `package.json`, (json) => {
28
+ json.type = 'module';
29
+ return json;
31
30
  });
31
+ await (0, devkit_1.formatFiles)(tree);
32
+ return (0, devkit_1.runTasksInSerial)(...tasks);
32
33
  }
33
34
  exports.default = default_1;
34
- //# sourceMappingURL=setup.impl.js.map
@@ -33,14 +33,16 @@ exports[`setup-tailwind generator should add a js tailwind config to an applicat
33
33
  } from '@remix-run/react';
34
34
  import styles from './tailwind.css';
35
35
  export const links = () => [{ rel: 'stylesheet', href: styles }];
36
- export const meta = () => ({
37
- charset: 'utf-8',
38
- title: 'New Remix App',
39
- viewport: 'width=device-width,initial-scale=1',
40
- });
36
+ export const meta = () => [
37
+ {
38
+ charset: 'utf-8',
39
+ title: 'New Remix App',
40
+ viewport: 'width=device-width,initial-scale=1',
41
+ },
42
+ ];
41
43
  export default function App() {
42
44
  return (
43
- <html lang=\\"en\\">
45
+ <html lang="en">
44
46
  <head>
45
47
  <Meta />
46
48
  <Links />
@@ -64,22 +66,22 @@ exports[`setup-tailwind generator should add a js tailwind config to an applicat
64
66
  module.exports = {
65
67
  tailwind: true,
66
68
  ignoredRouteFiles: ['**/.*'],
67
- // appDirectory: \\"app\\",
68
- // assetsBuildDirectory: \\"public/build\\",
69
- // serverBuildPath: \\"build/index.js\\",
70
- // publicPath: \\"/build/\\",
69
+ // appDirectory: "app",
70
+ // assetsBuildDirectory: "public/build",
71
+ // serverBuildPath: "build/index.js",
72
+ // publicPath: "/build/",
71
73
  watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
72
74
  };
73
75
  "
74
76
  `;
75
77
 
76
78
  exports[`setup-tailwind generator should add a tailwind config to an application correctly 1`] = `
77
- "import type { Config } from \\"tailwindcss\\";
79
+ "import type { Config } from "tailwindcss";
78
80
  import { createGlobPatternsForDependencies } from '@nx/react/tailwind';
79
81
 
80
82
  export default {
81
83
  content: [
82
- \\"./app/**/*.{js,jsx,ts,tsx}\\",
84
+ "./app/**/*.{js,jsx,ts,tsx}",
83
85
  ...createGlobPatternsForDependencies(__dirname)
84
86
  ],
85
87
  theme: {
@@ -98,7 +100,7 @@ exports[`setup-tailwind generator should add a tailwind config to an application
98
100
  `;
99
101
 
100
102
  exports[`setup-tailwind generator should add a tailwind config to an application correctly 3`] = `
101
- "import type { LinksFunction, MetaFunction } from '@remix-run/node';
103
+ "import type { MetaFunction, LinksFunction } from '@remix-run/node';
102
104
  import {
103
105
  Links,
104
106
  LiveReload,
@@ -110,15 +112,17 @@ import {
110
112
  import styles from './tailwind.css';
111
113
  export const links: LinksFunction = () => [{ rel: 'stylesheet', href: styles }];
112
114
 
113
- export const meta: MetaFunction = () => ({
114
- charset: 'utf-8',
115
- title: 'New Remix App',
116
- viewport: 'width=device-width,initial-scale=1',
117
- });
115
+ export const meta: MetaFunction = () => [
116
+ {
117
+ charset: 'utf-8',
118
+ title: 'New Remix App',
119
+ viewport: 'width=device-width,initial-scale=1',
120
+ },
121
+ ];
118
122
 
119
123
  export default function App() {
120
124
  return (
121
- <html lang=\\"en\\">
125
+ <html lang="en">
122
126
  <head>
123
127
  <Meta />
124
128
  <Links />
@@ -142,10 +146,10 @@ exports[`setup-tailwind generator should add a tailwind config to an application
142
146
  module.exports = {
143
147
  tailwind: true,
144
148
  ignoredRouteFiles: ['**/.*'],
145
- // appDirectory: \\"app\\",
146
- // assetsBuildDirectory: \\"public/build\\",
147
- // serverBuildPath: \\"build/index.js\\",
148
- // publicPath: \\"/build/\\",
149
+ // appDirectory: "app",
150
+ // assetsBuildDirectory: "public/build",
151
+ // serverBuildPath: "build/index.js",
152
+ // publicPath: "/build/",
149
153
  watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
150
154
  };
151
155
  "
@@ -2,4 +2,3 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./update-remix-config"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -4,9 +4,9 @@ exports.updateRemixConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const tsquery_1 = require("@phenomnomnominal/tsquery");
6
6
  function updateRemixConfig(tree, projectRoot) {
7
- const pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'remix.config.js');
7
+ const pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'remix.config.cjs');
8
8
  if (!tree.exists(pathToRemixConfig)) {
9
- throw new Error(`Could not find "${pathToRemixConfig}". Please ensure a "remix.config.js" exists at the root of your project.`);
9
+ throw new Error(`Could not find "${pathToRemixConfig}". Please ensure a "remix.config.cjs" exists at the root of your project.`);
10
10
  }
11
11
  const fileContents = tree.read(pathToRemixConfig, 'utf-8');
12
12
  const REMIX_CONFIG_OBJECT_SELECTOR = 'PropertyAccessExpression:has(Identifier[name=module], Identifier[name=exports])~ObjectLiteralExpression';
@@ -36,4 +36,3 @@ function updateRemixConfig(tree, projectRoot) {
36
36
  tree.write(pathToRemixConfig, updatedFileContents);
37
37
  }
38
38
  exports.updateRemixConfig = updateRemixConfig;
39
- //# sourceMappingURL=update-remix-config.js.map
@@ -2,6 +2,7 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "$id": "NxRemixTailwind",
4
4
  "title": "Add TailwindCSS to a Remix App",
5
+ "description": "Setup tailwindcss for a given project.",
5
6
  "type": "object",
6
7
  "examples": [
7
8
  {
@@ -1,38 +1,34 @@
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 upsert_links_function_1 = require("../../utils/upsert-links-function");
6
5
  const versions_1 = require("../../utils/versions");
7
6
  const lib_1 = require("./lib");
8
- function setupTailwind(tree, options) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
11
- if (project.projectType !== 'application') {
12
- throw new Error(`Project "${options.project}" is not an application. Please ensure the project is an application.`);
13
- }
14
- (0, lib_1.updateRemixConfig)(tree, project.root);
15
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), project.root, {
16
- tpl: '',
17
- });
18
- if (options.js) {
19
- tree.rename((0, devkit_1.joinPathFragments)(project.root, 'app/root.js'), (0, devkit_1.joinPathFragments)(project.root, 'app/root.tsx'));
20
- }
21
- const pathToRoot = (0, devkit_1.joinPathFragments)(project.root, 'app/root.tsx');
22
- (0, upsert_links_function_1.upsertLinksFunction)(tree, pathToRoot, 'styles', './tailwind.css', `{ rel: "stylesheet", href: styles }`);
23
- (0, devkit_1.addDependenciesToPackageJson)(tree, {
24
- tailwindcss: versions_1.tailwindVersion,
25
- }, {});
26
- if (options.js) {
27
- (0, devkit_1.toJS)(tree);
28
- }
29
- if (!options.skipFormat) {
30
- yield (0, devkit_1.formatFiles)(tree);
31
- }
32
- return () => {
33
- (0, devkit_1.installPackagesTask)(tree);
34
- };
7
+ async function setupTailwind(tree, options) {
8
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
9
+ if (project.projectType !== 'application') {
10
+ throw new Error(`Project "${options.project}" is not an application. Please ensure the project is an application.`);
11
+ }
12
+ (0, lib_1.updateRemixConfig)(tree, project.root);
13
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), project.root, {
14
+ tpl: '',
35
15
  });
16
+ if (options.js) {
17
+ tree.rename((0, devkit_1.joinPathFragments)(project.root, 'app/root.js'), (0, devkit_1.joinPathFragments)(project.root, 'app/root.tsx'));
18
+ }
19
+ const pathToRoot = (0, devkit_1.joinPathFragments)(project.root, 'app/root.tsx');
20
+ (0, upsert_links_function_1.upsertLinksFunction)(tree, pathToRoot, 'styles', './tailwind.css', `{ rel: "stylesheet", href: styles }`);
21
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {
22
+ tailwindcss: versions_1.tailwindVersion,
23
+ }, {});
24
+ if (options.js) {
25
+ (0, devkit_1.toJS)(tree);
26
+ }
27
+ if (!options.skipFormat) {
28
+ await (0, devkit_1.formatFiles)(tree);
29
+ }
30
+ return () => {
31
+ (0, devkit_1.installPackagesTask)(tree);
32
+ };
36
33
  }
37
34
  exports.default = setupTailwind;
38
- //# sourceMappingURL=setup-tailwind.impl.js.map
@@ -1,7 +1,7 @@
1
- import { Linter } from '@nx/linter';
1
+ import { Linter } from '@nx/eslint';
2
2
 
3
3
  export interface StorybookConfigurationSchema {
4
- name: string;
4
+ project: string;
5
5
  configureCypress: boolean;
6
6
  generateStories?: boolean;
7
7
  generateCypressSpecs?: boolean;
@@ -6,12 +6,9 @@
6
6
  "description": "Set up Storybook for a Remix library.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "project": {
10
10
  "type": "string",
11
- "aliases": [
12
- "project",
13
- "projectName"
14
- ],
11
+ "aliases": ["name", "projectName"],
15
12
  "description": "Project for which to generate Storybook configuration.",
16
13
  "$default": {
17
14
  "$source": "argv",
@@ -66,9 +63,7 @@
66
63
  "linter": {
67
64
  "description": "The tool to use for running lint checks.",
68
65
  "type": "string",
69
- "enum": [
70
- "eslint"
71
- ],
66
+ "enum": ["eslint"],
72
67
  "default": "eslint"
73
68
  },
74
69
  "ignorePaths": {
@@ -90,7 +85,5 @@
90
85
  "description": "Add a Storybook Test-Runner target."
91
86
  }
92
87
  },
93
- "required": [
94
- "name"
95
- ]
88
+ "required": ["name"]
96
89
  }
@@ -1,19 +1,14 @@
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 path_1 = require("path");
6
- const versions_1 = require("../../utils/versions");
7
- function remixStorybookConfiguration(tree, schema) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const { root } = (0, devkit_1.readProjectConfiguration)(tree, schema.name);
10
- if (!tree.exists((0, devkit_1.joinPathFragments)(root, 'vite.config.ts'))) {
11
- (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), root, { tpl: '' });
12
- }
13
- const { storybookConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/react', (0, versions_1.getPackageVersion)(tree, 'nx'));
14
- const task = yield storybookConfigurationGenerator(tree, schema);
15
- return task;
16
- });
5
+ const react_1 = require("@nx/react");
6
+ async function remixStorybookConfiguration(tree, schema) {
7
+ const { root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
8
+ if (!tree.exists((0, devkit_1.joinPathFragments)(root, 'vite.config.ts'))) {
9
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), root, { tpl: '' });
10
+ }
11
+ const task = await (0, react_1.storybookConfigurationGenerator)(tree, schema);
12
+ return task;
17
13
  }
18
14
  exports.default = remixStorybookConfiguration;
19
- //# sourceMappingURL=storybook-configuration.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 RemixStyleSchema {
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
  }