@joshmossas/nx-cargo 0.6.4 → 0.6.6

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
+ console.log("CHECKING FOR Cargo.toml", manifest.filepath);
35
+ return fs__namespace.existsSync(manifest.filepath);
36
+ }).sort((a, b) => a.depth - b.depth);
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;
@@ -90,10 +93,14 @@ function mapCargoProjects(ctx, packages) {
90
93
  }
91
94
  function getCargoMetadata(cwd) {
92
95
  const availableMemory = os__namespace.freemem();
96
+ const cmd = "cargo metadata --format-version=1 --no-deps";
97
+ console.info(`[nx-json] Executing: "${cmd}"`);
93
98
  const metadata = cp__namespace.execSync("cargo metadata --format-version=1 --no-deps", {
94
99
  encoding: "utf8",
95
100
  maxBuffer: availableMemory,
96
- cwd
101
+ cwd,
102
+ env: { ...process.env },
103
+ stdio: ["ignore", "pipe", "pipe"]
97
104
  });
98
105
  return JSON.parse(metadata);
99
106
  }
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
+ console.log("CHECKING FOR Cargo.toml", manifest.filepath);
16
+ return fs.existsSync(manifest.filepath);
17
+ }).sort((a, b) => a.depth - b.depth);
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;
@@ -71,10 +74,14 @@ function mapCargoProjects(ctx, packages) {
71
74
  }
72
75
  function getCargoMetadata(cwd) {
73
76
  const availableMemory = os.freemem();
77
+ const cmd = "cargo metadata --format-version=1 --no-deps";
78
+ console.info(`[nx-json] Executing: "${cmd}"`);
74
79
  const metadata = cp.execSync("cargo metadata --format-version=1 --no-deps", {
75
80
  encoding: "utf8",
76
81
  maxBuffer: availableMemory,
77
- cwd
82
+ cwd,
83
+ env: { ...process.env },
84
+ stdio: ["ignore", "pipe", "pipe"]
78
85
  });
79
86
  return JSON.parse(metadata);
80
87
  }
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@joshmossas/nx-cargo",
3
3
  "private": false,
4
- "version": "0.6.4",
4
+ "version": "0.6.6",
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,13 @@ 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
+ console.log("CHECKING FOR Cargo.toml", manifest.filepath);
64
+ return fs.existsSync(manifest.filepath);
65
+ })
63
66
  .sort((a, b) => a.depth - b.depth);
64
67
 
65
68
  for (const { filepath } of sortedManifests) {
66
- // 2. Skip if this manifest was already included in a previously processed workspace
67
69
  if (seenManifestPaths.has(filepath)) {
68
70
  continue;
69
71
  }
@@ -71,19 +73,17 @@ export function createDependencies(_: unknown, ctx: Context): GraphDependency[]
71
73
  try {
72
74
  const metadata = getCargoMetadata(path.dirname(filepath));
73
75
 
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));
76
+ if (metadata.packages) {
77
+ for (const pkg of metadata.packages) {
78
+ seenManifestPaths.add(path.resolve(pkg.manifest_path));
79
+ }
77
80
  }
78
81
 
79
- // 4. Extract dependencies from this specific workspace/crate
80
82
  const workspaceDeps = processWorkspaceMetadata(ctx, metadata);
81
83
  allDependencies.push(...workspaceDeps);
82
84
  } catch (e) {
83
- console.warn(
84
- `[nx-rust] Skipping ${filepath} due to error:`,
85
- e instanceof Error ? e.message : e
86
- );
85
+ // Log to stderr so it shows up in the terminal even if Nx masks the error
86
+ process.stderr.write(`[nx-rust] Error processing ${filepath}\n`);
87
87
  }
88
88
  }
89
89
 
@@ -160,10 +160,14 @@ function mapCargoProjects(ctx: Context, packages: Map<CargoId, CargoPackage>) {
160
160
  */
161
161
  function getCargoMetadata(cwd: string): CargoMetadata {
162
162
  const availableMemory = os.freemem();
163
+ const cmd = "cargo metadata --format-version=1 --no-deps";
164
+ console.info(`[nx-json] Executing: "${cmd}"`);
163
165
  const metadata = cp.execSync("cargo metadata --format-version=1 --no-deps", {
164
166
  encoding: "utf8",
165
167
  maxBuffer: availableMemory,
166
168
  cwd: cwd,
169
+ env: { ...process.env },
170
+ stdio: ["ignore", "pipe", "pipe"],
167
171
  });
168
172
 
169
173
  return JSON.parse(metadata);