meodp 0.0.6 → 0.0.8
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/README.md +1 -0
- package/bin/index.mjs +0 -0
- package/dist/cli/index.cjs +188 -18
- package/dist/cli/index.mjs +174 -7
- package/dist/index.cjs +39 -37
- package/dist/index.d.cts +87 -3
- package/dist/index.d.mts +87 -3
- package/dist/index.d.ts +87 -3
- package/dist/index.mjs +9 -8
- package/dist/shared/{meodp.c2959ba5.cjs → meodp.6b19529e.cjs} +286 -191
- package/dist/shared/{meodp.9c5df07b.mjs → meodp.b58178b8.mjs} +281 -187
- package/package.json +6 -2
package/README.md
CHANGED
package/bin/index.mjs
CHANGED
|
File without changes
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1,29 +1,184 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const process = require('node:process');
|
|
3
|
+
const process$1 = require('node:process');
|
|
4
4
|
const c12 = require('c12');
|
|
5
5
|
const consola = require('consola');
|
|
6
6
|
const utils = require('consola/utils');
|
|
7
7
|
const yargs = require('yargs');
|
|
8
8
|
const helpers = require('yargs/helpers');
|
|
9
9
|
require('playwright');
|
|
10
|
-
const
|
|
10
|
+
const index = require('../shared/meodp.6b19529e.cjs');
|
|
11
11
|
require('node:path');
|
|
12
12
|
require('strip-ansi');
|
|
13
13
|
require('winston');
|
|
14
14
|
require('p-queue');
|
|
15
|
-
require('
|
|
16
|
-
require('
|
|
15
|
+
require('lowdb/node');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const process = require('process');
|
|
18
|
+
const fs = require('fs-extra');
|
|
19
|
+
const markdownTable = require('markdown-table');
|
|
17
20
|
require('cli-progress');
|
|
18
21
|
require('cli-progress/lib/options.js');
|
|
19
22
|
require('cli-progress/lib/format-bar.js');
|
|
20
23
|
require('cli-progress/lib/format-time.js');
|
|
24
|
+
require('date-fns');
|
|
21
25
|
|
|
22
26
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
23
27
|
|
|
24
|
-
const process__default = /*#__PURE__*/_interopDefaultCompat(process);
|
|
28
|
+
const process__default$1 = /*#__PURE__*/_interopDefaultCompat(process$1);
|
|
25
29
|
const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
|
|
26
30
|
const yargs__default = /*#__PURE__*/_interopDefaultCompat(yargs);
|
|
31
|
+
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
32
|
+
const process__default = /*#__PURE__*/_interopDefaultCompat(process);
|
|
33
|
+
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
34
|
+
|
|
35
|
+
const successIcon = '<font color="green">\u2714</font>';
|
|
36
|
+
const errorIcon = '<font color="red">\u2716</font>';
|
|
37
|
+
function getCheckStatusEmoji(checkStatus) {
|
|
38
|
+
switch (checkStatus) {
|
|
39
|
+
case "passed":
|
|
40
|
+
return "\u2705";
|
|
41
|
+
case "failed":
|
|
42
|
+
return "\u274C";
|
|
43
|
+
case "timeout":
|
|
44
|
+
return "\u23F0";
|
|
45
|
+
case "ignored":
|
|
46
|
+
return "\u{1F47B}";
|
|
47
|
+
case "goto":
|
|
48
|
+
return "\u{1F517}";
|
|
49
|
+
case "pending":
|
|
50
|
+
return "\u23F3";
|
|
51
|
+
default:
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getErrorMdContent(sites) {
|
|
56
|
+
const errorSites = Object.entries(sites).filter(([key, value]) => {
|
|
57
|
+
return ["failed", "timeout"].includes(value.checkStatus);
|
|
58
|
+
});
|
|
59
|
+
if (!errorSites.length) {
|
|
60
|
+
return "No error found.";
|
|
61
|
+
}
|
|
62
|
+
let md = "";
|
|
63
|
+
for (const [key, value] of errorSites) {
|
|
64
|
+
md += `- [${value.name || value.url}](${value.url})
|
|
65
|
+
`;
|
|
66
|
+
for (const link of value.links) {
|
|
67
|
+
if (link.checkStatus === "passed") {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const statusInfo = link.statusText ? `${link.statusCode} ${link.statusText}` : link.statusCode;
|
|
71
|
+
md += ` - [${statusInfo}] <${link.url}>
|
|
72
|
+
`;
|
|
73
|
+
for (const req of link.requests) {
|
|
74
|
+
if (req.failed) {
|
|
75
|
+
if (req.statusCode) {
|
|
76
|
+
const statusInfo2 = req.statusText ? `${req.statusCode} ${req.statusText}` : req.statusCode;
|
|
77
|
+
md += ` - [${statusInfo2}] <${req.url}>
|
|
78
|
+
`;
|
|
79
|
+
} else {
|
|
80
|
+
md += ` - [\u23F0 TIMEOUT] <${req.url}>
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return md;
|
|
88
|
+
}
|
|
89
|
+
async function generateContentFromSiteData(site) {
|
|
90
|
+
let md = "";
|
|
91
|
+
const successLength = site.links.filter((link) => link.checkStatus === "passed").length;
|
|
92
|
+
const failedLength = site.links.filter((link) => link.checkStatus === "failed").length;
|
|
93
|
+
const timeoutLength = site.links.filter((link) => link.checkStatus === "timeout").length;
|
|
94
|
+
const summary = `
|
|
95
|
+
> \u{1F517} Links ${site.links.length} | ${successIcon} ${successLength} Passed | ${errorIcon} ${failedLength} Failed | \u23F0 ${timeoutLength} Timeout | \u{1F47B} ${site.ignored.length} Ignored
|
|
96
|
+
|
|
97
|
+
`;
|
|
98
|
+
md += summary;
|
|
99
|
+
const siteArr = [
|
|
100
|
+
["", "CheckInfo", "Duration", "URL"]
|
|
101
|
+
];
|
|
102
|
+
site.links?.forEach((link) => {
|
|
103
|
+
let checkStr = getCheckStatusEmoji(link.checkStatus);
|
|
104
|
+
let checkInfo = [
|
|
105
|
+
"<span>**" + link.total + " Requests**</span><br>"
|
|
106
|
+
];
|
|
107
|
+
if (link.success) {
|
|
108
|
+
checkInfo.push('<font color="green">\u2714</font> ' + link.success);
|
|
109
|
+
}
|
|
110
|
+
if (link.failed) {
|
|
111
|
+
checkInfo.push(errorIcon + " " + link.failed);
|
|
112
|
+
}
|
|
113
|
+
if (link.timeout) {
|
|
114
|
+
checkInfo.push("\u23F0 " + link.timeout);
|
|
115
|
+
}
|
|
116
|
+
if (link.ignored) {
|
|
117
|
+
checkInfo.push("\u{1F47B} " + link.ignored);
|
|
118
|
+
}
|
|
119
|
+
(link.statusText ? `${link.statusCode} ${link.statusText}` : link.statusCode).toString();
|
|
120
|
+
siteArr.push([
|
|
121
|
+
checkStr,
|
|
122
|
+
checkInfo.join(" "),
|
|
123
|
+
// statusStr,
|
|
124
|
+
link.duration ? `${link.duration}ms` : "",
|
|
125
|
+
`[${link.url}](${link.url})`
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
md += markdownTable.markdownTable(siteArr, {
|
|
129
|
+
align: ["l", "l", "r", "l"]
|
|
130
|
+
});
|
|
131
|
+
md += "\n";
|
|
132
|
+
return md;
|
|
133
|
+
}
|
|
134
|
+
async function outputMarkdown(options = {
|
|
135
|
+
/**
|
|
136
|
+
* Show config in markdown
|
|
137
|
+
*/
|
|
138
|
+
showConfig: false
|
|
139
|
+
}) {
|
|
140
|
+
const db = await index.createLowDB();
|
|
141
|
+
await db.read();
|
|
142
|
+
const rootDir = process__default.cwd();
|
|
143
|
+
const mdPath = path__default.resolve(rootDir, "logs/meodp/report.md");
|
|
144
|
+
await fs__default.ensureFile(mdPath);
|
|
145
|
+
let mdContent = "# MEODP Report\n";
|
|
146
|
+
if (options.showConfig) {
|
|
147
|
+
mdContent += `
|
|
148
|
+
<details>
|
|
149
|
+
<summary>Config</summary>
|
|
150
|
+
|
|
151
|
+
\`\`\`json
|
|
152
|
+
${JSON.stringify(db.data.config, null, 2)}
|
|
153
|
+
\`\`\`
|
|
154
|
+
|
|
155
|
+
</details>
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
mdContent += `
|
|
159
|
+
## Errors
|
|
160
|
+
|
|
161
|
+
${getErrorMdContent(db.data.sites)}
|
|
162
|
+
`;
|
|
163
|
+
mdContent += "## Sites\n";
|
|
164
|
+
for (const [key, value] of Object.entries(db.data.sites)) {
|
|
165
|
+
const site = value;
|
|
166
|
+
mdContent += `
|
|
167
|
+
### ${getCheckStatusEmoji(site.checkStatus)} [${site.name || site.url}](${site.url})
|
|
168
|
+
`;
|
|
169
|
+
mdContent += await generateContentFromSiteData(value);
|
|
170
|
+
}
|
|
171
|
+
await fs__default.writeFile(mdPath, mdContent);
|
|
172
|
+
consola__default.success(`${utils.colors.cyan("Report Markdown File:")} ${utils.colors.gray(mdPath)}`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function output(type = "md") {
|
|
176
|
+
switch (type) {
|
|
177
|
+
case "md":
|
|
178
|
+
await outputMarkdown();
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
27
182
|
|
|
28
183
|
function commonOptions(args) {
|
|
29
184
|
return args.positional("root", {
|
|
@@ -38,31 +193,46 @@ consola__default.level = 3;
|
|
|
38
193
|
function debug(name, ...args) {
|
|
39
194
|
consola__default.debug(utils.colors.dim(name), ...args);
|
|
40
195
|
}
|
|
41
|
-
const cli = yargs__default(helpers.hideBin(process__default.argv)).scriptName("meodp").usage("$0 \u68C0\u6D4B\u94FE\u63A5").command(
|
|
196
|
+
const cli = yargs__default(helpers.hideBin(process__default$1.argv)).scriptName("meodp").usage("$0 \u68C0\u6D4B\u94FE\u63A5").command(
|
|
42
197
|
"* [root]",
|
|
43
198
|
"Run MEODP to check links",
|
|
44
199
|
(args) => commonOptions(args),
|
|
45
200
|
async (argv) => {
|
|
46
201
|
debug("argv", argv);
|
|
47
|
-
const { root = process__default.cwd() } = argv;
|
|
48
|
-
const { config
|
|
202
|
+
const { root = process__default$1.cwd() } = argv;
|
|
203
|
+
const { config, configFile } = await c12.loadConfig({
|
|
49
204
|
cwd: root,
|
|
50
205
|
name: "meodp",
|
|
51
|
-
defaultConfig:
|
|
206
|
+
defaultConfig: index.defaultMEODPConfig
|
|
52
207
|
});
|
|
53
|
-
await
|
|
54
|
-
debug("config", config
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
208
|
+
await index.MEODP.init(config);
|
|
209
|
+
debug("config", config);
|
|
210
|
+
index.MEODP.logger.info(`\u{1F6E0}\uFE0F Config File: ${configFile}`);
|
|
211
|
+
index.MEODP.config = config;
|
|
212
|
+
index.MEODP.configFile = configFile || "";
|
|
213
|
+
index.MEODP.logger.start("\u{1F310} Start checking links...");
|
|
59
214
|
const startTime = Date.now();
|
|
60
|
-
await
|
|
215
|
+
await index.runByConfig(config);
|
|
61
216
|
const endTime = Date.now();
|
|
62
217
|
const duration = endTime - startTime;
|
|
63
218
|
console.log();
|
|
64
|
-
|
|
65
|
-
|
|
219
|
+
index.MEODP.logger.success(`All done! in ${utils.colors.yellow(duration / 1e3)}s.`);
|
|
220
|
+
console.log();
|
|
221
|
+
consola__default.start("\u{1F680} Start exporting Markdown Report...");
|
|
222
|
+
await output(argv.type);
|
|
223
|
+
process__default$1.exit(0);
|
|
224
|
+
}
|
|
225
|
+
).command(
|
|
226
|
+
"export [root]",
|
|
227
|
+
"Export MEODP Report",
|
|
228
|
+
(args) => commonOptions(args).option("type", {
|
|
229
|
+
alias: "t",
|
|
230
|
+
describe: "Export type",
|
|
231
|
+
choices: ["html", "md"],
|
|
232
|
+
default: "md"
|
|
233
|
+
}),
|
|
234
|
+
async (argv) => {
|
|
235
|
+
await output(argv.type);
|
|
66
236
|
}
|
|
67
237
|
).alias("h", "help").alias("v", "version").showHelpOnFail(false).help();
|
|
68
238
|
function run() {
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,21 +1,173 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
1
|
+
import process$1 from 'node:process';
|
|
2
2
|
import { loadConfig } from 'c12';
|
|
3
3
|
import consola from 'consola';
|
|
4
4
|
import { colors } from 'consola/utils';
|
|
5
5
|
import yargs from 'yargs';
|
|
6
6
|
import { hideBin } from 'yargs/helpers';
|
|
7
7
|
import 'playwright';
|
|
8
|
-
import { h as defaultMEODPConfig, M as MEODP, r as runByConfig } from '../shared/meodp.
|
|
8
|
+
import { j as createLowDB, h as defaultMEODPConfig, M as MEODP, r as runByConfig } from '../shared/meodp.b58178b8.mjs';
|
|
9
9
|
import 'node:path';
|
|
10
10
|
import 'strip-ansi';
|
|
11
11
|
import 'winston';
|
|
12
12
|
import 'p-queue';
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
13
|
+
import 'lowdb/node';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import process from 'process';
|
|
16
|
+
import fs from 'fs-extra';
|
|
17
|
+
import { markdownTable } from 'markdown-table';
|
|
15
18
|
import 'cli-progress';
|
|
16
19
|
import 'cli-progress/lib/options.js';
|
|
17
20
|
import 'cli-progress/lib/format-bar.js';
|
|
18
21
|
import 'cli-progress/lib/format-time.js';
|
|
22
|
+
import 'date-fns';
|
|
23
|
+
|
|
24
|
+
const successIcon = '<font color="green">\u2714</font>';
|
|
25
|
+
const errorIcon = '<font color="red">\u2716</font>';
|
|
26
|
+
function getCheckStatusEmoji(checkStatus) {
|
|
27
|
+
switch (checkStatus) {
|
|
28
|
+
case "passed":
|
|
29
|
+
return "\u2705";
|
|
30
|
+
case "failed":
|
|
31
|
+
return "\u274C";
|
|
32
|
+
case "timeout":
|
|
33
|
+
return "\u23F0";
|
|
34
|
+
case "ignored":
|
|
35
|
+
return "\u{1F47B}";
|
|
36
|
+
case "goto":
|
|
37
|
+
return "\u{1F517}";
|
|
38
|
+
case "pending":
|
|
39
|
+
return "\u23F3";
|
|
40
|
+
default:
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getErrorMdContent(sites) {
|
|
45
|
+
const errorSites = Object.entries(sites).filter(([key, value]) => {
|
|
46
|
+
return ["failed", "timeout"].includes(value.checkStatus);
|
|
47
|
+
});
|
|
48
|
+
if (!errorSites.length) {
|
|
49
|
+
return "No error found.";
|
|
50
|
+
}
|
|
51
|
+
let md = "";
|
|
52
|
+
for (const [key, value] of errorSites) {
|
|
53
|
+
md += `- [${value.name || value.url}](${value.url})
|
|
54
|
+
`;
|
|
55
|
+
for (const link of value.links) {
|
|
56
|
+
if (link.checkStatus === "passed") {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const statusInfo = link.statusText ? `${link.statusCode} ${link.statusText}` : link.statusCode;
|
|
60
|
+
md += ` - [${statusInfo}] <${link.url}>
|
|
61
|
+
`;
|
|
62
|
+
for (const req of link.requests) {
|
|
63
|
+
if (req.failed) {
|
|
64
|
+
if (req.statusCode) {
|
|
65
|
+
const statusInfo2 = req.statusText ? `${req.statusCode} ${req.statusText}` : req.statusCode;
|
|
66
|
+
md += ` - [${statusInfo2}] <${req.url}>
|
|
67
|
+
`;
|
|
68
|
+
} else {
|
|
69
|
+
md += ` - [\u23F0 TIMEOUT] <${req.url}>
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return md;
|
|
77
|
+
}
|
|
78
|
+
async function generateContentFromSiteData(site) {
|
|
79
|
+
let md = "";
|
|
80
|
+
const successLength = site.links.filter((link) => link.checkStatus === "passed").length;
|
|
81
|
+
const failedLength = site.links.filter((link) => link.checkStatus === "failed").length;
|
|
82
|
+
const timeoutLength = site.links.filter((link) => link.checkStatus === "timeout").length;
|
|
83
|
+
const summary = `
|
|
84
|
+
> \u{1F517} Links ${site.links.length} | ${successIcon} ${successLength} Passed | ${errorIcon} ${failedLength} Failed | \u23F0 ${timeoutLength} Timeout | \u{1F47B} ${site.ignored.length} Ignored
|
|
85
|
+
|
|
86
|
+
`;
|
|
87
|
+
md += summary;
|
|
88
|
+
const siteArr = [
|
|
89
|
+
["", "CheckInfo", "Duration", "URL"]
|
|
90
|
+
];
|
|
91
|
+
site.links?.forEach((link) => {
|
|
92
|
+
let checkStr = getCheckStatusEmoji(link.checkStatus);
|
|
93
|
+
let checkInfo = [
|
|
94
|
+
"<span>**" + link.total + " Requests**</span><br>"
|
|
95
|
+
];
|
|
96
|
+
if (link.success) {
|
|
97
|
+
checkInfo.push('<font color="green">\u2714</font> ' + link.success);
|
|
98
|
+
}
|
|
99
|
+
if (link.failed) {
|
|
100
|
+
checkInfo.push(errorIcon + " " + link.failed);
|
|
101
|
+
}
|
|
102
|
+
if (link.timeout) {
|
|
103
|
+
checkInfo.push("\u23F0 " + link.timeout);
|
|
104
|
+
}
|
|
105
|
+
if (link.ignored) {
|
|
106
|
+
checkInfo.push("\u{1F47B} " + link.ignored);
|
|
107
|
+
}
|
|
108
|
+
(link.statusText ? `${link.statusCode} ${link.statusText}` : link.statusCode).toString();
|
|
109
|
+
siteArr.push([
|
|
110
|
+
checkStr,
|
|
111
|
+
checkInfo.join(" "),
|
|
112
|
+
// statusStr,
|
|
113
|
+
link.duration ? `${link.duration}ms` : "",
|
|
114
|
+
`[${link.url}](${link.url})`
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
md += markdownTable(siteArr, {
|
|
118
|
+
align: ["l", "l", "r", "l"]
|
|
119
|
+
});
|
|
120
|
+
md += "\n";
|
|
121
|
+
return md;
|
|
122
|
+
}
|
|
123
|
+
async function outputMarkdown(options = {
|
|
124
|
+
/**
|
|
125
|
+
* Show config in markdown
|
|
126
|
+
*/
|
|
127
|
+
showConfig: false
|
|
128
|
+
}) {
|
|
129
|
+
const db = await createLowDB();
|
|
130
|
+
await db.read();
|
|
131
|
+
const rootDir = process.cwd();
|
|
132
|
+
const mdPath = path.resolve(rootDir, "logs/meodp/report.md");
|
|
133
|
+
await fs.ensureFile(mdPath);
|
|
134
|
+
let mdContent = "# MEODP Report\n";
|
|
135
|
+
if (options.showConfig) {
|
|
136
|
+
mdContent += `
|
|
137
|
+
<details>
|
|
138
|
+
<summary>Config</summary>
|
|
139
|
+
|
|
140
|
+
\`\`\`json
|
|
141
|
+
${JSON.stringify(db.data.config, null, 2)}
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
</details>
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
mdContent += `
|
|
148
|
+
## Errors
|
|
149
|
+
|
|
150
|
+
${getErrorMdContent(db.data.sites)}
|
|
151
|
+
`;
|
|
152
|
+
mdContent += "## Sites\n";
|
|
153
|
+
for (const [key, value] of Object.entries(db.data.sites)) {
|
|
154
|
+
const site = value;
|
|
155
|
+
mdContent += `
|
|
156
|
+
### ${getCheckStatusEmoji(site.checkStatus)} [${site.name || site.url}](${site.url})
|
|
157
|
+
`;
|
|
158
|
+
mdContent += await generateContentFromSiteData(value);
|
|
159
|
+
}
|
|
160
|
+
await fs.writeFile(mdPath, mdContent);
|
|
161
|
+
consola.success(`${colors.cyan("Report Markdown File:")} ${colors.gray(mdPath)}`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function output(type = "md") {
|
|
165
|
+
switch (type) {
|
|
166
|
+
case "md":
|
|
167
|
+
await outputMarkdown();
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
19
171
|
|
|
20
172
|
function commonOptions(args) {
|
|
21
173
|
return args.positional("root", {
|
|
@@ -30,13 +182,13 @@ consola.level = 3;
|
|
|
30
182
|
function debug(name, ...args) {
|
|
31
183
|
consola.debug(colors.dim(name), ...args);
|
|
32
184
|
}
|
|
33
|
-
const cli = yargs(hideBin(process.argv)).scriptName("meodp").usage("$0 \u68C0\u6D4B\u94FE\u63A5").command(
|
|
185
|
+
const cli = yargs(hideBin(process$1.argv)).scriptName("meodp").usage("$0 \u68C0\u6D4B\u94FE\u63A5").command(
|
|
34
186
|
"* [root]",
|
|
35
187
|
"Run MEODP to check links",
|
|
36
188
|
(args) => commonOptions(args),
|
|
37
189
|
async (argv) => {
|
|
38
190
|
debug("argv", argv);
|
|
39
|
-
const { root = process.cwd() } = argv;
|
|
191
|
+
const { root = process$1.cwd() } = argv;
|
|
40
192
|
const { config, configFile } = await loadConfig({
|
|
41
193
|
cwd: root,
|
|
42
194
|
name: "meodp",
|
|
@@ -54,7 +206,22 @@ const cli = yargs(hideBin(process.argv)).scriptName("meodp").usage("$0 \u68C0\u6
|
|
|
54
206
|
const duration = endTime - startTime;
|
|
55
207
|
console.log();
|
|
56
208
|
MEODP.logger.success(`All done! in ${colors.yellow(duration / 1e3)}s.`);
|
|
57
|
-
|
|
209
|
+
console.log();
|
|
210
|
+
consola.start("\u{1F680} Start exporting Markdown Report...");
|
|
211
|
+
await output(argv.type);
|
|
212
|
+
process$1.exit(0);
|
|
213
|
+
}
|
|
214
|
+
).command(
|
|
215
|
+
"export [root]",
|
|
216
|
+
"Export MEODP Report",
|
|
217
|
+
(args) => commonOptions(args).option("type", {
|
|
218
|
+
alias: "t",
|
|
219
|
+
describe: "Export type",
|
|
220
|
+
choices: ["html", "md"],
|
|
221
|
+
default: "md"
|
|
222
|
+
}),
|
|
223
|
+
async (argv) => {
|
|
224
|
+
await output(argv.type);
|
|
58
225
|
}
|
|
59
226
|
).alias("h", "help").alias("v", "version").showHelpOnFail(false).help();
|
|
60
227
|
function run() {
|
package/dist/index.cjs
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
require('consola');
|
|
5
|
-
require('p-queue');
|
|
3
|
+
const index = require('./shared/meodp.6b19529e.cjs');
|
|
6
4
|
require('consola/utils');
|
|
7
5
|
require('playwright');
|
|
8
6
|
require('node:path');
|
|
9
7
|
require('node:process');
|
|
10
|
-
require('
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
require('winston');
|
|
8
|
+
require('consola');
|
|
9
|
+
require('lowdb/node');
|
|
10
|
+
require('p-queue');
|
|
14
11
|
require('cli-progress');
|
|
15
12
|
require('cli-progress/lib/options.js');
|
|
16
13
|
require('cli-progress/lib/format-bar.js');
|
|
17
14
|
require('cli-progress/lib/format-time.js');
|
|
15
|
+
require('date-fns');
|
|
16
|
+
require('fs-extra');
|
|
17
|
+
require('strip-ansi');
|
|
18
|
+
require('winston');
|
|
18
19
|
|
|
19
20
|
async function checkSiteMap(urlItem) {
|
|
20
21
|
const { url } = urlItem;
|
|
21
22
|
const robotsUrl = new URL("/robots.txt", url).href;
|
|
22
|
-
const browser = await
|
|
23
|
+
const browser = await index.getBrowser();
|
|
23
24
|
const page = await browser.newPage();
|
|
24
25
|
await page.goto(robotsUrl);
|
|
25
26
|
const text = await page.textContent("pre");
|
|
@@ -33,8 +34,8 @@ async function checkSiteMap(urlItem) {
|
|
|
33
34
|
return elements.map((element) => element.textContent);
|
|
34
35
|
});
|
|
35
36
|
for (const link of links) {
|
|
36
|
-
if (link && !
|
|
37
|
-
|
|
37
|
+
if (link && !index.siteUrlMap.has(link)) {
|
|
38
|
+
index.siteUrlMap.set(link, {
|
|
38
39
|
statusCode: 0,
|
|
39
40
|
checkStatus: "pending"
|
|
40
41
|
});
|
|
@@ -42,31 +43,32 @@ async function checkSiteMap(urlItem) {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
exports.LocalLog =
|
|
46
|
-
exports.PQueueMap =
|
|
47
|
-
exports.checkLink =
|
|
48
|
-
exports.checkMEODPUrl =
|
|
49
|
-
exports.checkSite =
|
|
50
|
-
exports.checkSiteUrl =
|
|
51
|
-
exports.checkUrlNomoduleAssets =
|
|
52
|
-
exports.
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
57
|
-
exports.
|
|
58
|
-
exports.
|
|
59
|
-
exports.
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
65
|
-
exports.
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
46
|
+
exports.LocalLog = index.LocalLog;
|
|
47
|
+
exports.PQueueMap = index.PQueueMap;
|
|
48
|
+
exports.checkLink = index.checkLink;
|
|
49
|
+
exports.checkMEODPUrl = index.checkMEODPUrl;
|
|
50
|
+
exports.checkSite = index.checkSite;
|
|
51
|
+
exports.checkSiteUrl = index.checkSiteUrl;
|
|
52
|
+
exports.checkUrlNomoduleAssets = index.checkUrlNomoduleAssets;
|
|
53
|
+
exports.createLowDB = index.createLowDB;
|
|
54
|
+
exports.createMEODPLogger = index.createMEODPLogger;
|
|
55
|
+
exports.createWinstonLogger = index.createWinstonLogger;
|
|
56
|
+
exports.defaultMEODPConfig = index.defaultMEODPConfig;
|
|
57
|
+
exports.defineConfig = index.defineConfig;
|
|
58
|
+
exports.emojiMap = index.emojiMap;
|
|
59
|
+
exports.formatArgs = index.formatArgs;
|
|
60
|
+
exports.getBrowser = index.getBrowser;
|
|
61
|
+
exports.getFormattedDataFromResponse = index.getFormattedDataFromResponse;
|
|
62
|
+
exports.getFormattedDuration = index.getFormattedDuration;
|
|
63
|
+
exports.getMEODPUrlItemInfo = index.getMEODPUrlItemInfo;
|
|
64
|
+
exports.getSiteLinks = index.getSiteLinks;
|
|
65
|
+
exports.isLink = index.isLink;
|
|
66
|
+
exports.localLog = index.localLog;
|
|
67
|
+
exports.logUrlItemInfo = index.logUrlItemInfo;
|
|
68
|
+
exports.multiBar = index.multiBar;
|
|
69
|
+
exports.parseUrlMap = index.parseUrlMap;
|
|
70
|
+
exports.progressBarMap = index.progressBarMap;
|
|
71
|
+
exports.registerPageEvents = index.registerPageEvents;
|
|
72
|
+
exports.runByConfig = index.runByConfig;
|
|
73
|
+
exports.siteUrlMap = index.siteUrlMap;
|
|
72
74
|
exports.checkSiteMap = checkSiteMap;
|