-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open liberty starter #112
base: main
Are you sure you want to change the base?
Open liberty starter #112
Changes from 5 commits
d595f52
30b0a46
1d18786
97d1d2c
3b3055e
fb3698a
38eda0e
a1c3e96
ab3ac76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import axios from "axios"; | ||
|
||
export async function getProjectOptions(): Promise<any> { | ||
const response = await axios({ | ||
method: "get", | ||
url: 'https://start.openliberty.io/api/start/info', | ||
}) | ||
return response.data; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
|
||
import * as fs from "fs"; | ||
import * as Path from "path"; | ||
import * as vscode from "vscode"; | ||
import axios from "axios"; | ||
import { LibertyProject } from "./libertyProject"; | ||
import { getReport } from "../util/helperUtil"; | ||
import { LIBERTY_MAVEN_PROJECT, LIBERTY_GRADLE_PROJECT, LIBERTY_MAVEN_PROJECT_CONTAINER, LIBERTY_GRADLE_PROJECT_CONTAINER } from "../definitions/constants"; | ||
import { getGradleTestReport } from "../util/gradleUtil"; | ||
import { pathExists } from "fs-extra"; | ||
|
||
export const terminals: { [libProjectId: number]: LibertyProject } = {}; | ||
let _customParameters = ""; | ||
|
||
|
@@ -145,6 +145,40 @@ export async function startContainerDevMode(libProject?: LibertyProject | undefi | |
} | ||
} | ||
|
||
export async function buildStarterProject( state?: any, libProject?: LibertyProject | undefined): Promise<void> { | ||
var apiURL = `https://start.openliberty.io/api/start?a=${state.a}&b=${state.b}&e=${state.e}&g=${state.g}&j=${state.j}&m=${state.m}`; | ||
const downloadStarterProject = async function(downloadLocation: string): Promise<void> { | ||
axios({ | ||
method: "get", | ||
url: apiURL, | ||
responseType: "stream" | ||
}).then( function (response){ | ||
response.data.pipe(fs.createWriteStream(downloadLocation)) | ||
.on("close", () => { | ||
var unzip = require("unzip-stream"); | ||
fs.createReadStream(downloadLocation).pipe(unzip.Extract({ path: `${state.dir}/${state.a}`})); | ||
fs.unlink(downloadLocation, async (err) => { | ||
const folderUri = vscode.Uri.file(state.dir); | ||
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders[0].uri.fsPath != state.dir) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the idea here that if the workspace is empty we automatically add the newly generated project to the current workspace? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if it's empty or the target dir is the same as the currrent, then we don't ask to open in a new window. |
||
await vscode.window.showInformationMessage("Where would you like to open the project?", "Current Window", "New Window") | ||
.then(selection => { | ||
if (selection == "Current Window") { | ||
vscode.commands.executeCommand(`vscode.openFolder`, folderUri); | ||
} else { | ||
vscode.commands.executeCommand(`vscode.openFolder`, folderUri, true); | ||
} | ||
}); | ||
} else { | ||
vscode.commands.executeCommand(`vscode.openFolder`, folderUri); | ||
} | ||
}) | ||
}) | ||
}); | ||
} | ||
let zipPath = `${state.dir}/${state.a}.zip`; | ||
downloadStarterProject(zipPath); | ||
} | ||
|
||
// run tests on dev mode | ||
export async function runTests(libProject?: LibertyProject | undefined): Promise<void> { | ||
if (libProject !== undefined) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to open the parent folder of the newly generated project rather than the newly generated project. For example, if I generate into my downloads, my entire downloads folder is opened in VS Code rather than just the
app-name
project I generatedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in fb3698a. Not sure if it is the flow we are looking for. I also used a timeout to refresh the file explore. I'll go back and use async/await, when I have more time.