From 68c6f4960a8ed808a4083be017ad82a8539fc68f Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Wed, 27 Sep 2023 10:21:57 -0400 Subject: [PATCH] v2.0.0: Refactor, New Features, etc. (#113) * Refactor CI workflow * Update dev dependencies * Add publishConfig to package.json * Set current year in banner * Specify lts/hydrogen as development version * Set minimum supported Node.js version * Use JSDoc syntax in banner comments * Remove dist folder and gitignore it * Regenerate lockfile * Specify files to be in published tarball * Point to src files in example and test * Remove CONTRIBUTING.md * Formatting and name changes and whatnot * Add test against null textContent value * Add support for null textContent * Document support for null textContent * Add more insertion non-Object tests * S E M I C O L O N S * Properly check insertions argument type * Remove dist files * Add and configure concurrently and http-server * Re-point example and spec at built dist files * Use Array.isArray() * Add another spec * Add commit message prefixes to Dependabot config * Add CHANGELOG.md * Rebuild lockfile * Refactor ESLint config file * Add publish workflow * Bump version and update CHANGELOG --- .github/dependabot.yml | 4 + .github/workflows/ci.yml | 35 +- .github/workflows/publish.yml | 43 ++ .gitignore | 3 +- .nvmrc | 2 +- CHANGELOG.md | 33 + CONTRIBUTING.md | 55 -- README.md | 58 +- dist/templatetemplate.js | 41 -- dist/templatetemplate.min.js | 12 - dist/templatetemplate.mjs | 36 - eslint.config.js | 9 +- package-lock.json | 1242 ++++++++++++++++++++++++++------- package.json | 27 +- rollup.config.mjs | 14 +- spec/spec.mjs | 90 ++- src/templatetemplate.mjs | 15 +- 17 files changed, 1193 insertions(+), 526 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 CHANGELOG.md delete mode 100644 CONTRIBUTING.md delete mode 100644 dist/templatetemplate.js delete mode 100644 dist/templatetemplate.min.js delete mode 100644 dist/templatetemplate.mjs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 34f89bb..6335b83 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,9 +7,13 @@ updates: interval: "weekly" assignees: - "jgarber623" + commit-message: + prefix: "ci" - package-ecosystem: "npm" directory: "/" schedule: interval: "monthly" assignees: - "jgarber623" + commit-message: + prefix: "chore" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4346fc6..423bf22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,11 @@ name: CI -on: [push, pull_request] +on: + pull_request: + workflow_call: + workflow_dispatch: jobs: - analyze: - name: Analyze - permissions: - contents: read - security-events: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: github/codeql-action/init@v2 - with: - languages: javascript - - uses: github/codeql-action/analyze@v2 lint: name: Lint runs-on: ubuntu-latest @@ -26,25 +17,9 @@ jobs: cache: npm - run: npm ci - run: npm run lint - build: - name: Build - needs: [analyze, lint] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - cache: npm - - run: npm ci - - run: npm run build - - name: Check for changed files - run: | - git status - git diff --quiet test: name: Test - needs: build + needs: lint runs-on: macos-latest strategy: matrix: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..934dc77 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,43 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + ci: + name: CI + uses: ./.github/workflows/ci.yml + publish-to-npm: + name: Publish to npm + needs: ci + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: npm + registry-url: https://registry.npmjs.org + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish-to-github-packages: + name: Publish to GitHub Packages + permissions: + contents: read + packages: write + needs: ci + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: npm + registry-url: https://npm.pkg.github.com + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index c2658d7..3d2bc62 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules/ +/dist/ +/node_modules/ diff --git a/.nvmrc b/.nvmrc index b009dfb..a77793e 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -lts/* +lts/hydrogen diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c2a95e1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +## 2.0.0 (2023-09-27) + +- 46460b8 chore: Add publish workflow +- 1085936 chore: Refactor ESLint config file +- 65f3092 chore: Rebuild lockfile +- 5e1092b docs: Add CHANGELOG.md +- a239fb8 chore: Add commit message prefixes to Dependabot config +- 625576c chore: Add another spec +- 849b1af feat: Use Array.isArray() +- 5a701e7 chore: Re-point example and spec at built dist files +- 8e39544 chore: Add and configure concurrently and http-server +- 230245e chore: Remove dist files +- 68d8081 fix: Properly check insertions argument type +- 3bd434d fix: S E M I C O L O N S +- 5fcd652 chore: Add more insertion non-Object tests +- 6d418c3 docs: Document support for null textContent +- fbbf654 feat: Add support for null textContent +- 426d9e3 chore: Add test against null textContent value +- 199f5e9 chore: Formatting and name changes and whatnot +- 76609b0 docs: Remove CONTRIBUTING.md +- 86d5de5 chore: Point to src files in example and test +- 8800f79 chore: Specify files to be in published tarball +- 7bcbbba chore: Regenerate lockfile +- e90dce4 chore: Remove dist folder and gitignore it +- c614555 docs: Use JSDoc syntax in banner comments +- 80db616 breaking: Set minimum supported Node.js version +- 51ef4a6 chore: Specify lts/hydrogen as development version +- f8a38d0 chore: Set current year in banner +- 3bb1f3b chore: Add publishConfig to package.json +- 1082b37 chore: Update dev dependencies +- 098a32d chore: Refactor CI workflow diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index ec3fdde..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,55 +0,0 @@ -# Contributing to TemplateTemplate - -I'd love to have your help improving TemplateTemplate! If you'd like to pitch in, you can do so in a number of ways: - -1. Look through open [Issues](https://github.com/jgarber623/TemplateTemplate/issues). -1. Review any open [Pull Requests](https://github.com/jgarber623/TemplateTemplate/pulls). -1. [Fork TemplateTemplate](#get-set-up-to-contribute) and fix an open Issue or add your own feature. -1. File new Issues if you have a good idea or see a bug and don't know how to fix it yourself. _Only do this after you've made sure the behavior or problem you're seeing isn't already documented in an open Issue._ - -I definitely appreciate your interest in (and help improving) TemplateTemplate. Thanks! - -## Install development dependencies - -TemplateTemplate's build process uses [npm](https://www.npmjs.com) and [Node.js](https://nodejs.org). If you're using a Mac, the easiest way to install npm and Node.js (and plenty of other great tools) is with [Homebrew](https://brew.sh): - -```sh -brew install node -``` - -If you're using a different operating system, use a different package manager, or prefer not to use Homebrew, check out the [Node.js Downloads page](https://nodejs.org/en/download/). - -## Get set up to contribute - -Contributing to TemplateTemplate is pretty straightforward: - -1. Fork the TemplateTemplate repo and clone it. -1. Install development dependencies by running `npm install` from the root of the project. -1. Create a feature branch for the issue or new feature you're looking to tackle: `git checkout -b your-descriptive-branch-name`. -1. Run `npm start` which instructs [Rollup](https://rollupjs.org) to watch `src/templatetemplate.mjs` for changes and automatically exports built files to the `dist` folder. -1. _Write some code!_ -1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `npm test`. -1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`. -1. Push the branch to your fork of TemplateTemplate: `git push origin your-descriptive-branch-name`. -1. Create a new Pull Request and I'll give it a look! - -## "But which files do I change?!?" - -Excellent question. TemplateTemplate's source code is in the file `src/templatetemplate.mjs`. Make your changes here! - -When you're done working (and before you push your code or issue a pull request), run `npm run build` from the root of the project to recreate the files in the `dist` folder. This task will generate compiled and compressed versions of the project. - -**Do not directly edit the files in the `dist` folder!** - -## Code Style - -Code styles are like opinions: Everyone's got one and yours is better than mine. Here's how TemplateTemplate should be written: - -- Use two spaces for indentation. -- No trailing whitespace and blank lines should have whitespace removed. -- Prefer single quotes over double quotes unless interpolating. -- Follow the conventions you see in the existing source code as best as you can. - -TemplateTemplate's formatting guidelines are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org) syntax. There are [a number of great plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. Using EditorConfig will make your time spent coding a little bit easier. - -Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier. diff --git a/README.md b/README.md index 93df532..106258b 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ - Uses established Web standards (e.g. `