@oussema_mili/test-pkg-123 1.1.46 → 1.1.48

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,13 +173,76 @@ class ContainerManager {
173
173
  const WS_PORT = options.wsPort || getCurrentWsPort();
174
174
  let APP_PORT = options.containerPort || getCurrentContainerPort();
175
175
 
176
+ // Check Docker availability
177
+ const dockerAvailable = await this.checkDockerAvailable();
178
+ if (!dockerAvailable) {
179
+ throw new Error(
180
+ 'Docker is not available. Please install Docker and try again.'
181
+ );
182
+ }
183
+
184
+ // Stop existing container if running
185
+ await this.stopContainer();
186
+
187
+ // Check if image exists locally and handle pull accordingly
188
+ const imageExists = await this.imageExistsLocally();
189
+
190
+ if (!imageExists) {
191
+ // Image doesn't exist, pull it
192
+ try {
193
+ await this.pullImage();
194
+ } catch (pullError) {
195
+ throw new Error('Failed to pull image. Please check your network connection.');
196
+ }
197
+ } else {
198
+ // Image exists, check for updates silently
199
+ console.log(chalk.blue('📦 Checking for image updates...'));
200
+ try {
201
+ const pullProcess = spawn('docker', ['pull', DOCKER_IMAGE], {
202
+ stdio: 'pipe',
203
+ });
204
+
205
+ let hasUpdates = false;
206
+ let errorOutput = '';
207
+
208
+ pullProcess.stdout.on('data', (data) => {
209
+ const output = data.toString();
210
+ if (output.includes('Downloaded') || output.includes('Downloading')) {
211
+ hasUpdates = true;
212
+ }
213
+ });
214
+
215
+ pullProcess.stderr.on('data', (data) => {
216
+ errorOutput += data.toString();
217
+ });
218
+
219
+ await new Promise((resolve, reject) => {
220
+ pullProcess.on('close', (code) => {
221
+ if (code === 0) {
222
+ if (hasUpdates) {
223
+ console.log(chalk.green('✅ Image updated successfully'));
224
+ } else {
225
+ console.log(chalk.green('✅ Image is up to date'));
226
+ }
227
+ resolve();
228
+ } else {
229
+ reject(new Error(`Update check failed with code ${code}`));
230
+ }
231
+ });
232
+ });
233
+ } catch (updateError) {
234
+ console.log(chalk.yellow('⚠️ Update check failed, using cached local image'));
235
+ }
236
+ }
237
+
238
+ // Now resolve container port (after image is ready)
176
239
  // If containerPort is 0, find an available port
177
240
  if (APP_PORT === 0) {
178
241
  try {
179
242
  APP_PORT = await findAvailableContainerPort(DEFAULT_CONTAINER_PORT, 100, [WS_PORT]);
180
- console.log(chalk.blue(`📍 Auto-assigned container port: ${APP_PORT}`));
243
+ console.log(chalk.blue(`📍 Auto-assigned DevApp port: ${APP_PORT}`));
181
244
  } catch (error) {
182
- throw new Error(`Failed to find available container port: ${error.message}`);
245
+ throw new Error(`Failed to find available DevApp port: ${error.message}`);
183
246
  }
184
247
  }
185
248
 
@@ -187,34 +250,11 @@ class ContainerManager {
187
250
  if (APP_PORT === WS_PORT || !(await isPortAvailable(APP_PORT))) {
188
251
  try {
189
252
  const newPort = await findAvailableContainerPort(DEFAULT_CONTAINER_PORT, 100, [WS_PORT]);
190
- console.log(chalk.yellow(`⚠️ Port ${APP_PORT} is unavailable. Using ${newPort} instead.`));
253
+ console.log(chalk.blue(`Port ${APP_PORT} is in use, using port ${newPort} for DevApp`));
191
254
  APP_PORT = newPort;
192
255
  } catch (err) {
193
- throw new Error(`Failed to resolve container port conflict: ${err.message}`);
194
- }
195
- }
196
-
197
- // Check Docker availability
198
- const dockerAvailable = await this.checkDockerAvailable();
199
- if (!dockerAvailable) {
200
- throw new Error(
201
- 'Docker is not available. Please install Docker and try again.'
202
- );
203
- }
204
-
205
- // Stop existing container if running
206
- await this.stopContainer();
207
-
208
- // Pull image from GHCR (public registry, no auth required)
209
- try {
210
- await this.pullImage();
211
- } catch (pullError) {
212
- console.log(chalk.yellow('⚠️ Image pull failed, checking for local image...'));
213
- const imageExists = await this.imageExistsLocally();
214
- if (!imageExists) {
215
- throw new Error('No local image available and pull failed. Please check your network connection.');
256
+ throw new Error(`Failed to resolve DevApp port conflict: ${err.message}`);
216
257
  }
217
- console.log(chalk.green('✅ Using cached local image'));
218
258
  }
219
259
 
220
260
  // Determine WebSocket URL based on platform
@@ -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.46",
3
+ "version": "1.1.48",
4
4
  "description": "Fenwave Docker Agent and CLI",
5
5
  "keywords": [
6
6
  "fenwave",