setup static method

Future<bool> setup({
  1. bool verbose = false,
})

Sets up Pug.js by running npm install.

This function will install Pug.js globally if it's not already installed. It checks for both local and global installations.

Returns true if setup was successful, false otherwise.

Example:

final success = await PugServer.setup();
if (success) {
  print('Pug.js is ready to use!');
} else {
  print('Failed to setup Pug.js');
}

Implementation

static Future<bool> setup({bool verbose = false}) async {
  if (verbose) print('Checking if Pug.js is available...');

  // First check if Pug is already available
  if (await _isPugAvailable()) {
    if (verbose) print('✅ Pug.js is already installed and available.');
    return true;
  }

  if (verbose) print('Pug.js not found. Installing...');

  // Try to install Pug locally first
  if (await _installPugLocally(verbose)) {
    if (verbose) print('✅ Pug.js installed locally.');
    return true;
  }

  // If local install fails, try global install
  if (await _installPugGlobally(verbose)) {
    if (verbose) print('✅ Pug.js installed globally.');
    return true;
  }

  if (verbose) print('❌ Failed to install Pug.js.');
  return false;
}