Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
KennanHunter committed Aug 6, 2023
0 parents commit d51cc17
Show file tree
Hide file tree
Showing 18 changed files with 3,114 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: kennan
16 changes: 16 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI Benchmark

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn benchmark
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Publish to NPM

on:
release:
types: [published]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"
registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI Test

on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

benchmark/dist
13 changes: 13 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0

# Prettify all selected files
echo "$FILES" | xargs yarn format --ignore-unknown

# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add

exit 0
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"orta.vscode-twoslash-queries",
"streetsidesoftware.code-spell-checker",
"yoavbls.pretty-ts-errors",
"orta.vscode-jest"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": ["CODECOV", "kennanhunter"],
"editor.detectIndentation": false,
"editor.tabSize": 2
}
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2023 Kennan Hunter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 5 additions & 0 deletions benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function main() {
console.log("Might want to use a benchmark framework for this");
}

main();
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
collectCoverage: true,
};
53 changes: 53 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@kennanhunter/npm-package-template",
"version": "0.0.0-alpha.1",
"description": "Kennan Hunter's simple package template",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/KennanHunter/npm-package-template#readme"
},
"bugs": {
"url": "https://github.com/kennanhunter/npm-package-template/issues"
},
"homepage": "https://github.com/KennanHunter/npm-package-template/",
"author": {
"name": "Kennan Hunter",
"email": "kennanhunter5@gmail.com",
"url": "https://kennan.tech"
},
"keywords": [],
"main": "dist/index.js",
"exports": {
".": "./dist/index.js",
"./package.json": "./package.json"
},
"files": [
"/dist"
],
"scripts": {
"benchmark": "yarn build && node ./dist/benchmark/index.js",
"build": "yarn clean && tsc",
"clean": "rimraf ./dist",
"execute:bin": "ts-node ./src/bin.ts",
"format": "format-package -w && prettier -w .",
"prepare": "husky install",
"test": "jest"
},
"funding": {
"type": "individual",
"url": "https://ko-fi.com/kennan"
},
"dependencies": {},
"devDependencies": {
"@types/jest": "^29.4.1",
"format-package": "^7.0.0",
"husky": "^8.0.3",
"jest": "^29.5.0",
"prettier": "^2.8.7",
"rimraf": "^5.0.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
}
6 changes: 6 additions & 0 deletions prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
61 changes: 61 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
> For almost everything, just replace
> `kennanhunter` with your username
> `@kennanhunter/npm-package-template` with your npm name (line 20 + 21 of readme.md)
> `npm-package-template` with your repo name
>
> For github actions add
>
> - NPM_TOKEN: found in access tokens on your npm settings
> - CODECOV_TOKEN: found in code coverage
>
> Always remember [grug's timeless advice on testing](https://grugbrain.dev/#grug-on-testing)
>
> You also will want to change the `funding` key in [package.json](./package.json)
> and the ko-fi key in [FUNDING.yml](./.github/FUNDING.yml)
> to your financial details
# NPM Package Template

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/kennanhunter/npm-package-template/publish.yml?style=for-the-badge)
![NPM Downloads](https://img.shields.io/npm/dt/@kennanhunter/npm-package-template?style=for-the-badge)
![NPM License](https://img.shields.io/npm/l/@kennanhunter/npm-package-template?style=for-the-badge)
[![Code coverage](https://img.shields.io/codecov/c/github/kennanhunter/npm-package-template?style=for-the-badge)](https://app.codecov.io/gh/KennanHunter/npm-package-template)

## Usage

### Installing

```shell
# npm
npm install npm-package-template
# Yarn
yarn add npm-package-template
```

### Adding

```typescript
import { add } from "zod";

const res = add(5, 7);

console.log(res); // 13
```

## Developing

```shell
git clone https://github.com/KennanHunter/npm-package-template.git
cd npm-package-template

yarn
yarn test

# Benchmarking (builds in background)
yarn benchmark

# Only needed for final publishing
yarn build
```

There exists recommended extensions and basic settings in the [.vscode](./.vscode) folder.
Loading

0 comments on commit d51cc17

Please sign in to comment.