xshell 1.0.130 → 1.0.131

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/builder.d.ts CHANGED
@@ -54,6 +54,13 @@ export declare class Bundler {
54
54
  - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
55
55
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
56
56
  constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, { source_map, globals, external_dayjs, externals, commonjs2, single_chunk, dynamic_import, resolve_alias, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, license, }?: BundlerOptions);
57
+ /** 获取构建时 git 仓库的最新提交、分支信息 */
58
+ get_git_info(version?: string): Promise<{
59
+ version: string;
60
+ branch: string;
61
+ time: string;
62
+ commit: string;
63
+ }>;
57
64
  build(print?: boolean): Promise<void>;
58
65
  close(): Promise<void>;
59
66
  build_and_close(print?: boolean): Promise<void>;
package/builder.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import Webpack from 'webpack';
3
3
  import { Lock, Timer, filter_values } from './utils.js';
4
+ import { Git } from './git.js';
4
5
  export class Bundler {
5
6
  name;
6
7
  fpd_root;
@@ -261,6 +262,21 @@ export class Bundler {
261
262
  }
262
263
  };
263
264
  }
265
+ /** 获取构建时 git 仓库的最新提交、分支信息 */
266
+ async get_git_info(version) {
267
+ let git = new Git(this.fpd_root);
268
+ const branch = await git.get_branch();
269
+ const { hash, time } = (await git.get_last_commits(1))[0];
270
+ version ||= branch;
271
+ const timestr = time.to_formal_str();
272
+ const commit = hash.slice(0, 6);
273
+ return {
274
+ version: version,
275
+ branch,
276
+ time: timestr,
277
+ commit
278
+ };
279
+ }
264
280
  async build(print = true) {
265
281
  let timer = new Timer();
266
282
  if (!this.lcompiler) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.130",
3
+ "version": "1.0.131",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {