Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove ./ prefixes in package.json bin and main #1871

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pnpm build --watch

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`.
VS Code will automatically run the `build` task in the background before running `bin/index.js`.

## Formatting

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm build
- run: node ./lib/index.js --version
- run: node lib/index.js --version
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"name": "Debug Program",
"preLaunchTask": "build",
"program": "./bin/index.js",
"program": "bin/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
Expand Down
10 changes: 5 additions & 5 deletions docs/FAQs.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ Then:
"exports": {
".": {
"types": {
"import": "./lib/index.d.ts",
"require": "./lib/index.d.cts"
"import": "lib/index.d.ts",
"require": "lib/index.d.cts"
},
"import": "./lib/index.js",
"require": "./lib/index.cjs"
"import": "lib/index.js",
"require": "lib/index.cjs"
}
}
}
Expand Down Expand Up @@ -222,7 +222,7 @@ If you really want spaces in your project you can always remove the `"useTabs":
## How can I use `bin`?

The `--bin` option allows you to create a `package.json` bin value to include for npx-style running.
An example of this would be `"./bin/index.js"`.
An example of this would be `"bin/index.js"`.
You'll need to create the folders and files that `bin` references.

If you'd like an example of what that looks like, take a look at the [CTA source code](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/e7fafcb8968f8f6c551ab0917c9a6a849a3cba28/bin/index.js)!
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"email": "[email protected]"
},
"type": "module",
"main": "./lib/index.js",
"bin": "./bin/index.js",
"main": "lib/index.js",
"bin": "bin/index.js",
"files": [
"LICENSE.md",
"README.md",
Expand All @@ -24,7 +24,7 @@
"scripts": {
"build": "tsup",
"format": "prettier .",
"initialize": "pnpm build --no-dts && tsx ./bin/index.js --mode initialize",
"initialize": "pnpm build --no-dts && tsx bin/index.js --mode initialize",
"lint": "eslint . --max-warnings 0",
"lint:knip": "knip",
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
Expand Down
4 changes: 2 additions & 2 deletions script/__snapshots__/migrate-test-e2e.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ exports[`expected file changes > .github/workflows/ci.yml 1`] = `
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm build
- - run: node ./lib/index.js --version
+ - run: node ./lib/index.js
- - run: node lib/index.js --version
+ - run: node lib/index.js
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion script/create-test-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ await rimraf(["coverage*", repository]);
// asserting that pnpm i passes in that repository's directory.
await $({
stdio: "inherit",
})`c8 -o ./coverage-create -r html -r lcov --src src node ./bin/index.js --base everything --mode create --author ${author} --email ${email} --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api`;
})`c8 -o ./coverage-create -r html -r lcov --src src node bin/index.js --base everything --mode create --author ${author} --email ${email} --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api`;

process.chdir(repository);

Expand Down
2 changes: 1 addition & 1 deletion script/initialize-test-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ await $`pnpm i`;
await $`pnpm run build`;
await $({
stdio: "inherit",
})`c8 -o ./coverage -r html -r lcov --src src node ./bin/index.js --base everything --mode initialize --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api --skip-removal --skip-restore`;
})`c8 -o ./coverage -r html -r lcov --src src node bin/index.js --base everything --mode initialize --description ${description} --owner ${owner} --title ${title} --repository ${repository} --skip-all-contributors-api --skip-github-api --skip-removal --skip-restore`;
2 changes: 1 addition & 1 deletion script/migrate-test-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

await $({
stdio: "inherit",
})`c8 -o ./coverage -r html -r lcov --src src node ./bin/index.js --auto --mode migrate --skip-all-contributors-api --skip-github-api --skip-install`;
})`c8 -o ./coverage -r html -r lcov --src src node bin/index.js --auto --mode migrate --skip-all-contributors-api --skip-github-api --skip-install`;

// All Contributors seems to not be using Prettier to format files...
await fs.writeFile(
Expand Down Expand Up @@ -102,7 +102,7 @@

// If this fails, see .github/DEVELOPMENT.md > Setup Scripts for context.
// Then see .github/DEVELOPMENT.md > Migration Snapshot Failures.
expect(contentsAfterGitMarkers).toMatchSnapshot();

Check failure on line 105 in script/migrate-test-e2e.ts

View workflow job for this annotation

GitHub Actions / Test Migration Script

migrate-test-e2e.ts > expected file changes > README.md

Error: Snapshot `expected file changes > README.md 1` mismatched - Expected + Received @@ -1,12 +1,15 @@ "--- a/README.md +++ b/README.md @@ ... @@ <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">A very lovely package. Hooray!</p> + +<p align="center">Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 🎁</p> <p align="center"> <!-- prettier-ignore-start --> @@ ... @@ Thanks! 💖 ❯ migrate-test-e2e.ts:105:35

Check failure on line 105 in script/migrate-test-e2e.ts

View workflow job for this annotation

GitHub Actions / Test Migration Script

migrate-test-e2e.ts > expected file changes > eslint.config.js

Error: Snapshot `expected file changes > eslint.config.js 1` mismatched - Expected + Received @@ -28,17 +28,16 @@ + ignores: ["**/*.snap", "coverage", "lib", "node_modules", "pnpm-lock.yaml"], }, { linterOptions: { reportUnusedDisableDirectives: "error" } }, eslint.configs.recommended, @@ ... @@ export default tseslint.config( - files: ["**/*.js", "**/*.ts"], languageOptions: { parserOptions: { - - projectService: { + projectService: { - allowDefaultProject: ["*.config.*s", "bin/*.js"], - - }, - + projectService: { allowDefaultProject: ["*.config.*s"] }, + + allowDefaultProject: ["*.config.*s", "bin/index.js"], + }, tsconfigRootDir: import.meta.dirname, }, }, rules: { - // These on-by-default rules work well for this repo if configured @@ -62,5 +61,18 @@ - ], - // Stylistic concerns that don't interfere with Prettier "logical-assignment-operators": [ "error", + @@ ... @@ export default tseslint.config( + { + extends: [tseslint.configs.disableTypeChecked], + files: ["**/*.md/*.ts"], + + rules: { + + "n/no-missing-import": [ + + "error", + + { allowModules: ["create-typescript-app"] }, + + ], + + }, + }, + { + extends: [vitest.configs.recommended]," ❯ migrate-test-e2e.ts:105:35

Check failure on line 105 in script/migrate-test-e2e.ts

View workflow job for this annotation

GitHub Actions / Test Migration Script

migrate-test-e2e.ts > expected file changes > package.json

Error: Snapshot `expected file changes > package.json 1` mismatched - Expected + Received @@ -1,18 +1,9 @@ "--- a/package.json +++ b/package.json @@ ... @@ - { - "name": "create-typescript-app", - "version": "1.79.0", - - "description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 🎁", - + "description": "A very lovely package. Hooray! 💖", - "repository": { - "type": "git", - "url": "https://github.com/JoshuaKGoldberg/create-typescript-app" - @@ ... @@ - "lint-staged": "15.2.11", + "lint-staged": "15.3.0", "markdownlint": "0.37.2", "markdownlint-cli": "0.43.0", + "prettier": "^3.4.2", "prettier-plugin-curly": "0.3.1", "prettier-plugin-packagejson": "2.5.6", ❯ migrate-test-e2e.ts:105:35
});
});

Expand Down Expand Up @@ -134,7 +134,7 @@

console.log(`Stdout from running \`${gitDiffCommand}\`:\n${stdout}`);

throw new Error(

Check failure on line 137 in script/migrate-test-e2e.ts

View workflow job for this annotation

GitHub Actions / Test Migration Script

migrate-test-e2e.ts > unexpected file changes

Error: Oh no! Running the migrate script unexpectedly modified: - .all-contributorsrc - .github/workflows/release.yml See .github/DEVELOPMENT.md > Setup Scripts for context. Then see .github/DEVELOPMENT.md > Unexpected File Modifications. ❯ migrate-test-e2e.ts:137:9
[
"",
"Oh no! Running the migrate script unexpectedly modified:",
Expand Down
8 changes: 4 additions & 4 deletions src/next/blocks/blockPackageJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("blockPackageJson", () => {
expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"./lib/index.js","files":["README.md","package.json"]}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
},
"scripts": [
{
Expand All @@ -36,7 +36,7 @@ describe("blockPackageJson", () => {
expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"./lib/index.js","files":["README.md","package.json"]}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
},
"scripts": [
{
Expand Down Expand Up @@ -73,7 +73,7 @@ describe("blockPackageJson", () => {
expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"./lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"other":true}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"other":true}",
},
"scripts": [
{
Expand Down Expand Up @@ -108,7 +108,7 @@ describe("blockPackageJson", () => {
expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"./lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"devDependencies":{"is-even":"4.5.6"},"other":true}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"devDependencies":{"is-even":"4.5.6"},"other":true}",
},
"scripts": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/next/blocks/blockPackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const blockPackageJson = base.createBlock({
keyword.split(/ /),
),
license: "MIT",
main: "./lib/index.js",
main: "lib/index.js",
name: options.repository,
repository: {
type: "git",
Expand Down
6 changes: 3 additions & 3 deletions src/next/blocks/blockTSup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("blockTSup", () => {
"run": "pnpm build",
},
{
"run": "node ./lib/index.js",
"run": "node lib/index.js",
},
],
},
Expand Down Expand Up @@ -139,7 +139,7 @@ describe("blockTSup", () => {
"run": "pnpm build",
},
{
"run": "node ./lib/index.js",
"run": "node lib/index.js",
},
],
},
Expand Down Expand Up @@ -236,7 +236,7 @@ describe("blockTSup", () => {
"run": "pnpm build",
},
{
"run": "node ./lib/index.js",
"run": "node lib/index.js",
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/next/blocks/blockTSup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pnpm build --watch
steps: [
{ run: "pnpm build" },
{
run: `node ./lib/index.js${addons.runArgs.map((arg) => ` ${arg}`).join("")}`,
run: `node lib/index.js${addons.runArgs.map((arg) => ` ${arg}`).join("")}`,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/next/blocks/blockTypeScript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe("blockTypeScript", () => {
"files": [
"lib/",
],
"main": "./lib/index.js",
"main": "lib/index.js",
"scripts": {
"tsc": "tsc",
},
Expand Down Expand Up @@ -258,7 +258,7 @@ describe("blockTypeScript", () => {
"files": [
"lib/",
],
"main": "./lib/index.js",
"main": "lib/index.js",
"scripts": {
"tsc": "tsc",
},
Expand Down
2 changes: 1 addition & 1 deletion src/next/blocks/blockTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export * from "./types.js";
properties: {
devDependencies: getPackageDependencies("typescript"),
files: ["lib/"],
main: "./lib/index.js",
main: "lib/index.js",
scripts: {
tsc: "tsc",
},
Expand Down
2 changes: 1 addition & 1 deletion src/shared/options/createOptionDefaults/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("createOptionDefaults", () => {
});

it("returns the bin when package data has a bin", async () => {
const bin = "./lib/index.js";
const bin = "lib/index.js";

mockReadPackageData.mockResolvedValue({ bin });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const createOptions = (exclude: boolean) =>
({
access: "public",
base: "everything",
bin: exclude ? undefined : "./bin/index.js",
bin: exclude ? undefined : "bin/index.js",
description: "Test description.",
directory: ".",
email: {
Expand Down
6 changes: 3 additions & 3 deletions src/steps/writing/creation/dotGitHub/createWorkflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const createOptions = (exclude: boolean) =>
({
access: "public",
base: "everything",
bin: exclude ? undefined : "./bin/index.js",
bin: exclude ? undefined : "bin/index.js",
description: "Test description.",
directory: ".",
email: {
Expand Down Expand Up @@ -75,7 +75,7 @@ describe("createWorkflows", () => {
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm build
- run: node ./lib/index.js
- run: node lib/index.js
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down Expand Up @@ -320,7 +320,7 @@ describe("createWorkflows", () => {
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm build
- run: node ./lib/index.js
- run: node lib/index.js
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion src/steps/writing/creation/dotGitHub/createWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function createWorkflows(options: Options) {
jobs: [
{
name: "Build",
steps: [{ run: "pnpm build" }, { run: "node ./lib/index.js" }],
steps: [{ run: "pnpm build" }, { run: "node lib/index.js" }],
},
{
name: "Prettier",
Expand Down
2 changes: 1 addition & 1 deletion src/steps/writing/creation/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe("createStructure", () => {
),
scripts: {
initialize:
"pnpm build --no-dts && tsx ./bin/index.js --mode initialize",
"pnpm build --no-dts && tsx bin/index.js --mode initialize",
"test:create": "npx tsx script/create-test-e2e.ts",
"test:initialize": "npx tsx script/initialize-test-e2e.ts",
"test:migrate": "vitest run -r script/",
Expand Down
8 changes: 4 additions & 4 deletions src/steps/writing/creation/writePackageJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("writePackageJson", () => {
"lint-staged": {
"*": "prettier --ignore-unknown --write",
},
"main": "./lib/index.js",
"main": "lib/index.js",
"name": "test-repository",
"publishConfig": {
"provenance": true,
Expand Down Expand Up @@ -121,7 +121,7 @@ describe("writePackageJson", () => {

const packageJson = await writePackageJson({
...options,
bin: "./bin/index.js",
bin: "bin/index.js",
excludeAllContributors: true,
excludeBuild: true,
excludeCompliance: true,
Expand All @@ -144,7 +144,7 @@ describe("writePackageJson", () => {
"email": "[email protected]",
"name": "test-author",
},
"bin": "./bin/index.js",
"bin": "bin/index.js",
"description": "Test description.",
"devDependencies": {},
"engines": {
Expand All @@ -161,7 +161,7 @@ describe("writePackageJson", () => {
"lint-staged": {
"*": "prettier --ignore-unknown --write",
},
"main": "./lib/index.js",
"main": "lib/index.js",
"name": "test-repository",
"publishConfig": {
"provenance": true,
Expand Down
2 changes: 1 addition & 1 deletion src/steps/writing/creation/writePackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function writePackageJson(options: Options) {
"lint-staged": {
"*": "prettier --ignore-unknown --write",
},
main: "./lib/index.js",
main: "lib/index.js",
name: options.repository,
publishConfig: {
provenance: true,
Expand Down
Loading