-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- 👋 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 - [x] Addresses an existing open issue: fixes #18 - [x] 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) - [x] 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 adds a "no parse" mode for when an `.npmrc` is not available
- Loading branch information
1 parent
97390b8
commit aaa5c2f
Showing
12 changed files
with
224 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from "./createPat.js"; | ||
export * from "./createUserNpmrc.js"; | ||
export * from "./makeParsedProjectNpmrc.js"; | ||
export * from "./parseProjectNpmrc.js"; | ||
export * from "./types.js"; | ||
export * from "./writeNpmrc.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { makeParsedProjectNpmrc } from "./makeParsedProjectNpmrc.js"; | ||
|
||
describe("makeParsedProjectNpmrc", () => { | ||
it("given no project it constructs an organisation feed ParsedProjectNpmrc", () => { | ||
const result = makeParsedProjectNpmrc({ | ||
organization: "johnnyreilly", | ||
feed: "npmrc-script-organization", | ||
}); | ||
expect(result).toEqual({ | ||
organization: "johnnyreilly", | ||
urlWithoutRegistryAtEnd: | ||
"//pkgs.dev.azure.com/johnnyreilly/_packaging/npmrc-script-organization/npm/", | ||
urlWithoutRegistryAtStart: | ||
"//pkgs.dev.azure.com/johnnyreilly/_packaging/npmrc-script-organization/npm/registry/", | ||
}); | ||
}); | ||
|
||
it("given a project it constructs a project feed ParsedProjectNpmrc", () => { | ||
const result = makeParsedProjectNpmrc({ | ||
organization: "johnnyreilly", | ||
project: "azure-static-web-apps", | ||
feed: "npmrc-script-demo", | ||
}); | ||
expect(result).toEqual({ | ||
organization: "johnnyreilly", | ||
urlWithoutRegistryAtEnd: | ||
"//pkgs.dev.azure.com/johnnyreilly/azure-static-web-apps/_packaging/npmrc-script-demo/npm/", | ||
urlWithoutRegistryAtStart: | ||
"//pkgs.dev.azure.com/johnnyreilly/azure-static-web-apps/_packaging/npmrc-script-demo/npm/registry/", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { ParsedProjectNpmrc } from "./types.js"; | ||
|
||
import { fallbackLogger, type Logger } from "./shared/cli/logger.js"; | ||
|
||
/** | ||
* Construct a ParsedProjectNpmrc object using the provided parameters | ||
*/ | ||
export function makeParsedProjectNpmrc({ | ||
organization, | ||
project, | ||
feed, | ||
logger = fallbackLogger, | ||
}: { | ||
organization: string; | ||
project?: string | undefined; | ||
feed: string; | ||
logger?: Logger; | ||
}): ParsedProjectNpmrc { | ||
const urlWithoutRegistryAtEnd = project | ||
? `//pkgs.dev.azure.com/${organization}/${project}/_packaging/${feed}/npm/` | ||
: `//pkgs.dev.azure.com/${organization}/_packaging/${feed}/npm/`; | ||
|
||
const urlWithoutRegistryAtStart = project | ||
? `//pkgs.dev.azure.com/${organization}/${project}/_packaging/${feed}/npm/registry/` | ||
: `//pkgs.dev.azure.com/${organization}/_packaging/${feed}/npm/registry/`; | ||
|
||
// eg | ||
// organization: "johnnyreilly", | ||
// urlWithoutRegistryAtEnd: "//pkgs.dev.azure.com/johnnyreilly/_packaging/npmrc-script-organization/npm/", | ||
// urlWithoutRegistryAtStart: "//pkgs.dev.azure.com/johnnyreilly/_packaging/npmrc-script-organization/npm/registry/", | ||
|
||
logger.info(`Made: | ||
- organization: ${organization} | ||
- urlWithoutRegistryAtStart: ${urlWithoutRegistryAtStart} | ||
- urlWithoutRegistryAtEnd: ${urlWithoutRegistryAtEnd}`); | ||
|
||
return { urlWithoutRegistryAtStart, urlWithoutRegistryAtEnd, organization }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters