Configuration
How the generated configs extend the Forge.js base configs, and how to override them.
This page explains how the config files init generates relate to the base configs in @apollogeddon/forgejs, and where to put project-specific settings.
Forge.js uses layered configuration: each tool’s project-level config extends a base config shipped in the package, so you override only what your project needs.
Shared configs
The base configs are published through the package’s exports, and init adds @apollogeddon/forgejs as a devDependency so they resolve after npm install.
| Base config | Extended by |
|---|---|
node_modules/@apollogeddon/forgejs/configs/biome.json |
biome.json |
@apollogeddon/forgejs/configs/tsconfig.json |
tsconfig.json |
@apollogeddon/forgejs/vitest.config.cjs |
vitest.config.ts |
@apollogeddon/forgejs/tsdown.config.cjs |
tsdown.config.ts |
@apollogeddon/forgejs/commitlint.config.cjs |
commitlint.config.ts |
Biome resolves extends as a file path, so biome.json references the copy in node_modules. The others use the package’s exports.
Upgrading @apollogeddon/forgejs updates every base config at once, with no files to refresh.
Quality and testing
Biome: linting and formatting
The generated biome.json extends the shared config:
{
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["node_modules/@apollogeddon/forgejs/configs/biome.json"]
}
Add project-specific settings alongside extends; they take precedence over the base.
TypeScript
The generated tsconfig.json extends the shared TypeScript config, so every project compiles with the same strictness settings. Add compilerOptions to override individual settings.
The shared config sets rootDir, outDir and paths with ${configDir}, which TypeScript reads as the directory of your tsconfig.json, not the package’s. So tsc builds into your project’s dist/, and @/* is an alias for your src/*:
import { greeting } from "@/util"; // src/util.ts
Vitest, Vite and tsdown read the alias from tsconfig.json, so it works in tests and builds too.
Vitest: testing
The generated vitest.config.ts merges the base configuration:
import baseConfig from "@apollogeddon/forgejs/vitest.config.cjs";
import { mergeConfig } from "vitest/config";
export default mergeConfig(baseConfig, {
test: {
// Project-specific overrides
},
});
Lefthook: Git hooks
lefthook.yml runs Biome and Publint before each commit, and commitlint on each commit message:
| Hook | Stage |
|---|---|
biome check on staged files |
pre-commit |
publint |
pre-commit |
commitlint --edit |
commit-msg, only with versioning on |
Lefthook installs the hooks through the prepare script when you run npm install. To customise them, edit lefthook.yml.
commitlint: commit messages
With versioning on, the generated commitlint.config.ts extends the shared Conventional Commits configuration:
import baseConfig from '@apollogeddon/forgejs/commitlint.config.cjs';
import type { UserConfig } from '@commitlint/types';
const Configuration: UserConfig = {
extends: baseConfig.extends,
// Add project-specific rules here
};
export default Configuration;
Build and release
tsdown: TypeScript bundler
Backends and libraries bundle with tsdown. The base config builds src/index.ts to ESM for Node.js, with type declarations and source maps, keeping the .js and .d.ts extensions that main, types and bin point to. The generated tsdown.config.ts spreads it:
import baseConfig from "@apollogeddon/forgejs/tsdown.config.cjs";
import { defineConfig } from "tsdown";
export default defineConfig({
...baseConfig,
});
Vite: websites
--website generates a vite.config.ts that builds to dist/, the directory the pages pipeline deploys to GitHub Pages. It sets base: "./" so asset URLs are relative and the site works under a GitHub Pages project path (https://<owner>.github.io/<repo>/).
release-please: versioning
The reusable version.yml pipeline runs release-please with the node release type. It needs no local config file: version numbers and changelogs come from your Conventional Commits.
To set release-please options, add a config and manifest to the project’s .github directory (under working_directory, if set). version.yml then runs release-please from them instead of the node defaults. The config keys the package by its path from the repository root, . for a project at the root:
{
"packages": {
".": {
"release-type": "node",
"include-component-in-tag": false
}
}
}
{
".": "X.Y.Z"
}
Set the manifest to the current released version. See release-please’s config options for the rest.
Docker
--docker adds a multi-stage Dockerfile:
- Backend: compiles once on the build host, installs production dependencies per target platform, and runs
node dist/index.jsonnode:<version>-slim, at the project’s Node.js version, as the non-rootnodeuser. - Website: builds the static site once on the build host and serves it with
nginx:stable-alpineon port 80.
CI builds the image for every configured platform on pull requests, and pushes it on a release. See docker.yml in the pipeline reference.
Snodeb: Debian packaging
--debian generates a snodeb.config.cjs (CommonJS, as Snodeb requires). Edit it to suit your service; this is the generated default:
const { defineSnodebConfig } = require("snodeb");
module.exports = defineSnodebConfig({
architecture: "all",
depends: ["nodejs"],
files: {
include: ["dist/index.js", "node_modules/**/*"],
configInclude: [".env", "config/default.json"],
prune: true,
unPrune: false,
},
systemd: {
user: "root",
group: "node-service",
entryPoint: "dist/index.js",
},
});
Windows and macOS
--windows and --macos add no files: they set test_windows: windows-latest and test_macos: macos-latest on the checks job in .index.yml, so the library or service pipeline also runs the tests and the build on that system and uploads the build as its own artifact. A website has no such stages, so init refuses them with --website. Without them, CI runs on Linux only, as a private repository pays more for Windows and macOS minutes. To pass a runner’s environment, a shorter suite or a setup script, edit the job’s inputs instead; see Windows and macOS.
Node.js version
A project’s Node.js version lives in .nvmrc, which init writes with forgejs’s default, or the version --node gives, and nvm, fnm and actions/setup-node all read. init also sets engines.node to that version or newer in package.json, unless the project already has one; --node replaces it.
Every pipeline stage that sets up Node.js picks the version in this order:
- The
node_versioninput, when the caller sets one. - The project’s
.nvmrc. - forgejs’s default, when the project has neither.
So moving a project to another version is one edit to .nvmrc. The generated Dockerfile’s node base images are the one other place to change.
Repository files
init also writes three files for the repository itself. Like the configs, an existing file is kept unless you pass --force.
| File | What it does |
|---|---|
.editorconfig |
LF line endings, UTF-8, 2-space indent and 120 columns, matching the Biome config |
.gitattributes |
LF in the working tree on every platform, so a Windows checkout reads the same; written once, never overwritten, so your own rules (Git LFS, say) are safe |
.github/dependabot.yml |
Weekly npm and GitHub Actions updates, plus Docker with --docker. Minor and patch updates are grouped into one pull request, and each update waits 3 days after it’s published before it’s proposed, so a compromised release has time to be caught upstream. The merge pipeline requests your review on them and squash-merges each one once CI passes, majors included. |
.github/CODEOWNERS |
* @owner, so every pull request someone else opens, Dependabot’s and release-please’s included, requests your review and shows in your review requests. It doesn’t block merging. |
In a private repository, Dependabot can’t read @apollogeddon/forgejs, or your own packages, from GitHub Packages without a token, and its npm updates fail with private_source_authentication_failure. Add a classic token with only read:packages as a Dependabot secret named PACKAGES_TOKEN (Settings → Secrets and variables → Dependabot), then give the npm update the registry:
registries:
npm-github:
type: npm-registry
url: https://npm.pkg.github.com
# Without a committed .npmrc, Dependabot needs the scope this registry serves.
scope: "@apollogeddon"
token: ${{ secrets.PACKAGES_TOKEN }}
updates:
- package-ecosystem: "npm"
registries:
- npm-github
# ...the rest of the generated entry
init leaves this out, as a public repository needs no token and Dependabot fails on a secret that doesn’t exist.
The CODEOWNERS owner is the GitHub account in package.json’s repository field or, failing that, the origin remote. A project with neither gets no CODEOWNERS; run init again once it has a GitHub remote.