-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
…e output implementation
- Loading branch information
There are no files selected for viewing
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" | ||
} | ||
} |
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" | ||
] | ||
} |
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" | ||
] | ||
} | ||
] | ||
} |
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. | ||
{ | ||
} |
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 |
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 |
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"); | ||
}); | ||
} |
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" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.