Migrate from jshint to eslint

This commit is contained in:
Maddison Hellstrom 2017-12-01 18:48:58 -08:00
parent 7f9bd58f2c
commit f047497398
9 changed files with 1741 additions and 3256 deletions

55
.eslintrc.js Normal file
View File

@ -0,0 +1,55 @@
module.exports = {
extends: "airbnb",
globals: {
Omnibar: false,
Front: false,
runtime: false,
chrome: false,
tabOpenLink: false,
Hints: false,
unmap: false,
map: false,
mapkey: false,
settings: false,
removeSearchAliasX: false,
addSearchAliasX: false,
completions: false,
},
env: {
browser: true,
node: true,
jquery: true,
},
rules: {
semi: ["error", "never"],
"comma-dangle": ["warn", "always-multiline"],
quotes: ["warn", "double"],
"newline-per-chained-call": "off",
"key-spacing": [
"warn",
{
singleLine: {
beforeColon: false,
afterColon: true,
},
multiLine: {
beforeColon: false,
afterColon: true,
align: "value",
},
},
],
indent: [
"warn",
2,
{
SwitchCase: 0,
VariableDeclarator: { var: 2, let: 2, const: 3 },
},
],
},
}

View File

@ -1,4 +0,0 @@
{
"laxcomma": true,
"esversion": 6
}

File diff suppressed because it is too large Load Diff

474
conf.js
View File

@ -1,38 +1,40 @@
//---- Cleanup ----//
// ---- Cleanup ----//
// Unmap undesired defaults
var unmaps = [ "sb" , "sw", "ob"
, "ow" , "cp", ";cp"
, ";ap", "spa", "spb"
, "spd", "sps", "spc"
, "spi", "sfr", "zQ"
, "zz" , "zR", "ab"
, "Q" , "q", "ag"
, "af" , ";s", "yp"
];
const unmaps = [
"sb", "sw", "ob",
"ow", "cp", ";cp",
";ap", "spa", "spb",
"spd", "sps", "spc",
"spi", "sfr", "zQ",
"zz", "zR", "ab",
"Q", "q", "ag",
"af", ";s", "yp",
]
unmaps.forEach(function(u) {
unmap(u);
});
unmaps.forEach((u) => {
unmap(u)
})
var rmSearchAliases =
{ "s" : [ "g", "d", "b"
, "w", "s", "h" ]
};
const rmSearchAliases =
{
s: ["g", "d", "b",
"w", "s", "h"],
}
Object.keys(rmSearchAliases).forEach(function(k) {
rmSearchAliases[k].forEach(function(v) {
removeSearchAliasX(v, k);
});
});
Object.keys(rmSearchAliases).forEach((k) => {
rmSearchAliases[k].forEach((v) => {
removeSearchAliasX(v, k)
})
})
//---- Settings ----//
settings.hintAlign = "left";
settings.omnibarSuggestionTimeout = 500;
settings.hintGroups = true;
// ---- Settings ----//
settings.hintAlign = "left"
settings.omnibarSuggestionTimeout = 500
settings.hintGroups = true
// settings.hintGroupStart = "middle";
settings.richHintsForKeystroke = 1;
settings.richHintsForKeystroke = 1
//---- Theme ----//
// ---- Theme ----//
settings.theme = `
/* Disable RichHints CSS animation */
.expandRichHints {
@ -41,235 +43,265 @@ settings.theme = `
.collapseRichHints {
animation: 0s ease-in-out 1 forwards collapseRichHints;
}
`;
`
//---- Maps ----//
// ---- Site-Specific Settings ----//
if (/github\.com/.test(window.location.hostname)) {
settings.theme += `
sk_theme {
background: #000;
color: #fff;
}
.sk_theme tbody {
color: #fff;
}
.sk_theme input {
color: #d9dce0;
}
.sk_theme .url {
color: #2173c5;
}
.sk_theme .annotation {
color: #38f;
}
.sk_theme .omnibar_highlight {
color: #fbd60a;
}
.sk_theme ul>li:nth-child(odd) {
background: #1e211d;
}
.sk_theme ul>li.focused {
background: #4ec10d;
}`
}
// ---- Maps ----//
// Left-hand aliases
// Movement
map('w', 'k');
map('s', 'j');
map("w", "k")
map("s", "j")
// Right-hand aliases
// Tab Navigation
map('J', 'E');
map('K', 'R');
map("J", "E")
map("K", "R")
// History
map('H', 'S');
map('L', 'D');
map("H", "S")
map("L", "D")
//---- Mapkeys ----//
const ri = { repeatIgnore: true };
mapkey('=w', "Lookup whois information for domain", whois, ri);
mapkey('=d', "Lookup dns information for domain", dns, ri);
mapkey('=D', "Lookup all information for domain", dnsVerbose, ri);
mapkey(';se', "#11Edit Settings", editSettings, ri);
mapkey(';pd', "Toggle PDF viewer from SurfingKeys", togglePdfViewer, ri);
mapkey('gi', "Edit current URL with vim editor", vimEditURL, ri);
mapkey('yp', "Copy URL path of current page", () => copyURLPath(), ri);
const siteleader = "<Space>";
function mapsitekey(domainRegex, key, desc, f, opts) {
opts = opts || {};
mapkey(`${siteleader}${key}`, desc, f, Object.assign({}, opts, { domain: domainRegex }));
// ---- Functions ----//
function fakeSpot() {
const url = `http://fakespot.com/analyze?url=${window.location.href}`
window.open(url, "_blank").focus()
}
function mapsitekeys(domain, maps) {
domain = domain.replace('.', '\\.');
var domainRegex = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${domain})(/.*)?`);
maps.forEach(function(map) {
mapsitekey(domainRegex, map[0], map[1], map[2]);
});
function ytFullscreen() {
$(".ytp-fullscreen-button.ytp-button").click()
}
function vimeoFullscreen() {
$(".fullscreen-icon").click()
}
function ghStar(toggle) {
const repo = window.location.pathname.slice(1).split("/").slice(0, 2).join("/")
const cur = $("div.starring-container > form").filter(function filter() {
return $(this).css("display") === "block"
})
let star = "★"
let status = "starred"
let verb = "is"
const starred = $(cur).attr("class").indexOf("unstarred") === -1
if (starred && toggle) {
status = `un${status}`
star = "☆"
}
if (toggle) {
$(cur).find("button").click()
verb = "has been"
}
Front.showBanner(`${star} Repository ${repo} ${verb} ${status}!`)
}
function glToggleStar() {
const repo = window.location.pathname.slice(1).split("/").slice(0, 2).join("/")
const action = `${$(".btn.star-btn > span").click().text().toLowerCase()}red`
let star = "☆"
if (action === "starred") {
star = "★"
}
Front.showBanner(`${star} Repository ${repo} ${action}`)
}
function vimEditURL() {
Front.showEditor(window.location.href, (data) => {
window.location.href = data
}, "url")
}
function whois() {
const url = `http://centralops.net/co/DomainDossier.aspx?dom_whois=true&addr=${window.location.hostname}`
window.open(url, "_blank").focus()
}
function dns() {
const url = `http://centralops.net/co/DomainDossier.aspx?dom_dns=true&addr=${window.location.hostname}`
window.open(url, "_blank").focus()
}
function dnsVerbose() {
const url = `http://centralops.net/co/DomainDossier.aspx?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=${window.location.hostname}`
window.open(url, "_blank").focus()
}
function togglePdfViewer() {
chrome.storage.local.get("noPdfViewer", (resp) => {
if (!resp.noPdfViewer) {
chrome.storage.local.set({ noPdfViewer: 1 }, () => {
Front.showBanner("PDF viewer disabled.")
})
} else {
chrome.storage.local.remove("noPdfViewer", () => {
Front.showBanner("PDF viewer enabled.")
})
}
})
}
function getURLPath(count, domain) {
let path = window.location.pathname.slice(1)
if (count) {
path = path.split("/").slice(0, count).join("/")
}
if (domain) {
path = `${window.location.hostname}/${path}`
}
return path
}
function copyURLPath(count, domain) {
Front.writeClipboard(getURLPath(count, domain))
}
function viewGodoc() {
const repo = getURLPath(2, true)
tabOpenLink(`https://godoc.org/${repo}`)
}
function editSettings() {
tabOpenLink("/pages/options.html")
}
function redditCollapseComment() {
Hints.create("a.expand", Hints.dispatchMouseClick)
}
function hnCollapseComment() {
Hints.create("a.togg", Hints.dispatchMouseClick)
}
function redditVote() {
Hints.create("div.arrow", Hints.dispatchMouseClick)
}
function hnVote() {
Hints.create("div.votearrow", Hints.dispatchMouseClick)
}
function twitterFollowUser() {
Hints.create(".follow-button", Hints.dispatchMouseClick)
}
// ---- Mapkeys ----//
const ri = { repeatIgnore: true }
mapkey("=w", "Lookup whois information for domain", whois, ri)
mapkey("=d", "Lookup dns information for domain", dns, ri)
mapkey("=D", "Lookup all information for domain", dnsVerbose, ri)
mapkey(";se", "#11Edit Settings", editSettings, ri)
mapkey(";pd", "Toggle PDF viewer from SurfingKeys", togglePdfViewer, ri)
mapkey("gi", "Edit current URL with vim editor", vimEditURL, ri)
mapkey("yp", "Copy URL path of current page", () => copyURLPath(), ri)
const siteleader = "<Space>"
function mapsitekey(domainRegex, key, desc, f, o) {
const opts = o || {}
mapkey(`${siteleader}${key}`, desc, f, Object.assign({}, opts, { domain: domainRegex }))
}
function mapsitekeys(d, maps) {
const domain = d.replace(".", "\\.")
const domainRegex = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${domain})(/.*)?`)
maps.forEach((map) => {
mapsitekey(domainRegex, map[0], map[1], map[2])
})
}
mapsitekeys("amazon.com", [
['fs', "Fakespot", fakeSpot],
// TODO: Add to cart
]);
["fs", "Fakespot", fakeSpot],
// TODO: Add to cart
])
mapsitekeys("yelp.com", [
['fs', "Fakespot", fakeSpot],
]);
["fs", "Fakespot", fakeSpot],
])
mapsitekeys("youtube.com", [
['F', "Toggle fullscreen", ytFullscreen],
]);
["F", "Toggle fullscreen", ytFullscreen],
])
mapsitekeys("vimeo.com", [
['F', "Toggle fullscreen", vimeoFullscreen],
]);
["F", "Toggle fullscreen", vimeoFullscreen],
])
mapsitekeys("github.com", [
['s', "Toggle Star", () => ghStar(true)],
['S', "Check Star", () => ghStar(false)],
['y', "Copy Project Path", () => copyURLPath(2)],
['Y', "Copy Project Path (including domain)", () => copyURLPath(2, true)],
['D', "View GoDoc for Project", viewGodoc],
]);
["s", "Toggle Star", () => ghStar(true)],
["S", "Check Star", () => ghStar(false)],
["y", "Copy Project Path", () => copyURLPath(2)],
["Y", "Copy Project Path (including domain)", () => copyURLPath(2, true)],
["D", "View GoDoc for Project", viewGodoc],
])
mapsitekeys("gitlab.com", [
['s', "Toggle Star", glToggleStar],
['y', "Copy Project Path", () => copyURLPath(2)],
['Y', "Copy Project Path (including domain)", () => copyURLPath(2, true)],
['D', "View GoDoc for Project", viewGodoc],
]);
["s", "Toggle Star", glToggleStar],
["y", "Copy Project Path", () => copyURLPath(2)],
["Y", "Copy Project Path (including domain)", () => copyURLPath(2, true)],
["D", "View GoDoc for Project", viewGodoc],
])
mapsitekeys("twitter.com", [
['f', "Follow user", twitterFollowUser],
]);
["f", "Follow user", twitterFollowUser],
])
mapsitekeys("reddit.com", [
['c', "Collapse comment", redditCollapseComment],
['v', "Cast vote", redditVote],
]);
["c", "Collapse comment", redditCollapseComment],
["v", "Cast vote", redditVote],
])
mapsitekeys("news.ycombinator.com", [
['c', "Collapse comment", hnCollapseComment],
['v', "Cast vote", hnVote],
]);
["c", "Collapse comment", hnCollapseComment],
["v", "Cast vote", hnVote],
])
//---- Search & completion ----//
// ---- Search & completion ----//
// Search leader
const sl = 'a';
const sl = "a"
// Register Search Engine Completions
// The `completions` variable is defined in `completions.js` and
// is prepended to this file by gulp-concat.
Object.keys(completions).map(function(k) {
var s = completions[k], // Search Engine object
la = sl + s.alias; // Search leader + alias
Object.keys(completions).forEach((k) => {
const s = completions[k] // Search Engine object
const la = sl + s.alias // Search leader + alias
addSearchAliasX(s.alias, s.name, s.search, sl, s.compl, s.callback);
mapkey(la, '#8Search ' + s.name, 'Front.openOmnibar({type: "SearchEngine", extra: "' + s.alias + '"})');
});
//---- Functions ----//
function fakeSpot() {
var url = "http://fakespot.com/analyze?url=" + window.location.href;
window.open(url, '_blank').focus();
}
function ytFullscreen() {
$('.ytp-fullscreen-button.ytp-button').click();
}
function vimeoFullscreen() {
$('.fullscreen-icon').click();
}
function ghStar(toggle) {
var repo = window.location.pathname.slice(1).split("/").slice(0,2).join("/");
var cur = $('div.starring-container > form').filter(function() {
return $(this).css("display") === "block";
});
var star = "★";
var status = "starred";
var verb = "is";
var starred = $(cur).attr("class").indexOf("unstarred") === -1;
if (starred && toggle) {
status = "un" + status;
star = "☆";
}
if (toggle) {
$(cur).find("button").click();
verb = "has been";
}
Front.showBanner(`${star} Repository ${repo} ${verb} ${status}!`);
}
function glToggleStar() {
var repo = window.location.pathname.slice(1).split("/").slice(0,2).join("/");
var action = $('.btn.star-btn > span').click().text().toLowerCase() + "red";
var star = "☆";
if (action === "starred") {
star = "★";
}
Front.showBanner(star + " Repository " + repo + " " + action);
}
function vimEditURL() {
Front.showEditor(window.location.href, function(data) {
window.location.href = data;
}, 'url');
}
function whois() {
var url = "http://centralops.net/co/DomainDossier.aspx?dom_whois=true&addr=" + window.location.hostname;
window.open(url, '_blank').focus();
}
function dns() {
var url = "http://centralops.net/co/DomainDossier.aspx?dom_dns=true&addr=" + window.location.hostname;
window.open(url, '_blank').focus();
}
function dnsVerbose() {
var url = "http://centralops.net/co/DomainDossier.aspx?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=" + window.location.hostname;
window.open(url, '_blank').focus();
}
function togglePdfViewer() {
chrome.storage.local.get("noPdfViewer", function(resp) {
if(!resp.noPdfViewer) {
chrome.storage.local.set({"noPdfViewer": 1}, function() {
Front.showBanner("PDF viewer disabled.");
});
} else {
chrome.storage.local.remove("noPdfViewer", function() {
Front.showBanner("PDF viewer enabled.");
});
}
});
}
function getURLPath(count, domain) {
var path = window.location.pathname.slice(1);
if (count) {
path = path.split('/').slice(0, count).join('/');
}
if (domain) {
path = window.location.hostname + '/' + path;
}
return path;
}
function copyURLPath(count, domain) {
Front.writeClipboard(getURLPath(count, domain));
}
function viewGodoc() {
var repo = getURLPath(2, true);
tabOpenLink("https://godoc.org/" + repo);
}
function editSettings() {
tabOpenLink("/pages/options.html");
}
function redditCollapseComment() {
Hints.create('a.expand', Hints.dispatchMouseClick);
}
function hnCollapseComment() {
Hints.create('a.togg', Hints.dispatchMouseClick);
}
function redditVote() {
Hints.create('div.arrow', Hints.dispatchMouseClick);
}
function hnVote() {
Hints.create('div.votearrow', Hints.dispatchMouseClick);
}
function twitterFollowUser() {
Hints.create('.follow-button', Hints.dispatchMouseClick);
}
addSearchAliasX(s.alias, s.name, s.search, sl, s.compl, s.callback)
mapkey(la, `#8Search ${s.name}`, `Front.openOmnibar({type: "SearchEngine", extra: "${s.alias}"})`)
})
// vim: set ft=javascript expandtab:

View File

@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars, camelcase */
// This is a reference for how conf.priv.js should look.
//
// Copy this file to a new file named "conf.priv.js" and update
@ -10,26 +12,26 @@
// These are private API keys which are required for certain search completions.
// You can obtain them all for free at the supplied links.
var keys = {
crunchbase: "", // https://about.crunchbase.com/crunchbase-basic-access/
google_cs: "", // https://developers.google.com/custom-search/json-api/v1/overview?hl=en_US
google_yt: "", // https://developers.google.com/youtube/v3/docs/
wolframalpha: "", // https://products.wolframalpha.com/api/
domainr: "", // https://market.mashape.com/domainr/domainr
const keys = {
crunchbase: "", // https://about.crunchbase.com/crunchbase-basic-access/
google_cs: "", // https://developers.google.com/custom-search/json-api/v1/overview?hl=en_US
google_yt: "", // https://developers.google.com/youtube/v3/docs/
wolframalpha: "", // https://products.wolframalpha.com/api/
domainr: "", // https://market.mashape.com/domainr/domainr
//*** Google Custom Search Engines ***//
// Can be created at https://cse.google.com/cse
// Simply create a separate Custom Search Engine for each of the following entries,
// pasting the provided URL string in the "Sites to Search" field.
// Then, after creation, go to the control panel for the new Search Engine and copy the
// Search Engine ID (cx) into the appropriate configuration variable below:
google_cx_ex: "", // hexdocs.pm/*/master/*.html
google_cx_af: "", // bbs.archlinux.org/*
google_cx_al: "", // www.archlinux.org/packages/*/x86_64/*
google_cx_no: "", // nodejs.org/api/*
google_cx_cs: "", // chrome.google.com/webstore/*
google_cx_jq: "", // api.jquery.com/*
};
//* ** Google Custom Search Engines ***//
// Can be created at https://cse.google.com/cse
// Simply create a separate Custom Search Engine for each of the following entries,
// pasting the provided URL string in the "Sites to Search" field.
// Then, after creation, go to the control panel for the new Search Engine and copy the
// Search Engine ID (cx) into the appropriate configuration variable below:
google_cx_ex: "", // hexdocs.pm/*/master/*.html
google_cx_af: "", // bbs.archlinux.org/*
google_cx_al: "", // www.archlinux.org/packages/*/x86_64/*
google_cx_no: "", // nodejs.org/api/*
google_cx_cs: "", // chrome.google.com/webstore/*
google_cx_jq: "", // api.jquery.com/*
}
// You can place any additional private/sensitive variables here and they will
// be included before the rest of your configuration scripts.

View File

@ -1,22 +1,22 @@
const gulp = require('gulp');
const concat = require('gulp-concat');
const replace = require('gulp-replace');
const rename = require('gulp-rename');
const jshint = require('gulp-jshint');
const path = require('path');
const del = require('del');
const os = require('os');
const fs = require('fs');
const spawn = require('child_process').spawn;
const { URL } = require('url');
const compl = require('./completions');
const gulp = require("gulp")
const concat = require("gulp-concat")
const replace = require("gulp-replace")
const rename = require("gulp-rename")
const eslint = require("gulp-eslint")
const path = require("path")
const del = require("del")
const os = require("os")
const fs = require("fs")
const { spawn } = require("child_process")
const { URL } = require("url")
const compl = require("./completions")
var paths = {
scripts: ['conf.priv.js', 'completions.js', 'conf.js'],
gulpfile: ['gulpfile.js'],
readme: ['README.tmpl.md'],
screenshots: 'assets/screenshots',
};
const paths = {
scripts: ["conf.priv.js", "completions.js", "conf.js"],
gulpfile: ["gulpfile.js"],
readme: ["README.tmpl.md"],
screenshots: "assets/screenshots",
}
// This notice will be injected into the generated README.md file
const disclaimer = `\
@ -26,92 +26,86 @@ NOTICE:
This is an automatically generated file - Do not edit it directly.
The source file is README.tmpl.md
-->`;
-->`
gulp.task('gulp-autoreload', function() {
var p;
var spawnChildren = function() {
if (p) p.kill();
p = spawn('gulp', ['lint-gulpfile', 'install', 'watch-nogulpfile'], {stdio: 'inherit'});
};
gulp.watch('gulpfile.js', spawnChildren);
spawnChildren();
});
gulp.task("gulp-autoreload", () => {
let p
const spawnChildren = function spawnChildren() {
if (p) p.kill()
p = spawn("gulp", ["lint-gulpfile", "install", "watch-nogulpfile"], { stdio: "inherit" })
}
gulp.watch("gulpfile.js", spawnChildren)
spawnChildren()
})
gulp.task('clean', function() {
return del(['build']);
});
gulp.task("clean", () => del(["build"]))
gulp.task('lint', function() {
return gulp.src([].concat(paths.scripts, paths.gulpfile))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task("lint", () =>
gulp
.src([].concat(paths.scripts, paths.gulpfile))
.pipe(eslint())
.pipe(eslint.format()))
gulp.task('lint-gulpfile', function() {
return gulp.src([].concat(paths.gulpfile))
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task("lint", () =>
gulp
.src(paths.gulpfile)
.pipe(eslint())
.pipe(eslint.format()))
gulp.task('build', ['clean', 'lint', 'readme'], function() {
return gulp.src(paths.scripts)
.pipe(concat('.surfingkeys'))
.pipe(gulp.dest('build'));
});
gulp.task("build", ["clean", "lint", "readme"], () => gulp.src(paths.scripts)
.pipe(concat(".surfingkeys"))
.pipe(gulp.dest("build")))
gulp.task('install', ['build'], function() {
return gulp.src('build/.surfingkeys')
.pipe(gulp.dest(os.homedir()));
});
gulp.task("install", ["build"], () => gulp.src("build/.surfingkeys")
.pipe(gulp.dest(os.homedir())))
gulp.task('watch', function() {
gulp.watch([].concat(paths.scripts, paths.gulpfile), ['readme', 'install']);
gulp.watch(paths.readme, ['readme']);
});
gulp.task("watch", () => {
gulp.watch([].concat(paths.scripts, paths.gulpfile), ["readme", "install"])
gulp.watch(paths.readme, ["readme"])
})
gulp.task('watch-nogulpfile', function() {
gulp.watch([].concat(paths.scripts), ['readme', 'install']);
gulp.watch(paths.readme, ['readme']);
});
gulp.task("watch-nogulpfile", () => {
gulp.watch([].concat(paths.scripts), ["readme", "install"])
gulp.watch(paths.readme, ["readme"])
})
gulp.task('readme', function() {
var screens = {};
var screenshotList = "";
fs.readdirSync(path.join(__dirname, paths.screenshots)).forEach(function(s) {
var file = path.basename(s, '.png').split('-');
var alias = file[0];
if (!screens[alias]) {
screens[alias] = [];
}
screens[alias].push(path.join(paths.screenshots, path.basename(s)));
});
var table = Object.keys(compl).sort(function(a, b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}).reduce(function(a, k) {
var c = compl[k];
var u = new URL(c.search);
var domain = (u.hostname === "cse.google.com") ? "Google Custom Search" : u.hostname;
var s = "";
if (screens[c.alias]) {
screens[c.alias].forEach(function(url, i) {
var num = (i > 0) ? ` ${i+1}` : "";
s += `[\\[${i+1}\\]](#${c.name}${num.replace(' ', '-')}) `;
screenshotList += `##### ${c.name}${num}\n`;
screenshotList += `![${c.name} screenshot](./${url})\n\n`;
});
}
return a + `| \`${c.alias}\` | \`${c.name}\` | \`${domain}\` | ${s} |\n`;
}, "");
return gulp.src(['./README.tmpl.md'])
gulp.task("readme", () => {
const screens = {}
let screenshotList = ""
fs.readdirSync(path.join(__dirname, paths.screenshots)).forEach((s) => {
const file = path.basename(s, ".png").split("-")
const alias = file[0]
if (!screens[alias]) {
screens[alias] = []
}
screens[alias].push(path.join(paths.screenshots, path.basename(s)))
})
const table = Object.keys(compl).sort((a, b) => {
if (a < b) return -1
if (a > b) return 1
return 0
}).reduce((a, k) => {
const c = compl[k]
const u = new URL(c.search)
const domain = (u.hostname === "cse.google.com") ? "Google Custom Search" : u.hostname
let s = ""
if (screens[c.alias]) {
screens[c.alias].forEach((url, i) => {
const num = (i > 0) ? ` ${i + 1}` : ""
s += `[\\[${i + 1}\\]](#${c.name}${num.replace(" ", "-")}) `
screenshotList += `##### ${c.name}${num}\n`
screenshotList += `![${c.name} screenshot](./${url})\n\n`
})
}
return `${a}| \`${c.alias}\` | \`${c.name}\` | \`${domain}\` | ${s} |\n`
}, "")
return gulp.src(["./README.tmpl.md"])
.pipe(replace("<!--DISCLAIMER-->", disclaimer))
.pipe(replace("<!--COMPL_COUNT-->", Object.keys(compl).length))
.pipe(replace("<!--COMPL_TABLE-->", table))
.pipe(replace("<!--SCREENSHOTS-->", screenshotList))
.pipe(rename('README.md'))
.pipe(gulp.dest('.'));
});
.pipe(rename("README.md"))
.pipe(gulp.dest("."))
})
gulp.task('default', ['build']);
gulp.task("default", ["build"])

1971
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,12 +19,11 @@
"license": "MIT",
"dependencies": {
"del": "^3.0.0",
"eslint": "^4.12.1",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-jshint": "^2.0.4",
"gulp-eslint": "^4.0.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.6.1",
"jshint": "^2.9.5",
"jshint-stylish": "^2.2.1"
"gulp-replace": "^0.6.1"
}
}

742
yarn.lock

File diff suppressed because it is too large Load Diff