-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## PR Checklist - [x] Addresses an existing open issue: fixes #1042 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Adds extra logic to `getPrefillOrPromptedOption` so that it can return immediately without prompting if needed.
- Loading branch information
1 parent
e1c008f
commit 082b0d9
Showing
23 changed files
with
404 additions
and
218 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
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ const options = { | |
github: "[email protected]", | ||
npm: "[email protected]", | ||
}, | ||
logo: undefined, | ||
mode: "create", | ||
owner: "TestOwner", | ||
repository: "test-repository", | ||
|
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { describe, expect, it, vi } from "vitest"; | ||
|
||
import { InferredOptions, logInferredOptions } from "./logInferredOptions.js"; | ||
|
||
function makeProxy<T extends object>(receiver: T): T { | ||
return new Proxy(receiver, { | ||
get: () => makeProxy((input: string) => input), | ||
}); | ||
} | ||
|
||
vi.mock("chalk", () => ({ | ||
default: makeProxy({}), | ||
})); | ||
|
||
const mockLogLine = vi.fn(); | ||
|
||
vi.mock("../cli/lines.js", () => ({ | ||
get logLine() { | ||
return mockLogLine; | ||
}, | ||
})); | ||
|
||
const options = { | ||
description: "Test description.", | ||
email: { | ||
github: "[email protected]", | ||
npm: "[email protected]", | ||
}, | ||
owner: "TestOwner", | ||
repository: "test-repository", | ||
title: "Test Title", | ||
} satisfies InferredOptions; | ||
|
||
describe("logInferredOptions", () => { | ||
it("logs the required inferred values when only they exist", () => { | ||
logInferredOptions(options); | ||
|
||
expect(mockLogLine.mock.calls).toMatchInlineSnapshot(` | ||
[ | ||
[], | ||
[ | ||
"--auto inferred the following values:", | ||
], | ||
[ | ||
"- description: Test description.", | ||
], | ||
[ | ||
"- email-github: [email protected]", | ||
], | ||
[ | ||
"- email-npm: [email protected]", | ||
], | ||
[ | ||
"- owner: TestOwner", | ||
], | ||
[ | ||
"- repository: test-repository", | ||
], | ||
[ | ||
"- title: Test Title", | ||
], | ||
] | ||
`); | ||
}); | ||
|
||
it("logs additional and required inferred values when all they exist", () => { | ||
logInferredOptions({ | ||
...options, | ||
guide: { | ||
href: "https://example.com/guide", | ||
title: "Example Guide", | ||
}, | ||
logo: { | ||
alt: "Logo text.", | ||
src: "https://example.com/logo", | ||
}, | ||
}); | ||
|
||
expect(mockLogLine.mock.calls).toMatchInlineSnapshot(` | ||
[ | ||
[], | ||
[ | ||
"--auto inferred the following values:", | ||
], | ||
[ | ||
"- description: Test description.", | ||
], | ||
[ | ||
"- email-github: [email protected]", | ||
], | ||
[ | ||
"- email-npm: [email protected]", | ||
], | ||
[ | ||
"- guide: https://example.com/guide", | ||
], | ||
[ | ||
"- guide-title: Example Guide", | ||
], | ||
[ | ||
"- logo: https://example.com/logo", | ||
], | ||
[ | ||
"- logo-alt: Logo text.", | ||
], | ||
[ | ||
"- owner: TestOwner", | ||
], | ||
[ | ||
"- repository: test-repository", | ||
], | ||
[ | ||
"- title: Test Title", | ||
], | ||
] | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.