diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6a5fc7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.vsix + +.vscode/ + +bin/ + +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a722f44 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## v1.0.0 + +- Initial release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..42d64be --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Bowler Hat LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5179bc5 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Feathers UI for Visual Studio Code + +Provides useful commands for [Feathers UI](https://feathersui.com/) projects created with [Haxe](https://haxe.org/) and [OpenFL](https://openfl.org/) in [Visual Studio Code](https://code.visualstudio.com/). + +## Create a new Feathers UI project + +1. Open an empty workspace folder in Visual Studio Code. +1. Go to the **View** menu and choose **Command Paletteā€¦**. + > Alternatively, use the Ctrl+Shift+P keyboard shortcut (Command+Shift+P on macOS). +1. Run the **Feathers UI: Create new project** command. diff --git a/build.hxml b/build.hxml new file mode 100644 index 0000000..dad116a --- /dev/null +++ b/build.hxml @@ -0,0 +1,5 @@ +-lib vscode +-cp src +-D js-es=6 +-js bin/extension.js +Extension \ No newline at end of file diff --git a/feathersui.png b/feathersui.png new file mode 100644 index 0000000..ae035a2 Binary files /dev/null and b/feathersui.png differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..94c8a48 --- /dev/null +++ b/package.json @@ -0,0 +1,45 @@ +{ + "name": "vscode-feathersui", + "displayName": "Feathers UI", + "description": "Manage Feathers UI projects in VSCode", + "version": "1.0.0", + "private": true, + "publisher": "bowlerhatllc", + "author": { + "name": "Josh Tynjala" + }, + "homepage": "https://feathersui.com/", + "repository": { + "type": "git", + "url": "https://github.com/BowlerHatLLC/vscode-feathersui.git" + }, + "bugs": { + "url": "https://github.com/BowlerHatLLC/vscode-feathersui/issues" + }, + "main": "bin/extension.js", + "icon": "feathersui.png", + "scripts": { + "vscode:prepublish": "haxe build.hxml" + }, + "keywords": [ + "Feathers UI", + "Haxe", + "OpenFL" + ], + "license": "MIT", + "engines": { + "vscode": "^1.36.0" + }, + "activationEvents": [ + "onCommand:feathersui.newProject" + ], + "contributes": { + "commands": [ + { + "command": "feathersui.newProject", + "title": "Create new project", + "category": "Feathers UI" + } + ] + } +} diff --git a/src/Extension.hx b/src/Extension.hx new file mode 100644 index 0000000..80e4136 --- /dev/null +++ b/src/Extension.hx @@ -0,0 +1,45 @@ +import vscode.WorkspaceFolder; +import vscode.ExtensionContext; + +class Extension { + private static final COMMAND_OPEN_FOLDER = "Open Folder"; + + @:expose("activate") + public static function main(context:ExtensionContext):Void { + Vscode.commands.registerCommand("feathersui.newProject", createNewProject); + } + + private static function createNewProject():Void { + var workspaceFolders = Vscode.workspace.workspaceFolders; + if (workspaceFolders == null) { + Vscode.window.showErrorMessage("Failed to create new Feathers UI project. Open an empty folder before running this command.", null, + COMMAND_OPEN_FOLDER) + .then(function(result) { + switch (result) { + case COMMAND_OPEN_FOLDER: + Vscode.commands.executeCommand("workbench.action.files.openFolder"); + } + }); + return; + } + if (workspaceFolders.length == 1) { + var workspaceFolder = workspaceFolders[0]; + createNewProjectInWorkspaceFolder(workspaceFolder); + } else { + Vscode.window.showWorkspaceFolderPick().then((workspaceFolder) -> { + if (workspaceFolder == null) { + return; + } + createNewProjectInWorkspaceFolder(workspaceFolder); + }, (reason) -> { + // do nothing + }); + } + } + + private static function createNewProjectInWorkspaceFolder(workspaceFolder:WorkspaceFolder):Void { + var terminal = Vscode.window.createTerminal(); + terminal.sendText("haxelib run feathersui new-project \"" + workspaceFolder.uri.fsPath + "\" --vscode"); + terminal.show(); + } +}