{"id":13902983,"url":"https://github.com/jr-codes/cli-rewire","last_synced_at":"2025-05-12T22:32:09.006Z","repository":{"id":38191895,"uuid":"255151733","full_name":"jr-codes/cli-rewire","owner":"jr-codes","description":"Make a CLI by rewiring other CLIs","archived":false,"fork":false,"pushed_at":"2024-10-25T19:33:35.000Z","size":1300,"stargazers_count":5,"open_issues_count":12,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-06T19:07:54.744Z","etag":null,"topics":["args","arguments","binary","cli","clis","command","config","configuration","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jr-codes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-12T19:07:55.000Z","updated_at":"2024-05-15T15:32:18.000Z","dependencies_parsed_at":"2023-02-06T12:30:41.453Z","dependency_job_id":"8f943561-217c-42da-9bf1-0ed3166585ae","html_url":"https://github.com/jr-codes/cli-rewire","commit_stats":{"total_commits":125,"total_committers":5,"mean_commits":25.0,"dds":0.512,"last_synced_commit":"6b6d185af64e70c9d9c8491ab0595f9fafaef096"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-codes%2Fcli-rewire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-codes%2Fcli-rewire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-codes%2Fcli-rewire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr-codes%2Fcli-rewire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jr-codes","download_url":"https://codeload.github.com/jr-codes/cli-rewire/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224517383,"owners_count":17324407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["args","arguments","binary","cli","clis","command","config","configuration","javascript","nodejs"],"created_at":"2024-08-06T22:01:32.435Z","updated_at":"2024-11-18T10:14:07.864Z","avatar_url":"https://github.com/jr-codes.png","language":"JavaScript","readme":"# cli-rewire\n\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![npm](https://img.shields.io/npm/v/cli-rewire)](https://www.npmjs.com/package/cli-rewire)\n[![CI](https://github.com/jr-codes/cli-rewire/workflows/CI/badge.svg)](https://github.com/jr-codes/cli-rewire/actions)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jr-codes/cli-rewire/blob/master/LICENSE)\n[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/jr-codes/cli-rewire.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/jr-codes/cli-rewire/context:javascript)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/jr-codes/cli-rewire.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/jr-codes/cli-rewire/alerts/)\n\nMake a CLI by rewiring other CLIs.\n\nCLI Rewire is a tool that lets you take existing CLIs, reconfigure their options, and combine them together to form new commands. Using CLI Rewire, you can create CLI wrappers and toolchains like [Create React App's react-scripts](https://github.com/facebook/create-react-app/tree/master/packages/react-scripts), [Standard](https://github.com/standard/standard), [XO](https://github.com/xojs/xo), and [kcd-scripts](https://github.com/kentcdodds/kcd-scripts).\n\nCLI Rewire internally uses [yargs](https://github.com/yargs/yargs-parser) to reconfigure args, [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) to override configs, and [execa](https://github.com/sindresorhus/execa) to run CLIs.\n\n## 🔧 Install\n\n```sh\nnpm install cli-rewire\n```\n\n## 📝 Usage\n\nFirst, `npm install` each CLI you want to rewire into you project.\n\nThen, make a script file for each CLI. For example, if you wanted to rewire [Jest](https://github.com/facebook/jest) to use a custom config by default:\n\n```js\n// jest.js\n\nconst { getConfigPath, rewire } = require('cli-rewire')\n\n// Uses yargs-parser to rewire args; see yargs-parser docs for options\nconst runJest = rewire({\n  alias: {\n    // Capture -c and --config\n    config: 'c'\n  },\n  default: {\n    // If --config or -c isn't provided, find the user's Jest config.\n    // If not found, use /path/to/my/jest.config.js.\n    config: getConfigPath('jest', {}, '/path/to/my/jest.config.js'))\n  }\n})\n\n// Run Jest CLI\nrunJest()\n```\n\nAfter making your scripts, wire them together in your CLI's bin file.\n\n```js\n// my-cli.js\n\n#!/usr/bin/env node\n\nconst { wire } = require('cli-rewire')\n\n// Get script paths\nconst scripts = [\n  './scripts/babel.js',\n  './scripts/prettier.js',\n  './scripts/jest.js',\n  './scripts/webpack.js'\n].map(require.resolve)\n\n// Wire up the scripts together\nconst runCLI = wire(scripts, {\n  // Combine CLI commands to form your own custom commands\n  commands: {\n    format: [\n      'prettier --write .'\n    ],\n    'test-ci': [\n      'prettier --check .',\n      'jest --ci'\n    ]\n  }\n})\n\nrunCLI()\n```\n\nIf this were published as a `my-cli` package, these would be a few possible commands:\n\n- `my-cli babel my-file.js`\n- `my-cli prettier --check \"src/**/*.js\"`\n- `my-cli jest --silent`\n- `my-cli format`\n- `my-cli test-ci --verbose`\n\nUsers of your CLI would be able to run any of the rewired tools, as well as any custom commands you specified.\n","funding_links":[],"categories":["cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjr-codes%2Fcli-rewire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjr-codes%2Fcli-rewire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjr-codes%2Fcli-rewire/lists"}