scripts-orchestrator 1.2.2 → 1.2.3

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.
@@ -120,6 +120,8 @@ export class Orchestrator {
120
120
  // Execute the main command with retries
121
121
  let result = false;
122
122
  let commandOutput = '';
123
+ let commandFailed = false;
124
+
123
125
  for (let attempt = 1; attempt <= attempts; attempt++) {
124
126
  if (attempt > 1) {
125
127
  this.logger.warn(`Retrying ${command} (attempt ${attempt}/${attempts})`);
@@ -136,22 +138,29 @@ export class Orchestrator {
136
138
  result = success;
137
139
 
138
140
  if (result) {
141
+ // Remove from failed commands if it was there
139
142
  this.failedCommands = this.failedCommands.filter(cmd => cmd !== command);
143
+ commandFailed = false;
140
144
  break;
141
145
  } else if (attempt < attempts) {
142
146
  if (should_retry && !should_retry(commandOutput)) {
143
147
  this.logger.warn(
144
148
  `${command} failed but doesn't meet retry criteria. Skipping retry.`,
145
149
  );
146
- this.failedCommands.push(command);
150
+ commandFailed = true;
147
151
  break;
148
152
  }
149
153
  this.logger.error(`Attempt ${attempt}/${attempts} failed for ${command}`);
154
+ commandFailed = true;
150
155
  } else {
151
- this.failedCommands.push(command);
156
+ commandFailed = true;
152
157
  }
153
158
  }
154
159
 
160
+ if (commandFailed) {
161
+ this.failedCommands.push(command);
162
+ }
163
+
155
164
  this.commandTimings.set(command, Date.now() - startTime);
156
165
  visited.delete(command);
157
166
  return result;
@@ -159,20 +168,24 @@ export class Orchestrator {
159
168
 
160
169
  summarizeResults() {
161
170
  this.logger.info('\nCommand Summary:');
171
+ let hasFailures = false;
172
+
162
173
  this.config.forEach(({ command }) => {
163
174
  const duration = this.commandTimings.get(command);
164
175
  const durationStr = duration ? ` (${this.formatDuration(duration)})` : '';
165
176
 
166
177
  if (this.failedCommands.includes(command)) {
178
+ hasFailures = true;
167
179
  this.logger.error(`- ${command}: ❌${durationStr} (See logs/scripts-orchestrator_${command}.log)`);
168
180
  } else if (this.skippedCommands.includes(command)) {
181
+ hasFailures = true;
169
182
  this.logger.warn(`- ${command}: ⚠️${durationStr} (Skipped due to failed dependency)`);
170
183
  } else {
171
184
  this.logger.success(`- ${command}: ✅${durationStr}`);
172
185
  }
173
186
  });
174
187
 
175
- if (this.failedCommands.length > 0 || this.skippedCommands.length > 0) {
188
+ if (hasFailures) {
176
189
  this.logger.error('\n❌ Some commands failed or were skipped. See details above.');
177
190
  } else {
178
191
  this.logger.success('\n🎉 All commands executed successfully!');
@@ -187,21 +200,28 @@ export class Orchestrator {
187
200
  );
188
201
 
189
202
  // Wait for all top-level commands to complete
190
- await Promise.all(tasks);
203
+ const results = await Promise.all(tasks);
204
+
205
+ // Check if any command failed
206
+ const hasFailures = results.some(result => !result) ||
207
+ this.failedCommands.length > 0 ||
208
+ this.skippedCommands.length > 0;
191
209
 
192
210
  // Add a small delay to ensure all processes have finished
193
211
  await new Promise((resolve) => setTimeout(resolve, 1000));
194
212
 
195
213
  this.summarizeResults();
214
+
215
+ // Exit with appropriate status
216
+ if (hasFailures) {
217
+ process.exit(1);
218
+ }
196
219
  } finally {
197
220
  try {
198
221
  await this.processManager.cleanup();
199
222
  } catch (error) {
200
223
  this.logger.error(`Cleanup failed: ${error.message}`);
201
224
  }
202
- if (this.failedCommands.length > 0 || this.skippedCommands.length > 0) {
203
- process.exit(1);
204
- }
205
225
  }
206
226
  }
207
227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripts-orchestrator",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "A powerful script orchestrator for running parallel commands with dependency management, background processes, and health checks",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",