Skip to content

Commit

Permalink
feat: add ast script
Browse files Browse the repository at this point in the history
  • Loading branch information
novlan1 committed May 28, 2024
1 parent 67ecdd7 commit d7091ad
Show file tree
Hide file tree
Showing 32 changed files with 1,120 additions and 61 deletions.
87 changes: 87 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
16 changes: 12 additions & 4 deletions docs/zh/daily-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ import { dailyMerge} from 't-comm/lib/daily-merge/index';
```


## `dailyMerge(param)`
## `dailyMerge(param0)`


**描述**:<p>每日合并</p>

**参数**


| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| param | <code>object</code> | <p>参数</p> |
| 参数名 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| param0 | <code>object</code> | | <p>参数</p> |
| param0.webhookUrl | <code>string</code> | | <p>机器人地址</p> |
| param0.appName | <code>string</code> | | <p>项目名称</p> |
| param0.devRoot | <code>string</code> | | <p>项目根路径</p> |
| param0.baseUrl | <code>string</code> | | <p>基础请求 url</p> |
| param0.repoName | <code>string</code> | | <p>仓库名称</p> |
| param0.privateToken | <code>string</code> | | <p>密钥</p> |
| [param0.isDryRun] | <code>boolean</code> | <code>false</code> | <p>是否演练</p> |
| [param0.mainBranch] | <code>string</code> | <code>&quot;&#x27;develop&#x27;&quot;</code> | <p>主分支</p> |



Expand Down
56 changes: 54 additions & 2 deletions docs/zh/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`


**描述**:<p>获取所有 git 仓库</p>

**参数**


| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| root | <code>string</code> | <p>根路径</p> |

**返回**: <code>array</code><br>

<p>路径列表</p>

**示例**

```ts
getAllGitRepo('/root/yang');

[
{
root: '/root',
origin: 'git@git.address',
}
]
```
<a name="getGitCurBranch"></a>

## `getGitCurBranch()`


Expand Down Expand Up @@ -149,3 +183,21 @@ getGitCommitInfo()

**返回**: <p>user</p>

<a name="reCloneGitRemote"></a>

## `reCloneGitRemote(list)`


**描述**:<p>根据配置表,重新 clone 仓库</p>

**参数**


| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| list | <code>Array&lt;item&gt;</code> | <p>列表</p> |
| item.root | <code>string</code> | <p>路径</p> |
| item.origin | <code>string</code> | <p>origin</p> |



37 changes: 37 additions & 0 deletions docs/zh/i18n.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[[toc]]

## 引入

```ts
import { getI18nToken } from 't-comm';

// or

import { getI18nToken} from 't-comm/lib/i18n/index';
```


## `getI18nToken(appId, appKey)`


**描述**:<p>获取 i18n token</p>

**参数**


| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| appId | <code>string</code> | <p>appId</p> |
| appKey | <code>string</code> | <p>appKey</p> |

**返回**: <code>Promise.&lt;string&gt;</code><br>

<p>token</p>

**示例**

```ts
getI18nToken('appId', 'appKey').then(token => {
console.log('token', token)
})
```
94 changes: 94 additions & 0 deletions docs/zh/slash.md
Original file line number Diff line number Diff line change
@@ -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])`


**描述**:<p>移除第一个反斜杠</p>

**参数**


| 参数名 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| [str] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | <p>输入字符串</p> |

**返回**: <code>string</code><br>

<p>字符串</p>

**示例**

```ts
removeFirstSlash('/abc/ddd/')

'abc/ddd/'
```
<a name="removeLastSlash"></a>

## `removeLastSlash([str])`


**描述**:<p>移除最后一个反斜杠</p>

**参数**


| 参数名 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| [str] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | <p>输入字符串</p> |

**返回**: <code>string</code><br>

<p>字符串</p>

**示例**

```ts
removeLastSlash('/abc/')

'/abc'
```
<a name="removeFirstAndLastSlash"></a>

## `removeFirstAndLastSlash([str])`


**描述**:<p>移除第一个和最后一个反斜杠</p>

**参数**


| 参数名 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| [str] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | <p>输入字符串</p> |

**返回**: <code>string</code><br>

<p>字符串</p>

**示例**

```ts
removeFirstAndLastSlash('/abc/')

'abc'
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 18 additions & 0 deletions script/trial/tgit/project.js
Original file line number Diff line number Diff line change
@@ -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();
3 changes: 3 additions & 0 deletions src/ast/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { IImportType } from './types';
export { parseReplaceConfig } from './parse-config-list';
export { replaceDependencies } from './replace-dependencies';
Loading

0 comments on commit d7091ad

Please sign in to comment.