-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#52: Add special logic to handle github repository separately from az…
…ure (#53) * #52: Add special logic to handle github repository separately from azure. * Create ten-jokes-boil.md * Improve INCORRECT_REPOSITORY_FIELD support for azure. Add tests. * Only validate repo field check for supported hosts Co-Authored-By: Mitchell Hamilton <[email protected]> Co-authored-by: Nate Radebaugh <[email protected]> Co-authored-by: Mitchell Hamilton <[email protected]>
- Loading branch information
1 parent
8c7fdbb
commit 503f242
Showing
3 changed files
with
189 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@manypkg/cli": patch | ||
--- | ||
|
||
Add special logic for `INCORRECT_REPOSITORY_FIELD` check to handle github repository separately from azure |
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 |
---|---|---|
|
@@ -3,61 +3,169 @@ import check from "../INCORRECT_REPOSITORY_FIELD"; | |
import { getWS, getFakeWS } from "../../test-helpers"; | ||
|
||
describe("incorrect repository field", () => { | ||
it("should work", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://github.com/Thinkmill/manypkg"; | ||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(workspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"correctRepositoryField": "https://github.com/Thinkmill/manypkg/tree/master/packages/no-repository-field", | ||
"currentRepositoryField": undefined, | ||
"type": "INCORRECT_REPOSITORY_FIELD", | ||
}, | ||
] | ||
`); | ||
|
||
check.fix(errors[0]); | ||
|
||
expect((workspace.config as any).repository).toBe( | ||
"https://github.com/Thinkmill/manypkg/tree/master/packages/no-repository-field" | ||
); | ||
describe("github", () => { | ||
it("should work", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://github.com/Thinkmill/manypkg"; | ||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(workspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"correctRepositoryField": "https://github.com/Thinkmill/manypkg/tree/master/packages/no-repository-field", | ||
"currentRepositoryField": undefined, | ||
"type": "INCORRECT_REPOSITORY_FIELD", | ||
}, | ||
] | ||
`); | ||
|
||
check.fix(errors[0]); | ||
|
||
expect((workspace.config as any).repository).toBe( | ||
"https://github.com/Thinkmill/manypkg/tree/master/packages/no-repository-field" | ||
); | ||
}); | ||
it("should fix root in a different format", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://github.com/Thinkmill/manypkg.git"; | ||
|
||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(rootWorkspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"correctRepositoryField": "https://github.com/Thinkmill/manypkg", | ||
"currentRepositoryField": "https://github.com/Thinkmill/manypkg.git", | ||
"type": "INCORRECT_REPOSITORY_FIELD", | ||
}, | ||
] | ||
`); | ||
|
||
check.fix(errors[0]); | ||
|
||
expect((rootWorkspace.config as any).repository).toBe( | ||
"https://github.com/Thinkmill/manypkg" | ||
); | ||
}); | ||
it("should do nothing if already in good format", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://github.com/Thinkmill/manypkg"; | ||
|
||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(rootWorkspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)).toMatchInlineSnapshot( | ||
`Array []` | ||
); | ||
|
||
expect((rootWorkspace.config as any).repository).toBe( | ||
"https://github.com/Thinkmill/manypkg" | ||
); | ||
}); | ||
}); | ||
it("should fix root in a different format", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://github.com/Thinkmill/manypkg.git"; | ||
|
||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(rootWorkspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"correctRepositoryField": "https://github.com/Thinkmill/manypkg", | ||
"currentRepositoryField": "https://github.com/Thinkmill/manypkg.git", | ||
"type": "INCORRECT_REPOSITORY_FIELD", | ||
}, | ||
] | ||
`); | ||
|
||
check.fix(errors[0]); | ||
|
||
expect((rootWorkspace.config as any).repository).toBe( | ||
"https://github.com/Thinkmill/manypkg" | ||
); | ||
|
||
describe("azure devops", () => { | ||
it("should work", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://dev.azure.com/Thinkmill/monorepos/_git/manypkg"; | ||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(workspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"correctRepositoryField": "https://dev.azure.com/Thinkmill/monorepos/_git/manypkg?path=packages/no-repository-field&version=GBmaster&_a=contents", | ||
"currentRepositoryField": undefined, | ||
"type": "INCORRECT_REPOSITORY_FIELD", | ||
}, | ||
] | ||
`); | ||
|
||
check.fix(errors[0]); | ||
|
||
expect((workspace.config as any).repository).toBe( | ||
"https://dev.azure.com/Thinkmill/monorepos/_git/manypkg?path=packages/no-repository-field&version=GBmaster&_a=contents" | ||
); | ||
}); | ||
it("should fix root in a different format", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://[email protected]/Thinkmill/monorepos/_git/manypkg"; | ||
|
||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(rootWorkspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)) | ||
.toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"correctRepositoryField": "https://dev.azure.com/Thinkmill/monorepos/_git/manypkg", | ||
"currentRepositoryField": "https://[email protected]/Thinkmill/monorepos/_git/manypkg", | ||
"type": "INCORRECT_REPOSITORY_FIELD", | ||
}, | ||
] | ||
`); | ||
|
||
check.fix(errors[0]); | ||
|
||
expect((rootWorkspace.config as any).repository).toBe( | ||
"https://dev.azure.com/Thinkmill/monorepos/_git/manypkg" | ||
); | ||
}); | ||
it("should do nothing if already in good format", () => { | ||
let ws = getWS(); | ||
let rootWorkspace = getFakeWS("root"); | ||
|
||
(rootWorkspace.config as any).repository = | ||
"https://dev.azure.com/Thinkmill/monorepos/_git/manypkg"; | ||
|
||
rootWorkspace.dir = __dirname; | ||
let workspace = getFakeWS("no-repository-field"); | ||
workspace.dir = path.join(__dirname, "packages/no-repository-field"); | ||
ws.set("depends-on-one", workspace); | ||
ws.set("root", rootWorkspace); | ||
let errors = check.validate(rootWorkspace, ws, rootWorkspace); | ||
expect(errors.map(({ workspace, ...x }: any) => x)).toMatchInlineSnapshot( | ||
`Array []` | ||
); | ||
|
||
expect((rootWorkspace.config as any).repository).toBe( | ||
"https://dev.azure.com/Thinkmill/monorepos/_git/manypkg" | ||
); | ||
}); | ||
}); | ||
}); |