From 49f78807d7e26483bd926b45cc7e0f797d77e41b Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Sun, 7 Mar 2021 13:17:43 +0000 Subject: [PATCH] fix: update to new aegir (#3528) - update aegir - fix some linting - enable multiple test runs at the same time (all servers now try to find free ports) Co-authored-by: achingbrain --- .github/workflows/bundlesize.yml | 19 +-- .github/workflows/typecheck.yml | 6 - .travis.yml | 65 +++++--- examples/browser-browserify/package.json | 5 +- examples/browser-exchange-files/package.json | 9 +- examples/browser-ipns-publish/package.json | 6 +- examples/browser-parceljs/package.json | 6 +- examples/browser-service-worker/package.json | 6 +- examples/browser-service-worker/test.js | 3 - .../browser-service-worker/webpack.config.js | 15 +- .../package.json | 6 +- .../webpack.config.js | 15 +- examples/browser-webpack/package.json | 8 +- examples/browser-webpack/webpack.config.js | 17 +- examples/circuit-relaying/package.json | 6 +- examples/custom-ipfs-repo/package.json | 2 +- examples/custom-ipld-formats/package.json | 10 +- examples/custom-libp2p/package.json | 2 +- .../http-client-browser-pubsub/package.json | 4 +- .../http-client-bundle-webpack/package.json | 10 +- .../webpack.config.js | 11 +- examples/http-client-name-api/package.json | 4 +- examples/ipfs-101/package.json | 2 +- examples/ipfs-client-add-files/package.json | 2 +- examples/test-ipfs-example/package.json | 4 +- examples/traverse-ipld-graphs/package.json | 2 +- package.json | 9 +- packages/interface-ipfs-core/.aegir.js | 9 +- packages/interface-ipfs-core/.eslintrc | 3 - packages/interface-ipfs-core/package.json | 17 +- packages/interface-ipfs-core/src/pin/utils.js | 2 +- packages/interface-ipfs-core/src/refs.js | 2 +- .../interface-ipfs-core/src/stats/utils.js | 3 +- .../interface-ipfs-core/src/swarm/peers.js | 4 +- .../interface-ipfs-core/src/utils/index.js | 2 +- packages/ipfs-cli/.eslintrc | 3 - packages/ipfs-cli/package.json | 15 +- packages/ipfs-client/.aegir.js | 5 +- packages/ipfs-client/package.json | 5 +- packages/ipfs-core-types/package.json | 2 +- packages/ipfs-core-utils/.aegir.js | 58 +------ packages/ipfs-core-utils/.eslintrc | 3 - packages/ipfs-core-utils/package.json | 6 +- packages/ipfs-core/.aegir.js | 79 +++++---- packages/ipfs-core/.eslintrc | 3 - packages/ipfs-core/package.json | 22 +-- packages/ipfs-daemon/.eslintrc | 3 - packages/ipfs-daemon/package.json | 5 +- packages/ipfs-grpc-client/.aegir.js | 5 +- packages/ipfs-grpc-client/package.json | 6 +- packages/ipfs-grpc-server/package.json | 5 +- packages/ipfs-http-client/.aegir.js | 43 +++-- packages/ipfs-http-client/.eslintrc | 3 - packages/ipfs-http-client/package.json | 18 +- .../ipfs-http-client/test/utils/factory.js | 2 +- packages/ipfs-http-gateway/.eslintrc | 3 - packages/ipfs-http-gateway/package.json | 7 +- packages/ipfs-http-server/.eslintrc | 3 - packages/ipfs-http-server/package.json | 11 +- .../src/api/resources/block.js | 2 +- packages/ipfs-message-port-client/.aegir.js | 90 ++++++---- packages/ipfs-message-port-client/.eslintrc | 3 - .../ipfs-message-port-client/package.json | 10 +- .../test/util/webpack.config.js | 13 -- packages/ipfs-message-port-protocol/.aegir.js | 5 +- packages/ipfs-message-port-protocol/.eslintrc | 3 - .../ipfs-message-port-protocol/package.json | 9 +- .../ipfs-message-port-protocol/src/rpc.ts | 10 +- packages/ipfs-message-port-server/.eslintrc | 3 - .../ipfs-message-port-server/package.json | 10 +- packages/ipfs-message-port-server/src/ipfs.ts | 8 +- packages/ipfs/.aegir.js | 155 ++++++++++-------- packages/ipfs/.eslintrc | 3 - packages/ipfs/package.json | 14 +- packages/ipfs/test/utils/factory.js | 4 +- .../ipfs/test/utils/mock-pinning-service.js | 7 +- packages/ipfs/test/utils/mock-preload-node.js | 13 +- scripts/node-globals.js | 3 + 78 files changed, 487 insertions(+), 489 deletions(-) delete mode 100644 packages/interface-ipfs-core/.eslintrc delete mode 100644 packages/ipfs-cli/.eslintrc delete mode 100644 packages/ipfs-core-utils/.eslintrc delete mode 100644 packages/ipfs-core/.eslintrc delete mode 100644 packages/ipfs-daemon/.eslintrc delete mode 100644 packages/ipfs-http-client/.eslintrc delete mode 100644 packages/ipfs-http-gateway/.eslintrc delete mode 100644 packages/ipfs-http-server/.eslintrc delete mode 100644 packages/ipfs-message-port-client/.eslintrc delete mode 100644 packages/ipfs-message-port-client/test/util/webpack.config.js delete mode 100644 packages/ipfs-message-port-protocol/.eslintrc delete mode 100644 packages/ipfs-message-port-server/.eslintrc delete mode 100644 packages/ipfs/.eslintrc create mode 100644 scripts/node-globals.js diff --git a/.github/workflows/bundlesize.yml b/.github/workflows/bundlesize.yml index 23ba944ad7..e3ca35188e 100644 --- a/.github/workflows/bundlesize.yml +++ b/.github/workflows/bundlesize.yml @@ -7,33 +7,20 @@ on: name: Bundlesize jobs: check: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md strategy: matrix: - node-version: [14.x] project: - packages/ipfs-core-utils - packages/ipfs-core - packages/ipfs-http-client - packages/ipfs - - packages/ipfs-message-port-protocol - packages/ipfs-message-port-client steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Restore dependencies - id: cache-modules - uses: actions/checkout@v2 - with: - path: node_modules - key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }} - - name: Install dependencies - run: npm install + - run: npm install - name: Bundlesize ${{ matrix.project }} - uses: ipfs/aegir/actions/bundle-size@v29.0.0 + uses: ipfs/aegir/actions/bundle-size@v31.0.4 with: project: ${{ matrix.project }} github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index bc2eca3a32..9bcb2ad555 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -27,12 +27,6 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: Restore dependencies - id: cache-modules - uses: actions/checkout@v2 - with: - path: node_modules - key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }} - name: Install dependencies run: npm install - name: Typecheck ${{ matrix.project }} diff --git a/.travis.yml b/.travis.yml index 9d601fa7a6..8c5d2841f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js +dist: bionic services: - xvfb @@ -31,14 +32,30 @@ env: addons: apt: packages: - # Fixes error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory - # https://github.com/electron/electron/issues/1518 - - libgconf-2-4 - # Ensure chrome is the latest version - # https://stackoverflow.com/questions/57903415/travis-ci-chrome-62-instead-of-77 - - dpkg + # These are required to run webkit + - libwoff1 + - libopus0 + - libwebp6 + - libwebpdemux2 + - libenchant1c2a + - libgudev-1.0-0 + - libsecret-1-0 + - libhyphen0 + - libgdk-pixbuf2.0-0 + - libegl1 + - libgles2 + - libevent-2.1-6 + - libnotify4 + - libxslt1.1 + - libvpx5 + # gstreamer and plugins to support video playback in WebKit. + - gstreamer1.0-gl + - gstreamer1.0-plugins-base + - gstreamer1.0-plugins-good + - gstreamer1.0-plugins-bad + # This is required to run chromium + - libgbm1 chrome: stable - firefox: latest before_install: # prevents windows error: npm ERR! ... git-sh-setup: file not found @@ -46,10 +63,10 @@ before_install: # only run jobs in packages that have changed since master in PR builds - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export RUN_SINCE='--since master' ; fi # modules with pre-built binaries may not have deployed versions for bleeding-edge node so this lets us fall back to building from source - - npm install -g node-pre-gyp + - npm install -g @mapbox/node-pre-gyp script: - - npm run test:node -- $RUN_SINCE -- -- --timeout 10000 --bail + - npm run test:node -- $RUN_SINCE -- -- --timeout 10000 --bail -- --exit # TODO remove --exit https://mochajs.org/#-exit jobs: allow_failures: @@ -91,12 +108,12 @@ jobs: - stage: test name: firefox script: - - npm run test:browser -- $RUN_SINCE -- -- --bail --browsers FirefoxHeadless + - npm run test:browser -- $RUN_SINCE -- -- --bail -- --browser firefox - stage: test name: firefox webworker script: - - npm run test:webworker -- $RUN_SINCE -- -- --bail --browsers FirefoxHeadless --timeout 60000 + - npm run test:webworker -- $RUN_SINCE -- -- --bail --timeout 60000 -- --browser firefox - stage: test name: electron-main @@ -131,7 +148,7 @@ jobs: - stage: test name: js-ipfs interface tests - node script: - - npm run test:interface:core -- $RUN_SINCE -- -- --bail -t node + - npm run test:interface:core -- $RUN_SINCE -- -- --bail -t node -- --exit # TODO remove --exit https://mochajs.org/#-exit - stage: test name: js-ipfs interface tests - chrome @@ -146,12 +163,12 @@ jobs: - stage: test name: js-ipfs interface tests - firefox script: - - npm run test:interface:core -- $RUN_SINCE -- -- --bail -t browser --browsers FirefoxHeadless + - npm run test:interface:core -- $RUN_SINCE -- -- --bail -t browser -- --browser firefox - stage: test name: js-ipfs interface tests - firefox webworker script: - - npm run test:interface:core -- $RUN_SINCE -- -- --bail -t webworker --browsers FirefoxHeadless --timeout 60000 + - npm run test:interface:core -- $RUN_SINCE -- -- --bail -t webworker --timeout 60000 -- --browser firefox - stage: test name: js-ipfs interface tests - electron main @@ -166,7 +183,7 @@ jobs: - stage: test name: js-ipfs interface tests - ipfs-client - node script: - - npm run test:interface:client -- $RUN_SINCE -- -- --bail -t node + - npm run test:interface:client -- $RUN_SINCE -- -- --bail -t node -- --exit # TODO remove --exit https://mochajs.org/#-exit - stage: test name: js-ipfs interface tests - ipfs-client - chrome @@ -181,12 +198,12 @@ jobs: - stage: test name: js-ipfs interface tests - ipfs-client - firefox script: - - npm run test:interface:client -- $RUN_SINCE -- -- --bail -t browser --browsers FirefoxHeadless + - npm run test:interface:client -- $RUN_SINCE -- -- --bail -t browser -- --browser firefox - stage: test name: js-ipfs interface tests - ipfs-client - firefox webworker script: - - npm run test:interface:client -- $RUN_SINCE -- -- --bail -t webworker --browsers FirefoxHeadless --timeout 60000 + - npm run test:interface:client -- $RUN_SINCE -- -- --bail -t webworker --timeout 60000 -- --browser firefox - stage: test name: js-ipfs interface tests - ipfs-client - electron main @@ -201,7 +218,7 @@ jobs: - stage: test name: http-api-client interface tests vs go-ipfs - node script: - - npm run test:interface:http-go -- $RUN_SINCE -- -- --bail -t node + - npm run test:interface:http-go -- $RUN_SINCE -- -- --bail -t node -- --exit # TODO remove --exit https://mochajs.org/#-exit - stage: test name: http-api-client interface tests vs go-ipfs - chrome @@ -216,17 +233,17 @@ jobs: - stage: test name: http-api-client interface tests vs go-ipfs - firefox script: - - npm run test:interface:http-go -- $RUN_SINCE -- -- --bail -t browser --browsers FirefoxHeadless + - npm run test:interface:http-go -- $RUN_SINCE -- -- --bail -t browser -- --browser firefox - stage: test name: http-api-client interface tests vs go-ipfs - firefox webworker script: - - npm run test:interface:http-go -- $RUN_SINCE -- -- --bail -t webworker --browsers FirefoxHeadless --timeout 60000 + - npm run test:interface:http-go -- $RUN_SINCE -- -- --bail -t webworker --timeout 60000 -- --browser firefox - stage: test name: http-api-client interface tests vs js-ipfs - node script: - - npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t node + - npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t node -- --exit # TODO remove --exit https://mochajs.org/#-exit - stage: test name: http-api-client interface tests vs js-ipfs - chrome @@ -241,12 +258,12 @@ jobs: - stage: test name: http-api-client interface tests vs js-ipfs - firefox script: - - npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t browser --browsers FirefoxHeadless + - npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t browser --browser firefox - stage: test name: http-api-client interface tests vs js-ipfs - firefox webworker script: - - npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t webworker --browsers FirefoxHeadless --timeout 60000 + - npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t webworker --timeout 60000 -- --browser firefox - stage: test name: http-api-client interface tests vs js-ipfs - electron main @@ -266,7 +283,7 @@ jobs: - stage: test name: ipfs-message-port-client interface tests - firefox script: - - npm run test:interface:message-port-client -- $RUN_SINCE -- -- --bail -t browser --browsers FirefoxHeadless + - npm run test:interface:message-port-client -- $RUN_SINCE -- -- --bail -t browser -- --browser firefox - stage: test name: examples diff --git a/examples/browser-browserify/package.json b/examples/browser-browserify/package.json index 4758461821..9dbb5211b8 100644 --- a/examples/browser-browserify/package.json +++ b/examples/browser-browserify/package.json @@ -16,13 +16,10 @@ "devDependencies": { "browserify": "^16.2.3", "concat-stream": "^2.0.0", - "execa": "^4.0.3", + "execa": "^5.0.0", "http-server": "^0.12.3", "ipfs": "^0.54.2", "rimraf": "^3.0.2", "test-ipfs-example": "^3.0.0" - }, - "browser": { - "ipfs": "ipfs/dist/index.min.js" } } diff --git a/examples/browser-exchange-files/package.json b/examples/browser-exchange-files/package.json index ad72e734c6..338f49bb4f 100644 --- a/examples/browser-exchange-files/package.json +++ b/examples/browser-exchange-files/package.json @@ -12,19 +12,16 @@ "license": "MIT", "devDependencies": { "browserify": "^16.2.3", - "execa": "^4.0.3", + "execa": "^5.0.0", "http-server": "^0.12.3", "ipfs-http-client": "^49.0.2", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "dependencies": { "ipfs": "^0.54.2", "it-all": "^1.0.4", - "libp2p-websockets": "^0.15.0", + "libp2p-websockets": "^0.15.1", "rimraf": "^3.0.2", "test-ipfs-example": "^3.0.0" - }, - "browser": { - "ipfs": "ipfs/dist/index.min.js" } } diff --git a/examples/browser-ipns-publish/package.json b/examples/browser-ipns-publish/package.json index a65a41b65c..cca5654742 100644 --- a/examples/browser-ipns-publish/package.json +++ b/examples/browser-ipns-publish/package.json @@ -19,16 +19,16 @@ "ipns": "^0.8.0", "it-last": "^1.0.4", "p-retry": "^4.2.0", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "browserslist": [ "last 2 versions and not dead and > 2%" ], "devDependencies": { "delay": "^4.4.0", - "execa": "^4.0.3", + "execa": "^5.0.0", "ipfsd-ctl": "^7.2.0", - "go-ipfs": "0.8.0-rc2", + "go-ipfs": "0.8.0", "parcel-bundler": "^1.12.4", "path": "^0.12.7", "test-ipfs-example": "^3.0.0" diff --git a/examples/browser-parceljs/package.json b/examples/browser-parceljs/package.json index c450af5f12..96425c0f48 100644 --- a/examples/browser-parceljs/package.json +++ b/examples/browser-parceljs/package.json @@ -21,9 +21,9 @@ "ipfs": "^0.54.2" }, "devDependencies": { - "@babel/cli": "^7.1.5", - "@babel/core": "^7.2.2", - "@babel/preset-env": "^7.3.1", + "@babel/cli": "7.13.0", + "@babel/core": "7.13.0", + "@babel/preset-env": "7.13.0", "babel-plugin-syntax-async-functions": "^6.13.0", "babel-plugin-transform-regenerator": "^6.26.0", "babel-polyfill": "^6.26.0", diff --git a/examples/browser-service-worker/package.json b/examples/browser-service-worker/package.json index 69cd7bdde4..a1e899b3ce 100644 --- a/examples/browser-service-worker/package.json +++ b/examples/browser-service-worker/package.json @@ -12,9 +12,9 @@ "license": "MIT", "keywords": [], "devDependencies": { - "@babel/core": "^7.2.2", - "@babel/preset-env": "^7.3.1", - "babel-loader": "^8.0.5", + "@babel/core": "7.13.0", + "@babel/preset-env": "7.13.0", + "babel-loader": "^8.2.2", "copy-webpack-plugin": "^5.0.4", "test-ipfs-example": "^3.0.0", "webpack": "5.4.0", diff --git a/examples/browser-service-worker/test.js b/examples/browser-service-worker/test.js index 2d297a7cca..cae7e39759 100644 --- a/examples/browser-service-worker/test.js +++ b/examples/browser-service-worker/test.js @@ -8,7 +8,6 @@ module.exports = { .url(process.env.IPFS_EXAMPLE_TEST_URL) .waitForElementVisible('body') - browser.expect.element('body').text.to.contain('Load content by adding IPFS path to the URL') browser.expect.element('a').text.to.contain('/ipfs/bafy') @@ -19,8 +18,6 @@ module.exports = { .waitForElementVisible('body') .waitForElementVisible('iframe') - - browser.element('css selector', 'iframe', frame => { browser.frame({ ELEMENT: frame.value.ELEMENT }, () => { browser.waitForElementPresent('body') diff --git a/examples/browser-service-worker/webpack.config.js b/examples/browser-service-worker/webpack.config.js index 5c6b204e09..e63c6f4d7d 100644 --- a/examples/browser-service-worker/webpack.config.js +++ b/examples/browser-service-worker/webpack.config.js @@ -5,7 +5,7 @@ const webpack = require('webpack') const CopyWebpackPlugin = require('copy-webpack-plugin') module.exports = { - mode: "development", + mode: 'development', devtool: 'source-map', entry: './src/main.js', output: { @@ -28,7 +28,16 @@ module.exports = { use: { loader: 'babel-loader', options: { - presets: ['@babel/preset-env'] + presets: [ + [ + '@babel/preset-env', + { + targets: { + esmodules: true + } + } + ] + ] } } } @@ -36,7 +45,7 @@ module.exports = { }, resolve: { fallback: { - "stream": require.resolve("stream-browserify") + stream: require.resolve('stream-browserify') } }, plugins: [ diff --git a/examples/browser-sharing-node-across-tabs/package.json b/examples/browser-sharing-node-across-tabs/package.json index c006d5354b..52d547d57a 100644 --- a/examples/browser-sharing-node-across-tabs/package.json +++ b/examples/browser-sharing-node-across-tabs/package.json @@ -12,9 +12,9 @@ "license": "MIT", "keywords": [], "devDependencies": { - "@babel/core": "^7.2.2", - "@babel/preset-env": "^7.3.1", - "babel-loader": "^8.0.5", + "@babel/core": "7.13.0", + "@babel/preset-env": "7.13.0", + "babel-loader": "^8.2.2", "copy-webpack-plugin": "^5.0.4", "rimraf": "^3.0.2", "test-ipfs-example": "^3.0.0", diff --git a/examples/browser-sharing-node-across-tabs/webpack.config.js b/examples/browser-sharing-node-across-tabs/webpack.config.js index fd76d66141..0523345954 100644 --- a/examples/browser-sharing-node-across-tabs/webpack.config.js +++ b/examples/browser-sharing-node-across-tabs/webpack.config.js @@ -1,7 +1,7 @@ 'use strict' -var path = require('path') -var webpack = require('webpack') +const path = require('path') +const webpack = require('webpack') const WorkerPlugin = require('worker-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin') @@ -35,7 +35,16 @@ module.exports = { use: { loader: 'babel-loader', options: { - presets: ['@babel/preset-env'] + presets: [ + [ + '@babel/preset-env', + { + targets: { + esmodules: true + } + } + ] + ] } } } diff --git a/examples/browser-webpack/package.json b/examples/browser-webpack/package.json index 2949fc7e3b..f3ecbabb61 100644 --- a/examples/browser-webpack/package.json +++ b/examples/browser-webpack/package.json @@ -12,10 +12,10 @@ "license": "MIT", "keywords": [], "devDependencies": { - "@babel/core": "^7.2.2", - "@babel/preset-env": "^7.3.1", - "@babel/preset-react": "^7.0.0", - "babel-loader": "^8.0.5", + "@babel/core": "7.13.0", + "@babel/preset-env": "7.13.0", + "@babel/preset-react": "7.12.1", + "babel-loader": "^8.2.2", "copy-webpack-plugin": "^7.0.0", "node-polyfill-webpack-plugin": "^1.0.2", "react": "^17.0.1", diff --git a/examples/browser-webpack/webpack.config.js b/examples/browser-webpack/webpack.config.js index 8b3e6ddaf3..bf615d1304 100644 --- a/examples/browser-webpack/webpack.config.js +++ b/examples/browser-webpack/webpack.config.js @@ -1,7 +1,6 @@ -'use strict' -var path = require('path') -var webpack = require('webpack') +const path = require('path') +const webpack = require('webpack') const CopyWebpackPlugin = require('copy-webpack-plugin') const NodePolyfillPlugin = require('node-polyfill-webpack-plugin') @@ -20,7 +19,7 @@ module.exports = { plugins: [ new webpack.HotModuleReplacementPlugin(), new CopyWebpackPlugin({ - patterns: [{ + patterns: [{ from: 'index.html' }, { from: 'img', @@ -46,7 +45,15 @@ module.exports = { use: { loader: 'babel-loader', options: { - presets: ['@babel/preset-env', '@babel/preset-react'] + presets: [ + ['@babel/preset-env', + { + targets: { + esmodules: true + } + }], + '@babel/preset-react' + ] } } } diff --git a/examples/circuit-relaying/package.json b/examples/circuit-relaying/package.json index 76aa8b740c..c2e6d184cb 100644 --- a/examples/circuit-relaying/package.json +++ b/examples/circuit-relaying/package.json @@ -17,11 +17,11 @@ "delay": "^4.4.0", "ipfs": "^0.54.2", "ipfs-pubsub-room": "^2.0.1", - "libp2p-websockets": "^0.15.0", - "uint8arrays": "^2.0.5" + "libp2p-websockets": "^0.15.1", + "uint8arrays": "^2.1.3" }, "devDependencies": { - "execa": "^4.0.3", + "execa": "^5.0.0", "ipfs-css": "^0.13.1", "ipfs-http-client": "^49.0.2", "parcel-bundler": "^1.12.4", diff --git a/examples/custom-ipfs-repo/package.json b/examples/custom-ipfs-repo/package.json index f0ae5dbd4f..cf0be4ae4e 100644 --- a/examples/custom-ipfs-repo/package.json +++ b/examples/custom-ipfs-repo/package.json @@ -16,7 +16,7 @@ "it-all": "^1.0.4" }, "devDependencies": { - "execa": "^4.0.3", + "execa": "^5.0.0", "test-ipfs-example": "^3.0.0" } } diff --git a/examples/custom-ipld-formats/package.json b/examples/custom-ipld-formats/package.json index e0cf37bdb7..44986b50b7 100644 --- a/examples/custom-ipld-formats/package.json +++ b/examples/custom-ipld-formats/package.json @@ -1,5 +1,5 @@ { - "name": "example-custom-ipld-formats", + "name": "skipped-example-custom-ipld-formats", "version": "1.0.0", "private": true, "scripts": { @@ -7,7 +7,7 @@ }, "license": "MIT", "devDependencies": { - "execa": "^4.0.3", + "execa": "^5.0.0", "test-ipfs-example": "^3.0.0" }, "dependencies": { @@ -15,8 +15,8 @@ "ipfs-daemon": "^0.5.2", "ipfs-core": "^0.5.2", "ipfs-http-client": "^49.0.2", - "multicodec": "^2.0.1", - "multihashing-async": "^2.0.1", - "uint8arrays": "^2.0.5" + "multicodec": "^3.0.1", + "multihashing-async": "^2.1.2", + "uint8arrays": "^2.1.3" } } diff --git a/examples/custom-libp2p/package.json b/examples/custom-libp2p/package.json index 9fa1f914e3..85ec52f4b1 100644 --- a/examples/custom-libp2p/package.json +++ b/examples/custom-libp2p/package.json @@ -20,7 +20,7 @@ "libp2p-tcp": "^0.15.1" }, "devDependencies": { - "execa": "^4.0.3", + "execa": "^5.0.0", "test-ipfs-example": "^3.0.0" } } diff --git a/examples/http-client-browser-pubsub/package.json b/examples/http-client-browser-pubsub/package.json index 7d45f50197..4d025cbf99 100644 --- a/examples/http-client-browser-pubsub/package.json +++ b/examples/http-client-browser-pubsub/package.json @@ -18,8 +18,8 @@ "last 2 versions and not dead and > 2%" ], "devDependencies": { - "execa": "^4.0.3", - "go-ipfs": "0.8.0-rc2", + "execa": "^5.0.0", + "go-ipfs": "0.8.0", "ipfs": "^0.54.2", "ipfsd-ctl": "^7.2.0", "parcel-bundler": "^1.12.4", diff --git a/examples/http-client-bundle-webpack/package.json b/examples/http-client-bundle-webpack/package.json index ec08b06ef2..24b1a9fbf0 100644 --- a/examples/http-client-bundle-webpack/package.json +++ b/examples/http-client-bundle-webpack/package.json @@ -18,12 +18,12 @@ "react-dom": "^16.8.6" }, "devDependencies": { - "@babel/core": "^7.2.2", - "@babel/preset-env": "^7.3.1", - "@babel/preset-react": "^7.0.0", - "babel-loader": "^8.0.5", + "@babel/core": "7.13.0", + "@babel/preset-env": "7.13.0", + "@babel/preset-react": "7.12.1", + "babel-loader": "^8.2.2", "copy-webpack-plugin": "^5.0.4", - "execa": "^4.0.3", + "execa": "^5.0.0", "ipfs": "^0.54.2", "ipfsd-ctl": "^7.2.0", "react-hot-loader": "^4.12.21", diff --git a/examples/http-client-bundle-webpack/webpack.config.js b/examples/http-client-bundle-webpack/webpack.config.js index 44e0063802..48a5caf408 100644 --- a/examples/http-client-bundle-webpack/webpack.config.js +++ b/examples/http-client-bundle-webpack/webpack.config.js @@ -1,4 +1,3 @@ -'use strict' const path = require('path') const webpack = require('webpack') @@ -31,7 +30,15 @@ module.exports = { use: { loader: 'babel-loader', options: { - presets: ['@babel/preset-env', '@babel/preset-react'] + presets: [ + ['@babel/preset-env', + { + targets: { + esmodules: true + } + }], + '@babel/preset-react' + ] } } } diff --git a/examples/http-client-name-api/package.json b/examples/http-client-name-api/package.json index 315c8f06db..255ac7462e 100644 --- a/examples/http-client-name-api/package.json +++ b/examples/http-client-name-api/package.json @@ -16,8 +16,8 @@ "ipfs-http-client": "^49.0.2" }, "devDependencies": { - "execa": "^4.0.3", - "go-ipfs": "0.8.0-rc2", + "execa": "^5.0.0", + "go-ipfs": "0.8.0", "ipfsd-ctl": "^7.2.0", "parcel-bundler": "^1.12.4", "rimraf": "^3.0.2", diff --git a/examples/ipfs-101/package.json b/examples/ipfs-101/package.json index 9a999c5928..122cf7229d 100644 --- a/examples/ipfs-101/package.json +++ b/examples/ipfs-101/package.json @@ -12,7 +12,7 @@ "dependencies": { "ipfs": "^0.54.2", "it-all": "^1.0.4", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "devDependencies": { "test-ipfs-example": "^3.0.0" diff --git a/examples/ipfs-client-add-files/package.json b/examples/ipfs-client-add-files/package.json index 59c33d225c..e4df551348 100644 --- a/examples/ipfs-client-add-files/package.json +++ b/examples/ipfs-client-add-files/package.json @@ -14,7 +14,7 @@ "ipfs-client": "^0.3.2" }, "devDependencies": { - "execa": "^4.0.3", + "execa": "^5.0.0", "ipfs": "^0.54.2", "ipfsd-ctl": "^7.2.0", "parcel-bundler": "^1.12.4", diff --git a/examples/test-ipfs-example/package.json b/examples/test-ipfs-example/package.json index 0e3a6da74d..5f4bcf4559 100644 --- a/examples/test-ipfs-example/package.json +++ b/examples/test-ipfs-example/package.json @@ -8,11 +8,11 @@ "license": "MIT", "dependencies": { "chromedriver": "latest", - "execa": "^4.0.3", + "execa": "^5.0.0", "fs-extra": "^9.0.1", "http-server": "^0.12.3", "nightwatch": "^1.2.4", - "uint8arrays": "^2.0.5", + "uint8arrays": "^2.1.3", "which": "^2.0.1" } } diff --git a/examples/traverse-ipld-graphs/package.json b/examples/traverse-ipld-graphs/package.json index aee863eb17..0f80db2f1c 100644 --- a/examples/traverse-ipld-graphs/package.json +++ b/examples/traverse-ipld-graphs/package.json @@ -19,6 +19,6 @@ "ipld-dag-pb": "^0.20.0", "ipld-git": "^0.6.1", "ipld-ethereum": "^5.0.1", - "multihashing-async": "^2.0.1" + "multihashing-async": "^2.1.2" } } diff --git a/package.json b/package.json index 56deda257e..c724847a5f 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,9 @@ "test:interface:http-go": "lerna run test:interface:http-go", "test:interface:http-js": "lerna run test:interface:http-js", "test:interface:message-port-client": "lerna run test:interface:message-port-client", + "prepare": "lerna run prepare", "coverage": "lerna run coverage", - "build": "lerna run prepublishOnly", + "build": "lerna run build", "clean": "lerna run clean", "lint": "lerna run lint", "dep-check": "lerna run dep-check", @@ -51,6 +52,12 @@ "docker:rc:push-next": "docker push ipfs/js-ipfs:next", "docker:rc:push-rc": "docker push ipfs/js-ipfs:v`npm show ipfs@next version -q`" }, + "eslintConfig": { + "extends": "ipfs", + "ignorePatterns": [ + "!.aegir.js" + ] + }, "devDependencies": { "execa": "^5.0.0", "json": "^10.0.0", diff --git a/packages/interface-ipfs-core/.aegir.js b/packages/interface-ipfs-core/.aegir.js index 7d033bcb07..5f45288dba 100644 --- a/packages/interface-ipfs-core/.aegir.js +++ b/packages/interface-ipfs-core/.aegir.js @@ -1,11 +1,8 @@ 'use strict' +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { maxSize: '262kB' }, - lint: { - files: [ - 'src/**/*.js', - 'test/*.js' - ] + build: { + bundlesizeMax: '338kB' } } diff --git a/packages/interface-ipfs-core/.eslintrc b/packages/interface-ipfs-core/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/interface-ipfs-core/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index 0fce3d4254..1041a4fcc9 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -29,9 +29,16 @@ "IPFS" ], "license": "MIT", + "eslintConfig": { + "extends": "ipfs", + "ignorePatterns": [ + "test/fixtures/*" + ] + }, "dependencies": { "abort-controller": "^3.0.0", - "aegir": "^30.3.0", + "aegir": "^31.0.0", + "bignumber.js": "^9.0.1", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "chai-subset": "^1.6.0", @@ -57,16 +64,16 @@ "it-map": "^1.0.4", "it-pushable": "^1.4.0", "libp2p-crypto": "^0.19.0", - "libp2p-websockets": "^0.15.0", + "libp2p-websockets": "^0.15.1", "multiaddr": "^8.0.0", - "multibase": "^3.0.0", - "multihashing-async": "^2.0.1", + "multibase": "^4.0.2", + "multihashing-async": "^2.1.2", "nanoid": "^3.1.12", "native-abort-controller": "^1.0.3", "p-map": "^4.0.0", "peer-id": "^0.14.1", "readable-stream": "^3.4.0", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "contributors": [ "Alan Shaw ", diff --git a/packages/interface-ipfs-core/src/pin/utils.js b/packages/interface-ipfs-core/src/pin/utils.js index f774eff459..1b5721c704 100644 --- a/packages/interface-ipfs-core/src/pin/utils.js +++ b/packages/interface-ipfs-core/src/pin/utils.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('../utils/mocha') -const loadFixture = require('aegir/fixtures') +const loadFixture = require('aegir/utils/fixtures') const CID = require('cids') const drain = require('it-drain') const map = require('it-map') diff --git a/packages/interface-ipfs-core/src/refs.js b/packages/interface-ipfs-core/src/refs.js index c9fda5309d..757c395b0b 100644 --- a/packages/interface-ipfs-core/src/refs.js +++ b/packages/interface-ipfs-core/src/refs.js @@ -2,7 +2,7 @@ 'use strict' const { getDescribe, getIt, expect } = require('./utils/mocha') -const loadFixture = require('aegir/fixtures') +const loadFixture = require('aegir/utils/fixtures') const CID = require('cids') const all = require('it-all') const drain = require('it-drain') diff --git a/packages/interface-ipfs-core/src/stats/utils.js b/packages/interface-ipfs-core/src/stats/utils.js index fd7a1d62a0..15904c0c51 100644 --- a/packages/interface-ipfs-core/src/stats/utils.js +++ b/packages/interface-ipfs-core/src/stats/utils.js @@ -1,9 +1,10 @@ 'use strict' const { expect } = require('../utils/mocha') +const { BigNumber } = require('bignumber.js') const isBigInt = (n) => { - return n.constructor.name === 'BigNumber' + return BigNumber.isBigNumber(n) } exports.expectIsBitswap = (err, stats) => { diff --git a/packages/interface-ipfs-core/src/swarm/peers.js b/packages/interface-ipfs-core/src/swarm/peers.js index 3ce9a2b2a4..ad36c7c623 100644 --- a/packages/interface-ipfs-core/src/swarm/peers.js +++ b/packages/interface-ipfs-core/src/swarm/peers.js @@ -110,8 +110,8 @@ module.exports = (common, options) => { // TODO: Change to port 0, needs: https://github.com/ipfs/interface-ipfs-core/issues/152 const config = getConfig(isBrowser && common.opts.type !== 'go' ? [ - '/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star', - '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' + process.env.SIGNALA_SERVER, + process.env.SIGNALB_SERVER ] : [ '/ip4/127.0.0.1/tcp/26545/ws', diff --git a/packages/interface-ipfs-core/src/utils/index.js b/packages/interface-ipfs-core/src/utils/index.js index 0efe482307..66b3394686 100644 --- a/packages/interface-ipfs-core/src/utils/index.js +++ b/packages/interface-ipfs-core/src/utils/index.js @@ -1,7 +1,7 @@ 'use strict' const fromString = require('uint8arrays/from-string') -const loadFixture = require('aegir/fixtures') +const loadFixture = require('aegir/utils/fixtures') const ONE_MEG = Math.pow(2, 20) diff --git a/packages/ipfs-cli/.eslintrc b/packages/ipfs-cli/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-cli/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-cli/package.json b/packages/ipfs-cli/package.json index a1f031dc38..a539b3cad5 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -20,15 +20,14 @@ }, "scripts": { "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "test": "npm run test:node", "test:node": "aegir test -t node", "coverage": "nyc --reporter=text --reporter=lcov npm run test:node", "clean": "rimraf ./dist", - "dep-check": "aegir dep-check -i @types/yargs -i cid-tool" + "dep-check": "aegir dep-check -i cid-tool" }, "dependencies": { - "bignumber.js": "^9.0.0", + "bignumber.js": "^9.0.1", "byteman": "^1.3.5", "cid-tool": "^1.0.0", "cids": "^1.1.5", @@ -47,27 +46,27 @@ "it-all": "^1.0.4", "it-concat": "^1.0.1", "it-first": "^1.0.4", - "it-glob": "0.0.10", + "it-glob": "0.0.11", "it-pipe": "^1.1.0", "jsondiffpatch": "^0.4.1", "libp2p-crypto": "^0.19.0", "mafmt": "^8.0.0", "multiaddr": "^8.0.0", "multiaddr-to-uri": "^6.0.0", - "multibase": "^3.0.0", - "multihashing-async": "^2.0.1", + "multibase": "^4.0.2", + "multihashing-async": "^2.1.2", "parse-duration": "^0.4.4", "peer-id": "^0.14.1", "pretty-bytes": "^5.4.1", "progress": "^2.0.3", "stream-to-it": "^0.2.2", "streaming-iterables": "^5.0.2", - "uint8arrays": "^2.0.5", + "uint8arrays": "^2.1.3", "yargs": "^16.0.3" }, "devDependencies": { "@types/yargs": "^16.0.0", - "aegir": "^30.3.0", + "aegir": "^31.0.0", "nanoid": "^3.1.12", "ncp": "^2.0.0", "rimraf": "^3.0.2", diff --git a/packages/ipfs-client/.aegir.js b/packages/ipfs-client/.aegir.js index b55dc70587..4b403feb55 100644 --- a/packages/ipfs-client/.aegir.js +++ b/packages/ipfs-client/.aegir.js @@ -1,7 +1,8 @@ 'use strict' +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { - maxSize: '112kB' + build: { + bundlesizeMax: '135kB' } } diff --git a/packages/ipfs-client/package.json b/packages/ipfs-client/package.json index b61b9b4fcf..ac9f85d3b8 100644 --- a/packages/ipfs-client/package.json +++ b/packages/ipfs-client/package.json @@ -30,10 +30,9 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { + "build": "aegir build", "test": "aegir test", "lint": "aegir lint", - "prepare": "aegir build --no-bundle", - "prepublishOnly": "aegir build", "coverage": "npx nyc -r html npm run test:node -- --bail", "clean": "rimraf ./dist", "dep-check": "aegir dep-check -i aegir -i rimraf" @@ -44,7 +43,7 @@ "merge-options": "^3.0.4" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "rimraf": "^3.0.2" } } diff --git a/packages/ipfs-core-types/package.json b/packages/ipfs-core-types/package.json index 80d0d66e8b..7d2170bdc7 100644 --- a/packages/ipfs-core-types/package.json +++ b/packages/ipfs-core-types/package.json @@ -33,7 +33,7 @@ "peer-id": "^0.14.1" }, "devDependencies": { - "aegir": "^30.3.0" + "aegir": "^31.0.0" }, "contributors": [ "Irakli Gozalishvili " diff --git a/packages/ipfs-core-utils/.aegir.js b/packages/ipfs-core-utils/.aegir.js index b0dc5419a4..ef3e3aa890 100644 --- a/packages/ipfs-core-utils/.aegir.js +++ b/packages/ipfs-core-utils/.aegir.js @@ -1,60 +1,8 @@ 'use strict' -const { promisify } = require('util') -const http = require('http') -const url = require('url') -const querystring = require('querystring') - -const echoServer = async (port = 3000) => { - const server = http.createServer() - - server.on('request', (request, response) => { - try { - - const uri = url.parse(request.url) - const qs = uri.query ? querystring.parse(uri.query) : {} - const status = qs.status || 200 - const contentType = qs.contentType || 'text/plain' - - const headers = { - 'Access-Control-Allow-Origin': '*' - } - - if (qs.body) { - headers['Content-Type'] = contentType - headers['Content-Length'] = qs.body.length - } - - response.writeHead(status, headers) - - if (qs.body) { - response.end(qs.body) - } else { - request.pipe(response) - } - - } catch (err) { - console.error(err) - } - }) - - await promisify(server.listen.bind(server))(port) - - return { - stop: promisify(server.close.bind(server)) - } -} - -let echo - +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { maxSize: '540B' }, - hooks: { - pre: async () => { - echo = await echoServer() - }, - post: async () => { - await echo.stop() - } + build: { + bundlesizeMax: '540B' } } diff --git a/packages/ipfs-core-utils/.eslintrc b/packages/ipfs-core-utils/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-core-utils/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index 65b28cf360..7f8df194cb 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -24,13 +24,13 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { + "prepare": "aegir build --no-bundle", "test": "aegir test", "test:browser": "aegir test -t browser", "test:electron": "aegir test -t electron-main", "test:electron-renderer": "aegir test -t electron-renderer", "test:node": "aegir test -t node", "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "clean": "rimraf ./dist", "dep-check": "aegir dep-check -i rimraf -i ipfs-core-types" }, @@ -50,10 +50,10 @@ "multiaddr-to-uri": "^6.0.0", "parse-duration": "^0.4.4", "timeout-abort-controller": "^1.1.1", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "rimraf": "^3.0.2" } } diff --git a/packages/ipfs-core/.aegir.js b/packages/ipfs-core/.aegir.js index dc2115e8d7..d5af852bc9 100644 --- a/packages/ipfs-core/.aegir.js +++ b/packages/ipfs-core/.aegir.js @@ -4,42 +4,35 @@ const { createServer } = require('ipfsd-ctl') const MockPreloadNode = require('./test/utils/mock-preload-node') const path = require('path') -let preloadNode = MockPreloadNode.createNode() -let ipfsdServer +/** @type {import('aegir').Options["build"]["config"]} */ +const esbuild = { + inject: [path.join(__dirname, '../../scripts/node-globals.js')], + plugins: [ + { + name: 'node built ins', + setup (build) { + build.onResolve({ filter: /^stream$/ }, () => { + return { path: require.resolve('readable-stream') } + }) + } + } + ] +} +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { maxSize: '545kB' }, - karma: { - files: [{ - pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*', - watched: false, - served: true, - included: false - }], - browserNoActivityTimeout: 600 * 1000 - }, - webpack: { - node: { - // required by the nofilter module - stream: true, - - // required by the core-util-is module - Buffer: true - } - }, - hooks: { - node: { - pre: async () => { - await preloadNode.start() - }, - post: async () => { - await preloadNode.stop() + test: { + browser: { + config: { + assets: '..', + buildConfig: esbuild } }, - browser: { - pre: async () => { - await preloadNode.start() - ipfsdServer = await createServer({ + async before (options) { + const preloadNode = MockPreloadNode.createNode() + await preloadNode.start() + if (options.runner !== 'node') { + const ipfsdServer = await createServer({ host: '127.0.0.1', port: 57483 }, { @@ -59,11 +52,25 @@ module.exports = { ipfsBin: require('go-ipfs').path() } }).start() - }, - post: async () => { - await ipfsdServer.stop() - await preloadNode.stop() + return { + ipfsdServer, + preloadNode + } + } + + return { + preloadNode + } + }, + async after (options, before) { + await before.preloadNode.stop() + if (options.runner !== 'node') { + await before.ipfsdServer.stop() } } + }, + build: { + bundlesizeMax: '660kB', + config: esbuild } } diff --git a/packages/ipfs-core/.eslintrc b/packages/ipfs-core/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-core/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index 03c4fa26d3..7adb43adbc 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -38,13 +38,13 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { - "lint": "aegir lint", "prepare": "aegir build --no-bundle", - "prepublishOnly": "aegir build", + "build": "aegir build", + "lint": "aegir lint", "test": "aegir test", "test:node": "aegir test -t node", "test:browser": "aegir test -t browser", - "test:webworker": "aegir test -t webworker -- --timeout 10000", + "test:webworker": "aegir test -t webworker", "test:electron-main": "aegir test -t electron-main", "test:electron-renderer": "aegir test -t electron-renderer", "test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js", @@ -55,7 +55,7 @@ "dependencies": { "abort-controller": "^3.0.0", "array-shuffle": "^2.0.0", - "bignumber.js": "^9.0.0", + "bignumber.js": "^9.0.1", "cbor": "^6.0.1", "cids": "^1.1.5", "class-is": "^1.1.0", @@ -101,26 +101,26 @@ "libp2p-record": "^0.9.0", "libp2p-tcp": "^0.15.1", "libp2p-webrtc-star": "^0.21.0", - "libp2p-websockets": "^0.15.0", + "libp2p-websockets": "^0.15.1", "mafmt": "^8.0.0", "merge-options": "^3.0.4", "mortice": "^2.0.0", "multiaddr": "^8.0.0", "multiaddr-to-uri": "^6.0.0", - "multibase": "^3.0.0", - "multicodec": "^2.0.1", - "multihashing-async": "^2.0.1", + "multibase": "^4.0.2", + "multicodec": "^3.0.1", + "multihashing-async": "^2.1.2", "native-abort-controller": "^1.0.3", "p-queue": "^6.6.1", "parse-duration": "^0.4.4", "peer-id": "^0.14.1", "streaming-iterables": "^5.0.2", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "delay": "^4.4.0", - "go-ipfs": "0.8.0-rc2", + "go-ipfs": "0.8.0", "interface-ipfs-core": "^0.144.1", "ipfsd-ctl": "^7.2.0", "ipld-git": "^0.6.1", diff --git a/packages/ipfs-daemon/.eslintrc b/packages/ipfs-daemon/.eslintrc deleted file mode 100644 index f14de43aac..0000000000 --- a/packages/ipfs-daemon/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ -"extends": "ipfs" -} diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index b5e1f761a5..50db500c41 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -20,12 +20,11 @@ }, "scripts": { "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "test": "npm run test:node", "test:node": "aegir test -t node", "coverage": "nyc --reporter=text --reporter=lcov npm run test:node", "clean": "rimraf ./dist", - "dep-check": "aegir dep-check -i @types/yargs" + "dep-check": "aegir dep-check" }, "dependencies": { "debug": "^4.1.1", @@ -44,7 +43,7 @@ "multiaddr": "^8.0.0" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "node-fetch": "^2.6.1", "ws": "^7.3.1" }, diff --git a/packages/ipfs-grpc-client/.aegir.js b/packages/ipfs-grpc-client/.aegir.js index 4173cb261e..13212abe94 100644 --- a/packages/ipfs-grpc-client/.aegir.js +++ b/packages/ipfs-grpc-client/.aegir.js @@ -1,7 +1,8 @@ 'use strict' +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { - maxSize: '48kB' + build: { + bundlesizeMax: '48kB' } } diff --git a/packages/ipfs-grpc-client/package.json b/packages/ipfs-grpc-client/package.json index 4a2dc1e406..b6d98853fe 100644 --- a/packages/ipfs-grpc-client/package.json +++ b/packages/ipfs-grpc-client/package.json @@ -30,10 +30,10 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { + "prepare": "aegir build --no-bundle", + "build": "aegir build", "test": "aegir test", "lint": "aegir lint", - "prepare": "aegir build --no-bundle", - "prepublishOnly": "aegir build", "coverage": "npx nyc -r html npm run test:node -- --bail", "clean": "rimraf ./dist", "dep-check": "aegir dep-check -i aegir -i rimraf -i ipfs-grpc-protocol" @@ -54,7 +54,7 @@ "ws": "^7.3.1" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "it-all": "^1.0.4", "rimraf": "^3.0.2", "sinon": "^9.0.3" diff --git a/packages/ipfs-grpc-server/package.json b/packages/ipfs-grpc-server/package.json index e53a7abd9e..854ab26823 100644 --- a/packages/ipfs-grpc-server/package.json +++ b/packages/ipfs-grpc-server/package.json @@ -29,7 +29,6 @@ }, "scripts": { "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "test": "aegir test -t node", "coverage": "nyc --reporter=text --reporter=lcov npm run test:node", "clean": "rimraf ./dist", @@ -50,12 +49,12 @@ "ws": "^7.3.1" }, "devDependencies": { - "aegir": "^30.3.0", "ipfs-core": "^0.5.2", + "aegir": "^31.0.0", "it-all": "^1.0.4", "it-drain": "^1.0.3", "rimraf": "^3.0.2", "sinon": "^9.0.3", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" } } diff --git a/packages/ipfs-http-client/.aegir.js b/packages/ipfs-http-client/.aegir.js index 978ae66789..bd9b72bd07 100644 --- a/packages/ipfs-http-client/.aegir.js +++ b/packages/ipfs-http-client/.aegir.js @@ -1,26 +1,35 @@ 'use strict' const { createServer } = require('ipfsd-ctl') +const getPort = require('aegir/utils/get-port') -const server = createServer({ - host: '127.0.0.1', - port: 48372 -}, { - type: 'go', - ipfsHttpModule: require('./'), - ipfsBin: require('go-ipfs').path() -}) - +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { maxSize: '83kB' }, - hooks: { - browser: { - pre: async () => { - await server.start() - }, - post: async () => { - await server.stop() + build: { + bundlesizeMax: '110kB' + }, + test: { + async before (options) { + const port = await getPort() + const server = createServer({ + host: '127.0.0.1', + port: port + }, { + type: 'go', + ipfsHttpModule: require('./'), + ipfsBin: require('go-ipfs').path() + }) + + await server.start() + return { + server, + env: { + IPFSD_SERVER: `http://${server.host}:${server.port}` + } } + }, + async after (options, before) { + await before.server.stop() } } } diff --git a/packages/ipfs-http-client/.eslintrc b/packages/ipfs-http-client/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-http-client/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index 1555d808bb..9897358fd3 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -35,7 +35,8 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { - "prepublishOnly": "aegir build", + "prepare": "aegir build --no-bundle", + "build": "aegir build", "test": "aegir test", "test:node": "aegir test -t node", "test:browser": "aegir test -t browser", @@ -45,7 +46,6 @@ "test:chrome": "aegir test -t browser -t webworker -- --browsers ChromeHeadless", "test:firefox": "aegir test -t browser -t webworker -- --browsers FirefoxHeadless", "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "coverage": "npx nyc -r html npm run test:node -- --bail", "clean": "rimraf ./dist", "dep-check": "aegir dep-check -i ipfs-core -i rimraf -i ipfs-core-types -i abort-controller" @@ -53,7 +53,7 @@ "dependencies": { "abort-controller": "^3.0.0", "any-signal": "^2.1.2", - "bignumber.js": "^9.0.0", + "bignumber.js": "^9.0.1", "cids": "^1.1.5", "debug": "^4.1.1", "form-data": "^3.0.0", @@ -70,19 +70,19 @@ "it-to-stream": "^0.1.2", "merge-options": "^3.0.4", "multiaddr": "^8.0.0", - "multibase": "^3.0.0", - "multicodec": "^2.0.1", - "multihashes": "^3.0.1", + "multibase": "^4.0.2", + "multicodec": "^3.0.1", + "multihashes": "^4.0.2", "nanoid": "^3.1.12", "native-abort-controller": "^1.0.3", "parse-duration": "^0.4.4", "stream-to-it": "^0.2.2", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "delay": "^4.4.0", - "go-ipfs": "0.8.0-rc2", + "go-ipfs": "0.8.0", "ipfs-core": "^0.5.2", "ipfsd-ctl": "^7.2.0", "it-all": "^1.0.4", diff --git a/packages/ipfs-http-client/test/utils/factory.js b/packages/ipfs-http-client/test/utils/factory.js index 8ba97c4aec..e7f1096a0e 100644 --- a/packages/ipfs-http-client/test/utils/factory.js +++ b/packages/ipfs-http-client/test/utils/factory.js @@ -8,7 +8,7 @@ const commonOptions = { test: true, type: 'go', ipfsHttpModule: require('../../src'), - endpoint: 'http://localhost:48372' + endpoint: process.env.IPFSD_SERVER } const commonOverrides = { diff --git a/packages/ipfs-http-gateway/.eslintrc b/packages/ipfs-http-gateway/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-http-gateway/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-http-gateway/package.json b/packages/ipfs-http-gateway/package.json index f736313f5b..16bdc168b2 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -20,7 +20,6 @@ }, "scripts": { "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "test": "npm run test:node", "test:node": "aegir test -t node", "coverage": "nyc --reporter=text --reporter=lcov npm run test:node", @@ -40,12 +39,12 @@ "it-last": "^1.0.4", "it-to-stream": "^0.1.2", "joi": "^17.2.1", - "multibase": "^3.0.0", - "uint8arrays": "^2.0.5", + "multibase": "^4.0.2", + "uint8arrays": "^2.1.3", "uri-to-multiaddr": "^4.0.0" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "file-type": "^16.0.0", "rimraf": "^3.0.2", "sinon": "^9.0.3" diff --git a/packages/ipfs-http-server/.eslintrc b/packages/ipfs-http-server/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-http-server/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index d92506da26..1b097bc60d 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -20,7 +20,6 @@ }, "scripts": { "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "test": "npm run test:node", "test:node": "aegir test -t node", "coverage": "nyc --reporter=text --reporter=lcov npm run test:node", @@ -54,18 +53,18 @@ "joi": "^17.2.1", "just-safe-set": "^2.1.0", "multiaddr": "^8.0.0", - "multibase": "^3.0.0", - "multicodec": "^2.0.1", - "multihashing-async": "^2.0.1", + "multibase": "^4.0.2", + "multicodec": "^3.0.1", + "multihashing-async": "^2.1.2", "native-abort-controller": "^1.0.3", "parse-duration": "^0.4.4", "stream-to-it": "^0.2.2", "streaming-iterables": "^5.0.2", - "uint8arrays": "^2.0.5", + "uint8arrays": "^2.1.3", "uri-to-multiaddr": "^4.0.0" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "form-data": "^3.0.0", "ipfs-http-client": "^49.0.2", "iso-random-stream": "^1.1.1", diff --git a/packages/ipfs-http-server/src/api/resources/block.js b/packages/ipfs-http-server/src/api/resources/block.js index d3288587d1..bee96e199c 100644 --- a/packages/ipfs-http-server/src/api/resources/block.js +++ b/packages/ipfs-http-server/src/api/resources/block.js @@ -1,7 +1,7 @@ 'use strict' const multihash = require('multihashing-async').multihash -const { baseTable: codecs } = require('multicodec/src/base-table') +const { nameToCode: codecs } = require('multicodec') const multipart = require('../../utils/multipart-request-parser') const Joi = require('../../utils/joi') const Boom = require('@hapi/boom') diff --git a/packages/ipfs-message-port-client/.aegir.js b/packages/ipfs-message-port-client/.aegir.js index 5ef0106a01..e5fa08175e 100644 --- a/packages/ipfs-message-port-client/.aegir.js +++ b/packages/ipfs-message-port-client/.aegir.js @@ -1,48 +1,68 @@ 'use strict' - +const path = require('path') +const esbuild = require('esbuild') const EchoServer = require('aegir/utils/echo-server') -const echoServer = new EchoServer() -module.exports = { - bundlesize: { maxSize: '13kB' }, - karma: { - files: [ - { - pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*', - watched: false, - served: true, - included: false - }, - { - pattern: 'dist/**/*', - watched: true, - served: true, - included: false +/** @type {import('aegir').Options["build"]["config"]} */ +const buildConfig = { + inject: [path.join(__dirname, '../../scripts/node-globals.js')], + plugins: [ + { + name: 'node built ins', + setup (build) { + build.onResolve({ filter: /^stream$/ }, () => { + return { path: require.resolve('readable-stream') } + }) } - ], - browserNoActivityTimeout: 210 * 1000, - singleRun: true, - captureConsole: true, - logLevel: 'LOG_DEBUG', - mocha: { - bail: true } + ] +} + +/** @type {import('aegir').PartialOptions} */ +module.exports = { + build: { + bundlesizeMax: '23kB', + config: buildConfig }, - hooks: { + test: { browser: { - pre: async () => { - await echoServer.start() + config: { + assets: '..', + buildConfig + } + }, + async before () { + await buildWorker() + const echoServer = new EchoServer() + await echoServer.start() - return { - env: { - IPFS_WORKER_URL: `/base/dist/worker.bundle.js`, - ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}` - } + return { + echoServer, + env: { + IPFS_WORKER_URL: '/ipfs-message-port-client/dist/worker.bundle.js', + ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}` } - }, - post: async () => { - await echoServer.stop() } + }, + async after (options, before) { + await before.echoServer.stop() } } } + +const buildWorker = async () => { + await esbuild.build( + { + entryPoints: [path.join(__dirname, 'test/util/worker.js')], + bundle: true, + mainFields: ['browser', 'module', 'main'], + sourcemap: 'inline', + outfile: path.join(__dirname, 'dist/worker.bundle.js'), + define: { + global: 'globalThis', + 'process.env.NODE_ENV': '"production"' + }, + ...buildConfig + } + ) +} diff --git a/packages/ipfs-message-port-client/.eslintrc b/packages/ipfs-message-port-client/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-message-port-client/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-message-port-client/package.json b/packages/ipfs-message-port-client/package.json index a1db779b95..2054c844b5 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -30,14 +30,14 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { + "prepare": "aegir build --no-bundle", + "build": "aegir build", "test": "echo 'Only interface tests live here'", - "test:interface:message-port-client": "npm run prepare && aegir test -t browser -f ./test/interface-message-port-client.js", + "test:interface:message-port-client": "aegir test -t browser --bail -f ./test/interface-message-port-client.js", "lint": "aegir lint", - "prepare": "aegir build --no-bundle && aegir build -- --config ./test/util/webpack.config.js", - "prepublishOnly": "aegir build && aegir build -- --config ./test/util/webpack.config.js", "coverage": "npx nyc -r html npm run test:node -- --bail", "clean": "rimraf ./dist", - "dep-check": "aegir dep-check -i ipfs-core -i rimraf -i ipfs-core-types" + "dep-check": "aegir dep-check -i ipfs-core -i rimraf -i ipfs-core-types -i esbuild" }, "dependencies": { "browser-readablestream-to-it": "^1.0.1", @@ -45,10 +45,10 @@ "ipfs-message-port-protocol": "^0.6.0" }, "devDependencies": { - "aegir": "^30.3.0", "interface-ipfs-core": "^0.144.1", "ipfs": "^0.54.2", "ipfs-core": "^0.5.2", + "aegir": "^31.0.0", "ipfs-message-port-server": "^0.6.1", "rimraf": "^3.0.2" }, diff --git a/packages/ipfs-message-port-client/test/util/webpack.config.js b/packages/ipfs-message-port-client/test/util/webpack.config.js deleted file mode 100644 index 6613f75972..0000000000 --- a/packages/ipfs-message-port-client/test/util/webpack.config.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict' - -const path = require('path') - -module.exports = { - mode: 'development', - devtool: 'source-map', - entry: [path.join(__dirname, './worker.js')], - output: { - path: path.join(__dirname, '../../dist/'), - filename: 'worker.bundle.js' - } -} diff --git a/packages/ipfs-message-port-protocol/.aegir.js b/packages/ipfs-message-port-protocol/.aegir.js index 823e1d0e1a..2c09cac6a8 100644 --- a/packages/ipfs-message-port-protocol/.aegir.js +++ b/packages/ipfs-message-port-protocol/.aegir.js @@ -1,5 +1,8 @@ 'use strict' +/** @type {import('aegir').PartialOptions} */ module.exports = { - bundlesize: { maxSize: '547B' } + build: { + bundlesizeMax: '547B' + } } diff --git a/packages/ipfs-message-port-protocol/.eslintrc b/packages/ipfs-message-port-protocol/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-message-port-protocol/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index a1e5d0bd79..f456148e4c 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -31,10 +31,9 @@ "test:node": "aegir test -t node", "test:browser": "aegir test -t browser", "test:webworker": "aegir test -t webworker", - "test:chrome": "aegir test -t browser -t webworker -- --browsers ChromeHeadless", - "test:firefox": "aegir test -t browser -t webworker -- --browsers FirefoxHeadless", + "test:chrome": "aegir test -t browser -t webworker", + "test:firefox": "aegir test -t browser -t webworker -- --browsers firefox", "lint": "aegir lint", - "prepare": "aegir build --no-bundle", "coverage": "npx nyc -r html npm run test:node -- --bail", "clean": "rimraf ./dist", "dep-check": "aegir dep-check -i rimraf" @@ -44,9 +43,9 @@ "ipld-block": "^0.11.0" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "rimraf": "^3.0.2", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "engines": { "node": ">=10.3.0", diff --git a/packages/ipfs-message-port-protocol/src/rpc.ts b/packages/ipfs-message-port-protocol/src/rpc.ts index 6a1d571465..0e2393da78 100644 --- a/packages/ipfs-message-port-protocol/src/rpc.ts +++ b/packages/ipfs-message-port-protocol/src/rpc.ts @@ -57,11 +57,11 @@ export type NamespacedQuery = Values< { [M in keyof S]-?: S[M] extends (input: infer I) => infer O ? { - namespace: NS - method: M - input: I & QueryOptions - result: R - } & QueryOptions + namespace: NS + method: M + input: I & QueryOptions + result: R + } & QueryOptions : never } > diff --git a/packages/ipfs-message-port-server/.eslintrc b/packages/ipfs-message-port-server/.eslintrc deleted file mode 100644 index 88e5a82ccb..0000000000 --- a/packages/ipfs-message-port-server/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} \ No newline at end of file diff --git a/packages/ipfs-message-port-server/package.json b/packages/ipfs-message-port-server/package.json index d87e29da1f..04fb108f42 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -16,7 +16,9 @@ "dist" ], "main": "src/index.js", - "browser": {}, + "browser": { + "worker_threads": false + }, "typesVersions": { "*": { "*": [ @@ -30,14 +32,14 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { + "prepare": "aegir build --no-bundle", + "build": "aegir build", "test": "aegir test", "test:browser": "aegir test -t browser", "test:webworker": "aegir test -t webworker", "test:chrome": "aegir test -t browser -t webworker -- --browsers ChromeHeadless", "test:firefox": "aegir test -t browser -t webworker -- --browsers FirefoxHeadless", "lint": "aegir lint", - "prepare": "aegir build --no-bundle", - "prepublishOnly": "aegir build", "coverage": "npx nyc -r html npm run test:node -- --bail", "clean": "rimraf ./dist", "dep-check": "aegir dep-check -i rimraf" @@ -47,7 +49,7 @@ "it-all": "^1.0.4" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", "cids": "^1.1.5", "rimraf": "^3.0.2" }, diff --git a/packages/ipfs-message-port-server/src/ipfs.ts b/packages/ipfs-message-port-server/src/ipfs.ts index 765a4087e5..197e47b4ea 100644 --- a/packages/ipfs-message-port-server/src/ipfs.ts +++ b/packages/ipfs-message-port-server/src/ipfs.ts @@ -8,6 +8,7 @@ import { CIDVersion } from 'ipfs-message-port-protocol/src/data' import { ReadStream } from 'fs' +import Block from 'ipld-block' type Mode = string | number export interface IPFS extends Core { @@ -207,14 +208,9 @@ export interface WriteResult { size: number } -export interface Block { - cid: CID - data: Uint8Array -} - export interface BlockService { get: (cid: CID, options?: GetBlockOptions) => Promise - put: ((block: Uint8Array, options?: PutBufferOptions) => Promise) & ((buffer: Uint8Array, options?: PutBufferOptions) => Promise) + put: ((block: Uint8Array | Block, options?: PutBufferOptions) => Promise) & ((buffer: Uint8Array, options?: PutBufferOptions) => Promise) rm: ( cid: CID | CID[], options?: RmBlockOptions diff --git a/packages/ipfs/.aegir.js b/packages/ipfs/.aegir.js index afe6b207a7..b6f95eaa21 100644 --- a/packages/ipfs/.aegir.js +++ b/packages/ipfs/.aegir.js @@ -1,5 +1,6 @@ 'use strict' +const getPort = require('aegir/utils/get-port') const { createServer } = require('ipfsd-ctl') const MockPreloadNode = require('./test/utils/mock-preload-node') const PinningService = require('./test/utils/mock-pinning-service') @@ -7,77 +8,56 @@ const EchoServer = require('aegir/utils/echo-server') const webRTCStarSigServer = require('libp2p-webrtc-star/src/sig-server') const path = require('path') -let preloadNode -let pinningService -let echoServer = new EchoServer() - -// the second signalling server is needed for the interface test 'should list peers only once even if they have multiple addresses' -let sigServerA -let sigServerB -let ipfsdServer - -module.exports = { - bundlesize: { maxSize: '545kB' }, - karma: { - files: [{ - pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*', - watched: false, - served: true, - included: false - }], - browserNoActivityTimeout: 600 * 1000 - }, - webpack: { - node: { - // required by the nofilter module - stream: true, - - // required by the core-util-is module - Buffer: true +/** @type {import('aegir').Options["build"]["config"]} */ +const esbuild = { + inject: [path.join(__dirname, '../../scripts/node-globals.js')], + plugins: [ + { + name: 'node built ins', + setup (build) { + build.onResolve({ filter: /^stream$/ }, () => { + return { path: require.resolve('readable-stream') } + }) + } } - }, - hooks: { - node: { - pre: async () => { - preloadNode = MockPreloadNode.createNode() - pinningService = await PinningService.start() + ] +} - await preloadNode.start(), - await echoServer.start() - return { - env: { - PINNING_SERVICE_ENDPOINT: pinningService.endpoint, - PINNING_SERVIEC_KEY: pinningService.token, - ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}` - } - } - }, - post: async () => { - await preloadNode.stop() - await PinningService.stop(pinningService) - await echoServer.stop() +/** @type {import('aegir').PartialOptions} */ +module.exports = { + test: { + browser: { + config: { + assets: '..', + buildConfig: esbuild } }, - browser: { - pre: async () => { - preloadNode = MockPreloadNode.createNode() - pinningService = await PinningService.start() + before: async (options) => { + const echoServer = new EchoServer() + const preloadNode = MockPreloadNode.createNode() + const pinningService = await PinningService.start() - await preloadNode.start() - await echoServer.start() - sigServerA = await webRTCStarSigServer.start({ + await preloadNode.start() + await echoServer.start() + + if (options.runner !== 'node') { + const ipfsdPort = await getPort() + const signalAPort = await getPort() + const signalBPort = await getPort() + const sigServerA = await webRTCStarSigServer.start({ host: '127.0.0.1', - port: 14579, + port: signalAPort, metrics: false }) - sigServerB = await webRTCStarSigServer.start({ + // the second signalling server is needed for the interface test 'should list peers only once even if they have multiple addresses' + const sigServerB = await webRTCStarSigServer.start({ host: '127.0.0.1', - port: 14578, + port: signalBPort, metrics: false }) - ipfsdServer = await createServer({ + const ipfsdServer = await createServer({ host: '127.0.0.1', - port: 57483 + port: ipfsdPort }, { type: 'js', ipfsModule: require(__dirname), @@ -98,23 +78,58 @@ module.exports = { ipfsClientModule: require('ipfs-client') } }).start() - return { env: { PINNING_SERVICE_ENDPOINT: pinningService.endpoint, PINNING_SERVIEC_KEY: pinningService.token, - ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}` - } + ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}`, + IPFSD_SERVER: `http://127.0.0.1:${ipfsdPort}`, + SIGNALA_SERVER: `/ip4/127.0.0.1/tcp/${signalAPort}/ws/p2p-webrtc-star`, + SIGNALB_SERVER: `/ip4/127.0.0.1/tcp/${signalBPort}/ws/p2p-webrtc-star` + }, + echoServer, + preloadNode, + pinningService, + ipfsdServer, + sigServerA, + sigServerB } - }, - post: async () => { - await ipfsdServer.stop() - await preloadNode.stop() - await PinningService.stop(pinningService) - await echoServer.stop() - await sigServerA.stop() - await sigServerB.stop() + } + return { + env: { + PINNING_SERVICE_ENDPOINT: pinningService.endpoint, + PINNING_SERVIEC_KEY: pinningService.token, + ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}` + }, + echoServer, + preloadNode, + pinningService + } + }, + after: async (options, beforeResult) => { + await beforeResult.echoServer.stop() + await beforeResult.preloadNode.stop() + await PinningService.stop(beforeResult.pinningService) + if (options.runner !== 'node') { + await beforeResult.ipfsdServer.stop() + await beforeResult.sigServerA.stop() + await beforeResult.sigServerB.stop() } } + }, + build: { + bundlesizeMax: '660kB', + config: esbuild + }, + dependencyCheck: { + ignore: [ + 'assert', + 'cross-env', + 'rimraf', + 'url', + 'wrtc', + 'electron-webrtc', + 'ipfs-interop' + ] } } diff --git a/packages/ipfs/.eslintrc b/packages/ipfs/.eslintrc deleted file mode 100644 index ea565dd639..0000000000 --- a/packages/ipfs/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "ipfs" -} diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index ea39e5707c..aef1214c19 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -22,9 +22,9 @@ "url": "git+https://github.com/ipfs/js-ipfs.git" }, "scripts": { - "lint": "aegir lint", "prepare": "aegir build --no-bundle", - "prepublishOnly": "aegir build", + "build": "aegir build", + "lint": "aegir lint", "test": "echo 'Only interface tests live here'", "test:interface:core": "aegir test -f test/interface-core.js", "test:interface:client": "aegir test -f test/interface-client.js", @@ -34,7 +34,7 @@ "test:external": "aegir test-dependant", "coverage": "nyc --reporter=text --reporter=lcov npm run test:interface:core -- -t node", "clean": "rimraf ./dist", - "dep-check": "aegir dep-check -i cross-env -i ipfs-interop -i electron-webrtc -i wrtc -i rimraf" + "dep-check": "aegir dep-check" }, "dependencies": { "debug": "^4.1.1", @@ -45,21 +45,23 @@ "update-notifier": "^5.0.0" }, "devDependencies": { - "aegir": "^30.3.0", + "aegir": "^31.0.0", + "assert": "^2.0.0", "cross-env": "^7.0.0", "electron-webrtc": "^0.3.0", - "go-ipfs": "0.8.0-rc2", + "go-ipfs": "0.8.0", "interface-ipfs-core": "^0.144.1", "ipfs-client": "^0.3.2", "ipfs-http-client": "^49.0.2", - "ipfs-interop": "^4.0.2", "ipfs-utils": "^6.0.1", + "ipfs-interop": "^4.0.3", "ipfsd-ctl": "^7.2.0", "iso-url": "^1.0.0", "libp2p-webrtc-star": "^0.21.0", "merge-options": "^3.0.4", "mock-ipfs-pinning-service": "^0.1.2", "rimraf": "^3.0.2", + "url": "^0.11.0", "wrtc": "^0.4.6" }, "typesVersions": { diff --git a/packages/ipfs/test/utils/factory.js b/packages/ipfs/test/utils/factory.js index ea792df206..7268659079 100644 --- a/packages/ipfs/test/utils/factory.js +++ b/packages/ipfs/test/utils/factory.js @@ -16,7 +16,7 @@ const commonOptions = { } } }, - endpoint: 'http://localhost:57483' + endpoint: process.env.IPFSD_SERVER } const commonOverrides = { @@ -39,7 +39,7 @@ const commonOverrides = { config: { Addresses: { Swarm: [ - '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' + process.env.SIGNALA_SERVER ] } } diff --git a/packages/ipfs/test/utils/mock-pinning-service.js b/packages/ipfs/test/utils/mock-pinning-service.js index fae4c4f9f3..9e8a1b2826 100644 --- a/packages/ipfs/test/utils/mock-pinning-service.js +++ b/packages/ipfs/test/utils/mock-pinning-service.js @@ -2,6 +2,7 @@ const http = require('http') const { setup } = require('mock-ipfs-pinning-service') +const getPort = require('aegir/utils/get-port') const defaultPort = 1139 const defaultToken = 'secret' @@ -16,9 +17,11 @@ class PinningService { static async start ({ port = defaultPort, token = defaultToken } = {}) { const service = await setup({ token }) const server = http.createServer(service) - await new Promise(resolve => server.listen(port, resolve)) + const host = '127.0.0.1' + port = await getPort(port) + await new Promise(resolve => server.listen(port, host, resolve)) - return new PinningService({ server, host: '127.0.0.1', port, token }) + return new PinningService({ server, host, port, token }) } /** diff --git a/packages/ipfs/test/utils/mock-preload-node.js b/packages/ipfs/test/utils/mock-preload-node.js index cd779bfa44..3a5b15f76d 100644 --- a/packages/ipfs/test/utils/mock-preload-node.js +++ b/packages/ipfs/test/utils/mock-preload-node.js @@ -3,6 +3,7 @@ const http = require('http') const { URL } = require('iso-url') +const getPort = require('aegir/utils/get-port') const defaultPort = 1138 const defaultAddr = `/dnsaddr/localhost/tcp/${defaultPort}` @@ -44,7 +45,17 @@ module.exports.createNode = () => { res.end() }) - server.start = (opts = {}) => new Promise(resolve => server.listen({ port: defaultPort, ...opts }, resolve)) + server.start = async (opts = {}) => { + const port = await getPort(defaultPort) + return new Promise((resolve, reject) => { + server.listen(port, '127.0.0.1', err => { + if (err) { + return reject(err) + } + resolve() + }) + }) + } server.stop = () => new Promise(resolve => server.close(resolve)) return server diff --git a/scripts/node-globals.js b/scripts/node-globals.js new file mode 100644 index 0000000000..69c2de1c3e --- /dev/null +++ b/scripts/node-globals.js @@ -0,0 +1,3 @@ +// @ts-nocheck +export const { Buffer } = require('buffer') +export const process = require('process/browser')