Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ package-lock.json
internal-links.tap
stats.json
printable.md
repositories/*.json
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
"clean-dist": "rimraf ./dist",
"clean-printable": "rimraf src/content/**/printable.md",
"preclean": "run-s clean-dist clean-printable",
"clean": "rimraf src/content/**/_*.md src/**/_*.json",
"clean": "rimraf src/content/**/_*.md src/**/_*.json repositories/*.json",
"start": "npm run clean-dist && cross-env NODE_ENV=development webpack-dev-server --config webpack.dev.js --env.dev",
"update-repos": "node src/utilities/fetch-package-repos.js",
"content": "node src/scripts/build-content-tree.js ./src/content ./src/_content.json",
"bundle-analyze": "run-s clean fetch printable content && cross-env NODE_ENV=production webpack --config webpack.ssg.js && run-s clean-printable content && cross-env NODE_ENV=production webpack --config webpack.prod.js --profile --json > stats.json && webpack-bundle-analyzer stats.json",
"fetch-repos": "node src/utilities/fetch-package-repos.js",
"fetch": "run-p fetch:*",
"fetch:readmes": "node src/utilities/fetch-package-readmes.js",
"fetch:supporters": "node src/utilities/fetch-supporters.js",
"fetch:starter-kits": "node src/utilities/fetch-starter-kits.js",
"prebuild": "npm run clean",
"build": "run-s fetch printable content && cross-env NODE_ENV=production webpack --config webpack.ssg.js && run-s clean-printable content && cross-env NODE_ENV=production webpack --config webpack.prod.js",
"build": "run-s fetch-repos fetch printable content && cross-env NODE_ENV=production webpack --config webpack.ssg.js && run-s clean-printable content && cross-env NODE_ENV=production webpack --config webpack.prod.js",
"postbuild": "npm run sitemap",
"build-test": "npm run build && http-server dist/",
"test": "npm run lint",
Expand Down
32 changes: 0 additions & 32 deletions repositories/loaders.json

This file was deleted.

11 changes: 0 additions & 11 deletions repositories/plugins.json

This file was deleted.

30 changes: 30 additions & 0 deletions src/utilities/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const excludedLoaders = [
'webpack-contrib/config-loader',
'webpack-contrib/eslint-loader',
'webpack-contrib/transform-loader',
'webpack-contrib/json-loader',
'webpack-contrib/script-loader',
'webpack-contrib/bundle-loader',
'webpack-contrib/i18n-loader',
'webpack-contrib/jshint-loader',
'webpack-contrib/coverjs-loader',
'webpack-contrib/coffee-redux-loader',
'webpack-contrib/react-proxy-loader',
'webpack-contrib/multi-loader',
'webpack-contrib/yaml-frontmatter-loader',
'webpack-contrib/restyle-loader',
'webpack-contrib/gzip-loader'
];
const excludedPlugins = [
'webpack-contrib/component-webpack-plugin',
'webpack-contrib/extract-text-webpack-plugin',
'webpack-contrib/i18n-webpack-plugin',
'webpack-contrib/babel-minify-webpack-plugin',
'webpack-contrib/uglifyjs-webpack-plugin',
'webpack-contrib/zopfli-webpack-plugin'
];

module.exports = {
excludedLoaders,
excludedPlugins
};
9 changes: 5 additions & 4 deletions src/utilities/fetch-package-repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ const path = require('path');
const mkdirp = require('mkdirp');
const _ = require('lodash');
const GithubAPI = require('@octokit/rest');
const { excludedLoaders, excludedPlugins } = require('./constants');

const fetch = {
loaders: [
{
organization: 'webpack-contrib',
suffixes: ['-loader'],
hides: ['webpack-contrib/config-loader']
hides: excludedLoaders
},
'babel/babel-loader',
'postcss/postcss-loader',
'peerigon/extract-loader'
'peerigon/extract-loader',
'Banno/polymer-webpack-loader'
],
plugins: [
{
organization: 'webpack-contrib',
suffixes: ['-webpack-plugin', '-extract-plugin'],
hides: ['webpack-contrib/component-webpack-plugin']
hides: excludedPlugins
}
]
};
Expand Down
35 changes: 31 additions & 4 deletions src/utilities/process-readme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const url = require('url');
const { excludedLoaders, excludedPlugins } = require('./constants');

const beginsWithDocsDomainRegex = /^(?:https?:)\/\/webpack\.js\.org/;
const inlineLinkRegex = /\[[^\]]*\]\(([^)]+)\)/g;
Expand Down Expand Up @@ -66,8 +67,18 @@ function linkFixerFactory(sourceUrl) {
};
}

function getMatches(string, regex) {
const matches = [];
let match;
// eslint-disable-next-line
while (match = regex.exec(string)) {
matches.push(match);
}
return matches;
}

module.exports = function processREADME(body, options = {}) {
return body
let processingString = body
.replace(/[^]*?<div align="center">([^]*?)<\/div>/, (match, content) => {
let parsed = content.match(/<p>([^]*?)<\/?p>/);
return parsed ? parsed[1] : '';
Expand All @@ -82,12 +93,28 @@ module.exports = function processREADME(body, options = {}) {
// EXAMPLE: [line-identifier]: https://webpack.js.org/loaders/
.replace(inlineLinkRegex, linkFixerFactory(options.source))
.replace(externalLinkRegex, linkFixerFactory(options.source))
// Modify links to keep them within the site
.replace(/https?:\/\/github.com\/(webpack|webpack-contrib)\/([-A-za-z0-9]+-loader\/?)([)"])/g, '/loaders/$2/$3')
.replace(/https?:\/\/github.com\/(webpack|webpack-contrib)\/([-A-za-z0-9]+-plugin\/?)([)"])/g, '/plugins/$2/$3')
// Replace any <h2> with `##`
.replace(/<h2[^>]*>/g, '## ')
.replace(/<\/h2>/g, '')
// Drop any comments
.replace(/<!--[\s\S]*?-->/g, '');

// find the laoders links
const loaderMatches = getMatches(processingString, /https?:\/\/github.com\/(webpack|webpack-contrib)\/([-A-za-z0-9]+-loader\/?)([)"])/g);
// dont make relative links for excluded loaders
loaderMatches.forEach((match) => {
if (!excludedLoaders.includes(`${match[1]}/${match[2]}`)) {
processingString = processingString.replace(match[0], `/loaders/${match[2]}`);
}
});

const pluginMatches = getMatches(processingString, /https?:\/\/github.com\/(webpack|webpack-contrib)\/([-A-za-z0-9]+-plugin\/?)([)"])/g);
// dont make relative links for excluded loaders
pluginMatches.forEach((match) => {
if (!excludedPlugins.includes(`${match[1]}/${match[2]}`)) {
processingString = processingString.replace(match[0], `/plugins/${match[2]}`);
}
});

return processingString;
};