diff --git a/template/.github/workflows/lint.yml b/template/.github/workflows/lint.yml index 9578aeb..607ba15 100644 --- a/template/.github/workflows/lint.yml +++ b/template/.github/workflows/lint.yml @@ -1,9 +1,7 @@ -# https://github.com/orgs/community/discussions/26276#discussioncomment-3251141 name: CI Lint on: push: - branches: - - main + branches: [main] pull_request: jobs: lint: diff --git a/template/.github/workflows/test-pr.yml b/template/.github/workflows/test-pr.yml deleted file mode 100644 index 881efb4..0000000 --- a/template/.github/workflows/test-pr.yml +++ /dev/null @@ -1,19 +0,0 @@ -# https://github.com/orgs/community/discussions/26276#discussioncomment-3251141 -name: CI Test -on: - - pull_request -jobs: - test: - name: Node.js ${{ matrix.node-version }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node-version: [18, 20, 21] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm test diff --git a/template/.github/workflows/test-push.yml b/template/.github/workflows/test.yml similarity index 71% rename from template/.github/workflows/test-push.yml rename to template/.github/workflows/test.yml index aff9807..c67b861 100644 --- a/template/.github/workflows/test-push.yml +++ b/template/.github/workflows/test.yml @@ -1,9 +1,8 @@ -# https://github.com/orgs/community/discussions/26276#discussioncomment-3251141 name: CI Test on: push: - branches: - - main + branches: [main] + pull_request: jobs: test: name: Node.js ${{ matrix.node-version }} @@ -11,11 +10,12 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18, 20, 21] + node-version: [18.19, 20.8, 21, 22] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install + - run: npx tsimp --start # Preload the transpiler - run: npm test diff --git a/template/.vscode/extensions.json b/template/.vscode/extensions.json index 280627f..bab54a5 100644 --- a/template/.vscode/extensions.json +++ b/template/.vscode/extensions.json @@ -1,8 +1,6 @@ { "recommendations": [ - "sculpt0r.vsc-ava-test-runner", "samverschueren.linter-xo", - "dbaeumer.vscode-eslint", - "dprint.dprint" - ] + "dprint.dprint", + ], } diff --git a/template/.vscode/settings.json b/template/.vscode/settings.json index 515530f..7fc0a69 100644 --- a/template/.vscode/settings.json +++ b/template/.vscode/settings.json @@ -3,8 +3,11 @@ "xo.format.enable": true, "xo.overrideSeverity": "warn", "xo.debounce": 100, - "[javascript][typescript][markdown][json][jsonc]": { + "[javascript][javascriptreact][typescript][typescriptreact][json][jsonc][yaml]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "dprint.dprint" + "editor.defaultFormatter": "dprint.dprint", + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + }, }, } diff --git a/template/.xo-config.json b/template/.xo-config.json index 0e06197..ff794de 100644 --- a/template/.xo-config.json +++ b/template/.xo-config.json @@ -1,3 +1,7 @@ { - "extends": ["@tommy-mitchell/xo"] + "$schema": "https://json.schemastore.org/eslintrc.json", + "extends": ["@tommy-mitchell/xo", "@tommy-mitchell/xo/dprint"], + "rules": { + "unicorn/no-process-exit": "off" + } } diff --git a/template/dprint.json b/template/dprint.json index 272ee2f..90d020e 100644 --- a/template/dprint.json +++ b/template/dprint.json @@ -1,9 +1,10 @@ { - "includes": ["**/*.{js,ts,md,json,jsonc}"], + "includes": ["**/*.{js,jsx,ts,tsx,json,jsonc,yml}"], "extends": ["node_modules/@tommy-mitchell/dprint-config/index.json"], "plugins": [ - "https://plugins.dprint.dev/json-0.19.1.wasm", - "https://plugins.dprint.dev/markdown-0.16.3.wasm", - "https://plugins.dprint.dev/typescript-0.89.1.wasm" + "https://plugins.dprint.dev/json-0.19.3.wasm", + "https://plugins.dprint.dev/typescript-0.91.6.wasm", + "https://plugins.dprint.dev/g-plane/malva-v0.7.1.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.4.0.wasm" ] } diff --git a/template/package.json b/template/package.json index c29d626..46299e8 100644 --- a/template/package.json +++ b/template/package.json @@ -21,14 +21,14 @@ "dist" ], "engines": { - "node": "^18.18 || ^20.8 || ^21" + "node": "^18.19 || ^20.8 || >=21" }, "scripts": { "prepare": "npm run build", "build": "tsc -p tsconfig.build.json && execify --all", "lint": "xo", "format": "dprint fmt && xo --fix", - "test": "tsc --noEmit && c8 ava" + "test": "c8 ava && tsc --noEmit" }, "ava": { "extensions": { @@ -45,20 +45,19 @@ "meow": "^13.2.0" }, "devDependencies": { - "@shopify/semaphore": "^3.0.2", - "@tommy-mitchell/dprint-config": "^0.1.0", - "@tommy-mitchell/eslint-config-xo": "^0.1.1", + "@shopify/semaphore": "^3.1.0", + "@tommy-mitchell/dprint-config": "^0.4.0", + "@tommy-mitchell/eslint-config-xo": "^0.7.0", "@tommy-mitchell/tsconfig": "^2.1.0", - "@types/node": "^18.18", - "ava": "^6.1.1", - "c8": "^9.1.0", + "@types/node": "18.19", + "ava": "^6.1.3", + "c8": "^10.1.2", "execify-cli": "beta", - "execa": "^8.0.1", - "get-bin-path": "^11.0.0", - "is-executable": "^2.0.1", + "execa": "^9.3.1", + "get-executable-bin-path": "^0.1.0", "tsimp": "^2.0.11", - "type-fest": "^4.10.2", - "typescript": "~5.3.3", - "xo": "^0.57.0" + "type-fest": "^4.25.0", + "typescript": "~5.5.4", + "xo": "^0.59.3" } } diff --git a/template/readme.md b/template/readme.md index af5bd8d..d4418ca 100644 --- a/template/readme.md +++ b/template/readme.md @@ -10,11 +10,13 @@
Other Package Managers +

```sh {{ tmplr.install_yarn }} ``` +

## Usage diff --git a/template/src/cli.ts b/template/src/cli.ts index eab6cc7..e29b16f 100644 --- a/template/src/cli.ts +++ b/template/src/cli.ts @@ -1,6 +1,7 @@ #!/usr/bin/env tsimp import meow from "meow"; +// dprint-ignore const cli = meow(` Usage $ {{ tmplr.command_name }} […] @@ -21,8 +22,8 @@ const cli = meow(` }, }); -const { input, flags: { help: helpShortFlag } } = cli; +const { input } = cli; -if (input.length === 0 || helpShortFlag) { +if (input.length === 0) { cli.showHelp(0); } diff --git a/template/test-fixtures/_utils.ts b/template/test-fixtures/_utils.ts index 41221e7..4c968e4 100644 --- a/template/test-fixtures/_utils.ts +++ b/template/test-fixtures/_utils.ts @@ -1,3 +1,3 @@ import { fileURLToPath } from "node:url"; -export const atFixture = (name: string) => fileURLToPath(new URL(`_fixtures/${name}`, import.meta.url)); +export const atFixture = (name: string) => fileURLToPath(new URL(`fixtures/${name}`, import.meta.url)); diff --git a/template/test-fixtures/cli.ts b/template/test-fixtures/cli.ts index bea0f95..7d2663c 100644 --- a/template/test-fixtures/cli.ts +++ b/template/test-fixtures/cli.ts @@ -2,8 +2,7 @@ import process from "node:process"; import anyTest, { type TestFn } from "ava"; import { Semaphore, type Permit } from "@shopify/semaphore"; import { execa } from "execa"; -import { getBinPath } from "get-bin-path"; -import { isExecutable } from "is-executable"; +import { getExecutableBinPath } from "get-executable-bin-path"; import { atFixture } from "./_utils.js"; const test = anyTest as TestFn<{ @@ -12,14 +11,9 @@ const test = anyTest as TestFn<{ }>; test.before("setup context", async t => { - const binPath = await getBinPath(); - t.truthy(binPath, "No bin path found!"); - - t.context.binPath = binPath!.replace("dist", "src").replace(".js", ".ts"); - t.true(await isExecutable(t.context.binPath), "Source binary not executable!"); + t.context.binPath = await getExecutableBinPath(); }); -// https://github.com/avajs/ava/discussions/3177 const semaphore = new Semaphore(Number(process.env["concurrency"]) || 5); test.beforeEach("setup concurrency", async t => { @@ -31,7 +25,7 @@ test.afterEach.always(async t => { }); test("main", async t => { - const {exitCode} = await execa(t.context.binPath); + const { exitCode } = await execa(t.context.binPath); t.is(exitCode, 0); }); diff --git a/template/test-fixtures/_fixtures/.gitkeep b/template/test-fixtures/fixtures/.gitkeep similarity index 100% rename from template/test-fixtures/_fixtures/.gitkeep rename to template/test-fixtures/fixtures/.gitkeep diff --git a/template/test/cli.ts b/template/test/cli.ts index a58aafd..9ddbb2b 100644 --- a/template/test/cli.ts +++ b/template/test/cli.ts @@ -2,8 +2,7 @@ import process from "node:process"; import anyTest, { type TestFn } from "ava"; import { Semaphore, type Permit } from "@shopify/semaphore"; import { execa } from "execa"; -import { getBinPath } from "get-bin-path"; -import { isExecutable } from "is-executable"; +import { getExecutableBinPath } from "get-executable-bin-path"; const test = anyTest as TestFn<{ binPath: string; @@ -11,14 +10,9 @@ const test = anyTest as TestFn<{ }>; test.before("setup context", async t => { - const binPath = await getBinPath(); - t.truthy(binPath, "No bin path found!"); - - t.context.binPath = binPath!.replace("dist", "src").replace(".js", ".ts"); - t.true(await isExecutable(t.context.binPath), "Source binary not executable!"); + t.context.binPath = await getExecutableBinPath(); }); -// https://github.com/avajs/ava/discussions/3177 const semaphore = new Semaphore(Number(process.env["concurrency"]) || 5); test.beforeEach("setup concurrency", async t => { @@ -30,7 +24,7 @@ test.afterEach.always(async t => { }); test("main", async t => { - const {exitCode} = await execa(t.context.binPath); + const { exitCode } = await execa(t.context.binPath); t.is(exitCode, 0); });