10000 feat: fallback to using the Azure CLI (#11) Β· mrvus/azdo-npm-auth@1e10db2 Β· GitHub
[go: up one dir, main page]

Skip to content

Commit 1e10db2

Browse files
authored
feat: fallback to using the Azure CLI (johnnyreilly#11)
<!-- πŸ‘‹ Hi, thanks for sending a PR to ado-npm-auth-lite! πŸ’–. 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 johnnyreilly#10 - [ ] That issue was marked as [`status: accepting prs`](https://github.com/johnnyreilly/ado-npm-auth-lite/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [ ] Steps in [CONTRIBUTING.md](https://github.com/johnnyreilly/ado-npm-auth-lite/blob/main/.github/CONTRIBUTING.md) were taken ## Overview <!-- Description of what is changed and how the code change does that. --> Falls back to using the AZ CLI with execa if the initial attempt fails. Output looks like this: ```sh β”Œ πŸ“¦πŸ”‘ Welcome to ado-npm-auth-lite 0.5.0! πŸ“¦πŸ”‘ β”‚ β”‚ ● options: β”‚ - pat: [NONE SUPPLIED - WILL ACQUIRE FROM AZURE API] β”‚ - config: ./ignore/.npmrc β”‚ - email: [NONE SUPPLIED - WILL USE DEFAULT] β”‚ β”‚ ● Loading .npmrc at: /home/john/code/github/ado-npm-auth-lite/ignore/.npmrc β”‚ ● Parsed: β”‚ - organisation: johnnyreilly β”‚ - urlWithoutRegistryAtStart: //pkgs.dev.azure.com/johnnyreilly/_packaging/npmrc-script-organization/npm/registry/ β”‚ - urlWithoutRegistryAtEnd: //pkgs.dev.azure.com/johnnyreilly/_packaging/npmrc-script-organization/npm/ β—‡ βœ… Passed parsing project .npmrc. β”‚ β”‚ ● Creating Azure CLI Token β—“ Creating Personal Access Token..β”‚ ● Creating Personal Access Token with API: { β”‚ "displayName": "made by ado-npm-auth-lite at: 2024-11-10T17:41:11.033Z", β”‚ "scope": "vso.packaging", β”‚ "validTo": "2024-12-10T17:41:11.033Z", β”‚ "allOrgs": false β”‚ } β—“ Creating Personal Access Token...β”‚ β–  Error creating Personal Access Token with API: HTTP error! status: 401 - {"$id":"1","innerException":null,"message":"TF401444: Please sign-in at least once as Windows Live ID\\johnny_reilly@hotmail.com in a web browser to enable access to the service.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000} β”‚ ● Will re-attempt with Azure CLI β”‚ ● Creating Personal Access Token with Azure CLI: { β”‚ "displayName": "made by ado-npm-auth-lite at: 2024-11-10T17:41:11.033Z", β”‚ "scope": "vso.packaging", β”‚ "validTo": "2024-12-10T17:41:11.033Z", β”‚ "allOrgs": false β”‚ } β—’ Creating Personal Access Token.β”‚ ● Created Personal Access Token with Azure CLI β—‡ βœ… Passed creating Personal Access Token. β”‚ β—‡ βœ… Passed constructing user .npmrc. β”‚ β”‚ ● Writing users .npmrc to: /home/john/.npmrc β—‡ βœ… Passed writing user .npmrc. β”‚ β”” πŸ“¦πŸ”‘ Thanks for using ado-npm-auth-lite 0.5.0! πŸ“¦πŸ”‘ ```
1 parent 0a89880 commit 1e10db2

File tree

6 files changed

+267
-32
lines changed

6 files changed

+267
-32
lines changed

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@clack/prompts": "^0.7.0",
4646
"chalk": "^5.3.0",
4747
"ci-info": "^4.0.0",
48+
"execa": "^9.5.1",
4849
"zod": "^3.23.8",
4950
"zod-validation-error": "^3.3.1"
5051
},

β€Žpnpm-lock.yamlβ€Ž

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsrc/bin/index.tsβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as prompts from "@clack/prompts";
22
import chalk from "chalk";
33
import ci from "ci-info";
4+
import path from "node:path";
45
import { parseArgs } from "node:util";
56
import { fromZodError } from "zod-validation-error";
67

@@ -97,7 +98,9 @@ export async function bin(args: string[]) {
9798
try {
9899
const parsedProjectNpmrc = await withSpinner(`Parsing project .npmrc`, () =>
99100
parseProjectNpmrc({
100-
config,
101+
npmrcPath: config
102+
? path.resolve(config)
103+
: path.resolve(process.cwd(), ".npmrc"),
101104
logger,
102105
}),
103106
);

0 commit comments

Comments
Β (0)
0