yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.43k stars 1.11k forks source link

[Bug]: `yarn version` doesn't accept `premajor`, `preminor`, `prepatch` strategies #4191

Open snk7891 opened 2 years ago

snk7891 commented 2 years ago

Self-service

Describe the bug

According to the inline help:

$ yarn version --help

...

━━━ Details ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This command will bump the version number for the given package, following the 
specified strategy:

...

- If prefixed by `pre` (`premajor`, ...), a `-0` suffix will be set (`0.0.0-0`).

...

But none of the premajor, preminor, prepatch strategies work, and they all return the following error:

Usage Error: Invalid value for enumeration: "preminor" (expected one of "decline", "major", "minor", "patch", "prerelease")

$ yarn version [-d,--deferred] [-i,--immediate] <strategy>

To reproduce

await packageJsonAndInstall({
"name": "example-yarn-package",
"version": "1.0.1",
"description": "An example package to demonstrate Yarn"
});

const versionPromise = yarn(`version`, `preminor`);

await expect(versionPromise).resolves.toBeTruthy();

Environment

System:
    OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri)
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
  Binaries:
    Node: 14.18.1 - /tmp/xfs-735429fe/node
    Yarn: 3.2.0 - /tmp/xfs-735429fe/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm

Thanks!

yarnbot commented 2 years ago

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟

cvolant commented 2 years ago

Hi @snk7891, I encountered the same issue as you, and made a reproduction using yarn playground. According to the above message, it must be included in the first post. Could you add it? Just copy-paste this in your post:

```js repro
const installPromise = packageJsonAndInstall({
"name": "example-yarn-package",
"version": "1.0.1",
"description": "An example package to demonstrate Yarn"
});

const versionPromise = yarn(`version`, `preminor`);

await expect(versionPromise).resolves.toBeTruthy();

---

[Playground](https://yarnpkg.com/playground?code=Y29uc3QgaW5zdGFsbFByb21pc2UgPSBwYWNrYWdlSnNvbkFuZEluc3RhbGwoewogICJuYW1lIjogImV4YW1wbGUteWFybi1wYWNrYWdlIiwKICAidmVyc2lvbiI6ICIxLjAuMSIsCiAgImRlc2NyaXB0aW9uIjogIkFuIGV4YW1wbGUgcGFja2FnZSB0byBkZW1vbnN0cmF0ZSBZYXJuIgp9KTsKCmNvbnN0IHZlcnNpb25Qcm9taXNlID0geWFybihgdmVyc2lvbmAsIGBwcmVtaW5vcmApOwoKYXdhaXQgZXhwZWN0KHZlcnNpb25Qcm9taXNlKS5yZXNvbHZlcy50b0JlVHJ1dGh5KCk7Cg%3D%3D)

```js repro
const installPromise = packageJsonAndInstall({
"name": "example-yarn-package",
"version": "1.0.1",
"description": "An example package to demonstrate Yarn"
});

const versionPromise = yarn(`version`, `preminor`);

await expect(versionPromise).resolves.toBeTruthy();

Output:

Error: expect(received).resolves.toBeTruthy()

Received promise rejected instead of resolved
Rejected to value: [Error: Command failed: /home/sandbox/.nvm/versions/node/v16.12.0/bin/node /sandbox/berry/scripts/actions/../run-yarn.js version preminor·
Usage Error: Invalid value for enumeration: "preminor" (expected one of "decline", "major", "minor", "patch", "prerelease")·
$ yarn version [-d,--deferred] [-i,--immediate] <strategy>
]
at expect (/sandbox/node_modules/expect/build/index.js:138:15)
at module.exports (evalmachine.<anonymous>:10:7)
at /sandbox/node_modules/@arcanis/sherlock/lib/executeRepro.js:57:19
at executeInTempDirectory (/sandbox/node_modules/@arcanis/sherlock/lib/executeRepro.js:18:22)
at executeRepro (/sandbox/node_modules/@arcanis/sherlock/lib/executeRepro.js:25:18)
at module.exports../pages/api/sherlock.js.__webpack_exports__.default (/sandbox/.next/server/static/development/pages/api/sherlock.js:140:122)
at Object.apiResolver (/sandbox/node_modules/next/dist/next-server/server/api-utils.js:46:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async DevServer.handleApiRequest (/sandbox/node_modules/next/dist/next-server/server/next-server.js:449:9)
at async Object.fn (/sandbox/node_modules/next/dist/next-server/server/next-server.js:371:37)
at async Router.execute (/sandbox/node_modules/next/dist/next-server/server/router.js:134:32)
at async DevServer.run (/sandbox/node_modules/next/dist/next-server/server/next-server.js:491:29)
at async DevServer.handleRequest (/sandbox/node_modules/next/dist/next-server/server/next-server.js:144:20)

yarnbot commented 2 years ago

This issue reproduces on master:

Error: expect(received).resolves.toBeTruthy()

Received promise rejected instead of resolved
Rejected to value: [Error: Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js version preminor

Usage Error: Invalid value for enumeration: "preminor" (expected one of "decline", "major", "minor", "patch", "prerelease")

$ yarn version [-d,--deferred] [-i,--immediate] <strategy>
]
    at expect (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-44ff9ab1e7.zip/node_modules/expect/build/index.js:138:15)
    at module.exports (evalmachine.<anonymous>:10:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:57:13
    at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:18:16)
    at async executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:25:12)
    at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.3-558f52b79f-286d94b96d.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:26:38)
    at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-4061026d74.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
    at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-4061026d74.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
    at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-4061026d74.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)
merceyz commented 2 years ago

@cvolant Thanks for the reproduction, I've updated the OP to include it.

indooorsman commented 2 years ago

same issue with yarn 3.2.2:

$ yarn version prepatch
Usage Error: Invalid value for enumeration: "prepatch" (expected one of "decline", "major", "minor", "patch", "prerelease")

$ yarn version [-d,--deferred] [-i,--immediate] <strategy>
» yarn --version
3.2.2
pbrennand-francis commented 6 months ago

Reproducing on 4.1.1 This is strange because the docs explicitly mention "premajor" Should we update the docs in the meantime until this is supported?

wickkidd commented 5 months ago

Still an issue for v4.2.2

NarHakobyan commented 2 days ago

Still an issue for v4.5.1