@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,150 +1,200 @@
|
|
|
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 create_ts_config_1 = require("@nx/js/src/utils/typescript/create-ts-config");
|
|
6
5
|
const versions_1 = require("../../utils/versions");
|
|
7
|
-
const cypress_impl_1 = require("../cypress/cypress.impl");
|
|
8
6
|
const lib_1 = require("./lib");
|
|
9
|
-
function default_1(tree, _options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
|
|
24
|
-
},
|
|
7
|
+
async function default_1(tree, _options) {
|
|
8
|
+
const options = await (0, lib_1.normalizeOptions)(tree, _options);
|
|
9
|
+
const tasks = [];
|
|
10
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
|
|
11
|
+
root: options.projectRoot,
|
|
12
|
+
sourceRoot: `${options.projectRoot}`,
|
|
13
|
+
projectType: 'application',
|
|
14
|
+
tags: options.parsedTags,
|
|
15
|
+
targets: {
|
|
16
|
+
build: {
|
|
17
|
+
executor: '@nx/remix:build',
|
|
18
|
+
outputs: ['{options.outputPath}'],
|
|
19
|
+
options: {
|
|
20
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
|
|
25
21
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
22
|
+
},
|
|
23
|
+
serve: {
|
|
24
|
+
executor: `@nx/remix:serve`,
|
|
25
|
+
options: {
|
|
26
|
+
command: `${(0, devkit_1.getPackageManagerCommand)().exec} remix-serve build/index.js`,
|
|
27
|
+
manual: true,
|
|
28
|
+
port: 4200,
|
|
31
29
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
},
|
|
31
|
+
start: {
|
|
32
|
+
dependsOn: ['build'],
|
|
33
|
+
command: `remix-serve build/index.js`,
|
|
34
|
+
options: {
|
|
35
|
+
cwd: options.projectRoot,
|
|
38
36
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
},
|
|
38
|
+
typecheck: {
|
|
39
|
+
command: `tsc`,
|
|
40
|
+
options: {
|
|
41
|
+
cwd: options.projectRoot,
|
|
44
42
|
},
|
|
45
43
|
},
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
project: options.projectName,
|
|
96
|
-
skipFormat: true,
|
|
97
|
-
setupFile: 'none',
|
|
98
|
-
supportTsx: true,
|
|
99
|
-
});
|
|
100
|
-
tasks.push(jestTask);
|
|
101
|
-
}
|
|
102
|
-
const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner);
|
|
103
|
-
tasks.push(pkgInstallTask);
|
|
104
|
-
}
|
|
105
|
-
if (options.js) {
|
|
106
|
-
(0, devkit_1.toJS)(tree);
|
|
107
|
-
}
|
|
108
|
-
if (options.rootProject && tree.exists('tsconfig.base.json')) {
|
|
109
|
-
// If this is a standalone project, merge tsconfig.json and tsconfig.base.json.
|
|
110
|
-
const tsConfigBaseJson = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
|
|
111
|
-
(0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
|
|
112
|
-
var _a, _b, _c, _d;
|
|
113
|
-
delete json.extends;
|
|
114
|
-
json.compilerOptions = Object.assign(Object.assign(Object.assign({}, tsConfigBaseJson.compilerOptions), json.compilerOptions), {
|
|
115
|
-
// Taken from remix default setup
|
|
116
|
-
// https://github.com/remix-run/remix/blob/68c8982/templates/remix/tsconfig.json#L15-L17
|
|
117
|
-
paths: {
|
|
118
|
-
'~/*': ['./app/*'],
|
|
119
|
-
} });
|
|
120
|
-
json.include = [
|
|
121
|
-
...((_a = tsConfigBaseJson.include) !== null && _a !== void 0 ? _a : []),
|
|
122
|
-
...((_b = json.include) !== null && _b !== void 0 ? _b : []),
|
|
123
|
-
];
|
|
124
|
-
json.exclude = [
|
|
125
|
-
...((_c = tsConfigBaseJson.exclude) !== null && _c !== void 0 ? _c : []),
|
|
126
|
-
...((_d = json.exclude) !== null && _d !== void 0 ? _d : []),
|
|
127
|
-
];
|
|
128
|
-
return json;
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
47
|
+
'@remix-run/node': versions_1.remixVersion,
|
|
48
|
+
'@remix-run/react': versions_1.remixVersion,
|
|
49
|
+
'@remix-run/serve': versions_1.remixVersion,
|
|
50
|
+
isbot: versions_1.isbotVersion,
|
|
51
|
+
react: versions_1.reactVersion,
|
|
52
|
+
'react-dom': versions_1.reactDomVersion,
|
|
53
|
+
}, {
|
|
54
|
+
'@remix-run/dev': versions_1.remixVersion,
|
|
55
|
+
'@remix-run/eslint-config': versions_1.remixVersion,
|
|
56
|
+
'@types/react': versions_1.typesReactVersion,
|
|
57
|
+
'@types/react-dom': versions_1.typesReactDomVersion,
|
|
58
|
+
eslint: versions_1.eslintVersion,
|
|
59
|
+
typescript: versions_1.typescriptVersion,
|
|
60
|
+
});
|
|
61
|
+
tasks.push(installTask);
|
|
62
|
+
const vars = {
|
|
63
|
+
...options,
|
|
64
|
+
tmpl: '',
|
|
65
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
66
|
+
remixVersion: versions_1.remixVersion,
|
|
67
|
+
isbotVersion: versions_1.isbotVersion,
|
|
68
|
+
reactVersion: versions_1.reactVersion,
|
|
69
|
+
reactDomVersion: versions_1.reactDomVersion,
|
|
70
|
+
typesReactVersion: versions_1.typesReactVersion,
|
|
71
|
+
typesReactDomVersion: versions_1.typesReactDomVersion,
|
|
72
|
+
eslintVersion: versions_1.eslintVersion,
|
|
73
|
+
typescriptVersion: versions_1.typescriptVersion,
|
|
74
|
+
};
|
|
75
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/common'), options.projectRoot, vars);
|
|
76
|
+
if (options.rootProject) {
|
|
77
|
+
const gitignore = tree.read('.gitignore', 'utf-8');
|
|
78
|
+
tree.write('.gitignore', `${gitignore}\n.cache\nbuild\npublic/build\n.env\n`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/integrated'), options.projectRoot, vars);
|
|
82
|
+
}
|
|
83
|
+
if (options.unitTestRunner !== 'none') {
|
|
84
|
+
if (options.unitTestRunner === 'vitest') {
|
|
85
|
+
const { vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
86
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
87
|
+
uiFramework: 'react',
|
|
88
|
+
project: options.projectName,
|
|
89
|
+
coverageProvider: 'v8',
|
|
90
|
+
inSourceTests: false,
|
|
91
|
+
skipFormat: true,
|
|
92
|
+
testEnvironment: 'jsdom',
|
|
129
93
|
});
|
|
130
|
-
|
|
94
|
+
tasks.push(vitestTask);
|
|
131
95
|
}
|
|
132
96
|
else {
|
|
133
|
-
|
|
134
|
-
(
|
|
135
|
-
}
|
|
136
|
-
if (options.e2eTestRunner === 'cypress') {
|
|
137
|
-
const cypressTasks = yield (0, cypress_impl_1.default)(tree, {
|
|
97
|
+
const { configurationGenerator: jestConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
98
|
+
const jestTask = await jestConfigurationGenerator(tree, {
|
|
138
99
|
project: options.projectName,
|
|
139
|
-
|
|
100
|
+
setupFile: 'none',
|
|
101
|
+
supportTsx: true,
|
|
102
|
+
skipSerializers: false,
|
|
103
|
+
skipPackageJson: false,
|
|
104
|
+
skipFormat: true,
|
|
140
105
|
});
|
|
141
|
-
|
|
106
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
107
|
+
projectConfig.targets['test'].options.passWithNoTests = true;
|
|
108
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
|
|
109
|
+
tasks.push(jestTask);
|
|
142
110
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
111
|
+
const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner);
|
|
112
|
+
tasks.push(pkgInstallTask);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
tree.delete((0, devkit_1.joinPathFragments)(options.projectRoot, `tests/routes/_index.spec.tsx`));
|
|
116
|
+
}
|
|
117
|
+
if (options.linter !== 'none') {
|
|
118
|
+
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
119
|
+
const eslintTask = await lintProjectGenerator(tree, {
|
|
120
|
+
linter: options.linter,
|
|
121
|
+
project: options.projectName,
|
|
122
|
+
tsConfigPaths: [
|
|
123
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
|
|
124
|
+
],
|
|
125
|
+
unitTestRunner: options.unitTestRunner,
|
|
126
|
+
skipFormat: true,
|
|
127
|
+
rootProject: options.rootProject,
|
|
128
|
+
});
|
|
129
|
+
tasks.push(eslintTask);
|
|
130
|
+
}
|
|
131
|
+
if (options.js) {
|
|
132
|
+
(0, devkit_1.toJS)(tree);
|
|
133
|
+
}
|
|
134
|
+
if (options.rootProject && tree.exists('tsconfig.base.json')) {
|
|
135
|
+
// If this is a standalone project, merge tsconfig.json and tsconfig.base.json.
|
|
136
|
+
const tsConfigBaseJson = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
|
|
137
|
+
(0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
|
|
138
|
+
delete json.extends;
|
|
139
|
+
json.compilerOptions = {
|
|
140
|
+
...tsConfigBaseJson.compilerOptions,
|
|
141
|
+
...json.compilerOptions,
|
|
142
|
+
// Taken from remix default setup
|
|
143
|
+
// https://github.com/remix-run/remix/blob/68c8982/templates/remix/tsconfig.json#L15-L17
|
|
144
|
+
paths: {
|
|
145
|
+
'~/*': ['./app/*'],
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
json.include = [
|
|
149
|
+
...(tsConfigBaseJson.include ?? []),
|
|
150
|
+
...(json.include ?? []),
|
|
151
|
+
];
|
|
152
|
+
json.exclude = [
|
|
153
|
+
...(tsConfigBaseJson.exclude ?? []),
|
|
154
|
+
...(json.exclude ?? []),
|
|
155
|
+
];
|
|
156
|
+
return json;
|
|
157
|
+
});
|
|
158
|
+
tree.delete('tsconfig.base.json');
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// Otherwise, extract the tsconfig.base.json from tsconfig.json so we can share settings.
|
|
162
|
+
(0, create_ts_config_1.extractTsConfigBase)(tree);
|
|
163
|
+
}
|
|
164
|
+
if (options.e2eTestRunner === 'cypress') {
|
|
165
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
166
|
+
addFileServerTarget(tree, options, 'serve-static');
|
|
167
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
168
|
+
projectType: 'application',
|
|
169
|
+
root: options.e2eProjectRoot,
|
|
170
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
171
|
+
targets: {},
|
|
172
|
+
tags: [],
|
|
173
|
+
implicitDependencies: [options.projectName],
|
|
174
|
+
});
|
|
175
|
+
tasks.push(await configurationGenerator(tree, {
|
|
176
|
+
project: options.e2eProjectName,
|
|
177
|
+
directory: 'src',
|
|
178
|
+
skipFormat: true,
|
|
179
|
+
devServerTarget: `${options.projectName}:serve:development`,
|
|
180
|
+
baseUrl: 'http://localhost:4200',
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
if (!options.skipFormat) {
|
|
184
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
185
|
+
}
|
|
186
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
148
187
|
}
|
|
149
188
|
exports.default = default_1;
|
|
150
|
-
|
|
189
|
+
function addFileServerTarget(tree, options, targetName) {
|
|
190
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/web': (0, versions_1.getPackageVersion)(tree, 'nx') });
|
|
191
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
192
|
+
projectConfig.targets[targetName] = {
|
|
193
|
+
executor: '@nx/web:file-server',
|
|
194
|
+
options: {
|
|
195
|
+
buildTarget: `${options.projectName}:build`,
|
|
196
|
+
port: 4200,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
|
|
200
|
+
}
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
ScrollRestoration,
|
|
9
9
|
} from "@remix-run/react";
|
|
10
10
|
|
|
11
|
-
export const meta: MetaFunction = () => ({
|
|
11
|
+
export const meta: MetaFunction = () => ([{
|
|
12
12
|
charset: "utf-8",
|
|
13
13
|
title: "New Remix App",
|
|
14
14
|
viewport: "width=device-width,initial-scale=1",
|
|
15
|
-
});
|
|
15
|
+
}]);
|
|
16
16
|
|
|
17
17
|
export default function App() {
|
|
18
18
|
return (
|
|
@@ -29,4 +29,4 @@ export default function App() {
|
|
|
29
29
|
</body>
|
|
30
30
|
</html>
|
|
31
31
|
);
|
|
32
|
-
}
|
|
32
|
+
}
|
|
@@ -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('Welcome to Remix'));
|
|
16
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { NxRemixGeneratorSchema } from '../schema';
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { type NxRemixGeneratorSchema } from '../schema';
|
|
3
3
|
export interface NormalizedSchema extends NxRemixGeneratorSchema {
|
|
4
4
|
projectName: string;
|
|
5
5
|
projectRoot: string;
|
|
6
|
+
e2eProjectName: string;
|
|
7
|
+
e2eProjectRoot: string;
|
|
6
8
|
parsedTags: string[];
|
|
7
9
|
}
|
|
8
|
-
export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): NormalizedSchema
|
|
10
|
+
export declare function normalizeOptions(tree: Tree, options: NxRemixGeneratorSchema): Promise<NormalizedSchema>;
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
function normalizeOptions(tree, options) {
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
5
|
+
const eslint_1 = require("@nx/eslint");
|
|
6
|
+
async function normalizeOptions(tree, options) {
|
|
7
|
+
const { projectName, projectRoot, projectNameAndRootFormat } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
8
|
+
name: options.name,
|
|
9
|
+
projectType: 'application',
|
|
10
|
+
directory: options.directory,
|
|
11
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
|
+
rootProject: options.rootProject,
|
|
13
|
+
callingGenerator: '@nx/remix:application',
|
|
14
|
+
});
|
|
15
|
+
options.rootProject = projectRoot === '.';
|
|
16
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
17
|
+
const e2eProjectName = options.rootProject ? 'e2e' : `${projectName}-e2e`;
|
|
18
|
+
const e2eProjectRoot = options.rootProject ? 'e2e' : `${projectRoot}-e2e`;
|
|
16
19
|
const parsedTags = options.tags
|
|
17
20
|
? options.tags.split(',').map((s) => s.trim())
|
|
18
21
|
: [];
|
|
19
|
-
return
|
|
22
|
+
return {
|
|
23
|
+
...options,
|
|
24
|
+
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
25
|
+
projectName,
|
|
20
26
|
projectRoot,
|
|
21
|
-
|
|
27
|
+
e2eProjectName,
|
|
28
|
+
e2eProjectRoot,
|
|
29
|
+
parsedTags,
|
|
30
|
+
};
|
|
22
31
|
}
|
|
23
32
|
exports.normalizeOptions = normalizeOptions;
|
|
24
|
-
//# sourceMappingURL=normalize-options.js.map
|
|
@@ -8,23 +8,28 @@ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
|
|
|
8
8
|
const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
|
|
9
9
|
tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
|
|
10
10
|
import { installGlobals } from '@remix-run/node';
|
|
11
|
-
import '@testing-library/jest-dom/
|
|
11
|
+
import '@testing-library/jest-dom/matchers';
|
|
12
12
|
installGlobals();`);
|
|
13
13
|
if (unitTestRunner === 'vitest') {
|
|
14
14
|
const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vite.config.ts');
|
|
15
15
|
(0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
|
|
16
|
-
(0, testing_config_utils_1.
|
|
16
|
+
(0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
|
|
17
|
+
(0, testing_config_utils_1.updateViteTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
|
|
17
18
|
}
|
|
18
19
|
else if (unitTestRunner === 'jest') {
|
|
19
20
|
const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
|
|
21
|
+
tree.rename('jest.preset.js', 'jest.preset.cjs');
|
|
20
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'));
|
|
21
26
|
}
|
|
22
27
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
23
28
|
'@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
|
|
24
29
|
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
25
30
|
'@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
|
|
26
31
|
'@remix-run/node': (0, versions_1.getRemixVersion)(tree),
|
|
32
|
+
'@remix-run/testing': (0, versions_1.getRemixVersion)(tree),
|
|
27
33
|
});
|
|
28
34
|
}
|
|
29
35
|
exports.updateUnitTestConfig = updateUnitTestConfig;
|
|
30
|
-
//# sourceMappingURL=update-unit-test-config.js.map
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/eslint';
|
|
3
|
+
|
|
1
4
|
export interface NxRemixGeneratorSchema {
|
|
2
5
|
name: string;
|
|
3
6
|
tags?: string;
|
|
4
7
|
js?: boolean;
|
|
5
8
|
directory?: string;
|
|
9
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
10
|
+
linter?: Linter;
|
|
6
11
|
unitTestRunner?: 'vitest' | 'jest' | 'none';
|
|
7
12
|
e2eTestRunner?: 'cypress' | 'none';
|
|
8
13
|
skipFormat?: boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "NxRemixApplication",
|
|
4
4
|
"title": "Create an Application",
|
|
5
|
+
"description": "Generate a new Remix application.",
|
|
5
6
|
"type": "object",
|
|
6
7
|
"properties": {
|
|
7
8
|
"name": {
|
|
@@ -24,23 +25,27 @@
|
|
|
24
25
|
"alias": "dir",
|
|
25
26
|
"x-priority": "important"
|
|
26
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
|
+
},
|
|
27
39
|
"unitTestRunner": {
|
|
28
40
|
"type": "string",
|
|
29
|
-
"enum": [
|
|
30
|
-
"vitest",
|
|
31
|
-
"jest",
|
|
32
|
-
"none"
|
|
33
|
-
],
|
|
41
|
+
"enum": ["vitest", "jest", "none"],
|
|
34
42
|
"default": "vitest",
|
|
35
43
|
"description": "Test runner to use for unit tests.",
|
|
36
44
|
"x-prompt": "What unit test runner should be used?"
|
|
37
45
|
},
|
|
38
46
|
"e2eTestRunner": {
|
|
39
47
|
"type": "string",
|
|
40
|
-
"enum": [
|
|
41
|
-
"cypress",
|
|
42
|
-
"none"
|
|
43
|
-
],
|
|
48
|
+
"enum": ["cypress", "none"],
|
|
44
49
|
"default": "cypress",
|
|
45
50
|
"description": "Test runner to use for e2e tests"
|
|
46
51
|
},
|