@nx/remix 17.0.0 → 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.
- package/LICENSE +1 -1
- package/README.md +32 -89
- package/executors.json +0 -12
- package/generators.d.ts +14 -0
- package/generators.js +31 -0
- package/generators.json +14 -19
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/migrations.json +68 -86
- package/package.json +44 -13
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/component-testing/index.js +11 -6
- package/src/executors/build/build.impl.js +64 -74
- package/src/executors/build/schema.json +1 -1
- 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 +11 -8
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1119 -305
- package/src/generators/application/application.impl.d.ts +3 -1
- package/src/generators/application/application.impl.js +171 -110
- package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
- package/src/generators/application/files/common/app/root.tsx__tmpl__ +3 -3
- package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
- package/src/generators/application/files/common/remix.config.js__tmpl__ +13 -7
- package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
- package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +20 -14
- package/src/generators/application/files/integrated/package.json__tmpl__ +1 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +68 -0
- package/src/generators/application/lib/index.d.ts +1 -0
- package/src/generators/application/lib/index.js +1 -1
- package/src/generators/application/lib/normalize-options.d.ts +8 -3
- package/src/generators/application/lib/normalize-options.js +52 -14
- package/src/generators/application/lib/update-unit-test-config.d.ts +1 -1
- package/src/generators/application/lib/update-unit-test-config.js +32 -7
- package/src/generators/application/schema.d.ts +7 -1
- package/src/generators/application/schema.json +17 -11
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +3 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +26 -17
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- 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 -16
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +60 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- 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 +5 -7
- package/src/generators/library/lib/index.js +0 -1
- package/src/generators/library/lib/normalize-options.d.ts +3 -2
- package/src/generators/library/lib/normalize-options.js +21 -11
- package/src/generators/library/lib/update-buildable-config.js +5 -2
- package/src/generators/library/library.impl.d.ts +3 -1
- package/src/generators/library/library.impl.js +37 -33
- package/src/generators/library/schema.d.ts +3 -0
- package/src/generators/library/schema.json +7 -1
- package/src/generators/loader/loader.impl.js +24 -26
- package/src/generators/loader/schema.d.ts +7 -1
- package/src/generators/loader/schema.json +11 -8
- 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 +11 -12
- package/src/generators/preset/lib/normalize-options.js +5 -3
- package/src/generators/preset/preset.impl.js +22 -23
- package/src/generators/preset/schema.json +2 -1
- 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 +11 -8
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
- package/src/generators/route/route.impl.js +56 -43
- package/src/generators/route/schema.d.ts +7 -1
- package/src/generators/route/schema.json +12 -9
- package/src/generators/setup/schema.json +2 -1
- package/src/generators/setup/setup.impl.js +23 -23
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +51 -33
- package/src/generators/setup-tailwind/lib/index.js +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js +3 -7
- package/src/generators/setup-tailwind/schema.json +2 -1
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
- package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +15 -27
- package/src/generators/storybook-configuration/schema.d.ts +2 -1
- package/src/generators/storybook-configuration/schema.json +5 -12
- package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +2 -1
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +19 -12
- package/src/generators/style/schema.d.ts +7 -1
- package/src/generators/style/schema.json +13 -10
- package/src/generators/style/style.impl.js +32 -24
- package/src/generators/utils/update-dependencies.d.ts +2 -0
- package/src/generators/utils/update-dependencies.js +21 -0
- package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
- package/src/plugins/plugin.d.ts +9 -0
- package/src/plugins/plugin.js +134 -0
- 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 +2 -2
- package/src/utils/remix-config.js +34 -11
- 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.d.ts +3 -2
- package/src/utils/testing-config-utils.js +24 -10
- package/src/utils/upsert-links-function.js +0 -1
- package/src/utils/versions.d.ts +10 -9
- package/src/utils/versions.js +15 -15
- 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/files/common/app/routes/index.tsx__tmpl__ +0 -32
- 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.d.ts +0 -3
- package/src/generators/cypress/cypress.impl.js +0 -67
- package/src/generators/cypress/cypress.impl.js.map +0 -1
- package/src/generators/cypress/schema.d.ts +0 -10
- package/src/generators/cypress/schema.json +0 -55
- 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
|
@@ -20,24 +20,19 @@ function addV2ErrorBoundary(tree, options) {
|
|
|
20
20
|
<p>{error.data.message}</p>
|
|
21
21
|
</div>
|
|
22
22
|
);
|
|
23
|
+
} else if (error instanceof Error) {
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<h1>Error</h1>
|
|
27
|
+
<p>{error.message}</p>
|
|
28
|
+
<p>The stack trace is:</p>
|
|
29
|
+
<pre>{error.stack}</pre>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
} else {
|
|
33
|
+
return <h1>Unknown Error</h1>;
|
|
23
34
|
}
|
|
24
|
-
|
|
25
|
-
// Don't forget to typecheck with your own logic.
|
|
26
|
-
// Any value can be thrown, not just errors!
|
|
27
|
-
let errorMessage = "Unknown error";
|
|
28
|
-
// if (isDefinitelyAnError(error)) {
|
|
29
|
-
// errorMessage = error.message;
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div>
|
|
34
|
-
<h1>Uh oh ...</h1>
|
|
35
|
-
<p>Something went wrong.</p>
|
|
36
|
-
<pre>{errorMessage}</pre>
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
35
|
}
|
|
40
36
|
`);
|
|
41
37
|
}
|
|
42
38
|
exports.addV2ErrorBoundary = addV2ErrorBoundary;
|
|
43
|
-
//# sourceMappingURL=add-v2-error-boundary.js.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./add-v1-error-boundary"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./add-v2-error-boundary"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
2
|
import type { ErrorBoundarySchema } from '../schema';
|
|
3
|
-
export declare function normalizeOptions(tree: Tree, schema: ErrorBoundarySchema): ErrorBoundarySchema
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, schema: ErrorBoundarySchema): Promise<ErrorBoundarySchema>;
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
4
|
const remix_route_utils_1 = require("../../../utils/remix-route-utils");
|
|
5
|
-
function normalizeOptions(tree, schema) {
|
|
6
|
-
const pathToRouteFile =
|
|
5
|
+
async function normalizeOptions(tree, schema) {
|
|
6
|
+
const pathToRouteFile = schema.nameAndDirectoryFormat === 'as-provided'
|
|
7
|
+
? schema.path
|
|
8
|
+
: await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
|
|
7
9
|
if (!tree.exists(pathToRouteFile)) {
|
|
8
|
-
throw new Error(`Route file specified does not exist "${pathToRouteFile}". Please ensure you pass a correct path to the file
|
|
10
|
+
throw new Error(`Route file specified does not exist "${pathToRouteFile}". Please ensure you pass a correct path to the file.`);
|
|
9
11
|
}
|
|
10
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
...schema,
|
|
14
|
+
path: pathToRouteFile,
|
|
15
|
+
};
|
|
11
16
|
}
|
|
12
17
|
exports.normalizeOptions = normalizeOptions;
|
|
13
|
-
//# sourceMappingURL=normalize-options.js.map
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface ErrorBoundarySchema {
|
|
2
|
-
project: string;
|
|
3
4
|
path: string;
|
|
4
|
-
apiVersion: number;
|
|
5
5
|
skipFormat?: false;
|
|
6
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v19.
|
|
9
|
+
*/
|
|
10
|
+
project?: string;
|
|
6
11
|
}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxRemixErrorBoundary",
|
|
4
4
|
"title": "Create an ErrorBoundary for a Route",
|
|
5
|
+
"description": "Generate an ErrorBoundary for a given route.",
|
|
5
6
|
"type": "object",
|
|
6
7
|
"examples": [
|
|
7
8
|
{
|
|
8
|
-
"command": "g error-boundary --
|
|
9
|
+
"command": "g error-boundary --routePath=apps/demo/app/routes/my-route.tsx",
|
|
9
10
|
"description": "Generate an ErrorBoundary for my-route.tsx"
|
|
10
11
|
}
|
|
11
12
|
],
|
|
12
13
|
"properties": {
|
|
13
|
-
"project": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "The name of the project.",
|
|
16
|
-
"$default": {
|
|
17
|
-
"$source": "projectName"
|
|
18
|
-
},
|
|
19
|
-
"x-prompt": "What project contains the route file that this ErrorBoundary is for?",
|
|
20
|
-
"pattern": "^[a-zA-Z].*$"
|
|
21
|
-
},
|
|
22
14
|
"path": {
|
|
23
15
|
"type": "string",
|
|
24
16
|
"description": "The path to route file relative to the project root."
|
|
25
17
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
18
|
+
"nameAndDirectoryFormat": {
|
|
19
|
+
"description": "Whether to generate the error boundary in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": ["as-provided", "derived"]
|
|
22
|
+
},
|
|
23
|
+
"project": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "The name of the project.",
|
|
26
|
+
"pattern": "^[a-zA-Z].*$",
|
|
27
|
+
"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
28
|
},
|
|
31
29
|
"skipFormat": {
|
|
32
30
|
"type": "boolean",
|
|
@@ -35,5 +33,5 @@
|
|
|
35
33
|
"x-priority": "internal"
|
|
36
34
|
}
|
|
37
35
|
},
|
|
38
|
-
"required": ["
|
|
36
|
+
"required": ["path"]
|
|
39
37
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Tree, GeneratorCallback } from '@nx/devkit';
|
|
2
|
+
import { type Schema } from './schema';
|
|
3
|
+
export declare function remixInitGenerator(tree: Tree, options: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function remixInitGeneratorInternal(tree: Tree, options: Schema): Promise<GeneratorCallback>;
|
|
5
|
+
export default remixInitGenerator;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remixInitGeneratorInternal = exports.remixInitGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
|
+
const plugin_1 = require("../../plugins/plugin");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
8
|
+
function addPlugin(tree) {
|
|
9
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
10
|
+
nxJson.plugins ??= [];
|
|
11
|
+
for (const plugin of nxJson.plugins) {
|
|
12
|
+
if (typeof plugin === 'string'
|
|
13
|
+
? plugin === '@nx/remix/plugin'
|
|
14
|
+
: plugin.plugin === '@nx/remix/plugin') {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
nxJson.plugins.push({
|
|
19
|
+
plugin: '@nx/remix/plugin',
|
|
20
|
+
options: {
|
|
21
|
+
buildTargetName: 'build',
|
|
22
|
+
devTargetName: 'dev',
|
|
23
|
+
startTargetName: 'start',
|
|
24
|
+
typecheckTargetName: 'typecheck',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
28
|
+
}
|
|
29
|
+
function remixInitGenerator(tree, options) {
|
|
30
|
+
return remixInitGeneratorInternal(tree, { addPlugin: false, ...options });
|
|
31
|
+
}
|
|
32
|
+
exports.remixInitGenerator = remixInitGenerator;
|
|
33
|
+
async function remixInitGeneratorInternal(tree, options) {
|
|
34
|
+
const tasks = [];
|
|
35
|
+
if (!options.skipPackageJson) {
|
|
36
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
37
|
+
'@remix-run/serve': versions_1.remixVersion,
|
|
38
|
+
}, {
|
|
39
|
+
'@nx/web': versions_1.nxVersion,
|
|
40
|
+
'@remix-run/dev': versions_1.remixVersion,
|
|
41
|
+
}, undefined, options.keepExistingVersions);
|
|
42
|
+
tasks.push(installTask);
|
|
43
|
+
}
|
|
44
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
45
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
46
|
+
nxJson.useInferencePlugins !== false;
|
|
47
|
+
options.addPlugin ??= addPluginDefault;
|
|
48
|
+
if (options.addPlugin) {
|
|
49
|
+
addPlugin(tree);
|
|
50
|
+
}
|
|
51
|
+
if (options.updatePackageScripts) {
|
|
52
|
+
await (0, update_package_scripts_1.updatePackageScripts)(tree, plugin_1.createNodes);
|
|
53
|
+
}
|
|
54
|
+
if (!options.skipFormat) {
|
|
55
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
56
|
+
}
|
|
57
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
58
|
+
}
|
|
59
|
+
exports.remixInitGeneratorInternal = remixInitGeneratorInternal;
|
|
60
|
+
exports.default = remixInitGenerator;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxRemixInit",
|
|
4
|
+
"title": "Init Remix Plugin",
|
|
5
|
+
"description": "Initialize the Remix Plugin.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"skipFormat": {
|
|
10
|
+
"description": "Skip formatting files.",
|
|
11
|
+
"type": "boolean",
|
|
12
|
+
"default": false
|
|
13
|
+
},
|
|
14
|
+
"skipPackageJson": {
|
|
15
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": false
|
|
18
|
+
},
|
|
19
|
+
"keepExistingVersions": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"x-priority": "internal",
|
|
22
|
+
"description": "Keep existing dependencies versions",
|
|
23
|
+
"default": false
|
|
24
|
+
},
|
|
25
|
+
"updatePackageScripts": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"x-priority": "internal",
|
|
28
|
+
"description": "Update `package.json` scripts with inferred targets",
|
|
29
|
+
"default": false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": []
|
|
33
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with jest 1`] = `
|
|
4
|
+
"/* eslint-disable */
|
|
5
|
+
export default {
|
|
6
|
+
setupFilesAfterEnv: ['./src/test-setup.ts'],
|
|
7
|
+
displayName: 'test',
|
|
8
|
+
preset: '../jest.preset.js',
|
|
9
|
+
transform: {
|
|
10
|
+
'^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
11
|
+
'^.+\\\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
|
|
12
|
+
},
|
|
13
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
14
|
+
coverageDirectory: '../coverage/test',
|
|
15
|
+
};
|
|
16
|
+
"
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with jest 2`] = `
|
|
20
|
+
"import { installGlobals } from '@remix-run/node';
|
|
21
|
+
import '@testing-library/jest-dom/matchers';
|
|
22
|
+
installGlobals();
|
|
23
|
+
"
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with vitest 1`] = `
|
|
27
|
+
"import { defineConfig } from 'vite';
|
|
28
|
+
import react from '@vitejs/plugin-react';
|
|
29
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
root: __dirname,
|
|
33
|
+
cacheDir: '../node_modules/.vite/test',
|
|
34
|
+
|
|
35
|
+
plugins: [react(), nxViteTsPaths()],
|
|
36
|
+
|
|
37
|
+
// Uncomment this if you are using workers.
|
|
38
|
+
// worker: {
|
|
39
|
+
// plugins: [ nxViteTsPaths() ],
|
|
40
|
+
// },
|
|
41
|
+
|
|
42
|
+
test: {
|
|
43
|
+
setupFiles: ['./src/test-setup.ts'],
|
|
44
|
+
globals: true,
|
|
45
|
+
cache: { dir: '../node_modules/.vitest' },
|
|
46
|
+
environment: 'jsdom',
|
|
47
|
+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
48
|
+
reporters: ['default'],
|
|
49
|
+
coverage: { reportsDirectory: '../coverage/test', provider: 'v8' },
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
"
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=as-provided --unitTestRunner should create the correct config files for testing with vitest 2`] = `
|
|
56
|
+
"import { installGlobals } from '@remix-run/node';
|
|
57
|
+
import '@testing-library/jest-dom/matchers';
|
|
58
|
+
installGlobals();
|
|
59
|
+
"
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=as-provided should generate a library correctly 1`] = `
|
|
63
|
+
[
|
|
64
|
+
"test.module.css",
|
|
65
|
+
"test.spec.tsx",
|
|
66
|
+
"test.tsx",
|
|
67
|
+
]
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=as-provided should generate a library correctly 2`] = `
|
|
71
|
+
{
|
|
72
|
+
"@proj/test": [
|
|
73
|
+
"test/src/index.ts",
|
|
74
|
+
],
|
|
75
|
+
"@proj/test/server": [
|
|
76
|
+
"test/src/server.ts",
|
|
77
|
+
],
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with jest 1`] = `
|
|
82
|
+
"/* eslint-disable */
|
|
83
|
+
export default {
|
|
84
|
+
setupFilesAfterEnv: ['./src/test-setup.ts'],
|
|
85
|
+
displayName: 'test',
|
|
86
|
+
preset: '../../jest.preset.js',
|
|
87
|
+
transform: {
|
|
88
|
+
'^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
89
|
+
'^.+\\\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
|
|
90
|
+
},
|
|
91
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
92
|
+
coverageDirectory: '../../coverage/libs/test',
|
|
93
|
+
};
|
|
94
|
+
"
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with jest 2`] = `
|
|
98
|
+
"import { installGlobals } from '@remix-run/node';
|
|
99
|
+
import '@testing-library/jest-dom/matchers';
|
|
100
|
+
installGlobals();
|
|
101
|
+
"
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with vitest 1`] = `
|
|
105
|
+
"import { defineConfig } from 'vite';
|
|
106
|
+
import react from '@vitejs/plugin-react';
|
|
107
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
108
|
+
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
root: __dirname,
|
|
111
|
+
cacheDir: '../../node_modules/.vite/libs/test',
|
|
112
|
+
|
|
113
|
+
plugins: [react(), nxViteTsPaths()],
|
|
114
|
+
|
|
115
|
+
// Uncomment this if you are using workers.
|
|
116
|
+
// worker: {
|
|
117
|
+
// plugins: [ nxViteTsPaths() ],
|
|
118
|
+
// },
|
|
119
|
+
|
|
120
|
+
test: {
|
|
121
|
+
setupFiles: ['./src/test-setup.ts'],
|
|
122
|
+
globals: true,
|
|
123
|
+
cache: { dir: '../../node_modules/.vitest' },
|
|
124
|
+
environment: 'jsdom',
|
|
125
|
+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
126
|
+
reporters: ['default'],
|
|
127
|
+
coverage: { reportsDirectory: '../../coverage/libs/test', provider: 'v8' },
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
"
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=derived --unitTestRunner should create the correct config files for testing with vitest 2`] = `
|
|
134
|
+
"import { installGlobals } from '@remix-run/node';
|
|
135
|
+
import '@testing-library/jest-dom/matchers';
|
|
136
|
+
installGlobals();
|
|
137
|
+
"
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=derived should generate a library correctly 1`] = `
|
|
141
|
+
[
|
|
142
|
+
"test.module.css",
|
|
143
|
+
"test.spec.tsx",
|
|
144
|
+
"test.tsx",
|
|
145
|
+
]
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
exports[`Remix Library Generator -projectNameAndRootFormat=derived should generate a library correctly 2`] = `
|
|
149
|
+
{
|
|
150
|
+
"@proj/libs/test": [
|
|
151
|
+
"libs/test/src/index.ts",
|
|
152
|
+
],
|
|
153
|
+
"@proj/libs/test/server": [
|
|
154
|
+
"libs/test/src/server.ts",
|
|
155
|
+
],
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
@@ -5,22 +5,21 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const testing_config_utils_1 = require("../../../utils/testing-config-utils");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
7
|
function addUnitTestingSetup(tree, options) {
|
|
8
|
-
const
|
|
9
|
-
const pathToTestSetup = (0, devkit_1.joinPathFragments)(projectRoot, 'src/test-setup.ts');
|
|
8
|
+
const pathToTestSetup = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/test-setup.ts');
|
|
10
9
|
let testSetupFileContents = '';
|
|
11
10
|
if (tree.exists(pathToTestSetup)) {
|
|
12
11
|
testSetupFileContents = tree.read(pathToTestSetup, 'utf-8');
|
|
13
12
|
}
|
|
14
13
|
tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `${testSetupFileContents}
|
|
15
14
|
import { installGlobals } from '@remix-run/node';
|
|
16
|
-
import "@testing-library/jest-dom/
|
|
15
|
+
import "@testing-library/jest-dom/matchers";
|
|
17
16
|
installGlobals();`);
|
|
18
17
|
if (options.unitTestRunner === 'vitest') {
|
|
19
|
-
const pathToVitestConfig = (0, devkit_1.joinPathFragments)(projectRoot, `vite.config.ts`);
|
|
20
|
-
(0, testing_config_utils_1.
|
|
18
|
+
const pathToVitestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `vite.config.ts`);
|
|
19
|
+
(0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToVitestConfig, './src/test-setup.ts');
|
|
21
20
|
}
|
|
22
21
|
else if (options.unitTestRunner === 'jest') {
|
|
23
|
-
const pathToJestConfig = (0, devkit_1.joinPathFragments)(projectRoot, `jest.config.ts`);
|
|
22
|
+
const pathToJestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `jest.config.ts`);
|
|
24
23
|
(0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, './src/test-setup.ts');
|
|
25
24
|
}
|
|
26
25
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
@@ -31,4 +30,3 @@ function addUnitTestingSetup(tree, options) {
|
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
32
|
exports.addUnitTestingSetup = addUnitTestingSetup;
|
|
34
|
-
//# sourceMappingURL=add-unit-testing.js.map
|
|
@@ -5,4 +5,3 @@ tslib_1.__exportStar(require("./add-tsconfig-entry-points"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("./add-unit-testing"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./update-buildable-config"), exports);
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
2
|
import type { NxRemixGeneratorSchema } from '../schema';
|
|
3
3
|
export interface RemixLibraryOptions extends NxRemixGeneratorSchema {
|
|
4
4
|
projectName: string;
|
|
5
|
+
projectRoot: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): RemixLibraryOptions
|
|
7
|
+
export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): Promise<RemixLibraryOptions>;
|
|
@@ -2,18 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
5
6
|
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
async function normalizeOptions(tree, options) {
|
|
8
|
+
const { projectName, projectRoot, projectNameAndRootFormat } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
9
|
+
name: options.name,
|
|
10
|
+
projectType: 'library',
|
|
11
|
+
directory: options.directory,
|
|
12
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
13
|
+
callingGenerator: '@nx/remix:library',
|
|
14
|
+
});
|
|
15
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
16
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
+
nxJson.useInferencePlugins !== false;
|
|
18
|
+
options.addPlugin ??= addPluginDefault;
|
|
19
|
+
const importPath = options.importPath ?? (0, get_import_path_1.getImportPath)(tree, projectRoot);
|
|
20
|
+
return {
|
|
21
|
+
...options,
|
|
22
|
+
unitTestRunner: options.unitTestRunner ?? 'vitest',
|
|
15
23
|
importPath,
|
|
16
|
-
projectName
|
|
24
|
+
projectName,
|
|
25
|
+
projectRoot,
|
|
26
|
+
projectNameAndRootFormat,
|
|
27
|
+
};
|
|
17
28
|
}
|
|
18
29
|
exports.normalizeOptions = normalizeOptions;
|
|
19
|
-
//# sourceMappingURL=normalize-options.js.map
|
|
@@ -5,7 +5,11 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
function updateBuildableConfig(tree, name) {
|
|
6
6
|
// Nest dist under project root to we can link it
|
|
7
7
|
const project = (0, devkit_1.readProjectConfiguration)(tree, name);
|
|
8
|
-
project.targets.build.options =
|
|
8
|
+
project.targets.build.options = {
|
|
9
|
+
...project.targets.build.options,
|
|
10
|
+
format: ['cjs'],
|
|
11
|
+
outputPath: (0, devkit_1.joinPathFragments)(project.root, 'dist'),
|
|
12
|
+
};
|
|
9
13
|
(0, devkit_1.updateProjectConfiguration)(tree, name, project);
|
|
10
14
|
// Point to nested dist for yarn/npm/pnpm workspaces
|
|
11
15
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(project.root, 'package.json'), (json) => {
|
|
@@ -15,4 +19,3 @@ function updateBuildableConfig(tree, name) {
|
|
|
15
19
|
});
|
|
16
20
|
}
|
|
17
21
|
exports.updateBuildableConfig = updateBuildableConfig;
|
|
18
|
-
//# sourceMappingURL=update-buildable-config.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import { GeneratorCallback } from '@nx/devkit';
|
|
3
3
|
import type { NxRemixGeneratorSchema } from './schema';
|
|
4
|
-
export
|
|
4
|
+
export declare function remixLibraryGenerator(tree: Tree, schema: NxRemixGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
|
+
export declare function remixLibraryGeneratorInternal(tree: Tree, schema: NxRemixGeneratorSchema): Promise<GeneratorCallback>;
|
|
6
|
+
export default remixLibraryGenerator;
|
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.remixLibraryGeneratorInternal = exports.remixLibraryGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const eslint_1 = require("@nx/eslint");
|
|
6
6
|
const react_1 = require("@nx/react");
|
|
7
7
|
const lib_1 = require("./lib");
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
(0, lib_1.addTsconfigEntryPoints)(tree, options);
|
|
31
|
-
if (options.buildable) {
|
|
32
|
-
(0, lib_1.updateBuildableConfig)(tree, options.projectName);
|
|
33
|
-
}
|
|
34
|
-
if (!options.skipFormat) {
|
|
35
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
36
|
-
}
|
|
37
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
8
|
+
async function remixLibraryGenerator(tree, schema) {
|
|
9
|
+
return remixLibraryGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
10
|
+
}
|
|
11
|
+
exports.remixLibraryGenerator = remixLibraryGenerator;
|
|
12
|
+
async function remixLibraryGeneratorInternal(tree, schema) {
|
|
13
|
+
const tasks = [];
|
|
14
|
+
const options = await (0, lib_1.normalizeOptions)(tree, schema);
|
|
15
|
+
const libGenTask = await (0, react_1.libraryGenerator)(tree, {
|
|
16
|
+
name: options.projectName,
|
|
17
|
+
style: options.style,
|
|
18
|
+
unitTestRunner: options.unitTestRunner,
|
|
19
|
+
tags: options.tags,
|
|
20
|
+
importPath: options.importPath,
|
|
21
|
+
directory: options.projectRoot,
|
|
22
|
+
projectNameAndRootFormat: 'as-provided',
|
|
23
|
+
skipFormat: true,
|
|
24
|
+
skipTsConfig: false,
|
|
25
|
+
linter: eslint_1.Linter.EsLint,
|
|
26
|
+
component: true,
|
|
27
|
+
buildable: options.buildable,
|
|
28
|
+
addPlugin: options.addPlugin,
|
|
38
29
|
});
|
|
30
|
+
tasks.push(libGenTask);
|
|
31
|
+
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
32
|
+
const pkgInstallTask = (0, lib_1.addUnitTestingSetup)(tree, options);
|
|
33
|
+
tasks.push(pkgInstallTask);
|
|
34
|
+
}
|
|
35
|
+
(0, lib_1.addTsconfigEntryPoints)(tree, options);
|
|
36
|
+
if (options.buildable) {
|
|
37
|
+
(0, lib_1.updateBuildableConfig)(tree, options.projectName);
|
|
38
|
+
}
|
|
39
|
+
if (!options.skipFormat) {
|
|
40
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
41
|
+
}
|
|
42
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
39
43
|
}
|
|
40
|
-
exports.
|
|
41
|
-
|
|
44
|
+
exports.remixLibraryGeneratorInternal = remixLibraryGeneratorInternal;
|
|
45
|
+
exports.default = remixLibraryGenerator;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
1
2
|
import { SupportedStyles } from '@nx/react';
|
|
2
3
|
|
|
3
4
|
export interface NxRemixGeneratorSchema {
|
|
4
5
|
name: string;
|
|
5
6
|
style: SupportedStyles;
|
|
6
7
|
directory?: string;
|
|
8
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
7
9
|
tags?: string;
|
|
8
10
|
importPath?: string;
|
|
9
11
|
buildable?: boolean;
|
|
10
12
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
11
13
|
js?: boolean;
|
|
12
14
|
skipFormat?: boolean;
|
|
15
|
+
addPlugin?: boolean;
|
|
13
16
|
}
|