Fix regex for links

This commit is contained in:
Julien Bisconti 2020-04-13 17:02:33 +02:00
parent 3ddaea3999
commit 6e85932357
No known key found for this signature in database
GPG Key ID: 62772C6698F736CB
3 changed files with 16 additions and 11 deletions

View File

@ -120,7 +120,7 @@ _Source:_ [What is Docker](https://www.docker.com/why-docker)
- [Exploring ASP.NET Core with Docker in both Linux and Windows Containers](https://www.hanselman.com/blog/ExploringASPNETCoreWithDockerInBothLinuxAndWindowsContainers.aspx) Running ASP.NET Core apps in Linux and Windows containers, using [Docker for Windows][docker-for-windows]
- [Running a Legacy ASP.NET App in a Windows Container](https://blog.sixeyed.com/dockerizing-nerd-dinner-part-1-running-a-legacy-asp-net-app-in-a-windows-container/) Steps for Dockerizing a legacy ASP.NET app and runnning as a Windows container
- [Windows Containers and Docker: The 101](https://www.youtube.com/watch?v=N7SG2wEyQtM) :movie_camera: - A 20-minute overview, using Docker to run PowerShell, ASP.NET Core and ASP.NET apps
- [Windows Containers Quick Start](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/index) Overview of Windows containers, drilling down to Quick Starts for Windows 10 and Windows Server 2016
- [Windows Containers Quick Start](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/) Overview of Windows containers, drilling down to Quick Starts for Windows 10 and Windows Server 2016
---
@ -659,7 +659,7 @@ Services to securely store your Docker images.
## Awesome Lists
- [Awesome CI/CD](https://github.com/ciandcd/awesome-ciandcd) - Not specific to docker but relevant.
- [Awesome CI/CD](https://github.com/cicdops/awesome-ciandcd) - Not specific to docker but relevant.
- [Awesome Kubernetes](https://github.com/ramitsurana/awesome-kubernetes) by [@ramitsurana][ramitsurana]
- [Awesome Linux Container](https://github.com/Friz-zy/awesome-linux-containers) more general about container than this repo, by [@Friz-zy](https://github.com/Friz-zy).
- [Awesome Selfhosted](https://github.com/awesome-selfhosted/awesome-selfhosted) list of Free Software network services and web applications which can be hosted locally by running in a classical way (setup local web server and run applications from there) or in a Docker container. By [@Kickball](https://github.com/Kickball)

4
exclude_in_test.json Normal file
View File

@ -0,0 +1,4 @@
{
"https://vimeo.com": true,
"https://travis-ci.org/veggiemonk/awesome-docker.svg": true
}

View File

@ -1,5 +1,6 @@
const fs = require('fs-extra');
const fetch = require('node-fetch');
const exclude = require('./exclude_in_test.json');
function envvar_undefined(variable_name) {
throw new Error(`${variable_name} must be defined`);
@ -37,16 +38,13 @@ const make_GQL_options = (query) => ({
const LOG = {
error: (...args) => console.error('❌ ERROR', args),
error_string: (...args) =>
console.error(
'❌ ERROR',
args.map((a) => JSON.stringify(a)),
),
console.error('❌ ERROR', JSON.stringify({ ...args }, null, ' ')),
debug: (...args) => {
if (process.env.DEBUG) console.log('>>> DEBUG: ', { ...args });
},
debug_string: (...args) => {
if (process.env.DEBUG)
console.log('>>> DEBUG: ', JSON.stringify({ ...args }));
console.log('>>> DEBUG: ', JSON.stringify({ ...args }, null, ' '));
},
};
@ -60,7 +58,8 @@ process.on('unhandledRejection', handleFailure);
const extract_all_links = (markdown) => {
// if you have a problem and you try to solve it with a regex,
// now you have two problems
const re = /(((https:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/g;
// TODO: replace this mess with a mardown parser ?
const re = /(((https:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/@\-\\\w]*))?)/g;
return markdown.match(re);
};
@ -139,10 +138,12 @@ const generate_GQL_query = (arr) =>
async function main() {
const markdown = await fs.readFile(README, 'utf8');
const links = extract_all_links(markdown);
let links = extract_all_links(markdown);
links = links.filter((l) => !exclude[l]); // exclude websites
const duplicates = find_duplicates(links);
if (duplicates.length > 0) {
LOG.error('duplicates', duplicates);
LOG.error_string({ duplicates });
}
const [github_links, other_links] = partition(links, (link) =>
link.startsWith('https://github.com'),
@ -155,7 +156,7 @@ async function main() {
BATCH_SIZE: 8,
});
if (other_links_error.length > 0) {
LOG.error('other_links_error', other_links_error);
LOG.error({ other_links_error });
}
const repos = extract_repos(github_links);