@moneko/core 4.6.3 → 4.6.5
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/commom/git.d.mts +13 -0
- package/lib/commom/git.mjs +1 -0
- package/lib/common.mjs +1 -1
- package/lib/index.d.mts +1 -0
- package/lib/index.mjs +1 -1
- package/lib/plugin/html-plugin.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface GitInfo {
|
|
2
|
+
/** 当前分支名 */ branch: string;
|
|
3
|
+
/** 短 commit ID */ commitId: string;
|
|
4
|
+
/** 提交信息 */ message: string;
|
|
5
|
+
/** 提交用户名 */ author: string;
|
|
6
|
+
/** 提交用户邮箱 */ email: string;
|
|
7
|
+
/** 提交日期 */ date: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 获取 Git 信息
|
|
11
|
+
* @param cache 是否使用缓存,默认 true
|
|
12
|
+
* @returns Git 信息
|
|
13
|
+
*/ export declare const getGitInfo: (cache?: boolean) => GitInfo | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{execSync as r}from"node:child_process";let t=null;export const getGitInfo=e=>{let i=!1!==e;if(i&&null!==t)return t;let l=null;try{let t=r('git rev-parse --abbrev-ref HEAD && git log -1 --pretty=format:"%h%x00%B%x00%an%x00%ae%x00%ai"',{encoding:"utf-8",stdio:["pipe","pipe","ignore"],maxBuffer:1048576}).trim();if(t){let r=t.indexOf("\n");if(-1===r)throw l=null,Error("Git 信息格式不正确");{let e=t.substring(0,r).trim(),i=t.substring(r+1).split("\0");if(i.length<5)throw l=null,Error(`Git 提交信息格式不正确,字段数量: ${i.length}`);{let r=i[0].trim(),t=i[1],n=i[2].trim(),o=i[3].trim(),u=i[4].trim();if(e&&r)l={branch:e,commitId:r,message:t,author:n,email:o,date:u};else throw l=null,Error("Git 信息不完整")}}}else throw l=null,Error("无法获取 Git 信息")}catch(r){throw l=null,Error(`获取 Git 信息失败: ${r}`)}return i&&(t=l),l};
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extname as e,join as t,resolve as s}from"node:path";import o from"./commom/has-pkg.mjs";import a,{config_files as n,CUSTOMCONFIG as i}from"./commom/paths.mjs";import*as r from"./commom/rule.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,resolveProgram as c}from"./utils/index.mjs";import{CONFIG as p}from"./config.mjs";import u from"./plugins.config.mjs";import{app_schema as
|
|
1
|
+
import{extname as e,join as t,resolve as s}from"node:path";import o from"./commom/has-pkg.mjs";import a,{config_files as n,CUSTOMCONFIG as i}from"./commom/paths.mjs";import*as r from"./commom/rule.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,resolveProgram as c}from"./utils/index.mjs";import{CONFIG as p}from"./config.mjs";import u from"./plugins.config.mjs";import{app_schema as h,CACHE_NAME as d,isDev as f,isLibrary as g,packageJson as y,projectNameCamelCase as b}from"./process-env.mjs";export const outputConfig={path:c(g?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":e.chunk?.name==="main"?"js/[name].[contenthash].entry.js":"js/[name].[contenthash].js",chunkFilename:"js/[contenthash].js",cssFilename:"style/[contenthash].css",cssChunkFilename:"style/[contenthash].css",assetModuleFilename:t=>{let s=e(t.filename||"").substring(1);return`assets/${s}/[hash][ext]`},library:{name:`${b}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${y.name}`,pathinfo:f,clean:!0,publicPath:p.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${b}`};let j={main:[o(t(p.alias["@"],"service-worker")),`${h}:entry`].filter(Boolean)},v=[t(a.corePath,"./polyfills/public-path.mjs")];if(f&&p.refresh&&p.env.injectRemoteReactRefresh&&v.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),p.polyfill&&v.push(t(a.corePath,"./polyfills/replace-children.mjs")),p.entry&&("string"==typeof p.entry?j={...j,main:[p.entry]}:Object.keys(p.entry)&&(j=Object.assign(j,p.entry))),"string"==typeof j.main?j.main=[...v,j.main]:Array.isArray(j.main)&&(j.main=[...v,...j.main]),p.output){if("string"==typeof p.output)outputConfig.path=p.output;else if(Object.keys(p.output)){let e=p.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof p.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!0,name:d,version:`${y.version}`,buildDependencies:{config:n},maxMemoryGenerations:1};!1===p.cache?C=!1:m(p.cache)&&(C=Object.assign(C,p.cache));let P={},k={imports:!0,entries:!0,test:e=>{let s=e.nameForCondition();return!!(s&&(/^[a-z][a-z0-9]*:.+$/.test(s)||s?.startsWith(t(a.programPath,"src"))||s?.startsWith(t(a.programPath,"site"))||s?.startsWith(a.componentsPath)))}};p.lazyCompilation&&f&&"true"!==process.env.IS_BUILD?m(p.lazyCompilation)?Object.assign(P,k,p.lazyCompilation):Object.assign(P,k):P=!1;export const commonConfig={name:"client",target:"web",devtool:p.devtool,entry:j,mode:p.mode??"production",cache:C,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,r.node_modules],managedPaths:[a.pnpmNodeModules,a.denoNodeModules,r.node_modules],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0},contextModule:{timestamp:!0,hash:!0}},stats:"errors-only",infrastructureLogging:{level:"error"},externalsPresets:p.externalsPresets,plugins:u,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:P,buildHttp:m(p.buildHttp)?{allowedUris:[],lockfileLocation:s(a.httpCachePath,"http.lock"),cacheLocation:s(a.httpCachePath,"data"),upgrade:!0,...p.buildHttp}:p.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1,deferImport:!0},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:p.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:p.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:p.externals,output:outputConfig,recordsPath:p.recordsPath};p.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:p.alias["@"],override:i&&c(i)},p.overrideResolve)));
|
package/lib/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type * from '../typings/global.js';
|
|
2
2
|
export type { CommitRuleConfig, CommitRules } from './bin/commit-lint.mjs';
|
|
3
3
|
export type { cssInJsMinify, CssInJsMinifyOption } from './commom/css-in-js-minify.mjs';
|
|
4
|
+
export * from './commom/git.mjs';
|
|
4
5
|
export { default as hasPkg } from './commom/has-pkg.mjs';
|
|
5
6
|
export { getIPv4, getPort } from './commom/net.mjs';
|
|
6
7
|
export { default as open } from './commom/open.mjs';
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{default as open}from"./commom/open.mjs";export{default as parseArgs}from"./commom/parse-args.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as printLog}from"./commom/print-log.mjs";export{default as require}from"./commom/require.mjs";export*as Rule from"./commom/rule.mjs";export{default as timer}from"./commom/timer.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{HtmlPlugin}from"./plugin/html-plugin.mjs";export*from"./plugin/manifest/index.mjs";export{APPTYPE,coreName,FRAMEWORK,isCI,isDev,isLibrary,isMicro,mainDirectory,packageJson,PACKAGENAME}from"./process-env.mjs";export{digest,md5,node_modules,resolveProgram,toCamelCase}from"./utils/index.mjs";export*from"@moneko/mdx";export*from"@moneko/utils";import o from"webpack";export{o as webpack};
|
|
1
|
+
export*from"./commom/git.mjs";export{default as hasPkg}from"./commom/has-pkg.mjs";export{getIPv4,getPort}from"./commom/net.mjs";export{default as open}from"./commom/open.mjs";export{default as parseArgs}from"./commom/parse-args.mjs";export{CUSTOMCONFIG,default as paths,routeDir,yarnArgv}from"./commom/paths.mjs";export{default as printLog}from"./commom/print-log.mjs";export{default as require}from"./commom/require.mjs";export*as Rule from"./commom/rule.mjs";export{default as timer}from"./commom/timer.mjs";export{yApiMock,yApiSchemaMock}from"./dev/mock.mjs";export{default as jsxDomExpressions}from"./options/jsx-dom-expressions.mjs";export{default as splitChunk}from"./options/split-chunk.mjs";export{HtmlPlugin}from"./plugin/html-plugin.mjs";export*from"./plugin/manifest/index.mjs";export{APPTYPE,coreName,FRAMEWORK,isCI,isDev,isLibrary,isMicro,mainDirectory,packageJson,PACKAGENAME}from"./process-env.mjs";export{digest,md5,node_modules,resolveProgram,toCamelCase}from"./utils/index.mjs";export*from"@moneko/mdx";export*from"@moneko/utils";import o from"webpack";export{o as webpack};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i,sep as n}from"node:path";import o from"webpack";import{join as a}from"../commom/posix.mjs";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.
|
|
1
|
+
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i,sep as n}from"node:path";import o from"webpack";import{join as a}from"../commom/posix.mjs";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.entry\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}getPublicPath(t){if("string"==typeof this.options.publicPath)return this.options.publicPath;let e=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),s="auto"===e?"/":e;return s.length&&!s.endsWith("/")&&(s+="/"),s}apply(h){h.hooks.compilation.tap(this.name,l=>{l.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let r;if(this.options.favicon){let r=i(h.context,this.options.favicon);if(t(r)){let t=s(this.options.favicon),i=e(r);l.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1});let h=this.getPublicPath(l);this.faviconPath=a(h,t).replaceAll(n,"/")}else l.warnings.push(new o.WebpackError(`Favicon file ${r} does not exist`))}if(r=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(h.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(l);r=this.injectAssets(r,t,this.options.inject)}let c="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";l.emitAsset(c,new o.sources.RawSource(r),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:n="",inject:o=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=["import-scripts","require","async-node"],i=this.getPublicPath(t);for(let o of t.entrypoints.values())for(let t of o.chunks){let o=t.getEntryOptions(),h=o?.chunkLoading;if(!(o?.asyncChunks||h&&s.includes(h)))for(let s of t.files)s.endsWith(".js")?e.js.push(a(i,s).replaceAll(n,"/")):s.endsWith(".css")&&e.css.push(a(i,s).replaceAll(n,"/"))}return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",n=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",o=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${n}${o.head}</head>${h[0]}${o.body}</body>${h[1]||""}`:`${t}${o.head}</head>${h[0]}${i}${n}${o.body}</body>${h[1]||""}`}return t}}
|