Initial commit
This commit is contained in:
commit
bb9633fb9b
9 changed files with 293 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
node_modules
|
||||||
|
.vscode-test/
|
||||||
|
*.vsix
|
||||||
28
.vscode/launch.json
vendored
Normal file
28
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
// A launch configuration that launches the extension 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": "Extension",
|
||||||
|
"type": "extensionHost",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeExecutable": "${execPath}",
|
||||||
|
"args": [
|
||||||
|
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Extension Tests",
|
||||||
|
"type": "extensionHost",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeExecutable": "${execPath}",
|
||||||
|
"args": [
|
||||||
|
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||||
|
"--extensionTestsPath=${workspaceFolder}/test"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
}
|
||||||
7
.vscodeignore
Normal file
7
.vscodeignore
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
.vscode/**
|
||||||
|
.vscode-test/**
|
||||||
|
test/**
|
||||||
|
.gitignore
|
||||||
|
jsconfig.json
|
||||||
|
vsc-extension-quickstart.md
|
||||||
|
.eslintrc.json
|
||||||
65
README.md
Normal file
65
README.md
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
# code-gen-vscode README
|
||||||
|
|
||||||
|
This is the README for your extension "code-gen-vscode". 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 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) or `Cmd+Space` (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!**
|
||||||
106
extension.js
Normal file
106
extension.js
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
const vscode = require('vscode');
|
||||||
|
const CodeGenCLI = require('code-gen/src/cli');
|
||||||
|
|
||||||
|
const extension = {
|
||||||
|
|
||||||
|
actions: {},
|
||||||
|
|
||||||
|
hasActions: false,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
process.chdir(vscode.workspace.rootPath);
|
||||||
|
for (let command of CodeGenCLI.commands) {
|
||||||
|
if (typeof command.vsCodeCallback === 'function') {
|
||||||
|
this.hasActions = true;
|
||||||
|
this.actions[command.name()] = command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
prosesOptions(options, i, args, cb) {
|
||||||
|
if(options.length === i) {
|
||||||
|
cb(args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let option = options[i];
|
||||||
|
let next = (value) => {
|
||||||
|
args[option.name] = value;
|
||||||
|
this.prosesOptions(options, (i + 1), args, cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
switch(option.type) {
|
||||||
|
case 'input':
|
||||||
|
vscode.window
|
||||||
|
.showInputBox(option.options || {})
|
||||||
|
.then(next);
|
||||||
|
break;
|
||||||
|
case 'dropdown':
|
||||||
|
vscode.window
|
||||||
|
.showQuickPick(option.items, option.options || {})
|
||||||
|
.then(next);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
generate(item) {
|
||||||
|
let command = extension.actions[item];
|
||||||
|
let callback = () => {};
|
||||||
|
let args = {
|
||||||
|
workspaceRoot: vscode.workspace.rootPath
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof command.vsCodeCallback === 'function') {
|
||||||
|
callback = (args) => {
|
||||||
|
Object.assign(command, args);
|
||||||
|
let message = command.vsCodeCallback.apply(command, args);
|
||||||
|
switch(message.type) {
|
||||||
|
case 'info':
|
||||||
|
vscode.window.showInformationMessage(
|
||||||
|
message.message,
|
||||||
|
message.options || {}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
vscode.window.showErrorMessage(
|
||||||
|
message.message,
|
||||||
|
message.options || {}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof command.vsCodeOptions === 'object') {
|
||||||
|
extension.prosesOptions(
|
||||||
|
command.vsCodeOptions,
|
||||||
|
0,
|
||||||
|
args,
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
callback(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.activate = (context) => {
|
||||||
|
extension.init();
|
||||||
|
|
||||||
|
let disposable = vscode.commands.registerCommand('code-gen.generate', function () {
|
||||||
|
if (extension.hasActions === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vscode.window
|
||||||
|
.showQuickPick(Object.keys(extension.actions))
|
||||||
|
.then(extension.generate);
|
||||||
|
});
|
||||||
|
|
||||||
|
context.subscriptions.push(disposable);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.deactivate = () => {
|
||||||
|
console.log('CodeGen Deactivated');
|
||||||
|
};
|
||||||
35
package.json
Normal file
35
package.json
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"name": "code-gen-vscode",
|
||||||
|
"displayName": "code-gen-vscode",
|
||||||
|
"description": "CodeGen vscode extension for extending the code gen cli tool",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"publisher": "Ade Attwood",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.26.0"
|
||||||
|
},
|
||||||
|
"categories": [
|
||||||
|
"Other"
|
||||||
|
],
|
||||||
|
"activationEvents": [
|
||||||
|
"onCommand:code-gen.generate"
|
||||||
|
],
|
||||||
|
"main": "./extension",
|
||||||
|
"contributes": {
|
||||||
|
"commands": [{
|
||||||
|
"command": "code-gen.generate",
|
||||||
|
"title": "Generate",
|
||||||
|
"category": "Code Gen"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||||
|
"test": "node ./node_modules/vscode/bin/test"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^2.6.1",
|
||||||
|
"vscode": "^1.1.21",
|
||||||
|
"eslint": "^4.11.0",
|
||||||
|
"@types/node": "^8.10.25",
|
||||||
|
"@types/mocha": "^2.2.42"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
test/extension.test.js
Normal file
24
test/extension.test.js
Normal file
|
|
@ -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));
|
||||||
|
});
|
||||||
|
});
|
||||||
22
test/index.js
Normal file
22
test/index.js
Normal file
|
|
@ -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;
|
||||||
Loading…
Reference in a new issue