From a4cb2c4865dd0e97292fba06d666bd245caf87fd Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 4 Jan 2022 09:19:46 +0000 Subject: [PATCH 1/6] refactor: remove ipfs on path --- assets/locales/en.json | 11 --- src/daemon/index.js | 16 ---- src/ipfs-on-path/index.js | 110 +++++++--------------- src/ipfs-on-path/scripts/backup.js | 59 ------------ src/ipfs-on-path/scripts/bin-win/ipfs.cmd | 8 -- src/ipfs-on-path/scripts/consts.js | 6 -- src/ipfs-on-path/scripts/install.js | 52 ---------- src/ipfs-on-path/scripts/install.ps1 | 4 - src/ipfs-on-path/scripts/ipfs.sh | 15 --- src/ipfs-on-path/scripts/uninstall.js | 45 ++++++++- src/tray.js | 10 -- 11 files changed, 74 insertions(+), 262 deletions(-) delete mode 100644 src/ipfs-on-path/scripts/backup.js delete mode 100644 src/ipfs-on-path/scripts/bin-win/ipfs.cmd delete mode 100644 src/ipfs-on-path/scripts/consts.js delete mode 100644 src/ipfs-on-path/scripts/install.js delete mode 100644 src/ipfs-on-path/scripts/install.ps1 delete mode 100755 src/ipfs-on-path/scripts/ipfs.sh diff --git a/assets/locales/en.json b/assets/locales/en.json index f60c72c90..2caf385f1 100644 --- a/assets/locales/en.json +++ b/assets/locales/en.json @@ -187,16 +187,6 @@ "title": "Error", "message": "Launch at login could not be enabled on your machine." }, - "enableIpfsOnPath": { - "title": "Enable IPFS on PATH", - "message": "By enabling this option, IPFS will be available on your command line as \"ipfs\". This action is reversible.", - "action": "Enable" - }, - "disableIpfsOnPath": { - "title": "Disable IPFS on PATH", - "message": "By disabling this option, IPFS will no longer be available on your command line as \"ipfs\".", - "action": "Disable" - }, "enableGlobalTakeScreenshotShortcut": { "title": "Enable screenshot shortcut", "message": "By enabling this, the shortcut \"{ accelerator }\" will be available to take screenshots as long as IPFS Desktop is running." @@ -215,7 +205,6 @@ "pubsub": "Enable PubSub", "namesysPubsub": "Enable IPNS over PubSub", "automaticGC": "Automatic Garbage Collection", - "ipfsCommandLineTools": "Command Line Tools", "takeScreenshotShortcut": "Global Screenshot Shortcut", "downloadHashShortcut": "Global Download Shortcut", "experiments": "Experiments", diff --git a/src/daemon/index.js b/src/daemon/index.js index 63ac0899e..fe52fa428 100644 --- a/src/daemon/index.js +++ b/src/daemon/index.js @@ -43,13 +43,6 @@ module.exports = async function (ctx) { const config = store.get('ipfsConfig') updateStatus(STATUS.STARTING_STARTED) - if (config.path) { - // Updates the IPFS_PATH file. We do this every time we start up - // to make sure we always have that file present, even though - // there are installations and updates that might remove the file. - writeIpfsPath(config.path) - } - try { ipfsd = await createDaemon(config) @@ -59,7 +52,6 @@ module.exports = async function (ctx) { if (!config.path || typeof config.path !== 'string') { config.path = ipfsd.path store.set('ipfsConfig', config) - writeIpfsPath(config.path) } log.end() @@ -125,11 +117,3 @@ module.exports = async function (ctx) { } module.exports.STATUS = STATUS - -function writeIpfsPath (path) { - fs.outputFileSync( - join(app.getPath('home'), './.ipfs-desktop/IPFS_PATH') - .replace('app.asar', 'app.asar.unpacked'), - path - ) -} diff --git a/src/ipfs-on-path/index.js b/src/ipfs-on-path/index.js index 6b6ad37b3..a036809a8 100644 --- a/src/ipfs-on-path/index.js +++ b/src/ipfs-on-path/index.js @@ -1,13 +1,13 @@ const { join } = require('path') const i18n = require('i18next') -const which = require('which') +const { app } = require('electron') const { execFile } = require('child_process') -const createToggler = require('../utils/create-toggler') const execOrSudo = require('../utils/exec-or-sudo') const logger = require('../common/logger') const store = require('../common/store') const { IS_WIN } = require('../common/consts') -const { showDialog, recoverableErrorDialog } = require('../dialogs') +const { showDialog } = require('../dialogs') +const { unlinkSync } = require('fs') const CONFIG_KEY = 'ipfsOnPath' @@ -17,107 +17,61 @@ const errorMessage = { } module.exports = async function () { - createToggler(CONFIG_KEY, async ({ newValue, oldValue }) => { - if (newValue === oldValue || (oldValue === null && !newValue)) { - return + if (store.get(CONFIG_KEY, null) === true) { + try { + await uninstall('uninstall') + } catch (err) { + // Weird, but not worth bothering. + logger.error(`[ipfs on path] ${err.toStrinng()}`) } - if (newValue === true) { - if (showDialog({ - title: i18n.t('enableIpfsOnPath.title'), - message: i18n.t('enableIpfsOnPath.message'), - buttons: [ - i18n.t('enableIpfsOnPath.action'), - i18n.t('cancel') - ] - }) !== 0) { - // User canceled - return - } - - return run('install') + try { + unlinkSync(join(app.getPath('home'), './.ipfs-desktop/IPFS_PATH').replace('app.asar', 'app.asar.unpacked')) + } catch (err) { + // Weird, but not worth bothering. + logger.error(`[ipfs on path] ${err.toStrinng()}`) } - if (showDialog({ - title: i18n.t('disableIpfsOnPath.title'), - message: i18n.t('disableIpfsOnPath.message'), + logger.info('[ipfs on path] uninstalled') + + showDialog({ + title: 'Command Line Tools Uninstalled', + message: 'Command Line Tools via IPFS Desktop have been deprecated in February 2021. They have now been uninstalled. Please refer to https://docs.ipfs.io/install/command-line/ if you need to use ipfs from the command line.', buttons: [ - i18n.t('disableIpfsOnPath.action'), - i18n.t('cancel') + i18n.t('close') ] - }) !== 0) { - // User canceled - return - } - - return run('uninstall') - }) - - firstTime() -} - -module.exports.CONFIG_KEY = CONFIG_KEY - -async function firstTime () { - // Check if we've done this before. - if (store.get(CONFIG_KEY, null) !== null) { - logger.info('[ipfs on path] no action taken') - return - } - - if (which.sync('ipfs', { nothrow: true }) !== null) { - // ipfs already exists on user's system so we won't take any action - // by default. Doesn't try again next time. - store.set(CONFIG_KEY, false) - return + }) } - // Tries to install ipfs-on-path on the system. It doesn't try to elevate - // to sudo so the user doesn't get annoying prompts when running IPFS Desktop - // for the first time. Sets the option according to the success or failure of the - // procedure. - try { - const res = await run('install', { trySudo: false, failSilently: true }) - store.set(CONFIG_KEY, res) - } catch (err) { - logger.error(`[ipfs on path] unexpected error while no-sudo install: ${err.toString()}`) - store.set(CONFIG_KEY, false) - } + store.delete(CONFIG_KEY) } -async function runWindows (script, { failSilently }) { - return new Promise(resolve => { +async function uninstallWindows () { + return new Promise((resolve, reject) => { execFile('powershell.exe', [ '-nop', '-exec', 'bypass', '-win', 'hidden', '-File', - join(__dirname, `scripts/${script}.ps1`).replace('app.asar', 'app.asar.unpacked') + join(__dirname, 'scripts/uninstall.ps1').replace('app.asar', 'app.asar.unpacked') ], {}, err => { if (err) { - logger.error(`[ipfs on path] ${err.toString()}`) - - if (!failSilently) { - recoverableErrorDialog(err, errorMessage) - } - - return resolve(false) + return reject(err) } - logger.info(`[ipfs on path] ${script}ed`) - resolve(true) + resolve() }) }) } -async function run (script, { trySudo = true, failSilently = false } = {}) { +async function uninstall () { if (IS_WIN) { - return runWindows(script, { failSilently }) + return uninstallWindows() } return execOrSudo({ - script: join(__dirname, `./scripts/${script}.js`), + script: join(__dirname, './scripts/uninstall.js'), scope: 'ipfs on path', - trySudo, - failSilently, + trySudo: true, + failSilently: false, errorOptions: errorMessage }) } diff --git a/src/ipfs-on-path/scripts/backup.js b/src/ipfs-on-path/scripts/backup.js deleted file mode 100644 index b6afb50b7..000000000 --- a/src/ipfs-on-path/scripts/backup.js +++ /dev/null @@ -1,59 +0,0 @@ -const fs = require('fs-extra') -const { join } = require('path') - -function checkErr (err) { - // NOTE: there is a bug where copySync will throw if the inode - // from the src and dst are equal. In the case of symlinks, that'll happen. - // https://github.com/jprichardson/node-fs-extra/issues/657 - if (!err.toString().includes('Source and destination must not be the same')) { - throw err - } -} - -function backup (userData, original) { - const bin = original.split('/').pop() - const backup = join(userData, bin + '.bak') - - try { - fs.copySync(original, backup) - } catch (err) { - checkErr(err) - } - - console.log(`${original} copied to ${backup}`) -} - -function revert (userData, bin, dst) { - const backup = join(userData, bin + '.bak') - - try { - fs.removeSync(dst) - } catch (err) { - if (err.code !== 'ENOENT') { - throw err - } - } - - try { - fs.copySync(backup, dst) - console.log(`${backup} restored to ${dst}`) - } catch (err) { - if (err.code === 'ENOENT') { - console.log(`${backup} not found, skipping`) - return - } - - checkErr(err) - } - - try { - fs.unlinkSync(backup) - } catch (_) { - // Failed to remove the backup. Suprising, but not worth bothering the user about. - } -} - -module.exports = Object.freeze({ - backup, - revert -}) diff --git a/src/ipfs-on-path/scripts/bin-win/ipfs.cmd b/src/ipfs-on-path/scripts/bin-win/ipfs.cmd deleted file mode 100644 index 4406b39aa..000000000 --- a/src/ipfs-on-path/scripts/bin-win/ipfs.cmd +++ /dev/null @@ -1,8 +0,0 @@ -@echo off - -if exist "%USERPROFILE%\.ipfs-desktop\IPFS_PATH" ( - SET /P IPFS_PATH=<"%USERPROFILE%\.ipfs-desktop\IPFS_PATH" -) - -SET /P IPFS_EXEC=<"%USERPROFILE%\.ipfs-desktop\IPFS_EXEC" -"%IPFS_EXEC%" %* diff --git a/src/ipfs-on-path/scripts/consts.js b/src/ipfs-on-path/scripts/consts.js deleted file mode 100644 index 77a15d7e7..000000000 --- a/src/ipfs-on-path/scripts/consts.js +++ /dev/null @@ -1,6 +0,0 @@ -const { join } = require('path') - -module.exports = Object.freeze({ - SOURCE_SCRIPT: join(__dirname, 'ipfs.sh').replace('app.asar', 'app.asar.unpacked'), - DEST_SCRIPT: '/usr/local/bin/ipfs' -}) diff --git a/src/ipfs-on-path/scripts/install.js b/src/ipfs-on-path/scripts/install.js deleted file mode 100644 index 80fa03030..000000000 --- a/src/ipfs-on-path/scripts/install.js +++ /dev/null @@ -1,52 +0,0 @@ -const fs = require('fs-extra') -const which = require('which') -const { backup } = require('./backup') -const { argv } = require('yargs') -const { SOURCE_SCRIPT, DEST_SCRIPT } = require('./consts') - -let exists = false - -try { - fs.lstatSync(DEST_SCRIPT) - exists = true - console.log(`${DEST_SCRIPT} already exists`) -} catch (e) { - if (!e.toString().includes('ENOENT')) { - // Some other error - throw e - } -} - -if (exists) { - try { - const link = fs.readlinkSync(DEST_SCRIPT) - - if (link === SOURCE_SCRIPT) { - console.log('already symlinked') - process.exit(0) - } - } catch (_) { - // DEST_SCRIPT is not a symlink, ignore. - } -} - -if (which.sync('ipfs', { nothrow: true }) !== null) { - exists = true -} - -if (exists) { - try { - backup(argv.data, DEST_SCRIPT) - } catch (e) { - if (!e.toString().includes('ENOENT')) { - // Some other error - throw e - } - } - - fs.unlinkSync(DEST_SCRIPT) - console.log(`${DEST_SCRIPT} removed`) -} - -fs.ensureSymlinkSync(SOURCE_SCRIPT, DEST_SCRIPT) -console.log(`${DEST_SCRIPT} symlinked to ${SOURCE_SCRIPT}`) diff --git a/src/ipfs-on-path/scripts/install.ps1 b/src/ipfs-on-path/scripts/install.ps1 deleted file mode 100644 index f2df74b67..000000000 --- a/src/ipfs-on-path/scripts/install.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -$path = [System.Environment]::GetEnvironmentVariable('PATH', 'User') -$path = ($path.Split(';') | Where-Object { $_ -ne "$PSScriptRoot\bin-win" }) -join ';' -$path = $path, "$PSScriptRoot\bin-win" -join ';' -[Environment]::SetEnvironmentVariable('PATH', $path, 'User') diff --git a/src/ipfs-on-path/scripts/ipfs.sh b/src/ipfs-on-path/scripts/ipfs.sh deleted file mode 100755 index b967c5bfa..000000000 --- a/src/ipfs-on-path/scripts/ipfs.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -dir="$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")" - -if [ -f ~/.ipfs-desktop/IPFS_PATH ]; then - export IPFS_PATH="$(cat ~/.ipfs-desktop/IPFS_PATH)" -fi - -# Get the full path of the app directory (resolving the symlink if needed) -app=$(dirname "$(dirname "$(dirname "$dir")")") - -# Get the full path to ipfs binary bundled with ipfs-desktop -ipfs="$(cat ~/.ipfs-desktop/IPFS_EXEC)" - -exec "$ipfs" "$@" diff --git a/src/ipfs-on-path/scripts/uninstall.js b/src/ipfs-on-path/scripts/uninstall.js index e2b236771..1d30a1fa8 100644 --- a/src/ipfs-on-path/scripts/uninstall.js +++ b/src/ipfs-on-path/scripts/uninstall.js @@ -1,5 +1,44 @@ -const { DEST_SCRIPT } = require('./consts') -const { revert } = require('./backup') const { argv } = require('yargs') +const fs = require('fs-extra') +const { join } = require('path') -revert(argv.data, 'ipfs', DEST_SCRIPT) +function checkErr (err) { + // NOTE: there is a bug where copySync will throw if the inode + // from the src and dst are equal. In the case of symlinks, that'll happen. + // https://github.com/jprichardson/node-fs-extra/issues/657 + if (!err.toString().includes('Source and destination must not be the same')) { + throw err + } +} + +function revert (userData, bin, dst) { + const backup = join(userData, bin + '.bak') + + try { + fs.removeSync(dst) + } catch (err) { + if (err.code !== 'ENOENT') { + throw err + } + } + + try { + fs.copySync(backup, dst) + console.log(`${backup} restored to ${dst}`) + } catch (err) { + if (err.code === 'ENOENT') { + console.log(`${backup} not found, skipping`) + return + } + + checkErr(err) + } + + try { + fs.unlinkSync(backup) + } catch (_) { + // Failed to remove the backup. Suprising, but not worth bothering the user about. + } +} + +revert(argv.data, 'ipfs', '/usr/local/bin/ipfs') diff --git a/src/tray.js b/src/tray.js index d7ec3a7cd..518c738a9 100644 --- a/src/tray.js +++ b/src/tray.js @@ -16,32 +16,24 @@ const { CONFIG_KEY: AUTO_LAUNCH_KEY, isSupported: supportsLaunchAtLogin } = requ const { CONFIG_KEY: PUBSUB_KEY } = require('./enable-pubsub') const { CONFIG_KEY: NAMESYS_PUBSUB_KEY } = require('./enable-namesys-pubsub') const { CONFIG_KEY: AUTO_GC_KEY } = require('./automatic-gc') -const { CONFIG_KEY: IPFS_PATH_KEY } = require('./ipfs-on-path') const { CONFIG_KEY: AUTO_LAUNCH_WEBUI_KEY } = require('./webui') const CONFIG_KEYS = [ AUTO_LAUNCH_KEY, AUTO_LAUNCH_WEBUI_KEY, AUTO_GC_KEY, - IPFS_PATH_KEY, SCREENSHOT_KEY, DOWNLOAD_KEY, PUBSUB_KEY, NAMESYS_PUBSUB_KEY ] -// We show them if user enabled them before, but hide when off -const DEPRECATED_KEYS = new Set([ - IPFS_PATH_KEY // brittle, buggy, way better if user does this by hand for now -]) - function buildCheckbox (key, label) { return { id: key, label: i18n.t(label), click: () => { ipcMain.emit(`toggle_${key}`) }, type: 'checkbox', - visible: !DEPRECATED_KEYS.has(key), checked: false } } @@ -134,7 +126,6 @@ function buildMenu (ctx) { buildCheckbox(AUTO_LAUNCH_KEY, 'settings.launchOnStartup'), buildCheckbox(AUTO_LAUNCH_WEBUI_KEY, 'settings.openWebUIAtLaunch'), buildCheckbox(AUTO_GC_KEY, 'settings.automaticGC'), - buildCheckbox(IPFS_PATH_KEY, 'settings.ipfsCommandLineTools'), buildCheckbox(SCREENSHOT_KEY, 'settings.takeScreenshotShortcut'), buildCheckbox(DOWNLOAD_KEY, 'settings.downloadHashShortcut'), { type: 'separator' }, @@ -341,7 +332,6 @@ module.exports = function (ctx) { for (const key of CONFIG_KEYS) { const enabled = store.get(key, false) menu.getMenuItemById(key).checked = enabled - menu.getMenuItemById(key).visible = !DEPRECATED_KEYS.has(key) || enabled } if (!IS_MAC && !IS_WIN) { From f7b3b28a7b4bb6ca858f5915bc0eac32f7f3e898 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 4 Jan 2022 09:22:59 +0000 Subject: [PATCH 2/6] refactor: remove ipfs on path --- assets/locales/en.json | 4 ---- src/ipfs-on-path/index.js | 14 +++++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/assets/locales/en.json b/assets/locales/en.json index 2caf385f1..73b5c0451 100644 --- a/assets/locales/en.json +++ b/assets/locales/en.json @@ -149,10 +149,6 @@ "title": "Move repository", "message": "Could not move the repository from \"{ currDir }\" to \"{ newDir }\"." }, - "cantAddIpfsToPath": { - "title": "IPFS on PATH", - "message": "Could not add IPFS to the PATH." - }, "runGarbageCollectorErrored": { "title": "Garbage collector", "message": "The garbage collector run could not be completed successfully." diff --git a/src/ipfs-on-path/index.js b/src/ipfs-on-path/index.js index a036809a8..40ce0c0ad 100644 --- a/src/ipfs-on-path/index.js +++ b/src/ipfs-on-path/index.js @@ -11,25 +11,22 @@ const { unlinkSync } = require('fs') const CONFIG_KEY = 'ipfsOnPath' -const errorMessage = { - title: i18n.t('cantAddIpfsToPath.title'), - message: i18n.t('cantAddIpfsToPath.message') -} - +// Deprecated in February 2021 https://github.com/ipfs/ipfs-desktop/pull/1768 +// Once this bit of code is removed, also remove ../utils/exec-or-sudo. module.exports = async function () { if (store.get(CONFIG_KEY, null) === true) { try { await uninstall('uninstall') } catch (err) { // Weird, but not worth bothering. - logger.error(`[ipfs on path] ${err.toStrinng()}`) + logger.error(`[ipfs on path] ${err.toString()}`) } try { unlinkSync(join(app.getPath('home'), './.ipfs-desktop/IPFS_PATH').replace('app.asar', 'app.asar.unpacked')) } catch (err) { // Weird, but not worth bothering. - logger.error(`[ipfs on path] ${err.toStrinng()}`) + logger.error(`[ipfs on path] ${err.toString()}`) } logger.info('[ipfs on path] uninstalled') @@ -71,7 +68,6 @@ async function uninstall () { script: join(__dirname, './scripts/uninstall.js'), scope: 'ipfs on path', trySudo: true, - failSilently: false, - errorOptions: errorMessage + failSilently: true }) } From 94e07998d993074782c6f56985561e58636c1df2 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 7 Jan 2022 12:28:20 +0100 Subject: [PATCH 3/6] remove IPFS_EXEC file License: MIT Signed-off-by: Henrique Dias --- src/daemon/daemon.js | 12 ------------ src/ipfs-on-path/index.js | 1 + 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/daemon/daemon.js b/src/daemon/daemon.js index 2e79906c6..12c7dcacf 100644 --- a/src/daemon/daemon.js +++ b/src/daemon/daemon.js @@ -1,8 +1,5 @@ const Ctl = require('ipfsd-ctl') const i18n = require('i18next') -const fs = require('fs-extra') -const { join } = require('path') -const { app } = require('electron') const { showDialog } = require('../dialogs') const logger = require('../common/logger') const { applyDefaults, migrateConfig, checkCorsConfig, checkPorts, configExists, rmApiFile, apiFileExists } = require('./config') @@ -27,17 +24,8 @@ function getIpfsBinPath () { .replace('app.asar', 'app.asar.unpacked') } -function writeIpfsBinaryPath (path) { - fs.outputFileSync( - join(app.getPath('home'), './.ipfs-desktop/IPFS_EXEC') - .replace('app.asar', 'app.asar.unpacked'), - path - ) -} - async function spawn ({ flags, path }) { const ipfsBin = getIpfsBinPath() - writeIpfsBinaryPath(ipfsBin) const ipfsd = await Ctl.createController({ ipfsHttpModule: require('ipfs-http-client'), diff --git a/src/ipfs-on-path/index.js b/src/ipfs-on-path/index.js index 40ce0c0ad..f8528b077 100644 --- a/src/ipfs-on-path/index.js +++ b/src/ipfs-on-path/index.js @@ -24,6 +24,7 @@ module.exports = async function () { try { unlinkSync(join(app.getPath('home'), './.ipfs-desktop/IPFS_PATH').replace('app.asar', 'app.asar.unpacked')) + unlinkSync(join(app.getPath('home'), './.ipfs-desktop/IPFS_EXEC').replace('app.asar', 'app.asar.unpacked')) } catch (err) { // Weird, but not worth bothering. logger.error(`[ipfs on path] ${err.toString()}`) From 5d7b486a693ef640aea7a24267478ee97c2b7619 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 21 Jan 2022 14:51:19 +0100 Subject: [PATCH 4/6] feat: add open cli doc opt --- assets/locales/en.json | 1 + src/ipfs-on-path/index.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/assets/locales/en.json b/assets/locales/en.json index 73b5c0451..5769cb1cc 100644 --- a/assets/locales/en.json +++ b/assets/locales/en.json @@ -47,6 +47,7 @@ "customIpfsBinary": "Custom IPFS Binary", "setCustomIpfsBinary": "Set Custom IPFS Binary", "clearCustomIpfsBinary": "Clear Custom IPFS Binary", + "openCliDocumentation": "Open CLI Documentation", "polkitDialog": { "title": "Polkit not found", "message": "IPFS can't be added to /usr/local/bin/ without polkit agent." diff --git a/src/ipfs-on-path/index.js b/src/ipfs-on-path/index.js index f8528b077..401cfe1fa 100644 --- a/src/ipfs-on-path/index.js +++ b/src/ipfs-on-path/index.js @@ -1,6 +1,6 @@ const { join } = require('path') const i18n = require('i18next') -const { app } = require('electron') +const { app, shell } = require('electron') const { execFile } = require('child_process') const execOrSudo = require('../utils/exec-or-sudo') const logger = require('../common/logger') @@ -32,13 +32,18 @@ module.exports = async function () { logger.info('[ipfs on path] uninstalled') - showDialog({ + const opt = showDialog({ title: 'Command Line Tools Uninstalled', message: 'Command Line Tools via IPFS Desktop have been deprecated in February 2021. They have now been uninstalled. Please refer to https://docs.ipfs.io/install/command-line/ if you need to use ipfs from the command line.', buttons: [ + i18n.t('openCliDocumentation'), i18n.t('close') ] }) + + if (opt === 0) { + shell.openExternal('https://docs.ipfs.io/install/command-line/') + } } store.delete(CONFIG_KEY) From cc01a6ce04b3f5948b6461cecab3a092ebe236d2 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 21 Jan 2022 14:54:36 +0100 Subject: [PATCH 5/6] remove backup file, keep symlink Co-authored-by: Marcin Rataj --- src/ipfs-on-path/scripts/uninstall.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/ipfs-on-path/scripts/uninstall.js b/src/ipfs-on-path/scripts/uninstall.js index 1d30a1fa8..ee44712a4 100644 --- a/src/ipfs-on-path/scripts/uninstall.js +++ b/src/ipfs-on-path/scripts/uninstall.js @@ -14,25 +14,6 @@ function checkErr (err) { function revert (userData, bin, dst) { const backup = join(userData, bin + '.bak') - try { - fs.removeSync(dst) - } catch (err) { - if (err.code !== 'ENOENT') { - throw err - } - } - - try { - fs.copySync(backup, dst) - console.log(`${backup} restored to ${dst}`) - } catch (err) { - if (err.code === 'ENOENT') { - console.log(`${backup} not found, skipping`) - return - } - - checkErr(err) - } try { fs.unlinkSync(backup) From b4a5af2b736c4422ccdfa2ca07770cf72f5b5bcc Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 21 Jan 2022 14:54:57 +0100 Subject: [PATCH 6/6] cleanup uninstall.js file --- src/ipfs-on-path/scripts/uninstall.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/ipfs-on-path/scripts/uninstall.js b/src/ipfs-on-path/scripts/uninstall.js index ee44712a4..ff15773f6 100644 --- a/src/ipfs-on-path/scripts/uninstall.js +++ b/src/ipfs-on-path/scripts/uninstall.js @@ -2,19 +2,9 @@ const { argv } = require('yargs') const fs = require('fs-extra') const { join } = require('path') -function checkErr (err) { - // NOTE: there is a bug where copySync will throw if the inode - // from the src and dst are equal. In the case of symlinks, that'll happen. - // https://github.com/jprichardson/node-fs-extra/issues/657 - if (!err.toString().includes('Source and destination must not be the same')) { - throw err - } -} - function revert (userData, bin, dst) { const backup = join(userData, bin + '.bak') - try { fs.unlinkSync(backup) } catch (_) {