Skip to content

Commit

Permalink
docs: streamlined and organized DEVELOPMENT.md (#1735)
Browse files Browse the repository at this point in the history
## PR Checklist

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

Mostly re-applies changes from #1670.

💖
  • Loading branch information
JoshuaKGoldberg authored Dec 3, 2024
1 parent 1094f0f commit 9f14f47
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
21 changes: 7 additions & 14 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Add `--watch` to run the builder in a watch mode that continuously cleans and re
pnpm build --watch
```

### Built App Debugging

This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging.
To debug a `bin` app, add a breakpoint to your code, then run _Debug Program_ from the VS Code Debug panel (or press F5).
VS Code will automatically run the `build` task in the background before running `./bin/index.js`.

## Formatting

[Prettier](https://prettier.io) is used to format code.
Expand Down Expand Up @@ -58,7 +64,7 @@ For example, ESLint can be run with `--fix` to auto-fix some lint rule complaint
pnpm run lint --fix
```

Note that you'll likely need to run `pnpm build` before `pnpm lint` so that lint rules which check the file system can pick up on any built files.
Note that you'll need to run `pnpm build` before `pnpm lint` so that lint rules which check the file system can pick up on any built files.

## Testing

Expand Down Expand Up @@ -99,19 +105,6 @@ Add `--watch` to keep the type checker running in a watch mode that updates the
pnpm tsc --watch
```

## Debugging

This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging.
Depending upon the type of usage, it can include debugging for unit tests _and_ for executable (or "bin") apps.

### Unit Tests

To debug a unit test, open a test file, then run _Debug Current Test File_ from the VS Code Debug panel (or press F5).

### `bin` Apps

To debug a `bin` app, add a breakpoint to your code, then run _Debug Program_ from the VS Code Debug panel (or press F5).

## Setup Scripts

As described in the `README.md` file and `docs/`, this template repository comes with three scripts that can set up an existing or new repository.
Expand Down
4 changes: 1 addition & 3 deletions script/__snapshots__/migrate-test-e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ exports[`expected file changes > cspell.json 1`] = `
"markdownlintignore",
"mtfoley",
"npmignore",
- "npmpackagejsonlintrc",
"outro",
- "packagejson",
@@ ... @@
"tada",
"tseslint",
"tsup",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("createDevelopment", () => {
- \`pnpm lint\` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files
- \`pnpm lint:knip\` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports
- \`pnpm lint:md\` ([Markdownlint](https://github.com/DavidAnson/markdownlint): Checks Markdown source files
- \`pnpm lint:md\` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files
- \`pnpm lint:packages\` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the \`pnpm-lock.yml\` file
- \`pnpm lint:spelling\` ([cspell](https://cspell.org)): Spell checks across all source files
Expand All @@ -99,7 +99,7 @@ describe("createDevelopment", () => {
pnpm run lint --fix
\`\`\`
Note that you'll likely need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.
Note that you'll need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.
## Testing
Expand Down Expand Up @@ -216,7 +216,7 @@ describe("createDevelopment", () => {
pnpm run lint --fix
\`\`\`
Note that you'll likely need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.
Note that you'll need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.
## Testing
Expand Down Expand Up @@ -303,7 +303,17 @@ Def 456.
## Building
Will be removed.
Run [**tsup**](https://tsup.egoist.dev) locally to build source files from \`src/\` into output files in \`lib/\`:
\`\`\`shell
pnpm build
\`\`\`
Add \`--watch\` to run the builder in a watch mode that continuously cleans and recreates \`lib/\` as you save files:
\`\`\`shell
pnpm build --watch
\`\`\`
## Formatting
Expand All @@ -323,7 +333,7 @@ Def 456.
- \`pnpm lint\` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files
- \`pnpm lint:knip\` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports
- \`pnpm lint:md\` ([Markdownlint](https://github.com/DavidAnson/markdownlint): Checks Markdown source files
- \`pnpm lint:md\` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files
- \`pnpm lint:packages\` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the \`pnpm-lock.yml\` file
- \`pnpm lint:spelling\` ([cspell](https://cspell.org)): Spell checks across all source files
Expand All @@ -335,7 +345,7 @@ Def 456.
pnpm run lint --fix
\`\`\`
Note that you'll likely need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.
Note that you'll need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.
## Testing
Expand Down
56 changes: 37 additions & 19 deletions src/steps/writing/creation/dotGitHub/createDevelopment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Add \`--watch\` to run the builder in a watch mode that continuously cleans and
\`\`\`shell
pnpm build --watch
\`\`\``,
...(options.bin && {
"### Built App Debugging": `This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging.
To debug a \`bin\` app, add a breakpoint to your code, then run _Debug Program_ from the VS Code Debug panel (or press F5).
VS Code will automatically run the \`build\` task in the background before running \`${options.bin}\`.`,
}),
"## Formatting": `[Prettier](https://prettier.io) is used to format code.
It should be applied automatically when you save files in VS Code or make a Git commit.
Expand All @@ -40,8 +45,7 @@ pnpm format --write
pnpm run lint --fix
\`\`\`
Note that you'll likely need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.`,

Note that you'll need to run \`pnpm build\` before \`pnpm lint\` so that lint rules which check the file system can pick up on any built files.`,
...(!options.excludeTests && {
"## Testing": `[Vitest](https://vitest.dev) is used for tests.
You can run it locally on the command-line:
Expand Down Expand Up @@ -83,14 +87,35 @@ pnpm tsc --watch
Object.keys(newSections).map((key) => key.replace(/^#* /, "")),
]);

const preservedSections = Object.fromEntries(
splitIntoSections(existingContents).filter(([key]) => {
const keyText = key.replace(/^#* /, "");
return !newSectionHeadings.has(
headingAliases.get(keyText.toLowerCase()) ?? keyText,
);
}),
);
const existingSectionsSplit = splitIntoSections(existingContents);
const preservedSectionsSplit = existingSectionsSplit.filter(([key]) => {
const keyText = key.replace(/^#* /, "");
return !newSectionHeadings.has(
headingAliases.get(keyText.toLowerCase()) ?? keyText,
);
});
const preservedSections = Object.fromEntries(preservedSectionsSplit);

const sectionLines: string[] = [];
const seen = new Set<string>();

for (const sections of [newSections, preservedSections]) {
for (const heading in sections) {
if (seen.has(heading)) {
continue;
}

seen.add(heading);

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const contents = sections[heading as keyof typeof sections]!;

sectionLines.push("");
sectionLines.push(heading);
sectionLines.push("");
sectionLines.push(contents);
}
}

const result = `# Development
${
Expand All @@ -111,14 +136,7 @@ pnpm install
> This repository includes a list of suggested VS Code extensions.
> It's a good idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion to install them, as they'll help with development.
${Object.entries({ ...newSections, ...preservedSections })
.map(
([heading, content]) => `${heading}
${content}`,
)
.join("\n\n")}
${sectionLines.join("\n")}
`;

return result;
Expand All @@ -129,7 +147,7 @@ function createLintingSection(options: Options) {
!options.excludeLintKnip &&
`- \`pnpm lint:knip\` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports`,
!options.excludeLintMd &&
`- \`pnpm lint:md\` ([Markdownlint](https://github.com/DavidAnson/markdownlint): Checks Markdown source files`,
`- \`pnpm lint:md\` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files`,
!options.excludeLintPackages &&
`- \`pnpm lint:packages\` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the \`pnpm-lock.yml\` file`,
!options.excludeLintSpelling &&
Expand Down

0 comments on commit 9f14f47

Please sign in to comment.