-
Notifications
You must be signed in to change notification settings - Fork 0
/
md-check.js
121 lines (109 loc) · 2.88 KB
/
md-check.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const { MochaExecutor } = require('@btilford/md-check-exec-mocha');
const { TsCompiler } = require('@btilford/md-check-compile-typescript');
const path = require('path');
const pkg = require('../main/package.json');
const {
mdCheck, NodeVmExecutor, ForkExecutor, WriteSourceCompiler,
} = require('@btilford/md-check');
const outputDir = 'docs/';
process.env.LEVEL = 'debug';
const now = new Date();
const ghUrl = 'https://github.com/btilford/md-check';
const schemaOrg = 'http://schema.org';
function ldJson() {
return [
{
'@context': schemaOrg,
'@type': 'WebPage',
name: pkg.name,
url: pkg.homepage,
author: pkg.author,
copyrightHolder: { '@type': 'Person', name: 'Ben Tilford' },
copyrightYear: now.getFullYear(),
dateModified: now.toISOString(),
discussionUrl: pkg.bugs.url,
description: pkg.description,
keywords: pkg.keywords,
},
{
'@context': schemaOrg,
'@type': 'Project',
name: pkg.name,
founder: pkg.author,
url: ghUrl,
description: pkg.description,
sameAs: pkg.repository.url,
contactPoint: pkg.bugs,
},
{
'@context': schemaOrg,
'@type': 'SoftwareSourceCode',
name: pkg.name,
version: pkg.version,
codeRepository: pkg.repository.url,
codeSampleType: 'full',
programmingLanguage: ['Typescript','Javacript','Markdown'],
runtimePlatform: 'NodeJS',
copyrightHolder: 'Ben Tilford',
copyrightYear: now.getFullYear(),
dateModified: now.toISOString(),
discussionUrl: pkg.bugs.url,
description: pkg.description,
license: `${ghUrl}/LICENSE`,
keywords: pkg.keywords,
contributor: pkg.contributors ? pkg.contributors.map(user => ({ '@type': 'Person', ...user })) : [],
maintainer: pkg.maintainers ? pkg.maintainers.map(user => ({ '@type': 'Person', ...user })) : [],
url: ghUrl,
inLanguage: 'en-US'
},
];
}
const config = mdCheck({
outputStyle: 'single-file',
failOnerror: true,
project: {
name: pkg.name,
version: pkg.version,
outputDir,
ldJson: ldJson(),
},
include: {
patterns: [
'src/**/*.{mdx,md}',
],
},
executors: [
[NodeVmExecutor.supply()],
[
ForkExecutor.supply(
/eval$/,
'eval',
{},
'"$SOURCE"',
),
],
[
ForkExecutor.supply(
/bash$/,
'bash',
{},
'$COMPILED_FILE',
),
],
[
MochaExecutor.supply(),
],
],
compilers: [
WriteSourceCompiler.supply(/bash$/),
TsCompiler.supply({ tsConfig: 'tsconfig.json' }),
],
});
config.run().then(async results => {
console.log('Finished generating partials');
const basePath = path.resolve(path.join(__dirname, outputDir));
// const nav = fs.readFile(path.join(basePath, 'index.html'));
//
}).catch(err => {
console.error('Error running!', err);
});