Skip to content

Commit

Permalink
chore: use create's applyFilesToSystem with create engine (#1762)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #1761
- [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

Uses the (temporarily exported) `applyFilesToSystem` and
`createWritingFileSystem` APIs from `create`.

💖
  • Loading branch information
JoshuaKGoldberg authored Dec 11, 2024
1 parent 4849839 commit cb5cfa0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0",
"create": "0.1.0-alpha.1",
"execa": "^9.5.1",
"get-github-auth-token": "^0.1.0",
"git-remote-origin-url": "^4.0.0",
Expand Down Expand Up @@ -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.0",
"create-testers": "0.1.0-alpha.1",
"cspell": "8.16.1",
"eslint": "9.16.0",
"eslint-plugin-jsdoc": "50.6.0",
Expand Down
38 changes: 19 additions & 19 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/next/blocks/blockPrettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pnpm format --write
files: {
".husky": {
".gitignore": "_",
"pre-commit": "npx lint-staged",
"pre-commit": ["npx lint-staged", { mode: 0x777 }],
},
".prettierignore": ["/.husky", "/lib", "/pnpm-lock.yaml", ...ignores]
.sort()
Expand Down
13 changes: 6 additions & 7 deletions src/steps/writing/creation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ async function recursivelyFormat(files: CreatedFiles): Promise<Structure> {
const result: Structure = {};

for (const [key, value] of Object.entries(files)) {
switch (typeof value) {
case "object":
result[key] = await recursivelyFormat(value);
break;
case "string":
result[key] = await formatCreatedFile(key, value);
break;
if (Array.isArray(value)) {
result[key] = await formatCreatedFile(key, value[0]);
} else if (typeof value === "string") {
result[key] = await formatCreatedFile(key, value);
} else if (typeof value === "object") {
result[key] = await recursivelyFormat(value);
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/steps/writing/writeStructure.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { applyFilesToSystem, createWritingFileSystem } from "create";
import { $ } from "execa";

import { isUsingCreateEngine } from "../../shared/isUsingCreateEngine.js";
Expand All @@ -6,10 +7,15 @@ import { createStructure } from "./creation/index.js";
import { writeStructureWorker } from "./writeStructureWorker.js";

export async function writeStructure(options: Options) {
await writeStructureWorker(
await createStructure(options, isUsingCreateEngine()),
".",
);
const usingCreateEngine = isUsingCreateEngine();
const structure = await createStructure(options, usingCreateEngine);

if (usingCreateEngine) {
await applyFilesToSystem(structure, createWritingFileSystem(), ".");
return;
}

await writeStructureWorker(structure, ".");

try {
// https://github.com/JoshuaKGoldberg/create-typescript-app/issues/718
Expand Down

0 comments on commit cb5cfa0

Please sign in to comment.