|
| 1 | +#!npx tsx |
| 2 | + |
1 | 3 | /** |
2 | 4 | * Copyright 2026 Arm Limited |
3 | 5 | * |
|
19 | 21 | /* |
20 | 22 | * Script to extract version info from manifest_*.yml files in ./tools/cmsis-toolbox |
21 | 23 | * 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> |
23 | 25 | */ |
24 | 26 | import fs from 'fs'; |
25 | 27 | import path from 'path'; |
@@ -49,9 +51,21 @@ const TOOLBOX_CHILDREN = [ |
49 | 51 | ]; |
50 | 52 |
|
51 | 53 | 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 | + } |
55 | 69 | } |
56 | 70 |
|
57 | 71 | function parseManifest(file: string): Record<string, string> { |
@@ -101,15 +115,16 @@ function mergeVersions(manifests: Record<string, string>[]): Record<string, stri |
101 | 115 | function printDependencyGraph(versions: Record<string, string>, uv2csolutionVersion: string | undefined, nightlyVersion: string) { |
102 | 116 | console.log('```text'); |
103 | 117 | 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'}`); |
105 | 120 | for (let i = 0; i < TOOLBOX_CHILDREN.length; ++i) { |
106 | 121 | const tool = TOOLBOX_CHILDREN[i]; |
107 | 122 | const ver = versions[tool] ?? 'unknown'; |
108 | 123 | const isLast = i === TOOLBOX_CHILDREN.length - 1; |
109 | | - const prefix = isLast ? ' │ └──' : ' │ ├──'; |
| 124 | + const prefix = isLast ? ' │ └──' : ' │ ├──'; |
110 | 125 | console.log(`${prefix} ${tool} v${ver}`); |
111 | 126 | } |
112 | | - console.log(` └─── uv2csolution v${uv2csolutionVersion ?? 'unknown'}`); |
| 127 | + console.log(` └── uv2csolution v${uv2csolutionVersion ?? 'unknown'}`); |
113 | 128 | console.log('```'); |
114 | 129 | } |
115 | 130 |
|
|
0 commit comments