Skip to content

Commit

Permalink
Merge pull request #71 from purduesigbots/develop
Browse files Browse the repository at this point in the history
Release Version 0.4.1
  • Loading branch information
BennyBot authored Jul 25, 2022
2 parents 8868d66 + f4dc9d2 commit 954324a
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 64 deletions.
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"color": "#D6B872",
"theme": "dark"
},
"version": "0.4.0",
"version": "0.4.1",
"engines": {
"vscode": "^1.56.0"
},
Expand Down Expand Up @@ -197,6 +197,16 @@
"type": "boolean",
"default": true,
"description": "Prompt for PROS CLI install on startup."
},
"pros.OneClick: CliDownloadURL": {
"type": "string",
"default": "default",
"description": "URL to download PROS CLI from. SHOULD NOT BE CHANGED BY MOST USERS!"
},
"pros.OneClick: ToolchainDownloadURL": {
"type": "string",
"default": "default",
"description": "URL to download PROS Toolchain from. SHOULD NOT BE CHANGED BY MOST USERS!"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const runBuild = async () => {
async (progress, token) => {
try {
// Command to run to build project
var command = `pros make --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros make --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
console.log(process.env["PATH"]);
const { stdout, stderr } = await promisify(child_process.exec)(
Expand Down
3 changes: 2 additions & 1 deletion src/commands/buildUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const runBuildUpload = async () => {
async (progress, token) => {
try {
// Command to run to build and upload project
var command = `pros mu --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros mu --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(
command,
Expand All @@ -30,6 +30,7 @@ const runBuildUpload = async () => {
...process.env,
PATH: getChildProcessPath(),
},
maxBuffer: 1024 * 1024 * 50
}
);
await vscode.window.showInformationMessage("Project Built!");
Expand Down
2 changes: 1 addition & 1 deletion src/commands/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const runCapture = async (output: string) => {
async (progress, token) => {
try {
// Command to run to clean project
var command = `pros v5 capture ${output} --force ${process.env["VSCODE FLAGS"]} --machine-output`;
var command = `pros v5 capture ${output} --force ${process.env["PROS_VSCODE_FLAGS"]} --machine-output`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(
command,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const runClean = async () => {
async (progress, token) => {
try {
// Command to run to clean project
var command = `pros make clean --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros make clean --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(
command,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const selectProjectName = async () => {
*/
const selectKernelVersion = async (target: string) => {
// Command to run to fetch all kernel versions
var command = `pros c ls-templates --target ${target} --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros c ls-templates --target ${target} --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(command, {
env: {
Expand Down Expand Up @@ -140,7 +140,7 @@ const runCreateProject = async (
try {
// Command to run to make a new project with
// user specified name, version, and location
var command = `pros c n "${projectPath}" ${target} ${version} --machine-output --build-cache ${process.env["VSCODE FLAGS"]}`;
var command = `pros c n "${projectPath}" ${target} ${version} --machine-output --build-cache ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(
command,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/upgrade-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const fetchTarget = async (): Promise<{
curOkapi: string | undefined;
}> => {
// Command to run to fetch the current project that needs to be updated
var command = `pros c info-project --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros c info-project --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
// console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(command, {
env: {
Expand Down Expand Up @@ -55,7 +55,7 @@ const fetchServerVersions = async (
target: string
): Promise<{ newKernel: string; newOkapi: string | undefined }> => {
// Command to run to fetch latest okapi and kernel versions
var command = `pros c q --target ${target} --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros c q --target ${target} --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
// console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(command, {
env: {
Expand Down Expand Up @@ -91,7 +91,7 @@ const fetchServerVersions = async (
*/
const runUpgrade = async () => {
// Command to run to upgrade project to a newer version
var command = `pros c u --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros c u --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(command, {
encoding: "utf8",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const runUpload = async () => {
async (progress, token) => {
try {
// Command to run to upload project to brain
var command = `pros u --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["VSCODE FLAGS"]}`;
var command = `pros u --project "${vscode.workspace.workspaceFolders?.[0].uri.fsPath}" --machine-output ${process.env["PROS_VSCODE_FLAGS"]}`;
console.log(command);
const { stdout, stderr } = await promisify(child_process.exec)(
command,
Expand Down
19 changes: 4 additions & 15 deletions src/one-click/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async function download(
async (progress, token) => {
var out: fs.WriteStream;
token.onCancellationRequested(() => {
console.log("User canceled the long running operation");
out!.destroy();
});
// Fetch the file to download
Expand All @@ -44,12 +43,10 @@ async function download(
response.body.on("data", (chunk: Buffer) => {
progress.report({ increment: chunk.length * 100 / total_size });
});
console.log("Write stream created")
// Write file contents to "sigbots.pros/download/filename.tar.bz2"
out = fs.createWriteStream(
path.join(globalPath, "download", storagePath)
);
console.log("Start stream pipeline");
await promisify(stream.pipeline)(response.body, out).catch((e) => {
// Clean up the partial file if the download failed.
fs.unlink(
Expand All @@ -59,11 +56,9 @@ async function download(
console.log(e);
throw e;
});
console.log("Finished downloading")

}
);
console.log("returning bz2 status");
return bz2;
}

Expand Down Expand Up @@ -91,31 +86,28 @@ export async function extract(

if (bz2) {
// Read the contents of the bz2 file
console.log("Extracting bz2 file");
var compressedData = await fs.promises.readFile(
path.join(globalPath, "download", storagePath)
);

console.log("Decoding bz2");

// Decrypt the bz2 file contents.
let decompressedData;
try {
decompressedData = bunzip.decode(compressedData);
} catch(e: any) {
console.log(e);
vscode.window.showErrorMessage("An error occured while decoding the toolchain");
console.log("Decoding failed");
}

console.log("Bz2 decoded");

storagePath = storagePath.replace(".bz2", "");
await fs.promises.writeFile(
path.join(globalPath, "download", storagePath),
decompressedData
);
console.log("Completed extraction of bz2 file");
// Write contents of the decrypted bz2 into "sigbots.pros/download/filename.tar"
console.log("Extracting tar file");


await new Promise(function(resolve, reject) {
// Create our read stream
Expand Down Expand Up @@ -166,24 +158,21 @@ export async function extract(

} // if bz2
else {
console.log("start extraction");
let readPath = path.join(globalPath, "download", storagePath);
storagePath = storagePath.replace(".zip","");
let writePath = path.join(globalPath, "install", storagePath);

// Extract the contents of the zip file
await fs.createReadStream(readPath).pipe(unzipper.Extract({ path: writePath})).promise();
console.log("Start file moving");
if (storagePath.includes("pros-toolchain-windows")) {

// create tmp folder
console.log("Create tmp folder");
await fs.promises.mkdir(
path.join(globalPath, "install", "pros-toolchain-windows", "tmp")
);

// extract contents of gcc-arm-none-eabi-version folder
console.log("began reading usr");

const files = await fs.promises.readdir(
path.join(globalPath, "install", "pros-toolchain-windows", "usr")
);
Expand Down
Loading

0 comments on commit 954324a

Please sign in to comment.