Socket
Socket
Sign inDemoInstall

@electron/get

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@electron/get - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

dist/cjs/Cache.d.ts
export declare class Cache {
private cacheRoot;
constructor(cacheRoot?: any);
constructor(cacheRoot?: string);
private getCachePath;

@@ -5,0 +5,0 @@ getPathForFileInCache(fileName: string): Promise<string | null>;

@@ -38,5 +38,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var debug_1 = require("debug");
var env_paths_1 = require("env-paths");
var fs = require("fs-extra");
var path = require("path");
var d = debug_1.default('@electron/get:cache');
var defaultCacheRoot = env_paths_1.default('electron', {

@@ -77,5 +79,7 @@ suffix: '',

cachePath = this.getCachePath(fileName);
d("Moving " + currentPath + " to " + cachePath);
return [4 /*yield*/, fs.pathExists(cachePath)];
case 1:
if (!_a.sent()) return [3 /*break*/, 3];
d('* Replacing existing file');
return [4 /*yield*/, fs.remove(cachePath)];

@@ -82,0 +86,0 @@ case 2:

import { Downloader } from './Downloader';
export declare class GotDownloader implements Downloader<any> {
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
download(url: string, targetFilePath: string, options?: any): Promise<void>;
}

@@ -44,2 +44,5 @@ "use strict";

}
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
GotDownloader.prototype.download = function (url, targetFilePath, options) {

@@ -46,0 +49,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -7,3 +7,3 @@ import { ElectronArtifactDetails, ElectronDownloadRequestOptions } from './types';

*
* @param version The version of Electron you want to download
* @param version - The version of Electron you want to download
*/

@@ -15,4 +15,4 @@ export declare function download(version: string, options?: ElectronDownloadRequestOptions): Promise<string>;

*
* @param artifactDetails The information required to download the artifact
* @param artifactDetails - The information required to download the artifact
*/
export declare function downloadArtifact(_artifactDetails: ElectronArtifactDetails): Promise<string>;

@@ -49,2 +49,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var debug_1 = require("debug");
var path = require("path");

@@ -57,2 +58,3 @@ var artifact_utils_1 = require("./artifact-utils");

exports.getHostArch = utils_2.getHostArch;
var d = debug_1.default('@electron/get:index');
var sumchecker = require('sumchecker');

@@ -63,3 +65,3 @@ /**

*
* @param version The version of Electron you want to download
* @param version - The version of Electron you want to download
*/

@@ -74,3 +76,3 @@ function download(version, options) {

*
* @param artifactDetails The information required to download the artifact
* @param artifactDetails - The information required to download the artifact
*/

@@ -90,6 +92,11 @@ function downloadArtifact(_artifactDetails) {

if (!!artifactDetails.force) return [3 /*break*/, 2];
d("Checking the cache for " + fileName);
return [4 /*yield*/, cache.getPathForFileInCache(fileName)];
case 1:
cachedPath = _a.sent();
if (cachedPath !== null) {
if (cachedPath === null) {
d('Cache miss');
}
else {
d('Cache hit');
return [2 /*return*/, cachedPath];

@@ -99,3 +106,3 @@ }

case 2: return [4 /*yield*/, utils_1.withTempDirectory(function (tempFolder) { return __awaiter(_this, void 0, void 0, function () {
var tempDownloadPath, downloader, _a, shasumPath;
var tempDownloadPath, downloader, _a, url, shasumPath;
return __generator(this, function (_b) {

@@ -113,3 +120,5 @@ switch (_b.label) {

downloader = _a;
return [4 /*yield*/, downloader.download(artifact_utils_1.getArtifactRemoteURL(artifactDetails), tempDownloadPath, artifactDetails.downloadOptions)];
url = artifact_utils_1.getArtifactRemoteURL(artifactDetails);
d("Downloading " + url + " to " + tempDownloadPath + " with options: " + JSON.stringify(artifactDetails.downloadOptions));
return [4 /*yield*/, downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions)];
case 3:

@@ -116,0 +125,0 @@ _b.sent();

import { Downloader } from './Downloader';
export interface MirrorOptions {
/**
* The Electron nightly-specific mirror URL.
*/
nightly_mirror?: string;

@@ -9,15 +12,65 @@ mirror?: string;

export interface ElectronDownloadRequest {
/**
* The version of Electron associated with the artifact.
*/
version: string;
/**
* The type of artifact. For example:
* * `electron`
* * `ffmpeg`
*/
artifactName: string;
}
export interface ElectronDownloadRequestOptions {
/**
* Whether to download an artifact regardless of whether it's in the cache directory.
*
* Defaults to `false`.
*/
force?: boolean;
/**
* When set to `true`, disables checking that the artifact download completed successfully
* with the correct payload.
*
* Defaults to `false`.
*/
unsafelyDisableChecksums?: boolean;
/**
* The directory that caches Electron artifact downloads.
*
* The default value is dependent upon the host platform:
*
* * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
* * MacOS: `~/Library/Caches/electron/`
* * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
*/
cacheRoot?: string;
/**
* Options passed to the downloader module.
*/
downloadOptions?: DownloadOptions;
/**
* Options related to specifying an artifact mirror.
*/
mirrorOptions?: MirrorOptions;
/**
* The custom [[Downloader]] class used to download artifacts. Defaults to the
* built-in [[GotDownloader]].
*/
downloader?: Downloader<any>;
}
export declare type ElectronPlatformArtifactDetails = {
/**
* The target artifact platform. These are Node-style platform names, for example:
* * `win32`
* * `darwin`
* * `linux`
*/
platform: string;
/**
* The target artifact architecture. These are Node-style architecture names, for example:
* * `ia32`
* * `x64`
* * `armv7l`
*/
arch: string;

@@ -24,0 +77,0 @@ artifactSuffix?: string;

export declare class Cache {
private cacheRoot;
constructor(cacheRoot?: any);
constructor(cacheRoot?: string);
private getCachePath;

@@ -5,0 +5,0 @@ getPathForFileInCache(fileName: string): Promise<string | null>;

@@ -36,5 +36,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import debug from 'debug';
import envPaths from 'env-paths';
import * as fs from 'fs-extra';
import * as path from 'path';
var d = debug('@electron/get:cache');
var defaultCacheRoot = envPaths('electron', {

@@ -75,5 +77,7 @@ suffix: '',

cachePath = this.getCachePath(fileName);
d("Moving " + currentPath + " to " + cachePath);
return [4 /*yield*/, fs.pathExists(cachePath)];
case 1:
if (!_a.sent()) return [3 /*break*/, 3];
d('* Replacing existing file');
return [4 /*yield*/, fs.remove(cachePath)];

@@ -80,0 +84,0 @@ case 2:

import { Downloader } from './Downloader';
export declare class GotDownloader implements Downloader<any> {
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
download(url: string, targetFilePath: string, options?: any): Promise<void>;
}

@@ -42,2 +42,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
GotDownloader.prototype.download = function (url, targetFilePath, options) {

@@ -44,0 +47,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -7,3 +7,3 @@ import { ElectronArtifactDetails, ElectronDownloadRequestOptions } from './types';

*
* @param version The version of Electron you want to download
* @param version - The version of Electron you want to download
*/

@@ -15,4 +15,4 @@ export declare function download(version: string, options?: ElectronDownloadRequestOptions): Promise<string>;

*
* @param artifactDetails The information required to download the artifact
* @param artifactDetails - The information required to download the artifact
*/
export declare function downloadArtifact(_artifactDetails: ElectronArtifactDetails): Promise<string>;

@@ -47,2 +47,3 @@ var __assign = (this && this.__assign) || function () {

};
import debug from 'debug';
import * as path from 'path';

@@ -54,2 +55,3 @@ import { getArtifactFileName, getArtifactRemoteURL, FileNameUse } from './artifact-utils';

export { getHostArch } from './utils';
var d = debug('@electron/get:index');
var sumchecker = require('sumchecker');

@@ -60,3 +62,3 @@ /**

*
* @param version The version of Electron you want to download
* @param version - The version of Electron you want to download
*/

@@ -70,3 +72,3 @@ export function download(version, options) {

*
* @param artifactDetails The information required to download the artifact
* @param artifactDetails - The information required to download the artifact
*/

@@ -86,6 +88,11 @@ export function downloadArtifact(_artifactDetails) {

if (!!artifactDetails.force) return [3 /*break*/, 2];
d("Checking the cache for " + fileName);
return [4 /*yield*/, cache.getPathForFileInCache(fileName)];
case 1:
cachedPath = _a.sent();
if (cachedPath !== null) {
if (cachedPath === null) {
d('Cache miss');
}
else {
d('Cache hit');
return [2 /*return*/, cachedPath];

@@ -95,3 +102,3 @@ }

case 2: return [4 /*yield*/, withTempDirectory(function (tempFolder) { return __awaiter(_this, void 0, void 0, function () {
var tempDownloadPath, downloader, _a, shasumPath;
var tempDownloadPath, downloader, _a, url, shasumPath;
return __generator(this, function (_b) {

@@ -109,3 +116,5 @@ switch (_b.label) {

downloader = _a;
return [4 /*yield*/, downloader.download(getArtifactRemoteURL(artifactDetails), tempDownloadPath, artifactDetails.downloadOptions)];
url = getArtifactRemoteURL(artifactDetails);
d("Downloading " + url + " to " + tempDownloadPath + " with options: " + JSON.stringify(artifactDetails.downloadOptions));
return [4 /*yield*/, downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions)];
case 3:

@@ -112,0 +121,0 @@ _b.sent();

import { Downloader } from './Downloader';
export interface MirrorOptions {
/**
* The Electron nightly-specific mirror URL.
*/
nightly_mirror?: string;

@@ -9,15 +12,65 @@ mirror?: string;

export interface ElectronDownloadRequest {
/**
* The version of Electron associated with the artifact.
*/
version: string;
/**
* The type of artifact. For example:
* * `electron`
* * `ffmpeg`
*/
artifactName: string;
}
export interface ElectronDownloadRequestOptions {
/**
* Whether to download an artifact regardless of whether it's in the cache directory.
*
* Defaults to `false`.
*/
force?: boolean;
/**
* When set to `true`, disables checking that the artifact download completed successfully
* with the correct payload.
*
* Defaults to `false`.
*/
unsafelyDisableChecksums?: boolean;
/**
* The directory that caches Electron artifact downloads.
*
* The default value is dependent upon the host platform:
*
* * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
* * MacOS: `~/Library/Caches/electron/`
* * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
*/
cacheRoot?: string;
/**
* Options passed to the downloader module.
*/
downloadOptions?: DownloadOptions;
/**
* Options related to specifying an artifact mirror.
*/
mirrorOptions?: MirrorOptions;
/**
* The custom [[Downloader]] class used to download artifacts. Defaults to the
* built-in [[GotDownloader]].
*/
downloader?: Downloader<any>;
}
export declare type ElectronPlatformArtifactDetails = {
/**
* The target artifact platform. These are Node-style platform names, for example:
* * `win32`
* * `darwin`
* * `linux`
*/
platform: string;
/**
* The target artifact architecture. These are Node-style architecture names, for example:
* * `ia32`
* * `x64`
* * `armv7l`
*/
arch: string;

@@ -24,0 +77,0 @@ artifactSuffix?: string;

{
"name": "@electron/get",
"version": "1.1.1",
"version": "1.2.0",
"description": "Utility for downloading artifacts from different versions of Electron",

@@ -12,2 +12,3 @@ "main": "dist/cjs/index.js",

"build": "tsc && tsc -p tsconfig.esm.json",
"build:docs": "typedoc --out docs",
"prepublishOnly": "npm run build",

@@ -24,3 +25,4 @@ "test": "prettier --check \"src/**/*.ts\" && jest --coverage"

"dependencies": {
"env-paths": "^2.1.0",
"debug": "^4.1.1",
"env-paths": "^2.2.0",
"fs-extra": "^7.0.1",

@@ -32,2 +34,3 @@ "got": "^9.6.0",

"@continuous-auth/semantic-release-npm": "^1.0.3",
"@types/debug": "^4.1.4",
"@types/fs-extra": "^7.0.0",

@@ -43,2 +46,3 @@ "@types/got": "^9.4.4",

"ts-jest": "^24.0.0",
"typedoc": "^0.14.2",
"typescript": "^3.4.5"

@@ -45,0 +49,0 @@ },

@@ -5,2 +5,4 @@ # @electron/get

[![CircleCI](https://circleci.com/gh/electron/get.svg?style=svg)](https://circleci.com/gh/electron/get)
## Usage

@@ -10,5 +12,7 @@

```js
```typescript
import { download } from '@electron/get';
// NB: Use this syntax within an async function, Node does not have support for
// top-level await as of Node 12.
const zipFilePath = await download('4.0.4');

@@ -20,5 +24,7 @@ ```

```js
```typescript
import { downloadArtifact } from '@electron/get';
// NB: Use this syntax within an async function, Node does not have support for
// top-level await as of Node 12.
const zipFilePath = await downloadArtifact({

@@ -42,1 +48,5 @@ version: '4.0.4',

* Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
By default, the module uses [`got`](https://github.com/sindresorhus/got) as the
downloader. As a result, you can use the same [options](https://github.com/sindresorhus/got#options)
via `downloadOptions`.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc