mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Require @changesets/cli resolving from cwd (#67)
* Resolve @changesets/cli with resolve-from * Use require.resolve directly * Add documentation section to README * Add custom version command docs for Yarn 2
This commit is contained in:
@@ -4,7 +4,6 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
### Inputs
|
||||
|
||||
- publish - The command to use to build and publish packages
|
||||
@@ -101,7 +100,6 @@ jobs:
|
||||
if: steps.changesets.outputs.published == 'true'
|
||||
# You can do something when a publish happens.
|
||||
run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"
|
||||
|
||||
```
|
||||
|
||||
By default the GitHub Action creates a `.npmrc` file with the following content:
|
||||
@@ -164,3 +162,14 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
#### With Yarn 2 / Plug'n'Play
|
||||
|
||||
If you are using [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp), you should use a custom `version` command so that the action can resolve the `changeset` CLI:
|
||||
|
||||
```yaml
|
||||
- uses: changesets/action@master
|
||||
with:
|
||||
version: yarn changeset version
|
||||
...
|
||||
```
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+10
-7
@@ -181,17 +181,20 @@ export async function runVersion({
|
||||
let [versionCommand, ...versionArgs] = script.split(/\s+/);
|
||||
await exec(versionCommand, versionArgs, { cwd });
|
||||
} else {
|
||||
let changesetsCliPkgJson = await require(path.join(
|
||||
cwd,
|
||||
"node_modules",
|
||||
"@changesets",
|
||||
"cli",
|
||||
"package.json"
|
||||
let changesetsCliPkgJson = await require(require.resolve(
|
||||
"@changesets/cli/package.json",
|
||||
{ paths: [cwd] }
|
||||
));
|
||||
let cmd = semver.lt(changesetsCliPkgJson.version, "2.0.0")
|
||||
? "bump"
|
||||
: "version";
|
||||
await exec("node", ["./node_modules/@changesets/cli/bin.js", cmd], { cwd });
|
||||
await exec(
|
||||
"node",
|
||||
[require.resolve("@changesets/cli/bin.js", { paths: [cwd] }), cmd],
|
||||
{
|
||||
cwd,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let searchQuery = `repo:${repo}+state:open+head:${versionBranch}+base:${branch}`;
|
||||
|
||||
Reference in New Issue
Block a user