Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ basis Public

A unified development toolkit with CLI, package management, versioning, publishing, linting, and git hooks.

License

Notifications You must be signed in to change notification settings

funish/basis

Repository files navigation

Funish Basis

GitHub Contributor Covenant

Monorepo for @funish/basis - A unified development toolkit with CLI for package management, versioning, publishing, linting, and git hooks management for JavaScript/TypeScript projects.

About This Project

This is the monorepo for @funish/basis, a modern development toolkit that unifies common development workflows into a single CLI. Instead of juggling multiple tools for package management, versioning, publishing, linting, and git hooks, Basis provides one interface for everything.

πŸ‘€ User? Looking to use @funish/basis? Check out the package documentation or install directly:

# Install globally with pnpm (recommended)
pnpm add -g @funish/basis
# Quick start
basis init

πŸ§‘β€πŸ’» Developer? Welcome! This document is for you. Keep reading to learn how to contribute to this project.

What is Basis?

Basis is a unified CLI toolkit that provides:

  • πŸ“¦ Package Management: Auto-detected package manager support (npm, yarn, pnpm, bun, deno)
  • 🏷️ Version Management: Semantic versioning with automated git tagging
  • πŸš€ Publishing: Multi-tag publishing strategy with edge version tracking
  • πŸ”§ Linting: Tool-agnostic linting workflow
  • πŸͺ Git Hooks: Smart git hooks management
  • πŸ’» Modern Architecture: Built on unjs ecosystem (citty, consola, c12, nypm, semver)

Repository Structure

basis/
β”œβ”€β”€ packages/
β”‚ └── basis/ # Main @funish/basis package
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ cli.ts # CLI entry point
β”‚ β”‚ β”œβ”€β”€ commands/ # CLI command implementations
β”‚ β”‚ β”‚ β”œβ”€β”€ install.ts # Package installation (nypm)
β”‚ β”‚ β”‚ β”œβ”€β”€ add.ts # Add dependencies (nypm)
β”‚ β”‚ β”‚ β”œβ”€β”€ remove.ts # Remove dependencies (nypm)
β”‚ β”‚ β”‚ β”œβ”€β”€ run.ts # Run scripts (nypm)
β”‚ β”‚ β”‚ β”œβ”€β”€ version.ts # Version management (semver)
β”‚ β”‚ β”‚ β”œβ”€β”€ publish.ts # Publishing workflow
β”‚ β”‚ β”‚ β”œβ”€β”€ lint.ts # Linting coordination
β”‚ β”‚ β”‚ β”œβ”€β”€ git.ts # Git management with subcommands
β”‚ β”‚ β”‚ β”œβ”€β”€ init.ts # Project initialization
β”‚ β”‚ β”‚ └── config.ts # Configuration management
β”‚ β”‚ β”œβ”€β”€ modules/ # Core business logic
β”‚ β”‚ β”‚ β”œβ”€β”€ version.ts # Version management logic
β”‚ β”‚ β”‚ β”œβ”€β”€ publish.ts # Publishing logic
β”‚ β”‚ β”‚ β”œβ”€β”€ git.ts # Git hooks and config implementation
β”‚ β”‚ β”‚ β”œβ”€β”€ lint.ts # Linting implementation
β”‚ β”‚ β”‚ └── init.ts # Initialization logic
β”‚ β”‚ β”œβ”€β”€ config.ts # Configuration system (c12)
β”‚ β”‚ β”œβ”€β”€ types.ts # TypeScript type definitions
β”‚ β”‚ └── utils.ts # Shared utilities
β”‚ β”œβ”€β”€ package.json # Package manifest
β”‚ β”œβ”€β”€ build.config.ts # Build configuration (unbuild)
β”‚ └── README.md # User documentation
β”œβ”€β”€ package.json # Monorepo configuration
β”œβ”€β”€ pnpm-workspace.yaml # pnpm workspace configuration
β”œβ”€β”€ tsconfig.json # TypeScript configuration
β”œβ”€β”€ basis.config.ts # Self-hosting configuration
└── README.md # This file (development documentation)

Development Setup

Prerequisites

  • Node.js 18.x or higher
  • pnpm 9.x or higher (this project uses pnpm as the package manager)
  • Git for version control

Getting Started

  1. Clone the repository:

    git clone https://github.com/funish/basis.git
    cd basis
  2. Install dependencies:

    pnpm install
  3. Build packages:

    pnpm build
  4. Development mode (watch and rebuild):

    pnpm dev
  5. Test the CLI locally:

    # Link the package globally for testing
    cd packages/basis
    pnpm link --global
    # Now you can use 'basis' command anywhere
    basis --version

Development Commands

pnpm dev # Watch and rebuild (recommended for development)
pnpm build # Build all packages for production
pnpm lint # Run code formatting and linting

Architecture & Design Principles

πŸ—οΈ Modular Architecture

The codebase is organized into clear layers:

  • Commands (src/commands/): CLI interface using citty
  • Modules (src/modules/): Business logic implementation
  • Configuration (src/config.ts): Unified config system using c12
  • Types (src/types.ts): TypeScript definitions
  • Utilities (src/utils.ts): Shared helper functions

πŸ”§ Technology Choices

  • citty : Modern CLI framework for command structure
  • consola : Elegant console logging
  • c12 : Universal configuration loader
  • nypm : Universal package manager interface
  • semver : Semantic versioning utilities
  • pkg-types : Package.json utilities
  • pathe : Universal path utilities
  • micromatch : Pattern matching for linting

πŸ“ Configuration System

Uses c12 for powerful configuration loading with:

  • TypeScript support
  • Environment-based overrides
  • Schema validation
  • Unified configuration file (basis.config.ts)

πŸš€ Publishing Strategy

Multi-tag publishing approach:

  • edge: Always points to latest published version
  • latest: Stable releases only
  • alpha/beta/rc: Prerelease channels
  • Custom tags: Flexible workflow support

Contributing

We welcome contributions! Here's how to get started:

Quick Setup

# Clone and setup
git clone https://github.com/funish/basis.git
cd basis
pnpm install
pnpm dev
# Test your changes
cd packages/basis && pnpm link --global
basis --version

Development Workflow

  1. Code: Follow our standards in CONTRIBUTING.md
  2. Test: pnpm build && basis <your-command>
  3. Commit: Use conventional commits (feat:, fix:, etc.)
  4. Submit: Create a Pull Request

πŸ“‹ For detailed guidelines, principles, and best practices, see our Contributing Guide.

Release Process

This project uses itself for version management and publishing:

# Create a new version
basis version patch # or minor/major
# Publish to npm
basis publish --stable # for stable release
basis publish # for edge release

Version Strategy

  • Patch: Bug fixes, small improvements
  • Minor: New features, backwards compatible
  • Major: Breaking changes
  • Prerelease: Alpha/beta releases with basis version --prerelease

Self-Hosting

This monorepo uses its own basis configuration:

// basis.config.ts
export default defineBasisConfig({
 lint: [
 { runner: "oxlint" },
 { runner: "tsc" },
 ],
 fmt: [
 { runner: "oxfmt" },
 ],
 check: {
 staged: {
 "*.{ts,js,json}": "basis lint",
 "*.{ts,js,json,md}": "basis fmt",
 },
 },
 git: {
 hooks: {
 "pre-commit": "pnpm basis check --staged",
 "commit-msg": "pnpm basis git --lint-commit",
 },
 config: {
 core: {
 autocrlf: "input",
 },
 },
 autoInitGit: true,
 },
 version: {
 tagPrefix: "v",
 autoCommit: true,
 autoTag: true,
 autoPush: false,
 },
 publish: {
 defaultTag: "edge",
 stableTag: "latest",
 checkGitClean: true,
 checkTests: true,
 },
});

Project Philosophy

Basis follows core principles that guide its design and development:

  1. Unified Interface: One CLI for all development tasks
  2. Tool Agnostic: Don't replace tools, orchestrate them
  3. Auto-Detection: Minimize configuration, maximize convenience
  4. Modern Stack: Built on proven unjs ecosystem
  5. Developer Experience: Focus on productivity and simplicity
  6. Balanced Output: Silent process with clear completion status

πŸ“‹ For detailed development principles and coding standards, see our Contributing Guide.

Why Unjs Ecosystem?

The unjs ecosystem provides:

  • Consistency: Similar APIs across tools
  • Quality: Well-tested, maintained packages
  • Performance: Optimized for speed and bundle size
  • Community: Active development and support

Support & Community

License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ by Funish using the amazing unjs ecosystem

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /