{"id":20125693,"url":"https://github.com/a-nozeret/prompt-run","last_synced_at":"2025-05-06T17:34:36.895Z","repository":{"id":35024190,"uuid":"197805052","full_name":"a-nozeret/prompt-run","owner":"a-nozeret","description":"🏃 Run commands based on user input, dynamically generating environment variables, arguments, flags","archived":false,"fork":false,"pushed_at":"2023-01-04T04:51:06.000Z","size":1527,"stargazers_count":2,"open_issues_count":14,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-22T17:14:38.281Z","etag":null,"topics":["cli","command","env","environment-variables","flags","nodejs","npm","prompt","run","yarn"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/prompt-run","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/a-nozeret.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-19T16:05:17.000Z","updated_at":"2020-04-07T14:58:18.000Z","dependencies_parsed_at":"2023-01-15T12:15:08.931Z","dependency_job_id":null,"html_url":"https://github.com/a-nozeret/prompt-run","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-nozeret%2Fprompt-run","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-nozeret%2Fprompt-run/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-nozeret%2Fprompt-run/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-nozeret%2Fprompt-run/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a-nozeret","download_url":"https://codeload.github.com/a-nozeret/prompt-run/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252734414,"owners_count":21796015,"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":["cli","command","env","environment-variables","flags","nodejs","npm","prompt","run","yarn"],"created_at":"2024-11-13T20:09:12.149Z","updated_at":"2025-05-06T17:34:36.549Z","avatar_url":"https://github.com/a-nozeret.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e🏃 prompt-run\u003c/h1\u003e\n  \n  [![NPM](https://img.shields.io/npm/v/prompt-run.svg?logo=npm)](https://www.npmjs.com/package/prompt-run)\n  [![Travis Build](https://img.shields.io/travis/a-nozeret/prompt-run/master.svg?logo=travis-ci)](https://travis-ci.org/a-nozeret/prompt-run)\n  [![Codecov Coverage](https://img.shields.io/codecov/c/github/a-nozeret/prompt-run/master.svg?logo=codecov)](https://codecov.io/gh/a-nozeret/prompt-run/)\n  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-airbnb-brightgreen.svg)](https://github.com/airbnb/javascript)\n  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\n\u003e Run commands based on user input, dynamically generating environment variables, arguments, flags\n\n## Getting started\n\n```sh\nyarn add -D prompt-run\n```\n```sh\nprompt-run [options] [command]\n```\n\n## API\n**Note:** Check the [**Inquirer** documentation](https://github.com/SBoudrias/Inquirer.js#objects) for full details on how to create question objects.\n\n### CLI\n```\n  Usage\n    $ prompt-run [options] [command]\n\n  Options\n    --config, -c \u003cfilename\u003e  Path to questions config file\n    --prefix, -p \u003cprefix\u003e    Prompt scripts with the provided prefix\n    --dry-run                No execution after generating the command\n    --silent, -s             Disable output of generated command\n```\n### Module\n```js\nconst promptRun = require('prompt-run')\n\npromptRun({\n  command: 'yarn',\n  options: {},\n  questions: {\n    env: [],\n    args: [],\n  },\n}).then((childProcess) =\u003e {})\n```\n\n#### Command\nThe base used to run along the generated command.\n\n*Default*: `yarn` (or `npm run` if your project doesn't contain a `yarn.lock` file)\n\nIt can be anything which is not needed to prompt.\n\n#### Options\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| config | string | \"prompt-run.js\"| Path to questions config file |\n| prefix | string | *undefined* | Prompt existing scripts starting with the given prefix |\n| dryRun | boolean | false | No execution after generating the command |\n| silent | boolean | false | Disable output of the generated command |\n\n#### Questions\n##### Questions config file\n```js\nmodule.exports = () =\u003e ({\n  env: [\n    // Question objects\n  ],\n  args: [\n    // Question objects\n  ],\n})\n```\nThe config is divided into:\n+ `env`: Node Environment variables to prompt\n+ `args`: Arguments/flags prompted. Anything coming after the base command.\n\n##### Questions object\nCheck the [**Inquirer** documentation](https://github.com/SBoudrias/Inquirer.js#objects) for full details on how to create question objects.\n\n## Examples\n#### 1. CLI\nWith a defined config of questions\n\n\u003cimg src=\"https://github.com/a-nozeret/prompt-run/raw/master/docs/example-1-cli.gif?raw=true\" alt=\"example-1-cli\" width=\"550\"/\u003e\n\n*questions.js*\n```js\nmodule.exports = () =\u003e ({\n  env: [\n    {\n      type: 'list',\n      name: 'NODE_ENV',\n      choices: ['production', 'development'],\n    },\n    {\n      name: 'SECRET_KEY',\n    },\n  ],\n  args: [\n    {\n      type: 'confirm',\n      name: '--watch',\n      default: false,\n    },\n    {\n      name: '--log-level',\n      type: 'list',\n      choices: ['error', 'warning'],\n    },\n  ],\n})\n```\n*Run*\n```sh\nprompt-run -c questions.js yarn start\n```\n*Example output / command executed*\n```sh\n$ NODE_ENV=development SECRET_KEY=1234 yarn start --watch --log-level warning\n```\n\n#### 2. Scripts\nAs a node module in scripts\n\n\u003cimg src=\"https://github.com/a-nozeret/prompt-run/raw/master/docs/example-2-script.gif?raw=true\" alt=\"example-2-script\" width=\"550\"/\u003e\n\n*dependency-info.js*\n```js\nconst promptRun = require('prompt-run')\nconst packageJson = require('./package.json')\n\nconst dependencies = Object.keys(packageJson.dependencies)\nconst fields = ['description', 'readme', 'version', 'dependencies']\n\npromptRun({\n  command: 'yarn info',\n  questions: {\n    args: [\n      {\n        type: 'list',\n        name: 'dependency',\n        message: 'Select a dependency',\n        choices: dependencies,\n      },\n      {\n        type: 'list',\n        name: 'field',\n        message: 'Select a field to print',\n        choices: fields,\n      },\n    ],\n  },\n}).then((childProcess) =\u003e {\n  childProcess.on('close', () =\u003e {\n    console.log('\\nFinished with the child process!')\n  })\n})\n```\n*Run*\n```sh\nnode dependency-info.js\n```\n\n#### 3. Prefix shortcut\nPrompt existing scripts starting with a given prefix\n\n\u003cimg src=\"https://github.com/a-nozeret/prompt-run/raw/master/docs/example-3-prefix.gif?raw=true\" alt=\"example-3-prefix\" width=\"550\"/\u003e\n\n*package.json*\n```json\n{\n  \"scripts\": {\n    \"start:dev\": \"...\",\n    \"start:prod\": \"...\",\n    \"start:docker\": \"...\"\n  }\n}\n```\n*Run*\n```sh\nprompt-run -p start\n```\n\n## Development\n```sh\nyarn\nyarn link\n...\nyarn test --coverage\nyarn lint\nyarn commit\nyarn unlink\n```\n### Publish / release\n```sh\nyarn release\ngit push --follow-tags origin master\n```\n[Github Action](https://github.com/a-nozeret/prompt-run/blob/master/.github/workflows/npmpublish.yml) will be triggered, publishing the package to NPM\n\n\n### Todo list\n+ Bugs:\n  + Inquirer errors do not appear directly in CLI mode\n+ Configs should consist in promptRun Object argument\n+ feature: `$ prompt-run -env NODE_ENV yarn start` shortcut for question\n\n## License\n\nLicensed under the MIT License, Copyright © 2019-present Antoine Nozeret.\n\nSee [LICENSE](./LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-nozeret%2Fprompt-run","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-nozeret%2Fprompt-run","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-nozeret%2Fprompt-run/lists"}