Skip to content

Commit

Permalink
chore: init
Browse files Browse the repository at this point in the history
Initialized from `namesmt/starter-ts`, source copied from `hono: /src/adapter/aws-lambda`
  • Loading branch information
NamesMT committed Mar 22, 2024
0 parents commit ed43e37
Show file tree
Hide file tree
Showing 31 changed files with 5,953 additions and 0 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM namesmt/images-alpine:node-dev
60 changes: 60 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* eslint-disable jsonc/comma-dangle */
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
{
"name": "Alpine-NamesMT",
"image": "namesmt/images-alpine:node-dev",
// "build": {
// "dockerfile": "Dockerfile"
// },
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {
"version": "latest"
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "sh .devcontainer/postCreate.sh",
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"antfu.goto-alias",
"antfu.iconify",
"antfu.unocss",
"antfu.vite",
"antfu.where-am-i",
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"george-alisson.html-preview-vscode",
"Gruntfuggly.todo-tree",
"jock.svg",
"lokalise.i18n-ally",
"ms-vscode.live-server",
"naumovs.color-highlight",
"oderwat.indent-rainbow",
"rangav.vscode-thunder-client",
"streetsidesoftware.code-spell-checker",
"thinker.sort-json",
"usernamehw.errorlens",
"Vue.volar",
"yoavbls.pretty-ts-errors",
]
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",
"runArgs": [
// mount pnpm store for shared caching/linking
// "--volume=${env:PNPM_HOME}/store:${env:PNPM_HOME}/store",

// // Enable both in this block if you want to mount home dir
// mount user home directory for things like git, ssh, and other configs
// "--volume=${env:HOME}:${env:HOME}",
// isolate the .vscode-server folder so you don't overwrite settings from remote ssh vscode
// "--volume=${localWorkspaceFolder}/.cache/vscode-server:${env:HOME}/.vscode-server",
// //
],
}
2 changes: 2 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Force pnpm to use global store instead of $PWD, ref: https://stackoverflow.com/questions/76573556/pnpm-use-docker-volume-as-store-path
pnpm config -g set store-dir $PNPM_HOME/store
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# dependencies
node_modules
.pnp
.pnp.js
.pnpm-store

# testing
coverage

# builds
dist
build
out/
.next/

# misc
.DS_Store
.idea
*.pem
temp
logs
lib-cov
coverage
.cache
.idea
*.log

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env.*local

# turbo
.turbo

# local netlify folder
.netlify
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.npm-pack-all-tmp
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-workspace-root-check=true
46 changes: 46 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
// Enable Vue Volar (v2) Hybrid Mode, ref: https://github.com/vuejs/language-tools/releases/tag/v2.0.7
"vue.server.hybridMode": true,

// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

/* // Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
], */

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 NamesMT <https://github.com/namesmt>

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.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# starter-ts [![NPM version](https://img.shields.io/npm/v/starter-ts?color=a1b858&label=)](https://www.npmjs.com/package/starter-ts)

**starter-ts** is my starter/boilerplate for typescript projects.
This template assumes you are using Linux, or the included Dev Container.

### Notes (remove this section when you use the template)
#### * Do a global replace for `starter-ts` and `NamesMT`

#### * I'm heavily inspired by [antfu](https://github.com/antfu) and [UnJS](https://github.com/unjs), some notable things:
- [antfu/ni](https://github.com/antfu/ni)
- [antfu/taze](https://github.com/antfu/taze)
- [antfu/vscode-settings](https://github.com/antfu/vscode-settings)
- [antfu/eslint-config](https://github.com/antfu/eslint-config)
- Style error silencing is commented out

#### * Script: `play` vs `play:useBuild` for playground testing?
- `play` script uses `unbuild`'s [passive watcher (stub mode)](https://github.com/unjs/unbuild#-passive-watcher), which allows you to execute new code **live** without rebuilding the project. The cons is TS declarations are not available.
- `play:useBuild` builds a static version of the package, useful for testing the actual look/behavior when shipping.
### END NOTE

## Features
- [x] TypeScript ready!

## Usage
### Install package:
```sh
# npm
npm install starter-ts

# yarn
yarn add starter-ts

# pnpm (recommended)
pnpm install starter-ts
```

### Import:
```ts
// ESM
import { hello } from 'starter-ts'
```

## Roadmap

- [x] Setting up Dev Container
- [ ] Become the legendary 10000x developer

## License

[MIT](./LICENSE) License © 2023 [NamesMT](https://github.com/NamesMT)
24 changes: 24 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineBuildConfig } from 'unbuild'
import sharedConfig from './shared.config'

export default defineBuildConfig({
entries: [
// normal bundles
'src/index',

// file-to-file (please use .mts for all of your files), currently mkdist uncontrollably generates .d.ts and .d.mts based on the original extension: .ts or .mts
// {
// builder: 'mkdist',
// input: './src/',
// esbuild: { minify: true },
// },
],
declaration: 'node16',
clean: true,
rollup: {
esbuild: {
// minify: true,
},
},
...sharedConfig,
})
23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import antfu from '@antfu/eslint-config'

export default antfu(
{
unocss: true,
ignores: [
// eslint ignore globs here
],
},
{
rules: {
'ts/ban-types': 'off',
'style/no-trailing-spaces': ['error', { ignoreComments: true }],
'style/max-statements-per-line': ['error', { max: 2 }],
},
},
{
files: ['*.md'],
rules: {
'style/no-trailing-spaces': 'off',
},
},
)
79 changes: 79 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "starter-ts",
"type": "module",
"version": "0.0.0",
"packageManager": "[email protected]",
"description": "",
"author": "NamesMT <[email protected]>",
"license": "MIT",
"funding": "https://github.com/sponsors/namesmt",
"homepage": "https://github.com/namesmt/starter-ts#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/namesmt/starter-ts.git"
},
"bugs": "https://github.com/namesmt/starter-ts/issues",
"keywords": [],
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs"
}
},
"source": "./src/index.ts",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"files": [
"dist"
],
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"start": "NODE_ENV=dev tsx src/index.ts",
"watch": "NODE_ENV=dev tsx watch src/index.ts",
"stub": "unbuild --stub",
"dev": "pnpm run watch",
"play": "pnpm run stub && pnpm run --filter playground dev",
"play:useBuild": "pnpm run build && pnpm run --filter playground dev",
"lint": "eslint .",
"test": "vitest",
"test:types": "tsc --noEmit --skipLibCheck",
"check": "pnpm lint && pnpm test:types && vitest run --coverage",
"build": "unbuild",
"release": "pnpm dlx changelogen@latest --release --push --publish",
"prepare": "simple-git-hooks",
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"consola": "^3.2.3",
"hono": "^4.1.3",
"std-env": "^3.7.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.8.1",
"@types/node": "^20.11.26",
"@unocss/eslint-plugin": "^0.58.5",
"@vitest/coverage-v8": "^1.3.1",
"eslint": "^8.57.0",
"lint-staged": "^15.2.2",
"simple-git-hooks": "^2.10.0",
"tsx": "^4.7.1",
"typescript": "^5.4.2",
"unbuild": "^2.0.0",
"vitest": "^1.3.1"
},
"pnpm": {
"overrides": {
"hasown": "npm:@nolyfill/hasown@latest"
}
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
}
}
14 changes: 14 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="app">
</div>
<a href="/__inspect/#/module?id=./main.ts&index=2" target="_blank" style="text-decoration: none; margin-top:10px; display: block;">visit /__inspect/ to inspect the intermediate state</a>
<script type="module" src="./main.ts"></script>
</body>
</html>
Empty file added playground/main.ts
Empty file.
14 changes: 14 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "playground",
"type": "module",
"private": true,
"scripts": {
"dev": "nodemon -w '../src/**/*.ts' -w 'main.ts' -e .ts -x vite"
},
"devDependencies": {
"nodemon": "^3.0.1",
"starter-ts": "workspace:^",
"vite": "^5.0.2",
"vite-plugin-inspect": "^0.7.42"
}
}
Empty file added playground/test/.gitignore
Empty file.
6 changes: 6 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"lib": ["ESNExt", "DOM"]
}
}
Loading

0 comments on commit ed43e37

Please sign in to comment.