diff --git a/README.md b/README.md index 200ff669..d29e8df9 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Thanks! 💖 John Reilly
John Reilly

💻 🤔 🐛 🚧 📖 🔧 - Josh Goldberg
Josh Goldberg

🐛 💻 🚧 👀 🔧 📖 🚇 ⚠️ 🤔 + Josh Goldberg
Josh Goldberg

🔧 Joël Galeran
Joël Galeran

💻 Juan A.
Juan A.

💻 📖 Kristo Baricevic
Kristo Baricevic

💻 diff --git a/package.json b/package.json index a0f0d124..a8468223 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@prettier/sync": "^0.5.2", "all-contributors-for-repository": "^0.3.0", "chalk": "^5.3.0", - "create": "0.1.0-alpha.1", + "create": "0.1.0-alpha.3", "execa": "^9.5.1", "get-github-auth-token": "^0.1.0", "git-remote-origin-url": "^4.0.0", @@ -80,7 +80,7 @@ "@vitest/eslint-plugin": "1.1.14", "c8": "10.1.2", "console-fail-test": "0.5.0", - "create-testers": "0.1.0-alpha.1", + "create-testers": "0.1.0-alpha.3", "cspell": "8.16.1", "eslint": "9.16.0", "eslint-plugin-jsdoc": "50.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76b42f35..5beaaea3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ importers: specifier: ^5.3.0 version: 5.3.0 create: - specifier: 0.1.0-alpha.1 - version: 0.1.0-alpha.1 + specifier: 0.1.0-alpha.3 + version: 0.1.0-alpha.3 execa: specifier: ^9.5.1 version: 9.5.1 @@ -37,10 +37,10 @@ importers: version: 16.0.0 input-from-file: specifier: 0.1.0-alpha.0 - version: 0.1.0-alpha.0(create@0.1.0-alpha.1) + version: 0.1.0-alpha.0(create@0.1.0-alpha.3) input-from-file-json: specifier: 0.1.0-alpha.1 - version: 0.1.0-alpha.1(create@0.1.0-alpha.1) + version: 0.1.0-alpha.1(create@0.1.0-alpha.3) js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -121,8 +121,8 @@ importers: specifier: 0.5.0 version: 0.5.0 create-testers: - specifier: 0.1.0-alpha.1 - version: 0.1.0-alpha.1(create@0.1.0-alpha.1) + specifier: 0.1.0-alpha.3 + version: 0.1.0-alpha.3(create@0.1.0-alpha.3) cspell: specifier: 8.16.1 version: 8.16.1 @@ -1883,14 +1883,14 @@ packages: typescript: optional: true - create-testers@0.1.0-alpha.1: - resolution: {integrity: sha512-NSkwbkojgeubP5kRUboi81RnZ4X0PS0eE1KEjMP78jabrF/RotD++L2rvesTpr2dJ0pUACNW9bhpDOhMve0Jrw==} + create-testers@0.1.0-alpha.3: + resolution: {integrity: sha512-2PBTCn+9CcWT6hoqYRyh1aFOGk485dxOiGWE0vfNsdKYbYRdaGnOg3Gbhc354PQX9MyzojpP4rOM7ytFkUr3Ag==} engines: {node: '>=18'} peerDependencies: - create: 0.1.0-alpha.1 + create: 0.1.0-alpha.3 - create@0.1.0-alpha.1: - resolution: {integrity: sha512-yk0OhrKutpLKVBKfIwBIfxpLjKyANeG4r7exPpICkRF5wQfnCyPWK5+Ub8SrxrgsMimEfk0xUrlhmsGN6ZY99g==} + create@0.1.0-alpha.3: + resolution: {integrity: sha512-wYj56M08XZXuQm3r3QTX/bZVQYq31QoiyvbXcVq+i/xy5AJRHVfDMESSaoT2Y3AINtJRlCCiOJ92HULcFE9bqA==} engines: {node: '>=18'} hasBin: true @@ -5581,13 +5581,15 @@ snapshots: optionalDependencies: typescript: 5.7.2 - create-testers@0.1.0-alpha.1(create@0.1.0-alpha.1): + create-testers@0.1.0-alpha.3(create@0.1.0-alpha.3): dependencies: - create: 0.1.0-alpha.1 + create: 0.1.0-alpha.3 - create@0.1.0-alpha.1: + create@0.1.0-alpha.3: dependencies: execa: 9.5.1 + get-github-auth-token: 0.1.0 + octokit: 4.0.2 zod: 3.23.8 cross-spawn@7.0.6: @@ -6459,15 +6461,15 @@ snapshots: ini@4.1.1: {} - input-from-file-json@0.1.0-alpha.1(create@0.1.0-alpha.1): + input-from-file-json@0.1.0-alpha.1(create@0.1.0-alpha.3): dependencies: - create: 0.1.0-alpha.1 - input-from-file: 0.1.0-alpha.0(create@0.1.0-alpha.1) + create: 0.1.0-alpha.3 + input-from-file: 0.1.0-alpha.0(create@0.1.0-alpha.3) zod: 3.23.8 - input-from-file@0.1.0-alpha.0(create@0.1.0-alpha.1): + input-from-file@0.1.0-alpha.0(create@0.1.0-alpha.3): dependencies: - create: 0.1.0-alpha.1 + create: 0.1.0-alpha.3 zod: 3.23.8 inquirer@9.3.2: diff --git a/src/bin/promptForMode.ts b/src/bin/promptForMode.ts index f4bcfc0d..8bb6ab43 100644 --- a/src/bin/promptForMode.ts +++ b/src/bin/promptForMode.ts @@ -5,6 +5,7 @@ import path from "node:path"; import * as process from "node:process"; import { logLine } from "../shared/cli/lines.js"; +import { isUsingCreateEngine } from "../shared/isUsingCreateEngine.js"; import { filterPromptCancel } from "../shared/prompts.js"; import { Mode, PromptedOptions } from "../shared/types.js"; @@ -41,7 +42,7 @@ export async function promptForMode( const dir = await fs.readdir("."); - if (dir.length === 0) { + if (dir.length === 0 && !isUsingCreateEngine()) { const mode = filterPromptCancel( (await prompts.select({ message: chalk.blue("How would you like to use the template?"), diff --git a/src/create/createWithOptions.ts b/src/create/createWithOptions.ts index d0848b36..9c8bc6cd 100644 --- a/src/create/createWithOptions.ts +++ b/src/create/createWithOptions.ts @@ -1,5 +1,6 @@ import { $ } from "execa"; +import { runCreateEnginePreset } from "../next/runCreateEnginePreset.js"; import { LabeledSpinnerTask, withSpinner, @@ -18,6 +19,13 @@ import { writeReadme } from "../steps/writeReadme/index.js"; import { writeStructure } from "../steps/writing/writeStructure.js"; export async function createWithOptions({ github, options }: GitHubAndOptions) { + if (isUsingCreateEngine()) { + await withSpinner("Creating repository", async () => { + await runCreateEnginePreset(options); + }); + return { sentToGitHub: false }; + } + await withSpinners("Creating repository structure", [ [ "Writing structure", @@ -25,16 +33,12 @@ export async function createWithOptions({ github, options }: GitHubAndOptions) { await writeStructure(options); }, ], - ...(isUsingCreateEngine() - ? [] - : [ - [ - "Writing README.md", - async () => { - await writeReadme(options); - }, - ] satisfies LabeledSpinnerTask, - ]), + [ + "Writing README.md", + async () => { + await writeReadme(options); + }, + ] satisfies LabeledSpinnerTask, ]); if (!options.excludeAllContributors && !options.skipAllContributorsApi) { diff --git a/src/next/base.ts b/src/next/base.ts index 550c11ce..69186bdb 100644 --- a/src/next/base.ts +++ b/src/next/base.ts @@ -172,6 +172,10 @@ export const base = createBase({ version, }; }, + template: { + owner: "JoshuaKGoldberg", + repository: "create-typescript-app", + }, }); export type BaseOptions = BaseOptionsFor; diff --git a/src/next/blocks/blockAllContributors.ts b/src/next/blocks/blockAllContributors.ts index 33b0dbf8..5391d6ce 100644 --- a/src/next/blocks/blockAllContributors.ts +++ b/src/next/blocks/blockAllContributors.ts @@ -1,6 +1,7 @@ import { createSoloWorkflowFile } from "../../steps/writing/creation/dotGitHub/createSoloWorkflowFile.js"; import { base } from "../base.js"; import { blockPrettier } from "./blockPrettier.js"; +import { CommandPhase } from "./phases.js"; export const blockAllContributors = base.createBlock({ about: { @@ -13,10 +14,6 @@ export const blockAllContributors = base.createBlock({ ignores: ["/.all-contributorsrc"], }), ], - commands: - options.login === "JoshuaKGoldberg" - ? [`npx -y all-contributors-cli add JoshuaKGoldberg tool`] - : undefined, files: { ".all-contributorsrc": JSON.stringify({ badgeTemplate: @@ -55,6 +52,15 @@ export const blockAllContributors = base.createBlock({ }, }, }, + scripts: [ + { + commands: [ + `npx -y all-contributors-cli generate`, + `npx -y all-contributors-cli add ${options.owner} code,content,docs,ideas,infra,maintenance,projectManagement,tool`, + ], + phase: CommandPhase.Process, + }, + ], }; }, }); diff --git a/src/next/blocks/blockCSpell.ts b/src/next/blocks/blockCSpell.ts index b7ce0ffb..f5274244 100644 --- a/src/next/blocks/blockCSpell.ts +++ b/src/next/blocks/blockCSpell.ts @@ -7,6 +7,8 @@ import { blockPackageJson } from "./blockPackageJson.js"; import { blockVSCode } from "./blockVSCode.js"; import { getPackageDependencies } from "./packageData.js"; +const filesGlob = `"**" ".github/**/*"`; + export const blockCSpell = base.createBlock({ about: { name: "CSpell", @@ -46,7 +48,7 @@ export const blockCSpell = base.createBlock({ properties: { devDependencies: getPackageDependencies("cspell"), scripts: { - "lint:spelling": 'cspell "**" ".github/**/*"', + "lint:spelling": `cspell ${filesGlob}`, }, }, }), @@ -65,12 +67,6 @@ export const blockCSpell = base.createBlock({ ...(words.length && { words: words.sort() }), }), }, - package: { - devDependencies: getPackageDependencies("cspell"), - scripts: { - "lint:spelling": 'cspell "**" ".github/**/*"', - }, - }, }; }, }); diff --git a/src/next/blocks/blockESLint.ts b/src/next/blocks/blockESLint.ts index 2ef4c168..bd5dd124 100644 --- a/src/next/blocks/blockESLint.ts +++ b/src/next/blocks/blockESLint.ts @@ -9,6 +9,7 @@ import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js"; import { blockPackageJson } from "./blockPackageJson.js"; import { blockVSCode } from "./blockVSCode.js"; import { getPackageDependencies } from "./packageData.js"; +import { CommandPhase } from "./phases.js"; const zRuleOptions = z.union([ z.literal("error"), @@ -197,6 +198,12 @@ export default tseslint.config( ${extensionLines.join(",")} );`, }, + scripts: [ + { + commands: ["pnpm lint --fix"], + phase: CommandPhase.Process, + }, + ], }; }, }); diff --git a/src/next/blocks/blockExampleFiles.ts b/src/next/blocks/blockExampleFiles.ts new file mode 100644 index 00000000..b8bc8bf1 --- /dev/null +++ b/src/next/blocks/blockExampleFiles.ts @@ -0,0 +1,23 @@ +import { z } from "zod"; + +import { base } from "../base.js"; + +export const blockExampleFiles = base.createBlock({ + about: { + name: "Example Files", + }, + addons: { + files: z.record(z.string()).default({}), + }, + initialize({ addons }) { + return { + files: { + src: addons.files, + }, + }; + }, + // TODO: Make produce() optional (so base is generic on its definition) + produce() { + return {}; + }, +}); diff --git a/src/next/blocks/blockPackageJson.ts b/src/next/blocks/blockPackageJson.ts index 91488c68..828ca8f9 100644 --- a/src/next/blocks/blockPackageJson.ts +++ b/src/next/blocks/blockPackageJson.ts @@ -2,12 +2,14 @@ import sortPackageJson from "sort-package-json"; import { z } from "zod"; import { base } from "../base.js"; +import { CommandPhase } from "./phases.js"; export const blockPackageJson = base.createBlock({ about: { name: "Package JSON", }, addons: { + cleanupCommands: z.array(z.string()).default([]), // TODO: Find a zod package for this? properties: z .intersection( @@ -24,12 +26,6 @@ export const blockPackageJson = base.createBlock({ }, produce({ addons, options }) { return { - commands: [ - { - phase: 0, // TODO: ??? - script: "pnpm i", - }, - ], files: { "package.json": sortPackageJson( JSON.stringify({ @@ -77,6 +73,12 @@ export const blockPackageJson = base.createBlock({ }), ), }, + scripts: [ + { + commands: ["pnpm install", ...addons.cleanupCommands], + phase: CommandPhase.Install, + }, + ], }; }, }); diff --git a/src/next/blocks/blockPnpmDedupe.ts b/src/next/blocks/blockPnpmDedupe.ts index d5971f58..11131684 100644 --- a/src/next/blocks/blockPnpmDedupe.ts +++ b/src/next/blocks/blockPnpmDedupe.ts @@ -30,6 +30,7 @@ export const blockPnpmDedupe = base.createBlock({ ], }), blockPackageJson({ + cleanupCommands: ["pnpm dedupe --offline"], properties: { scripts: { "lint:packages": "pnpm dedupe --check", @@ -37,12 +38,6 @@ export const blockPnpmDedupe = base.createBlock({ }, }), ], - commands: [ - { - phase: 1, - script: "pnpm dedupe", - }, - ], }; }, }); diff --git a/src/next/blocks/blockPrettier.ts b/src/next/blocks/blockPrettier.ts index 6d98d138..bead7f67 100644 --- a/src/next/blocks/blockPrettier.ts +++ b/src/next/blocks/blockPrettier.ts @@ -7,6 +7,7 @@ import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js"; import { blockPackageJson } from "./blockPackageJson.js"; import { blockVSCode } from "./blockVSCode.js"; import { getPackageDependencies } from "./packageData.js"; +import { CommandPhase } from "./phases.js"; export const blockPrettier = base.createBlock({ about: { @@ -80,12 +81,6 @@ pnpm format --write settings: { "editor.defaultFormatter": "esbenp.prettier-vscode" }, }), ], - commands: [ - { - phase: 2, // TODO: ??? - script: "pnpm format --write", - }, - ], files: { ".husky": { ".gitignore": "_", @@ -101,6 +96,12 @@ pnpm format --write useTabs: true, }), }, + scripts: [ + { + commands: ["pnpm format --write"], + phase: CommandPhase.Format, + }, + ], }; }, }); diff --git a/src/next/blocks/blockTSup.ts b/src/next/blocks/blockTSup.ts index e3d24303..3797266a 100644 --- a/src/next/blocks/blockTSup.ts +++ b/src/next/blocks/blockTSup.ts @@ -6,6 +6,7 @@ import { blockESLint } from "./blockESLint.js"; import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js"; import { blockPackageJson } from "./blockPackageJson.js"; import { getPackageDependencies } from "./packageData.js"; +import { CommandPhase } from "./phases.js"; export const blockTSup = base.createBlock({ about: { @@ -14,7 +15,7 @@ export const blockTSup = base.createBlock({ addons: { entry: z.array(z.string()).default([]), }, - produce({ addons }) { + produce({ addons, options }) { const { entry } = addons; return { @@ -72,6 +73,14 @@ export default defineConfig({ }); `, }, + scripts: options.bin + ? [ + { + commands: ["pnpm build"], + phase: CommandPhase.Build, + }, + ] + : undefined, }; }, }); diff --git a/src/next/blocks/blockTypeScript.ts b/src/next/blocks/blockTypeScript.ts index 65f3cee5..b4acd1bf 100644 --- a/src/next/blocks/blockTypeScript.ts +++ b/src/next/blocks/blockTypeScript.ts @@ -1,5 +1,6 @@ import { base } from "../base.js"; import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js"; +import { blockExampleFiles } from "./blockExampleFiles.js"; import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js"; import { blockGitignore } from "./blockGitignore.js"; import { blockMarkdownlint } from "./blockMarkdownlint.js"; @@ -36,6 +37,33 @@ pnpm tsc --watch }, }, }), + blockExampleFiles({ + files: { + "greet.ts": `import { GreetOptions } from "./types.js"; + + export function greet(options: GreetOptions | string) { + const { + logger = console.log.bind(console), + message, + times = 1, + } = typeof options === "string" ? { message: options } : options; + + for (let i = 0; i < times; i += 1) { + logger(message); + } + } + `, + "index.ts": `export * from "./greet.js"; +export * from "./types.js"; +`, + "types.ts": `export interface GreetOptions { + logger?: (message: string) => void; + message: string; + times?: number; + } + `, + }, + }), blockGitignore({ ignores: ["/lib"], }), diff --git a/src/next/blocks/blockVitest.ts b/src/next/blocks/blockVitest.ts index d034b199..f3fb53fa 100644 --- a/src/next/blocks/blockVitest.ts +++ b/src/next/blocks/blockVitest.ts @@ -4,6 +4,7 @@ import { base } from "../base.js"; import { blockCSpell } from "./blockCSpell.js"; import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js"; import { blockESLint } from "./blockESLint.js"; +import { blockExampleFiles } from "./blockExampleFiles.js"; import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js"; import { blockGitignore } from "./blockGitignore.js"; import { blockPackageJson } from "./blockPackageJson.js"; @@ -78,6 +79,55 @@ Calls to \`console.log\`, \`console.warn\`, and other console methods will cause }, }, }), + blockExampleFiles({ + files: { + "greet.test.ts": `import { describe, expect, it, vi } from "vitest"; + +import { greet } from "./greet.js"; + +const message = "Yay, testing!"; + +describe("greet", () => { + it("logs to the console once when message is provided as a string", () => { + const logger = vi.spyOn(console, "log").mockImplementation(() => undefined); + + greet(message); + + expect(logger).toHaveBeenCalledWith(message); + expect(logger).toHaveBeenCalledTimes(1); + }); + + it("logs to the console once when message is provided as an object", () => { + const logger = vi.spyOn(console, "log").mockImplementation(() => undefined); + + greet({ message }); + + expect(logger).toHaveBeenCalledWith(message); + expect(logger).toHaveBeenCalledTimes(1); + }); + + it("logs once when times is not provided in an object", () => { + const logger = vi.fn(); + + greet({ logger, message }); + + expect(logger).toHaveBeenCalledWith(message); + expect(logger).toHaveBeenCalledTimes(1); + }); + + it("logs a specified number of times when times is provided", () => { + const logger = vi.fn(); + const times = 7; + + greet({ logger, message, times }); + + expect(logger).toHaveBeenCalledWith(message); + expect(logger).toHaveBeenCalledTimes(7); + }); +}); +`, + }, + }), blockGitignore({ ignores: [`/${coverage.directory}`], }), diff --git a/src/next/blocks/phases.ts b/src/next/blocks/phases.ts new file mode 100644 index 00000000..58396462 --- /dev/null +++ b/src/next/blocks/phases.ts @@ -0,0 +1,9 @@ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable perfectionist/sort-enums */ + +export enum CommandPhase { + Install = 0, + Build = 1, + Process = 2, + Format = 3, +} diff --git a/src/next/presetMinimal.ts b/src/next/presetMinimal.ts index 04cbe662..df6bcb32 100644 --- a/src/next/presetMinimal.ts +++ b/src/next/presetMinimal.ts @@ -3,6 +3,7 @@ import { blockContributingDocs } from "./blocks/blockContributingDocs.js"; import { blockContributorCovenant } from "./blocks/blockContributorCovenant.js"; import { blockDevelopmentDocs } from "./blocks/blockDevelopmentDocs.js"; import { blockESLint } from "./blocks/blockESLint.js"; +import { blockExampleFiles } from "./blocks/blockExampleFiles.js"; import { blockFunding } from "./blocks/blockFunding.js"; import { blockGitHubActionsCI } from "./blocks/blockGitHubActionsCI.js"; import { blockGitHubIssueTemplates } from "./blocks/blockGitHubIssueTemplates.js"; @@ -27,6 +28,7 @@ export const presetMinimal = base.createPreset({ blockContributorCovenant, blockDevelopmentDocs, blockESLint, + blockExampleFiles, blockFunding, blockGitHubActionsCI, blockGitHubIssueTemplates, diff --git a/src/next/runCreateEnginePreset.ts b/src/next/runCreateEnginePreset.ts new file mode 100644 index 00000000..bf2b1309 --- /dev/null +++ b/src/next/runCreateEnginePreset.ts @@ -0,0 +1,23 @@ +import { runPreset } from "create"; + +import { Options } from "../shared/types.js"; +import { presetCommon } from "./presetCommon.js"; +import { presetEverything } from "./presetEverything.js"; +import { presetMinimal } from "./presetMinimal.js"; + +const presets = { + common: presetCommon, + everything: presetEverything, + minimal: presetMinimal, +}; + +export async function runCreateEnginePreset(options: Options) { + const preset = + options.base && options.base !== "prompt" && presets[options.base]; + + if (!preset) { + throw new Error(`Cannot yet use create engine with base ${options.base}.`); + } + + await runPreset(preset, { mode: "new", options }); +} diff --git a/src/shared/options/ensureRepositoryExists.ts b/src/shared/options/ensureRepositoryExists.ts index 2187b8b2..08b0ee40 100644 --- a/src/shared/options/ensureRepositoryExists.ts +++ b/src/shared/options/ensureRepositoryExists.ts @@ -1,6 +1,7 @@ import * as prompts from "@clack/prompts"; import { doesRepositoryExist } from "../doesRepositoryExist.js"; +import { isUsingCreateEngine } from "../isUsingCreateEngine.js"; import { filterPromptCancel } from "../prompts.js"; import { Options } from "../types.js"; import { createRepositoryWithApi } from "./createRepositoryWithApi.js"; @@ -27,7 +28,10 @@ export async function ensureRepositoryExists( // We'll continuously pester the user for a repository // until they bail, create a new one, or it exists. while (github) { - if (await doesRepositoryExist(github.octokit, options)) { + if ( + isUsingCreateEngine() || + (await doesRepositoryExist(github.octokit, options)) + ) { return { github, repository }; } diff --git a/src/steps/finalizeDependencies.ts b/src/steps/finalizeDependencies.ts index 518f2baa..ffb123e1 100644 --- a/src/steps/finalizeDependencies.ts +++ b/src/steps/finalizeDependencies.ts @@ -1,73 +1,66 @@ import { execaCommand } from "execa"; -import { isUsingCreateEngine } from "../shared/isUsingCreateEngine.js"; import { readPackageData, removeDependencies } from "../shared/packages.js"; import { Options } from "../shared/types.js"; export async function finalizeDependencies(options: Options) { - if (isUsingCreateEngine()) { - // TODO: How to switch from "latest" to the actual versions? - // Maybe an eslint-plugin-package-json lint rule? - await execaCommand("pnpm install"); - } else { - const devDependencies = [ - "@eslint/js", - "@types/node", - "eslint-plugin-n", - "eslint", - "husky", - "lint-staged", - "prettier-plugin-curly", - "prettier-plugin-packagejson", - "prettier-plugin-sh", - "prettier", - "tsup", - "typescript-eslint", - "typescript", - ...(options.excludeAllContributors ? [] : ["all-contributors-cli"]), - ...(options.excludeLintESLint - ? [] - : ["@eslint-community/eslint-plugin-eslint-comments"]), - ...(options.excludeLintJSDoc ? [] : ["eslint-plugin-jsdoc"]), - ...(options.excludeLintJson ? [] : ["eslint-plugin-jsonc"]), - ...(options.excludeLintKnip ? [] : ["knip"]), - ...(options.excludeLintMd - ? [] - : [ - "@types/eslint-plugin-markdown", - "eslint-plugin-markdown", - "markdownlint", - "markdownlint-cli", - "sentences-per-line", - ]), - ...(options.excludeLintPackageJson ? [] : ["eslint-plugin-package-json"]), - ...(options.excludeLintPerfectionist - ? [] - : ["eslint-plugin-perfectionist"]), - ...(options.excludeLintRegex ? [] : ["eslint-plugin-regexp"]), - ...(options.excludeLintSpelling ? [] : ["cspell"]), - ...(options.excludeLintYml ? [] : ["eslint-plugin-yml"]), - ...(options.excludeReleases - ? [] - : ["@release-it/conventional-changelog", "release-it"]), - ...(options.excludeTests - ? [] - : [ - "@vitest/coverage-v8", - "@vitest/eslint-plugin", - "console-fail-test", - "vitest", - ]), - ] - .filter(Boolean) - .sort() - .map((packageName) => `${packageName}@latest`) - .join(" "); + const devDependencies = [ + "@eslint/js", + "@types/node", + "eslint-plugin-n", + "eslint", + "husky", + "lint-staged", + "prettier-plugin-curly", + "prettier-plugin-packagejson", + "prettier-plugin-sh", + "prettier", + "tsup", + "typescript-eslint", + "typescript", + ...(options.excludeAllContributors ? [] : ["all-contributors-cli"]), + ...(options.excludeLintESLint + ? [] + : ["@eslint-community/eslint-plugin-eslint-comments"]), + ...(options.excludeLintJSDoc ? [] : ["eslint-plugin-jsdoc"]), + ...(options.excludeLintJson ? [] : ["eslint-plugin-jsonc"]), + ...(options.excludeLintKnip ? [] : ["knip"]), + ...(options.excludeLintMd + ? [] + : [ + "@types/eslint-plugin-markdown", + "eslint-plugin-markdown", + "markdownlint", + "markdownlint-cli", + "sentences-per-line", + ]), + ...(options.excludeLintPackageJson ? [] : ["eslint-plugin-package-json"]), + ...(options.excludeLintPerfectionist + ? [] + : ["eslint-plugin-perfectionist"]), + ...(options.excludeLintRegex ? [] : ["eslint-plugin-regexp"]), + ...(options.excludeLintSpelling ? [] : ["cspell"]), + ...(options.excludeLintYml ? [] : ["eslint-plugin-yml"]), + ...(options.excludeReleases + ? [] + : ["@release-it/conventional-changelog", "release-it"]), + ...(options.excludeTests + ? [] + : [ + "@vitest/coverage-v8", + "@vitest/eslint-plugin", + "console-fail-test", + "vitest", + ]), + ] + .filter(Boolean) + .sort() + .map((packageName) => `${packageName}@latest`) + .join(" "); - await execaCommand( - `pnpm add ${devDependencies} -D${options.offline ? " --offline" : ""}`, - ); - } + await execaCommand( + `pnpm add ${devDependencies} -D${options.offline ? " --offline" : ""}`, + ); if (!options.excludeAllContributors) { await execaCommand(`npx all-contributors-cli generate`); diff --git a/src/steps/uninstallPackages.ts b/src/steps/uninstallPackages.ts index b3a93ab0..9354c351 100644 --- a/src/steps/uninstallPackages.ts +++ b/src/steps/uninstallPackages.ts @@ -10,6 +10,7 @@ export async function uninstallPackages(offline: boolean | undefined) { "@clack/prompts", "@prettier/sync", "all-contributors-for-repository", + "all-contributors-cli", "chalk", "create", "execa", diff --git a/src/steps/writing/creation/index.ts b/src/steps/writing/creation/index.ts index 767bdac1..1cb7145a 100644 --- a/src/steps/writing/creation/index.ts +++ b/src/steps/writing/creation/index.ts @@ -29,13 +29,12 @@ export async function createStructure( presets[options.base]; if (preset) { - const creation = await producePreset(preset, { options }); - - return await recursivelyFormat({ - ...creation.files, - // TODO: Add a "starting files" option in create Presets/Templates? - src: await createSrc(options), + const { creation } = await producePreset(preset, { + mode: "new", + options, }); + + return await recursivelyFormat(creation.files); } return {