@tmsfe/tmskit 0.0.27 → 0.0.28

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/CHANGELOG.md CHANGED
@@ -55,4 +55,7 @@
55
55
  * 支持编译插件
56
56
  * 支持npm源配置
57
57
  13. [0.0.27]
58
- * 添加云函数cloud-dev命令
58
+ * 添加云函数cloud-dev命令
59
+ 14. [0.0.28]
60
+ * 修复git pull 代码失败的兼容问题
61
+ * 拉取第三方仓库时,支持按group维度配置账号信息
package/dist/index.cjs.js CHANGED
@@ -1660,15 +1660,17 @@ const {
1660
1660
  */
1661
1661
 
1662
1662
  function replaceGitUrlAccount(httpRepoUrl, moduleName) {
1663
- var _tmsConfig$gitAccount, _tmsConfig$gitAccount2;
1663
+ var _tmsConfig$gitAccount, _tmsConfig$gitAccount2, _tmsConfig$gitAccount3;
1664
1664
 
1665
1665
  // 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
1666
1666
  const tmsConfig = global$8.getData('tmsConfig');
1667
1667
  let gitUrl = httpRepoUrl;
1668
+ const gitGroupReg = /http(s)?:\/\/[^/]+\/[^/]+/;
1669
+ const group = gitUrl.match(gitGroupReg)[0];
1668
1670
  const {
1669
1671
  username = '',
1670
1672
  pass = ''
1671
- } = (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount === void 0 ? void 0 : _tmsConfig$gitAccount[moduleName]) || (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount2 = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount2 === void 0 ? void 0 : _tmsConfig$gitAccount2[httpRepoUrl]) || {};
1673
+ } = (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount === void 0 ? void 0 : _tmsConfig$gitAccount[moduleName]) || (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount2 = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount2 === void 0 ? void 0 : _tmsConfig$gitAccount2[httpRepoUrl]) || (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount3 = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount3 === void 0 ? void 0 : _tmsConfig$gitAccount3[group]) || {};
1672
1674
  const urlPrefixReg = /http(s)?:\/\//;
1673
1675
 
1674
1676
  if (username && pass && urlPrefixReg.test(gitUrl)) {
@@ -1819,7 +1821,10 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1819
1821
  if (fs$d.existsSync(sourcePath) && fs$d.existsSync(`${sourcePath}/.git`)) {
1820
1822
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1821
1823
  info$d(`git pull:${httpRepoUrl} --branch: ${branch}`);
1822
- return pullRepoForGit(sourcePath, branch);
1824
+ return pullRepoForGit(sourcePath, branch).catch(e => {
1825
+ info$d(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1826
+ return downloadRepoForGit(gitUrl, sourcePath, branch);
1827
+ });
1823
1828
  };
1824
1829
  } else {
1825
1830
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
@@ -4195,7 +4200,7 @@ var entry = [{
4195
4200
 
4196
4201
  var require$$12 = {
4197
4202
  name: "@tmsfe/tmskit",
4198
- version: "0.0.27",
4203
+ version: "0.0.28",
4199
4204
  description: "tmskit",
4200
4205
  main: "dist/index.cjs",
4201
4206
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
@@ -21,10 +21,15 @@ function replaceGitUrlAccount(httpRepoUrl, moduleName) {
21
21
  const tmsConfig = global.getData('tmsConfig');
22
22
 
23
23
  let gitUrl = httpRepoUrl;
24
-
25
- const { username = '', pass = '' } = tmsConfig?.gitAccount?.[moduleName] || tmsConfig?.gitAccount?.[httpRepoUrl] || {};
24
+ const gitGroupReg = /http(s)?:\/\/[^/]+\/[^/]+/;
25
+ const group = gitUrl.match(gitGroupReg)[0];
26
+
27
+ const { username = '', pass = '' } = tmsConfig?.gitAccount?.[moduleName]
28
+ || tmsConfig?.gitAccount?.[httpRepoUrl]
29
+ || tmsConfig?.gitAccount?.[group] || {};
26
30
 
27
31
  const urlPrefixReg = /http(s)?:\/\//;
32
+
28
33
  if (username && pass && urlPrefixReg.test(gitUrl)) {
29
34
  gitUrl = gitUrl.replace(urlPrefixReg, val => `${val}${encodeURIComponent(username)}:${pass}@`);
30
35
  }
@@ -160,7 +165,10 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
160
165
  if (fs.existsSync(sourcePath) && fs.existsSync(`${sourcePath}/.git`)) {
161
166
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
162
167
  info(`git pull:${httpRepoUrl} --branch: ${branch}`);
163
- return pullRepoForGit(sourcePath, branch);
168
+ return pullRepoForGit(sourcePath, branch).catch((e) => {
169
+ info(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
170
+ return downloadRepoForGit(gitUrl, sourcePath, branch);
171
+ });
164
172
  };
165
173
  } else {
166
174
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
package/src/.DS_Store DELETED
Binary file
Binary file