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

fix: remove redundant coverage.exclude: lib from vitest.config.ts #1818

Merged
merged 3 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
890 changes: 381 additions & 509 deletions .all-contributorsrc

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.all-contributorsrc
/.husky
/coverage*
/lib
Expand Down
1 change: 0 additions & 1 deletion script/__snapshots__/migrate-test-e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ exports[`expected file changes > .prettierignore 1`] = `
"--- a/.prettierignore
+++ b/.prettierignore
@@ ... @@
/.all-contributorsrc
/.husky
-/coverage*
+/coverage
Expand Down
20 changes: 2 additions & 18 deletions src/next/blocks/blockAllContributors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ describe("blockAllContributors", () => {
expect(creation).toMatchInlineSnapshot(`
{
"addons": [
{
"addons": {
"ignores": [
"/.all-contributorsrc",
],
},
"block": [Function],
},
{
"addons": {
"secrets": [
Expand Down Expand Up @@ -61,7 +53,7 @@ describe("blockAllContributors", () => {
{
"commands": [
"pnpx all-contributors-cli generate",
"pnpx all-contributors-cli add test-owner code,content,docs,ideas,infra,maintenance,projectManagement,tool",
"pnpx all-contributors-cli add test-owner code,content,doc,ideas,infra,maintenance,projectManagement,tool",
],
"phase": 3,
},
Expand Down Expand Up @@ -89,14 +81,6 @@ describe("blockAllContributors", () => {
expect(creation).toMatchInlineSnapshot(`
{
"addons": [
{
"addons": {
"ignores": [
"/.all-contributorsrc",
],
},
"block": [Function],
},
{
"addons": {
"secrets": [
Expand Down Expand Up @@ -139,7 +123,7 @@ describe("blockAllContributors", () => {
{
"commands": [
"pnpx all-contributors-cli generate",
"pnpx all-contributors-cli add test-owner code,content,docs,ideas,infra,maintenance,projectManagement,tool",
"pnpx all-contributors-cli add test-owner code,content,doc,ideas,infra,maintenance,projectManagement,tool",
],
"phase": 3,
},
Expand Down
6 changes: 1 addition & 5 deletions src/next/blocks/blockAllContributors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createSoloWorkflowFile } from "../../steps/writing/creation/dotGitHub/createSoloWorkflowFile.js";
import { base } from "../base.js";
import { blockPrettier } from "./blockPrettier.js";
import { blockRepositorySecrets } from "./blockRepositorySecrets.js";
import { CommandPhase } from "./phases.js";

Expand All @@ -11,9 +10,6 @@ export const blockAllContributors = base.createBlock({
produce({ options }) {
return {
addons: [
blockPrettier({
ignores: ["/.all-contributorsrc"],
}),
blockRepositorySecrets({
secrets: [
{
Expand Down Expand Up @@ -57,7 +53,7 @@ export const blockAllContributors = base.createBlock({
{
commands: [
`pnpx all-contributors-cli generate`,
`pnpx all-contributors-cli add ${options.owner} code,content,docs,ideas,infra,maintenance,projectManagement,tool`,
`pnpx all-contributors-cli add ${options.owner} code,content,doc,ideas,infra,maintenance,projectManagement,tool`,
],
phase: CommandPhase.Process,
},
Expand Down
16 changes: 10 additions & 6 deletions src/next/blocks/blockTypeScript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ describe("blockTypeScript", () => {
},
{
"addons": {
"coverage": {
"include": [
"src",
],
},
"exclude": [
"lib",
],
"include": [
"src",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -266,12 +268,14 @@ describe("blockTypeScript", () => {
},
{
"addons": {
"coverage": {
"include": [
"src",
],
},
"exclude": [
"lib",
],
"include": [
"src",
],
},
"block": [Function],
},
Expand Down
5 changes: 1 addition & 4 deletions src/next/blocks/blockTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ export * from "./types.js";
},
},
}),
blockVitest({
exclude: ["lib"],
include: ["src"],
}),
blockVitest({ coverage: { include: ["src"] }, exclude: ["lib"] }),
blockVSCode({
debuggers: options.bin
? [
Expand Down
11 changes: 5 additions & 6 deletions src/next/blocks/blockVitest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ describe("blockVitest", () => {
clearMocks: true,
coverage: {
all: true,
exclude: [],
include: [],
include: undefined,
reporter: ["html", "lcov"],
},
exclude: [, "node_modules"],
Expand Down Expand Up @@ -488,8 +487,7 @@ describe("blockVitest", () => {
clearMocks: true,
coverage: {
all: true,
exclude: [],
include: [],
include: undefined,
reporter: ["html", "lcov"],
},
exclude: [, "node_modules"],
Expand All @@ -515,10 +513,11 @@ describe("blockVitest", () => {
addons: {
coverage: {
directory: "coverage*",
exclude: ["other"],
flags: "unit",
include: ["src/"],
},
exclude: ["lib/"],
include: ["src/"],
},
options: optionsBase,
});
Expand Down Expand Up @@ -755,7 +754,7 @@ describe("blockVitest", () => {
clearMocks: true,
coverage: {
all: true,
exclude: ["lib/"],
exclude: ["other"],
include: ["src/"],
reporter: ["html", "lcov"],
},
Expand Down
32 changes: 20 additions & 12 deletions src/next/blocks/blockVitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ export const blockVitest = base.createBlock({
addons: {
coverage: z
.object({
directory: z.string(),
directory: z.string().optional(),
exclude: z.array(z.string()).optional(),
flags: z.string().optional(),
include: z.array(z.string()).optional(),
})
.default({ directory: "coverage" }),
.default({}),
env: z.record(z.string(), z.string()).default({}),
exclude: z.array(z.string()).default([]),
include: z.array(z.string()).default([]),
flags: z.array(z.string()).default([]),
},
migrate() {
return {
Expand All @@ -42,14 +45,14 @@ export const blockVitest = base.createBlock({
};
},
produce({ addons }) {
const { coverage, exclude = [], include = [] } = addons;
const { coverage, env, exclude = [], flags } = addons;
const coverageDirectory = coverage.directory ?? "coverage";
const excludeText = JSON.stringify(exclude);
const includeText = JSON.stringify(include);

return {
addons: [
blockCSpell({
ignores: [coverage.directory],
ignores: [coverageDirectory],
}),
blockDevelopmentDocs({
sections: {
Expand Down Expand Up @@ -90,7 +93,7 @@ Calls to \`console.log\`, \`console.warn\`, and other console methods will cause
],
},
],
ignores: [coverage.directory, "**/*.snap"],
ignores: [coverageDirectory, "**/*.snap"],
imports: [{ source: "@vitest/eslint-plugin", specifier: "vitest" }],
}),
blockExampleFiles({
Expand Down Expand Up @@ -143,7 +146,7 @@ describe("greet", () => {
},
}),
blockGitignore({
ignores: [`/${coverage.directory}`],
ignores: [`/${coverageDirectory}`],
}),
blockGitHubActionsCI({
jobs: [
Expand All @@ -152,6 +155,7 @@ describe("greet", () => {
steps: [
{ run: "pnpm run test --coverage" },
{
...(Object.keys(env).length && { env }),
if: "always()",
uses: "codecov/codecov-action@v3",
...(coverage.flags && { with: { flags: coverage.flags } }),
Expand All @@ -177,12 +181,12 @@ describe("greet", () => {
"vitest",
),
scripts: {
test: "vitest",
test: `vitest ${flags.join(" ")}`.trim(),
},
},
}),
blockPrettier({
ignores: [`/${coverage.directory}`],
ignores: [`/${coverageDirectory}`],
}),
blockTSup({
entry: ["!src/**/*.test.*"],
Expand Down Expand Up @@ -212,8 +216,12 @@ export default defineConfig({
clearMocks: true,
coverage: {
all: true,
exclude: ${excludeText},
include: ${includeText},
${
coverage.exclude?.length
? `exclude: ${JSON.stringify(coverage.exclude)},
`
: ""
}include: ${JSON.stringify(coverage.include)},
reporter: ["html", "lcov"],
},
exclude: [${excludeText.slice(1, excludeText.length - 1)}, "node_modules"],
Expand Down
2 changes: 0 additions & 2 deletions src/steps/writing/creation/rootFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function createRootFiles(options: Options) {
}),
".nvmrc": `20.18.0\n`,
".prettierignore": formatIgnoreFile([
...(options.excludeAllContributors ? [] : ["/.all-contributorsrc"]),
"/.husky",
...(options.excludeTests ? [] : ["/coverage"]),
"/lib",
Expand Down Expand Up @@ -137,7 +136,6 @@ export default defineConfig({
clearMocks: true,
coverage: {
all: true,
exclude: ["lib"],
include: ["src"],
reporter: ["html", "lcov"],
},
Expand Down
1 change: 0 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default defineConfig({
clearMocks: true,
coverage: {
all: true,
exclude: ["lib"],
include: ["src"],
reporter: ["html", "lcov"],
},
Expand Down
Loading