From d44018401e54b754bdb0949c873270ea092a425c Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 18 Aug 2023 16:47:21 +0200 Subject: [PATCH] refactor: rename from go-ipfs to kubo Closes #51 --- .../check-for-go-ipfs-release/Dockerfile | 2 +- .../check-for-go-ipfs-release/action.yml | 2 +- .../check-for-go-ipfs-release/entrypoint.sh | 4 +- .github/actions/publish/Dockerfile | 2 +- .github/actions/publish/entrypoint.sh | 8 ++-- .github/workflows/main.yml | 4 +- README.md | 40 +++++++++---------- package.json | 10 ++--- src/download.js | 28 ++++++------- src/index.js | 6 +-- test/download.js | 4 +- test/fixtures/clean.js | 2 +- test/fixtures/example-project/package.json | 2 +- test/install.js | 10 ++--- 14 files changed, 62 insertions(+), 62 deletions(-) diff --git a/.github/actions/check-for-go-ipfs-release/Dockerfile b/.github/actions/check-for-go-ipfs-release/Dockerfile index e233784..240a0d1 100644 --- a/.github/actions/check-for-go-ipfs-release/Dockerfile +++ b/.github/actions/check-for-go-ipfs-release/Dockerfile @@ -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" diff --git a/.github/actions/check-for-go-ipfs-release/action.yml b/.github/actions/check-for-go-ipfs-release/action.yml index e6ce7c1..cf2d825 100644 --- a/.github/actions/check-for-go-ipfs-release/action.yml +++ b/.github/actions/check-for-go-ipfs-release/action.yml @@ -1,4 +1,4 @@ -name: 'Check for go-ipfs release' +name: 'Check for kubo release' runs: using: 'docker' image: 'Dockerfile' diff --git a/.github/actions/check-for-go-ipfs-release/entrypoint.sh b/.github/actions/check-for-go-ipfs-release/entrypoint.sh index eba3b72..7971e3d 100755 --- a/.github/actions/check-for-go-ipfs-release/entrypoint.sh +++ b/.github/actions/check-for-go-ipfs-release/entrypoint.sh @@ -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 diff --git a/.github/actions/publish/Dockerfile b/.github/actions/publish/Dockerfile index 1e440c5..3702c10 100644 --- a/.github/actions/publish/Dockerfile +++ b/.github/actions/publish/Dockerfile @@ -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" diff --git a/.github/actions/publish/entrypoint.sh b/.github/actions/publish/entrypoint.sh index dd4eefc..b858817 100755 --- a/.github/actions/publish/entrypoint.sh +++ b/.github/actions/publish/entrypoint.sh @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 143aa53..5e862b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/README.md b/README.md index a425e4e..ee5843f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 # Install locally -> npm install go-ipfs +> npm install kubo > ./node_modules/.bin/ipfs ipfs version v0.7.0 ``` ## Usage -This module downloads Kubo (go-ipfs) binaries from https://dist.ipfs.tech into your project. +This module downloads Kubo (kubo) 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.7.0` will install `kubo v0.7.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. @@ -67,7 +67,7 @@ You should be able to just run `./publish.sh` for example: ```sh > ./publish.sh usage ./publish.sh -publish a version of go-ipfs to npm +publish a version of kubo to npm > ./publish.sh 0.3.11 ``` @@ -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 `` -2. **Add a "hacky" version suffix:** use version: `-hacky` -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 `` +2. **Add a "hacky" version suffix:** use version: `-hacky` +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`? -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` or can i just use `-`? @@ -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). diff --git a/package.json b/package.json index 052b356..cc041c9 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", diff --git a/src/download.js b/src/download.js index f975add..45c33a8 100644 --- a/src/download.js +++ b/src/download.js @@ -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(, , , ) 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') @@ -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) { @@ -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]+/, ''), @@ -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`) @@ -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}'`) @@ -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}` } /** @@ -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' : ''}`) } /** @@ -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)) { @@ -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. diff --git a/src/index.js b/src/index.js index 4f81346..1ec6f6a 100644 --- a/src/index.js +++ b/src/index.js @@ -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) { @@ -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') } diff --git a/test/download.js b/test/download.js index 0f3b3d2..86800f8 100644 --- a/test/download.js +++ b/test/download.js @@ -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() }) diff --git a/test/fixtures/clean.js b/test/fixtures/clean.js index 94e9adc..1b7e03b 100644 --- a/test/fixtures/clean.js +++ b/test/fixtures/clean.js @@ -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')]) } diff --git a/test/fixtures/example-project/package.json b/test/fixtures/example-project/package.json index 15b08c8..a93fcf0 100644 --- a/test/fixtures/example-project/package.json +++ b/test/fixtures/example-project/package.json @@ -6,6 +6,6 @@ "author": "", "license": "ISC", "dependencies": { - "go-ipfs": "file://../../../" + "kubo": "file://../../../" } } diff --git a/test/install.js b/test/install.js index 315b357..4268c34 100644 --- a/test/install.js +++ b/test/install.js @@ -5,7 +5,7 @@ const execa = require('execa') const cachedir = require('cachedir') /* - Test that correct go-ipfs is downloaded during npm install. + Test that correct kubo is downloaded during npm install. */ const expectedVersion = require('../package.json').version @@ -13,12 +13,12 @@ const expectedVersion = require('../package.json').version async function clean () { await fs.remove(path.join(__dirname, 'fixtures', 'example-project', 'node_modules')) await fs.remove(path.join(__dirname, 'fixtures', 'example-project', 'package-lock.json')) - await fs.remove(cachedir('npm-go-ipfs')) + await fs.remove(cachedir('npm-kubo')) } test.onFinish(clean) -test('Ensure go-ipfs defined in package.json is fetched on dependency install', async (t) => { +test('Ensure kubo defined in package.json is fetched on dependency install', async (t) => { await clean() const exampleProjectRoot = path.join(__dirname, 'fixtures', 'example-project') @@ -29,11 +29,11 @@ test('Ensure go-ipfs defined in package.json is fetched on dependency install', }) // confirm package.json is correct - const fetchedVersion = require(path.join(exampleProjectRoot, 'node_modules', 'go-ipfs', 'package.json')).version + const fetchedVersion = require(path.join(exampleProjectRoot, 'node_modules', 'kubo', 'package.json')).version t.ok(expectedVersion === fetchedVersion, `package.json versions match '${expectedVersion}'`) // confirm binary is correct - const binary = path.join(exampleProjectRoot, 'node_modules', 'go-ipfs', 'bin', 'ipfs') + const binary = path.join(exampleProjectRoot, 'node_modules', 'kubo', 'bin', 'ipfs') const versionRes = execa.sync(binary, ['--version'], { cwd: exampleProjectRoot })