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: assorted transition mode removals #2026

Merged
merged 2 commits into from
Mar 26, 2025
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
92 changes: 76 additions & 16 deletions src/blocks/blockCSpell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ describe("blockCSpell", () => {
],
},
],
"removedWorkflows": [
"lint-spelling",
"spelling",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -125,10 +121,6 @@ describe("blockCSpell", () => {
],
},
],
"removedWorkflows": [
"lint-spelling",
"spelling",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -198,10 +190,6 @@ describe("blockCSpell", () => {
],
},
],
"removedWorkflows": [
"lint-spelling",
"spelling",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -269,10 +257,6 @@ describe("blockCSpell", () => {
],
},
],
"removedWorkflows": [
"lint-spelling",
"spelling",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -304,4 +288,80 @@ describe("blockCSpell", () => {
}
`);
});

test("transition mode", () => {
const creation = testBlock(blockCSpell, {
mode: "transition",
options: optionsBase,
});

expect(creation).toMatchInlineSnapshot(`
{
"addons": [
{
"addons": {
"sections": {
"Linting": {
"contents": {
"items": [
"- \`pnpm lint:spelling\` ([cspell](https://cspell.org)): Spell checks across all source files",
],
},
},
},
},
"block": [Function],
},
{
"addons": {
"extensions": [
"streetsidesoftware.code-spell-checker",
],
},
"block": [Function],
},
{
"addons": {
"jobs": [
{
"name": "Lint Spelling",
"steps": [
{
"run": "pnpm lint:spelling",
},
],
},
],
},
"block": [Function],
},
{
"addons": {
"properties": {
"devDependencies": {
"cspell": "8.17.5",
},
"scripts": {
"lint:spelling": "cspell "**" ".github/**/*"",
},
},
},
"block": [Function],
},
{
"addons": {
"workflows": [
"lint-spelling",
"spelling",
],
},
"block": [Function],
},
],
"files": {
"cspell.json": "{"dictionaries":["npm","node","typescript"],"ignorePaths":[".github","CHANGELOG.md","lib","node_modules","pnpm-lock.yaml"]}",
},
}
`);
});
});
11 changes: 10 additions & 1 deletion src/blocks/blockCSpell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { resolveBin } from "../utils/resolveBin.js";
import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js";
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
import { blockPackageJson } from "./blockPackageJson.js";
import { blockRemoveWorkflows } from "./blockRemoveWorkflows.js";
import { blockVSCode } from "./blockVSCode.js";
import { CommandPhase } from "./phases.js";

Expand Down Expand Up @@ -50,7 +51,6 @@ export const blockCSpell = base.createBlock({
steps: [{ run: "pnpm lint:spelling" }],
},
],
removedWorkflows: ["lint-spelling", "spelling"],
}),
blockPackageJson({
properties: {
Expand Down Expand Up @@ -93,4 +93,13 @@ export const blockCSpell = base.createBlock({
],
};
},
transition() {
return {
addons: [
blockRemoveWorkflows({
workflows: ["lint-spelling", "spelling"],
}),
],
};
},
});
25 changes: 9 additions & 16 deletions src/blocks/blockESLint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ describe("blockESLint", () => {
],
},
],
"removedWorkflows": [
"eslint",
"lint",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -194,10 +190,6 @@ describe("blockESLint", () => {
],
},
],
"removedWorkflows": [
"eslint",
"lint",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -271,6 +263,15 @@ describe("blockESLint", () => {
},
"block": [Function],
},
{
"addons": {
"workflows": [
"eslint",
"lint",
],
},
"block": [Function],
},
],
"files": {
"eslint.config.js": "import eslint from "@eslint/js";
Expand Down Expand Up @@ -388,10 +389,6 @@ describe("blockESLint", () => {
],
},
],
"removedWorkflows": [
"eslint",
"lint",
],
},
"block": [Function],
},
Expand Down Expand Up @@ -538,10 +535,6 @@ describe("blockESLint", () => {
],
},
],
"removedWorkflows": [
"eslint",
"lint",
],
},
"block": [Function],
},
Expand Down
5 changes: 4 additions & 1 deletion src/blocks/blockESLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
import { blockPackageJson } from "./blockPackageJson.js";
import { blockRemoveDependencies } from "./blockRemoveDependencies.js";
import { blockRemoveFiles } from "./blockRemoveFiles.js";
import { blockRemoveWorkflows } from "./blockRemoveWorkflows.js";
import { blockVSCode } from "./blockVSCode.js";
import { CommandPhase } from "./phases.js";

Expand Down Expand Up @@ -161,7 +162,6 @@ Each should be shown in VS Code, and can be run manually on the command-line:
],
},
],
removedWorkflows: ["eslint", "lint"],
}),
blockPackageJson({
properties: {
Expand Down Expand Up @@ -239,6 +239,9 @@ export default tseslint.config(
blockRemoveFiles({
files: [".eslintrc*", ".eslintignore", "eslint.config.{cjs,mjs}"],
}),
blockRemoveWorkflows({
workflows: ["eslint", "lint"],
}),
],
};
},
Expand Down
52 changes: 49 additions & 3 deletions src/blocks/blockESLintPackageJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { blockESLintPackageJson } from "./blockESLintPackageJson.js";
import { optionsBase } from "./options.fakes.js";

describe("blockESLintPackageJson", () => {
test("production", () => {
test("without mode", () => {
const creation = testBlock(blockESLintPackageJson, {
options: optionsBase,
});
Expand All @@ -29,8 +29,38 @@ describe("blockESLintPackageJson", () => {
},
{
"addons": {
"removedWorkflows": [
"lint-package-json",
"properties": {
"scripts": {
"lint:package-json": undefined,
},
},
},
"block": [Function],
},
],
}
`);
});

test("transition mode", () => {
const creation = testBlock(blockESLintPackageJson, {
mode: "transition",
options: optionsBase,
});

expect(creation).toMatchInlineSnapshot(`
{
"addons": [
{
"addons": {
"extensions": [
"packageJson.configs.recommended",
],
"imports": [
{
"source": "eslint-plugin-package-json",
"specifier": "packageJson",
},
],
},
"block": [Function],
Expand All @@ -45,6 +75,14 @@ describe("blockESLintPackageJson", () => {
},
"block": [Function],
},
{
"addons": {
"files": [
".npmpackagejsonlintrc*",
],
},
"block": [Function],
},
{
"addons": {
"dependencies": [
Expand All @@ -54,6 +92,14 @@ describe("blockESLintPackageJson", () => {
},
"block": [Function],
},
{
"addons": {
"workflows": [
"lint-package-json",
],
},
"block": [Function],
},
],
}
`);
Expand Down
18 changes: 14 additions & 4 deletions src/blocks/blockESLintPackageJson.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { base } from "../base.js";
import { blockESLint } from "./blockESLint.js";
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
import { blockPackageJson } from "./blockPackageJson.js";
import { blockRemoveDependencies } from "./blockRemoveDependencies.js";
import { blockRemoveFiles } from "./blockRemoveFiles.js";
import { blockRemoveWorkflows } from "./blockRemoveWorkflows.js";

export const blockESLintPackageJson = base.createBlock({
about: {
Expand All @@ -20,22 +21,31 @@ export const blockESLintPackageJson = base.createBlock({
},
],
}),
blockGitHubActionsCI({
removedWorkflows: ["lint-package-json"],
}),
blockPackageJson({
properties: {
scripts: {
"lint:package-json": undefined,
},
},
}),
],
};
},
transition() {
return {
addons: [
blockRemoveFiles({
files: [".npmpackagejsonlintrc*"],
}),
blockRemoveDependencies({
dependencies: [
"npm-package-json-lint",
"npm-package-json-lint-config-default",
],
}),
blockRemoveWorkflows({
workflows: ["lint-package-json"],
}),
],
};
},
Expand Down
12 changes: 2 additions & 10 deletions src/blocks/blockGitHubActionsCI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const blockGitHubActionsCI = base.createBlock({
}),
)
.optional(),
removedWorkflows: z.array(z.string()).optional(),
},
produce({ addons, options }) {
const { jobs } = addons;
Expand Down Expand Up @@ -145,18 +144,11 @@ export const blockGitHubActionsCI = base.createBlock({
},
};
},
transition({ addons }) {
const { removedWorkflows = [] } = addons;
transition() {
return {
addons: [
blockRemoveFiles({
files: [
".circleci",
"travis.yml",
...removedWorkflows.map(
(removedWorkflow) => `.github/workflows/${removedWorkflow}.yml`,
),
],
files: [".circleci", "travis.yml"],
}),
],
};
Expand Down
Loading