cloud-pc-templates 1.1.1 → 1.1.2

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.
@@ -97,30 +97,46 @@ async function downloadAndRunProxy(endpoint) {
97
97
  // Get API key from user
98
98
  const apiKey = await promptForApiKey();
99
99
 
100
- // Run the proxy with API key passed as environment variable
100
+ // Run the proxy with API key passed as command-line argument
101
101
  return new Promise((resolve, reject) => {
102
- const env = Object.assign({}, process.env, { API_KEY: apiKey });
103
- const child = spawn('node', [tempFile], { env });
102
+ const child = spawn('node', [tempFile, apiKey]);
104
103
 
105
- child.on('close', (code) => {
106
- if (code === 0) {
107
- // Wait a bit for the server to start, then validate
108
- setTimeout(async () => {
109
- const isHealthy = await checkHealthEndpoint(endpoint);
110
- if (isHealthy) {
111
- console.log('✓ Logged in');
112
- console.log(` - Endpoint checked: ${endpoint}`);
113
- } else {
114
- console.log('✓ Proxy started');
115
- console.log(` - Endpoint: ${endpoint}`);
116
- }
117
- resolve();
118
- }, 1000);
119
- } else {
120
- reject(new Error('Proxy process failed'));
104
+ let serverReady = false;
105
+
106
+ // Capture stdout to detect when server is ready
107
+ child.stdout.on('data', (data) => {
108
+ const output = data.toString();
109
+ console.log(output);
110
+
111
+ // Check if server indicates it's ready
112
+ if (output.includes('listening') || output.includes('started') || output.includes('running')) {
113
+ serverReady = true;
121
114
  }
122
115
  });
123
116
 
117
+ // Capture stderr for error messages
118
+ child.stderr.on('data', (data) => {
119
+ console.error(data.toString());
120
+ });
121
+
122
+ // Wait a bit for server to start, then validate
123
+ setTimeout(async () => {
124
+ try {
125
+ const isHealthy = await checkHealthEndpoint(endpoint);
126
+ if (isHealthy) {
127
+ console.log('✓ Logged in');
128
+ console.log(` - Endpoint checked: ${endpoint}`);
129
+ resolve();
130
+ } else {
131
+ console.log('✓ Proxy started');
132
+ console.log(` - Endpoint: ${endpoint}`);
133
+ resolve();
134
+ }
135
+ } catch (error) {
136
+ reject(error);
137
+ }
138
+ }, 2000);
139
+
124
140
  child.on('error', reject);
125
141
  });
126
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloud-pc-templates",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {