Skip to content

Commit

Permalink
chore: apply prettier on many more files
Browse files Browse the repository at this point in the history
Bring prettier to many more files, including all examples and
documentation.

Issue: BTC-0
  • Loading branch information
OttoAllmendinger committed Jun 30, 2023
1 parent 83a23d1 commit da718f7
Show file tree
Hide file tree
Showing 132 changed files with 1,775 additions and 1,652 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ coverage:
project: off
patch: off
comment:
layout: "diff, flags, files"
layout: 'diff, flags, files'
require_changes: true
flags:
bitgo:
Expand Down
17 changes: 11 additions & 6 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: Bug Report
about: Report any bugs you find to help us improve the library.
labels: 'bug'

---

<!---
Expand All @@ -14,24 +13,30 @@ This will help us review, prioritize, and assign the issue to internal teams. Do
-->

## Environment Details
* **OS:** <!--- What is your operating system -->
* **Node Version:** <!--- What version of node are you running -->
* **Yarn Version:** <!--- What version of yarn are you running -->
* **BitGoJS Version:** <!--- What version of this library are you running -->
* **BitGo Environment:** <!--- Are you running against testnet or mainnet -->

- **OS:** <!--- What is your operating system -->
- **Node Version:** <!--- What version of node are you running -->
- **Yarn Version:** <!--- What version of yarn are you running -->
- **BitGoJS Version:** <!--- What version of this library are you running -->
- **BitGo Environment:** <!--- Are you running against testnet or mainnet -->

## Expected Behavior

<!--- Tell us what should happen -->

## Current Behavior

<!--- Tell us what happens instead of the expected behavior -->

## Possible Solution

<!--- Not obligatory, but suggest a fix/reason for the bug, -->

## Steps to Reproduce

<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->

1.
2.
3.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: Feature Request
about: Suggest an idea for this project.
labels: 'feature'

---

<!---
Expand All @@ -14,10 +13,13 @@ This will help us review, prioritize, and assign the issue to internal teams. Do
-->

## Feature Description

<!-- A concise description of the feature you would like. -->

## Motivation

<!-- Why should this feature be added. -->

## Context

<!--- Not obligatory; but provide any other context that would be helpful in terms of prioritization. -->
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] I have made corresponding changes to the documentation and on any new/updated functions and/or methods - [jsdoc](https://jsdoc.app/)
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
-->
-->
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
id: lerna-cache
uses: actions/cache@v3
with:
path: |
path: |
node_modules
modules/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('tsconfig.packages.json')}}
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
id: lerna-cache
uses: actions/cache@v3
with:
path: |
path: |
node_modules
modules/*/node_modules
/home/runner/.cache/Cypress
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
if: github.ref != 'refs/heads/master' # only publish changes if on feature branches
run: |
echo "preid=alpha" >> $GITHUB_ENV
- name: Set Environment Variable for Beta
if: github.ref == 'refs/heads/master' # only publish changes if on master branches
run: |
Expand All @@ -45,20 +45,20 @@ jobs:
echo "@bitgo-beta:registry=https://registry.npmjs.org" >> .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.BETA_TOKEN }}" >> .npmrc
echo "//registry.npmjs.org/:always-auth=true" >> .npmrc
- name: Prepare Release
run: |
rm -rfd ./modules/web-demo
rm -rfd ./modules/express
npx ts-node ./scripts/prepare-release.ts ${{ env.preid }}
- name: Rebuild packages
run: yarn

- name: Commit Local Changes
run: git commit -am "Auto updated ${{ env.preid }} branch" --no-verify || echo "No changes to commit"

- name: Lerna Publish
- name: Lerna Publish
run: yarn lerna publish from-package --preid ${{ env.preid }} --dist-tag ${{ env.preid }} --force-publish --yes --loglevel silly

- name: Verify Publish
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/test_package_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ on:
branches:
- master
paths:
- "*/**/package.json"
- "!*/**/node_modules/package.json"
- "package.json"
- "!node_modules/package.json"
- '*/**/package.json'
- '!*/**/node_modules/package.json'
- 'package.json'
- '!node_modules/package.json'
pull_request:
branches:
- master
- rel/**
paths:
- "*/**/package.json"
- "!*/**/node_modules/package.json"
- "package.json"
- "!node_modules/package.json"
- '*/**/package.json'
- '!*/**/node_modules/package.json'
- 'package.json'
- '!node_modules/package.json'

jobs:
unit-test-all:
Expand Down
61 changes: 34 additions & 27 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Requirements
* yarn version 1 (classic)
* node version >=14.18.0 and <17

- yarn version 1 (classic)
- node version >=14.18.0 and <17

# Installing

In the BitGoJS/ directory:
In the BitGoJS/ directory:

```bash
$ yarn install
Expand Down Expand Up @@ -51,6 +52,7 @@ Modules typically provide both unit and integration tests.
The rule of thumb for whether a test is a unit test or an integration test is whether or not the test makes a real network request to another system. If it does, it's probably an integration test, otherwise it's a unit test.

You can run unit tests for each individual module:

```bash
$ yarn run unit-test --scope bitgo
```
Expand All @@ -62,22 +64,25 @@ $ yarn run unit-test
```

Or just the modules which have changed since master:

```bash
$ yarn run unit-test-changed
```

Or the file that contains a specific string
- if you are a specific module:

- if you are a specific module:

```bash
$ yarn run unit-test --grep"keyword"
```

- if you are in the BitGoJs/ top-level directory

```bash
$ yarn run unit-test -- -- --grep "keyword"
```
```

**Note:** Each module's output will be prefixed with it's name, but it may be difficult to unmangle the test output.

To aid with evaluating test results, and especially test failures, a fancy test report is generated by the CI system and uploaded to S3.
Expand Down Expand Up @@ -127,19 +132,19 @@ Each module should have the following basic file structure:

### `package.json`

* #### `name`
For a binary application module named "fooapp", this should be set to `@bitgo/fooapp`.
- #### `name`
For a binary application module named "fooapp", this should be set to `@bitgo/fooapp`.

For a generic library module named "bar", this should be set to `@bitgo/sdk-lib-bar`.

For a coin library module which supports a coin with ticker "BAZ", this should be set to `@bitgo/sdk-coin-baz`.

* #### `scripts`
- #### `scripts`

These npm scripts may be run during lifecycle events and by lerna across all modules. If a script is not present in a module, that module will be skipped.

| Name | Description | Required? |
|----------------------|--------------------------------------------------------------------------------------------|-----------|
| -------------------- | ------------------------------------------------------------------------------------------ | --------- |
| `test` / `unit-test` | Run module unit tests | Yes |
| `integration-test` | Run module integration tests. These are run when a PR is targeted to merge against master. | No |
| `prepare` / `build` | Compile typescript sources | No |
Expand All @@ -151,9 +156,10 @@ These npm scripts may be run during lifecycle events and by lerna across all mod

Additional scripts which are too large for the package.json file should be placed in `scripts/` and should be plain javascript or bash.

* #### `repository`
- #### `repository`

This shall always be set for all modules to:

```json
{
"repository": {
Expand All @@ -163,13 +169,14 @@ This shall always be set for all modules to:
}
```

* #### `license`
- #### `license`

License shall be `Apache-2.0`.

* #### `engines`
- #### `engines`

Engines should be set to the following:

```json
{
"engines": {
Expand All @@ -182,24 +189,23 @@ Engines should be set to the following:
### `tsconfig.json`

There are a few things each module's `tsconfig.json` must do:
* Extend the root tsconfig.json
* Set the `outDir` and `rootDir` compiler options
* Set the `include` property to the correct module source directories (`package.json` should also be included if it is read at runtime)
* Include references to other packages within the repo already added to the `package.json`

- Extend the root tsconfig.json
- Set the `outDir` and `rootDir` compiler options
- Set the `include` property to the correct module source directories (`package.json` should also be included if it is read at runtime)
- Include references to other packages within the repo already added to the `package.json`

Here is a template to help get started:</br>
<b>Note: you only need to add references to other modules in the repo you actually use. </b>

```json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "."
},
"include": [
"src/**/*",
"package.json"
],
"include": ["src/**/*", "package.json"],
"references": [
{
"path": "../sdk-core"
Expand All @@ -212,7 +218,8 @@ Here is a template to help get started:</br>
```

### `tsconfig.packages.json`
Each package should also be listed in the root level `tsconfig.packages.json` as well.

Each package should also be listed in the root level `tsconfig.packages.json` as well.

## Package Installation

Expand Down Expand Up @@ -241,6 +248,7 @@ Make sure to run `yarn install` after adding a new dependency to a module. This
- Standalone packages that do not rely on direct SDK development but rather depend on SDK modules as installed from `npm` should keep all used dependencies within their module. They should not depend on any single dependency as defined at the root `package.json` or `node_modules`.

Examples of exceptions include:

- `express`
- `web-demo`

Expand All @@ -265,10 +273,10 @@ This will prompt you for both the coin's name (mainnet and testnet), symbol, and
Additional information about coin development can be found in the newly created coin's README.md file.

Due to supporting legacy versions of registering coins to `bitgo`, you will continue to add new coin definitions to:
| Module | Notes |
| Module | Notes |
|---------------|----------------------------------------------------------------------------------------------------------------------|
| `statics` | |
| `bitgo` | Coin registration in the `CoinFactory` class |
| `statics` | |
| `bitgo` | Coin registration in the `CoinFactory` class |
| `account-lib` | For account based coins that are converting from `account-lib`, the import/export at `account-lib`'s root `index.ts` |

### Coin Creation Options
Expand All @@ -278,8 +286,7 @@ Upon creating coins, you are given different options to choose from to create yo
> Do not install coin packages in the root of BitGoJS. They must be scoped to their respective package.
| Option | Description |
|---------|--------------------------------------------------------|
| ------- | ------------------------------------------------------ |
| Account | Used for account based coins. Eth based or "Eth like". |
| Utxo | Used for utxo based coins. Bitcoin, Litecoin, etc... |
| Simple | Base implementation extending BaseCoin. |

16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Please email us at [email protected] if you have questions or comments about thi
The BitGo SDK repository is a monorepo composed of separate modules, each of which implement some subset of the features of the SDK.

| Package Name | Module | Description | |
|---------------------|----------------|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| ------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| bitgo | `bitgo` | Authentication, wallet management, user authentication, cryptographic primitives, abstract coin interfaces, coin implementations. | [Link](https://github.com/BitGo/BitGoJS/tree/master/modules/bitgo) |
| @bitgo/account-lib | `account-lib` | Build and sign transactions for account-based coins. | [Link](https://github.com/BitGo/BitGoJS/tree/master/modules/account-lib) |
| @bitgo/blake2b | `blake2b` | Blake2b (64-bit version) in pure JavaScript. | [Link](https://github.com/BitGo/BitGoJS/tree/master/modules/blake2b) |
Expand All @@ -35,9 +35,9 @@ The release notes for the `bitgo` module are [here](https://github.com/BitGo/Bit

The BitGoJS SDK use a number of branches to control the development of various packages throughout the deployment lifecycle. Provided below is an overview to how branches relate to one another.

| Branch | Status | NPM | Description |
|--------------|----------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `master` | Unstable | N/A | Ongoing development of SDK packages |
| Branch | Status | NPM | Description |
| ------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `master` | Unstable | N/A | Ongoing development of SDK packages |
| `rel/latest` | Stable | `latest` | Deployed packages from `master` to `rel/latest`. This includes Express and is recommended to use `rel/latest` when not using Docker images for Express. |

Other tags may be released to npm (e.g. `hotfix`, `dev`, etc...), but are not considered critical to the common path for consumers usage of SDK packages unless otherwise stated.
Expand All @@ -49,6 +49,7 @@ Examples can be found in each of the modules specific to the module use cases. S
# NodeJS Version Support Policy

BitGoJS currently provides support for the following Node versions per package.json engines policy:

```
"engines": {
"node": ">=14.18.0 <17",
Expand All @@ -60,12 +61,13 @@ We specifically limit our support to these versions of Node, not because this pa

As each Node LTS version reaches its end-of-life we will exclude that version from the node engines property of our package's package.json file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node, and any pull requests or issues regarding support for an end-of-life version of Node will be closed. We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs the full test suite on the latest release of the following versions of node:

* `>=14.18.0`
* `16`
- `>=14.18.0`
- `16`

JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our node engines property. If you encounter issues installing this package on a supported version of Node, please report the issue to us.

> **_NOTE:_** Users that would like to use ecdsa tss coins with node v14 must enable `--experimental-wasm-bigint` to initialize wallets
> **_NOTE:_** Users that would like to use ecdsa tss coins with node v14 must enable `--experimental-wasm-bigint` to initialize wallets
# Notes for Developers

See [DEVELOPERS.md](https://github.com/BitGo/BitGoJS/blob/master/DEVELOPERS.md)
Loading

0 comments on commit da718f7

Please sign in to comment.