Skip to content

Commit 282a53c

Browse files
authored
feat: Cross platform usage docs and attempt to fix post release permissions (#19)
<!-- 👋 Hi, thanks for sending a PR to azdo-npm-auth! 💖. Please fill out all fields below and make sure each item is true and [x] checked. Otherwise we may not be able to review your PR. --> ## PR Checklist - [ ] Addresses an existing open issue: fixes #000 - [ ] That issue was marked as [`status: accepting prs`](https://github.com/johnnyreilly/azdo-npm-auth/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [ ] Steps in [CONTRIBUTING.md](https://github.com/johnnyreilly/azdo-npm-auth/blob/main/.github/CONTRIBUTING.md) were taken ## Overview <!-- Description of what is changed and how the code change does that. --> This PR documents how to use the tool in a cross platform way. It also applies the change suggested by @apexskier here to attempt to fix post-release permissions: apexskier/github-release-commenter#545 (comment)
1 parent ead5d8f commit 282a53c

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

.github/workflows/post-release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# based on https://github.com/apexskier/github-release-commenter/issues/545#issuecomment-2513388057
2+
permissions:
3+
issues: write
4+
pull-requests: write
5+
16
jobs:
27
post_release:
38
runs-on: ubuntu-latest

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Simply set up user authentication to Azure DevOps npm feeds, optionally using th
1717
To get `azdo-npm-auth` to create the necessary user `.npmrc` file, run the following command:
1818

1919
```shell
20-
npm_config_registry=https://registry.npmjs.org npx azdo-npm-auth
20+
npx -y --registry https://registry.npmjs.org azdo-npm-auth
2121
```
2222

23-
You might be wondering what the `npm_config_registry=https://registry.npmjs.org` part is for. It is a way to ensure that the `npx` command uses the **public** npm registry to install `azdo-npm-auth`. Without this, you might encounter an error like below:
23+
You might be wondering what the `--registry https://registry.npmjs.org` part is for. It is a way to ensure that the `npx` command uses the **public** npm registry to install `azdo-npm-auth`. Without this, you might encounter an error like below:
2424

2525
```shell
2626
npm error code E401
@@ -29,26 +29,28 @@ npm error To correct this please try logging in again with:
2929
npm error npm login
3030
```
3131

32-
If you're catering for Windows users that do not use Bash then you might need to introduce a `npx cross-env` prefix:
32+
It is possible to use environment variables to control the `registry` setting as well; consider the following (non-Windows compatible) example:
3333

3434
```shell
35-
npx cross-env npm_config_registry=https://registry.npmjs.org npx azdo-npm-auth
35+
npm_config_registry=https://registry.npmjs.org npx azdo-npm-auth
3636
```
3737

38-
### "No parse"-mode / manually supplying `organization`, `project`, and `feed`
38+
But the `--registry` flag is the recommended approach.
3939

40-
If you would like to manually supply the `organization`, `project`, and `feed` values, you can do so. In this mode of operation `azdo-npm-auth` will not attempt to parse the `.npmrc` file, and will use the supplied values to build a user `.npmrc` file.
40+
### "No parse"-mode / manually supplying `organization`, `feed` and `project`
4141

42-
If your feed is project-scoped, you will need to supply the `project` value:
42+
If you would like to manually supply the `organization`, `feed` and (optionally) `project` values, you can do so. In this mode of operation `azdo-npm-auth` will not attempt to parse the **project** `.npmrc` file, and will use the supplied values to build a **user** `.npmrc` file.
43+
44+
If your feed is organization-scoped, you will **not** need to supply the `project` value:
4345

4446
```shell
45-
npm_config_registry=https://registry.npmjs.org npx azdo-npm-auth --organization johnnyreilly --project my-project --feed project-feed-name
47+
npx -y --registry https://registry.npmjs.org azdo-npm-auth --organization johnnyreilly --feed organization-feed-name
4648
```
4749

48-
If your feed is organization-scoped, you will **not** need to supply the `project` value:
50+
If your feed is project-scoped, you will need to supply the `project` value:
4951

5052
```shell
51-
npm_config_registry=https://registry.npmjs.org npx azdo-npm-auth --organization johnnyreilly --feed organization-feed-name
53+
npx -y --registry https://registry.npmjs.org azdo-npm-auth --organization johnnyreilly --project my-project --feed project-feed-name
5254
```
5355

5456
## Integration with `package.json`
@@ -59,7 +61,7 @@ We generally advise setting up a custom npm script like the one below:
5961

6062
```json
6163
"scripts": {
62-
"auth": "npm_config_registry=https://registry.npmjs.org npx --yes azdo-npm-auth"
64+
"auth": "npx -y --registry https://registry.npmjs.org azdo-npm-auth"
6365
},
6466
```
6567

@@ -73,7 +75,7 @@ First the bad news. The below **won't** work:
7375

7476
```json
7577
"scripts": {
76-
"preinstall": "npm_config_registry=https://registry.npmjs.org npx --yes azdo-npm-auth"
78+
"preinstall": "npx -y --registry https://registry.npmjs.org azdo-npm-auth"
7779
},
7880
```
7981

@@ -154,7 +156,7 @@ When you are attempting to install from private feeds, npm will commonly error o
154156
This section exists to list some classic errors you might encounter when you try to `npm i`. Regardless of the error, the remedy is generally:
155157

156158
```shell
157-
npm_config_registry=https://registry.npmjs.org npx azdo-npm-auth
159+
npx -y --registry https://registry.npmjs.org azdo-npm-auth
158160
```
159161

160162
### User `.npmrc` not found

0 commit comments

Comments
 (0)