Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 4be9336

Browse files
authored
chore: update ipfs (#43)
* chore: update ipfs The next ipfs release will be a dual ESM/CJS version which is presenting some interesting challenges for all the different tools used here. We also use the `ipfs` module everywhere when we could be using `ipfs-core` instead - it's lighter and much quicker to install. Really we should only use `ipfs` when we need the CLI and the HTTP RPC API, though I'm a little wary of the potential confusion for new users having two options introduces.
1 parent ac45d3f commit 4be9336

File tree

70 files changed

+2738
-6319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2738
-6319
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- browser-ipns-publish
2222
- browser-lit
2323
- browser-mfs
24-
- browser-nextjs
24+
#- browser-nextjs
2525
- browser-parceljs
2626
- browser-readablestream
2727
- browser-script-tag

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- [Structure](#structure)
3030
- [IPFS Tutorials at ProtoSchool](#ipfs-tutorials-at-protoschool)
3131
- [Documentation](#documentation)
32+
- [ipfs or ipfs-core?](#ipfs-or-ipfs-core)
3233
- [Contributing](#contributing)
3334
- [Guidelines](#guidelines)
3435
- [Steps to follow after adding a new example](#steps-to-follow-after-adding-a-new-example)
@@ -88,6 +89,16 @@ Explore [ProtoSchool's IPFS tutorials](https://proto.school/#/tutorials?course=i
8889
- [Development](https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md)
8990
- [Tutorials](https://proto.school)
9091

92+
## ipfs or ipfs-core?
93+
94+
The JavaScript implementation of IPFS is available as two packages, `ipfs-core` and `ipfs`.
95+
96+
`ipfs-core` contains the [core api](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) and is intended to be used to run an IPFS node as part of your application without the need to start external processes or manage API ports and servers.
97+
98+
`ipfs` is built on `ipfs-core` but also includes the CLI, an HTTP RPC API server and other tools to run `ipfs` as a background process so is a larger install with more dependencies.
99+
100+
If you are writing an application that needs to access the IPFS network, use `ipfs-core`. If you wish to use js-IPFS in a terminal window or run it as a server for use by multiple otherwise unrelated processes, use `ipfs`.
101+
91102
## Contributing
92103

93104
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.

examples/browser-add-readable-stream/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"browserslist": "last 1 Chrome version",
1616
"dependencies": {
17-
"ipfs": "^0.58.1"
17+
"ipfs-core": "^0.11.0"
1818
},
1919
"devDependencies": {
2020
"@babel/core": "^7.14.8",

examples/browser-add-readable-stream/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import Ipfs from 'ipfs'
3+
import { create } from 'ipfs-core'
44

55
const main = async () => {
66
let ipfs;
@@ -123,7 +123,7 @@ const main = async () => {
123123
showStatus(`Creating IPFS node...`, COLORS.active)
124124

125125
const repoPath = `ipfs-${Math.random()}`
126-
ipfs = await Ipfs.create({ repo: repoPath })
126+
ipfs = await create({ repo: repoPath })
127127
}
128128

129129
const id = await ipfs.id();

examples/browser-angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"@angular/platform-browser-dynamic": "~12.2.0",
2222
"@angular/router": "~12.2.0",
2323
"global": "^4.4.0",
24-
"ipfs": "^0.58.1",
25-
"ipfs-core-types": "^0.7.1",
24+
"ipfs-core": "^0.11.0",
25+
"ipfs-core-types": "^0.8.0",
2626
"rxjs": "~6.6.0",
2727
"tslib": "^2.3.0",
2828
"zone.js": "~0.11.4"

examples/browser-angular/src/app/ipfs.service.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Injectable } from '@angular/core';
22

3-
import * as IPFS from 'ipfs';
3+
import { IPFS, create } from 'ipfs-core';
44
import * as IPFS_ROOT_TYPES from 'ipfs-core-types/src/root';
5-
import * as IPFS_UTILS_TYPES from 'ipfs-core-types/src/utils';
65
import { BehaviorSubject, } from 'rxjs';
76
@Injectable({
87
providedIn: 'root'
98
})
109
export class IpfsService {
11-
private _ipfsSource = new BehaviorSubject<null | IPFS.IPFS>(null);
12-
private _createIPFSNodePromise: Promise<IPFS.IPFS>;
10+
private _ipfsSource = new BehaviorSubject<null | IPFS>(null);
11+
private _createIPFSNodePromise: Promise<IPFS>;
1312

1413
private get ipfs() {
1514
const getter = async () => {
@@ -18,7 +17,7 @@ export class IpfsService {
1817
if (node == null) {
1918
console.log("Waiting node creation...")
2019

21-
node = await this._createIPFSNodePromise as IPFS.IPFS
20+
node = await this._createIPFSNodePromise as IPFS
2221
this._ipfsSource.next(node);
2322
}
2423

@@ -31,7 +30,7 @@ export class IpfsService {
3130
constructor() {
3231
console.log("Starting new node...")
3332

34-
this._createIPFSNodePromise = IPFS.create()
33+
this._createIPFSNodePromise = create()
3534
}
3635

3736
/**

examples/browser-browserify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "npm run build && playwright test tests"
1414
},
1515
"dependencies": {
16-
"ipfs": "^0.58.1"
16+
"ipfs-core": "^0.11.0"
1717
},
1818
"devDependencies": {
1919
"@playwright/test": "^1.12.3",

examples/browser-browserify/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const IPFS = require('ipfs')
3+
const IPFS = require('ipfs-core')
44

55
const App = () => {
66
let ipfs

examples/browser-create-react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@testing-library/react": "^11.2.7",
3636
"@testing-library/user-event": "^12.8.3",
3737
"dot-prop": "^6.0.1",
38-
"ipfs": "^0.58.1",
38+
"ipfs-core": "^0.11.0",
3939
"ipfs-css": "^1.3.0",
4040
"react": "^17.0.2",
4141
"react-dom": "^17.0.2",

examples/browser-create-react-app/src/hooks/use-ipfs-factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Ipfs from 'ipfs'
1+
import { create } from 'ipfs-core'
22
import { useEffect, useState } from 'react'
33

44
let ipfs = null
@@ -42,7 +42,7 @@ export default function useIpfsFactory () {
4242
} else {
4343
try {
4444
console.time('IPFS Started')
45-
ipfs = await Ipfs.create()
45+
ipfs = await create()
4646
console.timeEnd('IPFS Started')
4747
} catch (error) {
4848
console.error('IPFS init error:', error)

examples/browser-exchange-files/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
},
1313
"browserslist": "last 1 Chrome version",
1414
"dependencies": {
15-
"ipfs": "^0.58.1",
15+
"ipfs-core": "^0.11.0",
1616
"it-all": "^1.0.4",
1717
"libp2p-websockets": "^0.16.1",
1818
"uint8arrays": "^3.0.0"
1919
},
2020
"devDependencies": {
2121
"@babel/core": "^7.14.8",
2222
"@playwright/test": "^1.12.3",
23-
"ipfs-http-client": "^52.0.1",
23+
"ipfs": "^0.59.0",
24+
"ipfs-core-types": "^0.8.0",
25+
"ipfs-http-client": "^53.0.0",
2426
"libp2p-webrtc-star": "^0.23.0",
2527
"parcel": "latest",
2628
"playwright": "^1.12.3",

examples/browser-exchange-files/src/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global location */
22
'use strict'
33

4-
const IPFS = require('ipfs')
4+
const IPFS = require('ipfs-core')
55
const WS = require('libp2p-websockets')
66
const filters = require('libp2p-websockets/src/filters')
77
const transportKey = WS.prototype[Symbol.toStringTag]
@@ -41,7 +41,7 @@ let workspace = (location.hash || 'default-workspace').replace(/^#/, '')
4141

4242
let fileSize = 0
4343

44-
/** @type {import('ipfs').IPFS} */
44+
/** @type {import('ipfs-core-types').IPFS} */
4545
let node
4646
let info
4747

examples/browser-exchange-files/tests/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const play = test.extend({
2525
ipfsHttpModule: require('ipfs-http-client')
2626
}, {
2727
js: {
28-
ipfsBin: require.resolve('ipfs/src/cli.js')
28+
ipfsBin: require('ipfs').path()
2929
}
3030
},
3131
[

examples/browser-ipns-publish/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"browserslist": "last 1 Chrome version",
2424
"dependencies": {
2525
"human-crypto-keys": "^0.1.4",
26-
"ipfs": "^0.58.1",
27-
"ipfs-http-client": "^52.0.1",
26+
"ipfs-core": "^0.11.0",
27+
"ipfs-http-client": "^53.0.0",
2828
"ipfs-utils": "^8.1.4",
2929
"ipns": "^0.13.3",
3030
"it-last": "^1.0.4",

examples/browser-ipns-publish/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const IpfsHttpClient = require("ipfs-http-client");
44
const ipns = require("ipns");
5-
const IPFS = require("ipfs");
5+
const IPFS = require("ipfs-core");
66
const pRetry = require("p-retry");
77
const last = require("it-last");
88
const cryptoKeys = require("human-crypto-keys"); // { getKeyPairFromSeed }

examples/browser-lit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"browserslist": "last 1 Chrome version",
1616
"dependencies": {
17-
"ipfs": "^0.58.1",
17+
"ipfs-core": "^0.11.0",
1818
"ipfs-css": "^1.3.0",
1919
"lit": "^2.0.0-rc.2",
2020
"tachyons": "^4.12.0"

examples/browser-lit/src/ipfs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
import {html, LitElement} from 'lit';
4-
import IPFS from 'ipfs'
4+
import { create } from 'ipfs-core'
55

66
export class IPFSInfo extends LitElement {
77
static get properties() {
@@ -29,7 +29,7 @@ export class IPFSInfo extends LitElement {
2929
}
3030

3131
async initIPFS() {
32-
const ipfs = await IPFS.create();
32+
const ipfs = await create();
3333
const id = await ipfs.id();
3434
const version = await ipfs.version();
3535

examples/browser-mfs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"browserslist": "last 1 Chrome version",
1616
"dependencies": {
17-
"ipfs": "^0.58.1",
17+
"ipfs-core": "^0.11.0",
1818
"mime-sniffer": "~0.0.3"
1919
},
2020
"devDependencies": {

examples/browser-mfs/src/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import {
2020
hideForms
2121
} from './forms'
2222
import mime from 'mime-sniffer'
23-
24-
/** @type {import('ipfs-core-types/src/index').IPFS} IPFS */
25-
import IPFS from 'ipfs'
23+
import { create } from 'ipfs-core'
2624

2725
document.addEventListener('DOMContentLoaded', async () => {
28-
const ipfs = await IPFS.create({
26+
const ipfs = await create({
2927
repo: `ipfs-${Math.random()}`
3028
})
3129

examples/browser-nextjs/components/ipfs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from 'react'
2-
import Ipfs from 'ipfs'
2+
import { create } from 'ipfs-core'
33

44
const IpfsComponent = () => {
55
const [id, setId] = useState(null);
@@ -11,7 +11,7 @@ const IpfsComponent = () => {
1111
const init = async () => {
1212
if (ipfs) return
1313

14-
const node = await Ipfs.create();
14+
const node = await create();
1515

1616
const nodeId = await node.id();
1717
const nodeVersion = await node.version();

examples/browser-nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "npm run build && playwright test tests"
1313
},
1414
"dependencies": {
15-
"ipfs": "^0.58.1",
15+
"ipfs-core": "^0.11.0",
1616
"next": "11.0.0",
1717
"react": "17.0.2",
1818
"react-dom": "17.0.2"

examples/browser-parceljs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"browserslist": "last 1 Chrome version",
1717
"dependencies": {
18-
"ipfs": "^0.58.1"
18+
"ipfs-core": "^0.11.0"
1919
},
2020
"devDependencies": {
2121
"@babel/core": "^7.14.8",

examples/browser-parceljs/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import IPFS from 'ipfs'
3+
import { create } from 'ipfs-core'
44

55
const App = () => {
66
let ipfs
@@ -62,7 +62,7 @@ const App = () => {
6262
if (!ipfs) {
6363
showStatus('Creating IPFS node...', COLORS.active)
6464

65-
ipfs = await IPFS.create({
65+
ipfs = await create({
6666
repo: String(Math.random() + Date.now()),
6767
init: { alogorithm: 'ed25519' }
6868
})

examples/browser-readablestream/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"browserslist": "last 1 Chrome version",
1616
"dependencies": {
17-
"ipfs": "^0.58.1",
17+
"ipfs-core": "^0.11.0",
1818
"it-to-stream": "^1.0.0",
1919
"videostream": "^3.2.0"
2020
},

examples/browser-readablestream/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Ipfs from 'ipfs'
1+
import { create } from 'ipfs-core'
22
import VideoStream from 'videostream'
33
import toStream from 'it-to-stream'
44
import {
@@ -18,7 +18,7 @@ const App = async () => {
1818

1919
log('IPFS: Initializing')
2020
const videoElement = createVideoElement()
21-
const ipfs = await Ipfs.create({ repo: 'ipfs-' + Math.random() })
21+
const ipfs = await create({ repo: 'ipfs-' + Math.random() })
2222

2323
// Allow adding files to IPFS via drag and drop
2424
dragDrop(ipfs, log)

examples/browser-service-worker/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"last 1 Chrome version"
1717
],
1818
"dependencies": {
19-
"ipfs": "^0.58.1",
20-
"ipfs-message-port-client": "^0.8.3",
21-
"ipfs-message-port-protocol": "^0.9.0",
22-
"ipfs-message-port-server": "^0.9.0",
19+
"ipfs-core": "^0.11.0",
20+
"ipfs-message-port-client": "^0.9.0",
21+
"ipfs-message-port-protocol": "^0.10.0",
22+
"ipfs-message-port-server": "^0.10.0",
2323
"process": "0.11.10"
2424
},
2525
"devDependencies": {

0 commit comments

Comments
 (0)