Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: integrate with aegir types cmd #159

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
hugomrdias marked this conversation as resolved.
Show resolved Hide resolved

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
67 changes: 67 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
- run: yarn build
- uses: gozala/[email protected]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: gozala/[email protected].4
- uses: gozala/[email protected].8

- run: yarn aegir dep-check -- -i aegir
- uses: ipfs/aegir/actions/bundle-size@master
name: size
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [12, 14]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: npx nyc --reporter=lcov npm run test:node -- --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn aegir test -t browser -t webworker
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn aegir test -t browser -t webworker -- --browsers FirefoxHeadless
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: npx xvfb-maybe yarn aegir test -t electron-main --bail
test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: npx xvfb-maybe yarn aegir test -t electron-renderer --bail
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

104 changes: 61 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
js-multiaddr
js-multiaddr <!-- omit in toc -->
============

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)](https://github.com/multiformats/multiformats)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](https://webchat.freenode.net/?channels=%23ipfs)
[![Dependency Status](https://david-dm.org/multiformats/js-multiaddr.svg?style=flat-square)](https://david-dm.org/multiformats/js-multiaddr)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![](https://img.shields.io/travis/multiformats/js-multiaddr.svg?style=flat-square)](https://travis-ci.com/multiformats/js-multiaddr)
[![pl](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
[![project](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)](https://github.com/multiformats/multiformats)
[![irc](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](https://webchat.freenode.net/?channels=%23ipfs)
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiaddr.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiaddr)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/multiformats/js-multiaddr/ci?label=ci&style=flat-square)](https://github.com/multiformats/js-multiaddr/actions?query=branch%3Amaster+workflow%3Aci+)

> JavaScript implementation of [multiaddr](https://github.com/multiformats/multiaddr).

## Lead Maintainer
## Lead Maintainer <!-- omit in toc -->

[Jacob Heun](https://github.com/jacobheun)

## Table of Contents

- [js-multiaddr](#js-multiaddr)
- [Lead Maintainer](#lead-maintainer)
- [Table of Contents](#table-of-contents)
- [Background](#background)
- [What is multiaddr?](#what-is-multiaddr)
- [Install](#install)
- [Setup](#setup)
- [Node.js](#nodejs)
- [Browser: Browserify, Webpack, other bundlers](#browser-browserify-webpack-other-bundlers)
- [Browser: `<script>` Tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
- [Resolvers](#resolvers)
- [Contribute](#contribute)
- [License](#license)
## Table of Contents<!-- omit in toc -->

- [Background](#background)
- [What is multiaddr?](#what-is-multiaddr)
- [Migrate to 0.9](#migrate-to-09)
- [Install](#install)
- [NPM](#npm)
- [Browser: `<script>` Tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
- [Resolvers](#resolvers)
- [Contribute](#contribute)
- [License](#license)

## Background

Expand All @@ -46,32 +39,57 @@ A standard way to represent addresses that
- have a nice string representation
- encapsulate well

## Install
## Migrate to 0.9
Before 0.9 `multiaddr` would return an constructor function.
```js
const multiaddr = require('multiaddr')

```sh
npm i multiaddr
```
const mh1 = multiaddr('/ip4/127.0.0.1/udp/1234')

### Setup
const mh2 = new multiaddr('/ip4/127.0.0.1/udp/1234')
// both mh1 and mh2 were multiaddr instances

#### Node.js
multiaddr.isName()
multiaddr.protocols
// etc

```
In 0.9 `multiaddr` returns a class.
```js
const multiaddr = require('multiaddr')
const Multiaddr = require('multiaddr')
// you need to use `new` to create and instance
const mh1 = new Multiaddr('/ip4/127.0.0.1/udp/1234')
```

```js
// The Multiaddr class has a factory method to help migration
const { multiaddr } = require('multiaddr')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make more sense to have Multiaddr.parse(string) static and make constructor @private. That way this turns into

Suggested change
const { multiaddr } = require('multiaddr')
const { from: multiaddr } = require('multiaddr')

And if we really want to smooth out transition we could have deprecated alias multiaddr.

My argument for discouraging new Multiadddr is because has tendency to grow into new Multiaddr(any) over time.

My personal opinion is to reserve constructors for property initializations, all the computation and logic should go into dedicated functions.

Edit: Added more details in the contstructor


const mh1 = multiaddr('/ip4/127.0.0.1/udp/1234')
```
```js
// In case you are using the static methods/getters `fromNodeAddress`, `isName` , `isMultiaddr`, `protocols` and `resolvers`
// You will need to do a couple more changes
const Multiaddr = require('multiaddr')
const { multiaddr, isName } = Multiaddr

#### Browser: Browserify, Webpack, other bundlers
// multiaddr.isName() will not work anymore, only the default export has those methods/getters
Multiaddr.isName() // or just `isName()`

The code published to npm that gets loaded on require is in fact a ES5
transpiled version with the right shims added. This means that you can require
it and use with your favourite bundler without having to adjust asset management
process.
```

## Install

```sh
npm i multiaddr
```
### NPM

```js
const multiaddr = require('multiaddr')
```

#### Browser: `<script>` Tag
### Browser: `<script>` Tag

Loading this module through a script tag will make the `Multiaddr` obj available in
the global namespace.
Expand All @@ -85,9 +103,9 @@ the global namespace.
```js
$ node

> const multiaddr = require('multiaddr')
> const Multiaddr = require('multiaddr')

> const addr = multiaddr("/ip4/127.0.0.1/udp/1234")
> const addr = new Multiaddr("/ip4/127.0.0.1/udp/1234")
<Multiaddr /ip4/127.0.0.1/udp/1234>

> addr.bytes
Expand Down Expand Up @@ -124,10 +142,10 @@ https://multiformats.github.io/js-multiaddr/
To provide multiaddr resolvers you can do:

```js
const multiaddr = require('multiaddr')
const Multiaddr = require('multiaddr')
const resolvers = require('multiaddr/src/resolvers')

multiaddr.resolvers.set('dnsaddr', resolvers.dnsaddrResolver)
Multiaddr.resolvers.set('dnsaddr', resolvers.dnsaddrResolver)
```

The available resolvers are:
Expand Down
3 changes: 0 additions & 3 deletions documentation.yml

This file was deleted.

Loading