Skip to content

Commit 4e505cc

Browse files
committed
project init
0 parents  commit 4e505cc

19 files changed

+2512
-0
lines changed

.eslintrc.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": [
9+
"@typescript-eslint"
10+
],
11+
"rules": {
12+
"@typescript-eslint/naming-convention": "warn",
13+
"@typescript-eslint/semi": "warn",
14+
"curly": "warn",
15+
"eqeqeq": "warn",
16+
"no-throw-literal": "warn",
17+
"semi": "off"
18+
},
19+
"ignorePatterns": [
20+
"out",
21+
"dist",
22+
"**/*.d.ts"
23+
]
24+
}

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out
2+
dist
3+
node_modules
4+
.vscode-test/
5+
*.vsix

.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"]
5+
}

.vscode/launch.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}"
14+
],
15+
"outFiles": [
16+
"${workspaceFolder}/dist/**/*.js"
17+
],
18+
"preLaunchTask": "${defaultBuildTask}"
19+
},
20+
{
21+
"name": "Extension Tests",
22+
"type": "extensionHost",
23+
"request": "launch",
24+
"args": [
25+
"--extensionDevelopmentPath=${workspaceFolder}",
26+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
27+
],
28+
"outFiles": [
29+
"${workspaceFolder}/out/**/*.js",
30+
"${workspaceFolder}/dist/**/*.js"
31+
],
32+
"preLaunchTask": "tasks: watch-tests"
33+
}
34+
]
35+
}

.vscode/settings.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": false, // set this to true to hide the "out" folder with the compiled JS files
5+
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
6+
},
7+
"search.exclude": {
8+
"out": true, // set this to false to include "out" folder in search results
9+
"dist": true // set this to false to include "dist" folder in search results
10+
},
11+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
12+
"typescript.tsc.autoDetect": "off"
13+
}

.vscode/tasks.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": [
10+
"$ts-webpack-watch",
11+
"$tslint-webpack-watch"
12+
],
13+
"isBackground": true,
14+
"presentation": {
15+
"reveal": "never",
16+
"group": "watchers"
17+
},
18+
"group": {
19+
"kind": "build",
20+
"isDefault": true
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "watch-tests",
26+
"problemMatcher": "$tsc-watch",
27+
"isBackground": true,
28+
"presentation": {
29+
"reveal": "never",
30+
"group": "watchers"
31+
},
32+
"group": "build"
33+
},
34+
{
35+
"label": "tasks: watch-tests",
36+
"dependsOn": [
37+
"npm: watch",
38+
"npm: watch-tests"
39+
],
40+
"problemMatcher": []
41+
}
42+
]
43+
}

.vscodeignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.vscode/**
2+
.vscode-test/**
3+
out/**
4+
node_modules/**
5+
src/**
6+
.gitignore
7+
.yarnrc
8+
webpack.config.js
9+
vsc-extension-quickstart.md
10+
**/tsconfig.json
11+
**/.eslintrc.json
12+
**/*.map
13+
**/*.ts

.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--ignore-engines true

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
All notable changes to the "selection-manager" extension will be documented in this file.
4+
5+
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6+
7+
## [Unreleased]
8+
9+
- Initial release

README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# selection-manager README
2+
3+
This is the README for your extension "selection-manager". After writing up a brief description, we recommend including the following sections.
4+
5+
## Features
6+
7+
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
8+
9+
For example if there is an image subfolder under your extension project workspace:
10+
11+
\!\[feature X\]\(images/feature-x.png\)
12+
13+
> 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.
14+
15+
## Requirements
16+
17+
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
18+
19+
## Extension Settings
20+
21+
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
22+
23+
For example:
24+
25+
This extension contributes the following settings:
26+
27+
* `myExtension.enable`: enable/disable this extension
28+
* `myExtension.thing`: set to `blah` to do something
29+
30+
## Known Issues
31+
32+
Calling out known issues can help limit users opening duplicate issues against your extension.
33+
34+
## Release Notes
35+
36+
Users appreciate release notes as you update your extension.
37+
38+
### 1.0.0
39+
40+
Initial release of ...
41+
42+
### 1.0.1
43+
44+
Fixed issue #.
45+
46+
### 1.1.0
47+
48+
Added features X, Y, and Z.
49+
50+
-----------------------------------------------------------------------------------------------------------
51+
## Following extension guidelines
52+
53+
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
54+
55+
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines)
56+
57+
## Working with Markdown
58+
59+
**Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
60+
61+
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux)
62+
* Toggle preview (`Shift+CMD+V` on macOS or `Shift+Ctrl+V` on Windows and Linux)
63+
* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (macOS) to see a list of Markdown snippets
64+
65+
### For more information
66+
67+
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
68+
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
69+
70+
**Enjoy!**

package.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "selection-manager",
3+
"displayName": "Selection Manager",
4+
"description": "Manage selected text of a file.",
5+
"version": "0.0.1",
6+
"engines": {
7+
"vscode": "^1.66.0"
8+
},
9+
"categories": [
10+
"Other"
11+
],
12+
"activationEvents": [
13+
"onCommand:selection-manager.helloWorld"
14+
],
15+
"main": "./dist/extension.js",
16+
"contributes": {
17+
"commands": [
18+
{
19+
"command": "selection-manager.helloWorld",
20+
"title": "Hello World"
21+
}
22+
]
23+
},
24+
"scripts": {
25+
"vscode:prepublish": "yarn run package",
26+
"compile": "webpack",
27+
"watch": "webpack --watch",
28+
"package": "webpack --mode production --devtool hidden-source-map",
29+
"compile-tests": "tsc -p . --outDir out",
30+
"watch-tests": "tsc -p . -w --outDir out",
31+
"pretest": "yarn run compile-tests && yarn run compile && yarn run lint",
32+
"lint": "eslint src --ext ts",
33+
"test": "node ./out/test/runTest.js"
34+
},
35+
"devDependencies": {
36+
"@types/vscode": "^1.66.0",
37+
"@types/glob": "^7.2.0",
38+
"@types/mocha": "^9.1.0",
39+
"@types/node": "14.x",
40+
"@typescript-eslint/eslint-plugin": "^5.16.0",
41+
"@typescript-eslint/parser": "^5.16.0",
42+
"eslint": "^8.11.0",
43+
"glob": "^7.2.0",
44+
"mocha": "^9.2.2",
45+
"typescript": "^4.5.5",
46+
"ts-loader": "^9.2.8",
47+
"webpack": "^5.70.0",
48+
"webpack-cli": "^4.9.2",
49+
"@vscode/test-electron": "^2.1.3"
50+
}
51+
}

src/extension.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// The module 'vscode' contains the VS Code extensibility API
2+
// Import the module and reference it with the alias vscode in your code below
3+
import * as vscode from 'vscode';
4+
5+
// this method is called when your extension is activated
6+
// your extension is activated the very first time the command is executed
7+
export function activate(context: vscode.ExtensionContext) {
8+
9+
// Use the console to output diagnostic information (console.log) and errors (console.error)
10+
// This line of code will only be executed once when your extension is activated
11+
console.log('Congratulations, your extension "selection-manager" is now active!');
12+
13+
// The command has been defined in the package.json file
14+
// Now provide the implementation of the command with registerCommand
15+
// The commandId parameter must match the command field in package.json
16+
let disposable = vscode.commands.registerCommand('selection-manager.helloWorld', () => {
17+
// The code you place here will be executed every time your command is executed
18+
// Display a message box to the user
19+
vscode.window.showInformationMessage('Hello World from Selection Manager!');
20+
});
21+
22+
context.subscriptions.push(disposable);
23+
}
24+
25+
// this method is called when your extension is deactivated
26+
export function deactivate() {}

src/test/runTest.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as path from 'path';
2+
3+
import { runTests } from '@vscode/test-electron';
4+
5+
async function main() {
6+
try {
7+
// The folder containing the Extension Manifest package.json
8+
// Passed to `--extensionDevelopmentPath`
9+
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
10+
11+
// The path to test runner
12+
// Passed to --extensionTestsPath
13+
const extensionTestsPath = path.resolve(__dirname, './suite/index');
14+
15+
// Download VS Code, unzip it and run the integration test
16+
await runTests({ extensionDevelopmentPath, extensionTestsPath });
17+
} catch (err) {
18+
console.error('Failed to run tests');
19+
process.exit(1);
20+
}
21+
}
22+
23+
main();

src/test/suite/extension.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as assert from 'assert';
2+
3+
// You can import and use all API from the 'vscode' module
4+
// as well as import your extension to test it
5+
import * as vscode from 'vscode';
6+
// import * as myExtension from '../../extension';
7+
8+
suite('Extension Test Suite', () => {
9+
vscode.window.showInformationMessage('Start all tests.');
10+
11+
test('Sample test', () => {
12+
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
13+
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
14+
});
15+
});

src/test/suite/index.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as path from 'path';
2+
import * as Mocha from 'mocha';
3+
import * as glob from 'glob';
4+
5+
export function run(): Promise<void> {
6+
// Create the mocha test
7+
const mocha = new Mocha({
8+
ui: 'tdd',
9+
color: true
10+
});
11+
12+
const testsRoot = path.resolve(__dirname, '..');
13+
14+
return new Promise((c, e) => {
15+
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16+
if (err) {
17+
return e(err);
18+
}
19+
20+
// Add files to the test suite
21+
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22+
23+
try {
24+
// Run the mocha test
25+
mocha.run(failures => {
26+
if (failures > 0) {
27+
e(new Error(`${failures} tests failed.`));
28+
} else {
29+
c();
30+
}
31+
});
32+
} catch (err) {
33+
console.error(err);
34+
e(err);
35+
}
36+
});
37+
});
38+
}

0 commit comments

Comments
 (0)