-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added download with progress, and new version check
- Loading branch information
Showing
11 changed files
with
435 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
{ | ||
"name": "mvc", | ||
"language": "ts", | ||
"type": "app", | ||
"framework": "none", | ||
"author": "Maxim Savenkov", | ||
"git": true, | ||
"gitLink": "https://github.com/TeamMV/mvc.git", | ||
"licence": "MIT" | ||
} | ||
"name": "mvc", | ||
"language": "ts", | ||
"type": "app", | ||
"framework": "none", | ||
"author": "Maxim Savenkov", | ||
"git": true, | ||
"gitLink": "https://github.com/TeamMV/mvc.git", | ||
"licence": "MIT", | ||
"frameworkVersion": "v0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import {Input, prompt } from "https://deno.land/x/[email protected]/prompt/mod.ts"; | ||
import { ConfigFile, ScriptsFile, writeConfig, writeScripts } from "../file.ts"; | ||
import { updateVersion } from "../update/repos.ts"; | ||
import { shScript, sh } from "../utils.ts"; | ||
|
||
import { Setup } from "./create.ts"; | ||
|
@@ -68,6 +69,7 @@ export async function finalizeJava(setup: Setup) { | |
language: "java", | ||
type: setup.type, | ||
framework: setup.framework, | ||
frameworkVersion: "none", | ||
author: setup.author, | ||
git: setup.git, | ||
gitLink: setup.gitLink, | ||
|
@@ -92,4 +94,6 @@ export async function finalizeJava(setup: Setup) { | |
|
||
await writeConfig(config); | ||
await writeScripts(scripts); | ||
|
||
await updateVersion("java", config.framework); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { Confirm, Input, Select, prompt } from "https://deno.land/x/[email protected]/prompt/mod.ts"; | ||
import { writeConfig, writeScripts } from "../file.ts"; | ||
import { printSetupHelpMenu } from "../help.ts"; | ||
import { getRepo } from "../update/repos.ts"; | ||
import { getVersion } from "../update/repos.ts"; | ||
import { sh } from "../utils.ts"; | ||
|
||
export interface SetupEmpty { | ||
|
@@ -169,7 +171,7 @@ export async function setupProject(args: string[]) { | |
}, | ||
{ | ||
name: "None", | ||
value: "" | ||
value: "none" | ||
} | ||
] | ||
}]); | ||
|
@@ -185,6 +187,7 @@ export async function setupProject(args: string[]) { | |
language: setup.language!, | ||
type: setup.type!, | ||
framework: setup.framework!, | ||
frameworkVersion: await getVersion(getRepo(setup.language, setup.framework)), | ||
author: setup.author!, | ||
git: setup.git!, | ||
gitLink: setup.gitLink!, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// deno-lint-ignore-file prefer-const ban-types | ||
import ProgressBar from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { bgWhite, green, } from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import { Buffer } from "https://deno.land/[email protected]/io/buffer.ts"; | ||
|
||
export interface Destination { | ||
dir?: string, | ||
file?: string, | ||
mode?: number | ||
} | ||
|
||
export interface DownlodedFile { | ||
file: string, | ||
dir: string, | ||
fullPath: string, | ||
size: number | ||
} | ||
|
||
export async function download(url: string | URL, destination?: Destination, options?: RequestInit) { | ||
let file: string; | ||
let fullPath: string; | ||
let dir = ''; | ||
let mode: object = {}; | ||
let finalUrl: string; | ||
let size: number; | ||
|
||
const response = await fetch(url, options); | ||
finalUrl = response.url.replace(/\/$/, ""); | ||
if (response.status != 200) { | ||
return Promise.reject( | ||
new Deno.errors.Http(`status ${response.status}-'${response.statusText}' received instead of 200`) | ||
); | ||
} | ||
|
||
if (response == null) { | ||
return; | ||
} | ||
|
||
const reader = response.body!.getReader(); | ||
|
||
const contentLength = Math.floor(parseInt(response.headers.get('Content-Length')!) / 1024); | ||
|
||
const progress = new ProgressBar({ | ||
total: contentLength, | ||
preciseBar: [ | ||
bgWhite(green("▏")), | ||
bgWhite(green("▎")), | ||
bgWhite(green("▍")), | ||
bgWhite(green("▌")), | ||
bgWhite(green("▋")), | ||
bgWhite(green("▊")), | ||
bgWhite(green("▉")), | ||
] | ||
}); | ||
|
||
let receivedLength = 0; | ||
|
||
while (true) { | ||
const { done, value } = await reader.read(); | ||
|
||
if (done) { | ||
break; | ||
} | ||
|
||
receivedLength += value.length; | ||
|
||
progress.render(Math.floor(receivedLength / 1024)); | ||
} | ||
|
||
const blob = await response.blob(); | ||
size = blob.size; | ||
const buffer = await blob.arrayBuffer(); | ||
const unit8arr = new Buffer(buffer).bytes(); | ||
if (typeof destination === 'undefined' || typeof destination.dir === 'undefined') { | ||
dir = Deno.makeTempDirSync({ prefix: 'deno_dwld' }); | ||
} | ||
else { | ||
dir = destination.dir; | ||
} | ||
|
||
if (typeof destination === 'undefined' || typeof destination.file === 'undefined') { | ||
file = finalUrl.substring(finalUrl.lastIndexOf('/') + 1); | ||
} | ||
else { | ||
file = destination.file; | ||
} | ||
|
||
if (typeof destination != 'undefined' && typeof destination.mode != 'undefined') { | ||
mode = { mode: destination.mode } | ||
} | ||
|
||
dir = dir.replace(/\/$/, ""); | ||
|
||
fullPath = `${dir}/${file}`; | ||
Deno.writeFileSync(fullPath, unit8arr, mode); | ||
return Promise.resolve({ file, dir, fullPath, size }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.