ts-mysql-plugin 项目教程
1. 项目的目录结构及介绍
ts-mysql-plugin/
├── dist/
│ └── index.js
├── src/
│ ├── index.ts
│ └── ...
├── e2e/
│ ├── ...
│ └── ...
├── package.json
├── tsconfig.json
├── README.md
├── LICENSE
└── ...
- dist/: 编译后的 JavaScript 文件存放目录。
- src/: TypeScript 源代码目录,包含项目的核心逻辑。
- e2e/: 端到端测试目录,包含项目的测试代码。
- package.json: 项目的配置文件,包含依赖、脚本等信息。
- tsconfig.json: TypeScript 配置文件,定义编译选项。
- README.md: 项目说明文档。
- LICENSE: 项目许可证文件。
2. 项目的启动文件介绍
项目的启动文件是 src/index.ts
,该文件是 TypeScript 语言服务插件的入口点。它负责初始化插件并提供对 SQL 标签模板字符串的增强功能。
3. 项目的配置文件介绍
package.json
{
"name": "ts-mysql-plugin",
"version": "1.0.1",
"description": "A typescript language service plugin that gives superpowers to SQL tagged template literals, Specifically aimed at the MySQL syntax",
"license": "MIT",
"repository": "segmentio/ts-mysql-plugin",
"author": "Steven Miller (https://github.com/stevenmiller888)",
"keywords": [
"typescript",
"extension",
"vscode",
"plugin",
"mysql",
"sql"
],
"files": [
"dist"
],
"main": "dist/index.js",
"scripts": {
"pub": "np",
"test": "jest --forceExit --runInBand",
"lint": "eslint src/**/*.ts",
"build": "tsc",
"watch": "tsc -b -w",
"clean": "rm -rf dist"
},
"prettier": {
"semi": false
},
"dependencies": {
"typescript": "^4.0.0",
"markdown-table": "^2.0.0",
"ts-simple-type": "^1.0.0",
"ts-mysql-parser": "^1.0.0",
"ts-mysql-analyzer": "^1.0.0",
"ts-mysql-autocomplete": "^1.0.0",
"typescript-template-language-service-decorator": "^1.0.0"
}
}
- name: 项目名称。
- version: 项目版本号。
- description: 项目描述。
- license: 项目许可证。
- repository: 项目代码仓库地址。
- author: 项目作者。
- keywords: 项目关键词。
- files: 项目发布时包含的文件。
- main: 项目入口文件。
- scripts: 项目脚本命令,如发布、测试、构建等。
- prettier: Prettier 配置。
- dependencies: 项目依赖包。
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
- compilerOptions: TypeScript 编译选项。
- target: 编译目标版本。
- module: 模块系统。
- strict: 启用严格模式。
- esModuleInterop: 启用 ES 模块互操作。
- skipLibCheck: 跳过库文件检查。
- forceConsistentCasingInFileNames: 强制文件名大小写一致。
- outDir: 输出目录。
- rootDir: 源代码根目录。
- include: 包含的文件。
- exclude: 排除的文件。