{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/assets/postinstall.cts"],"sourcesContent":["/**\n * Postinstall script for node-version-use\n *\n * Downloads the platform-specific binary and installs it to ~/.nvu/bin/\n * This enables transparent Node version switching.\n *\n * Uses safe atomic download pattern:\n * 1. Download to temp file\n * 2. Extract to temp directory\n * 3. Atomic rename to final location\n */\n\nconst exit = require('exit-compat');\nconst path = require('path');\nconst os = require('os');\nconst { installBinaries, printInstructions, syncAllShims } = require('./installBinaries.cjs');\n\nconst hasHomedir = typeof os.homedir === 'function';\nfunction homedir(): string {\n  if (hasHomedir) return os.homedir();\n  const home = require('homedir-polyfill');\n  return home();\n}\n\n// Allow NVU_HOME override for testing\nconst storagePath = process.env.NVU_HOME || path.join(homedir(), '.nvu');\n\n/**\n * Main installation function\n */\nfunction main(): void {\n  installBinaries({}, (err: Error | null, installed: boolean) => {\n    if (err) {\n      console.log(`postinstall warning: Failed to install binary: ${err.message || err}`);\n      console.log('You can still use nvu with explicit versions: nvu 18 npm test');\n      return exit(1);\n    }\n\n    if (installed) {\n      // Sync all shims to the new binary version\n      const binDir = path.join(storagePath, 'bin');\n      syncAllShims(binDir);\n\n      printInstructions();\n      console.log('postinstall: Binary installed successfully!');\n    } else {\n      console.log('postinstall: Binaries already up to date.');\n    }\n    exit(0);\n  });\n}\n\nmain();\n"],"names":["exit","require","path","os","installBinaries","printInstructions","syncAllShims","hasHomedir","homedir","home","storagePath","process","env","NVU_HOME","join","main","err","installed","console","log","message","binDir"],"mappings":";AAAA;;;;;;;;;;CAUC,GAED,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,OAAOD,QAAQ;AACrB,IAAME,KAAKF,QAAQ;AACnB,IAA6DA,WAAAA,QAAQ,0BAA7DG,kBAAqDH,SAArDG,iBAAiBC,oBAAoCJ,SAApCI,mBAAmBC,eAAiBL,SAAjBK;AAE5C,IAAMC,aAAa,OAAOJ,GAAGK,OAAO,KAAK;AACzC,SAASA;IACP,IAAID,YAAY,OAAOJ,GAAGK,OAAO;IACjC,IAAMC,OAAOR,QAAQ;IACrB,OAAOQ;AACT;AAEA,sCAAsC;AACtC,IAAMC,cAAcC,QAAQC,GAAG,CAACC,QAAQ,IAAIX,KAAKY,IAAI,CAACN,WAAW;AAEjE;;CAEC,GACD,SAASO;IACPX,gBAAgB,CAAC,GAAG,SAACY,KAAmBC;QACtC,IAAID,KAAK;YACPE,QAAQC,GAAG,CAAC,AAAC,kDAAoE,OAAnBH,IAAII,OAAO,IAAIJ;YAC7EE,QAAQC,GAAG,CAAC;YACZ,OAAOnB,KAAK;QACd;QAEA,IAAIiB,WAAW;YACb,2CAA2C;YAC3C,IAAMI,SAASnB,KAAKY,IAAI,CAACJ,aAAa;YACtCJ,aAAae;YAEbhB;YACAa,QAAQC,GAAG,CAAC;QACd,OAAO;YACLD,QAAQC,GAAG,CAAC;QACd;QACAnB,KAAK;IACP;AACF;AAEAe"}