@nx/remix 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +14 -0
- package/generators.d.ts +14 -0
- package/generators.js +31 -0
- package/generators.json +90 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/migrations.json +107 -0
- package/package.json +53 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/component-testing/index.d.ts +30 -0
- package/plugins/component-testing/index.js +64 -0
- package/src/executors/build/build.impl.d.ts +5 -0
- package/src/executors/build/build.impl.js +109 -0
- package/src/executors/build/schema.d.ts +7 -0
- package/src/executors/build/schema.json +38 -0
- package/src/executors/serve/schema.d.ts +9 -0
- package/src/executors/serve/schema.json +41 -0
- package/src/executors/serve/serve.impl.d.ts +6 -0
- package/src/executors/serve/serve.impl.js +77 -0
- package/src/generators/action/action.impl.d.ts +3 -0
- package/src/generators/action/action.impl.js +39 -0
- package/src/generators/action/schema.d.ts +10 -0
- package/src/generators/action/schema.json +29 -0
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1487 -0
- package/src/generators/application/application.impl.d.ts +5 -0
- package/src/generators/application/application.impl.js +198 -0
- package/src/generators/application/files/common/README.md__tmpl__ +54 -0
- package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
- package/src/generators/application/files/common/app/root.tsx__tmpl__ +32 -0
- package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
- package/src/generators/application/files/common/public/favicon.ico +0 -0
- package/src/generators/application/files/common/remix.config.js__tmpl__ +17 -0
- package/src/generators/application/files/common/remix.env.d.ts__tmpl__ +2 -0
- package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
- package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +24 -0
- package/src/generators/application/files/integrated/.gitignore__tmpl__ +4 -0
- package/src/generators/application/files/integrated/package.json__tmpl__ +28 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +66 -0
- package/src/generators/application/lib/index.d.ts +3 -0
- package/src/generators/application/lib/index.js +6 -0
- package/src/generators/application/lib/normalize-options.d.ts +10 -0
- package/src/generators/application/lib/normalize-options.js +37 -0
- package/src/generators/application/lib/update-unit-test-config.d.ts +2 -0
- package/src/generators/application/lib/update-unit-test-config.js +55 -0
- package/src/generators/application/schema.d.ts +16 -0
- package/src/generators/application/schema.json +68 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +5 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +34 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +6 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
- package/src/generators/cypress-component-configuration/schema.json +41 -0
- package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +61 -0
- package/src/generators/error-boundary/error-boundary.impl.d.ts +3 -0
- package/src/generators/error-boundary/error-boundary.impl.js +12 -0
- package/src/generators/error-boundary/lib/add-v2-error-boundary.d.ts +3 -0
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js +38 -0
- package/src/generators/error-boundary/lib/index.d.ts +2 -0
- package/src/generators/error-boundary/lib/index.js +5 -0
- package/src/generators/error-boundary/lib/normalize-options.d.ts +3 -0
- package/src/generators/error-boundary/lib/normalize-options.js +17 -0
- package/src/generators/error-boundary/schema.d.ts +11 -0
- package/src/generators/error-boundary/schema.json +37 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +60 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.d.ts +3 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.js +19 -0
- package/src/generators/library/lib/add-unit-testing.d.ts +3 -0
- package/src/generators/library/lib/add-unit-testing.js +32 -0
- package/src/generators/library/lib/index.d.ts +4 -0
- package/src/generators/library/lib/index.js +7 -0
- package/src/generators/library/lib/normalize-options.d.ts +7 -0
- package/src/generators/library/lib/normalize-options.js +29 -0
- package/src/generators/library/lib/update-buildable-config.d.ts +2 -0
- package/src/generators/library/lib/update-buildable-config.js +21 -0
- package/src/generators/library/library.impl.d.ts +6 -0
- package/src/generators/library/library.impl.js +45 -0
- package/src/generators/library/schema.d.ts +16 -0
- package/src/generators/library/schema.json +74 -0
- package/src/generators/loader/loader.impl.d.ts +3 -0
- package/src/generators/loader/loader.impl.js +39 -0
- package/src/generators/loader/schema.d.ts +10 -0
- package/src/generators/loader/schema.json +29 -0
- package/src/generators/meta/lib/v2.impl.d.ts +3 -0
- package/src/generators/meta/lib/v2.impl.js +28 -0
- package/src/generators/meta/meta.impl.d.ts +3 -0
- package/src/generators/meta/meta.impl.js +7 -0
- package/src/generators/meta/schema.d.ts +10 -0
- package/src/generators/meta/schema.json +29 -0
- package/src/generators/preset/lib/normalize-options.d.ts +11 -0
- package/src/generators/preset/lib/normalize-options.js +20 -0
- package/src/generators/preset/preset.impl.d.ts +3 -0
- package/src/generators/preset/preset.impl.js +32 -0
- package/src/generators/preset/schema.d.ts +4 -0
- package/src/generators/preset/schema.json +14 -0
- package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
- package/src/generators/resource-route/resource-route.impl.d.ts +3 -0
- package/src/generators/resource-route/resource-route.impl.js +41 -0
- package/src/generators/resource-route/schema.d.ts +13 -0
- package/src/generators/resource-route/schema.json +51 -0
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +95 -0
- package/src/generators/route/route.impl.d.ts +3 -0
- package/src/generators/route/route.impl.js +78 -0
- package/src/generators/route/schema.d.ts +15 -0
- package/src/generators/route/schema.json +62 -0
- package/src/generators/setup/schema.json +14 -0
- package/src/generators/setup/setup.impl.d.ts +2 -0
- package/src/generators/setup/setup.impl.js +34 -0
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +170 -0
- package/src/generators/setup-tailwind/files/app/tailwind.css__tpl__ +3 -0
- package/src/generators/setup-tailwind/files/tailwind.config.ts__tpl__ +13 -0
- package/src/generators/setup-tailwind/lib/index.d.ts +1 -0
- package/src/generators/setup-tailwind/lib/index.js +4 -0
- package/src/generators/setup-tailwind/lib/update-remix-config.d.ts +2 -0
- package/src/generators/setup-tailwind/lib/update-remix-config.js +35 -0
- package/src/generators/setup-tailwind/schema.d.ts +5 -0
- package/src/generators/setup-tailwind/schema.json +36 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.d.ts +3 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +34 -0
- package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +73 -0
- package/src/generators/storybook-configuration/files/vite.config.ts__tpl__ +15 -0
- package/src/generators/storybook-configuration/schema.d.ts +16 -0
- package/src/generators/storybook-configuration/schema.json +89 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +4 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +26 -0
- package/src/generators/style/schema.d.ts +10 -0
- package/src/generators/style/schema.json +36 -0
- package/src/generators/style/style.impl.d.ts +3 -0
- package/src/generators/style/style.impl.js +61 -0
- package/src/generators/utils/update-dependencies.d.ts +2 -0
- package/src/generators/utils/update-dependencies.js +21 -0
- package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
- package/src/plugins/plugin.d.ts +9 -0
- package/src/plugins/plugin.js +136 -0
- package/src/utils/create-watch-paths.d.ts +8 -0
- package/src/utils/create-watch-paths.js +40 -0
- package/src/utils/get-default-export-name.d.ts +2 -0
- package/src/utils/get-default-export-name.js +8 -0
- package/src/utils/get-default-export.d.ts +2 -0
- package/src/utils/get-default-export.js +15 -0
- package/src/utils/insert-import.d.ts +4 -0
- package/src/utils/insert-import.js +54 -0
- package/src/utils/insert-statement-after-imports.d.ts +5 -0
- package/src/utils/insert-statement-after-imports.js +28 -0
- package/src/utils/insert-statement-in-default-function.d.ts +2 -0
- package/src/utils/insert-statement-in-default-function.js +23 -0
- package/src/utils/remix-config.d.ts +5 -0
- package/src/utils/remix-config.js +45 -0
- package/src/utils/remix-route-utils.d.ts +13 -0
- package/src/utils/remix-route-utils.js +70 -0
- package/src/utils/testing-config-utils.d.ts +4 -0
- package/src/utils/testing-config-utils.js +79 -0
- package/src/utils/upsert-links-function.d.ts +2 -0
- package/src/utils/upsert-links-function.js +31 -0
- package/src/utils/versions.d.ts +16 -0
- package/src/utils/versions.js +28 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxRemixStorybookConfigure",
|
|
5
|
+
"title": "Remix Storybook Configuration",
|
|
6
|
+
"description": "Set up Storybook for a Remix library.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"aliases": ["name", "projectName"],
|
|
12
|
+
"description": "Project for which to generate Storybook configuration.",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "argv",
|
|
15
|
+
"index": 0
|
|
16
|
+
},
|
|
17
|
+
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
18
|
+
"x-dropdown": "projects",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"configureCypress": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Run the cypress-configure generator.",
|
|
24
|
+
"x-prompt": "Configure a cypress e2e app to run against the storybook instance?",
|
|
25
|
+
"default": true,
|
|
26
|
+
"x-priority": "important"
|
|
27
|
+
},
|
|
28
|
+
"generateStories": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"description": "Automatically generate `*.stories.ts` files for components declared in this project?",
|
|
31
|
+
"x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
32
|
+
"default": true,
|
|
33
|
+
"x-priority": "important"
|
|
34
|
+
},
|
|
35
|
+
"generateCypressSpecs": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator.",
|
|
38
|
+
"x-prompt": "Automatically generate test files in the Cypress E2E app generated by the cypress-configure generator?",
|
|
39
|
+
"default": true,
|
|
40
|
+
"x-priority": "important"
|
|
41
|
+
},
|
|
42
|
+
"configureStaticServe": {
|
|
43
|
+
"type": "boolean",
|
|
44
|
+
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
45
|
+
"x-prompt": "Configure a static file server for the storybook instance?",
|
|
46
|
+
"default": true,
|
|
47
|
+
"x-priority": "important"
|
|
48
|
+
},
|
|
49
|
+
"cypressDirectory": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "A directory where the Cypress project will be placed. Placed at the root by default."
|
|
52
|
+
},
|
|
53
|
+
"js": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
56
|
+
"default": false
|
|
57
|
+
},
|
|
58
|
+
"tsConfiguration": {
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"description": "Configure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.",
|
|
61
|
+
"default": false
|
|
62
|
+
},
|
|
63
|
+
"linter": {
|
|
64
|
+
"description": "The tool to use for running lint checks.",
|
|
65
|
+
"type": "string",
|
|
66
|
+
"enum": ["eslint"],
|
|
67
|
+
"default": "eslint"
|
|
68
|
+
},
|
|
69
|
+
"ignorePaths": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"description": "Paths to ignore when looking for components.",
|
|
72
|
+
"items": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "Path to ignore."
|
|
75
|
+
},
|
|
76
|
+
"examples": [
|
|
77
|
+
"**/**/src/**/not-stories/**",
|
|
78
|
+
"libs/my-lib/**/*.something.ts",
|
|
79
|
+
"**/**/src/**/*.other.*",
|
|
80
|
+
"libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"configureTestRunner": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"description": "Add a Storybook Test-Runner target."
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"required": ["project"]
|
|
89
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { StorybookConfigurationSchema } from './schema';
|
|
3
|
+
export declare function remixStorybookConfiguration(tree: Tree, schema: StorybookConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
+
export default function remixStorybookConfigurationInternal(tree: Tree, schema: StorybookConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remixStorybookConfiguration = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const react_1 = require("@nx/react");
|
|
7
|
+
function remixStorybookConfiguration(tree, schema) {
|
|
8
|
+
return remixStorybookConfigurationInternal(tree, {
|
|
9
|
+
addPlugin: false,
|
|
10
|
+
...schema,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
3
|
+
export interface RemixStyleSchema {
|
|
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;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxRemixRouteStyle",
|
|
4
|
+
"title": "Add style import to a route",
|
|
5
|
+
"description": "Generate a style import and file for a given route.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"examples": [
|
|
8
|
+
{
|
|
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"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"path": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Route path",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
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"]
|
|
27
|
+
},
|
|
28
|
+
"project": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "The name of the project.",
|
|
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."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": ["path"]
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
const path_1 = require("path");
|
|
6
|
+
const insert_import_1 = require("../../utils/insert-import");
|
|
7
|
+
const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
|
|
8
|
+
const remix_route_utils_1 = require("../../utils/remix-route-utils");
|
|
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) `
|
|
26
|
+
:root {
|
|
27
|
+
--color-foreground: #fff;
|
|
28
|
+
--color-background: #143157;
|
|
29
|
+
--color-links: hsl(214, 73%, 69%);
|
|
30
|
+
--color-border: #275da8;
|
|
31
|
+
--font-body: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
|
32
|
+
Liberation Mono, Courier New, monospace;
|
|
33
|
+
}
|
|
34
|
+
`);
|
|
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}'
|
|
44
|
+
|
|
45
|
+
export const links: LinksFunction = () => {
|
|
46
|
+
return [{ rel: 'stylesheet', href: stylesUrl }];
|
|
47
|
+
};
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
|
|
52
|
+
import stylesUrl from '${(0, path_1.relative)((0, path_1.dirname)(routeFilePath), stylesheetPath)}';
|
|
53
|
+
|
|
54
|
+
export const links: LinksFunction = () => {
|
|
55
|
+
return [{ rel: 'stylesheet', href: stylesUrl }];
|
|
56
|
+
};
|
|
57
|
+
`);
|
|
58
|
+
}
|
|
59
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
60
|
+
}
|
|
61
|
+
exports.default = default_1;
|
|
@@ -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
|
+
"dependsOn": [
|
|
12
|
+
"^build",
|
|
13
|
+
],
|
|
14
|
+
"executor": "@nx/remix:build",
|
|
15
|
+
"inputs": [
|
|
16
|
+
"production",
|
|
17
|
+
"^production",
|
|
18
|
+
],
|
|
19
|
+
"options": {
|
|
20
|
+
"outputPath": "my-app",
|
|
21
|
+
},
|
|
22
|
+
"outputs": [
|
|
23
|
+
"{workspaceRoot}/my-app/build",
|
|
24
|
+
"{workspaceRoot}/my-app/public/build",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
"serve": {
|
|
28
|
+
"executor": "@nx/remix:serve",
|
|
29
|
+
"options": {
|
|
30
|
+
"command": "npx remix-serve build/index.js",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"start": {
|
|
34
|
+
"command": "npx 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
|
+
"dependsOn": [
|
|
68
|
+
"^build",
|
|
69
|
+
],
|
|
70
|
+
"executor": "@nx/remix:build",
|
|
71
|
+
"inputs": [
|
|
72
|
+
"production",
|
|
73
|
+
"^production",
|
|
74
|
+
],
|
|
75
|
+
"options": {
|
|
76
|
+
"outputPath": ".",
|
|
77
|
+
},
|
|
78
|
+
"outputs": [
|
|
79
|
+
"{workspaceRoot}/build",
|
|
80
|
+
"{workspaceRoot}/public/build",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
"serve": {
|
|
84
|
+
"executor": "@nx/remix:serve",
|
|
85
|
+
"options": {
|
|
86
|
+
"command": "npx remix-serve build/index.js",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
"start": {
|
|
90
|
+
"command": "npx 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
|
+
serveTargetName?: string;
|
|
6
|
+
startTargetName?: string;
|
|
7
|
+
typecheckTargetName?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const createNodes: CreateNodes<RemixPluginOptions>;
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
options = normalizeOptions(options);
|
|
38
|
+
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
39
|
+
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
40
|
+
]);
|
|
41
|
+
const targets = targetsCache[hash]
|
|
42
|
+
? targetsCache[hash]
|
|
43
|
+
: await buildRemixTargets(configFilePath, projectRoot, options, context, siblingFiles);
|
|
44
|
+
calculatedTargets[hash] = targets;
|
|
45
|
+
return {
|
|
46
|
+
projects: {
|
|
47
|
+
[projectRoot]: {
|
|
48
|
+
root: projectRoot,
|
|
49
|
+
targets,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
async function buildRemixTargets(configFilePath, projectRoot, options, context, siblingFiles) {
|
|
56
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
57
|
+
const { buildDirectory, assetsBuildDirectory, serverBuildPath } = await getBuildPaths(configFilePath, context.workspaceRoot);
|
|
58
|
+
const targets = {};
|
|
59
|
+
targets[options.buildTargetName] = buildTarget(options.buildTargetName, projectRoot, buildDirectory, assetsBuildDirectory, namedInputs);
|
|
60
|
+
targets[options.serveTargetName] = serveTarget(serverBuildPath);
|
|
61
|
+
targets[options.startTargetName] = startTarget(projectRoot, serverBuildPath, options.buildTargetName);
|
|
62
|
+
targets[options.typecheckTargetName] = typecheckTarget(projectRoot, namedInputs, siblingFiles);
|
|
63
|
+
return targets;
|
|
64
|
+
}
|
|
65
|
+
function buildTarget(buildTargetName, projectRoot, buildDirectory, assetsBuildDirectory, namedInputs) {
|
|
66
|
+
const serverBuildOutputPath = projectRoot === '.'
|
|
67
|
+
? (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, buildDirectory)
|
|
68
|
+
: (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot, buildDirectory);
|
|
69
|
+
const assetsBuildOutputPath = projectRoot === '.'
|
|
70
|
+
? (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, assetsBuildDirectory)
|
|
71
|
+
: (0, devkit_1.joinPathFragments)(`{workspaceRoot}`, projectRoot, assetsBuildDirectory);
|
|
72
|
+
return {
|
|
73
|
+
cache: true,
|
|
74
|
+
dependsOn: [`^${buildTargetName}`],
|
|
75
|
+
inputs: [
|
|
76
|
+
...('production' in namedInputs
|
|
77
|
+
? ['production', '^production']
|
|
78
|
+
: ['default', '^default']),
|
|
79
|
+
],
|
|
80
|
+
outputs: [serverBuildOutputPath, assetsBuildOutputPath],
|
|
81
|
+
executor: '@nx/remix:build',
|
|
82
|
+
options: {
|
|
83
|
+
outputPath: projectRoot,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function serveTarget(serverBuildPath) {
|
|
88
|
+
return {
|
|
89
|
+
executor: '@nx/remix:serve',
|
|
90
|
+
options: {
|
|
91
|
+
command: `npx remix-serve ${serverBuildPath}`,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function startTarget(projectRoot, serverBuildPath, buildTargetName) {
|
|
96
|
+
return {
|
|
97
|
+
dependsOn: [buildTargetName],
|
|
98
|
+
command: `npx remix-serve ${serverBuildPath}`,
|
|
99
|
+
options: {
|
|
100
|
+
cwd: projectRoot,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function typecheckTarget(projectRoot, namedInputs, siblingFiles) {
|
|
105
|
+
const hasTsConfigAppJson = siblingFiles.includes('tsconfig.app.json');
|
|
106
|
+
const command = `tsc${hasTsConfigAppJson ? ` --project tsconfig.app.json` : ``}`;
|
|
107
|
+
return {
|
|
108
|
+
command,
|
|
109
|
+
cache: true,
|
|
110
|
+
inputs: [
|
|
111
|
+
...('production' in namedInputs
|
|
112
|
+
? ['production', '^production']
|
|
113
|
+
: ['default', '^default']),
|
|
114
|
+
],
|
|
115
|
+
options: {
|
|
116
|
+
cwd: projectRoot,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async function getBuildPaths(configFilePath, workspaceRoot) {
|
|
121
|
+
const configPath = (0, path_1.join)(workspaceRoot, configFilePath);
|
|
122
|
+
let appConfig = await (0, config_utils_1.loadConfigFile)(configPath);
|
|
123
|
+
return {
|
|
124
|
+
buildDirectory: 'build',
|
|
125
|
+
serverBuildPath: appConfig.serverBuildPath ?? 'build/index.js',
|
|
126
|
+
assetsBuildDirectory: appConfig.assetsBuildDirectory ?? 'public/build',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function normalizeOptions(options) {
|
|
130
|
+
options ??= {};
|
|
131
|
+
options.buildTargetName ??= 'build';
|
|
132
|
+
options.serveTargetName ??= 'serve';
|
|
133
|
+
options.startTargetName ??= 'start';
|
|
134
|
+
options.typecheckTargetName ??= 'typecheck';
|
|
135
|
+
return options;
|
|
136
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ProjectGraph, type ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Generates an array of paths to watch based on the project dependencies.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} dirname The absolute path to the Remix project, typically `__dirname`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createWatchPaths(dirname: string): Promise<string[]>;
|
|
8
|
+
export declare function getRelativeDependencyPaths(project: ProjectGraphProjectNode, deps: string[], graph: ProjectGraph): string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRelativeDependencyPaths = exports.createWatchPaths = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
6
|
+
const project_graph_utils_1 = require("nx/src/utils/project-graph-utils");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
/**
|
|
9
|
+
* Generates an array of paths to watch based on the project dependencies.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} dirname The absolute path to the Remix project, typically `__dirname`.
|
|
12
|
+
*/
|
|
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);
|
|
19
|
+
}
|
|
20
|
+
exports.createWatchPaths = createWatchPaths;
|
|
21
|
+
// Exported for testing
|
|
22
|
+
function getRelativeDependencyPaths(project, deps, graph) {
|
|
23
|
+
if (!project.data?.root) {
|
|
24
|
+
throw new Error(`Project ${project.name} has no root set. Check the project configuration.`);
|
|
25
|
+
}
|
|
26
|
+
const paths = new Set();
|
|
27
|
+
const offset = (0, devkit_1.offsetFromRoot)(project.data.root);
|
|
28
|
+
const [baseProjectPath] = project.data.root.split('/');
|
|
29
|
+
for (const dep of deps) {
|
|
30
|
+
const node = graph.nodes[dep];
|
|
31
|
+
if (!node?.data?.root)
|
|
32
|
+
continue;
|
|
33
|
+
const [basePath] = (0, path_1.normalize)(node.data.root).split(path_1.sep);
|
|
34
|
+
const watchPath = baseProjectPath !== basePath ? basePath : node.data.root;
|
|
35
|
+
const relativeWatchPath = (0, devkit_1.joinPathFragments)(offset, watchPath);
|
|
36
|
+
paths.add(relativeWatchPath);
|
|
37
|
+
}
|
|
38
|
+
return Array.from(paths);
|
|
39
|
+
}
|
|
40
|
+
exports.getRelativeDependencyPaths = getRelativeDependencyPaths;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultExportName = void 0;
|
|
4
|
+
const get_default_export_1 = require("./get-default-export");
|
|
5
|
+
function getDefaultExportName(tree, path) {
|
|
6
|
+
return (0, get_default_export_1.getDefaultExport)(tree, path)?.name.text ?? 'Unknown';
|
|
7
|
+
}
|
|
8
|
+
exports.getDefaultExportName = getDefaultExportName;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultExport = void 0;
|
|
4
|
+
const typescript_1 = require("typescript");
|
|
5
|
+
function getDefaultExport(tree, path) {
|
|
6
|
+
const contents = tree.read(path, 'utf-8');
|
|
7
|
+
const sourceFile = (0, typescript_1.createSourceFile)(path, contents, typescript_1.ScriptTarget.ESNext);
|
|
8
|
+
const functionDeclarations = sourceFile.statements.filter(typescript_1.isFunctionDeclaration);
|
|
9
|
+
return functionDeclarations.find((functionDeclaration) => {
|
|
10
|
+
const isDefault = functionDeclaration.modifiers.find((mod) => mod.kind === typescript_1.SyntaxKind.DefaultKeyword);
|
|
11
|
+
const isExport = functionDeclaration.modifiers.find((mod) => mod.kind === typescript_1.SyntaxKind.ExportKeyword);
|
|
12
|
+
return isDefault && isExport;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.getDefaultExport = getDefaultExport;
|