diff --git a/.env b/.env deleted file mode 100644 index e69de29..0000000 diff --git a/.env.production b/.env.production deleted file mode 100644 index fe2f4f8..0000000 --- a/.env.production +++ /dev/null @@ -1 +0,0 @@ -NODE_ENV = production \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index 2458a95..8d12b89 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-25 15:15:42 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-27 13:27:08 + * LastEditTime : 2019-12-31 16:29:11 * FilePath : /autoCommit/src/extension.ts * Description : 自动commit插件 入口 * https://github.com/OBKoro1 @@ -16,7 +16,6 @@ import { setExtensionContext } from './util/vscodeUtil' // 扩展激活 默认运行 export function activate(context: vscode.ExtensionContext) { setExtensionContext(context) - const autoCommit = vscode.commands.registerCommand('extension.autoCommit', () => { new ExtensionLogic(context) }) diff --git a/src/models/WebView.ts b/src/models/WebView.ts index e030c2c..853de39 100644 --- a/src/models/WebView.ts +++ b/src/models/WebView.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-26 13:49:02 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-30 20:10:46 + * LastEditTime : 2019-12-31 16:43:30 * FilePath : /autoCommit/src/models/WebView.ts * Description : 创建webview * https://github.com/OBKoro1 @@ -11,7 +11,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; import * as fs from 'fs'; -import { showMessage } from '../util/vscodeUtil'; +import { showMessage, isProduction } from '../util/vscodeUtil'; import { webviewMsg } from '../util/dataStatement'; // webview 设置 @@ -35,8 +35,7 @@ class WebView { column: vscode.ViewColumn = vscode.ViewColumn.One ) { // 获取资源地址 - // TODO: 打包 - const srcPath = process.env.NODE_ENV !== 'production' ? 'src' : 'dist'; + const srcPath = isProduction() ? 'out' : 'src'; this.currentPanel = vscode.window.createWebviewPanel( WebviewPanelOption.type, WebviewPanelOption.title, @@ -111,9 +110,9 @@ class WebView { * @param command * @param message */ - public postMessage(command: string, data: object) { - if (!this.currentPanel) return - this.currentPanel.webview.postMessage({ command, data }) + public postMessage(command: string, data: any) { + if (!this.currentPanel) return; + this.currentPanel.webview.postMessage({ command, data }); } } diff --git a/src/models/commitHandle.ts b/src/models/commitHandle.ts index cce6d78..26a8fbe 100644 --- a/src/models/commitHandle.ts +++ b/src/models/commitHandle.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-30 16:59:30 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-30 20:21:13 + * LastEditTime : 2019-12-31 18:00:43 * FilePath : /autoCommit/src/models/commitHandle.ts * Description : commit 具体操作 * https://github.com/OBKoro1 @@ -37,6 +37,15 @@ class CommitHandle { detailTimeArr = detailTimeArr.filter(ele => { return !this.timeArr.includes(ele); }); + // TODO: commit number + // if(){ + + // } + // detailTimeArr.map(element=>{ + // return { + // time: element + // } + // }) this.timeArr.push(...detailTimeArr); }); this.sortTime(); diff --git a/src/models/index.ts b/src/models/index.ts index e835609..f2e4be2 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-25 17:08:18 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-30 21:02:57 + * LastEditTime : 2019-12-31 16:42:46 * FilePath : /autoCommit/src/models/index.ts * Description : 插件逻辑入口 * https://github.com/OBKoro1 @@ -10,7 +10,7 @@ import * as vscode from 'vscode'; import WebView from './WebView'; import { webviewMsg } from '../util/dataStatement'; -import { setPanelWebview } from '../util/vscodeUtil'; +import { setPanelWebview, isProduction } from '../util/vscodeUtil'; import CommitHandle from './commitHandle'; import { outputLog } from '../util/vscodeUtil'; import * as fs from 'fs'; @@ -20,6 +20,7 @@ class ExtensionLogic { public MessageCallBack: any; public autoCommitView: WebView; public CommitHandle: any; + public isDebug: boolean; public constructor(context: vscode.ExtensionContext) { this.context = context; @@ -27,6 +28,7 @@ class ExtensionLogic { this.context, this.messageCallBack.bind(this) ); + this.isDebug = true; setPanelWebview(this.autoCommitView); this.createView(); } @@ -37,6 +39,7 @@ class ExtensionLogic { fileName: 'autoCommit' }; this.autoCommitView.create(option); + this.autoCommitView.postMessage('isProduction', isProduction()); } // 处理webview的消息 private messageCallBack(message: webviewMsg) { @@ -52,10 +55,12 @@ class ExtensionLogic { canSelectFolders: true, // 是否可以选择文件夹 canSelectMany: false // 是否可以选择多个文件 }); + if (!urlArr) return; // 用户取消选择 const itemSrc = urlArr[0].path; if (this.hasGit(itemSrc)) { this.autoCommitView.postMessage('choose item success', itemSrc); } else { + this.autoCommitView.postMessage('choose item error', itemSrc); outputLog('项目地址错误', `${itemSrc}根目录没有.git文件夹`); } } diff --git a/src/util/vscodeUtil.ts b/src/util/vscodeUtil.ts index f6e2569..aaa3d8d 100644 --- a/src/util/vscodeUtil.ts +++ b/src/util/vscodeUtil.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-25 17:13:30 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-30 21:10:57 + * LastEditTime : 2019-12-31 16:36:12 * FilePath : /autoCommit/src/util/vscodeUtil.ts * Description : vscode 相关的公共方法 * https://github.com/OBKoro1 @@ -38,6 +38,11 @@ function outputLog(...arr: any) { webview.postMessage('console-log', arr); } +// 是否生产环境 +function isProduction() { + return process.env.NODE_ENV === 'production' // production时 为打包安装版本 +} + // vscode 消息通知 function showMessage(message: string, type = 'error') { const actions: any = { @@ -56,6 +61,7 @@ function showMessage(message: string, type = 'error') { } export { + isProduction, // 是否生产环境 outputLog, // 打印日志 getPanelWebview, // 获取webview setPanelWebview, // 存储webview diff --git a/src/views/autoCommit.html b/src/views/autoCommit.html index eab8264..d0af5a8 100644 --- a/src/views/autoCommit.html +++ b/src/views/autoCommit.html @@ -13,6 +13,7 @@