CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-aurelia-cli

The command line tooling for Aurelia, providing project scaffolding, build tools, and development utilities for the Aurelia JavaScript framework.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

cli-engine.mddocs/

CLI Engine

Core command-line interface functionality for executing commands, managing options, and handling project context within the Aurelia CLI system.

Capabilities

CLI Class

The main command-line interface class that handles command execution and dependency injection.

/**
 * Main CLI class for command execution and container management
 */
class CLI {
  /**
   * Initialize CLI with options
   * @param options - CLI options instance
   */
  constructor(options?: CLIOptions);
  
  /**
   * Execute a command with arguments
   * @param command - Command name to execute
   * @param args - Command arguments array
   * @returns Promise resolving when command completes
   */
  run(command: string, args: string[]): Promise<void>;
  
  /**
   * Configure logger with appropriate log level
   */
  configureLogger(): void;
  
  // Properties (read-only access)
  options: CLIOptions;
  container: Container;
  ui: ConsoleUI;
  project?: Project;
}

Usage Examples:

const { CLI, CLIOptions } = require("aurelia-cli");

// Create CLI instance with default options
const cli = new CLI();

// Create CLI with custom options
const options = new CLIOptions();
const cli = new CLI(options);

// Execute help command
await cli.run("help", []);

// Execute new project command with arguments
await cli.run("new", ["my-app", "--typescript"]);

// Execute generate command
await cli.run("generate", ["component", "my-component"]);

CLIOptions Class

Command-line options parser and manager for handling flags, values, and environment configuration.

/**
 * Command-line options parser and manager
 */
class CLIOptions {
  /**
   * Initialize CLI options parser
   */
  constructor();
  
  /**
   * Get the current task name from task path
   * @returns Task name without extension
   */
  taskName(): string;
  
  /**
   * Get current environment (dev, prod, etc.)
   * @returns Environment name
   */
  getEnvironment(): string;
  
  /**
   * Check if a flag is present in arguments
   * @param name - Flag name (without dashes)
   * @param shortcut - Optional shortcut flag
   * @returns True if flag is present
   */
  hasFlag(name: string, shortcut?: string): boolean;
  
  /**
   * Get the value of a flag
   * @param name - Flag name (without dashes)
   * @param shortcut - Optional shortcut flag
   * @returns Flag value or null if not present
   */
  getFlagValue(name: string, shortcut?: string): string | null;
  
  // Static methods for global access
  static taskName(): string;
  static hasFlag(name: string, shortcut?: string): boolean;
  static getFlagValue(name: string, shortcut?: string): string | null;
  static getEnvironment(): string;
  
  // Properties
  args?: string[];
  taskPath?: string;
  runningGlobally?: boolean;
  runningLocally?: boolean;
  originalBaseDir?: string;
}

Usage Examples:

const { CLIOptions } = require("aurelia-cli");

// Create options instance
const options = new CLIOptions();

// Check for flags
if (options.hasFlag("typescript", "ts")) {
  console.log("TypeScript flag is set");
}

// Get flag values
const env = options.getFlagValue("env", "e") || "dev";
const port = options.getFlagValue("port", "p") || "9000";

// Get environment
const environment = options.getEnvironment(); // "dev", "prod", etc.

// Static usage
if (CLIOptions.hasFlag("watch")) {
  console.log("Watch mode enabled");
}

const currentEnv = CLIOptions.getEnvironment();

Environment Management

The CLI handles multiple environments through configuration files and command-line flags.

/**
 * Environment detection and normalization
 * Supports environments defined in aurelia_project/environments/
 * Normalizes NODE_ENV values (production -> prod, development -> dev)
 */
const supportedEnvironments = ["dev", "prod", "test"];

/**
 * Environment sources (in order of precedence):
 * 1. --env flag
 * 2. NODE_ENV environment variable
 * 3. "dev" (default)
 */

Usage Examples:

// Set environment via command line
// au build --env prod
// au test --env test

// Set environment via NODE_ENV
process.env.NODE_ENV = "production"; // normalized to "prod"

// Check current environment
const env = CLIOptions.getEnvironment();
switch (env) {
  case "dev":
    // Development configuration
    break;
  case "prod":
    // Production configuration
    break;
}

Command Resolution

The CLI automatically resolves and executes commands from the commands directory.

/**
 * Command resolution process:
 * 1. Look for command in lib/commands/{commandName}/command.js
 * 2. Instantiate command class with dependency injection
 * 3. Call execute(args) method on command instance
 */

interface Command {
  execute(args: string[]): Promise<void>;
  static inject?(): any[]; // Optional dependency injection
}

Available Commands:

  • new - Create new Aurelia project
  • generate - Generate project components
  • help - Show help information
  • config - Manage project configuration
  • gulp - Run gulp tasks (legacy)

docs

build-system.md

cli-engine.md

configuration-management.md

index.md

package-management.md

project-management.md

user-interface.md

tile.json