@oussema_mili/test-pkg-123 1.1.46 → 1.1.47

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.
@@ -173,27 +173,6 @@ class ContainerManager {
173
173
  const WS_PORT = options.wsPort || getCurrentWsPort();
174
174
  let APP_PORT = options.containerPort || getCurrentContainerPort();
175
175
 
176
- // If containerPort is 0, find an available port
177
- if (APP_PORT === 0) {
178
- try {
179
- APP_PORT = await findAvailableContainerPort(DEFAULT_CONTAINER_PORT, 100, [WS_PORT]);
180
- console.log(chalk.blue(`📍 Auto-assigned container port: ${APP_PORT}`));
181
- } catch (error) {
182
- throw new Error(`Failed to find available container port: ${error.message}`);
183
- }
184
- }
185
-
186
- // If the desired container port conflicts with the WebSocket port or is unavailable, pick another port
187
- if (APP_PORT === WS_PORT || !(await isPortAvailable(APP_PORT))) {
188
- try {
189
- const newPort = await findAvailableContainerPort(DEFAULT_CONTAINER_PORT, 100, [WS_PORT]);
190
- console.log(chalk.yellow(`⚠️ Port ${APP_PORT} is unavailable. Using ${newPort} instead.`));
191
- APP_PORT = newPort;
192
- } catch (err) {
193
- throw new Error(`Failed to resolve container port conflict: ${err.message}`);
194
- }
195
- }
196
-
197
176
  // Check Docker availability
198
177
  const dockerAvailable = await this.checkDockerAvailable();
199
178
  if (!dockerAvailable) {
@@ -217,6 +196,28 @@ class ContainerManager {
217
196
  console.log(chalk.green('✅ Using cached local image'));
218
197
  }
219
198
 
199
+ // Now resolve container port (after image is ready)
200
+ // If containerPort is 0, find an available port
201
+ if (APP_PORT === 0) {
202
+ try {
203
+ APP_PORT = await findAvailableContainerPort(DEFAULT_CONTAINER_PORT, 100, [WS_PORT]);
204
+ console.log(chalk.blue(`📍 Auto-assigned DevApp port: ${APP_PORT}`));
205
+ } catch (error) {
206
+ throw new Error(`Failed to find available DevApp port: ${error.message}`);
207
+ }
208
+ }
209
+
210
+ // If the desired container port conflicts with the WebSocket port or is unavailable, pick another port
211
+ if (APP_PORT === WS_PORT || !(await isPortAvailable(APP_PORT))) {
212
+ try {
213
+ const newPort = await findAvailableContainerPort(DEFAULT_CONTAINER_PORT, 100, [WS_PORT]);
214
+ console.log(chalk.blue(`Port ${APP_PORT} is in use, using port ${newPort} for DevApp`));
215
+ APP_PORT = newPort;
216
+ } catch (err) {
217
+ throw new Error(`Failed to resolve DevApp port conflict: ${err.message}`);
218
+ }
219
+ }
220
+
220
221
  // Determine WebSocket URL based on platform
221
222
  let wsUrl = `ws://host.docker.internal:${WS_PORT}`;
222
223
  if (os.platform() === 'linux') {
@@ -301,9 +301,9 @@ export async function runAgent(options = {}) {
301
301
  const startPort = preferredPort === 0 ? DEFAULT_WS_PORT : preferredPort;
302
302
  actualPort = await findAvailablePort(startPort);
303
303
  if (actualPort !== preferredPort && preferredPort !== 0) {
304
- log(`Port ${preferredPort} is in use, using port ${actualPort}`, 'warn');
304
+ log(`Port ${preferredPort} is in use, using port ${actualPort} for agent WebSocket`, 'warn');
305
305
  } else if (preferredPort === 0) {
306
- log(`Auto-assigned WebSocket port: ${actualPort}`);
306
+ log(`Auto-assigned agent WebSocket port: ${actualPort}`);
307
307
  }
308
308
  } catch (error) {
309
309
  releaseLock();
@@ -428,12 +428,14 @@ export async function runAgent(options = {}) {
428
428
  };
429
429
 
430
430
  // Now that WebSocket is bound, start container (so it cannot take the WS port)
431
+ log('Starting container (after WebSocket bind)...');
431
432
  let actualContainerPort = preferredContainerPort;
432
433
  try {
433
434
  actualContainerPort = await containerManager.startContainer({
434
435
  wsPort: actualPort,
435
436
  containerPort: preferredContainerPort,
436
437
  });
438
+ log(`Container started successfully on port ${actualContainerPort}`);
437
439
  } catch (containerError) {
438
440
  log(`Failed to start container: ${containerError.message}`, 'warn');
439
441
  log('Continuing without container...');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oussema_mili/test-pkg-123",
3
- "version": "1.1.46",
3
+ "version": "1.1.47",
4
4
  "description": "Fenwave Docker Agent and CLI",
5
5
  "keywords": [
6
6
  "fenwave",