diff --git a/CHANGELOG.md b/CHANGELOG.md index cb708eccd..efbbfaa0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ### New Features & Improvements * Changed `lando setup` to pull common plugins based on release `channel` to better mimic fatcore -* Rebased `axios` on `@npmcli/agent` to improve request consistency across environments +* Improved internet detection tests [#243](https://github.com/lando/core/issues/243) +* Rebased `axios` and `octokit` on `@npmcli/agent` to improve request consistency across environments * Updated default Docker Desktop version to `4.34.3` * Updated default Docker Engine version to `27.3.1` * Udpated recommended Docker Destkop range to `>=4.34.0` @@ -19,6 +20,7 @@ * Added `debugShim` to `lando.utils` * Added `downloadX` to `lando.utils` * Added `getAxios` to `lando.utils` +* Added `getOctokit` to `lando.utils` * Added `getUserShell` to `lando.utils` * Added `getUserShellProfile` to `lando.utils` * Added `isVersionLte` to `lando.utils` diff --git a/components/plugin.js b/components/plugin.js index 87e62ec24..b1b5e5867 100644 --- a/components/plugin.js +++ b/components/plugin.js @@ -292,11 +292,6 @@ class Plugin { const channel = this.channel === 'stable' ? 'latest' : this.channel; try { - // check internet connection - const online = await require('is-online')(); - // throw error if not online - if (!online) throw new Error('Cannot detect connection to internet!'); - // process to check // get release data const data = await packument(this.spec, merge({}, [Plugin.config, {fullMetadata: true}])); // build a list of highest available versions diff --git a/hooks/lando-setup-build-engine-darwin.js b/hooks/lando-setup-build-engine-darwin.js index 86642c09a..5d2414d17 100644 --- a/hooks/lando-setup-build-engine-darwin.js +++ b/hooks/lando-setup-build-engine-darwin.js @@ -1,5 +1,6 @@ 'use strict'; +const axios = require('../utils/get-axios')(); const os = require('os'); const path = require('path'); const semver = require('semver'); @@ -86,6 +87,9 @@ module.exports = async (lando, options) => { // cosmetics const install = version ? `v${version}` : `build ${build}`; + // download url + const url = getEngineDownloadUrl(build); + // darwin install task options.tasks.push({ title: `Downloading build engine`, @@ -112,8 +116,8 @@ module.exports = async (lando, options) => { canRun: async () => { // throw if we cannot resolve a semantic version to a buildid if (!build) throw new Error(`Could not resolve ${install} to an installable version!`); - // throw error if not online - if (!await require('is-online')()) throw new Error('Cannot detect connection to internet!'); + // throw error if we cannot ping the download link + await axios.head(url); // throw if user is not an admin if (!await require('../utils/is-admin-user')()) { throw new Error([ @@ -127,7 +131,7 @@ module.exports = async (lando, options) => { task: async (ctx, task) => { try { // download the installer - ctx.download = await downloadDockerDesktop(getEngineDownloadUrl(build), {ctx, debug, task}); + ctx.download = await downloadDockerDesktop(url, {ctx, debug, task}); // prompt for password if interactive if (ctx.password === undefined && lando.config.isInteractive) { diff --git a/hooks/lando-setup-build-engine-linux.js b/hooks/lando-setup-build-engine-linux.js index 666a6ce43..1fdbd4bcd 100644 --- a/hooks/lando-setup-build-engine-linux.js +++ b/hooks/lando-setup-build-engine-linux.js @@ -1,5 +1,6 @@ 'use strict'; +const axios = require('../utils/get-axios')(); const os = require('os'); const path = require('path'); @@ -31,6 +32,7 @@ module.exports = async (lando, options) => { if (options.buildEngine === false) return; const version = options.buildEngine; + const url = 'https://get.docker.com'; // darwin install task options.tasks.push({ @@ -46,8 +48,8 @@ module.exports = async (lando, options) => { canRun: async () => { // throw if we cannot resolve a semantic version to a buildid if (!version) throw new Error(`Could not resolve ${version} to an installable version!`); - // throw error if not online - if (!await require('is-online')()) throw new Error('Cannot detect connection to internet!'); + // throw error if we cannot ping the download link + await axios.head(url); // throw if user is not an admin if (!await require('../utils/is-admin-user')()) { throw new Error([ @@ -61,7 +63,7 @@ module.exports = async (lando, options) => { task: async (ctx, task) => { try { // download the installer - ctx.download = await downloadDockerEngine('https://get.docker.com', {ctx, debug, task}); + ctx.download = await downloadDockerEngine(url, {ctx, debug, task}); // prompt for password if interactive and we dont have it if (ctx.password === undefined && lando.config.isInteractive) { diff --git a/hooks/lando-setup-build-engine-win32.js b/hooks/lando-setup-build-engine-win32.js index bb188cb86..73ea717a8 100644 --- a/hooks/lando-setup-build-engine-win32.js +++ b/hooks/lando-setup-build-engine-win32.js @@ -1,5 +1,6 @@ 'use strict'; +const axios = require('../utils/get-axios')(); const os = require('os'); const path = require('path'); const semver = require('semver'); @@ -90,10 +91,13 @@ module.exports = async (lando, options) => { // get stuff from config/opts const build = getId(options.buildEngine); const version = getVersion(options.buildEngine); + // cosmetics const buildEngine = process.platform === 'linux' ? 'docker-engine' : 'docker-desktop'; const install = version ? `v${version}` : `build ${build}`; + const url = getEngineDownloadUrl(build); + // win32 install docker desktop task options.tasks.push({ title: `Downloading build engine`, @@ -120,8 +124,8 @@ module.exports = async (lando, options) => { canRun: async () => { // throw if we cannot resolve a semantic version to a buildid if (!build) throw new Error(`Could not resolve ${install} to an installable version!`); - // throw error if not online - if (!await require('is-online')()) throw new Error('Cannot detect connection to internet!'); + // throw error if we cannot ping the download link + await axios.head(url); // @TODO: check for wsl2? return true; }, @@ -135,7 +139,7 @@ module.exports = async (lando, options) => { task: async (ctx, task) => { try { // download the installer - ctx.download = await downloadDockerDesktop(getEngineDownloadUrl(build), {ctx, debug, task}); + ctx.download = await downloadDockerDesktop(url, {ctx, debug, task}); // script const script = [path.join(lando.config.userConfRoot, 'scripts', 'install-docker-desktop.ps1')]; // args diff --git a/hooks/lando-setup-install-ca-linux.js b/hooks/lando-setup-install-ca-linux.js index e3cb65634..891ccec07 100644 --- a/hooks/lando-setup-install-ca-linux.js +++ b/hooks/lando-setup-install-ca-linux.js @@ -40,8 +40,6 @@ module.exports = async (lando, options) => { } }, canRun: async () => { - // Check for internet connection - if (!await require('is-online')()) throw new Error('Cannot detect connection to internet!'); // Check for admin privileges if (!await require('../utils/is-admin-user')()) { throw new Error([ diff --git a/hooks/lando-setup-orchestrator.js b/hooks/lando-setup-orchestrator.js index d4ce69ef9..1bb8b468e 100644 --- a/hooks/lando-setup-orchestrator.js +++ b/hooks/lando-setup-orchestrator.js @@ -1,5 +1,6 @@ 'use strict'; +const axios = require('../utils/get-axios')(); const fs = require('fs'); const path = require('path'); @@ -64,10 +65,9 @@ module.exports = async (lando, options) => { return !!orchestratorBin && typeof orchestrator === 'string' && fs.existsSync(dest); }, canRun: async () => { - const online = await require('is-online')(); - // throw error if not online - if (!online) throw new Error('Cannot detect connection to internet!'); - + // throw error if we cannot ping the download link + await axios.head(url); + // true if we get here return true; }, task: async (ctx, task) => new Promise((resolve, reject) => { diff --git a/lib/lando.js b/lib/lando.js index 865450efb..4ab2bed8a 100644 --- a/lib/lando.js +++ b/lib/lando.js @@ -273,6 +273,7 @@ module.exports = class Lando { // updater is more complex now this.updates = new UpdateManager({ + agent: this.config.userAgent, channel: this.config.channel, cli: _.get(this, 'config.cli'), config: getPluginConfig(this.config.pluginConfigFile, this.config.pluginConfig), diff --git a/lib/updates.js b/lib/updates.js index 9ea076fba..8ace61653 100644 --- a/lib/updates.js +++ b/lib/updates.js @@ -1,14 +1,15 @@ 'use strict'; +const axios = require('../utils/get-axios')(); const fs = require('fs'); const get = require('lodash/get'); +const getOctokit = require('../utils/get-octokit'); const os = require('os'); const path = require('path'); const semver = require('semver'); const uniqBy = require('lodash/uniqBy'); const {color} = require('listr2'); -const {Octokit} = require('@octokit/rest'); const getOS = () => { switch (process.platform) { @@ -32,6 +33,7 @@ const getPluginClass = ({channel, config, debug} = {}) => { module.exports = class UpdateManager { constructor({ + agent = 'Lando', config = {}, cli, channel = 'stable', @@ -40,6 +42,7 @@ module.exports = class UpdateManager { plugins = [], } = {}) { // set things + this.agent = agent; this._plugins = plugins; this.channel = channel; this.cli = cli; @@ -108,11 +111,7 @@ module.exports = class UpdateManager { checks.push(new Promise(async resolve => { // summon the katkraken - const octokit = new Octokit({auth: get(process, 'env.LANDO_GITHUB_TOKEN')}); - // check internet connection - const online = await require('is-online')(); - // throw error if not online - if (!online) throw new Error('Cannot detect connection to internet!'); + const octokit = getOctokit({auth: get(process, 'env.LANDO_GITHUB_TOKEN'), userAgent: this.agent}); // just a helper to give consistent prez const extra = color.dim('@lando/cli'); @@ -230,8 +229,8 @@ module.exports = class UpdateManager { throw new Error(`Lando cannot write to ${this._cli.installPath}!`); } - // throw error if not online - if (!await require('is-online')()) throw new Error('Cannot detect connection to internet!'); + // throw error if we cannot ping the download link + await axios.head(this._cli.update.download); // or true return true; @@ -320,7 +319,7 @@ module.exports = class UpdateManager { }); // summon the katkraken - const octokit = new Octokit({auth: get(process, 'env.LANDO_GITHUB_TOKEN')}); + const octokit = getOctokit({auth: get(process, 'env.LANDO_GITHUB_TOKEN'), userAgent: this.agent}); // get latest try { diff --git a/lib/utils.js b/lib/utils.js index e40766a3d..fc0aff969 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -110,6 +110,7 @@ module.exports = { debugShim: (...args) => require('../utils/debug-shim')(...args), downloadX: (...args) => require('../utils/download-x')(...args), getAxios: (...args) => require('../utils/get-axios')(...args), + getOctokit: (...args) => require('../utils/get-octokit')(...args), getUserShell: (...args) => require('../utils/get-user-shell')(...args), getUserShellProfile: (...args) => require('../utils/get-user-shell-profile')(...args), isVersionLte: (...args) => require('../utils/is-lte-version')(...args), diff --git a/package-lock.json b/package-lock.json index e11f388dc..bb2f5c74d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,6 @@ "is-class": "^0.0.9", "is-docker": "^2.2.1", "is-interactive": "^1", - "is-online": "^9", "is-root": "^2", "js-yaml": "^4.1.0", "jsonfile": "^2.4.0", @@ -1886,12 +1885,6 @@ "node": ">=12" } }, - "node_modules/@leichtgewicht/ip-codec": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz", - "integrity": "sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==", - "license": "MIT" - }, "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", @@ -3603,18 +3596,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/@sindresorhus/is": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", - "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/is?sponsor=1" - } - }, "node_modules/@sinonjs/commons": { "version": "1.8.6", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", @@ -3664,18 +3645,6 @@ "dev": true, "license": "(Unlicense OR Apache-2.0)" }, - "node_modules/@szmarczak/http-timer": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", - "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", - "license": "MIT", - "dependencies": { - "defer-to-connect": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@tootallnate/once": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", @@ -3707,18 +3676,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/@types/cacheable-request": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", - "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", - "license": "MIT", - "dependencies": { - "@types/http-cache-semantics": "*", - "@types/keyv": "^3.1.4", - "@types/node": "*", - "@types/responselike": "^1.0.0" - } - }, "node_modules/@types/cli-progress": { "version": "3.11.6", "resolved": "https://registry.npmjs.org/@types/cli-progress/-/cli-progress-3.11.6.tgz", @@ -3745,21 +3702,6 @@ "@types/unist": "*" } }, - "node_modules/@types/http-cache-semantics": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", - "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==", - "license": "MIT" - }, - "node_modules/@types/keyv": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", - "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", @@ -3825,15 +3767,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/responselike": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", - "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -4976,33 +4909,6 @@ "node": ">=12" } }, - "node_modules/cacheable-lookup": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", - "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", - "license": "MIT", - "engines": { - "node": ">=10.6.0" - } - }, - "node_modules/cacheable-request": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", - "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", - "license": "MIT", - "dependencies": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^4.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^6.0.1", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -5471,18 +5377,6 @@ "node": ">=0.8" } }, - "node_modules/clone-response": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", - "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", - "license": "MIT", - "dependencies": { - "mimic-response": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/cmd-shim": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.3.tgz", @@ -5834,6 +5728,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, "license": "MIT", "dependencies": { "mimic-response": "^3.1.0" @@ -5849,6 +5744,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -5903,15 +5799,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/defer-to-connect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/delay": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", @@ -6011,30 +5898,6 @@ "node": ">=8" } }, - "node_modules/dns-packet": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", - "integrity": "sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==", - "license": "MIT", - "dependencies": { - "@leichtgewicht/ip-codec": "^2.0.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/dns-socket": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/dns-socket/-/dns-socket-4.2.2.tgz", - "integrity": "sha512-BDeBd8najI4/lS00HSKpdFia+OvUMytaVjfzR9n5Lq8MlZRSvtbI+uLtx1+XmQFls5wFU9dssccTmQQ6nfpjdg==", - "license": "MIT", - "dependencies": { - "dns-packet": "^5.2.4" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/docker-modem": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/docker-modem/-/docker-modem-1.0.9.tgz", @@ -6289,12 +6152,6 @@ "dottojs": "bin/dot-packer" } }, - "node_modules/duplexer3": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.5.tgz", - "integrity": "sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA==", - "license": "BSD-3-Clause" - }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -7441,21 +7298,6 @@ "node": ">=8.0.0" } }, - "node_modules/get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "license": "MIT", - "dependencies": { - "pump": "^3.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", @@ -7557,31 +7399,6 @@ "node": ">= 4" } }, - "node_modules/got": { - "version": "11.8.6", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", - "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", - "license": "MIT", - "dependencies": { - "@sindresorhus/is": "^4.0.0", - "@szmarczak/http-timer": "^4.0.5", - "@types/cacheable-request": "^6.0.1", - "@types/responselike": "^1.0.0", - "cacheable-lookup": "^5.0.3", - "cacheable-request": "^7.0.2", - "decompress-response": "^6.0.0", - "http2-wrapper": "^1.0.0-beta.5.2", - "lowercase-keys": "^2.0.0", - "p-cancelable": "^2.0.0", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=10.19.0" - }, - "funding": { - "url": "https://github.com/sindresorhus/got?sponsor=1" - } - }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -7824,19 +7641,6 @@ "node": ">= 6" } }, - "node_modules/http2-wrapper": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", - "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", - "license": "MIT", - "dependencies": { - "quick-lru": "^5.1.1", - "resolve-alpn": "^1.0.0" - }, - "engines": { - "node": ">=10.19.0" - } - }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -8247,6 +8051,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz", "integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -8363,18 +8168,6 @@ "node": ">=8" } }, - "node_modules/is-ip": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-ip/-/is-ip-3.1.0.tgz", - "integrity": "sha512-35vd5necO7IitFPjd/YBeqwWnyDWbuLH9ZXQdMfDA8TEo7pv5X8yfrvVO3xbJbLUlERCMvf6X0hTUamQxCYJ9Q==", - "license": "MIT", - "dependencies": { - "ip-regex": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-lambda": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", @@ -8390,24 +8183,6 @@ "node": ">=0.12.0" } }, - "node_modules/is-online": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/is-online/-/is-online-9.0.1.tgz", - "integrity": "sha512-+08dRW0dcFOtleR2N3rHRVxDyZtQitUp9cC+KpKTds0mXibbQyW5js7xX0UGyQXkaLUJObe0w6uQ4ex34lX9LA==", - "license": "MIT", - "dependencies": { - "got": "^11.8.0", - "p-any": "^3.0.0", - "p-timeout": "^3.2.0", - "public-ip": "^4.0.4" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -8789,6 +8564,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, "license": "MIT" }, "node_modules/json-parse-even-better-errors": { @@ -8902,6 +8678,7 @@ "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, "license": "MIT", "dependencies": { "json-buffer": "3.0.1" @@ -9371,15 +9148,6 @@ "get-func-name": "^2.0.1" } }, - "node_modules/lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -10012,15 +9780,6 @@ "node": ">=4" } }, - "node_modules/mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -10993,18 +10752,6 @@ "node": ">=0.10.0" } }, - "node_modules/normalize-url": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", - "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/npm-bundled": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-3.0.1.tgz", @@ -11633,40 +11380,6 @@ "node": ">=0.10.0" } }, - "node_modules/p-any": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-any/-/p-any-3.0.0.tgz", - "integrity": "sha512-5rqbqfsRWNb0sukt0awwgJMlaep+8jV45S15SKKB34z4UuzjcofIfnriCBhWjZP2jbVtjt9yRl7buB6RlKsu9w==", - "license": "MIT", - "dependencies": { - "p-cancelable": "^2.0.0", - "p-some": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-cancelable": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", - "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/p-is-promise": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-3.0.0.tgz", @@ -11724,34 +11437,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-some": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-some/-/p-some-5.0.0.tgz", - "integrity": "sha512-Js5XZxo6vHjB9NOYAzWDYAIyyiPvva0DWESAIWIK7uhSpGsyg5FwUPxipU/SOQx5x9EqhOh545d1jo6cVkitig==", - "license": "MIT", - "dependencies": { - "aggregate-error": "^3.0.0", - "p-cancelable": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-timeout": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", - "integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==", - "license": "MIT", - "dependencies": { - "p-finally": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -12196,15 +11881,6 @@ "node": ">= 0.8.0" } }, - "node_modules/prepend-http": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", - "integrity": "sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/proc-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", @@ -12297,178 +11973,11 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "license": "MIT" }, - "node_modules/public-ip": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/public-ip/-/public-ip-4.0.4.tgz", - "integrity": "sha512-EJ0VMV2vF6Cu7BIPo3IMW1Maq6ME+fbR0NcPmqDfpfNGIRPue1X8QrGjrg/rfjDkOsIkKHIf2S5FlEa48hFMTA==", - "license": "MIT", - "dependencies": { - "dns-socket": "^4.2.2", - "got": "^9.6.0", - "is-ip": "^3.1.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/public-ip/node_modules/@sindresorhus/is": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", - "integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/public-ip/node_modules/@szmarczak/http-timer": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz", - "integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==", - "license": "MIT", - "dependencies": { - "defer-to-connect": "^1.0.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/public-ip/node_modules/cacheable-request": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", - "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", - "license": "MIT", - "dependencies": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^3.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^4.1.0", - "responselike": "^1.0.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/public-ip/node_modules/decompress-response": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", - "integrity": "sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA==", - "license": "MIT", - "dependencies": { - "mimic-response": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/public-ip/node_modules/defer-to-connect": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.3.tgz", - "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", - "license": "MIT" - }, - "node_modules/public-ip/node_modules/got": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", - "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", - "license": "MIT", - "dependencies": { - "@sindresorhus/is": "^0.14.0", - "@szmarczak/http-timer": "^1.1.2", - "cacheable-request": "^6.0.0", - "decompress-response": "^3.3.0", - "duplexer3": "^0.1.4", - "get-stream": "^4.1.0", - "lowercase-keys": "^1.0.1", - "mimic-response": "^1.0.1", - "p-cancelable": "^1.0.0", - "to-readable-stream": "^1.0.0", - "url-parse-lax": "^3.0.0" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/public-ip/node_modules/got/node_modules/get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "license": "MIT", - "dependencies": { - "pump": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/public-ip/node_modules/got/node_modules/lowercase-keys": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/public-ip/node_modules/json-buffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", - "integrity": "sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ==", - "license": "MIT" - }, - "node_modules/public-ip/node_modules/keyv": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", - "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", - "license": "MIT", - "dependencies": { - "json-buffer": "3.0.0" - } - }, - "node_modules/public-ip/node_modules/normalize-url": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", - "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/public-ip/node_modules/p-cancelable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", - "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/public-ip/node_modules/responselike": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", - "integrity": "sha512-/Fpe5guzJk1gPqdJLJR5u7eG/gNY4nImjbRDaVWVMRhne55TCmj2i9Q+54PBRfatRC8v/rIiv9BN0pMd9OV5EQ==", - "license": "MIT", - "dependencies": { - "lowercase-keys": "^1.0.0" - } - }, - "node_modules/public-ip/node_modules/responselike/node_modules/lowercase-keys": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/pump": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", + "dev": true, "license": "MIT", "dependencies": { "end-of-stream": "^1.1.0", @@ -12505,18 +12014,6 @@ ], "license": "MIT" }, - "node_modules/quick-lru": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", - "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -12917,12 +12414,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-alpn": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", - "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", - "license": "MIT" - }, "node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", @@ -12933,18 +12424,6 @@ "node": ">=8" } }, - "node_modules/responselike": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", - "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", - "license": "MIT", - "dependencies": { - "lowercase-keys": "^2.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -14348,15 +13827,6 @@ "node": ">=4" } }, - "node_modules/to-readable-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", - "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -14728,18 +14198,6 @@ "punycode": "^2.1.0" } }, - "node_modules/url-parse-lax": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", - "integrity": "sha512-NjFKA0DidqPa5ciFcSrXnAltTtzz84ogy+NebPvfEgAck0+TNg4UJ4IN+fB7zRZfbgUf0syOo9MDxFkDSMuFaQ==", - "license": "MIT", - "dependencies": { - "prepend-http": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 7f54e8f3f..eb577ce3e 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,6 @@ "is-class": "^0.0.9", "is-docker": "^2.2.1", "is-interactive": "^1", - "is-online": "^9", "is-root": "^2", "js-yaml": "^4.1.0", "jsonfile": "^2.4.0", diff --git a/sources/github.js b/sources/github.js index 6bd217957..7195d41ff 100644 --- a/sources/github.js +++ b/sources/github.js @@ -6,8 +6,6 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); -const {Octokit} = require('@octokit/rest'); - // Github const githubTokenCache = 'github.tokens'; const gitHubLandoKey = 'github.lando.id_rsa'; @@ -31,7 +29,7 @@ const parseTokens = tokens => _.flatten([getTokens(tokens), [{name: 'add or refr // Helper to post a github ssh key const postKey = (keyDir, token, id) => { - const octokit = new Octokit({auth: token}); + const octokit = require('../utils/get-octokit')({auth: token}); return octokit.users.createPublicSshKeyForAuthenticatedUser({ title: id, key: _.trim(fs.readFileSync(path.join(keyDir, `${gitHubLandoKey}.pub`), 'utf8')), @@ -52,7 +50,7 @@ const postKey = (keyDir, token, id) => { // Helper to set caches const setCaches = (options, lando) => { - const octokit = new Octokit({auth: options['github-auth']}); + const octokit = require('../utils/get-octokit')({auth: options['github-auth']}); return octokit.rest.users.getAuthenticated() .then(user => { const metaData = lando.cache.get(`${options.name}.meta.cache`) || {}; @@ -74,7 +72,7 @@ const showTokenEntry = (source, answer, tkez = []) => ((_.isEmpty(tkez) || answe const getRepos = answers => { // Log console.log('Getting your GitHub repos... this may take a moment if you have a lot'); - const octokit = new Octokit({auth: answers['github-auth']}); + const octokit = require('../utils/get-octokit')({auth: answers['github-auth']}); return octokit.paginate('GET /user/repos', {affliation: 'owner,collaborator,organization_member', per_page: 100}) .then(results => results.map(result => ({name: result.full_name, value: result.ssh_url}))) .catch(gerror => { diff --git a/utils/get-octokit.js b/utils/get-octokit.js new file mode 100644 index 000000000..35e01f739 --- /dev/null +++ b/utils/get-octokit.js @@ -0,0 +1,14 @@ +'use strict'; + +const {Octokit} = require('@octokit/rest'); + +const {HttpsAgent} = require('@npmcli/agent'); + +const defaults = { + userAgent: 'Lando/unknown', + request: { + agent: new HttpsAgent({family: 4}), + }, +}; + +module.exports = (options = {}) => new Octokit({...defaults, ...options}); diff --git a/utils/get-plugin-add-task.js b/utils/get-plugin-add-task.js index c26990a84..ce3ca3624 100644 --- a/utils/get-plugin-add-task.js +++ b/utils/get-plugin-add-task.js @@ -26,11 +26,8 @@ module.exports = (plugin, { } }, canInstall: async () => { - const online = await require('is-online')(); - // throw error if not online - if (!online) throw new Error('Cannot detect connection to internet!'); - // attempt ti get info on the plugin await Plugin.info(plugin); + return true; }, task: async (ctx, task) => { try { diff --git a/utils/get-plugin-update-task.js b/utils/get-plugin-update-task.js index 1173290cb..78df89603 100644 --- a/utils/get-plugin-update-task.js +++ b/utils/get-plugin-update-task.js @@ -14,10 +14,7 @@ module.exports = (plugin, { title: `Updating ${pkg.name} to v${pkg.peg}`, description: pkg.name, canInstall: async () => { - const online = await require('is-online')(); - // throw error if not online - if (!online) throw new Error('Cannot detect connection to internet!'); - // or true + await Plugin.info(plugin); return true; }, task: async (ctx, task) => {