@oussema_mili/test-pkg-123 1.1.45 → 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.
package/cli-commands.js CHANGED
@@ -493,7 +493,7 @@ function setupCLICommands(program, startServerFunction) {
493
493
  } else {
494
494
  console.log(chalk.yellow("Status: Not Running"));
495
495
  console.log(chalk.gray("\nTo start the agent, run:"));
496
- console.log(chalk.cyan(" fenwave service start"));
496
+ console.log(chalk.cyan(" fenwave service start or fenwave service run"));
497
497
  }
498
498
 
499
499
  console.log("");
@@ -768,7 +768,7 @@ function setupCLICommands(program, startServerFunction) {
768
768
  } else {
769
769
  console.log(chalk.yellow("Agent: Not Running"));
770
770
  console.log(
771
- chalk.gray(' Run "fenwave service start" to start the agent'),
771
+ chalk.gray(' Run "fenwave service start" or "fenwave service run" to start the agent'),
772
772
  );
773
773
  }
774
774
 
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oussema_mili/test-pkg-123",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "description": "Fenwave Docker Agent and CLI",
5
5
  "keywords": [
6
6
  "fenwave",