@moneko/core 3.54.0-beta.1 → 3.54.0-beta.3
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/commit-lint.d.mts +1 -42
- package/lib/bin/commit-lint.mjs +1 -1
- package/lib/bin/file.d.mts +0 -2
- package/lib/bin/index.d.mts +1 -5
- package/lib/bin/pin.d.mts +4 -38
- package/lib/bin/pure-lint.d.mts +1 -31
- package/lib/bin/pure-lint.mjs +1 -1
- package/lib/bin/setup.d.mts +0 -3
- package/lib/bin/utils/convert-solid.d.mts +3 -6
- package/lib/bin/utils/convert-solid.mjs +1 -1
- package/lib/bin/utils/setup-swcrc.d.mts +1 -3
- package/lib/build/common.d.mts +1 -10
- package/lib/build/server.d.mts +0 -5
- package/lib/build.d.mts +1 -16
- package/lib/commom/ca.d.mts +7 -17
- package/lib/commom/ca.mjs +1 -1
- package/lib/commom/esm.d.mts +1 -1
- package/lib/commom/has-pkg.d.mts +0 -1
- package/lib/commom/is-ci-environment.d.mts +4 -2
- package/lib/commom/log.d.mts +1 -6
- package/lib/commom/match-path.d.mts +16 -1
- package/lib/commom/parse-module-meta.d.mts +0 -2
- package/lib/commom/print-log.d.mts +0 -1
- package/lib/commom/require.d.mts +0 -6
- package/lib/commom/timer.d.mts +3 -4
- package/lib/common.d.mts +1 -14
- package/lib/config.d.mts +0 -24
- package/lib/dev/generate-progress-html.d.mts +1 -1
- package/lib/dev/json-schema.d.mts +3 -3
- package/lib/dev/proxy.d.mts +3 -7
- package/lib/dev.d.mts +1 -48
- package/lib/dev.mjs +2 -2
- package/lib/file-system.d.mts +1 -1
- package/lib/loader/lightning-css/runtime/api.d.cts +5 -3
- package/lib/loader/lightning-css/runtime/get-url.cjs +1 -1
- package/lib/loader/lightning-css/runtime/get-url.d.cts +1 -9
- package/lib/module.config.d.mts +3 -49
- package/lib/module.config.mjs +1 -1
- package/lib/options/css-extract.d.mts +0 -5
- package/lib/options/modify-vars.d.mts +0 -9
- package/lib/options/split-chunk.d.mts +0 -2
- package/lib/plugin/eslint.d.mts +6 -14
- package/lib/plugin/module-federation.d.mts +1 -19
- package/lib/plugin/stylelint.d.mts +6 -14
- package/lib/plugins.config.d.mts +1 -10
- package/lib/polyfills/replace-children.d.mts +1 -1
- package/lib/process-env.d.mts +4 -8
- package/lib/utils/compile-dts.d.mts +16 -3
- package/lib/utils/create-types.d.mts +0 -13
- package/lib/utils/create-types.mjs +1 -1
- package/lib/utils/dts.d.mts +12 -5
- package/lib/utils/svg-to-data-uri.d.mts +1 -58
- package/lib/utils/vts.d.mts +14 -6
- package/lib/vm/docs.d.mts +0 -11
- package/lib/vm/docs.mjs +1 -1
- package/lib/vm/info.d.mts +0 -3
- package/lib/vm/locales.d.mts +0 -24
- package/lib/vm/modules.d.mts +0 -25
- package/lib/vm/render-app.d.mts +0 -9
- package/lib/worker/dts.d.mts +1 -2
- package/lib/worker/eslint.d.mts +0 -6
- package/lib/worker/eslint.mjs +1 -1
- package/lib/worker/react-compiler.d.mts +23 -8
- package/lib/worker/react-compiler.mjs +1 -1
- package/lib/worker/stylelint.d.mts +0 -4
- package/lib/worker/swc-minify.d.mts +1 -2
- package/package.json +6 -6
- package/lib/bin/build-app.d.mts +0 -11
- package/lib/bin/build-app.mjs +0 -1
- package/lib/bin/build.d.mts +0 -13
- package/lib/bin/build.mjs +0 -1
- package/lib/bin/changelog.d.mts +0 -12
- package/lib/bin/changelog.mjs +0 -4
- package/lib/bin/eslint.d.mts +0 -6
- package/lib/bin/eslint.mjs +0 -2
- package/lib/bin/git-hooks.d.mts +0 -5
- package/lib/bin/git-hooks.mjs +0 -2
- package/lib/bin/help.d.mts +0 -85
- package/lib/bin/help.mjs +0 -13
- package/lib/bin/lessc.d.mts +0 -10
- package/lib/bin/lessc.mjs +0 -1
- package/lib/bin/server.d.mts +0 -14
- package/lib/bin/server.mjs +0 -1
- package/lib/bin/start.d.mts +0 -5
- package/lib/bin/start.mjs +0 -1
- package/lib/bin/stylelint.d.mts +0 -7
- package/lib/bin/stylelint.mjs +0 -2
- package/lib/bin/tsc.d.mts +0 -6
- package/lib/bin/tsc.mjs +0 -1
- package/lib/bin/utils/bundle-app.d.mts +0 -7
- package/lib/bin/utils/bundle-app.mjs +0 -1
- package/lib/bin/utils/config.d.mts +0 -13
- package/lib/bin/utils/config.mjs +0 -1
- package/lib/bin/utils/get-commit-files.d.mts +0 -3
- package/lib/bin/utils/get-commit-files.mjs +0 -1
- package/lib/commom/check-npm.d.mts +0 -4
- package/lib/commom/check-npm.mjs +0 -1
- package/lib/commom/corepack.d.mts +0 -12
- package/lib/commom/corepack.mjs +0 -1
- package/lib/commom/diff-object.d.mts +0 -2
- package/lib/commom/diff-object.mjs +0 -1
- package/lib/commom/host.d.mts +0 -3
- package/lib/commom/host.mjs +0 -19
- package/lib/commom/module-resolve.d.mts +0 -3
- package/lib/commom/module-resolve.mjs +0 -1
- package/lib/commom/net.d.mts +0 -4
- package/lib/commom/net.mjs +0 -1
- package/lib/commom/open.d.mts +0 -5
- package/lib/commom/open.mjs +0 -1
- package/lib/commom/paths.d.mts +0 -36
- package/lib/commom/paths.mjs +0 -1
- package/lib/commom/reactive-object.d.mts +0 -10
- package/lib/commom/reactive-object.mjs +0 -1
- package/lib/commom/rule.d.mts +0 -20
- package/lib/commom/rule.mjs +0 -1
- package/lib/commom/setup-env.d.mts +0 -4
- package/lib/commom/setup-env.mjs +0 -1
- package/lib/commom/sigint-exit.d.mts +0 -3
- package/lib/commom/sigint-exit.mjs +0 -1
- package/lib/commom/transform-solid-js.d.mts +0 -41
- package/lib/commom/transform-solid-js.mjs +0 -1
- package/lib/dev/config.d.mts +0 -14
- package/lib/dev/config.mjs +0 -2
- package/lib/dev/get-cert.d.mts +0 -10
- package/lib/dev/get-cert.mjs +0 -1
- package/lib/dev/mock.d.mts +0 -61
- package/lib/dev/mock.mjs +0 -1
- package/lib/dev/server.d.mts +0 -34
- package/lib/dev/server.mjs +0 -1
- package/lib/loader/css-in-js-minify.cjs +0 -1
- package/lib/loader/css-in-js-minify.d.cts +0 -22
- package/lib/loader/lightning-css/codegen.cjs +0 -20
- package/lib/loader/lightning-css/codegen.d.cts +0 -36
- package/lib/loader/lightning-css/loader.cjs +0 -1
- package/lib/loader/lightning-css/loader.d.cts +0 -49
- package/lib/loader/lightning-css/utils.cjs +0 -1
- package/lib/loader/lightning-css/utils.d.cts +0 -26
- package/lib/loader/mdx.cjs +0 -1
- package/lib/loader/mdx.d.cts +0 -4
- package/lib/loader/react-compiler.cjs +0 -1
- package/lib/loader/react-compiler.d.cts +0 -21
- package/lib/loader/solid.cjs +0 -1
- package/lib/loader/solid.d.cts +0 -9
- package/lib/loader/ts-doc.cjs +0 -1
- package/lib/loader/ts-doc.d.cts +0 -11
- package/lib/options/md-to-html.d.mts +0 -5
- package/lib/options/md-to-html.mjs +0 -1
- package/lib/options/reslove.d.mts +0 -11
- package/lib/options/reslove.mjs +0 -1
- package/lib/options/swcrc.d.mts +0 -21
- package/lib/options/swcrc.mjs +0 -1
- package/lib/plugin/compression.d.mts +0 -17
- package/lib/plugin/compression.mjs +0 -1
- package/lib/plugin/copy.d.mts +0 -21
- package/lib/plugin/copy.mjs +0 -1
- package/lib/plugin/done.d.mts +0 -11
- package/lib/plugin/done.mjs +0 -1
- package/lib/plugin/exposes-declararion.d.mts +0 -20
- package/lib/plugin/exposes-declararion.mjs +0 -1
- package/lib/plugin/external-remotes.d.mts +0 -8
- package/lib/plugin/external-remotes.mjs +0 -1
- package/lib/plugin/html-plugin.d.mts +0 -48
- package/lib/plugin/html-plugin.mjs +0 -1
- package/lib/plugin/lightningcss-plugin.d.mts +0 -31
- package/lib/plugin/lightningcss-plugin.mjs +0 -1
- package/lib/plugin/manifest.d.mts +0 -43
- package/lib/plugin/manifest.mjs +0 -1
- package/lib/plugin/override-resolve.d.mts +0 -14
- package/lib/plugin/override-resolve.mjs +0 -1
- package/lib/plugin/swc-minify-plugin.d.mts +0 -13
- package/lib/plugin/swc-minify-plugin.mjs +0 -1
- package/lib/plugin/virtual-module.d.mts +0 -24
- package/lib/plugin/virtual-module.mjs +0 -1
- package/lib/polyfills/polyfills.d.mts +0 -7
- package/lib/polyfills/polyfills.mjs +0 -1
- package/lib/polyfills/targets.d.mts +0 -8
- package/lib/polyfills/targets.mjs +0 -1
- package/lib/utils/fetch-module-federation-dts.d.mts +0 -6
- package/lib/utils/fetch-module-federation-dts.mjs +0 -1
- package/lib/utils/index.d.mts +0 -12
- package/lib/utils/index.mjs +0 -1
- package/lib/utils/run.d.mts +0 -3
- package/lib/utils/run.mjs +0 -1
- package/lib/utils/seo.d.mts +0 -10
- package/lib/utils/seo.mjs +0 -4
- package/lib/vm/coverage.d.mts +0 -39
- package/lib/vm/coverage.mjs +0 -1
- package/lib/vm/example.d.mts +0 -12
- package/lib/vm/example.mjs +0 -1
- package/lib/vm/generate-doc.d.mts +0 -35
- package/lib/vm/generate-doc.mjs +0 -1
- package/lib/vm/routes.d.mts +0 -17
- package/lib/vm/routes.mjs +0 -1
- package/lib/vm/utils.d.mts +0 -5
- package/lib/vm/utils.mjs +0 -1
|
@@ -1,43 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { argv } from 'node:process';
|
|
4
|
-
import { loadFileSync, println } from '@moneko/utils';
|
|
5
|
-
import log from '../commom/log.mjs';
|
|
6
|
-
import paths from '../commom/paths.mjs';
|
|
7
|
-
interface FormatProblem {
|
|
8
|
-
level: number;
|
|
9
|
-
message: string;
|
|
10
|
-
name: string;
|
|
11
|
-
}
|
|
12
|
-
interface FormatResult {
|
|
13
|
-
valid: boolean;
|
|
14
|
-
errors: FormatProblem[];
|
|
15
|
-
warnings: FormatProblem[];
|
|
16
|
-
}
|
|
17
|
-
declare const LEVEL: {
|
|
18
|
-
readonly DISABLED: number;
|
|
19
|
-
readonly WARNING: number;
|
|
20
|
-
readonly ERROR: number;
|
|
21
|
-
};
|
|
22
|
-
declare const RULE_OUTCOME: {
|
|
23
|
-
readonly ALWAYS: string;
|
|
24
|
-
readonly NEVER: string;
|
|
25
|
-
};
|
|
26
|
-
declare function isSentenceCase(text: string);
|
|
27
|
-
declare function isStartCase(text: string);
|
|
28
|
-
declare function isPascalCase(text: string);
|
|
29
|
-
declare function isUpperCase(text: string);
|
|
30
|
-
interface CommitMessage {
|
|
31
|
-
header: string;
|
|
32
|
-
type: string;
|
|
33
|
-
subject: string;
|
|
34
|
-
body: string;
|
|
35
|
-
footer: string;
|
|
36
|
-
raw: string;
|
|
37
|
-
lines: string[];
|
|
38
|
-
}
|
|
39
|
-
declare function parseCommitMessage(message: string): CommitMessage;
|
|
40
|
-
type Rules = Record<string, [number, string, ...unknown[]]>;
|
|
41
|
-
declare function lint(message: string, rules: Rules);
|
|
42
|
-
declare function format(result: FormatResult);
|
|
43
|
-
declare function main();
|
|
2
|
+
export { };
|
package/lib/bin/commit-lint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{join as e}from"node:path";import{argv as t}from"node:process";import{loadFileSync as a,println as r}from"@moneko/utils";import s from"../commom/log.mjs";import n from"../commom/paths.mjs";
|
|
2
|
+
import{join as e}from"node:path";import{argv as t}from"node:process";import{loadFileSync as a,println as r}from"@moneko/utils";import s from"../commom/log.mjs";import n from"../commom/paths.mjs";function l(e){return/^[A-Z][a-z\d\s]*$/.test(e)}function o(e){return/^([A-Z][a-z\d]*\s*)+$/.test(e)}function i(e){return/^([A-Z][a-z\d]*)+$/.test(e)}function c(e){return e===e.toUpperCase()}let m=t[2]||e(n.programPath,".git","COMMIT_EDITMSG");m||(s("Commit message file path is required."),process.exit(1));let p=a(m);null===p&&(s("Commit message cannot be empty"),process.exit(1));let b=function(e,t){let a=function(e){let t=e.trim().split("\n"),a=t[0]||"",r=a.match(/^([a-zA-Z]+)(?:\([a-zA-Z0-9-]+\))?:\s*(.+)$/),s=r?r[1]:"",n=r?r[2]:a,l=1;for(;l<t.length&&""===t[l].trim();)l++;let o=t.length;for(let e=l,a=/^(BREAKING CHANGE|[A-Za-z-]+(?:\([A-Za-z-]+\))?:)/,r=t.length;e<r;e++)if(a.test(t[e])){o=e;break}return{header:a,type:s,subject:n,body:t.slice(l,o).join("\n"),footer:t.slice(o).join("\n"),raw:e,lines:t}}(e),r={valid:!0,errors:[],warnings:[]};return Object.entries(t).forEach(([e,t])=>{let[s,n,...m]=t;if(0===s)return;let p=!0,b="";switch(e){case"body-leading-blank":p=!a.body||a.lines.length>1&&""===a.lines[1].trim(),b="body must have leading blank line";break;case"body-max-line-length":{let e=m[0]||100;p=a.body.split("\n").every(t=>t.length<=e),b=`body's lines must not be longer than ${e} characters`;break}case"footer-leading-blank":p=!a.footer||""===a.lines[a.lines.length-a.footer.split("\n").length-1].trim(),b="footer must have leading blank line";break;case"footer-max-line-length":{let e=m[0]||100;p=a.footer.split("\n").every(t=>t.length<=e),b=`footer's lines must not be longer than ${e} characters`;break}case"header-max-length":{let e=m[0]||100;p=a.header.length<=e,b=`header must not be longer than ${e} characters`;break}case"header-trim":p=a.header.trim()===a.header,b="header must not have leading or trailing whitespace";break;case"subject-case":{let e=m[0]||[],t=a.subject.trim(),r={"sentence-case":l,"start-case":o,"pascal-case":i,"upper-case":c};p=!e.some(e=>r[e]&&r[e](t)),b=`subject must not be in ${e.join(", ")}`;break}case"subject-empty":p=""!==a.subject.trim(),b="subject cannot be empty";break;case"subject-full-stop":{let e=m[0]||".";p=!a.subject.trim().endsWith(e),b=`subject must not end with ${e}`;break}case"type-case":"lower-case"==("always"===n?"lower-case":"upper-case")?(p=a.type===a.type.toLowerCase(),b="type must be lower-case"):(p=a.type===a.type.toUpperCase(),b="type must be upper-case");break;case"type-empty":p=""!==a.type,b="type cannot be empty";break;case"type-enum":{let e=m[0]||[];p=e.includes(a.type.toLowerCase()),b=`type must be one of [${e.join(", ")}]`}}if("never"===n&&(p=!0),!p){let t={level:s,message:b,name:e};2===s?(r.errors.push(t),r.valid=!1):1===s&&r.warnings.push(t)}}),r}(p,{"body-leading-blank":[1,"always"],"body-max-line-length":[2,"always",200],"footer-leading-blank":[1,"always"],"footer-max-line-length":[2,"always",100],"header-max-length":[2,"always",100],"header-trim":[2,"always"],"subject-case":[2,"never",["sentence-case","start-case","pascal-case","upper-case"]],"subject-empty":[2,"never"],"subject-full-stop":[2,"never","."],"type-case":[2,"always","lower-case"],"type-empty":[2,"never"],"type-enum":[2,"always",["build","chore","ci","docs","feat","fix","perf","refactor","revert","style","test"]]});(function(e){let t=[" ","⚠","✖"],a={green:"\x1b[32m",yellow:"\x1b[33m",red:"\x1b[31m",gray:"\x1b[90m",reset:"\x1b[0m",bold:"\x1b[1m"},{errors:r=[],warnings:s=[]}=e,n=[...r,...s].map(e=>{let r=a[2===e.level?"red":"yellow"]+t[e.level]+a.reset;return`${r} ${e.message} ${a.gray}[${e.name}]${a.reset}`}),l=r.length>0?"✖":s.length?"⚠":"✔",o=r.length>0?a.red:s.length?a.yellow:a.green,i=n.length>0;return[...n,i?"":null,`${o}${l}${a.reset} ${a.gray}${a.bold}found ${r.length} problems, ${s.length} warnings${a.reset}`,i?"":null].filter(e=>null!==e)})(b).forEach(e=>{r(e)}),process.exit(+!b.valid);
|
package/lib/bin/file.d.mts
CHANGED
package/lib/bin/index.d.mts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { ink, println } from '@moneko/utils';
|
|
4
|
-
import require from '../commom/require.mjs';
|
|
5
|
-
import sigintExit from '../commom/sigint-exit.mjs';
|
|
6
|
-
import { corePkg } from './utils/config.mjs';
|
|
2
|
+
export { };
|
package/lib/bin/pin.d.mts
CHANGED
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import paths from '../commom/paths.mjs';
|
|
6
|
-
import require from '../commom/require.mjs';
|
|
7
|
-
declare const packageJsonPath: string;
|
|
8
|
-
declare function getPackageJson(): typeof import('package.json');
|
|
9
|
-
type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'deno' | 'npm';
|
|
10
|
-
declare function getPackageManager(packageManager?: string): PackageManager;
|
|
11
|
-
type V = 'major' | 'minor' | 'patch' | 'equal';
|
|
12
|
-
declare function versionCompare(v1: string, v2: string): V;
|
|
13
|
-
declare async function getVersion(name: string);
|
|
14
|
-
declare async function checkDependencies(dependencies: Record<string, string>, progress: {
|
|
15
|
-
done: string[];
|
|
16
|
-
total: number;
|
|
17
|
-
});
|
|
18
|
-
interface DiffVersion {
|
|
19
|
-
name: string;
|
|
20
|
-
wanted: string;
|
|
21
|
-
latest: string;
|
|
22
|
-
color: string;
|
|
23
|
-
err?: string;
|
|
24
|
-
}
|
|
25
|
-
declare const levels: {
|
|
26
|
-
readonly major: string;
|
|
27
|
-
readonly minor: string;
|
|
28
|
-
readonly patch: string;
|
|
29
|
-
readonly equal: string;
|
|
30
|
-
};
|
|
31
|
-
declare function diff(prev: Record<string, string>, next: Record<string, string>): DiffVersion[];
|
|
32
|
-
declare async function checkUpdates(packageJson: typeof import('package.json'), key: 'peerDependencies' | 'optionalDependencies' | 'devDependencies' | 'dependencies', result: Record<string, DiffVersion[]>, progress: {
|
|
33
|
-
done: string[];
|
|
34
|
-
total: number;
|
|
35
|
-
});
|
|
36
|
-
declare function getMaxLength(pkgs: string[], result: Record<string, DiffVersion[]>, key: keyof DiffVersion);
|
|
37
|
-
declare function extractVersion(version: string): [optical: string, version: string];
|
|
38
|
-
declare async function pin(): Promise<void>;
|
|
1
|
+
/**
|
|
2
|
+
* 检测过时依赖
|
|
3
|
+
* @returns {Promise<void>} 返回码 1 失败,0 成功
|
|
4
|
+
*/ declare function pin(): Promise<void>;
|
|
39
5
|
export default pin;
|
package/lib/bin/pure-lint.d.mts
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { argv, cwd as _cwd, exit, stdout } from 'node:process';
|
|
5
|
-
import { ESLint } from '@moneko/eslint';
|
|
6
|
-
import { LinterResult, stylelint as Stylelint } from '@moneko/stylelint';
|
|
7
|
-
import { ink, loadFile, println } from '@moneko/utils';
|
|
8
|
-
import log from '../commom/log.mjs';
|
|
9
|
-
import parseArgs from '../commom/parse-args.mjs';
|
|
10
|
-
import timer from '../commom/timer.mjs';
|
|
11
|
-
type Args = {
|
|
12
|
-
fix?: boolean;
|
|
13
|
-
cache?: boolean;
|
|
14
|
-
mode?: 'ci' | 'commit';
|
|
15
|
-
};
|
|
16
|
-
declare const args: Args;
|
|
17
|
-
declare const fix: boolean | undefined;
|
|
18
|
-
declare const cache: boolean;
|
|
19
|
-
declare const cwd: string;
|
|
20
|
-
declare const cachePath: string;
|
|
21
|
-
declare const cmd: {
|
|
22
|
-
readonly ci: readonly ['diff', '--name-only', 'HEAD^', 'HEAD'];
|
|
23
|
-
readonly commit: readonly ['diff', '--cached', '--name-only', '--diff-filter=ACM'];
|
|
24
|
-
};
|
|
25
|
-
declare const scriptRegExp: RegExp;
|
|
26
|
-
declare const vueRegExp: RegExp;
|
|
27
|
-
declare const styleRegExp: RegExp;
|
|
28
|
-
declare const child: SpawnSyncReturns<Buffer>;
|
|
29
|
-
declare const lintFiles: string[];
|
|
30
|
-
declare async function eslint();
|
|
31
|
-
declare const styleFiles: string[];
|
|
32
|
-
declare async function stylelint();
|
|
2
|
+
export { };
|
package/lib/bin/pure-lint.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as
|
|
2
|
+
import{spawnSync as t}from"node:child_process";import{join as e}from"node:path";import{argv as o,cwd as i,exit as r,stdout as n}from"node:process";import{ESLint as l}from"@moneko/eslint";import{stylelint as a}from"@moneko/stylelint";import{ink as m,loadFile as c,println as s}from"@moneko/utils";import d from"../commom/log.mjs";import f from"../commom/parse-args.mjs";import p from"../commom/timer.mjs";let y=f(o.slice(2)),h=y.fix,u=y.cache||!0,w=e(i(),"node_modules/.cache"),g={ci:["diff","--name-only","HEAD^","HEAD"],commit:["diff","--cached","--name-only","--diff-filter=ACM"]},S=/.*(?<!\.d)\.(j|t|mj|mt|cj|ct)sx?$/,$=/.*(?<!\.d)\.vue$/,E=/.*(?<!\.d)\.(c|sc|sa|le)ss$/,j=t("git",g[y.mode||"ci"]||g.ci).stdout.toString().trim().split("\n");async function L(){let t=m("ESLint","cyan");s(`${t}: ${m("runing...","yellow")}`,!0);try{p.start("ESLint");let t=j.filter(t=>S.test(t)||$.test(t));if(0===t.length)return void p.end("ESLint");let e=new l({cache:u,cacheLocation:`${w}/.eslintcache`,fix:h}),o=await e.lintFiles(t),i=await e.loadFormatter("stylish"),a=await i.format(o);h&&await l.outputFixes(o),a&&n.write(a);let m=o.some(t=>t.errorCount>0);p.end("ESLint"),m&&r(1)}catch(t){d(t)}}let v=j.filter(t=>E.test(t)||$.test(t));async function k(){let t=m("Stylelint","cyan");if(s(`${t}: ${m("runing...","yellow")}`,!0),p.start("Stylelint"),0===v.length)return void p.end("Stylelint");let e=await Promise.all(v.map(async t=>{let e=await c(t);return await a.lint({codeFilename:t,code:e,cache:u,cacheLocation:`${w}/.stylelintcache`,fix:h,formatter:"string"}).catch(d)})),o=!1;e.forEach(t=>{t&&(t.report&&n.write(t.report),t.errored&&(o=!!t.errored))}),p.end("Stylelint"),o&&r(1)}await Promise.all([L(),k()]);
|
package/lib/bin/setup.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { copyFile, ink, loadFileSync, println, scanFolderSync, updateFile } from '@moneko/utils';
|
|
3
|
-
import { transformSolidJs, TransformSolidJsOption } from '../../commom/transform-solid-js.mjs';
|
|
4
|
-
declare function getOutfilePath(outDir: string, file: string, outFileExtension?: string);
|
|
1
|
+
import { TransformSolidJsOption } from '../../commom/transform-solid-js.mjs';
|
|
5
2
|
interface ConvertOptions {
|
|
6
3
|
outDir: string;
|
|
7
4
|
inputDir: string;
|
|
@@ -18,8 +15,7 @@ interface ConvertResult {
|
|
|
18
15
|
copied: string[];
|
|
19
16
|
failed: string[];
|
|
20
17
|
}
|
|
21
|
-
declare
|
|
22
|
-
export declare async function convertSolid({ ignore = [], quiet = true, copy = true, outDir, outputExtension, inputDir, options, extensions = [
|
|
18
|
+
export declare function convertSolid({ ignore = [], quiet = true, copy = true, outDir, outputExtension, inputDir, options, extensions = [
|
|
23
19
|
'.ts',
|
|
24
20
|
'.js',
|
|
25
21
|
'.tsx',
|
|
@@ -29,3 +25,4 @@ export declare async function convertSolid({ ignore = [], quiet = true, copy = t
|
|
|
29
25
|
'.cts',
|
|
30
26
|
'.cjs'
|
|
31
27
|
] }: ConvertOptions): Promise<ConvertResult>;
|
|
28
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:path";import{copyFile as t,ink as o,loadFileSync as s,println as i,scanFolderSync as a,updateFile as
|
|
1
|
+
import e from"node:path";import{copyFile as t,ink as o,loadFileSync as s,println as i,scanFolderSync as a,updateFile as r}from"@moneko/utils";import{transformSolidJs as m}from"../../commom/transform-solid-js.mjs";function n(t,o,s){let i=o.split(e.sep),a=""===i[0]?i[1]:i[0],r=o.replace(a,""),m=e.join(t,r);return s?m.replace(e.extname(m),s):m}let p={".ts":".js",".tsx":".js",".mts":".mjs",".cts":".cjs",".js":".js",".jsx":".js",".mjs":".mjs",".cjs":".cjs"};export async function convertSolid({ignore:l=[],quiet:c=!0,copy:d=!0,outDir:j,outputExtension:f,inputDir:h,options:u,extensions:$=[".ts",".js",".tsx",".jsx",".mts",".mjs",".cts",".cjs"]}){let g=process.hrtime(),x={duration:0,compiled:[],copied:[],failed:[]},y=a(h,["^.*"]).map(t=>e.normalize(t)),S=[],w=[];y.forEach(t=>{!(/\.DS_Store/.test(t)||l.some(e=>e.test(t)))&&($.includes(e.extname(t))?S.push(t):d&&w.push(t))});let E=S.map(async t=>{try{let o=f||p[e.extname(t)],i=await m(s(t)||"",{...u,filename:t,minified:!0,compact:!0}),a=n(j,t,o);await r(a,i?.code??""),i?.map&&await r(`${a}.map`,"string"==typeof i.map?i.map:JSON.stringify(i.map)),x.compiled.push(`${t} -> ${a}`)}catch(e){x.failed.push(`Error converting ${t}: ${e}`)}}).concat(w.map(async e=>{let o=n(j,e);await t(e,o)?x.copied.push(`${e} -> ${o}`):x.failed.push(`Error copying ${e} -> ${o}`)}));await Promise.all(E);let v=process.hrtime(g);if(x.duration=1e3*v[0]+v[1]/1e6,c){let e=u.presetEnvOption?.modules,t=!1===e?"ESM":e?.toString().toLocaleUpperCase();i([`${o("✨ 编译成功!🎉","82",{bold:!0})} ${o(`(${t})`,"213")}`,o(`⏱️ 总耗时:${x.duration.toFixed(3)} ms`,"117"),x.compiled.length&&o(`📄 编译文件:${x.compiled.length} 个`,"111"),x.copied.length&&o(`📋 复制文件:${x.copied.length} 个`,"226"),x.failed.length&&o(`❌ 编译失败:${x.failed.length} 个`,"203")].filter(Boolean).join("\n- "))}return x}
|
package/lib/build/common.d.mts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import webpack, { type Configuration } from 'webpack';
|
|
3
|
-
import { merge } from 'webpack-merge';
|
|
4
|
-
import { commonConfig } from '../common.mjs';
|
|
5
|
-
import { CONFIG } from '../config.mjs';
|
|
6
|
-
import { LightningCssMinifyPlugin } from '../plugin/lightningcss-plugin.mjs';
|
|
7
|
-
import { SwcMinifyPlugin } from '../plugin/swc-minify-plugin.mjs';
|
|
8
|
-
import { getLightningCssTargets } from '../polyfills/targets.mjs';
|
|
9
|
-
declare const minimizer: readonly [];
|
|
10
|
-
declare const defaultPerformance: Configuration['performance'];
|
|
1
|
+
import { type Configuration } from 'webpack';
|
|
11
2
|
declare const buildCommon: Configuration;
|
|
12
3
|
export default buildCommon;
|
package/lib/build/server.d.mts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { env } from 'node:process';
|
|
2
1
|
import { type Configuration } from 'webpack';
|
|
3
|
-
import { CUSTOMCONFIG } from '../commom/paths.mjs';
|
|
4
|
-
import moduleConfig from '../module.config.mjs';
|
|
5
|
-
import { isLibrary } from '../process-env.mjs';
|
|
6
|
-
import { resolveProgram } from '../utils/index.mjs';
|
|
7
2
|
declare const serverOption: Configuration;
|
|
8
3
|
export default serverOption;
|
package/lib/build.d.mts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import { analyzeBundleSize, completedInfo, ink, println, progressBar } from '@moneko/utils';
|
|
4
|
-
import webpack, { type Compiler, type Configuration, type Stats } from 'webpack';
|
|
5
|
-
import { merge } from 'webpack-merge';
|
|
6
|
-
import buildCommon from './build/common.mjs';
|
|
7
|
-
import paths from './commom/paths.mjs';
|
|
8
|
-
import { DonePlugin } from './plugin/done.mjs';
|
|
9
|
-
import { empty } from './utils/index.mjs';
|
|
10
|
-
import seo from './utils/seo.mjs';
|
|
11
|
-
import { CONFIG } from './config.mjs';
|
|
12
|
-
import moduleConfig from './module.config.mjs';
|
|
13
|
-
declare const clientOption: Configuration;
|
|
14
|
-
declare const instance: Compiler;
|
|
15
|
-
declare function printCompilationMessages(stats: Stats);
|
|
16
|
-
declare async function build();
|
|
1
|
+
export { };
|
package/lib/commom/ca.d.mts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { type ChildProcess
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import paths from './paths.mjs';
|
|
9
|
-
type ExecPromise = (command: string) => PromiseWithChild<{
|
|
10
|
-
stdout: string;
|
|
11
|
-
stderr: string;
|
|
12
|
-
}>;
|
|
13
|
-
declare const execPromise: ExecPromise;
|
|
14
|
-
declare async function isCertificateInstalled(organization: string): Promise<boolean>;
|
|
15
|
-
declare function installCallback(error: ExecException | null, _stdout: string, stderr: string): void;
|
|
16
|
-
export declare function installCA(certPath: string): ChildProcess | void;
|
|
17
|
-
export declare async function setupCert(domain?: string, install?: boolean): Promise<CertificateResult>;
|
|
1
|
+
import { type ChildProcess } from 'node:child_process';
|
|
2
|
+
import { type CertificateResult } from '@moneko/utils';
|
|
3
|
+
/**
|
|
4
|
+
* 安装本地根 CA 到用户证书存储区(开发时信任 HTTPS 证书)
|
|
5
|
+
* @param certPath 本地 CA 证书路径
|
|
6
|
+
*/ export declare function installCA(certPath: string): ChildProcess | void;
|
|
7
|
+
export declare function setupCert(domain?: string, install?: boolean): Promise<CertificateResult>;
|
package/lib/commom/ca.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exec as t}from"node:child_process";import{join as e,relative as r}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";import{fileExists as a,generateCert as n,loadFile as l,normalCertificateAuthority as c,println as s,saveFile as m}from"@moneko/utils";import u from"./log.mjs";import{getIPv4 as f}from"./net.mjs";import p from"./paths.mjs";let d=i(t);async function y(t){try{if("darwin"===o){let{stdout:e}=await d(`security find-certificate -c "${t}" -a`);return e.length>0}if("win32"===o){let{stdout:e}=await d(`certutil -store -user Root | findstr /C:"${t}"`);return e.length>0}}catch(t){u(t)}return!1}function h(t,e,r){if(t&&!r.includes("already exists"))
|
|
1
|
+
import{exec as t}from"node:child_process";import{join as e,relative as r}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";import{fileExists as a,generateCert as n,loadFile as l,normalCertificateAuthority as c,println as s,saveFile as m}from"@moneko/utils";import u from"./log.mjs";import{getIPv4 as f}from"./net.mjs";import p from"./paths.mjs";let d=i(t);async function y(t){try{if("darwin"===o){let{stdout:e}=await d(`security find-certificate -c "${t}" -a`);return e.length>0}if("win32"===o){let{stdout:e}=await d(`certutil -store -user Root | findstr /C:"${t}"`);return e.length>0}}catch(t){u(t)}return!1}function h(t,e,r){if(t&&!r.includes("already exists"))return void u(t)}export function installCA(e){return"darwin"===o?t(`sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "${e}"`,h):"win32"===o?t(`certutil -addstore -user "Root" "${e}"`,h):void s(`⚠️ 暂不支持自动安装 CA 的平台: ${o}`)}export async function setupCert(t="localhost",o=!0){let i=r(p.programPath,`${p.corePath}/cert/cert.pem`),s=r(p.programPath,`${p.corePath}/cert/key.pem`),u=!a(i)||!a(s);if(u){let t=c();await Promise.all([m(i,t.cert),m(s,t.key)])}o&&(!await y("Local Root Certificate Authority - Moneko")||u)&&installCA(i);let d=e(p.CA_DIR,`${t}_cert.pem`),h=e(p.CA_DIR,`${t}_key.pem`);if(u||!a(d)||!a(h)){let e=await Promise.all([l(i),l(s)]),r=n(e[0],e[1],[...new Set([t,"localhost","127.0.0.1",f()].filter(Boolean))]);await Promise.all([m(d,r.cert),m(h,r.key)])}let w=await Promise.all([l(d),l(h)]);return{cert:w[0],key:w[1]}}
|
package/lib/commom/esm.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]);
|
|
1
|
+
declare function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
|
|
2
2
|
export default esm;
|
package/lib/commom/has-pkg.d.mts
CHANGED
package/lib/commom/log.d.mts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { appendToFileSync } from '@moneko/utils';
|
|
3
|
-
declare const startDate: Date;
|
|
4
|
-
declare const startHrTime: [number, number];
|
|
5
|
-
declare function getCurrentTime(): string;
|
|
6
|
-
declare async function log(message: Error | string | unknown): Promise<void>;
|
|
1
|
+
declare function log(message: Error | string | unknown): Promise<void>;
|
|
7
2
|
export default log;
|
|
@@ -2,5 +2,20 @@ type MatchPath = {
|
|
|
2
2
|
path: string;
|
|
3
3
|
params: Record<string, unknown>;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* RESTful 风格api
|
|
7
|
+
* @param {String} pattern pattern
|
|
8
|
+
* @param {String} path paths
|
|
9
|
+
* @example
|
|
10
|
+
* const pattern = '/users/:id';
|
|
11
|
+
* const pathToMatch = '/users/123';
|
|
12
|
+
* const result = matchPath(pattern, pathToMatch);
|
|
13
|
+
* if (result) {
|
|
14
|
+
* console.log('Match found:', result);
|
|
15
|
+
* console.log('Params:', result.params);
|
|
16
|
+
* } else {
|
|
17
|
+
* console.log('No match found.');
|
|
18
|
+
* }
|
|
19
|
+
* @returns {MatchPath|null} MatchPath
|
|
20
|
+
*/ declare function matchPath(pattern: string, path: string): MatchPath | null;
|
|
6
21
|
export default matchPath;
|
package/lib/commom/require.d.mts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { type Options, transformFileSync } from '@swc/core';
|
|
3
1
|
declare const require: NodeJS.Require;
|
|
4
|
-
declare const transformOptions: Options;
|
|
5
|
-
declare function requireEsm(module: NodeJS.Module & {
|
|
6
|
-
_compile?: (code: string, filename: string) => void;
|
|
7
|
-
}, filename: string);
|
|
8
2
|
export default require;
|
package/lib/commom/timer.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { hrtime } from 'node:process';
|
|
2
|
-
import { ink, println } from '@moneko/utils';
|
|
3
1
|
interface Timer {
|
|
4
2
|
start(label: string): void;
|
|
5
3
|
end(label: string): {
|
|
@@ -7,6 +5,7 @@ interface Timer {
|
|
|
7
5
|
milliseconds: number;
|
|
8
6
|
};
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 最高精度的计时方法,返回纳秒级精度的bigint
|
|
10
|
+
*/ declare const timer: Timer;
|
|
12
11
|
export default timer;
|
package/lib/common.d.mts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Configuration, FileCacheOptions } from 'webpack';
|
|
3
|
-
import paths, { config_files, CUSTOMCONFIG, TMP_DIR } from './commom/paths.mjs';
|
|
4
|
-
import { type OverrideResolverOption, OverrideResolverPlugin } from './plugin/override-resolve.mjs';
|
|
5
|
-
import { isObject, node_modules, resolveProgram } from './utils/index.mjs';
|
|
6
|
-
import { exampleModuleName } from './vm/example.mjs';
|
|
7
|
-
import app from './vm/info.mjs';
|
|
8
|
-
import { CONFIG } from './config.mjs';
|
|
9
|
-
import plugins from './plugins.config.mjs';
|
|
10
|
-
import { isCI, isDev, isLibrary, NODE_ENV, packageJson } from './process-env.mjs';
|
|
1
|
+
import type { Configuration } from 'webpack';
|
|
11
2
|
export declare const outputConfig: Configuration['output'];
|
|
12
|
-
declare let entryMap: {
|
|
13
|
-
readonly main: string[];
|
|
14
|
-
};
|
|
15
|
-
declare let cacheConfig: FileCacheOptions | false;
|
|
16
3
|
export declare const commonConfig: Configuration;
|
package/lib/config.d.mts
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import { join, relative } from 'node:path';
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import { fileExists } from '@moneko/utils';
|
|
4
|
-
import { merge } from 'webpack-merge';
|
|
5
|
-
import paths from './commom/paths.mjs';
|
|
6
|
-
import require from './commom/require.mjs';
|
|
7
|
-
import setupEnv from './commom/setup-env.mjs';
|
|
8
|
-
import jsxDomExpressions from './options/jsx-dom-expressions.mjs';
|
|
9
|
-
import splitChunk from './options/split-chunk.mjs';
|
|
10
|
-
import { isFunction, node_modules, resolveProgram } from './utils/index.mjs';
|
|
11
1
|
import type { ConfigType } from './index.mjs';
|
|
12
|
-
import { APPTYPE, FRAMEWORK, frameworkVersion, isCI, isDev, isLibrary, isMobile, isReact, jsxImportSource, mainDirectory, NODE_ENV, PACKAGENAME } from './process-env.mjs';
|
|
13
|
-
declare const includeModule: readonly [string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string];
|
|
14
2
|
export declare function getConfig(path: string): Promise<ConfigType>;
|
|
15
|
-
type EnvType = {
|
|
16
|
-
NODE_ENV: string;
|
|
17
|
-
APPTYPE: string;
|
|
18
|
-
FRAMEWORK: string;
|
|
19
|
-
PROJECTNAME?: string;
|
|
20
|
-
};
|
|
21
|
-
declare const resp: [EnvType, ConfigType, ConfigType];
|
|
22
|
-
declare const env: EnvType;
|
|
23
|
-
declare const normalConf: ConfigType;
|
|
24
|
-
declare const envConf: ConfigType;
|
|
25
|
-
declare const defaultConfig: ConfigType;
|
|
26
|
-
declare let customConf: ConfigType;
|
|
27
3
|
export declare const CONFIG: ConfigType;
|
|
28
4
|
export declare const PUBLICPATH: string;
|
|
@@ -2,5 +2,5 @@ export type CompliationProcess = {
|
|
|
2
2
|
percentage: number;
|
|
3
3
|
info: string;
|
|
4
4
|
};
|
|
5
|
-
declare function generateProgressHtml(progressApi: string, progress: CompliationProcess);
|
|
5
|
+
declare function generateProgressHtml(progressApi: string, progress: CompliationProcess): string;
|
|
6
6
|
export default generateProgressHtml;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1
2
|
type Any = any;
|
|
2
3
|
type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
|
|
3
4
|
type ArraySchemaObjectType = 'array';
|
|
@@ -66,7 +67,6 @@ interface XMLObject {
|
|
|
66
67
|
interface ReferenceObject {
|
|
67
68
|
$ref: string;
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
declare function clamp(value: number, min: number, max: number): number;
|
|
71
|
-
declare function take<T>(array: T[], n?: number): T[];
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
71
|
export declare function jsonSchema<T>(schema: SchemaObject): any;
|
|
72
|
+
export { };
|
package/lib/dev/proxy.d.mts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { IncomingMessage,
|
|
2
|
-
import { request as httpsRequest } from 'node:https';
|
|
3
|
-
import { URL } from 'node:url';
|
|
4
|
-
import log from '../commom/log.mjs';
|
|
5
|
-
import { containMockUrl } from './mock.mjs';
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
2
|
type ProxyItem = {
|
|
7
3
|
target: string;
|
|
8
4
|
changeOrigin?: boolean;
|
|
@@ -15,5 +11,5 @@ export type ProxyConfig = Record<string, string | ProxyItem>;
|
|
|
15
11
|
type IServerResponse = ServerResponse<IncomingMessage> & {
|
|
16
12
|
req: IncomingMessage;
|
|
17
13
|
};
|
|
18
|
-
declare function
|
|
19
|
-
export
|
|
14
|
+
export declare function setupProxy(req: IncomingMessage, res: IServerResponse, proxyConfig: ProxyConfig): Promise<IServerResponse | false>;
|
|
15
|
+
export { };
|
package/lib/dev.d.mts
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { watchFile } from 'node:fs';
|
|
3
|
-
import { join, relative } from 'node:path';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import { URL } from 'node:url';
|
|
6
|
-
import { ink, print, println, progressBar } from '@moneko/utils';
|
|
7
|
-
import webpack, { type Compiler, type OutputFileSystem, type Watching, type WebpackPluginInstance } from 'webpack';
|
|
8
|
-
import hotMiddleware, { type ClientOptions } from 'webpack-hot-middleware';
|
|
9
|
-
import { merge } from 'webpack-merge';
|
|
10
|
-
import { diffObject } from './commom/diff-object.mjs';
|
|
11
|
-
import paths, { config_files } from './commom/paths.mjs';
|
|
12
|
-
import sigintExit from './commom/sigint-exit.mjs';
|
|
13
|
-
import { devLog, getServerAddress, PORT } from './dev/config.mjs';
|
|
14
|
-
import generateProgressHtml, { type CompliationProcess } from './dev/generate-progress-html.mjs';
|
|
15
|
-
import server, { type FileSystem, type Server } from './dev/server.mjs';
|
|
16
|
-
import reslove from './options/reslove.mjs';
|
|
17
|
-
import { ESLintPlugin } from './plugin/eslint.mjs';
|
|
18
|
-
import { generateManifest } from './plugin/manifest.mjs';
|
|
19
|
-
import { StylelintPlugin } from './plugin/stylelint.mjs';
|
|
20
|
-
import { empty } from './utils/index.mjs';
|
|
21
|
-
import { commonConfig } from './common.mjs';
|
|
22
|
-
import { CONFIG, getConfig } from './config.mjs';
|
|
23
|
-
import { outputFileSystem } from './file-system.mjs';
|
|
24
|
-
import type { ConfigType } from './index.mjs';
|
|
25
|
-
import moduleConfig from './module.config.mjs';
|
|
26
|
-
import { isLibrary, isReact, refresh } from './process-env.mjs';
|
|
27
|
-
type WebpackPlugin = new(opt?: object) => WebpackPluginInstance;
|
|
28
|
-
declare let isInitialBuildDone: boolean;
|
|
29
|
-
declare const progressApi: string;
|
|
30
|
-
declare const compilationProgress: CompliationProcess;
|
|
31
|
-
declare const hmrPath: string;
|
|
32
|
-
declare const clientParams: ClientOptions;
|
|
33
|
-
declare const hotParams: string;
|
|
34
|
-
declare const clientOption: webpack.Configuration;
|
|
35
|
-
declare function getLintFiles(exts: string[]);
|
|
36
|
-
declare const compiler: Compiler | null;
|
|
37
|
-
declare const watching: Watching;
|
|
38
|
-
declare const hotUrl: string;
|
|
39
|
-
declare const hot: ReturnType<typeof hotMiddleware>;
|
|
40
|
-
declare const manifestUrl: string | false;
|
|
41
|
-
declare const app: Server;
|
|
42
|
-
declare function exit();
|
|
43
|
-
declare const _prev: ConfigType[];
|
|
44
|
-
declare let prev: ConfigType;
|
|
45
|
-
declare function watchConfig(filepath: string);
|
|
46
|
-
declare function restart();
|
|
47
|
-
declare const isWindow: boolean;
|
|
48
|
-
declare function killPort(port: number);
|
|
1
|
+
export { };
|
package/lib/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as n}from"node:path";import i from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,getServerAddress as j,PORT as $}from"./dev/config.mjs";import
|
|
2
|
-
`):(p(e||0,1,{msg:r,name:t,barColor:n.barColor,nameColor:n.nameColor,barBgColor:n.barBgColor,msgColor:n.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});if(I){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function J(e){let t=e.join(","),o=[n(d.programPath,`${H.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return E&&o.push(n(d.programPath,`${H.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}H.eslint&&U.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:J(["js","jsx","ts","tsx","json","html","vue"]),...H.eslint})),H.stylelint&&U.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:J(["css","scss","sass","less","ts","tsx","js","jsx"]),...H.stylelint}));let M=c(U);if(!M)throw Error("无法创建编译器");M.outputFileSystem=T;let A=M.watch(M.options.watchOptions,y);M.hooks.done.tap("client-log",e=>{y(null,e)});let K=`${H.basename}/${N}`.replace(/\/+/g,"/"),W=f(M,{log:!1,path:K,heartbeat:2e3}),z=!!H.manifest&&r(H.basename,H.manifest.filename).replaceAll(/\\/g,"/"),D=await
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as n}from"node:path";import i from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,getServerAddress as j,PORT as $}from"./dev/config.mjs";import v from"./dev/generate-progress-html.mjs";import b from"./dev/server.mjs";import C from"./options/reslove.mjs";import{ESLintPlugin as x}from"./plugin/eslint.mjs";import{generateManifest as P}from"./plugin/manifest.mjs";import{StylelintPlugin as _}from"./plugin/stylelint.mjs";import{empty as S}from"./utils/index.mjs";import{commonConfig as k}from"./common.mjs";import{CONFIG as H,getConfig as O}from"./config.mjs";import{outputFileSystem as T}from"./file-system.mjs";import B from"./module.config.mjs";import{isLibrary as E,isReact as I,refresh as q}from"./process-env.mjs";let F=!1,G="/____progress____",L={percentage:0,info:""},N="/__hmr__",R=new URLSearchParams({name:"client",path:N.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!q,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=h(k,{output:{publicPath:H.moduleFederation?.length>0?`${j("local")}/`:"/"},watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${C.hotMiddlewareClient}?${R}`]},module:B(!1),plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";F||(L.info=r,L.percentage=e,F=1===e);let n=H.bar;if(n){let t=n.name||"Build";n.quiet?i.stdout.write(`${r}
|
|
2
|
+
`):(p(e||0,1,{msg:r,name:t,barColor:n.barColor,nameColor:n.nameColor,barBgColor:n.barBgColor,msgColor:n.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});if(I){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function J(e){let t=e.join(","),o=[n(d.programPath,`${H.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return E&&o.push(n(d.programPath,`${H.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}H.eslint&&U.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:J(["js","jsx","ts","tsx","json","html","vue"]),...H.eslint})),H.stylelint&&U.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:J(["css","scss","sass","less","ts","tsx","js","jsx"]),...H.stylelint}));let M=c(U);if(!M)throw Error("无法创建编译器");M.outputFileSystem=T;let A=M.watch(M.options.watchOptions,y);M.hooks.done.tap("client-log",e=>{y(null,e)});let K=`${H.basename}/${N}`.replace(/\/+/g,"/"),W=f(M,{log:!1,path:K,heartbeat:2e3}),z=!!H.manifest&&r(H.basename,H.manifest.filename).replaceAll(/\\/g,"/"),D=await b({port:$,root_dir:M.options.output.path,fileSystem:M.outputFileSystem,headers:H.devServer.headers,https:H.devServer.https,host:H.devServer.host,open:H.devServer.open,basename:H.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${H.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(z&&o.pathname===z)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(P({}))),!0;if(o.pathname===G)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(L)),!0;if(!F)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(v(G,L)),!0;if(o.pathname===K&&"text/event-stream"===e.headers.accept)return W(e,t,S),!0}return!1}}});function Q(){i.exit(0)}D.on("close",()=>{A.close(S),W.close()});let V=await Promise.all(g.map(O)),X=h(V[0]||{},V[1]||{});g.forEach(function(t){o(t,async function(){var o;let[r,n]=await Promise.all(g.map(O)),s=h(r||{},n||{}),p=u(X,s);1===Object.keys(p).length&&"proxy"in p?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),H.proxy=s.proxy,X.proxy=s.proxy,X=s):(X=s,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(Y?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){l(a(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),n=Y?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!n)return void l(a(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(n),"SIGHUP")}catch(e){l(a(`终止进程 ${n} 时发生错误: ${e.message}`,"red"))}}))})});let Y="win32"===i.platform;i.on("SIGHUP",function(){D.close(S);let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",Q)}),i.on("exit",function(){D.close(S)}),w(Q);
|
package/lib/file-system.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type IFs } from 'memfs';
|
|
2
2
|
export declare const outputFileSystem: IFs;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable no-param-reassign */ /*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/ // css base code, injected by the css-loader
|
|
5
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";module.exports=function(e,a){
|
|
1
|
+
"use strict";module.exports=function(e,a){if(a||(a={}),"string"!=typeof(e=e&&e.__esModule?e.default:e))return"Buffer"===e.type&&e.data?`data:${function(e){let a=(function(e,a=0){return e.slice(a,16).map(e=>e.toString(16).padStart(2,"0")).join("")})(e,0).toLowerCase();for(let[e,f]of Object.entries({"0001000000":"font/ttf","4f54544f":"font/otf","774f4646":"font/woff","774f4632":"font/woff2","89504e470d0a1a0a":"image/png",ffd8ffe0:"image/jpeg",ffd8ffdb:"image/jpeg",ffd8ffee:"image/jpeg",ffd8ffe000104a4649460001:"image/jpeg","ffd8ffe1????457869660000":"image/jpeg","0000000c4a584c200d0a870a":"image/jxl","474946383761":"image/gif","474946383961":"image/gif","49492a00":"image/tif","49492b00":"image/tif","4d4d002a":"image/tiff","4d4d002b":"image/tiff","52494646????????57454250":"image/webp","424d":"image/bmp","00000100":"image/x-icon","69636e73":"image/x-icns","6674797068656963":"image/heic","667479706d":"image/heic",ff4fff51:"image/jp2","0000000c6a5020200d0a870a":"image/jp2","667479704d534e56":"video/mp4","6674797069736f6d":"video/mp4","1a45dfa3":"video/webm","52494646????????41564920":"video/avi","000001ba":"video/mpeg","000001b3":"video/mpeg","464c56":"video/x-flv",494433:"audio/mpeg","4f676753":"audio/ogg","52494646????????57415645":"audio/wav","664c6143":"audio/flac","4d546864":"audio/midi","3026b2758e66cf11a6d900aa0062ce6c":"application/x-ms-asf"}))if(a.startsWith(e))return f;return"unknown"}(e.data)};base64,${btoa(Array.from(e.data,e=>String.fromCharCode(e)).join(""))}`:e;return(/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),a.hash&&(e+=a.hash),/["'() \t\n]/.test(e)||a.needQuotes)?'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):e};
|