@nx/remix 20.2.1 → 20.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/remix",
3
- "version": "20.2.1",
3
+ "version": "20.2.2",
4
4
  "description": "The Remix plugin for Nx contains executors and generators for managing Remix applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Vitest, Jest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, routes, loaders, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,9 +29,9 @@
29
29
  "migrations": "./migrations.json"
30
30
  },
31
31
  "dependencies": {
32
- "@nx/devkit": "20.2.1",
33
- "@nx/js": "20.2.1",
34
- "@nx/react": "20.2.1",
32
+ "@nx/devkit": "20.2.2",
33
+ "@nx/js": "20.2.2",
34
+ "@nx/react": "20.2.2",
35
35
  "tslib": "^2.3.1",
36
36
  "@phenomnomnominal/tsquery": "~5.0.1"
37
37
  },
@@ -7,13 +7,14 @@ const remix_route_utils_1 = require("../../utils/remix-route-utils");
7
7
  const action_impl_1 = require("../action/action.impl");
8
8
  const loader_impl_1 = require("../loader/loader.impl");
9
9
  async function default_1(tree, options) {
10
- const { artifactName: name, directory } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
10
+ const { filePath: routeFilePath } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
11
11
  path: options.path.replace(/^\//, '').replace(/\/$/, ''),
12
+ allowedFileExtensions: ['ts', 'tsx'],
13
+ fileExtension: 'tsx',
12
14
  });
13
15
  if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
14
16
  throw new Error(`Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.`);
15
17
  }
16
- const routeFilePath = await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, (0, devkit_1.joinPathFragments)(directory, name), undefined);
17
18
  if (tree.exists(routeFilePath))
18
19
  throw new Error(`Path already exists: ${options.path}`);
19
20
  if (!options.loader && !options.action)
@@ -6,19 +6,23 @@
6
6
  "description": "Generate a resource route.",
7
7
  "examples": [
8
8
  {
9
- "command": "g resource-route 'path/to/page'",
10
- "description": "Generate resource route at /path/to/page"
9
+ "description": "Generate a resource route at `myapp/app/routes/foo.ts`",
10
+ "command": "nx g resource-route myapp/app/routes/foo.ts"
11
+ },
12
+ {
13
+ "description": "Generate a resource route without providing the file extension at `myapp/app/routes/foo.tsx`",
14
+ "command": "nx g resource-route myapp/app/routes/foo"
11
15
  }
12
16
  ],
13
17
  "properties": {
14
18
  "path": {
15
19
  "type": "string",
16
- "description": "The route path or path to the filename of the route.",
20
+ "description": "The file path to the route. Relative to the current working directory.",
17
21
  "$default": {
18
22
  "$source": "argv",
19
23
  "index": 0
20
24
  },
21
- "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar')"
25
+ "x-prompt": "What is the route file path?"
22
26
  },
23
27
  "action": {
24
28
  "type": "boolean",
@@ -10,20 +10,15 @@ const loader_impl_1 = require("../loader/loader.impl");
10
10
  const meta_impl_1 = require("../meta/meta.impl");
11
11
  const style_impl_1 = require("../style/style.impl");
12
12
  async function default_1(tree, options) {
13
- const { artifactName: name, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
13
+ const { artifactName: name, filePath: routeFilePath } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
14
14
  path: options.path.replace(/^\//, '').replace(/\/$/, ''),
15
+ allowedFileExtensions: ['ts', 'tsx'],
16
+ fileExtension: 'tsx',
15
17
  });
16
- const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
17
- if (!project)
18
- throw new Error(`Project does not exist: ${projectName}`);
19
18
  if (!options.skipChecks && (0, remix_route_utils_1.checkRoutePathForErrors)(options.path)) {
20
19
  throw new Error(`Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.`);
21
20
  }
22
- const routeFilePath = await (0, remix_route_utils_1.resolveRemixRouteFile)(tree, (0, devkit_1.joinPathFragments)(directory, name), undefined);
23
- const nameToUseForComponent = name.replace('.tsx', '');
24
- const { className: componentName } = (0, devkit_1.names)(nameToUseForComponent === '.' || nameToUseForComponent === ''
25
- ? (0, path_1.basename)((0, path_1.dirname)(routeFilePath))
26
- : nameToUseForComponent);
21
+ const { className: componentName } = (0, devkit_1.names)(name === '.' || name === '' ? (0, path_1.basename)((0, path_1.dirname)(routeFilePath)) : name);
27
22
  if (tree.exists(routeFilePath))
28
23
  throw new Error(`Path already exists: ${routeFilePath}`);
29
24
  tree.write(routeFilePath, (0, devkit_1.stripIndents) `
@@ -6,19 +6,23 @@
6
6
  "type": "object",
7
7
  "examples": [
8
8
  {
9
- "command": "g route 'path/to/page'",
10
- "description": "Generate route at /path/to/page"
9
+ "description": "Generate a route at `myapp/app/routes/foo.tsx`",
10
+ "command": "nx g resource-route myapp/app/routes/foo.tsx"
11
+ },
12
+ {
13
+ "description": "Generate a route without providing the file extension at `myapp/app/routes/foo.tsx`",
14
+ "command": "nx g resource-route myapp/app/routes/foo"
11
15
  }
12
16
  ],
13
17
  "properties": {
14
18
  "path": {
15
19
  "type": "string",
16
- "description": "The route path or path to the filename of the route.",
20
+ "description": "The file path to the route. Relative to the current working directory.",
17
21
  "$default": {
18
22
  "$source": "argv",
19
23
  "index": 0
20
24
  },
21
- "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar')"
25
+ "x-prompt": "What is the route file path?"
22
26
  },
23
27
  "style": {
24
28
  "type": "string",
@@ -6,19 +6,19 @@
6
6
  "type": "object",
7
7
  "examples": [
8
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"
9
+ "description": "Generate a stylesheet at `myapp/app/styles/foo.css`",
10
+ "command": "nx g style myapp/app/routes/foo.tsx"
11
11
  }
12
12
  ],
13
13
  "properties": {
14
14
  "path": {
15
15
  "type": "string",
16
- "description": "Route path",
16
+ "description": "The file path to the route. Relative to the current working directory.",
17
17
  "$default": {
18
18
  "$source": "argv",
19
19
  "index": 0
20
20
  },
21
- "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')"
21
+ "x-prompt": "What is the route file path?"
22
22
  }
23
23
  },
24
24
  "required": ["path"]
@@ -8,16 +8,14 @@ const insert_import_1 = require("../../utils/insert-import");
8
8
  const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
9
9
  const remix_route_utils_1 = require("../../utils/remix-route-utils");
10
10
  async function default_1(tree, options) {
11
- const { project: projectName, artifactName: name } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
11
+ const { project: projectName, directory, fileName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
12
12
  path: options.path,
13
13
  });
14
14
  const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
15
15
  if (!project)
16
16
  throw new Error(`Project does not exist: ${projectName}`);
17
17
  const appDir = await (0, remix_route_utils_1.resolveRemixAppDirectory)(tree, project.name);
18
- const normalizedRoutePath = `${(0, remix_route_utils_1.normalizeRoutePath)(options.path)
19
- .replace(/^\//, '')
20
- .replace('.tsx', '')}.css`;
18
+ const normalizedRoutePath = `${(0, remix_route_utils_1.normalizeRoutePath)((0, devkit_1.joinPathFragments)(directory, fileName)).replace(/^\//, '')}.css`;
21
19
  const stylesheetPath = (0, devkit_1.joinPathFragments)(appDir, 'styles', normalizedRoutePath);
22
20
  tree.write(stylesheetPath, (0, devkit_1.stripIndents) `
23
21
  :root {
@@ -1,13 +1,4 @@
1
1
  import { Tree } from '@nx/devkit';
2
- /**
3
- *
4
- * @param tree
5
- * @param path to the route which could be fully specified or just "foo/bar"
6
- * @param projectName the name of the project where the route should be added
7
- * @param fileExtension the file extension to add to resolved route file
8
- * @returns file path to the route
9
- */
10
- export declare function resolveRemixRouteFile(tree: Tree, path: string, projectName?: string, fileExtension?: string): Promise<string>;
11
2
  export declare function normalizeRoutePath(path: string): string;
12
3
  export declare function checkRoutePathForErrors(path: string): RegExpMatchArray;
13
4
  export declare function resolveRemixAppDirectory(tree: Tree, projectName: string): Promise<string>;
@@ -1,57 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveRemixRouteFile = resolveRemixRouteFile;
4
3
  exports.normalizeRoutePath = normalizeRoutePath;
5
4
  exports.checkRoutePathForErrors = checkRoutePathForErrors;
6
5
  exports.resolveRemixAppDirectory = resolveRemixAppDirectory;
7
6
  const devkit_1 = require("@nx/devkit");
8
- const remix_config_1 = require("./remix-config");
9
7
  const path_1 = require("path");
10
- /**
11
- *
12
- * @param tree
13
- * @param path to the route which could be fully specified or just "foo/bar"
14
- * @param projectName the name of the project where the route should be added
15
- * @param fileExtension the file extension to add to resolved route file
16
- * @returns file path to the route
17
- */
18
- async function resolveRemixRouteFile(tree, path, projectName, fileExtension) {
19
- const { name: routePath } = (0, devkit_1.names)(path.replace(/^\//, '').replace(/\/$/, ''));
20
- if (!projectName) {
21
- return appendRouteFileExtension(tree, routePath, fileExtension);
22
- }
23
- else {
24
- const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
25
- if (!project)
26
- throw new Error(`Project does not exist: ${projectName}`);
27
- const normalizedRoutePath = normalizeRoutePath(routePath);
28
- const fileName = appendRouteFileExtension(tree, normalizedRoutePath, fileExtension);
29
- return (0, devkit_1.joinPathFragments)(await resolveRemixAppDirectory(tree, projectName), 'routes', fileName);
30
- }
31
- }
32
- function appendRouteFileExtension(tree, routePath, fileExtension) {
33
- // if no file extension specified, let's try to find it
34
- if (!fileExtension) {
35
- // see if the path already has it
36
- const extensionMatch = routePath.match(/(\.[^.]+)$/);
37
- if (extensionMatch) {
38
- fileExtension = extensionMatch[0];
39
- }
40
- else {
41
- // look for either .ts or .tsx to exist in tree
42
- if (tree.exists(`${routePath}.ts`)) {
43
- fileExtension = '.ts';
44
- }
45
- else {
46
- // default to .tsx if nothing else found
47
- fileExtension = '.tsx';
48
- }
49
- }
50
- }
51
- return routePath.endsWith(fileExtension)
52
- ? routePath
53
- : `${routePath}${fileExtension}`;
54
- }
8
+ const remix_config_1 = require("./remix-config");
55
9
  function normalizeRoutePath(path) {
56
10
  return path.indexOf('/routes/') > -1
57
11
  ? path.substring(path.indexOf('/routes/') + 8)