vibesdev 1.0.2 → 1.0.3

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.
package/bin/vibesdev.js CHANGED
@@ -2,6 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  const fs = require('fs');
5
+ const os = require('os');
5
6
  const path = require('path');
6
7
  const { spawnSync } = require('child_process');
7
8
 
@@ -16,10 +17,44 @@ const binPath = path.join(packageDir, 'bin', 'vibes');
16
17
  const exePath = path.join(packageDir, 'bin', 'vibes.exe');
17
18
  const args = process.argv.slice(2);
18
19
 
20
+ function readCommandOutput(command, commandArgs) {
21
+ const result = spawnSync(command, commandArgs, {
22
+ encoding: 'utf8',
23
+ stdio: ['ignore', 'pipe', 'ignore'],
24
+ windowsHide: true
25
+ });
26
+ if (result.error || result.status !== 0) return undefined;
27
+ const value = result.stdout.trim();
28
+ return value.length > 0 ? value : undefined;
29
+ }
30
+
31
+ function getPersistentBinDir() {
32
+ if (process.env.VIBES_INSTALL_DIR) return process.env.VIBES_INSTALL_DIR;
33
+
34
+ const bunGlobalBin = readCommandOutput('bun', ['pm', 'bin', '-g']);
35
+ if (bunGlobalBin) return bunGlobalBin;
36
+
37
+ if (process.env.BUN_INSTALL) return path.join(process.env.BUN_INSTALL, 'bin');
38
+
39
+ if (process.platform === 'win32') {
40
+ const base = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
41
+ return path.join(base, 'Programs', 'vibes', 'bin');
42
+ }
43
+
44
+ if (process.env.XDG_BIN_HOME) return process.env.XDG_BIN_HOME;
45
+
46
+ return path.join(os.homedir(), '.local', 'bin');
47
+ }
48
+
49
+ function getPersistentBinaryPath() {
50
+ return path.join(getPersistentBinDir(), process.platform === 'win32' ? 'vibes.exe' : 'vibes');
51
+ }
52
+
19
53
  function runInstaller() {
20
54
  const result = spawnSync(process.execPath, [installerPath], {
21
55
  stdio: 'inherit',
22
- windowsHide: false
56
+ windowsHide: false,
57
+ env: { ...process.env, VIBES_INSTALL_PERSISTENT: '1' }
23
58
  });
24
59
  if (result.error) {
25
60
  fail(`Failed to run vibes installer: ${result.error.message}`);
@@ -33,7 +68,10 @@ let command = binPath;
33
68
  let commandArgs = args;
34
69
 
35
70
  if (process.platform === 'win32') {
36
- if (fs.existsSync(exePath)) {
71
+ const persistentPath = getPersistentBinaryPath();
72
+ if (fs.existsSync(persistentPath)) {
73
+ command = persistentPath;
74
+ } else if (fs.existsSync(exePath)) {
37
75
  command = exePath;
38
76
  } else {
39
77
  command = process.execPath;
@@ -42,10 +80,20 @@ if (process.platform === 'win32') {
42
80
  }
43
81
 
44
82
  if (!fs.existsSync(binPath) && !fs.existsSync(exePath)) {
83
+ const persistentPath = getPersistentBinaryPath();
84
+ if (fs.existsSync(persistentPath)) {
85
+ command = persistentPath;
86
+ commandArgs = args;
87
+ }
88
+ }
89
+
90
+ if (!fs.existsSync(binPath) && !fs.existsSync(exePath) && !fs.existsSync(command)) {
45
91
  runInstaller();
92
+ command = getPersistentBinaryPath();
93
+ commandArgs = args;
46
94
  }
47
95
 
48
- if (!fs.existsSync(binPath) && !fs.existsSync(exePath)) {
96
+ if (!fs.existsSync(binPath) && !fs.existsSync(exePath) && !fs.existsSync(command)) {
49
97
  fail([
50
98
  'Error: vibes binary is not installed.',
51
99
  '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibesdev",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Short npm alias for the Vibes CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -3,6 +3,7 @@
3
3
  const https = require('https');
4
4
  const http = require('http');
5
5
  const crypto = require('crypto');
6
+ const { spawnSync } = require('child_process');
6
7
  const fs = require('fs');
7
8
  const path = require('path');
8
9
  const os = require('os');
@@ -33,11 +34,56 @@ function getBinaryName() {
33
34
 
34
35
  function getOutputPath() {
35
36
  const platform = getPlatform();
37
+ if (process.env.VIBES_INSTALL_PERSISTENT === '1') {
38
+ const dir = getPersistentBinDir();
39
+ const outputName = platform === 'win32' ? 'vibes.exe' : 'vibes';
40
+ return path.join(dir, outputName);
41
+ }
36
42
  const dir = path.join(__dirname, '..', 'bin');
37
43
  const outputName = platform === 'win32' ? 'vibes.exe' : 'vibes';
38
44
  return path.join(dir, outputName);
39
45
  }
40
46
 
47
+ function getPersistentBinDir() {
48
+ if (process.env.VIBES_INSTALL_DIR) return process.env.VIBES_INSTALL_DIR;
49
+
50
+ const bunGlobalBin = readCommandOutput('bun', ['pm', 'bin', '-g']);
51
+ if (bunGlobalBin) return bunGlobalBin;
52
+
53
+ if (process.env.BUN_INSTALL) return path.join(process.env.BUN_INSTALL, 'bin');
54
+
55
+ if (process.platform === 'win32') {
56
+ const base = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
57
+ return path.join(base, 'Programs', 'vibes', 'bin');
58
+ }
59
+
60
+ if (process.env.XDG_BIN_HOME) return process.env.XDG_BIN_HOME;
61
+
62
+ // POSIX fallback used by Linux distributions and many shell setups. If it is
63
+ // not on PATH, the installer prints a warning with the exact directory.
64
+ return path.join(os.homedir(), '.local', 'bin');
65
+ }
66
+
67
+ function readCommandOutput(command, args) {
68
+ const result = spawnSync(command, args, {
69
+ encoding: 'utf8',
70
+ stdio: ['ignore', 'pipe', 'ignore'],
71
+ windowsHide: true
72
+ });
73
+ if (result.error || result.status !== 0) return undefined;
74
+ const value = result.stdout.trim();
75
+ return value.length > 0 ? value : undefined;
76
+ }
77
+
78
+ function pathHasDir(dir) {
79
+ const pathValue = process.env.PATH || '';
80
+ const resolvedDir = path.resolve(dir);
81
+ return pathValue
82
+ .split(path.delimiter)
83
+ .filter(Boolean)
84
+ .some((entry) => path.resolve(entry) === resolvedDir);
85
+ }
86
+
41
87
  function showProgress(total, current) {
42
88
  if (total > 0) {
43
89
  const percent = Math.round((current / total) * 100);
@@ -244,6 +290,10 @@ async function main() {
244
290
  .then(() => {
245
291
  makeExecutable(outputPath);
246
292
  console.log(`Installed to ${outputPath}`);
293
+ const outputDir = path.dirname(outputPath);
294
+ if (process.env.VIBES_INSTALL_PERSISTENT === '1' && !pathHasDir(outputDir)) {
295
+ console.warn(`Warning: ${outputDir} is not on PATH. Add it to run \`vibes\` directly.`);
296
+ }
247
297
  resolve();
248
298
  })
249
299
  .catch(reject);