@nx/remix 16.8.2 → 17.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +32 -89
  3. package/executors.json +0 -12
  4. package/generators.d.ts +14 -0
  5. package/generators.js +31 -0
  6. package/generators.json +14 -19
  7. package/index.d.ts +1 -0
  8. package/index.js +5 -0
  9. package/migrations.json +68 -86
  10. package/package.json +44 -12
  11. package/plugin.d.ts +1 -0
  12. package/plugin.js +6 -0
  13. package/plugins/component-testing/index.js +11 -6
  14. package/src/executors/build/build.impl.js +64 -74
  15. package/src/executors/build/schema.json +1 -1
  16. package/src/executors/serve/serve.impl.js +43 -43
  17. package/src/generators/action/action.impl.js +24 -26
  18. package/src/generators/action/schema.d.ts +7 -1
  19. package/src/generators/action/schema.json +11 -8
  20. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1121 -307
  21. package/src/generators/application/application.impl.d.ts +3 -1
  22. package/src/generators/application/application.impl.js +171 -110
  23. package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
  24. package/src/generators/application/files/common/app/root.tsx__tmpl__ +3 -3
  25. package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
  26. package/src/generators/application/files/common/remix.config.js__tmpl__ +13 -7
  27. package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
  28. package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
  29. package/src/generators/application/files/common/tsconfig.json__tmpl__ +20 -14
  30. package/src/generators/application/files/integrated/package.json__tmpl__ +1 -0
  31. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  32. package/src/generators/application/lib/add-e2e.js +68 -0
  33. package/src/generators/application/lib/index.d.ts +1 -0
  34. package/src/generators/application/lib/index.js +1 -1
  35. package/src/generators/application/lib/normalize-options.d.ts +8 -3
  36. package/src/generators/application/lib/normalize-options.js +52 -14
  37. package/src/generators/application/lib/update-unit-test-config.d.ts +1 -1
  38. package/src/generators/application/lib/update-unit-test-config.js +32 -7
  39. package/src/generators/application/schema.d.ts +7 -1
  40. package/src/generators/application/schema.json +17 -11
  41. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +3 -1
  42. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +26 -17
  43. package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
  44. package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +39 -27
  45. package/src/generators/error-boundary/error-boundary.impl.js +6 -15
  46. package/src/generators/error-boundary/lib/add-v2-error-boundary.js +11 -16
  47. package/src/generators/error-boundary/lib/index.d.ts +0 -1
  48. package/src/generators/error-boundary/lib/index.js +0 -2
  49. package/src/generators/error-boundary/lib/normalize-options.d.ts +1 -1
  50. package/src/generators/error-boundary/lib/normalize-options.js +9 -5
  51. package/src/generators/error-boundary/schema.d.ts +7 -2
  52. package/src/generators/error-boundary/schema.json +14 -16
  53. package/src/generators/init/init.d.ts +5 -0
  54. package/src/generators/init/init.js +60 -0
  55. package/src/generators/init/schema.d.ts +7 -0
  56. package/src/generators/init/schema.json +33 -0
  57. package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
  58. package/src/generators/library/lib/add-tsconfig-entry-points.js +0 -1
  59. package/src/generators/library/lib/add-unit-testing.js +5 -7
  60. package/src/generators/library/lib/index.js +0 -1
  61. package/src/generators/library/lib/normalize-options.d.ts +3 -2
  62. package/src/generators/library/lib/normalize-options.js +21 -12
  63. package/src/generators/library/lib/update-buildable-config.js +5 -2
  64. package/src/generators/library/library.impl.d.ts +3 -1
  65. package/src/generators/library/library.impl.js +38 -34
  66. package/src/generators/library/schema.d.ts +3 -0
  67. package/src/generators/library/schema.json +7 -1
  68. package/src/generators/loader/loader.impl.js +24 -26
  69. package/src/generators/loader/schema.d.ts +7 -1
  70. package/src/generators/loader/schema.json +11 -8
  71. package/src/generators/meta/lib/v2.impl.js +14 -16
  72. package/src/generators/meta/meta.impl.js +2 -17
  73. package/src/generators/meta/schema.d.ts +7 -2
  74. package/src/generators/meta/schema.json +11 -12
  75. package/src/generators/preset/lib/normalize-options.js +5 -3
  76. package/src/generators/preset/preset.impl.js +22 -23
  77. package/src/generators/preset/schema.json +2 -1
  78. package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
  79. package/src/generators/resource-route/resource-route.impl.js +32 -26
  80. package/src/generators/resource-route/schema.d.ts +7 -1
  81. package/src/generators/resource-route/schema.json +11 -8
  82. package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
  83. package/src/generators/route/route.impl.js +56 -43
  84. package/src/generators/route/schema.d.ts +7 -1
  85. package/src/generators/route/schema.json +12 -9
  86. package/src/generators/setup/schema.json +2 -1
  87. package/src/generators/setup/setup.impl.js +23 -23
  88. package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +51 -33
  89. package/src/generators/setup-tailwind/lib/index.js +0 -1
  90. package/src/generators/setup-tailwind/lib/update-remix-config.js +3 -7
  91. package/src/generators/setup-tailwind/schema.json +2 -1
  92. package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
  93. package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +15 -27
  94. package/src/generators/storybook-configuration/schema.d.ts +3 -2
  95. package/src/generators/storybook-configuration/schema.json +5 -12
  96. package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +2 -1
  97. package/src/generators/storybook-configuration/storybook-configuration.impl.js +19 -12
  98. package/src/generators/style/schema.d.ts +7 -1
  99. package/src/generators/style/schema.json +13 -10
  100. package/src/generators/style/style.impl.js +32 -24
  101. package/src/generators/utils/update-dependencies.d.ts +2 -0
  102. package/src/generators/utils/update-dependencies.js +21 -0
  103. package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
  104. package/src/plugins/plugin.d.ts +9 -0
  105. package/src/plugins/plugin.js +134 -0
  106. package/src/utils/create-watch-paths.js +8 -13
  107. package/src/utils/get-default-export-name.js +1 -3
  108. package/src/utils/get-default-export.js +0 -1
  109. package/src/utils/insert-import.js +0 -1
  110. package/src/utils/insert-statement-after-imports.js +0 -1
  111. package/src/utils/insert-statement-in-default-function.js +0 -1
  112. package/src/utils/remix-config.d.ts +2 -2
  113. package/src/utils/remix-config.js +34 -11
  114. package/src/utils/remix-route-utils.d.ts +2 -2
  115. package/src/utils/remix-route-utils.js +23 -17
  116. package/src/utils/testing-config-utils.d.ts +3 -2
  117. package/src/utils/testing-config-utils.js +24 -10
  118. package/src/utils/upsert-links-function.js +0 -1
  119. package/src/utils/versions.d.ts +10 -9
  120. package/src/utils/versions.js +15 -15
  121. package/plugins/component-testing/index.js.map +0 -1
  122. package/src/executors/build/build.impl.js.map +0 -1
  123. package/src/executors/build/compat.d.ts +0 -2
  124. package/src/executors/build/compat.js +0 -6
  125. package/src/executors/build/compat.js.map +0 -1
  126. package/src/executors/serve/compat.d.ts +0 -2
  127. package/src/executors/serve/compat.js +0 -6
  128. package/src/executors/serve/compat.js.map +0 -1
  129. package/src/executors/serve/serve.impl.js.map +0 -1
  130. package/src/generators/action/action.impl.js.map +0 -1
  131. package/src/generators/application/application.impl.js.map +0 -1
  132. package/src/generators/application/files/common/app/routes/index.tsx__tmpl__ +0 -32
  133. package/src/generators/application/lib/index.js.map +0 -1
  134. package/src/generators/application/lib/normalize-options.js.map +0 -1
  135. package/src/generators/application/lib/update-unit-test-config.js.map +0 -1
  136. package/src/generators/cypress/cypress.impl.d.ts +0 -3
  137. package/src/generators/cypress/cypress.impl.js +0 -67
  138. package/src/generators/cypress/cypress.impl.js.map +0 -1
  139. package/src/generators/cypress/schema.d.ts +0 -10
  140. package/src/generators/cypress/schema.json +0 -55
  141. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +0 -1
  142. package/src/generators/error-boundary/error-boundary.impl.js.map +0 -1
  143. package/src/generators/error-boundary/lib/add-v1-error-boundary.d.ts +0 -3
  144. package/src/generators/error-boundary/lib/add-v1-error-boundary.js +0 -21
  145. package/src/generators/error-boundary/lib/add-v1-error-boundary.js.map +0 -1
  146. package/src/generators/error-boundary/lib/add-v2-error-boundary.js.map +0 -1
  147. package/src/generators/error-boundary/lib/index.js.map +0 -1
  148. package/src/generators/error-boundary/lib/normalize-options.js.map +0 -1
  149. package/src/generators/library/lib/add-tsconfig-entry-points.js.map +0 -1
  150. package/src/generators/library/lib/add-unit-testing.js.map +0 -1
  151. package/src/generators/library/lib/index.js.map +0 -1
  152. package/src/generators/library/lib/normalize-options.js.map +0 -1
  153. package/src/generators/library/lib/update-buildable-config.js.map +0 -1
  154. package/src/generators/library/library.impl.js.map +0 -1
  155. package/src/generators/loader/loader.impl.js.map +0 -1
  156. package/src/generators/meta/lib/normalize-options.d.ts +0 -3
  157. package/src/generators/meta/lib/normalize-options.js +0 -15
  158. package/src/generators/meta/lib/normalize-options.js.map +0 -1
  159. package/src/generators/meta/lib/v1.impl.d.ts +0 -3
  160. package/src/generators/meta/lib/v1.impl.js +0 -30
  161. package/src/generators/meta/lib/v1.impl.js.map +0 -1
  162. package/src/generators/meta/lib/v2.impl.js.map +0 -1
  163. package/src/generators/meta/meta.impl.js.map +0 -1
  164. package/src/generators/preset/lib/normalize-options.js.map +0 -1
  165. package/src/generators/preset/preset.impl.js.map +0 -1
  166. package/src/generators/resource-route/resource-route.impl.js.map +0 -1
  167. package/src/generators/route/route.impl.js.map +0 -1
  168. package/src/generators/setup/setup.impl.js.map +0 -1
  169. package/src/generators/setup-tailwind/lib/index.js.map +0 -1
  170. package/src/generators/setup-tailwind/lib/update-remix-config.js.map +0 -1
  171. package/src/generators/setup-tailwind/setup-tailwind.impl.js.map +0 -1
  172. package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +0 -1
  173. package/src/generators/style/style.impl.js.map +0 -1
  174. package/src/index.d.ts +0 -15
  175. package/src/index.js +0 -21
  176. package/src/index.js.map +0 -1
  177. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +0 -6
  178. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +0 -45
  179. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +0 -1
  180. package/src/migrations/update-15-8-6/update-remix-env-d.d.ts +0 -6
  181. package/src/migrations/update-15-8-6/update-remix-env-d.js +0 -27
  182. package/src/migrations/update-15-8-6/update-remix-env-d.js.map +0 -1
  183. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  184. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -13
  185. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  186. package/src/utils/create-watch-paths.js.map +0 -1
  187. package/src/utils/get-default-export-name.js.map +0 -1
  188. package/src/utils/get-default-export.js.map +0 -1
  189. package/src/utils/get-remix-projects.d.ts +0 -2
  190. package/src/utils/get-remix-projects.js +0 -15
  191. package/src/utils/get-remix-projects.js.map +0 -1
  192. package/src/utils/insert-import.js.map +0 -1
  193. package/src/utils/insert-statement-after-imports.js.map +0 -1
  194. package/src/utils/insert-statement-in-default-function.js.map +0 -1
  195. package/src/utils/project.d.ts +0 -2
  196. package/src/utils/project.js +0 -15
  197. package/src/utils/project.js.map +0 -1
  198. package/src/utils/remix-config.js.map +0 -1
  199. package/src/utils/remix-route-utils.js.map +0 -1
  200. package/src/utils/testing-config-utils.js.map +0 -1
  201. package/src/utils/upsert-links-function.js.map +0 -1
  202. package/src/utils/versions.js.map +0 -1
@@ -1,65 +1,78 @@
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
+ nameAndDirectoryFormat: 'as-provided',
74
+ });
75
+ }
76
+ await (0, devkit_1.formatFiles)(tree);
63
77
  }
64
78
  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 v19.
13
+ */
14
+ project?: string;
9
15
  }
@@ -1,7 +1,8 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://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,21 +13,23 @@
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",
24
30
  "description": "The name of the project.",
25
- "$default": {
26
- "$source": "projectName"
27
- },
28
- "x-prompt": "What project is this route for?",
29
- "pattern": "^[a-zA-Z].*$"
31
+ "pattern": "^[a-zA-Z].*$",
32
+ "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v19."
30
33
  },
31
34
  "style": {
32
35
  "type": "string",
@@ -55,5 +58,5 @@
55
58
  "default": false
56
59
  }
57
60
  },
58
- "required": ["project", "path"]
61
+ "required": ["path"]
59
62
  }
@@ -1,8 +1,9 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
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
@@ -31,16 +31,18 @@ exports[`setup-tailwind generator should add a js tailwind config to an applicat
31
31
  Scripts,
32
32
  ScrollRestoration,
33
33
  } from '@remix-run/react';
34
- import styles from './tailwind.css';
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
- });
34
+ import twStyles from './tailwind.css';
35
+ export const links = () => [{ rel: 'stylesheet', href: twStyles }];
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 />
@@ -58,28 +60,34 @@ export default function App() {
58
60
  `;
59
61
 
60
62
  exports[`setup-tailwind generator should add a js tailwind config to an application correctly 4`] = `
61
- "/**
63
+ "import { createWatchPaths } from '@nx/remix';
64
+ import { dirname } from 'path';
65
+ import { fileURLToPath } from 'url';
66
+
67
+ const __dirname = dirname(fileURLToPath(import.meta.url));
68
+
69
+ /**
62
70
  * @type {import('@remix-run/dev').AppConfig}
63
71
  */
64
- module.exports = {
72
+ export default {
65
73
  tailwind: true,
66
74
  ignoredRouteFiles: ['**/.*'],
67
- // appDirectory: \\"app\\",
68
- // assetsBuildDirectory: \\"public/build\\",
69
- // serverBuildPath: \\"build/index.js\\",
70
- // publicPath: \\"/build/\\",
71
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
75
+ // appDirectory: "app",
76
+ // assetsBuildDirectory: "public/build",
77
+ // serverBuildPath: "build/index.js",
78
+ // publicPath: "/build/",
79
+ watchPaths: () => createWatchPaths(__dirname),
72
80
  };
73
81
  "
74
82
  `;
75
83
 
76
84
  exports[`setup-tailwind generator should add a tailwind config to an application correctly 1`] = `
77
- "import type { Config } from \\"tailwindcss\\";
85
+ "import type { Config } from "tailwindcss";
78
86
  import { createGlobPatternsForDependencies } from '@nx/react/tailwind';
79
87
 
80
88
  export default {
81
89
  content: [
82
- \\"./app/**/*.{js,jsx,ts,tsx}\\",
90
+ "./app/**/*.{js,jsx,ts,tsx}",
83
91
  ...createGlobPatternsForDependencies(__dirname)
84
92
  ],
85
93
  theme: {
@@ -98,7 +106,7 @@ exports[`setup-tailwind generator should add a tailwind config to an application
98
106
  `;
99
107
 
100
108
  exports[`setup-tailwind generator should add a tailwind config to an application correctly 3`] = `
101
- "import type { LinksFunction, MetaFunction } from '@remix-run/node';
109
+ "import type { MetaFunction, LinksFunction } from '@remix-run/node';
102
110
  import {
103
111
  Links,
104
112
  LiveReload,
@@ -107,18 +115,22 @@ import {
107
115
  Scripts,
108
116
  ScrollRestoration,
109
117
  } from '@remix-run/react';
110
- import styles from './tailwind.css';
111
- export const links: LinksFunction = () => [{ rel: 'stylesheet', href: styles }];
118
+ import twStyles from './tailwind.css';
119
+ export const links: LinksFunction = () => [
120
+ { rel: 'stylesheet', href: twStyles },
121
+ ];
112
122
 
113
- export const meta: MetaFunction = () => ({
114
- charset: 'utf-8',
115
- title: 'New Remix App',
116
- viewport: 'width=device-width,initial-scale=1',
117
- });
123
+ export const meta: MetaFunction = () => [
124
+ {
125
+ charset: 'utf-8',
126
+ title: 'New Remix App',
127
+ viewport: 'width=device-width,initial-scale=1',
128
+ },
129
+ ];
118
130
 
119
131
  export default function App() {
120
132
  return (
121
- <html lang=\\"en\\">
133
+ <html lang="en">
122
134
  <head>
123
135
  <Meta />
124
136
  <Links />
@@ -136,17 +148,23 @@ export default function App() {
136
148
  `;
137
149
 
138
150
  exports[`setup-tailwind generator should add a tailwind config to an application correctly 4`] = `
139
- "/**
151
+ "import { createWatchPaths } from '@nx/remix';
152
+ import { dirname } from 'path';
153
+ import { fileURLToPath } from 'url';
154
+
155
+ const __dirname = dirname(fileURLToPath(import.meta.url));
156
+
157
+ /**
140
158
  * @type {import('@remix-run/dev').AppConfig}
141
159
  */
142
- module.exports = {
160
+ export default {
143
161
  tailwind: true,
144
162
  ignoredRouteFiles: ['**/.*'],
145
- // appDirectory: \\"app\\",
146
- // assetsBuildDirectory: \\"public/build\\",
147
- // serverBuildPath: \\"build/index.js\\",
148
- // publicPath: \\"/build/\\",
149
- watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
163
+ // appDirectory: "app",
164
+ // assetsBuildDirectory: "public/build",
165
+ // serverBuildPath: "build/index.js",
166
+ // publicPath: "/build/",
167
+ watchPaths: () => createWatchPaths(__dirname),
150
168
  };
151
169
  "
152
170
  `;
@@ -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
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateRemixConfig = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
4
  const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ const remix_config_1 = require("../../../utils/remix-config");
6
6
  function updateRemixConfig(tree, projectRoot) {
7
- const pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'remix.config.js');
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.`);
10
- }
7
+ const pathToRemixConfig = (0, remix_config_1.getRemixConfigPathFromProjectRoot)(tree, projectRoot);
11
8
  const fileContents = tree.read(pathToRemixConfig, 'utf-8');
12
- const REMIX_CONFIG_OBJECT_SELECTOR = 'PropertyAccessExpression:has(Identifier[name=module], Identifier[name=exports])~ObjectLiteralExpression';
9
+ const REMIX_CONFIG_OBJECT_SELECTOR = 'ObjectLiteralExpression';
13
10
  const ast = tsquery_1.tsquery.ast(fileContents);
14
11
  const nodes = (0, tsquery_1.tsquery)(ast, REMIX_CONFIG_OBJECT_SELECTOR, {
15
12
  visitAllChildren: true,
@@ -36,4 +33,3 @@ function updateRemixConfig(tree, projectRoot) {
36
33
  tree.write(pathToRemixConfig, updatedFileContents);
37
34
  }
38
35
  exports.updateRemixConfig = updateRemixConfig;
39
- //# sourceMappingURL=update-remix-config.js.map
@@ -1,7 +1,8 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://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, 'twStyles', './tailwind.css', `{ rel: "stylesheet", href: twStyles }`);
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
@@ -3,21 +3,17 @@
3
3
  exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework jest 1`] = `
4
4
  "import type { StorybookConfig } from '@storybook/react-vite';
5
5
 
6
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
7
- import { mergeConfig } from 'vite';
8
-
9
6
  const config: StorybookConfig = {
10
7
  stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
11
8
  addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'],
12
9
  framework: {
13
10
  name: '@storybook/react-vite',
14
- options: {},
11
+ options: {
12
+ builder: {
13
+ viteConfigPath: 'vite.config.ts',
14
+ },
15
+ },
15
16
  },
16
-
17
- viteFinal: async (config) =>
18
- mergeConfig(config, {
19
- plugins: [nxViteTsPaths()],
20
- }),
21
17
  };
22
18
 
23
19
  export default config;
@@ -31,21 +27,17 @@ export default config;
31
27
  exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework none 1`] = `
32
28
  "import type { StorybookConfig } from '@storybook/react-vite';
33
29
 
34
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
35
- import { mergeConfig } from 'vite';
36
-
37
30
  const config: StorybookConfig = {
38
31
  stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
39
32
  addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'],
40
33
  framework: {
41
34
  name: '@storybook/react-vite',
42
- options: {},
35
+ options: {
36
+ builder: {
37
+ viteConfigPath: 'vite.config.ts',
38
+ },
39
+ },
43
40
  },
44
-
45
- viteFinal: async (config) =>
46
- mergeConfig(config, {
47
- plugins: [nxViteTsPaths()],
48
- }),
49
41
  };
50
42
 
51
43
  export default config;
@@ -59,21 +51,17 @@ export default config;
59
51
  exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework vitest 1`] = `
60
52
  "import type { StorybookConfig } from '@storybook/react-vite';
61
53
 
62
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
63
- import { mergeConfig } from 'vite';
64
-
65
54
  const config: StorybookConfig = {
66
55
  stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
67
56
  addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'],
68
57
  framework: {
69
58
  name: '@storybook/react-vite',
70
- options: {},
59
+ options: {
60
+ builder: {
61
+ viteConfigPath: 'vite.config.ts',
62
+ },
63
+ },
71
64
  },
72
-
73
- viteFinal: async (config) =>
74
- mergeConfig(config, {
75
- plugins: [nxViteTsPaths()],
76
- }),
77
65
  };
78
66
 
79
67
  export default config;
@@ -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;
@@ -12,4 +12,5 @@ export interface StorybookConfigurationSchema {
12
12
  ignorePaths?: string[];
13
13
  configureTestRunner?: boolean;
14
14
  configureStaticServe?: boolean;
15
+ addPlugin?: boolean;
15
16
  }
@@ -1,17 +1,14 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxRemixStorybookConfigure",
5
5
  "title": "Remix Storybook Configuration",
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": ["project"]
96
89
  }
@@ -1,3 +1,4 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import type { StorybookConfigurationSchema } from './schema';
3
- export default function remixStorybookConfiguration(tree: Tree, schema: StorybookConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
3
+ export declare function remixStorybookConfiguration(tree: Tree, schema: StorybookConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
4
+ export default function remixStorybookConfigurationInternal(tree: Tree, schema: StorybookConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;