Skip to content

Commit fae5dc0

Browse files
committed
Addressed review findings
1 parent e08d57e commit fae5dc0

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

scripts/get-package-deps.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!npx tsx
2+
13
/**
24
* Copyright 2026 Arm Limited
35
*
@@ -19,7 +21,7 @@
1921
/*
2022
* Script to extract version info from manifest_*.yml files in ./tools/cmsis-toolbox
2123
* and print a dependency graph in the format used in the GitHub Actions summary.
22-
* Usage: npx tsx scripts/print-toolbox-deps.ts <nightlyVersion>
24+
* Usage: npx tsx scripts/get-package-deps.ts <nightlyVersion>
2325
*/
2426
import fs from 'fs';
2527
import path from 'path';
@@ -49,9 +51,21 @@ const TOOLBOX_CHILDREN = [
4951
];
5052

5153
function findManifestFiles(dir: string): string[] {
52-
return fs.readdirSync(dir)
53-
.filter(f => MANIFEST_PATTERN.test(f))
54-
.map(f => path.join(dir, f));
54+
if (!fs.existsSync(dir)) {
55+
console.error(`Toolbox directory not found: ${dir}`);
56+
process.exit(1);
57+
}
58+
59+
try {
60+
return fs.readdirSync(dir)
61+
.filter(f => MANIFEST_PATTERN.test(f))
62+
.map(f => path.join(dir, f));
63+
}
64+
catch (error) {
65+
const message = error instanceof Error ? error.message : String(error);
66+
console.error(`Failed to read toolbox directory "${dir}": ${message}`);
67+
process.exit(1);
68+
}
5569
}
5670

5771
function parseManifest(file: string): Record<string, string> {
@@ -101,15 +115,16 @@ function mergeVersions(manifests: Record<string, string>[]): Record<string, stri
101115
function printDependencyGraph(versions: Record<string, string>, uv2csolutionVersion: string | undefined, nightlyVersion: string) {
102116
console.log('```text');
103117
console.log(`vscode-cmsis-solution ${nightlyVersion}`);
104-
console.log(` └── cmsis-toolbox v${versions['cmsis-toolbox'] ?? 'unknown'}`);
118+
119+
console.log(` ├── cmsis-toolbox v${versions['cmsis-toolbox'] ?? 'unknown'}`);
105120
for (let i = 0; i < TOOLBOX_CHILDREN.length; ++i) {
106121
const tool = TOOLBOX_CHILDREN[i];
107122
const ver = versions[tool] ?? 'unknown';
108123
const isLast = i === TOOLBOX_CHILDREN.length - 1;
109-
const prefix = isLast ? ' │ └──' : ' │ ├──';
124+
const prefix = isLast ? ' │ └──' : ' │ ├──';
110125
console.log(`${prefix} ${tool} v${ver}`);
111126
}
112-
console.log(` └── uv2csolution v${uv2csolutionVersion ?? 'unknown'}`);
127+
console.log(` └── uv2csolution v${uv2csolutionVersion ?? 'unknown'}`);
113128
console.log('```');
114129
}
115130

0 commit comments

Comments
 (0)