Skip to content

Commit

Permalink
#2 #3 #4 #6 #7 Add AppRun, AppMake, AppSettings, AppUpload and consol…
Browse files Browse the repository at this point in the history
…e output implementation
  • Loading branch information
Zhitao Pan committed Dec 20, 2018
1 parent ae3d1fa commit 1178883
Show file tree
Hide file tree
Showing 4,175 changed files with 1,252,953 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place your settings in this file to overwrite default and user settings.
{
}
8 changes: 8 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.vscode/**
.vscode-test/**
test/**
.gitignore
vsc-extension-quickstart.md
**/jsconfig.json
**/*.map
**/.eslintrc.json
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Change Log
All notable changes to the "appstudio" 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
171 changes: 171 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const { spawn } = require('child_process');
const { window, workspace, commands } = vscode;

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {

// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "appstudio" is now active!');

// Array containing the paths of all qml projects in the workspace
let qmlProjectPaths = [];
// Console ouput for the AppStudio Apps
let consoleOutput = window.createOutputChannel('AppStudio');

// Function to find files with extension '.qmlproject' across all workspace folders,
// and add the folder path to the qmlProjectPaths array
let addQmlProject = () => {
workspace.findFiles('*.qmlproject').then( result => {
result.forEach( uri => {
let folderPath = workspace.getWorkspaceFolder(uri).uri.fsPath;
qmlProjectPaths.push(folderPath);
});
});
}

addQmlProject();

// Event emitted when a workspace folder is added or removed
// Empty the qmlProjectPaths array and call the function to add qml projects again
workspace.onDidChangeWorkspaceFolders( () => {
qmlProjectPaths = [];
addQmlProject();
});

// Command to select the AppStudio bin folder for executables
let selectBinFolderCmd = commands.registerCommand('selectBinFolder', function () {

//window.showInformationMessage('Current AppStudio bin folder: ' + workspace.getConfiguration().get('AppStudio Bin Folder'));

window.showOpenDialog({
canSelectFolders: true,
canSelectFiles: false,
canSelectMany: false
}).then( folder => {
if (folder !== undefined && folder.length === 1) {
workspace.getConfiguration().update('AppStudio Bin Folder', folder[0].fsPath.toString(),true);
window.showInformationMessage('AppStudio bin folder updated: ' + folder[0].fsPath);
}
});
});

// Commands to run all executables
let appRunCmd = commands.registerCommand('appRun', () => {
createCommand('\\appRun.exe', qmlProjectPaths, consoleOutput);
});

let appMakeCmd = commands.registerCommand('appMake', () => {
createCommand('\\appMake.exe', qmlProjectPaths, consoleOutput);
});

let appSettingCmd = commands.registerCommand('appSetting', () => {
createCommand('\\appSettings.exe', qmlProjectPaths, consoleOutput);
});

let appUploadCmd = commands.registerCommand('appUpload', () => {
createCommand('\\appUpload.exe', qmlProjectPaths, consoleOutput);
});

// Add to a list of disposables which are disposed when this extension is deactivated.
context.subscriptions.push(selectBinFolderCmd);
context.subscriptions.push(appRunCmd);
context.subscriptions.push(appMakeCmd);
context.subscriptions.push(appSettingCmd);
context.subscriptions.push(appUploadCmd);

// Create status bar items for the commands
createStatusBarItem('$(file-directory)', 'selectBinFolder', "Select Bin Folder");
createStatusBarItem('$(gear)', 'appSetting', 'appSetting');
createStatusBarItem('$(cloud-upload)', 'appUpload', 'appUpload');
createStatusBarItem('$(circuit-board)', 'appMake', 'appMake');
createStatusBarItem('$(triangle-right)', 'appRun', 'appRun');

}
exports.activate = activate;

// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;

function createStatusBarItem(itemText, itemCommand, itemTooltip) {
const statusBarItem = window.createStatusBarItem(vscode.StatusBarAlignment.Left);
statusBarItem.text = itemText;
statusBarItem.command = itemCommand;
statusBarItem.tooltip = itemTooltip;
statusBarItem.show();
}

// Create commands to run the executables
function createCommand (executable, qmlProjectPaths, consoleOutputs) {
let appStudioBinPath = workspace.getConfiguration().get('AppStudio Bin Folder');

if (appStudioBinPath === "") {
window.showWarningMessage("Please select the AppStudio bin folder first.");
return;
}

if (!workspace.workspaceFolders) {
window.showWarningMessage('No folder opened.');
} else {

if (qmlProjectPaths.length === 0) {
window.showErrorMessage("No qmlproject found.");
} else if (qmlProjectPaths.length > 1) {
// if there are more than one qml projects in the workspace, prompts the user to select one of them to run the command

window.showQuickPick(qmlProjectPaths, {
placeHolder: 'Multiple qmlprojects detected in workspace, please choose one to proceed'
}).then( folder => {
if(folder !== undefined) {
runProcess(consoleOutputs,appStudioBinPath,executable,folder);
}
});

} else {
runProcess(consoleOutputs,appStudioBinPath,executable,qmlProjectPaths[0]);
}
}
}

// run the executable with the corresponding paths and parameters
function runProcess(consoleOutput, appStudioBinPath, executable, qmlProjectPath) {

consoleOutput.show();
consoleOutput.appendLine("Starting external tool " + "\"" + appStudioBinPath + executable + " " + qmlProjectPath + "\"");
//let process = execFile(appStudioBinPath + '\\AppRun.exe ' + projectPath, { env:
let process = spawn(appStudioBinPath + executable, [qmlProjectPath], { env:
{
'QT_ASSUME_STDERR_HAS_CONSOLE':'1',
'QT_FORCE_STDERR_LOGGING':'1'
}}
);

process.stdout.on('data', data => {
consoleOutput.show();
consoleOutput.append(data.toString());
});

process.stderr.on('data', data => {
consoleOutput.show();
consoleOutput.append(data.toString());
});

process.on('error', err => {
window.showErrorMessage('Error occured during execution, see console output for more details.');
window.showWarningMessage('Please ensure correct path for AppStudio bin folder is selected.');
consoleOutput.show();
consoleOutput.appendLine(err.message);
console.error(`exec error: ${err}`);
})

process.on('exit', (code) => {
console.log(`child process exited with code ${code}`);
consoleOutput.appendLine("\"" + appStudioBinPath + executable + "\"" + " finished");
});
}
13 changes: 13 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"checkJs": true, /* Typecheck .js files. */
"lib": [
"es6"
]
},
"exclude": [
"node_modules"
]
}
15 changes: 15 additions & 0 deletions node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/_mocha.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions node_modules/.bin/acorn

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/acorn.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions node_modules/.bin/eslint

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/eslint.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions node_modules/.bin/esparse

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/esparse.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions node_modules/.bin/esvalidate

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/esvalidate.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1178883

Please sign in to comment.