Skip to content

Commit

Permalink
update template, dev deps, Node.js 22 support
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Aug 27, 2024
1 parent a967442 commit fe725c0
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 72 deletions.
4 changes: 1 addition & 3 deletions template/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
19 changes: 0 additions & 19 deletions template/.github/workflows/test-pr.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# 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 }}
runs-on: ubuntu-latest
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
6 changes: 2 additions & 4 deletions template/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"recommendations": [
"sculpt0r.vsc-ava-test-runner",
"samverschueren.linter-xo",
"dbaeumer.vscode-eslint",
"dprint.dprint"
]
"dprint.dprint",
],
}
7 changes: 5 additions & 2 deletions template/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
6 changes: 5 additions & 1 deletion template/.xo-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
9 changes: 5 additions & 4 deletions template/dprint.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
27 changes: 13 additions & 14 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
}
}
2 changes: 2 additions & 0 deletions template/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

<details>
<summary>Other Package Managers</summary>
<p>

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

</p>
</details>

## Usage
Expand Down
5 changes: 3 additions & 2 deletions template/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env tsimp
import meow from "meow";

// dprint-ignore
const cli = meow(`
Usage
$ {{ tmplr.command_name }} […]
Expand All @@ -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);
}
2 changes: 1 addition & 1 deletion template/test-fixtures/_utils.ts
Original file line number Diff line number Diff line change
@@ -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));
12 changes: 3 additions & 9 deletions template/test-fixtures/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand All @@ -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 => {
Expand All @@ -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);
});
File renamed without changes.
12 changes: 3 additions & 9 deletions template/test/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@ 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;
permit: Permit;
}>;

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 => {
Expand All @@ -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);
});

0 comments on commit fe725c0

Please sign in to comment.