JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2166
  • Score
    100M100P100Q117991F
  • License MIT

A lightweight and flexible workflow automation library for JavaScript/TypeScript projects

Package Exports

  • alvamind-workflow
  • alvamind-workflow/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (alvamind-workflow) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

๐ŸŒŠ Alvamind Workflow

A lightweight and flexible workflow automation library for JavaScript/TypeScript projects.

๐ŸŽฏ Introduction

Alvamind Workflow streamlines your development process by providing an elegant way to define and execute multi-step workflows. Whether you prefer YAML configurations or programmatic approaches, Alvamind makes automation simple and maintainable.

โœจ Key Features

๐Ÿ”„ Flexible Workflow Definition

  • YAML-based configuration for simple, readable workflows
  • Programmatic API for dynamic workflow creation
  • Mix and match approaches based on your needs

โšก Powerful Execution Engine

  • Real-time execution progress with timing
  • Intelligent error handling and recovery
  • Skippable steps for optional tasks
  • Graceful interruption handling

๐Ÿ› ๏ธ Developer Experience

  • TypeScript-first design
  • Minimal configuration required
  • Clear, colorful console output
  • Comprehensive error messages

๐Ÿงช Testing & Development

  • Test mode for dry runs
  • Promise-based API
  • Easy to integrate with CI/CD

๐Ÿš€ Quick Start

Installation

npm install alvamind-workflow

Simple Example (YAML)

  1. Create workflow.yml:
version: "1.0"
name: "Deploy Application"
commands:
  - name: "Build Project"
    command: "npm run build"
  - name: "Run Tests"
    command: "npm test"
    skippable: true
  - name: "Deploy"
    command: "npm run deploy"
  1. Run it:
workflow-run

Programmatic Usage

import { createWorkflow } from 'alvamind-workflow';

const workflow = createWorkflow({ name: 'CI Pipeline' })
  .execute('npm run lint', 'Lint Code')
  .execute('npm run test', 'Run Tests', true)
  .execute('npm run build', 'Build Project');

await workflow.run();

๐Ÿ“Š Example Output

๐Ÿณ Executing workflow: Deploy Application
=====================================
Step 1/3: Build Project
> npm run build
 -> running... 2.5s
[1/3] โœ“ Build Project 2.5s

Step 2/3: Run Tests
> npm test
 -> running... 1.2s
[2/3] โœ“ Run Tests 1.2s

Step 3/3: Deploy
> npm run deploy
 -> running... 3.1s
[3/3] โœ“ Deploy 3.1s
=====================================
โœ“ Workflow completed in 6.8s

๐ŸŽ›๏ธ Advanced Features

Error Handling

try {
  await workflow
    .execute('risky-command', 'Risky Step', true) // skippable
    .execute('must-run', 'Critical Step')         // will fail if error
    .run();
} catch (error) {
  console.error('Workflow failed:', error);
}

Test Mode

await workflow.run({ testMode: true }); // Dry run without executing commands

Interactive Mode

When a command fails, the interactive mode provides options to:

  1. Retry the original command
  2. Enter a new command to execute
  3. Skip the current step (if skippable)
  4. Abort the entire workflow

๐Ÿ”ง API Reference

loadWorkflow(path?: string)

Loads a workflow configuration from a YAML file.

  • path: (optional) Path to the YAML file. Defaults to workflow.yml.
  • Returns: Promise<WorkflowConfig>

runWorkflow(config: WorkflowConfig, options?: RunnerOptions)

Executes a workflow based on the provided configuration.

  • config: Workflow configuration object.
  • options: (optional) Runner options.
    • testMode: (boolean) Enable test mode to prevent actual command execution.
  • Returns: Promise<boolean>

createWorkflow(options?: WorkflowOptions)

Creates a new programmatic workflow builder.

  • options: (optional) Workflow options.
    • name: (string) Workflow name.
  • Returns: WorkflowBuilder

WorkflowBuilder

A fluent interface for constructing workflows programmatically.

  • name(name: string): Sets the workflow name.
  • execute(command: string, name: string, skippable?: boolean): Adds a command to the workflow.
  • executeWith(command: string, name: string, callback: (result: { exitCode: number, stdout: string, stderr: string }) => string | undefined, skippable?: boolean): Adds a command with a callback (for branching logic).
  • build(): Builds the workflow configuration object (WorkflowConfig).
  • run(options?: WorkflowOptions): Runs the workflow.

Workflow Configuration (WorkflowConfig)

interface WorkflowConfig {
  version: string;
  name: string;
  commands: WorkflowCommand[];
}

Workflow Command (WorkflowCommand)

interface WorkflowCommand {
  command: string;
  name: string;
  skippable?: boolean;
}

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  • ๐Ÿ› Report bugs by opening issues
  • ๐Ÿ’ก Propose new features
  • ๐Ÿ“ Improve documentation
  • ๐Ÿ”€ Submit pull requests

๐Ÿ“ฆ What's Inside

alvamind-workflow/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ cli.ts         # CLI implementation
โ”‚   โ”œโ”€โ”€ index.ts       # Main entry point
โ”‚   โ”œโ”€โ”€ runner.ts      # Execution engine
โ”‚   โ”œโ”€โ”€ types.ts       # TypeScript types
โ”‚   โ””โ”€โ”€ workflow.ts    # Workflow builder
โ””โ”€โ”€ README.md

๐Ÿ“„ License

MIT ยฉ Alvamind 2025


Built with โค๏ธ by the Alvamind team