This document is intended for contributors. It explains how to set up the development environment for this project.
User-oriented documentation, including installation and usage instructions, can be found in README.md.
Development VM ID from Thorsten for this project: 014
(Only interesting to him.)
- execute a
git pull
- open project in VSCode
- If you work with VSCode via remote software:
{Ctrl}+{Shift}+{P}
->>Preferences: Open Settings (UI)
-> search forkeyboard.dispatch
and set it tokeyCode
- Restart or reload VSCode.
- Install recommended extensions/ plugins:
- Open Extensions menu in VSCode (
{Ctrl}+{Shift}+{X}
) - type in the search
@recommended
- install and enable the plugins
- see file
.vscode/extensions.json
for configuring some of the extensions - Restart or reload VSCode.
- Open Extensions menu in VSCode (
- In VSCode on the bottom left click your profile image and log in all services (GitHub due to VSCode extensions, ...)
If the browser to VSCode callback fails, wait for the login popup on the bottom right to timeout (ca. 5 minutes) and then on the upcoming popup questionYou have not yet finished authorizing [...] Would you like to try a different way? (local server)
clickYes
and use this alternative login mechanic.
(When you do not want to wait for the timeout to happen, you can also click theCancel
to trigger the dialog faster.) - Install dependencies:
pnpm i
- Happy coding <3
When the variable {VERSION}
is used in the following, then the exact string from field version
of the
package.json
is meant, so to say the new version that the software will have after the release without
prefixes like v
.
- Do not merge new things while the release is prepared, so stop it here until done.
- Check out branch
main
locally. - Let us reset possible local disparities & test if the lockfile is healthy:
rm -rf node_modules/ dist/ pnpm install --frozen-lockfile
- Let us now find what the new version should be, therefore you have two ways to go:
- Variant 1: automatically detect new version depending on conventional commits of the commit messages since
the old version
- bump the new version in
package.json
depending on conventional commits of the commit messages since the old version and generate a new entry inCHANGELOG.md
.
(You could force a verion bump, but this is not what we whant. But see Doc for details.)pnpm changelogen --no-commit --no-tag --bump [--{FORCE_VERSION}]
- See the changes made in
package.json
andCHANGELOG.md
and check if the version is reasonable. - Reset the changelog bc we will generate it later again:
git checkout "CHANGELOG.md"
- bump the new version in
- Variant 2: manually set a new version
- Open the
package.json
and write the wanted version in theversion
field.
- Open the
- Variant 1: automatically detect new version depending on conventional commits of the commit messages since
the old version
- Use the following to create a changelog for the new version:
pnpm changelogen --output CHANGELOG.md -r "{VERSION}" --no-commit --no-tag
- Create a branch with the name
rel/v{VERSION}
so that the made changes that are not committed yet are on there. - Commit the made changes to the branch.
(You can use whatever commit message you want to use, e.g.chore: prepare release v{VERSION}
.) - Create a PR on GitHub for the branch to be merged to
main
with the title:chore(release): v{VERSION}
- Open
CHANGELOG.md
.- Directly after the headline
## v{VERSION}
add the following with correctly changed content:Compare changes [from v{VERSION-old} to v{VERSION}](https://github.com/toddeTV/gltf-type-toolkit/compare/v{VERSION-old}...v{VERSION}) or see [full changelog](https://github.com/toddeTV/gltf-type-toolkit/blob/main/CHANGELOG.md).
- In the
### 🏡 Chore
section (always the last before### ❤️ Contributors
) add a new line at the end with the correct content for{VERSION}
and{PR_NUMBER}
:- **release:** v{VERSION} ([#{PR_NUMBER}](https://github.com/toddeTV/gltf-type-toolkit/pull/{PR_NUMBER}))
- [optional] Change more things if needed (e.g. add description text at the top, ...)
- Directly after the headline
- Commit the made changes to the branch.
(You can use whatever commit message you want to use, e.g.chore: add current release PR to changelog
.) - Squash & merge the GitHub PR to
main
. - The GitHub workflow action defined in the file
github-release-and-npm-package-publish.yml
will create a GitHub Release & a NPM package publishing for the new version. - Now you can continue merging new things, the release is done.
The commit message trigger must be present in the main commit message, so to say the first line, not the description.
Using the suffix [rel-TYPE-CHANGELOG]
in a commit message on branch main
will trigger the GitHub
workflow (CI action) that uses pnpm changelogen
under the hood to analyze the
Conventional Commits from the last version to the current
commit.
-
TYPE
can be:none
will take the version frompackage.json
as new version (best if you already set the wanted new version locally and pushed it)- All other types will bump the version in
package.json
like the following:- automatically:
auto
: Bump the version depending on the detected semver changes.
- manually by forcing a version increase:
major
: Bump as a semver-major versionminor
: Bump as a semver-minor versionpatch
: Bump as a semver-patch versionpremajor
: Bump as a semver-premajor version, can set id with string.preminor
: Bump as a semver-preminor version, can set id with string.prepatch
: Bump as a semver-prepatch version, can set id with string.prerelease
: Bump as a semver-prerelease version, can set id with string.
- automatically:
-
CHANGELOG
can be:n
for using the givenCHANGELOG.md
without updates (best if you already created it locally and pushed it)y
for updating theCHANGELOG.md
according to the semver commit messages from last version tag to current commit (recommended)
- evaluate the parameter and work accordingly
- [optional] Committing changes as author
github-actions[bot] <no-reply@todde.tv>
directly on branchmain
if changes were made - Creating a tag at the new version commit on with the version number
- Creating a GitHub Release out of it
- Publishing the package into the NPM Registry
You can use pnpm changelogen --dry
to generate the new changelog in a dry run to preview in development.
It uses Handlebars to generate the code.
Here's a more detailed explanation of how everything works:
-
During local installation, all Handlebars templates are precompiled into JavaScript code so they can be bundled without the need to manually specify which
*.hbs
files need to be included or reference them at runtime.- The process works by scanning all files in the
src
directory and generating a TypeScript file for each found template. - These files contain the precompiled Handlebars code and export the instantiated template (which is a regular function) as the default export. This allows the templates to be used simply by importing them.
- The script treats partials (identified by being in
_partials
directories) differently: They are also precompiled as described above, but for each_partials
directory, an index file is generated that registers all the contained partials on import. - To generate these two types of files, the script itself uses Handlebars templates. These do not need to be precompiled or bundled as they are only used during the plugin's development.
- The process works by scanning all files in the
-
The templates themselves are fairly simple but split across multiple files and helpers to reduce duplication.
- The
fn_prefix
partial generates code for the node getter function and is adaptable for both.d.ts
and.js
code. For example, in declaration files, the use ofasync function
is not allowed. - The
children
partial is recursive and constructs the tree of child indices, using a helper function to build the index array. - The
imports
partial builds a list of imports and takes into account type-only imports. Currently, this is not required and is a remnant of a previous iteration. I decided to keep it in, as it might be useful in the future. - The main templates,
declaration
andruntime
, are now simply wrappers around these partials.
- The
See PR #16, which introduces this logic for the first time.
This project uses antfu/eslint-config for eslint most of the files. The following extend it:
- antfu/eslint-plugin-format for using external formatters like
e.g.
prettier
for the file types that eslint cannot handle. - azat-io/eslint-plugin-perfectionist for sorting object keys, imports, etc. - with auto-fix.
Keep in mind that the plugin names are renamed, see Plugins Rename, e.g.:
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
+// eslint-disable-next-line ts/consistent-type-definitions
type foo = { bar: 2 }
Why I don't use Prettier for every file type
[currently none]