npm init create .nvmrc create .envrc
pnpm add -D typescript npx tsc --init
update ts config "noEmit": true, "skipLibCheck": true
pnpm add -D tsup
update package.json
"private": false,
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
create src/index.ts
add package build/lint scripts
"build": "tsup src/index.ts --format cjs,esm --dts", "lint": "tsc",
add .gitignore
node_modules
.idea
dist
git init create repo and push initial commit
-- add vitest pnpm add vitest -D create src/index.test.ts
import {describe, it, expect} from "vitest"
describe("index", () => {
it("should pass ci", () => {
expect(1).toBe(1);
})
})
add package tests scripts
"dev": "vitest",
"test": "vitest run",
commit vitests
add prettier pnpm add -D --save-exact prettier node --eval "fs.writeFileSync('.prettierrc','{}\n')" node --eval "fs.writeFileSync('.prettierignore','dist\npnpm-lock.yaml')" pnpm exec prettier . --write
Commit
add github actions node --eval "fs.mkdirSync('.github/workflows', { recursive: true })" node --eval "fs.writeFileSync('.github/workflows/main.yml','')"
add ci script to package.json "lint": "tsc && pnpm exec prettier . --write", "ci": "tsc && pnpm run test && pnpm run build",
add npm publish script node --eval "fs.writeFileSync('.github/workflows/publish.yml','')" pnpm add @changesets/cli -D pnpm changeset init
update .changeset/config.json add package.json release script set "access": "public" add env variable NPM_TOKEN to github actions secret settingss => actions => allow GitHub Actions to create and approve pull requests set github workflow permissions to allow create and approve pull requests add .npmignore
pnpm changesets