Skip to content

Commit 5f133fb

Browse files
authored
Initial commit
0 parents  commit 5f133fb

30 files changed

+8296
-0
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
indent_style = space
7+
indent_size = 2
8+
trim_trailing_whitespace = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cache/
2+
coverage/
3+
dist/
4+
node_modules/
5+
private/

.eslintrc.json

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"root": true,
3+
"extends": ["@webdeveric/eslint-config-ts", "plugin:import/recommended", "plugin:import/typescript", "prettier"],
4+
"env": {
5+
"es6": true,
6+
"node": true
7+
},
8+
"parserOptions": {
9+
"project": ["./tsconfig.json"],
10+
"EXPERIMENTAL_useProjectService": true
11+
},
12+
"settings": {
13+
"import/extensions": [".ts", ".mts", ".cts", ".js", ".json"],
14+
"import/resolver": {
15+
"typescript": {
16+
"project": "./tsconfig.json"
17+
},
18+
"node": {
19+
"extensions": [".js", ".ts", ".mts", ".cts"]
20+
}
21+
},
22+
"import/parsers": {
23+
"@typescript-eslint/parser": [".ts", ".mts", ".cts"]
24+
}
25+
},
26+
"rules": {
27+
"import/first": "error",
28+
"import/no-absolute-path": "error",
29+
"import/no-cycle": "error",
30+
"import/no-deprecated": "error",
31+
"import/no-extraneous-dependencies": [
32+
"error",
33+
{
34+
"devDependencies": ["./vitest.config.mts", "./lint-staged.config.mjs", "./test/**/*"]
35+
}
36+
],
37+
"import/no-relative-packages": "error",
38+
"import/no-self-import": "error",
39+
"import/no-unresolved": "error",
40+
"import/no-useless-path-segments": [
41+
"error",
42+
{
43+
"noUselessIndex": false
44+
}
45+
],
46+
"import/order": [
47+
"error",
48+
{
49+
"alphabetize": {
50+
"order": "asc",
51+
"caseInsensitive": true
52+
},
53+
"groups": ["builtin", "external", "internal", "parent", ["sibling", "index"], "type"],
54+
"newlines-between": "always"
55+
}
56+
],
57+
"sort-imports": "off"
58+
},
59+
"overrides": [
60+
{
61+
"files": ["**/*.test.ts"],
62+
"rules": {
63+
"@typescript-eslint/no-explicit-any": "off"
64+
}
65+
}
66+
]
67+
}

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @webdeveric

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [webdeveric]

.github/workflows/node.js.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Node.js CI
2+
3+
on: [push]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
ci:
11+
name: Continuous Integration
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Setup pnpm
17+
uses: pnpm/action-setup@v4
18+
- name: Use Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version-file: '.nvmrc'
22+
cache: 'pnpm'
23+
- name: Installing dependencies
24+
run: pnpm install --frozen-lockfile
25+
- name: Linting
26+
run: pnpm lint
27+
- name: Type checking
28+
run: pnpm typecheck
29+
- name: Testing
30+
run: pnpm coverage
31+
- name: Building
32+
run: pnpm build

.github/workflows/release.yml.example

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read # for checkout
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # to be able to publish a GitHub release
17+
issues: write # to be able to comment on released issues
18+
pull-requests: write # to be able to comment on released pull requests
19+
id-token: write # to enable use of OIDC for npm provenance
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Use Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version-file: '.nvmrc'
33+
cache: 'pnpm'
34+
35+
- name: Installing dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
# https://github.com/pnpm/pnpm/issues/7909
39+
# - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
40+
# run: npm audit signatures
41+
42+
- name: Release
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
# Set this value in your repository secrets after you generate it at NPM.
46+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
NPM_CONFIG_PROVENANCE: true
48+
run: npx --no semantic-release

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cache/
2+
coverage/
3+
dist/
4+
node_modules/
5+
private/

.husky/commit-msg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no lint-staged -- --relative

.npmrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://pnpm.io/npmrc
2+
# node-linker=hoisted
3+
# symlink=false
4+
# shared-workspace-lockfile=false
5+
auto-install-peers=true
6+
enable-pre-post-scripts=true
7+
engine-strict=true

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

.prettierignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.vscode/
2+
cache/
3+
coverage/
4+
dist/
5+
node_modules/
6+
private/
7+
.editorconfig
8+
.npmrc
9+
.nvmrc
10+
.prettierignore
11+
pnpm-lock.yaml

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Eric King
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

commitlint.config.mjs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @type {import('@commitlint/types').UserConfig}
3+
*/
4+
export default {
5+
extends: ['@commitlint/config-conventional'],
6+
plugins: ['commitlint-plugin-cspell'],
7+
rules: {
8+
'cspell/type': [2, 'always'],
9+
'cspell/scope': [2, 'always'],
10+
'cspell/subject': [2, 'always'],
11+
'cspell/body': [2, 'always'],
12+
'cspell/footer': [2, 'always'],
13+
'scope-case': [2, 'always', ['lower-case', 'upper-case']],
14+
'subject-empty': [2, 'never'],
15+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
16+
'type-case': [2, 'always', 'lower-case'],
17+
'type-empty': [2, 'never'],
18+
'type-enum': [
19+
2,
20+
'always',
21+
['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert'],
22+
],
23+
},
24+
};

cspell.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"words": [
5+
"CODEOWNERS",
6+
"commitlint",
7+
"conventionalcommits",
8+
"nvmrc",
9+
"postbuild",
10+
"tsbuildinfo",
11+
"typecheck",
12+
"vitest",
13+
"webdeveric"
14+
],
15+
"flagWords": [],
16+
"ignorePaths": ["pnpm-lock.yaml", "node_modules", ".vscode"],
17+
"languageSettings": [
18+
{
19+
"languageId": "commit-msg",
20+
"ignoreRegExpList": ["/^#.*/gm"]
21+
}
22+
]
23+
}

lint-staged.config.mjs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @type {Record<string, string | string[] | ((filenames: string[]) => string | string[] | Promise<string | string[]>)>}
3+
*/
4+
export default {
5+
'*.{js,cjs,mjs,ts,cts,mts}': ['eslint --fix', 'prettier --write'],
6+
'*.{json,md}': 'prettier --write',
7+
'*': (files) => {
8+
return [
9+
`cspell lint --no-progress --no-summary --no-must-find-files ${files.join(' ')}`,
10+
`sh -c 'echo "${files.join('\n')}" | cspell --show-context stdin'`, // Spell check file names.
11+
];
12+
},
13+
};

package.json

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"name": "@webdeveric/dual-ts-package-template",
3+
"description": "",
4+
"version": "0.0.0",
5+
"keywords": [],
6+
"author": "Eric King <[email protected]> (https://webdeveric.com/)",
7+
"private": false,
8+
"publishConfig": {
9+
"access": "public"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/webdeveric/dual-ts-package-template.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/webdeveric/dual-ts-package-template/issues"
17+
},
18+
"license": "MIT",
19+
"packageManager": "[email protected]+sha512.c0f53ee99477ed969b82b289ad011a5d16bf1623c957e7f29eabe8d0c00b574c29b8c7f54f6c67ee710c73f285c8154d07ce44b46fe2c0eeb476a90441bac371",
20+
"sideEffects": false,
21+
"engines": {
22+
"node": ">=20.0.0"
23+
},
24+
"type": "module",
25+
"main": "./dist/mjs/index.js",
26+
"types": "./dist/types/index.d.ts",
27+
"exports": {
28+
".": {
29+
"types": "./dist/types/index.d.ts",
30+
"require": "./dist/cjs/index.js",
31+
"import": "./dist/mjs/index.js"
32+
},
33+
"./*": {
34+
"types": "./dist/types/*.d.ts",
35+
"require": "./dist/cjs/*.js",
36+
"import": "./dist/mjs/*.js"
37+
},
38+
"./package.json": "./package.json"
39+
},
40+
"files": [
41+
"dist"
42+
],
43+
"scripts": {
44+
"clean": "rimraf ./dist/",
45+
"prebuild": "pnpm clean",
46+
"build": "tsc --build tsconfig.cjs.json tsconfig.mjs.json --force",
47+
"validate": "validate-package-exports --check --verify --info",
48+
"postbuild": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && echo '{\"type\":\"module\"}' > ./dist/mjs/package.json && pnpm validate",
49+
"typecheck": "tsc --build --verbose",
50+
"lint": "eslint ./*.{js,cjs,mjs,ts,cts,mts} ./src/ ./test/ --ext .ts,.mjs,.cjs",
51+
"test": "vitest",
52+
"coverage": "vitest --coverage",
53+
"spellcheck": "cspell './{.github,src,test}/**/*.{ts,json}' './*.{js,json,md,mjs,mts}' './package.json' --no-progress",
54+
"prepublishOnly": "pnpm typecheck && pnpm spellcheck && pnpm lint && pnpm coverage && pnpm build",
55+
"format": "prettier --write ./*.{js,json,md,mjs,mts} ./src/ ./test/",
56+
"prepare": "husky"
57+
},
58+
"prettier": "@webdeveric/prettier-config",
59+
"devDependencies": {
60+
"@commitlint/config-conventional": "^19.6.0",
61+
"@commitlint/types": "^19.5.0",
62+
"@types/node": "^22.10.1",
63+
"@vitest/coverage-v8": "^2.1.6",
64+
"@webdeveric/eslint-config-ts": "^0.11.0",
65+
"@webdeveric/prettier-config": "^0.3.0",
66+
"commitlint": "^19.6.0",
67+
"commitlint-plugin-cspell": "^0.1.1",
68+
"conventional-changelog-conventionalcommits": "^8.0.0",
69+
"cspell": "^8.16.1",
70+
"eslint": "^8.57.1",
71+
"eslint-config-prettier": "^9.1.0",
72+
"eslint-import-resolver-typescript": "^3.6.3",
73+
"eslint-plugin-import": "^2.31.0",
74+
"husky": "^9.1.7",
75+
"lint-staged": "^15.2.10",
76+
"prettier": "^3.4.1",
77+
"rimraf": "^6.0.1",
78+
"semantic-release": "^24.2.0",
79+
"typescript": "^5.7.2",
80+
"validate-package-exports": "^0.8.0",
81+
"vitest": "^2.1.6"
82+
}
83+
}

0 commit comments

Comments
 (0)