Skip to content

Commit

Permalink
fix: add workaround for camel-case flags
Browse files Browse the repository at this point in the history
Camel-case flags was not working as expected. See: sindresorhus/meow#178
  • Loading branch information
ozum committed Mar 7, 2021
1 parent bcfac89 commit 9a7cac6
Show file tree
Hide file tree
Showing 10 changed files with 6,882 additions and 4,172 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -49,7 +49,7 @@ jobs:
env:
CI: true
- name: Release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
29 changes: 15 additions & 14 deletions .yo-rc.json
Expand Up @@ -13,10 +13,10 @@
"package.json": {
"safe": {
"author.email": "ozum@ozum.net",
"author.name": "Özüm Eldoğan",
"author.url": "",
"author.name": "Özüm Eldoğan",
"author.url": "https://www.ozum.net/",
"bugs": "https://github.com/ozum/meow-helper/issues",
"engines.node": ">= 12.0.0",
"engines.node": ">= 14.0.0",
"files": ["dist", "!dist/**/@(*.spec|*.test)*", "!dist/**/__test__", "module-files"],
"homepage": "https://github.com/ozum/meow-helper",
"repository": "ozum/meow-helper",
Expand All @@ -39,34 +39,35 @@
"types": "dist/index.d.ts"
},
"normal": {
"devDependencies.@commitlint/cli": "^11.0.0",
"devDependencies.@commitlint/config-conventional": "^11.0.0",
"devDependencies.@commitlint/cli": "^12.0.1",
"devDependencies.@commitlint/config-conventional": "^12.0.1",
"devDependencies.@ozum/pinst": "^2.1.4",
"devDependencies.@types/jest": "^26.0.20",
"devDependencies.@types/node": "^14.14.25",
"devDependencies.@typescript-eslint/eslint-plugin": "^4.15.0",
"devDependencies.@typescript-eslint/parser": "^4.15.0",
"devDependencies.@types/node": "^14.14.31",
"devDependencies.@typescript-eslint/eslint-plugin": "^4.15.1",
"devDependencies.@typescript-eslint/parser": "^4.15.1",
"devDependencies.commitizen": "^4.2.3",
"devDependencies.concat-md": "^0.3.5",
"devDependencies.eslint": "^7.19.0",
"devDependencies.eslint": "^7.20.0",
"devDependencies.eslint-config-airbnb-base": "^14.1.0",
"devDependencies.eslint-config-prettier": "^7.2.0",
"devDependencies.eslint-config-prettier": "^8.1.0",
"devDependencies.eslint-plugin-import": "^2.22.0",
"devDependencies.eslint-plugin-jest": "^24.1.3",
"devDependencies.eslint-plugin-jest": "^24.1.5",
"devDependencies.eslint-plugin-prettier": "^3.3.1",
"devDependencies.husky": "^5.0.9",
"devDependencies.is-ci": "^2.0.0",
"devDependencies.is-ci": "^3.0.0",
"devDependencies.jest": "^26.6.3",
"devDependencies.lint-staged": "^10.5.4",
"devDependencies.not-sync": "^1.4.1",
"devDependencies.prettier": "^2.2.1",
"devDependencies.readmeasy": "^0.2.7",
"devDependencies.ts-jest": "^26.5.1",
"devDependencies.ts-node-dev": "^1.1.1",
"devDependencies.typedoc": "^0.20.24",
"devDependencies.typedoc": "^0.20.28",
"devDependencies.typedoc-neo-theme": "^1.1.0",
"devDependencies.typedoc-plugin-example-tag": "^1.0.2",
"devDependencies.typedoc-plugin-markdown": "^3.4.5",
"devDependencies.typedoc-plugin-markdown": "^3.6.0",
"devDependencies.typedoc-plugin-param-names": "^2.0.0",
"devDependencies.typescript": "^4.1.5",
"devDependencies.walkdir": "^0.4.1"
}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Özüm Eldoğan <ozum@ozum.net>
Copyright (c) 2021 Özüm Eldoğan <ozum@ozum.net> (https://www.ozum.net/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
98 changes: 31 additions & 67 deletions README.md
Expand Up @@ -90,30 +90,12 @@ const help = getHelp({

<a name="readmemd"></a>

meow-helper

# meow-helper

## Table of contents

### Interfaces

- [HelpOptions](#interfaceshelpoptionsmd)

### Type aliases

- [ExtendedAnyFlag](#extendedanyflag)
- [ExtendedAnyFlags](#extendedanyflags)

### Variables

- [cliui](#cliui)
- [commonFlags](#commonflags)

### Functions

- [default](#default)

## Type aliases

### ExtendedAnyFlag
Expand All @@ -122,7 +104,7 @@ meow-helper

Meow flag extended with `desc` key.

Defined in: [get-help.ts:7](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L7)
Defined in: [get-help.ts:8](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L8)

---

Expand All @@ -132,15 +114,15 @@ Defined in: [get-help.ts:7](https://github.com/ozum/meow-helper/blob/f01e9df/src

Record of extended any flag.

Defined in: [get-help.ts:10](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L10)
Defined in: [get-help.ts:11](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L11)

## Variables

### cliui

`Const` **cliui**: _any_

Defined in: [index.ts:5](https://github.com/ozum/meow-helper/blob/f01e9df/src/index.ts#L5)
Defined in: [index.ts:5](https://github.com/ozum/meow-helper/blob/bcfac89/src/index.ts#L5)

---

Expand All @@ -150,7 +132,7 @@ Defined in: [index.ts:5](https://github.com/ozum/meow-helper/blob/f01e9df/src/in

Very common flags

Defined in: [index.ts:12](https://github.com/ozum/meow-helper/blob/f01e9df/src/index.ts#L12)
Defined in: [index.ts:12](https://github.com/ozum/meow-helper/blob/bcfac89/src/index.ts#L12)

## Functions

Expand All @@ -177,7 +159,7 @@ meow(getHelp({ flags, args, pkg }), { flags, pkg, allowUnknownFlags: false });

**Returns:** _string_

Defined in: [get-help.ts:192](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L192)
Defined in: [get-help.ts:193](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L193)

# Interfaces

Expand All @@ -189,150 +171,132 @@ Defined in: [get-help.ts:192](https://github.com/ozum/meow-helper/blob/f01e9df/s

Options below modify behaviour of [[getHelp]] function.

## Table of contents

### Properties

- [args](#args)
- [autoHelp](#autohelp)
- [command](#command)
- [description](#description)
- [examples](#examples)
- [flags](#flags)
- [groups](#groups)
- [lineLength](#linelength)
- [multilineThreshold](#multilinethreshold)
- [notThrow](#notthrow)
- [pkg](#pkg)
- [titleLength](#titlelength)
- [usage](#usage)

## Properties

### args

`Optional` **args**: _undefined_ \| _Record_<string, string\>
`Optional` **args**: _Record_<string, string\>

Name and description of positional arguments.

Defined in: [get-help.ts:27](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L27)
Defined in: [get-help.ts:28](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L28)

---

### autoHelp

`Optional` **autoHelp**: _undefined_ \| _boolean_
`Optional` **autoHelp**: _boolean_

This option sets whether the `autoHelp` option of `meow` is used. If this is true, the description text is not added, because meow adds it automatically.

Defined in: [get-help.ts:35](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L35)
Defined in: [get-help.ts:36](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L36)

---

### command

`Optional` **command**: _undefined_ \| _string_
`Optional` **command**: _string_

Name of the command.

Defined in: [get-help.ts:21](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L21)
Defined in: [get-help.ts:22](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L22)

---

### description

`Optional` **description**: _undefined_ \| _string_ \| _string_[]
`Optional` **description**: _string_ \| _string_[]

Command description.

Defined in: [get-help.ts:23](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L23)
Defined in: [get-help.ts:24](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L24)

---

### examples

`Optional` **examples**: _undefined_ \| _string_ \| _string_[]
`Optional` **examples**: _string_ \| _string_[]

A single example or list of examples can be provided to show in the help text. Lines are prefixed with `$` and the command is colored automatically.

Defined in: [get-help.ts:31](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L31)
Defined in: [get-help.ts:32](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L32)

---

### flags

`Optional` **flags**: _undefined_ \| _Record_<string, [_ExtendedAnyFlag_](#extendedanyflag)\>
`Optional` **flags**: [_ExtendedAnyFlags_](#extendedanyflags)

Flags provided to meow. Uses `desc` key for the description.

Defined in: [get-help.ts:29](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L29)
Defined in: [get-help.ts:30](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L30)

---

### groups

`Optional` **groups**: _undefined_ \| _Record_<string, { `description?`: _undefined_ \| _string_ ; `title?`: _undefined_ \| _string_ }\>
`Optional` **groups**: _Record_<string, { `description?`: _string_ ; `title?`: _string_ }\>

Option groups shown in help text. Key is the first option in group.

Defined in: [get-help.ts:39](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L39)
Defined in: [get-help.ts:40](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L40)

---

### lineLength

`Optional` **lineLength**: _undefined_ \| _number_
`Optional` **lineLength**: _number_

Text longer than line length will be word-wrapped.

Defined in: [get-help.ts:15](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L15)
Defined in: [get-help.ts:16](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L16)

---

### multilineThreshold

`Optional` **multilineThreshold**: _undefined_ \| _number_
`Optional` **multilineThreshold**: _number_

If space available for option descriptions is less than this threshold, descriptions are given their own rows. So they have more space. See images above.

Defined in: [get-help.ts:33](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L33)
Defined in: [get-help.ts:34](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L34)

---

### notThrow

`Optional` **notThrow**: _undefined_ \| _boolean_
`Optional` **notThrow**: _boolean_

Whether to throw an error when `meow` exits with exit code 2. If true, it adds `process.on("exit")` to show help and exits with code 0.

Defined in: [get-help.ts:37](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L37)
Defined in: [get-help.ts:38](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L38)

---

### pkg

`Optional` **pkg**: _undefined_ \| _Record_<string, any\>
`Optional` **pkg**: _Record_<string, any\>

`package.json` data.

Defined in: [get-help.ts:19](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L19)
Defined in: [get-help.ts:20](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L20)

---

### titleLength

`Optional` **titleLength**: _undefined_ \| _number_
`Optional` **titleLength**: _number_

The total length of the colored background area of titles.

Defined in: [get-help.ts:17](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L17)
Defined in: [get-help.ts:18](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L18)

---

### usage

`Optional` **usage**: _undefined_ \| _string_ \| _string_[]
`Optional` **usage**: _string_ \| _string_[]

Uasge text is shown at the beginning of help text. Lines are prefixed with `$` and command is colored automatically.

Defined in: [get-help.ts:25](https://github.com/ozum/meow-helper/blob/f01e9df/src/get-help.ts#L25)
Defined in: [get-help.ts:26](https://github.com/ozum/meow-helper/blob/bcfac89/src/get-help.ts#L26)
2 changes: 0 additions & 2 deletions module-files/configs/.eslintrc.js
Expand Up @@ -22,7 +22,6 @@ module.exports = {
"eslint:recommended", // TURN ON ESLint recommended rules.
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended", // TURN ON TypeScript rules by using `typescript-eslint/typescript-eslint`.
"prettier/@typescript-eslint", // TURN OFF ESLint TypesSript rules which conflict with Prettier by using `prettier/eslint-config-prettier`.
],
plugins: ["@typescript-eslint"],
settings: {
Expand Down Expand Up @@ -63,7 +62,6 @@ module.exports = {
"plugin:jest/recommended", // TURN ON Jest rules by using "jest-community/eslint-plugin-jest".
"airbnb-base", // TURN ON airbnb-base rules.
"plugin:prettier/recommended", // RUN Prettier as ESLint rule by using `prettier/eslint-plugin-prettier` and TURN OFF ESLint rules which conflict with Prettier by using `prettier/eslint-config-prettier`.
"prettier/@typescript-eslint", // TURN OFF ESLint TypesSript rules which conflict with Prettier by using `prettier/eslint-config-prettier`.
],
},
],
Expand Down
8 changes: 4 additions & 4 deletions module-files/scripts/tsmod.js
Expand Up @@ -63,14 +63,13 @@ async function md({ out, singleFile = false }) {

const options = [
"--plugin",
"typedoc-plugin-example-tag,typedoc-plugin-markdown",
"typedoc-plugin-example-tag,typedoc-plugin-markdown,typedoc-plugin-param-names",
"--excludeExternals",
"--excludePrivate",
"--excludeProtected",
"--exclude",
"'src/bin/**/*'",
"--theme",
"markdown",
"--hideInPageTOC",
"--readme",
"none",
"--out",
Expand All @@ -94,7 +93,8 @@ async function md({ out, singleFile = false }) {
}

if (singleFile) {
const apiDoc = await concatMd(outDir, { dirNameAsTitle: true });
// Remove titles at the beginning. README already has a title.
const apiDoc = (await concatMd(outDir, { dirNameAsTitle: true })).replace(new RegExp(`${pkg.name}.+?${pkg.name}`, "sm"), "");
fs.writeFile(out, apiDoc);
await rmdir(outDir);
}
Expand Down
4 changes: 4 additions & 0 deletions module-files/template-partials/installation
@@ -1,6 +1,8 @@
{% if package.scripts and package.scripts.build %}
{% if package.scripts.build.match("microbundle") %}

# Installation

| Format | Instructions |
| ---------------------------------- | ------------------------------------------------------------------ |
| **TypeScript** | `import { ... } from "{{ package.name }}";` |
Expand All @@ -12,6 +14,8 @@ Development versions can be found in `dist/dev` directory.

{% elif package.scripts.build.match("rollup") %}

# Installation

| Format | Instructions |
| ---------------------------------- | --------------------------------------------------------------- |
| **TypeScript** | `import { ... } from "{{ package.name }}";` |
Expand Down

0 comments on commit 9a7cac6

Please sign in to comment.