Skip to content

Commit

Permalink
feat: add opt-in usage of create as underlying files engine (#1670)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #1181
- [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 an intentionally undocumented option for a `CTA_CREATE_ENGINE`
environment variable. It switches the file creation engine from the
current (now, legacy!) system to the [`create`
engine](https://github.com/JoshuaKGoldberg/create):

```shell
CTA_CREATE_ENGINE=true node ./bin/index.js ...
```

Next up after this will be to wholly remove the current/legacy files,
then move onto commands and network requests, then options parsing
altogether. Those will be followup PRs.

💝
  • Loading branch information
JoshuaKGoldberg authored Dec 7, 2024
1 parent 79412ab commit e6e1575
Show file tree
Hide file tree
Showing 77 changed files with 3,716 additions and 118 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">Create TypeScript App</h1>

<p align="center">Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 💝</p>
<p align="center">Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. ❤️‍🔥</p>

<p align="center">
<!-- prettier-ignore-start -->
Expand Down
5 changes: 4 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
],
"words": [
"allcontributors",
"Anson",
"apexskier",
"arethetypeswrong",
"automerge",
"codespace",
"dbaeumer",
"execa",
"infile",
"joshuakgoldberg",
"markdownlintignore",
"mtfoley",
"outro",
"tada",
"tseslint"
"tseslint",
"wontfix"
]
}
4 changes: 1 addition & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export default tseslint.config(
{
extends: [vitest.configs.recommended],
files: ["**/*.test.*"],
rules: {
"@typescript-eslint/no-unsafe-assignment": "off",
},
rules: { "@typescript-eslint/no-unsafe-assignment": "off" },
},
{
extends: [yml.configs["flat/recommended"], yml.configs["flat/prettier"]],
Expand Down
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/knip@latest/schema.json",
"entry": ["src/index.ts!", "script/*e2e.js"],
"entry": ["script/*e2e.js", "src/index.ts!", "src/**/*.test.*"],
"ignoreExportsUsedInFile": { "interface": true, "type": true },
"project": ["src/**/*.ts!", "script/**/*.js"]
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-typescript-app",
"version": "1.75.0",
"description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 💝",
"description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. ❤️‍🔥",
"repository": {
"type": "git",
"url": "https://github.com/JoshuaKGoldberg/create-typescript-app"
Expand Down Expand Up @@ -45,6 +45,7 @@
"@prettier/sync": "^0.5.2",
"all-contributors-for-repository": "^0.3.0",
"chalk": "^5.3.0",
"create": "0.1.0-alpha.0",
"execa": "^9.5.1",
"get-github-auth-token": "^0.1.0",
"git-remote-origin-url": "^4.0.0",
Expand All @@ -54,6 +55,7 @@
"npm-user": "^6.1.1",
"octokit": "^4.0.2",
"parse-author": "^2.0.0",
"parse-package-name": "^1.0.0",
"prettier": "^3.4.1",
"replace-in-file": "^8.2.0",
"rimraf": "^6.0.1",
Expand All @@ -76,6 +78,7 @@
"@vitest/eslint-plugin": "1.1.14",
"c8": "10.1.2",
"console-fail-test": "0.5.0",
"create-testers": "0.1.0-alpha.0",
"cspell": "8.16.1",
"eslint": "9.16.0",
"eslint-plugin-jsdoc": "50.6.0",
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 14 additions & 37 deletions script/__snapshots__/migrate-test-e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -114,42 +114,6 @@ exports[`expected file changes > README.md 1`] = `
+> 💙 This package was templated with [\`create-typescript-app\`](https://github.com/JoshuaKGoldberg/create-typescript-app)."
`;

exports[`expected file changes > cspell.json 1`] = `
"--- a/cspell.json
+++ b/cspell.json
@@ ... @@
".all-contributorsrc",
".github",
"CHANGELOG.md",
- "coverage*",
+ "coverage",
"lib",
"node_modules",
- "pnpm-lock.yaml",
- "script/__snapshots__"
+ "pnpm-lock.yaml"
],
"words": [
"allcontributors",
@@ ... @@
"arethetypeswrong",
"automerge",
"codespace",
- "execa",
+ "contributorsrc",
"infile",
"joshuakgoldberg",
"markdownlintignore",
"mtfoley",
"outro",
"tada",
- "tseslint"
+ "tseslint",
+ "wontfix"
]
}"
`;

exports[`expected file changes > eslint.config.js 1`] = `
"--- a/eslint.config.js
+++ b/eslint.config.js
Expand Down Expand Up @@ -238,14 +202,27 @@ exports[`expected file changes > knip.json 1`] = `
@@ ... @@
{
"$schema": "https://unpkg.com/knip@latest/schema.json",
- "entry": ["src/index.ts!", "script/*e2e.js"],
- "entry": ["script/*e2e.js", "src/index.ts!", "src/**/*.test.*"],
+ "entry": ["src/index.ts!"],
"ignoreExportsUsedInFile": { "interface": true, "type": true },
- "project": ["src/**/*.ts!", "script/**/*.js"]
+ "project": ["src/**/*.ts!"]
}"
`;
exports[`expected file changes > package.json 1`] = `
"--- a/package.json
+++ b/package.json
@@ ... @@
"lint-staged": "15.2.10",
"markdownlint": "0.36.1",
"markdownlint-cli": "0.43.0",
+ "prettier": "^3.4.1",
"prettier-plugin-curly": "0.3.1",
"prettier-plugin-packagejson": "2.5.6",
"prettier-plugin-sh": "0.14.0","
`;
exports[`expected file changes > tsconfig.json 1`] = `
"--- a/tsconfig.json
+++ b/tsconfig.json
Expand Down
5 changes: 4 additions & 1 deletion script/migrate-test-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ const filesExpectedToBeChanged = [
".github/workflows/ci.yml",
".gitignore",
".prettierignore",
"cspell.json",
"eslint.config.js",
"package.json",
"tsconfig.json",
];

const filesThatMightBeChanged = new Set([
// For now, ignore typos cspell is picking up from migration snapshots.
"cspell.json",

"script/__snapshots__/migrate-test-e2e.ts.snap",
...filesExpectedToBeChanged,
]);
Expand Down
23 changes: 16 additions & 7 deletions src/create/createWithOptions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { $ } from "execa";

import { withSpinner, withSpinners } from "../shared/cli/spinners.js";
import {
LabeledSpinnerTask,
withSpinner,
withSpinners,
} from "../shared/cli/spinners.js";
import { createCleanupCommands } from "../shared/createCleanupCommands.js";
import { doesRepositoryExist } from "../shared/doesRepositoryExist.js";
import { isUsingCreateEngine } from "../shared/isUsingCreateEngine.js";
import { GitHubAndOptions } from "../shared/options/readOptions.js";
import { addToolAllContributors } from "../steps/addToolAllContributors.js";
import { clearLocalGitTags } from "../steps/clearLocalGitTags.js";
Expand All @@ -20,12 +25,16 @@ export async function createWithOptions({ github, options }: GitHubAndOptions) {
await writeStructure(options);
},
],
[
"Writing README.md",
async () => {
await writeReadme(options);
},
],
...(isUsingCreateEngine()
? []
: [
[
"Writing README.md",
async () => {
await writeReadme(options);
},
] satisfies LabeledSpinnerTask<void>,
]),
]);

if (!options.excludeAllContributors && !options.skipAllContributorsApi) {
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export * from "./greet.js";

// If you're using create-typescript-app as a template, ignore these.
// They're plumbing for the create engine. :)
export * from "./next/blocks/index.js";
export { default } from "./next/template.js";

export * from "./types.js";
Loading

0 comments on commit e6e1575

Please sign in to comment.