diff --git a/.aegir.js b/.aegir.js index 50c3f734..6d42a32a 100644 --- a/.aegir.js +++ b/.aegir.js @@ -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() } } } diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a86f628c..5048454a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -26,14 +29,14 @@ 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: @@ -41,26 +44,38 @@ jobs: 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 \ No newline at end of file + - 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 diff --git a/package.json b/package.json index ab7bdf55..41d37988 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", diff --git a/scripts/node-globals.js b/scripts/node-globals.js new file mode 100644 index 00000000..ae37a467 --- /dev/null +++ b/scripts/node-globals.js @@ -0,0 +1,3 @@ +// @ts-nocheck +export const { Buffer } = require('buffer') +export const __dirname = globalThis.__dirname diff --git a/src/factory.js b/src/factory.js index ed134919..3bfb9bb5 100644 --- a/src/factory.js +++ b/src/factory.js @@ -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 ) diff --git a/src/utils.browser.js b/src/utils.browser.js index 8f6ef1ac..199c21ff 100644 --- a/src/utils.browser.js +++ b/src/utils.browser.js @@ -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() diff --git a/test/factory.spec.js b/test/factory.spec.js index 9d59357a..4f867544 100644 --- a/test/factory.spec.js +++ b/test/factory.spec.js @@ -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') diff --git a/test/node.routes.js b/test/node.routes.js index 433d5c38..e7d45942 100644 --- a/test/node.routes.js +++ b/test/node.routes.js @@ -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 diff --git a/test/node.utils.js b/test/node.utils.js index 0c974317..726984b4 100644 --- a/test/node.utils.js +++ b/test/node.utils.js @@ -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_'))