lint-wiki-dumps 0.2.0 → 0.3.0
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/package.json +1 -1
- package/processor.js +2 -23
- package/report.js +4 -6
- package/reports/article.html +4 -0
- package/reports/dist/article.js +1 -1
- package/reports/dist/article.js.map +3 -3
- package/reports/dist/index.js +1 -1
- package/reports/dist/index.js.map +2 -2
- package/reports/dist/rule.js +1 -1
- package/reports/dist/rule.js.map +3 -3
- package/reports/dist/wiki.js +1 -1
- package/reports/dist/wiki.js.map +2 -2
- package/reports/rule.html +0 -4
- package/server.js +71 -22
- package/util.js +36 -2
package/package.json
CHANGED
package/processor.js
CHANGED
@@ -8,7 +8,6 @@ const cluster_1 = __importDefault(require("cluster"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
9
9
|
const wikilint_1 = __importDefault(require("wikilint"));
|
10
10
|
const util_1 = require("./util");
|
11
|
-
const ignore = new Set(['no-arg', 'url-encoding', 'h1', 'var-anchor']);
|
12
11
|
class Processor {
|
13
12
|
parsed = 0;
|
14
13
|
#failed = 0;
|
@@ -72,30 +71,10 @@ class Processor {
|
|
72
71
|
}
|
73
72
|
}
|
74
73
|
try {
|
75
|
-
const errors =
|
76
|
-
.filter(({ severity, rule }) => severity === 'error' && !ignore.has(rule));
|
74
|
+
const errors = (0, util_1.lint)($text, ns);
|
77
75
|
this.parsed++;
|
78
76
|
if (errors.length > 0) {
|
79
|
-
this.newEntry(title, errors
|
80
|
-
/* DISABLED */
|
81
|
-
code, startIndex, endLine, endCol, endIndex,
|
82
|
-
/* DISABLED END */
|
83
|
-
...e }) => ({
|
84
|
-
...e,
|
85
|
-
// eslint-disable-next-line @stylistic/multiline-comment-style
|
86
|
-
/* DISABLED
|
87
|
-
|
88
|
-
...suggestions && {
|
89
|
-
suggestions: suggestions.map(action => ({
|
90
|
-
...action,
|
91
|
-
original: $text.slice(...action.range),
|
92
|
-
})),
|
93
|
-
},
|
94
|
-
...fix && {fix: {...fix, original: $text.slice(...fix.range)}},
|
95
|
-
|
96
|
-
*/
|
97
|
-
excerpt: $text.slice(startIndex, endIndex).slice(0, util_1.MAX),
|
98
|
-
})));
|
77
|
+
this.newEntry(title, errors);
|
99
78
|
}
|
100
79
|
}
|
101
80
|
catch (e) {
|
package/report.js
CHANGED
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
7
7
|
const path_1 = __importDefault(require("path"));
|
8
|
-
const crypto_1 = require("crypto");
|
9
8
|
const chalk_1 = __importDefault(require("chalk"));
|
10
9
|
const util_1 = require("./util");
|
11
10
|
const { argv } = process, [, , lang] = argv, defaultOurDir = path_1.default.join(__dirname, 'reports');
|
@@ -30,11 +29,11 @@ else {
|
|
30
29
|
const dataDir = path_1.default.join(outDir, 'data');
|
31
30
|
mkdir(dataDir);
|
32
31
|
const writeJS = (data, file) => {
|
33
|
-
|
32
|
+
(0, util_1.write)(path_1.default.join(dataDir, `${file}.js`), data);
|
34
33
|
};
|
35
34
|
const initJS = (file) => {
|
36
35
|
const stream = fs_1.default.createWriteStream(`${file}.js`);
|
37
|
-
stream.write('
|
36
|
+
stream.write('globalThis.data={"articles":[');
|
38
37
|
return stream;
|
39
38
|
};
|
40
39
|
const compare = (a, b) => a.localeCompare(b);
|
@@ -60,8 +59,7 @@ for (const file of dir) {
|
|
60
59
|
const data = fs_1.default.readFileSync(fileDir, 'utf8'), date = new Date(data.substr(data.indexOf('\n"#timestamp": "') + 16, 10));
|
61
60
|
latest = !latest || date > latest ? date : latest;
|
62
61
|
for (const mt of data.matchAll(/^(".+"): \[$/gmu)) {
|
63
|
-
const page = JSON.parse(mt[1]),
|
64
|
-
.slice(0, 8), errors = JSON.parse(data.slice(mt.index + mt[0].length - 1, data.indexOf('\n]', mt.index) + 2)), rules = new Set(), info = [];
|
62
|
+
const page = JSON.parse(mt[1]), errors = JSON.parse(data.slice(mt.index + mt[0].length - 1, data.indexOf('\n]', mt.index) + 2)), rules = new Set(), info = [];
|
65
63
|
for (const { rule, startLine, startCol, message, excerpt } of errors) {
|
66
64
|
// article
|
67
65
|
const line = startLine + 1, col = startCol + 1;
|
@@ -86,7 +84,7 @@ for (const file of dir) {
|
|
86
84
|
ruleRecord[0] += `${JSON.stringify([page, line, col, message, excerpt.slice(0, util_1.MAX * 0.8)], null, '\t')},`;
|
87
85
|
}
|
88
86
|
}
|
89
|
-
writeJS(info,
|
87
|
+
writeJS(info, (0, util_1.getHash)(site, page));
|
90
88
|
}
|
91
89
|
}
|
92
90
|
const timestamp = latest.toISOString().slice(0, 10);
|
package/reports/article.html
CHANGED
@@ -19,10 +19,14 @@
|
|
19
19
|
<div>
|
20
20
|
<a id="wiki" href="./wiki.html">Wikipedia</a>
|
21
21
|
</div>
|
22
|
+
<div>
|
23
|
+
<a id="purge" href="#">Refresh</a>
|
24
|
+
</div>
|
22
25
|
</div>
|
23
26
|
<h2>
|
24
27
|
Diagnostic Report for
|
25
28
|
<a id="article">Article</a>
|
29
|
+
[<a id="edit">Edit</a>]
|
26
30
|
</h2>
|
27
31
|
<table style="table-layout:fixed;width:100%;min-width:900px">
|
28
32
|
<colgroup>
|
package/reports/dist/article.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var p=(n,e)=>{n.href=e,e.startsWith("https://")&&(n.target="_blank",n.rel="noopener")},g=(n,e)=>{let t=document.createElement("script");t.src=n,t.addEventListener("load",e),document.head.append(t)},u=(n,e)=>{let t=document.querySelector(n);return t.textContent=t.textContent.replace("Wikipedia",e),t},l=(n,e,t)=>{let r=document.getElementById(n);typeof e=="function"?r.href=e(r.href):e?p(r,e):r.removeAttribute("href"),t!==void 0&&(r.textContent=t)},E=(n,e,t,r)=>{let i=document.createElement(n),a=document.createElement("a");return a.textContent=e,p(a,t),i.append(a),r&&(i.className=r),i},c=(n,e)=>{let t=document.createElement("td");return t.textContent=n,e&&(t.className=e),t},f=(...n)=>{let e=document.createElement("tr");e.append(...n),document.querySelector("tbody").append(e)},L=(n,e,t,r)=>[c(String(n)),c(String(e)),c(t,"excerpt"),c(r,"excerpt mono")];(async()=>{let n=new URLSearchParams(location.search),e=n.get("page"),t=n.get("lang"),r=n.get("timestamp"),i=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)),a=[...new Uint8Array(i)].slice(0,4).map(o=>o.toString(16).padStart(2,"0")).join(""),m=`https://${t==="mediawiki"?"www.mediawiki.org":`${t}.wikipedia.org`}/wiki/${encodeURIComponent(e)}`,s=document.getElementById("purge");u("title",e),l("article",`${m}?redirect=no`,e),l("edit",`${m}?action=edit`),l("wiki",o=>`${o}?lang=${t}`,`${t}wiki`),s.addEventListener("click",()=>{s.style.pointerEvents="none",(async()=>{let o=await fetch(`./purge/${t}/${encodeURIComponent(e.replace(/ /gu,"_"))}`);if(o.ok){let{timestamp:d}=await o.json();n.set("timestamp",d),location.href=`./article.html?${n}`}else s.style.pointerEvents=""})()}),g(`./data/${t}/pages/${a}.js${r?`?timestamp=${r}`:""}`,()=>{if(data.length===0)s.style.display="none";else for(let[o,d,w,$,h]of data)f(E("td",o,`./rule.html?lang=${t}&rule=${o}`,"excerpt"),...L(d,w,$,h))})})();})();
|
2
2
|
//# sourceMappingURL=article.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../src/common.ts", "../src/article.ts"],
|
4
|
-
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const
|
5
|
-
"mappings": "mBAAA,IAAMA,EAAY,CAACC,EAAsBC,IAAuB,CAC/DD,EAAE,KAAOC,EACLA,EAAK,WAAW,UAAU,IAC7BD,EAAE,OAAS,SACXA,EAAE,IAAM,WAEV,EAEaE,EAAO,CAACC,EAAaC,IAA+B,CAChE,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMF,EACbE,EAAO,iBAAiB,OAAQD,CAAQ,EACxC,SAAS,KAAK,OAAOC,CAAM,CAC5B,EAEaC,
|
6
|
-
"names": ["armorLink", "a", "href", "load", "src", "callback", "script", "
|
4
|
+
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const update = (tag: string, replace: string): Element => {\n\tconst ele = document.querySelector(tag)!;\n\tele.textContent = ele.textContent!.replace('Wikipedia', replace);\n\treturn ele;\n};\n\nexport const updateLink = (id: string, href: string | ((s: string) => string) | false, text?: string): void => {\n\tconst a = document.getElementById(id) as HTMLAnchorElement;\n\tif (typeof href === 'function') {\n\t\ta.href = href(a.href);\n\t} else if (href) {\n\t\tarmorLink(a, href);\n\t} else {\n\t\ta.removeAttribute('href');\n\t}\n\tif (text !== undefined) {\n\t\ta.textContent = text;\n\t}\n};\n\nexport const addLink = (tag: string, text: string, href: string, className?: string): HTMLElement => {\n\tconst container = document.createElement(tag),\n\t\ta = document.createElement('a');\n\ta.textContent = text;\n\tarmorLink(a, href);\n\tcontainer.append(a);\n\tif (className) {\n\t\tcontainer.className = className;\n\t}\n\treturn container;\n};\n\nexport const createTd = (text: string, className?: string): HTMLTableCellElement => {\n\tconst td = document.createElement('td');\n\ttd.textContent = text;\n\tif (className) {\n\t\ttd.className = className;\n\t}\n\treturn td;\n};\n\nexport const insertRow = (...tds: HTMLElement[]): void => {\n\tconst tr = document.createElement('tr');\n\ttr.append(...tds);\n\tdocument.querySelector('tbody')!.append(tr);\n};\n\nexport const getErrorInfo = (\n\tstartLine: number,\n\tstartCol: number,\n\tmessage: string,\n\texcerpt: string,\n): [HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement] => [\n\tcreateTd(String(startLine)),\n\tcreateTd(String(startCol)),\n\tcreateTd(message, 'excerpt'),\n\tcreateTd(excerpt, 'excerpt mono'),\n];\n", "import {load, update, updateLink, addLink, insertRow, getErrorInfo} from './common';\n\ndeclare const data: [string, number, number, string, string][];\n\n(async () => {\n\tconst search = new URLSearchParams(location.search),\n\t\tpage = search.get('page')!,\n\t\tlang = search.get('lang')!,\n\t\ttime = search.get('timestamp'),\n\t\tbuffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(page)),\n\t\thash = [...new Uint8Array(buffer)].slice(0, 4)\n\t\t\t.map(b => b.toString(16).padStart(2, '0'))\n\t\t\t.join(''),\n\t\tbase = `https://${\n\t\t\tlang === 'mediawiki' ? 'www.mediawiki.org' : `${lang}.wikipedia.org`\n\t\t}/wiki/${encodeURIComponent(page)}`,\n\t\tpurge = document.getElementById('purge')!;\n\tupdate('title', page);\n\tupdateLink('article', `${base}?redirect=no`, page);\n\tupdateLink('edit', `${base}?action=edit`);\n\tupdateLink('wiki', s => `${s}?lang=${lang}`, `${lang}wiki`);\n\tpurge.addEventListener('click', () => {\n\t\tpurge.style.pointerEvents = 'none';\n\t\t(async () => {\n\t\t\tconst response = await fetch(`./purge/${lang}/${\n\t\t\t\tencodeURIComponent(page.replace(/ /gu, '_'))\n\t\t\t}`);\n\t\t\tif (response.ok) {\n\t\t\t\tconst {timestamp} = await response.json();\n\t\t\t\tsearch.set('timestamp', timestamp as string);\n\t\t\t\tlocation.href = `./article.html?${search}`;\n\t\t\t} else {\n\t\t\t\tpurge.style.pointerEvents = '';\n\t\t\t}\n\t\t})();\n\t});\n\tload(`./data/${lang}/pages/${hash}.js${time ? `?timestamp=${time}` : ''}`, () => {\n\t\tif (data.length === 0) {\n\t\t\tpurge.style.display = 'none';\n\t\t} else {\n\t\t\tfor (const [rule, startLine, startCol, message, excerpt] of data) {\n\t\t\t\tinsertRow(\n\t\t\t\t\taddLink('td', rule, `./rule.html?lang=${lang}&rule=${rule}`, 'excerpt'),\n\t\t\t\t\t...getErrorInfo(startLine, startCol, message, excerpt),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n})();\n"],
|
5
|
+
"mappings": "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",
|
6
|
+
"names": ["armorLink", "a", "href", "load", "src", "callback", "script", "update", "tag", "replace", "ele", "updateLink", "id", "text", "addLink", "className", "container", "createTd", "td", "insertRow", "tds", "tr", "getErrorInfo", "startLine", "startCol", "message", "excerpt", "search", "page", "lang", "time", "buffer", "hash", "b", "base", "purge", "update", "updateLink", "s", "response", "timestamp", "load", "rule", "startLine", "startCol", "message", "excerpt", "insertRow", "addLink", "getErrorInfo"]
|
7
7
|
}
|
package/reports/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var l=(e,t)=>{e.href=t,t.startsWith("https://")&&(e.target="_blank",e.rel="noopener")},d=(e,t)=>{let n=document.createElement("script");n.src=e,n.addEventListener("load",t),document.head.append(n)};var s=(e,t,n,i)=>{let r=document.createElement(e),o=document.createElement("a");return o.textContent=t,l(o,n),r.append(o),i&&(r.className=i),r};d("./data/index.js",()=>{document.getElementById("container").append(...data.map(e=>s("div",`${e}wiki`,`./wiki.html?lang=${e}`)))});})();
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../src/common.ts", "../src/index.ts"],
|
4
|
-
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const
|
5
|
-
"mappings": "mBAAA,IAAMA,EAAY,CAACC,EAAsBC,IAAuB,CAC/DD,EAAE,KAAOC,EACLA,EAAK,WAAW,UAAU,IAC7BD,EAAE,OAAS,SACXA,EAAE,IAAM,WAEV,EAEaE,EAAO,CAACC,EAAaC,IAA+B,CAChE,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMF,EACbE,EAAO,iBAAiB,OAAQD,CAAQ,EACxC,SAAS,KAAK,OAAOC,CAAM,CAC5B,
|
4
|
+
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const update = (tag: string, replace: string): Element => {\n\tconst ele = document.querySelector(tag)!;\n\tele.textContent = ele.textContent!.replace('Wikipedia', replace);\n\treturn ele;\n};\n\nexport const updateLink = (id: string, href: string | ((s: string) => string) | false, text?: string): void => {\n\tconst a = document.getElementById(id) as HTMLAnchorElement;\n\tif (typeof href === 'function') {\n\t\ta.href = href(a.href);\n\t} else if (href) {\n\t\tarmorLink(a, href);\n\t} else {\n\t\ta.removeAttribute('href');\n\t}\n\tif (text !== undefined) {\n\t\ta.textContent = text;\n\t}\n};\n\nexport const addLink = (tag: string, text: string, href: string, className?: string): HTMLElement => {\n\tconst container = document.createElement(tag),\n\t\ta = document.createElement('a');\n\ta.textContent = text;\n\tarmorLink(a, href);\n\tcontainer.append(a);\n\tif (className) {\n\t\tcontainer.className = className;\n\t}\n\treturn container;\n};\n\nexport const createTd = (text: string, className?: string): HTMLTableCellElement => {\n\tconst td = document.createElement('td');\n\ttd.textContent = text;\n\tif (className) {\n\t\ttd.className = className;\n\t}\n\treturn td;\n};\n\nexport const insertRow = (...tds: HTMLElement[]): void => {\n\tconst tr = document.createElement('tr');\n\ttr.append(...tds);\n\tdocument.querySelector('tbody')!.append(tr);\n};\n\nexport const getErrorInfo = (\n\tstartLine: number,\n\tstartCol: number,\n\tmessage: string,\n\texcerpt: string,\n): [HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement] => [\n\tcreateTd(String(startLine)),\n\tcreateTd(String(startCol)),\n\tcreateTd(message, 'excerpt'),\n\tcreateTd(excerpt, 'excerpt mono'),\n];\n", "import {load, addLink} from './common';\n\ndeclare const data: string[];\n\nload('./data/index.js', () => {\n\tdocument.getElementById('container')!.append(...data.map(\n\t\tlang => addLink('div', `${lang}wiki`, `./wiki.html?lang=${lang}`),\n\t));\n});\n"],
|
5
|
+
"mappings": "mBAAA,IAAMA,EAAY,CAACC,EAAsBC,IAAuB,CAC/DD,EAAE,KAAOC,EACLA,EAAK,WAAW,UAAU,IAC7BD,EAAE,OAAS,SACXA,EAAE,IAAM,WAEV,EAEaE,EAAO,CAACC,EAAaC,IAA+B,CAChE,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMF,EACbE,EAAO,iBAAiB,OAAQD,CAAQ,EACxC,SAAS,KAAK,OAAOC,CAAM,CAC5B,EAsBO,IAAMC,EAAU,CAACC,EAAaC,EAAcC,EAAcC,IAAoC,CACpG,IAAMC,EAAY,SAAS,cAAcJ,CAAG,EAC3CK,EAAI,SAAS,cAAc,GAAG,EAC/B,OAAAA,EAAE,YAAcJ,EAChBK,EAAUD,EAAGH,CAAI,EACjBE,EAAU,OAAOC,CAAC,EACdF,IACHC,EAAU,UAAYD,GAEhBC,CACR,ECzCAG,EAAK,kBAAmB,IAAM,CAC7B,SAAS,eAAe,WAAW,EAAG,OAAO,GAAG,KAAK,IACpDC,GAAQC,EAAQ,MAAO,GAAGD,CAAI,OAAQ,oBAAoBA,CAAI,EAAE,CACjE,CAAC,CACF,CAAC",
|
6
6
|
"names": ["armorLink", "a", "href", "load", "src", "callback", "script", "addLink", "tag", "text", "href", "className", "container", "a", "armorLink", "load", "lang", "addLink"]
|
7
7
|
}
|
package/reports/dist/rule.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var g=(e,t)=>{e.href=t,t.startsWith("https://")&&(e.target="_blank",e.rel="noopener")},p=(e,t)=>{let n=document.createElement("script");n.src=e,n.addEventListener("load",t),document.head.append(n)},m=(e,t)=>{let n=document.querySelector(e);return n.textContent=n.textContent.replace("Wikipedia",t),n},d=(e,t,n)=>{let r=document.getElementById(e);typeof t=="function"?r.href=t(r.href):t?g(r,t):r.removeAttribute("href"),n!==void 0&&(r.textContent=n)},u=(e,t,n,r)=>{let s=document.createElement(e),c=document.createElement("a");return c.textContent=t,g(c,n),s.append(c),r&&(s.className=r),s},l=(e,t)=>{let n=document.createElement("td");return n.textContent=e,t&&(n.className=t),n},E=(...e)=>{let t=document.createElement("tr");t.append(...e),document.querySelector("tbody").append(t)},x=(e,t,n,r)=>[l(String(e)),l(String(t)),l(n,"excerpt"),l(r,"excerpt mono")];var o=new URLSearchParams(location.search),i=o.get("lang"),b=o.get("rule"),a=Math.floor(Number(o.get("start")||0)/200),f=m("h2",`${i}wiki: ${b}`);m("title",`${i}wiki`);d("wiki",e=>`${e}?lang=${i}`,`${i}wiki`);o.set("start",String((a-1)*200));d("prev",a!==0&&`${location.pathname}?${o}`);document.getElementById("start").textContent=String(a*200+1);p(`./data/${i}/${b}-${a}.js`,()=>{let e=String(a*200+data.articles.length);f.textContent+=` (${data.timestamp})`,document.getElementById("end").textContent=e,o.set("start",e),d("next",data.batches!==a+1&&`${location.pathname}?${o}`),document.querySelector("table").after(document.getElementById("nav").cloneNode(!0));for(let[t,n,r,s,c]of data.articles){let h=encodeURIComponent(t);E(u("td",t,`./article.html?lang=${i}&page=${h}`,"excerpt"),...x(n,r,s,c))}});})();
|
2
2
|
//# sourceMappingURL=rule.js.map
|
package/reports/dist/rule.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../src/common.ts", "../src/rule.ts"],
|
4
|
-
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const
|
5
|
-
"mappings": "mBAAA,IAAMA,EAAY,CAACC,EAAsBC,IAAuB,CAC/DD,EAAE,KAAOC,EACLA,EAAK,WAAW,UAAU,IAC7BD,EAAE,OAAS,SACXA,EAAE,IAAM,WAEV,EAEaE,EAAO,CAACC,EAAaC,IAA+B,CAChE,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMF,EACbE,EAAO,iBAAiB,OAAQD,CAAQ,EACxC,SAAS,KAAK,OAAOC,CAAM,CAC5B,EAEaC,
|
6
|
-
"names": ["armorLink", "a", "href", "load", "src", "callback", "script", "
|
4
|
+
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const update = (tag: string, replace: string): Element => {\n\tconst ele = document.querySelector(tag)!;\n\tele.textContent = ele.textContent!.replace('Wikipedia', replace);\n\treturn ele;\n};\n\nexport const updateLink = (id: string, href: string | ((s: string) => string) | false, text?: string): void => {\n\tconst a = document.getElementById(id) as HTMLAnchorElement;\n\tif (typeof href === 'function') {\n\t\ta.href = href(a.href);\n\t} else if (href) {\n\t\tarmorLink(a, href);\n\t} else {\n\t\ta.removeAttribute('href');\n\t}\n\tif (text !== undefined) {\n\t\ta.textContent = text;\n\t}\n};\n\nexport const addLink = (tag: string, text: string, href: string, className?: string): HTMLElement => {\n\tconst container = document.createElement(tag),\n\t\ta = document.createElement('a');\n\ta.textContent = text;\n\tarmorLink(a, href);\n\tcontainer.append(a);\n\tif (className) {\n\t\tcontainer.className = className;\n\t}\n\treturn container;\n};\n\nexport const createTd = (text: string, className?: string): HTMLTableCellElement => {\n\tconst td = document.createElement('td');\n\ttd.textContent = text;\n\tif (className) {\n\t\ttd.className = className;\n\t}\n\treturn td;\n};\n\nexport const insertRow = (...tds: HTMLElement[]): void => {\n\tconst tr = document.createElement('tr');\n\ttr.append(...tds);\n\tdocument.querySelector('tbody')!.append(tr);\n};\n\nexport const getErrorInfo = (\n\tstartLine: number,\n\tstartCol: number,\n\tmessage: string,\n\texcerpt: string,\n): [HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement] => [\n\tcreateTd(String(startLine)),\n\tcreateTd(String(startCol)),\n\tcreateTd(message, 'excerpt'),\n\tcreateTd(excerpt, 'excerpt mono'),\n];\n", "import {load, update, addLink, insertRow, getErrorInfo, updateLink} from './common';\n\ndeclare const data: {\n\tarticles: [string, number, number, string, string][];\n\tbatches: number;\n\ttimestamp: string;\n};\n\nconst search = new URLSearchParams(location.search),\n\tlang = search.get('lang'),\n\trule = search.get('rule'),\n\tbatch = Math.floor(Number(search.get('start') || 0) / 200),\n\th2 = update('h2', `${lang}wiki: ${rule}`);\nupdate('title', `${lang}wiki`);\nupdateLink('wiki', s => `${s}?lang=${lang}`, `${lang}wiki`);\nsearch.set('start', String((batch - 1) * 200));\nupdateLink('prev', batch !== 0 && `${location.pathname}?${search}`);\ndocument.getElementById('start')!.textContent = String(batch * 200 + 1);\nload(`./data/${lang}/${rule}-${batch}.js`, () => {\n\tconst endStr = String(batch * 200 + data.articles.length);\n\th2.textContent += ` (${data.timestamp})`;\n\tdocument.getElementById('end')!.textContent = endStr;\n\tsearch.set('start', endStr);\n\tupdateLink('next', data.batches !== batch + 1 && `${location.pathname}?${search}`);\n\tdocument.querySelector('table')!\n\t\t.after(document.getElementById('nav')!.cloneNode(true));\n\tfor (const [page, startLine, startCol, message, excerpt] of data.articles) {\n\t\tconst title = encodeURIComponent(page);\n\t\tinsertRow(\n\t\t\taddLink('td', page, `./article.html?lang=${lang}&page=${title}`, 'excerpt'),\n\t\t\t...getErrorInfo(startLine, startCol, message, excerpt),\n\t\t);\n\t}\n});\n"],
|
5
|
+
"mappings": "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",
|
6
|
+
"names": ["armorLink", "a", "href", "load", "src", "callback", "script", "update", "tag", "replace", "ele", "updateLink", "id", "text", "addLink", "className", "container", "createTd", "td", "insertRow", "tds", "tr", "getErrorInfo", "startLine", "startCol", "message", "excerpt", "search", "lang", "rule", "batch", "h2", "update", "updateLink", "s", "load", "endStr", "page", "startLine", "startCol", "message", "excerpt", "title", "insertRow", "addLink", "getErrorInfo"]
|
7
7
|
}
|
package/reports/dist/wiki.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";(()=>{var g=(t,e)=>{t.href=e,e.startsWith("https://")&&(t.target="_blank",t.rel="noopener")},l=(t,e)=>{let n=document.createElement("script");n.src=t,n.addEventListener("load",e),document.head.append(n)}
|
1
|
+
"use strict";(()=>{var g=(t,e)=>{t.href=e,e.startsWith("https://")&&(t.target="_blank",t.rel="noopener")},l=(t,e)=>{let n=document.createElement("script");n.src=t,n.addEventListener("load",e),document.head.append(n)},s=(t,e)=>{let n=document.querySelector(t);return n.textContent=n.textContent.replace("Wikipedia",e),n};var c=(t,e,n,a)=>{let o=document.createElement(t),i=document.createElement("a");return i.textContent=e,g(i,n),o.append(i),a&&(o.className=a),o},d=(t,e)=>{let n=document.createElement("td");return n.textContent=t,e&&(n.className=e),n},m=(...t)=>{let e=document.createElement("tr");e.append(...t),document.querySelector("tbody").append(e)};var r=new URLSearchParams(location.search).get("lang"),p=s("h2",`${r}wiki`);s("title",`${r}wiki`);l(`./data/${r}/index.js`,()=>{p.textContent+=` (${data[data.length-1]})`;for(let[t,e]of data.slice(0,-1))m(c("td",t,`./rule.html?lang=${r}&rule=${t}`),d(String(e)))});})();
|
2
2
|
//# sourceMappingURL=wiki.js.map
|
package/reports/dist/wiki.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../src/common.ts", "../src/wiki.ts"],
|
4
|
-
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const
|
5
|
-
"mappings": "mBAAA,IAAMA,EAAY,CAACC,EAAsBC,IAAuB,CAC/DD,EAAE,KAAOC,EACLA,EAAK,WAAW,UAAU,IAC7BD,EAAE,OAAS,SACXA,EAAE,IAAM,WAEV,EAEaE,EAAO,CAACC,EAAaC,IAA+B,CAChE,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMF,EACbE,EAAO,iBAAiB,OAAQD,CAAQ,EACxC,SAAS,KAAK,OAAOC,CAAM,CAC5B,
|
4
|
+
"sourcesContent": ["const armorLink = (a: HTMLAnchorElement, href: string): void => {\n\ta.href = href;\n\tif (href.startsWith('https://')) {\n\t\ta.target = '_blank';\n\t\ta.rel = 'noopener';\n\t}\n};\n\nexport const load = (src: string, callback: () => void): void => {\n\tconst script = document.createElement('script');\n\tscript.src = src;\n\tscript.addEventListener('load', callback);\n\tdocument.head.append(script);\n};\n\nexport const update = (tag: string, replace: string): Element => {\n\tconst ele = document.querySelector(tag)!;\n\tele.textContent = ele.textContent!.replace('Wikipedia', replace);\n\treturn ele;\n};\n\nexport const updateLink = (id: string, href: string | ((s: string) => string) | false, text?: string): void => {\n\tconst a = document.getElementById(id) as HTMLAnchorElement;\n\tif (typeof href === 'function') {\n\t\ta.href = href(a.href);\n\t} else if (href) {\n\t\tarmorLink(a, href);\n\t} else {\n\t\ta.removeAttribute('href');\n\t}\n\tif (text !== undefined) {\n\t\ta.textContent = text;\n\t}\n};\n\nexport const addLink = (tag: string, text: string, href: string, className?: string): HTMLElement => {\n\tconst container = document.createElement(tag),\n\t\ta = document.createElement('a');\n\ta.textContent = text;\n\tarmorLink(a, href);\n\tcontainer.append(a);\n\tif (className) {\n\t\tcontainer.className = className;\n\t}\n\treturn container;\n};\n\nexport const createTd = (text: string, className?: string): HTMLTableCellElement => {\n\tconst td = document.createElement('td');\n\ttd.textContent = text;\n\tif (className) {\n\t\ttd.className = className;\n\t}\n\treturn td;\n};\n\nexport const insertRow = (...tds: HTMLElement[]): void => {\n\tconst tr = document.createElement('tr');\n\ttr.append(...tds);\n\tdocument.querySelector('tbody')!.append(tr);\n};\n\nexport const getErrorInfo = (\n\tstartLine: number,\n\tstartCol: number,\n\tmessage: string,\n\texcerpt: string,\n): [HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement, HTMLTableCellElement] => [\n\tcreateTd(String(startLine)),\n\tcreateTd(String(startCol)),\n\tcreateTd(message, 'excerpt'),\n\tcreateTd(excerpt, 'excerpt mono'),\n];\n", "import {load, update, addLink, createTd, insertRow} from './common';\n\ndeclare const data: [...[string, number][], string];\n\nconst lang = new URLSearchParams(location.search).get('lang'),\n\th2 = update('h2', `${lang}wiki`);\nupdate('title', `${lang}wiki`);\nload(`./data/${lang}/index.js`, () => {\n\th2.textContent += ` (${data[data.length - 1] as string})`;\n\tfor (const [rule, count] of data.slice(0, -1) as [string, number][]) {\n\t\tinsertRow(\n\t\t\taddLink('td', rule, `./rule.html?lang=${lang}&rule=${rule}`),\n\t\t\tcreateTd(String(count)),\n\t\t);\n\t}\n});\n"],
|
5
|
+
"mappings": "mBAAA,IAAMA,EAAY,CAACC,EAAsBC,IAAuB,CAC/DD,EAAE,KAAOC,EACLA,EAAK,WAAW,UAAU,IAC7BD,EAAE,OAAS,SACXA,EAAE,IAAM,WAEV,EAEaE,EAAO,CAACC,EAAaC,IAA+B,CAChE,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMF,EACbE,EAAO,iBAAiB,OAAQD,CAAQ,EACxC,SAAS,KAAK,OAAOC,CAAM,CAC5B,EAEaC,EAAS,CAACC,EAAaC,IAA6B,CAChE,IAAMC,EAAM,SAAS,cAAcF,CAAG,EACtC,OAAAE,EAAI,YAAcA,EAAI,YAAa,QAAQ,YAAaD,CAAO,EACxDC,CACR,EAgBO,IAAMC,EAAU,CAACC,EAAaC,EAAcC,EAAcC,IAAoC,CACpG,IAAMC,EAAY,SAAS,cAAcJ,CAAG,EAC3CK,EAAI,SAAS,cAAc,GAAG,EAC/B,OAAAA,EAAE,YAAcJ,EAChBK,EAAUD,EAAGH,CAAI,EACjBE,EAAU,OAAOC,CAAC,EACdF,IACHC,EAAU,UAAYD,GAEhBC,CACR,EAEaG,EAAW,CAACN,EAAcE,IAA6C,CACnF,IAAMK,EAAK,SAAS,cAAc,IAAI,EACtC,OAAAA,EAAG,YAAcP,EACbE,IACHK,EAAG,UAAYL,GAETK,CACR,EAEaC,EAAY,IAAIC,IAA6B,CACzD,IAAMC,EAAK,SAAS,cAAc,IAAI,EACtCA,EAAG,OAAO,GAAGD,CAAG,EAChB,SAAS,cAAc,OAAO,EAAG,OAAOC,CAAE,CAC3C,ECxDA,IAAMC,EAAO,IAAI,gBAAgB,SAAS,MAAM,EAAE,IAAI,MAAM,EAC3DC,EAAKC,EAAO,KAAM,GAAGF,CAAI,MAAM,EAChCE,EAAO,QAAS,GAAGF,CAAI,MAAM,EAC7BG,EAAK,UAAUH,CAAI,YAAa,IAAM,CACrCC,EAAG,aAAe,KAAK,KAAK,KAAK,OAAS,CAAC,CAAW,IACtD,OAAW,CAACG,EAAMC,CAAK,IAAK,KAAK,MAAM,EAAG,EAAE,EAC3CC,EACCC,EAAQ,KAAMH,EAAM,oBAAoBJ,CAAI,SAASI,CAAI,EAAE,EAC3DI,EAAS,OAAOH,CAAK,CAAC,CACvB,CAEF,CAAC",
|
6
6
|
"names": ["armorLink", "a", "href", "load", "src", "callback", "script", "update", "tag", "replace", "ele", "addLink", "tag", "text", "href", "className", "container", "a", "armorLink", "createTd", "td", "insertRow", "tds", "tr", "lang", "h2", "update", "load", "rule", "count", "insertRow", "addLink", "createTd"]
|
7
7
|
}
|
package/reports/rule.html
CHANGED
@@ -31,22 +31,18 @@
|
|
31
31
|
<table style="table-layout:fixed;width:100%;min-width:900px">
|
32
32
|
<colgroup>
|
33
33
|
<col span="1">
|
34
|
-
<col span="1" style="width:calc(1.6em + 5ch)">
|
35
34
|
<col span="1" style="width:calc(1.6em + 7ch)">
|
36
35
|
<col span="1" style="width:calc(1.6em + 7ch)">
|
37
36
|
<col span="1" style="width:20%">
|
38
37
|
<col span="1" style="width:40%">
|
39
|
-
<col span="1" style="width:calc(1.6em + 5ch)">
|
40
38
|
</colgroup>
|
41
39
|
<tbody>
|
42
40
|
<tr>
|
43
41
|
<th>Article</th>
|
44
|
-
<th>Edit</th>
|
45
42
|
<th>Line</th>
|
46
43
|
<th>Column</th>
|
47
44
|
<th>Detail</th>
|
48
45
|
<th>Notice</th>
|
49
|
-
<th>More</th>
|
50
46
|
</tr>
|
51
47
|
</tbody>
|
52
48
|
</table>
|
package/server.js
CHANGED
@@ -6,33 +6,82 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const http_1 = require("http");
|
7
7
|
const path_1 = __importDefault(require("path"));
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
9
|
-
const
|
9
|
+
const util_1 = require("./util");
|
10
|
+
const port = parseInt(process.env['PORT'] || '8000'), headers = {
|
11
|
+
'content-type': 'application/json',
|
12
|
+
'x-content-type-options': 'nosniff',
|
13
|
+
'cache-control': 'max-age=5',
|
14
|
+
};
|
15
|
+
let busy = false;
|
10
16
|
(0, http_1.createServer)(({ url }, res) => {
|
11
17
|
if (!url || url === '/') {
|
12
18
|
url = 'index.html'; // eslint-disable-line no-param-reassign
|
13
19
|
}
|
14
|
-
const file = new URL(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
const file = new URL(path_1.default.join('reports', url), 'http://localhost').pathname.slice(1);
|
21
|
+
if (file.startsWith('reports/purge/')) {
|
22
|
+
const [, , lang, page] = file.split('/');
|
23
|
+
(async () => {
|
24
|
+
const obj = { status: 'error' };
|
25
|
+
let code = 400;
|
26
|
+
if (busy) {
|
27
|
+
code = 503;
|
28
|
+
}
|
29
|
+
else if (lang && page) {
|
30
|
+
busy = true;
|
31
|
+
try {
|
32
|
+
const response = await fetch(`https://${lang === 'mediawiki' ? 'www.mediawiki.org' : `${lang}.wikipedia.org`}/w/rest.php/v1/page/${page}`, {
|
33
|
+
headers: {
|
34
|
+
'Api-User-Agent': 'tools.lint-wiki-dumps (https://github.com/bhsd-harry/lint-wiki-dumps)',
|
35
|
+
},
|
36
|
+
}), title = decodeURIComponent(page).replaceAll('_', ' ');
|
37
|
+
code = response.status;
|
38
|
+
console.log(`Purging ${lang}wiki: ${title}; status: ${code}`);
|
39
|
+
if (code === 200) {
|
40
|
+
const { source, content_model: contentModel, latest: { timestamp } } = await response.json();
|
41
|
+
if (contentModel === 'wikitext') {
|
42
|
+
const errors = (0, util_1.lint)(source), hash = `${(0, util_1.getHash)(lang, title)}.js`, filepath = path_1.default.join('reports', 'data', hash);
|
43
|
+
console.log(`Remaining errors in ${hash}: ${errors.length}`);
|
44
|
+
(0, util_1.write)(filepath, errors);
|
45
|
+
obj.status = 'success';
|
46
|
+
obj.timestamp = timestamp;
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
code = 400;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
catch {
|
54
|
+
code = 500;
|
55
|
+
}
|
56
|
+
busy = false; // eslint-disable-line require-atomic-updates
|
57
|
+
}
|
58
|
+
res.writeHead(code, headers);
|
59
|
+
res.end(JSON.stringify(obj), 'utf8');
|
60
|
+
})();
|
33
61
|
}
|
34
62
|
else {
|
35
|
-
|
36
|
-
|
63
|
+
let contentType;
|
64
|
+
switch (path_1.default.extname(file)) {
|
65
|
+
case '.js':
|
66
|
+
contentType = 'text/javascript';
|
67
|
+
break;
|
68
|
+
case '.css':
|
69
|
+
contentType = 'text/css';
|
70
|
+
break;
|
71
|
+
default:
|
72
|
+
contentType = 'text/html';
|
73
|
+
}
|
74
|
+
if (fs_1.default.existsSync(file)) {
|
75
|
+
res.writeHead(200, {
|
76
|
+
'content-type': contentType,
|
77
|
+
'x-content-type-options': 'nosniff',
|
78
|
+
'cache-control': `max-age=${60 * 60 * 24}, public`,
|
79
|
+
});
|
80
|
+
res.end(fs_1.default.readFileSync(file), 'utf8');
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
res.writeHead(301, { Location: '/' });
|
84
|
+
res.end();
|
85
|
+
}
|
37
86
|
}
|
38
87
|
}).listen(port);
|
package/util.js
CHANGED
@@ -3,15 +3,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.normalize = exports.reading = exports.replaceTilde = exports.isArticle = exports.getErrors = exports.getTimestamp = exports.getXmlStream = exports.getWriteStream = exports.init = exports.getTempPath = exports.resultDir = exports.MAX = void 0;
|
6
|
+
exports.write = exports.getHash = exports.normalize = exports.reading = exports.replaceTilde = exports.isArticle = exports.getErrors = exports.getTimestamp = exports.getXmlStream = exports.getWriteStream = exports.init = exports.getTempPath = exports.lint = exports.resultDir = exports.MAX = void 0;
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
8
8
|
const path_1 = __importDefault(require("path"));
|
9
9
|
const os_1 = __importDefault(require("os"));
|
10
|
+
const crypto_1 = require("crypto");
|
10
11
|
const chalk_1 = __importDefault(require("chalk"));
|
11
12
|
const unbzip2_stream_1 = __importDefault(require("unbzip2-stream"));
|
12
13
|
const xml_stream_1 = __importDefault(require("xml-stream"));
|
14
|
+
const wikilint_1 = __importDefault(require("wikilint"));
|
13
15
|
exports.MAX = 100, exports.resultDir = path_1.default.join(__dirname, 'results');
|
14
|
-
const tempDir = path_1.default.join(__dirname, 'temp');
|
16
|
+
const tempDir = path_1.default.join(__dirname, 'temp'), ignore = new Set(['h1', 'no-arg', 'unclosed-table', 'unmatched-tag', 'url-encoding', 'var-anchor', 'void-ext']);
|
17
|
+
const lint = ($text, ns) => wikilint_1.default.parse($text, ns === '828').lint()
|
18
|
+
.filter(({ severity, rule }) => severity === 'error' && !ignore.has(rule))
|
19
|
+
.map(({ severity, suggestions, fix,
|
20
|
+
/* DISABLED */
|
21
|
+
code, startIndex, endLine, endCol, endIndex,
|
22
|
+
/* DISABLED END */
|
23
|
+
...e }) => ({
|
24
|
+
...e,
|
25
|
+
// eslint-disable-next-line @stylistic/multiline-comment-style
|
26
|
+
/* DISABLED
|
27
|
+
|
28
|
+
...suggestions && {
|
29
|
+
suggestions: suggestions.map(action => ({
|
30
|
+
...action,
|
31
|
+
original: $text.slice(...action.range),
|
32
|
+
})),
|
33
|
+
},
|
34
|
+
...fix && {fix: {...fix, original: $text.slice(...fix.range)}},
|
35
|
+
|
36
|
+
*/
|
37
|
+
excerpt: $text.slice(startIndex, endIndex).slice(0, exports.MAX),
|
38
|
+
}));
|
39
|
+
exports.lint = lint;
|
15
40
|
const getTempPath = (file) => path_1.default.join(tempDir, file);
|
16
41
|
exports.getTempPath = getTempPath;
|
17
42
|
const init = () => {
|
@@ -67,3 +92,12 @@ const reading = (file) => {
|
|
67
92
|
exports.reading = reading;
|
68
93
|
const normalize = (str) => str.replaceAll('-', '_');
|
69
94
|
exports.normalize = normalize;
|
95
|
+
const getHash = (lang, page) => {
|
96
|
+
const hash = (0, crypto_1.createHash)('sha256').update(page).digest('hex').slice(0, 8);
|
97
|
+
return path_1.default.join(lang, 'pages', hash);
|
98
|
+
};
|
99
|
+
exports.getHash = getHash;
|
100
|
+
const write = (file, data) => {
|
101
|
+
fs_1.default.writeFileSync(file, `globalThis.data=${JSON.stringify(data)}`);
|
102
|
+
};
|
103
|
+
exports.write = write;
|