(feature): init
This commit is contained in:
commit
f748bde022
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
out
|
||||||
|
dist
|
||||||
|
node_modules
|
||||||
|
.vscode-test/
|
||||||
|
*.vsix
|
||||||
5
.vscode-test.mjs
Normal file
5
.vscode-test.mjs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { defineConfig } from '@vscode/test-cli';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
files: 'out/test/**/*.test.js',
|
||||||
|
});
|
||||||
8
.vscode/extensions.json
vendored
Normal file
8
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"ms-vscode.extension-test-runner"
|
||||||
|
]
|
||||||
|
}
|
||||||
21
.vscode/launch.json
vendored
Normal file
21
.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",
|
||||||
|
"args": [
|
||||||
|
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/out/**/*.js"
|
||||||
|
],
|
||||||
|
"preLaunchTask": "${defaultBuildTask}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
.vscode/settings.json
vendored
Normal file
11
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
"files.exclude": {
|
||||||
|
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
||||||
|
},
|
||||||
|
"search.exclude": {
|
||||||
|
"out": true // set this to false to include "out" folder in search results
|
||||||
|
},
|
||||||
|
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||||
|
"typescript.tsc.autoDetect": "off"
|
||||||
|
}
|
||||||
20
.vscode/tasks.json
vendored
Normal file
20
.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
.vscodeignore
Normal file
11
.vscodeignore
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.vscode/**
|
||||||
|
.vscode-test/**
|
||||||
|
src/**
|
||||||
|
.gitignore
|
||||||
|
.yarnrc
|
||||||
|
vsc-extension-quickstart.md
|
||||||
|
**/tsconfig.json
|
||||||
|
**/eslint.config.mjs
|
||||||
|
**/*.map
|
||||||
|
**/*.ts
|
||||||
|
**/.vscode-test.*
|
||||||
9
CHANGELOG.md
Normal file
9
CHANGELOG.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to the "maksit-openfolderrecurs" extension will be documented in this file.
|
||||||
|
|
||||||
|
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Initial release
|
||||||
183
README.md
Normal file
183
README.md
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
local
|
||||||
|
npx --package yo --package generator-code -- yo code
|
||||||
|
|
||||||
|
global
|
||||||
|
npm install --global yo generator-code
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
yo code
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ? What type of extension do you want to create? New Extension (TypeScript)
|
||||||
|
# ? What's the name of your extension? HelloWorld
|
||||||
|
### Press <Enter> to choose default for all options below ###
|
||||||
|
|
||||||
|
# ? What's the identifier of your extension? helloworld
|
||||||
|
# ? What's the description of your extension? LEAVE BLANK
|
||||||
|
# ? Initialize a git repository? Yes
|
||||||
|
# ? Bundle the source code with webpack? No
|
||||||
|
# ? Which package manager to use? npm
|
||||||
|
|
||||||
|
# ? Do you want to open the new folder with Visual Studio Code? Open with `code`
|
||||||
|
|
||||||
|
|
||||||
|
If you'd like to publish your Visual Studio Code (VSCode) extension so everyone can access it, you can publish it to the **Visual Studio Code Marketplace**. Here's how:
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 1. **Prepare Your Extension**
|
||||||
|
Ensure your extension meets these requirements:
|
||||||
|
- **Manifest (`package.json`)**:
|
||||||
|
- Make sure the `name`, `displayName`, `description`, and `version` fields are filled out.
|
||||||
|
- Specify the correct `publisher` field (this should match your Visual Studio Marketplace publisher name).
|
||||||
|
- **README.md**:
|
||||||
|
- Include a detailed explanation of what your extension does.
|
||||||
|
- **LICENSE**:
|
||||||
|
- Add a license file to your project. Common options include MIT, Apache 2.0, etc.
|
||||||
|
- **Icon**:
|
||||||
|
- Add an `icon` field in your `package.json` to point to a 128x128 PNG file for the Marketplace.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 2. **Set Up a Publisher Account**
|
||||||
|
1. Go to the [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/).
|
||||||
|
2. Sign in with your Microsoft account.
|
||||||
|
3. Create a **publisher account**:
|
||||||
|
- Go to the [Manage Publishers](https://dev.azure.com/) page.
|
||||||
|
- Click `+ New Publisher`.
|
||||||
|
- Enter the publisher name and description.
|
||||||
|
- Verify your publisher account.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3. **Install the `vsce` Tool**
|
||||||
|
The `vsce` (Visual Studio Code Extension Manager) CLI is required for publishing:
|
||||||
|
```bash
|
||||||
|
npm install -g vsce
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 4. **Login to Your Publisher**
|
||||||
|
To authenticate with the Marketplace, use the Azure DevOps Personal Access Token (PAT):
|
||||||
|
1. Go to [Azure DevOps PAT](https://dev.azure.com/).
|
||||||
|
2. Create a new PAT with `All accessible organizations` and `Marketplace (Publish)` scopes.
|
||||||
|
3. Save the generated token.
|
||||||
|
|
||||||
|
Login to `vsce`:
|
||||||
|
```bash
|
||||||
|
vsce login <your-publisher-name>
|
||||||
|
```
|
||||||
|
Paste the PAT token when prompted.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5. **Package Your Extension**
|
||||||
|
Run the following command in your extension's root directory:
|
||||||
|
```bash
|
||||||
|
vsce package
|
||||||
|
```
|
||||||
|
This will generate a `.vsix` file.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 6. **Publish the Extension**
|
||||||
|
Run the following command to publish your extension:
|
||||||
|
```bash
|
||||||
|
vsce publish
|
||||||
|
```
|
||||||
|
- This will publish the extension to the Visual Studio Code Marketplace under your publisher account.
|
||||||
|
- If you are updating an existing extension, increment the `version` field in `package.json` before publishing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 7. **Verify on the Marketplace**
|
||||||
|
After publishing, go to the [Marketplace](https://marketplace.visualstudio.com/) and check your publisher page to confirm the extension is listed.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 8. **Promote Your Extension**
|
||||||
|
- Share the link to your extension's Marketplace page.
|
||||||
|
- Use social media, forums, and blogs to reach a wider audience.
|
||||||
|
- Gather feedback to improve future versions.
|
||||||
|
|
||||||
|
Let me know if you face any issues or need clarification!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# maksit-openfolderrecurs README
|
||||||
|
|
||||||
|
This is the README for your extension "maksit-openfolderrecurs". After writing up a brief description, we recommend including the following sections.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
|
||||||
|
|
||||||
|
For example if there is an image subfolder under your extension project workspace:
|
||||||
|
|
||||||
|
\!\[feature X\]\(images/feature-x.png\)
|
||||||
|
|
||||||
|
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
|
||||||
|
|
||||||
|
## Extension Settings
|
||||||
|
|
||||||
|
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
This extension contributes the following settings:
|
||||||
|
|
||||||
|
* `myExtension.enable`: Enable/disable this extension.
|
||||||
|
* `myExtension.thing`: Set to `blah` to do something.
|
||||||
|
|
||||||
|
## Known Issues
|
||||||
|
|
||||||
|
Calling out known issues can help limit users opening duplicate issues against your extension.
|
||||||
|
|
||||||
|
## Release Notes
|
||||||
|
|
||||||
|
Users appreciate release notes as you update your extension.
|
||||||
|
|
||||||
|
### 1.0.0
|
||||||
|
|
||||||
|
Initial release of ...
|
||||||
|
|
||||||
|
### 1.0.1
|
||||||
|
|
||||||
|
Fixed issue #.
|
||||||
|
|
||||||
|
### 1.1.0
|
||||||
|
|
||||||
|
Added features X, Y, and Z.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Following extension guidelines
|
||||||
|
|
||||||
|
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
|
||||||
|
|
||||||
|
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines)
|
||||||
|
|
||||||
|
## Working with Markdown
|
||||||
|
|
||||||
|
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
|
||||||
|
|
||||||
|
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
|
||||||
|
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
|
||||||
|
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.
|
||||||
|
|
||||||
|
## For more information
|
||||||
|
|
||||||
|
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
|
||||||
|
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
|
||||||
|
|
||||||
|
**Enjoy!**
|
||||||
28
eslint.config.mjs
Normal file
28
eslint.config.mjs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
||||||
|
import tsParser from "@typescript-eslint/parser";
|
||||||
|
|
||||||
|
export default [{
|
||||||
|
files: ["**/*.ts"],
|
||||||
|
}, {
|
||||||
|
plugins: {
|
||||||
|
"@typescript-eslint": typescriptEslint,
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/naming-convention": ["warn", {
|
||||||
|
selector: "import",
|
||||||
|
format: ["camelCase", "PascalCase"],
|
||||||
|
}],
|
||||||
|
|
||||||
|
curly: "warn",
|
||||||
|
eqeqeq: "warn",
|
||||||
|
"no-throw-literal": "warn",
|
||||||
|
semi: "warn",
|
||||||
|
},
|
||||||
|
}];
|
||||||
3217
package-lock.json
generated
Normal file
3217
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
package.json
Normal file
49
package.json
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"name": "maksit-openfolderrecurs",
|
||||||
|
"displayName": "MaksIT.OpenFolderRecurs",
|
||||||
|
"description": "Recursively open all files in folder",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.96.0"
|
||||||
|
},
|
||||||
|
"categories": [
|
||||||
|
"Other"
|
||||||
|
],
|
||||||
|
"activationEvents": [],
|
||||||
|
"main": "./out/extension.js",
|
||||||
|
"contributes": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"command": "maksit-openfolderrecurs.openAllFilesAndKeepWithErrors",
|
||||||
|
"title": "Open All Files in Folder With Errors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "maksit-openfolderrecurs.closeWithoutErrors",
|
||||||
|
"title": "Close All Open Files Without Errors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "maksit-openfolderrecurs.openAllFiles",
|
||||||
|
"title": "Open all files in a folder recursively"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"vscode:prepublish": "npm run compile",
|
||||||
|
"compile": "tsc -p ./",
|
||||||
|
"watch": "tsc -watch -p ./",
|
||||||
|
"pretest": "npm run compile && npm run lint",
|
||||||
|
"lint": "eslint src",
|
||||||
|
"test": "vscode-test"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/vscode": "^1.96.0",
|
||||||
|
"@types/mocha": "^10.0.10",
|
||||||
|
"@types/node": "20.x",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
||||||
|
"@typescript-eslint/parser": "^8.17.0",
|
||||||
|
"eslint": "^9.16.0",
|
||||||
|
"typescript": "^5.7.2",
|
||||||
|
"@vscode/test-cli": "^0.0.10",
|
||||||
|
"@vscode/test-electron": "^2.4.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
155
src/extension.ts
Normal file
155
src/extension.ts
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
// Command: Open files in batches, wait for lint, and close if no errors
|
||||||
|
let lintAndCloseCommand = vscode.commands.registerCommand('maksit-openfolderrecurs.openAllFilesAndKeepWithErrors', async () => {
|
||||||
|
const folderUri = await vscode.window.showOpenDialog({
|
||||||
|
canSelectFolders: true,
|
||||||
|
canSelectFiles: false,
|
||||||
|
canSelectMany: false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!folderUri || folderUri.length === 0) {
|
||||||
|
return; // No folder selected
|
||||||
|
}
|
||||||
|
|
||||||
|
const folderPath = folderUri[0].fsPath;
|
||||||
|
const files = getAllFiles(folderPath);
|
||||||
|
|
||||||
|
const batchSize = 20;
|
||||||
|
for (let i = 0; i < files.length; i += batchSize) {
|
||||||
|
const batch = files.slice(i, i + batchSize);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
batch.map(async (file) => {
|
||||||
|
try {
|
||||||
|
const document = await vscode.workspace.openTextDocument(file);
|
||||||
|
const editor = await vscode.window.showTextDocument(document, { preview: false });
|
||||||
|
|
||||||
|
// Wait for lint results
|
||||||
|
await waitForLinting(file);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Could not process file: ${file}. Skipping.`, error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Close documents in the current batch without lint errors
|
||||||
|
await closeDocumentsWithoutErrors(batch);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Command: Close open documents without lint errors
|
||||||
|
let closeWithoutErrorsCommand = vscode.commands.registerCommand('maksit-openfolderrecurs.closeWithoutErrors', async () => {
|
||||||
|
await closeDocumentsWithoutErrors();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Command: Open all files in a folder recursively
|
||||||
|
let openAllFilesCommand = vscode.commands.registerCommand('maksit-openfolderrecurs.openAllFiles', async () => {
|
||||||
|
const folderUri = await vscode.window.showOpenDialog({
|
||||||
|
canSelectFolders: true,
|
||||||
|
canSelectFiles: false,
|
||||||
|
canSelectMany: false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!folderUri || folderUri.length === 0) {
|
||||||
|
return; // No folder selected
|
||||||
|
}
|
||||||
|
|
||||||
|
const folderPath = folderUri[0].fsPath;
|
||||||
|
const files = getAllFiles(folderPath);
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
try {
|
||||||
|
const document = await vscode.workspace.openTextDocument(file);
|
||||||
|
await vscode.window.showTextDocument(document, { preview: false });
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Could not open file: ${file}. Skipping.`, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
context.subscriptions.push(lintAndCloseCommand, closeWithoutErrorsCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to close open documents without lint errors
|
||||||
|
async function closeDocumentsWithoutErrors(filesToCheck?: string[]) {
|
||||||
|
const tabGroups = vscode.window.tabGroups.all;
|
||||||
|
|
||||||
|
for (const group of tabGroups) {
|
||||||
|
for (const tab of group.tabs) {
|
||||||
|
if (tab.input instanceof vscode.TabInputText) {
|
||||||
|
try {
|
||||||
|
const documentUri = tab.input.uri;
|
||||||
|
|
||||||
|
// If filesToCheck is provided, ensure the file is in the list
|
||||||
|
if (filesToCheck && !filesToCheck.includes(documentUri.fsPath)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const document = await vscode.workspace.openTextDocument(documentUri);
|
||||||
|
|
||||||
|
// Wait for lint results
|
||||||
|
await waitForLinting(document.fileName, 500);
|
||||||
|
|
||||||
|
// Check if there are no errors
|
||||||
|
const problems = vscode.languages.getDiagnostics(document.uri);
|
||||||
|
const hasErrors = problems.some(problem => problem.severity === vscode.DiagnosticSeverity.Error);
|
||||||
|
|
||||||
|
if (!hasErrors) {
|
||||||
|
// Set the document as active
|
||||||
|
await vscode.window.showTextDocument(document, { preview: false });
|
||||||
|
|
||||||
|
// Close the active editor
|
||||||
|
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||||
|
|
||||||
|
// Add a delay to ensure the editor is closed before moving to the next one
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to process document: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to get all files recursively
|
||||||
|
function getAllFiles(dir: string, fileList: string[] = []): string[] {
|
||||||
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
const fullPath = path.join(dir, entry.name);
|
||||||
|
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
getAllFiles(fullPath, fileList);
|
||||||
|
} else if (entry.isFile()) {
|
||||||
|
fileList.push(fullPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to wait for linting results to update
|
||||||
|
function waitForLinting(filePath: string, maxWaitTime: number = 5000): Promise<void> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const checkInterval = 500; // Check every 500ms
|
||||||
|
let elapsed = 0;
|
||||||
|
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const diagnostics = vscode.languages.getDiagnostics(vscode.Uri.file(filePath));
|
||||||
|
if (diagnostics.length > 0 || elapsed >= maxWaitTime) {
|
||||||
|
clearInterval(interval);
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
elapsed += checkInterval;
|
||||||
|
}
|
||||||
|
}, checkInterval);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deactivate() {}
|
||||||
15
src/test/extension.test.ts
Normal file
15
src/test/extension.test.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as assert from 'assert';
|
||||||
|
|
||||||
|
// You can import and use all API from the 'vscode' module
|
||||||
|
// as well as import your extension to test it
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
// import * as myExtension from '../../extension';
|
||||||
|
|
||||||
|
suite('Extension Test Suite', () => {
|
||||||
|
vscode.window.showInformationMessage('Start all tests.');
|
||||||
|
|
||||||
|
test('Sample test', () => {
|
||||||
|
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
|
||||||
|
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
|
||||||
|
});
|
||||||
|
});
|
||||||
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "Node16",
|
||||||
|
"target": "ES2022",
|
||||||
|
"outDir": "out",
|
||||||
|
"lib": [
|
||||||
|
"ES2022"
|
||||||
|
],
|
||||||
|
"sourceMap": true,
|
||||||
|
"rootDir": "src",
|
||||||
|
"strict": true, /* enable all strict type-checking options */
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
}
|
||||||
|
}
|
||||||
44
vsc-extension-quickstart.md
Normal file
44
vsc-extension-quickstart.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Welcome to your VS Code Extension
|
||||||
|
|
||||||
|
## What's in the folder
|
||||||
|
|
||||||
|
* This folder contains all of the files necessary for your extension.
|
||||||
|
* `package.json` - this is the manifest file in which you declare your extension and command.
|
||||||
|
* The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
|
||||||
|
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
|
||||||
|
* The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
|
||||||
|
* We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
|
||||||
|
|
||||||
|
## Get up and running straight away
|
||||||
|
|
||||||
|
* Press `F5` to open a new window with your extension loaded.
|
||||||
|
* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
|
||||||
|
* Set breakpoints in your code inside `src/extension.ts` to debug your extension.
|
||||||
|
* Find output from your extension in the debug console.
|
||||||
|
|
||||||
|
## Make changes
|
||||||
|
|
||||||
|
* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
|
||||||
|
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
||||||
|
|
||||||
|
## Explore the API
|
||||||
|
|
||||||
|
* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
|
||||||
|
|
||||||
|
## Run tests
|
||||||
|
|
||||||
|
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
|
||||||
|
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
|
||||||
|
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
|
||||||
|
* See the output of the test result in the Test Results view.
|
||||||
|
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
|
||||||
|
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
|
||||||
|
* You can create folders inside the `test` folder to structure your tests any way you want.
|
||||||
|
|
||||||
|
## Go further
|
||||||
|
|
||||||
|
* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns.
|
||||||
|
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
|
||||||
|
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace.
|
||||||
|
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
|
||||||
|
* Integrate to the [report issue](https://code.visualstudio.com/api/get-started/wrapping-up#issue-reporting) flow to get issue and feature requests reported by users.
|
||||||
Loading…
Reference in New Issue
Block a user