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.4.0 to 1.5.0

6

dist/cjs/artifact-utils.d.ts
import { ElectronArtifactDetails } from './types';
export declare enum FileNameUse {
LOCAL = 0,
REMOTE = 1
}
export declare function getArtifactFileName(details: ElectronArtifactDetails, usage?: FileNameUse): string;
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): string;

21

dist/cjs/artifact-utils.js

@@ -6,21 +6,10 @@ "use strict";

var NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
var FileNameUse;
(function (FileNameUse) {
FileNameUse[FileNameUse["LOCAL"] = 0] = "LOCAL";
FileNameUse[FileNameUse["REMOTE"] = 1] = "REMOTE";
})(FileNameUse = exports.FileNameUse || (exports.FileNameUse = {}));
function getArtifactFileName(details, usage) {
if (usage === void 0) { usage = FileNameUse.LOCAL; }
function getArtifactFileName(details) {
utils_1.ensureIsTruthyString(details, 'artifactName');
utils_1.ensureIsTruthyString(details, 'version');
if (details.isGeneric) {
// When downloading we have to use the artifact name directly as that it was is stored in the release on GitHub
if (usage === FileNameUse.REMOTE) {
return details.artifactName;
}
// When caching / using on your local disk we want the generic artifact to be versioned
return details.version + "-" + details.artifactName;
return details.artifactName;
}
utils_1.ensureIsTruthyString(details, 'arch');
utils_1.ensureIsTruthyString(details, 'platform');
utils_1.ensureIsTruthyString(details, 'arch');
utils_1.ensureIsTruthyString(details, 'version');
return [

@@ -51,3 +40,3 @@ details.artifactName,

var path = mirrorVar('customDir', opts, details.version);
var file = mirrorVar('customFilename', opts, getArtifactFileName(details, FileNameUse.REMOTE));
var file = mirrorVar('customFilename', opts, getArtifactFileName(details));
return "" + base + path + "/" + file;

@@ -54,0 +43,0 @@ }

@@ -5,4 +5,4 @@ export declare class Cache {

private getCachePath;
getPathForFileInCache(fileName: string): Promise<string | null>;
putFileInCache(currentPath: string, fileName: string): Promise<string>;
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
}

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

var path = require("path");
var sanitize = require("sanitize-filename");
var d = debug_1.default('@electron/get:cache');

@@ -52,6 +53,7 @@ var defaultCacheRoot = env_paths_1.default('electron', {

}
Cache.prototype.getCachePath = function (fileName) {
return path.resolve(this.cacheRoot, fileName);
Cache.prototype.getCachePath = function (url, fileName) {
var sanitizedUrl = sanitize(url);
return path.resolve(this.cacheRoot, sanitizedUrl, fileName);
};
Cache.prototype.getPathForFileInCache = function (fileName) {
Cache.prototype.getPathForFileInCache = function (url, fileName) {
return __awaiter(this, void 0, void 0, function () {

@@ -62,3 +64,3 @@ var cachePath;

case 0:
cachePath = this.getCachePath(fileName);
cachePath = this.getCachePath(url, fileName);
return [4 /*yield*/, fs.pathExists(cachePath)];

@@ -74,3 +76,3 @@ case 1:

};
Cache.prototype.putFileInCache = function (currentPath, fileName) {
Cache.prototype.putFileInCache = function (url, currentPath, fileName) {
return __awaiter(this, void 0, void 0, function () {

@@ -81,3 +83,3 @@ var cachePath;

case 0:
cachePath = this.getCachePath(fileName);
cachePath = this.getCachePath(url, fileName);
d("Moving " + currentPath + " to " + cachePath);

@@ -84,0 +86,0 @@ return [4 /*yield*/, fs.pathExists(cachePath)];

@@ -77,3 +77,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var artifactDetails, fileName, cache, cachedPath;
var artifactDetails, fileName, url, cache, cachedPath;
var _this = this;

@@ -88,6 +88,7 @@ return __generator(this, function (_a) {

fileName = artifact_utils_1.getArtifactFileName(artifactDetails);
url = artifact_utils_1.getArtifactRemoteURL(artifactDetails);
cache = new Cache_1.Cache(artifactDetails.cacheRoot);
if (!!artifactDetails.force) return [3 /*break*/, 2];
d("Checking the cache for " + fileName);
return [4 /*yield*/, cache.getPathForFileInCache(fileName)];
d("Checking the cache for " + fileName + " (" + url + ")");
return [4 /*yield*/, cache.getPathForFileInCache(url, fileName)];
case 1:

@@ -110,7 +111,7 @@ cachedPath = _a.sent();

return [4 /*yield*/, utils_1.withTempDirectory(function (tempFolder) { return __awaiter(_this, void 0, void 0, function () {
var tempDownloadPath, downloader, _a, url, shasumPath;
var tempDownloadPath, downloader, _a, shasumPath;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
tempDownloadPath = path.resolve(tempFolder, artifact_utils_1.getArtifactFileName(artifactDetails, artifact_utils_1.FileNameUse.REMOTE));
tempDownloadPath = path.resolve(tempFolder, artifact_utils_1.getArtifactFileName(artifactDetails));
_a = artifactDetails.downloader;

@@ -124,3 +125,2 @@ if (_a) return [3 /*break*/, 2];

downloader = _a;
url = artifact_utils_1.getArtifactRemoteURL(artifactDetails);
d("Downloading " + url + " to " + tempDownloadPath + " with options: " + JSON.stringify(artifactDetails.downloadOptions));

@@ -149,3 +149,3 @@ return [4 /*yield*/, downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions)];

_b.label = 6;
case 6: return [4 /*yield*/, cache.putFileInCache(tempDownloadPath, fileName)];
case 6: return [4 /*yield*/, cache.putFileInCache(url, tempDownloadPath, fileName)];
case 7: return [2 /*return*/, _b.sent()];

@@ -152,0 +152,0 @@ }

import { ElectronArtifactDetails } from './types';
export declare enum FileNameUse {
LOCAL = 0,
REMOTE = 1
}
export declare function getArtifactFileName(details: ElectronArtifactDetails, usage?: FileNameUse): string;
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): string;
import { ensureIsTruthyString } from './utils';
var BASE_URL = 'https://github.com/electron/electron/releases/download/';
var NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
export var FileNameUse;
(function (FileNameUse) {
FileNameUse[FileNameUse["LOCAL"] = 0] = "LOCAL";
FileNameUse[FileNameUse["REMOTE"] = 1] = "REMOTE";
})(FileNameUse || (FileNameUse = {}));
export function getArtifactFileName(details, usage) {
if (usage === void 0) { usage = FileNameUse.LOCAL; }
export function getArtifactFileName(details) {
ensureIsTruthyString(details, 'artifactName');
ensureIsTruthyString(details, 'version');
if (details.isGeneric) {
// When downloading we have to use the artifact name directly as that it was is stored in the release on GitHub
if (usage === FileNameUse.REMOTE) {
return details.artifactName;
}
// When caching / using on your local disk we want the generic artifact to be versioned
return details.version + "-" + details.artifactName;
return details.artifactName;
}
ensureIsTruthyString(details, 'arch');
ensureIsTruthyString(details, 'platform');
ensureIsTruthyString(details, 'arch');
ensureIsTruthyString(details, 'version');
return [

@@ -47,5 +36,5 @@ details.artifactName,

var path = mirrorVar('customDir', opts, details.version);
var file = mirrorVar('customFilename', opts, getArtifactFileName(details, FileNameUse.REMOTE));
var file = mirrorVar('customFilename', opts, getArtifactFileName(details));
return "" + base + path + "/" + file;
}
//# sourceMappingURL=artifact-utils.js.map

@@ -5,4 +5,4 @@ export declare class Cache {

private getCachePath;
getPathForFileInCache(fileName: string): Promise<string | null>;
putFileInCache(currentPath: string, fileName: string): Promise<string>;
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
}

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

import * as path from 'path';
import * as sanitize from 'sanitize-filename';
var d = debug('@electron/get:cache');

@@ -50,6 +51,7 @@ var defaultCacheRoot = envPaths('electron', {

}
Cache.prototype.getCachePath = function (fileName) {
return path.resolve(this.cacheRoot, fileName);
Cache.prototype.getCachePath = function (url, fileName) {
var sanitizedUrl = sanitize(url);
return path.resolve(this.cacheRoot, sanitizedUrl, fileName);
};
Cache.prototype.getPathForFileInCache = function (fileName) {
Cache.prototype.getPathForFileInCache = function (url, fileName) {
return __awaiter(this, void 0, void 0, function () {

@@ -60,3 +62,3 @@ var cachePath;

case 0:
cachePath = this.getCachePath(fileName);
cachePath = this.getCachePath(url, fileName);
return [4 /*yield*/, fs.pathExists(cachePath)];

@@ -72,3 +74,3 @@ case 1:

};
Cache.prototype.putFileInCache = function (currentPath, fileName) {
Cache.prototype.putFileInCache = function (url, currentPath, fileName) {
return __awaiter(this, void 0, void 0, function () {

@@ -79,3 +81,3 @@ var cachePath;

case 0:
cachePath = this.getCachePath(fileName);
cachePath = this.getCachePath(url, fileName);
d("Moving " + currentPath + " to " + cachePath);

@@ -82,0 +84,0 @@ return [4 /*yield*/, fs.pathExists(cachePath)];

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

import * as path from 'path';
import { getArtifactFileName, getArtifactRemoteURL, FileNameUse } from './artifact-utils';
import { getArtifactFileName, getArtifactRemoteURL } from './artifact-utils';
import { Cache } from './Cache';

@@ -74,3 +74,3 @@ import { getDownloaderForSystem } from './downloader-resolver';

return __awaiter(this, void 0, void 0, function () {
var artifactDetails, fileName, cache, cachedPath;
var artifactDetails, fileName, url, cache, cachedPath;
var _this = this;

@@ -85,6 +85,7 @@ return __generator(this, function (_a) {

fileName = getArtifactFileName(artifactDetails);
url = getArtifactRemoteURL(artifactDetails);
cache = new Cache(artifactDetails.cacheRoot);
if (!!artifactDetails.force) return [3 /*break*/, 2];
d("Checking the cache for " + fileName);
return [4 /*yield*/, cache.getPathForFileInCache(fileName)];
d("Checking the cache for " + fileName + " (" + url + ")");
return [4 /*yield*/, cache.getPathForFileInCache(url, fileName)];
case 1:

@@ -107,7 +108,7 @@ cachedPath = _a.sent();

return [4 /*yield*/, withTempDirectory(function (tempFolder) { return __awaiter(_this, void 0, void 0, function () {
var tempDownloadPath, downloader, _a, url, shasumPath;
var tempDownloadPath, downloader, _a, shasumPath;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
tempDownloadPath = path.resolve(tempFolder, getArtifactFileName(artifactDetails, FileNameUse.REMOTE));
tempDownloadPath = path.resolve(tempFolder, getArtifactFileName(artifactDetails));
_a = artifactDetails.downloader;

@@ -121,3 +122,2 @@ if (_a) return [3 /*break*/, 2];

downloader = _a;
url = getArtifactRemoteURL(artifactDetails);
d("Downloading " + url + " to " + tempDownloadPath + " with options: " + JSON.stringify(artifactDetails.downloadOptions));

@@ -146,3 +146,3 @@ return [4 /*yield*/, downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions)];

_b.label = 6;
case 6: return [4 /*yield*/, cache.putFileInCache(tempDownloadPath, fileName)];
case 6: return [4 /*yield*/, cache.putFileInCache(url, tempDownloadPath, fileName)];
case 7: return [2 /*return*/, _b.sent()];

@@ -149,0 +149,0 @@ }

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

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

"got": "^9.6.0",
"sanitize-filename": "^1.6.2",
"sumchecker": "^3.0.0"

@@ -39,2 +40,3 @@ },

"@types/node": "^12.0.2",
"@types/sanitize-filename": "^1.1.28",
"gh-pages": "^2.0.1",

@@ -41,0 +43,0 @@ "husky": "^2.3.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

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