Skip to content
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

feat: pre-fill cspell.json words #1734

Merged
merged 24 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
29ccfea
feat: pre-fill cspell.json words
JoshuaKGoldberg Dec 3, 2024
024f78d
Migration test snapshot updates
JoshuaKGoldberg Dec 3, 2024
bd6d362
always tseslint
JoshuaKGoldberg Dec 3, 2024
1d18f9e
Handle packagejson and 1737
JoshuaKGoldberg Dec 3, 2024
9fe6bae
codecov is no longer flagged
JoshuaKGoldberg Dec 3, 2024
6977b28
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
f839ca2
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
3145037
fix: always words, and actually use the new function in rootFiles
JoshuaKGoldberg Dec 3, 2024
64ed115
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
5446250
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
14bbf2e
AHA: expand npm, node dictionaries for all
JoshuaKGoldberg Dec 3, 2024
5789521
Remove from cspell
JoshuaKGoldberg Dec 3, 2024
ceb9ef6
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
f4d6d15
Merge branch 'main'
JoshuaKGoldberg Dec 3, 2024
820539f
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
404b6df
Remove seemingly unnecessary words
JoshuaKGoldberg Dec 3, 2024
b568f74
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
0e0da2d
Remove seemingly unnecessary words: knip, vitest
JoshuaKGoldberg Dec 3, 2024
8c07ed5
Update migration snapshots
JoshuaKGoldberg Dec 3, 2024
1a6161c
Flesh out words
JoshuaKGoldberg Dec 3, 2024
b2cc98d
Remove tsup, swap markdownlint -> markdownlintignore
JoshuaKGoldberg Dec 4, 2024
95b917a
Update migration snapshots
JoshuaKGoldberg Dec 4, 2024
6f5beae
Remove npmignore too
JoshuaKGoldberg Dec 4, 2024
ec2d12a
Update migration snapshots
JoshuaKGoldberg Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
{
"dictionaries": ["typescript"],
"dictionaries": ["npm", "node", "typescript"],
"ignorePaths": [
"./coverage*",
"./script/__snapshots__",
".all-contributorsrc",
".github",
"CHANGELOG.md",
"coverage*",
"lib",
"node_modules",
"pnpm-lock.yaml"
"pnpm-lock.yaml",
"script/__snapshots__"
],
"words": [
"allcontributors",
"apexskier",
"arethetypeswrong",
"automerge",
"codecov",
"codespace",
"contributorsrc",
"execa",
"infile",
"knip",
"joshuakgoldberg",
"markdownlintignore",
"mtfoley",
"npmignore",
"npmpackagejsonlintrc",
"outro",
"packagejson",
"tada",
"tseslint",
"tsup",
"vitest"
"tseslint"
]
}
32 changes: 13 additions & 19 deletions script/__snapshots__/migrate-test-e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -105,39 +105,33 @@ exports[`expected file changes > cspell.json 1`] = `
"--- a/cspell.json
+++ b/cspell.json
@@ ... @@
{
"dictionaries": ["typescript"],
"ignorePaths": [
- "./coverage*",
- "./script/__snapshots__",
".all-contributorsrc",
".github",
"CHANGELOG.md",
- "coverage*",
+ "coverage",
"lib",
"node_modules",
"pnpm-lock.yaml"
- "pnpm-lock.yaml",
- "script/__snapshots__"
+ "pnpm-lock.yaml"
],
"words": [
"allcontributors",
@@ ... @@
"apexskier",
"arethetypeswrong",
"automerge",
- "codecov",
"codespace",
"contributorsrc",
"execa",
- "execa",
+ "contributorsrc",
"infile",
+ "joshuakgoldberg",
"knip",
+ "markdownlint",
"joshuakgoldberg",
"markdownlintignore",
"mtfoley",
"npmignore",
@@ ... @@
"outro",
"tada",
"tseslint",
"tsup",
- "vitest"
+ "vitest",
- "tseslint"
+ "tseslint",
+ "wontfix"
]
}"
Expand Down
9 changes: 2 additions & 7 deletions src/create/createWithOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Options } from "../shared/types.js";
import { addToolAllContributors } from "../steps/addToolAllContributors.js";
import { finalizeDependencies } from "../steps/finalizeDependencies.js";
import { initializeGitHubRepository } from "../steps/initializeGitHubRepository/index.js";
import { populateCSpellDictionary } from "../steps/populateCSpellDictionary.js";
import { runCleanup } from "../steps/runCleanup.js";
import { createWithOptions } from "./createWithOptions.js";

Expand Down Expand Up @@ -61,8 +60,6 @@ vi.mock("../steps/writeReadme/index.js");

vi.mock("../steps/finalizeDependencies.js");

vi.mock("../steps/populateCSpellDictionary.js");

vi.mock("../steps/clearLocalGitTags.js");

vi.mock("../steps/runCleanup.js");
Expand Down Expand Up @@ -119,19 +116,18 @@ describe("createWithOptions", () => {
expect(addToolAllContributors).not.toHaveBeenCalled();
});

it("does not call finalizeDependencies, populateCSpellDictionary, or runCleanup when skipInstall is true", async () => {
it("does not call finalizeDependencies or runCleanup when skipInstall is true", async () => {
const options = {
...optionsBase,
skipInstall: true,
};

await createWithOptions({ github, options });
expect(finalizeDependencies).not.toHaveBeenCalled();
expect(populateCSpellDictionary).not.toHaveBeenCalled();
expect(runCleanup).not.toHaveBeenCalled();
});

it("calls finalizeDependencies, populateCSpellDictionary, and runCleanup when skipInstall is false", async () => {
it("calls finalizeDependencies and runCleanup when skipInstall is false", async () => {
const options = {
...optionsBase,
skipInstall: false,
Expand All @@ -140,7 +136,6 @@ describe("createWithOptions", () => {
await createWithOptions({ github, options });

expect(finalizeDependencies).toHaveBeenCalledWith(options);
expect(populateCSpellDictionary).toHaveBeenCalled();
expect(runCleanup).toHaveBeenCalled();
});

Expand Down
8 changes: 0 additions & 8 deletions src/create/createWithOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { addToolAllContributors } from "../steps/addToolAllContributors.js";
import { clearLocalGitTags } from "../steps/clearLocalGitTags.js";
import { finalizeDependencies } from "../steps/finalizeDependencies.js";
import { initializeGitHubRepository } from "../steps/initializeGitHubRepository/index.js";
import { populateCSpellDictionary } from "../steps/populateCSpellDictionary.js";
import { runCleanup } from "../steps/runCleanup.js";
import { writeReadme } from "../steps/writeReadme/index.js";
import { writeStructure } from "../steps/writing/writeStructure.js";
Expand Down Expand Up @@ -40,13 +39,6 @@ export async function createWithOptions({ github, options }: GitHubAndOptions) {
finalizeDependencies(options),
);

if (!options.excludeLintSpelling) {
await withSpinner(
"Populating CSpell dictionary",
populateCSpellDictionary,
);
}

await runCleanup(createCleanupCommands(options.bin), options.mode);
}

Expand Down
1 change: 0 additions & 1 deletion src/steps/clearUnnecessaryFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const globPaths = [
".eslintrc",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
".npmpackagejsonlintrc.json",
"codecov.yml",
"DEVELOPMENT.md",
"dist",
Expand Down
58 changes: 58 additions & 0 deletions src/steps/writing/creation/createCSpellConfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { describe, expect, it } from "vitest";

import { createCSpellConfig } from "./createCSpellConfig.js";

describe("createCSpellConfig", () => {
it("creates an ignore file with all words when exclusions are disabled", async () => {
const actual = await createCSpellConfig({});

expect(actual).toMatchInlineSnapshot(`
"{
"dictionaries": ["npm", "node", "typescript"],
"ignorePaths": [
".all-contributorsrc",
".github",
"CHANGELOG.md",
"coverage",
"lib",
"node_modules",
"pnpm-lock.yaml"
],
"words": [
"apexskier",
"automerge",
"joshuakgoldberg",
"markdownlintignore",
"tseslint"
]
}
"
`);
});

it("creates an ignore file with minimal words when exclusions are enabled", async () => {
const actual = await createCSpellConfig({
excludeAllContributors: true,
excludeLintMd: true,
excludeReleases: true,
excludeRenovate: true,
excludeTemplatedBy: true,
excludeTests: true,
});

expect(actual).toMatchInlineSnapshot(`
"{
"dictionaries": ["npm", "node", "typescript"],
"ignorePaths": [
".github",
"CHANGELOG.md",
"lib",
"node_modules",
"pnpm-lock.yaml"
],
"words": ["tseslint"]
}
"
`);
});
});
38 changes: 38 additions & 0 deletions src/steps/writing/creation/createCSpellConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Options } from "../../../shared/types.js";
import { formatJson } from "./formatters/formatJson.js";

export async function createCSpellConfig(
options: Pick<
Options,
| "excludeAllContributors"
| "excludeLintMd"
| "excludeReleases"
| "excludeRenovate"
| "excludeTemplatedBy"
| "excludeTests"
>,
) {
const words = [
"tseslint",
!options.excludeReleases && "apexskier",
!options.excludeRenovate && "automerge",
!options.excludeLintMd && "markdownlintignore",
!options.excludeTemplatedBy && "joshuakgoldberg",
]
.filter(Boolean)
.sort();

return await formatJson({
dictionaries: ["npm", "node", "typescript"],
ignorePaths: [
...(options.excludeAllContributors ? [] : [".all-contributorsrc"]),
".github",
"CHANGELOG.md",
...(options.excludeTests ? [] : ["coverage"]),
"lib",
"node_modules",
"pnpm-lock.yaml",
],
words,
});
}
14 changes: 2 additions & 12 deletions src/steps/writing/creation/rootFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Options } from "../../../shared/types.js";
import { createCSpellConfig } from "./createCSpellConfig.js";
import { createDotGitignore } from "./createDotGitignore.js";
import { createESLintConfig } from "./createESLintConfig.js";
import { createTsupConfig } from "./createTsupConfig.js";
Expand Down Expand Up @@ -92,18 +93,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
`,
...(!options.excludeLintSpelling && {
"cspell.json": await formatJson({
dictionaries: ["typescript"],
ignorePaths: [
...(options.excludeAllContributors ? [] : [".all-contributorsrc"]),
".github",
"CHANGELOG.md",
...(options.excludeTests ? [] : ["coverage"]),
"lib",
"node_modules",
"pnpm-lock.yaml",
],
}),
"cspell.json": await createCSpellConfig(options),
}),
...(!options.excludeLintKnip && {
"knip.json": await formatJson({
Expand Down
Loading