Skip to content

Commit

Permalink
Add CHANGELOG, CONTRIBUTING, PUBLISHING, PR template
Browse files Browse the repository at this point in the history
  • Loading branch information
stefcameron committed Mar 8, 2024
1 parent 6ba9b58 commit 7332888
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
Thank you for your contribution! 🎉
Please be sure to go over the PR CHECKLIST below before posting your PR to make sure we all think of "everything". :)
-->

...ADD PR DETAILS HERE...

<details>
<summary>PR Checklist</summary>
<br/>

__Please leave this checklist in your PR.__

- Issue being fixed is referenced.
- Source changes maintain browser compatibility.
- Web APIs introduced have __broad__ browser coverage (remember to check Safari which is often very late to adopt new APIs).
- Docs app has been updated (if applicable).
- Unit test coverage added/updated.
- Typings added/updated.
- Changes do not break SSR:
- Careful to test `typeof document/window !== 'undefined'` before using it in code that gets executed on load.
- README updated (API changes, instructions, etc.).
- Changes to dependencies explained.
- Changelog entry added under "UNRELEASED" section (added if did not exist).
- See [Contributing](../CONTRIBUTING.md) instructions for guidance.
- EXCEPTION: A Changelog entry is not required if the change does not affect any of the source files that produce the package bundles. For example, demo changes, tooling changes, test updates, or a new dev-only dependency to run tests more efficiently should not have a Changelog entry since it will not affect package consumers.

</details>
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ node_modules/
dist/
dist-docs/

# Test output
output.png
# Demo output
demo/
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Date format is YYYY-MM-DD.

## UNRELEASED

- First official release 🎉
51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Contributing

Thank you for considering a contribution to this project!

## Development

Local development is straightforward. Use the following CLI tools:

* `node`: At least the latest __Active__ LTS (note CI will test with latest stable version)
* `npm`: See package.json `engines` requirement

Install all project dependencies:

```bash
$ npm install
```

## Scripts

The following package scripts will get you started:

* `build`: Builds the library, outputs to `./dist`
* `demo:node`: Runs the node demo, outputs to `./demo`
* `docs`: Builds the docs app, outputs to `./dist-docs`
* `fmt`: Formats the code using Prettier.
* `fmt:check`: Checks code formatting without making any changes.
* `lint`: Checks the code for lint (syntax, style, types)
* `lint:code`: Check the code for syntax lint (i.e. `eslint`)
* `lint:types`: Check the types (i.e. `tsc`)
* `start`: Runs the docs app locally on [localhost:5173](http://localhost:5173/)
* `test`: Runs all unit tests, linting, and library build
* `test:unit`: Runs unit tests only

See `/package.json` scripts for other commands.

## Pull requests

Always include a new bullet point in the [CHANGELOG](./CHANGELOG.md) under the __UNRELEASED__ heading at the very top.

Include your change description in one of the following subsections under "UNRELEASED":

> If an "UNRELEASED" heading doesn't exist, please add one!
- "Breaking": If your change alters an existing API/type in a way that is not backward-compatible, or makes use of a Web API that doesn't yet have wide browser support.
- __AVOID__ this type of change as best as possible.
- "Added": If your change adds a new feature without breaking anything pre-existing.
- "Changed": If your change alters existing behavior without breaking anything pre-existing, including bug fixes.
- If you're fixing a bug, try to start your change description with, "Fixed ..."
- Always link to the issue being addressed when applicable, typically ending your change description with `([#123](https://github.com/stefcameron/text-to-canvas/issues/123))`

And please fill-out the pull request template when prompted!
12 changes: 12 additions & 0 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Publishing releases

The release/publishing process is as follows:

1. Checkout `master`, rebase, and make sure it's in a clean state __with no pending commits__ not yet pushed to origin.
2. Move all entries under the __UNRELEASED__ section in the `/CHANGELOG.md` into a new version section matching the version number that will be released.
- Include the release date in the new section in `YYYY-MM-DD` format.
- Remove the __UNRELEASED__ section.
3. Commit changes to `/CHANGELOG.md` using a commit message like `"Changes for version x.y.z"`.
4. Run `npm version <major|minor|patch>` to version the `package.json` and create a git tag.
5. Run `npm publish`
6. Push commits and tags to origin: `git push && git push --tags`
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"files": [
"dist",
"LICENSE",
"README.md"
"README.md",
"CHANGELOG.md"
],
"main": "./dist/text-to-canvas.umd.min.js",
"module": "./dist/text-to-canvas.esm.min.js",
Expand Down Expand Up @@ -65,6 +66,7 @@
"lint:code": "eslint \"{*,config/**/*,src/**/*}.+(js|mjs|ts|mts|vue)\"",
"lint:types": "tsc",
"prepare": "npm run build",
"prepublishOnly": "npm run lint && npm run test:unit && npm run build",
"start": "vite serve --config config/vite.config.docs.mts",
"test": "npm run lint && npm run test:unit && npm run build",
"test:unit": "npm run demo:node"
Expand Down
4 changes: 3 additions & 1 deletion src/demos/node-demo.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// TODO: import { createCanvas } from 'canvas'
// TODO: will need "canvas": "^2.11.2", in package.json if node-gyp can just succeed...
// TODO: output to ./demo/node-demo-output.png

// import { drawText, textToWords } from '../lib/index'
// // @ts-ignore
Expand Down Expand Up @@ -38,9 +39,10 @@ function main() {
// Convert the canvas to a buffer in PNG format
const buffer = canvas.toBuffer('image/png')
// @ts-ignore
fs.writeFileSync('output.png', buffer)
fs.writeFileSync('./demo/node-demo-output.png', buffer)
console.log(`Total height = ${height}`)
console.log('See demo output in ./demo/node-demo-output.png')
}
main()
Expand Down

0 comments on commit 7332888

Please sign in to comment.