### Install and Run Funish Toolchains Examples Source: https://github.com/funish/toolchains/blob/main/playground/README.md Instructions for installing dependencies and running specific examples using pnpm and tsx. ```bash pnpm install ``` ```bash pnpm tsx playground/examples//.ts ``` -------------------------------- ### Install @funish/prompt Source: https://github.com/funish/toolchains/blob/main/packages/prompt/README.md Install the package using npm, yarn, or pnpm. ```bash # npm $ npm install @funish/prompt ``` ```bash # yarn $ yarn add @funish/prompt ``` ```bash # pnpm $ pnpm add @funish/prompt ``` -------------------------------- ### Run Benchmarking Example Source: https://github.com/funish/toolchains/blob/main/playground/README.md Example command to run the performance benchmarking demonstration. ```bash pnpm tsx playground/examples/bench/performance-test.ts ``` -------------------------------- ### Install @funish/scaffolding Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Install the package using npm, yarn, or pnpm. ```bash # npm $ npm install @funish/scaffolding ``` ```bash # yarn $ yarn add @funish/scaffolding ``` ```bash # pnpm $ pnpm add @funish/scaffolding ``` -------------------------------- ### Install @funish/cli Source: https://github.com/funish/toolchains/blob/main/packages/cli/README.md Install the @funish/cli package using npm, yarn, or pnpm. ```bash # npm $ npm install @funish/cli ``` ```bash # yarn $ yarn add @funish/cli ``` ```bash # pnpm $ pnpm add @funish/cli ``` -------------------------------- ### Run argv Parsing Example Source: https://github.com/funish/toolchains/blob/main/playground/README.md Example command to run the argv parsing demonstration. ```bash pnpm tsx playground/examples/argv/parse-command.ts ``` -------------------------------- ### Install Git hooks using CLI Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Install hooks in the default location or a custom directory. Optionally save the install script. ```bash # Install in default location (.githooks) $ githooks install # Install in custom directory $ githooks install --path .hooks # Install and save postinstall script $ githooks install --script ``` -------------------------------- ### Install Unified @funish/basis Toolkit Source: https://github.com/funish/toolchains/blob/main/README.md For new projects, install the unified @funish/basis toolkit globally using pnpm. ```bash pnpm install -g @funish/basis ``` -------------------------------- ### Install @funish/argv with npm, yarn, or pnpm Source: https://github.com/funish/toolchains/blob/main/packages/argv/README.md Install the package using your preferred package manager. ```bash # npm $ npm install @funish/argv ``` ```bash # yarn $ yarn add @funish/argv ``` ```bash # pnpm $ pnpm add @funish/argv ``` -------------------------------- ### Install @funish/githooks with npm, yarn, or pnpm Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Install the package using your preferred package manager. ```bash # npm $ npm install @funish/githooks # yarn $ yarn add @funish/githooks # pnpm $ pnpm add @funish/githooks ``` -------------------------------- ### Install @funish/bench with npm, yarn, or pnpm Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Install the @funish/bench package using your preferred package manager. ```bash # npm $ npm install @funish/bench # yarn $ yarn add @funish/bench # pnpm $ pnpm add @funish/bench ``` -------------------------------- ### Install @funish/lint Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Install the package as a development dependency using npm, yarn, or pnpm. ```bash # npm $ npm install -D @funish/lint ``` ```bash # yarn $ yarn add -D @funish/lint ``` ```bash # pnpm $ pnpm add -D @funish/lint ``` -------------------------------- ### Install All Funish Toolchains Packages Source: https://github.com/funish/toolchains/blob/main/README.md Install all packages within the Funish Toolchains monorepo using pnpm. ```bash pnpm install ``` -------------------------------- ### Install @funish/bump with npm, yarn, or pnpm Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Install the package using your preferred package manager. ```bash # npm $ npm install @funish/bump ``` ```bash # yarn $ yarn add @funish/bump ``` ```bash # pnpm $ pnpm add @funish/bump ``` -------------------------------- ### Install @funish/githooks-config Source: https://github.com/funish/toolchains/blob/main/packages/githooks-config/README.md Install the package as a development dependency using npm, yarn, or pnpm. ```bash # Using npm npm install @funish/githooks-config # Using yarn yarn add @funish/githooks-config # Using pnpm pnpm add @funish/githooks-config ``` -------------------------------- ### Install Individual Funish Toolchains Packages Source: https://github.com/funish/toolchains/blob/main/README.md Install specific packages from Funish Toolchains individually using pnpm add. ```bash pnpm add @funish/cli @funish/argv # etc. ``` -------------------------------- ### githooksInstall Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Installs Git hooks in the specified directory. Optionally saves the installation script. ```APIDOC ## githooksInstall(path?, isSaveScript?) ### Description Installs Git hooks in the specified directory. The `isSaveScript` parameter determines whether to save the installation script. ### Parameters #### Path Parameters - **path** (string) - Optional - Directory to install hooks in. #### Query Parameters - **isSaveScript** (boolean | string) - Optional - Whether to save installation script. ### Method ``` await githooksInstall(path?: string, isSaveScript?: boolean | string) ``` ### Request Example ```typescript await githooksInstall('.hooks', true); ``` ``` -------------------------------- ### Handlebars Template Example Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Demonstrates dynamic content generation in template files using Handlebars syntax, including dynamic file names and JSON structure. ```json { "name": "{{projectName}}", "version": "{{version}}", "description": "{{description}}", "author": "{{author}}", "license": "{{license}}", "dependencies": { {{#each dependencies}} "{{@key}}": "{{this}}" {{/each}} } } ``` -------------------------------- ### Example Commit Message Configuration Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md A sample configuration for commit messages, specifying allowed types and rules for scope, description, and body. ```typescript { commitMsg: { type: { enum: ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert'], rules: ['lowercase'] }, scope: { rules: ['lowercase'] }, description: { rules: ['phrasecase'] }, body: { rules: ['phrasecase'] } } } ``` -------------------------------- ### Commit Message Format Example Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Illustrates the standard format for commit messages, including type, scope, description, body, and footers. ```markdown [optional scope][!]: [optional body] [optional footer(s)] ``` -------------------------------- ### Programmatic usage of @funish/githooks API Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Install, set up, uninstall, and migrate Git hooks programmatically using the provided functions. ```typescript import { githooksInstall, githooksSetup, githooksUninstall, githooksMigrateFromHusky, } from "@funish/githooks"; // Install hooks await githooksInstall(".hooks", true); // Set up a hook await githooksSetup("pre-commit", "npm test"); // Uninstall hooks await githooksUninstall(); // Migrate from husky await githooksMigrateFromHusky(); ``` -------------------------------- ### Breaking Change Indicator Example Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Demonstrates how to indicate breaking changes in commit messages using either the '!' character or a 'BREAKING CHANGE:' footer. ```markdown feat(api)!: change authentication method BREAKING CHANGE: new authentication method requires token ``` -------------------------------- ### Uninstall Git hooks using CLI Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Remove all installed Git hooks and revert configuration. ```bash $ githooks uninstall ``` -------------------------------- ### Get Benchmark Results Programmatically Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Retrieve benchmark results as an array of objects for further processing instead of printing them directly to the console. ```typescript const bench = new Bench(); bench.add("test", () => { /* ... */ }); const results = bench.getResults(); // Process results as needed ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Clone the Funish Toolchains repository and navigate into the project directory. This is the first step in setting up your development environment. ```bash git clone https://github.com/funish/toolchains.git cd toolchains ``` -------------------------------- ### createScaffolding Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Creates a new project from a specified template source to a target directory, with optional context and configuration options. ```APIDOC ## createScaffolding(source, target, context?, options?) ### Description Creates a new project from a template. ### Parameters #### Parameters - **source** (string) - Required - Template source (git repository, npm package, or local path) - **target** (string) - Required - Directory where the project should be created - **context** (object) - Optional - Template variables - **options** (object) - Optional - Download options (auth tokens, branch name, etc) ``` -------------------------------- ### Set up Git hooks using CLI Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Configure specific Git hooks with associated scripts. ```bash # Set up pre-commit hook $ githooks setup pre-commit # Set up with script $ githooks setup pre-commit --script "npm test" ``` -------------------------------- ### Basic Project Creation with @funish/scaffolding Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Use createScaffolding to generate projects from GitHub or local templates, providing project-specific context. ```typescript import { createScaffolding } from "@funish/scaffolding"; // Create from GitHub template await createScaffolding("github:user/repo", "./my-project", { projectName: "my-awesome-project", description: "An awesome project", }); // Create from local template await createScaffolding("./templates/vue-app", "./my-vue-app", { name: "My Vue App", version: "1.0.0", }); ``` -------------------------------- ### Build All Funish Toolchains Packages Source: https://github.com/funish/toolchains/blob/main/README.md Build all packages in the Funish Toolchains project using the pnpm build command. ```bash pnpm build ``` -------------------------------- ### Migrate from Husky using CLI Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Facilitates migration of existing hooks from Husky to @funish/githooks. ```bash $ githooks migrate ``` -------------------------------- ### Use Single Prompt with @funish/prompt Source: https://github.com/funish/toolchains/blob/main/packages/prompt/README.md Demonstrates how to use the `usePrompt` function to create basic text, confirmation, and selection prompts. Ensure you import `usePrompt` from the package. ```typescript import { usePrompt } from "@funish/prompt"; // Basic text prompt const name = await usePrompt("What is your name?", { type: "text" }); // Confirmation prompt const confirm = await usePrompt("Are you sure?", { type: "confirm" }); // Selection prompt const color = await usePrompt("Choose a color:", { type: "select", options: ["red", "blue", "green"], }); ``` -------------------------------- ### Using Different Parsers in @funish/argv Source: https://github.com/funish/toolchains/blob/main/packages/argv/README.md Illustrates how to specify different parsing strategies, 'regexp' or 'split', for command line arguments. ```typescript // Using regexp parser const args1 = parseArgv(["--name=value"], { parser: "regexp" }); // Using split parser (default) const args2 = parseArgv(["--name", "value"], { parser: "split" }); ``` -------------------------------- ### Automatic Metadata Integration with @funish/cli Source: https://github.com/funish/toolchains/blob/main/packages/cli/README.md Demonstrates how defineCommand automatically loads name, version, and description from package.json, eliminating the need for manual specification. ```typescript const cmd = defineCommand({ // No need to specify name, version, or description // They are automatically loaded from package.json args: { // ... }, run: (ctx) => { // ... }, }); ``` -------------------------------- ### Basic Benchmarking with @funish/bench Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Perform basic benchmarking by adding tasks to a Bench instance and printing the results. Configure the number of iterations and time unit. ```typescript import { Bench } from "@funish/bench"; const bench = new Bench({ times: 1000, // Number of iterations unit: "ms", // Time unit (s, ms, µs, ns) }); // Add tasks to benchmark bench.add("Array.push", () => { const arr = []; arr.push(1); }); bench.add("Array literal", () => { const arr = [1]; }); // Print results bench.print(); ``` -------------------------------- ### Basic Argument Parsing with @funish/argv Source: https://github.com/funish/toolchains/blob/main/packages/argv/README.md Demonstrates basic parsing of command line arguments including flags, negated flags, options with values, and positional arguments. ```typescript import { parseArgv } from "@funish/argv"; const args = parseArgv([ "-b", "--bool", "--no-meep", "--multi=baz", "--foo", "bar", ]); // => { _: [], b: true, bool: true, meep: false, multi: "baz", foo: "bar" } ``` -------------------------------- ### Bench Class Constructor Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Initializes a new Bench instance. You can configure the number of iterations and the time unit for the benchmark results. ```APIDOC ## Bench Class Constructor ### Description Initializes a new Bench instance with optional configuration for benchmarking. ### Constructor Signature ```typescript new Bench(options?: BenchOptions) ``` ### Options - `times` (number, default: 1000): The number of iterations to run for each task. - `unit` ("s" | "ms" | "µs" | "ns", default: "ns"): The time unit for reporting benchmark results. Available units are seconds, milliseconds, microseconds, and nanoseconds. ``` -------------------------------- ### githooksSetup Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Sets up a specific Git hook with a provided script. ```APIDOC ## githooksSetup(hooks, script?) ### Description Sets up a specific Git hook with the provided script content. ### Parameters #### Path Parameters - **hooks** (GithooksName) - Required - Name of the hook to set up. #### Query Parameters - **script** (string) - Optional - Script content for the hook. ### Method ``` await githooksSetup(hooks: GithooksName, script?: string) ``` ### Request Example ```typescript await githooksSetup('pre-commit', 'npm test'); ``` ``` -------------------------------- ### Run Tests in Funish Toolchains Source: https://github.com/funish/toolchains/blob/main/README.md Execute all tests for the Funish Toolchains project using the pnpm test command. ```bash pnpm test ``` -------------------------------- ### createPrompt Source: https://github.com/funish/toolchains/blob/main/packages/prompt/README.md Creates multiple interactive prompts. This function takes an object where each key is a prompt name and its value is the configuration for that prompt. ```APIDOC ## createPrompt(prompts) ### Description Creates multiple interactive prompts. ### Parameters #### Parameters - `prompts` (Prompts): Object mapping prompt names to their configurations ### Returns Promise resolving to an object containing all prompt responses. ``` -------------------------------- ### usePrompt Source: https://github.com/funish/toolchains/blob/main/packages/prompt/README.md Creates a single interactive prompt. This function displays a message to the user and waits for their input based on the provided options. ```APIDOC ## usePrompt(message, options?) ### Description Creates a single interactive prompt. ### Parameters #### Parameters - `message` (string): The prompt message to display - `options` (PromptOptions): Configuration options - `type`: Prompt type ("text" | "confirm" | "select" | "multiselect") - `placeholder`: Default placeholder text - `initial`: Initial value - `required`: Whether the input is required - `validate`: Custom validation function - `options`: Array of options for select/multiselect ``` -------------------------------- ### Define a Basic Command with @funish/cli Source: https://github.com/funish/toolchains/blob/main/packages/cli/README.md Define a simple command with a required string argument and a run function. ```typescript import { defineCommand } from "@funish/cli"; const cmd = defineCommand({ meta: { name: "greet", }, args: { name: { type: "string", description: "Name to greet", required: true, }, }, run: (ctx) => { console.log(`Hello, ${ctx.args.name}!`); }, }); ``` -------------------------------- ### Use @funish/lint CLI Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Execute linting tasks for staged files or commit messages directly from the command line. ```bash # Lint staged files $ lint staged # Validate commit message $ lint commit-msg # Show help $ lint --help ``` -------------------------------- ### Argument Parsing with Aliases and Defaults Source: https://github.com/funish/toolchains/blob/main/packages/argv/README.md Shows how to use aliases for options and provide default values when options are not specified. ```typescript const args = parseArgv(["--port", "3000"], { alias: { p: "port" }, default: { port: 8080 }, }); // => { _: [], port: 3000, p: 3000 } ``` -------------------------------- ### Run Linting in Funish Toolchains Source: https://github.com/funish/toolchains/blob/main/README.md Perform code linting across the Funish Toolchains project using the pnpm lint command. ```bash pnpm lint ``` -------------------------------- ### defineScaffoldingConfig Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Creates a type-safe scaffolding configuration object, used for defining interactive prompts and extending base configurations. ```APIDOC ## defineScaffoldingConfig(config) ### Description Creates a type-safe scaffolding configuration. ### Parameters #### Parameters - **config** (ScaffoldingConfig) - Required - Configuration object - **prompts**: Interactive prompts configuration - **extends**: Base configuration to extend ``` -------------------------------- ### githooksUninstall Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Uninstalls all Git hooks and restores the original configuration. ```APIDOC ## githooksUninstall() ### Description Uninstalls all Git hooks and restores the original Git configuration. ### Method ``` await githooksUninstall() ``` ### Request Example ```typescript await githooksUninstall(); ``` ``` -------------------------------- ### print Method Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Prints the benchmark results to the console in a formatted table. ```APIDOC ## print Method ### Description Outputs the benchmark results to the console in a human-readable table format. ### Signature ```typescript print(): void ``` ``` -------------------------------- ### Define a Command with Subcommands using @funish/cli Source: https://github.com/funish/toolchains/blob/main/packages/cli/README.md Define a command with nested subcommands, including argument definitions and run functions for each. ```typescript const cmd = defineCommand({ meta: { name: "app", }, subCommands: { serve: { args: { port: { type: "number", default: 3000, }, }, run: (ctx) => { console.log(`Starting server on port ${ctx.args.port}`); }, }, }, }); ``` -------------------------------- ### Publish Package via CLI Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Publish your package using the CLI. Supports interactive publishing, specifying tags, and publishing from a specific directory. ```bash # Publish package (interactive) $ bump publish ``` ```bash # Publish with specific tag $ bump publish --tag beta ``` ```bash # Publish from specific directory $ bump publish --path ./packages/mypackage ``` -------------------------------- ### Define Scaffolding Configuration Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Create a scaffolding.config.ts file to define interactive prompts for project configuration. ```typescript import { defineScaffoldingConfig } from "@funish/scaffolding"; export default defineScaffoldingConfig({ // Interactive prompts prompts: { projectName: { type: "text", placeholder: "Project name", }, framework: { type: "select", options: ["vue", "react", "svelte"], }, features: { type: "multiselect", options: ["typescript", "eslint", "prettier", "testing", "ci"], }, }, }); ``` -------------------------------- ### Use Multiple Prompts with @funish/prompt Source: https://github.com/funish/toolchains/blob/main/packages/prompt/README.md Utilizes the `createPrompt` function to define and run multiple prompts simultaneously, including text, confirmation, multiselect, and single selection types. The results are returned as an object. ```typescript import { createPrompt } from "@funish/prompt"; const answers = await createPrompt({ // Text input name: { type: "text", placeholder: "Your name", required: true, }, // Confirmation private: { type: "confirm", initial: false, }, // Multiple selection keywords: { type: "multiselect", options: ["TypeScript", "Node.js", "React", "Vue"], required: true, }, // Single selection framework: { type: "select", options: ["Next.js", "Nuxt", "Remix"], initial: "Next.js", }, }); console.log(answers); // { // name: "John Doe", // private: false, // keywords: ["TypeScript", "Node.js"], // framework: "Next.js" // } ``` -------------------------------- ### Bump Package Version via CLI Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Use the CLI to bump package versions. Supports default prerelease bumps, specific release types (minor, major), and prerelease tags. ```bash # Bump prerelease version (default) $ bump version ``` ```bash # Bump specific version type $ bump version --release minor ``` ```bash # Bump version with tag $ bump version --release prerelease --tag beta ``` ```bash # Bump version in specific directory $ bump version --path ./packages/mypackage ``` -------------------------------- ### add Method Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Adds a new task to be benchmarked. This method can be chained to add multiple tasks sequentially. ```APIDOC ## add Method ### Description Adds a task to the benchmark suite. This method is chainable, allowing multiple tasks to be added in a single statement. ### Signature ```typescript add(name: string, fn: () => void): Bench ``` ### Parameters - `name` (string) - Required - A unique identifier for the task being benchmarked. - `fn` (() => void) - Required - The function containing the code to be benchmarked. ``` -------------------------------- ### Push Changes and Submit Pull Request Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Push your feature branch to your fork and submit a pull request to the main repository. ```bash git push origin feature/your-feature-name ``` -------------------------------- ### Build Specific Package Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Build a specific package within the Funish Toolchains monorepo using the --filter flag. Replace '[package-name]' with the actual package name. ```bash pnpm --filter @funish/[package-name] build ``` -------------------------------- ### githooksMigrateFromHusky Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Migrates existing Git hooks from Husky to @funish/githooks. ```APIDOC ## githooksMigrateFromHusky() ### Description Migrates Git hooks from Husky to the @funish/githooks format. ### Method ``` await githooksMigrateFromHusky() ``` ### Request Example ```typescript await githooksMigrateFromHusky(); ``` ``` -------------------------------- ### Programmatically Publish Package Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Use the `bumpPublish` function to programmatically publish your package. Options allow specifying the tag and the path to the package directory. ```typescript import { bumpPublish } from "@funish/bump"; // Publish package await bumpPublish(); ``` ```typescript import { bumpPublish } from "@funish/bump"; // Publish with tag await bumpPublish({ tag: "beta" }); ``` ```typescript import { bumpPublish } from "@funish/bump"; // Publish from specific directory await bumpPublish({ path: "./packages/mypackage" }); ``` -------------------------------- ### Define @funish/githooks configuration Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Configure custom hooks directory, hook scripts, and additional Git configurations. ```typescript import { defineGithooksConfig } from "@funish/githooks"; export default defineGithooksConfig({ // Custom hooks directory path: ".hooks", // Hook scripts hooks: { "pre-commit": "npm test", "pre-push": "npm run build", }, // Additional Git config gitConfig: { core: { autocrlf: "input", }, }, }); ``` -------------------------------- ### Supported Template Sources Source: https://github.com/funish/toolchains/blob/main/packages/scaffolding/README.md Utilize giget to specify template sources from GitHub, GitLab, npm packages, or local directories. ```typescript // GitHub repository await createScaffolding("github:user/repo"); // GitLab repository await createScaffolding("gitlab:user/repo"); // npm package await createScaffolding("npm:package-name"); // Local directory await createScaffolding("./path/to/template"); ``` -------------------------------- ### Programmatically Bump Package Version Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Import and use the `bumpVersion` function to programmatically bump package versions. Options include specifying the release type and prerelease tag. ```typescript import { bumpVersion } from "@funish/bump"; // Bump prerelease version await bumpVersion(); ``` ```typescript import { bumpVersion } from "@funish/bump"; // Bump minor version await bumpVersion({ release: "minor" }); ``` ```typescript import { bumpVersion } from "@funish/bump"; // Bump version with tag await bumpVersion({ release: "prerelease", tag: "beta", }); ``` -------------------------------- ### Extend Default Configuration Source: https://github.com/funish/toolchains/blob/main/packages/githooks-config/README.md Extend the default configuration with your own custom hooks. ```typescript import baseConfig from "@funish/githooks-config"; import { defineGithooksConfig } from "@funish/githooks"; export default defineGithooksConfig({ ...baseConfig, hooks: { ...baseConfig.hooks, "pre-push": "npm test", // Add your own hooks }, }); ``` -------------------------------- ### Create a New Feature Branch Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Create a new branch for your feature development. It's recommended to base your branch off the 'main' branch. ```bash git checkout -b feature/your-feature-name ``` -------------------------------- ### Run Specific Package Tests Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Run tests for a specific package within the Funish Toolchains monorepo using the --filter flag. Replace '[package-name]' with the actual package name. ```bash pnpm --filter @funish/[package-name] test ``` -------------------------------- ### Chaining API for Benchmarking Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Utilize the chaining API to add multiple tasks to a Bench instance sequentially before printing results. ```typescript new Bench() .add("Task 1", () => { /* ... */ }) .add("Task 2", () => { /* ... */ }) .print(); ``` -------------------------------- ### Configure Staged File Linting Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Sets up linting rules for files that are staged for commit. ```typescript await stagedLint({ "*.ts": "eslint --fix", }); ``` -------------------------------- ### Integrate with Git Hooks Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Configure Git hooks using `@funish/githooks` to automatically lint staged files and validate commit messages before committing. ```typescript // githooks.config.ts import { defineGithooksConfig } from "@funish/githooks"; export default defineGithooksConfig({ hooks: { // Lint staged files before commit "pre-commit": "pnpm lint staged", // Validate commit message "commit-msg": "pnpm lint commit-msg", }, }); ``` -------------------------------- ### bumpPublish Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Publishes a package to npm with smart tag handling. This function allows for publishing packages with specific tags, ensuring correct version handling for stable and prerelease versions. ```APIDOC ## bumpPublish(options?) ### Description Publishes a package to npm with smart tag handling. ### Parameters #### Options - `path` (string) - Optional - Path to package directory (default: current directory) - `tag` (string) - Optional - Tag to publish with (default: prerelease identifier or "edge") ``` -------------------------------- ### Staged Files Configuration Schema Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Defines the structure for mapping file patterns to lint commands. Supports glob patterns, negation, and multiple commands. ```typescript { staged: { [pattern: string]: string | string[] } } ``` -------------------------------- ### Reference in githooks.config.ts Source: https://github.com/funish/toolchains/blob/main/packages/githooks-config/README.md Reference the default configuration in your githooks.config.ts file. ```typescript import config from "@funish/githooks-config"; export default config; ``` -------------------------------- ### Add Validation to Prompts with @funish/prompt Source: https://github.com/funish/toolchains/blob/main/packages/prompt/README.md Shows how to implement custom validation for prompt inputs using the `validate` option. The provided function receives the input value and should return `true` if valid, or an error message string. ```typescript const port = await usePrompt("Enter port number:", { type: "text", validate: (value) => { const num = parseInt(value); if (isNaN(num)) return "Must be a number"; if (num < 1 || num > 65535) return "Must be between 1 and 65535"; return true; }, }); ``` -------------------------------- ### defineLintConfig Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Creates a type-safe lint configuration object. This function helps in defining rules and settings for your linting process. ```APIDOC ## defineLintConfig(config) ### Description Creates a type-safe lint configuration. ### Parameters #### Path Parameters - `config` (LintConfig) - Required - Configuration object - `staged` (Staged files configuration) - Optional - `commitMsg` (Commit message configuration) - Optional - `extends` (Base configuration to extend) - Optional ``` -------------------------------- ### getResults Method Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Retrieves the benchmark results programmatically as an array of objects. ```APIDOC ## getResults Method ### Description Returns a read-only array containing the results of all benchmarked tasks. This allows for programmatic access and further processing of the performance data. ### Signature ```typescript getResults(): readonly BenchResult[] ``` ### Return Value - `readonly BenchResult[]`: An array of objects, where each object represents the results for a single benchmarked task. ``` -------------------------------- ### Configure Lint Rules Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Define linting rules for staged files and commit messages in a `lint.config.ts` file. Supports ESLint, Prettier, and Jest integration. ```typescript import { defineLintConfig } from "@funish/lint"; export default defineLintConfig({ // Staged files linting configuration staged: { // Lint TypeScript files "*.ts": "eslint --fix", // Format other files "*.{json,md}": "prettier --write", // Run tests for changed files "__tests__/**/*.ts": "jest --findRelatedTests", }, // Commit message validation commitMsg: { // Conventional commit types type: { enum: ["feat", "fix", "docs", "style", "refactor", "test", "chore"], rules: ["lowercase"], }, // Scope validation scope: { rules: ["lowercase", "kebabcase"], }, // Description validation description: { rules: ["phrasecase"], }, }, }); ``` -------------------------------- ### parseArgv Source: https://github.com/funish/toolchains/blob/main/packages/argv/README.md Parses an array of command line arguments into a structured object. It supports various options for aliasing, default values, and different parsing strategies. ```APIDOC ## parseArgv(argv, options?) ### Description Main function to parse command line arguments. ### Parameters #### Parameters - `argv` (string[]): Array of command line arguments to parse - `options` (object, optional): - `alias` (object): Map of option aliases (e.g., `{ p: 'port' }`) - `default` (object): Default values for options - `parser` ('split' | 'regexp'): Parser to use (default: 'split') ### Returns Returns an object containing: - `_`: Array of positional arguments - Named properties for each option with their parsed values ``` -------------------------------- ### GithooksConfig interface definition Source: https://github.com/funish/toolchains/blob/main/packages/githooks/README.md Defines the structure for configuring Git hooks, including path, hook scripts, Git configurations, and extensions. ```typescript interface GithooksConfig { path?: string; // Custom hooks directory hooks?: { // Hook scripts [key in GithooksName]?: string; }; gitConfig?: object; // Additional Git config extends?: string | [string]; // Base config to extend } ``` -------------------------------- ### Commit Changes with Conventional Commits Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Commit your changes using the Conventional Commits specification. This ensures a consistent and readable project history. ```bash git commit -m "feat: add amazing feature" ``` -------------------------------- ### BenchResult Format Source: https://github.com/funish/toolchains/blob/main/packages/bench/README.md Details the structure of each result object returned by the `getResults` method. ```APIDOC ## BenchResult Format ### Description Each object in the array returned by `getResults()` represents the performance metrics for a single benchmarked task. ### Fields - `Task` (string): The name of the task. - `Total` (number): The total time taken for all iterations of the task. - `Average` (number): The average time taken per iteration. - `Fastest` (number): The fastest time recorded for a single iteration. - `Slowest` (number): The slowest time recorded for a single iteration. - `Median` (number): The median time of all iterations. - `Standard deviation` (number): The standard deviation of the iteration times. ### Example Output ``` ┌─────────┬────────────┬─────────────┬─────────────┬─────────────┬─────────────┬────────────────────┐ │ Task │ Total (ms) │ Average (ms)│ Fastest (ms)│ Slowest (ms)│ Median (ms) │ Standard deviation │ ├─────────┼────────────┼─────────────┼─────────────┼─────────────┼─────────────┼────────────────────┤ │ Task 1 │ 100.000 │ 0.100 │ 0.080 │ 0.150 │ 0.095 │ 0.015 │ └─────────┴────────────┴─────────────┴─────────────┴─────────────┴─────────────┴────────────────────┘ ``` ``` -------------------------------- ### Fix Linting Issues Source: https://github.com/funish/toolchains/blob/main/CONTRIBUTING.md Automatically fix common linting issues in the project. This command attempts to resolve style violations and minor errors. ```bash pnpm lint:fix ``` -------------------------------- ### bumpVersion Source: https://github.com/funish/toolchains/blob/main/packages/bump/README.md Bumps the version of a package according to semver rules. It can be used to increment stable or prerelease versions, with options for specifying the release type and prerelease tag. ```APIDOC ## bumpVersion(options?) ### Description Bumps the version of a package according to semver rules. ### Parameters #### Options - `path` (string) - Optional - Path to package directory (default: current directory) - `release` (ReleaseType) - Optional - Type of version bump (default: "prerelease") - `tag` (string) - Optional - Tag for prerelease versions (default: "edge") ``` -------------------------------- ### stagedLint Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Runs linters on files that are currently staged in your version control system. This is useful for ensuring code quality before committing. ```APIDOC ## stagedLint(config?) ### Description Runs linters on staged files. ### Parameters #### Path Parameters - `config` (object) - Optional - Configuration object mapping file patterns to linter commands. ### Request Example ```ts await stagedLint({ "*.ts": "eslint --fix", }); ``` ``` -------------------------------- ### Commit Message Configuration Schema Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Schema for validating commit messages against Conventional Commits. Allows configuration of type, scope, description, and body rules. ```typescript { commitMsg: { type?: { enum?: string[] // Allowed types (e.g., ['feat', 'fix', 'docs']) rules?: string[] // Validation rules }, scope?: { rules?: string[] // Validation rules }, description?: { rules?: string[] // Validation rules }, body?: { rules?: string[] // Validation rules } } } ``` -------------------------------- ### Define Commit Message Linting Rules Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Configures commit message linting to enforce specific commit types. ```typescript await commitMsgLint({ type: { enum: ["feat", "fix"] }, }); ``` -------------------------------- ### commitMsgLint Source: https://github.com/funish/toolchains/blob/main/packages/lint/README.md Validates commit messages against a defined set of rules. It can be configured to enforce specific commit message formats. ```APIDOC ## commitMsgLint(config?) ### Description Validates commit messages against rules. ### Parameters #### Path Parameters - `config` (object) - Optional - Configuration object for commit message linting. - `type` (object) - Optional - Configuration for commit message types. - `enum` (array of strings) - Required - Allowed commit message types (e.g., ["feat", "fix"]) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.