This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new 065c3be Rework Debugger
065c3be is described below
commit 065c3be736163bd7cbfc66c46d7777973ac00567
Author: Shane Dell <[email protected]>
AuthorDate: Mon Oct 18 15:40:20 2021 -0400
Rework Debugger
- Update extension build to include sbt zip package file
- If extension is being used it will use the zip package in the extension
files to run the serrver
- If running local and the zip package does exist it will be created via
running sbt universal:packageBin then it will be extracted to the proper
location then the server will be ran
Closes #39, #40
---
.vscodeignore | 1 +
src/adapter/activateDaffodilDebug.ts | 12 +++++--
src/daffodilDebugger.ts | 67 +++++++++++++-----------------------
src/hexView.ts | 2 +-
4 files changed, 34 insertions(+), 48 deletions(-)
diff --git a/.vscodeignore b/.vscodeignore
index 9616e48..dec88c4 100644
--- a/.vscodeignore
+++ b/.vscodeignore
@@ -31,3 +31,4 @@ sampleWorkspace
target
server
project
+!server/core/target/universal/daffodil-debugger-*.zip
diff --git a/src/adapter/activateDaffodilDebug.ts
b/src/adapter/activateDaffodilDebug.ts
index 2f8f2e1..ba13144 100644
--- a/src/adapter/activateDaffodilDebug.ts
+++ b/src/adapter/activateDaffodilDebug.ts
@@ -145,7 +145,7 @@ export function activateDaffodilDebug(
)
// register a configuration provider for 'dfdl' debug type
- const provider = new DaffodilConfigurationProvider()
+ const provider = new DaffodilConfigurationProvider(context)
context.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider('dfdl', provider)
)
@@ -274,6 +274,12 @@ export function activateDaffodilDebug(
class DaffodilConfigurationProvider
implements vscode.DebugConfigurationProvider
{
+ context: vscode.ExtensionContext
+
+ constructor(context: vscode.ExtensionContext) {
+ this.context = context
+ }
+
/**
* Massage a debug configuration just before a debug session is being
launched,
* e.g. add all missing attributes to the debug configuration.
@@ -331,13 +337,13 @@ class DaffodilConfigurationProvider
) {
return getDataFileFromFolder(dataFolder).then((dataFile) => {
config.data = dataFile
- return getDebugger(config).then((result) => {
+ return getDebugger(this.context, config).then((result) => {
return config
})
})
}
- return getDebugger(config).then((result) => {
+ return getDebugger(this.context, config).then((result) => {
return config
})
}
diff --git a/src/daffodilDebugger.ts b/src/daffodilDebugger.ts
index 671d46c..b849725 100644
--- a/src/daffodilDebugger.ts
+++ b/src/daffodilDebugger.ts
@@ -22,14 +22,10 @@ import * as os from 'os'
import * as child_process from 'child_process'
import { deactivate } from './adapter/extension'
import { LIB_VERSION } from './version'
-import { HttpClient } from 'typed-rest-client/HttpClient'
import XDGAppPaths from 'xdg-app-paths'
+import * as path from 'path'
-const xdgAppPaths = XDGAppPaths({ name: 'dapodil' })
-
-class Backend {
- constructor(readonly owner: string, readonly repo: string) {}
-}
+const xdgAppPaths = XDGAppPaths({ name: 'daffodil-dap' })
class Artifact {
constructor(
@@ -39,14 +35,12 @@ class Artifact {
name = `daffodil-debugger-${this.daffodilVersion}-${this.version}`
archive = `${this.name}.zip`
- archiveUrl = (backend: Backend) =>
-
`https://github.com/${backend.owner}/${backend.repo}/releases/download/v${this.version}/${this.archive}`
+
scriptName =
os.platform() === 'win32' ? 'daffodil-debugger.bat' : './daffodil-debugger'
}
const daffodilVersion = '3.1.0' // TODO: will become a runtime parameter
driven by config or artifacts in the releases repo
-const backend = new Backend('apache', 'daffodil-vscode')
const artifact = new Artifact(daffodilVersion)
// Class for getting release data
@@ -90,7 +84,10 @@ export async function getDataFileFromFolder(dataFolder:
string) {
}
// Function for getting the daffodil-debugger
-export async function getDebugger(config: vscode.DebugConfiguration) {
+export async function getDebugger(
+ context: vscode.ExtensionContext,
+ config: vscode.DebugConfiguration
+) {
// If useExistingServer var set to false make sure version of debugger
entered is downloaded then ran
if (!config.useExistingServer) {
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms))
@@ -105,42 +102,25 @@ export async function getDebugger(config:
vscode.DebugConfiguration) {
// Code for downloading and setting up daffodil-debugger files
if (!fs.existsSync(`${rootPath}/${artifact.name}`)) {
- // Get daffodil-debugger of version entered using http client
- const client = new HttpClient('client') // TODO: supply daffodil
version from config
- const artifactUrl = artifact.archiveUrl(backend)
- const response = await client.get(artifactUrl)
-
- if (response.message.statusCode !== 200) {
- const err: Error = new Error(
- `Couldn't download the Daffodil debugger backend from
${artifactUrl}.`
+ // Get daffodil-debugger zip from extension files
+ const filePath = path
+ .join(
+ context.asAbsolutePath('./server/core/target/universal'),
+ artifact.archive
)
- err['httpStatusCode'] = response.message.statusCode
- throw err
+ .toString()
+
+ // If debugging the extension without vsix installed make sure
debugger is created
+ if (!filePath.includes('.vscode/extension')) {
+ if (!fs.existsSync(filePath)) {
+ let baseFolder = context.asAbsolutePath('./')
+ child_process.execSync(
+ `cd ${baseFolder} && sbt universal:packageBin`
+ )
+ }
}
- // Create zip from rest call
- const filePath = `${rootPath}/${artifact.archive}`
- const file = fs.createWriteStream(filePath)
-
- await new Promise((res, rej) => {
- file.on(
- 'error',
- (err) =>
- function () {
- throw err
- }
- )
- const stream = response.message.pipe(file)
- stream.on('close', () => {
- try {
- res(filePath)
- } catch (err) {
- rej(err)
- }
- })
- })
-
- // Unzip file and remove zip file
+ // Unzip file
await new Promise((res, rej) => {
let stream = fs
.createReadStream(filePath)
@@ -153,7 +133,6 @@ export async function getDebugger(config:
vscode.DebugConfiguration) {
}
})
})
- fs.unlinkSync(filePath)
}
// Stop debugger if running
diff --git a/src/hexView.ts b/src/hexView.ts
index 114c1f1..f6298fd 100644
--- a/src/hexView.ts
+++ b/src/hexView.ts
@@ -21,7 +21,7 @@ import * as fs from 'fs'
import * as hexy from 'hexy'
import XDGAppPaths from 'xdg-app-paths'
import { ConfigEvent, DaffodilData } from './daffodil'
-const xdgAppPaths = XDGAppPaths({ name: 'dapodil' })
+const xdgAppPaths = XDGAppPaths({ name: 'daffodil-dap' })
export class DebuggerHexView {
context: vscode.ExtensionContext