@infly/libs 2.2.8 → 2.2.9

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.
@@ -36,6 +36,7 @@ const {
36
36
  pullSingleDirFromBranch
37
37
  } = require("../../script/git-automation");
38
38
  const { resolveSiblingAppDeps } = require("../build-utils/deps");
39
+ const { resolveGitWorktreeRoot } = require("../../script/git-automation/git-utils");
39
40
 
40
41
  const scriptEvent = process.env.npm_lifecycle_event;
41
42
  const isBuilZipScript = process.env.npm_lifecycle_event;
@@ -46,6 +47,9 @@ const npmPackageConfigKey = "infly";
46
47
  const currentBranch = getCurrentBranch();
47
48
 
48
49
  const projectRoot = process.cwd();
50
+ // 构建配置可以位于主仓中的子目录(例如合并后的 level/)。配置、产物仍以
51
+ // projectRoot 为基准,只有 Git 检查与分支更新定位到实际工作树根目录。
52
+ const projectGitRoot = resolveGitWorktreeRoot(projectRoot);
49
53
 
50
54
  // 依赖包的配置
51
55
  const originConfigPath = currentProjectFileResolve("template-version-config.json"); // 模板项目文件
@@ -813,14 +817,14 @@ async function beforeBuild() {
813
817
  return;
814
818
  }
815
819
 
816
- const currentProjectStatus = checkSingleDirGitStatus(projectRoot, projectName);
820
+ const currentProjectStatus = checkSingleDirGitStatus(projectGitRoot, projectName);
817
821
 
818
822
  if (currentProjectStatus.hasUncommitted) {
819
823
  console.log(global.logColor.error, `\n❌ 当前项目存在未提交的更改,请先提交或暂存后再继续构建`);
820
824
  process.exit(1);
821
825
  }
822
826
 
823
- const currentProjectUpdateResult = pullSingleDirFromBranch(projectRoot, projectName, targetBranch);
827
+ const currentProjectUpdateResult = pullSingleDirFromBranch(projectGitRoot, projectName, targetBranch);
824
828
 
825
829
  if (!currentProjectUpdateResult.success) {
826
830
  console.log(global.logColor.error, `\n❌ 当前项目切换到 ${targetBranch} 分支失败,请检查`);
@@ -66,7 +66,9 @@ async function selectOptions(message, choices, dependencies = {}) {
66
66
  name: "selections",
67
67
  message,
68
68
  indicator: { on: "[√]", off: "[ ]" },
69
- hint: "↑/↓ 移动,空格勾选/取消,回车确认,Ctrl+C 退出(至少选择一项)",
69
+ // Enquirer 不会正确清除 Git Bash 中发生自动换行的提示行,提示过长时
70
+ // 每次移动光标都会残留一帧。保持简短,最少选择一项由 min 校验提示。
71
+ hint: "空格选择,回车确认",
70
72
  stdin,
71
73
  stdout,
72
74
  min: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infly/libs",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "description": "不受前端框架限制的独立工具库",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -64,6 +64,7 @@
64
64
  "dotenv": "16.6.1",
65
65
  "enquirer": "^2.4.1",
66
66
  "path-browserify": "^1.0.1",
67
+ "sass": "^1.69.5",
67
68
  "serve-static": "^1.15.0",
68
69
  "yaml": "^2.3.4"
69
70
  },
@@ -45,7 +45,7 @@ function findGitRepo(cwd) {
45
45
  }
46
46
  }
47
47
 
48
- function getGitCommonDir(cwd) {
48
+ function getGitCommonDir(cwd) {
49
49
  const repo = findGitRepo(cwd);
50
50
 
51
51
  if (repo) {
@@ -58,10 +58,16 @@ function getGitCommonDir(cwd) {
58
58
  } catch {
59
59
  return path.resolve(cwd || process.cwd());
60
60
  }
61
- }
62
-
63
- module.exports = {
64
- gitOutput,
65
- findGitRepo,
66
- getGitCommonDir
67
- };
61
+ }
62
+
63
+ function resolveGitWorktreeRoot(cwd) {
64
+ const resolvedCwd = path.resolve(cwd || process.cwd());
65
+ return findGitRepo(resolvedCwd)?.root || resolvedCwd;
66
+ }
67
+
68
+ module.exports = {
69
+ gitOutput,
70
+ findGitRepo,
71
+ getGitCommonDir,
72
+ resolveGitWorktreeRoot
73
+ };