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

chore: remove peer deps #623

Merged
merged 13 commits into from
Apr 9, 2021
74 changes: 34 additions & 40 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
'use strict'

const path = require('path')
const getPort = require('aegir/utils/get-port')
const createServer = require('./src').createServer

const server = createServer(undefined,
{
ipfsModule: require('ipfs'),
ipfsHttpModule: require('ipfs-http-client')
},
{
go: {
ipfsBin: require('go-ipfs').path()
},
js: {
ipfsBin: require.resolve('ipfs/src/cli.js')
}
}
)
/** @type {import('aegir').Options["build"]["config"]} */
const esbuild = {
inject: [path.join(__dirname, 'scripts/node-globals.js')],
}

module.exports = {
bundlesize: { maxSize: '35kB' },
karma: {
files: [{
pattern: 'test/fixtures/**/*',
watched: false,
served: true,
included: false
}]
bundlesize: {
maxSize: '35kB'
},
hooks: {
pre: async () => {
await server.start(await getPort(server.port, server.host))
return {
env: {
IPFSD_CTL_SERVER: `http://${server.host}:${server.port}`
test: {
browser: {
config: {
buildConfig: esbuild
}
},
before: async () => {
const server = createServer(undefined, {
ipfsModule: require('ipfs'),
ipfsHttpModule: require('ipfs-http-client')
}, {
go: {
ipfsBin: require('go-ipfs').path()
},
js: {
ipfsBin: require.resolve('ipfs/src/cli.js')
}
}
},
post: () => server.stop()
},
webpack: {
node: {
// needed by ipfs-repo-migrations
path: true,
)

// needed by abstract-leveldown
Buffer: true,

// needed by nofilter
stream: true
await server.start(await getPort(server.port, server.host))
return {
env: {
IPFSD_CTL_SERVER: `http://${server.host}:${server.port}`
},
server
}
},
after: async (options, beforeResult) => {
await beforeResult.server.stop()
}
}
}
39 changes: 27 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
- run: yarn build
- run: yarn aegir dep-check
- uses: actions/setup-node@v1
with:
node-version: 15
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: npm run lint
- run: npm run build
- run: npx aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
name: size
with:
Expand All @@ -26,41 +29,53 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [12, 14]
node: [14, 15]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: npx nyc --reporter=lcov aegir test -t node --bail --timeout 60000
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- uses: actions/setup-node@v1
with:
node-version: 15
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: npx aegir test -t browser -t webworker --timeout 10000
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: npx aegir test -t browser -t webworker --timeout 10000 -- --browsers FirefoxHeadless
- uses: actions/setup-node@v1
with:
node-version: 15
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: npx aegir test -t browser -t webworker --timeout 10000 -- --browser firefox
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- uses: actions/setup-node@v1
with:
node-version: 15
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: npx xvfb-maybe aegir test -t electron-main --bail --timeout 10000
test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: npx xvfb-maybe aegir test -t electron-renderer --bail --timeout 10000
- uses: actions/setup-node@v1
with:
node-version: 15
- run: npm install -g @mapbox/node-pre-gyp && npm install
- run: npx xvfb-maybe aegir test -t electron-renderer --bail --timeout 10000
36 changes: 9 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,8 @@
"./src/ipfsd-daemon.js": "./src/ipfsd-client.js",
"go-ipfs": false
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && npx aegir dep-check",
"commit-msg": "npx aegir commitlint -- -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.js": [
"eslint --fix -c node_modules/aegir/src/config/eslintrc.js",
"git add"
]
},
"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},
"files": [
"src",
Expand All @@ -55,7 +43,7 @@
"debug": "^4.1.1",
"execa": "^5.0.0",
"fs-extra": "^9.0.0",
"ipfs-utils": "^5.0.1",
"ipfs-utils": "^6.0.6",
"joi": "^17.2.1",
"merge-options": "^3.0.1",
"multiaddr": "^8.0.0",
Expand All @@ -64,20 +52,14 @@
"temp-write": "^4.0.0"
},
"devDependencies": {
"aegir": "^29.2.2",
"aegir": "^33.0.0",
"assert": "^2.0.0",
"benchmark": "^2.1.4",
"go-ipfs": "^0.7.0",
"husky": "^4.2.5",
"ipfs": "^0.52.2",
"ipfs-http-client": "^48.1.2",
"ipfs-unixfs": "^2.0.3",
"lint-staged": "^10.1.6"
},
"peerDependencies": {
"go-ipfs": "*",
"ipfs": "*",
"ipfs-client": "*",
"ipfs-http-client": "*"
"go-ipfs": "^0.8.0",
"ipfs": "next",
"ipfs-client": "next",
"ipfs-http-client": "next",
"ipfs-unixfs": "^4.0.1"
},
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions scripts/node-globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @ts-nocheck
export const { Buffer } = require('buffer')
export const __dirname = globalThis.__dirname
10 changes: 6 additions & 4 deletions src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ class Factory {
start: false,
init: false
},
opts.test ? {
config: testsConfig(opts),
preload: { enabled: false }
} : {},
opts.test
? {
config: testsConfig(opts),
preload: { enabled: false }
}
: {},
opts.ipfsOptions
)

Expand Down
4 changes: 2 additions & 2 deletions src/utils.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const removeRepo = async (repoPath) => {

const repoExists = (repoPath) => {
return new Promise((resolve, reject) => {
var req = self.indexedDB.open(repoPath)
var existed = true
const req = self.indexedDB.open(repoPath)
let existed = true
req.onerror = () => reject(req.error)
req.onsuccess = function () {
req.result.close()
Expand Down
2 changes: 1 addition & 1 deletion test/factory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { expect } = require('aegir/utils/chai')
const { isNode } = require('ipfs-utils/src/env')
const pathJoin = require('ipfs-utils/src/path-join')
const { createFactory } = require('../src')
const UnixFS = require('ipfs-unixfs')
const { UnixFS } = require('ipfs-unixfs')

const defaultOps = {
ipfsHttpModule: require('ipfs-http-client')
Expand Down
4 changes: 3 additions & 1 deletion test/node.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const Hapi = require('@hapi/hapi')
const routes = require('../src/endpoint/routes')
const { createFactory } = require('../src')

describe('routes', () => {
describe('routes', function () {
this.timeout(60000)

let id
let server

Expand Down
2 changes: 2 additions & 0 deletions test/node.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const { tmpDir, checkForRunningApi, defaultRepo, repoExists, removeRepo, buildIn
const { createFactory, createController } = require('../src')

describe('utils node version', function () {
this.timeout(60000)

it('tmpDir should return correct path', () => {
expect(tmpDir('js')).to.be.contain(path.join(os.tmpdir(), 'js_ipfs_'))
expect(tmpDir('go')).to.be.contain(path.join(os.tmpdir(), 'go_ipfs_'))
Expand Down