@nx/remix 0.0.0-pr-22179-271588f

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 (163) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +63 -0
  3. package/executors.json +14 -0
  4. package/generators.d.ts +14 -0
  5. package/generators.js +31 -0
  6. package/generators.json +90 -0
  7. package/index.d.ts +1 -0
  8. package/index.js +5 -0
  9. package/migrations.json +107 -0
  10. package/package.json +53 -0
  11. package/plugin.d.ts +1 -0
  12. package/plugin.js +6 -0
  13. package/plugins/component-testing/index.d.ts +30 -0
  14. package/plugins/component-testing/index.js +64 -0
  15. package/src/executors/build/build.impl.d.ts +5 -0
  16. package/src/executors/build/build.impl.js +109 -0
  17. package/src/executors/build/schema.d.ts +7 -0
  18. package/src/executors/build/schema.json +38 -0
  19. package/src/executors/serve/schema.d.ts +9 -0
  20. package/src/executors/serve/schema.json +41 -0
  21. package/src/executors/serve/serve.impl.d.ts +6 -0
  22. package/src/executors/serve/serve.impl.js +77 -0
  23. package/src/generators/action/action.impl.d.ts +3 -0
  24. package/src/generators/action/action.impl.js +39 -0
  25. package/src/generators/action/schema.d.ts +10 -0
  26. package/src/generators/action/schema.json +29 -0
  27. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1487 -0
  28. package/src/generators/application/application.impl.d.ts +5 -0
  29. package/src/generators/application/application.impl.js +198 -0
  30. package/src/generators/application/files/common/README.md__tmpl__ +54 -0
  31. package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
  32. package/src/generators/application/files/common/app/root.tsx__tmpl__ +32 -0
  33. package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
  34. package/src/generators/application/files/common/public/favicon.ico +0 -0
  35. package/src/generators/application/files/common/remix.config.js__tmpl__ +17 -0
  36. package/src/generators/application/files/common/remix.env.d.ts__tmpl__ +2 -0
  37. package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
  38. package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
  39. package/src/generators/application/files/common/tsconfig.json__tmpl__ +24 -0
  40. package/src/generators/application/files/integrated/.gitignore__tmpl__ +4 -0
  41. package/src/generators/application/files/integrated/package.json__tmpl__ +28 -0
  42. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  43. package/src/generators/application/lib/add-e2e.js +66 -0
  44. package/src/generators/application/lib/index.d.ts +3 -0
  45. package/src/generators/application/lib/index.js +6 -0
  46. package/src/generators/application/lib/normalize-options.d.ts +10 -0
  47. package/src/generators/application/lib/normalize-options.js +37 -0
  48. package/src/generators/application/lib/update-unit-test-config.d.ts +2 -0
  49. package/src/generators/application/lib/update-unit-test-config.js +55 -0
  50. package/src/generators/application/schema.d.ts +16 -0
  51. package/src/generators/application/schema.json +68 -0
  52. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +5 -0
  53. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +34 -0
  54. package/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +6 -0
  55. package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
  56. package/src/generators/cypress-component-configuration/schema.json +41 -0
  57. package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +61 -0
  58. package/src/generators/error-boundary/error-boundary.impl.d.ts +3 -0
  59. package/src/generators/error-boundary/error-boundary.impl.js +12 -0
  60. package/src/generators/error-boundary/lib/add-v2-error-boundary.d.ts +3 -0
  61. package/src/generators/error-boundary/lib/add-v2-error-boundary.js +38 -0
  62. package/src/generators/error-boundary/lib/index.d.ts +2 -0
  63. package/src/generators/error-boundary/lib/index.js +5 -0
  64. package/src/generators/error-boundary/lib/normalize-options.d.ts +3 -0
  65. package/src/generators/error-boundary/lib/normalize-options.js +17 -0
  66. package/src/generators/error-boundary/schema.d.ts +11 -0
  67. package/src/generators/error-boundary/schema.json +37 -0
  68. package/src/generators/init/init.d.ts +5 -0
  69. package/src/generators/init/init.js +60 -0
  70. package/src/generators/init/schema.d.ts +7 -0
  71. package/src/generators/init/schema.json +33 -0
  72. package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
  73. package/src/generators/library/lib/add-tsconfig-entry-points.d.ts +3 -0
  74. package/src/generators/library/lib/add-tsconfig-entry-points.js +19 -0
  75. package/src/generators/library/lib/add-unit-testing.d.ts +3 -0
  76. package/src/generators/library/lib/add-unit-testing.js +32 -0
  77. package/src/generators/library/lib/index.d.ts +4 -0
  78. package/src/generators/library/lib/index.js +7 -0
  79. package/src/generators/library/lib/normalize-options.d.ts +7 -0
  80. package/src/generators/library/lib/normalize-options.js +29 -0
  81. package/src/generators/library/lib/update-buildable-config.d.ts +2 -0
  82. package/src/generators/library/lib/update-buildable-config.js +21 -0
  83. package/src/generators/library/library.impl.d.ts +6 -0
  84. package/src/generators/library/library.impl.js +45 -0
  85. package/src/generators/library/schema.d.ts +16 -0
  86. package/src/generators/library/schema.json +74 -0
  87. package/src/generators/loader/loader.impl.d.ts +3 -0
  88. package/src/generators/loader/loader.impl.js +39 -0
  89. package/src/generators/loader/schema.d.ts +10 -0
  90. package/src/generators/loader/schema.json +29 -0
  91. package/src/generators/meta/lib/v2.impl.d.ts +3 -0
  92. package/src/generators/meta/lib/v2.impl.js +28 -0
  93. package/src/generators/meta/meta.impl.d.ts +3 -0
  94. package/src/generators/meta/meta.impl.js +7 -0
  95. package/src/generators/meta/schema.d.ts +10 -0
  96. package/src/generators/meta/schema.json +29 -0
  97. package/src/generators/preset/lib/normalize-options.d.ts +11 -0
  98. package/src/generators/preset/lib/normalize-options.js +20 -0
  99. package/src/generators/preset/preset.impl.d.ts +3 -0
  100. package/src/generators/preset/preset.impl.js +32 -0
  101. package/src/generators/preset/schema.d.ts +4 -0
  102. package/src/generators/preset/schema.json +14 -0
  103. package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
  104. package/src/generators/resource-route/resource-route.impl.d.ts +3 -0
  105. package/src/generators/resource-route/resource-route.impl.js +41 -0
  106. package/src/generators/resource-route/schema.d.ts +13 -0
  107. package/src/generators/resource-route/schema.json +51 -0
  108. package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +95 -0
  109. package/src/generators/route/route.impl.d.ts +3 -0
  110. package/src/generators/route/route.impl.js +78 -0
  111. package/src/generators/route/schema.d.ts +15 -0
  112. package/src/generators/route/schema.json +62 -0
  113. package/src/generators/setup/schema.json +14 -0
  114. package/src/generators/setup/setup.impl.d.ts +2 -0
  115. package/src/generators/setup/setup.impl.js +34 -0
  116. package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +170 -0
  117. package/src/generators/setup-tailwind/files/app/tailwind.css__tpl__ +3 -0
  118. package/src/generators/setup-tailwind/files/tailwind.config.ts__tpl__ +13 -0
  119. package/src/generators/setup-tailwind/lib/index.d.ts +1 -0
  120. package/src/generators/setup-tailwind/lib/index.js +4 -0
  121. package/src/generators/setup-tailwind/lib/update-remix-config.d.ts +2 -0
  122. package/src/generators/setup-tailwind/lib/update-remix-config.js +35 -0
  123. package/src/generators/setup-tailwind/schema.d.ts +5 -0
  124. package/src/generators/setup-tailwind/schema.json +36 -0
  125. package/src/generators/setup-tailwind/setup-tailwind.impl.d.ts +3 -0
  126. package/src/generators/setup-tailwind/setup-tailwind.impl.js +34 -0
  127. package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +73 -0
  128. package/src/generators/storybook-configuration/files/vite.config.ts__tpl__ +15 -0
  129. package/src/generators/storybook-configuration/schema.d.ts +16 -0
  130. package/src/generators/storybook-configuration/schema.json +89 -0
  131. package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +4 -0
  132. package/src/generators/storybook-configuration/storybook-configuration.impl.js +26 -0
  133. package/src/generators/style/schema.d.ts +10 -0
  134. package/src/generators/style/schema.json +36 -0
  135. package/src/generators/style/style.impl.d.ts +3 -0
  136. package/src/generators/style/style.impl.js +61 -0
  137. package/src/generators/utils/update-dependencies.d.ts +2 -0
  138. package/src/generators/utils/update-dependencies.js +21 -0
  139. package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
  140. package/src/plugins/plugin.d.ts +9 -0
  141. package/src/plugins/plugin.js +136 -0
  142. package/src/utils/create-watch-paths.d.ts +8 -0
  143. package/src/utils/create-watch-paths.js +40 -0
  144. package/src/utils/get-default-export-name.d.ts +2 -0
  145. package/src/utils/get-default-export-name.js +8 -0
  146. package/src/utils/get-default-export.d.ts +2 -0
  147. package/src/utils/get-default-export.js +15 -0
  148. package/src/utils/insert-import.d.ts +4 -0
  149. package/src/utils/insert-import.js +54 -0
  150. package/src/utils/insert-statement-after-imports.d.ts +5 -0
  151. package/src/utils/insert-statement-after-imports.js +28 -0
  152. package/src/utils/insert-statement-in-default-function.d.ts +2 -0
  153. package/src/utils/insert-statement-in-default-function.js +23 -0
  154. package/src/utils/remix-config.d.ts +5 -0
  155. package/src/utils/remix-config.js +45 -0
  156. package/src/utils/remix-route-utils.d.ts +13 -0
  157. package/src/utils/remix-route-utils.js +70 -0
  158. package/src/utils/testing-config-utils.d.ts +4 -0
  159. package/src/utils/testing-config-utils.js +79 -0
  160. package/src/utils/upsert-links-function.d.ts +2 -0
  161. package/src/utils/upsert-links-function.js +31 -0
  162. package/src/utils/versions.d.ts +16 -0
  163. package/src/utils/versions.js +28 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "pipe",
4
+ "$schema": "https://json-schema.org/schema",
5
+ "cli": "nx",
6
+ "title": "Remix Build",
7
+ "description": "Build a Remix app.",
8
+ "type": "object",
9
+ "properties": {
10
+ "outputPath": {
11
+ "type": "string",
12
+ "description": "The output path of the generated files.",
13
+ "x-completion-type": "directory",
14
+ "x-priority": "important"
15
+ },
16
+ "includeDevDependenciesInPackageJson": {
17
+ "type": "boolean",
18
+ "description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.",
19
+ "default": false
20
+ },
21
+ "generatePackageJson": {
22
+ "type": "boolean",
23
+ "description": "Generate package.json file in the output folder.",
24
+ "default": false
25
+ },
26
+ "generateLockfile": {
27
+ "type": "boolean",
28
+ "description": "Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match.",
29
+ "default": false
30
+ },
31
+ "sourcemap": {
32
+ "type": "boolean",
33
+ "description": "Generate source maps for production.",
34
+ "default": false
35
+ }
36
+ },
37
+ "required": ["outputPath"]
38
+ }
@@ -0,0 +1,9 @@
1
+ export interface RemixServeSchema {
2
+ port: number;
3
+ devServerPort?: number;
4
+ debug?: boolean;
5
+ command?: string;
6
+ manual?: boolean;
7
+ tlsKey?: string;
8
+ tlsCert?: string;
9
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "pipe",
4
+ "cli": "nx",
5
+ "title": "Remix Serve",
6
+ "description": "Serve a Remix app.",
7
+ "type": "object",
8
+ "properties": {
9
+ "port": {
10
+ "type": "number",
11
+ "description": "Set PORT environment variable that can be used to serve the Remix application.",
12
+ "default": 4200
13
+ },
14
+ "devServerPort": {
15
+ "type": "number",
16
+ "description": "Port to start the dev server on."
17
+ },
18
+ "debug": {
19
+ "type": "boolean",
20
+ "description": "Attach a Node.js inspector.",
21
+ "default": false
22
+ },
23
+ "command": {
24
+ "type": "string",
25
+ "description": "Command used to run your app server."
26
+ },
27
+ "manual": {
28
+ "type": "boolean",
29
+ "description": "Enable manual mode",
30
+ "default": false
31
+ },
32
+ "tlsKey": {
33
+ "type": "string",
34
+ "description": "Path to TLS key (key.pem)."
35
+ },
36
+ "tlsCert": {
37
+ "type": "string",
38
+ "description": "Path to TLS certificate (cert.pem)."
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,6 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import { type RemixServeSchema } from './schema';
3
+ export default function serveExecutor(schema: RemixServeSchema, context: ExecutorContext): AsyncGenerator<{
4
+ success: boolean;
5
+ baseUrl: string;
6
+ }, void, undefined>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
5
+ const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_path_1 = require("node:path");
8
+ function normalizeOptions(schema) {
9
+ return {
10
+ ...schema,
11
+ port: schema.port ?? 4200,
12
+ debug: schema.debug ?? false,
13
+ manual: schema.manual ?? false,
14
+ };
15
+ }
16
+ function buildRemixDevArgs(options) {
17
+ const args = [];
18
+ if (options.command) {
19
+ args.push(`--command=${options.command}`);
20
+ }
21
+ if (options.devServerPort) {
22
+ args.push(`--port=${options.devServerPort}`);
23
+ }
24
+ if (options.debug) {
25
+ args.push(`--debug`);
26
+ }
27
+ if (options.manual) {
28
+ args.push(`--manual`);
29
+ }
30
+ if (options.tlsKey) {
31
+ args.push(`--tls-key=${options.tlsKey}`);
32
+ }
33
+ if (options.tlsCert) {
34
+ args.push(`--tls-cert=${options.tlsCert}`);
35
+ }
36
+ return args;
37
+ }
38
+ async function* serveExecutor(schema, context) {
39
+ const options = normalizeOptions(schema);
40
+ const projectRoot = context.workspace.projects[context.projectName].root;
41
+ const remixBin = require.resolve('@remix-run/dev/dist/cli');
42
+ const args = buildRemixDevArgs(options);
43
+ // Cast to any to overwrite NODE_ENV
44
+ process.env.NODE_ENV = process.env.NODE_ENV
45
+ ? process.env.NODE_ENV
46
+ : 'development';
47
+ process.env.PORT = `${options.port}`;
48
+ yield* (0, async_iterable_1.createAsyncIterable)(async ({ done, next, error }) => {
49
+ const server = (0, node_child_process_1.fork)(remixBin, ['dev', ...args], {
50
+ cwd: (0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot),
51
+ stdio: 'inherit',
52
+ });
53
+ server.once('exit', (code) => {
54
+ if (code === 0) {
55
+ done();
56
+ }
57
+ else {
58
+ error(new Error(`Remix app exited with code ${code}`));
59
+ }
60
+ });
61
+ const killServer = () => {
62
+ if (server.connected) {
63
+ server.kill('SIGTERM');
64
+ }
65
+ };
66
+ process.on('exit', () => killServer());
67
+ process.on('SIGINT', () => killServer());
68
+ process.on('SIGTERM', () => killServer());
69
+ process.on('SIGHUP', () => killServer());
70
+ await (0, wait_for_port_open_1.waitForPortOpen)(options.port);
71
+ next({
72
+ success: true,
73
+ baseUrl: `http://localhost:${options.port}`,
74
+ });
75
+ });
76
+ }
77
+ exports.default = serveExecutor;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { LoaderSchema } from './schema';
3
+ export default function (tree: Tree, schema: LoaderSchema): Promise<void>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const insert_import_1 = require("../../utils/insert-import");
5
+ const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
6
+ const insert_statement_in_default_function_1 = require("../../utils/insert-statement-in-default-function");
7
+ const remix_route_utils_1 = require("../../utils/remix-route-utils");
8
+ async function default_1(tree, schema) {
9
+ const routeFilePath = schema.nameAndDirectoryFormat === 'as-provided'
10
+ ? schema.path
11
+ : await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
12
+ if (!tree.exists(routeFilePath)) {
13
+ throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
14
+ }
15
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'ActionFunctionArgs', '@remix-run/node', {
16
+ typeOnly: true,
17
+ });
18
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
19
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'useActionData', '@remix-run/react');
20
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
+ export const action = async ({ request }: ActionFunctionArgs) => {
22
+ let formData = await request.formData();
23
+
24
+ return json({message: formData.toString()}, { status: 200 });
25
+ };
26
+
27
+ `);
28
+ const statement = `\nconst actionMessage = useActionData<typeof action>();`;
29
+ try {
30
+ (0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
31
+ }
32
+ catch (err) {
33
+ // eslint-disable-next-line no-empty
34
+ }
35
+ finally {
36
+ await (0, devkit_1.formatFiles)(tree);
37
+ }
38
+ }
39
+ exports.default = default_1;
@@ -0,0 +1,10 @@
1
+ import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
3
+ export interface LoaderSchema {
4
+ path: string;
5
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
6
+ /**
7
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v19.
8
+ */
9
+ project?: string;
10
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "action",
4
+ "type": "object",
5
+ "description": "Generate an action for a given route.",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "description": "The route path or path to the filename of the route.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
15
+ },
16
+ "nameAndDirectoryFormat": {
17
+ "description": "Whether to generate the action in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
18
+ "type": "string",
19
+ "enum": ["as-provided", "derived"]
20
+ },
21
+ "project": {
22
+ "type": "string",
23
+ "description": "The name of the project.",
24
+ "pattern": "^[a-zA-Z].*$",
25
+ "x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v19."
26
+ }
27
+ },
28
+ "required": ["path"]
29
+ }