!33 Fix the problem that the plug-in cannot be used

Merge pull request !33 from Joey/master
This commit is contained in:
openharmony_sig_ci 2022-02-22 10:51:37 +00:00 committed by Gitee
commit cd5ea36a08
11 changed files with 22 additions and 14 deletions

View File

@ -1,7 +1,7 @@
## 可执行文件开发说明
1.安装typescript在napi_generator目录下执行命令npm i typescript
1.安装typescript在napi_generator目录下和napi_generator/src目录下分别都执行命令npm i typescript
2.安装stdio在napi_generator目录下执行命令npm i stdio

View File

@ -131,13 +131,13 @@ visual studio code 版本需1.62.0及以上
![](figures/pic-plug-in-gnapi.png)
4) 在vscode中找到需要转换的.d.ts文件例如
4) 在vscode中找到需要转换的.d.ts文件并且检查需要转换的d.ts文件中是否声明了import的d.ts文件如果存在需要将import的d.ts文件也放入到待转换的d.ts文件相同的目录下例如
![](figures/pic-plug-in-select-d-ts.png)
5) 鼠标在.d.ts上点击右键选择.d.ts生成c++选项。
![](figures/pic-plug-in-gen.png)
![](figures/pic-plug-in-gen-c++.png)
6) 之后就会在该目录下生成对应文件,例如:

BIN
figures/pic-plug-in-gen-c++.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -23,7 +23,7 @@
"bin": "./src/gen/cmd_gen.js",
"pkg": {
"assets": [
"node_modules/typescript/**/*"
"src/node_modules/typescript/**/*"
]
}
}

BIN
prebuilt/gnapi-0.0.1.vsix Normal file → Executable file

Binary file not shown.

View File

@ -17,6 +17,8 @@
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const xgen = require('./gen/main');
const path = require("path");
const { CheckFileError } = require("./gen/tools/common");
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
@ -32,9 +34,15 @@ function activate(context) {
let disposable = vscode.commands.registerCommand('generate_napi', function (uri) {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
vscode.window.showInformationMessage("正在生成" + uri.fsPath);
xgen.doGenerate(uri.fsPath);
vscode.window.showInformationMessage("生成成功");
let result = CheckFileError(uri.fsPath);
if (result[0]) {
vscode.window.showInformationMessage("正在生成" + uri.fsPath);
xgen.doGenerate(uri.fsPath, path.dirname(uri.fsPath));
vscode.window.showInformationMessage("生成成功");
}
else {
vscode.window.showErrorMessage("" + result[1]);
}
});
context.subscriptions.push(disposable);

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
const re = require("./re");
const tsc = require("../../../node_modules/typescript");
const tsc = require("../../node_modules/typescript");
function checkFileError(ifname) {
let program = tsc.createProgram([ifname], {})

View File

@ -32,10 +32,7 @@
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "node ./test/runTest.js",
"vscode:prepublish": "webpack --mode production",
"compile": "webpack --mode none",
"watch": "webpack --mode none --watch"
"test": "node ./test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.4",
@ -46,8 +43,11 @@
"eslint": "^8.1.0",
"glob": "^7.1.7",
"mocha": "^9.1.3",
"typescript": "^4.4.4",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"typescript": "^4.5.5",
"vsce": "^2.6.7"
}
}
}