@trustify-da/trustify-da-javascript-client 0.3.0-ea.a783c26 → 0.3.0-ea.a87208f

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.
Files changed (81) hide show
  1. package/README.md +177 -3
  2. package/dist/package.json +27 -22
  3. package/dist/src/analysis.d.ts +14 -7
  4. package/dist/src/analysis.js +29 -13
  5. package/dist/src/cli.js +106 -2
  6. package/dist/src/cyclone_dx_sbom.d.ts +20 -1
  7. package/dist/src/cyclone_dx_sbom.js +68 -9
  8. package/dist/src/index.d.ts +74 -11
  9. package/dist/src/index.js +83 -29
  10. package/dist/src/license/index.d.ts +3 -3
  11. package/dist/src/license/index.js +4 -1
  12. package/dist/src/license/license_utils.js +4 -1
  13. package/dist/src/license/licenses_api.d.ts +2 -2
  14. package/dist/src/oci_image/images.d.ts +1 -1
  15. package/dist/src/oci_image/images.js +15 -1
  16. package/dist/src/oci_image/utils.d.ts +5 -5
  17. package/dist/src/package_version.d.ts +8 -0
  18. package/dist/src/package_version.js +31 -0
  19. package/dist/src/provider.d.ts +4 -3
  20. package/dist/src/provider.js +6 -2
  21. package/dist/src/providers/base_java.d.ts +67 -12
  22. package/dist/src/providers/base_java.js +82 -61
  23. package/dist/src/providers/base_javascript.d.ts +74 -9
  24. package/dist/src/providers/base_javascript.js +115 -6
  25. package/dist/src/providers/base_pyproject.d.ts +15 -6
  26. package/dist/src/providers/base_pyproject.js +12 -4
  27. package/dist/src/providers/containerfile_parser.d.ts +5 -0
  28. package/dist/src/providers/containerfile_parser.js +20 -0
  29. package/dist/src/providers/golang_gomodules.d.ts +11 -1
  30. package/dist/src/providers/golang_gomodules.js +108 -10
  31. package/dist/src/providers/java_gradle.d.ts +19 -0
  32. package/dist/src/providers/java_gradle.js +116 -2
  33. package/dist/src/providers/java_gradle_groovy.d.ts +1 -1
  34. package/dist/src/providers/java_gradle_kotlin.d.ts +1 -1
  35. package/dist/src/providers/java_maven.d.ts +38 -5
  36. package/dist/src/providers/java_maven.js +261 -8
  37. package/dist/src/providers/javascript_bun.d.ts +22 -0
  38. package/dist/src/providers/javascript_bun.js +141 -0
  39. package/dist/src/providers/javascript_npm.d.ts +19 -1
  40. package/dist/src/providers/javascript_npm.js +40 -1
  41. package/dist/src/providers/javascript_pnpm.d.ts +13 -0
  42. package/dist/src/providers/javascript_pnpm.js +53 -3
  43. package/dist/src/providers/javascript_yarn.d.ts +12 -0
  44. package/dist/src/providers/javascript_yarn.js +75 -2
  45. package/dist/src/providers/marker_evaluator.d.ts +14 -0
  46. package/dist/src/providers/marker_evaluator.js +191 -0
  47. package/dist/src/providers/oci_dockerfile.d.ts +51 -0
  48. package/dist/src/providers/oci_dockerfile.js +177 -0
  49. package/dist/src/providers/processors/yarn_berry_processor.d.ts +6 -2
  50. package/dist/src/providers/processors/yarn_berry_processor.js +3 -2
  51. package/dist/src/providers/processors/yarn_classic_processor.d.ts +6 -2
  52. package/dist/src/providers/processors/yarn_classic_processor.js +8 -6
  53. package/dist/src/providers/python_controller.d.ts +5 -1
  54. package/dist/src/providers/python_controller.js +62 -5
  55. package/dist/src/providers/python_pip.d.ts +5 -0
  56. package/dist/src/providers/python_pip.js +5 -5
  57. package/dist/src/providers/python_pip_pyproject.js +3 -1
  58. package/dist/src/providers/python_poetry.d.ts +63 -8
  59. package/dist/src/providers/python_poetry.js +132 -21
  60. package/dist/src/providers/python_uv.d.ts +20 -1
  61. package/dist/src/providers/python_uv.js +122 -2
  62. package/dist/src/providers/rust_cargo.d.ts +6 -2
  63. package/dist/src/providers/rust_cargo.js +105 -19
  64. package/dist/src/providers/tree-sitter-containerfile.wasm +0 -0
  65. package/dist/src/remediate.d.ts +21 -0
  66. package/dist/src/remediate.js +149 -0
  67. package/dist/src/remediation.d.ts +57 -0
  68. package/dist/src/remediation.js +436 -0
  69. package/dist/src/remediation_report.d.ts +40 -0
  70. package/dist/src/remediation_report.js +159 -0
  71. package/dist/src/sbom.d.ts +18 -1
  72. package/dist/src/sbom.js +14 -2
  73. package/dist/src/tools.d.ts +28 -2
  74. package/dist/src/tools.js +82 -1
  75. package/dist/src/updaters/maven_updater.d.ts +26 -0
  76. package/dist/src/updaters/maven_updater.js +322 -0
  77. package/dist/src/updaters/toml_updater.d.ts +33 -0
  78. package/dist/src/updaters/toml_updater.js +244 -0
  79. package/dist/src/workspace.d.ts +9 -0
  80. package/dist/src/workspace.js +1 -1
  81. package/package.json +28 -23
@@ -1,7 +1,9 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { parse as parseToml } from 'smol-toml';
3
4
  import { environmentVariableIsPopulated, getCustom, getCustomPath, invokeCommand } from '../tools.js';
4
5
  import Base_pyproject from './base_pyproject.js';
6
+ import { evaluateMarker } from './marker_evaluator.js';
5
7
  export default class Python_poetry extends Base_pyproject {
6
8
  /**
7
9
  * Poetry has no native workspace/monorepo support (python-poetry/poetry#2270).
@@ -30,6 +32,17 @@ export default class Python_poetry extends Base_pyproject {
30
32
  _cmdName() {
31
33
  return 'poetry';
32
34
  }
35
+ _verifyPoetryAccessible(poetryBin) {
36
+ try {
37
+ invokeCommand(poetryBin, ['--version']);
38
+ }
39
+ catch (error) {
40
+ if (error.code === 'ENOENT') {
41
+ throw new Error(`poetry is not accessible at "${poetryBin}"`, { cause: error });
42
+ }
43
+ throw new Error('failed to check for poetry binary', { cause: error });
44
+ }
45
+ }
33
46
  /**
34
47
  * @param {string} manifestDir
35
48
  * @param {string} _workspaceDir - unused (poetry has no workspace support)
@@ -39,24 +52,31 @@ export default class Python_poetry extends Base_pyproject {
39
52
  */
40
53
  // eslint-disable-next-line no-unused-vars
41
54
  async _getDependencyData(manifestDir, _workspaceDir, parsed, opts) {
55
+ let poetryBin = getCustomPath('poetry', opts);
56
+ let envBypass = environmentVariableIsPopulated('TRUSTIFY_DA_POETRY_SHOW_TREE')
57
+ && environmentVariableIsPopulated('TRUSTIFY_DA_POETRY_SHOW_ALL');
58
+ if (!envBypass) {
59
+ this._verifyPoetryAccessible(poetryBin);
60
+ }
42
61
  let hasDevGroup = !!(parsed.tool?.poetry?.group?.dev || parsed.tool?.poetry?.['dev-dependencies']);
43
- let treeOutput = this._getPoetryShowTreeOutput(manifestDir, hasDevGroup, opts);
44
- let showAllOutput = this._getPoetryShowAllOutput(manifestDir, opts);
62
+ let treeOutput = this._getPoetryShowTreeOutput(manifestDir, hasDevGroup, poetryBin);
63
+ let showAllOutput = this._getPoetryShowAllOutput(manifestDir, poetryBin);
45
64
  let versionMap = this._parsePoetryShowAll(showAllOutput);
46
- return this._parsePoetryTree(treeOutput, versionMap);
65
+ let lockDir = this._findLockFileDir(manifestDir, opts);
66
+ let markerData = this._extractMarkerData(lockDir, parsed);
67
+ return this._parsePoetryTree(treeOutput, versionMap, markerData);
47
68
  }
48
69
  /**
49
70
  * Get poetry show --tree output.
50
71
  * @param {string} manifestDir
51
72
  * @param {boolean} hasDevGroup
52
- * @param {Object} opts
73
+ * @param {string} poetryBin
53
74
  * @returns {string}
54
75
  */
55
- _getPoetryShowTreeOutput(manifestDir, hasDevGroup, opts) {
76
+ _getPoetryShowTreeOutput(manifestDir, hasDevGroup, poetryBin) {
56
77
  if (environmentVariableIsPopulated('TRUSTIFY_DA_POETRY_SHOW_TREE')) {
57
78
  return Buffer.from(process.env['TRUSTIFY_DA_POETRY_SHOW_TREE'], 'base64').toString('utf-8');
58
79
  }
59
- let poetryBin = getCustomPath('poetry', opts);
60
80
  let args = ['show', '--tree', '--no-ansi'];
61
81
  if (hasDevGroup) {
62
82
  args.push('--without', 'dev');
@@ -66,14 +86,13 @@ export default class Python_poetry extends Base_pyproject {
66
86
  /**
67
87
  * Get poetry show --all output (flat list with resolved versions).
68
88
  * @param {string} manifestDir
69
- * @param {Object} opts
89
+ * @param {string} poetryBin
70
90
  * @returns {string}
71
91
  */
72
- _getPoetryShowAllOutput(manifestDir, opts) {
92
+ _getPoetryShowAllOutput(manifestDir, poetryBin) {
73
93
  if (environmentVariableIsPopulated('TRUSTIFY_DA_POETRY_SHOW_ALL')) {
74
94
  return Buffer.from(process.env['TRUSTIFY_DA_POETRY_SHOW_ALL'], 'base64').toString('utf-8');
75
95
  }
76
- let poetryBin = getCustomPath('poetry', opts);
77
96
  return invokeCommand(poetryBin, ['show', '--no-ansi', '--all'], { cwd: manifestDir }).toString();
78
97
  }
79
98
  /**
@@ -98,16 +117,83 @@ export default class Python_poetry extends Base_pyproject {
98
117
  }
99
118
  return versions;
100
119
  }
120
+ /**
121
+ * Collects PEP 508 marker expressions for direct and transitive deps.
122
+ * Direct markers come from pyproject.toml dependency strings, e.g.:
123
+ * "pywin32>=311 ; sys_platform == 'win32'" → directMarkers['pywin32'] = "sys_platform == 'win32'"
124
+ * Transitive markers come from poetry.lock [package.dependencies] entries, e.g.:
125
+ * colorama = {version = "*", markers = "sys_platform == 'win32'"}
126
+ * → transitiveMarkers['click']['colorama'] = "sys_platform == 'win32'"
127
+ * @param {string|null} lockDir
128
+ * @param {object} parsed - parsed pyproject.toml
129
+ * @returns {{directMarkers: Map<string, string>, transitiveMarkers: Map<string, Map<string, string>>, hashMap: Map<string, Array<{alg: string, content: string}>>}}
130
+ */
131
+ _extractMarkerData(lockDir, parsed) {
132
+ let directMarkers = new Map();
133
+ let transitiveMarkers = new Map();
134
+ let hashMap = new Map();
135
+ // Extract markers from PEP 621 dependency strings: "name[extras]>=ver ; marker"
136
+ let deps = parsed.project?.dependencies || [];
137
+ for (let dep of deps) {
138
+ let m = dep.match(/^([A-Za-z0-9][A-Za-z0-9._-]*)\s*[^;]*;\s*(.+)$/);
139
+ if (m) {
140
+ directMarkers.set(this._canonicalize(m[1]), m[2].trim());
141
+ }
142
+ }
143
+ if (lockDir) {
144
+ let lockPath = path.join(lockDir, this._lockFileName());
145
+ if (fs.existsSync(lockPath)) {
146
+ let lockContent = fs.readFileSync(lockPath, 'utf-8');
147
+ let lock = parseToml(lockContent);
148
+ let packages = lock.package || [];
149
+ for (let pkg of packages) {
150
+ let pkgKey = this._canonicalize(pkg.name);
151
+ let pkgDeps = pkg.dependencies || {};
152
+ for (let [depName, depSpec] of Object.entries(pkgDeps)) {
153
+ let markers = typeof depSpec === 'object' && depSpec != null ? depSpec.markers : null;
154
+ if (markers) {
155
+ if (!transitiveMarkers.has(pkgKey)) {
156
+ transitiveMarkers.set(pkgKey, new Map());
157
+ }
158
+ transitiveMarkers.get(pkgKey).set(this._canonicalize(depName), markers);
159
+ }
160
+ }
161
+ let sha256Hex = this._extractSha256FromFiles(pkg.files);
162
+ if (sha256Hex) {
163
+ hashMap.set(pkgKey, [{ alg: "SHA-256", content: sha256Hex }]);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ return { directMarkers, transitiveMarkers, hashMap };
169
+ }
170
+ /**
171
+ * Extract a SHA-256 hex digest from poetry.lock files array.
172
+ * Prefers the sdist (.tar.gz) hash; falls back to the first wheel hash.
173
+ * @param {Array<{file: string, hash: string}>} [files]
174
+ * @returns {string|null}
175
+ */
176
+ _extractSha256FromFiles(files) {
177
+ if (!Array.isArray(files) || files.length === 0) {
178
+ return null;
179
+ }
180
+ let sdist = files.find(f => f.file.endsWith('.tar.gz'));
181
+ let entry = sdist || files[0];
182
+ let hash = entry.hash;
183
+ if (hash && hash.startsWith('sha256:')) {
184
+ return hash.slice(7);
185
+ }
186
+ return null;
187
+ }
101
188
  /**
102
189
  * Parse poetry show --tree output into a dependency graph structure.
103
- * Top-level lines (no indentation/tree chars) are direct deps: "name version description"
104
- * Indented lines are transitive deps with tree chars: "├── name >=constraint"
105
190
  *
106
191
  * @param {string} treeOutput
107
192
  * @param {Map<string, string>} versionMap - canonical name -> resolved version
108
- * @returns {{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}}
193
+ * @param {{directMarkers: Map<string, string>, transitiveMarkers: Map<string, Map<string, string>>, hashMap: Map<string, Array<{alg: string, content: string}>>}} markerData
194
+ * @returns {{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[], hashes?: Array<{alg: string, content: string}>}>}}
109
195
  */
110
- _parsePoetryTree(treeOutput, versionMap) {
196
+ _parsePoetryTree(treeOutput, versionMap, markerData) {
111
197
  let lines = treeOutput.split(/\r?\n/);
112
198
  let graph = new Map();
113
199
  let directDeps = [];
@@ -123,9 +209,20 @@ export default class Python_poetry extends Base_pyproject {
123
209
  let name = topMatch[1];
124
210
  let version = topMatch[2];
125
211
  let key = this._canonicalize(name);
212
+ let marker = markerData.directMarkers.get(key);
213
+ if (marker && !evaluateMarker(marker)) {
214
+ currentDirectDep = null;
215
+ stack = [];
216
+ continue;
217
+ }
126
218
  directDeps.push(key);
127
219
  if (!graph.has(key)) {
128
- graph.set(key, { name, version, children: [] });
220
+ let entry = { name, version, children: [] };
221
+ let hashes = markerData.hashMap.get(key);
222
+ if (hashes) {
223
+ entry.hashes = hashes;
224
+ }
225
+ graph.set(key, entry);
129
226
  }
130
227
  currentDirectDep = key;
131
228
  stack = [{ key, depth: -1 }];
@@ -149,20 +246,34 @@ export default class Python_poetry extends Base_pyproject {
149
246
  // determine depth by counting tree-drawing groups in the prefix
150
247
  let prefix = line.substring(0, nameStart);
151
248
  let depth = (prefix.match(/(?:[├└│ ][\s─]{2} ?)/g) || []).length;
249
+ // pop stack back to find the parent at depth-1
250
+ while (stack.length > 0 && stack[stack.length - 1].depth >= depth) {
251
+ stack.pop();
252
+ }
253
+ let parentKey = stack.length > 0 ? stack[stack.length - 1].key : null;
254
+ if (parentKey) {
255
+ let parentMarkers = markerData.transitiveMarkers.get(parentKey);
256
+ if (parentMarkers) {
257
+ let marker = parentMarkers.get(depKey);
258
+ if (marker && !evaluateMarker(marker)) {
259
+ continue;
260
+ }
261
+ }
262
+ }
152
263
  // resolve version from the version map
153
264
  let version = versionMap.get(depKey) || null;
154
265
  if (!version) {
155
266
  throw new Error(`poetry: package '${depName}' has no resolved version`);
156
267
  }
157
268
  if (!graph.has(depKey)) {
158
- graph.set(depKey, { name: depName, version, children: [] });
159
- }
160
- // pop stack back to find the parent at depth-1
161
- while (stack.length > 0 && stack[stack.length - 1].depth >= depth) {
162
- stack.pop();
269
+ let entry = { name: depName, version, children: [] };
270
+ let hashes = markerData.hashMap.get(depKey);
271
+ if (hashes) {
272
+ entry.hashes = hashes;
273
+ }
274
+ graph.set(depKey, entry);
163
275
  }
164
- if (stack.length > 0) {
165
- let parentKey = stack[stack.length - 1].key;
276
+ if (parentKey) {
166
277
  let parentEntry = graph.get(parentKey);
167
278
  if (parentEntry && !parentEntry.children.includes(depKey)) {
168
279
  parentEntry.children.push(depKey);
@@ -1,11 +1,30 @@
1
+ /**
2
+ * Discover all pyproject.toml manifest paths in a uv workspace.
3
+ * Parses `[tool.uv.workspace]` from root pyproject.toml and glob-expands member patterns.
4
+ *
5
+ * @param {string} workspaceRoot - Absolute or relative path to workspace root (must contain pyproject.toml and uv.lock)
6
+ * @param {{ workspaceDiscoveryIgnore?: string[], TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE?: string, [key: string]: unknown }} [opts={}]
7
+ * @returns {Promise<string[]>} Paths to pyproject.toml files (absolute)
8
+ */
9
+ export function discoverUvWorkspaceMembers(workspaceRoot: string, opts?: {
10
+ workspaceDiscoveryIgnore?: string[];
11
+ TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE?: string;
12
+ [key: string]: unknown;
13
+ }): Promise<string[]>;
1
14
  export default class Python_uv extends Base_pyproject {
15
+ /**
16
+ * Parse uv.lock and attach SHA-256 hashes to graph entries.
17
+ * @param {string} lockFilePath - path to uv.lock
18
+ * @param {Map<string, import('./base_pyproject.js').GraphEntry>} graph
19
+ */
20
+ _attachHashesFromLockFile(lockFilePath: string, graph: Map<string, import("./base_pyproject.js").GraphEntry>): Promise<void>;
2
21
  /**
3
22
  * Get the uv export output, either from env var or by running the command.
4
23
  * @param {string} manifestDir
5
24
  * @param {Object} opts
6
25
  * @returns {string}
7
26
  */
8
- _getUvExportOutput(manifestDir: string, opts: any): string;
27
+ _getUvExportOutput(manifestDir: string, opts: Object): string;
9
28
  /**
10
29
  * Parse uv export output into a dependency graph using tree-sitter-requirements
11
30
  * for package/version extraction and string parsing for "# via" comments.
@@ -1,8 +1,11 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import fg from 'fast-glob';
3
4
  import { parse as parseToml } from 'smol-toml';
4
5
  import { environmentVariableIsPopulated, getCustomPath, invokeCommand } from '../tools.js';
6
+ import { filterManifestPathsByDiscoveryIgnore, resolveWorkspaceDiscoveryIgnore, toManifestGlobPatterns } from '../workspace.js';
5
7
  import Base_pyproject from './base_pyproject.js';
8
+ import { evaluateMarker } from './marker_evaluator.js';
6
9
  import { getParser, getPinnedVersionQuery } from './requirements_parser.js';
7
10
  export default class Python_uv extends Base_pyproject {
8
11
  /** @returns {string} */
@@ -18,12 +21,54 @@ export default class Python_uv extends Base_pyproject {
18
21
  * @param {string} workspaceDir - workspace root (for resolving editable install paths)
19
22
  * @param {object} parsed - parsed pyproject.toml
20
23
  * @param {Object} opts
21
- * @returns {Promise<{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}>}
24
+ * @returns {Promise<{directDeps: string[], graph: Map<string, import('./base_pyproject.js').GraphEntry>}>}
22
25
  */
23
26
  async _getDependencyData(manifestDir, workspaceDir, parsed, opts) {
24
27
  let projectName = this._getProjectName(parsed);
25
28
  let uvOutput = this._getUvExportOutput(manifestDir, opts);
26
- return this._parseUvExport(uvOutput, projectName, workspaceDir);
29
+ let { directDeps, graph } = await this._parseUvExport(uvOutput, projectName, workspaceDir);
30
+ await this._attachHashesFromLockFile(path.join(workspaceDir, 'uv.lock'), graph);
31
+ return { directDeps, graph };
32
+ }
33
+ /**
34
+ * Parse uv.lock and attach SHA-256 hashes to graph entries.
35
+ * @param {string} lockFilePath - path to uv.lock
36
+ * @param {Map<string, import('./base_pyproject.js').GraphEntry>} graph
37
+ */
38
+ async _attachHashesFromLockFile(lockFilePath, graph) {
39
+ let lockContent;
40
+ try {
41
+ lockContent = await fs.promises.readFile(lockFilePath, 'utf-8');
42
+ }
43
+ catch {
44
+ return;
45
+ }
46
+ let parsed;
47
+ try {
48
+ parsed = parseToml(lockContent);
49
+ }
50
+ catch {
51
+ return;
52
+ }
53
+ let packages = parsed.package;
54
+ if (!Array.isArray(packages)) {
55
+ return;
56
+ }
57
+ for (let pkg of packages) {
58
+ if (!pkg.name) {
59
+ continue;
60
+ }
61
+ let hashStr = pkg.sdist?.hash || pkg.wheels?.[0]?.hash;
62
+ if (!hashStr || !hashStr.startsWith('sha256:')) {
63
+ continue;
64
+ }
65
+ let key = this._canonicalize(pkg.name);
66
+ let entry = graph.get(key);
67
+ if (!entry || entry.hashes) {
68
+ continue;
69
+ }
70
+ entry.hashes = [{ alg: "SHA-256", content: hashStr.slice(7) }];
71
+ }
27
72
  }
28
73
  /**
29
74
  * Get the uv export output, either from env var or by running the command.
@@ -89,6 +134,16 @@ export default class Python_uv extends Base_pyproject {
89
134
  if (!nameNode) {
90
135
  continue;
91
136
  }
137
+ // Skip packages with non-matching PEP 508 markers, e.g. "pywin32==311 ; sys_platform == 'win32'"
138
+ let markerNode = child.children.find(c => c.type === 'marker_spec');
139
+ if (markerNode) {
140
+ let markerText = markerNode.text.replace(/^\s*;\s*/, '');
141
+ if (!evaluateMarker(markerText)) {
142
+ currentPkg = null;
143
+ collectingVia = false;
144
+ continue;
145
+ }
146
+ }
92
147
  let name = nameNode.text;
93
148
  let version = null;
94
149
  let versionMatches = pinnedVersionQuery.matches(child);
@@ -147,3 +202,68 @@ export default class Python_uv extends Base_pyproject {
147
202
  return { directDeps, graph };
148
203
  }
149
204
  }
205
+ const DEFAULT_UV_DISCOVERY_IGNORE = [
206
+ '**/__pycache__/**',
207
+ '**/.venv/**',
208
+ ];
209
+ /**
210
+ * Discover all pyproject.toml manifest paths in a uv workspace.
211
+ * Parses `[tool.uv.workspace]` from root pyproject.toml and glob-expands member patterns.
212
+ *
213
+ * @param {string} workspaceRoot - Absolute or relative path to workspace root (must contain pyproject.toml and uv.lock)
214
+ * @param {{ workspaceDiscoveryIgnore?: string[], TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE?: string, [key: string]: unknown }} [opts={}]
215
+ * @returns {Promise<string[]>} Paths to pyproject.toml files (absolute)
216
+ */
217
+ export async function discoverUvWorkspaceMembers(workspaceRoot, opts = {}) {
218
+ const root = path.resolve(workspaceRoot);
219
+ const rootPyproject = path.join(root, 'pyproject.toml');
220
+ const uvLock = path.join(root, 'uv.lock');
221
+ if (!fs.existsSync(rootPyproject) || !fs.existsSync(uvLock)) {
222
+ return [];
223
+ }
224
+ let parsed;
225
+ try {
226
+ parsed = parseToml(fs.readFileSync(rootPyproject, 'utf-8'));
227
+ }
228
+ catch {
229
+ return [];
230
+ }
231
+ const workspaceConfig = parsed?.tool?.uv?.workspace;
232
+ if (!workspaceConfig) {
233
+ return [];
234
+ }
235
+ const memberPatterns = workspaceConfig.members;
236
+ if (!Array.isArray(memberPatterns) || memberPatterns.length === 0) {
237
+ return [];
238
+ }
239
+ const excludePatterns = Array.isArray(workspaceConfig.exclude) ? workspaceConfig.exclude : [];
240
+ const excludeGlobs = excludePatterns
241
+ .filter(p => typeof p === 'string' && p.trim())
242
+ .map(p => `${p.trim()}/pyproject.toml`);
243
+ const ignorePatterns = [...resolveWorkspaceDiscoveryIgnore(opts), ...DEFAULT_UV_DISCOVERY_IGNORE];
244
+ const globOpts = {
245
+ cwd: root,
246
+ absolute: true,
247
+ onlyFiles: true,
248
+ ignore: [...ignorePatterns, ...excludeGlobs],
249
+ followSymbolicLinks: false,
250
+ };
251
+ const patterns = toManifestGlobPatterns(memberPatterns.filter(p => typeof p === 'string'), 'pyproject.toml');
252
+ const manifestPaths = await fg(patterns, globOpts);
253
+ if (!manifestPaths.includes(rootPyproject) && hasProjectMetadata(parsed)) {
254
+ manifestPaths.unshift(rootPyproject);
255
+ }
256
+ return filterManifestPathsByDiscoveryIgnore(manifestPaths, root, ignorePatterns);
257
+ }
258
+ /**
259
+ * @param {import('smol-toml').TomlTable} parsedPyProject
260
+ * @returns {boolean}
261
+ */
262
+ function hasProjectMetadata(parsedPyProject) {
263
+ try {
264
+ return typeof parsedPyProject?.project?.name === 'string' && parsedPyProject.project.name.trim() !== '';
265
+ }
266
+ catch {
267
+ return false;
268
+ }
269
+ }
@@ -4,9 +4,10 @@ declare namespace _default {
4
4
  export { provideComponent };
5
5
  export { provideStack };
6
6
  export { readLicenseFromManifest };
7
+ export function packageManagerName(): string;
7
8
  }
8
9
  export default _default;
9
- export type Provided = import("../provider").Provided;
10
+ export type Provided = any;
10
11
  /**
11
12
  * @param {string} manifestName - the subject manifest name-type
12
13
  * @returns {boolean} - return true if `Cargo.toml` is the manifest name-type
@@ -46,7 +47,10 @@ declare function provideStack(manifest: string, opts?: {}): Provided;
46
47
  * Read project license from Cargo.toml, with fallback to LICENSE file.
47
48
  * Supports the `license` field under `[package]` (single crate / workspace
48
49
  * with root) and under `[workspace.package]` (virtual workspaces).
50
+ * When a member crate uses `license = { workspace = true }`, the actual
51
+ * license is resolved from the workspace root Cargo.toml.
49
52
  * @param {string} manifestPath - path to Cargo.toml
53
+ * @param {object} [metadata] - cargo metadata output (needed for workspace license resolution)
50
54
  * @returns {string|null} SPDX identifier or null
51
55
  */
52
- declare function readLicenseFromManifest(manifestPath: string): string | null;
56
+ declare function readLicenseFromManifest(manifestPath: string, metadata?: object): string | null;