From 25149c8bbd87699795df3928c89a59c13e7b1d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=AB=20=E3=82=A6=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=83=96?= Date: Tue, 29 Jan 2019 17:29:14 -0600 Subject: [PATCH] Upgrades! --- app/client.js | 4 ++-- app/components/ecosystem/module-applications.js | 2 +- app/components/ecosystem/module-lbry.js | 2 +- app/components/ecosystem/module-lbrycrd.js | 2 +- .../ecosystem/submodule-chainquery.js | 2 +- .../ecosystem/submodule-lighthouse.js | 2 +- app/components/ecosystem/submodule-reflector.js | 2 +- app/components/ecosystem/submodule-wallet.js | 2 +- app/components/edit-link.js | 5 ++--- app/components/footer.js | 6 ++---- app/components/head.js | 5 ++--- app/components/markdown.js | 7 ++++--- app/helpers/github.js | 17 +++++++++-------- app/index.js | 4 ++-- app/sockets.js | 6 +++--- app/views/api.js | 6 +++--- app/views/home.js | 2 +- app/views/redirect.js | 2 +- app/views/spec.js | 6 +++--- package.json | 11 +++++++++++ 20 files changed, 52 insertions(+), 43 deletions(-) diff --git a/app/client.js b/app/client.js index 388c0e8..76e4235 100755 --- a/app/client.js +++ b/app/client.js @@ -11,8 +11,8 @@ import ssr from "choo-ssr"; // U T I L S -import head from "./components/head"; -import wrapper from "./components/wrapper"; +import head from "@component/head"; +import wrapper from "@component/wrapper"; diff --git a/app/components/ecosystem/module-applications.js b/app/components/ecosystem/module-applications.js index 8289ad4..891dbec 100644 --- a/app/components/ecosystem/module-applications.js +++ b/app/components/ecosystem/module-applications.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/ecosystem/module-lbry.js b/app/components/ecosystem/module-lbry.js index fca744a..833eaf5 100644 --- a/app/components/ecosystem/module-lbry.js +++ b/app/components/ecosystem/module-lbry.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/ecosystem/module-lbrycrd.js b/app/components/ecosystem/module-lbrycrd.js index 7c632fd..dadbfac 100644 --- a/app/components/ecosystem/module-lbrycrd.js +++ b/app/components/ecosystem/module-lbrycrd.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/ecosystem/submodule-chainquery.js b/app/components/ecosystem/submodule-chainquery.js index 92364bb..6e62af9 100644 --- a/app/components/ecosystem/submodule-chainquery.js +++ b/app/components/ecosystem/submodule-chainquery.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/ecosystem/submodule-lighthouse.js b/app/components/ecosystem/submodule-lighthouse.js index 1a044d2..c1ac0c1 100644 --- a/app/components/ecosystem/submodule-lighthouse.js +++ b/app/components/ecosystem/submodule-lighthouse.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/ecosystem/submodule-reflector.js b/app/components/ecosystem/submodule-reflector.js index 8b64d4d..6604162 100644 --- a/app/components/ecosystem/submodule-reflector.js +++ b/app/components/ecosystem/submodule-reflector.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/ecosystem/submodule-wallet.js b/app/components/ecosystem/submodule-wallet.js index be717af..d0bba0a 100644 --- a/app/components/ecosystem/submodule-wallet.js +++ b/app/components/ecosystem/submodule-wallet.js @@ -4,7 +4,7 @@ // U T I L -import markdown from "../markdown"; +import markdown from "@component/markdown"; diff --git a/app/components/edit-link.js b/app/components/edit-link.js index 9251edf..6e26e70 100644 --- a/app/components/edit-link.js +++ b/app/components/edit-link.js @@ -2,14 +2,13 @@ -// I M P O R T S +// I M P O R T import html from "choo/html"; -import { require as local } from "app-root-path"; // U T I L -const config = local("/config"); +import config from "@root/config"; diff --git a/app/components/footer.js b/app/components/footer.js index 55e09f1..e47472f 100644 --- a/app/components/footer.js +++ b/app/components/footer.js @@ -2,18 +2,16 @@ -// I M P O R T S +// I M P O R T import html from "choo/html"; -import { require as local } from "app-root-path"; // U T I L S +import config from "@root/config"; import editLink from "./edit-link"; import emailSubscribe from "./email-subscribe"; -const config = local("/config"); - // E X P O R T diff --git a/app/components/head.js b/app/components/head.js index 3cd6834..65a9d4f 100644 --- a/app/components/head.js +++ b/app/components/head.js @@ -2,14 +2,13 @@ -// I M P O R T S +// I M P O R T import html from "choo/html"; -import { require as local } from "app-root-path"; // U T I L S -const config = local("/config"); +import config from "@root/config"; let title = ""; diff --git a/app/components/markdown.js b/app/components/markdown.js index 89c314a..dfb7262 100644 --- a/app/components/markdown.js +++ b/app/components/markdown.js @@ -9,9 +9,10 @@ import exists from "fs-exists-sync"; import fm from "front-matter"; import fs from "graceful-fs"; import html from "choo/html"; +import markdownAnchor from "markdown-it-anchor"; +import markdownSup from "@module/markdown-it-sup"; import path from "path"; import raw from "choo/html/raw"; -import { require as local } from "app-root-path"; // U T I L S @@ -19,8 +20,8 @@ const numberRegex = /^[0-9]/g; const md = require("markdown-it")({ html: true, typographer: true -}).use(local("/app/modules/markdown-it-sup")) - .use(require("markdown-it-anchor"), { +}).use(markdownSup) + .use(markdownAnchor, { slugify: stringToSlugify => { let finalString = stringToSlugify .toLowerCase() diff --git a/app/helpers/github.js b/app/helpers/github.js index a973c1b..2beaf95 100644 --- a/app/helpers/github.js +++ b/app/helpers/github.js @@ -4,16 +4,16 @@ // P A C K A G E S -const async = require("async"); -const color = require("colorette"); -const local = require("app-root-path").require; -const Octokit = require("@octokit/rest"); -const redis = require("redis"); +import async from "async"; +import color from "colorette"; +import Octokit from "@octokit/rest"; +import redis from "redis"; // U T I L S -const messageSlack = local("/app/helpers/slack"); -const relativeDate = local("/app/modules/relative-date"); +import messageSlack from "@helper/slack"; +import relativeDate from "@module/relative-date"; + let octokit; String.prototype.escape = function() { @@ -365,7 +365,8 @@ function updateGithubFeed() { // H E L P E R function refToBranch(ref) { - if (ref) return ref.replace("refs/heads/", ""); + if (ref) + return ref.replace("refs/heads/", ""); } diff --git a/app/index.js b/app/index.js index 24ec78e..5e33c60 100755 --- a/app/index.js +++ b/app/index.js @@ -16,8 +16,8 @@ import websockets from "@inc/fastify-ws"; // U T I L S import handleSocketMessages from "./sockets"; -import messageSlack from "./helpers/slack"; -import redirects from "./data/redirects.json"; +import messageSlack from "@helper/slack"; +import redirects from "@data/redirects.json"; const server = fastify({ logger: { diff --git a/app/sockets.js b/app/sockets.js index 54dd9ce..f246d76 100644 --- a/app/sockets.js +++ b/app/sockets.js @@ -9,9 +9,9 @@ import html from "choo/html"; // U T I L S -import fetchMetadata from "./helpers/fetch-metadata"; -import { generateGitHubFeed } from "./helpers/github"; -import messageSlack from "./helpers/slack"; +import fetchMetadata from "@helper/fetch-metadata"; +import { generateGitHubFeed } from "@helper/github"; +import messageSlack from "@helper/slack"; diff --git a/app/views/api.js b/app/views/api.js index 41c0e2e..e1aea10 100644 --- a/app/views/api.js +++ b/app/views/api.js @@ -10,9 +10,9 @@ import got from "got"; // U T I L S -import headerBlockchain from "../components/api/header-blockchain"; -import headerSdk from "../components/api/header-sdk"; -import redirects from "../data/redirects.json"; +import headerBlockchain from "@component/api/header-blockchain"; +import headerSdk from "@component/api/header-sdk"; +import redirects from "@data/redirects.json"; const blockchainApi = "https://cdn.jsdelivr.net/gh/lbryio/lbrycrd@master/contrib/devtools/generated/api_v1.json"; const cache = new Map(); diff --git a/app/views/home.js b/app/views/home.js index 14a649f..62899e4 100644 --- a/app/views/home.js +++ b/app/views/home.js @@ -8,7 +8,7 @@ import html from "choo/html"; // U T I L -import linkGrid from "../components/link-grid"; +import linkGrid from "@component/link-grid"; diff --git a/app/views/redirect.js b/app/views/redirect.js index 0e6289a..c6f382f 100644 --- a/app/views/redirect.js +++ b/app/views/redirect.js @@ -11,7 +11,7 @@ import raw from "choo/html/raw"; // U T I L S -import markdown from "../components/markdown"; +import markdown from "@component/markdown"; import page404 from "./404"; diff --git a/app/views/spec.js b/app/views/spec.js index 2c6906c..f351039 100644 --- a/app/views/spec.js +++ b/app/views/spec.js @@ -14,7 +14,7 @@ export default state => { state.hideFooter = true; return html` -
+
@@ -22,12 +22,12 @@ export default state => { const specDomain = "https://spec.lbry.io"; const spec = document.getElementById("spec"); spec.src = specDomain + window.location.hash; - + window.addEventListener("message", event => { if (event.origin !== specDomain || event.source !== spec.contentWindow) // security return; - const url = window.location.href.substr(0, window.location.href.lastIndexOf("#")); + const url = window.location.href.substr(0, window.location.href.lastIndexOf("#")); history.replaceState(null, null, url + "#" + event.data); }); diff --git a/package.json b/package.json index 45ade00..5764074 100755 --- a/package.json +++ b/package.json @@ -1,4 +1,12 @@ { + "_moduleAliases": { + "@component": "app/components", + "@data": "app/data", + "@helper": "app/helpers", + "@module": "app/modules", + "@root": ".", + "@view": "app/views" + }, "author": "LBRY Team", "dependencies": { "@babel/polyfill": "^7.2.5", @@ -28,6 +36,7 @@ "fs-exists-sync": "^0.1.0", "got": "^9.6.0", "graceful-fs": "^4.1.15", + "link-module-alias": "^1.1.6", "make-promises-safe": "^4.0.0", "markdown-it": "^8.4.2", "markdown-it-anchor": "^5.0.2", @@ -85,6 +94,8 @@ "scripts": { "css": "sass --load-path=node_modules --update app/sass:app/dist --style compressed", "format": "eslint '**/*.js' --fix --ignore-pattern '/app/dist/'", + "postinstall": "link-module-alias", + "preinstall": "command -v link-module-alias && link-module-alias clean || true", "start": "npm run css && npm i && NODE_ENV=production node index.js", "test": "run-s test:*", "test:dependencies": "updates --update ./ --exclude fastify,prismjs",