diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 580cdbee..4b7ff7e4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,92 @@ # 更新日志 +### [1.3.90](https://github.com/novlan1/t-comm/compare/v1.3.89...v1.3.90) (2024-05-23) + + +### Features 🎉 + +* add isDirectory ([b267126](https://github.com/novlan1/t-comm/commit/b267126b14933e40f53b75d99b13555b80dc7d55)) +* **git:** add getAllGitRepo ([7b8fb82](https://github.com/novlan1/t-comm/commit/7b8fb82a980004c19eef777ff8bba4b12405b542)) +* **git:** add reclone and transformGitToSSH ([28a88bc](https://github.com/novlan1/t-comm/commit/28a88bca071f5ceb86ea14780f0254062a595724)) + +### [1.3.89](https://github.com/novlan1/t-comm/compare/v1.3.88...v1.3.89) (2024-05-14) + + +### Features 🎉 + +* 优化daily-merge ([d47cb37](https://github.com/novlan1/t-comm/commit/d47cb3787e374b2f5c15c831544f998480c346bf)) +* **ast:** 支持保留之前的引用 ([90ace6d](https://github.com/novlan1/t-comm/commit/90ace6da1202f19296da86b824600f5456aa28fe)) +* **ast:** 支持空导入 ([fdf4491](https://github.com/novlan1/t-comm/commit/fdf4491d7a8a9b6ed235816a2019e8baa518b47d)) + +### [1.3.88](https://github.com/novlan1/t-comm/compare/v1.3.87...v1.3.88) (2024-05-06) + + +### Features 🎉 + +* **ast:** 支持source为数组 ([4e76a6a](https://github.com/novlan1/t-comm/commit/4e76a6ac5f4ee1e6bff6dc3ba6741cf457430764)) + +### [1.3.87](https://github.com/novlan1/t-comm/compare/v1.3.86...v1.3.87) (2024-05-06) + + +### Features 🎉 + +* add export ast ([db8e3b0](https://github.com/novlan1/t-comm/commit/db8e3b0b3555614b7e314a200b073972f378e92e)) + + +### Bug Fixes 🐞 + +* **ast:** 修复默认导出的替换 ([51e3cd2](https://github.com/novlan1/t-comm/commit/51e3cd2746d127c43dac3600782f5fc91a967088)) + +### [1.3.86](https://github.com/novlan1/t-comm/compare/v1.3.85...v1.3.86) (2024-05-04) + + +### Features 🎉 + +* **ast:** add replace dependencies ([d9a36e4](https://github.com/novlan1/t-comm/commit/d9a36e4544f61525311f717d7449a318f513372e)) + +### [1.3.85](https://github.com/novlan1/t-comm/compare/v1.3.84...v1.3.85) (2024-04-20) + + +### Features 🎉 + +* **slash:** add remove last slash ([bc5f125](https://github.com/novlan1/t-comm/commit/bc5f1253e8c6a710f2f0576505a00735d7befc15)) + +### [1.3.84](https://github.com/novlan1/t-comm/compare/v1.3.82...v1.3.84) (2024-04-20) + + +### Features 🎉 + +* **v-console:** 支持showConsole事件 ([b6fe6c1](https://github.com/novlan1/t-comm/commit/b6fe6c10e7fcb6fbc95bfca902623ba0d076315c)) + +### [1.3.82](https://github.com/novlan1/t-comm/compare/v1.3.81...v1.3.82) (2024-04-19) + + +### Features 🎉 + +* **v-console:** 插件显示的时候重新渲染 ([0bd9a40](https://github.com/novlan1/t-comm/commit/0bd9a4010dde479c5d3c2b908b568c72848f6101)) + +### [1.3.81](https://github.com/novlan1/t-comm/compare/v1.3.80...v1.3.81) (2024-04-19) + + +### Chore 🚀 + +* lint ([81710e7](https://github.com/novlan1/t-comm/commit/81710e7606c58d57055c75b7ea81b3b50d39a4f3)) + + +### Documentation 📖 + +* **git:** update docs ([7c3d86e](https://github.com/novlan1/t-comm/commit/7c3d86e08ab7b1b503d3db0e9d2b75e706a63290)) + + +### Features 🎉 + +* **scheduler:** 支持unshift插入请求 ([c97ef4e](https://github.com/novlan1/t-comm/commit/c97ef4e13942a6aacfe87a73d8c7577c05a1348e)) + + +### Bug Fixes 🐞 + +* **debug:** 修复vconsole ([7cb3723](https://github.com/novlan1/t-comm/commit/7cb37232d2f5a8c82fca23b2edcbbd9ecc6b4400)) + ### [1.3.80](https://github.com/novlan1/t-comm/compare/v1.3.79...v1.3.80) (2024-04-16) diff --git a/docs/zh/daily-merge.md b/docs/zh/daily-merge.md index da849678..058ae62a 100644 --- a/docs/zh/daily-merge.md +++ b/docs/zh/daily-merge.md @@ -11,7 +11,7 @@ import { dailyMerge} from 't-comm/lib/daily-merge/index'; ``` -## `dailyMerge(param)` +## `dailyMerge(param0)` **描述**:
每日合并
@@ -19,9 +19,17 @@ import { dailyMerge} from 't-comm/lib/daily-merge/index'; **参数**: -| 参数名 | 类型 | 描述 | -| --- | --- | --- | -| param |object
| 参数
| +| 参数名 | 类型 | 默认值 | 描述 | +| --- | --- | --- | --- | +| param0 |object
| | 参数
| +| param0.webhookUrl |string
| | 机器人地址
| +| param0.appName |string
| | 项目名称
| +| param0.devRoot |string
| | 项目根路径
| +| param0.baseUrl |string
| | 基础请求 url
| +| param0.repoName |string
| | 仓库名称
| +| param0.privateToken |string
| | 密钥
| +| [param0.isDryRun] |boolean
| false
| 是否演练
| +| [param0.mainBranch] |string
| "'develop'"
| 主分支
| diff --git a/docs/zh/git.md b/docs/zh/git.md index 50e1d728..233d585f 100644 --- a/docs/zh/git.md +++ b/docs/zh/git.md @@ -4,27 +4,61 @@ ```ts import { + getAllGitRepo, getGitCurBranch, getGitCommitMessage, getGitCommitInfo, getGitLastTag, getGitCommitsBeforeTag, - getGitAuthor + getGitAuthor, + reCloneGitRemote } from 't-comm'; // or import { + getAllGitRepo, getGitCurBranch, getGitCommitMessage, getGitCommitInfo, getGitLastTag, getGitCommitsBeforeTag, - getGitAuthor + getGitAuthor, + reCloneGitRemote } from 't-comm/lib/git/index'; ``` +## `getAllGitRepo(root)` + + +**描述**:获取所有 git 仓库
+ +**参数**: + + +| 参数名 | 类型 | 描述 | +| --- | --- | --- | +| root |string
| 根路径
| + +**返回**:array
路径列表
+ +**示例** + +```ts +getAllGitRepo('/root/yang'); + +[ + { + root: '/root', + origin: 'git@git.address', + } +] +``` + + ## `getGitCurBranch()` @@ -149,3 +183,21 @@ getGitCommitInfo() **返回**:user
+ + +## `reCloneGitRemote(list)` + + +**描述**:根据配置表,重新 clone 仓库
+ +**参数**: + + +| 参数名 | 类型 | 描述 | +| --- | --- | --- | +| list |Array<item>
| 列表
| +| item.root |string
| 路径
| +| item.origin |string
| origin
| + + + diff --git a/docs/zh/i18n.md b/docs/zh/i18n.md new file mode 100644 index 00000000..669b016b --- /dev/null +++ b/docs/zh/i18n.md @@ -0,0 +1,37 @@ +[[toc]] + +## 引入 + +```ts +import { getI18nToken } from 't-comm'; + +// or + +import { getI18nToken} from 't-comm/lib/i18n/index'; +``` + + +## `getI18nToken(appId, appKey)` + + +**描述**:获取 i18n token
+ +**参数**: + + +| 参数名 | 类型 | 描述 | +| --- | --- | --- | +| appId |string
| appId
| +| appKey |string
| appKey
| + +**返回**:Promise.<string>
token
+ +**示例** + +```ts +getI18nToken('appId', 'appKey').then(token => { + console.log('token', token) +}) +``` diff --git a/docs/zh/slash.md b/docs/zh/slash.md new file mode 100644 index 00000000..b9eaace2 --- /dev/null +++ b/docs/zh/slash.md @@ -0,0 +1,94 @@ +[[toc]] + +## 引入 + +```ts +import { + removeFirstSlash, + removeLastSlash, + removeFirstAndLastSlash +} from 't-comm'; + +// or + +import { + removeFirstSlash, + removeLastSlash, + removeFirstAndLastSlash +} from 't-comm/lib/slash/index'; +``` + + +## `removeFirstSlash([str])` + + +**描述**:移除第一个反斜杠
+ +**参数**: + + +| 参数名 | 类型 | 默认值 | 描述 | +| --- | --- | --- | --- | +| [str] |string
| "''"
| 输入字符串
| + +**返回**:string
字符串
+ +**示例** + +```ts +removeFirstSlash('/abc/ddd/') + +'abc/ddd/' +``` + + +## `removeLastSlash([str])` + + +**描述**:移除最后一个反斜杠
+ +**参数**: + + +| 参数名 | 类型 | 默认值 | 描述 | +| --- | --- | --- | --- | +| [str] |string
| "''"
| 输入字符串
| + +**返回**:string
字符串
+ +**示例** + +```ts +removeLastSlash('/abc/') + +'/abc' +``` + + +## `removeFirstAndLastSlash([str])` + + +**描述**:移除第一个和最后一个反斜杠
+ +**参数**: + + +| 参数名 | 类型 | 默认值 | 描述 | +| --- | --- | --- | --- | +| [str] |string
| "''"
| 输入字符串
| + +**返回**:string
字符串
+ +**示例** + +```ts +removeFirstAndLastSlash('/abc/') + +'abc' +``` diff --git a/package.json b/package.json index 31e80619..69388cfb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "t-comm", - "version": "1.3.80", + "version": "1.3.90", "description": "丰富易用的工具库", "main": "lib/index.js", "module": "lib/index.esm.js", diff --git a/script/trial/tgit/project.js b/script/trial/tgit/project.js new file mode 100644 index 00000000..1a3c9358 --- /dev/null +++ b/script/trial/tgit/project.js @@ -0,0 +1,18 @@ +const { getOneProjectDetail } = require('../../../lib'); +require('../../utils/env'); + +console.log('process.env', process.env); +function main() { + getOneProjectDetail({ + projectName: 'pmd-mobile/match/pro', + privateToken: process.env.GIT_WOA_PRIVATE_TOKEN, + baseUrl: process.env.GIT_WOA_BASE_URL, + }).then((res) => { + console.log('res', res); + }) + .catch((err) => { + console.log('err', err); + }); +} + +main(); diff --git a/src/ast/index.ts b/src/ast/index.ts new file mode 100644 index 00000000..a7c9e766 --- /dev/null +++ b/src/ast/index.ts @@ -0,0 +1,3 @@ +export { IImportType } from './types'; +export { parseReplaceConfig } from './parse-config-list'; +export { replaceDependencies } from './replace-dependencies'; diff --git a/src/ast/parse-config-list.ts b/src/ast/parse-config-list.ts new file mode 100644 index 00000000..c2096795 --- /dev/null +++ b/src/ast/parse-config-list.ts @@ -0,0 +1,89 @@ +import { IImportItem, IImportType, IReplaceConfig } from './types'; + + +function parseOneReplaceConfig(config: IImportItem): { + sourceName: string; + sourceType: IImportType; + targetName: string; + targetType: IImportType; +} { + if (typeof config === 'string') { + return { + sourceName: config, + sourceType: IImportType.ImportSpecifier, + targetName: config, + targetType: IImportType.ImportSpecifier, + }; + } + if (Array.isArray(config)) { + return { + sourceName: config[0], + sourceType: IImportType.ImportSpecifier, + targetName: config[1] || config[0], + targetType: IImportType.ImportSpecifier, + }; + } + + return { + sourceName: config.sourceName || '', + sourceType: config.sourceType || IImportType.ImportSpecifier, + targetName: config.targetName || config.sourceName || '', + targetType: config.targetType || config.sourceType || IImportType.ImportSpecifier, + }; +} + + +export function parseReplaceConfig(configList: Array