From b623e33888ee829e005c5669af6c6a54585011b4 Mon Sep 17 00:00:00 2001 From: xav-ie Date: Sat, 8 Mar 2025 20:54:04 -0500 Subject: [PATCH 1/2] fix(husky): use pnpx Defaulting to npx causes users to unexpectedly also have npx installed. --- .husky/pre-commit | 2 +- docs/FAQs.md | 2 +- src/blocks/blockPrettier.test.ts | 6 +++--- src/blocks/blockPrettier.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 2312dc587..09dd6bf4f 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -npx lint-staged +pnpx lint-staged diff --git a/docs/FAQs.md b/docs/FAQs.md index 9b1567824..c3cb37565 100644 --- a/docs/FAQs.md +++ b/docs/FAQs.md @@ -93,7 +93,7 @@ Here we'll outline the steps required to migrate a CTA app to a GitHub Action: ```diff +pnpm run build +git add dist - npx lint-staged + pnpx lint-staged ``` 2. Create an [`action.yml` metadata file](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#creating-an-action-metadata-file). diff --git a/src/blocks/blockPrettier.test.ts b/src/blocks/blockPrettier.test.ts index 72a447034..ef29cd6d9 100644 --- a/src/blocks/blockPrettier.test.ts +++ b/src/blocks/blockPrettier.test.ts @@ -91,7 +91,7 @@ describe("blockPrettier", () => { ".gitignore": "_ ", "pre-commit": [ - "npx lint-staged + "pnpx lint-staged ", { "executable": true, @@ -203,7 +203,7 @@ describe("blockPrettier", () => { ".gitignore": "_ ", "pre-commit": [ - "npx lint-staged + "pnpx lint-staged ", { "executable": true, @@ -333,7 +333,7 @@ describe("blockPrettier", () => { ".gitignore": "_ ", "pre-commit": [ - "npx lint-staged + "pnpx lint-staged ", { "executable": true, diff --git a/src/blocks/blockPrettier.ts b/src/blocks/blockPrettier.ts index 4df257872..3c3892a38 100644 --- a/src/blocks/blockPrettier.ts +++ b/src/blocks/blockPrettier.ts @@ -85,7 +85,7 @@ pnpm format --write files: { ".husky": { ".gitignore": "_\n", - "pre-commit": ["npx lint-staged\n", { executable: true }], + "pre-commit": ["pnpx lint-staged\n", { executable: true }], }, ".prettierignore": formatIgnoreFile( ["/.husky", "/lib", "/pnpm-lock.yaml", ...ignores].sort(), From c5e7b7172149c14347b85992a449367f50842d5a Mon Sep 17 00:00:00 2001 From: xav-ie Date: Sat, 8 Mar 2025 21:35:58 -0500 Subject: [PATCH 2/2] chore(npx): migrate to pnpx These edge cases cause users to have both npx and pnpx installed. `pnpx` is faster and simplifies environment setup. --- README.md | 4 ++-- docs/Options.md | 10 +++++----- docs/Setup.md | 6 +++--- docs/Transition.md | 6 +++--- docs/UseThisTemplate.md | 6 +++--- src/blocks/blockAreTheTypesWrong.test.ts | 2 +- src/blocks/blockAreTheTypesWrong.ts | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6ce46fc93..153c34f1a 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ First make sure you have the following installed: Then in an existing repository or in your directory where you'd like to make a new repository: ```shell -npx create-typescript-app +pnpx create-typescript-app ``` You can read more about the supported runtime modes in their docs pages: @@ -51,7 +51,7 @@ You can read more about `create-typescript-app` and the tooling it supports: 2. [**Options**](./docs/Options.md): granular options to customize how the template is run. 3. [**FAQs**](./docs/FAQs.md): frequently asked questions -> [!NOTE] +> [!NOTE] > This template is early stage, opinionated, and not endorsed by the TypeScript team. > It can be configured to set up a _lot_ of tooling out of the box. > If you don't want to use any particular tool, you can always remove it manually. diff --git a/docs/Options.md b/docs/Options.md index b31fe2cda..9d1c10ce1 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -3,7 +3,7 @@ `create-typescript-app` is built on top of [Bingo](https://create.bingo). It supports all the flags supported by [Bingo CLIs](https://www.create.bingo/cli). -`npx create-typescript-app` provides three `--preset` options: +`pnpx create-typescript-app` provides three `--preset` options: 1. **Minimal**: Just bare starter tooling: building, formatting, linting, and type checking. 2. **Common**: Bare starters plus testing and automation for all-contributors and releases. @@ -12,7 +12,7 @@ It supports all the flags supported by [Bingo CLIs](https://www.create.bingo/cli For example, to create a new repository with the _Everything_ preset: ```shell -npx create-typescript-app --preset everything +pnpx create-typescript-app --preset everything ``` `create-typescript-app` itself adds in two sections of flags: @@ -35,7 +35,7 @@ Each will be prompted for when creating a new repository if not explicitly provi For example, pre-populating all required base options: ```shell -npx create-typescript-app --directory my-typescript-app --description "My awesome TypeScript app! 💖" --preset everything +pnpx create-typescript-app --directory my-typescript-app --description "My awesome TypeScript app! 💖" --preset everything ``` That script will run completely autonomously, no prompted inputs required. ✨ @@ -58,7 +58,7 @@ They will be inferred from the running user, and if migrating an existing reposi For example, customizing the npm author and funding source: ```shell -npx create-typescript-app --author my-npm-username --funding MyGitHubOrganization +pnpx create-typescript-app --author my-npm-username --funding MyGitHubOrganization ``` ## Block Exclusions @@ -67,7 +67,7 @@ Per [Bingo > Stratum > Configurations > `blocks`](https://www.create.bingo/engin For example, initializing with all tooling except for Renovate: ```shell -npx create-typescript-app --exclude-renovate +pnpx create-typescript-app --exclude-renovate ``` See [Blocks.md](./Blocks.md) for the list of blocks and their corresponding presets. diff --git a/docs/Setup.md b/docs/Setup.md index ae36930ee..383985adc 100644 --- a/docs/Setup.md +++ b/docs/Setup.md @@ -1,9 +1,9 @@ # Setup Mode -You can run `npx create-typescript-app` in your terminal to interactively create a new repository: +You can run `pnpx create-typescript-app` in your terminal to interactively create a new repository: ```shell -npx create-typescript-app +pnpx create-typescript-app ``` The setup script will by default: @@ -34,7 +34,7 @@ See [Options.md](./Options.md). For example, skipping the _"This package was templated with..."_ block: ```shell -npx create-typescript-app --mode create --exclude-templated-with +pnpx create-typescript-app --mode create --exclude-templated-with ``` See [Blocks.md](./Blocks.md) for details on the tooling pieces and which presets they're included in. diff --git a/docs/Transition.md b/docs/Transition.md index fc6e8c17f..2158f0ab3 100644 --- a/docs/Transition.md +++ b/docs/Transition.md @@ -1,9 +1,9 @@ # Transition Mode -If you have an existing repository that you'd like to migrate to the files from this template, you can run `npx create-typescript-app` in it to "migrate" its tooling to this template's. +If you have an existing repository that you'd like to migrate to the files from this template, you can run `pnpx create-typescript-app` in it to "migrate" its tooling to this template's. ```shell -npx create-typescript-app +pnpx create-typescript-app ``` The transition script will: @@ -46,7 +46,7 @@ See [Options.md](./Options.md). For example, skipping the _"This package was templated with..."_ block: ```shell -npx create-typescript-app --exclude-templated-with +pnpx create-typescript-app --exclude-templated-with ``` See [Blocks.md](./Blocks.md) for details on the tooling pieces and which presets they're included in. diff --git a/docs/UseThisTemplate.md b/docs/UseThisTemplate.md index 28f897532..74503d6ca 100644 --- a/docs/UseThisTemplate.md +++ b/docs/UseThisTemplate.md @@ -1,12 +1,12 @@ # Using the Template Repository -As an alternative to [creating with `npx create-typescript-app`](./Setup.md), the [_Use this template_](https://github.com/JoshuaKGoldberg/create-typescript-app/generate) button on GitHub can be used to quickly create a new repository from the template. +As an alternative to [creating with `pnpx create-typescript-app`](./Setup.md), the [_Use this template_](https://github.com/JoshuaKGoldberg/create-typescript-app/generate) button on GitHub can be used to quickly create a new repository from the template. You can set up the new repository locally by cloning it and installing packages: ```shell git clone https://github.com/YourUsername/YourRepositoryName cd YourRepositoryName -npx create-typescript-app +pnpx create-typescript-app ``` You'll then need to manually go through the following two steps to set up tooling on GitHub: @@ -29,7 +29,7 @@ See [Options.md](./Options.md). For example, skipping the _"This package was templated with..."_ block: ```shell -npx create-typescript-app --exclude-templated-with +pnpx create-typescript-app --exclude-templated-with ``` See [Blocks.md](./Blocks.md) for details on the tooling pieces and which presets they're included in. diff --git a/src/blocks/blockAreTheTypesWrong.test.ts b/src/blocks/blockAreTheTypesWrong.test.ts index 26cc38c37..9ac113b5b 100644 --- a/src/blocks/blockAreTheTypesWrong.test.ts +++ b/src/blocks/blockAreTheTypesWrong.test.ts @@ -23,7 +23,7 @@ describe("blockAreTheTypesWrong", () => { "run": "pnpm build", }, { - "run": "npx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm", + "run": "pnpx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm", }, ], }, diff --git a/src/blocks/blockAreTheTypesWrong.ts b/src/blocks/blockAreTheTypesWrong.ts index fe16041f1..e32095c2a 100644 --- a/src/blocks/blockAreTheTypesWrong.ts +++ b/src/blocks/blockAreTheTypesWrong.ts @@ -15,7 +15,7 @@ export const blockAreTheTypesWrong = base.createBlock({ steps: [ { run: "pnpm build" }, { - run: "npx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm", + run: "pnpx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm", }, ], },