From 49ffe8a7fc7bf701b189879f41f7b88a1d832147 Mon Sep 17 00:00:00 2001 From: Arthur Fontaine <57626613+arthur-fontaine@users.noreply.github.com> Date: Sat, 3 Jun 2023 15:09:37 +0200 Subject: [PATCH] Initial commit --- .changeset/README.md | 8 ++ .changeset/config.json | 11 ++ .eslintrc.js | 4 + .github/workflows/release.yml | 36 +++++ .gitignore | 222 ++++++++++++++++++++++++++++++ .husky/commit-msg | 6 + .husky/pre-commit | 5 + .npmrc | 1 + README.md | 41 ++++++ apps/.gitkeep | 0 commitlint.config.js | 3 + package.json | 35 +++++ packages/my-package/package.json | 16 +++ packages/my-package/src/index.ts | 1 + packages/my-package/tsconfig.json | 10 ++ pnpm-workspace.yaml | 3 + turbo.json | 18 +++ 17 files changed, 420 insertions(+) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json create mode 100644 .eslintrc.js create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100755 .husky/commit-msg create mode 100755 .husky/pre-commit create mode 100644 .npmrc create mode 100644 README.md create mode 100644 apps/.gitkeep create mode 100644 commitlint.config.js create mode 100644 package.json create mode 100644 packages/my-package/package.json create mode 100644 packages/my-package/src/index.ts create mode 100644 packages/my-package/tsconfig.json create mode 100644 pnpm-workspace.yaml create mode 100644 turbo.json diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..e5b6d8d --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..7fcf973 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..f2a16a9 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ['@whitebird'], +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fcc77a5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + id: pnpm-install + with: + run_install: true + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + publish: pnpm release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a184db --- /dev/null +++ b/.gitignore @@ -0,0 +1,222 @@ +# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,node,turbo +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,node,turbo + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Node ### +# 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 + +# 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.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +### Turbo ### +# Turborepo task cache +.turbo + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos,node,turbo \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..84a5b50 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +[ -n "$CI" ] && exit 0 + +npx --no -- commitlint --edit "" diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..506dd56 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +pnpm lint +pnpm test diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..6c59086 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +enable-pre-post-scripts=true diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f737f6 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +

Whitebird Node.js starter

+ +This is a starter project for Node.js projects. It is built on top of the [Turborepo starter](https://github.com/vercel/turbo/tree/main/examples/with-pnpm). + +## What's inside? + +It uses [pnpm](https://pnpm.io/) as a package manager. + +### Utilities + + - [TypeScript](https://www.typescriptlang.org/) for static type checking configured with [@whitebird/tsconfig](https://github.com/bywhitebird/whitebird/tree/main/packages/tsconfig) + - [ESLint](https://eslint.org/) for code linting configured with [@whitebird/eslint-config](https://github.com/bywhitebird/whitebird/tree/main/packages/eslint-config) + - [Husky](https://typicode.github.io/husky/#/) for Git hooks + - [Commitlint](https://commitlint.js.org/#/) for commit message linting + - [Changesets](https://github.com/changesets/changesets) and the GitHub Action [changesets/action](https://github.com/changesets/action) for versioning and publishing + +## Setup + +```bash +git clone --depth=1 https://github.com/bywhitebird/starter-node.git +rm -rf starter-node/.git +cd starter-node +pnpm install +``` + +## Usage + +The `packages/my-package` directory is a sample package/app. You can copy it to `packages` or `apps` directory and start working on it. + +### Commands + + - `pnpm build` - build the project + - `pnpm dev` - run the project in development mode + - `pnpm lint` - lint the project + - `pnpm test` - run tests + - `pnpm format` - format the project + +## Useful links + + - [Turborepo documentation](https://turbo.build/repo/docs) + - [Turborepo starter](https://github.com/vercel/turbo/tree/main/examples/with-pnpm) \ No newline at end of file diff --git a/apps/.gitkeep b/apps/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..98ee7df --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..2ea8ee8 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "whitebird", + "version": "0.0.0", + "private": true, + "workspaces": [ + "apps/*", + "packages/*" + ], + "scripts": { + "build": "turbo run build", + "dev": "turbo run dev --parallel", + "lint": "turbo run lint", + "test": "turbo run test", + "format": "prettier --write \"**/*.{ts,tsx,md}\"", + "prepare": "husky install", + "prerelease": "turbo run build lint test", + "release": "changeset version && changeset publish" + }, + "devDependencies": { + "@commitlint/cli": "^17.2.0", + "@commitlint/config-conventional": "^17.2.0", + "@whitebird/eslint-config": "latest", + "@whitebird/tsconfig": "latest", + "husky": "^8.0.0", + "turbo": "latest", + "typescript": "^4.8.4" + }, + "engines": { + "node": ">=18.0.0" + }, + "packageManager": "pnpm@7.15.0", + "dependencies": { + "@changesets/cli": "^2.25.2" + } +} diff --git a/packages/my-package/package.json b/packages/my-package/package.json new file mode 100644 index 0000000..1727653 --- /dev/null +++ b/packages/my-package/package.json @@ -0,0 +1,16 @@ +{ + "name": "@whitebird/my-package", + "private": true, + "version": "0.0.0", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc", + "lint": "eslint .", + "lint:fix": "eslint . --fix" + }, + "dependencies": {}, + "devDependencies": { + "@types/node": "^18.11.9" + } +} diff --git a/packages/my-package/src/index.ts b/packages/my-package/src/index.ts new file mode 100644 index 0000000..b1c6ea4 --- /dev/null +++ b/packages/my-package/src/index.ts @@ -0,0 +1 @@ +export default {} diff --git a/packages/my-package/tsconfig.json b/packages/my-package/tsconfig.json new file mode 100644 index 0000000..7a9ba97 --- /dev/null +++ b/packages/my-package/tsconfig.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Default", + "extends": "@whitebird/tsconfig/node.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..3ff5faa --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - "apps/*" + - "packages/*" diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..59de14b --- /dev/null +++ b/turbo.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": { + "dependsOn": ["^build"], + "outputs": ["dist/**"] + }, + "lint": { + "outputs": [] + }, + "dev": { + "cache": false + }, + "test": { + "outputs": [] + } + } +}