@@ -3,12 +3,14 @@ const path = require('path');
33const fs = require ( 'fs' ) ;
44const { flatten } = require ( 'array-flatten' ) ;
55
6- // console.log(flatten);
7-
8- // process.exit(0);
9-
106dotenv . config ( ) ;
117
8+ // eslint-disable-next-line no-unused-vars
9+ const logger = ( name ) => {
10+ console . log ( name ) ;
11+ return name ;
12+ } ;
13+
1214/**
1315 * ArticleBuilder
1416 * @class
@@ -66,20 +68,20 @@ class ArticleBuilder {
6668 } ;
6769 let plugins = this . pluginCollector ( path . resolve ( './source/plugins' ) ) ;
6870 // eslint-disable-next-line import/no-dynamic-require, global-require
69- plugins = plugins . map ( uri => ( require ( uri ) ) ) ;
71+ plugins = plugins . map ( ( uri ) => ( require ( uri ) ) ) ;
7072
71- await flatten ( this . stages
73+ return flatten ( this . stages
7274 // remove stages we should skip
73- . filter ( stage => ( ! this . skip . stages . includes ( stage ) ) )
75+ . filter ( ( stage ) => ( ! this . skip . stages . includes ( stage ) ) )
7476 // map stages to plugins array
75- . map ( stage => plugins
77+ . map ( ( stage ) => plugins
7678 // filter plugin that have no functions for this stage
77- . filter ( plugin => ( ( plugin [ stage ] !== undefined ) && ( typeof plugin [ stage ] === 'function' ) ) )
79+ . filter ( ( plugin ) => ( ( plugin [ stage ] !== undefined ) && ( typeof plugin [ stage ] === 'function' ) ) )
7880 // filter plugin we need to skip
7981 . filter ( ( plugin ) => {
8082 const { meta : { name } } = plugin ;
8183 return ( this . skip . plugins . find (
82- skippedPlugin => (
84+ ( skippedPlugin ) => (
8385 (
8486 skippedPlugin . name === name
8587 && skippedPlugin . stages === undefined
@@ -99,8 +101,9 @@ class ArticleBuilder {
99101 . sort ( ( pluginA , pluginB ) => (
100102 pluginA . meta . dependency . includes ( pluginB . meta . name )
101103 ? 1 : - 1 ) )
104+ // .map(logger)
102105 // map plugins to functions
103- . map ( plugin => ( plugin [ stage ] ) ) ) )
106+ . map ( ( plugin ) => ( plugin [ stage ] ) ) ) )
104107 . reduce ( async ( state , plugin ) => {
105108 const resolvedState = await state ;
106109 return plugin ( resolvedState ) ;
@@ -109,9 +112,32 @@ class ArticleBuilder {
109112}
110113
111114// (async () => {
115+ // const builder = new ArticleBuilder();
116+ // builder.skip.stages = [
117+ // 'github:before',
118+ // 'github',
119+ // 'github:after',
120+ // ];
121+ // builder.skip.plugins = [
122+ // { name: 'codepenTransform' },
123+ // { name: 'codepenTransformIFrame' },
124+ // { name: 'createREADME' },
125+ // { name: 'downloadImages' },
126+ // { name: 'writeMarkdown' },
127+ // { name: 'TMPDir' },
128+ // { name: 'initGithub' },
129+ // { name: 'uploadToRepo' },
130+ // { name: 'createRepo' },
131+ // { name: 'createREADME' },
132+ // { name: 'createCard' },
133+ // ];
134+
112135// try {
113- // const builder = new ArticleBuilder();
114- // await builder.create('https://www.smashingmagazine.com/2020/05/convince-others-against-dark-patterns/');
136+ // const result = await builder.create('https://increment.com/frontend/a-users-guide-to-css-variables/');
137+ // // console.log(result);
138+ // console.log(result.tags);
139+ // console.log(result.mercury[0].author);
140+ // console.log(result.openGraph);
115141// } catch (error) {
116142// console.log(error);
117143// }
0 commit comments