Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions npm-overrides/boolean-compat/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict'

function boolean (value) {
const tag = Object.prototype.toString.call(value)
switch (tag) {
case '[object String]':
return ['true', 't', 'yes', 'y', 'on', '1'].includes(String(value).trim().toLowerCase())
case '[object Number]':
return Number(value) === 1
case '[object Boolean]':
return Boolean(value.valueOf())
default:
return false
}
}

function isBooleanable (value) {
if (Object.prototype.toString.call(value) === '[object String]') {
const normalized = String(value).trim().toLowerCase()
return ['true', 't', 'yes', 'y', 'on', '1', 'false', 'f', 'no', 'n', 'off', '0'].includes(normalized)
}
if (Object.prototype.toString.call(value) === '[object Number]') {
return Number(value) === 0 || Number(value) === 1
}
return Object.prototype.toString.call(value) === '[object Boolean]'
}

module.exports = {
boolean,
isBooleanable
}
7 changes: 7 additions & 0 deletions npm-overrides/boolean-compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "boolean",
"version": "3.2.0-ipfs.0",
"description": "Compatibility shim for boolean package API",
"main": "index.js",
"license": "MIT"
}
7 changes: 7 additions & 0 deletions npm-overrides/lodash.isequal-compat/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

const { isDeepStrictEqual } = require('node:util')

module.exports = function isEqual (value, other) {
return isDeepStrictEqual(value, other)
}
7 changes: 7 additions & 0 deletions npm-overrides/lodash.isequal-compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lodash.isequal",
"version": "4.5.0-ipfs.0",
"description": "Compatibility shim using node:util.isDeepStrictEqual",
"main": "index.js",
"license": "MIT"
}
59 changes: 25 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"release-pr": "release-please release-pr --token=$GITHUB_TOKEN --plugin '@ipfs-shipyard/release-please-ipfs-plugin' --repo-url=ipfs/ipfs-desktop --trace --debug --draft-pull-request",
"release-gh": "release-please github-release --token=$GITHUB_TOKEN --plugin '@ipfs-shipyard/release-please-ipfs-plugin' --repo-url=ipfs/ipfs-desktop --trace --debug --draft"
},
"overrides": {
"boolean": "file:./npm-overrides/boolean-compat",
"lodash.isequal": "file:./npm-overrides/lodash.isequal-compat"
},
"pre-commit": [
"lint"
],
Expand Down Expand Up @@ -81,12 +85,10 @@
"ipfs-http-client": "56.0.2",
"ipfs-utils": "^9.0.10",
"ipfsd-ctl": "10.0.6",
"it-last": "^1.0.6",
"kubo": "0.40.1",
"multiaddr": "10.0.1",
"multiaddr-to-uri": "8.0.0",
"portfinder": "^1.0.32",
"untildify": "^4.0.0",
"v8-compile-cache": "^2.4.0",
"winston": "^3.7.2"
},
Expand Down
11 changes: 9 additions & 2 deletions src/add-to-ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ const { extname, basename } = require('path')
const { clipboard } = require('electron')
const { globSource } = require('ipfs-http-client')
const i18n = require('i18next')
const last = require('it-last')
const fs = require('fs-extra')
const logger = require('./common/logger')
const { notify, notifyError } = require('./common/notify')
const { analyticsKeys } = require('./analytics/keys')
const getCtx = require('./context')

async function lastItem (iterable) {
let value
for await (const item of iterable) {
value = item
}
return value
}

async function copyFileToMfs (ipfs, cid, filename) {
let i = 0
const ext = extname(filename)
Expand Down Expand Up @@ -91,7 +98,7 @@ async function addFileOrDirectory (ipfs, filepath) {

if (stat.isDirectory()) {
const files = globSource(filepath, '**/*', { recursive: true, cidVersion: 1 })
const res = await last(ipfs.addAll(files, {
const res = await lastItem(ipfs.addAll(files, {
pin: false,
wrapWithDirectory: true,
cidVersion: 1
Expand Down
7 changes: 3 additions & 4 deletions src/auto-launch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// @ts-check
const { app } = require('electron')
const i18n = require('i18next')
const os = require('os')
const path = require('path')
const os = require('node:os')
const path = require('node:path')
const fs = require('fs-extra')
const untildify = require('untildify')
const createToggler = require('./utils/create-toggler')
const logger = require('./common/logger')
const store = require('./common/store')
Expand All @@ -18,7 +17,7 @@ function isSupported () {
}

function getDesktopFile () {
return path.join(untildify('~/.config/autostart/'), 'ipfs-desktop.desktop')
return path.join(os.homedir(), '.config/autostart/', 'ipfs-desktop.desktop')
}

async function enable () {
Expand Down