Skip to content

Commit e55ca60

Browse files
author
Joel de Leon
authored
Merge pull request #142 from particle-iot/feature/sc-102555/update-particle-api-js-to-node-js-v16-and
Update to node@16 and npm@8
2 parents 92d914c + 0eacae5 commit e55ca60

File tree

10 files changed

+15253
-433
lines changed

10 files changed

+15253
-433
lines changed

.circleci/config.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
version: 2.1
2+
3+
orbs:
4+
browser-tools: circleci/browser-tools@1.1.0
5+
6+
jobs:
7+
run-tests:
8+
parameters:
9+
node-version:
10+
type: string
11+
docker:
12+
- image: cimg/node:<< parameters.node-version >>-browsers # Primary execution image
13+
auth:
14+
username: $DOCKERHUB_USERNAME
15+
password: $DOCKERHUB_PASSWORD
16+
steps:
17+
- checkout
18+
- run:
19+
name: NPM install
20+
command: npm ci
21+
- run:
22+
name: Run tests with coverage
23+
command: npm run test:ci
24+
- when:
25+
condition:
26+
equal: ["16.15.0", << parameters.node-version >>]
27+
steps:
28+
- browser-tools/install-browser-tools
29+
- run:
30+
name: Run tests with browser
31+
command: npm run test:browser
32+
publish-npm:
33+
docker:
34+
- image: cimg/node:16.15.0 # Primary execution image
35+
auth:
36+
username: $DOCKERHUB_USERNAME
37+
password: $DOCKERHUB_PASSWORD
38+
steps:
39+
- checkout
40+
- run:
41+
name: NPM install
42+
command: npm ci
43+
- run:
44+
name: Authenticate with NPM
45+
command: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
46+
- run:
47+
name: Publish package
48+
command: |
49+
# Publish as beta for pre-release tags like v1.2.3-pre.1
50+
[[ $CIRCLE_TAG =~ ^v.*- ]] && NPM_TAG=--tag=beta
51+
npm publish $NPM_TAG
52+
53+
workflows:
54+
version: 2
55+
test-and-publish:
56+
jobs:
57+
- run-tests:
58+
context:
59+
- particle-ci-private
60+
matrix:
61+
parameters:
62+
node-version: ["12.22.12", "14.19.2", "16.15.0"]
63+
# run tests for all branches and tags
64+
filters:
65+
tags:
66+
only: /^v.*/
67+
branches:
68+
only: /.*/
69+
- publish-npm:
70+
requires:
71+
- run-tests
72+
context:
73+
- particle-ci-private
74+
# publish for tags only
75+
filters:
76+
tags:
77+
only: /^v.*/
78+
branches:
79+
ignore: /.*/

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ node_modules
1111
lib/
1212
/.idea
1313
*.tgz
14-
.vscode
14+
.vscode
15+
tmp

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

.travis.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# particle-api-js
22
JS Library for the Particle Cloud API for Node.js and the browser
33

4-
[![Build Status](https://travis-ci.org/particle-iot/particle-api-js.svg?branch=master)](https://travis-ci.org/particle-iot/particle-api-js)
4+
[![Build Status](https://circleci.com/gh/particle-iot/particle-api-js.svg?style=shield)](https://app.circleci.com/pipelines/github/particle-iot/particle-api-js)
5+
6+
[Installation](#installation) | [Development](#development) | [Conventions](#conventions) | [Docs](#docs--resources) | [Examples](#examples) | [Building](#building) | [Releasing](#releasing) | [License](#license)
57

68
## Installation
79

@@ -23,7 +25,62 @@ $ bower install particle-api-js
2325
</script>
2426
```
2527

26-
## Documentation
28+
## Development
29+
30+
All essential commands are available at the root via `npm run <script name>` - e.g. `npm run lint`. To view the available commands, run: `npm run`
31+
32+
<details id="develop-run-tests">
33+
<summary><b>How to run your tests</b></summary>
34+
<p>
35+
36+
to run the tests:
37+
38+
`npm test`
39+
40+
to run the coverage:
41+
42+
`npm run coverage`
43+
44+
to run browser tests with [karma](https://karma-runner.github.io/latest/index.html) (make sure you have the [Firefox launcher](https://npmjs.org/browse/keyword/karma-launcher) installed):
45+
46+
`npm run test:browser`
47+
48+
</p>
49+
</details>
50+
51+
52+
<details id="develop-npm-scripts">
53+
<summary><b>How to name npm scripts</b></summary>
54+
<p>
55+
56+
npm scripts are the primary means of executing programmatic tasks (e.g. tests, linting, releasing, etc) within the repo. to view available scripts, run `npm run`.
57+
58+
when creating a new script, be sure it does not already exist and use the following naming convention:
59+
60+
`<category>:[<subcategory>]:[<action>]`
61+
62+
our standard categories include: `test`, `lint`, `build`, `clean`, `docs`, `package`, `dependencies`, and `release`. top-level scripts - e.g. `npm run clean` - will typically run all of its subcategories (e.g. `npm run clean:dist && npm run clean:tmp`).
63+
64+
`npm` itself includes special handling for `test` and `start` (doc: [1](https://docs.npmjs.com/cli/v6/commands/npm-test), [2](https://docs.npmjs.com/cli/v6/commands/npm-start)) amongst other [lifecycle scripts](https://docs.npmjs.com/cli/v7/using-npm/scripts#life-cycle-scripts) - use these to expose key testing and start-up commands.
65+
66+
sometimes your new script will be very similar to an existing script. in those cases, try to extend the existing script before adding another one.
67+
68+
</p>
69+
</details>
70+
71+
## Conventions
72+
73+
* [npm scripts](https://docs.npmjs.com/misc/scripts) form the _developer's API_ for the repo and all of its packages - key orchestration commands should be exposed here
74+
* document developer-facing process / tooling instructions in the [Development](#development) section
75+
* plan to release your changes upon merging to `main` - refrain from merging if you cannot so you don't leave unpublished changes to others
76+
* avoid making changes in files unrelated to the work you are doing so you aren't having to publish trivial updates
77+
* test files live alongside their source files and are named like `*.test.js` or `*.spec.js`
78+
* if the linter does not flag your code (error or warning), it's formatted properly
79+
* avoid reformatting unflagged code as it can obscure more meaningful changes and increase the chance of merge conflicts
80+
* todo comments include your last name and are formatted like: `TODO (mirande): <message>`
81+
82+
83+
## Docs & Resources
2784

2885
First, read the [documentation for Particle API JS on the Documentation website.][docs-website] It contains examples to get started.
2986

@@ -55,6 +112,9 @@ Update the API docs with your changes:
55112
$ npm run docs
56113
```
57114

115+
## Releasing
116+
117+
See the release process in the [RELEASE.md](RELEASE.md) file.
58118

59119
## License
60120

RELEASE.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# Releasing a new version
22

3-
- `npm version <major | minor | patch>`
4-
5-
This builds the distribution file `particle.js.min` and generates the
6-
API documentation. Before the command finishes, update `CHANGELOG.md`.
7-
8-
- `git push && git push --tags`
9-
10-
- Travis will run `npm publish` if the build passes.
11-
12-
- Create a release on GitHub with the notes from the `CHANGELOG.md`
3+
1. Merge your changes to master and be on `master`
4+
2. Run `npm version <major|minor|patch>`
5+
1. This builds the distribution file `particle.js.min` and generates the
6+
API documentation. Before the command finishes, update `CHANGELOG.md`.
7+
3. Push to origin `git push --follow-tags`
8+
4. CircleCI will publish the npm package to the `latest` tag
9+
5. Create a release on GitHub with the notes from the `CHANGELOG.md`
10+
6. Point your project to the new version `npm install particle-api-js@latest`
1311

1412
- After updating major version, update the installation instructions in the [docs](https://github.com/particle-iot/docs/blob/master/src/content/reference/SDKs/javascript.md)

0 commit comments

Comments
 (0)