JSPM

  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q69003F
  • License MIT

CLI tool to scaffold GitHub Actions workflows and code quality setup with Husky

Package Exports

  • @netanelh2/create-workflows-package
  • @netanelh2/create-workflows-package/dist/src/cli.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 (@netanelh2/create-workflows-package) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@netanelh2/create-workflows-package

🚀 CLI tool to add GitHub Actions workflows and code quality setup with Husky to your existing project.

Quick Start

Add workflows and code quality to your project using npx (recommended):

npx @netanelh2/create-workflows-package

Or install globally and use:

npm install -g @netanelh2/create-workflows-package
create-workflows-package

Usage

Interactive Mode (Default)

Run to be prompted for which workflows and features to include:

npx @netanelh2/create-workflows-package

Non-Interactive Mode

Skip all prompts and include everything:

npx @netanelh2/create-workflows-package --yes

Command Options

  • -y, --yes - Skip prompts and include all features
  • --no-install - Skip automatic dependency installation

Examples

# Interactive setup
npx @netanelh2/create-workflows-package

# Include everything without prompts
npx @netanelh2/create-workflows-package --yes

# Setup without installing dependencies
npx @netanelh2/create-workflows-package --no-install

What Gets Added

The CLI adds to your existing project:

  • GitHub Actions workflows for CI/CD automation
  • Code quality tools: ESLint, Prettier with TypeScript support
  • Husky git hooks for pre-commit quality checks
  • lint-staged for efficient pre-commit linting
  • Updated package.json with quality scripts

Available Workflows

Choose from these GitHub Actions workflows:

  • Sanity Tests - Run quick sanity checks on pull requests
  • Regression Tests - Full test suite for releases
  • Code Quality - Linting, formatting, and type checking
  • Cleanup Artifacts - Automatic cleanup of old workflow artifacts
  • Deploy Reports - Deploy test reports to GitHub Pages
  • Slack Notifications - Send notifications to Slack channels
  • Nightly Regression - Run full regression tests nightly

GitHub Actions Setup Guide

After running the CLI, follow these steps to enable GitHub Actions:

  1. Repository Permissions:

    • Go to your repository on GitHub
    • Navigate to Settings > Actions > General
    • Under "Workflow permissions", select "Read and write permissions"
  2. GitHub Pages Setup (for report deployment):

    • Go to Settings > Pages
    • Set Source to "GitHub Actions"
    • This enables automatic publishing of test reports
  3. Required Secrets (Settings > Secrets and variables > Actions):

    • BASE_URL: Your application URL (e.g., https://your-app.com) - required for tests
    • SLACK_WEBHOOK_URL: Slack webhook URL for notifications (optional, only if Slack notifications enabled)
  4. Branch Protection (recommended):

    • Go to Settings > Branches
    • Add rules for your main branch (main/master/develop)
    • Require status checks from "Code Quality Check" workflow
    • This ensures code quality before merging
  5. Package.json Scripts: Ensure your package.json has these scripts (automatically added by CLI):

    {
      "scripts": {
        "test:sanity": "playwright test --grep '@sanity'",
        "test:regression": "playwright test --grep '@regression'",
        "check": "npm run lint:check && npm run format:check && npx tsc"
      }
    }
  6. Slack Setup (if notifications enabled):

    • Create a Slack app with incoming webhooks
    • Get the webhook URL and add it as SLACK_WEBHOOK_URL secret
    • Ensure the Slack channel has proper permissions
  7. Optional: Code Ownership:

    • The CLI will ask if you want to create a CODEOWNERS file
    • If yes, provide your GitHub username to set up automatic code ownership

Scripts Added to package.json

{
  "scripts": {
    "lint:check": "eslint src/**/*.ts --max-warnings 0 --no-warn-ignored",
    "format:check": "prettier --check src/**/*.ts",
    "check": "npm run lint:check && npm run format:check && npx tsc",
    "fix": "prettier --write src/**/*.ts && eslint src/**/*.ts --fix --no-warn-ignored",
    "pre-commit": "lint-staged",
    "prepare": "husky"
  }
}

After Setup

Once setup is complete, you can use these commands:

# Code Quality
npm run check            # Run all quality checks
npm run lint:check       # Check linting
npm run format:check     # Check formatting
npm run fix              # Auto-fix issues

# Git Hooks
npm run prepare          # Setup Husky (run once)

Requirements

  • Node.js 18.0.0 or higher
  • npm or yarn
  • Existing Git repository (recommended)

Dependencies Added

Dev Dependencies:

  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • eslint
  • eslint-config-prettier
  • eslint-plugin-prettier
  • prettier
  • husky
  • lint-staged

License

MIT

Support