| 91 | |
| 92 | // Update dependencies in a package.json file |
| 93 | function updateDependencies( |
| 94 | deps: Record<string, string> | undefined, |
| 95 | versions: Map<string, string>, |
| 96 | ): { updated: boolean; deps: Record<string, string> | undefined } { |
| 97 | if (!deps) return { updated: false, deps } |
| 98 | |
| 99 | let updated = false |
| 100 | const newDeps = { ...deps } |
| 101 | |
| 102 | for (const [name, currentVersion] of Object.entries(deps)) { |
| 103 | if (name.startsWith(`@tanstack/`) && versions.has(name)) { |
| 104 | const newVersion = `^${versions.get(name)}` |
| 105 | if (currentVersion !== newVersion) { |
| 106 | newDeps[name] = newVersion |
| 107 | updated = true |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return { updated, deps: newDeps } |
| 113 | } |
| 114 | |
| 115 | function main() { |
| 116 | console.log(`\n📦 Updating example dependencies...\n`) |