@nx/remix 17.0.0 → 17.2.8

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 -13
  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 +772 -145
  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 +7 -2
  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 -12
  46. package/src/generators/library/lib/update-buildable-config.js +5 -2
  47. package/src/generators/library/library.impl.js +29 -32
  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 +1 -1
  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,27 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
- const package_json_1 = require("nx/package.json");
6
- function default_1(tree, options) {
7
- var _a, _b, _c, _d;
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- (_a = options.baseUrl) !== null && _a !== void 0 ? _a : (options.baseUrl = 'http://localhost:3000');
10
- const { cypressInitGenerator, cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', package_json_1.version);
11
- const initSideEffects = yield cypressInitGenerator(tree, {});
12
- const projSideEffects = yield cypressProjectGenerator(tree, Object.assign(Object.assign({}, options), { standaloneConfig: true }));
13
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.name);
14
- tree.delete((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'app.po.ts'));
15
- tree.write((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'e2e', 'app.cy.ts'), `describe('webapp', () => {
4
+ const cypress_1 = require("@nx/cypress");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ const versions_1 = require("../../utils/versions");
7
+ async function default_1(tree, options) {
8
+ const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = 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
+ callingGenerator: '@nx/remix:cypress',
14
+ });
15
+ const rootProject = e2eProjectRoot === '.';
16
+ let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
17
+ options.baseUrl ??= `http://localhost:${projectConfig.targets['serve'].options.port}`;
18
+ addFileServerTarget(tree, options, 'serve-static');
19
+ (0, devkit_1.addProjectConfiguration)(tree, e2eProjectName, {
20
+ projectType: 'application',
21
+ root: e2eProjectRoot,
22
+ sourceRoot: (0, devkit_1.joinPathFragments)(e2eProjectRoot, 'src'),
23
+ targets: {},
24
+ tags: [],
25
+ implicitDependencies: [options.name],
26
+ });
27
+ const installTask = await (0, cypress_1.configurationGenerator)(tree, {
28
+ project: e2eProjectName,
29
+ directory: 'src',
30
+ linter: options.linter,
31
+ skipPackageJson: false,
32
+ skipFormat: true,
33
+ devServerTarget: `${options.project}:serve:development`,
34
+ baseUrl: options.baseUrl,
35
+ rootProject,
36
+ });
37
+ projectConfig = (0, devkit_1.readProjectConfiguration)(tree, e2eProjectName);
38
+ tree.delete((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'app.po.ts'));
39
+ tree.write((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'e2e', 'app.cy.ts'), `describe('webapp', () => {
16
40
  beforeEach(() => cy.visit('/'));
17
41
 
18
42
  it('should display welcome message', () => {
19
43
  cy.get('h1').contains('Welcome to Remix');
20
44
  });
21
45
  });`);
22
- const supportFilePath = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'e2e.ts');
23
- const supportContent = tree.read(supportFilePath, 'utf-8');
24
- tree.write(supportFilePath, `${supportContent}
46
+ const supportFilePath = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'e2e.ts');
47
+ const supportContent = tree.read(supportFilePath, 'utf-8');
48
+ tree.write(supportFilePath, `${supportContent}
25
49
 
26
50
  // from https://github.com/remix-run/indie-stack
27
51
  Cypress.on("uncaught:exception", (err) => {
@@ -36,32 +60,18 @@ Cypress.on("uncaught:exception", (err) => {
36
60
  return false;
37
61
  }
38
62
  });`);
39
- // run-commands won't emit { success: true, baseUrl: '...' } to Cypress executor.
40
- // We'll wire it up manually and skip serve from Cypress.
41
- projectConfig.targets.e2e.options.skipServe = true;
42
- projectConfig.targets.e2e.options.baseUrl =
43
- (_b = options.baseUrl) !== null && _b !== void 0 ? _b : 'http://localhost:3000';
44
- projectConfig.targets.e2e.dependsOn = ['dev-server'];
45
- delete projectConfig.targets.e2e.options.devServerTarget;
46
- (_d = (_c = projectConfig.targets.e2e) === null || _c === void 0 ? void 0 : _c.configurations) === null || _d === void 0 ? true : delete _d.production.devServerTarget;
47
- projectConfig.targets['dev-server'] = {
48
- command: `nx serve ${options.project}`,
49
- options: {
50
- readyWhen: 'Server started',
51
- },
52
- configurations: {
53
- production: {
54
- command: `nx serve ${options.project} --configuration=production`,
55
- },
56
- },
57
- };
58
- (0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfig);
59
- // returning this in case the cypress generator has any side effects
60
- return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
61
- yield initSideEffects();
62
- yield projSideEffects();
63
- });
64
- });
63
+ return (0, devkit_1.runTasksInSerial)(installTask);
65
64
  }
66
65
  exports.default = default_1;
67
- //# sourceMappingURL=cypress.impl.js.map
66
+ function addFileServerTarget(tree, options, targetName) {
67
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/web': versions_1.nxVersion });
68
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
69
+ projectConfig.targets[targetName] = {
70
+ executor: '@nx/web:file-server',
71
+ options: {
72
+ buildTarget: `${options.project}:build`,
73
+ port: projectConfig.targets['serve'].options.port,
74
+ },
75
+ };
76
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
77
+ }
@@ -1,9 +1,13 @@
1
+ import { type ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import { Linter } from '@nx/eslint';
3
+
1
4
  export interface CypressGeneratorSchema {
2
5
  project: string;
3
6
  name: string;
4
7
  baseUrl?: string;
5
8
  directory?: string;
6
- linter?: 'none' | 'eslint';
9
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
10
+ linter?: Linter;
7
11
  js?: boolean;
8
12
  skipFormat?: boolean;
9
13
  setParserOptionsProject?: boolean;
@@ -3,6 +3,7 @@
3
3
  "$id": "NxRemixCypress",
4
4
  "title": "",
5
5
  "type": "object",
6
+ "description": "Generate a Cypress e2e project for a given application.",
6
7
  "properties": {
7
8
  "project": {
8
9
  "type": "string",
@@ -11,6 +12,11 @@
11
12
  "$source": "projectName"
12
13
  }
13
14
  },
15
+ "projectNameAndRootFormat": {
16
+ "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`).",
17
+ "type": "string",
18
+ "enum": ["as-provided", "derived"]
19
+ },
14
20
  "baseUrl": {
15
21
  "type": "string",
16
22
  "description": "URL to access the application on",
@@ -1,25 +1,20 @@
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 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
- }
5
+ const react_1 = require("@nx/react");
6
+ async function cypressComponentConfigurationGenerator(tree, options) {
7
+ await (0, react_1.cypressComponentConfigGenerator)(tree, {
8
+ project: options.project,
9
+ generateTests: options.generateTests,
10
+ skipFormat: true,
11
+ bundler: 'vite',
12
+ buildTarget: '',
22
13
  });
14
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
15
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
16
+ if (!options.skipFormat) {
17
+ await (0, devkit_1.formatFiles)(tree);
18
+ }
23
19
  }
24
20
  exports.default = cypressComponentConfigurationGenerator;
25
- //# sourceMappingURL=cypress-component-configuration.impl.js.map
@@ -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
@@ -20,24 +20,19 @@ function addV2ErrorBoundary(tree, options) {
20
20
  <p>{error.data.message}</p>
21
21
  </div>
22
22
  );
23
+ } else if (error instanceof Error) {
24
+ return (
25
+ <div>
26
+ <h1>Error</h1>
27
+ <p>{error.message}</p>
28
+ <p>The stack trace is:</p>
29
+ <pre>{error.stack}</pre>
30
+ </div>
31
+ );
32
+ } else {
33
+ return <h1>Unknown Error</h1>;
23
34
  }
24
-
25
- // Don't forget to typecheck with your own logic.
26
- // Any value can be thrown, not just errors!
27
- let errorMessage = "Unknown error";
28
- // if (isDefinitelyAnError(error)) {
29
- // errorMessage = error.message;
30
- // }
31
-
32
- return (
33
- <div>
34
- <h1>Uh oh ...</h1>
35
- <p>Something went wrong.</p>
36
- <pre>{errorMessage}</pre>
37
- </div>
38
- );
39
35
  }
40
36
  `);
41
37
  }
42
38
  exports.addV2ErrorBoundary = addV2ErrorBoundary;
43
- //# sourceMappingURL=add-v2-error-boundary.js.map
@@ -1,3 +1,2 @@
1
- export * from './add-v1-error-boundary';
2
1
  export * from './add-v2-error-boundary';
3
2
  export * from './normalize-options';
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./add-v1-error-boundary"), exports);
5
4
  tslib_1.__exportStar(require("./add-v2-error-boundary"), exports);
6
5
  tslib_1.__exportStar(require("./normalize-options"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import type { ErrorBoundarySchema } from '../schema';
3
- export declare function normalizeOptions(tree: Tree, schema: ErrorBoundarySchema): ErrorBoundarySchema;
3
+ export declare function normalizeOptions(tree: Tree, schema: ErrorBoundarySchema): Promise<ErrorBoundarySchema>;
@@ -2,12 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
4
  const remix_route_utils_1 = require("../../../utils/remix-route-utils");
5
- function normalizeOptions(tree, schema) {
6
- const pathToRouteFile = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
5
+ async function normalizeOptions(tree, schema) {
6
+ const pathToRouteFile = schema.nameAndDirectoryFormat === 'as-provided'
7
+ ? schema.path
8
+ : await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
7
9
  if (!tree.exists(pathToRouteFile)) {
8
- throw new Error(`Route file specified does not exist "${pathToRouteFile}". Please ensure you pass a correct path to the file, relative to the project root.`);
10
+ throw new Error(`Route file specified does not exist "${pathToRouteFile}". Please ensure you pass a correct path to the file.`);
9
11
  }
10
- return Object.assign(Object.assign({}, schema), { path: pathToRouteFile });
12
+ return {
13
+ ...schema,
14
+ path: pathToRouteFile,
15
+ };
11
16
  }
12
17
  exports.normalizeOptions = normalizeOptions;
13
- //# sourceMappingURL=normalize-options.js.map
@@ -1,6 +1,11 @@
1
+ import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
1
3
  export interface ErrorBoundarySchema {
2
- project: string;
3
4
  path: string;
4
- apiVersion: number;
5
5
  skipFormat?: false;
6
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
7
+ /**
8
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v18.
9
+ */
10
+ project?: string;
6
11
  }
@@ -2,14 +2,24 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "$id": "NxRemixErrorBoundary",
4
4
  "title": "Create an ErrorBoundary for a Route",
5
+ "description": "Generate an ErrorBoundary for a given route.",
5
6
  "type": "object",
6
7
  "examples": [
7
8
  {
8
- "command": "g error-boundary --project=myapp --routePath=app/routes/my-route.tsx",
9
+ "command": "g error-boundary --routePath=apps/demo/app/routes/my-route.tsx",
9
10
  "description": "Generate an ErrorBoundary for my-route.tsx"
10
11
  }
11
12
  ],
12
13
  "properties": {
14
+ "path": {
15
+ "type": "string",
16
+ "description": "The path to route file relative to the project root."
17
+ },
18
+ "nameAndDirectoryFormat": {
19
+ "description": "Whether to generate the error boundary 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`).",
20
+ "type": "string",
21
+ "enum": ["as-provided", "derived"]
22
+ },
13
23
  "project": {
14
24
  "type": "string",
15
25
  "description": "The name of the project.",
@@ -17,16 +27,8 @@
17
27
  "$source": "projectName"
18
28
  },
19
29
  "x-prompt": "What project contains the route file that this ErrorBoundary is for?",
20
- "pattern": "^[a-zA-Z].*$"
21
- },
22
- "path": {
23
- "type": "string",
24
- "description": "The path to route file relative to the project root."
25
- },
26
- "apiVersion": {
27
- "type": "number",
28
- "description": "Which version of the ErrorBoundary convention to use for the route.",
29
- "default": 1
30
+ "pattern": "^[a-zA-Z].*$",
31
+ "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
32
  },
31
33
  "skipFormat": {
32
34
  "type": "boolean",
@@ -35,5 +37,5 @@
35
37
  "x-priority": "internal"
36
38
  }
37
39
  },
38
- "required": ["project", "path"]
40
+ "required": ["path"]
39
41
  }
@@ -0,0 +1,157 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with jest 1`] = `
4
+ "/* eslint-disable */
5
+ export default {
6
+ setupFilesAfterEnv: ['./src/test-setup.ts'],
7
+ displayName: 'test',
8
+ preset: '../jest.preset.js',
9
+ transform: {
10
+ '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
11
+ '^.+\\\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
12
+ },
13
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
14
+ coverageDirectory: '../coverage/test',
15
+ };
16
+ "
17
+ `;
18
+
19
+ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with jest 2`] = `
20
+ "import { installGlobals } from '@remix-run/node';
21
+ import '@testing-library/jest-dom/matchers';
22
+ installGlobals();
23
+ "
24
+ `;
25
+
26
+ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with vitest 1`] = `
27
+ "import { defineConfig } from 'vite';
28
+ import react from '@vitejs/plugin-react';
29
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
30
+
31
+ export default defineConfig({
32
+ root: __dirname,
33
+ cacheDir: '../node_modules/.vite/test',
34
+
35
+ plugins: [react(), nxViteTsPaths()],
36
+
37
+ // Uncomment this if you are using workers.
38
+ // worker: {
39
+ // plugins: [ nxViteTsPaths() ],
40
+ // },
41
+
42
+ test: {
43
+ setupFiles: ['./src/test-setup.ts'],
44
+ globals: true,
45
+ cache: { dir: '../node_modules/.vitest' },
46
+ environment: 'jsdom',
47
+ include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
48
+ reporters: ['default'],
49
+ coverage: { reportsDirectory: '../coverage/test', provider: 'v8' },
50
+ },
51
+ });
52
+ "
53
+ `;
54
+
55
+ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with vitest 2`] = `
56
+ "import { installGlobals } from '@remix-run/node';
57
+ import '@testing-library/jest-dom/matchers';
58
+ installGlobals();
59
+ "
60
+ `;
61
+
62
+ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided should generate a library correctly 1`] = `
63
+ [
64
+ "test.module.css",
65
+ "test.spec.tsx",
66
+ "test.tsx",
67
+ ]
68
+ `;
69
+
70
+ exports[`Remix Library Generator -projectNameAndRootFormat=as-provided should generate a library correctly 2`] = `
71
+ {
72
+ "@proj/test": [
73
+ "test/src/index.ts",
74
+ ],
75
+ "@proj/test/server": [
76
+ "test/src/server.ts",
77
+ ],
78
+ }
79
+ `;
80
+
81
+ exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with jest 1`] = `
82
+ "/* eslint-disable */
83
+ export default {
84
+ setupFilesAfterEnv: ['./src/test-setup.ts'],
85
+ displayName: 'test',
86
+ preset: '../../jest.preset.js',
87
+ transform: {
88
+ '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
89
+ '^.+\\\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
90
+ },
91
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
92
+ coverageDirectory: '../../coverage/libs/test',
93
+ };
94
+ "
95
+ `;
96
+
97
+ exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with jest 2`] = `
98
+ "import { installGlobals } from '@remix-run/node';
99
+ import '@testing-library/jest-dom/matchers';
100
+ installGlobals();
101
+ "
102
+ `;
103
+
104
+ exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with vitest 1`] = `
105
+ "import { defineConfig } from 'vite';
106
+ import react from '@vitejs/plugin-react';
107
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
108
+
109
+ export default defineConfig({
110
+ root: __dirname,
111
+ cacheDir: '../../node_modules/.vite/libs/test',
112
+
113
+ plugins: [react(), nxViteTsPaths()],
114
+
115
+ // Uncomment this if you are using workers.
116
+ // worker: {
117
+ // plugins: [ nxViteTsPaths() ],
118
+ // },
119
+
120
+ test: {
121
+ setupFiles: ['./src/test-setup.ts'],
122
+ globals: true,
123
+ cache: { dir: '../../node_modules/.vitest' },
124
+ environment: 'jsdom',
125
+ include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
126
+ reporters: ['default'],
127
+ coverage: { reportsDirectory: '../../coverage/libs/test', provider: 'v8' },
128
+ },
129
+ });
130
+ "
131
+ `;
132
+
133
+ exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with vitest 2`] = `
134
+ "import { installGlobals } from '@remix-run/node';
135
+ import '@testing-library/jest-dom/matchers';
136
+ installGlobals();
137
+ "
138
+ `;
139
+
140
+ exports[`Remix Library Generator -projectNameAndRootFormat=derived should generate a library correctly 1`] = `
141
+ [
142
+ "test.module.css",
143
+ "test.spec.tsx",
144
+ "test.tsx",
145
+ ]
146
+ `;
147
+
148
+ exports[`Remix Library Generator -projectNameAndRootFormat=derived should generate a library correctly 2`] = `
149
+ {
150
+ "@proj/libs/test": [
151
+ "libs/test/src/index.ts",
152
+ ],
153
+ "@proj/libs/test/server": [
154
+ "libs/test/src/server.ts",
155
+ ],
156
+ }
157
+ `;
@@ -17,4 +17,3 @@ function addTsconfigEntryPoints(tree, options) {
17
17
  });
18
18
  }
19
19
  exports.addTsconfigEntryPoints = addTsconfigEntryPoints;
20
- //# sourceMappingURL=add-tsconfig-entry-points.js.map
@@ -5,22 +5,21 @@ 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
7
  function addUnitTestingSetup(tree, options) {
8
- const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
9
- const pathToTestSetup = (0, devkit_1.joinPathFragments)(projectRoot, 'src/test-setup.ts');
8
+ const pathToTestSetup = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/test-setup.ts');
10
9
  let testSetupFileContents = '';
11
10
  if (tree.exists(pathToTestSetup)) {
12
11
  testSetupFileContents = tree.read(pathToTestSetup, 'utf-8');
13
12
  }
14
13
  tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `${testSetupFileContents}
15
14
  import { installGlobals } from '@remix-run/node';
16
- import "@testing-library/jest-dom/extend-expect";
15
+ import "@testing-library/jest-dom/matchers";
17
16
  installGlobals();`);
18
17
  if (options.unitTestRunner === 'vitest') {
19
- const pathToVitestConfig = (0, devkit_1.joinPathFragments)(projectRoot, `vite.config.ts`);
18
+ const pathToVitestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `vite.config.ts`);
20
19
  (0, testing_config_utils_1.updateViteTestSetup)(tree, pathToVitestConfig, './src/test-setup.ts');
21
20
  }
22
21
  else if (options.unitTestRunner === 'jest') {
23
- const pathToJestConfig = (0, devkit_1.joinPathFragments)(projectRoot, `jest.config.ts`);
22
+ const pathToJestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `jest.config.ts`);
24
23
  (0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, './src/test-setup.ts');
25
24
  }
26
25
  return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
@@ -31,4 +30,3 @@ function addUnitTestingSetup(tree, options) {
31
30
  });
32
31
  }
33
32
  exports.addUnitTestingSetup = addUnitTestingSetup;
34
- //# sourceMappingURL=add-unit-testing.js.map
@@ -5,4 +5,3 @@ tslib_1.__exportStar(require("./add-tsconfig-entry-points"), exports);
5
5
  tslib_1.__exportStar(require("./add-unit-testing"), exports);
6
6
  tslib_1.__exportStar(require("./normalize-options"), exports);
7
7
  tslib_1.__exportStar(require("./update-buildable-config"), exports);
8
- //# sourceMappingURL=index.js.map