-
Notifications
You must be signed in to change notification settings - Fork 12
Adding support for .yarnrc.yml files. #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules | |
.store | ||
dist | ||
lib | ||
.npmrc | ||
.npmrc | ||
.vscode |
This file contains hidden or 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 |
---|---|---|
|
@@ -12,5 +12,9 @@ | |
"lage": "^2.7.16", | ||
"typescript": "^5.4.2", | ||
"prettier": "^3.2.5" | ||
}, | ||
"engines": { | ||
"node": ">=16", | ||
"pnpm": "8" | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
export interface Args { | ||
doValidCheck: boolean; | ||
skipAuth: boolean; | ||
configFile?: string; | ||
} | ||
|
||
export function parseArgs(args: string[]) : Args { | ||
const doValidCheck = !args.includes("--skip-check"); | ||
const skipAuth = args.includes("--skip-auth"); | ||
|
||
return { | ||
doValidCheck, | ||
skipAuth | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,98 @@ | ||
import { getWorkspaceRoot } from "workspace-tools"; | ||
import { join } from "node:path"; | ||
import fs from "node:fs/promises"; | ||
import { homedir } from "node:os"; | ||
import { getOrganizationFromFeedUrl } from "./utils/get-organization-from-feed-url.js"; | ||
import { makeADORequest } from "./ado/make-ado-request.js"; | ||
|
||
|
||
/** | ||
* Default user to be used in the .npmrc | ||
*/ | ||
export const defaultUser = "me"; | ||
|
||
/** | ||
* Default email to be used in the .npmrc | ||
*/ | ||
export const defaultEmail = "[email protected]"; | ||
|
||
export interface Feed { | ||
registry: string; | ||
adoOrganization: string; | ||
userName?: string; | ||
email?: string; | ||
authToken?: string; | ||
} | ||
|
||
export type ValidatedFeed = { feed: Feed; isValid: boolean, fileProvider: FileProvider } | ||
|
||
export abstract class FileProvider { | ||
public workspaceFilePath: string; | ||
public userFilePath: string; | ||
|
||
public feeds: Map<string, Feed>; | ||
|
||
constructor(public id: string, public workspaceFileName: string) { | ||
const workspaceRoot = getWorkspaceRoot(process.cwd()) || ""; | ||
this.workspaceFilePath = join(workspaceRoot, this.workspaceFileName); | ||
|
||
const userHome = | ||
process.env["HOME"] || process.env["USERPROFILE"] || homedir() || ""; | ||
this.userFilePath = join(userHome, workspaceFileName); | ||
this.feeds = new Map<string, Feed>(); | ||
} | ||
|
||
public async isSupportedInRepo(): Promise<boolean> { | ||
try { | ||
await fs.access(this.workspaceFilePath); | ||
} catch (error) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public async validateAllUsedFeeds(): Promise<ValidatedFeed[]> { | ||
await this.prepUserFile(); | ||
|
||
const result: ValidatedFeed[] = []; | ||
|
||
const workspaceRegistries = await this.getWorkspaceRegistries(); | ||
const userFeeds = await this.getUserFeeds(); | ||
|
||
// check each feed for validity | ||
for (const registry of workspaceRegistries) { | ||
dannyvv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const feed = userFeeds.get(registry); | ||
|
||
if (feed) { | ||
let feedIsValid = true; | ||
try { | ||
await makeADORequest({ | ||
password: feed.authToken || "", | ||
organization: feed.adoOrganization, | ||
}); | ||
} catch (e) { | ||
feedIsValid = false; | ||
} | ||
result.push({ feed: feed, isValid: feedIsValid, fileProvider: this }); | ||
} else { | ||
// No representation of the token in the users config file. | ||
result.push({ | ||
feed: { | ||
registry: registry, | ||
adoOrganization: getOrganizationFromFeedUrl(registry), | ||
}, | ||
isValid: false, | ||
fileProvider: this, | ||
}); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
abstract prepUserFile(): Promise<void>; | ||
abstract getUserFeeds(): Promise<Map<string, Feed>>; | ||
abstract getWorkspaceRegistries(): Promise<string[]>; | ||
abstract writeWorspaceRegistries(feedsToPatch: Iterable<Feed>): Promise<void>; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
63 changes: 0 additions & 63 deletions
63
packages/ado-npm-auth/src/npmrc/get-repo-npmrc-ado-orgs.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.