From 2de40bd9aa1f92e82fda6354d21ae1a709bfddfb Mon Sep 17 00:00:00 2001 From: Julien Bisconti Date: Sat, 11 Jan 2020 09:09:10 +0100 Subject: [PATCH] Remove beta --- .eslintrc.js | 58 +++---- .prettierrc | 5 + build.js | 190 ---------------------- package.json | 5 +- website/index.js | 19 --- website/index.tmpl.html | 2 - website/sitemap.xml | 16 -- website/style.css | 0 website/table.tmpl.html | 344 ---------------------------------------- 9 files changed, 35 insertions(+), 604 deletions(-) create mode 100644 .prettierrc delete mode 100644 website/index.js delete mode 100644 website/sitemap.xml delete mode 100644 website/style.css delete mode 100644 website/table.tmpl.html diff --git a/.eslintrc.js b/.eslintrc.js index 8d01eba..2fbd828 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,31 +1,31 @@ module.exports = { - "env": { - "browser": true, - "node": true - }, - "extends": [ - "airbnb-base", - "plugin:import/errors", - "plugin:import/warnings", - "prettier", - ], - "plugins": [ - "import", - "prettier", - ], - "rules": { - "import/order": ["error", { - "groups": ["builtin", "external", "parent", "sibling", "index"], - "newlines-between": "never" - }], - "no-console": 0, - "prefer-template": 2, - "prettier/prettier": [ - "error", - { - "singleQuote": true, - "trailingComma": "all", - } - ] + env: { + browser: true, + node: true + }, + extends: [ + 'airbnb-base', + 'plugin:import/errors', + 'plugin:import/warnings', + 'prettier' + ], + plugins: ['import', 'prettier'], + rules: { + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'parent', 'sibling', 'index'], + 'newlines-between': 'never' } -}; \ No newline at end of file + ], + 'no-console': 0, + 'prefer-template': 2, + 'prettier/prettier': [ + 'error', + { + singleQuote: true, + trailingComma: 'all' + } + ] + } +}; diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0d18603 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": true, + "trailingComma": "all", + "singleQuote": true +} \ No newline at end of file diff --git a/build.js b/build.js index 6444506..ba83930 100644 --- a/build.js +++ b/build.js @@ -1,7 +1,5 @@ const fs = require('fs-extra'); -const fetch = require('node-fetch'); const cheerio = require('cheerio'); -const dayjs = require('dayjs'); const showdown = require('showdown'); const Parcel = require('parcel-bundler'); const sm = require('sitemap'); @@ -24,26 +22,8 @@ process.on('unhandledRejection', handleFailure); // --- FILES const README = 'README.md'; const WEBSITE_FOLDER = 'website'; -const DATA_FOLDER = 'data'; -const LATEST_FILENAME = `${DATA_FOLDER}/latest`; -const MAPPING = `${DATA_FOLDER}/mapping.json`; -const CATEGORY = `${DATA_FOLDER}/category.json`; const indexTemplate = `${WEBSITE_FOLDER}/index.tmpl.html`; const indexDestination = `${WEBSITE_FOLDER}/index.html`; -const tableTemplate = `${WEBSITE_FOLDER}/table.tmpl.html`; -const tableDestination = `${WEBSITE_FOLDER}/table.html`; - -// --- CONFIG -const valueNames = [ - 'name', - 'description', - 'homepage', - 'star', - 'updated', - 'language', - 'license', - 'author', -]; const sitemapOpts = { hostname: 'https://awesome-docker.netlify.com/', @@ -56,177 +36,9 @@ const sitemapOpts = { lastmodrealtime: true, lastmodfile: 'dist/index.html', }, - { - url: '/table.html', - changefreq: 'daily', - priority: 0.8, - lastmodrealtime: true, - lastmodfile: 'dist/table.html', - }, ], }; -// --- FORMAT -const loadEmoji = () => - fetch('https://api.github.com/emojis') - .then(r => r.json()) - .catch(handleFailure); - -let emojiMapURL = {}; - -const emojify = text => { - if (!text) return text; - const colonWrapped = /(:[\w\-+]+:)/g; - const result = text.replace(colonWrapped, match => { - const name = match.replace(/:/g, ''); - const url = emojiMapURL[name]; - return url ? `${name}` : match; - }); - return result || text; -}; - -const getLastUpdate = updated => { - const updt = Number(dayjs(updated).diff(dayjs(), 'days')); - if (updt < 0) { - if (Math.abs(updt) === 1) return `1 day ago`; - return `${Math.abs(updt)} days ago`; - } else if (updt === 0) return 'today'; - return updated; -}; - -const mapHomePage = h => { - if (h === 'manageiq.org') return 'https://manageiq.org'; - else if (h === 'dev-sec.io') return 'https://dev-sec.io'; - return h; -}; - -const mapLicense = l => { - if (l === 'GNU Lesser General Public License v3.0') return 'GNU LGPL v3.0'; - else if (l === 'GNU General Public License v2.0') return 'GNU GPL v2.0'; - else if (l === 'GNU General Public License v3.0') return 'GNU GPL v3.0'; - else if (l === 'BSD 3-Clause "New" or "Revised" License') - return 'BSD 3-Clause'; - else if (l === 'BSD 2-Clause "Simplified" License') return 'BSD 2-Clause'; - return l; -}; - -const formatEntry = ( - { - name, - html_url: repoURL, - description, - homepage, - stargazers_count: stargazers, - pushed_at: updated, - language, - license, - owner, - categoryName, - }, - i, -) => - [ - `
  • `, - `${name}`, - `

    ${emojify(description) || '-'}

    `, - `

    Last code update: ${getLastUpdate( - updated, - )}

    `, - (homepage && - `website`) || - '

    ', - `

    ⭐️${stargazers}

    `, - (language && `

    ${language}

    `) || '

    ', - (license && - license.url !== null && - `${mapLicense( - license.name, - )}`) || - '

    ', - `

    ${categoryName}

    `, - owner && - `${ - owner.login - }`, - '
  • ', - ].join(''); - -const buttonHTLM = valueNames - .filter(x => !['description', 'homepage'].includes(x)) - .map(v => ``) - .join(''); - -const processMetadata = metaData => - [ - `
    `, - `
    `, - `

    Sort by

    ${buttonHTLM}
    `, - `
    `, - '
      ', - Object.values(metaData) - .map(formatEntry) - .join(''), - '
    ', - ].join(''); - -const normalizedMetadata = ([mapping, category, data]) => - data.reduce((acc, repo) => { - const m = mapping[repo.html_url]; - if (!m) { - console.log('MISSING:', { repo: repo.html_url }); - return acc; - } - const c = m && category[m.category]; - if (!c) { - console.log('CATEGORY MISSING', { mapping: m }); - return acc; - } - return { - ...acc, - ...{ - [repo.html_url.toLowerCase()]: { - ...repo, - ownerType: repo.owner && repo.owner.type, - categoryName: c.name, - categoryDescription: c.description, - status: m.status, - }, - }, - }; - }, {}); - -async function processTable() { - try { - LOG.debug('Loading files...', { LATEST_FILENAME, tableTemplate }); - const latestFilename = await fs.readFile(LATEST_FILENAME, 'utf8'); - LOG.debug({ latestFilename }); - - const data = await Promise.all([ - fs.readJSON(MAPPING), - fs.readJSON(CATEGORY), - fs.readJSON(latestFilename), - ]); - - const metaData = normalizedMetadata(data); - LOG.debug({ metaData }); - const template = await fs.readFile(tableTemplate, 'utf8'); - LOG.debug('Processing template'); - const $ = cheerio.load(template); - $('#md').append(processMetadata(metaData)); - LOG.debug('Writing table.html'); - await fs.outputFile(tableDestination, $.html(), 'utf8'); - LOG.debug('✅ DONE 👍'); - } catch (err) { - handleFailure(err); - } -} - async function processIndex() { const converter = new showdown.Converter({ omitExtraWLInCodeBlocks: true, @@ -286,8 +98,6 @@ const bundle = () => { }; async function main() { - emojiMapURL = await loadEmoji(); - await processTable(); await processIndex(); await bundle(); } diff --git a/package.json b/package.json index 7663ec5..2b2815a 100644 --- a/package.json +++ b/package.json @@ -18,11 +18,8 @@ "homepage": "https://github.com/veggiemonk/awesome-docker#readme", "dependencies": { "cheerio": "1.0.0-rc.3", - "dayjs": "1.8.19", "draftlog": "1.0.12", "fs-extra": "8.1.0", - "list.js": "1.5.0", - "node-fetch": "2.6.0", "parcel-bundler": "1.12.4", "rimraf": "3.0.0", "showdown": "1.9.1", @@ -38,4 +35,4 @@ "eslint-plugin-prettier": "3.1.2", "prettier": "1.19.1" } -} +} \ No newline at end of file diff --git a/website/index.js b/website/index.js deleted file mode 100644 index 7614828..0000000 --- a/website/index.js +++ /dev/null @@ -1,19 +0,0 @@ -const List = require('list.js'); - -const main = () => { - const userList = new List('md', { - valueNames: [ - 'name', - 'description', - 'homepage', - { name: 'star', attr: 'data-stars' }, - { name: 'updated', attr: 'data-timestamp' }, - 'language', - 'license', - 'author', - ], - }); - console.log(`There are ${userList.size()} projects`); -}; - -main(); diff --git a/website/index.tmpl.html b/website/index.tmpl.html index 4be111c..e0ef6bb 100644 --- a/website/index.tmpl.html +++ b/website/index.tmpl.html @@ -207,8 +207,6 @@ View on GitHub - View Beta -
    - - - - - - http://awesome-docker.netlify.com/ - 2018-04-22T10:28:08+00:00 - - - - \ No newline at end of file diff --git a/website/style.css b/website/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/website/table.tmpl.html b/website/table.tmpl.html deleted file mode 100644 index f78abbf..0000000 --- a/website/table.tmpl.html +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - Awesome-docker - - - - - - - - - - - -
    -

    Awesome-docker

    -

    A curated list of Docker resources and projects

    -
    View on GitHub -
    - - Star -
    -
    - - - - - - \ No newline at end of file