@nx/remix 16.8.2 → 17.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +32 -89
- package/executors.json +0 -12
- package/generators.d.ts +14 -0
- package/generators.js +31 -0
- package/generators.json +14 -19
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/migrations.json +68 -86
- package/package.json +44 -12
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/component-testing/index.js +11 -6
- package/src/executors/build/build.impl.js +64 -74
- package/src/executors/build/schema.json +1 -1
- package/src/executors/serve/serve.impl.js +43 -43
- package/src/generators/action/action.impl.js +24 -26
- package/src/generators/action/schema.d.ts +7 -1
- package/src/generators/action/schema.json +11 -8
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1121 -307
- package/src/generators/application/application.impl.d.ts +3 -1
- package/src/generators/application/application.impl.js +171 -110
- package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
- package/src/generators/application/files/common/app/root.tsx__tmpl__ +3 -3
- package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
- package/src/generators/application/files/common/remix.config.js__tmpl__ +13 -7
- package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
- package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +20 -14
- package/src/generators/application/files/integrated/package.json__tmpl__ +1 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +68 -0
- package/src/generators/application/lib/index.d.ts +1 -0
- package/src/generators/application/lib/index.js +1 -1
- package/src/generators/application/lib/normalize-options.d.ts +8 -3
- package/src/generators/application/lib/normalize-options.js +52 -14
- package/src/generators/application/lib/update-unit-test-config.d.ts +1 -1
- package/src/generators/application/lib/update-unit-test-config.js +32 -7
- package/src/generators/application/schema.d.ts +7 -1
- package/src/generators/application/schema.json +17 -11
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +3 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +26 -17
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +39 -27
- package/src/generators/error-boundary/error-boundary.impl.js +6 -15
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js +11 -16
- package/src/generators/error-boundary/lib/index.d.ts +0 -1
- package/src/generators/error-boundary/lib/index.js +0 -2
- package/src/generators/error-boundary/lib/normalize-options.d.ts +1 -1
- package/src/generators/error-boundary/lib/normalize-options.js +9 -5
- package/src/generators/error-boundary/schema.d.ts +7 -2
- package/src/generators/error-boundary/schema.json +14 -16
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +60 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.js +0 -1
- package/src/generators/library/lib/add-unit-testing.js +5 -7
- package/src/generators/library/lib/index.js +0 -1
- package/src/generators/library/lib/normalize-options.d.ts +3 -2
- package/src/generators/library/lib/normalize-options.js +21 -12
- package/src/generators/library/lib/update-buildable-config.js +5 -2
- package/src/generators/library/library.impl.d.ts +3 -1
- package/src/generators/library/library.impl.js +38 -34
- package/src/generators/library/schema.d.ts +3 -0
- package/src/generators/library/schema.json +7 -1
- package/src/generators/loader/loader.impl.js +24 -26
- package/src/generators/loader/schema.d.ts +7 -1
- package/src/generators/loader/schema.json +11 -8
- package/src/generators/meta/lib/v2.impl.js +14 -16
- package/src/generators/meta/meta.impl.js +2 -17
- package/src/generators/meta/schema.d.ts +7 -2
- package/src/generators/meta/schema.json +11 -12
- package/src/generators/preset/lib/normalize-options.js +5 -3
- package/src/generators/preset/preset.impl.js +22 -23
- package/src/generators/preset/schema.json +2 -1
- package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
- package/src/generators/resource-route/resource-route.impl.js +32 -26
- package/src/generators/resource-route/schema.d.ts +7 -1
- package/src/generators/resource-route/schema.json +11 -8
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +62 -9
- package/src/generators/route/route.impl.js +56 -43
- package/src/generators/route/schema.d.ts +7 -1
- package/src/generators/route/schema.json +12 -9
- package/src/generators/setup/schema.json +2 -1
- package/src/generators/setup/setup.impl.js +23 -23
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +51 -33
- package/src/generators/setup-tailwind/lib/index.js +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js +3 -7
- package/src/generators/setup-tailwind/schema.json +2 -1
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +25 -29
- package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +15 -27
- package/src/generators/storybook-configuration/schema.d.ts +3 -2
- package/src/generators/storybook-configuration/schema.json +5 -12
- package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +2 -1
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +19 -12
- package/src/generators/style/schema.d.ts +7 -1
- package/src/generators/style/schema.json +13 -10
- package/src/generators/style/style.impl.js +32 -24
- package/src/generators/utils/update-dependencies.d.ts +2 -0
- package/src/generators/utils/update-dependencies.js +21 -0
- package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
- package/src/plugins/plugin.d.ts +9 -0
- package/src/plugins/plugin.js +134 -0
- package/src/utils/create-watch-paths.js +8 -13
- package/src/utils/get-default-export-name.js +1 -3
- package/src/utils/get-default-export.js +0 -1
- package/src/utils/insert-import.js +0 -1
- package/src/utils/insert-statement-after-imports.js +0 -1
- package/src/utils/insert-statement-in-default-function.js +0 -1
- package/src/utils/remix-config.d.ts +2 -2
- package/src/utils/remix-config.js +34 -11
- package/src/utils/remix-route-utils.d.ts +2 -2
- package/src/utils/remix-route-utils.js +23 -17
- package/src/utils/testing-config-utils.d.ts +3 -2
- package/src/utils/testing-config-utils.js +24 -10
- package/src/utils/upsert-links-function.js +0 -1
- package/src/utils/versions.d.ts +10 -9
- package/src/utils/versions.js +15 -15
- package/plugins/component-testing/index.js.map +0 -1
- package/src/executors/build/build.impl.js.map +0 -1
- package/src/executors/build/compat.d.ts +0 -2
- package/src/executors/build/compat.js +0 -6
- package/src/executors/build/compat.js.map +0 -1
- package/src/executors/serve/compat.d.ts +0 -2
- package/src/executors/serve/compat.js +0 -6
- package/src/executors/serve/compat.js.map +0 -1
- package/src/executors/serve/serve.impl.js.map +0 -1
- package/src/generators/action/action.impl.js.map +0 -1
- package/src/generators/application/application.impl.js.map +0 -1
- package/src/generators/application/files/common/app/routes/index.tsx__tmpl__ +0 -32
- package/src/generators/application/lib/index.js.map +0 -1
- package/src/generators/application/lib/normalize-options.js.map +0 -1
- package/src/generators/application/lib/update-unit-test-config.js.map +0 -1
- package/src/generators/cypress/cypress.impl.d.ts +0 -3
- package/src/generators/cypress/cypress.impl.js +0 -67
- package/src/generators/cypress/cypress.impl.js.map +0 -1
- package/src/generators/cypress/schema.d.ts +0 -10
- package/src/generators/cypress/schema.json +0 -55
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +0 -1
- package/src/generators/error-boundary/error-boundary.impl.js.map +0 -1
- package/src/generators/error-boundary/lib/add-v1-error-boundary.d.ts +0 -3
- package/src/generators/error-boundary/lib/add-v1-error-boundary.js +0 -21
- package/src/generators/error-boundary/lib/add-v1-error-boundary.js.map +0 -1
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js.map +0 -1
- package/src/generators/error-boundary/lib/index.js.map +0 -1
- package/src/generators/error-boundary/lib/normalize-options.js.map +0 -1
- package/src/generators/library/lib/add-tsconfig-entry-points.js.map +0 -1
- package/src/generators/library/lib/add-unit-testing.js.map +0 -1
- package/src/generators/library/lib/index.js.map +0 -1
- package/src/generators/library/lib/normalize-options.js.map +0 -1
- package/src/generators/library/lib/update-buildable-config.js.map +0 -1
- package/src/generators/library/library.impl.js.map +0 -1
- package/src/generators/loader/loader.impl.js.map +0 -1
- package/src/generators/meta/lib/normalize-options.d.ts +0 -3
- package/src/generators/meta/lib/normalize-options.js +0 -15
- package/src/generators/meta/lib/normalize-options.js.map +0 -1
- package/src/generators/meta/lib/v1.impl.d.ts +0 -3
- package/src/generators/meta/lib/v1.impl.js +0 -30
- package/src/generators/meta/lib/v1.impl.js.map +0 -1
- package/src/generators/meta/lib/v2.impl.js.map +0 -1
- package/src/generators/meta/meta.impl.js.map +0 -1
- package/src/generators/preset/lib/normalize-options.js.map +0 -1
- package/src/generators/preset/preset.impl.js.map +0 -1
- package/src/generators/resource-route/resource-route.impl.js.map +0 -1
- package/src/generators/route/route.impl.js.map +0 -1
- package/src/generators/setup/setup.impl.js.map +0 -1
- package/src/generators/setup-tailwind/lib/index.js.map +0 -1
- package/src/generators/setup-tailwind/lib/update-remix-config.js.map +0 -1
- package/src/generators/setup-tailwind/setup-tailwind.impl.js.map +0 -1
- package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +0 -1
- package/src/generators/style/style.impl.js.map +0 -1
- package/src/index.d.ts +0 -15
- package/src/index.js +0 -21
- package/src/index.js.map +0 -1
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +0 -6
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +0 -45
- package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +0 -1
- package/src/migrations/update-15-8-6/update-remix-env-d.d.ts +0 -6
- package/src/migrations/update-15-8-6/update-remix-env-d.js +0 -27
- package/src/migrations/update-15-8-6/update-remix-env-d.js.map +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -13
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
- package/src/utils/create-watch-paths.js.map +0 -1
- package/src/utils/get-default-export-name.js.map +0 -1
- package/src/utils/get-default-export.js.map +0 -1
- package/src/utils/get-remix-projects.d.ts +0 -2
- package/src/utils/get-remix-projects.js +0 -15
- package/src/utils/get-remix-projects.js.map +0 -1
- package/src/utils/insert-import.js.map +0 -1
- package/src/utils/insert-statement-after-imports.js.map +0 -1
- package/src/utils/insert-statement-in-default-function.js.map +0 -1
- package/src/utils/project.d.ts +0 -2
- package/src/utils/project.js +0 -15
- package/src/utils/project.js.map +0 -1
- package/src/utils/remix-config.js.map +0 -1
- package/src/utils/remix-route-utils.js.map +0 -1
- package/src/utils/testing-config-utils.js.map +0 -1
- package/src/utils/upsert-links-function.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.remixStorybookConfiguration = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("@nx/react");
|
|
7
7
|
function remixStorybookConfiguration(tree, schema) {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), root, { tpl: '' });
|
|
12
|
-
}
|
|
13
|
-
const { storybookConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/react', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
14
|
-
const task = yield storybookConfigurationGenerator(tree, schema);
|
|
15
|
-
return task;
|
|
8
|
+
return remixStorybookConfigurationInternal(tree, {
|
|
9
|
+
addPlugin: false,
|
|
10
|
+
...schema,
|
|
16
11
|
});
|
|
17
12
|
}
|
|
18
|
-
exports.
|
|
19
|
-
|
|
13
|
+
exports.remixStorybookConfiguration = remixStorybookConfiguration;
|
|
14
|
+
async function remixStorybookConfigurationInternal(tree, schema) {
|
|
15
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
16
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
+
nxJson.useInferencePlugins !== false;
|
|
18
|
+
schema.addPlugin ??= addPluginDefault;
|
|
19
|
+
const { root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
20
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(root, 'vite.config.ts'))) {
|
|
21
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), root, { tpl: '' });
|
|
22
|
+
}
|
|
23
|
+
const task = await (0, react_1.storybookConfigurationGenerator)(tree, schema);
|
|
24
|
+
return task;
|
|
25
|
+
}
|
|
26
|
+
exports.default = remixStorybookConfigurationInternal;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface RemixStyleSchema {
|
|
2
|
-
project: string;
|
|
3
4
|
path: string;
|
|
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 v19.
|
|
8
|
+
*/
|
|
9
|
+
project?: string;
|
|
4
10
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxRemixRouteStyle",
|
|
4
4
|
"title": "Add style import to a route",
|
|
5
|
+
"description": "Generate a style import and file for a given route.",
|
|
5
6
|
"type": "object",
|
|
6
7
|
"examples": [
|
|
7
8
|
{
|
|
8
|
-
"command": "g style --
|
|
9
|
-
"description": "Generate route at /path/to/page"
|
|
9
|
+
"command": "g style --path='apps/demo/app/routes/path/to/page.tsx'",
|
|
10
|
+
"description": "Generate route at apps/demo/app/routes/path/to/page.tsx"
|
|
10
11
|
}
|
|
11
12
|
],
|
|
12
13
|
"properties": {
|
|
@@ -17,17 +18,19 @@
|
|
|
17
18
|
"$source": "argv",
|
|
18
19
|
"index": 0
|
|
19
20
|
},
|
|
20
|
-
"x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
|
|
21
|
+
"x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
|
|
22
|
+
},
|
|
23
|
+
"nameAndDirectoryFormat": {
|
|
24
|
+
"description": "Whether to generate the styles 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`).",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["as-provided", "derived"]
|
|
21
27
|
},
|
|
22
28
|
"project": {
|
|
23
29
|
"type": "string",
|
|
24
30
|
"description": "The name of the project.",
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"x-prompt": "What project is this route in?",
|
|
29
|
-
"pattern": "^[a-zA-Z].*$"
|
|
31
|
+
"pattern": "^[a-zA-Z].*$",
|
|
32
|
+
"x-deprecated": "Provide the `path` option instead and use the `as-provided` format. The project will be determined from the path provided. It will be removed in Nx v19."
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
|
-
"required": ["
|
|
35
|
+
"required": ["path"]
|
|
33
36
|
}
|
|
@@ -1,20 +1,28 @@
|
|
|
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");
|
|
4
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const insert_import_1 = require("../../utils/insert-import");
|
|
7
7
|
const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
|
|
8
8
|
const remix_route_utils_1 = require("../../utils/remix-route-utils");
|
|
9
|
-
function default_1(tree, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
async function default_1(tree, options) {
|
|
10
|
+
const { project: projectName, artifactName: name } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
11
|
+
artifactType: 'style',
|
|
12
|
+
callingGenerator: '@nx/remix:style',
|
|
13
|
+
name: options.path,
|
|
14
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
15
|
+
project: options.project,
|
|
16
|
+
});
|
|
17
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
18
|
+
if (!project)
|
|
19
|
+
throw new Error(`Project does not exist: ${projectName}`);
|
|
20
|
+
const appDir = await (0, remix_route_utils_1.resolveRemixAppDirectory)(tree, project.name);
|
|
21
|
+
const normalizedRoutePath = `${(0, remix_route_utils_1.normalizeRoutePath)(options.path)
|
|
22
|
+
.replace(/^\//, '')
|
|
23
|
+
.replace('.tsx', '')}.css`;
|
|
24
|
+
const stylesheetPath = (0, devkit_1.joinPathFragments)(appDir, 'styles', normalizedRoutePath);
|
|
25
|
+
tree.write(stylesheetPath, (0, devkit_1.stripIndents) `
|
|
18
26
|
:root {
|
|
19
27
|
--color-foreground: #fff;
|
|
20
28
|
--color-background: #143157;
|
|
@@ -24,30 +32,30 @@ function default_1(tree, options) {
|
|
|
24
32
|
Liberation Mono, Courier New, monospace;
|
|
25
33
|
}
|
|
26
34
|
`);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
const routeFilePath = options.nameAndDirectoryFormat
|
|
36
|
+
? options.path
|
|
37
|
+
: await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.path, options.project, '.tsx');
|
|
38
|
+
(0, insert_import_1.insertImport)(tree, routeFilePath, 'LinksFunction', '@remix-run/node', {
|
|
39
|
+
typeOnly: true,
|
|
40
|
+
});
|
|
41
|
+
if (project.root === '.') {
|
|
42
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
|
|
43
|
+
import stylesUrl from '~/styles/${normalizedRoutePath}'
|
|
34
44
|
|
|
35
45
|
export const links: LinksFunction = () => {
|
|
36
46
|
return [{ rel: 'stylesheet', href: stylesUrl }];
|
|
37
47
|
};
|
|
38
48
|
`);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
|
|
42
52
|
import stylesUrl from '${(0, path_1.relative)((0, path_1.dirname)(routeFilePath), stylesheetPath)}';
|
|
43
53
|
|
|
44
54
|
export const links: LinksFunction = () => {
|
|
45
55
|
return [{ rel: 'stylesheet', href: stylesUrl }];
|
|
46
56
|
};
|
|
47
57
|
`);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
58
|
+
}
|
|
59
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
51
60
|
}
|
|
52
61
|
exports.default = default_1;
|
|
53
|
-
//# sourceMappingURL=style.impl.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../utils/versions");
|
|
6
|
+
function updateDependencies(tree) {
|
|
7
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
8
|
+
'@remix-run/node': versions_1.remixVersion,
|
|
9
|
+
'@remix-run/react': versions_1.remixVersion,
|
|
10
|
+
isbot: versions_1.isbotVersion,
|
|
11
|
+
react: versions_1.reactVersion,
|
|
12
|
+
'react-dom': versions_1.reactDomVersion,
|
|
13
|
+
}, {
|
|
14
|
+
'@remix-run/eslint-config': versions_1.remixVersion,
|
|
15
|
+
'@types/react': versions_1.typesReactVersion,
|
|
16
|
+
'@types/react-dom': versions_1.typesReactDomVersion,
|
|
17
|
+
eslint: versions_1.eslintVersion,
|
|
18
|
+
typescript: versions_1.typescriptVersion,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.updateDependencies = updateDependencies;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`@nx/remix/plugin non-root project should create nodes 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"projects": {
|
|
6
|
+
"my-app": {
|
|
7
|
+
"root": "my-app",
|
|
8
|
+
"targets": {
|
|
9
|
+
"build": {
|
|
10
|
+
"cache": true,
|
|
11
|
+
"command": "remix build",
|
|
12
|
+
"dependsOn": [
|
|
13
|
+
"^build",
|
|
14
|
+
],
|
|
15
|
+
"inputs": [
|
|
16
|
+
"production",
|
|
17
|
+
"^production",
|
|
18
|
+
],
|
|
19
|
+
"options": {
|
|
20
|
+
"cwd": "my-app",
|
|
21
|
+
},
|
|
22
|
+
"outputs": [
|
|
23
|
+
"{workspaceRoot}/my-app/build",
|
|
24
|
+
"{workspaceRoot}/my-app/public/build",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
"dev": {
|
|
28
|
+
"command": "remix dev --manual",
|
|
29
|
+
"options": {
|
|
30
|
+
"cwd": "my-app",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"start": {
|
|
34
|
+
"command": "remix-serve build/index.js",
|
|
35
|
+
"dependsOn": [
|
|
36
|
+
"build",
|
|
37
|
+
],
|
|
38
|
+
"options": {
|
|
39
|
+
"cwd": "my-app",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
"tsc": {
|
|
43
|
+
"cache": true,
|
|
44
|
+
"command": "tsc",
|
|
45
|
+
"inputs": [
|
|
46
|
+
"production",
|
|
47
|
+
"^production",
|
|
48
|
+
],
|
|
49
|
+
"options": {
|
|
50
|
+
"cwd": "my-app",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`@nx/remix/plugin root project should create nodes 1`] = `
|
|
60
|
+
{
|
|
61
|
+
"projects": {
|
|
62
|
+
".": {
|
|
63
|
+
"root": ".",
|
|
64
|
+
"targets": {
|
|
65
|
+
"build": {
|
|
66
|
+
"cache": true,
|
|
67
|
+
"command": "remix build",
|
|
68
|
+
"dependsOn": [
|
|
69
|
+
"^build",
|
|
70
|
+
],
|
|
71
|
+
"inputs": [
|
|
72
|
+
"production",
|
|
73
|
+
"^production",
|
|
74
|
+
],
|
|
75
|
+
"options": {
|
|
76
|
+
"cwd": ".",
|
|
77
|
+
},
|
|
78
|
+
"outputs": [
|
|
79
|
+
"{workspaceRoot}/build",
|
|
80
|
+
"{workspaceRoot}/public/build",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
"dev": {
|
|
84
|
+
"command": "remix dev --manual",
|
|
85
|
+
"options": {
|
|
86
|
+
"cwd": ".",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
"start": {
|
|
90
|
+
"command": "remix-serve build/index.js",
|
|
91
|
+
"dependsOn": [
|
|
92
|
+
"build",
|
|
93
|
+
],
|
|
94
|
+
"options": {
|
|
95
|
+
"cwd": ".",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
"typecheck": {
|
|
99
|
+
"cache": true,
|
|
100
|
+
"command": "tsc",
|
|
101
|
+
"inputs": [
|
|
102
|
+
"production",
|
|
103
|
+
"^production",
|
|
104
|
+
],
|
|
105
|
+
"options": {
|
|
106
|
+
"cwd": ".",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CreateDependencies, type CreateNodes } from '@nx/devkit';
|
|
2
|
+
export declare const createDependencies: CreateDependencies;
|
|
3
|
+
export interface RemixPluginOptions {
|
|
4
|
+
buildTargetName?: string;
|
|
5
|
+
devTargetName?: string;
|
|
6
|
+
startTargetName?: string;
|
|
7
|
+
typecheckTargetName?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const createNodes: CreateNodes<RemixPluginOptions>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
7
|
+
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
+
const js_1 = require("@nx/js");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
12
|
+
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'remix.hash');
|
|
13
|
+
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
14
|
+
const calculatedTargets = {};
|
|
15
|
+
function readTargetsCache() {
|
|
16
|
+
return (0, devkit_1.readJsonFile)(cachePath);
|
|
17
|
+
}
|
|
18
|
+
function writeTargetsToCache(targets) {
|
|
19
|
+
(0, devkit_1.writeJsonFile)(cachePath, targets);
|
|
20
|
+
}
|
|
21
|
+
const createDependencies = () => {
|
|
22
|
+
writeTargetsToCache(calculatedTargets);
|
|
23
|
+
return [];
|
|
24
|
+
};
|
|
25
|
+
exports.createDependencies = createDependencies;
|
|
26
|
+
exports.createNodes = [
|
|
27
|
+
'**/remix.config.{js,cjs,mjs}',
|
|
28
|
+
async (configFilePath, options, context) => {
|
|
29
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
30
|
+
const fullyQualifiedProjectRoot = (0, path_1.join)(context.workspaceRoot, projectRoot);
|
|
31
|
+
// Do not create a project if package.json and project.json isn't there
|
|
32
|
+
const siblingFiles = (0, fs_1.readdirSync)(fullyQualifiedProjectRoot);
|
|
33
|
+
if (!siblingFiles.includes('package.json') &&
|
|
34
|
+
!siblingFiles.includes('project.json') &&
|
|
35
|
+
!siblingFiles.includes('vite.config.ts') &&
|
|
36
|
+
!siblingFiles.includes('vite.config.js')) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
options = normalizeOptions(options);
|
|
40
|
+
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
41
|
+
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
42
|
+
]);
|
|
43
|
+
const targets = targetsCache[hash]
|
|
44
|
+
? targetsCache[hash]
|
|
45
|
+
: await buildRemixTargets(configFilePath, projectRoot, options, context, siblingFiles);
|
|
46
|
+
calculatedTargets[hash] = targets;
|
|
47
|
+
return {
|
|
48
|
+
projects: {
|
|
49
|
+
[projectRoot]: {
|
|
50
|
+
root: projectRoot,
|
|
51
|
+
targets,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
async function buildRemixTargets(configFilePath, projectRoot, options, context, siblingFiles) {
|
|
58
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
59
|
+
const { buildDirectory, assetsBuildDirectory, serverBuildPath } = await getBuildPaths(configFilePath, context.workspaceRoot);
|
|
60
|
+
const targets = {};
|
|
61
|
+
targets[options.buildTargetName] = buildTarget(options.buildTargetName, projectRoot, buildDirectory, assetsBuildDirectory, namedInputs);
|
|
62
|
+
targets[options.devTargetName] = devTarget(serverBuildPath, projectRoot);
|
|
63
|
+
targets[options.startTargetName] = startTarget(projectRoot, serverBuildPath, options.buildTargetName);
|
|
64
|
+
targets[options.typecheckTargetName] = typecheckTarget(projectRoot, namedInputs, siblingFiles);
|
|
65
|
+
return targets;
|
|
66
|
+
}
|
|
67
|
+
function buildTarget(buildTargetName, projectRoot, buildDirectory, assetsBuildDirectory, namedInputs) {
|
|
68
|
+
const serverBuildOutputPath = projectRoot === '.'
|
|
69
|
+
? (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, buildDirectory)
|
|
70
|
+
: (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot, buildDirectory);
|
|
71
|
+
const assetsBuildOutputPath = projectRoot === '.'
|
|
72
|
+
? (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, assetsBuildDirectory)
|
|
73
|
+
: (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot, assetsBuildDirectory);
|
|
74
|
+
return {
|
|
75
|
+
cache: true,
|
|
76
|
+
dependsOn: [`^${buildTargetName}`],
|
|
77
|
+
inputs: [
|
|
78
|
+
...('production' in namedInputs
|
|
79
|
+
? ['production', '^production']
|
|
80
|
+
: ['default', '^default']),
|
|
81
|
+
],
|
|
82
|
+
outputs: [serverBuildOutputPath, assetsBuildOutputPath],
|
|
83
|
+
command: 'remix build',
|
|
84
|
+
options: { cwd: projectRoot },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function devTarget(serverBuildPath, projectRoot) {
|
|
88
|
+
return {
|
|
89
|
+
command: 'remix dev --manual',
|
|
90
|
+
options: { cwd: projectRoot },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function startTarget(projectRoot, serverBuildPath, buildTargetName) {
|
|
94
|
+
return {
|
|
95
|
+
dependsOn: [buildTargetName],
|
|
96
|
+
command: `remix-serve ${serverBuildPath}`,
|
|
97
|
+
options: {
|
|
98
|
+
cwd: projectRoot,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function typecheckTarget(projectRoot, namedInputs, siblingFiles) {
|
|
103
|
+
const hasTsConfigAppJson = siblingFiles.includes('tsconfig.app.json');
|
|
104
|
+
const command = `tsc${hasTsConfigAppJson ? ` --project tsconfig.app.json` : ``}`;
|
|
105
|
+
return {
|
|
106
|
+
command,
|
|
107
|
+
cache: true,
|
|
108
|
+
inputs: [
|
|
109
|
+
...('production' in namedInputs
|
|
110
|
+
? ['production', '^production']
|
|
111
|
+
: ['default', '^default']),
|
|
112
|
+
],
|
|
113
|
+
options: {
|
|
114
|
+
cwd: projectRoot,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function getBuildPaths(configFilePath, workspaceRoot) {
|
|
119
|
+
const configPath = (0, path_1.join)(workspaceRoot, configFilePath);
|
|
120
|
+
let appConfig = await (0, config_utils_1.loadConfigFile)(configPath);
|
|
121
|
+
return {
|
|
122
|
+
buildDirectory: 'build',
|
|
123
|
+
serverBuildPath: appConfig.serverBuildPath ?? 'build/index.js',
|
|
124
|
+
assetsBuildDirectory: appConfig.assetsBuildDirectory ?? 'public/build',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function normalizeOptions(options) {
|
|
128
|
+
options ??= {};
|
|
129
|
+
options.buildTargetName ??= 'build';
|
|
130
|
+
options.devTargetName ??= 'dev';
|
|
131
|
+
options.startTargetName ??= 'start';
|
|
132
|
+
options.typecheckTargetName ??= 'typecheck';
|
|
133
|
+
return options;
|
|
134
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRelativeDependencyPaths = exports.createWatchPaths = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
7
6
|
const project_graph_utils_1 = require("nx/src/utils/project-graph-utils");
|
|
@@ -11,20 +10,17 @@ const path_1 = require("path");
|
|
|
11
10
|
*
|
|
12
11
|
* @param {string} dirname The absolute path to the Remix project, typically `__dirname`.
|
|
13
12
|
*/
|
|
14
|
-
function createWatchPaths(dirname) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return getRelativeDependencyPaths(graph.nodes[projectName], deps, graph);
|
|
21
|
-
});
|
|
13
|
+
async function createWatchPaths(dirname) {
|
|
14
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
15
|
+
const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappings)(graph.nodes);
|
|
16
|
+
const projectName = (0, find_project_for_path_1.findProjectForPath)((0, path_1.relative)(devkit_1.workspaceRoot, dirname), projectRootMappings);
|
|
17
|
+
const deps = (0, project_graph_utils_1.findAllProjectNodeDependencies)(projectName, graph);
|
|
18
|
+
return getRelativeDependencyPaths(graph.nodes[projectName], deps, graph);
|
|
22
19
|
}
|
|
23
20
|
exports.createWatchPaths = createWatchPaths;
|
|
24
21
|
// Exported for testing
|
|
25
22
|
function getRelativeDependencyPaths(project, deps, graph) {
|
|
26
|
-
|
|
27
|
-
if (!((_a = project.data) === null || _a === void 0 ? void 0 : _a.root)) {
|
|
23
|
+
if (!project.data?.root) {
|
|
28
24
|
throw new Error(`Project ${project.name} has no root set. Check the project configuration.`);
|
|
29
25
|
}
|
|
30
26
|
const paths = new Set();
|
|
@@ -32,7 +28,7 @@ function getRelativeDependencyPaths(project, deps, graph) {
|
|
|
32
28
|
const [baseProjectPath] = project.data.root.split('/');
|
|
33
29
|
for (const dep of deps) {
|
|
34
30
|
const node = graph.nodes[dep];
|
|
35
|
-
if (!
|
|
31
|
+
if (!node?.data?.root)
|
|
36
32
|
continue;
|
|
37
33
|
const [basePath] = (0, path_1.normalize)(node.data.root).split(path_1.sep);
|
|
38
34
|
const watchPath = baseProjectPath !== basePath ? basePath : node.data.root;
|
|
@@ -42,4 +38,3 @@ function getRelativeDependencyPaths(project, deps, graph) {
|
|
|
42
38
|
return Array.from(paths);
|
|
43
39
|
}
|
|
44
40
|
exports.getRelativeDependencyPaths = getRelativeDependencyPaths;
|
|
45
|
-
//# sourceMappingURL=create-watch-paths.js.map
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getDefaultExportName = void 0;
|
|
4
4
|
const get_default_export_1 = require("./get-default-export");
|
|
5
5
|
function getDefaultExportName(tree, path) {
|
|
6
|
-
|
|
7
|
-
return (_b = (_a = (0, get_default_export_1.getDefaultExport)(tree, path)) === null || _a === void 0 ? void 0 : _a.name.text) !== null && _b !== void 0 ? _b : 'Unknown';
|
|
6
|
+
return (0, get_default_export_1.getDefaultExport)(tree, path)?.name.text ?? 'Unknown';
|
|
8
7
|
}
|
|
9
8
|
exports.getDefaultExportName = getDefaultExportName;
|
|
10
|
-
//# sourceMappingURL=get-default-export-name.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { AppConfig } from '@remix-run/dev';
|
|
3
3
|
export declare function getRemixConfigPath(tree: Tree, projectName: string): string;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function getRemixConfigPathFromProjectRoot(tree: Tree, projectRoot: string): string;
|
|
5
|
+
export declare function getRemixConfigValues(tree: Tree, projectName: string): Promise<AppConfig>;
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getRemixConfigValues = exports.getRemixConfigPathFromProjectRoot = exports.getRemixConfigPath = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function getRemixConfigPath(tree, projectName) {
|
|
6
6
|
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
7
7
|
if (!project)
|
|
8
8
|
throw new Error(`Project does not exist: ${projectName}`);
|
|
9
|
-
|
|
9
|
+
for (const ext of ['.mjs', '.cjs', '.js']) {
|
|
10
|
+
const configPath = (0, devkit_1.joinPathFragments)(project.root, `remix.config${ext}`);
|
|
11
|
+
if (tree.exists(configPath)) {
|
|
12
|
+
return configPath;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
exports.getRemixConfigPath = getRemixConfigPath;
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
function getRemixConfigPathFromProjectRoot(tree, projectRoot) {
|
|
18
|
+
let pathToRemixConfig;
|
|
19
|
+
for (const ext of ['.js', '.mjs', '.cjs']) {
|
|
20
|
+
pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, `remix.config${ext}`);
|
|
21
|
+
if (tree.exists(pathToRemixConfig)) {
|
|
22
|
+
return pathToRemixConfig;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Could not find a Remix Config File. Please ensure a "remix.config.js" file exists at the root of your project.`);
|
|
15
26
|
}
|
|
16
|
-
exports.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
exports.getRemixConfigPathFromProjectRoot = getRemixConfigPathFromProjectRoot;
|
|
28
|
+
const _remixConfigCache = {};
|
|
29
|
+
async function getRemixConfigValues(tree, projectName) {
|
|
30
|
+
const remixConfigPath = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, getRemixConfigPath(tree, projectName));
|
|
31
|
+
const cacheKey = `${projectName}/${remixConfigPath}`;
|
|
32
|
+
let appConfig = _remixConfigCache[cacheKey];
|
|
33
|
+
if (!appConfig) {
|
|
34
|
+
try {
|
|
35
|
+
const importedConfig = await Function(`return import("${remixConfigPath}?t=${Date.now()}")`)();
|
|
36
|
+
appConfig = (importedConfig?.default || importedConfig);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
appConfig = require(remixConfigPath);
|
|
40
|
+
}
|
|
41
|
+
_remixConfigCache[cacheKey] = appConfig;
|
|
42
|
+
}
|
|
43
|
+
return appConfig;
|
|
20
44
|
}
|
|
21
|
-
exports.
|
|
22
|
-
//# sourceMappingURL=remix-config.js.map
|
|
45
|
+
exports.getRemixConfigValues = getRemixConfigValues;
|
|
@@ -7,7 +7,7 @@ import { Tree } from '@nx/devkit';
|
|
|
7
7
|
* @param fileExtension the file extension to add to resolved route file
|
|
8
8
|
* @returns file path to the route
|
|
9
9
|
*/
|
|
10
|
-
export declare function resolveRemixRouteFile(tree: Tree, path: string, projectName
|
|
10
|
+
export declare function resolveRemixRouteFile(tree: Tree, path: string, projectName?: string, fileExtension?: string): Promise<string>;
|
|
11
11
|
export declare function normalizeRoutePath(path: string): string;
|
|
12
12
|
export declare function checkRoutePathForErrors(path: string): RegExpMatchArray;
|
|
13
|
-
export declare function resolveRemixAppDirectory(tree: Tree, projectName: string): string
|
|
13
|
+
export declare function resolveRemixAppDirectory(tree: Tree, projectName: string): Promise<string>;
|