Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
foxted committed May 24, 2023
1 parent fc9ef05 commit 1ec4966
Show file tree
Hide file tree
Showing 8 changed files with 14,177 additions and 5,059 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Build, Lint, and Test'
name: Build, Lint, and Test

on: pull_request

Expand All @@ -8,16 +8,16 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [18.x]

steps:
- name: Check out the code
uses: actions/checkout@v2
uses: actions/checkout@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/main.yaml → .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,38 @@ jobs:
ENTITY_NAME: npm-library-initializer
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v2

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- uses: actions/setup-python@v2
with:
python-version: 3.9.1
- uses: google-github-actions/[email protected]
python-version: 3.11.3

- uses: google-github-actions/setup-gcloud@v1
with:
version: 290.0.1
project_id: ${{ secrets.SIMPLIFY_HUB_GCP_PROJECT_ID }}
service_account_key: ${{ secrets.SIMPLIFY_HUB_GCP_SA_KEY }}
credentials_json: ${{ secrets.SIMPLIFY_HUB_GCP_SA_KEY }}
export_default_credentials: true
- uses: cloudbees/plantuml-github-action@master
- name: Get techdocs guide github actions
uses: actions/checkout@v2

- name: Generate images for PlantUML diagrams
uses: cloudbees/plantuml-github-action@master

- name: Get TechDocs guide github actions
uses: actions/checkout@v3
with:
repository: telus/techdocs-common-files
ref: main
token: ${{ secrets.SIMPLIFY_HUB_GITHUB_TOKEN }}
path: common-files
- name: Techdocs guide building

- name: TechDocs guide building
uses: ./common-files/actions/guides
with:
github-token: ${{ secrets.SIMPLIFY_HUB_GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Publish package on merge to master'
name: Publish package

on:
push:
Expand All @@ -12,12 +12,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18

- name: Install deps
run: npm ci
Expand Down
74 changes: 26 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# NPM Library Initializer
![maintenance-status](https://img.shields.io/badge/maintenance-passively--maintained-yellowgreen.svg)
![npm (scoped)](https://img.shields.io/npm/v/@telus/create-library)


[![version][npm-image]][npm-url]
# NPM Library Initializer

An opinionated [npm package initializer][npm-init]. Scaffolds an npm library tree with fully configured CI automation, using a predefined [template](./template).
An opinionated [npm package initializer](https://docs.npmjs.com/cli/init#description). Scaffolds an npm library tree with fully configured CI automation, using a predefined [template](./template).

Use this to easily scaffold an NPM package for use within TELUS.

Expand All @@ -19,13 +21,13 @@ This starter kit is opinionated, and it is meant to encourage a good set of prac

Here are some of the principles and concepts we have based this on:

- We use Git _feature branches_, which allow us to isolate the development work and instantly get feedback as to how the changes impact the the unit tests and lint checks (using Github actions and integrated status checks).
- We believe in _the power of automation_, which is why we have opted for automated semantic versioning and releasing using [semantic-release][semantic-release]. The template pipeline is configured to only run the `release` step on the `master` branch, which is why it is vital that only good code gets pushed to it.
- We use Git _feature branches_, which allow us to isolate the development work and instantly get feedback as to how the changes impact the unit tests and lint checks (using Github actions and integrated status checks).
- We believe in _the power of automation_, which is why we have opted for automated semantic versioning and releasing using [semantic-release](https://github.com/semantic-release/semantic-release). The template pipeline is configured to only run the `release` step on the `master` branch, which is why it is vital that only good code gets pushed to it.
- Given this, we encourage implementing _branch protection for the `master` branch_ and merging changes into it following a pull request process, with at least one approval required. Having the unit tests and lint checks run in the CI pipeline automatically allows the PR reviewers to focus on the actual code changes, without having to always pull the respective branch locally to confirm no issues are introduced.
- Automation of the package release workflow is made possible by following _formalized git commit conventions_, more specifically [angular-commit-conventions][angular-commit-conventions]. This removes the immediate connection between human emotions and version numbers, strictly following the Semantic Versioning specs. Please refer to our [semantic-release][guides-semantic-release] guide for more details about how this works.
- We are fans of _configuration as code_, which is why we are taking advantage of Github's [Probot][probot-settings] framework to store the repository settings as [code](./.github/settings.yml). Please review these and configure as needed. We encourage the practice of squashing commits and keeping a clean commit history (without standard merge commits cluttering the history). If squashing commits is a practice your team chooses to use, you will have the responsibility to ensure that the squashed commit message follows the Angular commit conventions and captures all included changes correctly.
- We believe there is a lot of value in having _consistent code style_ across all of our projects, which is why we have centralized the configuration of our code quality and style checking tools in external libraries, such as [@telus/telus-standard][telus/telus-standard], [@telus/remark-config][telus/remark-config], etc. We encourage teams to use our centralized config packages and not override particular rules; our configuration is open to suggestions to contributions (feel free to add issues and/or open PRs in the repositories of the above mentioned packages).
- We believe in automation and in _leveraging automated code formatters_ such as [prettier][prettier]. The scaffolded library will be configured out of the box to automatically format all the staged files when the user commits. For that, we are using [husky][husky] to configure the pre-commit hook and restrict the formatting to the staged files that are part of the commit.
- Automation of the package release workflow is made possible by following _formalized git commit conventions_, more specifically [conventional-commit-conventions](https://www.conventionalcommits.org/en/v1.0.0/). This removes the immediate connection between human emotions and version numbers, strictly following the Semantic Versioning specs. Please refer to our [semantic-release][guides-semantic-release] guide for more details about how this works.
- We are fans of _configuration as code_, which is why we are taking advantage of Github's [Probot](https://github.com/probot/settings) framework to store the repository settings as [code](./.github/settings.yml). Please review these and configure as needed. We encourage the practice of squashing commits and keeping a clean commit history (without standard merge commits cluttering the history). If squashing commits is a practice your team chooses to use, you will have the responsibility to ensure that the squashed commit message follows the Angular commit conventions and captures all included changes correctly.
- We believe there is a lot of value in having _consistent code style_ across all of our projects, which is why we have centralized the configuration of our code quality and style checking tools in external libraries, such as [@telus/telus-standard](https://github.com/telus/telus-standard), [@telus/remark-config](https://github.com/telus/remark-config), etc. We encourage teams to use our centralized config packages and not override particular rules; our configuration is open to suggestions to contributions (feel free to add issues and/or open PRs in the repositories of the above mentioned packages).
- We believe in automation and in _leveraging automated code formatters_ such as [prettier](https://prettier.io/). The scaffolded library will be configured out of the box to automatically format all the staged files when the user commits. For that, we are using [husky](https://github.com/typicode/husky) to configure the pre-commit hook and restrict the formatting to the staged files that are part of the commit.

## <a id="step-1"></a> Requirements

Expand All @@ -37,20 +39,19 @@ Here are some of the principles and concepts we have based this on:
This NPM library initializer is a CLI tool that makes the process of creating and publishing a new NPM package significantly easier and faster. Here's what you get out of the box:

- Scaffolded NPM library, with automatically generated `package.json` and Github settings based on user input
- Github Actions for a standard workflow, including installing dependencies, testing, linting, and automated releases
- Automated version management and NPM package publishing using [semantic-release](https://github.com/semantic-release/semantic-release), that uses formalized commit message convention to document changes in the codebase
- Basic setup for unit tests with [tap](https://github.com/tapjs/node-tap)
- Security auditing using [npm audit](https://docs.npmjs.com/cli/audit)
- `.editorconfig` linting using [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker.javascript)
- Javascript linting using [telus-standard](https://github.com/telus/telus-standard), and a command to automatically fix most small issues
- Automated dependency updates using Dependabot
- Github repository settings as code living in the repository of your library (see [probot/settings][probot-settings] for more details)
- Github Actions [configuration file](./template/.github/main.workflow) for a standard workflow, including installing dependencies, testing, linting, and automated releases
- Automated version management and NPM package publishing using [semantic-release][semantic-release], that uses formalized commit message convention to document changes in the codebase
- Basic setup for unit tests with [tap][tap]
- Security auditing using [npm audit][npm-audit]
- `.editorconfig` linting using [editorconfig-checker][editorconfig]
- Javascript linting using [telus-standard][telus-standard], and a command to automatically fix most small issues
- Markdown linting for your README files using [remark-cli][remark-cli], and a command to automatically fix most small issues
- Automated dependency updates using [renovate bot][renovate]

Some of the tools mentioned above rely on centralized configuration files, that allow us to achieve consistency across all of the applications built by our team, and remove duplicated configs across all of our repositories. You are welcome to open a PR in either of these if you would like to suggest any changes:

- `telus-standard` (Javascript linting with our own flavour of StandardJS) - see [@telus/telus-standard][telus/telus-standard]
- `remark` (Markdown linting) - see [@telus/remark-config][telus/remark-config]
- `telus-standard` (Javascript linting with our own flavour of StandardJS) - see [@telus/telus-standard](https://github.com/telus/telus-standard)
- `remark` (Markdown linting) - see [@telus/remark-config](https://github.com/telus/remark-config)

## <a id="step-3"></a> Usage

Expand All @@ -77,13 +78,13 @@ When you run `npm init @telus/library`, you will be prompted with a few question
- project title
- project description
- repository name
- license type (read more about license types [here][github-licenses])
- license type (read more about [license types](https://help.github.com/articles/licensing-a-repository/))
- keywords
- maintainers (Github team slug)

### What's this `npm init` magic?

The `npm init` command was solely used to create a new `package.json` file. As of npm v6.1.0, `npm init` can be used as an initializer by passing the name of the package you want initialized after `npm init`; npm will prepend `create-` to the name of the initializer you provide and use `npx` to temporarily install and execute that project. You can read more about this [here][npm-init].
The `npm init` command was solely used to create a new `package.json` file. As of npm v6.1.0, `npm init` can be used as an initializer by passing the name of the package you want initialized after `npm init`; npm will prepend `create-` to the name of the initializer you provide and use `npx` to temporarily install and execute that project. You can read more about this [here](https://docs.npmjs.com/cli/init#description).

As a result, this is what happens after you run `npm init @telus/library`:

Expand All @@ -104,7 +105,7 @@ If you are thinking of bringing these updates into an existing NPM library, and
- You'll probably notice that this will create a few new files, and also modify some existing ones.
- Use your IDE or any diffing tool to walk through the changes and remove any unnecessary files.
- Pay special attention to `package.json` and your `README` files, as these will be completely replaced; however, you'll want to merge what you had in there before with what gets generated.
- If you run into any issues, reach out to the [Architecture Support Team][ast-confluence].
- If you run into any issues, reach out to the [Architecture Support Team](https://telusdigital.atlassian.net/wiki/spaces/AST/overview).

### 2. How do I keep up with the updates?

Expand All @@ -114,7 +115,7 @@ Just run `npm init @telus/library` inside your root folder just like you did it

Configure `babel` and your build script(s) as needed. Then consider the following for a good setup:

- Review the `package.json` `files` section and specify what files you would like included when your package is installed as a dependency. You can publish both your `src` and `lib` (or `dist`) if you would like your package consumers to be able to access the source code, or you can opt to only publish the distribution files (transpiled code). See more details about how this works [here][npm-files]. Feel free to add an `.npmignore` file if needed.
- Review the `package.json` `files` section and specify what files you would like included when your package is installed as a dependency. You can publish both your `src` and `lib` (or `dist`) if you would like your package consumers to be able to access the source code, or you can opt to [only publish the distribution files](https://docs.npmjs.com/files/package.json#files) (transpiled code). Feel free to add an `.npmignore` file if needed.
- Consider adding a `prepare` or `prepublishOnly` script to automate building & updating the distribution files. You can read more about these if you run `npm help scripts`.
- Consider adding your `lib`/`dist` folder to the `.gitignore`, especially if you automate the creation of these assets. It makes sense for only source files to be committed in the repository, especially as transpiled code is often hard to read (there have been incidents where malicious code has been included on purpose within the transpiled code and made it into published packages).

Expand All @@ -134,33 +135,10 @@ We recommend leaving the version as is at initialization: `"version": "0.0.0-dev

Before you start using this initializer and the tools inside it, **please make sure you familiarize yourself with `Github Actions` and `semantic-release`**. For more information about how these work and how they were configured, please refer to the documentation below:

- [Github Actions][github-actions]
- [semantic-release][guides-semantic-release]
- [GitHub Actions](https://developer.github.com/actions/)
- [Semantic Release](https://github.com/telus/guides/blob/master/semantic-release.md)

---

> Github: [@telus](https://github.com/telus) &bull;
> Twitter: [@telusdigital](https://twitter.com/telusdigital)
[npm-url]: https://www.npmjs.com/package/@telus/create-library
[npm-image]: https://img.shields.io/npm/v/@telus/create-library.svg?style=for-the-badge&logo=npm
[npm-library-starter-kit]: https://github.com/telus/npm-library-starter-kit
[angular-commit-conventions]: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines
[probot-settings]: https://github.com/probot/settings
[semantic-release]: https://github.com/semantic-release/semantic-release
[tap]: https://github.com/tapjs/node-tap
[npm-audit]: https://docs.npmjs.com/cli/audit
[editorconfig]: https://github.com/editorconfig-checker/editorconfig-checker.javascript
[telus-standard]: https://github.com/telus/telus-standard
[remark-cli]: https://github.com/remarkjs/remark/tree/master/packages/remark-cli
[renovate]: https://github.com/renovatebot/renovate
[telus/telus-standard]: https://github.com/telus/telus-standard
[telus/remark-config]: https://github.com/telus/remark-config
[prettier]: https://prettier.io/
[husky]: https://github.com/typicode/husky
[github-licenses]: https://help.github.com/articles/licensing-a-repository/
[npm-init]: https://docs.npmjs.com/cli/init#description
[ast-confluence]: https://telusdigital.atlassian.net/wiki/spaces/AST/overview
[npm-files]: https://docs.npmjs.com/files/package.json#files
[guides-semantic-release]: https://github.com/telus/guides/blob/master/semantic-release.md
[github-actions]: https://developer.github.com/actions/
25 changes: 1 addition & 24 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,6 @@ metadata:
icon: web
spec:
type: service
lifecycle: experimental
lifecycle: production
owner: telus
system: digital
---
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: create-library
description: An opinionated NPM Package initializer
tags:
- node
annotations:
github.com/project-slug: telus/create-library
links:
- url: https://github.com/telus/create-library
title: API Spec
icon: code
- url: https://github.com/telus/create-library
title: Website
icon: web
spec:
type: openapi
lifecycle: experimental
owner: digital
definition:
$text: https://github.com/telus/create-library
6 changes: 1 addition & 5 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = {extends: ['@commitlint/config-angular'],
rules: {
'type-enum': [2, 'always', ['build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test', 'chore']]
}
}
module.exports = {extends: ['@commitlint/config-conventional'] }
Loading

0 comments on commit 1ec4966

Please sign in to comment.