english | русский
Template for creating new packages on the Diplodoc platform.
Migrating from a package created from an older version of this template? See MIGRATION.md (RU).
# Clone this repo to a new folder
git clone git@github.com:diplodoc-platform/package-template.git new-package
cd new-package
# Init repo with the new package name
./init.sh new-packageThe init.sh script will:
- Replace
package-templatewith your package name inpackage.json,README.md, andAGENTS.md - Strip the template section from
AGENTS.md - Refresh
@diplodoc/infrascaffolding to the latest version vianpx @diplodoc/infra init:- lint configs (
.eslintrc.js,.prettierrc.js,.stylelintrc.js,.lintstagedrc.js) - editor / VCS configs (
.editorconfig,.gitattributes) - Git hooks via Husky (
.husky/pre-commit,.husky/commit-msg) - CI workflows (
.github/workflows/*.yml) .github/CODEOWNERSand.github/dependabot.yml.release-please-config.jsonand.release-please-manifest.json- SonarCloud config (with
{{PACKAGE_NAME}}substituted to your new name) - Standard
lint,lint:fix,pre-commit,preparescripts inpackage.json
- lint configs (
- Install dependencies
- Update the git remote URL
- Remove template-only files (
init.sh,README-template.md,MIGRATION*.md)
After initialization, you'll have a fully configured package with:
- TypeScript configuration extending
@diplodoc/infra/tsconfig.json - ESLint, Prettier, and Stylelint configured via
@diplodoc/infra(with.eslintrc.jsextending@diplodoc/infra/eslint-config) - Git hooks via Husky
- Build scripts using
@diplodoc/infra/esbuild(esbuild is re-exported from@diplodoc/infra) - Type declarations generation via
tsc - Vitest testing setup with an example test
- GitHub Actions workflows (
tests,security,coverage,release,release-please,package-lock,update-deps) - GitHub templates (issue templates, PR template) preserved from the template repo
- Dependabot configuration
- Release-please for automated versioning and changelog generation
- SECURITY.md and CONTRIBUTING.md documentation
The new package uses the push distribution model from @diplodoc/infra.
When a new stable version of @diplodoc/infra is released, an automated PR
is opened in every consumer repository listed in @diplodoc/infra's
distribution.yml with the latest scaffolding (CI workflows, lint configs,
husky hooks, release-please configs, etc.).
To customize per-package exclusions, add a .infrarc.yml file at the
package root:
exclude:
- path: .github/workflows/tests.yml
reason: 'Custom matrix build'See diplodoc-platform/infra for details.
The template itself (this repository) is also kept in sync via the same pipeline if it's listed in
distribution.yml, so the scaffolding committed here is always in line with the canonical version.
- Update
README.mdwith your package description - Update
package.jsondescription,repository,bugsURLs - Add your code to
src/index.ts - Configure exports in
package.jsonif needed - Add tests (Vitest is already configured with an example test)
- Update GitHub templates (
.github/ISSUE_TEMPLATE/,.github/pull_request_template.md) if needed - Update
SECURITY.mdwith your contact email if different - Set up GitHub Secrets for publishing:
NPM_TOKEN: required for npm publishingYC_UI_BOT_GITHUB_TOKEN: required byrelease-please.ymland other workflowsSONAR_TOKEN: optional, for SonarCloud coverage uploads
The package uses release-please for automated releases:
- Make conventional commits (e.g.,
feat: add feature,fix: bug fix) release-pleaseautomatically creates/updates a release PR- Review and merge the release PR
release-pleasecreates a GitHub release- The
release.ymlworkflow publishes the package to npm
package-name/
├── src/
│ ├── index.ts # Main source file
│ └── index.test.ts # Example test file
├── build/ # Build output (generated, excluded from VCS)
├── esbuild/
│ └── build.mjs # Build configuration (uses @diplodoc/infra/esbuild)
├── .github/
│ ├── ISSUE_TEMPLATE/ # Issue templates (custom)
│ ├── workflows/ # CI/CD workflows (managed by @diplodoc/infra)
│ ├── CODEOWNERS # managed by @diplodoc/infra
│ ├── dependabot.yml # managed by @diplodoc/infra
│ └── pull_request_template.md # custom
├── .husky/ # managed by @diplodoc/infra
├── tsconfig.json # TypeScript config (extends @diplodoc/infra/tsconfig.json)
├── tsconfig.publish.json # TypeScript config for declarations
├── vitest.config.mjs # Vitest configuration
├── .release-please-config.json # managed by @diplodoc/infra
├── .release-please-manifest.json # managed by @diplodoc/infra
├── .eslintrc.js # managed by @diplodoc/infra
├── .prettierrc.js # managed by @diplodoc/infra
├── .stylelintrc.js # managed by @diplodoc/infra
├── .lintstagedrc.js # managed by @diplodoc/infra
├── .editorconfig # managed by @diplodoc/infra
├── .gitattributes # managed by @diplodoc/infra
├── sonar-project.properties # managed by @diplodoc/infra
├── package.json
├── SECURITY.md
├── CONTRIBUTING.md
└── README.md
- Make changes in
src/ - Run
npm testto run tests - Run
npm run buildto build - Run
npm run lintto check code quality - Run
npm run typecheckto verify types - Commit changes (the pre-commit hook will run lint-staged automatically)
The package ships with a standard set of GitHub Actions workflows
(@diplodoc/infra-canonical):
tests.yml— type check, lint, tests, build on Linux/macOS/Windows + Nodevars.NODE_VERSIONsecurity.yml— weeklynpm auditcoverage.yml— optional coverage upload (runs whentest:coverageis defined)release.yml— publishes the package to npm on release (also supportsprereleaseanddeprecateviaworkflow_dispatch)release-please.yml— generates release PRs withCHANGELOG.mdand version bumpspackage-lock.yml— keepspackage-lock.jsonin sync after PR mergesupdate-deps.yml— manual workflow to bump@diplodoc/*dependencies