From b3e9ea3b3ed04c9c5eb076468d084a45d2dc1848 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 4 Apr 2018 00:47:17 +0200 Subject: [PATCH 1/6] change to compileServeD for beta branch --- src/extension.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 16d5b9e..b277200 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode"; import * as path from "path"; import * as fs from "fs"; import { LanguageClient, LanguageClientOptions, ServerOptions, DocumentFilter, NotificationType } from "vscode-languageclient"; -import { setContext, downloadDub, installServeD, getInstallOutput } from "./installer" +import { setContext, downloadDub, installServeD, compileServeD, getInstallOutput } from "./installer" import { EventEmitter } from "events" import * as ChildProcess from "child_process" @@ -18,7 +18,7 @@ import { DubDependency, DubDependencyInfo } from "./dub-view"; const opn = require('opn'); -const isBeta = false; +const isBeta = true; export class ServeD extends EventEmitter implements vscode.TreeDataProvider { constructor(public client: LanguageClient) { @@ -296,7 +296,7 @@ function preStartup(context: vscode.ExtensionContext) { checkProgram("dubPath", "dub", "dub", downloadDub, "Download", () => { if (isBeta && !context.globalState.get("newestServed", false)) { context.globalState.update("newestServed", true).then(() => { - installServeD(env, () => { + compileServeD(env, () => { setTimeout(() => { // make sure settings get updated startClient(context); From 749c4963da80de16dfe619d599d14b965c5dd928 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 4 Apr 2018 10:46:50 +0200 Subject: [PATCH 2/6] distribute dcd with serve-d on windows --- src/extension.ts | 4 +- src/installer.ts | 102 +++++++++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index b277200..ccf7b1d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -300,7 +300,7 @@ function preStartup(context: vscode.ExtensionContext) { setTimeout(() => { // make sure settings get updated startClient(context); - }, 200); + }, 500); }); }); } @@ -309,7 +309,7 @@ function preStartup(context: vscode.ExtensionContext) { // make sure settings get updated setTimeout(() => { startClient(context); - }, 200); + }, 500); }); } }); diff --git a/src/installer.ts b/src/installer.ts index af14392..8bba985 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -127,15 +127,18 @@ export function downloadDub(env: any, done: Function) { } export function installServeD(env: any, done: Function) { - var url: string; + var urls: string[]; var ext: string; // TODO: platform checks here if (process.platform == "linux" && process.arch == "x64") { - url = "https://github.com/Pure-D/serve-d/releases/download/v" + TARGET_SERVED_VERSION.join(".") + "/serve-d_" + TARGET_SERVED_VERSION.join(".") + "-linux-x86_64.tar.xz"; + urls = ["https://github.com/Pure-D/serve-d/releases/download/v" + TARGET_SERVED_VERSION.join(".") + "/serve-d_" + TARGET_SERVED_VERSION.join(".") + "-linux-x86_64.tar.xz"]; ext = ".tar.xz"; } else if (process.platform == "win32") { - url = "https://github.com/Pure-D/serve-d/releases/download/v" + TARGET_SERVED_VERSION.join(".") + "/serve-d_" + TARGET_SERVED_VERSION.join(".") + "-windows.zip"; + urls = [ + "https://github.com/Pure-D/serve-d/releases/download/v" + TARGET_SERVED_VERSION.join(".") + "/serve-d_" + TARGET_SERVED_VERSION.join(".") + "-windows.zip", + "https://github.com/Pure-D/serve-d/releases/download/v0.1.2/dcd_0.9.2-windows.zip" + ]; ext = ".zip"; } else @@ -155,53 +158,66 @@ export function installServeD(env: any, done: Function) { fs.mkdirSync(outputFolder); if (fs.existsSync(finalDestination)) fs.unlinkSync(finalDestination); - output.appendLine("Downloading from " + url + " into " + outputFolder); - var outputPath = path.join(outputFolder, "serve-d" + ext); - progress(req()(url)).on("progress", (state: any) => { - output.appendLine("Downloaded " + (state.percentage * 100).toFixed(2) + "%" + (state.time.remaining ? " (ETA " + state.time.remaining.toFixed(1) + "s)" : "")); - }).pipe(fs.createWriteStream(outputPath)).on("finish", () => { - output.appendLine("Extracting serve-d"); - if (ext == ".zip") { - fs.createReadStream(outputPath).pipe(unzip.Extract({ path: outputFolder })).on("finish", () => { + async.each(urls, function (url: string, cb: Function) { + output.appendLine("Downloading from " + url + " into " + outputFolder); + var fileName = path.basename(url, ext); + var outputPath = path.join(outputFolder, fileName); + progress(req()(url)).on("progress", (state: any) => { + output.appendLine("Downloaded " + (state.percentage * 100).toFixed(2) + "%" + (state.time.remaining ? " (ETA " + state.time.remaining.toFixed(1) + "s)" : "")); + }).pipe(fs.createWriteStream(outputPath)).on("finish", () => { + output.appendLine("Extracting " + fileName); + if (ext == ".zip") { try { - output.appendLine("Deleting " + outputPath); - fs.unlink(outputPath, (err) => { - if (err) - output.appendLine("Failed to delete " + outputPath); + fs.createReadStream(outputPath).pipe(unzip.Extract({ path: outputFolder })).on("finish", () => { + try { + output.appendLine("Deleting " + outputPath); + fs.unlink(outputPath, (err) => { + if (err) + output.appendLine("Failed to delete " + outputPath); + }); + } + catch (e) { + vscode.window.showErrorMessage("Failed to delete temporary file: " + outputPath); + } + cb(); }); } catch (e) { - vscode.window.showErrorMessage("Failed to delete temporary file: " + outputPath); + return cb(e); } - - config().update("servedPath", finalDestination, true); - done(true); + } + else if (ext == ".tar.xz") { + output.appendLine("> tar xvfJ " + fileName); + ChildProcess.spawn("tar", ["xvfJ", fileName], { + cwd: outputFolder + }).on("exit", function (code) { + if (code != 0) { + return cb(code); + } + try { + output.appendLine("Deleting " + outputPath); + fs.unlink(outputPath, (err) => { + if (err) + output.appendLine("Failed to delete " + outputPath); + }); + } + catch (e) { + vscode.window.showErrorMessage("Failed to delete temporary file: " + outputPath); + } + return cb(); + }); + } + }); + }, function (err: any) { + if (err) { + vscode.window.showErrorMessage("Failed to download release", "Compile from source").then((r?: string) => { + if (r == "Compile from source") + compileServeD(env, done); }); } - else if (ext == ".tar.xz") { - output.appendLine("> tar xvfJ serve-d" + ext); - ChildProcess.spawn("tar", ["xvfJ", "serve-d" + ext], { - cwd: outputFolder - }).on("exit", function (code) { - if (code != 0) - return vscode.window.showErrorMessage("Failed to extract .tar.xz release", "Compile from source").then((r?: string) => { - if (r == "Compile from source") - compileServeD(env, done); - }); - try { - output.appendLine("Deleting " + outputPath); - fs.unlink(outputPath, (err) => { - if (err) - output.appendLine("Failed to delete " + outputPath); - }); - } - catch (e) { - vscode.window.showErrorMessage("Failed to delete temporary file: " + outputPath); - } - - config().update("servedPath", finalDestination, true); - done(true); - }); + else { + config().update("servedPath", finalDestination, true); + done(true); } }); }); From 2538311f0543ca3a113a1d66829a9f02b9244d0d Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 4 Apr 2018 12:31:04 +0200 Subject: [PATCH 3/6] fixed project creator on windows --- src/project-creator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project-creator.ts b/src/project-creator.ts index 4a3380c..f04f8ce 100644 --- a/src/project-creator.ts +++ b/src/project-creator.ts @@ -51,7 +51,7 @@ export function showProjectCreator(context: vscode.ExtensionContext) { openFolderWithExtension(context); } }); - var path = folders[0].uri.path; + var path = folders[0].uri.fsPath; return fs.readdir(path, function (err, files) { if (files.length == 0) return performTemplateCopy(context, template.id, template.json, path, function () { From be2f326284f8a783ffe87c6bcc65775de89afdaa Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 4 Apr 2018 13:38:07 +0200 Subject: [PATCH 4/6] update template dependencies --- templates/info.json | 65 ++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/templates/info.json b/templates/info.json index b672aac..77ab7bf 100644 --- a/templates/info.json +++ b/templates/info.json @@ -17,7 +17,7 @@ "path": "EmptyDlangUI", "dub": { "dependencies": { - "dlangui": "~>0.9.7" + "dlangui": "~>0.9.177" } } }, @@ -27,7 +27,7 @@ "path": "EmptyGTKD", "dub": { "dependencies": { - "gtk-d:gtkd": "~>3.3.1" + "gtk-d:gtkd": "~>3.8.0" } } }, @@ -37,7 +37,7 @@ "path": "EmptyVibeServer", "dub": { "dependencies": { - "vibe-d": "~>0.7.30-rc.1" + "vibe-d": "~>0.8.3" }, "versions": [ "VibeDefaultMain" @@ -50,7 +50,7 @@ "path": "BasicVibeServer", "dub": { "dependencies": { - "vibe-d": "~>0.7.30-rc.1" + "vibe-d": "~>0.8.3" }, "versions": [ "VibeDefaultMain" @@ -63,8 +63,8 @@ "path": "EmptyOpenGL_SDL", "dub": { "dependencies": { - "derelict-gl3": "~>1.0.19", - "derelict-sdl2": "~>1.9.7" + "derelict-gl3": "~>1.0.24", + "derelict-sdl2": "~>2.1.4" } } }, @@ -74,8 +74,8 @@ "path": "EmptyLegacyOpenGL_SDL", "dub": { "dependencies": { - "derelict-gl3": "~>1.0.19", - "derelict-sdl2": "~>1.9.7" + "derelict-gl3": "~>1.0.24", + "derelict-sdl2": "~>2.1.4" } } }, @@ -91,7 +91,7 @@ "path": "EmptyX11", "dub": { "dependencies": { - "x11": "~>1.0.15" + "x11": "~>1.0.20" } } }, @@ -101,13 +101,24 @@ "path": "EmptyDiamondWebsite", "dub": { "dependencies": { - "vibe-d": "~>0.8.1", - "diamond": "~>2.4.5", - "mysql-native": "~>1.1.2" + "vibe-d": "~>0.8.3", + "diamond": "~>2.8.5", + "mysql-native": "~>2.2.1" }, - "versions": ["VibeDefaultMain", "Diamond_Debug", "Diamond_WebServer"], - "sourcePaths": ["core", "models", "controllers"], - "stringImportPaths": ["config", "views"] + "versions": [ + "VibeDefaultMain", + "Diamond_Debug", + "Diamond_WebServer" + ], + "sourcePaths": [ + "core", + "models", + "controllers" + ], + "stringImportPaths": [ + "config", + "views" + ] } }, { @@ -116,13 +127,23 @@ "path": "EmptyDiamondWebApi", "dub": { "dependencies": { - "vibe-d": "~>0.8.1", - "diamond": "~>2.4.5", - "mysql-native": "~>1.1.2" + "vibe-d": "~>0.8.3", + "diamond": "~>2.8.5", + "mysql-native": "~>2.2.1" }, - "versions": ["VibeDefaultMain", "Diamond_Debug", "Diamond_WebApi"], - "sourcePaths": ["core", "models", "controllers"], - "stringImportPaths": ["config"] + "versions": [ + "VibeDefaultMain", + "Diamond_Debug", + "Diamond_WebApi" + ], + "sourcePaths": [ + "core", + "models", + "controllers" + ], + "stringImportPaths": [ + "config" + ] } } -] +] \ No newline at end of file From a7cab0d60b2ed13e5c7cbf55b852ae528093102f Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 4 Apr 2018 14:08:44 +0200 Subject: [PATCH 5/6] update vibe templates --- templates/BasicVibeServer/source/app.d | 6 ++++-- templates/EmptyVibeServer/source/app.d | 6 ++++-- templates/info.json | 10 ++-------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/templates/BasicVibeServer/source/app.d b/templates/BasicVibeServer/source/app.d index 4214d5a..d4f3e18 100644 --- a/templates/BasicVibeServer/source/app.d +++ b/templates/BasicVibeServer/source/app.d @@ -1,6 +1,6 @@ -import vibe.d; +import vibe.vibe; -shared static this() +void main() { auto settings = new HTTPServerSettings; settings.port = 3000; @@ -22,6 +22,8 @@ shared static this() router.registerRestInterface(new MyAPIImplementation, "/api/"); listenHTTP(settings, router); + + runApplication(); } void index(HTTPServerRequest req, HTTPServerResponse res) diff --git a/templates/EmptyVibeServer/source/app.d b/templates/EmptyVibeServer/source/app.d index be9d56f..99ed2a9 100644 --- a/templates/EmptyVibeServer/source/app.d +++ b/templates/EmptyVibeServer/source/app.d @@ -1,11 +1,13 @@ -import vibe.d; +import vibe.vibe; -shared static this() +void main() { auto settings = new HTTPServerSettings; settings.port = 3000; settings.bindAddresses = ["::1", "127.0.0.1"]; listenHTTP(settings, &hello); + + runApplication(); } void hello(HTTPServerRequest req, HTTPServerResponse res) diff --git a/templates/info.json b/templates/info.json index 77ab7bf..139118a 100644 --- a/templates/info.json +++ b/templates/info.json @@ -38,10 +38,7 @@ "dub": { "dependencies": { "vibe-d": "~>0.8.3" - }, - "versions": [ - "VibeDefaultMain" - ] + } } }, { @@ -51,10 +48,7 @@ "dub": { "dependencies": { "vibe-d": "~>0.8.3" - }, - "versions": [ - "VibeDefaultMain" - ] + } } }, { From c3da49da658792de09234fbf6983fabb23e34eb7 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 5 Apr 2018 22:31:28 +0200 Subject: [PATCH 6/6] beta deprecation notice --- src/extension.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index ccf7b1d..e1a0cef 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -140,6 +140,9 @@ function startClient(context: vscode.ExtensionContext) { } export function activate(context: vscode.ExtensionContext) { + config().update("betaStream", true); + vscode.window.showErrorMessage("code-d beta is being deprecated. Switch to webfreak.code-d and set the d.betaStream setting to receive all the latest features."); + // TODO: Port to serve-d /*{ var phobosPath = config().getStdlibPath();