声享正努力加载中...
Hex
01
02
03
04
安装脚手架工具
npm install -g yo generator-code执行 Yeoman 命令创建项目
yo code
. |____.eslintrc.json |____.gitignore |____.vscode // vscode配置目录 | |____extensions.json | |____launch.json | |____settings.json |____.vscodeignore // 发布时排除掉的文件 |____CHANGELOG.md |____extension.js // 插件入口 |____jsconfig.json |____package.json // 资源配置 |____README.md // 文档 |____test // 自动化测试目录 | |____extension.test.js | |____index.js |____vsc-extension-quickstart.md
{
"name": "demo1",
"displayName": "demo1",
"description": "my demo1",
"version": "0.0.1",
"publisher": "name1",
"engines": {
"vscode": "^1.28.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.sayHello"
],
"main": "./extension",
"contributes": {
"commands": [
{
"command": "extension.sayHello",
"title": "Hello World"
}
]
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test"
},
"devDependencies": {
"typescript": "^2.6.1",
"vscode": "^1.1.21",
"eslint": "^4.11.0",
"@types/node": "^8.10.25",
"@types/mocha": "^2.2.42"
}
}// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "demo1" is now active!');
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand('extension.sayHello', function () {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
exports.activate = activate;
// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;安装发布工具
npm install -g vsce执行发布命令
$ cd demo1
$ vsce publish
Publishing demo1@0.0.1...
Successfully published demo1@0.0.1!
.webp)