@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.
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +14 -0
- package/generators.d.ts +14 -0
- package/generators.js +31 -0
- package/generators.json +90 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/migrations.json +107 -0
- package/package.json +53 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/component-testing/index.d.ts +30 -0
- package/plugins/component-testing/index.js +64 -0
- package/src/executors/build/build.impl.d.ts +5 -0
- package/src/executors/build/build.impl.js +109 -0
- package/src/executors/build/schema.d.ts +7 -0
- package/src/executors/build/schema.json +38 -0
- package/src/executors/serve/schema.d.ts +9 -0
- package/src/executors/serve/schema.json +41 -0
- package/src/executors/serve/serve.impl.d.ts +6 -0
- package/src/executors/serve/serve.impl.js +77 -0
- package/src/generators/action/action.impl.d.ts +3 -0
- package/src/generators/action/action.impl.js +39 -0
- package/src/generators/action/schema.d.ts +10 -0
- package/src/generators/action/schema.json +29 -0
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1487 -0
- package/src/generators/application/application.impl.d.ts +5 -0
- package/src/generators/application/application.impl.js +198 -0
- package/src/generators/application/files/common/README.md__tmpl__ +54 -0
- package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
- package/src/generators/application/files/common/app/root.tsx__tmpl__ +32 -0
- package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
- package/src/generators/application/files/common/public/favicon.ico +0 -0
- package/src/generators/application/files/common/remix.config.js__tmpl__ +17 -0
- package/src/generators/application/files/common/remix.env.d.ts__tmpl__ +2 -0
- 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__ +24 -0
- package/src/generators/application/files/integrated/.gitignore__tmpl__ +4 -0
- package/src/generators/application/files/integrated/package.json__tmpl__ +28 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +66 -0
- package/src/generators/application/lib/index.d.ts +3 -0
- package/src/generators/application/lib/index.js +6 -0
- package/src/generators/application/lib/normalize-options.d.ts +10 -0
- package/src/generators/application/lib/normalize-options.js +37 -0
- package/src/generators/application/lib/update-unit-test-config.d.ts +2 -0
- package/src/generators/application/lib/update-unit-test-config.js +55 -0
- package/src/generators/application/schema.d.ts +16 -0
- package/src/generators/application/schema.json +68 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +5 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +34 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +6 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
- package/src/generators/cypress-component-configuration/schema.json +41 -0
- package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +61 -0
- package/src/generators/error-boundary/error-boundary.impl.d.ts +3 -0
- package/src/generators/error-boundary/error-boundary.impl.js +12 -0
- package/src/generators/error-boundary/lib/add-v2-error-boundary.d.ts +3 -0
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js +38 -0
- package/src/generators/error-boundary/lib/index.d.ts +2 -0
- package/src/generators/error-boundary/lib/index.js +5 -0
- package/src/generators/error-boundary/lib/normalize-options.d.ts +3 -0
- package/src/generators/error-boundary/lib/normalize-options.js +17 -0
- package/src/generators/error-boundary/schema.d.ts +11 -0
- package/src/generators/error-boundary/schema.json +37 -0
- 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.d.ts +3 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.js +19 -0
- package/src/generators/library/lib/add-unit-testing.d.ts +3 -0
- package/src/generators/library/lib/add-unit-testing.js +32 -0
- package/src/generators/library/lib/index.d.ts +4 -0
- package/src/generators/library/lib/index.js +7 -0
- package/src/generators/library/lib/normalize-options.d.ts +7 -0
- package/src/generators/library/lib/normalize-options.js +29 -0
- package/src/generators/library/lib/update-buildable-config.d.ts +2 -0
- package/src/generators/library/lib/update-buildable-config.js +21 -0
- package/src/generators/library/library.impl.d.ts +6 -0
- package/src/generators/library/library.impl.js +45 -0
- package/src/generators/library/schema.d.ts +16 -0
- package/src/generators/library/schema.json +74 -0
- package/src/generators/loader/loader.impl.d.ts +3 -0
- package/src/generators/loader/loader.impl.js +39 -0
- package/src/generators/loader/schema.d.ts +10 -0
- package/src/generators/loader/schema.json +29 -0
- package/src/generators/meta/lib/v2.impl.d.ts +3 -0
- package/src/generators/meta/lib/v2.impl.js +28 -0
- package/src/generators/meta/meta.impl.d.ts +3 -0
- package/src/generators/meta/meta.impl.js +7 -0
- package/src/generators/meta/schema.d.ts +10 -0
- package/src/generators/meta/schema.json +29 -0
- package/src/generators/preset/lib/normalize-options.d.ts +11 -0
- package/src/generators/preset/lib/normalize-options.js +20 -0
- package/src/generators/preset/preset.impl.d.ts +3 -0
- package/src/generators/preset/preset.impl.js +32 -0
- package/src/generators/preset/schema.d.ts +4 -0
- package/src/generators/preset/schema.json +14 -0
- package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
- package/src/generators/resource-route/resource-route.impl.d.ts +3 -0
- package/src/generators/resource-route/resource-route.impl.js +41 -0
- package/src/generators/resource-route/schema.d.ts +13 -0
- package/src/generators/resource-route/schema.json +51 -0
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +95 -0
- package/src/generators/route/route.impl.d.ts +3 -0
- package/src/generators/route/route.impl.js +78 -0
- package/src/generators/route/schema.d.ts +15 -0
- package/src/generators/route/schema.json +62 -0
- package/src/generators/setup/schema.json +14 -0
- package/src/generators/setup/setup.impl.d.ts +2 -0
- package/src/generators/setup/setup.impl.js +34 -0
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +170 -0
- package/src/generators/setup-tailwind/files/app/tailwind.css__tpl__ +3 -0
- package/src/generators/setup-tailwind/files/tailwind.config.ts__tpl__ +13 -0
- package/src/generators/setup-tailwind/lib/index.d.ts +1 -0
- package/src/generators/setup-tailwind/lib/index.js +4 -0
- package/src/generators/setup-tailwind/lib/update-remix-config.d.ts +2 -0
- package/src/generators/setup-tailwind/lib/update-remix-config.js +35 -0
- package/src/generators/setup-tailwind/schema.d.ts +5 -0
- package/src/generators/setup-tailwind/schema.json +36 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.d.ts +3 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +34 -0
- package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +73 -0
- package/src/generators/storybook-configuration/files/vite.config.ts__tpl__ +15 -0
- package/src/generators/storybook-configuration/schema.d.ts +16 -0
- package/src/generators/storybook-configuration/schema.json +89 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +4 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +26 -0
- package/src/generators/style/schema.d.ts +10 -0
- package/src/generators/style/schema.json +36 -0
- package/src/generators/style/style.impl.d.ts +3 -0
- package/src/generators/style/style.impl.js +61 -0
- 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 +136 -0
- package/src/utils/create-watch-paths.d.ts +8 -0
- package/src/utils/create-watch-paths.js +40 -0
- package/src/utils/get-default-export-name.d.ts +2 -0
- package/src/utils/get-default-export-name.js +8 -0
- package/src/utils/get-default-export.d.ts +2 -0
- package/src/utils/get-default-export.js +15 -0
- package/src/utils/insert-import.d.ts +4 -0
- package/src/utils/insert-import.js +54 -0
- package/src/utils/insert-statement-after-imports.d.ts +5 -0
- package/src/utils/insert-statement-after-imports.js +28 -0
- package/src/utils/insert-statement-in-default-function.d.ts +2 -0
- package/src/utils/insert-statement-in-default-function.js +23 -0
- package/src/utils/remix-config.d.ts +5 -0
- package/src/utils/remix-config.js +45 -0
- package/src/utils/remix-route-utils.d.ts +13 -0
- package/src/utils/remix-route-utils.js +70 -0
- package/src/utils/testing-config-utils.d.ts +4 -0
- package/src/utils/testing-config-utils.js +79 -0
- package/src/utils/upsert-links-function.d.ts +2 -0
- package/src/utils/upsert-links-function.js +31 -0
- package/src/utils/versions.d.ts +16 -0
- package/src/utils/versions.js +28 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MetaFunction } from "@remix-run/node";
|
|
2
|
+
import {
|
|
3
|
+
Links,
|
|
4
|
+
LiveReload,
|
|
5
|
+
Meta,
|
|
6
|
+
Outlet,
|
|
7
|
+
Scripts,
|
|
8
|
+
ScrollRestoration,
|
|
9
|
+
} from "@remix-run/react";
|
|
10
|
+
|
|
11
|
+
export const meta: MetaFunction = () => ([{
|
|
12
|
+
charset: "utf-8",
|
|
13
|
+
title: "New Remix App",
|
|
14
|
+
viewport: "width=device-width,initial-scale=1",
|
|
15
|
+
}]);
|
|
16
|
+
|
|
17
|
+
export default function App() {
|
|
18
|
+
return (
|
|
19
|
+
<html lang="en">
|
|
20
|
+
<head>
|
|
21
|
+
<Meta />
|
|
22
|
+
<Links />
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<Outlet />
|
|
26
|
+
<ScrollRestoration />
|
|
27
|
+
<Scripts />
|
|
28
|
+
<LiveReload />
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {createWatchPaths} from '@nx/remix';
|
|
2
|
+
import {dirname} from 'path';
|
|
3
|
+
import {fileURLToPath} from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {import('@remix-run/dev').AppConfig}
|
|
9
|
+
*/
|
|
10
|
+
export default {
|
|
11
|
+
ignoredRouteFiles: ["**/.*"],
|
|
12
|
+
// appDirectory: "app",
|
|
13
|
+
// assetsBuildDirectory: "public/build",
|
|
14
|
+
// serverBuildPath: "build/index.js",
|
|
15
|
+
// publicPath: "/build/",
|
|
16
|
+
watchPaths: () => createWatchPaths(__dirname),
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRemixStub } from '@remix-run/testing';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import Index from '../../app/routes/_index';
|
|
4
|
+
|
|
5
|
+
test('renders loader data', async () => {
|
|
6
|
+
const RemixStub = createRemixStub([
|
|
7
|
+
{
|
|
8
|
+
path: '/',
|
|
9
|
+
Component: Index,
|
|
10
|
+
},
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
render(<RemixStub />);
|
|
14
|
+
|
|
15
|
+
await waitFor(() => screen.findByText('Hello there,'));
|
|
16
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"remix.env.d.ts",
|
|
5
|
+
"app/**/*.ts",
|
|
6
|
+
"app/**/*.tsx",
|
|
7
|
+
"app/**/*.js",
|
|
8
|
+
"app/**/*.jsx"
|
|
9
|
+
],
|
|
10
|
+
"exclude": [
|
|
11
|
+
"tests/**/*.spec.ts",
|
|
12
|
+
"tests/**/*.test.ts",
|
|
13
|
+
"tests/**/*.spec.tsx",
|
|
14
|
+
"tests/**/*.test.tsx",
|
|
15
|
+
"tests/**/*.spec.js",
|
|
16
|
+
"tests/**/*.test.js",
|
|
17
|
+
"tests/**/*.spec.jsx",
|
|
18
|
+
"tests/**/*.test.jsx"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable", "ES2019"],
|
|
5
|
+
"isolatedModules": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"target": "ES2019",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
// Remix takes care of building everything in `remix build`.
|
|
15
|
+
"noEmit": true
|
|
16
|
+
},
|
|
17
|
+
"include": [],
|
|
18
|
+
"files": [],
|
|
19
|
+
"references": [
|
|
20
|
+
{
|
|
21
|
+
"path": "./tsconfig.app.json"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"name": "<%= projectName %>",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "",
|
|
6
|
+
"scripts": {},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@remix-run/node": "<%= remixVersion %>",
|
|
10
|
+
"@remix-run/react": "<%= remixVersion %>",
|
|
11
|
+
"@remix-run/serve": "<%= remixVersion %>",
|
|
12
|
+
"isbot": "<%= isbotVersion %>",
|
|
13
|
+
"react": "<%= reactVersion %>",
|
|
14
|
+
"react-dom": "<%= reactDomVersion %>"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@remix-run/dev": "<%= remixVersion %>",
|
|
18
|
+
"@remix-run/eslint-config": "<%= remixVersion %>",
|
|
19
|
+
"@types/react": "<%= typesReactVersion %>",
|
|
20
|
+
"@types/react-dom": "<%= typesReactDomVersion %>",
|
|
21
|
+
"eslint": "<%= eslintVersion %>",
|
|
22
|
+
"typescript": "<%= typescriptVersion %>"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=14"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false
|
|
28
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addE2E = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
async function addE2E(tree, options) {
|
|
7
|
+
if (options.e2eTestRunner === 'cypress') {
|
|
8
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
9
|
+
addFileServerTarget(tree, options, 'serve-static');
|
|
10
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
11
|
+
projectType: 'application',
|
|
12
|
+
root: options.e2eProjectRoot,
|
|
13
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
14
|
+
targets: {},
|
|
15
|
+
tags: [],
|
|
16
|
+
implicitDependencies: [options.projectName],
|
|
17
|
+
});
|
|
18
|
+
return await configurationGenerator(tree, {
|
|
19
|
+
project: options.e2eProjectName,
|
|
20
|
+
directory: 'src',
|
|
21
|
+
skipFormat: true,
|
|
22
|
+
devServerTarget: `${options.projectName}:serve:development`,
|
|
23
|
+
baseUrl: 'http://localhost:4200',
|
|
24
|
+
addPlugin: options.addPlugin,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else if (options.e2eTestRunner === 'playwright') {
|
|
28
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
29
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
30
|
+
projectType: 'application',
|
|
31
|
+
root: options.e2eProjectRoot,
|
|
32
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
33
|
+
targets: {},
|
|
34
|
+
tags: [],
|
|
35
|
+
implicitDependencies: [options.projectName],
|
|
36
|
+
});
|
|
37
|
+
return configurationGenerator(tree, {
|
|
38
|
+
project: options.e2eProjectName,
|
|
39
|
+
skipFormat: true,
|
|
40
|
+
skipPackageJson: false,
|
|
41
|
+
directory: 'src',
|
|
42
|
+
js: false,
|
|
43
|
+
linter: options.linter,
|
|
44
|
+
setParserOptionsProject: false,
|
|
45
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
|
|
46
|
+
webServerAddress: 'http://localhost:4200',
|
|
47
|
+
rootProject: options.rootProject,
|
|
48
|
+
addPlugin: options.addPlugin,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return () => { };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.addE2E = addE2E;
|
|
56
|
+
function addFileServerTarget(tree, options, targetName) {
|
|
57
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
58
|
+
projectConfig.targets[targetName] = {
|
|
59
|
+
executor: '@nx/web:file-server',
|
|
60
|
+
options: {
|
|
61
|
+
buildTarget: `${options.projectName}:build`,
|
|
62
|
+
port: 4200,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
|
|
66
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./update-unit-test-config"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./add-e2e"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { type NxRemixGeneratorSchema } from '../schema';
|
|
3
|
+
export interface NormalizedSchema extends NxRemixGeneratorSchema {
|
|
4
|
+
projectName: string;
|
|
5
|
+
projectRoot: string;
|
|
6
|
+
e2eProjectName: string;
|
|
7
|
+
e2eProjectRoot: string;
|
|
8
|
+
parsedTags: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): Promise<NormalizedSchema>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = void 0;
|
|
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");
|
|
6
|
+
const eslint_1 = require("@nx/eslint");
|
|
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: 'application',
|
|
11
|
+
directory: options.directory,
|
|
12
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
13
|
+
rootProject: options.rootProject,
|
|
14
|
+
callingGenerator: '@nx/remix:application',
|
|
15
|
+
});
|
|
16
|
+
options.rootProject = projectRoot === '.';
|
|
17
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
18
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
19
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
20
|
+
nxJson.useInferencePlugins !== false;
|
|
21
|
+
options.addPlugin ??= addPluginDefault;
|
|
22
|
+
const e2eProjectName = options.rootProject ? 'e2e' : `${projectName}-e2e`;
|
|
23
|
+
const e2eProjectRoot = options.rootProject ? 'e2e' : `${projectRoot}-e2e`;
|
|
24
|
+
const parsedTags = options.tags
|
|
25
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
26
|
+
: [];
|
|
27
|
+
return {
|
|
28
|
+
...options,
|
|
29
|
+
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
30
|
+
projectName,
|
|
31
|
+
projectRoot,
|
|
32
|
+
e2eProjectName,
|
|
33
|
+
e2eProjectRoot,
|
|
34
|
+
parsedTags,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.normalizeOptions = normalizeOptions;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateUnitTestConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const testing_config_utils_1 = require("../../../utils/testing-config-utils");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
function updateUnitTestConfig(tree, pathToRoot, unitTestRunner, rootProject) {
|
|
8
|
+
const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
|
|
9
|
+
tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
|
|
10
|
+
import { installGlobals } from '@remix-run/node';
|
|
11
|
+
import '@testing-library/jest-dom/matchers';
|
|
12
|
+
installGlobals();`);
|
|
13
|
+
if (unitTestRunner === 'vitest') {
|
|
14
|
+
const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vitest.config.ts');
|
|
15
|
+
(0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
|
|
16
|
+
(0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
|
|
17
|
+
(0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
|
|
18
|
+
}
|
|
19
|
+
else if (unitTestRunner === 'jest' && rootProject) {
|
|
20
|
+
const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
|
|
21
|
+
tree.write('jest.preset.cjs', tree.read('jest.preset.js', 'utf-8'));
|
|
22
|
+
(0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, `<rootDir>/test-setup.ts`);
|
|
23
|
+
tree.write(pathToJestConfig, tree
|
|
24
|
+
.read(pathToJestConfig, 'utf-8')
|
|
25
|
+
.replace('jest.preset.js', 'jest.preset.cjs'));
|
|
26
|
+
}
|
|
27
|
+
const pathToTsConfigSpec = (0, devkit_1.joinPathFragments)(pathToRoot, `tsconfig.spec.json`);
|
|
28
|
+
(0, devkit_1.updateJson)(tree, pathToTsConfigSpec, (json) => {
|
|
29
|
+
json.include = [
|
|
30
|
+
'vite.config.ts',
|
|
31
|
+
'vitest.config.ts',
|
|
32
|
+
'app/**/*.ts',
|
|
33
|
+
'app/**/*.tsx',
|
|
34
|
+
'app/**/*.js',
|
|
35
|
+
'app/**/*.jsx',
|
|
36
|
+
'tests/**/*.spec.ts',
|
|
37
|
+
'tests/**/*.test.ts',
|
|
38
|
+
'tests/**/*.spec.tsx',
|
|
39
|
+
'tests/**/*.test.tsx',
|
|
40
|
+
'tests/**/*.spec.js',
|
|
41
|
+
'tests/**/*.test.js',
|
|
42
|
+
'tests/**/*.spec.jsx',
|
|
43
|
+
'tests/**/*.test.jsx',
|
|
44
|
+
];
|
|
45
|
+
return json;
|
|
46
|
+
});
|
|
47
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
48
|
+
'@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
|
|
49
|
+
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
50
|
+
'@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
|
|
51
|
+
'@remix-run/node': (0, versions_1.getRemixVersion)(tree),
|
|
52
|
+
'@remix-run/testing': (0, versions_1.getRemixVersion)(tree),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.updateUnitTestConfig = updateUnitTestConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/eslint';
|
|
3
|
+
|
|
4
|
+
export interface NxRemixGeneratorSchema {
|
|
5
|
+
name: string;
|
|
6
|
+
tags?: string;
|
|
7
|
+
js?: boolean;
|
|
8
|
+
directory?: string;
|
|
9
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
10
|
+
linter?: Linter;
|
|
11
|
+
unitTestRunner?: 'vitest' | 'jest' | 'none';
|
|
12
|
+
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
|
|
13
|
+
skipFormat?: boolean;
|
|
14
|
+
rootProject?: boolean;
|
|
15
|
+
addPlugin?: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxRemixApplication",
|
|
4
|
+
"title": "Create an Application",
|
|
5
|
+
"description": "Generate a new Remix application.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-prompt": "What is the name of the application?"
|
|
16
|
+
},
|
|
17
|
+
"js": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
20
|
+
"default": false
|
|
21
|
+
},
|
|
22
|
+
"directory": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "A directory where the app is placed.",
|
|
25
|
+
"alias": "dir",
|
|
26
|
+
"x-priority": "important"
|
|
27
|
+
},
|
|
28
|
+
"projectNameAndRootFormat": {
|
|
29
|
+
"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`).",
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": ["as-provided", "derived"]
|
|
32
|
+
},
|
|
33
|
+
"linter": {
|
|
34
|
+
"description": "The tool to use for running lint checks.",
|
|
35
|
+
"type": "string",
|
|
36
|
+
"enum": ["eslint", "none"],
|
|
37
|
+
"default": "eslint"
|
|
38
|
+
},
|
|
39
|
+
"unitTestRunner": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": ["vitest", "jest", "none"],
|
|
42
|
+
"default": "vitest",
|
|
43
|
+
"description": "Test runner to use for unit tests.",
|
|
44
|
+
"x-prompt": "What unit test runner should be used?"
|
|
45
|
+
},
|
|
46
|
+
"e2eTestRunner": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"enum": ["cypress", "playwright", "none"],
|
|
49
|
+
"default": "cypress",
|
|
50
|
+
"description": "Test runner to use for e2e tests"
|
|
51
|
+
},
|
|
52
|
+
"tags": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Add tags to the project (used for linting)",
|
|
55
|
+
"alias": "t"
|
|
56
|
+
},
|
|
57
|
+
"skipFormat": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"description": "Skip formatting files",
|
|
60
|
+
"default": false
|
|
61
|
+
},
|
|
62
|
+
"rootProject": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"x-priority": "internal",
|
|
65
|
+
"default": false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { type CypressComponentConfigurationSchema } from './schema';
|
|
3
|
+
export declare function cypressComponentConfigurationGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<void>;
|
|
4
|
+
export declare function cypressComponentConfigurationGeneratorInternal(tree: Tree, options: CypressComponentConfigurationSchema): Promise<void>;
|
|
5
|
+
export default cypressComponentConfigurationGenerator;
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cypressComponentConfigurationGeneratorInternal = exports.cypressComponentConfigurationGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const react_1 = require("@nx/react");
|
|
7
|
+
function cypressComponentConfigurationGenerator(tree, options) {
|
|
8
|
+
return cypressComponentConfigurationGeneratorInternal(tree, {
|
|
9
|
+
addPlugin: false,
|
|
10
|
+
...options,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.cypressComponentConfigurationGenerator = cypressComponentConfigurationGenerator;
|
|
14
|
+
async function cypressComponentConfigurationGeneratorInternal(tree, options) {
|
|
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
|
+
await (0, react_1.cypressComponentConfigGenerator)(tree, {
|
|
20
|
+
project: options.project,
|
|
21
|
+
generateTests: options.generateTests,
|
|
22
|
+
skipFormat: true,
|
|
23
|
+
bundler: 'vite',
|
|
24
|
+
buildTarget: '',
|
|
25
|
+
addPlugin: options.addPlugin,
|
|
26
|
+
});
|
|
27
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
28
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
|
|
29
|
+
if (!options.skipFormat) {
|
|
30
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.cypressComponentConfigurationGeneratorInternal = cypressComponentConfigurationGeneratorInternal;
|
|
34
|
+
exports.default = cypressComponentConfigurationGenerator;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxRemixCypressComponentTestConfiguration",
|
|
5
|
+
"title": "Add Cypress component testing",
|
|
6
|
+
"description": "Add a Cypress component testing configuration to an existing project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g @nx/remix:cypress-component-configuration --project=my-remix-project",
|
|
11
|
+
"description": "Add component testing to your Remix project"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"command": "nx g @nx/remix:cypress-component-configuration --project=my-remix-project --generate-tests",
|
|
15
|
+
"description": "Add component testing to your Remix project and generate component tests for your existing components"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"project": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The name of the project to add cypress component testing configuration to",
|
|
22
|
+
"x-dropdown": "projects",
|
|
23
|
+
"x-prompt": "What project should we add Cypress component testing to?",
|
|
24
|
+
"x-priority": "important"
|
|
25
|
+
},
|
|
26
|
+
"generateTests": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Generate default component tests for existing components in the project",
|
|
29
|
+
"x-prompt": "Automatically generate tests for components declared in this project?",
|
|
30
|
+
"default": false,
|
|
31
|
+
"x-priority": "important"
|
|
32
|
+
},
|
|
33
|
+
"skipFormat": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"description": "Skip formatting files",
|
|
36
|
+
"default": false,
|
|
37
|
+
"x-priority": "internal"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["project"]
|
|
41
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ErrorBoundary --nameAndDirectoryFormat=as-provided --apiVersion=2 should correctly add the ErrorBoundary to the route file 1`] = `
|
|
4
|
+
"import { useRouteError, isRouteErrorResponse } from '@remix-run/react';
|
|
5
|
+
export function ErrorBoundary() {
|
|
6
|
+
const error = useRouteError();
|
|
7
|
+
|
|
8
|
+
// when true, this is what used to go to 'CatchBoundary'
|
|
9
|
+
if (isRouteErrorResponse(error)) {
|
|
10
|
+
return (
|
|
11
|
+
<div>
|
|
12
|
+
<h1>Oops</h1>
|
|
13
|
+
<p>Status: {error.status}</p>
|
|
14
|
+
<p>{error.data.message}</p>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
} else if (error instanceof Error) {
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
<h1>Error</h1>
|
|
21
|
+
<p>{error.message}</p>
|
|
22
|
+
<p>The stack trace is:</p>
|
|
23
|
+
<pre>{error.stack}</pre>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
return <h1>Unknown Error</h1>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
"
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports[`ErrorBoundary --nameAndDirectoryFormat=as-provided --apiVersion=2 should correctly add the ErrorBoundary to the route file 2`] = `
|
|
34
|
+
"import { useRouteError, isRouteErrorResponse } from '@remix-run/react';
|
|
35
|
+
export function ErrorBoundary() {
|
|
36
|
+
const error = useRouteError();
|
|
37
|
+
|
|
38
|
+
// when true, this is what used to go to 'CatchBoundary'
|
|
39
|
+
if (isRouteErrorResponse(error)) {
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<h1>Oops</h1>
|
|
43
|
+
<p>Status: {error.status}</p>
|
|
44
|
+
<p>{error.data.message}</p>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
} else if (error instanceof Error) {
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
<h1>Error</h1>
|
|
51
|
+
<p>{error.message}</p>
|
|
52
|
+
<p>The stack trace is:</p>
|
|
53
|
+
<pre>{error.stack}</pre>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
return <h1>Unknown Error</h1>;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
"
|
|
61
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const lib_1 = require("./lib");
|
|
5
|
+
async function errorBoundaryGenerator(tree, schema) {
|
|
6
|
+
const options = await (0, lib_1.normalizeOptions)(tree, schema);
|
|
7
|
+
(0, lib_1.addV2ErrorBoundary)(tree, options);
|
|
8
|
+
if (!options.skipFormat) {
|
|
9
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = errorBoundaryGenerator;
|