diff --git a/napi_tool/.idea/.gitignore b/.idea/.gitignore similarity index 100% rename from napi_tool/.idea/.gitignore rename to .idea/.gitignore diff --git a/napi_tool/.idea/misc.xml b/.idea/misc.xml similarity index 100% rename from napi_tool/.idea/misc.xml rename to .idea/misc.xml diff --git a/napi_tool/.idea/modules.xml b/.idea/modules.xml similarity index 100% rename from napi_tool/.idea/modules.xml rename to .idea/modules.xml diff --git a/napi_tool/.idea/napi_tool.iml b/.idea/napi_tool.iml similarity index 100% rename from napi_tool/.idea/napi_tool.iml rename to .idea/napi_tool.iml diff --git a/napi_tool/.idea/vcs.xml b/.idea/vcs.xml similarity index 100% rename from napi_tool/.idea/vcs.xml rename to .idea/vcs.xml diff --git a/napi_tool/LICENSE b/LICENSE similarity index 100% rename from napi_tool/LICENSE rename to LICENSE diff --git a/napi_tool/OAT.xml b/OAT.xml similarity index 100% rename from napi_tool/OAT.xml rename to OAT.xml diff --git a/README.md b/README.md index 29572fb9..f4826c02 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,148 @@ -# assist_tools - -#### Description -This warehouse is used to incubate the assist tools of openharmony system, so that developers can improve development efficiency.Currently NAPI framework code generation tool has been implemented.Other similar tools can be incubated in this warehouse. - -#### Directory Structure -``` -/assist_tools/ -├── napi_tool # NAPI framework code generation tool -│ ├── doc # Current capability and version planning -│ ├── image # image resource -│ ├── output # Executable program and plug-in program corresponding to the tool -│ ├── code # Source code of tool -│ └── README # Instructions of tool -└──README -``` - -#### Repositories Involved -no +# napi_tool + +## Introduction +This paper mainly introduces the NAPi framework code generation tool, which can generate NAPi framework code, business code framework and designed.the GN file according to the TS interface file in the path specified by the user. So developers need to focus on Nodejs related grammar framework layer, interface between c + + with JS type conversion, data type conversion, etc.. This tool is mainly used in the scenario of JS application calling NaPi interface, can focus on business logic implementation, Thus, the development efficiency can be greatly improved. Currently, the tool supports command line and VScode plug-in. + +## Software architecture +![](figures/pic-frm-en.png) + +## Directory Structure + +``` +├── napi_tool # NAPI framework code generation tool +│ ├── docs # Plan the current tool capabilities and versions +│ ├── figures # Image resource file +│ ├── code # Tool source +| | ├── tool_code # Tool source +│ | ├── gen +│ | |── analyze # Parser +│ │ |── extend # Extension module, including GN file generation, Linux environment adaptation code, etc +│ │ |── generate # Generator +│ │ └── tools # Public module code, including message body check, file read and write, regular expression +│ | └── test # Plug-in test cases +| | └──ts_test # Example ts files required by the tool +│ └── README +└──README +``` + +### code directory source code introduction +This directory is the source code corresponding to the NAPI framework code generation tool, developers can be based on this code for secondary development. + +## Software environment preparation + +System: Ubuntu 20.04 or windows 10 is recommended + +Dependent version: vscode 1.62.0 + +## Development description + +Developers can use the source code to compile and package the corresponding executable files and plug-ins for type conversion between JS and C + +. The development instructions of executable files and plug-ins are as follows: + +### Source code + +Through the command: git clone git@gitee.com :openharmony-sig/assist_ tools.git to download the corresponding source code. + +### pack + +#### Executable file development instructions +1.Install pkg :execute the command sudo npm i -g pkg + +2.Package three versions : execute the command pkg vscode_plugin/gnapi/gen/cmd_gen.js + +After performing the preceding steps,ou can generate Windows, Linux, and MAC executable programs in the Gen directory:cmd_gen-win.exe、cmd_gen-linux、cmd_gen-macos. + +#### Plug-in development Instructions +1. Install yo : execute the command npm install -g yo generator-code. + +2. Use yo : execute the command yo code,gnapi is a plug-in code framework generated by Yo Code, in which gnAPI/Gen directory is the source code of the automatic generation of NAPI program we developed. + + ![](figures/pic-gen-source-code.png) + +3. Run npm i vsce in the napi_generator/vscode_plugin/gnapi directory. + +4. Execute the command./node_modules/vsce/vsce package command,The final package generates a plugin, gnapI-0.0.1.vsix. + + ![](figures/pic-gen-vsix.png) + +## instructions + +1. Copy the Windows executable program cmd_gen-win.exe from the gen directory to the corresponding directory. You do not need to install the program. +2. Copy the Linux executable program cmd_gen-linux from the gen directory to the corresponding directory, and run it directly on the terminal. + +### Usage + +#### Windows + +1) The.d.ts files to be converted should be placed in any directory. It is recommended to put them in the same directory as the executable program cmd_gen-win.exe, for example: + +![](figures/pic-d-ts-location.png) + +2) Right-click Windows Start menu, click Run, enter CMD, and click OK. + +![](figures/pic-cmd.png) + +3) In the command line interface (CLI), go to the directory where the previous executable program cmd_gen-win.exe resides and run cmd_gen-win.exe. After cmd_gen-win.exe, the corresponding. + +![](figures/pic-cmd-execute.png) + +4) After successful operation, the corresponding file will be generated in the directory where the. D. ts file says, for example: + +![](figures/pic-d-ts-transition.png) + +#### Linux + +1) Put the.d.ts files to be converted in any directory. It is recommended to put them in the same directory as the executable program cmd_gen-linux, for example: + + ![](figures/pic-d-ts-location-linux.png) + +2) In the terminal, go to the directory where the previous executable program cmd_gen-linux resides and run cmd_gen-linux. After cmd_gen-linux, the corresponding. D. s file name, for example: + + ![](figures/pic-cmd-execute-linux.png) + +3) After successful operation, the corresponding file will be generated in the directory where the. D. ts file says, for example: + + ![](figures/pic-d-ts-transition-linux.png) + +#### Mac +Method Step For details about how to use Windows and Linux + +## Plug-in usage +### Instruction +Visual Studio Code version 1.62.0 or later + +### Steps + +1) Open vscode and select plug-in installation in the left sidebar. + + ![](figures/pic-plug-in-search.png) + +2) Click the three buttons above, select the install from VSIX option, then select the gnapI-0.0.1. VSIX plug-in file you just generated, and click Install. + + ![](figures/pic-plug-in-select.png) + +3) After installation, the gnapi plugin should be visible in vscode's plugin manager. + + ![](figures/pic-plug-in-gnapi.png) + +4) Find the.d.ts file to convert in vscode, for example: + + ![](figures/pic-plug-in-select-d-ts.png) + +5) Right click on.d.ts and select.d.ts to generate c++ options. + + ![](figures/pic-plug-in-gen-c++.png) + +6) The corresponding files will be generated in this directory, for example: + + ![](figures/pic-plug-in-gen-result.png) + +## Matters needing attention +The examples above are for Windows. The methods for Linux and MAC are similar. + +## Participate in the contribution + +Not yet. + +## Related to the storehouse + +Not yet. \ No newline at end of file diff --git a/README_ZH.md b/README_ZH.md index 8cc3b9d5..ba0ddf63 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,23 +1,147 @@ -# assist_tools - -#### 仓名 - assist_tools -#### 简介 -此仓用于孵化OpenHarmony系统的辅助工具,以便开发者提升开发效率。当前已实现的工具有NAPI框架代码生成工具,后续其他类似工具均可在此仓孵化。 - -#### 目录 -``` -/assist_tools/ -├── napi_tool # NAPI框架代码生成工具 -│ ├── doc # 工具当前能力、版本规划 -│ ├── image # 图片资源文件 -│ ├── output # 工具对应的可执行程序与插件程序 -│ ├── code # 工具源码 -│ └── README # 工具使用指导 -└──README -``` - -#### 相关仓 -无 - - +# napi_tool + +## 概述 +本文主要介绍NAPI框架代码生成工具,它可以根据用户指定路径下的ts接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。在开发JS应用与NAPI间接口时,底层框架开发者无需关注Nodejs语法、C++与JS之间的数据类型转换等上层应用转换逻辑,只关注底层业务逻辑即可,专业的人做专业的事,从而可以大大提高开发效率。目前工具支持命令行、VScode插件两种入口。 + +## 软件架构 +![](figures/pic-frm.png) + +## 目录 + +``` +├── napi_tool # NAPI框架代码生成工具 +│ ├── docs # 工具当前能力、版本规划 +│ ├── figures # 图片资源文件 +│ ├── code # 工具源码 +| | ├── tool_code # 工具源码 +│ | ├── gen +│ | |── analyze # 解析器 +│ │ |── extend # 扩展模块,包括gn文件生成、linux环境适配代码等 +│ │ |── generate # 生成器 +│ │ └── tools # 公共模块代码,包括消息体校验、文件读写、正则表达式转换等 +│ | └── test # 插件测试用例 +| | └──ts_test # 工具需要的ts文件样例 +│ └── README # 工具使用指导 +└──README +``` +### code目录源码介绍 +此目录为NAPI框架代码生成工具对应的源码,开发者可基于此代码进行二次开发。 + +## 软件环境准备 + +系统:建议Ubuntu 20.04或者Windows 10 + +依赖版本:vscode 1.62.0 + +## 开发说明 + +开发者可以利用源码来编译打包生成对应的可执行文件和插件,用于在JS和c++之间进行类型转换。可执行文件和插件的开发说明如下: + +### 源码 + +通过命令:git clone git@gitee.com:openharmony-sig/assist_tools.git 下载对应的源码。 + +### 打包 + +#### 可执行文件开发说明 +1.安装pkg : 执行命令sudo npm i -g pkg + +2.打包三个版本 : 执行命令pkg vscode_plugin/gnapi/gen/cmd_gen.js + +执行以上步骤后,即可在gen目录下生成Windows、linux、mac系统下的可执行程序:cmd_gen-win.exe、cmd_gen-linux、cmd_gen-macos。 + +#### 插件开发说明 +1. 安装yo : 执行命令npm install -g yo generator-code。 + +2. 使用yo : 执行命令yo code,gnapi是使用yo code生成的插件代码框架,其中gnapi/gen目录下是我们开发的自动化生成napi程序的源代码。 + + ![](figures/pic-gen-source-code.png) + +3. 在napi_generator/vscode_plugin/gnapi这个目录中执行命令npm i vsce。 + +4. 执行命令./node_modules/vsce/vsce package命令,最终会打包生成一个插件gnapi-0.0.1.vsix。 + + ![](figures/pic-gen-vsix.png) + +## 使用说明 + +1. 将gen目录下Windows可执行程序cmd_gen-win.exe拷贝到对应目录下,不需要安装,可以在cmd命令行中直接运行。 +2. 将gen目录下Linux可执行程序cmd_gen-linux拷贝到对应目录下,可以在终端下直接运行。 + +### 可执行程序使用方法 + +#### Windows + +1) 将要转换的.d.ts文件放到任意目录下,建议放到可执行程序cmd_gen-win.exe同级目录下,例如: + +![](figures/pic-d-ts-location.png) + +2) 右键windows开始菜单,点击运行,输入cmd,点击确定。 + +![](figures/pic-cmd.png) + +3) 在命令行中进入到之前可执行程序cmd_gen-win.exe所在的目录,并运行cmd_gen-win.exe,在cmd_gen-win.exe后面要对应的.d.ts文件名,例如: + +![](figures/pic-cmd-execute.png) + +4) 运行成功后会在.d.ts文件说在的目录下生成对应的文件,例如: + +![](figures/pic-d-ts-transition.png) + +#### Linux + +1) 将要转换的.d.ts文件放到任意目录下,建议放到可执行程序cmd_gen-linux同级目录下,例如: + + ![](figures/pic-d-ts-location-linux.png) + +2) 在终端中进入到之前可执行程序cmd_gen-linux所在的目录,并运行cmd_gen-linux,在cmd_gen-linux后面要对应的.d.ts文件名,例如: + + ![](figures/pic-cmd-execute-linux.png) + +3) 运行成功后会在.d.ts文件说在的目录下生成对应的文件,例如: + + ![](figures/pic-d-ts-transition-linux.png) + +#### Mac +方法步骤参考windows、Linux的使用方法 + +## 插件使用方法 +### 说明 +visual studio code 版本需1.62.0及以上 + +### 步骤 + +1) 打开vscode,在左侧边栏中选择插件安装。 + + ![](figures/pic-plug-in-search.png) + +2) 点击上面三个点的按钮,选择从VSIX安装选项,然后选择刚才生成的gnapi-0.0.1.vsix插件文件,再点击安装。 + + ![](figures/pic-plug-in-select.png) + +3) 安装完成后就会在vscode的插件管理器中能看到gnapi这个插件了。 + + ![](figures/pic-plug-in-gnapi.png) + +4) 在vscode中找到需要转换的.d.ts文件,例如: + + ![](figures/pic-plug-in-select-d-ts.png) + +5) 鼠标在.d.ts上点击右键,选择.d.ts生成c++选项。 + + ![](figures/pic-plug-in-gen-c++.png) + +6) 之后就会在该目录下生成对应文件,例如: + + ![](figures/pic-plug-in-gen-result.png) + +## 注意事项 +以上插件使用示例为windows的,linux、mac的使用方法类似。 + +## 参与贡献 + +暂无 + +## 相关仓 + +暂无 diff --git a/napi_tool/docs/开发指南.md b/docs/开发指南.md similarity index 100% rename from napi_tool/docs/开发指南.md rename to docs/开发指南.md diff --git a/napi_tool/docs/版本规划.md b/docs/版本规划.md similarity index 100% rename from napi_tool/docs/版本规划.md rename to docs/版本规划.md diff --git a/napi_tool/figures/pic-cmd-execute-linux.png b/figures/pic-cmd-execute-linux.png similarity index 100% rename from napi_tool/figures/pic-cmd-execute-linux.png rename to figures/pic-cmd-execute-linux.png diff --git a/napi_tool/figures/pic-cmd-execute.png b/figures/pic-cmd-execute.png similarity index 100% rename from napi_tool/figures/pic-cmd-execute.png rename to figures/pic-cmd-execute.png diff --git a/napi_tool/figures/pic-cmd.png b/figures/pic-cmd.png similarity index 100% rename from napi_tool/figures/pic-cmd.png rename to figures/pic-cmd.png diff --git a/napi_tool/figures/pic-d-ts-location-linux.png b/figures/pic-d-ts-location-linux.png similarity index 100% rename from napi_tool/figures/pic-d-ts-location-linux.png rename to figures/pic-d-ts-location-linux.png diff --git a/napi_tool/figures/pic-d-ts-location.png b/figures/pic-d-ts-location.png similarity index 100% rename from napi_tool/figures/pic-d-ts-location.png rename to figures/pic-d-ts-location.png diff --git a/napi_tool/figures/pic-d-ts-transition-linux.png b/figures/pic-d-ts-transition-linux.png similarity index 100% rename from napi_tool/figures/pic-d-ts-transition-linux.png rename to figures/pic-d-ts-transition-linux.png diff --git a/napi_tool/figures/pic-d-ts-transition.png b/figures/pic-d-ts-transition.png similarity index 100% rename from napi_tool/figures/pic-d-ts-transition.png rename to figures/pic-d-ts-transition.png diff --git a/napi_tool/figures/pic-frm-en.png b/figures/pic-frm-en.png similarity index 100% rename from napi_tool/figures/pic-frm-en.png rename to figures/pic-frm-en.png diff --git a/napi_tool/figures/pic-frm.png b/figures/pic-frm.png similarity index 100% rename from napi_tool/figures/pic-frm.png rename to figures/pic-frm.png diff --git a/napi_tool/figures/pic-gen-source-code.png b/figures/pic-gen-source-code.png similarity index 100% rename from napi_tool/figures/pic-gen-source-code.png rename to figures/pic-gen-source-code.png diff --git a/napi_tool/figures/pic-gen-vsix.png b/figures/pic-gen-vsix.png similarity index 100% rename from napi_tool/figures/pic-gen-vsix.png rename to figures/pic-gen-vsix.png diff --git a/napi_tool/figures/pic-plug-in-gen-c++.png b/figures/pic-plug-in-gen-c++.png similarity index 100% rename from napi_tool/figures/pic-plug-in-gen-c++.png rename to figures/pic-plug-in-gen-c++.png diff --git a/napi_tool/figures/pic-plug-in-gen-result.png b/figures/pic-plug-in-gen-result.png similarity index 100% rename from napi_tool/figures/pic-plug-in-gen-result.png rename to figures/pic-plug-in-gen-result.png diff --git a/napi_tool/figures/pic-plug-in-gnapi.png b/figures/pic-plug-in-gnapi.png similarity index 100% rename from napi_tool/figures/pic-plug-in-gnapi.png rename to figures/pic-plug-in-gnapi.png diff --git a/napi_tool/figures/pic-plug-in-search.png b/figures/pic-plug-in-search.png similarity index 100% rename from napi_tool/figures/pic-plug-in-search.png rename to figures/pic-plug-in-search.png diff --git a/napi_tool/figures/pic-plug-in-select-d-ts.png b/figures/pic-plug-in-select-d-ts.png similarity index 100% rename from napi_tool/figures/pic-plug-in-select-d-ts.png rename to figures/pic-plug-in-select-d-ts.png diff --git a/napi_tool/figures/pic-plug-in-select.png b/figures/pic-plug-in-select.png similarity index 100% rename from napi_tool/figures/pic-plug-in-select.png rename to figures/pic-plug-in-select.png diff --git a/napi_tool/README.md b/napi_tool/README.md deleted file mode 100644 index f4826c02..00000000 --- a/napi_tool/README.md +++ /dev/null @@ -1,148 +0,0 @@ -# napi_tool - -## Introduction -This paper mainly introduces the NAPi framework code generation tool, which can generate NAPi framework code, business code framework and designed.the GN file according to the TS interface file in the path specified by the user. So developers need to focus on Nodejs related grammar framework layer, interface between c + + with JS type conversion, data type conversion, etc.. This tool is mainly used in the scenario of JS application calling NaPi interface, can focus on business logic implementation, Thus, the development efficiency can be greatly improved. Currently, the tool supports command line and VScode plug-in. - -## Software architecture -![](figures/pic-frm-en.png) - -## Directory Structure - -``` -├── napi_tool # NAPI framework code generation tool -│ ├── docs # Plan the current tool capabilities and versions -│ ├── figures # Image resource file -│ ├── code # Tool source -| | ├── tool_code # Tool source -│ | ├── gen -│ | |── analyze # Parser -│ │ |── extend # Extension module, including GN file generation, Linux environment adaptation code, etc -│ │ |── generate # Generator -│ │ └── tools # Public module code, including message body check, file read and write, regular expression -│ | └── test # Plug-in test cases -| | └──ts_test # Example ts files required by the tool -│ └── README -└──README -``` - -### code directory source code introduction -This directory is the source code corresponding to the NAPI framework code generation tool, developers can be based on this code for secondary development. - -## Software environment preparation - -System: Ubuntu 20.04 or windows 10 is recommended - -Dependent version: vscode 1.62.0 - -## Development description - -Developers can use the source code to compile and package the corresponding executable files and plug-ins for type conversion between JS and C + +. The development instructions of executable files and plug-ins are as follows: - -### Source code - -Through the command: git clone git@gitee.com :openharmony-sig/assist_ tools.git to download the corresponding source code. - -### pack - -#### Executable file development instructions -1.Install pkg :execute the command sudo npm i -g pkg - -2.Package three versions : execute the command pkg vscode_plugin/gnapi/gen/cmd_gen.js - -After performing the preceding steps,ou can generate Windows, Linux, and MAC executable programs in the Gen directory:cmd_gen-win.exe、cmd_gen-linux、cmd_gen-macos. - -#### Plug-in development Instructions -1. Install yo : execute the command npm install -g yo generator-code. - -2. Use yo : execute the command yo code,gnapi is a plug-in code framework generated by Yo Code, in which gnAPI/Gen directory is the source code of the automatic generation of NAPI program we developed. - - ![](figures/pic-gen-source-code.png) - -3. Run npm i vsce in the napi_generator/vscode_plugin/gnapi directory. - -4. Execute the command./node_modules/vsce/vsce package command,The final package generates a plugin, gnapI-0.0.1.vsix. - - ![](figures/pic-gen-vsix.png) - -## instructions - -1. Copy the Windows executable program cmd_gen-win.exe from the gen directory to the corresponding directory. You do not need to install the program. -2. Copy the Linux executable program cmd_gen-linux from the gen directory to the corresponding directory, and run it directly on the terminal. - -### Usage - -#### Windows - -1) The.d.ts files to be converted should be placed in any directory. It is recommended to put them in the same directory as the executable program cmd_gen-win.exe, for example: - -![](figures/pic-d-ts-location.png) - -2) Right-click Windows Start menu, click Run, enter CMD, and click OK. - -![](figures/pic-cmd.png) - -3) In the command line interface (CLI), go to the directory where the previous executable program cmd_gen-win.exe resides and run cmd_gen-win.exe. After cmd_gen-win.exe, the corresponding. - -![](figures/pic-cmd-execute.png) - -4) After successful operation, the corresponding file will be generated in the directory where the. D. ts file says, for example: - -![](figures/pic-d-ts-transition.png) - -#### Linux - -1) Put the.d.ts files to be converted in any directory. It is recommended to put them in the same directory as the executable program cmd_gen-linux, for example: - - ![](figures/pic-d-ts-location-linux.png) - -2) In the terminal, go to the directory where the previous executable program cmd_gen-linux resides and run cmd_gen-linux. After cmd_gen-linux, the corresponding. D. s file name, for example: - - ![](figures/pic-cmd-execute-linux.png) - -3) After successful operation, the corresponding file will be generated in the directory where the. D. ts file says, for example: - - ![](figures/pic-d-ts-transition-linux.png) - -#### Mac -Method Step For details about how to use Windows and Linux - -## Plug-in usage -### Instruction -Visual Studio Code version 1.62.0 or later - -### Steps - -1) Open vscode and select plug-in installation in the left sidebar. - - ![](figures/pic-plug-in-search.png) - -2) Click the three buttons above, select the install from VSIX option, then select the gnapI-0.0.1. VSIX plug-in file you just generated, and click Install. - - ![](figures/pic-plug-in-select.png) - -3) After installation, the gnapi plugin should be visible in vscode's plugin manager. - - ![](figures/pic-plug-in-gnapi.png) - -4) Find the.d.ts file to convert in vscode, for example: - - ![](figures/pic-plug-in-select-d-ts.png) - -5) Right click on.d.ts and select.d.ts to generate c++ options. - - ![](figures/pic-plug-in-gen-c++.png) - -6) The corresponding files will be generated in this directory, for example: - - ![](figures/pic-plug-in-gen-result.png) - -## Matters needing attention -The examples above are for Windows. The methods for Linux and MAC are similar. - -## Participate in the contribution - -Not yet. - -## Related to the storehouse - -Not yet. \ No newline at end of file diff --git a/napi_tool/README_ZH.md b/napi_tool/README_ZH.md deleted file mode 100644 index ba0ddf63..00000000 --- a/napi_tool/README_ZH.md +++ /dev/null @@ -1,147 +0,0 @@ -# napi_tool - -## 概述 -本文主要介绍NAPI框架代码生成工具,它可以根据用户指定路径下的ts接口文件一键生成NAPI框架代码、业务代码框架、GN文件等。在开发JS应用与NAPI间接口时,底层框架开发者无需关注Nodejs语法、C++与JS之间的数据类型转换等上层应用转换逻辑,只关注底层业务逻辑即可,专业的人做专业的事,从而可以大大提高开发效率。目前工具支持命令行、VScode插件两种入口。 - -## 软件架构 -![](figures/pic-frm.png) - -## 目录 - -``` -├── napi_tool # NAPI框架代码生成工具 -│ ├── docs # 工具当前能力、版本规划 -│ ├── figures # 图片资源文件 -│ ├── code # 工具源码 -| | ├── tool_code # 工具源码 -│ | ├── gen -│ | |── analyze # 解析器 -│ │ |── extend # 扩展模块,包括gn文件生成、linux环境适配代码等 -│ │ |── generate # 生成器 -│ │ └── tools # 公共模块代码,包括消息体校验、文件读写、正则表达式转换等 -│ | └── test # 插件测试用例 -| | └──ts_test # 工具需要的ts文件样例 -│ └── README # 工具使用指导 -└──README -``` -### code目录源码介绍 -此目录为NAPI框架代码生成工具对应的源码,开发者可基于此代码进行二次开发。 - -## 软件环境准备 - -系统:建议Ubuntu 20.04或者Windows 10 - -依赖版本:vscode 1.62.0 - -## 开发说明 - -开发者可以利用源码来编译打包生成对应的可执行文件和插件,用于在JS和c++之间进行类型转换。可执行文件和插件的开发说明如下: - -### 源码 - -通过命令:git clone git@gitee.com:openharmony-sig/assist_tools.git 下载对应的源码。 - -### 打包 - -#### 可执行文件开发说明 -1.安装pkg : 执行命令sudo npm i -g pkg - -2.打包三个版本 : 执行命令pkg vscode_plugin/gnapi/gen/cmd_gen.js - -执行以上步骤后,即可在gen目录下生成Windows、linux、mac系统下的可执行程序:cmd_gen-win.exe、cmd_gen-linux、cmd_gen-macos。 - -#### 插件开发说明 -1. 安装yo : 执行命令npm install -g yo generator-code。 - -2. 使用yo : 执行命令yo code,gnapi是使用yo code生成的插件代码框架,其中gnapi/gen目录下是我们开发的自动化生成napi程序的源代码。 - - ![](figures/pic-gen-source-code.png) - -3. 在napi_generator/vscode_plugin/gnapi这个目录中执行命令npm i vsce。 - -4. 执行命令./node_modules/vsce/vsce package命令,最终会打包生成一个插件gnapi-0.0.1.vsix。 - - ![](figures/pic-gen-vsix.png) - -## 使用说明 - -1. 将gen目录下Windows可执行程序cmd_gen-win.exe拷贝到对应目录下,不需要安装,可以在cmd命令行中直接运行。 -2. 将gen目录下Linux可执行程序cmd_gen-linux拷贝到对应目录下,可以在终端下直接运行。 - -### 可执行程序使用方法 - -#### Windows - -1) 将要转换的.d.ts文件放到任意目录下,建议放到可执行程序cmd_gen-win.exe同级目录下,例如: - -![](figures/pic-d-ts-location.png) - -2) 右键windows开始菜单,点击运行,输入cmd,点击确定。 - -![](figures/pic-cmd.png) - -3) 在命令行中进入到之前可执行程序cmd_gen-win.exe所在的目录,并运行cmd_gen-win.exe,在cmd_gen-win.exe后面要对应的.d.ts文件名,例如: - -![](figures/pic-cmd-execute.png) - -4) 运行成功后会在.d.ts文件说在的目录下生成对应的文件,例如: - -![](figures/pic-d-ts-transition.png) - -#### Linux - -1) 将要转换的.d.ts文件放到任意目录下,建议放到可执行程序cmd_gen-linux同级目录下,例如: - - ![](figures/pic-d-ts-location-linux.png) - -2) 在终端中进入到之前可执行程序cmd_gen-linux所在的目录,并运行cmd_gen-linux,在cmd_gen-linux后面要对应的.d.ts文件名,例如: - - ![](figures/pic-cmd-execute-linux.png) - -3) 运行成功后会在.d.ts文件说在的目录下生成对应的文件,例如: - - ![](figures/pic-d-ts-transition-linux.png) - -#### Mac -方法步骤参考windows、Linux的使用方法 - -## 插件使用方法 -### 说明 -visual studio code 版本需1.62.0及以上 - -### 步骤 - -1) 打开vscode,在左侧边栏中选择插件安装。 - - ![](figures/pic-plug-in-search.png) - -2) 点击上面三个点的按钮,选择从VSIX安装选项,然后选择刚才生成的gnapi-0.0.1.vsix插件文件,再点击安装。 - - ![](figures/pic-plug-in-select.png) - -3) 安装完成后就会在vscode的插件管理器中能看到gnapi这个插件了。 - - ![](figures/pic-plug-in-gnapi.png) - -4) 在vscode中找到需要转换的.d.ts文件,例如: - - ![](figures/pic-plug-in-select-d-ts.png) - -5) 鼠标在.d.ts上点击右键,选择.d.ts生成c++选项。 - - ![](figures/pic-plug-in-gen-c++.png) - -6) 之后就会在该目录下生成对应文件,例如: - - ![](figures/pic-plug-in-gen-result.png) - -## 注意事项 -以上插件使用示例为windows的,linux、mac的使用方法类似。 - -## 参与贡献 - -暂无 - -## 相关仓 - -暂无 diff --git a/napi_tool/code/README_ZH.md b/napi_tool/code/README_ZH.md deleted file mode 100644 index 874459fa..00000000 --- a/napi_tool/code/README_ZH.md +++ /dev/null @@ -1,19 +0,0 @@ -# napi_tool_code - -#### 介绍 -此目录为NAPI框架代码生成工具对应的源码,开发者可基于此代码进行二次开发。 - -#### 目录 -``` -/napi_tool/code -├── tool_code # 工具源码 -│ ├── gen -│ | |── analyze # 解析器 -│ │ |── extend # 扩展模块,包括gn文件生成、linux环境适配代码等 -│ │ |── generate # 生成器 -│ │ └── tools # 公共模块代码,包括消息体校验、文件读写、正则表达式转换等 -│ └── test # 插件测试用例 -└──ts_test # 工具需要的ts文件样例 -``` - - diff --git a/napi_tool/code/image/image-20220106161201896.png b/napi_tool/code/image/image-20220106161201896.png deleted file mode 100644 index 80a39816..00000000 Binary files a/napi_tool/code/image/image-20220106161201896.png and /dev/null differ diff --git a/napi_tool/code/image/image-20220106162517246.png b/napi_tool/code/image/image-20220106162517246.png deleted file mode 100644 index 0d732af7..00000000 Binary files a/napi_tool/code/image/image-20220106162517246.png and /dev/null differ diff --git a/napi_tool/code/tool_code/test/runTest.js b/napi_tool/code/tool_code/test/runTest.js deleted file mode 100644 index 7d482400..00000000 --- a/napi_tool/code/tool_code/test/runTest.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -const path = require('path'); - -const { runTests } = require('@vscode/test-electron'); - -async function main() { - try { - // The folder containing the Extension Manifest package.json - // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, '../'); - - // The path to the extension test script - // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './suite/index'); - - // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }); - } catch (err) { - console.error('Failed to run tests'); - process.exit(1); - } -} - -main(); diff --git a/napi_tool/code/tool_code/test/suite/extension.test.js b/napi_tool/code/tool_code/test/suite/extension.test.js deleted file mode 100644 index 006218ea..00000000 --- a/napi_tool/code/tool_code/test/suite/extension.test.js +++ /dev/null @@ -1,29 +0,0 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -const assert = require('assert'); - -// You can import and use all API from the 'vscode' module -// as well as import your extension to test it -const vscode = require('vscode'); -// const myExtension = require('../extension'); - -suite('Extension Test Suite', () => { - vscode.window.showInformationMessage('Start all tests.'); - - test('Sample test', () => { - assert.strictEqual(-1, [1, 2, 3].indexOf(5)); - assert.strictEqual(-1, [1, 2, 3].indexOf(0)); - }); -}); diff --git a/prebuilt/End User License Agreement-templet20211215.docx b/prebuilt/End User License Agreement-templet20211215.docx new file mode 100755 index 00000000..f83f7be7 Binary files /dev/null and b/prebuilt/End User License Agreement-templet20211215.docx differ diff --git a/prebuilt/cmd_gen-linux b/prebuilt/cmd_gen-linux new file mode 100755 index 00000000..aaf1f8da Binary files /dev/null and b/prebuilt/cmd_gen-linux differ diff --git a/prebuilt/cmd_gen-macos b/prebuilt/cmd_gen-macos new file mode 100755 index 00000000..6e8f7ee9 Binary files /dev/null and b/prebuilt/cmd_gen-macos differ diff --git a/prebuilt/cmd_gen-win.exe b/prebuilt/cmd_gen-win.exe new file mode 100755 index 00000000..453d3db1 Binary files /dev/null and b/prebuilt/cmd_gen-win.exe differ diff --git a/napi_tool/release-notes/napi_tool-1.0.md b/release-notes/napi_tool-1.0.md similarity index 100% rename from napi_tool/release-notes/napi_tool-1.0.md rename to release-notes/napi_tool-1.0.md diff --git a/napi_tool/code/tool_code/.eslintrc.json b/src/.eslintrc.json similarity index 100% rename from napi_tool/code/tool_code/.eslintrc.json rename to src/.eslintrc.json diff --git a/napi_tool/code/tool_code/.vscode/extensions.json b/src/.vscode/extensions.json similarity index 100% rename from napi_tool/code/tool_code/.vscode/extensions.json rename to src/.vscode/extensions.json diff --git a/napi_tool/code/tool_code/.vscode/launch.json b/src/.vscode/launch.json similarity index 100% rename from napi_tool/code/tool_code/.vscode/launch.json rename to src/.vscode/launch.json diff --git a/napi_tool/code/tool_code/.vscode/settings.json b/src/.vscode/settings.json similarity index 100% rename from napi_tool/code/tool_code/.vscode/settings.json rename to src/.vscode/settings.json diff --git a/napi_tool/code/tool_code/CHANGELOG.md b/src/CHANGELOG.md similarity index 100% rename from napi_tool/code/tool_code/CHANGELOG.md rename to src/CHANGELOG.md diff --git a/napi_tool/code/tool_code/README.md b/src/README.md similarity index 100% rename from napi_tool/code/tool_code/README.md rename to src/README.md diff --git a/napi_tool/code/tool_code/extension.js b/src/extension.js similarity index 100% rename from napi_tool/code/tool_code/extension.js rename to src/extension.js diff --git a/napi_tool/code/tool_code/gen/analyze.js b/src/gen/analyze.js similarity index 100% rename from napi_tool/code/tool_code/gen/analyze.js rename to src/gen/analyze.js diff --git a/napi_tool/code/tool_code/gen/analyze/function.js b/src/gen/analyze/function.js similarity index 100% rename from napi_tool/code/tool_code/gen/analyze/function.js rename to src/gen/analyze/function.js diff --git a/napi_tool/code/tool_code/gen/analyze/interface.js b/src/gen/analyze/interface.js similarity index 100% rename from napi_tool/code/tool_code/gen/analyze/interface.js rename to src/gen/analyze/interface.js diff --git a/napi_tool/code/tool_code/gen/analyze/namespace.js b/src/gen/analyze/namespace.js similarity index 100% rename from napi_tool/code/tool_code/gen/analyze/namespace.js rename to src/gen/analyze/namespace.js diff --git a/napi_tool/code/tool_code/gen/analyze/params.js b/src/gen/analyze/params.js similarity index 100% rename from napi_tool/code/tool_code/gen/analyze/params.js rename to src/gen/analyze/params.js diff --git a/napi_tool/code/tool_code/gen/analyze/return.js b/src/gen/analyze/return.js similarity index 100% rename from napi_tool/code/tool_code/gen/analyze/return.js rename to src/gen/analyze/return.js diff --git a/napi_tool/code/tool_code/gen/cmd_gen.js b/src/gen/cmd_gen.js similarity index 100% rename from napi_tool/code/tool_code/gen/cmd_gen.js rename to src/gen/cmd_gen.js diff --git a/napi_tool/code/tool_code/gen/extend/binding_gyp.js b/src/gen/extend/binding_gyp.js similarity index 100% rename from napi_tool/code/tool_code/gen/extend/binding_gyp.js rename to src/gen/extend/binding_gyp.js diff --git a/napi_tool/code/tool_code/gen/extend/build_gn.js b/src/gen/extend/build_gn.js similarity index 100% rename from napi_tool/code/tool_code/gen/extend/build_gn.js rename to src/gen/extend/build_gn.js diff --git a/napi_tool/code/tool_code/gen/extend/x_napi_tool.js b/src/gen/extend/x_napi_tool.js similarity index 100% rename from napi_tool/code/tool_code/gen/extend/x_napi_tool.js rename to src/gen/extend/x_napi_tool.js diff --git a/napi_tool/code/tool_code/gen/generate.js b/src/gen/generate.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate.js rename to src/gen/generate.js diff --git a/napi_tool/code/tool_code/gen/generate/function_async.js b/src/gen/generate/function_async.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/function_async.js rename to src/gen/generate/function_async.js diff --git a/napi_tool/code/tool_code/gen/generate/function_direct.js b/src/gen/generate/function_direct.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/function_direct.js rename to src/gen/generate/function_direct.js diff --git a/napi_tool/code/tool_code/gen/generate/function_sync.js b/src/gen/generate/function_sync.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/function_sync.js rename to src/gen/generate/function_sync.js diff --git a/napi_tool/code/tool_code/gen/generate/interface.js b/src/gen/generate/interface.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/interface.js rename to src/gen/generate/interface.js diff --git a/napi_tool/code/tool_code/gen/generate/namespace.js b/src/gen/generate/namespace.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/namespace.js rename to src/gen/generate/namespace.js diff --git a/napi_tool/code/tool_code/gen/generate/param_generate.js b/src/gen/generate/param_generate.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/param_generate.js rename to src/gen/generate/param_generate.js diff --git a/napi_tool/code/tool_code/gen/generate/return_generate.js b/src/gen/generate/return_generate.js similarity index 100% rename from napi_tool/code/tool_code/gen/generate/return_generate.js rename to src/gen/generate/return_generate.js diff --git a/napi_tool/code/tool_code/gen/main.js b/src/gen/main.js similarity index 100% rename from napi_tool/code/tool_code/gen/main.js rename to src/gen/main.js diff --git a/napi_tool/code/tool_code/gen/test.js b/src/gen/test.js similarity index 100% rename from napi_tool/code/tool_code/gen/test.js rename to src/gen/test.js diff --git a/napi_tool/code/tool_code/gen/tools/FileRW.js b/src/gen/tools/FileRW.js similarity index 100% rename from napi_tool/code/tool_code/gen/tools/FileRW.js rename to src/gen/tools/FileRW.js diff --git a/napi_tool/code/tool_code/gen/tools/common.js b/src/gen/tools/common.js similarity index 100% rename from napi_tool/code/tool_code/gen/tools/common.js rename to src/gen/tools/common.js diff --git a/napi_tool/code/tool_code/gen/tools/re.js b/src/gen/tools/re.js similarity index 100% rename from napi_tool/code/tool_code/gen/tools/re.js rename to src/gen/tools/re.js diff --git a/napi_tool/code/tool_code/gen/tools/tool.js b/src/gen/tools/tool.js similarity index 100% rename from napi_tool/code/tool_code/gen/tools/tool.js rename to src/gen/tools/tool.js diff --git a/napi_tool/code/tool_code/jsconfig.json b/src/jsconfig.json similarity index 100% rename from napi_tool/code/tool_code/jsconfig.json rename to src/jsconfig.json diff --git a/napi_tool/code/tool_code/package-lock.json b/src/package-lock.json similarity index 100% rename from napi_tool/code/tool_code/package-lock.json rename to src/package-lock.json diff --git a/napi_tool/code/tool_code/package.json b/src/package.json similarity index 100% rename from napi_tool/code/tool_code/package.json rename to src/package.json diff --git a/napi_tool/code/tool_code/vsc-extension-quickstart.md b/src/vsc-extension-quickstart.md similarity index 100% rename from napi_tool/code/tool_code/vsc-extension-quickstart.md rename to src/vsc-extension-quickstart.md diff --git a/napi_tool/code/ts_test/gen/@ohos.napitest.d.ts b/ts_test/gen/@ohos.napitest.d.ts similarity index 100% rename from napi_tool/code/ts_test/gen/@ohos.napitest.d.ts rename to ts_test/gen/@ohos.napitest.d.ts diff --git a/napi_tool/code/ts_test/gen/test.js b/ts_test/gen/test.js similarity index 100% rename from napi_tool/code/ts_test/gen/test.js rename to ts_test/gen/test.js