@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,74 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxRemixLibrary",
4
+ "title": "Create a Library",
5
+ "description": "Generate a Remix library to help structure workspace and application.",
6
+ "type": "object",
7
+ "examples": [
8
+ {
9
+ "command": "g lib mylib --directory=myapp",
10
+ "description": "Generate libs/myapp/mylib"
11
+ }
12
+ ],
13
+ "properties": {
14
+ "name": {
15
+ "type": "string",
16
+ "description": "Library name",
17
+ "$default": {
18
+ "$source": "argv",
19
+ "index": 0
20
+ },
21
+ "x-prompt": "What name would you like to use for the library?",
22
+ "pattern": "^[a-zA-Z].*$"
23
+ },
24
+ "directory": {
25
+ "type": "string",
26
+ "description": "A directory where the lib is placed.",
27
+ "alias": "dir",
28
+ "x-priority": "important"
29
+ },
30
+ "projectNameAndRootFormat": {
31
+ "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`).",
32
+ "type": "string",
33
+ "enum": ["as-provided", "derived"]
34
+ },
35
+ "tags": {
36
+ "type": "string",
37
+ "description": "Add tags to the library (used for linting)"
38
+ },
39
+ "style": {
40
+ "type": "string",
41
+ "description": "Generate a stylesheet",
42
+ "enum": ["none", "css"],
43
+ "default": "css"
44
+ },
45
+ "buildable": {
46
+ "type": "boolean",
47
+ "description": "Should the library be buildable?",
48
+ "default": false
49
+ },
50
+ "unitTestRunner": {
51
+ "type": "string",
52
+ "enum": ["jest", "vitest", "none"],
53
+ "description": "Test Runner to use for Unit Tests",
54
+ "x-prompt": "What test runner should be used?",
55
+ "default": "vitest"
56
+ },
57
+ "importPath": {
58
+ "type": "string",
59
+ "description": "The library name used to import it, like @myorg/my-awesome-lib"
60
+ },
61
+ "js": {
62
+ "type": "boolean",
63
+ "description": "Generate JavaScript files rather than TypeScript files",
64
+ "default": false
65
+ },
66
+ "skipFormat": {
67
+ "type": "boolean",
68
+ "description": "Skip formatting files after generator runs",
69
+ "default": false,
70
+ "x-priority": "internal"
71
+ }
72
+ },
73
+ "required": ["name"]
74
+ }
@@ -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, 'useLoaderData', '@remix-run/react');
16
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
17
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'LoaderFunctionArgs', '@remix-run/node', {
18
+ typeOnly: true,
19
+ });
20
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
+ export const loader = async ({request}: LoaderFunctionArgs ) => {
22
+ return json({
23
+ message: 'Hello, world!',
24
+ })
25
+ };
26
+
27
+ `);
28
+ const statement = `\nconst data = useLoaderData<typeof loader>();`;
29
+ try {
30
+ (0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
31
+ // eslint-disable-next-line no-empty
32
+ }
33
+ catch (err) {
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": "data-loader",
4
+ "type": "object",
5
+ "description": "Generate an loader 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 loader 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`).",
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
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { MetaSchema } from '../schema';
3
+ export declare function v2MetaGenerator(tree: Tree, schema: MetaSchema): Promise<void>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.v2MetaGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const get_default_export_name_1 = require("../../../utils/get-default-export-name");
6
+ const insert_import_1 = require("../../../utils/insert-import");
7
+ const insert_statement_after_imports_1 = require("../../../utils/insert-statement-after-imports");
8
+ const remix_route_utils_1 = require("../../../utils/remix-route-utils");
9
+ async function v2MetaGenerator(tree, schema) {
10
+ const routeFilePath = schema.nameAndDirectoryFormat === 'as-provided'
11
+ ? schema.path
12
+ : await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
13
+ if (!tree.exists(routeFilePath)) {
14
+ throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
15
+ }
16
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'MetaFunction', '@remix-run/node', {
17
+ typeOnly: true,
18
+ });
19
+ const defaultExportName = (0, get_default_export_name_1.getDefaultExportName)(tree, routeFilePath);
20
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
21
+ export const meta: MetaFunction = () => {
22
+ return [{ title: '${defaultExportName} Route' }];
23
+ };
24
+
25
+ `);
26
+ await (0, devkit_1.formatFiles)(tree);
27
+ }
28
+ exports.v2MetaGenerator = v2MetaGenerator;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { MetaSchema } from './schema';
3
+ export default function (tree: Tree, schema: MetaSchema): Promise<void>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const v2_impl_1 = require("./lib/v2.impl");
4
+ async function default_1(tree, schema) {
5
+ await (0, v2_impl_1.v2MetaGenerator)(tree, schema);
6
+ }
7
+ 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 MetaSchema {
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": "meta",
4
+ "type": "object",
5
+ "description": "Generate a meta function 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 meta function 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`).",
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
+ }
@@ -0,0 +1,11 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { RemixGeneratorSchema } from '../schema';
3
+ export interface NormalizedSchema extends RemixGeneratorSchema {
4
+ appName: string;
5
+ projectRoot: string;
6
+ parsedTags: string[];
7
+ unitTestRunner?: 'jest' | 'none' | 'vitest';
8
+ e2eTestRunner?: 'cypress' | 'none';
9
+ js?: boolean;
10
+ }
11
+ export declare function normalizeOptions(tree: Tree, options: RemixGeneratorSchema): NormalizedSchema;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = void 0;
4
+ function normalizeOptions(tree, options) {
5
+ // There is a bug in Nx core where custom preset args are not passed correctly for boolean values, thus causing the name to be "commit" or "nx-cloud" when not passed.
6
+ // TODO(jack): revert this hack once Nx core is fixed for custom preset args.
7
+ // TODO(philip): presets should probably be using the `appName` flag to name the app, but it's not getting passed down to this generator properly and is always an empty string
8
+ const appName = options.name;
9
+ const projectRoot = `packages/${appName}`;
10
+ const parsedTags = options.tags
11
+ ? options.tags.split(',').map((s) => s.trim())
12
+ : [];
13
+ return {
14
+ ...options,
15
+ appName,
16
+ projectRoot,
17
+ parsedTags,
18
+ };
19
+ }
20
+ exports.normalizeOptions = normalizeOptions;
@@ -0,0 +1,3 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { RemixGeneratorSchema } from './schema';
3
+ export default function (tree: Tree, _options: RemixGeneratorSchema): Promise<GeneratorCallback>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const devkit_2 = require("@nx/devkit");
5
+ const application_impl_1 = require("../application/application.impl");
6
+ const setup_impl_1 = require("../setup/setup.impl");
7
+ const normalize_options_1 = require("./lib/normalize-options");
8
+ async function default_1(tree, _options) {
9
+ const options = (0, normalize_options_1.normalizeOptions)(tree, _options);
10
+ const tasks = [];
11
+ const setupGenTask = await (0, setup_impl_1.default)(tree);
12
+ tasks.push(setupGenTask);
13
+ const nxJson = (0, devkit_1.readNxJson)(tree);
14
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
15
+ nxJson.useInferencePlugins !== false;
16
+ const appGenTask = await (0, application_impl_1.default)(tree, {
17
+ name: options.appName,
18
+ tags: options.tags,
19
+ skipFormat: true,
20
+ rootProject: true,
21
+ unitTestRunner: options.unitTestRunner ?? 'vitest',
22
+ e2eTestRunner: options.e2eTestRunner ?? 'cypress',
23
+ js: options.js ?? false,
24
+ addPlugin: addPluginDefault,
25
+ });
26
+ tasks.push(appGenTask);
27
+ tree.delete('apps');
28
+ tree.delete('libs');
29
+ await (0, devkit_1.formatFiles)(tree);
30
+ return (0, devkit_2.runTasksInSerial)(...tasks);
31
+ }
32
+ exports.default = default_1;
@@ -0,0 +1,4 @@
1
+ export interface RemixGeneratorSchema {
2
+ name: string;
3
+ tags?: string;
4
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "Remix",
4
+ "title": "",
5
+ "type": "object",
6
+ "description": "Generate a Remix application in a standalone workspace. Can be used with `create-nx-workspace --preset=@nx/remix`.",
7
+ "properties": {
8
+ "tags": {
9
+ "type": "string",
10
+ "description": "Add tags to the app (used for linting).",
11
+ "alias": "t"
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,21 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
4
+
5
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
6
+
7
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 4`] = `[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.]`;
8
+
9
+ exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 6`] = `[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.]`;
10
+
11
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
12
+
13
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
14
+
15
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 4`] = `[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.]`;
16
+
17
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 6`] = `[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.]`;
18
+
19
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 7`] = `[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.]`;
20
+
21
+ exports[`resource route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 9`] = `[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.]`;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { RemixRouteSchema } from './schema';
3
+ export default function (tree: Tree, options: RemixRouteSchema): Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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 remix_route_utils_1 = require("../../utils/remix-route-utils");
6
+ const action_impl_1 = require("../action/action.impl");
7
+ const loader_impl_1 = require("../loader/loader.impl");
8
+ async function default_1(tree, options) {
9
+ const { artifactName: name, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
10
+ artifactType: 'resource-route',
11
+ callingGenerator: '@nx/remix:resource-route',
12
+ name: options.path.replace(/^\//, '').replace(/\/$/, ''),
13
+ nameAndDirectoryFormat: options.nameAndDirectoryFormat,
14
+ project: options.project,
15
+ });
16
+ if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
17
+ 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.`);
18
+ }
19
+ const routeFilePath = await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.nameAndDirectoryFormat === 'as-provided'
20
+ ? (0, devkit_1.joinPathFragments)(directory, name)
21
+ : options.path, options.nameAndDirectoryFormat === 'as-provided' ? undefined : projectName, '.ts');
22
+ if (tree.exists(routeFilePath))
23
+ throw new Error(`Path already exists: ${options.path}`);
24
+ if (!options.loader && !options.action)
25
+ throw new Error('The resource route generator requires either `loader` or `action` to be true');
26
+ tree.write(routeFilePath, '');
27
+ if (options.loader) {
28
+ await (0, loader_impl_1.default)(tree, {
29
+ path: routeFilePath,
30
+ nameAndDirectoryFormat: 'as-provided',
31
+ });
32
+ }
33
+ if (options.action) {
34
+ await (0, action_impl_1.default)(tree, {
35
+ path: routeFilePath,
36
+ nameAndDirectoryFormat: 'as-provided',
37
+ });
38
+ }
39
+ await (0, devkit_1.formatFiles)(tree);
40
+ }
41
+ exports.default = default_1;
@@ -0,0 +1,13 @@
1
+ import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
3
+ export interface RemixRouteSchema {
4
+ path: string;
5
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
6
+ action: boolean;
7
+ loader: boolean;
8
+ skipChecks: boolean;
9
+ /**
10
+ * @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v19.
11
+ */
12
+ project?: string;
13
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxRemixResourceRoute",
4
+ "title": "Create a Resource Route",
5
+ "type": "object",
6
+ "description": "Generate a resource route.",
7
+ "examples": [
8
+ {
9
+ "command": "g resource-route 'path/to/page'",
10
+ "description": "Generate resource route at /path/to/page"
11
+ }
12
+ ],
13
+ "properties": {
14
+ "path": {
15
+ "type": "string",
16
+ "description": "The route path or path to the filename of the route.",
17
+ "$default": {
18
+ "$source": "argv",
19
+ "index": 0
20
+ },
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 styles 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`).",
25
+ "type": "string",
26
+ "enum": ["as-provided", "derived"]
27
+ },
28
+ "project": {
29
+ "type": "string",
30
+ "description": "The name of the project.",
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."
33
+ },
34
+ "action": {
35
+ "type": "boolean",
36
+ "description": "Generate an action function",
37
+ "default": false
38
+ },
39
+ "loader": {
40
+ "type": "boolean",
41
+ "description": "Generate a loader function",
42
+ "default": true
43
+ },
44
+ "skipChecks": {
45
+ "type": "boolean",
46
+ "description": "Skip route error detection",
47
+ "default": false
48
+ }
49
+ },
50
+ "required": ["path"]
51
+ }
@@ -0,0 +1,95 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`route --nameAndDirectoryFormat=as-provided should add route component 1`] = `
4
+ "import { useLoaderData, useActionData } from '@remix-run/react';
5
+ import { json } from '@remix-run/node';
6
+ import type {
7
+ LoaderFunctionArgs,
8
+ MetaFunction,
9
+ ActionFunctionArgs,
10
+ LinksFunction,
11
+ } from '@remix-run/node';
12
+
13
+ import stylesUrl from '../../../styles/path/to/example.css';
14
+
15
+ export const links: LinksFunction = () => {
16
+ return [{ rel: 'stylesheet', href: stylesUrl }];
17
+ };
18
+
19
+ export const action = async ({ request }: ActionFunctionArgs) => {
20
+ let formData = await request.formData();
21
+
22
+ return json({ message: formData.toString() }, { status: 200 });
23
+ };
24
+
25
+ export const meta: MetaFunction = () => {
26
+ return [{ title: 'Example Route' }];
27
+ };
28
+
29
+ export const loader = async ({ request }: LoaderFunctionArgs) => {
30
+ return json({
31
+ message: 'Hello, world!',
32
+ });
33
+ };
34
+
35
+ export default function Example() {
36
+ const actionMessage = useActionData<typeof action>();
37
+ const data = useLoaderData<typeof loader>();
38
+
39
+ return <p>Message: {data.message}</p>;
40
+ }
41
+ "
42
+ `;
43
+
44
+ exports[`route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
45
+
46
+ exports[`route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 2`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
47
+
48
+ exports[`route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
49
+
50
+ exports[`route --nameAndDirectoryFormat=derived should add route component 1`] = `
51
+ "import { useLoaderData, useActionData } from '@remix-run/react';
52
+ import { json } from '@remix-run/node';
53
+ import type {
54
+ LoaderFunctionArgs,
55
+ MetaFunction,
56
+ ActionFunctionArgs,
57
+ LinksFunction,
58
+ } from '@remix-run/node';
59
+
60
+ import stylesUrl from '../../../styles/path/to/example.css';
61
+
62
+ export const links: LinksFunction = () => {
63
+ return [{ rel: 'stylesheet', href: stylesUrl }];
64
+ };
65
+
66
+ export const action = async ({ request }: ActionFunctionArgs) => {
67
+ let formData = await request.formData();
68
+
69
+ return json({ message: formData.toString() }, { status: 200 });
70
+ };
71
+
72
+ export const meta: MetaFunction = () => {
73
+ return [{ title: 'PathToExample Route' }];
74
+ };
75
+
76
+ export const loader = async ({ request }: LoaderFunctionArgs) => {
77
+ return json({
78
+ message: 'Hello, world!',
79
+ });
80
+ };
81
+
82
+ export default function PathToExample() {
83
+ const actionMessage = useActionData<typeof action>();
84
+ const data = useLoaderData<typeof loader>();
85
+
86
+ return <p>Message: {data.message}</p>;
87
+ }
88
+ "
89
+ `;
90
+
91
+ exports[`route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
92
+
93
+ exports[`route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 2`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
94
+
95
+ exports[`route --nameAndDirectoryFormat=derived should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { RemixRouteSchema } from './schema';
3
+ export default function (tree: Tree, options: RemixRouteSchema): Promise<void>;