@joshmossas/nx-cargo 0.6.5 → 0.6.7

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/dist/index.cjs CHANGED
@@ -30,23 +30,26 @@ function createDependencies(_, ctx) {
30
30
  const filepath = path__namespace.resolve(ctx.workspaceRoot, project.root, "Cargo.toml");
31
31
  const depth = filepath.split(path__namespace.sep).length;
32
32
  return { filepath, depth };
33
- }).filter((manifest) => fs__namespace.existsSync(manifest.filepath)).sort((a, b) => a.depth - b.depth);
33
+ }).filter((manifest) => {
34
+ return fs__namespace.existsSync(manifest.filepath);
35
+ }).sort((a, b) => a.depth - b.depth);
36
+ fs__namespace.writeFileSync("__cargo-manifests.json", JSON.stringify(sortedManifests));
34
37
  for (const { filepath } of sortedManifests) {
35
38
  if (seenManifestPaths.has(filepath)) {
36
39
  continue;
37
40
  }
38
41
  try {
39
42
  const metadata = getCargoMetadata(path__namespace.dirname(filepath));
40
- for (const pkg of metadata.packages) {
41
- seenManifestPaths.add(path__namespace.resolve(pkg.manifest_path));
43
+ if (metadata.packages) {
44
+ for (const pkg of metadata.packages) {
45
+ seenManifestPaths.add(path__namespace.resolve(pkg.manifest_path));
46
+ }
42
47
  }
43
48
  const workspaceDeps = processWorkspaceMetadata(ctx, metadata);
44
49
  allDependencies.push(...workspaceDeps);
45
50
  } catch (e) {
46
- console.warn(
47
- `[nx-rust] Skipping ${filepath} due to error:`,
48
- e instanceof Error ? e.message : e
49
- );
51
+ process.stderr.write(`[nx-rust] Error processing ${filepath}
52
+ `);
50
53
  }
51
54
  }
52
55
  return allDependencies;
@@ -86,6 +89,7 @@ function mapCargoProjects(ctx, packages) {
86
89
  });
87
90
  }
88
91
  }
92
+ fs__namespace.writeFileSync("__cargo-projects.json", JSON.stringify(result));
89
93
  return result;
90
94
  }
91
95
  function getCargoMetadata(cwd) {
package/dist/index.mjs CHANGED
@@ -11,23 +11,26 @@ function createDependencies(_, ctx) {
11
11
  const filepath = path.resolve(ctx.workspaceRoot, project.root, "Cargo.toml");
12
12
  const depth = filepath.split(path.sep).length;
13
13
  return { filepath, depth };
14
- }).filter((manifest) => fs.existsSync(manifest.filepath)).sort((a, b) => a.depth - b.depth);
14
+ }).filter((manifest) => {
15
+ return fs.existsSync(manifest.filepath);
16
+ }).sort((a, b) => a.depth - b.depth);
17
+ fs.writeFileSync("__cargo-manifests.json", JSON.stringify(sortedManifests));
15
18
  for (const { filepath } of sortedManifests) {
16
19
  if (seenManifestPaths.has(filepath)) {
17
20
  continue;
18
21
  }
19
22
  try {
20
23
  const metadata = getCargoMetadata(path.dirname(filepath));
21
- for (const pkg of metadata.packages) {
22
- seenManifestPaths.add(path.resolve(pkg.manifest_path));
24
+ if (metadata.packages) {
25
+ for (const pkg of metadata.packages) {
26
+ seenManifestPaths.add(path.resolve(pkg.manifest_path));
27
+ }
23
28
  }
24
29
  const workspaceDeps = processWorkspaceMetadata(ctx, metadata);
25
30
  allDependencies.push(...workspaceDeps);
26
31
  } catch (e) {
27
- console.warn(
28
- `[nx-rust] Skipping ${filepath} due to error:`,
29
- e instanceof Error ? e.message : e
30
- );
32
+ process.stderr.write(`[nx-rust] Error processing ${filepath}
33
+ `);
31
34
  }
32
35
  }
33
36
  return allDependencies;
@@ -67,6 +70,7 @@ function mapCargoProjects(ctx, packages) {
67
70
  });
68
71
  }
69
72
  }
73
+ fs.writeFileSync("__cargo-projects.json", JSON.stringify(result));
70
74
  return result;
71
75
  }
72
76
  function getCargoMetadata(cwd) {
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@joshmossas/nx-cargo",
3
3
  "private": false,
4
- "version": "0.6.5",
4
+ "version": "0.6.7",
5
5
  "license": "MIT",
6
+ "type": "module",
6
7
  "main": "dist/index.mjs",
8
+ "types": "dist/index.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
7
16
  "repository": {
8
17
  "type": "git",
9
18
  "url": "git+https://github.com/nxrs/cargo.git"
@@ -22,6 +31,7 @@
22
31
  "@nx/devkit": ">= 17"
23
32
  },
24
33
  "devDependencies": {
34
+ "typescript": "^5.9.3",
25
35
  "unbuild": "^3.6.1"
26
36
  },
27
37
  "scripts": {
@@ -59,11 +59,12 @@ export function createDependencies(_: unknown, ctx: Context): GraphDependency[]
59
59
  const depth = filepath.split(path.sep).length;
60
60
  return { filepath, depth };
61
61
  })
62
- .filter(manifest => fs.existsSync(manifest.filepath))
62
+ .filter(manifest => {
63
+ return fs.existsSync(manifest.filepath);
64
+ })
63
65
  .sort((a, b) => a.depth - b.depth);
64
-
66
+ fs.writeFileSync("__cargo-manifests.json", JSON.stringify(sortedManifests));
65
67
  for (const { filepath } of sortedManifests) {
66
- // 2. Skip if this manifest was already included in a previously processed workspace
67
68
  if (seenManifestPaths.has(filepath)) {
68
69
  continue;
69
70
  }
@@ -71,19 +72,17 @@ export function createDependencies(_: unknown, ctx: Context): GraphDependency[]
71
72
  try {
72
73
  const metadata = getCargoMetadata(path.dirname(filepath));
73
74
 
74
- // 3. Mark every package in this metadata as "seen" to avoid redundant calls
75
- for (const pkg of metadata.packages) {
76
- seenManifestPaths.add(path.resolve(pkg.manifest_path));
75
+ if (metadata.packages) {
76
+ for (const pkg of metadata.packages) {
77
+ seenManifestPaths.add(path.resolve(pkg.manifest_path));
78
+ }
77
79
  }
78
80
 
79
- // 4. Extract dependencies from this specific workspace/crate
80
81
  const workspaceDeps = processWorkspaceMetadata(ctx, metadata);
81
82
  allDependencies.push(...workspaceDeps);
82
83
  } catch (e) {
83
- console.warn(
84
- `[nx-rust] Skipping ${filepath} due to error:`,
85
- e instanceof Error ? e.message : e
86
- );
84
+ // Log to stderr so it shows up in the terminal even if Nx masks the error
85
+ process.stderr.write(`[nx-rust] Error processing ${filepath}\n`);
87
86
  }
88
87
  }
89
88
 
@@ -151,6 +150,8 @@ function mapCargoProjects(ctx: Context, packages: Map<CargoId, CargoPackage>) {
151
150
  }
152
151
  }
153
152
 
153
+ fs.writeFileSync("__cargo-projects.json", JSON.stringify(result));
154
+
154
155
  return result;
155
156
  }
156
157