@nx/remix 16.8.2 → 17.2.5
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 -12
- 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 +776 -149
- 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 +8 -3
- 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 -13
- package/src/generators/library/lib/update-buildable-config.js +5 -2
- package/src/generators/library/library.impl.js +30 -33
- 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 +2 -2
- 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,27 +1,51 @@
|
|
|
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
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const cypress_1 = require("@nx/cypress");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
async function default_1(tree, options) {
|
|
8
|
+
const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = 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
|
+
callingGenerator: '@nx/remix:cypress',
|
|
14
|
+
});
|
|
15
|
+
const rootProject = e2eProjectRoot === '.';
|
|
16
|
+
let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
17
|
+
options.baseUrl ??= `http://localhost:${projectConfig.targets['serve'].options.port}`;
|
|
18
|
+
addFileServerTarget(tree, options, 'serve-static');
|
|
19
|
+
(0, devkit_1.addProjectConfiguration)(tree, e2eProjectName, {
|
|
20
|
+
projectType: 'application',
|
|
21
|
+
root: e2eProjectRoot,
|
|
22
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(e2eProjectRoot, 'src'),
|
|
23
|
+
targets: {},
|
|
24
|
+
tags: [],
|
|
25
|
+
implicitDependencies: [options.name],
|
|
26
|
+
});
|
|
27
|
+
const installTask = await (0, cypress_1.configurationGenerator)(tree, {
|
|
28
|
+
project: e2eProjectName,
|
|
29
|
+
directory: 'src',
|
|
30
|
+
linter: options.linter,
|
|
31
|
+
skipPackageJson: false,
|
|
32
|
+
skipFormat: true,
|
|
33
|
+
devServerTarget: `${options.project}:serve:development`,
|
|
34
|
+
baseUrl: options.baseUrl,
|
|
35
|
+
rootProject,
|
|
36
|
+
});
|
|
37
|
+
projectConfig = (0, devkit_1.readProjectConfiguration)(tree, e2eProjectName);
|
|
38
|
+
tree.delete((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'app.po.ts'));
|
|
39
|
+
tree.write((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'e2e', 'app.cy.ts'), `describe('webapp', () => {
|
|
16
40
|
beforeEach(() => cy.visit('/'));
|
|
17
41
|
|
|
18
42
|
it('should display welcome message', () => {
|
|
19
43
|
cy.get('h1').contains('Welcome to Remix');
|
|
20
44
|
});
|
|
21
45
|
});`);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
const supportFilePath = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'e2e.ts');
|
|
47
|
+
const supportContent = tree.read(supportFilePath, 'utf-8');
|
|
48
|
+
tree.write(supportFilePath, `${supportContent}
|
|
25
49
|
|
|
26
50
|
// from https://github.com/remix-run/indie-stack
|
|
27
51
|
Cypress.on("uncaught:exception", (err) => {
|
|
@@ -36,32 +60,18 @@ Cypress.on("uncaught:exception", (err) => {
|
|
|
36
60
|
return false;
|
|
37
61
|
}
|
|
38
62
|
});`);
|
|
39
|
-
|
|
40
|
-
// We'll wire it up manually and skip serve from Cypress.
|
|
41
|
-
projectConfig.targets.e2e.options.skipServe = true;
|
|
42
|
-
projectConfig.targets.e2e.options.baseUrl =
|
|
43
|
-
(_b = options.baseUrl) !== null && _b !== void 0 ? _b : 'http://localhost:3000';
|
|
44
|
-
projectConfig.targets.e2e.dependsOn = ['dev-server'];
|
|
45
|
-
delete projectConfig.targets.e2e.options.devServerTarget;
|
|
46
|
-
(_d = (_c = projectConfig.targets.e2e) === null || _c === void 0 ? void 0 : _c.configurations) === null || _d === void 0 ? true : delete _d.production.devServerTarget;
|
|
47
|
-
projectConfig.targets['dev-server'] = {
|
|
48
|
-
command: `nx serve ${options.project}`,
|
|
49
|
-
options: {
|
|
50
|
-
readyWhen: 'Server started',
|
|
51
|
-
},
|
|
52
|
-
configurations: {
|
|
53
|
-
production: {
|
|
54
|
-
command: `nx serve ${options.project} --configuration=production`,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfig);
|
|
59
|
-
// returning this in case the cypress generator has any side effects
|
|
60
|
-
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
yield initSideEffects();
|
|
62
|
-
yield projSideEffects();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
63
|
+
return (0, devkit_1.runTasksInSerial)(installTask);
|
|
65
64
|
}
|
|
66
65
|
exports.default = default_1;
|
|
67
|
-
|
|
66
|
+
function addFileServerTarget(tree, options, targetName) {
|
|
67
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/web': versions_1.nxVersion });
|
|
68
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
69
|
+
projectConfig.targets[targetName] = {
|
|
70
|
+
executor: '@nx/web:file-server',
|
|
71
|
+
options: {
|
|
72
|
+
buildTarget: `${options.project}:build`,
|
|
73
|
+
port: projectConfig.targets['serve'].options.port,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
77
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { type ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import { Linter } from '@nx/eslint';
|
|
3
|
+
|
|
1
4
|
export interface CypressGeneratorSchema {
|
|
2
5
|
project: string;
|
|
3
6
|
name: string;
|
|
4
7
|
baseUrl?: string;
|
|
5
8
|
directory?: string;
|
|
6
|
-
|
|
9
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
10
|
+
linter?: Linter;
|
|
7
11
|
js?: boolean;
|
|
8
12
|
skipFormat?: boolean;
|
|
9
13
|
setParserOptionsProject?: boolean;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"$id": "NxRemixCypress",
|
|
4
4
|
"title": "",
|
|
5
5
|
"type": "object",
|
|
6
|
+
"description": "Generate a Cypress e2e project for a given application.",
|
|
6
7
|
"properties": {
|
|
7
8
|
"project": {
|
|
8
9
|
"type": "string",
|
|
@@ -11,6 +12,11 @@
|
|
|
11
12
|
"$source": "projectName"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
15
|
+
"projectNameAndRootFormat": {
|
|
16
|
+
"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`).",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["as-provided", "derived"]
|
|
19
|
+
},
|
|
14
20
|
"baseUrl": {
|
|
15
21
|
"type": "string",
|
|
16
22
|
"description": "URL to access the application on",
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
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 cypressComponentConfigurationGenerator(tree, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
bundler: 'vite',
|
|
15
|
-
buildTarget: '',
|
|
16
|
-
});
|
|
17
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
18
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
|
|
19
|
-
if (!options.skipFormat) {
|
|
20
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
21
|
-
}
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
async function cypressComponentConfigurationGenerator(tree, options) {
|
|
7
|
+
await (0, react_1.cypressComponentConfigGenerator)(tree, {
|
|
8
|
+
project: options.project,
|
|
9
|
+
generateTests: options.generateTests,
|
|
10
|
+
skipFormat: true,
|
|
11
|
+
bundler: 'vite',
|
|
12
|
+
buildTarget: '',
|
|
22
13
|
});
|
|
14
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
15
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
|
|
16
|
+
if (!options.skipFormat) {
|
|
17
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
18
|
+
}
|
|
23
19
|
}
|
|
24
20
|
exports.default = cypressComponentConfigurationGenerator;
|
|
25
|
-
//# sourceMappingURL=cypress-component-configuration.impl.js.map
|
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`ErrorBoundary --apiVersion=
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
}
|
|
13
29
|
}
|
|
14
30
|
"
|
|
15
31
|
`;
|
|
16
32
|
|
|
17
|
-
exports[`ErrorBoundary --apiVersion=2 should correctly add the ErrorBoundary to the route file
|
|
18
|
-
"import {
|
|
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';
|
|
19
35
|
export function ErrorBoundary() {
|
|
20
36
|
const error = useRouteError();
|
|
21
37
|
|
|
@@ -28,22 +44,18 @@ export function ErrorBoundary() {
|
|
|
28
44
|
<p>{error.data.message}</p>
|
|
29
45
|
</div>
|
|
30
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>;
|
|
31
58
|
}
|
|
32
|
-
|
|
33
|
-
// Don't forget to typecheck with your own logic.
|
|
34
|
-
// Any value can be thrown, not just errors!
|
|
35
|
-
let errorMessage = 'Unknown error';
|
|
36
|
-
// if (isDefinitelyAnError(error)) {
|
|
37
|
-
// errorMessage = error.message;
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<h1>Uh oh ...</h1>
|
|
43
|
-
<p>Something went wrong.</p>
|
|
44
|
-
<pre>{errorMessage}</pre>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
59
|
}
|
|
48
60
|
"
|
|
49
61
|
`;
|
|
@@ -1,21 +1,12 @@
|
|
|
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 lib_1 = require("./lib");
|
|
6
|
-
function errorBoundaryGenerator(tree, schema) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
else {
|
|
13
|
-
(0, lib_1.addV2ErrorBoundary)(tree, options);
|
|
14
|
-
}
|
|
15
|
-
if (!options.skipFormat) {
|
|
16
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
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
|
+
}
|
|
19
11
|
}
|
|
20
12
|
exports.default = errorBoundaryGenerator;
|
|
21
|
-
//# sourceMappingURL=error-boundary.impl.js.map
|
|
@@ -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 v18.
|
|
9
|
+
*/
|
|
10
|
+
project?: string;
|
|
6
11
|
}
|
|
@@ -2,14 +2,24 @@
|
|
|
2
2
|
"$schema": "http://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": {
|
|
14
|
+
"path": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The path to route file relative to the project root."
|
|
17
|
+
},
|
|
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
|
+
},
|
|
13
23
|
"project": {
|
|
14
24
|
"type": "string",
|
|
15
25
|
"description": "The name of the project.",
|
|
@@ -17,16 +27,8 @@
|
|
|
17
27
|
"$source": "projectName"
|
|
18
28
|
},
|
|
19
29
|
"x-prompt": "What project contains the route file that this ErrorBoundary is for?",
|
|
20
|
-
"pattern": "^[a-zA-Z].*$"
|
|
21
|
-
|
|
22
|
-
"path": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "The path to route file relative to the project root."
|
|
25
|
-
},
|
|
26
|
-
"apiVersion": {
|
|
27
|
-
"type": "number",
|
|
28
|
-
"description": "Which version of the ErrorBoundary convention to use for the route.",
|
|
29
|
-
"default": 1
|
|
30
|
+
"pattern": "^[a-zA-Z].*$",
|
|
31
|
+
"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
32
|
},
|
|
31
33
|
"skipFormat": {
|
|
32
34
|
"type": "boolean",
|
|
@@ -35,5 +37,5 @@
|
|
|
35
37
|
"x-priority": "internal"
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
|
-
"required": ["
|
|
40
|
+
"required": ["path"]
|
|
39
41
|
}
|
|
@@ -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`);
|
|
18
|
+
const pathToVitestConfig = (0, devkit_1.joinPathFragments)(options.projectRoot, `vite.config.ts`);
|
|
20
19
|
(0, testing_config_utils_1.updateViteTestSetup)(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
|