@oussema_mili/test-pkg-123 1.1.47 → 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.
@@ -184,16 +184,55 @@ class ContainerManager {
184
184
  // Stop existing container if running
185
185
  await this.stopContainer();
186
186
 
187
- // Pull image from GHCR (public registry, no auth required)
188
- try {
189
- await this.pullImage();
190
- } catch (pullError) {
191
- console.log(chalk.yellow('⚠️ Image pull failed, checking for local image...'));
192
- const imageExists = await this.imageExistsLocally();
193
- if (!imageExists) {
194
- throw new Error('No local image available and pull failed. Please check your network connection.');
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'));
195
235
  }
196
- console.log(chalk.green('✅ Using cached local image'));
197
236
  }
198
237
 
199
238
  // Now resolve container port (after image is ready)
@@ -428,14 +428,12 @@ 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)...');
432
431
  let actualContainerPort = preferredContainerPort;
433
432
  try {
434
433
  actualContainerPort = await containerManager.startContainer({
435
434
  wsPort: actualPort,
436
435
  containerPort: preferredContainerPort,
437
436
  });
438
- log(`Container started successfully on port ${actualContainerPort}`);
439
437
  } catch (containerError) {
440
438
  log(`Failed to start container: ${containerError.message}`, 'warn');
441
439
  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.47",
3
+ "version": "1.1.48",
4
4
  "description": "Fenwave Docker Agent and CLI",
5
5
  "keywords": [
6
6
  "fenwave",