diff --git a/dev_tools/scripts/generateKeys.js.map b/dev_tools/scripts/generateKeys.js.map deleted file mode 100644 index 80d9e1c..0000000 --- a/dev_tools/scripts/generateKeys.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"generateKeys.js","sourceRoot":"","sources":["generateKeys.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,2CAA6B;AAC7B,uCAAyB;AACzB,2CAA6B;AAE7B,wBAAwB;AACxB,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC,CAAC;AACvF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,uBAAuB,CAAC,CAAC;AACrF,IAAI,uBAAuB,GAAyB,IAAI,MAAM,CAAC;AAC/D,IAAI,uBAAuB,GAA2B,IAAI,MAAM,CAAC;AAEjE,KAAK,UAAU,wBAAwB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACtC,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAChB,IAAI,IAAI,KAAG,WAAW,EAAE;gBACpB,cAAc;gBACd,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,mBAAmB;gBAE7D,aAAa;gBACb,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;gBAEvC,UAAU;gBACV,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;oB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aAAa,CAAC,CAAC;IAExC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,EAAE,CAAC,aAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChG,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAChG;KACI;IACD,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;CACrC"} \ No newline at end of file diff --git a/dev_tools/scripts/generateKeys.js b/devlop_tools/generateKeys.js similarity index 100% rename from dev_tools/scripts/generateKeys.js rename to devlop_tools/generateKeys.js diff --git a/devlop_tools/generateKeys.js.map b/devlop_tools/generateKeys.js.map new file mode 100644 index 0000000..0f22984 --- /dev/null +++ b/devlop_tools/generateKeys.js.map @@ -0,0 +1 @@ +{"version":3,"file":"generateKeys.js","sourceRoot":"","sources":["generateKeys.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,2CAA6B;AAC7B,uCAAyB;AACzB,2CAA6B;AAE7B,wBAAwB;AACxB,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC,CAAC;AACvF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,uBAAuB,CAAC,CAAC;AACrF,IAAI,uBAAuB,GAAyB,IAAI,MAAM,CAAC;AAC/D,IAAI,uBAAuB,GAA2B,IAAI,MAAM,CAAC;AAEjE,KAAK,UAAU,wBAAwB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,K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Q,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;4BAC/B,uBAAuB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;wBAE5D,CAAC;oBACL,CAAC;oBACD,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;gBACtE,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7B,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU;QAClD,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,aAAa,GAAU,EAAE,CAAC,CAAA,cAAc;AAE9C,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAC3B,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC7B,wBAAwB,CAAC,aAAa,CAAC,CAAC;IAExC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,EAAE,CAAC,aAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChG,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACjG,CAAC;KACI,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACtC,CAAC"} \ No newline at end of file diff --git a/dev_tools/scripts/generateKeys.ts b/devlop_tools/generateKeys.ts similarity index 100% rename from dev_tools/scripts/generateKeys.ts rename to devlop_tools/generateKeys.ts diff --git a/package-lock.json b/package-lock.json index b7a6580..16524f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "y3-helper", - "version": "0.1.3", + "version": "0.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "y3-helper", - "version": "0.1.3", + "version": "0.1.4", "dependencies": { "@types/uuid": "^9.0.8", "csv-parser": "^3.0.0", diff --git a/src/CSVimporter.ts b/src/CSVimporter.ts index c710ae4..bce083d 100644 --- a/src/CSVimporter.ts +++ b/src/CSVimporter.ts @@ -380,7 +380,7 @@ export class CSVimporter i++; }) .on('end', () => { - vscode.window.showInformationMessage("全部导入成功"); + vscode.window.showInformationMessage("全部成功"); ; console.log('Parsed CSV data Length:', i); }) .on('error', (error) => { diff --git a/src/templateGenerator.ts b/src/templateGenerator.ts index 272a6d0..00b67db 100644 --- a/src/templateGenerator.ts +++ b/src/templateGenerator.ts @@ -2,13 +2,38 @@ import * as vscode from 'vscode'; const fs = require('fs-extra'); import { Env } from './env'; import * as path from 'path'; +import { isInDirectory, isFileValid, isPathValid, removeSpacesAndNewlines, toUnicodeIgnoreASCII } from './utility'; export class TemplateGenerator{ private env: Env; public constructor(env: Env) { this.env = env; } + + public static async askUserTargetUri(): Promise { + + // 询问用户得到目标文件夹 + while (true) { + let selectedFiles = await vscode.window.showOpenDialog({ + canSelectFolders: true, + openLabel: '选择文件夹' + }); + let selectedExe = selectedFiles?.[0]; + if (!selectedExe) { + return undefined; + } + if (await isPathValid(selectedExe.fsPath)) { + return selectedExe; + } + } + } - private copyTemplateToTargetPath(templateType: string, targetPath: vscode.Uri): boolean{ + /** + * 选择类型,生成CSV文件模板 + * @param templateType 模板种类 + * @param targetPath 目标路径 + * @returns true or false 生成成功或失败 + */ + public generateTemplateCSVToTargetPath(templateType: string, targetPath: vscode.Uri): boolean{ try { fs.copy(path.join(path.join(__dirname, "../csv_template"), templateType), targetPath.fsPath); } diff --git a/tsconfig.json b/tsconfig.json index 6954702..4261ec3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,8 @@ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ - } + }, + "include": [ + "devlop_tools/*.ts" + ] }