Skip to content

Commit

Permalink
refactor: rename from go-ipfs to kubo (#63)
Browse files Browse the repository at this point in the history
Closes #51
  • Loading branch information
lidel authored Aug 18, 2023
1 parent 807ce2b commit 6d0a0e3
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:14

LABEL "com.github.actions.name"="Update and publish"
LABEL "com.github.actions.description"="Publish new version when a new go-ipfs version is relased"
LABEL "com.github.actions.description"="Publish new version when a new kubo version is relased"
LABEL "com.github.actions.icon"="rss"
LABEL "com.github.actions.color"="green"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Check for go-ipfs release'
name: 'Check for kubo release'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
set -eu

echo '💫 Checking https://dist.ipfs.tech/go-ipfs/versions for new releases...'
echo '💫 Checking https://dist.ipfs.tech/kubo/versions for new releases...'

# The version in packge.json e.g. "0.4.20"
CURRENT=`node -e 'console.log(require("./package.json").version)'`
# The latest version on dist.ipfs.tech e.g. "0.4.21"
LATEST=`curl --silent https://dist.ipfs.tech/go-ipfs/versions | tail -n 1 | cut -c 2-`
LATEST=`curl --silent https://dist.ipfs.tech/kubo/versions | tail -n 1 | cut -c 2-`

# Verify $LATEST is valid semver!
if ! npx semver $LATEST; then
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/publish/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:14

LABEL "com.github.actions.name"="Version and publish"
LABEL "com.github.actions.description"="npm version and publish with new go-ipfs version"
LABEL "com.github.actions.description"="npm version and publish with new kubo version"
LABEL "com.github.actions.icon"="box"
LABEL "com.github.actions.color"="green"

Expand Down
8 changes: 4 additions & 4 deletions .github/actions/publish/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fi
# The version in packge.json e.g. "0.4.20"
CURRENT=`node -e 'console.log(require("./package.json").version)'`
# The latest version on dist.ipfs.tech e.g. "0.4.21"
LATEST=`curl --silent https://dist.ipfs.tech/go-ipfs/versions | tail -n 1 | cut -c 2-`
LATEST=`curl --silent https://dist.ipfs.tech/kubo/versions | tail -n 1 | cut -c 2-`

# Verify $LATEST is valid semver!
if ! npx semver $LATEST; then
Expand All @@ -37,10 +37,10 @@ if [[ "$CURRENT" != "$LATEST" ]]; then
# Publish pre-releases under the @next tag and releases @latest tag.
if [[ $LATEST =~ "-" ]]; then
NPM_DIST_TAG='next'
echo "🧪 Found new go-ipfs pre-release $LATEST@$NPM_DIST_TAG"
echo "🧪 Found new kubo pre-release $LATEST@$NPM_DIST_TAG"
else
NPM_DIST_TAG='latest'
echo "🎉 Found new go-ipfs release $LATEST@$NPM_DIST_TAG"
echo "🎉 Found new kubo release $LATEST@$NPM_DIST_TAG"
fi

git config --global --add safe.directory /github/workspace
Expand All @@ -60,7 +60,7 @@ if [[ "$CURRENT" != "$LATEST" ]]; then
npm install
npm version $LATEST
npm publish --access public --tag $NPM_DIST_TAG
echo "📦 Published $LATEST to npm as go-ipfs@$NPM_DIST_TAG"
echo "📦 Published $LATEST to npm as kubo@$NPM_DIST_TAG"

git push -u origin master
git push --tags
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check for new go-ipfs version
- name: Check for new kubo version
id: check
uses: ./.github/actions/check-for-go-ipfs-release
uses: ./.github/actions/check-for-kubo-release
- name: Set up node
if: steps.check.outputs.publish == 'true'
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ package-lock.json

# Where the binaries go
go-ipfs
kubo
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# npm-go-ipfs
# npm-kubo

[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech/)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

> install [Kubo](https://github.com/ipfs/kubo) (previously known as "go-ipfs") from npm
> install [Kubo](https://github.com/ipfs/kubo) (previously known as "kubo") from npm
## Table of Contents

Expand All @@ -16,32 +16,32 @@

## Install

Install the latest [Kubo](https://github.com/ipfs/kubo/) (go-ipfs) binary:
Install the latest [Kubo](https://github.com/ipfs/kubo/) (kubo) binary:

```sh
# Install globally
> npm install -g go-ipfs
> npm install -g kubo
> ipfs version
ipfs version v0.7.0
ipfs version v0.23.0

# Install locally
> npm install go-ipfs
> npm install kubo
> ./node_modules/.bin/ipfs
ipfs version v0.7.0
ipfs version v0.23.0
```

## Usage

This module downloads Kubo (go-ipfs) binaries from https://dist.ipfs.tech into your project.

It will download the go-ipfs version that matches the npm version of this module. So depending on `go-ipfs@0.7.0` will install `go-ipfs v0.7.0` for your current system architecture, in to your project at `node_modules/go-ipfs/go-ipfs/ipfs` and additional symlink to it at `node_modules/go-ipfs/bin/ipfs`.
It will download the kubo version that matches the npm version of this module. So depending on `kubo@0.23.0` will install `kubo v0.23.0` for your current system architecture, in to your project at `node_modules/kubo/kubo/ipfs` and additional symlink to it at `node_modules/kubo/bin/ipfs`.

After downloading you can find out the path of the installed binary by calling the `path` function exported by this module:

```javascript
const { path } = require('go-ipfs')
const { path } = require('kubo')

console.info('go-ipfs is installed at', path())
console.info('kubo is installed at', path())
```

An error will be thrown if the path to the binary cannot be resolved.
Expand All @@ -67,7 +67,7 @@ You should be able to just run `./publish.sh` for example:
```sh
> ./publish.sh
usage ./publish.sh <version>
publish a version of go-ipfs to npm
publish a version of kubo to npm

> ./publish.sh 0.3.11
```
Expand All @@ -78,26 +78,26 @@ This will:
- check the size of `bin/ipfs` is right (must be the checked in file)
- update the version numbers in `package.json` and `README.md`
- `git commit` the changes
- push to https://github.com/ipfs/npm-go-ipfs
- publish to `go-ipfs@$version` to https://npmjs.com/package/go-ipfs
- push to https://github.com/ipfs/npm-kubo
- publish to `kubo@$version` to https://npmjs.com/package/kubo

Open an issue in the repo if you run into trouble.

### Publish a new version of this module with exact same go-ipfs version
### Publish a new version of this module with exact same kubo version

If some problem happens, and you need to publish a new version of this module targetting _the same_ go-ipfs version, then please follow this convention:
If some problem happens, and you need to publish a new version of this module targetting _the same_ kubo version, then please follow this convention:

1. **Clean up bad stuff:** unpublish all modules with this exact same `<go-ipfs-version>`
2. **Add a "hacky" version suffix:** use version: `<go-ipfs-version>-hacky<num>`
3. **Publish version:** publish the module. Since it's the only one with the go-ipfs version, then it should be installed.
1. **Clean up bad stuff:** unpublish all modules with this exact same `<kubo-version>`
2. **Add a "hacky" version suffix:** use version: `<kubo-version>-hacky<num>`
3. **Publish version:** publish the module. Since it's the only one with the kubo version, then it should be installed.

> Why do this?
Well, if you previously published npm module `go-ipfs@0.4.0` and there was a problem, we now must publish a different version, but we want to keep the version number the same. so the strategy is to publish as `go-ipfs@0.4.0-hacky1`, and unpublish `go-ipfs@0.4.0`.
Well, if you previously published npm module `kubo@0.4.0` and there was a problem, we now must publish a different version, but we want to keep the version number the same. so the strategy is to publish as `kubo@0.4.0-hacky1`, and unpublish `kubo@0.4.0`.

> Why `-hacky<num>`?
Because it is unlikely to be a legitimate go-ipfs version, and we want to support go-ipfs versions like `floodsub-1` etc.
Because it is unlikely to be a legitimate kubo version, and we want to support kubo versions like `floodsub-1` etc.

> Do i have to say `-hacky<num>` or can i just use `-<num>`?
Expand All @@ -106,7 +106,7 @@ change the convention, go for it, and update this readme accordingly.

## Contribute

Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/npm-go-ipfs/issues)!
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/npm-kubo/issues)!

This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "go-ipfs",
"name": "kubo",
"version": "0.22.0",
"description": "Install the latest go-ipfs binary",
"description": "Install the latest Kubo (go-ipfs) binary",
"main": "src/index.js",
"scripts": {
"postinstall": "node src/post-install.js",
Expand All @@ -26,7 +26,7 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/npm-go-ipfs.git"
"url": "git+https://github.com/ipfs/npm-kubo.git"
},
"keywords": [
"ipfs",
Expand All @@ -35,9 +35,9 @@
"author": "Protocol Labs, Inc.",
"license": "MIT",
"bugs": {
"url": "https://github.com/ipfs/npm-go-ipfs/issues"
"url": "https://github.com/ipfs/npm-kubo/issues"
},
"homepage": "https://github.com/ipfs/npm-go-ipfs",
"homepage": "https://github.com/ipfs/npm-kubo",
"types": "./src/types.d.ts",
"devDependencies": {
"@types/got": "^9.6.12",
Expand Down
28 changes: 14 additions & 14 deletions src/download.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict'

/*
Download go-ipfs distribution package for desired version, platform and architecture,
Download kubo distribution package for desired version, platform and architecture,
and unpack it to a desired output directory.
API:
download(<version>, <platform>, <arch>, <outputPath>)
Defaults:
go-ipfs version: value in package.json/go-ipfs/version
go-ipfs platform: the platform this program is run from
go-ipfs architecture: the architecture of the hardware this program is run from
go-ipfs install path: './go-ipfs'
kubo version: value in package.json/kubo/version
kubo platform: the platform this program is run from
kubo architecture: the architecture of the hardware this program is run from
kubo install path: './kubo'
*/
const goenv = require('./go-platform')
const gunzip = require('gunzip-maybe')
Expand All @@ -33,7 +33,7 @@ const isWin = process.platform === 'win32'
* @param {string} url
*/
async function cachingFetchAndVerify (url) {
const cacheDir = process.env.NPM_GO_IPFS_CACHE || cachedir('npm-go-ipfs')
const cacheDir = process.env.NPM_GO_IPFS_CACHE || cachedir('npm-kubo')
const filename = url.split('/').pop()

if (!filename) {
Expand Down Expand Up @@ -112,7 +112,7 @@ function unpack (url, installPath, stream) {
* @param {string} [installPath]
*/
function cleanArguments (version, platform, arch, installPath) {
const conf = pkgConf.sync('go-ipfs', {
const conf = pkgConf.sync('kubo', {
cwd: process.env.INIT_CWD || process.cwd(),
defaults: {
version: 'v' + pkg.version.replace(/-[0-9]+/, ''),
Expand All @@ -134,8 +134,8 @@ function cleanArguments (version, platform, arch, installPath) {
* @param {string} distUrl
*/
async function ensureVersion (version, distUrl) {
console.info(`${distUrl}/go-ipfs/versions`)
const versions = (await got(`${distUrl}/go-ipfs/versions`).text()).trim().split('\n')
console.info(`${distUrl}/kubo/versions`)
const versions = (await got(`${distUrl}/kubo/versions`).text()).trim().split('\n')

if (versions.indexOf(version) === -1) {
throw new Error(`Version '${version}' not available`)
Expand All @@ -151,7 +151,7 @@ async function ensureVersion (version, distUrl) {
async function getDownloadURL (version, platform, arch, distUrl) {
await ensureVersion(version, distUrl)

const data = await got(`${distUrl}/go-ipfs/${version}/dist.json`).json()
const data = await got(`${distUrl}/kubo/${version}/dist.json`).json()

if (!data.platforms[platform]) {
throw new Error(`No binary available for platform '${platform}'`)
Expand All @@ -162,7 +162,7 @@ async function getDownloadURL (version, platform, arch, distUrl) {
}

const link = data.platforms[platform].archs[arch].link
return `${distUrl}/go-ipfs/${version}${link}`
return `${distUrl}/kubo/${version}${link}`
}

/**
Expand All @@ -180,7 +180,7 @@ async function download ({ version, platform, arch, installPath, distUrl }) {
await unpack(url, installPath, data)
console.info(`Unpacked ${installPath}`)

return path.join(installPath, 'go-ipfs', `ipfs${platform === 'windows' ? '.exe' : ''}`)
return path.join(installPath, 'kubo', `ipfs${platform === 'windows' ? '.exe' : ''}`)
}

/**
Expand All @@ -196,7 +196,7 @@ async function link ({ depBin, version }) {
}

if (!fs.existsSync(depBin)) {
throw new Error('ipfs binary not found. maybe go-ipfs did not install correctly?')
throw new Error('ipfs binary not found. maybe kubo did not install correctly?')
}

if (fs.existsSync(localBin)) {
Expand All @@ -211,7 +211,7 @@ async function link ({ depBin, version }) {
const cmdFile = path.join(__dirname, '..', '..', 'ipfs.cmd')

fs.writeFileSync(cmdFile, `@ECHO OFF
"%~dp0\\node_modules\\go-ipfs\\bin\\ipfs.exe" %*`)
"%~dp0\\node_modules\\kubo\\bin\\ipfs.exe" %*`)
}

// test ipfs installed correctly.
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports.path = function () {
}

const paths = [
path.resolve(path.join(__dirname, '..', 'go-ipfs', 'ipfs')),
path.resolve(path.join(__dirname, '..', 'go-ipfs', 'ipfs.exe'))
path.resolve(path.join(__dirname, '..', 'kubo', 'ipfs')),
path.resolve(path.join(__dirname, '..', 'kubo', 'ipfs.exe'))
]

for (const bin of paths) {
Expand All @@ -19,5 +19,5 @@ module.exports.path = function () {
}
}

throw new Error('go-ipfs binary not found, it may not be installed or an error may have occurred during installation')
throw new Error('kubo binary not found, it may not be installed or an error may have occurred during installation')
}
4 changes: 2 additions & 2 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ test('Ensure ipfs gets downloaded (current version and platform)', async (t) =>
const installPath = await download()
const stats = await fs.stat(installPath)

t.ok(stats, 'go-ipfs was downloaded')
t.ok(installPath, detectLocation(), 'go-ipfs binary was detected')
t.ok(stats, 'kubo was downloaded')
t.ok(installPath, detectLocation(), 'kubo binary was detected')

t.end()
})
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const path = require('path')
const execa = require('execa')

module.exports = async function clean () {
await fs.remove(path.resolve(__dirname, '../../go-ipfs'))
await fs.remove(path.resolve(__dirname, '../../kubo'))
await execa('git', ['checkout', '--', path.resolve(__dirname, '../../bin/ipfs')])
}
2 changes: 1 addition & 1 deletion test/fixtures/example-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"go-ipfs": "file://../../../"
"kubo": "file://../../../"
}
}
Loading

0 comments on commit 6d0a0e3

Please sign in to comment.