@moneko/core 4.6.4 → 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.
@@ -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/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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.6.4",
3
+ "version": "4.6.5",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",