@liuli-util/cli 3.17.1 → 3.17.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liuli-util/cli",
3
- "version": "3.17.1",
3
+ "version": "3.17.2",
4
4
  "description": "一个针对于库和 CLI 应用程序打包的零配置 CLI",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -145,14 +145,21 @@ export class GhPagesDeployService implements IDeployService {
145
145
  const remoteDestPath = path.join(localRepoPath, this.options.remote)
146
146
  await mkdirp(remoteDestPath)
147
147
  await copy(path.resolve(this.options.cwd, this.options.dest), remoteDestPath)
148
- mark('推送到远端')
148
+ mark('提交所有文件')
149
149
  await git.cwd(localRepoPath)
150
150
  await git.add('-A')
151
- if ((await git.status()).files.length !== 0) {
151
+ if ((await git.status()).files.length === 0) {
152
+ mark('没有任何提交,跳过提交')
153
+ } else {
152
154
  await git.commit('Updates gh-pages by liuli-cli')
155
+ }
156
+ mark('推送到远端')
157
+ if ((await git.status()).ahead === 0) {
158
+ mark('没有更新,跳过推送')
159
+ } else {
153
160
  await git.push(defaultRemote, defaultBranch)
161
+ mark('完成推送')
154
162
  }
155
- mark('完成推送')
156
163
  obs.disconnect()
157
164
  })
158
165
  }
@@ -1,6 +1,7 @@
1
1
  import simpleGit, { SimpleGit } from 'simple-git'
2
2
  import * as path from 'path'
3
- import { mkdirp, remove } from 'fs-extra'
3
+ import { mkdirp, pathExists, remove } from 'fs-extra'
4
+ import * as os from 'os'
4
5
 
5
6
  describe('测试 simple-git', () => {
6
7
  async function getOriginRemote() {
@@ -32,3 +33,22 @@ describe('测试 simple-git', () => {
32
33
  console.log('status: ', status.files)
33
34
  })
34
35
  })
36
+
37
+ describe.skip('测试真实场景', () => {
38
+ const gitPath = path.resolve(
39
+ os.homedir(),
40
+ './AppData/Local/liuli-cli/Cache/gh-pages/https___github.com_rxliuli_webos.git',
41
+ )
42
+ const git = simpleGit(gitPath)
43
+ it('测试获取提交状态', async () => {
44
+ const res = await git.status()
45
+ console.log(res)
46
+ })
47
+ it('测试获取更新', async () => {
48
+ const res = await git.pull()
49
+ console.log(res)
50
+ }, 100_000)
51
+ it('测试 git add -A', async () => {
52
+ await git.add('-A')
53
+ })
54
+ })
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "temp",
3
+ "sync": [
4
+ "jest"
5
+ ],
6
+ "jest": {
7
+ "preset": "ts-jest",
8
+ "testMatch": [
9
+ "<rootDir>/src/**/__tests__/*.test.ts"
10
+ ]
11
+ },
12
+ "devDependencies": {
13
+ "jest": "^27.4.3",
14
+ "ts-jest": "^27.0.7"
15
+ }
16
+ }
@@ -1,28 +1,28 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "lib": [
5
- "ESNext"
6
- ],
7
- "outDir": "./dist",
8
- "skipLibCheck": true,
9
- "esModuleInterop": true,
10
- "strict": true,
11
- "module": "ESNext",
12
- "moduleResolution": "node",
13
- "sourceMap": true,
14
- "declaration": true,
15
- "declarationMap": true
16
- },
17
- "include": [
18
- "src"
19
- ],
20
- "typedocOptions": {
21
- "entryPoints": [
22
- "src/index.ts"
23
- ],
24
- "out": "docs",
25
- "readme": "README.md",
26
- "gitRemote": "origin"
27
- }
28
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "lib": [
5
+ "ESNext"
6
+ ],
7
+ "outDir": "./dist",
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "strict": true,
11
+ "module": "ESNext",
12
+ "moduleResolution": "node",
13
+ "sourceMap": true,
14
+ "declaration": true,
15
+ "declarationMap": true
16
+ },
17
+ "include": [
18
+ "src"
19
+ ],
20
+ "typedocOptions": {
21
+ "entryPoints": [
22
+ "src/index.ts"
23
+ ],
24
+ "out": "docs",
25
+ "readme": "README.md",
26
+ "gitRemote": "origin"
27
+ }
28
+ }
@@ -1,28 +1,28 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "lib": [
5
- "ESNext"
6
- ],
7
- "outDir": "./dist",
8
- "skipLibCheck": true,
9
- "esModuleInterop": true,
10
- "strict": true,
11
- "module": "ESNext",
12
- "moduleResolution": "node",
13
- "sourceMap": true,
14
- "declaration": true,
15
- "declarationMap": true
16
- },
17
- "include": [
18
- "src"
19
- ],
20
- "typedocOptions": {
21
- "entryPoints": [
22
- "src/index.ts"
23
- ],
24
- "out": "docs",
25
- "readme": "README.md",
26
- "gitRemote": "origin"
27
- }
28
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "lib": [
5
+ "ESNext"
6
+ ],
7
+ "outDir": "./dist",
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "strict": true,
11
+ "module": "ESNext",
12
+ "moduleResolution": "node",
13
+ "sourceMap": true,
14
+ "declaration": true,
15
+ "declarationMap": true
16
+ },
17
+ "include": [
18
+ "src"
19
+ ],
20
+ "typedocOptions": {
21
+ "entryPoints": [
22
+ "src/index.ts"
23
+ ],
24
+ "out": "docs",
25
+ "readme": "README.md",
26
+ "gitRemote": "origin"
27
+ }
28
+ }
package/tsconfig.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "lib": [
5
- "ESNext"
6
- ],
7
- "outDir": "./dist",
8
- "skipLibCheck": true,
9
- "esModuleInterop": true,
10
- "strict": true,
11
- "module": "ESNext",
12
- "moduleResolution": "node",
13
- "sourceMap": true,
14
- "declaration": true,
15
- "declarationMap": true,
16
- "resolveJsonModule": true
17
- },
18
- "include": [
19
- "src"
20
- ],
21
- "typedocOptions": {
22
- "entryPoints": [
23
- "src/index.ts"
24
- ],
25
- "out": "docs",
26
- "readme": "README.md",
27
- "gitRemote": "origin"
28
- },
29
- "ts-node": {
30
- "compilerOptions": {
31
- "module": "CommonJS"
32
- }
33
- }
34
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "lib": [
5
+ "ESNext"
6
+ ],
7
+ "outDir": "./dist",
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "strict": true,
11
+ "module": "ESNext",
12
+ "moduleResolution": "node",
13
+ "sourceMap": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "resolveJsonModule": true
17
+ },
18
+ "include": [
19
+ "src"
20
+ ],
21
+ "typedocOptions": {
22
+ "entryPoints": [
23
+ "src/index.ts"
24
+ ],
25
+ "out": "docs",
26
+ "readme": "README.md",
27
+ "gitRemote": "origin"
28
+ },
29
+ "ts-node": {
30
+ "compilerOptions": {
31
+ "module": "CommonJS"
32
+ }
33
+ }
34
+ }
@@ -1 +0,0 @@
1
- {"devDependencies":{"@types/node":"16"},"dependencies":{"ora":"^6"},"peerDependencies":{"typescript":"^4"}}
@@ -1 +0,0 @@
1
- # @liuli-util/cli-test-cli
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- // eslint-disable-next-line no-undef
3
- require('./dist/bin.js')
@@ -1,44 +0,0 @@
1
- {
2
- "name": "test-cli",
3
- "version": "0.1.0",
4
- "main": "dist/index.js",
5
- "module": "dist/index.esm.js",
6
- "types": "dist/index.d.ts",
7
- "license": "MIT",
8
- "scripts": {
9
- "build": "rimraf dist && liuli-cli build cli",
10
- "dev": "liuli-cli build cli -w",
11
- "start": "esno src/bin.ts",
12
- "docs:server": "live-server docs",
13
- "docs:dev": "typedoc --watch",
14
- "docs:build": "rimraf docs && typedoc",
15
- "docs:deploy": "yarn docs:build && gh-pages -d docs/ -e / -a"
16
- },
17
- "bin": {
18
- "cli-name": "./bin.js"
19
- },
20
- "jest": {
21
- "preset": "ts-jest"
22
- },
23
- "dependencies": {
24
- "commander": "^8.2.0",
25
- "fs-extra": "^10.0.0",
26
- "inquirer": "^8.1.5"
27
- },
28
- "devDependencies": {
29
- "@liuli-util/cli": "^3.11.1",
30
- "@types/fs-extra": "^9.0.13",
31
- "@types/inquirer": "^8.1.2",
32
- "@types/jest": "^27.0.2",
33
- "@types/lodash": "^4.14.173",
34
- "@types/node": "^16.9.6",
35
- "esno": "^0.9.1",
36
- "gh-pages": "^3.2.3",
37
- "jest": "^27.2.1",
38
- "rimraf": "^3.0.2",
39
- "ts-jest": "^27.0.5",
40
- "type-fest": "^2.3.4",
41
- "typedoc": "^0.22.4",
42
- "typescript": "^4.4.3"
43
- }
44
- }
@@ -1,13 +0,0 @@
1
- import { Command } from 'commander'
2
- import { prompt } from 'inquirer'
3
-
4
- new Command()
5
- .action(async () => {
6
- const { name } = await prompt<{ name: string }>({
7
- type: 'input',
8
- name: 'name',
9
- message: '请输入名字',
10
- })
11
- console.log(`hello ${name}`)
12
- })
13
- .parse()
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "lib": [
5
- "ESNext"
6
- ],
7
- "outDir": "./dist",
8
- "skipLibCheck": true,
9
- "esModuleInterop": true,
10
- "strict": true,
11
- "module": "ESNext",
12
- "moduleResolution": "node",
13
- "sourceMap": true,
14
- "declaration": true,
15
- "declarationMap": true
16
- },
17
- "include": [
18
- "src"
19
- ],
20
- "typedocOptions": {
21
- "entryPoints": [
22
- "src/index.ts"
23
- ],
24
- "out": "docs",
25
- "readme": "README.md",
26
- "gitRemote": "origin"
27
- }
28
- }