meodp 0.0.4 → 0.0.6
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 +4 -0
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +2 -2
- package/dist/shared/{meodp.f86a1a9f.mjs → meodp.9c5df07b.mjs} +42 -9
- package/dist/shared/{meodp.e8cfff87.cjs → meodp.c2959ba5.cjs} +42 -8
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/cli/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const utils = require('consola/utils');
|
|
|
7
7
|
const yargs = require('yargs');
|
|
8
8
|
const helpers = require('yargs/helpers');
|
|
9
9
|
require('playwright');
|
|
10
|
-
const config = require('../shared/meodp.
|
|
10
|
+
const config = require('../shared/meodp.c2959ba5.cjs');
|
|
11
11
|
require('node:path');
|
|
12
12
|
require('strip-ansi');
|
|
13
13
|
require('winston');
|
package/dist/cli/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ 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 { h as defaultMEODPConfig, M as MEODP, r as runByConfig } from '../shared/meodp.9c5df07b.mjs';
|
|
9
9
|
import 'node:path';
|
|
10
10
|
import 'strip-ansi';
|
|
11
11
|
import 'winston';
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('./shared/meodp.
|
|
3
|
+
const config = require('./shared/meodp.c2959ba5.cjs');
|
|
4
4
|
require('consola');
|
|
5
5
|
require('p-queue');
|
|
6
6
|
require('consola/utils');
|
|
@@ -57,6 +57,7 @@ exports.emojiMap = config.emojiMap;
|
|
|
57
57
|
exports.formatArgs = config.formatArgs;
|
|
58
58
|
exports.getBrowser = config.getBrowser;
|
|
59
59
|
exports.getFormattedDataFromResponse = config.getFormattedDataFromResponse;
|
|
60
|
+
exports.getFormattedDuration = config.getFormattedDuration;
|
|
60
61
|
exports.getMEODPUrlItemInfo = config.getMEODPUrlItemInfo;
|
|
61
62
|
exports.getSiteLinks = config.getSiteLinks;
|
|
62
63
|
exports.isLink = config.isLink;
|
package/dist/index.d.cts
CHANGED
|
@@ -305,6 +305,7 @@ declare const progressBarMap: Map<string, cliProgress.SingleBar>;
|
|
|
305
305
|
declare function registerPageEvents(page: Page, urlItem: MEODPUrlProps): Map<string, PageUrlEvent>;
|
|
306
306
|
|
|
307
307
|
declare function formatArgs(args: any[]): string;
|
|
308
|
+
declare function getFormattedDuration(duration: number): string;
|
|
308
309
|
/**
|
|
309
310
|
* get formatted data from response
|
|
310
311
|
*/
|
|
@@ -314,6 +315,7 @@ declare function getFormattedDataFromResponse(res: Response): {
|
|
|
314
315
|
statusCode: number;
|
|
315
316
|
statusText: string;
|
|
316
317
|
statusInfo: string;
|
|
318
|
+
statusInfoText: string;
|
|
317
319
|
linkText: string;
|
|
318
320
|
};
|
|
319
321
|
|
|
@@ -357,4 +359,4 @@ declare function getMEODPUrlItemInfo(urlItem: MEODPUrlItem): {
|
|
|
357
359
|
emoji: string;
|
|
358
360
|
};
|
|
359
361
|
|
|
360
|
-
export { type CheckSiteUrlOptions, LocalLog, type LocalLogOptions, type MEODPConfig, type MEODPUrlItem, type MEODPUrlProps, type MEODPUrlType, PQueueMap, type PageUrlEvent, type UrlCategoryInfo, type UrlMap, checkLink, checkMEODPUrl, checkSite, checkSiteMap, checkSiteUrl, checkUrlNomoduleAssets, createMEODPLogger, createWinstonLogger, defaultMEODPConfig, defineConfig, emojiMap, formatArgs, getBrowser, getFormattedDataFromResponse, getMEODPUrlItemInfo, getSiteLinks, isLink, localLog, logUrlItemInfo, multiBar, parseUrlMap, progressBarMap, registerPageEvents, runByConfig, siteUrlMap };
|
|
362
|
+
export { type CheckSiteUrlOptions, LocalLog, type LocalLogOptions, type MEODPConfig, type MEODPUrlItem, type MEODPUrlProps, type MEODPUrlType, PQueueMap, type PageUrlEvent, type UrlCategoryInfo, type UrlMap, checkLink, checkMEODPUrl, checkSite, checkSiteMap, checkSiteUrl, checkUrlNomoduleAssets, createMEODPLogger, createWinstonLogger, defaultMEODPConfig, defineConfig, emojiMap, formatArgs, getBrowser, getFormattedDataFromResponse, getFormattedDuration, getMEODPUrlItemInfo, getSiteLinks, isLink, localLog, logUrlItemInfo, multiBar, parseUrlMap, progressBarMap, registerPageEvents, runByConfig, siteUrlMap };
|
package/dist/index.d.mts
CHANGED
|
@@ -305,6 +305,7 @@ declare const progressBarMap: Map<string, cliProgress.SingleBar>;
|
|
|
305
305
|
declare function registerPageEvents(page: Page, urlItem: MEODPUrlProps): Map<string, PageUrlEvent>;
|
|
306
306
|
|
|
307
307
|
declare function formatArgs(args: any[]): string;
|
|
308
|
+
declare function getFormattedDuration(duration: number): string;
|
|
308
309
|
/**
|
|
309
310
|
* get formatted data from response
|
|
310
311
|
*/
|
|
@@ -314,6 +315,7 @@ declare function getFormattedDataFromResponse(res: Response): {
|
|
|
314
315
|
statusCode: number;
|
|
315
316
|
statusText: string;
|
|
316
317
|
statusInfo: string;
|
|
318
|
+
statusInfoText: string;
|
|
317
319
|
linkText: string;
|
|
318
320
|
};
|
|
319
321
|
|
|
@@ -357,4 +359,4 @@ declare function getMEODPUrlItemInfo(urlItem: MEODPUrlItem): {
|
|
|
357
359
|
emoji: string;
|
|
358
360
|
};
|
|
359
361
|
|
|
360
|
-
export { type CheckSiteUrlOptions, LocalLog, type LocalLogOptions, type MEODPConfig, type MEODPUrlItem, type MEODPUrlProps, type MEODPUrlType, PQueueMap, type PageUrlEvent, type UrlCategoryInfo, type UrlMap, checkLink, checkMEODPUrl, checkSite, checkSiteMap, checkSiteUrl, checkUrlNomoduleAssets, createMEODPLogger, createWinstonLogger, defaultMEODPConfig, defineConfig, emojiMap, formatArgs, getBrowser, getFormattedDataFromResponse, getMEODPUrlItemInfo, getSiteLinks, isLink, localLog, logUrlItemInfo, multiBar, parseUrlMap, progressBarMap, registerPageEvents, runByConfig, siteUrlMap };
|
|
362
|
+
export { type CheckSiteUrlOptions, LocalLog, type LocalLogOptions, type MEODPConfig, type MEODPUrlItem, type MEODPUrlProps, type MEODPUrlType, PQueueMap, type PageUrlEvent, type UrlCategoryInfo, type UrlMap, checkLink, checkMEODPUrl, checkSite, checkSiteMap, checkSiteUrl, checkUrlNomoduleAssets, createMEODPLogger, createWinstonLogger, defaultMEODPConfig, defineConfig, emojiMap, formatArgs, getBrowser, getFormattedDataFromResponse, getFormattedDuration, getMEODPUrlItemInfo, getSiteLinks, isLink, localLog, logUrlItemInfo, multiBar, parseUrlMap, progressBarMap, registerPageEvents, runByConfig, siteUrlMap };
|
package/dist/index.d.ts
CHANGED
|
@@ -305,6 +305,7 @@ declare const progressBarMap: Map<string, cliProgress.SingleBar>;
|
|
|
305
305
|
declare function registerPageEvents(page: Page, urlItem: MEODPUrlProps): Map<string, PageUrlEvent>;
|
|
306
306
|
|
|
307
307
|
declare function formatArgs(args: any[]): string;
|
|
308
|
+
declare function getFormattedDuration(duration: number): string;
|
|
308
309
|
/**
|
|
309
310
|
* get formatted data from response
|
|
310
311
|
*/
|
|
@@ -314,6 +315,7 @@ declare function getFormattedDataFromResponse(res: Response): {
|
|
|
314
315
|
statusCode: number;
|
|
315
316
|
statusText: string;
|
|
316
317
|
statusInfo: string;
|
|
318
|
+
statusInfoText: string;
|
|
317
319
|
linkText: string;
|
|
318
320
|
};
|
|
319
321
|
|
|
@@ -357,4 +359,4 @@ declare function getMEODPUrlItemInfo(urlItem: MEODPUrlItem): {
|
|
|
357
359
|
emoji: string;
|
|
358
360
|
};
|
|
359
361
|
|
|
360
|
-
export { type CheckSiteUrlOptions, LocalLog, type LocalLogOptions, type MEODPConfig, type MEODPUrlItem, type MEODPUrlProps, type MEODPUrlType, PQueueMap, type PageUrlEvent, type UrlCategoryInfo, type UrlMap, checkLink, checkMEODPUrl, checkSite, checkSiteMap, checkSiteUrl, checkUrlNomoduleAssets, createMEODPLogger, createWinstonLogger, defaultMEODPConfig, defineConfig, emojiMap, formatArgs, getBrowser, getFormattedDataFromResponse, getMEODPUrlItemInfo, getSiteLinks, isLink, localLog, logUrlItemInfo, multiBar, parseUrlMap, progressBarMap, registerPageEvents, runByConfig, siteUrlMap };
|
|
362
|
+
export { type CheckSiteUrlOptions, LocalLog, type LocalLogOptions, type MEODPConfig, type MEODPUrlItem, type MEODPUrlProps, type MEODPUrlType, PQueueMap, type PageUrlEvent, type UrlCategoryInfo, type UrlMap, checkLink, checkMEODPUrl, checkSite, checkSiteMap, checkSiteUrl, checkUrlNomoduleAssets, createMEODPLogger, createWinstonLogger, defaultMEODPConfig, defineConfig, emojiMap, formatArgs, getBrowser, getFormattedDataFromResponse, getFormattedDuration, getMEODPUrlItemInfo, getSiteLinks, isLink, localLog, logUrlItemInfo, multiBar, parseUrlMap, progressBarMap, registerPageEvents, runByConfig, siteUrlMap };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getBrowser, s as siteUrlMap } from './shared/meodp.
|
|
2
|
-
export { L as LocalLog, P as PQueueMap, a as checkLink, c as checkMEODPUrl, f as checkSite, e as checkSiteUrl, d as checkUrlNomoduleAssets, k as createMEODPLogger, m as createWinstonLogger, h as defaultMEODPConfig, i as defineConfig,
|
|
1
|
+
import { g as getBrowser, s as siteUrlMap } from './shared/meodp.9c5df07b.mjs';
|
|
2
|
+
export { L as LocalLog, P as PQueueMap, a as checkLink, c as checkMEODPUrl, f as checkSite, e as checkSiteUrl, d as checkUrlNomoduleAssets, k as createMEODPLogger, m as createWinstonLogger, h as defaultMEODPConfig, i as defineConfig, x as emojiMap, q as formatArgs, u as getFormattedDataFromResponse, t as getFormattedDuration, y as getMEODPUrlItemInfo, b as getSiteLinks, v as isLink, j as localLog, l as logUrlItemInfo, n as multiBar, w as parseUrlMap, p as progressBarMap, o as registerPageEvents, r as runByConfig } from './shared/meodp.9c5df07b.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'p-queue';
|
|
5
5
|
import 'consola/utils';
|
|
@@ -65,7 +65,11 @@ const _LocalLog = class _LocalLog {
|
|
|
65
65
|
* @desc append log
|
|
66
66
|
*/
|
|
67
67
|
static async SiteLog(urlItem, ...args) {
|
|
68
|
-
|
|
68
|
+
let id = urlItem.name || urlItem.url;
|
|
69
|
+
if (id.endsWith("/")) {
|
|
70
|
+
id = id.slice(0, -1);
|
|
71
|
+
}
|
|
72
|
+
const logName = id.replace("https://", "").replace("http://", "").replace(/\//g, "-");
|
|
69
73
|
const logPath = path.resolve(this.logFolder, urlItem.type, `${logName}.log`);
|
|
70
74
|
await _LocalLog.log(logPath, ...args);
|
|
71
75
|
}
|
|
@@ -182,19 +186,38 @@ const progressBarMap = /* @__PURE__ */ new Map();
|
|
|
182
186
|
function formatArgs(args) {
|
|
183
187
|
return args.join(" ");
|
|
184
188
|
}
|
|
189
|
+
const TIME_COLOR = {
|
|
190
|
+
fast: colors.green,
|
|
191
|
+
medium: colors.yellow,
|
|
192
|
+
slow: colors.red
|
|
193
|
+
};
|
|
194
|
+
function getFormattedDuration(duration) {
|
|
195
|
+
const durationText = `${(Math.round(duration) / 1e3).toString()}s`;
|
|
196
|
+
let type;
|
|
197
|
+
if (duration < 500) {
|
|
198
|
+
type = "fast";
|
|
199
|
+
} else if (duration < 3e3) {
|
|
200
|
+
type = "medium";
|
|
201
|
+
} else {
|
|
202
|
+
type = "slow";
|
|
203
|
+
}
|
|
204
|
+
return TIME_COLOR[type](durationText);
|
|
205
|
+
}
|
|
185
206
|
function getFormattedDataFromResponse(res) {
|
|
186
207
|
const statusCode = res?.status();
|
|
187
208
|
const statusText = res?.statusText();
|
|
188
209
|
const statusInfo = statusText ? `${statusCode?.toString()} ${statusText}` : statusCode?.toString();
|
|
210
|
+
const statusInfoText = statusCode >= 400 ? colors.red(`[${statusInfo}]`) : colors.green(`[${statusInfo}]`);
|
|
189
211
|
const req = res.request();
|
|
190
212
|
const duration = req.timing().responseEnd - req.timing().requestStart;
|
|
191
|
-
const durationText =
|
|
213
|
+
const durationText = `${COLORFUL_SYMBOLS.line} ${getFormattedDuration(duration)} ${COLORFUL_SYMBOLS.line}`;
|
|
192
214
|
return {
|
|
193
215
|
duration,
|
|
194
216
|
durationText,
|
|
195
217
|
statusCode,
|
|
196
218
|
statusText,
|
|
197
219
|
statusInfo,
|
|
220
|
+
statusInfoText,
|
|
198
221
|
linkText: colors.dim(res.url())
|
|
199
222
|
};
|
|
200
223
|
}
|
|
@@ -585,17 +608,25 @@ async function checkSiteUrl(url, options) {
|
|
|
585
608
|
}
|
|
586
609
|
if (!res)
|
|
587
610
|
return;
|
|
588
|
-
const
|
|
611
|
+
const {
|
|
612
|
+
statusCode,
|
|
613
|
+
statusInfoText,
|
|
614
|
+
durationText
|
|
615
|
+
} = getFormattedDataFromResponse(res);
|
|
589
616
|
const checkStatus = statusCode < 400 ? "passed" : "failed";
|
|
590
617
|
siteUrlMap.set(url, {
|
|
591
618
|
response: res,
|
|
592
619
|
statusCode,
|
|
593
620
|
checkStatus
|
|
594
621
|
});
|
|
595
|
-
MEODP.logger.
|
|
622
|
+
MEODP.logger.inner(statusInfoText, colors.cyan(url), durationText);
|
|
623
|
+
if (statusCode >= 400) {
|
|
624
|
+
MEODP.wLogger.error(` ${statusInfoText} ${url} ${durationText}`);
|
|
625
|
+
}
|
|
596
626
|
return;
|
|
597
627
|
}
|
|
598
628
|
const urlMap = registerPageEvents(page, options.urlItem);
|
|
629
|
+
const { success, failed, total, ignored, timeout } = parseUrlMap(urlMap);
|
|
599
630
|
try {
|
|
600
631
|
const res = await page.goto(url, {
|
|
601
632
|
waitUntil: "networkidle"
|
|
@@ -606,7 +637,6 @@ async function checkSiteUrl(url, options) {
|
|
|
606
637
|
statusCode,
|
|
607
638
|
checkStatus: "goto"
|
|
608
639
|
});
|
|
609
|
-
const { success, failed, total, ignored, timeout } = parseUrlMap(urlMap);
|
|
610
640
|
const duration = (Date.now() - startTime) / 1e3;
|
|
611
641
|
const statusText = res?.statusText();
|
|
612
642
|
const logInfo = [
|
|
@@ -624,19 +654,22 @@ async function checkSiteUrl(url, options) {
|
|
|
624
654
|
MEODP.logger.log(...logInfo);
|
|
625
655
|
log(...logInfo);
|
|
626
656
|
log();
|
|
657
|
+
if (failed.count > 0) {
|
|
658
|
+
MEODP.wLogger.error(logInfo.join(" "));
|
|
659
|
+
}
|
|
627
660
|
if (MEODP.config.log?.type === "progress") {
|
|
628
661
|
bar?.update(success.count, {
|
|
629
662
|
value: colors.green(success.count),
|
|
630
663
|
error_count: failed.count ? colors.red(failed.count) : 0
|
|
631
664
|
});
|
|
632
|
-
} else {
|
|
633
665
|
}
|
|
634
666
|
} catch (e) {
|
|
635
667
|
MEODP.logger.error(e);
|
|
636
668
|
}
|
|
637
669
|
for (const [url2, info] of urlMap) {
|
|
638
670
|
if (!info.response && !info.ignored) {
|
|
639
|
-
MEODP.logger.log(COLORFUL_SYMBOLS.line, " ", COLORFUL_SYMBOLS.error,
|
|
671
|
+
MEODP.logger.log(COLORFUL_SYMBOLS.line, " ", COLORFUL_SYMBOLS.error, colors.red("Timeout:"), colors.underline(url2));
|
|
672
|
+
MEODP.wLogger.error(` Timeout: ${url2}`);
|
|
640
673
|
}
|
|
641
674
|
}
|
|
642
675
|
let noModuleAssetsPassed = true;
|
|
@@ -764,7 +797,7 @@ async function checkMEODPUrl(meodpUrl) {
|
|
|
764
797
|
const duration = Date.now() - startTime;
|
|
765
798
|
const bar = progressBarMap.get(meodpUrl.url);
|
|
766
799
|
bar?.stop();
|
|
767
|
-
MEODP.logger.success(
|
|
800
|
+
MEODP.logger.success(`\u{1F577}\uFE0F ${colors.greenBright("[DONE]")} ${colors.gray("in")} ${duration / 1e3}s.`);
|
|
768
801
|
}
|
|
769
802
|
|
|
770
803
|
const defaultMEODPConfig = {
|
|
@@ -815,4 +848,4 @@ async function runByConfig(config) {
|
|
|
815
848
|
return true;
|
|
816
849
|
}
|
|
817
850
|
|
|
818
|
-
export { LocalLog as L, MEODP as M, PQueueMap as P, checkLink as a, getSiteLinks as b, checkMEODPUrl as c, checkUrlNomoduleAssets as d, checkSiteUrl as e, checkSite as f, getBrowser as g, defaultMEODPConfig as h, defineConfig as i, localLog as j, createMEODPLogger as k, logUrlItemInfo as l, createWinstonLogger as m, multiBar as n, registerPageEvents as o, progressBarMap as p, formatArgs as q, runByConfig as r, siteUrlMap as s,
|
|
851
|
+
export { LocalLog as L, MEODP as M, PQueueMap as P, checkLink as a, getSiteLinks as b, checkMEODPUrl as c, checkUrlNomoduleAssets as d, checkSiteUrl as e, checkSite as f, getBrowser as g, defaultMEODPConfig as h, defineConfig as i, localLog as j, createMEODPLogger as k, logUrlItemInfo as l, createWinstonLogger as m, multiBar as n, registerPageEvents as o, progressBarMap as p, formatArgs as q, runByConfig as r, siteUrlMap as s, getFormattedDuration as t, getFormattedDataFromResponse as u, isLink as v, parseUrlMap as w, emojiMap as x, getMEODPUrlItemInfo as y };
|
|
@@ -81,7 +81,11 @@ const _LocalLog = class _LocalLog {
|
|
|
81
81
|
* @desc append log
|
|
82
82
|
*/
|
|
83
83
|
static async SiteLog(urlItem, ...args) {
|
|
84
|
-
|
|
84
|
+
let id = urlItem.name || urlItem.url;
|
|
85
|
+
if (id.endsWith("/")) {
|
|
86
|
+
id = id.slice(0, -1);
|
|
87
|
+
}
|
|
88
|
+
const logName = id.replace("https://", "").replace("http://", "").replace(/\//g, "-");
|
|
85
89
|
const logPath = path__default.resolve(this.logFolder, urlItem.type, `${logName}.log`);
|
|
86
90
|
await _LocalLog.log(logPath, ...args);
|
|
87
91
|
}
|
|
@@ -198,19 +202,38 @@ const progressBarMap = /* @__PURE__ */ new Map();
|
|
|
198
202
|
function formatArgs(args) {
|
|
199
203
|
return args.join(" ");
|
|
200
204
|
}
|
|
205
|
+
const TIME_COLOR = {
|
|
206
|
+
fast: utils.colors.green,
|
|
207
|
+
medium: utils.colors.yellow,
|
|
208
|
+
slow: utils.colors.red
|
|
209
|
+
};
|
|
210
|
+
function getFormattedDuration(duration) {
|
|
211
|
+
const durationText = `${(Math.round(duration) / 1e3).toString()}s`;
|
|
212
|
+
let type;
|
|
213
|
+
if (duration < 500) {
|
|
214
|
+
type = "fast";
|
|
215
|
+
} else if (duration < 3e3) {
|
|
216
|
+
type = "medium";
|
|
217
|
+
} else {
|
|
218
|
+
type = "slow";
|
|
219
|
+
}
|
|
220
|
+
return TIME_COLOR[type](durationText);
|
|
221
|
+
}
|
|
201
222
|
function getFormattedDataFromResponse(res) {
|
|
202
223
|
const statusCode = res?.status();
|
|
203
224
|
const statusText = res?.statusText();
|
|
204
225
|
const statusInfo = statusText ? `${statusCode?.toString()} ${statusText}` : statusCode?.toString();
|
|
226
|
+
const statusInfoText = statusCode >= 400 ? utils.colors.red(`[${statusInfo}]`) : utils.colors.green(`[${statusInfo}]`);
|
|
205
227
|
const req = res.request();
|
|
206
228
|
const duration = req.timing().responseEnd - req.timing().requestStart;
|
|
207
|
-
const durationText =
|
|
229
|
+
const durationText = `${COLORFUL_SYMBOLS.line} ${getFormattedDuration(duration)} ${COLORFUL_SYMBOLS.line}`;
|
|
208
230
|
return {
|
|
209
231
|
duration,
|
|
210
232
|
durationText,
|
|
211
233
|
statusCode,
|
|
212
234
|
statusText,
|
|
213
235
|
statusInfo,
|
|
236
|
+
statusInfoText,
|
|
214
237
|
linkText: utils.colors.dim(res.url())
|
|
215
238
|
};
|
|
216
239
|
}
|
|
@@ -601,17 +624,25 @@ async function checkSiteUrl(url, options) {
|
|
|
601
624
|
}
|
|
602
625
|
if (!res)
|
|
603
626
|
return;
|
|
604
|
-
const
|
|
627
|
+
const {
|
|
628
|
+
statusCode,
|
|
629
|
+
statusInfoText,
|
|
630
|
+
durationText
|
|
631
|
+
} = getFormattedDataFromResponse(res);
|
|
605
632
|
const checkStatus = statusCode < 400 ? "passed" : "failed";
|
|
606
633
|
siteUrlMap.set(url, {
|
|
607
634
|
response: res,
|
|
608
635
|
statusCode,
|
|
609
636
|
checkStatus
|
|
610
637
|
});
|
|
611
|
-
MEODP.logger.
|
|
638
|
+
MEODP.logger.inner(statusInfoText, utils.colors.cyan(url), durationText);
|
|
639
|
+
if (statusCode >= 400) {
|
|
640
|
+
MEODP.wLogger.error(` ${statusInfoText} ${url} ${durationText}`);
|
|
641
|
+
}
|
|
612
642
|
return;
|
|
613
643
|
}
|
|
614
644
|
const urlMap = registerPageEvents(page, options.urlItem);
|
|
645
|
+
const { success, failed, total, ignored, timeout } = parseUrlMap(urlMap);
|
|
615
646
|
try {
|
|
616
647
|
const res = await page.goto(url, {
|
|
617
648
|
waitUntil: "networkidle"
|
|
@@ -622,7 +653,6 @@ async function checkSiteUrl(url, options) {
|
|
|
622
653
|
statusCode,
|
|
623
654
|
checkStatus: "goto"
|
|
624
655
|
});
|
|
625
|
-
const { success, failed, total, ignored, timeout } = parseUrlMap(urlMap);
|
|
626
656
|
const duration = (Date.now() - startTime) / 1e3;
|
|
627
657
|
const statusText = res?.statusText();
|
|
628
658
|
const logInfo = [
|
|
@@ -640,19 +670,22 @@ async function checkSiteUrl(url, options) {
|
|
|
640
670
|
MEODP.logger.log(...logInfo);
|
|
641
671
|
log(...logInfo);
|
|
642
672
|
log();
|
|
673
|
+
if (failed.count > 0) {
|
|
674
|
+
MEODP.wLogger.error(logInfo.join(" "));
|
|
675
|
+
}
|
|
643
676
|
if (MEODP.config.log?.type === "progress") {
|
|
644
677
|
bar?.update(success.count, {
|
|
645
678
|
value: utils.colors.green(success.count),
|
|
646
679
|
error_count: failed.count ? utils.colors.red(failed.count) : 0
|
|
647
680
|
});
|
|
648
|
-
} else {
|
|
649
681
|
}
|
|
650
682
|
} catch (e) {
|
|
651
683
|
MEODP.logger.error(e);
|
|
652
684
|
}
|
|
653
685
|
for (const [url2, info] of urlMap) {
|
|
654
686
|
if (!info.response && !info.ignored) {
|
|
655
|
-
MEODP.logger.log(COLORFUL_SYMBOLS.line, " ", COLORFUL_SYMBOLS.error,
|
|
687
|
+
MEODP.logger.log(COLORFUL_SYMBOLS.line, " ", COLORFUL_SYMBOLS.error, utils.colors.red("Timeout:"), utils.colors.underline(url2));
|
|
688
|
+
MEODP.wLogger.error(` Timeout: ${url2}`);
|
|
656
689
|
}
|
|
657
690
|
}
|
|
658
691
|
let noModuleAssetsPassed = true;
|
|
@@ -780,7 +813,7 @@ async function checkMEODPUrl(meodpUrl) {
|
|
|
780
813
|
const duration = Date.now() - startTime;
|
|
781
814
|
const bar = progressBarMap.get(meodpUrl.url);
|
|
782
815
|
bar?.stop();
|
|
783
|
-
MEODP.logger.success(
|
|
816
|
+
MEODP.logger.success(`\u{1F577}\uFE0F ${utils.colors.greenBright("[DONE]")} ${utils.colors.gray("in")} ${duration / 1e3}s.`);
|
|
784
817
|
}
|
|
785
818
|
|
|
786
819
|
const defaultMEODPConfig = {
|
|
@@ -847,6 +880,7 @@ exports.emojiMap = emojiMap;
|
|
|
847
880
|
exports.formatArgs = formatArgs;
|
|
848
881
|
exports.getBrowser = getBrowser;
|
|
849
882
|
exports.getFormattedDataFromResponse = getFormattedDataFromResponse;
|
|
883
|
+
exports.getFormattedDuration = getFormattedDuration;
|
|
850
884
|
exports.getMEODPUrlItemInfo = getMEODPUrlItemInfo;
|
|
851
885
|
exports.getSiteLinks = getSiteLinks;
|
|
852
886
|
exports.isLink = isLink;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meodp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"packageManager": "pnpm@9.12.3",
|
|
6
6
|
"description": "Mystic Eyes of Death Perception. Find out dead links in your site.",
|
|
7
7
|
"keywords": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"bin": {
|
|
22
22
|
"meodp-ts": "bin/index.ts",
|
|
23
|
-
"meodp": "
|
|
23
|
+
"meodp": "bin/index.mjs"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"bin",
|