@vpnsin/devkit 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +318 -0
  2. package/bin/cli.js +431 -0
  3. package/commitlint/index.js +7 -0
  4. package/eslint/base.js +50 -0
  5. package/eslint/next.js +27 -0
  6. package/jest/index.js +20 -0
  7. package/lint-staged/index.js +8 -0
  8. package/package.json +80 -0
  9. package/prettier/index.js +11 -0
  10. package/templates/README.template.md +51 -0
  11. package/templates/app/backend/Dockerfile +24 -0
  12. package/templates/app/backend/dockerignore +7 -0
  13. package/templates/app/backend/env.example +2 -0
  14. package/templates/app/backend/src/app.ts +22 -0
  15. package/templates/app/backend/src/env.ts +8 -0
  16. package/templates/app/backend/src/routes/health.ts +7 -0
  17. package/templates/app/backend/src/server.ts +19 -0
  18. package/templates/app/frontend/app/globals.css +28 -0
  19. package/templates/app/frontend/app/layout.tsx +16 -0
  20. package/templates/app/frontend/app/page.tsx +10 -0
  21. package/templates/app/frontend/env.example +5 -0
  22. package/templates/app/frontend/next.config.mjs +6 -0
  23. package/templates/claude/skills/design-craft/SKILL.md +226 -0
  24. package/templates/cspell.json +30 -0
  25. package/templates/dependabot.yml +18 -0
  26. package/templates/editorconfig +15 -0
  27. package/templates/github/CODEOWNERS +12 -0
  28. package/templates/github/CONTRIBUTING.md +51 -0
  29. package/templates/github/ISSUE_TEMPLATE/bug_report.yml +34 -0
  30. package/templates/github/ISSUE_TEMPLATE/config.yml +5 -0
  31. package/templates/github/ISSUE_TEMPLATE/feature_request.yml +23 -0
  32. package/templates/github/PULL_REQUEST_TEMPLATE.md +27 -0
  33. package/templates/github/SECURITY.md +24 -0
  34. package/templates/github/workflows/ci.yml +55 -0
  35. package/templates/github/workflows/codeql.yml +35 -0
  36. package/templates/github/workflows/dependency-review.yml +23 -0
  37. package/templates/github/workflows/lighthouse.yml +39 -0
  38. package/templates/github/workflows/publish.yml +38 -0
  39. package/templates/github/workflows/release-please-publish.yml +54 -0
  40. package/templates/github/workflows/release-please.yml +22 -0
  41. package/templates/github/workflows/scorecard.yml +41 -0
  42. package/templates/github/workflows/sonarqube.yml +31 -0
  43. package/templates/github/workflows/trivy.yml +43 -0
  44. package/templates/husky/commit-msg +1 -0
  45. package/templates/husky/pre-commit +1 -0
  46. package/templates/lighthouserc.json +23 -0
  47. package/templates/markdownlint-cli2.jsonc +20 -0
  48. package/templates/npmrc +9 -0
  49. package/templates/nvmrc +1 -0
  50. package/templates/release-please-config.json +14 -0
  51. package/templates/sonar-project.properties +13 -0
  52. package/templates/vscode/extensions.json +53 -0
  53. package/templates/vscode/settings.json +70 -0
  54. package/tsconfig/base.json +17 -0
  55. package/tsconfig/next.json +16 -0
  56. package/tsconfig/node.json +14 -0
  57. package/vitest/index.js +22 -0
package/README.md ADDED
@@ -0,0 +1,318 @@
1
+ # devkit
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@vpnsin/devkit.svg)](https://www.npmjs.com/package/@vpnsin/devkit)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@vpnsin/devkit.svg)](https://www.npmjs.com/package/@vpnsin/devkit)
5
+ [![license: MIT](https://img.shields.io/npm/l/@vpnsin/devkit.svg)](https://www.npmjs.com/package/@vpnsin/devkit)
6
+ [![node](https://img.shields.io/node/v/@vpnsin/devkit.svg)](https://www.npmjs.com/package/@vpnsin/devkit)
7
+
8
+ Shared development tooling for Node.js & Next.js repos — one source of truth for
9
+ **ESLint, Prettier, commitlint, markdownlint, lint-staged, Husky hooks, TypeScript,
10
+ VS Code settings, GitHub Actions (CI + CodeQL + dependency review) and
11
+ release-please**. It can also **scaffold a runnable Express backend or Next.js
12
+ frontend** so a new repo goes from empty to lint-clean-and-running in one command.
13
+
14
+ Adopt it in any repo with a single command instead of copy-pasting config.
15
+
16
+ ## Contents
17
+
18
+ - [Quick start](#quick-start)
19
+ - [Spin up a new app](#spin-up-a-new-app)
20
+ - [CLI options](#cli-options)
21
+ - [Public vs private repos](#public-vs-private-repos)
22
+ - [Manual usage (without the CLI)](#manual-usage-without-the-cli)
23
+ - [What's inside](#whats-inside)
24
+ - [What gets scaffolded](#what-gets-scaffolded)
25
+ - [Recommended VS Code extensions](#recommended-vs-code-extensions)
26
+ - [Not included (and why)](#not-included-and-why)
27
+ - [Conventions this enforces](#conventions-this-enforces)
28
+ - [Publishing (maintainers)](#publishing-maintainers)
29
+
30
+ ## Quick start
31
+
32
+ ```bash
33
+ # in the target repo (must contain a package.json)
34
+ npm i -D @vpnsin/devkit
35
+ npx devkit init
36
+ ```
37
+
38
+ `init` will:
39
+
40
+ - detect Next.js vs plain Node and pick the right ESLint + TypeScript preset;
41
+ - write thin **config shims** that re-export this package (`eslint.config.ts`,
42
+ `commitlint.config.ts`, `.lintstagedrc.mjs`, `tsconfig.json`, and the
43
+ `prettier` key in `package.json`) so config stays in sync via `npm update`;
44
+ - copy the **templates** that can't be referenced — Husky hooks, `.vscode/`,
45
+ `.markdownlint-cli2.jsonc`, the `.github/` **workflows** (CI, CodeQL,
46
+ dependency review, Trivy, release-please) and **governance** (PR template,
47
+ `SECURITY.md`, `CONTRIBUTING.md`, `CODEOWNERS`, issue templates), plus a
48
+ `README.md` skeleton if one is missing;
49
+ - add npm **scripts** (`lint`, `lint:fix`, `lint:md`, `format`, `format:check`,
50
+ `type-check`, `prepare`);
51
+ - install the required dev dependencies and set up Husky.
52
+
53
+ Existing files are left untouched unless you pass `--force`.
54
+
55
+ ## Spin up a new app
56
+
57
+ Bootstrap a fresh repo with a working app **plus** all the tooling above:
58
+
59
+ ```bash
60
+ mkdir my-api && cd my-api && npm init -y
61
+ npx devkit init --backend # Express + TypeScript API
62
+ ```
63
+
64
+ ```bash
65
+ mkdir my-web && cd my-web && npm init -y
66
+ npx devkit init --frontend # Next.js (App Router) + TypeScript
67
+ ```
68
+
69
+ Then:
70
+
71
+ ```bash
72
+ cp .env.example .env # backend/frontend ship an example env file
73
+ npm run dev # tsx watch (backend) / next dev (frontend)
74
+ ```
75
+
76
+ **`--backend`** scaffolds an Express + TypeScript skeleton and selects the Node
77
+ preset:
78
+
79
+ - `src/server.ts` (entry + graceful shutdown), `src/app.ts` (app factory with
80
+ `helmet` + `cors` + JSON body parsing), `src/routes/health.ts`, `src/env.ts`;
81
+ - a multi-stage `Dockerfile` (non-root, `--omit=dev` runtime) and `.dockerignore`;
82
+ - `.env.example`, and `dev` / `build` / `start` scripts;
83
+ - runtime deps `express`, `cors`, `helmet`, `dotenv`.
84
+
85
+ **`--frontend`** scaffolds a Next.js App Router skeleton and selects the Next
86
+ preset:
87
+
88
+ - `app/layout.tsx`, `app/page.tsx`, `app/globals.css`, `next.config.mjs`;
89
+ - `.env.example`, and `dev` / `build` / `start` scripts;
90
+ - runtime deps `next`, `react`, `react-dom`.
91
+
92
+ The app starters are flat (single-app) layouts; run them in separate
93
+ directories for a backend **and** a frontend, or wire up a monorepo yourself.
94
+
95
+ ## CLI options
96
+
97
+ ```bash
98
+ npx devkit init --next # force the Next.js preset
99
+ npx devkit init --node # force the base (Node) preset
100
+ npx devkit init --backend # scaffold an Express + TypeScript backend
101
+ npx devkit init --frontend # scaffold a Next.js (App Router) frontend
102
+ npx devkit init --private # private repo: skip GHAS workflows (auto-detected via gh)
103
+ npx devkit init --public # public repo: include GHAS workflows
104
+ npx devkit init --jest # scaffold Jest (ts-jest)
105
+ npx devkit init --vitest # scaffold Vitest (alternative to Jest)
106
+ npx devkit init --scorecard # also add the OSSF Scorecard workflow (public repos)
107
+ npx devkit init --lighthouse # also add a Lighthouse CI workflow (web apps)
108
+ npx devkit init --skills # also add Claude Code skills (design-craft for UI/UX)
109
+ npx devkit init --publish # auto-publish to npm when the release PR merges (needs NPM_TOKEN)
110
+ npx devkit init --sonar # also add SonarCloud analysis (needs SONAR_TOKEN secret)
111
+ npx devkit init --force # overwrite existing config/template files
112
+ npx devkit init --no-install # scaffold only, install deps yourself
113
+ ```
114
+
115
+ ## Public vs private repos
116
+
117
+ GitHub Advanced Security — **CodeQL, Trivy, Dependency Review, Scorecard** — is
118
+ free on **public** repos but needs a paid licence on **private** ones. `init`
119
+ auto-detects visibility with the `gh` CLI (override with `--private` / `--public`):
120
+
121
+ - **Public** → the full GHAS workflow set is scaffolded.
122
+ - **Private** → those GHAS workflows are skipped; you still get **Dependabot**
123
+ (alerts + grouped update PRs) and a non-blocking **`npm audit`** step in CI for
124
+ free dependency security. (Enable _Dependabot alerts_ in repo settings.)
125
+
126
+ `--sonar` adds a CI-based SonarCloud scan and a `sonar-project.properties`.
127
+ Set a `SONAR_TOKEN` secret, fill in your org/project keys, and turn **off**
128
+ Automatic Analysis in SonarCloud (CI and Automatic Analysis can't both run).
129
+ SonarCloud is also free only for public projects.
130
+
131
+ With `--publish`, merging the release-please PR auto-publishes to npm: the publish
132
+ step is integrated into the release-please workflow (a release created with
133
+ `GITHUB_TOKEN` can't trigger a separate `on: release` workflow, so it must live
134
+ there). You also get a manual `Publish (manual)` workflow (`workflow_dispatch`) to
135
+ re-publish if an auto-publish fails. Add an `NPM_TOKEN` repository secret (an npm
136
+ automation token) for it to authenticate.
137
+
138
+ After running, fill the placeholders in `.github/CODEOWNERS` (`@OWNER`) and the
139
+ security contact in `.github/SECURITY.md`.
140
+
141
+ ## Manual usage (without the CLI)
142
+
143
+ Each config is also importable directly:
144
+
145
+ ```ts
146
+ // eslint.config.ts (needs the `jiti` devDependency to load TS config)
147
+ export { default } from '@vpnsin/devkit/eslint/next'; // or '@vpnsin/devkit/eslint/base'
148
+
149
+ // extend it:
150
+ import base from '@vpnsin/devkit/eslint/base';
151
+ export default [...base, { rules: { 'no-console': 'off' } }];
152
+ ```
153
+
154
+ ```jsonc
155
+ // package.json
156
+ { "prettier": "@vpnsin/devkit/prettier" }
157
+ ```
158
+
159
+ ```ts
160
+ // commitlint.config.ts
161
+ export { default } from '@vpnsin/devkit/commitlint';
162
+
163
+ // vitest.config.ts (alternative to Jest)
164
+ import { defineConfig } from 'vitest/config';
165
+ import base from '@vpnsin/devkit/vitest';
166
+ export default defineConfig(base);
167
+ ```
168
+
169
+ ```js
170
+ // .lintstagedrc.mjs (stays .mjs — .ts breaks the bare `npx lint-staged` hook)
171
+ export { default } from '@vpnsin/devkit/lint-staged';
172
+
173
+ // jest.config.mjs (Node + ts-jest; stays .mjs — ts-node can't re-export the ESM preset)
174
+ export { default } from '@vpnsin/devkit/jest';
175
+ ```
176
+
177
+ ```jsonc
178
+ // tsconfig.json — extend a shared base (base / node / next)
179
+ {
180
+ "extends": "@vpnsin/devkit/tsconfig/node.json",
181
+ "include": ["src/**/*.ts"],
182
+ "exclude": ["node_modules", "dist"],
183
+ }
184
+ ```
185
+
186
+ ## What's inside
187
+
188
+ - **ESLint** — `@vpnsin/devkit/eslint/base` (Node) / `@vpnsin/devkit/eslint/next`
189
+ (base + `eslint-config-next`). Flat config: JS + typescript-eslint + Prettier.
190
+ - **Prettier** — `@vpnsin/devkit/prettier` (100 width, single quotes, es5 commas).
191
+ - **commitlint** — `@vpnsin/devkit/commitlint` (Conventional Commits).
192
+ - **lint-staged** — `@vpnsin/devkit/lint-staged` (ESLint/Prettier/markdownlint on staged files).
193
+ - **TypeScript** — `@vpnsin/devkit/tsconfig/{base,node,next}.json` (strict base + Node/Next variants).
194
+ - **Jest / Vitest** — `@vpnsin/devkit/jest` (ts-jest) or `@vpnsin/devkit/vitest`; opt-in via `--jest` / `--vitest`.
195
+ - **App starters** — `--backend` (Express + TS) / `--frontend` (Next.js App Router + TS).
196
+ - **GitHub workflows** — CI, CodeQL, dependency review, Trivy, release-please; opt-in: Scorecard, Lighthouse, npm-publish, SonarCloud.
197
+ - **Governance** — `SECURITY.md`, `CONTRIBUTING.md`, `CODEOWNERS`, PR & issue templates.
198
+ - **EditorConfig** — `templates/editorconfig` (LF, UTF-8, 2-space).
199
+ - **npm config** — `.npmrc` (`engine-strict`, quieter installs; optional exact pins).
200
+ - **Spell check** — `cspell.json` for the recommended Code Spell Checker extension.
201
+ - **Node version** — `.nvmrc`; CI reads it via `node-version-file`.
202
+ - **Claude Code skills** — `design-craft` (a UX/visual-design protocol); opt-in via `--skills`.
203
+
204
+ ## What gets scaffolded
205
+
206
+ | Area | Source template | Purpose |
207
+ | -------------------------------------------- | --------------------------------------------------------- | -------------------------------------------------------------- |
208
+ | ESLint / Prettier / commitlint / lint-staged | shims re-exporting the package | flat ESLint, Prettier, Conventional Commits, staged-file lint |
209
+ | TypeScript | `tsconfig.json` extending `@vpnsin/devkit/tsconfig/*` | strict base + Node/Next variant |
210
+ | Backend app | `templates/app/backend/*` | Express + TS skeleton, Dockerfile (opt-in, `--backend`) |
211
+ | Frontend app | `templates/app/frontend/*` | Next.js App Router + TS skeleton (opt-in, `--frontend`) |
212
+ | markdownlint | `templates/markdownlint-cli2.jsonc` | tuned to coexist with Prettier |
213
+ | Spell check | `templates/cspell.json` | project words + ignores for the Code Spell Checker extension |
214
+ | npm config | `templates/npmrc` | `engine-strict`, quieter installs, optional exact pins |
215
+ | Husky hooks | `templates/husky/*` | pre-commit → lint-staged, commit-msg → commitlint |
216
+ | CI | `templates/github/workflows/ci.yml` | type-check, lint, lint:md, format, build (each `--if-present`) |
217
+ | GHAS | `codeql.yml`, `dependency-review.yml`, `trivy.yml` | code scanning + vulnerable-dependency gate (public repos) |
218
+ | Scorecard | `templates/github/workflows/scorecard.yml` | OSSF supply-chain posture (opt-in, `--scorecard`) |
219
+ | Releases | `release-please.yml` + config | semantic version bumps, tags & changelog |
220
+ | Governance | `SECURITY.md`, `CONTRIBUTING.md`, `CODEOWNERS`, templates | project docs & review routing |
221
+ | Editor | `templates/vscode/*` | format + ESLint/markdownlint fix on save |
222
+
223
+ ## Recommended VS Code extensions
224
+
225
+ `init` writes a `.vscode/extensions.json` so VS Code prompts the team to install a
226
+ shared set of extensions. They're _recommendations_, not requirements — nothing
227
+ breaks if you skip one. Grouped by what they do:
228
+
229
+ **Formatting, linting & spell-check** — the toolchain devkit wires up:
230
+
231
+ - `esbenp.prettier-vscode` — format on save with Prettier.
232
+ - `dbaeumer.vscode-eslint` — inline ESLint + fix-on-save.
233
+ - `DavidAnson.vscode-markdownlint` — lint/fix Markdown (matches `lint:md`).
234
+ - `streetsidesoftware.code-spell-checker` — spell-check code & docs (reads `cspell.json`).
235
+ - `EditorConfig.EditorConfig` — apply `.editorconfig` (LF, 2-space, final newline).
236
+
237
+ **Diagnostics & DX**:
238
+
239
+ - `usernamehw.errorlens` — show errors/warnings inline on the line.
240
+ - `yoavbls.pretty-ts-errors` — make TypeScript errors readable.
241
+ - `wix.vscode-import-cost` — show the bundle size of each import.
242
+
243
+ **JavaScript / TypeScript / React authoring**:
244
+
245
+ - `dsznajder.es7-react-js-snippets` — React/Hooks snippets.
246
+ - `formulahendry.auto-rename-tag` — rename paired JSX/HTML tags together.
247
+ - `christian-kohler.npm-intellisense` — autocomplete `import` paths for npm packages.
248
+ - `christian-kohler.path-intellisense` — autocomplete local file paths.
249
+ - `wmaurer.change-case` — convert identifiers between camel/snake/kebab/etc.
250
+
251
+ **Testing** (pairs with `devkit init --jest`):
252
+
253
+ - `orta.vscode-jest` — run the Jest suite with inline pass/fail decorations.
254
+ - `firsttris.vscode-jest-runner` — run/debug a single test or `describe` block.
255
+ - `andys8.jest-snippets` — snippets for `describe`/`it`/`expect`.
256
+
257
+ **Git & GitHub** (devkit ships PR templates, governance & GH workflows):
258
+
259
+ - `eamodio.gitlens` — blame, history & authorship inline.
260
+ - `donjayamanne.githistory` — browse file/line history and diffs.
261
+ - `ziyasal.vscode-open-in-github` — jump from a line to its page on GitHub.
262
+ - `github.vscode-pull-request-github` — review & manage PRs/issues in-editor.
263
+
264
+ **Code quality** (pairs with `--sonar`):
265
+
266
+ - `sonarsource.sonarlint-vscode` — SonarLint findings as you type (mirrors SonarCloud).
267
+
268
+ **File-type support shipped by this scaffold**:
269
+
270
+ - `mikestead.dotenv` — syntax highlighting for `.env` / `.env.example`.
271
+ - `redhat.vscode-yaml` — schema-aware YAML (workflows, Dependabot, etc.).
272
+ - `github.vscode-github-actions` — validate & run GitHub Actions workflows.
273
+
274
+ **Markdown & docs**:
275
+
276
+ - `yzhang.markdown-all-in-one` — TOC, list editing, shortcuts, preview.
277
+ - `bierner.markdown-mermaid` — render Mermaid diagrams in Markdown preview.
278
+ - `tom-latham.markdown-pdf-plus` — export Markdown to PDF/HTML.
279
+
280
+ **Productivity & navigation**:
281
+
282
+ - `gruntfuggly.todo-tree` — collect `TODO`/`FIXME` markers into a tree.
283
+ - `hediet.vscode-drawio` — edit `.drawio` diagrams inside VS Code.
284
+ - `l13rary.l13-diff` — compare two folders side by side.
285
+ - `bokuweb.vscode-ripgrep` — fast ripgrep-powered search.
286
+ - `ritwickdey.liveserver` — serve static files with live reload.
287
+
288
+ > **Intentionally not recommended.** Color/icon **themes** (keep those in your
289
+ > personal user settings — recommending them nags the whole team) and
290
+ > **cloud/IaC tooling** (Azure CLI, Azure Resource Groups, Azure Pipelines,
291
+ > Terraform, PowerShell). devkit is a generic Node.js/Next.js kit using GitHub
292
+ > Actions, so those are off-domain — add them per-project if your repo needs them.
293
+
294
+ ## Not included (and why)
295
+
296
+ - **Babel / Webpack** — frameworks own this layer. Next.js uses SWC + webpack/
297
+ Turbopack (configure via `next.config.js`); Vite/Vitest use esbuild + Rollup;
298
+ plain TS libraries build with `tsc`/tsup. A shared Babel or Webpack config
299
+ would conflict or go unused. (A `tsup`/Rollup preset can be added if a
300
+ non-framework browser library ever needs bundling.)
301
+
302
+ ## Conventions this enforces
303
+
304
+ - **Conventional Commits** (`feat:`, `fix:`, `chore:` …) — required by the
305
+ `commit-msg` hook and read by release-please to bump the version.
306
+ - **Formatting is owned by Prettier**; ESLint surfaces deviations as warnings.
307
+ - **CI** runs `type-check`, `lint`, `lint:md`, `format:check`, `build` (each
308
+ `--if-present`, so it adapts to repos without a build step).
309
+
310
+ ## Publishing (maintainers)
311
+
312
+ ```bash
313
+ npm version <patch|minor|major>
314
+ npm publish # publishConfig.access is "public"
315
+ ```
316
+
317
+ Consumers pick up changes with `npm update devkit` (shims) — template files
318
+ are re-synced by re-running `npx devkit init --force`.