Skip to content

Commit

Permalink
feat(node-version-upgrade): added support for node 14 (#87)
Browse files Browse the repository at this point in the history
* fix: husky config and outdated depedencies
* feat: github action and colophone v4
* fix: updated template
* fix(doc): readme
  • Loading branch information
abduTas authored May 7, 2021
1 parent 95eb94a commit 29b1b63
Show file tree
Hide file tree
Showing 22 changed files with 6,594 additions and 2,980 deletions.
33 changes: 15 additions & 18 deletions .colophon.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
version: 2.0
version: 4.0

id: create-library
uid: 152944324

about:
title: create-library
description: An opinionated NPM Package initializer

contacts:
- type: Product Owner
name: Stephen Marie-Rhodes
email: [email protected]
github: stepmr
- type: Tech Lead
name: Mauricio Mercado
email: [email protected]
github: maumercado
- type: Architect
name: Matthew Cantelon
email: [email protected]
github: mattcan
contacts:
- type: Project Owner
name: Shimona Jain
email: [email protected]
- type: Team
name: ptt-ti
members_uri: https://github.com/orgs/telus/teams/ptt-ti/members
repositories_uri: https://github.com/orgs/telus/teams/ptt-ti/repositories

references:
- title: NPM Package
uri: https://www.npmjs.com/package/@telus/create-library
- title: git
description: Source Code
uri: https://github.com/telus/create-library.git

environments:
- type: git
title: Source Code
uri: https://github.com/telus/create-library
title: NPM Package
uri: https://www.npmjs.com/package/@telus/create-library
6 changes: 5 additions & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ repository:
teams:
- name: platform-technology-tools
permission: admin
- name: ptt-ti
permission: maintain

branches:
- name: master
Expand All @@ -28,6 +30,7 @@ branches:
users: []
teams:
- platform-technology-tools
- ptt-ti

required_status_checks:
strict: true
Expand All @@ -38,6 +41,7 @@ branches:
users: []
teams:
- platform-technology-tools
- ptt-ti

labels:
- name: bug
Expand All @@ -64,7 +68,7 @@ labels:
description: New feature or request
color: 5EBEFF

- name: optimizaiton
- name: optimization
description: Performance or Code Optimization
color: 5EBEFF

Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/build-publish.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Build, Lint, and Test'

on: pull_request

jobs:
Build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]

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

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

- name: Install dependencies
run: npm install

- name: Check linting
run: npm run lint
29 changes: 29 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Publish package on merge to master'

on:
push:
branches:
- master

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14

- name: Install deps
run: npm ci

- name: Publish package
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
4 changes: 2 additions & 2 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hooks": {
"pre-commit": "lint-staged"
"commit-msg": "commitlint -e $GIT_PARAMS",
"pre-commit": "npm run lint"
}
}

3 changes: 3 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@telus/semantic-release-config"
}
29 changes: 3 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Use this to easily scaffold an NPM package for use within TELUS.

## <a id="step-0"></a> Why and when should I use this?

The present NPM library initializer was created as a replacement to [npm-library-starter-kit][npm-library-starter-kit]. This starter kit is opinionated, and it is meant to encourage a good set of practices, but it is also flexible from a configuration point of view. We encourage teams to use the tools we have included in the template for setting up a solid and reliable pipeline that will allow for a good developer workflow and collaboration process. You are free to remove and/or add additional jobs or steps in your pipeline if that makes sense for your project and team.
This starter kit is opinionated, and it is meant to encourage a good set of practices, but it is also flexible from a configuration point of view. We encourage teams to use the tools we have included in the template for setting up a solid and reliable pipeline that will allow for a good developer workflow and collaboration process. You are free to remove and/or add additional jobs or steps in your pipeline if that makes sense for your project and team.

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

Expand All @@ -25,12 +25,12 @@ Here are some of the principles and concepts we have based this on:
- 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] and [lint-staged][lint-staged] to configure the pre-commit hook and restrict the formatting to the staged files that are part of the commit.
- 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.

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

- `npm >= 6.x`
- `node >= 12.*`
- `node >= 14.*`

## <a id="step-2"></a> What's included?

Expand Down Expand Up @@ -81,28 +81,6 @@ When you run `npm init @telus/library`, you will be prompted with a few question
- keywords
- maintainers (Github team slug)

Once you have scaffolded your library files and pushed them to a repository **you have to set up the `NPM_AUTH_TOKEN` secret** so that the workflow can automatically version and release your package to the NPM registry for you. In order to access the shared NPM token, you will need to be onboarded to `shippy`. Please contact the relevant teams in order to do so. Once you have access:

1. Login to `shippy` on the command line:

```sh
shippy login
```

2. Download the shared token:

```sh
shippy get secret npmrc-dev --common --field=npmrc | sed 's,//registry.npmjs.org/:_authToken=,,'
```

3. Take the result of the above command and save it as the value for the `NPM_AUTH_TOKEN` secret in your project

On rare occasions, the shared NPM token is changed which means you will need to update your secret when that occurs.

If you haven't created secrets before, please review the [Github documentation on secret creation](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets#creating-encrypted-secrets)

Once you have the token at hand, you need to add it to the Github Actions workflow setup, using the Github UI. Customize the URL below to point to your repository: `https://github.com/telus/<repository-name>/edit/master/.github/main.workflow`. Have a look at the steps in the workflow. Notice the ones that have the secrets associated to them, and click on `edit` and `Enter value` to insert your token.

### 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].
Expand Down Expand Up @@ -180,7 +158,6 @@ Before you start using this initializer and the tools inside it, **please make s
[telus/remark-config]: https://github.com/telus/remark-config
[prettier]: https://prettier.io/
[husky]: https://github.com/typicode/husky
[lint-staged]: https://github.com/okonet/lint-staged
[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
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-angular'] }
2 changes: 1 addition & 1 deletion lib/licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ const opensource = Object.entries(spdx)
.filter(([key]) => approved.includes(key))

// structure objects for use with `inquirer`
.map(([key, value]) => ({ name: value.name, value: Object.assign({ key }, value) }))
.map(([key, value]) => ({ name: value.name, value: { key , ...value } }))

module.exports = unlicensed.concat(opensource)
Loading

0 comments on commit 29b1b63

Please sign in to comment.