### Running Interactive Setup with create-typescript-app (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Setup.md This command initiates the interactive setup process for a new TypeScript repository. When executed, it prompts the user for configuration details such as the directory, template preset, and initial information, then proceeds to initialize a Git repository, copy template files, and set up a new GitHub repository. ```shell npx create-typescript-app ``` -------------------------------- ### Setting Up a New Repository Locally (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/UseThisTemplate.md This snippet provides the shell commands to clone a newly created repository from the template and then install its dependencies and finalize setup using `npx create-typescript-app`. ```shell git clone https://github.com/YourUsername/YourRepositoryName cd YourRepositoryName npx create-typescript-app ``` -------------------------------- ### Initializing create-typescript-app CLI Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/CLI.md This command initializes the `create-typescript-app` CLI, prompting the user for required options if not explicitly provided. It's the basic way to start a new project, guiding the user through the setup process interactively. ```shell npx create-typescript-app ``` -------------------------------- ### Customizing create-typescript-app Setup (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Setup.md This command demonstrates how to customize the `create-typescript-app` setup process using command-line options. The `--mode create` flag ensures the creation mode is active, while `--exclude-templated-with` specifically omits the 'This package was templated with...' block from the generated output, allowing for a more tailored project setup. ```shell npx create-typescript-app --mode create --exclude-templated-with ``` -------------------------------- ### Initializing create-typescript-app with All Required Options Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/CLI.md This command initializes `create-typescript-app` by pre-populating all required base options: `--directory`, `--description`, and `--preset`. This allows for a fully automated setup without interactive prompts, ideal for scripting or consistent project creation. ```shell npx create-typescript-app --directory my-app --description "My app! 💖" --preset everything ``` -------------------------------- ### Initializing a New TypeScript App with npx Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/README.md This command initializes a new TypeScript application using the `create-typescript-app` utility. It should be run in an existing repository or the directory where a new repository is desired. This command requires Node.js and pnpm to be installed as prerequisites. ```Shell npx create-typescript-app ``` -------------------------------- ### Installing Project Dependencies (pnpm) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command uses pnpm to install all required project dependencies. pnpm is a disk-efficient package manager that caches packages globally and symlinks them into the project's node_modules. ```shell pnpm run install ``` -------------------------------- ### Initiating Repository Tooling Migration (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Transition.md This shell command executes the `create-typescript-app` script to initiate the migration of an existing repository's tooling. It automatically handles the uninstallation of old conflicting packages, deletion of their configuration files, installation of new template-specific packages, and creation/rewriting of new configuration files. ```shell npx create-typescript-app ``` -------------------------------- ### Specifying Multiple Values for Array Flags in create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/CLI.md This command shows how to provide multiple values for array flags, such as `--keywords`, by repeating the flag for each desired value. This example adds 'eslint' and 'typescript' to the project's keywords in `package.json`. ```shell npx create-typescript-app --keywords eslint --keywords typescript ``` -------------------------------- ### Running Unit Tests in Watch Mode (Vitest) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command starts Vitest in watch mode, continuously running unit tests as code changes are detected, providing fast feedback during development. ```shell pnpm run test ``` -------------------------------- ### Excluding Templated-With Block with CLI (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/UseThisTemplate.md This command demonstrates how to use the `npx create-typescript-app` CLI with the `--exclude-templated-with` option to prevent the 'This package was templated with...' block from being included during the setup process. ```shell npx create-typescript-app --exclude-templated-with ``` -------------------------------- ### Deduplicating Package Dependencies (pnpm) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command uses `pnpm dedupe` to optimize the project's `node_modules` by deduplicating package dependencies, which can reduce disk space usage and improve installation times. ```shell pnpm lint:packages ``` -------------------------------- ### Integrating Custom 'arethetypeswrong' Lint Block Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Configuration Files.md This configuration snippet demonstrates how to integrate a previously defined custom block, `blockLintAreTheTypesWrong`, into the `create-typescript-app` setup. By importing the custom block and adding it to `refinements.blocks.add`, the custom linting task will be applied when `npx create-typescript-app` is run. ```TypeScript // create-typescript-app.config.js import { createConfig } from "create-typescript-app"; import { blockLintAreTheTypesWrong } from "./blockLintAreTheTypesWrong.js"; export default createConfig({ refinements: { blocks: { add: [blockLintAreTheTypesWrong] } } }); ``` -------------------------------- ### Type Checking in Watch Mode (TypeScript) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command starts the TypeScript compiler in watch mode, continuously monitoring source files for changes and re-running type checks automatically, providing immediate feedback during development. ```shell pnpm run tsc --watch ``` -------------------------------- ### Replacing `tsup` with `ncc` in a TypeScript Project (Bash) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/FAQs.md These Bash commands remove the `tsup` build tool and add `@vercel/ncc` as a development dependency. `ncc` is used to bundle source files and their dependencies into a single JavaScript file, which is necessary for GitHub Actions that run without installing package dependencies. ```Bash pnpm remove tsup pnpm add @vercel/ncc -D ``` -------------------------------- ### Initializing create-typescript-app with a Specific Preset Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/CLI.md This command initializes `create-typescript-app` using the `--preset everything` option, which includes the most comprehensive tooling. It will still prompt for `description` and `directory` if these required options are not explicitly provided. ```shell npx create-typescript-app --preset everything ``` -------------------------------- ### Updating `package.json` Build Script to Use `ncc` (Diff) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/FAQs.md This diff shows the modification to the `build` script in `package.json`. It changes the build command from using `tsup` to using `ncc`, specifying `src/index.ts` as the entry point, `dist` as the output directory, and including license information. This ensures the project builds correctly with the new `ncc` bundler. ```Diff -"build": "tsup", +"build": "ncc build src/index.ts -o dist --license licenses.txt", ``` -------------------------------- ### Automating Build and `dist` Staging in Pre-commit Hook (Diff) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/FAQs.md This diff updates the `.husky/pre-commit` hook. It adds commands to run `pnpm run build` and `git add dist` before `lint-staged` executes. This ensures that the project is built and the `dist` directory is staged automatically on each commit, preventing uncommitted build changes. ```Diff +pnpm run build +git add dist npx lint-staged ``` -------------------------------- ### Running Tests with Coverage Tracking (Vitest) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command executes Vitest to run all unit tests once and simultaneously generates a code coverage report, providing insights into how much of the codebase is covered by tests. ```shell pnpm run test run --coverage ``` -------------------------------- ### Using ncc Builder with create-typescript-app (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command demonstrates how to initialize a new TypeScript application using `create-typescript-app` while explicitly opting for the `ncc` builder instead of the default `tsup`. It adds the `ncc` block and excludes the `tsup` block, customizing the build tool for the project. ```shell npx create-typescript-app --add-ncc --exclude-tsup ``` -------------------------------- ### Building Project Once with tsup (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command executes the build script defined in `package.json` using `pnpm`, which typically triggers `tsup` to compile TypeScript source files into JavaScript and declaration files. It performs a single, one-time build operation, generating output files in the `lib/` directory. ```shell pnpm run build ``` -------------------------------- ### Customizing Migration by Excluding Templated-With Block (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Transition.md This shell command runs the `create-typescript-app` migration with a specific CLI option to exclude the 'This package was templated with...' block. It demonstrates how to customize the migration process by passing flags to the `npx` command, allowing users to control specific aspects of the generated tooling. ```shell npx create-typescript-app --exclude-templated-with ``` -------------------------------- ### Auto-formatting Files with Prettier (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command uses `pnpm` to execute the `format` script, which typically invokes Prettier to automatically format all supported files in the project according to predefined style rules. The `--write` flag ensures that any detected formatting inconsistencies are corrected and saved directly to the files. ```shell pnpm run format --write ``` -------------------------------- ### Excluding Specific Tooling Blocks in create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/CLI.md This command initializes `create-typescript-app` while explicitly excluding a specific 'Block' of tooling, in this case, Renovate, using the `--exclude-renovate` flag. This allows for fine-grained control over which features and configurations are included in the generated project. ```shell npx create-typescript-app --exclude-renovate ``` -------------------------------- ### Linting Markdown Files (Markdownlint) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command runs Markdownlint to perform linting on Markdown files, ensuring consistent formatting and adherence to best practices for Markdown syntax. ```shell pnpm lint:md ``` -------------------------------- ### Running Unused Code Detection (Knip) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command executes Knip, a tool that detects unused files, dependencies, and code exports within the project, helping to identify dead code and optimize the codebase. ```shell pnpm run lint:knip ``` -------------------------------- ### Configuring `package.json` Exports for Dual CJS/ESM Emit (JSON) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/FAQs.md This JSON snippet demonstrates how to add an "exports" entry to `package.json` to support dual CommonJS (CJS) and ECMAScript Modules (ESM) output. It defines specific paths for `types`, `import` (ESM), and `require` (CJS) for the package's entry point, allowing consumers to use the appropriate module format. ```JSON { "exports": { ".": { "types": { "import": "lib/index.d.ts", "require": "lib/index.d.cts" }, "import": "lib/index.js", "require": "lib/index.cjs" } } } ``` -------------------------------- ### Building Project in Watch Mode with tsup (Shell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command runs the build script in watch mode, continuously monitoring source files for changes and automatically recompiling them using `tsup`. This is highly beneficial during development as it provides immediate feedback on code modifications without requiring manual rebuilds. ```shell pnpm run build --watch ``` -------------------------------- ### Linting All Files (ESLint) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command executes ESLint to perform static analysis on all JavaScript and TypeScript files in the project, detecting potential logical issues and enforcing consistent code style. ```shell pnpm run lint ``` -------------------------------- ### Adding 'arethetypeswrong' Block to create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Configuration Files.md This snippet illustrates how to include an additional block, specifically `blockAreTheTypesWrong`, to the project's configuration using `refinements.blocks.add`. This allows for integrating new tooling or features not provided by the default preset. ```TypeScript // create-typescript-app.config.js import { blockAreTheTypesWrong, createConfig } from "create-typescript-app"; export default createConfig({ refinements: { blocks: { add: [blockAreTheTypesWrong] } } }); ``` -------------------------------- ### Customizing Optional Flags in create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/CLI.md This command demonstrates how to customize optional flags like `--author` and `--funding` when initializing `create-typescript-app`. These values will override the inferred defaults based on the running system or existing configurations, providing fine-grained control over project metadata. ```shell npx create-typescript-app --author my-npm-username --funding MyGitHubOrganization ``` -------------------------------- ### Updating GitHub Actions Build Workflow for `dist` Validation (YAML) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/FAQs.md This YAML snippet updates the `build.yml` GitHub Actions workflow. It ensures that the `dist` directory is up-to-date after a build by comparing `dist/index.js` with the committed version. If uncommitted changes are detected, it fails the build and prompts the user to run `pnpm run build` locally. This is crucial for GitHub Actions that rely on built output being committed to a branch. ```YAML jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - run: pnpm build - name: Compare dist/index.js run: | if [ "$(git diff --ignore-space-at-eol --text dist/index.js | wc -l)" -gt "0" ]; then echo "Detected uncommitted changes after build." echo "You may need to run 'pnpm run build' locally and commit the changes." echo "" echo "See diff below:" echo "" git diff --ignore-space-at-eol --text dist/index.js echo "" # say this again in case the diff is long echo "You may need to run 'pnpm run build' locally and commit the changes." echo "" exit 1 fi name: Build on: pull_request: ~ push: branches: - main permissions: contents: read ``` -------------------------------- ### Updating Vitest Snapshots Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command runs Vitest in watch mode and automatically updates any outdated Vitest snapshots, which is useful when expected test outputs have legitimately changed. ```shell pnpm run test -u ``` -------------------------------- ### Auto-Fixing Linting Issues (ESLint) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command runs ESLint on all project files and automatically fixes any fixable rule violations, ensuring code style consistency and resolving detected issues. ```shell pnpm run lint --fix ``` -------------------------------- ### Performing One-Time Type Checking (TypeScript) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command executes the TypeScript compiler once to perform a full type check of the project's source code, ensuring type safety and catching potential type-related errors. ```shell pnpm run tsc ``` -------------------------------- ### Configuring Node.js Versions in create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Configuration Files.md This snippet demonstrates how to override the inferred Node.js engine versions by explicitly setting `minimum` and `pinned` values within the `options` property of the `create-typescript-app.config.js` file. This ensures the project uses specific Node.js versions regardless of existing `.nvmrc` or `package.json` configurations. ```TypeScript // create-typescript-app.config.js import { createConfig } from "create-typescript-app"; export default createConfig({ options: { node: { minimum: ">=20.19.0", pinned: "22.14.0" } } }); ``` -------------------------------- ### Defining Custom Block for 'arethetypeswrong' Lint Task Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Configuration Files.md This JavaScript snippet defines a custom block, `blockLintAreTheTypesWrong`, which adds `@arethetypeswrong/cli` as a dev dependency and a `lint:arethetypeswrong` script to the `package.json`. It leverages `blockPackageJson` to modify package properties, enabling seamless integration of custom linting tasks. ```JavaScript // blockLintAreTheTypesWrong.js import { base, blockPackageJson } from "create-typescript-app"; export const blockLintAreTheTypesWrong = base.createBlock({ about: { name: "Lint Are The Types Wrong" }, produce() { return { addons: [ blockPackageJson({ properties: { devDependencies: { "@arethetypeswrong/cli": "0.17.3" }, scripts: { "lint:arethetypeswrong": "attw --pack ." } } }) ] }; } }); ``` -------------------------------- ### Performing Spell Checking (CSpell) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Blocks.md This command runs CSpell to perform spell checking on the project's code and documentation, helping to detect typos based on a configurable user dictionary. ```shell pnpm lint:spelling ``` -------------------------------- ### Excluding `dist` Directory from Linting and Prettier (Diff) Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/FAQs.md This diff indicates adding `dist` to `.eslintignore` and `.prettierignore` files. Since the build process now emits output to the `dist` directory, this change prevents ESLint and Prettier from processing generated files, avoiding unnecessary checks and potential conflicts. ```Diff +dist ``` -------------------------------- ### Adding Custom Words to CSpell Block in create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Configuration Files.md This configuration snippet shows how to add custom words to the CSpell Block's addons using the `refinements.addons` property. By importing `blockCSpell` and providing an array of `words`, you can extend the spell-checking dictionary for the project. ```TypeScript // create-typescript-app.config.js import { blockCSpell, createConfig } from "create-typescript-app"; export default createConfig({ refinements: { addons: [ blockCSpell({ words: ["joshuakgoldberg"] }) ] } }); ``` -------------------------------- ### Excluding 'blockTemplatedBy' Block from create-typescript-app Source: https://github.com/joshuakgoldberg/create-typescript-app/blob/main/docs/Configuration Files.md This configuration demonstrates how to prevent a default block, such as `blockTemplatedBy`, from being included in the generated output using `refinements.blocks.exclude`. This is useful for customizing the project's generated content, like omitting the "This package was templated with..." notice in the README.md. ```TypeScript // create-typescript-app.config.js import { blockTemplatedBy, createConfig } from "create-typescript-app"; export default createConfig({ refinements: { blocks: { exclude: [blockTemplatedBy] } } }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.