Skip to content

Commit b3e58b0

Browse files
committed
fix coding setting & git setting
1 parent 7d2ffc6 commit b3e58b0

8 files changed

Lines changed: 74 additions & 42 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"feed": "^2.0.4",
3434
"fs-extra": "^7.0.1",
3535
"gray-matter": "^4.0.1",
36-
"isomorphic-git": "1.0.0-beta.19",
36+
"isomorphic-git": "^0.78.3",
3737
"junk": "^3.1.0",
3838
"less": "^3.9.0",
3939
"lowdb": "^1.0.0",

src/assets/locales.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const message = {
7777
remotePathTip: '请填写绝对路径,例如:/home/username/www/',
7878
testConnection: '检测远程连接',
7979
connectSuccess: '远程连接成功',
80-
connectFailed: '远程连接失败,请检查仓库、用户名和 Token 设置',
80+
connectFailed: '远程连接失败,请检查仓库、用户名和令牌设置',
8181
sourceFolder: '站点源文件路径',
8282
language: '语 言',
8383
inConfig: '配置中',
@@ -108,6 +108,9 @@ const message = {
108108
words: '字 数',
109109
readingTime: '阅读时间',
110110
version: '版本',
111+
token: '令牌',
112+
tokenUsername: '令牌用户名',
113+
platform: '平台',
111114
},
112115
zh_TW: {
113116
preview: '預 覽',
@@ -188,7 +191,7 @@ const message = {
188191
remotePathTip: '請填寫絕對路徑,例如:/home/username/www/',
189192
testConnection: '檢測遠程連接',
190193
connectSuccess: '遠程連接成功',
191-
connectFailed: '遠程連接失敗,請檢查倉庫、用戶名和 Token 設置',
194+
connectFailed: '遠程連接失敗,請檢查倉庫、用戶名和令牌設置',
192195
sourceFolder: '站点源文件路径',
193196
language: '語 言',
194197
inConfig: '配置中',
@@ -219,6 +222,9 @@ const message = {
219222
words: '字 數',
220223
readingTime: '閱讀時間',
221224
version: '版本',
225+
token: '令牌',
226+
tokenUsername: '令牌用户名',
227+
platform: '平臺',
222228
},
223229
en: {
224230
preview: 'Preview',
@@ -329,6 +335,9 @@ const message = {
329335
words: 'Words',
330336
readingTime: 'Reading time',
331337
version: 'Version',
338+
token: 'Token',
339+
tokenUsername: 'Token Username',
340+
platform: 'Platform',
332341
},
333342
}
334343

src/interfaces/setting.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface ISetting {
55
branch: string
66
username: string
77
email: string
8+
tokenUsername: string
89
token: string
910
cname: string
1011
port: string

src/server/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default class App {
7070
branch: '',
7171
username: '',
7272
email: '',
73+
tokenUsername: '',
7374
token: '',
7475
cname: '',
7576
port: '22',

src/server/deploy.ts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import fs from 'fs'
22
import moment from 'moment'
33
// @ts-ignore
4-
import * as git from 'isomorphic-git/dist'
4+
import * as git from 'isomorphic-git/dist/for-node/isomorphic-git'
55
import Model from './model'
66

7-
const { http } = require('isomorphic-git/dist/http')
8-
97
export default class Deploy extends Model {
108
outputDir: string = `${this.appDir}/output`
119

@@ -19,9 +17,14 @@ export default class Deploy extends Model {
1917
const { setting } = this.db
2018
this.platformAddress = ({
2119
github: 'github.com',
22-
coding: 'git.coding.net',
20+
coding: 'e.coding.net',
21+
} as any)[setting.platform || 'github']
22+
const preUrl = ({
23+
github: `${setting.username}:${setting.token}`,
24+
coding: `${setting.tokenUsername}:${setting.token}`,
2325
} as any)[setting.platform || 'github']
24-
this.remoteUrl = `https://${setting.username}:${setting.token}@${this.platformAddress}/${setting.username}/${setting.repository}.git`
26+
27+
this.remoteUrl = `https://${preUrl}@${this.platformAddress}/${setting.username}/${setting.repository}.git`
2528
}
2629

2730
/**
@@ -50,13 +53,13 @@ export default class Deploy extends Model {
5053
}
5154
if (!isRepo) {
5255
await git.init({ fs, dir: this.outputDir })
53-
await git.setConfig({
56+
await git.config({
5457
fs,
5558
dir: this.outputDir,
5659
path: 'user.name',
5760
value: setting.username,
5861
})
59-
await git.setConfig({
62+
await git.config({
6063
fs,
6164
dir: this.outputDir,
6265
path: 'user.email',
@@ -67,7 +70,10 @@ export default class Deploy extends Model {
6770
await git.addRemote({
6871
fs, dir: this.outputDir, remote: 'origin', url: this.remoteUrl, force: true,
6972
})
70-
await git.listRemotes({ fs, dir: this.outputDir })
73+
const info = await git.getRemoteInfo({
74+
core: 'default',
75+
url: this.remoteUrl,
76+
})
7177
} catch (e) {
7278
console.log('Test Remote Error: ', e.message)
7379
result.success = false
@@ -105,13 +111,13 @@ export default class Deploy extends Model {
105111

106112
try {
107113
await git.init({ fs, dir: this.outputDir })
108-
await git.setConfig({
114+
await git.config({
109115
fs,
110116
dir: this.outputDir,
111117
path: 'user.name',
112118
value: setting.username,
113119
})
114-
await git.setConfig({
120+
await git.config({
115121
fs,
116122
dir: this.outputDir,
117123
path: 'user.email',
@@ -126,19 +132,18 @@ export default class Deploy extends Model {
126132
await git.addRemote({
127133
fs, dir: this.outputDir, remote: 'origin', url: this.remoteUrl, force: true,
128134
})
129-
// await git.fastCheckout({ fs, dir: this.outputDir, ref: setting.branch })
135+
130136
await this.checkCurrentBranch()
131-
// const pushRes = await git.push({
132-
// fs,
133-
// dir: this.outputDir,
134-
// remote: 'origin',
135-
// ref: setting.branch,
136-
// force: true,
137-
// http,
138-
// })
137+
const pushRes = await git.push({
138+
fs,
139+
dir: this.outputDir,
140+
remote: 'origin',
141+
ref: setting.branch,
142+
force: true,
143+
})
139144
return {
140145
success: true,
141-
// data: pushRes,
146+
data: pushRes,
142147
message: '',
143148
localBranchs,
144149
}
@@ -175,18 +180,17 @@ export default class Deploy extends Model {
175180

176181
await this.checkCurrentBranch()
177182

178-
// const pushRes = await git.push({
179-
// fs,
180-
// dir: this.outputDir,
181-
// remote: 'origin',
182-
// ref: setting.branch,
183-
// force: true,
184-
// http,
185-
// })
186-
// console.log('pushRes', pushRes)
183+
const pushRes = await git.push({
184+
fs,
185+
dir: this.outputDir,
186+
remote: 'origin',
187+
ref: setting.branch,
188+
force: true,
189+
})
190+
console.log('pushRes', pushRes)
187191
return {
188192
success: true,
189-
// data: pushRes,
193+
data: pushRes,
190194
message: '',
191195
localBranchs,
192196
}
@@ -215,7 +219,7 @@ export default class Deploy extends Model {
215219
await git.branch({ fs, dir: this.outputDir, ref: setting.branch })
216220
}
217221

218-
await git.checkout({ fs, dir: this.outputDir, ref: setting.branch })
222+
await git.fastCheckout({ fs, dir: this.outputDir, ref: setting.branch })
219223
}
220224
}
221225
}

src/store/modules/site.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const siteState: Site = {
5454
branch: '',
5555
username: '',
5656
email: '',
57+
tokenUsername: '',
5758
token: '',
5859
cname: '',
5960
port: '22',

src/views/setting/includes/BasicSetting.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<a-form :form="form" style="padding-bottom: 48px;">
4-
<a-form-item label="Platform" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
4+
<a-form-item :label="$t('platform')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
55
<a-radio-group name="platform" v-model="form.platform">
66
<a-radio value="github">Github Pages</a-radio>
77
<a-radio value="coding">Coding Pages</a-radio>
@@ -24,7 +24,10 @@
2424
<a-form-item :label="$t('email')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
2525
<a-input v-model="form.email" />
2626
</a-form-item>
27-
<a-form-item label="Token" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
27+
<a-form-item v-if="form.platform === 'coding'" :label="$t('tokenUsername')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
28+
<a-input v-model="form.tokenUsername" />
29+
</a-form-item>
30+
<a-form-item :label="$t('token')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
2831
<a-input :type="passVisible ? '' : 'password'" v-model="form.token">
2932
<a-icon class="icon" slot="addonAfter" :type="passVisible ? 'eye-invisible' : 'eye'" @click="passVisible = !passVisible" />
3033
</a-input>
@@ -97,6 +100,7 @@ export default class BasicSetting extends Vue {
97100
branch: '',
98101
username: '',
99102
email: '',
103+
tokenUsername: '',
100104
token: '',
101105
cname: '',
102106
port: '22',
@@ -108,12 +112,12 @@ export default class BasicSetting extends Vue {
108112
109113
get canSubmit() {
110114
const { form } = this
111-
const pagesPlatfomValid = ['github', 'coding'].includes(form.platform)
112-
&& form.domain
115+
const baseValid = form.domain
113116
&& form.repository
114117
&& form.branch
115118
&& form.username
116119
&& form.token
120+
const pagesPlatfomValid = baseValid && (form.platform === 'github' || (form.platform === 'coding' && form.tokenUsername))
117121
118122
const sftpPlatformValid = ['sftp'].includes(form.platform)
119123
&& form.port

yarn.lock

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5171,6 +5171,11 @@ globalthis@^1.0.0:
51715171
function-bind "^1.1.1"
51725172
object-keys "^1.0.12"
51735173

5174+
globalyzer@^0.1.4:
5175+
version "0.1.4"
5176+
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
5177+
integrity sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==
5178+
51745179
globby@^6.1.0:
51755180
version "6.1.0"
51765181
resolved "http://registry.npm.taobao.org/globby/download/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c"
@@ -5206,6 +5211,11 @@ globby@^9.2.0:
52065211
pify "^4.0.1"
52075212
slash "^2.0.0"
52085213

5214+
globrex@^0.1.2:
5215+
version "0.1.2"
5216+
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
5217+
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
5218+
52095219
good-listener@^1.2.2:
52105220
version "1.2.2"
52115221
resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50"
@@ -6108,16 +6118,18 @@ isobject@^3.0.0, isobject@^3.0.1:
61086118
version "3.0.1"
61096119
resolved "http://registry.npm.taobao.org/isobject/download/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
61106120

6111-
isomorphic-git@1.0.0-beta.19:
6112-
version "1.0.0-beta.19"
6113-
resolved "https://registry.yarnpkg.com/isomorphic-git/-/isomorphic-git-1.0.0-beta.19.tgz#421f0ae9de00c3ff967726f8eb5a0602929110ad"
6114-
integrity sha512-kJPF9R0HUdJmZcRWyYDH0ac2U3fCggScpU1Yn9kMZH8z+QEcNkCARPwH+bAKhaAYIQeb1ln3hufrGpAm/Ba8Gg==
6121+
isomorphic-git@^0.78.3:
6122+
version "0.78.3"
6123+
resolved "https://registry.yarnpkg.com/isomorphic-git/-/isomorphic-git-0.78.3.tgz#563d60f5f73868ba13701a33047fe356bacdca1f"
6124+
integrity sha512-3c8uqIg9tBBXFwypdlIo7yPM1x3uc7mNt4qbUvG2NPt8QYN1OFWo0MDNgHYfRIQWsgd8aux/qC3QnKyVqaq0TQ==
61156125
dependencies:
61166126
async-lock "^1.1.0"
61176127
clean-git-ref "^2.0.1"
61186128
crc-32 "^1.2.0"
61196129
diff3 "0.0.3"
61206130
git-apply-delta "0.0.7"
6131+
globalyzer "^0.1.4"
6132+
globrex "^0.1.2"
61216133
ignore "^5.1.4"
61226134
marky "^1.2.1"
61236135
minimisted "^2.0.0"

0 commit comments

Comments
 (0)