@moneko/core 3.38.1 → 3.39.0-beta.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/lib/bin/lint-stage-git.d.mts +29 -0
- package/lib/bin/lint-stage-git.mjs +1 -0
- package/lib/plugin/compression.d.mts +1 -1
- package/lib/plugin/compression.mjs +1 -1
- package/lib/plugin/worker/eslint.d.mts +5 -0
- package/lib/plugin/worker/eslint.mjs +1 -0
- package/lib/plugin/worker/stylelint.d.mts +5 -0
- package/lib/plugin/worker/stylelint.mjs +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawnSync, type SpawnSyncReturns } from 'node:child_process';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { argv } from 'node:process';
|
|
5
|
+
import { ESLint } from '@moneko/eslint';
|
|
6
|
+
import { stylelint as Stylelint } from '@moneko/stylelint';
|
|
7
|
+
declare function parseArgs<T>(args: string[]): T;
|
|
8
|
+
type Args = {
|
|
9
|
+
fix?: boolean;
|
|
10
|
+
cache?: boolean;
|
|
11
|
+
mode?: 'ci' | 'commit';
|
|
12
|
+
};
|
|
13
|
+
declare const args: Args;
|
|
14
|
+
declare const fix: boolean | undefined;
|
|
15
|
+
declare const cache: boolean;
|
|
16
|
+
declare const cwd: string;
|
|
17
|
+
declare const cachePath: string;
|
|
18
|
+
declare const cmd: {
|
|
19
|
+
readonly ci: readonly ['diff', '--name-only', 'HEAD^', 'HEAD'];
|
|
20
|
+
readonly commit: readonly ['diff', '--cached', '--name-only', '--diff-filter=ACMR'];
|
|
21
|
+
};
|
|
22
|
+
declare const scriptRegExp: RegExp;
|
|
23
|
+
declare const vueRegExp: RegExp;
|
|
24
|
+
declare const styleRegExp: RegExp;
|
|
25
|
+
declare const child: SpawnSyncReturns<Buffer>;
|
|
26
|
+
declare const lintFiles: string[];
|
|
27
|
+
export declare async function eslint();
|
|
28
|
+
declare const styleFiles: string[];
|
|
29
|
+
export declare async function stylelint();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawnSync as t}from"node:child_process";import{readFile as e}from"node:fs/promises";import{join as o}from"node:path";import{argv as i}from"node:process";import{ESLint as r}from"@moneko/eslint";import{stylelint as s}from"@moneko/stylelint";let n=Object.fromEntries(i.slice(2).map(function(t){let e=t.split("="),o=e[1];return void 0===o||"true"===o?o=!0:"false"===o?o=!1:/-?\d+(\.\d+)?([eE][+-]?\d+)?/.test(o)&&(o=parseFloat(o)),[e[0].replace(/^--/,""),o]})),c=n.fix,l=n.cache||!0,a=o(process.cwd(),"node_modules/.cache"),m={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACMR"]},d=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,f=/.*(?<!\.d)\.vue$/,p=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,u=t("git",m[n.mode||"ci"]||m.ci).stdout.toString().trim().split("\n");export async function eslint(){console.log("ESLint runing...");try{console.time("ESLint");let t=new r({cache:l,cacheLocation:`${a}/.eslintcache`,fix:c}),e=u.filter(t=>d.test(t)||f.test(t)),o=await t.lintFiles(e),i=await t.loadFormatter("stylish"),s=await i.format(o);c&&await r.outputFixes(o),s&&process.stdout.write(s);let n=o.some(t=>t.errorCount>0);console.timeEnd("ESLint"),n&&process.exit(1)}catch(t){console.error(t)}}let y=u.filter(t=>p.test(t)||f.test(t));export async function stylelint(){console.log("Stylelint runing..."),console.time("Stylelint");let t=await Promise.all(y.map(async t=>{let o=await e(t,{encoding:"utf-8"});return await s.lint({codeFilename:t,code:o,cache:l,cacheLocation:`${a}/.stylelintcache`,fix:c,formatter:"string"}).catch(console.log)})),o=!1;t.forEach(t=>{t&&(t.report&&process.stdout.write(t.report),t.errored&&(o=!!t.errored))}),console.timeEnd("Stylelint"),o&&process.exit(1)}
|
|
@@ -3,7 +3,7 @@ import { type AssetInfo, type Compilation, type Compiler, type sources, type Web
|
|
|
3
3
|
type Source = sources.Source;
|
|
4
4
|
interface CompressionPluginOptions {
|
|
5
5
|
test: RegExp;
|
|
6
|
-
algorithm: 'gzip' | '
|
|
6
|
+
algorithm: 'gzip' | 'brotli';
|
|
7
7
|
filename: string;
|
|
8
8
|
}
|
|
9
9
|
declare class CompressionPlugin {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{compression as e}from"@moneko/utils";export default class{constructor(e){this.name="compression-plugin";let{test:
|
|
1
|
+
import{compression as e}from"@moneko/utils";export default class{constructor(e){this.name="compression-plugin";let{test:t,algorithm:s="brotli",filename:o}=e||{};this.options={test:t,algorithm:s,filename:o||`[path][base].${"brotli"===s?"br":"gz"}`}}runCompressionAlgorithm(t){return Buffer.from(e(Buffer.isBuffer(t)?Array.from(t):t,this.options.algorithm))}async compress(e,t,s){let o=t.getCache(this.name),{RawSource:i}=e.webpack.sources;await Promise.all(Object.keys(s).map(async s=>{let r;let a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:l}=t.getAsset(s);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(s)||m.related&&m.related[a])return!1;let p=o.getItemCache(JSON.stringify({name:s,algorithm:this.options.algorithm}),o.getLazyHashedEtag(l)),n=await p.getPromise()||{};if(!n.source){if("function"==typeof l.buffer)r=l.buffer();else{let e=l.source();r=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!n.compressed&&r)try{n.compressed=this.runCompressionAlgorithm(r)}catch(e){t.errors.push(e);return}n.compressed&&(n.source=new i(n.compressed)),await p.storePromise(n)}let c=t.getPath(this.options.filename,{filename:s}),f={compressed:!0};m.immutable&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(f.immutable=!0),t.updateAsset(s,l,{related:{[a]:c}}),t.emitAsset(c,n.source,f)}))}apply(e){let t=this.constructor.name;e.hooks.thisCompilation.tap(t,s=>{s.hooks.processAssets.tapPromise({name:t,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,additionalAssets:!0},t=>this.compress(e,s,t))})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e,a;import{ESLint as t}from"@moneko/eslint";import{parentPort as r}from"worker_threads";if(!r)throw Error("This file must be run as a worker");let o=null;r.on("message",async({options:i})=>{o&&clearTimeout(o),o=setTimeout(async()=>{o&&(clearTimeout(o),o=null);try{e||(e=new t({cache:i.cache,cacheLocation:i.cacheLocation,cacheStrategy:i.cacheStrategy,fix:i.fix}),a=await e.loadFormatter("stylish"));let o=i.files.map(e=>e.replace(/\\/g,"/")),c=await e.lintFiles(o),s=[],l=[];i.fix&&await t.outputFixes(c),c.forEach(e=>{e.errorCount?l.push(e):e.warningCount&&s.push(e)});let n=await Promise.all([a.format(s),a.format(l)]);r.postMessage(n.map(e=>e.replace(/[^\r\n]*(\r?\n)*$/,"")))}catch(e){r.postMessage(e)}},4)}),r.on("close",()=>{o&&clearTimeout(o)});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Formatter, type LinterResult, type LintResult, stylelint, type Warning } from '@moneko/stylelint';
|
|
2
|
+
import { parentPort } from 'worker_threads';
|
|
3
|
+
export type StylelintWorkerMessage = [warnings: string, errors: string];
|
|
4
|
+
declare let timer: NodeJS.Timeout | null;
|
|
5
|
+
declare const formatter: Formatter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stylelint as e}from"@moneko/stylelint";import{parentPort as r}from"worker_threads";if(!r)throw Error("This file must be run as a worker");let t=null,a=await e.formatters.string;r.on("message",async({options:i})=>{t&&clearTimeout(t),t=setTimeout(async()=>{t&&(clearTimeout(t),t=null);try{let t=await e.lint({cache:i.cache,cacheLocation:i.cacheLocation,fix:i.fix,files:i.files.map(e=>e.replace(/\\/g,"/")),quietDeprecationWarnings:i.quietDeprecationWarnings,quiet:i.quiet});delete t.output;let n=[],s=[];t.results.forEach(e=>{if(!e.ignored&&(e.errored||e.parseErrors.length||e.invalidOptionWarnings.length||e.deprecations.length)){let r=[],t=[];e.warnings.forEach(e=>{"error"===e.severity?r.push(e):"warning"===e.severity&&t.push(e)}),r.length>0&&n.push({...e,warnings:r}),t.length>0&&s.push({...e,warnings:t})}});let o=[a(s,t),a(n,t)];r.postMessage(o.map(e=>e.replace(/[^\r\n]*(\r?\n)*$/,"")))}catch(e){r.postMessage(e)}},4)}),r.on("close",()=>{t&&clearTimeout(t)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.39.0-beta.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@moneko/raw-import": "0.0.3",
|
|
24
24
|
"@moneko/stylelint": "1.3.0",
|
|
25
25
|
"@moneko/transform-imports": "0.6.1",
|
|
26
|
-
"@moneko/utils": "0.2.
|
|
26
|
+
"@moneko/utils": "0.2.2",
|
|
27
27
|
"@swc/core": "1.6.13",
|
|
28
28
|
"browserslist": "4.24.4",
|
|
29
29
|
"chokidar": "4.0.3",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"style-loader": "4.0.0",
|
|
40
40
|
"swc-loader": "0.2.6",
|
|
41
41
|
"typescript": "5.8.3",
|
|
42
|
-
"webpack": "5.99.
|
|
42
|
+
"webpack": "5.99.2",
|
|
43
43
|
"webpack-hot-middleware": "2.26.1",
|
|
44
44
|
"webpack-merge": "6.0.1",
|
|
45
45
|
"webpack-virtual-modules": "0.6.2"
|