@nx/remix 17.0.0 → 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 -13
- package/plugins/component-testing/index.js +11 -6
- package/src/executors/build/build.impl.js +64 -74
- package/src/executors/serve/serve.impl.js +43 -43
- package/src/generators/action/action.impl.js +24 -26
- package/src/generators/action/schema.d.ts +7 -1
- package/src/generators/action/schema.json +10 -3
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +774 -147
- 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 -12
- package/src/generators/library/lib/update-buildable-config.js +5 -2
- package/src/generators/library/library.impl.js +29 -32
- package/src/generators/library/schema.d.ts +2 -0
- package/src/generators/library/schema.json +6 -0
- package/src/generators/loader/loader.impl.js +24 -26
- package/src/generators/loader/schema.d.ts +7 -1
- package/src/generators/loader/schema.json +10 -3
- package/src/generators/meta/lib/v2.impl.js +14 -16
- package/src/generators/meta/meta.impl.js +2 -17
- package/src/generators/meta/schema.d.ts +7 -2
- package/src/generators/meta/schema.json +10 -7
- package/src/generators/preset/lib/normalize-options.js +5 -3
- package/src/generators/preset/preset.impl.js +18 -23
- package/src/generators/preset/schema.json +1 -0
- package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
- package/src/generators/resource-route/resource-route.impl.js +32 -26
- package/src/generators/resource-route/schema.d.ts +7 -1
- package/src/generators/resource-route/schema.json +10 -3
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
- package/src/generators/route/route.impl.js +55 -43
- package/src/generators/route/schema.d.ts +7 -1
- package/src/generators/route/schema.json +11 -4
- package/src/generators/setup/schema.json +1 -0
- package/src/generators/setup/setup.impl.js +23 -23
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +27 -23
- package/src/generators/setup-tailwind/lib/index.js +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js +2 -3
- package/src/generators/setup-tailwind/schema.json +1 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
- package/src/generators/storybook-configuration/schema.d.ts +1 -1
- package/src/generators/storybook-configuration/schema.json +4 -11
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +8 -13
- package/src/generators/style/schema.d.ts +7 -1
- package/src/generators/style/schema.json +12 -5
- package/src/generators/style/style.impl.js +32 -24
- package/src/utils/create-watch-paths.js +8 -13
- package/src/utils/get-default-export-name.js +1 -3
- package/src/utils/get-default-export.js +0 -1
- package/src/utils/insert-import.js +0 -1
- package/src/utils/insert-statement-after-imports.js +0 -1
- package/src/utils/insert-statement-in-default-function.js +0 -1
- package/src/utils/remix-config.d.ts +1 -2
- package/src/utils/remix-config.js +8 -9
- package/src/utils/remix-route-utils.d.ts +2 -2
- package/src/utils/remix-route-utils.js +23 -17
- package/src/utils/testing-config-utils.js +0 -1
- package/src/utils/upsert-links-function.js +0 -1
- package/src/utils/versions.d.ts +9 -8
- package/src/utils/versions.js +14 -14
- package/plugins/component-testing/index.js.map +0 -1
- package/src/executors/build/build.impl.js.map +0 -1
- package/src/executors/build/compat.d.ts +0 -2
- package/src/executors/build/compat.js +0 -6
- package/src/executors/build/compat.js.map +0 -1
- package/src/executors/serve/compat.d.ts +0 -2
- package/src/executors/serve/compat.js +0 -6
- package/src/executors/serve/compat.js.map +0 -1
- package/src/executors/serve/serve.impl.js.map +0 -1
- package/src/generators/action/action.impl.js.map +0 -1
- package/src/generators/application/application.impl.js.map +0 -1
- package/src/generators/application/lib/index.js.map +0 -1
- package/src/generators/application/lib/normalize-options.js.map +0 -1
- package/src/generators/application/lib/update-unit-test-config.js.map +0 -1
- package/src/generators/cypress/cypress.impl.js.map +0 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +0 -1
- package/src/generators/error-boundary/error-boundary.impl.js.map +0 -1
- package/src/generators/error-boundary/lib/add-v1-error-boundary.d.ts +0 -3
- package/src/generators/error-boundary/lib/add-v1-error-boundary.js +0 -21
- package/src/generators/error-boundary/lib/add-v1-error-boundary.js.map +0 -1
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js.map +0 -1
- package/src/generators/error-boundary/lib/index.js.map +0 -1
- package/src/generators/error-boundary/lib/normalize-options.js.map +0 -1
- package/src/generators/library/lib/add-tsconfig-entry-points.js.map +0 -1
- package/src/generators/library/lib/add-unit-testing.js.map +0 -1
- package/src/generators/library/lib/index.js.map +0 -1
- package/src/generators/library/lib/normalize-options.js.map +0 -1
- package/src/generators/library/lib/update-buildable-config.js.map +0 -1
- package/src/generators/library/library.impl.js.map +0 -1
- package/src/generators/loader/loader.impl.js.map +0 -1
- package/src/generators/meta/lib/normalize-options.d.ts +0 -3
- package/src/generators/meta/lib/normalize-options.js +0 -15
- package/src/generators/meta/lib/normalize-options.js.map +0 -1
- package/src/generators/meta/lib/v1.impl.d.ts +0 -3
- package/src/generators/meta/lib/v1.impl.js +0 -30
- package/src/generators/meta/lib/v1.impl.js.map +0 -1
- package/src/generators/meta/lib/v2.impl.js.map +0 -1
- package/src/generators/meta/meta.impl.js.map +0 -1
- package/src/generators/preset/lib/normalize-options.js.map +0 -1
- package/src/generators/preset/preset.impl.js.map +0 -1
- package/src/generators/resource-route/resource-route.impl.js.map +0 -1
- package/src/generators/route/route.impl.js.map +0 -1
- package/src/generators/setup/setup.impl.js.map +0 -1
- package/src/generators/setup-tailwind/lib/index.js.map +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js.map +0 -1
- package/src/generators/setup-tailwind/setup-tailwind.impl.js.map +0 -1
- package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +0 -1
- package/src/generators/style/style.impl.js.map +0 -1
- package/src/index.d.ts +0 -15
- package/src/index.js +0 -21
- package/src/index.js.map +0 -1
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +0 -6
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +0 -45
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +0 -1
- package/src/migrations/update-15-8-6/update-remix-env-d.d.ts +0 -6
- package/src/migrations/update-15-8-6/update-remix-env-d.js +0 -27
- package/src/migrations/update-15-8-6/update-remix-env-d.js.map +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -13
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
- package/src/utils/create-watch-paths.js.map +0 -1
- package/src/utils/get-default-export-name.js.map +0 -1
- package/src/utils/get-default-export.js.map +0 -1
- package/src/utils/get-remix-projects.d.ts +0 -2
- package/src/utils/get-remix-projects.js +0 -15
- package/src/utils/get-remix-projects.js.map +0 -1
- package/src/utils/insert-import.js.map +0 -1
- package/src/utils/insert-statement-after-imports.js.map +0 -1
- package/src/utils/insert-statement-in-default-function.js.map +0 -1
- package/src/utils/project.d.ts +0 -2
- package/src/utils/project.js +0 -15
- package/src/utils/project.js.map +0 -1
- package/src/utils/remix-config.js.map +0 -1
- package/src/utils/remix-route-utils.js.map +0 -1
- package/src/utils/testing-config-utils.js.map +0 -1
- package/src/utils/upsert-links-function.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
- /package/src/generators/application/files/common/app/routes/{index.tsx__tmpl__ → _index.tsx__tmpl__} +0 -0
- /package/src/generators/application/files/common/{remix.config.js__tmpl__ → remix.config.cjs__tmpl__} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const js_1 = require("@nx/js");
|
|
6
5
|
const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
|
|
@@ -14,95 +13,87 @@ function buildRemixBuildArgs(options) {
|
|
|
14
13
|
}
|
|
15
14
|
return args;
|
|
16
15
|
}
|
|
17
|
-
function runBuild(options, context) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
reject();
|
|
32
|
-
});
|
|
16
|
+
async function runBuild(options, context) {
|
|
17
|
+
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const remixBin = require.resolve('@remix-run/dev/dist/cli');
|
|
20
|
+
const args = buildRemixBuildArgs(options);
|
|
21
|
+
const p = (0, child_process_1.fork)(remixBin, args, {
|
|
22
|
+
cwd: (0, path_1.join)(context.root, projectRoot),
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
});
|
|
25
|
+
p.on('exit', (code) => {
|
|
26
|
+
if (code === 0)
|
|
27
|
+
resolve();
|
|
28
|
+
else
|
|
29
|
+
reject();
|
|
33
30
|
});
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
|
-
function buildExecutor(options, context) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!packageJson.scripts.start) {
|
|
61
|
-
packageJson.scripts['start'] = 'remix-serve ./build';
|
|
62
|
-
}
|
|
63
|
-
updatePackageJson(packageJson, context);
|
|
64
|
-
(0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
packageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, 'package.json'));
|
|
68
|
-
}
|
|
69
|
-
if (options.generateLockfile) {
|
|
70
|
-
const packageManager = (0, devkit_1.detectPackageManager)(context.root);
|
|
71
|
-
const lockFile = (0, js_1.createLockFile)(packageJson, context.projectGraph, packageManager);
|
|
72
|
-
(0, fs_extra_1.writeFileSync)(`${options.outputPath}/${(0, js_1.getLockFileName)(packageManager)}`, lockFile, {
|
|
73
|
-
encoding: 'utf-8',
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
// If output path is different from source path, then copy over the config and public files.
|
|
77
|
-
// This is the default behavior when running `nx build <app>`.
|
|
78
|
-
if (options.outputPath.replace(/\/$/, '') !== projectRoot) {
|
|
79
|
-
(0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'public'), (0, path_1.join)(options.outputPath, 'public'), {
|
|
80
|
-
dereference: true,
|
|
81
|
-
});
|
|
82
|
-
(0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'build'), (0, path_1.join)(options.outputPath, 'build'), {
|
|
83
|
-
dereference: true,
|
|
84
|
-
});
|
|
33
|
+
async function buildExecutor(options, context) {
|
|
34
|
+
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
|
|
35
|
+
try {
|
|
36
|
+
await runBuild(options, context);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
devkit_1.logger.error(`Error occurred while trying to build application. See above for more details.`);
|
|
40
|
+
return { success: false };
|
|
41
|
+
}
|
|
42
|
+
if (!(0, fileutils_1.directoryExists)(options.outputPath)) {
|
|
43
|
+
(0, fs_extra_1.mkdir)(options.outputPath);
|
|
44
|
+
}
|
|
45
|
+
let packageJson;
|
|
46
|
+
if (options.generatePackageJson) {
|
|
47
|
+
packageJson = (0, js_1.createPackageJson)(context.projectName, context.projectGraph, {
|
|
48
|
+
target: context.targetName,
|
|
49
|
+
root: context.root,
|
|
50
|
+
isProduction: !options.includeDevDependenciesInPackageJson, // By default we remove devDependencies since this is a production build.
|
|
51
|
+
});
|
|
52
|
+
// Update `package.json` to reflect how users should run the build artifacts
|
|
53
|
+
packageJson.scripts ??= {};
|
|
54
|
+
// Don't override existing custom script since project may have its own server.
|
|
55
|
+
if (!packageJson.scripts.start) {
|
|
56
|
+
packageJson.scripts['start'] = 'remix-serve ./build';
|
|
85
57
|
}
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
updatePackageJson(packageJson, context);
|
|
59
|
+
(0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
packageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(projectRoot, 'package.json'));
|
|
63
|
+
}
|
|
64
|
+
if (options.generateLockfile) {
|
|
65
|
+
const packageManager = (0, devkit_1.detectPackageManager)(context.root);
|
|
66
|
+
const lockFile = (0, js_1.createLockFile)(packageJson, context.projectGraph, packageManager);
|
|
67
|
+
(0, fs_extra_1.writeFileSync)(`${options.outputPath}/${(0, js_1.getLockFileName)(packageManager)}`, lockFile, {
|
|
68
|
+
encoding: 'utf-8',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// If output path is different from source path, then copy over the config and public files.
|
|
72
|
+
// This is the default behavior when running `nx build <app>`.
|
|
73
|
+
if (options.outputPath.replace(/\/$/, '') !== projectRoot) {
|
|
74
|
+
(0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'public'), (0, path_1.join)(options.outputPath, 'public'), {
|
|
75
|
+
dereference: true,
|
|
76
|
+
});
|
|
77
|
+
(0, fs_extra_1.copySync)((0, path_1.join)(projectRoot, 'build'), (0, path_1.join)(options.outputPath, 'build'), {
|
|
78
|
+
dereference: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return { success: true };
|
|
88
82
|
}
|
|
89
83
|
exports.default = buildExecutor;
|
|
90
84
|
function updatePackageJson(packageJson, context) {
|
|
91
|
-
var _a, _b;
|
|
92
|
-
var _c;
|
|
93
85
|
if (!packageJson.scripts) {
|
|
94
86
|
packageJson.scripts = {};
|
|
95
87
|
}
|
|
96
88
|
if (!packageJson.scripts.start) {
|
|
97
89
|
packageJson.scripts.start = 'remix-serve build';
|
|
98
90
|
}
|
|
99
|
-
|
|
91
|
+
packageJson.dependencies ??= {};
|
|
100
92
|
// These are always required for a production Remix app to run.
|
|
101
93
|
const requiredPackages = [
|
|
102
94
|
'react',
|
|
103
95
|
'react-dom',
|
|
104
96
|
'isbot',
|
|
105
|
-
'typescript',
|
|
106
97
|
'@remix-run/css-bundle',
|
|
107
98
|
'@remix-run/node',
|
|
108
99
|
'@remix-run/react',
|
|
@@ -112,8 +103,7 @@ function updatePackageJson(packageJson, context) {
|
|
|
112
103
|
for (const pkg of requiredPackages) {
|
|
113
104
|
const externalNode = context.projectGraph.externalNodes[`npm:${pkg}`];
|
|
114
105
|
if (externalNode) {
|
|
115
|
-
|
|
106
|
+
packageJson.dependencies[pkg] ??= externalNode.data.version;
|
|
116
107
|
}
|
|
117
108
|
}
|
|
118
109
|
}
|
|
119
|
-
//# sourceMappingURL=build.impl.js.map
|
|
@@ -1,14 +1,17 @@
|
|
|
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 async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
6
5
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
7
6
|
const node_child_process_1 = require("node:child_process");
|
|
8
7
|
const node_path_1 = require("node:path");
|
|
9
8
|
function normalizeOptions(schema) {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return {
|
|
10
|
+
...schema,
|
|
11
|
+
port: schema.port ?? 4200,
|
|
12
|
+
debug: schema.debug ?? false,
|
|
13
|
+
manual: schema.manual ?? false,
|
|
14
|
+
};
|
|
12
15
|
}
|
|
13
16
|
function buildRemixDevArgs(options) {
|
|
14
17
|
const args = [];
|
|
@@ -32,46 +35,43 @@ function buildRemixDevArgs(options) {
|
|
|
32
35
|
}
|
|
33
36
|
return args;
|
|
34
37
|
}
|
|
35
|
-
function serveExecutor(schema, context) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
})))));
|
|
38
|
+
async function* serveExecutor(schema, context) {
|
|
39
|
+
const options = normalizeOptions(schema);
|
|
40
|
+
const projectRoot = context.workspace.projects[context.projectName].root;
|
|
41
|
+
const remixBin = require.resolve('@remix-run/dev/dist/cli');
|
|
42
|
+
const args = buildRemixDevArgs(options);
|
|
43
|
+
// Cast to any to overwrite NODE_ENV
|
|
44
|
+
process.env.NODE_ENV = process.env.NODE_ENV
|
|
45
|
+
? process.env.NODE_ENV
|
|
46
|
+
: 'development';
|
|
47
|
+
process.env.PORT = `${options.port}`;
|
|
48
|
+
yield* (0, async_iterable_1.createAsyncIterable)(async ({ done, next, error }) => {
|
|
49
|
+
const server = (0, node_child_process_1.fork)(remixBin, ['dev', ...args], {
|
|
50
|
+
cwd: (0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot),
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
});
|
|
53
|
+
server.once('exit', (code) => {
|
|
54
|
+
if (code === 0) {
|
|
55
|
+
done();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
error(new Error(`Remix app exited with code ${code}`));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const killServer = () => {
|
|
62
|
+
if (server.connected) {
|
|
63
|
+
server.kill('SIGTERM');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
process.on('exit', () => killServer());
|
|
67
|
+
process.on('SIGINT', () => killServer());
|
|
68
|
+
process.on('SIGTERM', () => killServer());
|
|
69
|
+
process.on('SIGHUP', () => killServer());
|
|
70
|
+
await (0, wait_for_port_open_1.waitForPortOpen)(options.port);
|
|
71
|
+
next({
|
|
72
|
+
success: true,
|
|
73
|
+
baseUrl: `http://localhost:${options.port}`,
|
|
74
|
+
});
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
exports.default = serveExecutor;
|
|
77
|
-
//# sourceMappingURL=serve.impl.js.map
|
|
@@ -1,41 +1,39 @@
|
|
|
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 insert_import_1 = require("../../utils/insert-import");
|
|
6
5
|
const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
|
|
7
6
|
const insert_statement_in_default_function_1 = require("../../utils/insert-statement-in-default-function");
|
|
8
7
|
const remix_route_utils_1 = require("../../utils/remix-route-utils");
|
|
9
|
-
function default_1(tree, schema) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
async function default_1(tree, schema) {
|
|
9
|
+
const routeFilePath = schema.nameAndDirectoryFormat === 'as-provided'
|
|
10
|
+
? schema.path
|
|
11
|
+
: await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
|
|
12
|
+
if (!tree.exists(routeFilePath)) {
|
|
13
|
+
throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
|
|
14
|
+
}
|
|
15
|
+
(0, insert_import_1.insertImport)(tree, routeFilePath, 'ActionFunctionArgs', '@remix-run/node', {
|
|
16
|
+
typeOnly: true,
|
|
17
|
+
});
|
|
18
|
+
(0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
|
|
19
|
+
(0, insert_import_1.insertImport)(tree, routeFilePath, 'useActionData', '@remix-run/react');
|
|
20
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
|
|
21
|
+
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
22
22
|
let formData = await request.formData();
|
|
23
23
|
|
|
24
24
|
return json({message: formData.toString()}, { status: 200 });
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
`);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
28
|
+
const statement = `\nconst actionMessage = useActionData<typeof action>();`;
|
|
29
|
+
try {
|
|
30
|
+
(0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
// eslint-disable-next-line no-empty
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
37
|
+
}
|
|
39
38
|
}
|
|
40
39
|
exports.default = default_1;
|
|
41
|
-
//# sourceMappingURL=action.impl.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface LoaderSchema {
|
|
2
4
|
path: string;
|
|
3
|
-
|
|
5
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Provide the `path` option instead. The project will be determined from the path provided. It will be removed in Nx v18.
|
|
8
|
+
*/
|
|
9
|
+
project?: string;
|
|
4
10
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "action",
|
|
4
4
|
"type": "object",
|
|
5
|
+
"description": "Generate an action for a given route.",
|
|
5
6
|
"properties": {
|
|
6
7
|
"path": {
|
|
7
8
|
"type": "string",
|
|
@@ -10,7 +11,12 @@
|
|
|
10
11
|
"$source": "argv",
|
|
11
12
|
"index": 0
|
|
12
13
|
},
|
|
13
|
-
"x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
|
|
14
|
+
"x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
|
|
15
|
+
},
|
|
16
|
+
"nameAndDirectoryFormat": {
|
|
17
|
+
"description": "Whether to generate the action in the directory 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`).",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"enum": ["as-provided", "derived"]
|
|
14
20
|
},
|
|
15
21
|
"project": {
|
|
16
22
|
"type": "string",
|
|
@@ -19,8 +25,9 @@
|
|
|
19
25
|
"$source": "projectName"
|
|
20
26
|
},
|
|
21
27
|
"x-prompt": "What project is this route for?",
|
|
22
|
-
"pattern": "^[a-zA-Z].*$"
|
|
28
|
+
"pattern": "^[a-zA-Z].*$",
|
|
29
|
+
"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."
|
|
23
30
|
}
|
|
24
31
|
},
|
|
25
|
-
"required": ["path"
|
|
32
|
+
"required": ["path"]
|
|
26
33
|
}
|