@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
@@ -8,11 +8,11 @@ import {
8
8
  ScrollRestoration,
9
9
  } from "@remix-run/react";
10
10
 
11
- export const meta: MetaFunction = () => ({
11
+ export const meta: MetaFunction = () => ([{
12
12
  charset: "utf-8",
13
13
  title: "New Remix App",
14
14
  viewport: "width=device-width,initial-scale=1",
15
- });
15
+ }]);
16
16
 
17
17
  export default function App() {
18
18
  return (
@@ -29,4 +29,4 @@ export default function App() {
29
29
  </body>
30
30
  </html>
31
31
  );
32
- }
32
+ }
@@ -0,0 +1,9 @@
1
+ import NxWelcome from "../nx-welcome";
2
+
3
+ export default function Index() {
4
+ return (
5
+ <div>
6
+ <NxWelcome title={"<%= projectName %>"} />
7
+ </div>
8
+ );
9
+ }
@@ -1,11 +1,17 @@
1
+ import {createWatchPaths} from '@nx/remix';
2
+ import {dirname} from 'path';
3
+ import {fileURLToPath} from 'url';
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
1
7
  /**
2
8
  * @type {import('@remix-run/dev').AppConfig}
3
9
  */
4
- module.exports = {
5
- ignoredRouteFiles: ["**/.*"],
6
- // appDirectory: "app",
7
- // assetsBuildDirectory: "public/build",
8
- // serverBuildPath: "build/index.js",
9
- // publicPath: "/build/",
10
- watchPaths: () => require("@nx/remix").createWatchPaths(__dirname),
10
+ export default {
11
+ ignoredRouteFiles: ["**/.*"],
12
+ // appDirectory: "app",
13
+ // assetsBuildDirectory: "public/build",
14
+ // serverBuildPath: "build/index.js",
15
+ // publicPath: "/build/",
16
+ watchPaths: () => createWatchPaths(__dirname),
11
17
  };
@@ -0,0 +1,16 @@
1
+ import { createRemixStub } from '@remix-run/testing';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import Index from '../../app/routes/_index';
4
+
5
+ test('renders loader data', async () => {
6
+ const RemixStub = createRemixStub([
7
+ {
8
+ path: '/',
9
+ Component: Index,
10
+ },
11
+ ]);
12
+
13
+ render(<RemixStub />);
14
+
15
+ await waitFor(() => screen.findByText('Hello there,'));
16
+ });
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": [
4
+ "remix.env.d.ts",
5
+ "app/**/*.ts",
6
+ "app/**/*.tsx",
7
+ "app/**/*.js",
8
+ "app/**/*.jsx"
9
+ ],
10
+ "exclude": [
11
+ "tests/**/*.spec.ts",
12
+ "tests/**/*.test.ts",
13
+ "tests/**/*.spec.tsx",
14
+ "tests/**/*.test.tsx",
15
+ "tests/**/*.spec.js",
16
+ "tests/**/*.test.js",
17
+ "tests/**/*.spec.jsx",
18
+ "tests/**/*.test.jsx"
19
+ ]
20
+ }
@@ -1,18 +1,24 @@
1
1
  {
2
2
  "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
- "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
4
3
  "compilerOptions": {
5
- "lib": ["DOM", "DOM.Iterable", "ES2019"],
6
- "isolatedModules": true,
7
- "esModuleInterop": true,
8
- "jsx": "react-jsx",
9
- "moduleResolution": "node",
10
- "resolveJsonModule": true,
11
- "target": "ES2019",
12
- "strict": true,
13
- "allowJs": true,
14
- "forceConsistentCasingInFileNames": true,
15
- // Remix takes care of building everything in `remix build`.
16
- "noEmit": true
17
- }
4
+ "lib": ["DOM", "DOM.Iterable", "ES2019"],
5
+ "isolatedModules": true,
6
+ "esModuleInterop": true,
7
+ "jsx": "react-jsx",
8
+ "moduleResolution": "node",
9
+ "resolveJsonModule": true,
10
+ "target": "ES2019",
11
+ "strict": true,
12
+ "allowJs": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ // Remix takes care of building everything in `remix build`.
15
+ "noEmit": true
16
+ },
17
+ "include": [],
18
+ "files": [],
19
+ "references": [
20
+ {
21
+ "path": "./tsconfig.app.json"
22
+ }
23
+ ]
18
24
  }
@@ -4,6 +4,7 @@
4
4
  "description": "",
5
5
  "license": "",
6
6
  "scripts": {},
7
+ "type": "module",
7
8
  "dependencies": {
8
9
  "@remix-run/node": "<%= remixVersion %>",
9
10
  "@remix-run/react": "<%= remixVersion %>",
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import { type NormalizedSchema } from './normalize-options';
3
+ export declare function addE2E(tree: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addE2E = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../../utils/versions");
6
+ async function addE2E(tree, options) {
7
+ if (options.e2eTestRunner === 'cypress') {
8
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', (0, versions_1.getPackageVersion)(tree, 'nx'));
9
+ // TODO(colum): Remix needs a different approach to serve-static
10
+ // Likely via remix start
11
+ // addFileServerTarget(tree, options, 'serve-static');
12
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
13
+ projectType: 'application',
14
+ root: options.e2eProjectRoot,
15
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
16
+ targets: {},
17
+ tags: [],
18
+ implicitDependencies: [options.projectName],
19
+ });
20
+ return await configurationGenerator(tree, {
21
+ project: options.e2eProjectName,
22
+ directory: 'src',
23
+ skipFormat: true,
24
+ devServerTarget: `${options.projectName}:${options.e2eWebServerTarget}:development`,
25
+ baseUrl: options.e2eWebServerAddress,
26
+ addPlugin: options.addPlugin,
27
+ });
28
+ }
29
+ else if (options.e2eTestRunner === 'playwright') {
30
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', (0, versions_1.getPackageVersion)(tree, 'nx'));
31
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
32
+ projectType: 'application',
33
+ root: options.e2eProjectRoot,
34
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
35
+ targets: {},
36
+ tags: [],
37
+ implicitDependencies: [options.projectName],
38
+ });
39
+ return configurationGenerator(tree, {
40
+ project: options.e2eProjectName,
41
+ skipFormat: true,
42
+ skipPackageJson: false,
43
+ directory: 'src',
44
+ js: false,
45
+ linter: options.linter,
46
+ setParserOptionsProject: false,
47
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.name}`,
48
+ webServerAddress: options.e2eWebServerAddress,
49
+ rootProject: options.rootProject,
50
+ addPlugin: options.addPlugin,
51
+ });
52
+ }
53
+ else {
54
+ return () => { };
55
+ }
56
+ }
57
+ exports.addE2E = addE2E;
58
+ function addFileServerTarget(tree, options, targetName) {
59
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
60
+ projectConfig.targets[targetName] = {
61
+ executor: '@nx/web:file-server',
62
+ options: {
63
+ buildTarget: `${options.projectName}:build`,
64
+ port: options.e2ePort,
65
+ },
66
+ };
67
+ (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
68
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './normalize-options';
2
2
  export * from './update-unit-test-config';
3
+ export * from './add-e2e';
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./normalize-options"), exports);
5
5
  tslib_1.__exportStar(require("./update-unit-test-config"), exports);
6
- //# sourceMappingURL=index.js.map
6
+ tslib_1.__exportStar(require("./add-e2e"), exports);
@@ -1,8 +1,13 @@
1
- import { Tree } from '@nx/devkit';
2
- import { NxRemixGeneratorSchema } from '../schema';
1
+ import { type Tree } from '@nx/devkit';
2
+ import { type NxRemixGeneratorSchema } from '../schema';
3
3
  export interface NormalizedSchema extends NxRemixGeneratorSchema {
4
4
  projectName: string;
5
5
  projectRoot: string;
6
+ e2eProjectName: string;
7
+ e2eProjectRoot: string;
8
+ e2eWebServerAddress: string;
9
+ e2eWebServerTarget: string;
10
+ e2ePort: number;
6
11
  parsedTags: string[];
7
12
  }
8
- export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): NormalizedSchema;
13
+ export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): Promise<NormalizedSchema>;
@@ -2,23 +2,61 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const project_1 = require("../../../utils/project");
6
- function normalizeOptions(tree, options) {
7
- const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
8
- const appDirectory = (0, project_1.normalizeDirectory)(options.name, projectDirectory);
9
- const appName = (0, project_1.normalizeProjectName)(options.name, projectDirectory);
10
- const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(tree);
11
- const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultAppsDir;
12
- const projectName = appName;
13
- const projectRoot = options.rootProject
14
- ? '.'
15
- : (0, devkit_1.joinPathFragments)(appsDir, appDirectory);
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ const eslint_1 = require("@nx/eslint");
7
+ async function normalizeOptions(tree, options) {
8
+ const { projectName, projectRoot, projectNameAndRootFormat } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
9
+ name: options.name,
10
+ projectType: 'application',
11
+ directory: options.directory,
12
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
13
+ rootProject: options.rootProject,
14
+ callingGenerator: '@nx/remix:application',
15
+ });
16
+ options.rootProject = projectRoot === '.';
17
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
18
+ const nxJson = (0, devkit_1.readNxJson)(tree);
19
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
20
+ nxJson.useInferencePlugins !== false;
21
+ options.addPlugin ??= addPluginDefault;
22
+ let e2eWebServerTarget = options.addPlugin ? 'dev' : 'serve';
23
+ if (options.addPlugin) {
24
+ if (nxJson.plugins) {
25
+ for (const plugin of nxJson.plugins) {
26
+ if (typeof plugin === 'object' &&
27
+ plugin.plugin === '@nx/remix/plugin' &&
28
+ plugin.options.devTargetName) {
29
+ e2eWebServerTarget = plugin.options
30
+ .devTargetName;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ let e2ePort = options.addPlugin ? 3000 : 4200;
36
+ if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
37
+ (nxJson.targetDefaults?.[e2eWebServerTarget].options?.port ||
38
+ nxJson.targetDefaults?.[e2eWebServerTarget].options?.env?.PORT)) {
39
+ e2ePort =
40
+ nxJson.targetDefaults?.[e2eWebServerTarget].options?.port ||
41
+ nxJson.targetDefaults?.[e2eWebServerTarget].options?.env?.PORT;
42
+ }
43
+ const e2eProjectName = options.rootProject ? 'e2e' : `${projectName}-e2e`;
44
+ const e2eProjectRoot = options.rootProject ? 'e2e' : `${projectRoot}-e2e`;
45
+ const e2eWebServerAddress = `http://localhost:${e2ePort}`;
16
46
  const parsedTags = options.tags
17
47
  ? options.tags.split(',').map((s) => s.trim())
18
48
  : [];
19
- return Object.assign(Object.assign({}, options), { projectName,
49
+ return {
50
+ ...options,
51
+ linter: options.linter ?? eslint_1.Linter.EsLint,
52
+ projectName,
20
53
  projectRoot,
21
- parsedTags });
54
+ e2eProjectName,
55
+ e2eProjectRoot,
56
+ e2eWebServerAddress,
57
+ e2eWebServerTarget,
58
+ e2ePort,
59
+ parsedTags,
60
+ };
22
61
  }
23
62
  exports.normalizeOptions = normalizeOptions;
24
- //# sourceMappingURL=normalize-options.js.map
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function updateUnitTestConfig(tree: Tree, pathToRoot: string, unitTestRunner: 'vitest' | 'jest'): import("@nx/devkit").GeneratorCallback;
2
+ export declare function updateUnitTestConfig(tree: Tree, pathToRoot: string, unitTestRunner: 'vitest' | 'jest', rootProject: boolean): import("@nx/devkit").GeneratorCallback;
@@ -4,27 +4,52 @@ exports.updateUnitTestConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const testing_config_utils_1 = require("../../../utils/testing-config-utils");
6
6
  const versions_1 = require("../../../utils/versions");
7
- function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
7
+ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner, rootProject) {
8
8
  const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
9
9
  tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
10
10
  import { installGlobals } from '@remix-run/node';
11
- import '@testing-library/jest-dom/extend-expect';
11
+ import '@testing-library/jest-dom/matchers';
12
12
  installGlobals();`);
13
13
  if (unitTestRunner === 'vitest') {
14
- const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vite.config.ts');
15
- (0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
16
- (0, testing_config_utils_1.updateViteTestSetup)(tree, pathToViteConfig, './test-setup.ts');
14
+ const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vitest.config.ts');
15
+ (0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
16
+ (0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
17
+ (0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
17
18
  }
18
- else if (unitTestRunner === 'jest') {
19
+ else if (unitTestRunner === 'jest' && rootProject) {
19
20
  const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
21
+ tree.write('jest.preset.cjs', tree.read('jest.preset.js', 'utf-8'));
20
22
  (0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, `<rootDir>/test-setup.ts`);
23
+ tree.write(pathToJestConfig, tree
24
+ .read(pathToJestConfig, 'utf-8')
25
+ .replace('jest.preset.js', 'jest.preset.cjs'));
21
26
  }
27
+ const pathToTsConfigSpec = (0, devkit_1.joinPathFragments)(pathToRoot, `tsconfig.spec.json`);
28
+ (0, devkit_1.updateJson)(tree, pathToTsConfigSpec, (json) => {
29
+ json.include = [
30
+ 'vite.config.ts',
31
+ 'vitest.config.ts',
32
+ 'app/**/*.ts',
33
+ 'app/**/*.tsx',
34
+ 'app/**/*.js',
35
+ 'app/**/*.jsx',
36
+ 'tests/**/*.spec.ts',
37
+ 'tests/**/*.test.ts',
38
+ 'tests/**/*.spec.tsx',
39
+ 'tests/**/*.test.tsx',
40
+ 'tests/**/*.spec.js',
41
+ 'tests/**/*.test.js',
42
+ 'tests/**/*.spec.jsx',
43
+ 'tests/**/*.test.jsx',
44
+ ];
45
+ return json;
46
+ });
22
47
  return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
23
48
  '@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
24
49
  '@testing-library/react': versions_1.testingLibraryReactVersion,
25
50
  '@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
26
51
  '@remix-run/node': (0, versions_1.getRemixVersion)(tree),
52
+ '@remix-run/testing': (0, versions_1.getRemixVersion)(tree),
27
53
  });
28
54
  }
29
55
  exports.updateUnitTestConfig = updateUnitTestConfig;
30
- //# sourceMappingURL=update-unit-test-config.js.map
@@ -1,10 +1,16 @@
1
+ import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/eslint';
3
+
1
4
  export interface NxRemixGeneratorSchema {
2
5
  name: string;
3
6
  tags?: string;
4
7
  js?: boolean;
5
8
  directory?: string;
9
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
10
+ linter?: Linter;
6
11
  unitTestRunner?: 'vitest' | 'jest' | 'none';
7
- e2eTestRunner?: 'cypress' | 'none';
12
+ e2eTestRunner?: 'cypress' | 'playwright' | 'none';
8
13
  skipFormat?: boolean;
9
14
  rootProject?: boolean;
15
+ addPlugin?: boolean;
10
16
  }
@@ -1,7 +1,8 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxRemixApplication",
4
4
  "title": "Create an Application",
5
+ "description": "Generate a new Remix application.",
5
6
  "type": "object",
6
7
  "properties": {
7
8
  "name": {
@@ -24,25 +25,30 @@
24
25
  "alias": "dir",
25
26
  "x-priority": "important"
26
27
  },
28
+ "projectNameAndRootFormat": {
29
+ "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`).",
30
+ "type": "string",
31
+ "enum": ["as-provided", "derived"]
32
+ },
33
+ "linter": {
34
+ "description": "The tool to use for running lint checks.",
35
+ "type": "string",
36
+ "enum": ["eslint", "none"],
37
+ "default": "eslint"
38
+ },
27
39
  "unitTestRunner": {
28
40
  "type": "string",
29
- "enum": [
30
- "vitest",
31
- "jest",
32
- "none"
33
- ],
41
+ "enum": ["vitest", "jest", "none"],
34
42
  "default": "vitest",
35
43
  "description": "Test runner to use for unit tests.",
36
44
  "x-prompt": "What unit test runner should be used?"
37
45
  },
38
46
  "e2eTestRunner": {
39
47
  "type": "string",
40
- "enum": [
41
- "cypress",
42
- "none"
43
- ],
48
+ "enum": ["cypress", "playwright", "none"],
44
49
  "default": "cypress",
45
- "description": "Test runner to use for e2e tests"
50
+ "description": "Test runner to use for e2e tests",
51
+ "x-prompt": "Which E2E test runner would you like to use?"
46
52
  },
47
53
  "tags": {
48
54
  "type": "string",
@@ -1,3 +1,5 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import { type CypressComponentConfigurationSchema } from './schema';
3
- export default function cypressComponentConfigurationGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<void>;
3
+ export declare function cypressComponentConfigurationGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<void>;
4
+ export declare function cypressComponentConfigurationGeneratorInternal(tree: Tree, options: CypressComponentConfigurationSchema): Promise<void>;
5
+ export default cypressComponentConfigurationGenerator;
@@ -1,25 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
3
+ exports.cypressComponentConfigurationGeneratorInternal = exports.cypressComponentConfigurationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const path_1 = require("path");
6
- const versions_1 = require("../../utils/versions");
6
+ const react_1 = require("@nx/react");
7
7
  function cypressComponentConfigurationGenerator(tree, options) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const { cypressComponentConfigGenerator } = (0, devkit_1.ensurePackage)('@nx/react', (0, versions_1.getPackageVersion)(tree, 'nx'));
10
- yield cypressComponentConfigGenerator(tree, {
11
- project: options.project,
12
- generateTests: options.generateTests,
13
- skipFormat: true,
14
- bundler: 'vite',
15
- buildTarget: '',
16
- });
17
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
18
- (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
19
- if (!options.skipFormat) {
20
- yield (0, devkit_1.formatFiles)(tree);
21
- }
8
+ return cypressComponentConfigurationGeneratorInternal(tree, {
9
+ addPlugin: false,
10
+ ...options,
22
11
  });
23
12
  }
13
+ exports.cypressComponentConfigurationGenerator = cypressComponentConfigurationGenerator;
14
+ async function cypressComponentConfigurationGeneratorInternal(tree, options) {
15
+ const nxJson = (0, devkit_1.readNxJson)(tree);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ options.addPlugin ??= addPluginDefault;
19
+ await (0, react_1.cypressComponentConfigGenerator)(tree, {
20
+ project: options.project,
21
+ generateTests: options.generateTests,
22
+ skipFormat: true,
23
+ bundler: 'vite',
24
+ buildTarget: '',
25
+ addPlugin: options.addPlugin,
26
+ });
27
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
28
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
29
+ if (!options.skipFormat) {
30
+ await (0, devkit_1.formatFiles)(tree);
31
+ }
32
+ }
33
+ exports.cypressComponentConfigurationGeneratorInternal = cypressComponentConfigurationGeneratorInternal;
24
34
  exports.default = cypressComponentConfigurationGenerator;
25
- //# sourceMappingURL=cypress-component-configuration.impl.js.map
@@ -2,4 +2,5 @@ export interface CypressComponentConfigurationSchema {
2
2
  project: string;
3
3
  generateTests?: boolean;
4
4
  skipFormat?: boolean;
5
+ addPlugin?: boolean;
5
6
  }
@@ -1,21 +1,37 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ErrorBoundary --apiVersion=1 should correctly add the ErrorBoundary to the route file 1`] = `
4
- "export function ErrorBoundary({ error }) {
5
- console.error(error);
6
- return (
7
- <div>
8
- <h1>Uh oh ...</h1>
9
- <p>Something went wrong</p>
10
- <pre>{error.message || 'Unknown error'}</pre>
11
- </div>
12
- );
3
+ exports[`ErrorBoundary --nameAndDirectoryFormat=as-provided --apiVersion=2 should correctly add the ErrorBoundary to the route file 1`] = `
4
+ "import { useRouteError, isRouteErrorResponse } from '@remix-run/react';
5
+ export function ErrorBoundary() {
6
+ const error = useRouteError();
7
+
8
+ // when true, this is what used to go to 'CatchBoundary'
9
+ if (isRouteErrorResponse(error)) {
10
+ return (
11
+ <div>
12
+ <h1>Oops</h1>
13
+ <p>Status: {error.status}</p>
14
+ <p>{error.data.message}</p>
15
+ </div>
16
+ );
17
+ } else if (error instanceof Error) {
18
+ return (
19
+ <div>
20
+ <h1>Error</h1>
21
+ <p>{error.message}</p>
22
+ <p>The stack trace is:</p>
23
+ <pre>{error.stack}</pre>
24
+ </div>
25
+ );
26
+ } else {
27
+ return <h1>Unknown Error</h1>;
28
+ }
13
29
  }
14
30
  "
15
31
  `;
16
32
 
17
- exports[`ErrorBoundary --apiVersion=2 should correctly add the ErrorBoundary to the route file 1`] = `
18
- "import { isRouteErrorResponse, useRouteError } from '@remix-run/react';
33
+ exports[`ErrorBoundary --nameAndDirectoryFormat=as-provided --apiVersion=2 should correctly add the ErrorBoundary to the route file 2`] = `
34
+ "import { useRouteError, isRouteErrorResponse } from '@remix-run/react';
19
35
  export function ErrorBoundary() {
20
36
  const error = useRouteError();
21
37
 
@@ -28,22 +44,18 @@ export function ErrorBoundary() {
28
44
  <p>{error.data.message}</p>
29
45
  </div>
30
46
  );
47
+ } else if (error instanceof Error) {
48
+ return (
49
+ <div>
50
+ <h1>Error</h1>
51
+ <p>{error.message}</p>
52
+ <p>The stack trace is:</p>
53
+ <pre>{error.stack}</pre>
54
+ </div>
55
+ );
56
+ } else {
57
+ return <h1>Unknown Error</h1>;
31
58
  }
32
-
33
- // Don't forget to typecheck with your own logic.
34
- // Any value can be thrown, not just errors!
35
- let errorMessage = 'Unknown error';
36
- // if (isDefinitelyAnError(error)) {
37
- // errorMessage = error.message;
38
- // }
39
-
40
- return (
41
- <div>
42
- <h1>Uh oh ...</h1>
43
- <p>Something went wrong.</p>
44
- <pre>{errorMessage}</pre>
45
- </div>
46
- );
47
59
  }
48
60
  "
49
61
  `;
@@ -1,21 +1,12 @@
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 lib_1 = require("./lib");
6
- function errorBoundaryGenerator(tree, schema) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- const options = (0, lib_1.normalizeOptions)(tree, schema);
9
- if (options.apiVersion === 1) {
10
- (0, lib_1.addV1ErrorBoundary)(tree, options);
11
- }
12
- else {
13
- (0, lib_1.addV2ErrorBoundary)(tree, options);
14
- }
15
- if (!options.skipFormat) {
16
- yield (0, devkit_1.formatFiles)(tree);
17
- }
18
- });
5
+ async function errorBoundaryGenerator(tree, schema) {
6
+ const options = await (0, lib_1.normalizeOptions)(tree, schema);
7
+ (0, lib_1.addV2ErrorBoundary)(tree, options);
8
+ if (!options.skipFormat) {
9
+ await (0, devkit_1.formatFiles)(tree);
10
+ }
19
11
  }
20
12
  exports.default = errorBoundaryGenerator;
21
- //# sourceMappingURL=error-boundary.impl.js.map