From 24e07e6423485e69f3b3c574f773df87250c3004 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 31 Oct 2017 10:50:24 +0800 Subject: [PATCH] :tada: Initial commit --- .eslintrc.json | 23 +++++++++++++++ .gitignore | 3 ++ .vscode/extensions.json | 7 +++++ .vscode/launch.json | 22 ++++++++++++++ .vscode/settings.json | 3 ++ .vscodeignore | 7 +++++ README.md | 65 +++++++++++++++++++++++++++++++++++++++++ extension.js | 17 +++++++++++ jsconfig.json | 12 ++++++++ package.json | 45 ++++++++++++++++++++++++++++ test/extension.test.js | 24 +++++++++++++++ test/index.js | 22 ++++++++++++++ 12 files changed, 250 insertions(+) create mode 100644 .eslintrc.json create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscodeignore create mode 100644 README.md create mode 100644 extension.js create mode 100644 jsconfig.json create mode 100644 package.json create mode 100644 test/extension.test.js create mode 100644 test/index.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..02509e2 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": false, + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "module" + }, + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "warn", + "no-unreachable": "warn", + "no-unused-vars": "warn", + "constructor-super": "warn", + "valid-typeof": "warn" + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..343fa72 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +.vscode-test/ +.vsix diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..0915202 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the extensions.json format + "recommendations": [ + "dbaeumer.vscode-eslint" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2131f2c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +// A launch configuration that launches the extension inside a new window +{ + "version": "0.1.0", + "configurations": [ + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], + "stopOnEntry": false + }, + { + "name": "Launch Tests", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ], + "stopOnEntry": false + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..20af2f6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +// Place your settings in this file to overwrite default and user settings. +{ +} \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..499648c --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,7 @@ +.vscode/** +.vscode-test/** +test/** +.gitignore +jsconfig.json +vsc-extension-quickstart.md +.eslintrc.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..94908ea --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# file-name-search README + +This is the README for your extension "file-name-search". 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. + +----------------------------------------------------------------------------------------------------------- + +## Working with Markdown + +**Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: + +* Split the editor (`Cmd+\` on OSX or `Ctrl+\` on Windows and Linux) +* Toggle preview (`Shift+CMD+V` on OSX or `Shift+Ctrl+V` on Windows and Linux) +* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (OSX) 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!** \ No newline at end of file diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..89db791 --- /dev/null +++ b/extension.js @@ -0,0 +1,17 @@ +const vscode = require('vscode'); + +function activate(context) { + let disposable = vscode.commands.registerCommand('extension.sayHello', function (fileUri) { + if (fileUri != undefined) { + var path = fileUri.fsPath.split("\"")[0]; + var name = path.split("\\")[path.split("\\").length - 1]; + vscode.commands.executeCommand('workbench.action.findInFiles'); + } + }); + context.subscriptions.push(disposable); +} +exports.activate = activate; + +function deactivate() { +} +exports.deactivate = deactivate; \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..b7caa7d --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": [ + "es6" + ] + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..f96693a --- /dev/null +++ b/package.json @@ -0,0 +1,45 @@ +{ + "name": "file-name-search", + "displayName": "File Name Search", + "description": "Quickly search over all files in the currently-opened folder.", + "version": "0.0.1", + "publisher": "Shawn", + "engines": { + "vscode": "^1.17.0" + }, + "categories": [ + "Other" + ], + "activationEvents": [ + "onCommand:extension.sayHello" + ], + "main": "./extension", + "contributes": { + "commands": [ + { + "command": "extension.sayHello", + "title": "Hello World" + } + ], + "menus": { + "explorer/context": [ + { + "command": "extension.sayHello", + "group": "navigation" + } + ] + } + }, + "scripts": { + "postinstall": "node ./node_modules/vscode/bin/install", + "test": "node ./node_modules/vscode/bin/test" + }, + "devDependencies": { + "typescript": "^2.5.2", + "vscode": "^1.1.5", + "mocha": "^3.5.0", + "eslint": "^4.6.1", + "@types/node": "^7.0.0", + "@types/mocha": "^2.2.42" + } +} \ No newline at end of file diff --git a/test/extension.test.js b/test/extension.test.js new file mode 100644 index 0000000..c2ae013 --- /dev/null +++ b/test/extension.test.js @@ -0,0 +1,24 @@ +/* global suite, test */ + +// +// Note: This example test is leveraging the Mocha test framework. +// Please refer to their documentation on https://mochajs.org/ for help. +// + +// The module 'assert' provides assertion methods from node +const assert = require('assert'); + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +const vscode = require('vscode'); +const myExtension = require('../extension'); + +// Defines a Mocha test suite to group tests of similar kind together +suite("Extension Tests", function() { + + // Defines a Mocha unit test + test("Something 1", function() { + assert.equal(-1, [1, 2, 3].indexOf(5)); + assert.equal(-1, [1, 2, 3].indexOf(0)); + }); +}); \ No newline at end of file diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..a0c8b63 --- /dev/null +++ b/test/index.js @@ -0,0 +1,22 @@ +// +// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING +// +// This file is providing the test runner to use when running extension tests. +// By default the test runner in use is Mocha based. +// +// You can provide your own test runner if you want to override it by exporting +// a function run(testRoot: string, clb: (error:Error) => void) that the extension +// host can call to run the tests. The test runner is expected to use console.log +// to report the results back to the caller. When the tests are finished, return +// a possible error to the callback or null if none. + +const testRunner = require('vscode/lib/testrunner'); + +// You can directly control Mocha options by uncommenting the following lines +// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info +testRunner.configure({ + ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.) + useColors: true // colored output from test results +}); + +module.exports = testRunner; \ No newline at end of file