@podlite/publisher 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE +22 -0
- package/README.md +41 -0
- package/esm/breadcrumb-plugin.d.ts +3 -0
- package/esm/breadcrumb-plugin.js +34 -0
- package/esm/breadcrumb-plugin.js.map +1 -0
- package/esm/constants.d.ts +27 -0
- package/esm/constants.js +28 -0
- package/esm/constants.js.map +1 -0
- package/esm/images-plugin.d.ts +3 -0
- package/esm/images-plugin.js +60 -0
- package/esm/images-plugin.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +5 -0
- package/esm/index.js.map +1 -0
- package/esm/links-plugin.d.ts +3 -0
- package/esm/links-plugin.js +87 -0
- package/esm/links-plugin.js.map +1 -0
- package/esm/node-utils.d.ts +50 -0
- package/esm/node-utils.js +376 -0
- package/esm/node-utils.js.map +1 -0
- package/esm/plugins.d.ts +138 -0
- package/esm/plugins.js +147 -0
- package/esm/plugins.js.map +1 -0
- package/esm/pubdate-plugin.d.ts +9 -0
- package/esm/pubdate-plugin.js +137 -0
- package/esm/pubdate-plugin.js.map +1 -0
- package/esm/react-plugin.d.ts +3 -0
- package/esm/react-plugin.js +109 -0
- package/esm/react-plugin.js.map +1 -0
- package/esm/shared.d.ts +36 -0
- package/esm/shared.js +157 -0
- package/esm/shared.js.map +1 -0
- package/esm/site-data-plugin.d.ts +25 -0
- package/esm/site-data-plugin.js +135 -0
- package/esm/site-data-plugin.js.map +1 -0
- package/esm/state-version-plugin.d.ts +3 -0
- package/esm/state-version-plugin.js +23 -0
- package/esm/state-version-plugin.js.map +1 -0
- package/esm/template-plugin.d.ts +3 -0
- package/esm/template-plugin.js +10 -0
- package/esm/template-plugin.js.map +1 -0
- package/esm/terms-index-plugin.d.ts +5 -0
- package/esm/terms-index-plugin.js +108 -0
- package/esm/terms-index-plugin.js.map +1 -0
- package/lib/breadcrumb-plugin.d.ts +3 -0
- package/lib/breadcrumb-plugin.js +36 -0
- package/lib/constants.d.ts +27 -0
- package/lib/constants.js +34 -0
- package/lib/images-plugin.d.ts +3 -0
- package/lib/images-plugin.js +84 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +17 -0
- package/lib/links-plugin.d.ts +3 -0
- package/lib/links-plugin.js +89 -0
- package/lib/node-utils.d.ts +50 -0
- package/lib/node-utils.js +412 -0
- package/lib/plugins.d.ts +138 -0
- package/lib/plugins.js +153 -0
- package/lib/pubdate-plugin.d.ts +9 -0
- package/lib/pubdate-plugin.js +143 -0
- package/lib/react-plugin.d.ts +3 -0
- package/lib/react-plugin.js +130 -0
- package/lib/shared.d.ts +36 -0
- package/lib/shared.js +169 -0
- package/lib/site-data-plugin.d.ts +25 -0
- package/lib/site-data-plugin.js +159 -0
- package/lib/state-version-plugin.d.ts +3 -0
- package/lib/state-version-plugin.js +44 -0
- package/lib/template-plugin.d.ts +3 -0
- package/lib/template-plugin.js +12 -0
- package/lib/terms-index-plugin.d.ts +5 -0
- package/lib/terms-index-plugin.js +129 -0
- package/package.json +52 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { getFromTree, getTextContentFromNode, makeAttrs, makeInterator, } from '@podlite/schema';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { getAllArticles, isExistsPubdate, makeAstFromSrc } from './shared';
|
|
5
|
+
import { parseMd } from '@podlite/markdown';
|
|
6
|
+
import { podlite } from 'podlite';
|
|
7
|
+
import matter from 'gray-matter';
|
|
8
|
+
const glob = require('glob');
|
|
9
|
+
export const getPathToOpen = (filepath, parentDocPath) => {
|
|
10
|
+
const isRemoteReg = new RegExp(/^(https?|ftp):/);
|
|
11
|
+
const isRemote = isRemoteReg.test(filepath);
|
|
12
|
+
if (isRemote) {
|
|
13
|
+
return { isRemote, path: filepath };
|
|
14
|
+
}
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const docDirPath = path.dirname(parentDocPath);
|
|
17
|
+
return {
|
|
18
|
+
isRemote,
|
|
19
|
+
path: path.isAbsolute(filepath) ? filepath : path.normalize(path.join(docDirPath, filepath)),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const makeLinksMap = (records) => {
|
|
23
|
+
const linksMap = {
|
|
24
|
+
...Object.fromEntries(records.map(({ publishUrl = '', file }) => [getPathToOpen(file, './').path, publishUrl])),
|
|
25
|
+
};
|
|
26
|
+
return linksMap;
|
|
27
|
+
};
|
|
28
|
+
export const convertFileLinksToUrl = (records, additinalMap = {}) => {
|
|
29
|
+
const linksMap = { ...additinalMap, ...makeLinksMap(records) };
|
|
30
|
+
const processed = records.map(item => {
|
|
31
|
+
const converter = makeInterator({
|
|
32
|
+
'L<>': (node, ctx, interator) => {
|
|
33
|
+
const { content, meta } = node;
|
|
34
|
+
const link = meta ? meta : getTextContentFromNode(content);
|
|
35
|
+
const r = link.match(/file:\s*(?<path>(.+))\s*$/);
|
|
36
|
+
const convertFileToUrl = filePath => {
|
|
37
|
+
const { isRemote, path } = getPathToOpen(filePath, item.file);
|
|
38
|
+
return isRemote ? null : linksMap[path];
|
|
39
|
+
};
|
|
40
|
+
const newLink = r?.groups?.path ? convertFileToUrl(r.groups.path) : link;
|
|
41
|
+
const newContent = {
|
|
42
|
+
type: 'text',
|
|
43
|
+
value: newLink,
|
|
44
|
+
};
|
|
45
|
+
const updated = meta ? { meta: newLink } : { content: newContent };
|
|
46
|
+
return { ...node, ...updated };
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const res = converter(item.node, {});
|
|
50
|
+
// process images inside description
|
|
51
|
+
let extra = {};
|
|
52
|
+
// process item description header and footer
|
|
53
|
+
const { footer, header, description } = item;
|
|
54
|
+
if (description) {
|
|
55
|
+
extra.description = converter(description, {});
|
|
56
|
+
}
|
|
57
|
+
if (footer) {
|
|
58
|
+
extra.footer = converter(footer, {});
|
|
59
|
+
}
|
|
60
|
+
if (header) {
|
|
61
|
+
extra.header = converter(header, {});
|
|
62
|
+
}
|
|
63
|
+
return { ...item, node: res, ...extra };
|
|
64
|
+
});
|
|
65
|
+
return processed;
|
|
66
|
+
};
|
|
67
|
+
export function parseFiles(path) {
|
|
68
|
+
let count = 0;
|
|
69
|
+
const allFiles = glob
|
|
70
|
+
.sync(path)
|
|
71
|
+
.map((f) => {
|
|
72
|
+
count++;
|
|
73
|
+
const testData = fs.readFileSync(f).toString();
|
|
74
|
+
const asAst = makeAstFromSrc(testData);
|
|
75
|
+
// now check if tree contains block with :pubdate attribute
|
|
76
|
+
// '* :pubdate'
|
|
77
|
+
if (!isExistsPubdate(asAst)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// extract notes
|
|
81
|
+
const notes = getFromTree(asAst, 'para')
|
|
82
|
+
.filter(n => makeAttrs(n, {}).exists('pubdate'))
|
|
83
|
+
.map((n) => {
|
|
84
|
+
const a_pubdate = makeAttrs(n, {}).getFirstValue('pubdate');
|
|
85
|
+
// Due to cover some cases whan new Date fail on safari, i.e.
|
|
86
|
+
// new Date("2022-05-07 10:00:00").getFullYear() -> NaN
|
|
87
|
+
// convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
|
|
88
|
+
const pubdate = a_pubdate.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
|
|
89
|
+
? a_pubdate.replace(' ', 'T')
|
|
90
|
+
: a_pubdate;
|
|
91
|
+
return {
|
|
92
|
+
pubdate,
|
|
93
|
+
type: 'note',
|
|
94
|
+
node: n,
|
|
95
|
+
description: n,
|
|
96
|
+
file: f,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
const articles = getAllArticles([asAst]).map(({ ...all }) => ({ ...all, file: f }));
|
|
100
|
+
// note get full posts
|
|
101
|
+
const pages = getFromTree(asAst, 'pod')
|
|
102
|
+
.filter(n => makeAttrs(n, {}).exists('pubdate'))
|
|
103
|
+
.map((n) => {
|
|
104
|
+
const a_pubdate = makeAttrs(n, {}).getFirstValue('pubdate');
|
|
105
|
+
// Due to cover some cases whan new Date fail on safari, i.e.
|
|
106
|
+
// new Date("2022-05-07 10:00:00").getFullYear() -> NaN
|
|
107
|
+
// convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
|
|
108
|
+
const pubdate = a_pubdate.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
|
|
109
|
+
? a_pubdate.replace(' ', 'T')
|
|
110
|
+
: a_pubdate;
|
|
111
|
+
return {
|
|
112
|
+
pubdate,
|
|
113
|
+
type: 'page',
|
|
114
|
+
node: n,
|
|
115
|
+
file: f,
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
console.warn(` pages: ${pages.length} articles: ${articles.length}, notes: ${notes.length} from ${f}`);
|
|
119
|
+
return [...pages, ...articles, ...notes].map(item => {
|
|
120
|
+
return { ...item, file: f };
|
|
121
|
+
});
|
|
122
|
+
})
|
|
123
|
+
.flat()
|
|
124
|
+
.filter(Boolean);
|
|
125
|
+
return allFiles;
|
|
126
|
+
}
|
|
127
|
+
const PARSER_TYPES = {
|
|
128
|
+
MARKDOWN: 'markdown',
|
|
129
|
+
PODLITE: 'podlite',
|
|
130
|
+
DEFAULT: 'default',
|
|
131
|
+
ERROR: 'error',
|
|
132
|
+
};
|
|
133
|
+
const MIME_TYPES_EXTENSIONS = {
|
|
134
|
+
'text/podlite': ['.podlite', '.pod6'],
|
|
135
|
+
'text/markdown': ['.md', '.markdown'],
|
|
136
|
+
'text/plain': ['.txt'],
|
|
137
|
+
'audio/mpeg': ['.mp3'],
|
|
138
|
+
};
|
|
139
|
+
const PARSER_TYPE_MIME_TYPES = {
|
|
140
|
+
[PARSER_TYPES.PODLITE]: ['text/podlite'],
|
|
141
|
+
[PARSER_TYPES.MARKDOWN]: ['text/markdown'],
|
|
142
|
+
[PARSER_TYPES.DEFAULT]: ['text/plain'],
|
|
143
|
+
[PARSER_TYPES.ERROR]: ['audio/mpeg'],
|
|
144
|
+
};
|
|
145
|
+
export function getParserTypeforFile(filePath, mime) {
|
|
146
|
+
// get parser type using PARSER_TYPE_MIME_TYPES
|
|
147
|
+
if (mime) {
|
|
148
|
+
for (const [key, value] of Object.entries(PARSER_TYPE_MIME_TYPES)) {
|
|
149
|
+
if (value.includes(mime)) {
|
|
150
|
+
return key;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// if not found return default TODO: possible change to error
|
|
154
|
+
console.warn(`Mime type ${mime} not found, using default parser`);
|
|
155
|
+
return PARSER_TYPES.DEFAULT;
|
|
156
|
+
}
|
|
157
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
158
|
+
const parserTypeMap = {
|
|
159
|
+
'.md': PARSER_TYPES.MARKDOWN,
|
|
160
|
+
'.markdown': PARSER_TYPES.MARKDOWN,
|
|
161
|
+
'.podlite': PARSER_TYPES.PODLITE,
|
|
162
|
+
'.rakudoc': PARSER_TYPES.PODLITE,
|
|
163
|
+
'.pod6': PARSER_TYPES.PODLITE,
|
|
164
|
+
};
|
|
165
|
+
return parserTypeMap[ext] || PARSER_TYPES.DEFAULT;
|
|
166
|
+
}
|
|
167
|
+
export function parseFile(filePath, fileContent, mime) {
|
|
168
|
+
// check extension of file and parse it deepnds on mime type
|
|
169
|
+
const parser_type = getParserTypeforFile(filePath, mime);
|
|
170
|
+
const typeToParserMap = {
|
|
171
|
+
[PARSER_TYPES.PODLITE]: (src) => {
|
|
172
|
+
const podlite_processor = podlite({ importPlugins: true }).use({});
|
|
173
|
+
const tree = podlite_processor.parse(src, { skipChain: 0, podMode: 1 });
|
|
174
|
+
return podlite_processor.toAstResult(tree).interator;
|
|
175
|
+
},
|
|
176
|
+
//@ts-ignore TODO: fix this
|
|
177
|
+
[PARSER_TYPES.MARKDOWN]: (src) => {
|
|
178
|
+
const { content } = matter(src);
|
|
179
|
+
return parseMd(content);
|
|
180
|
+
},
|
|
181
|
+
[PARSER_TYPES.DEFAULT]: (src) => {
|
|
182
|
+
const podlite_processor = podlite({ importPlugins: true }).use({});
|
|
183
|
+
const tree = podlite_processor.parse(src, { skipChain: 0, podMode: 0 });
|
|
184
|
+
return podlite_processor.toAstResult(tree).interator;
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
const src = fileContent || fs.readFileSync(filePath).toString();
|
|
188
|
+
return typeToParserMap[parser_type](src);
|
|
189
|
+
}
|
|
190
|
+
export function getDocumentAttributes(node) {
|
|
191
|
+
// filling title
|
|
192
|
+
let title = '';
|
|
193
|
+
let description = '';
|
|
194
|
+
let subtitle;
|
|
195
|
+
let author;
|
|
196
|
+
let footer = '';
|
|
197
|
+
let header = null;
|
|
198
|
+
makeInterator({
|
|
199
|
+
NAME: (node, ctx, interator) => {
|
|
200
|
+
title = getTextContentFromNode(node);
|
|
201
|
+
},
|
|
202
|
+
TITLE: (node, ctx, interator) => {
|
|
203
|
+
title = getTextContentFromNode(node);
|
|
204
|
+
},
|
|
205
|
+
DESCRIPTION: (node, ctx, interator) => {
|
|
206
|
+
description = node.content;
|
|
207
|
+
},
|
|
208
|
+
SUBTITLE: (node, ctx, interator) => {
|
|
209
|
+
subtitle = getTextContentFromNode(node);
|
|
210
|
+
},
|
|
211
|
+
AUTHOR: (node, ctx, interator) => {
|
|
212
|
+
const attr = makeAttrs(node, ctx);
|
|
213
|
+
author = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
|
|
214
|
+
},
|
|
215
|
+
FOOTER: (node, ctx, interator) => {
|
|
216
|
+
footer = node.content;
|
|
217
|
+
},
|
|
218
|
+
HEADER: (node, ctx, interator) => {
|
|
219
|
+
header = node.content;
|
|
220
|
+
},
|
|
221
|
+
})(node, {});
|
|
222
|
+
const props = {
|
|
223
|
+
title,
|
|
224
|
+
description,
|
|
225
|
+
subtitle,
|
|
226
|
+
author,
|
|
227
|
+
footer,
|
|
228
|
+
puburl: undefined,
|
|
229
|
+
pubdate: undefined,
|
|
230
|
+
...(header && { header }),
|
|
231
|
+
};
|
|
232
|
+
const [podnode] = getFromTree(node.content, 'pod');
|
|
233
|
+
if (podnode) {
|
|
234
|
+
// prepare publishUrl
|
|
235
|
+
const conf = makeAttrs(podnode, {});
|
|
236
|
+
props.puburl = conf.exists('puburl')
|
|
237
|
+
? conf.getFirstValue('puburl')
|
|
238
|
+
: // check old publishUrl attribute
|
|
239
|
+
conf.exists('publishUrl')
|
|
240
|
+
? conf.getFirstValue('publishUrl')
|
|
241
|
+
: undefined;
|
|
242
|
+
const a_pubdate = conf.getFirstValue('pubdate');
|
|
243
|
+
// Due to cover some cases whan new Date fail on safari, i.e.
|
|
244
|
+
// new Date("2022-05-07 10:00:00").getFullYear() -> NaN
|
|
245
|
+
// convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
|
|
246
|
+
props.pubdate = a_pubdate?.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
|
|
247
|
+
? a_pubdate.replace(' ', 'T')
|
|
248
|
+
: a_pubdate;
|
|
249
|
+
}
|
|
250
|
+
return props;
|
|
251
|
+
}
|
|
252
|
+
export function getPublishAttributes(node) {
|
|
253
|
+
// filling title
|
|
254
|
+
let title = '';
|
|
255
|
+
let description = '';
|
|
256
|
+
let subtitle;
|
|
257
|
+
let author;
|
|
258
|
+
let footer = '';
|
|
259
|
+
makeInterator({
|
|
260
|
+
NAME: (node, ctx, interator) => {
|
|
261
|
+
title = getTextContentFromNode(node);
|
|
262
|
+
},
|
|
263
|
+
TITLE: (node, ctx, interator) => {
|
|
264
|
+
title = getTextContentFromNode(node);
|
|
265
|
+
},
|
|
266
|
+
DESCRIPTION: (node, ctx, interator) => {
|
|
267
|
+
description = node.content;
|
|
268
|
+
},
|
|
269
|
+
SUBTITLE: (node, ctx, interator) => {
|
|
270
|
+
subtitle = getTextContentFromNode(node);
|
|
271
|
+
},
|
|
272
|
+
AUTHOR: (node, ctx, interator) => {
|
|
273
|
+
const attr = makeAttrs(node, ctx);
|
|
274
|
+
author = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
|
|
275
|
+
},
|
|
276
|
+
FOOTER: (node, ctx, interator) => {
|
|
277
|
+
footer = node.content;
|
|
278
|
+
},
|
|
279
|
+
})(node, {});
|
|
280
|
+
const props = {
|
|
281
|
+
title,
|
|
282
|
+
description,
|
|
283
|
+
subtitle,
|
|
284
|
+
author,
|
|
285
|
+
footer,
|
|
286
|
+
puburl: undefined,
|
|
287
|
+
pubdate: undefined,
|
|
288
|
+
};
|
|
289
|
+
const podnode = node;
|
|
290
|
+
if (podnode) {
|
|
291
|
+
// prepare publishUrl
|
|
292
|
+
const conf = makeAttrs(podnode, {});
|
|
293
|
+
props.puburl = conf.exists('puburl')
|
|
294
|
+
? conf.getFirstValue('puburl')
|
|
295
|
+
: // check old publishUrl attribute
|
|
296
|
+
conf.exists('publishUrl')
|
|
297
|
+
? conf.getFirstValue('publishUrl')
|
|
298
|
+
: undefined;
|
|
299
|
+
const a_pubdate = conf.getFirstValue('pubdate');
|
|
300
|
+
// Due to cover some cases whan new Date fail on safari, i.e.
|
|
301
|
+
// new Date("2022-05-07 10:00:00").getFullYear() -> NaN
|
|
302
|
+
// convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
|
|
303
|
+
props.pubdate = a_pubdate?.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
|
|
304
|
+
? a_pubdate.replace(' ', 'T')
|
|
305
|
+
: a_pubdate;
|
|
306
|
+
}
|
|
307
|
+
return props;
|
|
308
|
+
}
|
|
309
|
+
export function processFile(f, content, mime) {
|
|
310
|
+
const podlite_document = parseFile(f, content, mime);
|
|
311
|
+
// now extract some extra meta inforamtion, like pubdate, puburl
|
|
312
|
+
const attr = ((f, node) => {
|
|
313
|
+
if (getParserTypeforFile(f, mime) === PARSER_TYPES.MARKDOWN) {
|
|
314
|
+
// try to extract from markdown front matter
|
|
315
|
+
const { data } = matter(content || fs.readFileSync(f).toString());
|
|
316
|
+
return data;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
return getDocumentAttributes(podlite_document);
|
|
320
|
+
}
|
|
321
|
+
})(f, podlite_document);
|
|
322
|
+
// prepare attributes
|
|
323
|
+
const { title, description, subtitle, author, footer, puburl, pubdate, header } = attr;
|
|
324
|
+
return {
|
|
325
|
+
type: 'page',
|
|
326
|
+
title,
|
|
327
|
+
description,
|
|
328
|
+
subtitle,
|
|
329
|
+
author,
|
|
330
|
+
...(header && { header }),
|
|
331
|
+
footer,
|
|
332
|
+
publishUrl: puburl,
|
|
333
|
+
pubdate,
|
|
334
|
+
file: f,
|
|
335
|
+
sources: [],
|
|
336
|
+
node: podlite_document,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
export function parseSources(path) {
|
|
340
|
+
let count = 0;
|
|
341
|
+
const allFiles = glob
|
|
342
|
+
.sync(path)
|
|
343
|
+
.map((f) => {
|
|
344
|
+
count++;
|
|
345
|
+
return processFile(f);
|
|
346
|
+
})
|
|
347
|
+
.flat()
|
|
348
|
+
.filter(Boolean);
|
|
349
|
+
return allFiles;
|
|
350
|
+
}
|
|
351
|
+
export function streamWriteArray(array, outputPath) {
|
|
352
|
+
return new Promise((resolve, reject) => {
|
|
353
|
+
const writeStream = fs.createWriteStream(outputPath);
|
|
354
|
+
writeStream.write('[');
|
|
355
|
+
const writeItem = index => {
|
|
356
|
+
if (index >= array.length) {
|
|
357
|
+
writeStream.write(']');
|
|
358
|
+
writeStream.end();
|
|
359
|
+
resolve(1);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const item = array[index];
|
|
363
|
+
const json = JSON.stringify(item);
|
|
364
|
+
const data = index === 0 ? json : ',' + json;
|
|
365
|
+
if (writeStream.write(data)) {
|
|
366
|
+
setImmediate(() => writeItem(index + 1));
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
writeStream.once('drain', () => writeItem(index + 1));
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
writeItem(0);
|
|
373
|
+
writeStream.on('error', reject);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=node-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-utils.js","sourceRoot":"","sources":["../src/node-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,SAAS,EACT,aAAa,GAMd,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,MAAM,MAAM,aAAa,CAAA;AAGhC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE;IACvD,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAChD,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3C,IAAI,QAAQ,EAAE;QACZ,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;KACpC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAC9C,OAAO;QACL,QAAQ;QACR,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,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E,UAAU;IACvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,WAAW,GAAG,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;QAEpD,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAEtB,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE;YACxB,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE;gBACzB,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBACtB,WAAW,CAAC,GAAG,EAAE,CAAA;gBACjB,OAAO,CAAC,CAAC,CAAC,CAAA;gBACV,OAAM;aACP;YAED,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;YACzB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YACjC,MAAM,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAA;YAE5C,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;aACzC;iBAAM;gBACL,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;aACtD;QACH,CAAC,CAAA;QAED,SAAS,CAAC,CAAC,CAAC,CAAA;QAEZ,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACjC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/esm/plugins.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { PodliteDocument, PodNode } from '@podlite/schema';
|
|
2
|
+
export declare type pubRecord = {
|
|
3
|
+
type: string;
|
|
4
|
+
pubdate: string;
|
|
5
|
+
node: PodNode;
|
|
6
|
+
description?: PodNode;
|
|
7
|
+
file: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type publishRecord = pubRecord & {
|
|
10
|
+
title: string | null;
|
|
11
|
+
publishUrl: string;
|
|
12
|
+
sources: string[];
|
|
13
|
+
node: PodliteDocument;
|
|
14
|
+
pubdate: string | undefined;
|
|
15
|
+
template?: publishRecord | null;
|
|
16
|
+
header?: PodNode | null;
|
|
17
|
+
footer?: PodNode | null;
|
|
18
|
+
subtitle?: string | null;
|
|
19
|
+
pluginsData?: {
|
|
20
|
+
[name: string]: any;
|
|
21
|
+
};
|
|
22
|
+
template_file?: string;
|
|
23
|
+
};
|
|
24
|
+
export interface PodliteWebPluginContext {
|
|
25
|
+
[name: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export declare type PodliteWebPlugin = [
|
|
28
|
+
(rects: publishRecord[]) => publishRecord[],
|
|
29
|
+
(ctx: PodliteWebPluginContext) => {
|
|
30
|
+
[name: string]: any;
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
export interface PluginConfig {
|
|
34
|
+
name?: string;
|
|
35
|
+
plugin: PodliteWebPlugin;
|
|
36
|
+
includePatterns?: string | string[];
|
|
37
|
+
excludePatterns?: string | string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
=begin pod
|
|
41
|
+
=head1 filterFiles
|
|
42
|
+
|
|
43
|
+
This function filters an array of file names based on provided include and exclude patterns. It first converts the includePatterns and excludePatterns arguments into arrays, if they aren't already. The function then filters through the files array, including a file if it matches any of the include patterns (or if no include patterns are provided) and excluding it if it matches any of the exclude patterns. The function returns a new array containing the files that match the include criteria and do not match the exclude criteria.
|
|
44
|
+
|
|
45
|
+
=head2 Parameters
|
|
46
|
+
|
|
47
|
+
=begin item
|
|
48
|
+
B<files>
|
|
49
|
+
|
|
50
|
+
An array of strings, each representing a file name to be filtered.
|
|
51
|
+
=end item
|
|
52
|
+
=begin item
|
|
53
|
+
B<includePatterns>
|
|
54
|
+
|
|
55
|
+
Optional. A string or an array of strings representing the pattern(s) files must match to be included. If not provided, all files are considered to match the include criteria.
|
|
56
|
+
=end item
|
|
57
|
+
=begin item
|
|
58
|
+
B<excludePatterns>
|
|
59
|
+
|
|
60
|
+
Optional. A string or an array of strings representing the pattern(s) files must match to be excluded. If not provided, no files are excluded based on patterns.
|
|
61
|
+
=end item
|
|
62
|
+
|
|
63
|
+
=head2 Returns
|
|
64
|
+
|
|
65
|
+
An array of strings, each representing a file name that matched the include criteria and did not match the exclude criteria.
|
|
66
|
+
|
|
67
|
+
=end pod
|
|
68
|
+
*/
|
|
69
|
+
export declare function filterFiles(files: string[], includePatterns?: string | string[], excludePatterns?: string | string[]): string[];
|
|
70
|
+
/**
|
|
71
|
+
=begin pod
|
|
72
|
+
=head1 processPlugin
|
|
73
|
+
|
|
74
|
+
The function `processPlugin` processes a collection of publishing records based on a given
|
|
75
|
+
plugin configuration. It filters the items to determine which ones match specified inclusion
|
|
76
|
+
and exclusion patterns. Items that match are processed by the provided plugin function, while
|
|
77
|
+
items that do not match are passed through unchanged. Finally, it returns a tuple containing
|
|
78
|
+
the processed items and the result of calling the `onClose` function with a context object.
|
|
79
|
+
|
|
80
|
+
=head2 Parameters
|
|
81
|
+
|
|
82
|
+
=begin item
|
|
83
|
+
B<pluginConf>
|
|
84
|
+
|
|
85
|
+
An object of type `PluginConfig` that provides configuration for the plugin, including
|
|
86
|
+
the plugin processing function, inclusion patterns, and exclusion patterns.
|
|
87
|
+
=end item
|
|
88
|
+
=begin item
|
|
89
|
+
B<items>
|
|
90
|
+
|
|
91
|
+
An array of `publishRecord` objects representing the items to be processed by the plugin.
|
|
92
|
+
=end item
|
|
93
|
+
|
|
94
|
+
=head2 Returns
|
|
95
|
+
|
|
96
|
+
A tuple where the first element is an array of `publishRecord` objects representing
|
|
97
|
+
the processed and unprocessed items, and the second element is an object resulting
|
|
98
|
+
from calling the plugin's `onClose` function with a context object. This object may
|
|
99
|
+
contain arbitrary data based on the plugin's implementation.
|
|
100
|
+
|
|
101
|
+
=end pod
|
|
102
|
+
*/
|
|
103
|
+
export declare const processPlugin: (pluginConf: PluginConfig, items: publishRecord[], ctx?: {
|
|
104
|
+
[name: string]: any;
|
|
105
|
+
}) => [publishRecord[], {
|
|
106
|
+
[name: string]: any;
|
|
107
|
+
}];
|
|
108
|
+
/**
|
|
109
|
+
=begin pod
|
|
110
|
+
=head1 composePlugins
|
|
111
|
+
|
|
112
|
+
This function takes an array of PluginConfig objects and combines them into a single PluginConfig.
|
|
113
|
+
It does this by sequentially processing each PluginConfig in the array with the next,
|
|
114
|
+
effectively composing their behaviors into a single plugin configuration.
|
|
115
|
+
Each PluginConfig is expected to modify a shared state and context. The composition
|
|
116
|
+
is achieved by chaining the plugin functions within each PluginConfig, so that the
|
|
117
|
+
output (both state and context) of one plugin function becomes the input to the next.
|
|
118
|
+
|
|
119
|
+
=head2 Parameters
|
|
120
|
+
|
|
121
|
+
=begin item
|
|
122
|
+
B<configs>
|
|
123
|
+
|
|
124
|
+
An array of PluginConfig objects. Each PluginConfig is an object that represents
|
|
125
|
+
configuration for a plugin, which includes a plugin processing function and
|
|
126
|
+
potentially other settings.
|
|
127
|
+
=end item
|
|
128
|
+
|
|
129
|
+
=head2 Returns
|
|
130
|
+
|
|
131
|
+
Returns a single PluginConfig object that represents the composed configuration
|
|
132
|
+
of all the PluginConfig objects passed in the 'configs' array. This resulting
|
|
133
|
+
PluginConfig can be used to process items with the combined logic of all the
|
|
134
|
+
plugins defined in the input array.
|
|
135
|
+
|
|
136
|
+
=end pod
|
|
137
|
+
*/
|
|
138
|
+
export declare const composePlugins: (configs: PluginConfig[], inintCtx?: {}) => PluginConfig;
|
package/esm/plugins.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
=begin pod
|
|
3
|
+
=head1 filterFiles
|
|
4
|
+
|
|
5
|
+
This function filters an array of file names based on provided include and exclude patterns. It first converts the includePatterns and excludePatterns arguments into arrays, if they aren't already. The function then filters through the files array, including a file if it matches any of the include patterns (or if no include patterns are provided) and excluding it if it matches any of the exclude patterns. The function returns a new array containing the files that match the include criteria and do not match the exclude criteria.
|
|
6
|
+
|
|
7
|
+
=head2 Parameters
|
|
8
|
+
|
|
9
|
+
=begin item
|
|
10
|
+
B<files>
|
|
11
|
+
|
|
12
|
+
An array of strings, each representing a file name to be filtered.
|
|
13
|
+
=end item
|
|
14
|
+
=begin item
|
|
15
|
+
B<includePatterns>
|
|
16
|
+
|
|
17
|
+
Optional. A string or an array of strings representing the pattern(s) files must match to be included. If not provided, all files are considered to match the include criteria.
|
|
18
|
+
=end item
|
|
19
|
+
=begin item
|
|
20
|
+
B<excludePatterns>
|
|
21
|
+
|
|
22
|
+
Optional. A string or an array of strings representing the pattern(s) files must match to be excluded. If not provided, no files are excluded based on patterns.
|
|
23
|
+
=end item
|
|
24
|
+
|
|
25
|
+
=head2 Returns
|
|
26
|
+
|
|
27
|
+
An array of strings, each representing a file name that matched the include criteria and did not match the exclude criteria.
|
|
28
|
+
|
|
29
|
+
=end pod
|
|
30
|
+
*/
|
|
31
|
+
export function filterFiles(files, includePatterns, excludePatterns) {
|
|
32
|
+
const patternArray = includePatterns ? (Array.isArray(includePatterns) ? includePatterns : [includePatterns]) : ['.*'];
|
|
33
|
+
const excludePatternArray = excludePatterns
|
|
34
|
+
? Array.isArray(excludePatterns)
|
|
35
|
+
? excludePatterns
|
|
36
|
+
: [excludePatterns]
|
|
37
|
+
: [];
|
|
38
|
+
return files.filter(file => {
|
|
39
|
+
const include = patternArray.length === 0 ? true : patternArray.some(pattern => new RegExp(pattern).test(file));
|
|
40
|
+
const exclude = excludePatternArray.length === 0 ? false : excludePatternArray.some(pattern => new RegExp(pattern).test(file));
|
|
41
|
+
return include && !exclude;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
=begin pod
|
|
46
|
+
=head1 processPlugin
|
|
47
|
+
|
|
48
|
+
The function `processPlugin` processes a collection of publishing records based on a given
|
|
49
|
+
plugin configuration. It filters the items to determine which ones match specified inclusion
|
|
50
|
+
and exclusion patterns. Items that match are processed by the provided plugin function, while
|
|
51
|
+
items that do not match are passed through unchanged. Finally, it returns a tuple containing
|
|
52
|
+
the processed items and the result of calling the `onClose` function with a context object.
|
|
53
|
+
|
|
54
|
+
=head2 Parameters
|
|
55
|
+
|
|
56
|
+
=begin item
|
|
57
|
+
B<pluginConf>
|
|
58
|
+
|
|
59
|
+
An object of type `PluginConfig` that provides configuration for the plugin, including
|
|
60
|
+
the plugin processing function, inclusion patterns, and exclusion patterns.
|
|
61
|
+
=end item
|
|
62
|
+
=begin item
|
|
63
|
+
B<items>
|
|
64
|
+
|
|
65
|
+
An array of `publishRecord` objects representing the items to be processed by the plugin.
|
|
66
|
+
=end item
|
|
67
|
+
|
|
68
|
+
=head2 Returns
|
|
69
|
+
|
|
70
|
+
A tuple where the first element is an array of `publishRecord` objects representing
|
|
71
|
+
the processed and unprocessed items, and the second element is an object resulting
|
|
72
|
+
from calling the plugin's `onClose` function with a context object. This object may
|
|
73
|
+
contain arbitrary data based on the plugin's implementation.
|
|
74
|
+
|
|
75
|
+
=end pod
|
|
76
|
+
*/
|
|
77
|
+
export const processPlugin = (pluginConf, items, ctx = {}) => {
|
|
78
|
+
const [processItems, onClose] = pluginConf.plugin;
|
|
79
|
+
// process items
|
|
80
|
+
const allPaths = items.map(i => i.file);
|
|
81
|
+
const matchedPaths = filterFiles(allPaths, pluginConf.includePatterns || '.*', pluginConf.excludePatterns || []);
|
|
82
|
+
const matchedItems = items.filter(i => matchedPaths.includes(i.file));
|
|
83
|
+
const notMatchedPaths = allPaths.filter(i => !matchedPaths.includes(i));
|
|
84
|
+
const notMatchedItems = items.filter(i => notMatchedPaths.includes(i.file));
|
|
85
|
+
const nextState = [...notMatchedItems, ...processItems(matchedItems)];
|
|
86
|
+
return [nextState, onClose(ctx)];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
=begin pod
|
|
90
|
+
=head1 composePlugins
|
|
91
|
+
|
|
92
|
+
This function takes an array of PluginConfig objects and combines them into a single PluginConfig.
|
|
93
|
+
It does this by sequentially processing each PluginConfig in the array with the next,
|
|
94
|
+
effectively composing their behaviors into a single plugin configuration.
|
|
95
|
+
Each PluginConfig is expected to modify a shared state and context. The composition
|
|
96
|
+
is achieved by chaining the plugin functions within each PluginConfig, so that the
|
|
97
|
+
output (both state and context) of one plugin function becomes the input to the next.
|
|
98
|
+
|
|
99
|
+
=head2 Parameters
|
|
100
|
+
|
|
101
|
+
=begin item
|
|
102
|
+
B<configs>
|
|
103
|
+
|
|
104
|
+
An array of PluginConfig objects. Each PluginConfig is an object that represents
|
|
105
|
+
configuration for a plugin, which includes a plugin processing function and
|
|
106
|
+
potentially other settings.
|
|
107
|
+
=end item
|
|
108
|
+
|
|
109
|
+
=head2 Returns
|
|
110
|
+
|
|
111
|
+
Returns a single PluginConfig object that represents the composed configuration
|
|
112
|
+
of all the PluginConfig objects passed in the 'configs' array. This resulting
|
|
113
|
+
PluginConfig can be used to process items with the combined logic of all the
|
|
114
|
+
plugins defined in the input array.
|
|
115
|
+
|
|
116
|
+
=end pod
|
|
117
|
+
*/
|
|
118
|
+
export const composePlugins = (configs, inintCtx = {}) => {
|
|
119
|
+
const result = configs.reduce((acc, config) => {
|
|
120
|
+
if (acc.config?.plugin) {
|
|
121
|
+
const accCtx = acc.ctx || {};
|
|
122
|
+
let resultCtx = {};
|
|
123
|
+
const resultConfig = {
|
|
124
|
+
plugin: [
|
|
125
|
+
items => {
|
|
126
|
+
const [processedAccState, processedAccCtx] = processPlugin(acc.config, items, accCtx);
|
|
127
|
+
const [processedState, processedCtx] = processPlugin(config, processedAccState, {
|
|
128
|
+
...accCtx,
|
|
129
|
+
...processedAccCtx,
|
|
130
|
+
});
|
|
131
|
+
resultCtx = { ...accCtx, ...processedAccCtx, ...processedCtx };
|
|
132
|
+
return processedState;
|
|
133
|
+
},
|
|
134
|
+
() => {
|
|
135
|
+
return { ...accCtx, ...resultCtx };
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
return { config: resultConfig, ctx: resultCtx };
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
return { config, ctx: inintCtx };
|
|
143
|
+
}
|
|
144
|
+
}, { config: {}, ctx: {} });
|
|
145
|
+
return result.config;
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=plugins.js.map
|