From 33009ecd714b38354a415d538e17a0c15491ccc8 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Mon, 4 Sep 2023 16:22:41 -0500 Subject: [PATCH] Lint using prettier --- .all-contributorsrc | 91 +- .babelrc | 23 +- .codecov.yml | 2 +- .editorconfig | 2 +- .eslintrc.yaml | 101 +- .github/workflows/ci.yml | 3 +- .grenrc.js | 31 +- .jsdoc.conf.json | 44 +- .markdownlint.json | 6 +- .prettierignore | 1 + .prettierrc.json | 3 + .release-it.json | 18 +- CHANGELOG.md | 16 +- CONTRIBUTING.md | 3 +- README.md | 5 +- _postinstall.js | 34 +- github-release-notes.js | 2 +- gulpfile.js | 60 +- lib/_examples.js | 201 +- lib/_options.js | 364 +- lib/gren-changelog.js | 59 +- lib/gren-examples.js | 54 +- lib/gren-init.js | 83 +- lib/gren-release.js | 38 +- lib/gren.js | 35 +- lib/src/GitHubInfo.js | 190 +- lib/src/Gren.js | 2461 +-- lib/src/Program.js | 417 +- lib/src/_init.js | 410 +- lib/src/_template.js | 19 +- lib/src/_utils.js | 436 +- lib/src/templates.js | 19 +- package-lock.json | 30729 +++++++++++++++++----------------- package.json | 224 +- tasks/_generate-examples.js | 18 +- tasks/_generate-options.js | 35 +- test/GitHubInfo.spec.js | 69 +- test/Gren.spec.js | 1354 +- test/Program.spec.js | 272 +- test/_options.spec.js | 70 +- test/_template.spec.js | 34 +- test/_utils.spec.js | 532 +- test/data/PRs.json | 98 +- test/data/issues.json | 452 +- test/data/tags.json | 106 +- 45 files changed, 19834 insertions(+), 19390 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.json diff --git a/.all-contributorsrc b/.all-contributorsrc index 57029ebd..5a427e20 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "contributors": [ @@ -10,192 +8,147 @@ "name": "Dan Klausner", "avatar_url": "https://avatars1.githubusercontent.com/u/2083539?v=4", "profile": "https://github.com/wellDan28", - "contributions": [ - "bug", - "code" - ] + "contributions": ["bug", "code"] }, { "login": "datitisev", "name": "David Sevilla Martín", "avatar_url": "https://avatars2.githubusercontent.com/u/6401250?v=4", "profile": "https://datitisev.me", - "contributions": [ - "doc" - ] + "contributions": ["doc"] }, { "login": "phun-ky", "name": "Alexander Vassbotn Røyne-Helgesen", "avatar_url": "https://avatars1.githubusercontent.com/u/1714029?v=4", "profile": "http://phun-ky.net", - "contributions": [ - "bug", - "code" - ] + "contributions": ["bug", "code"] }, { "login": "joaquin-corchero", "name": "Joaquin Corchero", "avatar_url": "https://avatars2.githubusercontent.com/u/6892214?v=4", "profile": "https://github.com/joaquin-corchero", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "durera", "name": "David Parker", "avatar_url": "https://avatars1.githubusercontent.com/u/4400618?v=4", "profile": "https://github.com/durera", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "mariotacke", "name": "Mario Tacke", "avatar_url": "https://avatars2.githubusercontent.com/u/4942019?v=4", "profile": "https://www.mariotacke.io", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "kyeah", "name": "Kevin Yeh", "avatar_url": "https://avatars1.githubusercontent.com/u/2308368?v=4", "profile": "http://kyeh.me", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "jackocnr", "name": "Jack O'Connor", "avatar_url": "https://avatars0.githubusercontent.com/u/1186883?v=4", "profile": "https://jackocnr.com", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "kstolte", "name": "Keith Stolte", "avatar_url": "https://avatars0.githubusercontent.com/u/20091146?v=4", "profile": "https://keithstolte.io", - "contributions": [ - "doc", - "design" - ] + "contributions": ["doc", "design"] }, { "login": "david-poindexter", "name": "David Poindexter", "avatar_url": "https://avatars2.githubusercontent.com/u/4568451?v=4", "profile": "http://www.nvisionative.com", - "contributions": [ - "doc" - ] + "contributions": ["doc"] }, { "login": "fthomas", "name": "Frank S. Thomas", "avatar_url": "https://avatars1.githubusercontent.com/u/141252?v=4", "profile": "https://github.com/fthomas", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "pawk", "name": "pawk", "avatar_url": "https://avatars1.githubusercontent.com/u/27773225?v=4", "profile": "https://github.com/pawk", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "Atry", "name": "Yang, Bo", "avatar_url": "https://avatars3.githubusercontent.com/u/601530?v=4", "profile": "https://www.yang-bo.com/", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "v1v", "name": "Victor Martinez", "avatar_url": "https://avatars2.githubusercontent.com/u/2871786?v=4", "profile": "https://github.com/v1v", - "contributions": [ - "doc" - ] + "contributions": ["doc"] }, { "login": "Tybot204", "name": "Tyler Hogan", "avatar_url": "https://avatars3.githubusercontent.com/u/7002601?v=4", "profile": "https://github.com/Tybot204", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "blairg23", "name": "Blair Gemmer", "avatar_url": "https://avatars0.githubusercontent.com/u/6225764?v=4", "profile": "http://blairgemmer.com", - "contributions": [ - "doc" - ] + "contributions": ["doc"] }, { "login": "lianghx-319", "name": "Han", "avatar_url": "https://avatars2.githubusercontent.com/u/27187946?v=4", "profile": "https://github.com/lianghx-319", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "donmahallem", "name": "donmahallem", "avatar_url": "https://avatars2.githubusercontent.com/u/4698322?v=4", "profile": "https://github.com/donmahallem", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "aelbozie", "name": "Ahmed", "avatar_url": "https://avatars3.githubusercontent.com/u/36151122?v=4", "profile": "https://github.com/aelbozie", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "monicarib", "name": "Mônica Ribeiro", "avatar_url": "https://avatars0.githubusercontent.com/u/7025960?v=4", "profile": "https://github.com/monicarib", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "viatrix", "name": "Tanya Bushenyova", "avatar_url": "https://avatars.githubusercontent.com/u/16937734?v=4", "profile": "https://github.com/viatrix", - "contributions": [ - "code" - ] + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/.babelrc b/.babelrc index 6fde81d9..03fb40b4 100644 --- a/.babelrc +++ b/.babelrc @@ -1,13 +1,10 @@ -{ - "presets": ["@babel/preset-env"], - "plugins": [ - "@babel/plugin-transform-runtime", - "@babel/plugin-proposal-object-rest-spread" - ], - "env": { - "test": { - "plugins": ["istanbul"] - } - }, - "targets": "node 14.0" -} +{ + "presets": ["@babel/preset-env"], + "plugins": ["@babel/plugin-transform-runtime", "@babel/plugin-proposal-object-rest-spread"], + "env": { + "test": { + "plugins": ["istanbul"] + } + }, + "targets": "node 14.0" +} diff --git a/.codecov.yml b/.codecov.yml index 622b3665..7966f407 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,2 +1,2 @@ codecov: - branch: master + branch: master diff --git a/.editorconfig b/.editorconfig index 201241fe..e6eb7377 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ root = true [*] indent_style = space -indent_size = 4 +indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 7c2c3538..63da4c86 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,61 +1,54 @@ parser: babel-eslint env: - node: true - mocha: true - es6: true + node: true + mocha: true + es6: true parserOptions: - ecmaVersion: 6 - sourceType: module - ecmaFeatures: - impliedStrict: true - allowImportExportEverywhere: false + ecmaVersion: 6 + sourceType: module + ecmaFeatures: + impliedStrict: true + allowImportExportEverywhere: false plugins: - - mocha - - babel + - mocha + - babel extends: - - semistandard + - prettier rules: - no-undef: 1 - no-unreachable: 1 - no-empty: error - array-callback-return: error - no-var: error - indent: - - error - - 4 - - SwitchCase: 1 - space-before-function-paren: - - error - - never - no-debugger: 0 - prefer-const: error - strict: error - no-template-curly-in-string: error - consistent-return: error - no-multiple-empty-lines: - - error - - max: 1 - maxBOF: 0 - no-lonely-if: error - new-parens: error - eol-last: error - no-array-constructor: error - arrow-body-style: - - error - - as-needed - prefer-arrow-callback: - - error - - allowNamedFunctions: true - prefer-destructuring: - - error - - object: true - array: false - prefer-spread: error - prefer-rest-params: error - prefer-promise-reject-errors: 0 - valid-typeof: 0 + no-undef: 1 + no-unreachable: 1 + no-empty: error + array-callback-return: error + no-var: error + no-debugger: 0 + prefer-const: error + strict: error + no-template-curly-in-string: error + consistent-return: error + no-multiple-empty-lines: + - error + - max: 1 + maxBOF: 0 + no-lonely-if: error + new-parens: error + eol-last: error + no-array-constructor: error + arrow-body-style: + - error + - as-needed + prefer-arrow-callback: + - error + - allowNamedFunctions: true + prefer-destructuring: + - error + - object: true + array: false + prefer-spread: error + prefer-rest-params: error + prefer-promise-reject-errors: 0 + valid-typeof: 0 overrides: - - files: - - "*.spec.js" - env: - mocha: true + - files: + - "*.spec.js" + env: + mocha: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b77ad639..7825e174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: experimental: true runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} - + steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }} @@ -36,4 +36,3 @@ jobs: - run: npm ci - run: npm test - run: npm run build - diff --git a/.grenrc.js b/.grenrc.js index a1caa108..1ca10b24 100644 --- a/.grenrc.js +++ b/.grenrc.js @@ -1,20 +1,15 @@ module.exports = { - "dataSource": "commits", - "tags": "all", - "prefix": "v", - "ignoreIssuesWith": [ - "duplicate", - "wontfix", - "invalid", - "help wanted" - ], - username: "cjbarth", - repo: "github-release-notes", - "template": { - "issue": "- [{{text}}]({{url}}) {{name}}" - }, - "groupBy": { - "Enhancements:": ["enhancement", "internal"], - "Bug Fixes:": ["bug"] - } + dataSource: "commits", + tags: "all", + prefix: "v", + ignoreIssuesWith: ["duplicate", "wontfix", "invalid", "help wanted"], + username: "cjbarth", + repo: "github-release-notes", + template: { + issue: "- [{{text}}]({{url}}) {{name}}", + }, + groupBy: { + "Enhancements:": ["enhancement", "internal"], + "Bug Fixes:": ["bug"], + }, }; diff --git a/.jsdoc.conf.json b/.jsdoc.conf.json index e377cd13..1d33775b 100644 --- a/.jsdoc.conf.json +++ b/.jsdoc.conf.json @@ -1,25 +1,23 @@ { - "tags": { - "allowUnknownTags": true, - "dictionaries": ["jsdoc"] - }, - "source": { - "include": ["lib/src", "package.json", "CHANGELOG.md"], - "includePattern": ".js$", - "excludePattern": "(node_modules/|docs)" - }, - "plugins": [ - "plugins/markdown" - ], - "templates": { - "cleverLinks": false, - "monospaceLinks": true, - "useLongnameInNav": false - }, - "opts": { - "destination": "./docs/", - "encoding": "utf8", - "private": true, - "template": "./node_modules/minami" - } + "tags": { + "allowUnknownTags": true, + "dictionaries": ["jsdoc"] + }, + "source": { + "include": ["lib/src", "package.json", "CHANGELOG.md"], + "includePattern": ".js$", + "excludePattern": "(node_modules/|docs)" + }, + "plugins": ["plugins/markdown"], + "templates": { + "cleverLinks": false, + "monospaceLinks": true, + "useLongnameInNav": false + }, + "opts": { + "destination": "./docs/", + "encoding": "utf8", + "private": true, + "template": "./node_modules/minami" + } } diff --git a/.markdownlint.json b/.markdownlint.json index 4a69db55..6cfbfd99 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,4 +1,4 @@ { - "MDO13:": false, - "MD024": false -} \ No newline at end of file + "MDO13:": false, + "MD024": false +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..d8f8d469 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +docs diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..de753c53 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,3 @@ +{ + "printWidth": 100 +} diff --git a/.release-it.json b/.release-it.json index 49378572..d22c49f8 100644 --- a/.release-it.json +++ b/.release-it.json @@ -1,9 +1,9 @@ -{ - "github": { - "release": true, - "releaseName": "v${version}" - }, - "hooks": { - "after:bump": "npm run changelog" - } -} +{ + "github": { + "release": true, + "releaseName": "v${version}" + }, + "hooks": { + "after:bump": "npm run changelog" + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c1a6bc..cc9817bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,7 +150,7 @@ ### Bug Fixes -- [#229](https://github.com/github-tools/github-release-notes/issues/229) The number of commits will be reduced by one when "--data-source=commits" +- [#229](https://github.com/github-tools/github-release-notes/issues/229) The number of commits will be reduced by one when "--data-source=commits" - [#162](https://github.com/github-tools/github-release-notes/issues/162) Change in artifact name - Gren no longer creates release notes! - [#134](https://github.com/github-tools/github-release-notes/issues/134) Sort tags by date before fetching release notes @@ -193,7 +193,7 @@ ## v0.14.1 (2017-12-08) -*No changelog for this release.* +_No changelog for this release._ --- @@ -237,7 +237,7 @@ ## v0.12.1 (2017-10-14) -*No changelog for this release.* +_No changelog for this release._ --- @@ -343,7 +343,7 @@ ## v0.3.3 (2017-03-14) -*No changelog for this release.* +_No changelog for this release._ --- @@ -422,22 +422,22 @@ ## v0.2.2 (2017-03-10) -*No changelog for this release.* +_No changelog for this release._ --- ## v0.3.0 (2017-03-10) -*No changelog for this release.* +_No changelog for this release._ --- ## v0.3.1 (2017-03-10) -*No changelog for this release.* +_No changelog for this release._ --- ## v0.3.2 (2017-03-10) -*No changelog for this release.* +_No changelog for this release._ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b05c8e8b..cb3ccb5e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,6 @@ ❤️ Thanks for contributing to this project. Following, you can find a couple of things to keep in mind before contributing to gren. - 1. [Issues](#issues) 2. [Commits](#commits) 3. [Branches](#branches) @@ -53,6 +52,7 @@ The commit history in a PR should not contain `Merge` commits and should be reba It's easier to review the PR, if you rebase your commits so that every commit represents a sub-piece of the development and can be independently reviewed or a clear list of the features on that branch. e.g. + ``` Closes #123 @@ -62,4 +62,3 @@ Here any further informations needed to the reviewer, e.g. run yarn before revie ### Checks Every PR has to be reviewed before can be merged in. - diff --git a/README.md b/README.md index e252fa28..5bd6e2fc 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,11 @@ [![Codecov](https://codecov.io/gh/github-tools/github-release-notes/branch/master/graph/badge.svg)](https://codecov.io/gh/github-tools/github-release-notes/branch/master) [![npm downloads](https://img.shields.io/npm/dm/github-release-notes.svg)](https://www.npmjs.com/package/github-release-notes) [![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/) + + [![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat-square)](#contributors-) + Updates: @@ -132,7 +135,7 @@ npm install github-release-notes -g ### Setup First, generate a `GitHub token`, _with **repo** scope_, at [this link](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). -Then add this line to `~/.bash_profile` (or `~/.zshrc`): +Then add this line to `~/.bash_profile` (or `~/.zshrc`): ```shell export GREN_GITHUB_TOKEN=your_token_here diff --git a/_postinstall.js b/_postinstall.js index 4e4151e2..df66bcf7 100644 --- a/_postinstall.js +++ b/_postinstall.js @@ -1,22 +1,32 @@ -const chalk = require('chalk'); +const chalk = require("chalk"); -process.stdout.write(chalk.white(` - ${chalk.yellow('| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |')} - ${chalk.blue(`🙏 Thanks for downloading ${chalk.green('gren')}`)} - ${chalk.yellow('| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |')} +process.stdout.write( + chalk.white(` + ${chalk.yellow("| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |")} + ${chalk.blue(`🙏 Thanks for downloading ${chalk.green("gren")}`)} + ${chalk.yellow("| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |")} Before you start: - 1. Generate a token with ${chalk.yellow('repo scope')} at this link: ${chalk.blue('https://github.com/settings/tokens/new')} - 2. For every project, run ${chalk.green('gren init')} to create a config file (optional) - 3. Run ${chalk.green('gren help')} for more help or see ${chalk.blue('https://github-tools.github.io/github-release-notes/')} + 1. Generate a token with ${chalk.yellow("repo scope")} at this link: ${chalk.blue( + "https://github.com/settings/tokens/new", + )} + 2. For every project, run ${chalk.green("gren init")} to create a config file (optional) + 3. Run ${chalk.green("gren help")} for more help or see ${chalk.blue( + "https://github-tools.github.io/github-release-notes/", + )} -For any questions/issues, go here: ${chalk.blue('https://github.com/github-tools/github-release-notes/issues')} +For any questions/issues, go here: ${chalk.blue( + "https://github.com/github-tools/github-release-notes/issues", + )} -If you like ${chalk.green('gren')}, feel free to ⭐ it! +If you like ${chalk.green("gren")}, feel free to ⭐ it! -${chalk.yellow('.:| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |:.')} +${chalk.yellow( + ".:| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |:.", +)} -`)); +`), +); diff --git a/github-release-notes.js b/github-release-notes.js index 5791d95f..ca77863b 100644 --- a/github-release-notes.js +++ b/github-release-notes.js @@ -1 +1 @@ -require('./bin/gren.js'); +require("./bin/gren.js"); diff --git a/gulpfile.js b/gulpfile.js index 5e3923bf..afbd727a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,39 +1,33 @@ -const babel = require('gulp-babel'); -const chmod = require('gulp-chmod'); -const eslint = require('gulp-eslint'); -const gulp = require('gulp'); -const gulpIf = require('gulp-if'); +const babel = require("gulp-babel"); +const chmod = require("gulp-chmod"); +const eslint = require("gulp-eslint"); +const prettier = require("gulp-prettier"); +const gulp = require("gulp"); -gulp.task('scripts', done => { - gulp.src('./lib/src/**/*.js') - .pipe(babel()) - .pipe(gulp.dest('dist')); +gulp.task("scripts", (done) => { + gulp.src("./lib/src/**/*.js").pipe(babel()).pipe(gulp.dest("dist")); - gulp.src('./lib/src/**/*.json') - .pipe(gulp.dest('dist')); + gulp.src("./lib/src/**/*.json").pipe(gulp.dest("dist")); - gulp.src('./lib/*.js') - .pipe(babel()) - .pipe(chmod(0o755)) - .pipe(gulp.dest('bin')); + gulp.src("./lib/*.js").pipe(babel()).pipe(chmod(0o755)).pipe(gulp.dest("bin")); - done(); + done(); }); -gulp.task('lint', () => { - const isFixed = file => file.eslint != null && file.eslint.fixed; - - return gulp.src('./lib/**/*.js') - .pipe( - eslint({ - fix: true, - }) - ) - .pipe(eslint.format()) - .pipe(gulpIf(isFixed, gulp.dest('./lib/'))); -}); - -gulp.task('watch', () => gulp.watch('./lib/**/*.js', gulp.series(['lint', 'scripts']))); - -gulp.task('build', gulp.series(['lint', 'scripts'])); -gulp.task('default', gulp.series(['build', 'watch'])); +gulp.task("lint", () => + gulp + .src("./lib/**/*.js") + .pipe( + eslint({ + fix: true, + }), + ) + .pipe(eslint.format()) + .pipe(prettier()) + .pipe(gulp.dest("./lib/")), +); + +gulp.task("watch", () => gulp.watch("./lib/**/*.js", gulp.series(["lint", "scripts"]))); + +gulp.task("build", gulp.series(["lint", "scripts"])); +gulp.task("default", gulp.series(["build", "watch"])); diff --git a/lib/_examples.js b/lib/_examples.js index 8fd8bb2b..bffe71e4 100644 --- a/lib/_examples.js +++ b/lib/_examples.js @@ -1,112 +1,117 @@ -const chalk = require('chalk'); +const chalk = require("chalk"); /** * Generate examples based on an Array * * @param {Array} examples - */// istanbul ignore next + */ // istanbul ignore next function generateExamples(title, examples) { - process.stdout.write(`\n Examples for ${title}:`); - const spaceify = number => new Array(!number || number < 0 ? 0 : number + 1).join(' '); - const spaces = spaceify(6); - const descriptionPlaceholder = spaceify(Math.max(...examples.map(({ description }) => description ? description.length : 0))); + process.stdout.write(`\n Examples for ${title}:`); + const spaceify = (number) => new Array(!number || number < 0 ? 0 : number + 1).join(" "); + const spaces = spaceify(6); + const descriptionPlaceholder = spaceify( + Math.max(...examples.map(({ description }) => (description ? description.length : 0))), + ); - examples.forEach(({ name, description, code }) => { - const tabs = spaceify(descriptionPlaceholder.length - (description ? description.length : 0)); + examples.forEach(({ name, description, code }) => { + const tabs = spaceify(descriptionPlaceholder.length - (description ? description.length : 0)); - if (name) { - process.stdout.write(`\n\n ${chalk.blue(name)}:\n`); - } + if (name) { + process.stdout.write(`\n\n ${chalk.blue(name)}:\n`); + } - if (description) { - process.stdout.write(`\n${spaces}${description}`); - } else { - process.stdout.write(spaces); - } + if (description) { + process.stdout.write(`\n${spaces}${description}`); + } else { + process.stdout.write(spaces); + } - if (code) { - process.stdout.write(`${tabs}${spaces}${chalk.green(`$ ${code}`)}\n`); - } - }); + if (code) { + process.stdout.write(`${tabs}${spaces}${chalk.green(`$ ${code}`)}\n`); + } + }); } module.exports = { - generateExamples, - gren: [ - { - name: 'Help', - description: 'Show the general help of the gren tool', - code: 'gren' - }, - { - code: 'gren --help' - }, - { - code: 'gren -h' - }, - { - name: 'Version', - description: 'Show the using version', - code: 'gren --version' - }, - { - code: 'gren -v' - }, - { - description: 'Get help for the release options', - code: 'gren help release' - } - ], - release: [ - { - name: 'Manual repo infos', - description: 'Run gren outside of the project folder.', - code: 'gren release --username=REPO_USER --repo=REPO_NAME' - }, - { - name: 'Override an existing release', - description: 'By default, `gren` won\'t override an existing release and it will flag `Skipping 4.0.0 (use --override to replace it)`. If you want to override, as it suggests, use:', - code: 'gren release --override' - }, - { - name: 'Create release notes for a specific tag', - description: 'Create release notes from the commits or issues closed for the specified tag and the one before.', - code: 'gren release --tags=4.0.0' - }, - { - description: 'Create release notes from the commits or the issues between two specified tags.', - code: 'gren release --tags=4.0.0..3.0.0' - }, - { - name: 'Create release notes for all the tags', - description: 'Create release notes for all the tags in the repository.', - code: 'gren release --tags=all' - }, - { - description: 'Ignore the tags including an Array of strings', - code: 'gren release --tags=all --ignore-tags-with="-rc","-alpha","-beta"' - }, - { - name: 'Work with milestones', - description: 'Create release notes for a tag using the belonging to a milestone that matches the name of the tag. e.g. If the tag is 4.0.0, `gren` is going to match the milestone _"Release 4.0.0"_.', - code: 'gren release --data-source=milestones --milestone-match="Release {{tag_name}}"' - }, - { - description: 'Otherwise, you can just filter the issues that belong to _a_ milestone', - code: 'gren release --only-milestones' - }, - { - name: 'Use commit messages', - description: 'Generate release notes based on commit messages', - code: 'gren release --data-source=commits' - } - ], - changelog: [ - { - name: 'Custom changelog', - description: 'Create a changelog with a custom filename', - code: 'gren changelog --generate --override --changelog-filename=RELEASE_NOTES.md' - } - ] + generateExamples, + gren: [ + { + name: "Help", + description: "Show the general help of the gren tool", + code: "gren", + }, + { + code: "gren --help", + }, + { + code: "gren -h", + }, + { + name: "Version", + description: "Show the using version", + code: "gren --version", + }, + { + code: "gren -v", + }, + { + description: "Get help for the release options", + code: "gren help release", + }, + ], + release: [ + { + name: "Manual repo infos", + description: "Run gren outside of the project folder.", + code: "gren release --username=REPO_USER --repo=REPO_NAME", + }, + { + name: "Override an existing release", + description: + "By default, `gren` won't override an existing release and it will flag `Skipping 4.0.0 (use --override to replace it)`. If you want to override, as it suggests, use:", + code: "gren release --override", + }, + { + name: "Create release notes for a specific tag", + description: + "Create release notes from the commits or issues closed for the specified tag and the one before.", + code: "gren release --tags=4.0.0", + }, + { + description: + "Create release notes from the commits or the issues between two specified tags.", + code: "gren release --tags=4.0.0..3.0.0", + }, + { + name: "Create release notes for all the tags", + description: "Create release notes for all the tags in the repository.", + code: "gren release --tags=all", + }, + { + description: "Ignore the tags including an Array of strings", + code: 'gren release --tags=all --ignore-tags-with="-rc","-alpha","-beta"', + }, + { + name: "Work with milestones", + description: + 'Create release notes for a tag using the belonging to a milestone that matches the name of the tag. e.g. If the tag is 4.0.0, `gren` is going to match the milestone _"Release 4.0.0"_.', + code: 'gren release --data-source=milestones --milestone-match="Release {{tag_name}}"', + }, + { + description: "Otherwise, you can just filter the issues that belong to _a_ milestone", + code: "gren release --only-milestones", + }, + { + name: "Use commit messages", + description: "Generate release notes based on commit messages", + code: "gren release --data-source=commits", + }, + ], + changelog: [ + { + name: "Custom changelog", + description: "Create a changelog with a custom filename", + code: "gren changelog --generate --override --changelog-filename=RELEASE_NOTES.md", + }, + ], }; - diff --git a/lib/_options.js b/lib/_options.js index 93391001..68900194 100644 --- a/lib/_options.js +++ b/lib/_options.js @@ -1,189 +1,181 @@ -const chalk = require('chalk'); +const chalk = require("chalk"); module.exports = { - changelogOptions: [ - { - short: false, - name: false, - description: `\n${chalk.yellow('Changelog options')}\n\n` - }, - { - short: '-G', - name: 'generate', - description: - 'Generate the changelog with gren rather than using the repo releases' - }, - { - short: '-f', - name: 'changelog-filename', - valueType: '', - description: 'The name of the changelog file. [CHANGELOG.md]', - defaultValue: 'CHANGELOG.md' - }, - { - short: false, - name: false, - description: `\n\n${chalk.yellow('Release options')} \n${chalk.blue( - '(only applicable with the --generate option).' - )}\n\n` - } - ], - globalOptions: [ - { - short: '-u', - name: 'username', - valueType: '', - description: 'The username of the repo e.g. github-tools' - }, - { - short: '-r', - name: 'repo', - valueType: '', - description: 'The repository name e.g. github-release-notes' - }, - { - short: '-T', - name: 'token', - valueType: '', - description: 'The token generated with repo access' - }, - { - short: '-a', - name: 'api-url', - valueType: '', - description: - 'Override the GitHub API URL, allows gren to connect to a private GHE installation' - }, - { - short: '-o', - name: 'override', - description: 'Override the release notes if exist' - }, - { - short: '-B', - name: 'debug', - description: 'Run the command in debugging mode' - }, - { - short: '-t', - name: 'tags', - valueType: '..', - description: - 'Write release notes for using data collected until . If only one tag is specified, will use data until the previous tag. To run gren for all the tags, use --tags=all', - action: value => value.split('..') - }, - { - short: '-l', - name: 'limit', - valueType: '', - description: - 'Just produce release notes for the last releases.' - }, - { - short: '-D', - name: 'data-source', - valueType: '', - description: - 'The informations you want to use to build release notes. [issues]', - action: /^(issues|commits|milestones|prs|prs-with-issues)$/i, - defaultValue: 'issues' - }, - { - short: '-h', - name: 'head', - valueType: '', - description: 'Which branch would you like to include commits from after the last tag?' - }, - { - short: '-N', - name: 'include-messages', - valueType: '', - description: - 'Filter the messages added to the release notes. Only used when --data-source used is commits [commits]', - action: /^(merge|commits|all)$/i, - defaultValue: 'commits' - }, - { - short: '-i', - name: 'ignore-tags-with', - valueType: ',', - description: - 'Ignore tags that contain one of the specified strings.', - action: value => value.split(',') - }, - { - short: '-C', - name: 'ignore-commits-with', - valueType: ',', - description: - 'Ignore commits that contain one of the specified strings.', - action: value => value.split(',') - }, - { - short: '-p', - name: 'prefix', - valueType: '', - description: 'Add a prefix to the tag version. e.g. \'v\'' - }, - { - short: '-g', - name: 'group-by', - valueType: '