Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0-alpha.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
paxtonhare committed Feb 14, 2017
2 parents dfb5c6b + 708c7f3 commit 116f446
Show file tree
Hide file tree
Showing 22 changed files with 370 additions and 131 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea
/.vscode
.project
.classpath
.c9/
*.launch
.settings/

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# Change Log

## [v1.0.0-alpha.5](https://github.com/paxtonhare/marklogic-debugger/tree/v1.0.0-alpha.5)
## [v1.0.0-alpha.6](https://github.com/paxtonhare/marklogic-debugger/tree/v1.0.0-alpha.6)

[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.5...v1.0.0-alpha.6)

**Closed issues:**

- invoke a main module from the debugger [\#19](https://github.com/paxtonhare/marklogic-debugger/issues/19)
- determine if breakpoint is valid when set [\#18](https://github.com/paxtonhare/marklogic-debugger/issues/18)
- update node dependencies [\#17](https://github.com/paxtonhare/marklogic-debugger/issues/17)
- Rename the "Debugging is ON|OFF" [\#16](https://github.com/paxtonhare/marklogic-debugger/issues/16)
- Can we pause a long running request? [\#10](https://github.com/paxtonhare/marklogic-debugger/issues/10)
- Indicate that something happened [\#3](https://github.com/paxtonhare/marklogic-debugger/issues/3)

## [v1.0.0-alpha.5](https://github.com/paxtonhare/marklogic-debugger/tree/v1.0.0-alpha.5) (2017-02-10)
[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.4...v1.0.0-alpha.5)

**Closed issues:**
Expand Down
16 changes: 12 additions & 4 deletions angular-cli.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"project": {
"version": "1.0.0-beta.24",
"version": "1.0.0-beta.28.3",
"name": "marklogic-debugger"
},
"apps": [
Expand All @@ -13,10 +13,10 @@
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.scss"
],
Expand All @@ -28,13 +28,21 @@
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"files": "src/main/ui/**/*.ts",
"project": "src/main/ui/tsconfig.json"
},
{
"files": "e2e/**/*.ts",
"project": "e2e/tsconfig.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.0.0-alpha.5
version=1.0.0-alpha.6

21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"rimraf": "rimraf",
"ng": "ng",
"start": "ng serve -pc proxy.config.json",
"start": "ng serve --host 0.0.0.0 -pc proxy.config.json",
"lint": "tslint \"src/main/ui/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
Expand All @@ -24,27 +24,26 @@
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"angular2-grid": "^0.11.2",
"angular2-mdl": "^2.11.0",
"codemirror": "^5.22.0",
"angular2-mdl": "^2.13.1",
"codemirror": "^5.23.0",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"lodash": "^4.17.3",
"lodash": "^4.17.4",
"material-design-icons": "^3.0.1",
"mdi": "^1.7.22",
"ng2-codemirror": "^1.0.1",
"mdi": "^1.8.36",
"ng2-codemirror": "^1.1.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@types/codemirror": "0.0.35",
"@types/codemirror": "0.0.38",
"@types/jasmine": "^2.5.2",
"@types/lodash": "^4.14.44",
"@types/lodash": "^4.14.52",
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.24",
"angular-cli": "1.0.0-beta.28.3",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
Expand All @@ -57,7 +56,7 @@
"protractor": "~4.0.13",
"rimraf": "^2.5.4",
"ts-node": "1.2.1",
"tslint": "^4.0.2",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
}
34 changes: 27 additions & 7 deletions src/main/java/com/marklogic/debugger/web/ApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down Expand Up @@ -150,15 +150,25 @@ public String getServerFile(@PathVariable String serverId, @RequestParam String
return evalQuery(auth, "get-file.xqy", hm);
}

@RequestMapping(value = "/servers/{serverId}/attached", method = RequestMethod.GET)
@RequestMapping(value = "/servers/{serverId}/requests", method = RequestMethod.GET)
@ResponseBody
public String getAttached(@PathVariable String serverId) throws InvalidRequestException {
public String getRequests(@PathVariable String serverId) throws InvalidRequestException {
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
HashMap<String, String> hm = new HashMap<>();
hm.put("serverId", serverId);
return evalQuery(auth, "get-attached.xqy", hm);
return evalQuery(auth, "get-requests.xqy", hm);
}

@RequestMapping(value = "/servers/{serverId}/invoke", method = RequestMethod.POST)
public ResponseEntity<?> invokeModule(@PathVariable String serverId, @RequestParam String uri) throws InvalidRequestException {
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
HashMap<String, String> hm = new HashMap<>();
hm.put("serverId", serverId);
hm.put("uri", uri);
evalQuery(auth, "invoke-module.xqy", hm);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

@RequestMapping(value = "/requests/{requestId}/stack", method = RequestMethod.GET)
@ResponseBody
public String getStack(@PathVariable String requestId) throws InvalidRequestException {
Expand Down Expand Up @@ -204,13 +214,23 @@ public String continueExecution(@PathVariable String requestId) throws InvalidRe
return evalQuery(auth, "continue.xqy", hm);
}

@RequestMapping(value = "/requests/{requestId}/pause", method = RequestMethod.GET)
@ResponseBody
public String pauseRequest(@PathVariable String requestId) throws InvalidRequestException {
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
HashMap<String, String> hm = new HashMap<>();
hm.put("requestId", requestId);
return evalQuery(auth, "pause.xqy", hm);
}

@RequestMapping(value = "/requests/{requestId}/breakpoints", method = RequestMethod.POST)
@ResponseBody
public String setBreakpoints(@PathVariable String requestId, @RequestBody List<Breakpoint> breakpoints) throws InvalidRequestException {
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
HashMap<String, String> hm = new HashMap<>();
hm.put("requestId", requestId);
evalQuery(auth, "clear-breakpoints.xqy", hm);
for (Breakpoint bp : breakpoints) {
HashMap<String, String> hm = new HashMap<>();
hm.put("requestId", requestId);
hm.put("uri", bp.uri);
hm.put("line", bp.line);
evalQuery(auth, "set-breakpoints.xqy", hm);
Expand All @@ -224,7 +244,7 @@ public String getBreakpoints(@PathVariable String requestId) throws InvalidReque
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
HashMap<String, String> hm = new HashMap<>();
hm.put("requestId", requestId);
return evalQuery(auth, "set-breakpoints.xqy", hm);
return evalQuery(auth, "get-breakpoints.xqy", hm);
}

@RequestMapping(value = "/requests/{requestId}/eval", method = RequestMethod.POST)
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/modules/clear-breakpoints.xqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare variable $requestId external;

let $requestId := xs:unsignedLong($requestId)
for $expression in dbg:breakpoints($requestId)
return
dbg:clear($requestId, $expression)
2 changes: 2 additions & 0 deletions src/main/resources/modules/get-files.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ declare function local:build-dirs($uris as xs:string*, $parent as xs:string)
let $oo := local:build-dirs($uris, $parent || $dir)
let $_ := local:build-files($uris, $parent || $dir, $oo)
let $_ := map:put($o, "name", $dir)
let $_ := map:put($o, "uri", $parent || $dir)
let $_ := map:put($o, "type", "dir")
let $_ := map:put($o, "children", $oo)
let $_ := map:put($o, "collapsed", fn:true())
Expand Down Expand Up @@ -81,6 +82,7 @@ declare function local:get-system-dirs($root-dir, $dirs, $a as json:array) {
let $_ := local:get-system-dirs($root-dir, $child-dirs, $children)
let $_ := local:get-system-files($root-dir, $child-dirs, $children)
let $_ := map:put($o, "name", fn:string($entry/dir:filename))
let $_ := map:put($o, "uri", fn:replace($entry/dir:pathname, $root-dir, ""))
let $_ := map:put($o, "type", "dir")
let $_ := map:put($o, "collapsed", fn:true())
let $_ := map:put($o, "children", $children)
Expand Down
27 changes: 27 additions & 0 deletions src/main/resources/modules/get-requests.xqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
xquery version "1.0-ml";

declare namespace server = "http://marklogic.com/xdmp/status/server";

import module namespace functx = "http://www.functx.com"
at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";

declare variable $serverId external;

let $current-request := xdmp:request()
let $a := json:array()
let $_ :=
for $status in xdmp:server-status(xdmp:host(), (xdmp:server("TaskServer"), xs:unsignedLong($serverId)))/server:request-statuses/server:request-status[fn:not(server:request-id = $current-request)]
let $o := map:new((
map:entry("server", xdmp:server-name($status/*:server-id)),
map:entry("host", xdmp:host-name($status/*:host-id)),
map:entry("modules", if ($status/*:modules = 0) then "FileSystem" else xdmp:database-name($status/*:modules)),
map:entry("database", if ($status/*:database = 0) then "FileSystem" else xdmp:database-name($status/*:database)),
for $item in $status/*[fn:not(self::*:server-id or self::*:host-id or self::*:modules or self::*:database)]
return
map:entry(functx:words-to-camel-case(fn:replace(fn:local-name($item), "-", " ")), $item/fn:data())
))
return
json:array-push($a, $o)
return
xdmp:to-json($a)

24 changes: 24 additions & 0 deletions src/main/resources/modules/invoke-module.xqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";

declare variable $uri external;

declare variable $serverId external;

declare variable $ml-dir := xdmp:filesystem-filepath('.') || '/Modules';

let $server-id := xs:unsignedLong($serverId)
let $config := admin:get-configuration()
let $modules-db := admin:appserver-get-modules-database($config, $server-id)
let $content-db := admin:appserver-get-database($config, $server-id)
let $server-root := admin:appserver-get-root($config, $server-id)
let $options :=
<options xmlns="xdmp:eval">
<database>{$content-db}</database>
<modules>{$modules-db}</modules>
</options>
return
if (fn:starts-with($uri, "/MarkLogic/")) then
dbg:invoke($uri, (), $options)
else
dbg:invoke($uri, (), $options)
3 changes: 3 additions & 0 deletions src/main/resources/modules/pause.xqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare variable $requestId external;

dbg:attach(xs:unsignedLong($requestId))
12 changes: 6 additions & 6 deletions src/main/ui/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ describe('AppComponent', () => {
});

it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));

it(`should have as title 'app works!'`, async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));

it('should render title in a h1 tag', async(() => {
let fixture = TestBed.createComponent(AppComponent);
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
61 changes: 48 additions & 13 deletions src/main/ui/app/help/startup.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,56 @@
<div class="mdl-dialog__content">
<h4>Welcome to the MarkLogic Debugger!</h4>
<div>
<p>To get started turn on debugging above. <mdl-switch class="debug-instructions" [ngModel]="true" disabled></mdl-switch>
</p>
<p>The next time you run your code MarkLogic will stop automatically
at the first instruction.</p>
<p>Press the refresh arrow <i class="fa fa-repeat"></i> in the Requests pane to show all
of the waiting requests. Simply click on one to start debugging.
</p>
<p>Don't forget to turn off debugging when you are finished!</p>
<p>This help is available from the top right menu. Simply click on the <button class="help-button" mdl-button mdl-button-type="icon" disabled mdl-ripple><mdl-icon>more_vert</mdl-icon></button> button.
<p>There are 3 ways to debug your requests. (scroll to see them all)</p>

<h5>1. Auto-pause requests</h5>
<div class="instructions">
<p>With this option you tell MarkLogic to automatically pause subsequent requests on
the first instruction.</p>
<p>Enable this method by turning on Auto-pause in the requests pane <mdl-switch class="debug-instructions" [ngModel]="true" disabled></mdl-switch></p>
<p>Once enabled you can refresh the request list by clicking on the refresh button: <i class="fa fa-repeat"></i>.</p>
<p>Then click on the request you wish to debug.</p>
</div>

<h5>2. dbg:stop()</h5>
<div class="instructions">
<p>This method is when you put a call to db:stop() somewhere in your code.</p>
<p>This will force MarkLogic to stop execution of your code on the db:stop() statement.</p>
<p>Once you run your code you will need to refresh the request list by clicking on the refresh button: <i class="fa fa-repeat"></i>.</p>
<p>Then click on the request you wish to debug.</p>
</div>

<h5>3. Pause a long running request</h5>
<div class="instructions">
<p>This method is when you tell MarkLogic to pause a long running request so you can debug it.</p>
<p>Refresh the request list by clicking on the refresh button: <i class="fa fa-repeat"></i>.</p>
<p>Then click on the pause button next to the request you wish to debug.</p>
</div>

<h5>4. Invoke a main module on the server</h5>
<div class="instructions">
<p>This method is when you tell MarkLogic to run a specific main module in debug mode. MarkLogic will pause the module on the first instruction.</p>
<p>To do this, select a main module in the file browser.</p>
<p>Then click on the play icon above the source code view.</p>
<p>Refresh the request list by clicking on the refresh button: <i class="fa fa-repeat"></i>.</p>
<p>Then click on the newly launched request you wish to debug.</p>
</div>
</div>
<div class="scroll">
<i class="fa fa-arrow-down"></i>
<div>scroll</div>
</div>
</div>
<div class="mdl-dialog__actions">
<mdl-checkbox [(ngModel)]="showOnStartup">
Show this message on Startup
</mdl-checkbox>
<button mdl-button (click)="cancel()" mdl-button-type="raised" mdl-colored="primary" mdl-ripple>Ok</button>
<div class="show-on-startup">
<mdl-checkbox [(ngModel)]="showOnStartup">
Show this message on Startup
</mdl-checkbox>
<span>This help is available from the top right menu. Simply click on the <button class="help-button" mdl-button mdl-button-type="icon" disabled mdl-ripple><mdl-icon>more_vert</mdl-icon></button> button.</span>
</div>

<div>
<button mdl-button (click)="cancel()" mdl-button-type="raised" mdl-colored="primary" mdl-ripple>Ok</button>
</div>
</div>
</div>
Loading

0 comments on commit 116f446

Please sign in to comment.