这里写标题
1. VSCode MarkDown-TOC 插件
1.1. MarkDown-TOC 插件目录生成错误 auto
使用该插件自动生成 TOC, 但发现是一大坨很乱的字。仔细观察发现没有换行, 而且出现很多 audo
字符。
1.2. 解决
参考: https://github.com/AlanWalk/markdown-toc/issues/89
- 打开设置
- 搜索 eol
- 改为
\n
2. vscode 插件开发
这里以 markdown-toc 插件举例。
2.1. 发布
From: https://code.visualstudio.com/api/working-with-extensions/publishing-extension
特别要注意的是:
- 在设置 Personal Access Token 的时候 organization 一定要选择 “All accessible organizations” 否则设置的 token 不会生效。
- 可以直接登录 https://marketplace.visualstudio.com/manage/publishers/CharlesWan 进行手动上传 vsix 文件进行发布,免去命令行的麻烦。
npm install -g vsce
$ vsce login charleswan
$ vsce package
$ vsce publish
2.2. 执行 npm install
时提示: Error installing vscode.d.ts: Error: Request returned status code: 404
原因是这个包依赖的 vscode 包太旧了,访问原来的地址 https://vscode-update.azurewebsites.net/api/releases/stable 报错: Cannot GET /api/releases/stable
解决方法:
There are two ways to get out of that situation:
- The latest
vscode
module already points toupdate.code.visualstudio.com
. So the easy fix is to just updatevscode
to1.1.37
in your dependencies. - The
vscode
module has been deprecated since about a year. So the right fix is to follow the migration guide and move out of that module.
If you’re going to have regressive licensing, you need to make sure old builds stay available at their old URL’s.
All builds are still available in update.code.visualstudio.com
, as vscode-builds
was just a redirect to that service.
2.3. 升级为 TypeScript 2.0
From: https://code.visualstudio.com/updates/v1_6#_authoring-in-typescript
Open the package.json file and do the following changes:
- Change the TypeScript developer dependency from
"typescript": "x.x.x"
to"typescript": "^2.0.3"
. - Add a developer dependency for the Node.js typings using
"@types/node": "^6.0.40"
. - If your extension has Mocha tests, change the developer dependency to at least Mocha version 2.3.3.
- Add a developer dependency for the Mocha typing using
"@types/mocha": "^2.2.32"
. - In the script section, exchange the
compile
script with"compile": "tsc -watch -p ./"
and thevscode:prepublish
with"vscode:prepublish": "tsc -p ./"
.
The devDependencies
section should look like this:
"devDependencies": {
"typescript": "^2.0.3",
"vscode": "^1.0.0", // Or a higher version if necessary
"mocha": "^2.3.3",
"@types/node": "^6.0.40",
"@types/mocha": "^2.2.32"
}
and the scripts
section something like this:
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install"
}
- Open the
tsconfig.json
file and exchange the line"noLib": true
with"lib": [ "es6" ]
and"target": "es5"
with"target": "es6"
.
The file should look something like this:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": ["es6"],
"sourceMap": true,
"rootDir": "."
},
"exclude": ["node_modules", ".vscode-test"]
}
run npm install
.