Skip to content

Commit 150bce6

Browse files
fix: omit default --access value in rerun suggestions (#1307)
## PR Checklist - [x] Addresses an existing open issue: fixes #1127 - [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 a `defaultValues` map and filters out key/value pairs matched in it.
1 parent b019bce commit 150bce6

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/create/createRerunSuggestion.test.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,18 @@ describe("createRerunSuggestion", () => {
4646
const actual = createRerunSuggestion(options);
4747

4848
expect(actual).toMatchInlineSnapshot(
49-
`"npx create-typescript-app --mode create --base everything --access public --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --mode create --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
49+
`"npx create-typescript-app --mode create --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --mode create --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
50+
);
51+
});
52+
53+
it("includes a non-default value when specified", () => {
54+
const actual = createRerunSuggestion({
55+
...options,
56+
access: "restricted",
57+
});
58+
59+
expect(actual).toMatchInlineSnapshot(
60+
`"npx create-typescript-app --mode create --base everything --access restricted --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --mode create --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
5061
);
5162
});
5263

@@ -61,7 +72,7 @@ describe("createRerunSuggestion", () => {
6172
});
6273

6374
expect(actual).toMatchInlineSnapshot(
64-
`"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --guide https://example.com --guide-title "Test Title" --keywords "abc def ghi jkl mno pqr" --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
75+
`"npx create-typescript-app --mode initialize --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --guide https://example.com --guide-title "Test Title" --keywords "abc def ghi jkl mno pqr" --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
6576
);
6677
});
6778

@@ -76,7 +87,7 @@ describe("createRerunSuggestion", () => {
7687
});
7788

7889
expect(actual).toMatchInlineSnapshot(
79-
`"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --logo test/src.png --logo-alt "Test alt." --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
90+
`"npx create-typescript-app --mode initialize --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --logo test/src.png --logo-alt "Test alt." --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
8091
);
8192
});
8293

@@ -90,7 +101,7 @@ describe("createRerunSuggestion", () => {
90101
});
91102

92103
expect(actual).toMatchInlineSnapshot(
93-
`"npx create-typescript-app --mode initialize --base everything --access public --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-md --exclude-lint-package-json --exclude-lint-perfectionist --exclude-lint-spelling --keywords "abc def ghi jkl mno pqr" --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
104+
`"npx create-typescript-app --mode initialize --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-md --exclude-lint-package-json --exclude-lint-perfectionist --exclude-lint-spelling --keywords "abc def ghi jkl mno pqr" --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
94105
);
95106
});
96107

@@ -102,7 +113,7 @@ describe("createRerunSuggestion", () => {
102113
});
103114

104115
expect(common).toMatchInlineSnapshot(
105-
'"npx create-typescript-app --mode undefined --base common"',
116+
`"npx create-typescript-app --mode undefined --base common"`,
106117
);
107118
});
108119

@@ -114,7 +125,7 @@ describe("createRerunSuggestion", () => {
114125
});
115126

116127
expect(minimum).toMatchInlineSnapshot(
117-
'"npx create-typescript-app --mode undefined --base minimum"',
128+
`"npx create-typescript-app --mode undefined --base minimum"`,
118129
);
119130
});
120131
});

src/create/createRerunSuggestion.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function getFirstMatchingArg(key: string) {
1111
);
1212
}
1313

14+
const defaultValues = new Map([["access", "public"]]);
15+
1416
export function createRerunSuggestion(options: Partial<Options>): string {
1517
const optionsNormalized = {
1618
...options,
@@ -38,11 +40,13 @@ export function createRerunSuggestion(options: Partial<Options>): string {
3840
.sort(([a], [b]) =>
3941
a === "base" ? -1 : b === "base" ? 1 : a.localeCompare(b),
4042
)
41-
// Filter out all entries that have a key in the excluded object or have a falsy value
43+
// Filter out entries with an excluded key or a default or falsy value
4244
.filter(
4345
([key, value]) =>
4446
getExclusions(options, optionsNormalized.base)[key as ExclusionKey] ==
45-
undefined && !!value,
47+
undefined &&
48+
!!value &&
49+
value !== defaultValues.get(key),
4650
)
4751
.map(([key, value]) => {
4852
return `--${getFirstMatchingArg(key)}${stringifyValue(value)}`;

0 commit comments

Comments
 (0)