mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Add getting started sample
This commit is contained in:
20
getting-started-sample/.eslintrc.js
Normal file
20
getting-started-sample/.eslintrc.js
Normal file
@ -0,0 +1,20 @@
|
||||
/**@type {import('eslint').Linter.Config} */
|
||||
// eslint-disable-next-line no-undef
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
],
|
||||
rules: {
|
||||
'semi': [2, "always"],
|
||||
'@typescript-eslint/no-unused-vars': 0,
|
||||
'@typescript-eslint/no-explicit-any': 0,
|
||||
'@typescript-eslint/explicit-module-boundary-types': 0,
|
||||
'@typescript-eslint/no-non-null-assertion': 0,
|
||||
}
|
||||
};
|
||||
4
getting-started-sample/.gitignore
vendored
Normal file
4
getting-started-sample/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
out
|
||||
node_modules
|
||||
.vscode-test/
|
||||
*.vsix
|
||||
21
getting-started-sample/.vscode/launch.json
vendored
Normal file
21
getting-started-sample/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [{
|
||||
"name": "Run Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "npm: watch"
|
||||
}
|
||||
]
|
||||
}
|
||||
20
getting-started-sample/.vscode/tasks.json
vendored
Normal file
20
getting-started-sample/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch",
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "never"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
5
getting-started-sample/README.md
Normal file
5
getting-started-sample/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# getting-started-sample
|
||||
|
||||
This sample shows how to provide a walkthrough to the Getting Started section in vscode's welcome page.
|
||||
|
||||

|
||||
BIN
getting-started-sample/media/image.png
Normal file
BIN
getting-started-sample/media/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
9
getting-started-sample/media/linux.md
Normal file
9
getting-started-sample/media/linux.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Hello Linux Users
|
||||
|
||||
[Say hello](command:getting-started-sample.sayHello)
|
||||
|
||||

|
||||
|
||||
```ts
|
||||
const a = 12;
|
||||
```
|
||||
9
getting-started-sample/media/mac.md
Normal file
9
getting-started-sample/media/mac.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Hello Mac Users
|
||||
|
||||
[Say hello](command:getting-started-sample.sayHello)
|
||||
|
||||

|
||||
|
||||
```ts
|
||||
const a = 12;
|
||||
```
|
||||
BIN
getting-started-sample/media/preview.png
Normal file
BIN
getting-started-sample/media/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 686 KiB |
BIN
getting-started-sample/media/sample.png
Normal file
BIN
getting-started-sample/media/sample.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
BIN
getting-started-sample/media/small-image.png
Normal file
BIN
getting-started-sample/media/small-image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
9
getting-started-sample/media/windows.md
Normal file
9
getting-started-sample/media/windows.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Hello Windows Users
|
||||
|
||||
[Say hello](command:getting-started-sample.sayHello)
|
||||
|
||||

|
||||
|
||||
```ts
|
||||
const a = 12;
|
||||
```
|
||||
3142
getting-started-sample/package-lock.json
generated
Normal file
3142
getting-started-sample/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
113
getting-started-sample/package.json
Normal file
113
getting-started-sample/package.json
Normal file
@ -0,0 +1,113 @@
|
||||
{
|
||||
"name": "getting-started-sample",
|
||||
"displayName": "getting-started-sample",
|
||||
"description": "Example extension contribution to Getting Started page",
|
||||
"version": "0.0.1",
|
||||
"publisher": "vscode-samples",
|
||||
"repository": "https://github.com/Microsoft/vscode-extension-samples/getting-started-sample",
|
||||
"engines": {
|
||||
"vscode": "^1.57.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:getting-started-sample.runCommand",
|
||||
"onCommand:getting-started-sample.changeSetting",
|
||||
"onCommand:getting-started-sample.setContext",
|
||||
"onCommand:getting-started-sample.sayHello"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
"walkthroughs": [
|
||||
{
|
||||
"id": "sample",
|
||||
"title": "Sample",
|
||||
"description": "A sample walkthrough",
|
||||
"steps": [
|
||||
{
|
||||
"id": "runcommand",
|
||||
"title": "Run Command",
|
||||
"description": "This step will run a command and check off once it has been run.\n[Run Command](command:getting-started-sample.runCommand)",
|
||||
"media": { "image": "media/image.png", "altText": "Empty image" },
|
||||
"completionEvents": ["onCommand:getting-started-sample.runCommand"]
|
||||
},
|
||||
{
|
||||
"id": "changesetting",
|
||||
"title": "Change Setting",
|
||||
"description": "This step will change a setting and check off when the setting has changed\n[Change Setting](command:getting-started-sample.changeSetting)",
|
||||
"media": { "image": "media/image.png", "altText": "Empty image" },
|
||||
"completionEvents": ["onSettingChanged:getting-started-sample.sampleSetting"]
|
||||
},
|
||||
{
|
||||
"id": "setcontext",
|
||||
"title": "Set Context",
|
||||
"description": "This step will set a context key, and check off when that context has been set\n[Set Context](command:getting-started-sample.setContext)",
|
||||
"media": { "image": "media/image.png", "altText": "Empty image" },
|
||||
"completionEvents": ["onContext:gettingStartedContextKey"]
|
||||
},
|
||||
{
|
||||
"id": "install python extension",
|
||||
"title": "Install Python Extension",
|
||||
"description": "Click here to install the Python Extension. This step will complete once it has been installed.\n[Here](command:workbench.extensions.installExtension?%22ms-python.python%22)",
|
||||
"media": { "image": "media/image.png", "altText": "Empty image" },
|
||||
"completionEvents": ["extensionInstalled:ms-python.python"]
|
||||
},
|
||||
{
|
||||
"id": "open terminal view",
|
||||
"title": "Open Terminal",
|
||||
"description": "Click [here](command:workbench.action.terminal.toggleTerminal) to open terminal. This step will complete once the terminal has been opened.",
|
||||
"media": { "image": "media/image.png", "altText": "Empty image" },
|
||||
"completionEvents": ["onView:terminal"]
|
||||
},
|
||||
{
|
||||
"id": "mac",
|
||||
"title": "Platform: Mac",
|
||||
"description": "This step will only show on a Mac.",
|
||||
"when": "isMac",
|
||||
"media": { "markdown": "media/mac.md"}
|
||||
},
|
||||
{
|
||||
"id": "windows",
|
||||
"title": "Platform: Windows",
|
||||
"description": "This step will only show on Windows",
|
||||
"when": "isWindows",
|
||||
"media": { "markdown": "media/windows.md" }
|
||||
},
|
||||
{
|
||||
"id": "linux",
|
||||
"title": "Platform: Linux",
|
||||
"description": "This step will only show on Linux",
|
||||
"when": "isLinux",
|
||||
"media": { "markdown": "media/linux.md" }
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"configuration":{
|
||||
"title": "Getting Started Sample",
|
||||
"properties": {
|
||||
"getting-started-sample.sampleSetting":{
|
||||
"description": "Sample setting",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"lint": "eslint src --ext ts",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"pretest": "npm run compile && npm run lint",
|
||||
"test": "node ./out/test/runTest.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.0",
|
||||
"@types/vscode": "^1.32.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.16.0",
|
||||
"@typescript-eslint/parser": "^4.16.0",
|
||||
"eslint": "^7.21.0",
|
||||
"typescript": "^4.2.2"
|
||||
}
|
||||
}
|
||||
27
getting-started-sample/src/extension.ts
Normal file
27
getting-started-sample/src/extension.ts
Normal file
@ -0,0 +1,27 @@
|
||||
// The module 'vscode' contains the VS Code extensibility API
|
||||
// Import the module and reference it with the alias vscode in your code below
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
|
||||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext): void {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.runCommand', async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
vscode.commands.executeCommand('getting-started-sample.sayHello', vscode.Uri.joinPath(context.extensionUri, 'sample-folder'));
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.changeSetting', async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
vscode.workspace.getConfiguration('getting-started-sample').update('sampleSetting', true);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.setContext', async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
vscode.commands.executeCommand('setContext', 'gettingStartedContextKey', true);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('getting-started-sample.sayHello', () => {
|
||||
vscode.window.showInformationMessage('Hello');
|
||||
}));
|
||||
}
|
||||
12
getting-started-sample/tsconfig.json
Normal file
12
getting-started-sample/tsconfig.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2019",
|
||||
"lib": ["ES2019"],
|
||||
"outDir": "out",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"rootDir": "src"
|
||||
},
|
||||
"exclude": ["node_modules", ".vscode-test"]
|
||||
}
|
||||
Reference in New Issue
Block a user