脚手架

安装的yo可以直接生成一个Hello World版本的插件目录。执行

yo code

yocode

根据提示生成样板代码:

.
CHANGELOG.md
README.md
node_modules
package-lock.json
package.json
src
tsconfig.json
vsc-extension-quickstart.md

其中的quickstart.md是新手引导,里面包含了对文件的作用解析、如何运行插件、测试插等等,推荐去看一看,我们在下面也会介绍一些。除此之外在package.json里也包含了很多非常重要的信息:

{
  "name": "hello-world",
    "displayName": "hello-world",
    "description": "hello-world",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.61.0"
    },
    "categories": [
        "Other"
    ],
    "activationEvents": [
        "onCommand:hello-world.helloWorld"
    ],
    "main": "./out/extension.js",
    "contributes": {
        "commands": [
            {
                "command": "hello-world.helloWorld",
                "title": "Hello World"
            }
        ]
    },
    "scripts": {
        "vscode:prepublish": "npm run compile",
        "compile": "tsc -p ./",
        "watch": "tsc -watch -p ./",
        "pretest": "npm run compile && npm run lint",
        "lint": "eslint src --ext ts",
        "test": "node ./out/test/runTest.js"
    },
    "devDependencies": {
        "@types/vscode": "^1.61.0",
        "@types/glob": "^7.1.4",
        "@types/mocha": "^9.0.0",
        "@types/node": "14.x",
        "@typescript-eslint/eslint-plugin": "^4.31.1",
        "@typescript-eslint/parser": "^4.31.1",
        "eslint": "^7.32.0",
        "glob": "^7.1.7",
        "mocha": "^9.1.1",
        "typescript": "^4.4.3",
        "@vscode/test-electron": "^1.6.2"
    }
}
© 2017~ 随风逐叶 all right reserved,powered by Gitbook文章修订时间: 2021-10-20 15:32:00

results matching ""

    No results matching ""