scripts-orchestrator 2.5.0 → 2.6.0

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/index.js CHANGED
@@ -14,6 +14,7 @@ import { log } from './lib/logger.js';
14
14
  const args = process.argv.slice(2);
15
15
  let configPath = './scripts-orchestrator.config.js';
16
16
  let startPhase = null;
17
+ let logFolder = null;
17
18
 
18
19
  // Parse arguments
19
20
  for (let i = 0; i < args.length; i++) {
@@ -22,6 +23,9 @@ for (let i = 0; i < args.length; i++) {
22
23
  if (arg === '--phase' && i + 1 < args.length) {
23
24
  startPhase = args[i + 1];
24
25
  i++; // Skip the next argument since we consumed it
26
+ } else if (arg === '--logFolder' && i + 1 < args.length) {
27
+ logFolder = args[i + 1];
28
+ i++; // Skip the next argument since we consumed it
25
29
  } else if (!arg.startsWith('--') && !configPath) {
26
30
  // First non-flag argument is the config path
27
31
  configPath = arg;
@@ -31,7 +35,7 @@ for (let i = 0; i < args.length; i++) {
31
35
  // Validate config file exists
32
36
  if (!fs.existsSync(configPath)) {
33
37
  log.error(`Error: Config file not found at ${configPath}`);
34
- log.error('Usage: scripts-orchestrator [path-to-config-file] [--phase <phase-name>]');
38
+ log.error('Usage: scripts-orchestrator [path-to-config-file] [--phase <phase-name>] [--logFolder <log-directory>]');
35
39
  process.exit(1);
36
40
  }
37
41
 
@@ -45,8 +49,13 @@ if (!startPhase && commandsConfig.start_phase) {
45
49
  startPhase = commandsConfig.start_phase;
46
50
  }
47
51
 
52
+ // Check for log_folder in config if not provided via command line
53
+ if (!logFolder && commandsConfig.log_folder) {
54
+ logFolder = commandsConfig.log_folder;
55
+ }
56
+
48
57
  // Create and run the orchestrator
49
- const orchestrator = new Orchestrator(commandsConfig, startPhase);
58
+ const orchestrator = new Orchestrator(commandsConfig, startPhase, logFolder);
50
59
 
51
60
  // Enhanced signal handlers
52
61
  const handleSignal = async (signal) => {
package/lib/logger.js CHANGED
@@ -8,6 +8,14 @@ const argv = yargs(hideBin(process.argv))
8
8
  type: 'boolean',
9
9
  description: 'Run with verbose logging',
10
10
  })
11
+ .option('phase', {
12
+ type: 'string',
13
+ description: 'Start execution from a specific phase',
14
+ })
15
+ .option('logFolder', {
16
+ type: 'string',
17
+ description: 'Specify the directory for log files',
18
+ })
11
19
  .parse();
12
20
 
13
21
  class Logger {
@@ -3,9 +3,10 @@ import { healthCheck } from './health-check.js';
3
3
  import { log } from './logger.js';
4
4
 
5
5
  export class Orchestrator {
6
- constructor(config, startPhase = null) {
6
+ constructor(config, startPhase = null, logFolder = null) {
7
7
  this.config = config;
8
8
  this.startPhase = startPhase;
9
+ this.logFolder = logFolder;
9
10
  this.processManager = processManager;
10
11
  this.healthCheck = healthCheck;
11
12
  this.logger = log;
@@ -13,6 +14,11 @@ export class Orchestrator {
13
14
  this.skippedCommands = [];
14
15
  this.commandTimings = new Map();
15
16
 
17
+ // Set the log folder in process manager
18
+ if (logFolder) {
19
+ this.processManager.setLogFolder(logFolder);
20
+ }
21
+
16
22
  // Flatten commands for easier tracking
17
23
  this.allCommands = this.flattenCommands(config);
18
24
  }
@@ -10,6 +10,12 @@ export class ProcessManager {
10
10
  this.logger = log;
11
11
  this.backgroundProcesses = [];
12
12
  this.backgroundProcessesDetails = [];
13
+ this.logFolder = 'scripts-orchestrator-logs'; // Default log folder
14
+ }
15
+
16
+ setLogFolder(logFolder) {
17
+ this.logFolder = logFolder;
18
+ this.logger.verbose(`Log folder set to: ${logFolder}`);
13
19
  }
14
20
 
15
21
  addBackgroundProcess({ command, url, startedByScript, process_tracking, kill_command }) {
@@ -24,7 +30,8 @@ export class ProcessManager {
24
30
  }
25
31
 
26
32
  async runCommand({ cmd, logFile, background = false, healthCheck = null, kill_command = null, isRetry = false }) {
27
- const LOGS_DIR = path.resolve(process.cwd(), 'scripts-orchestrator-logs');
33
+ const baseDir = this.logFolder ? path.resolve(this.logFolder) : process.cwd();
34
+ const LOGS_DIR = path.join(baseDir, 'scripts-orchestrator-logs');
28
35
  const LOG_FILE = logFile || path.join(LOGS_DIR, `${cmd}.log`);
29
36
 
30
37
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripts-orchestrator",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
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",