├── .bumpedrc ├── .editorconfig ├── .gitattributes ├── .github └── dependabot.yml ├── .gitignore ├── .npmignore ├── .npmrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── bin ├── help.txt └── index.js ├── package.json └── test ├── index.js └── mocha.opts /.bumpedrc: -------------------------------------------------------------------------------- 1 | files: [ 2 | 'package.json' 3 | ] 4 | 5 | plugins: 6 | 7 | prerelease: 8 | 9 | 'Linting config files': 10 | plugin: 'bumped-finepack' 11 | 12 | postrelease: 13 | 14 | 'Generating CHANGELOG file': 15 | plugin: 'bumped-changelog' 16 | 17 | 'Commiting new version': 18 | plugin: 'bumped-terminal' 19 | command: 'git add CHANGELOG.md package.json && git commit -m "Release $newVersion"' 20 | 21 | 'Detecting problems before publish': 22 | plugin: 'bumped-terminal' 23 | command: 'git-dirty && npm test' 24 | 25 | 'Publishing tag at GitHub': 26 | plugin: 'bumped-terminal' 27 | command: 'git tag $newVersion && git push && git push --tags' 28 | 29 | 'Publishing at NPM': 30 | plugin: 'bumped-terminal' 31 | command: 'npm publish' 32 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | max_line_length = 100 13 | indent_brace_style = 1TBS 14 | spaces_around_operators = true 15 | quote_type = auto 16 | 17 | [package.json] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [*.md] 22 | trim_trailing_whitespace = false 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | # Check for updates to GitHub Actions every weekday 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ############################ 2 | # npm 3 | ############################ 4 | node_modules 5 | npm-debug.log 6 | 7 | ############################ 8 | # tmp, editor & OS files 9 | ############################ 10 | .tmp 11 | *.swo 12 | *.swp 13 | *.swn 14 | *.swm 15 | .DS_Store 16 | *# 17 | *~ 18 | .idea 19 | *sublime* 20 | nbproject 21 | 22 | ############################ 23 | # Tests 24 | ############################ 25 | testApp 26 | coverage 27 | .nyc_output 28 | 29 | ############################ 30 | # Other 31 | ############################ 32 | .node_history 33 | .envrc 34 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .project 3 | *.sublime-* 4 | .DS_Store 5 | *.seed 6 | *.log 7 | *.csv 8 | *.dat 9 | *.out 10 | *.pid 11 | *.swp 12 | *.swo 13 | node_modules 14 | coverage 15 | *.tgz 16 | *.xml 17 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | unsafe-perm=true 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | stages: 4 | - Test 5 | - name: Release 6 | if: commit_message !~ /(release|no-release)/ 7 | 8 | jobs: 9 | include: 10 | - stage: Test 11 | node_js: 12 | - lts/* 13 | - node 14 | after_success: npm run coverage || exit 0 15 | - stage: Release 16 | node_js: "lts/*" 17 | install: npm install --no-package-lock 18 | before_deploy: 19 | - git config user.email ${GITHUB_EMAIL:-"travis@travis-ci.org"} 20 | - git config user.name ${GITHUB_USER:-"Travis CI"} 21 | - git remote set-url origin https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git 22 | deploy: 23 | skip_cleanup: true 24 | provider: script 25 | script: npm run release 26 | on: 27 | branch: master 28 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [1.1.17](https://github.com/kikobeats/regexgen-cli/compare/v1.1.16...v1.1.17) (2020-12-25) 6 | 7 | ### [1.1.16](https://github.com/kikobeats/regexgen-cli/compare/v1.1.15...v1.1.16) (2020-10-30) 8 | 9 | ### [1.1.15](https://github.com/kikobeats/regexgen-cli/compare/v1.1.14...v1.1.15) (2020-10-12) 10 | 11 | ### [1.1.14](https://github.com/kikobeats/regexgen-cli/compare/v1.1.13...v1.1.14) (2020-08-11) 12 | 13 | ### [1.1.13](https://github.com/kikobeats/regexgen-cli/compare/v1.1.12...v1.1.13) (2020-05-13) 14 | 15 | ### [1.1.12](https://github.com/kikobeats/regexgen-cli/compare/v1.1.11...v1.1.12) (2020-05-07) 16 | 17 | ### [1.1.11](https://github.com/kikobeats/regexgen-cli/compare/v1.1.10...v1.1.11) (2020-03-20) 18 | 19 | ### [1.1.10](https://github.com/kikobeats/regexgen-cli/compare/v1.1.8...v1.1.10) (2020-02-17) 20 | 21 | ### [1.1.9](https://github.com/kikobeats/regexgen-cli/compare/v1.1.8...v1.1.9) (2020-01-20) 22 | 23 | ### [1.1.8](https://github.com/kikobeats/regexgen-cli/compare/v1.1.7...v1.1.8) (2019-06-19) 24 | 25 | 26 | ### Build System 27 | 28 | * update travis ([ba04f84](https://github.com/kikobeats/regexgen-cli/commit/ba04f84)) 29 | 30 | 31 | 32 | ### [1.1.7](https://github.com/kikobeats/regexgen-cli/compare/v1.1.6...v1.1.7) (2019-05-20) 33 | 34 | 35 | ### Bug Fixes 36 | 37 | * **package:** update update-notifier to version 2.6.0 ([316c5fa](https://github.com/kikobeats/regexgen-cli/commit/316c5fa)) 38 | 39 | 40 | ### Build System 41 | 42 | * change git-authors-cli position ([4fa9f51](https://github.com/kikobeats/regexgen-cli/commit/4fa9f51)) 43 | 44 | 45 | 46 | ## [1.1.6](https://github.com/kikobeats/regexgen-cli/compare/v1.1.5...v1.1.6) (2019-04-15) 47 | 48 | 49 | ### Bug Fixes 50 | 51 | * **package:** update get-stdin to version 7.0.0 ([c644a64](https://github.com/kikobeats/regexgen-cli/commit/c644a64)) 52 | 53 | 54 | 55 | 56 | ## 1.1.5 (2018-10-28) 57 | 58 | 59 | ### Bug Fixes 60 | 61 | * **package:** update get-stdin to version 6.0.0 ([fc85834](https://github.com/kikobeats/regexgen-cli/commit/fc85834)) 62 | * **package:** update meow to version 4.0.0 ([bfc54d5](https://github.com/kikobeats/regexgen-cli/commit/bfc54d5)) 63 | * **package:** update meow to version 5.0.0 ([bded669](https://github.com/kikobeats/regexgen-cli/commit/bded669)) 64 | * **package:** update regexgen to version 1.3.0 ([1e3d181](https://github.com/kikobeats/regexgen-cli/commit/1e3d181)) 65 | * **package:** update update-notifier to version 2.2.0 ([e3f6738](https://github.com/kikobeats/regexgen-cli/commit/e3f6738)) 66 | * **package:** update update-notifier to version 2.3.0 ([8ae7129](https://github.com/kikobeats/regexgen-cli/commit/8ae7129)) 67 | * **package:** update update-notifier to version 2.4.0 ([9734f73](https://github.com/kikobeats/regexgen-cli/commit/9734f73)) 68 | * **package:** update update-notifier to version 2.5.0 ([f25b9e7](https://github.com/kikobeats/regexgen-cli/commit/f25b9e7)) 69 | * automate workflow ([6b13355](https://github.com/kikobeats/regexgen-cli/commit/6b13355)) 70 | * linter ([074f876](https://github.com/kikobeats/regexgen-cli/commit/074f876)) 71 | 72 | 73 | 74 | 75 | ## 1.1.4 (2017-04-23) 76 | 77 | 78 | 79 | 80 | ## 1.1.3 (2017-04-22) 81 | 82 | 83 | 84 | 85 | ## 1.1.2 (2017-04-16) 86 | 87 | 88 | 89 | 90 | ## 1.1.1 (2017-03-19) 91 | 92 | 93 | ### Bug Fixes 94 | 95 | * **package:** update update-notifier to version 2.0.0 ([9d06748](https://github.com/kikobeats/regexgen-cli/commit/9d06748)) 96 | 97 | 98 | 99 | 100 | # 1.1.0 (2016-12-22) 101 | 102 | 103 | ### Bug Fixes 104 | 105 | * **package:** update regexgen to version 1.2.0 ([a98ad15](https://github.com/kikobeats/regexgen-cli/commit/a98ad15)) 106 | 107 | 108 | 109 | 110 | # 1.0.0 (2016-12-22) 111 | 112 | 113 | 114 | 115 | ## 1.1.4 (2017-04-23) 116 | 117 | * Use strip-eof dep for clean the EOF ([9e1cd1e](https://github.com/kikobeats/regexgen-cli/commit/9e1cd1e)) 118 | 119 | 120 | 121 | 122 | ## 1.1.3 (2017-04-22) 123 | 124 | * Fix test ([5814a32](https://github.com/kikobeats/regexgen-cli/commit/5814a32)) 125 | * Improve read from stdin ([ae69c61](https://github.com/kikobeats/regexgen-cli/commit/ae69c61)) 126 | 127 | 128 | 129 | 130 | ## 1.1.2 (2017-04-16) 131 | 132 | * Update deps ([06afd2d](https://github.com/kikobeats/regexgen-cli/commit/06afd2d)) 133 | 134 | 135 | 136 | 137 | ## 1.1.1 (2017-03-19) 138 | 139 | * Fix linter ([c3b90f9](https://github.com/kikobeats/regexgen-cli/commit/c3b90f9)) 140 | * Update command help ([d3139f9](https://github.com/kikobeats/regexgen-cli/commit/d3139f9)) 141 | * chore(package): update update-notifier to version 2.1.0 ([c59ddcb](https://github.com/kikobeats/regexgen-cli/commit/c59ddcb)) 142 | * fix(package): update update-notifier to version 2.0.0 ([9d06748](https://github.com/kikobeats/regexgen-cli/commit/9d06748)) 143 | 144 | 145 | 146 | 147 | # 1.1.0 (2016-12-22) 148 | 149 | * Add flags support ([a0b9ec0](https://github.com/kikobeats/regexgen-cli/commit/a0b9ec0)) 150 | * fix(package): update regexgen to version 1.2.0 ([a98ad15](https://github.com/kikobeats/regexgen-cli/commit/a98ad15)) 151 | 152 | 153 | 154 | 155 | # 1.0.0 (2016-12-22) 156 | 157 | * Avoid nodeify dep ([1abf208](https://github.com/kikobeats/regexgen-cli/commit/1abf208)) 158 | * Drop node 0.12 support ([b5730dd](https://github.com/kikobeats/regexgen-cli/commit/b5730dd)) 159 | * First commit ([2fe2762](https://github.com/kikobeats/regexgen-cli/commit/2fe2762)) 160 | * Fix linter ([adef075](https://github.com/kikobeats/regexgen-cli/commit/adef075)) 161 | * Setup node version ([6f79617](https://github.com/kikobeats/regexgen-cli/commit/6f79617)) 162 | * Update docs ([7cbe46b](https://github.com/kikobeats/regexgen-cli/commit/7cbe46b)) 163 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2016 Kiko Beats (https://github.com/Kikobeats) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # regexgen-cli 2 | 3 | ![Last version](https://img.shields.io/github/tag/Kikobeats/regexgen-cli.svg?style=flat-square) 4 | [![Build Status](https://img.shields.io/travis/Kikobeats/regexgen-cli/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/regexgen-cli) 5 | [![Coverage Status](https://img.shields.io/coveralls/Kikobeats/regexgen-cli.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/regexgen-cli) 6 | [![Dependency status](https://img.shields.io/david/Kikobeats/regexgen-cli.svg?style=flat-square)](https://david-dm.org/Kikobeats/regexgen-cli) 7 | [![Dev Dependencies Status](https://img.shields.io/david/dev/Kikobeats/regexgen-cli.svg?style=flat-square)](https://david-dm.org/Kikobeats/regexgen-cli#info=devDependencies) 8 | [![NPM Status](https://img.shields.io/npm/dm/regexgen-cli.svg?style=flat-square)](https://www.npmjs.org/package/regexgen-cli) 9 | [![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats) 10 | 11 | > CLI interface for [regexgen](https://github.com/devongovett/regexgen). It Generates regular expressions that match a set of strings. 12 | 13 | ## Install 14 | 15 | ```bash 16 | $ npm install regexgen-cli --global 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```bash 22 | $ regexgen --help 23 | 24 | Generates regular expressions that match a set of strings. 25 | 26 | Usage 27 | $ regexgen [-gimuy] string1 string2 string3... 28 | 29 | Examples 30 | $ regexgen foobar foobaz foozap fooza 31 | $ jq '.keywords' package.json | regexgen 32 | ``` 33 | 34 | ## Related 35 | 36 | - [randexp.js](https://github.com/fent/randexp.js) – Generate a random string that matches a given RegExp. 37 | 38 | ## License 39 | 40 | MIT © [Kiko Beats](https://github.com/Kikobeats). 41 | -------------------------------------------------------------------------------- /bin/help.txt: -------------------------------------------------------------------------------- 1 | Usage 2 | $ regexgen [-gimuy] string1 string2 string3... 3 | 4 | Examples 5 | $ regexgen foobar foobaz foozap fooza 6 | $ jq '.keywords' package.json | regexgen 7 | -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | const pkg = require('../package.json') 5 | const regexgen = require('regexgen') 6 | const getStdin = require('get-stdin') 7 | const stripEof = require('strip-final-newline') 8 | const path = require('path') 9 | 10 | require('update-notifier')({ pkg }).notify() 11 | 12 | const cli = require('meow')({ 13 | pkg: pkg, 14 | help: require('fs').readFileSync(path.join(__dirname, 'help.txt'), 'utf8') 15 | }) 16 | 17 | function parseJSON (str) { 18 | try { 19 | return JSON.parse(str) 20 | } catch (err) {} 21 | } 22 | 23 | getStdin() 24 | .then(stripEof) 25 | .then(stdin => parseJSON(stdin) || stdin || cli.input) 26 | .then(input => [].concat(input)) 27 | .then(input => { 28 | if (!input.length) { 29 | cli.showHelp() 30 | process.exit(1) 31 | } 32 | 33 | const flags = Object.keys(cli.flags).join('') 34 | const output = regexgen([].concat(input), flags) 35 | 36 | process.stdout.write(output.toString()) 37 | process.exit() 38 | }) 39 | .catch(error => { 40 | console.log(error) 41 | process.exit(1) 42 | }) 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "regexgen-cli", 3 | "description": "Generates regular expressions that match a set of strings.", 4 | "homepage": "https://github.com/Kikobeats/regexgen-cli", 5 | "version": "1.1.17", 6 | "main": "index.js", 7 | "bin": { 8 | "regexgen": "bin/index.js" 9 | }, 10 | "author": { 11 | "email": "josefrancisco.verdu@gmail.com", 12 | "name": "Kiko Beats", 13 | "url": "https://github.com/Kikobeats" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/kikobeats/regexgen-cli.git" 18 | }, 19 | "bugs": { 20 | "url": "https://github.com/Kikobeats/regexgen-cli/issues" 21 | }, 22 | "keywords": [ 23 | "cli", 24 | "regexgen" 25 | ], 26 | "dependencies": { 27 | "get-stdin": "~8.0.0", 28 | "meow": "~9.0.0", 29 | "regexgen": "~1.3.0", 30 | "strip-final-newline": "~2.0.0", 31 | "update-notifier": "~5.1.0" 32 | }, 33 | "devDependencies": { 34 | "@commitlint/cli": "latest", 35 | "@commitlint/config-conventional": "latest", 36 | "ci-publish": "latest", 37 | "conventional-github-releaser": "latest", 38 | "coveralls": "latest", 39 | "finepack": "latest", 40 | "git-authors-cli": "latest", 41 | "git-dirty": "latest", 42 | "simple-git-hooks": "latest", 43 | "nano-staged": "latest", 44 | "mocha": "latest", 45 | "npm-check-updates": "latest", 46 | "nyc": "latest", 47 | "should": "latest", 48 | "standard": "latest", 49 | "standard-markdown": "latest", 50 | "standard-version": "latest" 51 | }, 52 | "engines": { 53 | "node": ">= 6" 54 | }, 55 | "files": [ 56 | "bin" 57 | ], 58 | "scripts": { 59 | "clean": "rm -rf node_modules", 60 | "coverage": "nyc report --reporter=text-lcov | coveralls", 61 | "lint": "standard-markdown && standard", 62 | "postrelease": "npm run release:tags && npm run release:github && ci-publish", 63 | "prerelease": "npm run update:check", 64 | "pretest": "npm run lint", 65 | "release": "git-authors-cli && git add package.json && standard-version -a", 66 | "release:github": "conventional-github-releaser -p angular", 67 | "release:tags": "git push --follow-tags origin HEAD:master", 68 | "test": "nyc mocha", 69 | "update": "ncu -a", 70 | "update:check": "ncu -- --error-level 2" 71 | }, 72 | "preferGlobal": true, 73 | "license": "MIT", 74 | "commitlint": { 75 | "extends": [ 76 | "@commitlint/config-conventional" 77 | ] 78 | }, 79 | "simple-git-hooks": { 80 | "commit-msg": "npx commitlint --edit", 81 | "pre-commit": "npx nano-staged" 82 | }, 83 | "nano-staged": { 84 | "package.json": [ 85 | "finepack", 86 | "git add" 87 | ] 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 3 | 'use strict' 4 | 5 | const exec = require('child_process').execFileSync 6 | const path = require('path') 7 | 8 | const cli = path.resolve('./bin/index.js') 9 | 10 | require('should') 11 | 12 | describe('regexgen-cli', function () { 13 | it('get input from CLI', function () { 14 | const output = exec(cli, ['foo', 'bar'], { encoding: 'utf8' }) 15 | output.should.be.equal('/bar|foo/') 16 | }) 17 | 18 | it('get input from stdin', function () { 19 | const output = exec(cli, { encoding: 'utf8', input: 'foobar\n' }) 20 | output.should.be.equal('/foobar/') 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --require should 2 | --reporter spec 3 | --timeout 120000 4 | --slow 300 5 | --bail 6 | --recursive 7 | --------------------------------------------------------------------------------