Skip to content
Permalink
Browse files

fix coding setting & git setting

  • Loading branch information
EryouHao committed Feb 9, 2020
1 parent 7d2ffc6 commit b3e58b0791a276779fdc17c232bcd94330f5457a
@@ -33,7 +33,7 @@
"feed": "^2.0.4",
"fs-extra": "^7.0.1",
"gray-matter": "^4.0.1",
"isomorphic-git": "1.0.0-beta.19",
"isomorphic-git": "^0.78.3",
"junk": "^3.1.0",
"less": "^3.9.0",
"lowdb": "^1.0.0",
@@ -77,7 +77,7 @@ const message = {
remotePathTip: '请填写绝对路径,例如:/home/username/www/',
testConnection: '检测远程连接',
connectSuccess: '远程连接成功',
connectFailed: '远程连接失败,请检查仓库、用户名和 Token 设置',
connectFailed: '远程连接失败,请检查仓库、用户名和令牌设置',
sourceFolder: '站点源文件路径',
language: '语 言',
inConfig: '配置中',
@@ -108,6 +108,9 @@ const message = {
words: '字 数',
readingTime: '阅读时间',
version: '版本',
token: '令牌',
tokenUsername: '令牌用户名',
platform: '平台',
},
zh_TW: {
preview: '預 覽',
@@ -188,7 +191,7 @@ const message = {
remotePathTip: '請填寫絕對路徑,例如:/home/username/www/',
testConnection: '檢測遠程連接',
connectSuccess: '遠程連接成功',
connectFailed: '遠程連接失敗,請檢查倉庫、用戶名和 Token 設置',
connectFailed: '遠程連接失敗,請檢查倉庫、用戶名和令牌設置',
sourceFolder: '站点源文件路径',
language: '語 言',
inConfig: '配置中',
@@ -219,6 +222,9 @@ const message = {
words: '字 數',
readingTime: '閱讀時間',
version: '版本',
token: '令牌',
tokenUsername: '令牌用户名',
platform: '平臺',
},
en: {
preview: 'Preview',
@@ -329,6 +335,9 @@ const message = {
words: 'Words',
readingTime: 'Reading time',
version: 'Version',
token: 'Token',
tokenUsername: 'Token Username',
platform: 'Platform',
},
}

@@ -5,6 +5,7 @@ export interface ISetting {
branch: string
username: string
email: string
tokenUsername: string
token: string
cname: string
port: string
@@ -70,6 +70,7 @@ export default class App {
branch: '',
username: '',
email: '',
tokenUsername: '',
token: '',
cname: '',
port: '22',
@@ -1,11 +1,9 @@
import fs from 'fs'
import moment from 'moment'
// @ts-ignore
import * as git from 'isomorphic-git/dist'
import * as git from 'isomorphic-git/dist/for-node/isomorphic-git'
import Model from './model'

const { http } = require('isomorphic-git/dist/http')

export default class Deploy extends Model {
outputDir: string = `${this.appDir}/output`

@@ -19,9 +17,14 @@ export default class Deploy extends Model {
const { setting } = this.db
this.platformAddress = ({
github: 'github.com',
coding: 'git.coding.net',
coding: 'e.coding.net',
} as any)[setting.platform || 'github']
const preUrl = ({
github: `${setting.username}:${setting.token}`,
coding: `${setting.tokenUsername}:${setting.token}`,
} as any)[setting.platform || 'github']
this.remoteUrl = `https://${setting.username}:${setting.token}@${this.platformAddress}/${setting.username}/${setting.repository}.git`

this.remoteUrl = `https://${preUrl}@${this.platformAddress}/${setting.username}/${setting.repository}.git`
}

/**
@@ -50,13 +53,13 @@ export default class Deploy extends Model {
}
if (!isRepo) {
await git.init({ fs, dir: this.outputDir })
await git.setConfig({
await git.config({
fs,
dir: this.outputDir,
path: 'user.name',
value: setting.username,
})
await git.setConfig({
await git.config({
fs,
dir: this.outputDir,
path: 'user.email',
@@ -67,7 +70,10 @@ export default class Deploy extends Model {
await git.addRemote({
fs, dir: this.outputDir, remote: 'origin', url: this.remoteUrl, force: true,
})
await git.listRemotes({ fs, dir: this.outputDir })
const info = await git.getRemoteInfo({
core: 'default',
url: this.remoteUrl,
})
} catch (e) {
console.log('Test Remote Error: ', e.message)
result.success = false
@@ -105,13 +111,13 @@ export default class Deploy extends Model {

try {
await git.init({ fs, dir: this.outputDir })
await git.setConfig({
await git.config({
fs,
dir: this.outputDir,
path: 'user.name',
value: setting.username,
})
await git.setConfig({
await git.config({
fs,
dir: this.outputDir,
path: 'user.email',
@@ -126,19 +132,18 @@ export default class Deploy extends Model {
await git.addRemote({
fs, dir: this.outputDir, remote: 'origin', url: this.remoteUrl, force: true,
})
// await git.fastCheckout({ fs, dir: this.outputDir, ref: setting.branch })

await this.checkCurrentBranch()
// const pushRes = await git.push({
// fs,
// dir: this.outputDir,
// remote: 'origin',
// ref: setting.branch,
// force: true,
// http,
// })
const pushRes = await git.push({
fs,
dir: this.outputDir,
remote: 'origin',
ref: setting.branch,
force: true,
})
return {
success: true,
// data: pushRes,
data: pushRes,
message: '',
localBranchs,
}
@@ -175,18 +180,17 @@ export default class Deploy extends Model {

await this.checkCurrentBranch()

// const pushRes = await git.push({
// fs,
// dir: this.outputDir,
// remote: 'origin',
// ref: setting.branch,
// force: true,
// http,
// })
// console.log('pushRes', pushRes)
const pushRes = await git.push({
fs,
dir: this.outputDir,
remote: 'origin',
ref: setting.branch,
force: true,
})
console.log('pushRes', pushRes)
return {
success: true,
// data: pushRes,
data: pushRes,
message: '',
localBranchs,
}
@@ -215,7 +219,7 @@ export default class Deploy extends Model {
await git.branch({ fs, dir: this.outputDir, ref: setting.branch })
}

await git.checkout({ fs, dir: this.outputDir, ref: setting.branch })
await git.fastCheckout({ fs, dir: this.outputDir, ref: setting.branch })
}
}
}
@@ -54,6 +54,7 @@ const siteState: Site = {
branch: '',
username: '',
email: '',
tokenUsername: '',
token: '',
cname: '',
port: '22',
@@ -1,7 +1,7 @@
<template>
<div>
<a-form :form="form" style="padding-bottom: 48px;">
<a-form-item label="Platform" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-form-item :label="$t('platform')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-radio-group name="platform" v-model="form.platform">
<a-radio value="github">Github Pages</a-radio>
<a-radio value="coding">Coding Pages</a-radio>
@@ -24,7 +24,10 @@
<a-form-item :label="$t('email')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-input v-model="form.email" />
</a-form-item>
<a-form-item label="Token" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-form-item v-if="form.platform === 'coding'" :label="$t('tokenUsername')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-input v-model="form.tokenUsername" />
</a-form-item>
<a-form-item :label="$t('token')" :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-input :type="passVisible ? '' : 'password'" v-model="form.token">
<a-icon class="icon" slot="addonAfter" :type="passVisible ? 'eye-invisible' : 'eye'" @click="passVisible = !passVisible" />
</a-input>
@@ -97,6 +100,7 @@ export default class BasicSetting extends Vue {
branch: '',
username: '',
email: '',
tokenUsername: '',
token: '',
cname: '',
port: '22',
@@ -108,12 +112,12 @@ export default class BasicSetting extends Vue {
get canSubmit() {
const { form } = this
const pagesPlatfomValid = ['github', 'coding'].includes(form.platform)
&& form.domain
const baseValid = form.domain
&& form.repository
&& form.branch
&& form.username
&& form.token
const pagesPlatfomValid = baseValid && (form.platform === 'github' || (form.platform === 'coding' && form.tokenUsername))
const sftpPlatformValid = ['sftp'].includes(form.platform)
&& form.port
@@ -5171,6 +5171,11 @@ globalthis@^1.0.0:
function-bind "^1.1.1"
object-keys "^1.0.12"

globalyzer@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
integrity sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==

globby@^6.1.0:
version "6.1.0"
resolved "http://registry.npm.taobao.org/globby/download/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c"
@@ -5206,6 +5211,11 @@ globby@^9.2.0:
pify "^4.0.1"
slash "^2.0.0"

globrex@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==

good-listener@^1.2.2:
version "1.2.2"
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:
version "3.0.1"
resolved "http://registry.npm.taobao.org/isobject/download/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"

isomorphic-git@1.0.0-beta.19:
version "1.0.0-beta.19"
resolved "https://registry.yarnpkg.com/isomorphic-git/-/isomorphic-git-1.0.0-beta.19.tgz#421f0ae9de00c3ff967726f8eb5a0602929110ad"
integrity sha512-kJPF9R0HUdJmZcRWyYDH0ac2U3fCggScpU1Yn9kMZH8z+QEcNkCARPwH+bAKhaAYIQeb1ln3hufrGpAm/Ba8Gg==
isomorphic-git@^0.78.3:
version "0.78.3"
resolved "https://registry.yarnpkg.com/isomorphic-git/-/isomorphic-git-0.78.3.tgz#563d60f5f73868ba13701a33047fe356bacdca1f"
integrity sha512-3c8uqIg9tBBXFwypdlIo7yPM1x3uc7mNt4qbUvG2NPt8QYN1OFWo0MDNgHYfRIQWsgd8aux/qC3QnKyVqaq0TQ==
dependencies:
async-lock "^1.1.0"
clean-git-ref "^2.0.1"
crc-32 "^1.2.0"
diff3 "0.0.3"
git-apply-delta "0.0.7"
globalyzer "^0.1.4"
globrex "^0.1.2"
ignore "^5.1.4"
marky "^1.2.1"
minimisted "^2.0.0"

0 comments on commit b3e58b0

Please sign in to comment.
You can’t perform that action at this time.