@electron/get
Advanced tools
Comparing version 2.0.3 to 3.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getArtifactVersion = exports.getArtifactRemoteURL = exports.getArtifactFileName = void 0; | ||
const utils_1 = require("./utils"); | ||
@@ -7,9 +8,9 @@ const BASE_URL = 'https://github.com/electron/electron/releases/download/'; | ||
function getArtifactFileName(details) { | ||
utils_1.ensureIsTruthyString(details, 'artifactName'); | ||
(0, utils_1.ensureIsTruthyString)(details, 'artifactName'); | ||
if (details.isGeneric) { | ||
return details.artifactName; | ||
} | ||
utils_1.ensureIsTruthyString(details, 'arch'); | ||
utils_1.ensureIsTruthyString(details, 'platform'); | ||
utils_1.ensureIsTruthyString(details, 'version'); | ||
(0, utils_1.ensureIsTruthyString)(details, 'arch'); | ||
(0, utils_1.ensureIsTruthyString)(details, 'platform'); | ||
(0, utils_1.ensureIsTruthyString)(details, 'version'); | ||
return `${[ | ||
@@ -64,5 +65,5 @@ details.artifactName, | ||
function getArtifactVersion(details) { | ||
return utils_1.normalizeVersion(mirrorVar('customVersion', details.mirrorOptions || {}, details.version)); | ||
return (0, utils_1.normalizeVersion)(mirrorVar('customVersion', details.mirrorOptions || {}, details.version)); | ||
} | ||
exports.getArtifactVersion = getArtifactVersion; | ||
//# sourceMappingURL=artifact-utils.js.map |
@@ -14,2 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Cache = void 0; | ||
const debug_1 = require("debug"); | ||
@@ -21,4 +22,4 @@ const env_paths_1 = require("env-paths"); | ||
const crypto = require("crypto"); | ||
const d = debug_1.default('@electron/get:cache'); | ||
const defaultCacheRoot = env_paths_1.default('electron', { | ||
const d = (0, debug_1.default)('@electron/get:cache'); | ||
const defaultCacheRoot = (0, env_paths_1.default)('electron', { | ||
suffix: '', | ||
@@ -25,0 +26,0 @@ }).cache; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDownloaderForSystem = void 0; | ||
async function getDownloaderForSystem() { | ||
@@ -4,0 +5,0 @@ // TODO: Resolve the downloader or default to GotDownloader |
@@ -6,3 +6,3 @@ import { Progress as GotProgress, Options as GotOptions } from 'got'; | ||
*/ | ||
export declare type GotDownloaderOptions = (GotOptions & { | ||
export type GotDownloaderOptions = (GotOptions & { | ||
isStream?: true; | ||
@@ -9,0 +9,0 @@ }) & { |
@@ -14,2 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GotDownloader = void 0; | ||
const fs = require("fs-extra"); | ||
@@ -16,0 +17,0 @@ const got_1 = require("got"); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.download = exports.downloadArtifact = exports.initializeProxy = exports.getHostArch = void 0; | ||
const debug_1 = require("debug"); | ||
@@ -14,11 +29,12 @@ const fs = require("fs-extra"); | ||
var utils_2 = require("./utils"); | ||
exports.getHostArch = utils_2.getHostArch; | ||
Object.defineProperty(exports, "getHostArch", { enumerable: true, get: function () { return utils_2.getHostArch; } }); | ||
var proxy_2 = require("./proxy"); | ||
exports.initializeProxy = proxy_2.initializeProxy; | ||
const d = debug_1.default('@electron/get:index'); | ||
Object.defineProperty(exports, "initializeProxy", { enumerable: true, get: function () { return proxy_2.initializeProxy; } }); | ||
__exportStar(require("./types"), exports); | ||
const d = (0, debug_1.default)('@electron/get:index'); | ||
if (process.env.ELECTRON_GET_USE_PROXY) { | ||
proxy_1.initializeProxy(); | ||
(0, proxy_1.initializeProxy)(); | ||
} | ||
async function validateArtifact(artifactDetails, downloadedAssetPath, _downloadArtifact) { | ||
return await utils_1.withTempDirectoryIn(artifactDetails.tempDirectory, async (tempFolder) => { | ||
return await (0, utils_1.withTempDirectoryIn)(artifactDetails.tempDirectory, async (tempFolder) => { | ||
// Don't try to verify the hash of the hash file itself | ||
@@ -85,13 +101,13 @@ // and for older versions that don't have a SHASUMS256.txt | ||
if (platformArtifactDetails.arch) { | ||
platformArtifactDetails.arch = utils_1.getNodeArch(platformArtifactDetails.arch); | ||
platformArtifactDetails.arch = (0, utils_1.getNodeArch)(platformArtifactDetails.arch); | ||
} | ||
else { | ||
d('No arch found, defaulting to the host arch'); | ||
platformArtifactDetails.arch = utils_1.getHostArch(); | ||
platformArtifactDetails.arch = (0, utils_1.getHostArch)(); | ||
} | ||
} | ||
utils_1.ensureIsTruthyString(artifactDetails, 'version'); | ||
artifactDetails.version = artifact_utils_1.getArtifactVersion(artifactDetails); | ||
const fileName = artifact_utils_1.getArtifactFileName(artifactDetails); | ||
const url = await artifact_utils_1.getArtifactRemoteURL(artifactDetails); | ||
(0, utils_1.ensureIsTruthyString)(artifactDetails, 'version'); | ||
artifactDetails.version = (0, artifact_utils_1.getArtifactVersion)(artifactDetails); | ||
const fileName = (0, artifact_utils_1.getArtifactFileName)(artifactDetails); | ||
const url = await (0, artifact_utils_1.getArtifactRemoteURL)(artifactDetails); | ||
const cache = new Cache_1.Cache(artifactDetails.cacheRoot); | ||
@@ -118,9 +134,9 @@ // Do not check if the file exists in the cache when force === true | ||
if (!artifactDetails.isGeneric && | ||
utils_1.isOfficialLinuxIA32Download(artifactDetails.platform, artifactDetails.arch, artifactDetails.version, artifactDetails.mirrorOptions)) { | ||
(0, utils_1.isOfficialLinuxIA32Download)(artifactDetails.platform, artifactDetails.arch, artifactDetails.version, artifactDetails.mirrorOptions)) { | ||
console.warn('Official Linux/ia32 support is deprecated.'); | ||
console.warn('For more info: https://electronjs.org/blog/linux-32bit-support'); | ||
} | ||
return await utils_1.withTempDirectoryIn(artifactDetails.tempDirectory, async (tempFolder) => { | ||
const tempDownloadPath = path.resolve(tempFolder, artifact_utils_1.getArtifactFileName(artifactDetails)); | ||
const downloader = artifactDetails.downloader || (await downloader_resolver_1.getDownloaderForSystem()); | ||
return await (0, utils_1.withTempDirectoryIn)(artifactDetails.tempDirectory, async (tempFolder) => { | ||
const tempDownloadPath = path.resolve(tempFolder, (0, artifact_utils_1.getArtifactFileName)(artifactDetails)); | ||
const downloader = artifactDetails.downloader || (await (0, downloader_resolver_1.getDownloaderForSystem)()); | ||
d(`Downloading ${url} to ${tempDownloadPath} with options: ${JSON.stringify(artifactDetails.downloadOptions)}`); | ||
@@ -127,0 +143,0 @@ await downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initializeProxy = void 0; | ||
const debug = require("debug"); | ||
@@ -12,6 +13,6 @@ const utils_1 = require("./utils"); | ||
// See: https://github.com/electron/get/pull/214#discussion_r798845713 | ||
const env = utils_1.getEnv('GLOBAL_AGENT_'); | ||
utils_1.setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY')); | ||
utils_1.setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY')); | ||
utils_1.setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY')); | ||
const env = (0, utils_1.getEnv)('GLOBAL_AGENT_'); | ||
(0, utils_1.setEnv)('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY')); | ||
(0, utils_1.setEnv)('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY')); | ||
(0, utils_1.setEnv)('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY')); | ||
/** | ||
@@ -18,0 +19,0 @@ * TODO: replace global-agent with a hpagent. @BlackHole1 |
import { Downloader } from './Downloader'; | ||
export declare type DownloadOptions = any; | ||
export { Downloader }; | ||
export type DownloadOptions = any; | ||
export interface MirrorOptions { | ||
@@ -93,4 +94,4 @@ /** | ||
/** | ||
* The custom [[Downloader]] class used to download artifacts. Defaults to the | ||
* built-in [[GotDownloader]]. | ||
* The custom {@link Downloader} class used to download artifacts. Defaults to the | ||
* built-in {@link GotDownloader}. | ||
*/ | ||
@@ -104,3 +105,3 @@ downloader?: Downloader<DownloadOptions>; | ||
} | ||
export declare type ElectronPlatformArtifactDetails = { | ||
export type ElectronPlatformArtifactDetails = { | ||
/** | ||
@@ -123,10 +124,10 @@ * The target artifact platform. These are Node-style platform names, for example: | ||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions; | ||
export declare type ElectronGenericArtifactDetails = { | ||
export type ElectronGenericArtifactDetails = { | ||
isGeneric: true; | ||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions; | ||
export declare type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails; | ||
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
export declare type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & { | ||
export type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails; | ||
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
export type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & { | ||
platform?: string; | ||
arch?: string; | ||
}) | ElectronGenericArtifactDetails; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setEnv = exports.getEnv = exports.isOfficialLinuxIA32Download = exports.ensureIsTruthyString = exports.getHostArch = exports.getNodeArch = exports.uname = exports.normalizeVersion = exports.withTempDirectory = exports.withTempDirectoryIn = void 0; | ||
const childProcess = require("child_process"); | ||
@@ -72,3 +73,3 @@ const fs = require("fs-extra"); | ||
if (!obj[key] || typeof obj[key] !== 'string') { | ||
throw new Error(`Expected property "${key}" to be provided as a string but it was not`); | ||
throw new Error(`Expected property "${String(key)}" to be provided as a string but it was not`); | ||
} | ||
@@ -75,0 +76,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=Downloader.js.map |
@@ -6,3 +6,3 @@ import { Progress as GotProgress, Options as GotOptions } from 'got'; | ||
*/ | ||
export declare type GotDownloaderOptions = (GotOptions & { | ||
export type GotDownloaderOptions = (GotOptions & { | ||
isStream?: true; | ||
@@ -9,0 +9,0 @@ }) & { |
@@ -13,2 +13,3 @@ import debug from 'debug'; | ||
export { initializeProxy } from './proxy'; | ||
export * from './types'; | ||
const d = debug('@electron/get:index'); | ||
@@ -15,0 +16,0 @@ if (process.env.ELECTRON_GET_USE_PROXY) { |
import { Downloader } from './Downloader'; | ||
export declare type DownloadOptions = any; | ||
export { Downloader }; | ||
export type DownloadOptions = any; | ||
export interface MirrorOptions { | ||
@@ -93,4 +94,4 @@ /** | ||
/** | ||
* The custom [[Downloader]] class used to download artifacts. Defaults to the | ||
* built-in [[GotDownloader]]. | ||
* The custom {@link Downloader} class used to download artifacts. Defaults to the | ||
* built-in {@link GotDownloader}. | ||
*/ | ||
@@ -104,3 +105,3 @@ downloader?: Downloader<DownloadOptions>; | ||
} | ||
export declare type ElectronPlatformArtifactDetails = { | ||
export type ElectronPlatformArtifactDetails = { | ||
/** | ||
@@ -123,10 +124,10 @@ * The target artifact platform. These are Node-style platform names, for example: | ||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions; | ||
export declare type ElectronGenericArtifactDetails = { | ||
export type ElectronGenericArtifactDetails = { | ||
isGeneric: true; | ||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions; | ||
export declare type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails; | ||
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
export declare type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & { | ||
export type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails; | ||
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
export type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & { | ||
platform?: string; | ||
arch?: string; | ||
}) | ElectronGenericArtifactDetails; |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -64,3 +64,3 @@ import * as childProcess from 'child_process'; | ||
if (!obj[key] || typeof obj[key] !== 'string') { | ||
throw new Error(`Expected property "${key}" to be provided as a string but it was not`); | ||
throw new Error(`Expected property "${String(key)}" to be provided as a string but it was not`); | ||
} | ||
@@ -67,0 +67,0 @@ } |
{ | ||
"name": "@electron/get", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Utility for downloading artifacts from different versions of Electron", | ||
@@ -12,3 +12,3 @@ "main": "dist/cjs/index.js", | ||
"build": "tsc && tsc -p tsconfig.esm.json", | ||
"build:docs": "typedoc --out docs", | ||
"build:docs": "typedoc --out docs src/index.ts", | ||
"eslint": "eslint --ext .ts src test", | ||
@@ -23,7 +23,7 @@ "jest": "jest --coverage", | ||
"files": [ | ||
"dist/*", | ||
"dist/", | ||
"README.md" | ||
], | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=14" | ||
}, | ||
@@ -43,3 +43,3 @@ "dependencies": { | ||
"@types/fs-extra": "^8.0.0", | ||
"@types/jest": "^24.0.13", | ||
"@types/jest": "^29.0.0", | ||
"@types/node": "^12.20.55", | ||
@@ -55,8 +55,8 @@ "@types/progress": "^2.0.3", | ||
"husky": "^2.3.0", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^8.1.7", | ||
"jest": "^29.3.1", | ||
"lint-staged": "^13.0.4", | ||
"prettier": "^1.17.1", | ||
"ts-jest": "^24.0.0", | ||
"typedoc": "^0.17.2", | ||
"typescript": "^3.8.0" | ||
"ts-jest": "^29.0.0", | ||
"typedoc": "^0.23.21", | ||
"typescript": "^4.9.3" | ||
}, | ||
@@ -85,4 +85,3 @@ "eslintConfig": { | ||
"eslint --fix", | ||
"prettier --write", | ||
"git add" | ||
"prettier --write" | ||
] | ||
@@ -89,0 +88,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95542
1388