Skip to content

Commit

Permalink
Replace meow with mri (#1392)
Browse files Browse the repository at this point in the history
* Replace meow with mri

* Fix help
  • Loading branch information
bluwy authored Jun 24, 2024
1 parent 761b2d3 commit f295b3e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 86 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-jeans-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Replace `meow` dependency with `mri` to reduce the number of transitive dependencies
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@types/jest-in-case": "^1.0.6",
"@types/js-yaml": "^3.12.1",
"@types/lodash": "^4.14.136",
"@types/meow": "^5.0.0",
"@types/prettier": "^2.7.1",
"@types/semver": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"external-editor": "^3.1.0",
"fs-extra": "^7.0.1",
"human-id": "^1.0.2",
"meow": "^6.0.0",
"mri": "^1.2.0",
"outdent": "^0.5.0",
"p-limit": "^2.2.0",
"preferred-pm": "^3.0.0",
Expand Down
103 changes: 52 additions & 51 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
import meow from "meow";
import mri from "mri";
import { ExitError, InternalError } from "@changesets/errors";
import { error } from "@changesets/logger";
import { format } from "util";
import { run } from "./run";

const { input, flags } = meow(
`
const args = process.argv.slice(2);

const parsed = mri(args, {
boolean: ["sinceMaster", "verbose", "empty", "open", "gitTag", "snapshot"],
string: [
"output",
"otp",
"since",
"ignore",
"tag",
"snapshot",
"snapshotPrereleaseTemplate",
],
alias: {
// Short flags
v: "verbose",
o: "output",
// Support kebab-case flags
"since-master": "sinceMaster",
"git-tag": "gitTag",
"snapshot-prerelease-template": "snapshotPrereleaseTemplate",
// Deprecated flags
"update-changelog": "updateChangelog",
"is-public": "isPublic",
"skip-c-i": "skipCI",
},
default: {
gitTag: true,
},
});

// `mri` doesn't handle mixed boolean and strings well. It'll always try to coerce it as
// a string even if only `--snapshot` is passed. We check here if this was the case and
// try to coerce it as a boolean
if (parsed.snapshot === "" && args[args.indexOf("--snapshot") + 1] !== "") {
parsed.snapshot = true;
}

// Help message should only be shown if it's the only argument passed
if (parsed.help && args.length === 1) {
console.log(
`
Organise your package versioning and publishing to make both contributors and maintainers happy
Usage
$ changeset [command]
Commands
Expand All @@ -16,64 +58,23 @@ const { input, flags } = meow(
status [--since <branch>] [--verbose] [--output JSON_FILE.json]
pre <enter|exit> <tag>
tag
`,
{
flags: {
sinceMaster: {
type: "boolean",
},
verbose: {
type: "boolean",
alias: "v",
},
output: {
type: "string",
alias: "o",
},
otp: {
type: "string",
},
empty: {
type: "boolean",
},
since: {
type: "string",
},
ignore: {
type: "string",
isMultiple: true,
},
tag: {
type: "string",
},
open: {
type: "boolean",
},
gitTag: {
type: "boolean",
default: true,
},
snapshotPrereleaseTemplate: {
type: "string",
},
// mixed type like this is not supported by `meow`
// if it gets passed explicitly then it's still available on the flags with an inferred type though
// snapshot: { type: "boolean" | "string" },
},
}
);
`
);
process.exit(0);
}

const cwd = process.cwd();

run(input, flags, cwd).catch((err) => {
run(parsed._, parsed, cwd).catch((err) => {
if (err instanceof InternalError) {
error(
"The following error is an internal unexpected error, these should never happen."
);
error("Please open an issue with the following link");
error(
`https://github.com/changesets/changesets/issues/new?title=${encodeURIComponent(
`Unexpected error during ${input[0] || "add"} command`
`Unexpected error during ${parsed._[0] || "add"} command`
)}&body=${encodeURIComponent(`## Error
\`\`\`
Expand Down
40 changes: 7 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2003,13 +2003,6 @@
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.144.tgz#12e57fc99064bce45e5ab3c8bc4783feb75eab8e"
integrity sha512-ogI4g9W5qIQQUhXAclq6zhqgqNUr7UlFaqDHbch7WLSLeeM/7d3CRaw7GLajxvyFvhJqw4Rpcz5bhoaYtIx6Tg==

"@types/meow@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@types/meow/-/meow-5.0.0.tgz#60653cc3c3f91d6af3a131bd82614acf9b530357"
integrity sha512-csdM22P8TFF5KwuHseifUBOzWiGtiLfYmQosrKPGpA/xdK3o3PNo3+4YOpiJ5BQBshwO2kuhdJ7NoAitQ6m/jg==
dependencies:
"@types/minimist-options" "*"

"@types/micromatch@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.1.tgz#9381449dd659fc3823fd2a4190ceacc985083bc7"
Expand All @@ -2022,14 +2015,7 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/minimist-options@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/minimist-options/-/minimist-options-3.0.0.tgz#0dabe91d07e21c9b3fe9614ca862aab202566eb5"
integrity sha512-FYeTlkAANOr9KR0mQL7X+v7MT7Nb/aWdNNHNKzJ8sPctpS2Ei8ucgMbvQRbLRjaYZH2OVN5AGDGGcHV5x8lSgQ==
dependencies:
"@types/minimist" "*"

"@types/minimist@*", "@types/minimist@^1.2.0":
"@types/minimist@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
Expand Down Expand Up @@ -5476,23 +5462,6 @@ mdast-util-to-string@^1.0.6:
resolved "https://registry.yarnpkg.com/mdast-util-to-string/-/mdast-util-to-string-1.1.0.tgz#27055500103f51637bd07d01da01eb1967a43527"
integrity sha512-jVU0Nr2B9X3MU4tSK7JP1CMkSvOj7X5l/GboG1tKRw52lLF1x2Ju92Ms9tNetCcbfX3hzlM73zYo2NKkWSfF/A==

meow@^6.0.0:
version "6.1.1"
resolved "https://registry.yarnpkg.com/meow/-/meow-6.1.1.tgz#1ad64c4b76b2a24dfb2f635fddcadf320d251467"
integrity sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==
dependencies:
"@types/minimist" "^1.2.0"
camelcase-keys "^6.2.2"
decamelize-keys "^1.1.0"
hard-rejection "^2.1.0"
minimist-options "^4.0.2"
normalize-package-data "^2.5.0"
read-pkg-up "^7.0.1"
redent "^3.0.0"
trim-newlines "^3.0.0"
type-fest "^0.13.1"
yargs-parser "^18.1.3"

meow@^7.1.0:
version "7.1.1"
resolved "https://registry.yarnpkg.com/meow/-/meow-7.1.1.tgz#7c01595e3d337fcb0ec4e8eed1666ea95903d306"
Expand Down Expand Up @@ -5589,7 +5558,7 @@ minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

[email protected], minimist-options@^4.0.2:
[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619"
integrity sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==
Expand Down Expand Up @@ -5643,6 +5612,11 @@ mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mri@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b"
integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down

0 comments on commit f295b3e

Please sign in to comment.