2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 02:28:55 +00:00

Get rid of lodash

This commit is contained in:
Ronan Jouchet 2021-01-15 21:50:07 -05:00
parent 0eaf72ced8
commit 17f688de63
3 changed files with 19 additions and 10 deletions

View File

@ -54,7 +54,6 @@
}, },
"dependencies": { "dependencies": {
"@types/cheerio": "0.x", "@types/cheerio": "0.x",
"@types/lodash": "4.x",
"@types/ncp": "2.x", "@types/ncp": "2.x",
"@types/node": "10.x", "@types/node": "10.x",
"@types/page-icon": "0.x", "@types/page-icon": "0.x",
@ -66,7 +65,6 @@
"electron-packager": "15.x", "electron-packager": "15.x",
"gitcloud": "0.x", "gitcloud": "0.x",
"hasbin": "1.x", "hasbin": "1.x",
"lodash": "4.x",
"loglevel": "1.x", "loglevel": "1.x",
"ncp": "2.x", "ncp": "2.x",
"page-icon": "0.x", "page-icon": "0.x",

View File

@ -3,7 +3,6 @@ import * as crypto from 'crypto';
import * as path from 'path'; import * as path from 'path';
import { promisify } from 'util'; import { promisify } from 'util';
import { kebabCase } from 'lodash';
import * as log from 'loglevel'; import * as log from 'loglevel';
import { copyFileOrDir } from '../helpers/helpers'; import { copyFileOrDir } from '../helpers/helpers';
@ -106,7 +105,7 @@ function normalizeAppName(appName: string, url: string): string {
const hash = crypto.createHash('md5'); const hash = crypto.createHash('md5');
hash.update(url); hash.update(url);
const postFixHash = hash.digest('hex').substring(0, 6); const postFixHash = hash.digest('hex').substring(0, 6);
const normalized = kebabCase(appName.toLowerCase()); const normalized = appName.toLowerCase().replace(/[\s_]/g, '-');
return `${normalized}-nativefier-${postFixHash}`; return `${normalized}-nativefier-${postFixHash}`;
} }

View File

@ -1,10 +1,22 @@
import * as _ from 'lodash';
import axios from 'axios'; import axios from 'axios';
import * as log from 'loglevel'; import * as log from 'loglevel';
import { DEFAULT_CHROME_VERSION } from '../constants'; import { DEFAULT_CHROME_VERSION } from '../constants';
const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json'; const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json';
type ElectronRelease = {
version: string;
date: string;
node: string;
v8: string;
uv: string;
zlib: string;
openssl: string;
modules: string;
chrome: string;
files: string[];
};
async function getChromeVersionForElectronVersion( async function getChromeVersionForElectronVersion(
electronVersion: string, electronVersion: string,
url = ELECTRON_VERSIONS_URL, url = ELECTRON_VERSIONS_URL,
@ -14,11 +26,11 @@ async function getChromeVersionForElectronVersion(
if (response.status !== 200) { if (response.status !== 200) {
throw new Error(`Bad request: Status code ${response.status}`); throw new Error(`Bad request: Status code ${response.status}`);
} }
const { data } = response; const electronReleases: ElectronRelease[] = response.data;
const electronVersionToChromeVersion: _.Dictionary<string> = _.zipObject( const electronVersionToChromeVersion: { [key: string]: string } = {};
data.map((d) => d.version), for (const release of electronReleases) {
data.map((d) => d.chrome), electronVersionToChromeVersion[release.version] = release.chrome;
); }
if (!(electronVersion in electronVersionToChromeVersion)) { if (!(electronVersion in electronVersionToChromeVersion)) {
throw new Error( throw new Error(
`Electron version '${electronVersion}' not found in retrieved version list!`, `Electron version '${electronVersion}' not found in retrieved version list!`,