@nx/remix 17.0.0 → 17.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -89
- package/executors.json +0 -12
- package/generators.d.ts +14 -0
- package/generators.js +17 -0
- package/generators.json +3 -9
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/migrations.json +23 -123
- package/package.json +42 -13
- package/plugins/component-testing/index.js +11 -6
- package/src/executors/build/build.impl.js +64 -74
- package/src/executors/serve/serve.impl.js +43 -43
- package/src/generators/action/action.impl.js +24 -26
- package/src/generators/action/schema.d.ts +7 -1
- package/src/generators/action/schema.json +10 -3
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +772 -145
- package/src/generators/application/application.impl.js +181 -131
- package/src/generators/application/files/common/app/root.tsx__tmpl__ +3 -3
- package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
- package/src/generators/application/files/integrated/package.json__tmpl__ +1 -0
- package/src/generators/application/lib/index.js +0 -1
- package/src/generators/application/lib/normalize-options.d.ts +5 -3
- package/src/generators/application/lib/normalize-options.js +23 -15
- package/src/generators/application/lib/update-unit-test-config.js +7 -2
- package/src/generators/application/schema.d.ts +5 -0
- package/src/generators/application/schema.json +14 -9
- package/src/generators/cypress/cypress.impl.js +52 -42
- package/src/generators/cypress/schema.d.ts +5 -1
- package/src/generators/cypress/schema.json +6 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +13 -18
- package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +39 -27
- package/src/generators/error-boundary/error-boundary.impl.js +6 -15
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js +11 -16
- package/src/generators/error-boundary/lib/index.d.ts +0 -1
- package/src/generators/error-boundary/lib/index.js +0 -2
- package/src/generators/error-boundary/lib/normalize-options.d.ts +1 -1
- package/src/generators/error-boundary/lib/normalize-options.js +9 -5
- package/src/generators/error-boundary/schema.d.ts +7 -2
- package/src/generators/error-boundary/schema.json +14 -12
- package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.js +0 -1
- package/src/generators/library/lib/add-unit-testing.js +4 -6
- package/src/generators/library/lib/index.js +0 -1
- package/src/generators/library/lib/normalize-options.d.ts +2 -1
- package/src/generators/library/lib/normalize-options.js +16 -12
- package/src/generators/library/lib/update-buildable-config.js +5 -2
- package/src/generators/library/library.impl.js +29 -32
- package/src/generators/library/schema.d.ts +2 -0
- package/src/generators/library/schema.json +6 -0
- package/src/generators/loader/loader.impl.js +24 -26
- package/src/generators/loader/schema.d.ts +7 -1
- package/src/generators/loader/schema.json +10 -3
- package/src/generators/meta/lib/v2.impl.js +14 -16
- package/src/generators/meta/meta.impl.js +2 -17
- package/src/generators/meta/schema.d.ts +7 -2
- package/src/generators/meta/schema.json +10 -7
- package/src/generators/preset/lib/normalize-options.js +5 -3
- package/src/generators/preset/preset.impl.js +18 -23
- package/src/generators/preset/schema.json +1 -0
- package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
- package/src/generators/resource-route/resource-route.impl.js +32 -26
- package/src/generators/resource-route/schema.d.ts +7 -1
- package/src/generators/resource-route/schema.json +10 -3
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
- package/src/generators/route/route.impl.js +55 -43
- package/src/generators/route/schema.d.ts +7 -1
- package/src/generators/route/schema.json +11 -4
- package/src/generators/setup/schema.json +1 -0
- package/src/generators/setup/setup.impl.js +23 -23
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +27 -23
- package/src/generators/setup-tailwind/lib/index.js +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js +2 -3
- package/src/generators/setup-tailwind/schema.json +1 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
- package/src/generators/storybook-configuration/schema.d.ts +1 -1
- package/src/generators/storybook-configuration/schema.json +4 -11
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +8 -13
- package/src/generators/style/schema.d.ts +7 -1
- package/src/generators/style/schema.json +12 -5
- package/src/generators/style/style.impl.js +32 -24
- package/src/utils/create-watch-paths.js +8 -13
- package/src/utils/get-default-export-name.js +1 -3
- package/src/utils/get-default-export.js +0 -1
- package/src/utils/insert-import.js +0 -1
- package/src/utils/insert-statement-after-imports.js +0 -1
- package/src/utils/insert-statement-in-default-function.js +0 -1
- package/src/utils/remix-config.d.ts +1 -2
- package/src/utils/remix-config.js +8 -9
- package/src/utils/remix-route-utils.d.ts +2 -2
- package/src/utils/remix-route-utils.js +23 -17
- package/src/utils/testing-config-utils.js +0 -1
- package/src/utils/upsert-links-function.js +0 -1
- package/src/utils/versions.d.ts +9 -8
- package/src/utils/versions.js +14 -14
- package/plugins/component-testing/index.js.map +0 -1
- package/src/executors/build/build.impl.js.map +0 -1
- package/src/executors/build/compat.d.ts +0 -2
- package/src/executors/build/compat.js +0 -6
- package/src/executors/build/compat.js.map +0 -1
- package/src/executors/serve/compat.d.ts +0 -2
- package/src/executors/serve/compat.js +0 -6
- package/src/executors/serve/compat.js.map +0 -1
- package/src/executors/serve/serve.impl.js.map +0 -1
- package/src/generators/action/action.impl.js.map +0 -1
- package/src/generators/application/application.impl.js.map +0 -1
- package/src/generators/application/lib/index.js.map +0 -1
- package/src/generators/application/lib/normalize-options.js.map +0 -1
- package/src/generators/application/lib/update-unit-test-config.js.map +0 -1
- package/src/generators/cypress/cypress.impl.js.map +0 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +0 -1
- package/src/generators/error-boundary/error-boundary.impl.js.map +0 -1
- package/src/generators/error-boundary/lib/add-v1-error-boundary.d.ts +0 -3
- package/src/generators/error-boundary/lib/add-v1-error-boundary.js +0 -21
- package/src/generators/error-boundary/lib/add-v1-error-boundary.js.map +0 -1
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js.map +0 -1
- package/src/generators/error-boundary/lib/index.js.map +0 -1
- package/src/generators/error-boundary/lib/normalize-options.js.map +0 -1
- package/src/generators/library/lib/add-tsconfig-entry-points.js.map +0 -1
- package/src/generators/library/lib/add-unit-testing.js.map +0 -1
- package/src/generators/library/lib/index.js.map +0 -1
- package/src/generators/library/lib/normalize-options.js.map +0 -1
- package/src/generators/library/lib/update-buildable-config.js.map +0 -1
- package/src/generators/library/library.impl.js.map +0 -1
- package/src/generators/loader/loader.impl.js.map +0 -1
- package/src/generators/meta/lib/normalize-options.d.ts +0 -3
- package/src/generators/meta/lib/normalize-options.js +0 -15
- package/src/generators/meta/lib/normalize-options.js.map +0 -1
- package/src/generators/meta/lib/v1.impl.d.ts +0 -3
- package/src/generators/meta/lib/v1.impl.js +0 -30
- package/src/generators/meta/lib/v1.impl.js.map +0 -1
- package/src/generators/meta/lib/v2.impl.js.map +0 -1
- package/src/generators/meta/meta.impl.js.map +0 -1
- package/src/generators/preset/lib/normalize-options.js.map +0 -1
- package/src/generators/preset/preset.impl.js.map +0 -1
- package/src/generators/resource-route/resource-route.impl.js.map +0 -1
- package/src/generators/route/route.impl.js.map +0 -1
- package/src/generators/setup/setup.impl.js.map +0 -1
- package/src/generators/setup-tailwind/lib/index.js.map +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js.map +0 -1
- package/src/generators/setup-tailwind/setup-tailwind.impl.js.map +0 -1
- package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +0 -1
- package/src/generators/style/style.impl.js.map +0 -1
- package/src/index.d.ts +0 -15
- package/src/index.js +0 -21
- package/src/index.js.map +0 -1
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +0 -6
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +0 -45
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +0 -1
- package/src/migrations/update-15-8-6/update-remix-env-d.d.ts +0 -6
- package/src/migrations/update-15-8-6/update-remix-env-d.js +0 -27
- package/src/migrations/update-15-8-6/update-remix-env-d.js.map +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -13
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
- package/src/utils/create-watch-paths.js.map +0 -1
- package/src/utils/get-default-export-name.js.map +0 -1
- package/src/utils/get-default-export.js.map +0 -1
- package/src/utils/get-remix-projects.d.ts +0 -2
- package/src/utils/get-remix-projects.js +0 -15
- package/src/utils/get-remix-projects.js.map +0 -1
- package/src/utils/insert-import.js.map +0 -1
- package/src/utils/insert-statement-after-imports.js.map +0 -1
- package/src/utils/insert-statement-in-default-function.js.map +0 -1
- package/src/utils/project.d.ts +0 -2
- package/src/utils/project.js +0 -15
- package/src/utils/project.js.map +0 -1
- package/src/utils/remix-config.js.map +0 -1
- package/src/utils/remix-route-utils.js.map +0 -1
- package/src/utils/testing-config-utils.js.map +0 -1
- package/src/utils/upsert-links-function.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
- /package/src/generators/application/files/common/app/routes/{index.tsx__tmpl__ → _index.tsx__tmpl__} +0 -0
- /package/src/generators/application/files/common/{remix.config.js__tmpl__ → remix.config.cjs__tmpl__} +0 -0
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`route should add route component 1`] = `
|
|
4
|
-
"import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
8
|
MetaFunction,
|
|
9
|
+
ActionFunctionArgs,
|
|
10
|
+
LinksFunction,
|
|
9
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';
|
|
10
52
|
import { json } from '@remix-run/node';
|
|
11
|
-
import {
|
|
53
|
+
import type {
|
|
54
|
+
LoaderFunctionArgs,
|
|
55
|
+
MetaFunction,
|
|
56
|
+
ActionFunctionArgs,
|
|
57
|
+
LinksFunction,
|
|
58
|
+
} from '@remix-run/node';
|
|
12
59
|
|
|
13
60
|
import stylesUrl from '../../../styles/path/to/example.css';
|
|
14
61
|
|
|
@@ -16,17 +63,17 @@ export const links: LinksFunction = () => {
|
|
|
16
63
|
return [{ rel: 'stylesheet', href: stylesUrl }];
|
|
17
64
|
};
|
|
18
65
|
|
|
19
|
-
export const action = async ({ request }:
|
|
66
|
+
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
20
67
|
let formData = await request.formData();
|
|
21
68
|
|
|
22
69
|
return json({ message: formData.toString() }, { status: 200 });
|
|
23
70
|
};
|
|
24
71
|
|
|
25
72
|
export const meta: MetaFunction = () => {
|
|
26
|
-
return { title: 'PathToExample Route' };
|
|
73
|
+
return [{ title: 'PathToExample Route' }];
|
|
27
74
|
};
|
|
28
75
|
|
|
29
|
-
export const loader = async ({ request }:
|
|
76
|
+
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|
30
77
|
return json({
|
|
31
78
|
message: 'Hello, world!',
|
|
32
79
|
});
|
|
@@ -40,3 +87,9 @@ export default function PathToExample() {
|
|
|
40
87
|
}
|
|
41
88
|
"
|
|
42
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.]`;
|
|
@@ -1,65 +1,77 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
48
|
+
: `return (<p>${componentName} works!</p>)`}
|
|
35
49
|
}
|
|
36
50
|
`);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
});
|
|
74
|
+
}
|
|
75
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
63
76
|
}
|
|
64
77
|
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 v18.
|
|
13
|
+
*/
|
|
14
|
+
project?: string;
|
|
9
15
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"$schema": "http://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,12 +13,17 @@
|
|
|
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",
|
|
@@ -26,7 +32,8 @@
|
|
|
26
32
|
"$source": "projectName"
|
|
27
33
|
},
|
|
28
34
|
"x-prompt": "What project is this route for?",
|
|
29
|
-
"pattern": "^[a-zA-Z].*$"
|
|
35
|
+
"pattern": "^[a-zA-Z].*$",
|
|
36
|
+
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v18."
|
|
30
37
|
},
|
|
31
38
|
"style": {
|
|
32
39
|
"type": "string",
|
|
@@ -55,5 +62,5 @@
|
|
|
55
62
|
"default": false
|
|
56
63
|
}
|
|
57
64
|
},
|
|
58
|
-
"required": ["
|
|
65
|
+
"required": ["path"]
|
|
59
66
|
}
|
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
@@ -33,14 +33,16 @@ exports[`setup-tailwind generator should add a js tailwind config to an applicat
|
|
|
33
33
|
} from '@remix-run/react';
|
|
34
34
|
import styles from './tailwind.css';
|
|
35
35
|
export const links = () => [{ rel: 'stylesheet', href: styles }];
|
|
36
|
-
export const meta = () =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
45
|
+
<html lang="en">
|
|
44
46
|
<head>
|
|
45
47
|
<Meta />
|
|
46
48
|
<Links />
|
|
@@ -64,22 +66,22 @@ exports[`setup-tailwind generator should add a js tailwind config to an applicat
|
|
|
64
66
|
module.exports = {
|
|
65
67
|
tailwind: true,
|
|
66
68
|
ignoredRouteFiles: ['**/.*'],
|
|
67
|
-
// appDirectory:
|
|
68
|
-
// assetsBuildDirectory:
|
|
69
|
-
// serverBuildPath:
|
|
70
|
-
// publicPath:
|
|
69
|
+
// appDirectory: "app",
|
|
70
|
+
// assetsBuildDirectory: "public/build",
|
|
71
|
+
// serverBuildPath: "build/index.js",
|
|
72
|
+
// publicPath: "/build/",
|
|
71
73
|
watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
|
|
72
74
|
};
|
|
73
75
|
"
|
|
74
76
|
`;
|
|
75
77
|
|
|
76
78
|
exports[`setup-tailwind generator should add a tailwind config to an application correctly 1`] = `
|
|
77
|
-
"import type { Config } from
|
|
79
|
+
"import type { Config } from "tailwindcss";
|
|
78
80
|
import { createGlobPatternsForDependencies } from '@nx/react/tailwind';
|
|
79
81
|
|
|
80
82
|
export default {
|
|
81
83
|
content: [
|
|
82
|
-
|
|
84
|
+
"./app/**/*.{js,jsx,ts,tsx}",
|
|
83
85
|
...createGlobPatternsForDependencies(__dirname)
|
|
84
86
|
],
|
|
85
87
|
theme: {
|
|
@@ -98,7 +100,7 @@ exports[`setup-tailwind generator should add a tailwind config to an application
|
|
|
98
100
|
`;
|
|
99
101
|
|
|
100
102
|
exports[`setup-tailwind generator should add a tailwind config to an application correctly 3`] = `
|
|
101
|
-
"import type {
|
|
103
|
+
"import type { MetaFunction, LinksFunction } from '@remix-run/node';
|
|
102
104
|
import {
|
|
103
105
|
Links,
|
|
104
106
|
LiveReload,
|
|
@@ -110,15 +112,17 @@ import {
|
|
|
110
112
|
import styles from './tailwind.css';
|
|
111
113
|
export const links: LinksFunction = () => [{ rel: 'stylesheet', href: styles }];
|
|
112
114
|
|
|
113
|
-
export const meta: MetaFunction = () =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
export const meta: MetaFunction = () => [
|
|
116
|
+
{
|
|
117
|
+
charset: 'utf-8',
|
|
118
|
+
title: 'New Remix App',
|
|
119
|
+
viewport: 'width=device-width,initial-scale=1',
|
|
120
|
+
},
|
|
121
|
+
];
|
|
118
122
|
|
|
119
123
|
export default function App() {
|
|
120
124
|
return (
|
|
121
|
-
<html lang
|
|
125
|
+
<html lang="en">
|
|
122
126
|
<head>
|
|
123
127
|
<Meta />
|
|
124
128
|
<Links />
|
|
@@ -142,10 +146,10 @@ exports[`setup-tailwind generator should add a tailwind config to an application
|
|
|
142
146
|
module.exports = {
|
|
143
147
|
tailwind: true,
|
|
144
148
|
ignoredRouteFiles: ['**/.*'],
|
|
145
|
-
// appDirectory:
|
|
146
|
-
// assetsBuildDirectory:
|
|
147
|
-
// serverBuildPath:
|
|
148
|
-
// publicPath:
|
|
149
|
+
// appDirectory: "app",
|
|
150
|
+
// assetsBuildDirectory: "public/build",
|
|
151
|
+
// serverBuildPath: "build/index.js",
|
|
152
|
+
// publicPath: "/build/",
|
|
149
153
|
watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
|
|
150
154
|
};
|
|
151
155
|
"
|
|
@@ -4,9 +4,9 @@ exports.updateRemixConfig = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
6
|
function updateRemixConfig(tree, projectRoot) {
|
|
7
|
-
const pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'remix.config.
|
|
7
|
+
const pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'remix.config.cjs');
|
|
8
8
|
if (!tree.exists(pathToRemixConfig)) {
|
|
9
|
-
throw new Error(`Could not find "${pathToRemixConfig}". Please ensure a "remix.config.
|
|
9
|
+
throw new Error(`Could not find "${pathToRemixConfig}". Please ensure a "remix.config.cjs" exists at the root of your project.`);
|
|
10
10
|
}
|
|
11
11
|
const fileContents = tree.read(pathToRemixConfig, 'utf-8');
|
|
12
12
|
const REMIX_CONFIG_OBJECT_SELECTOR = 'PropertyAccessExpression:has(Identifier[name=module], Identifier[name=exports])~ObjectLiteralExpression';
|
|
@@ -36,4 +36,3 @@ function updateRemixConfig(tree, projectRoot) {
|
|
|
36
36
|
tree.write(pathToRemixConfig, updatedFileContents);
|
|
37
37
|
}
|
|
38
38
|
exports.updateRemixConfig = updateRemixConfig;
|
|
39
|
-
//# sourceMappingURL=update-remix-config.js.map
|
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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, 'styles', './tailwind.css', `{ rel: "stylesheet", href: styles }`);
|
|
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
|
|
@@ -6,12 +6,9 @@
|
|
|
6
6
|
"description": "Set up Storybook for a Remix library.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
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": ["name"]
|
|
96
89
|
}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
7
|
-
function remixStorybookConfiguration(tree, schema) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const task = yield storybookConfigurationGenerator(tree, schema);
|
|
15
|
-
return task;
|
|
16
|
-
});
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
async function remixStorybookConfiguration(tree, schema) {
|
|
7
|
+
const { root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
8
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(root, 'vite.config.ts'))) {
|
|
9
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), root, { tpl: '' });
|
|
10
|
+
}
|
|
11
|
+
const task = await (0, react_1.storybookConfigurationGenerator)(tree, schema);
|
|
12
|
+
return task;
|
|
17
13
|
}
|
|
18
14
|
exports.default = remixStorybookConfiguration;
|
|
19
|
-
//# sourceMappingURL=storybook-configuration.impl.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface RemixStyleSchema {
|
|
2
|
-
project: string;
|
|
3
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 v18.
|
|
8
|
+
*/
|
|
9
|
+
project?: string;
|
|
4
10
|
}
|