opencode-azure-setup 1.0.8 → 1.0.9

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 (2) hide show
  1. package/index.js +59 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -447,6 +447,65 @@ async function main() {
447
447
  console.log(colors.green + '✓ Configuration saved!' + colors.reset);
448
448
  console.log(colors.dim + ` ${configPath}` + colors.reset);
449
449
 
450
+ // Install opencode binary
451
+ console.log();
452
+ console.log(colors.blue + 'Installing opencode binary...' + colors.reset);
453
+
454
+ try {
455
+ const platform = process.platform === 'win32' ? 'windows' : process.platform;
456
+ const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
457
+ const binaryName = `opencode-${platform}-${arch}`;
458
+
459
+ // Get latest release from GitHub
460
+ const releaseUrl = 'https://api.github.com/repos/schwarztim/opencode/releases/latest';
461
+ const releaseRes = await fetch(releaseUrl, {
462
+ headers: { 'User-Agent': 'opencode-azure-setup' },
463
+ signal: AbortSignal.timeout(10000),
464
+ });
465
+
466
+ if (!releaseRes.ok) throw new Error(`Failed to fetch release: ${releaseRes.status}`);
467
+ const release = await releaseRes.json();
468
+
469
+ // Find the matching asset (handles -bin suffix for non-windows)
470
+ const asset = release.assets.find(a =>
471
+ a.name === binaryName ||
472
+ a.name === `${binaryName}.exe` ||
473
+ a.name === `${binaryName}-bin`
474
+ );
475
+ if (!asset) throw new Error(`No binary found for ${binaryName}`);
476
+
477
+ console.log(colors.dim + ` Downloading ${asset.name} (${(asset.size / 1024 / 1024).toFixed(1)} MB)...` + colors.reset);
478
+
479
+ // Download binary
480
+ const binRes = await fetch(asset.browser_download_url, {
481
+ headers: { 'User-Agent': 'opencode-azure-setup' },
482
+ signal: AbortSignal.timeout(120000),
483
+ });
484
+
485
+ if (!binRes.ok) throw new Error(`Failed to download: ${binRes.status}`);
486
+ const binData = await binRes.arrayBuffer();
487
+
488
+ // Install to ~/.local/bin
489
+ const binDir = path.join(os.homedir(), '.local', 'bin');
490
+ fs.mkdirSync(binDir, { recursive: true });
491
+
492
+ const binPath = path.join(binDir, platform === 'windows' ? 'opencode.exe' : 'opencode');
493
+ fs.writeFileSync(binPath, Buffer.from(binData));
494
+ fs.chmodSync(binPath, 0o755);
495
+
496
+ console.log(colors.green + '✓ opencode installed!' + colors.reset);
497
+ console.log(colors.dim + ` ${binPath}` + colors.reset);
498
+
499
+ // Check if ~/.local/bin is in PATH
500
+ const pathDirs = (process.env.PATH || '').split(path.delimiter);
501
+ if (!pathDirs.includes(binDir)) {
502
+ console.log(colors.yellow + ` Add to PATH: export PATH="$HOME/.local/bin:$PATH"` + colors.reset);
503
+ }
504
+ } catch (e) {
505
+ console.log(colors.yellow + '⚠ Binary install skipped: ' + e.message + colors.reset);
506
+ console.log(colors.dim + ' You can install manually from: https://github.com/schwarztim/opencode/releases' + colors.reset);
507
+ }
508
+
450
509
  // Show what was preserved
451
510
  if (existingConfig) {
452
511
  const preserved = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-azure-setup",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Easy Azure OpenAI setup for OpenCode",
5
5
  "type": "module",
6
6
  "main": "index.js",