@atomist/rug
Advanced tools
Comparing version 0.25.3 to 0.26.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var treeHelper = require("../tree/TreeHelper"); | ||
@@ -3,0 +4,0 @@ /** |
@@ -1,5 +0,5 @@ | ||
import {TreeNode,TextTreeNode,ParentAwareTreeNode,PathExpressionEngine} from "../tree/PathExpression" | ||
import { TreeNode, TextTreeNode, ParentAwareTreeNode, PathExpressionEngine } from "../tree/PathExpression" | ||
import * as treeHelper from "../tree/TreeHelper" | ||
import {File} from "../model/Core" | ||
import { File } from "../model/Core" | ||
@@ -6,0 +6,0 @@ /** |
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var TransformingPathExpressionEngine_1 = require("../tree/TransformingPathExpressionEngine"); | ||
@@ -40,2 +46,3 @@ var TextTreeNodeOps_1 = require("../ast/TextTreeNodeOps"); | ||
monkeyableBase[id] = fun; | ||
//console.log(`Adding function ${id} from right to left: ${fun} from source ${enricher}`) | ||
} | ||
@@ -63,4 +70,11 @@ return monkeyableBase; | ||
}; | ||
DecoratingPathExpressionEngine.prototype.save = function (n, expr) { | ||
var hits = []; | ||
this.with(n, expr, function (n) { | ||
hits.push(n); | ||
}); | ||
return hits; | ||
}; | ||
return DecoratingPathExpressionEngine; | ||
}(TransformingPathExpressionEngine_1.TransformingPathExpressionEngine)); | ||
exports.DecoratingPathExpressionEngine = DecoratingPathExpressionEngine; |
@@ -1,4 +0,4 @@ | ||
import {PathExpressionEngine,TreeNode} from "../tree/PathExpression" | ||
import {TransformingPathExpressionEngine} from "../tree/TransformingPathExpressionEngine" | ||
import {TextTreeNodeOps} from "../ast/TextTreeNodeOps" | ||
import { PathExpressionEngine, TreeNode } from "../tree/PathExpression" | ||
import { TransformingPathExpressionEngine } from "../tree/TransformingPathExpressionEngine" | ||
import { TextTreeNodeOps, RichTextTreeNode } from "../ast/TextTreeNodeOps" | ||
@@ -62,2 +62,10 @@ /** | ||
public save<N extends RichTextTreeNode>(n: TreeNode, expr: string) { | ||
let hits = []; | ||
this.with(n, expr, n => { | ||
hits.push(n); | ||
}); | ||
return hits; | ||
} | ||
} |
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var DecoratingPathExpressionEngine_1 = require("../DecoratingPathExpressionEngine"); | ||
@@ -8,0 +14,0 @@ var scala = require("./Types"); |
@@ -11,7 +11,13 @@ /** | ||
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var TextTreeNodeOps_1 = require("../TextTreeNodeOps"); | ||
@@ -18,0 +24,0 @@ var SourceOps = (function (_super) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var AstHelper_1 = require("./AstHelper"); | ||
@@ -55,2 +56,3 @@ var treeHelper = require("../tree/TreeHelper"); | ||
TextTreeNodeOps.prototype.commentConcerning = function (comment, severity) { | ||
var f = this.containingFile(); | ||
var line = 1; | ||
@@ -63,3 +65,3 @@ var col = 1; | ||
} | ||
return new RugOperation_1.ReviewComment(comment, severity, this.containingFile().path, line, col); | ||
return new RugOperation_1.ReviewComment(f.project.name, comment, severity, f.path, line, col); | ||
}; | ||
@@ -66,0 +68,0 @@ /** |
@@ -64,10 +64,11 @@ import {PathExpressionEngine,TextTreeNode} from "../tree/PathExpression" | ||
commentConcerning(comment: string, severity: Severity): ReviewComment { | ||
let line = 1 | ||
let col = 1 | ||
let point = this.node.formatInfo.start | ||
const f = this.containingFile(); | ||
let line = 1; | ||
let col = 1; | ||
const point = this.node.formatInfo.start; | ||
if (point) { | ||
line = point.lineNumberFrom1 | ||
col = point.columnNumberFrom1 | ||
line = point.lineNumberFrom1; | ||
col = point.columnNumberFrom1; | ||
} | ||
return new ReviewComment(comment, severity, this.containingFile().path, line, col) | ||
return new ReviewComment(f.project.name, comment, severity, f.path, line, col); | ||
} | ||
@@ -74,0 +75,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -272,2 +273,3 @@ * String without quotes or newlines. Leave it alone. | ||
this.node.update(newValue); | ||
// console.log(this.node.value()) | ||
} | ||
@@ -274,0 +276,0 @@ }; |
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helper = require("../../tree/TreeHelper"); | ||
@@ -8,0 +14,0 @@ var DecoratingPathExpressionEngine_1 = require("../DecoratingPathExpressionEngine"); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -29,5 +29,9 @@ /* | ||
import { File } from "./File"; | ||
import { FileAddition } from "./FileAddition"; | ||
import { FileArtifactBacked } from "./FileArtifactBacked"; | ||
import { FileImpact } from "./FileImpact"; | ||
import { FileUpdate } from "./FileUpdate"; | ||
import { FormatInfoProvider } from "./FormatInfoProvider"; | ||
import { FormatInfoProviderSupport } from "./FormatInfoProviderSupport"; | ||
import { Impact } from "./Impact"; | ||
import { JavaClassOrInterface } from "./JavaClassOrInterface"; | ||
@@ -75,5 +79,9 @@ import { JavaConstructor } from "./JavaConstructor"; | ||
export { File }; | ||
export { FileAddition }; | ||
export { FileArtifactBacked }; | ||
export { FileImpact }; | ||
export { FileUpdate }; | ||
export { FormatInfoProvider }; | ||
export { FormatInfoProviderSupport }; | ||
export { Impact }; | ||
export { JavaClassOrInterface }; | ||
@@ -80,0 +88,0 @@ export { JavaConstructor }; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -20,2 +20,3 @@ /* | ||
import { ViewSupport } from "./ViewSupport"; | ||
import { Project } from "./Project"; | ||
@@ -85,2 +86,9 @@ export { FileArtifactBacked }; | ||
/** | ||
* Containing project | ||
* | ||
* @property {Project} project | ||
*/ | ||
readonly project: Project; | ||
/** | ||
* Does this path begin with the given pattern? Pattern should contain slashes but not begin with a / | ||
@@ -87,0 +95,0 @@ * |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -113,2 +113,8 @@ /* | ||
/** | ||
* Copy the given files from the editor's backing archive project to the project being edited. Doesn't copy Atomist content. | ||
* | ||
*/ | ||
copyEditorBackingProject(): void; | ||
/** | ||
* Copy the given file in the target project. It is not an error if it doesn't exist | ||
@@ -115,0 +121,0 @@ * |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -10,2 +10,3 @@ "use strict"; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//used by annotation functions | ||
@@ -74,4 +75,2 @@ function set_metadata(obj, key, value) { | ||
exports.Generator = Generator; | ||
var Reviewer = ruglike("review", "reviewer", "review must be a function with first parameter = Project"); | ||
exports.Reviewer = Reviewer; | ||
var Editor = ruglike("edit", "editor", "edit must be a function with first parameter = Project"); | ||
@@ -78,0 +77,0 @@ exports.Editor = Editor; |
@@ -72,3 +72,2 @@ import {BaseParameter} from './RugOperation' | ||
let Generator = ruglike("populate","generator", "populate must be a function with first parameter = Project") | ||
let Reviewer = ruglike("review", "reviewer", "review must be a function with first parameter = Project") | ||
let Editor = ruglike("edit", "editor", "edit must be a function with first parameter = Project") | ||
@@ -125,4 +124,4 @@ let CommandHandler = ruglike("handle", "command-handler", "handle must be a function with first parameter = HandlerContext") | ||
export {Parameter, Secrets, Tags, Intent, MappedParameter} | ||
export {Editor, Generator, Reviewer} | ||
export {Editor, Generator} | ||
export {ParseJson} | ||
export {ResponseHandler, CommandHandler, EventHandler} |
"use strict"; | ||
var Respondable = (function () { | ||
function Respondable() { | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var EventRespondable = (function () { | ||
function EventRespondable() { | ||
} | ||
return Respondable; | ||
return EventRespondable; | ||
}()); | ||
exports.Respondable = Respondable; | ||
var NonRespondable = (function () { | ||
function NonRespondable() { | ||
exports.EventRespondable = EventRespondable; | ||
var CommandRespondable = (function () { | ||
function CommandRespondable() { | ||
} | ||
return NonRespondable; | ||
return CommandRespondable; | ||
}()); | ||
exports.NonRespondable = NonRespondable; | ||
exports.CommandRespondable = CommandRespondable; | ||
var Presentable = (function () { | ||
@@ -24,12 +35,12 @@ function Presentable() { | ||
Status[Status["success"] = 1] = "success"; | ||
})(Status || (Status = {})); | ||
})(Status = exports.Status || (exports.Status = {})); | ||
/** | ||
* A bunch of stuff to do asynchronously | ||
* Messages got to the bot. | ||
* Rugs are run straight away | ||
* PlanMessages got to the bot. | ||
* ImmediatelyRunnables are run straight away | ||
*/ | ||
var Plan = (function () { | ||
function Plan() { | ||
this.instructions = []; | ||
this.messages = []; | ||
this.instructions = []; | ||
} | ||
@@ -45,8 +56,39 @@ Plan.prototype.add = function (thing) { | ||
}; | ||
Plan.ofMessage = function (m) { | ||
return new Plan().add(m); | ||
}; | ||
return Plan; | ||
}()); | ||
exports.Plan = Plan; | ||
/** | ||
* For returning from Event Handlers | ||
*/ | ||
var EventPlan = (function (_super) { | ||
__extends(EventPlan, _super); | ||
function EventPlan() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
EventPlan.prototype.add = function (msg) { | ||
return _super.prototype.add.call(this, msg); | ||
}; | ||
EventPlan.ofMessage = function (m) { | ||
return new EventPlan().add(m); | ||
}; | ||
return EventPlan; | ||
}(Plan)); | ||
exports.EventPlan = EventPlan; | ||
/** | ||
* Plans returned from Command Handlers | ||
*/ | ||
var CommandPlan = (function (_super) { | ||
__extends(CommandPlan, _super); | ||
function CommandPlan() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
CommandPlan.prototype.add = function (msg) { | ||
return _super.prototype.add.call(this, msg); | ||
}; | ||
CommandPlan.ofMessage = function (m) { | ||
return new CommandPlan().add(m); | ||
}; | ||
return CommandPlan; | ||
}(Plan)); | ||
exports.CommandPlan = CommandPlan; | ||
var MessageMimeTypes = (function () { | ||
@@ -53,0 +95,0 @@ function MessageMimeTypes() { |
import { GraphNode, TreeNode, PathExpressionEngine, PathExpression, Match } from "../tree/PathExpression" | ||
import { Parameter } from "./RugOperation" | ||
interface RugCoordinate { | ||
export interface RugCoordinate { | ||
readonly name: string | ||
@@ -10,5 +10,5 @@ readonly group: string | ||
type InstructionKind = "generate" | "edit" | "review" | "execute" | "respond" | "command" | ||
type InstructionKind = "generate" | "edit" | "execute" | "respond" | "command" | ||
interface Instruction<T extends InstructionKind> { | ||
export interface Instruction<T extends InstructionKind> { | ||
readonly name: string | RugCoordinate | ||
@@ -19,16 +19,16 @@ readonly parameters?: {} | ||
interface ImmediatelyRunnable { } | ||
class Respondable<T extends Review | Edit | Generate | Execute> implements ImmediatelyRunnable { | ||
export class EventRespondable<T extends Edit | Generate | Execute> { | ||
instruction: T | ||
onSuccess?: Plan | PlanMessage | Respond | ||
onError?: Plan | PlanMessage | Respond | ||
onSuccess?: EventPlan | EventMessage | Respond | ||
onError?: EventPlan | EventMessage | Respond | ||
} | ||
class NonRespondable<T extends Command | Respond> implements ImmediatelyRunnable { | ||
export class CommandRespondable<T extends Edit | Generate | Execute | Command> { | ||
instruction: T | ||
onSuccess?: CommandPlan | CommandMessage | Respond | ||
onError?: CommandPlan | CommandMessage | Respond | ||
} | ||
class Presentable<T extends InstructionKind> { | ||
instruction: Instruction<T> | PresentableGenerate | PresentableEdit | PresentableReview | ||
export class Presentable<T extends InstructionKind> { | ||
instruction: Instruction<T> | PresentableGenerate | PresentableEdit | ||
label?: string | ||
@@ -39,25 +39,15 @@ } | ||
// in the future, we could add things like github urls, orgs etc. | ||
interface ProjectReference { | ||
interface ProjectReference {} | ||
} | ||
interface ProjectInstruction<T extends InstructionKind> extends Instruction<T> { | ||
export interface ProjectInstruction<T extends InstructionKind> extends Instruction<T> { | ||
project: string | ProjectReference | ||
} | ||
interface Review extends ProjectInstruction<"review"> { | ||
export interface Edit extends ProjectInstruction<"edit"> {} | ||
} | ||
interface Edit extends ProjectInstruction<"edit"> { | ||
} | ||
//extends ProjectInstruction because we need to know the project name | ||
interface Generate extends ProjectInstruction<"generate"> { | ||
export interface Generate extends ProjectInstruction<"generate"> {} | ||
} | ||
//because in a message, we may not know project name yet | ||
interface PresentableGenerate extends Instruction<"generate"> { | ||
export interface PresentableGenerate extends Instruction<"generate"> { | ||
project?: string | ProjectReference | ||
@@ -67,34 +57,24 @@ } | ||
//because in a message, we may not know project name yet | ||
interface PresentableEdit extends Instruction<"edit"> { | ||
export interface PresentableEdit extends Instruction<"edit"> { | ||
project?: string | ProjectReference | ||
} | ||
//because in a message, we may not know project name yet | ||
interface PresentableReview extends Instruction<"review"> { | ||
project?: string | ProjectReference | ||
} | ||
export interface Execute extends Instruction<"execute"> {} | ||
interface Execute extends Instruction<"execute"> { | ||
} | ||
export interface Respond extends Instruction<"respond"> {} | ||
interface Command extends Instruction<"command"> { | ||
export interface Command extends Instruction<"command"> {} | ||
export interface HandleCommand { | ||
handle(ctx: HandlerContext): CommandPlan | ||
} | ||
interface Respond extends Instruction<"respond"> { | ||
export interface HandleEvent<R extends GraphNode, M extends GraphNode> { | ||
handle(root: Match<R, M>): EventPlan | ||
} | ||
interface HandleCommand { | ||
handle(ctx: HandlerContext): Plan | ||
export interface HandleResponse<T> { | ||
handle(response: Response<T>): EventPlan | CommandPlan | ||
} | ||
interface HandleEvent<R extends GraphNode, M extends GraphNode> { | ||
handle(root: Match<R, M>): Plan | ||
} | ||
interface HandleResponse<T> { | ||
handle(response: Response<T>): Plan | ||
} | ||
/** | ||
@@ -105,3 +85,3 @@ * Context available to all handlers. Unique to a team. | ||
*/ | ||
interface HandlerContext { | ||
export interface HandlerContext { | ||
@@ -122,3 +102,3 @@ /** | ||
enum Status { | ||
export enum Status { | ||
failure, | ||
@@ -128,3 +108,3 @@ success | ||
interface Response<T> { | ||
export interface Response<T> { | ||
msg: string | ||
@@ -136,28 +116,58 @@ code: number | ||
type Respondable = EventRespondable<any> | CommandRespondable<any> | ||
/** | ||
* A bunch of stuff to do asynchronously | ||
* Messages got to the bot. | ||
* Rugs are run straight away | ||
* PlanMessages got to the bot. | ||
* ImmediatelyRunnables are run straight away | ||
*/ | ||
class Plan { | ||
export abstract class Plan { | ||
instructions: Respondable[] = []; | ||
messages: PlanMessage[] = []; | ||
instructions: ImmediatelyRunnable[] = []; | ||
public add?(thing: ImmediatelyRunnable | PlanMessage): this { | ||
public add?(thing: Respondable | PlanMessage): this { | ||
if (thing instanceof ResponseMessage || thing instanceof DirectedMessage || thing instanceof LifecycleMessage) { | ||
this.messages.push(thing) | ||
this.messages.push(thing); | ||
} else { | ||
this.instructions.push(thing); | ||
} | ||
else { | ||
this.instructions.push(thing) | ||
} | ||
return this; | ||
} | ||
} | ||
static ofMessage(m: PlanMessage): Plan { | ||
return new Plan().add(m); | ||
type EventMessage = LifecycleMessage | DirectedMessage | ||
type CommandMessage = ResponseMessage | DirectedMessage | ||
/** | ||
* For returning from Event Handlers | ||
*/ | ||
export class EventPlan extends Plan { | ||
public add?(msg: EventMessage | EventRespondable<any>): this { | ||
return super.add(msg); | ||
} | ||
static ofMessage(m: EventMessage): EventPlan { | ||
return new EventPlan().add(m); | ||
} | ||
} | ||
/** | ||
* Plans returned from Command Handlers | ||
*/ | ||
export class CommandPlan extends Plan { | ||
public add?(msg: CommandMessage | CommandRespondable<any>): this { | ||
return super.add(msg); | ||
} | ||
static ofMessage(m: CommandMessage): CommandPlan { | ||
return new CommandPlan().add(m); | ||
} | ||
} | ||
export type MessageMimeType = "application/x-atomist-slack+json" | "text/plain" | ||
@@ -268,3 +278,3 @@ | ||
abstract class MappedParameters { | ||
export abstract class MappedParameters { | ||
static readonly GITHUB_REPO_OWNER: string = "atomist://github/repository/owner" | ||
@@ -278,5 +288,1 @@ static readonly GITHUB_REPOSITORY: string = "atomist://github/repository" | ||
export { MappedParameters } | ||
export { Respond, Presentable, NonRespondable, Respondable, Instruction, Response, HandlerContext, Plan, Execute } | ||
export { HandleResponse, HandleCommand, HandleEvent } | ||
export { Edit, ProjectInstruction } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -62,3 +63,4 @@ * Well-known patterns used in operation parameters. | ||
var ReviewComment = (function () { | ||
function ReviewComment(comment, severity, fileName, line, column) { | ||
function ReviewComment(projectName, comment, severity, fileName, line, column) { | ||
this.projectName = projectName; | ||
this.comment = comment; | ||
@@ -73,31 +75,1 @@ this.severity = severity; | ||
exports.ReviewComment = ReviewComment; | ||
/** | ||
* Result of running a reviewer | ||
*/ | ||
var ReviewResult = (function () { | ||
function ReviewResult(note, comments) { | ||
this.note = note; | ||
this.comments = comments; | ||
} | ||
ReviewResult.prototype.add = function (rc) { | ||
this.comments.push(rc); | ||
}; | ||
ReviewResult.empty = function (note) { | ||
return new ReviewResult(note, []); | ||
}; | ||
/** | ||
* Combine the results of the given reviewers | ||
* @param results review results to combine | ||
*/ | ||
ReviewResult.combine = function (results) { | ||
if (results.length == 0) | ||
throw new Error("Invalid argument: Need at least one review result"); | ||
var combinedComments = []; | ||
results.forEach(function (r) { | ||
return r.comments.forEach(function (c) { return combinedComments.push(c); }); | ||
}); | ||
return new ReviewResult(results.map(function (r) { return r.note; }).join(","), combinedComments); | ||
}; | ||
return ReviewResult; | ||
}()); | ||
exports.ReviewResult = ReviewResult; |
@@ -85,2 +85,3 @@ | ||
constructor( | ||
public projectName: string, | ||
public comment: string, | ||
@@ -93,39 +94,3 @@ public severity: Severity, | ||
/** | ||
* Result of running a reviewer | ||
*/ | ||
class ReviewResult { | ||
constructor( | ||
public note: string, | ||
public comments: ReviewComment[]) {} | ||
add(rc: ReviewComment) { | ||
this.comments.push(rc) | ||
} | ||
static empty(note: string): ReviewResult { | ||
return new ReviewResult(note, []) | ||
} | ||
/** | ||
* Combine the results of the given reviewers | ||
* @param results review results to combine | ||
*/ | ||
static combine(results: ReviewResult[]): ReviewResult { | ||
if (results.length == 0) | ||
throw new Error("Invalid argument: Need at least one review result") | ||
let combinedComments: ReviewComment[] = [] | ||
results.forEach(r => | ||
r.comments.forEach( | ||
c => combinedComments.push(c) | ||
) | ||
) | ||
return new ReviewResult( | ||
results.map(r => r.note).join(","), | ||
combinedComments | ||
) | ||
} | ||
} | ||
export {RugOperation, Parameter, Pattern, Result, Status, ReviewResult, ReviewComment, Severity, BaseParameter} | ||
export {RugOperation, Parameter, Pattern, Result, Status, ReviewComment, Severity, BaseParameter} |
{ | ||
"name": "@atomist/rug", | ||
"version": "0.25.3", | ||
"version": "0.26.0", | ||
"description": "TypeScript model for Atomist editors, generators etc", | ||
@@ -5,0 +5,0 @@ "repository": { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function Given(s, f) { | ||
@@ -21,4 +22,20 @@ com_atomist_rug_test_gherkin_GherkinRunner$_definitions.Given(s, f); | ||
exports.Then = Then; | ||
/** | ||
* Convenient assertion if you are not using an assertion framework | ||
* such as chai | ||
*/ | ||
function rugAssert(statement, message) { | ||
if (!statement.apply(null)) { | ||
throw new Error("Assertion failed: " + message + ". Code was [" + statement + "]"); | ||
} | ||
} | ||
exports.rugAssert = rugAssert; | ||
function rugAssertEqual(a, b) { | ||
if (!(a === b)) { | ||
throw new Error("Assertion failed: " + a + " did not equal " + b); | ||
} | ||
} | ||
exports.rugAssertEqual = rugAssertEqual; | ||
// Import well-known step definitions. It's nicer | ||
// to have them in a separate file. | ||
require("./WellKnownSteps.js"); |
import { ScenarioWorld } from "../ScenarioWorld" | ||
import { Result } from "../Result" | ||
import { Plan } from "../../operations/Handlers" | ||
import { CommandPlan, EventPlan, Plan } from "../../operations/Handlers" | ||
import { GraphNode } from "../../tree/PathExpression" | ||
import { Project } from "../../model/Core" | ||
@@ -10,5 +11,10 @@ /** | ||
*/ | ||
export interface HandlerScenarioWorld extends ScenarioWorld { | ||
export interface HandlerScenarioWorld<T extends Plan> extends ScenarioWorld { | ||
/** | ||
* Return an empty project. Useful in creating fake repos. | ||
*/ | ||
emptyProject(name: string): Project; | ||
/** | ||
* Add this node to the root context so it can | ||
@@ -20,5 +26,10 @@ * be matched by path expressions other than event handler expressions | ||
/** | ||
* Define the given repo | ||
*/ | ||
defineRepo(owner: string, name: string, branchOrSha: string, p: Project); | ||
/** | ||
* Return a single plan. Throws an exception if no plan was recorded | ||
*/ | ||
plan(): Plan | ||
plan(): T | ||
@@ -28,3 +39,3 @@ /** | ||
*/ | ||
planFor(handlerName: string): Plan | ||
planFor(handlerName: string): T | ||
@@ -47,3 +58,3 @@ /** | ||
*/ | ||
export interface CommandHandlerScenarioWorld extends HandlerScenarioWorld { | ||
export interface CommandHandlerScenarioWorld extends HandlerScenarioWorld<CommandPlan> { | ||
@@ -63,3 +74,3 @@ /** | ||
export interface EventHandlerScenarioWorld extends HandlerScenarioWorld { | ||
export interface EventHandlerScenarioWorld extends HandlerScenarioWorld<EventPlan> { | ||
@@ -117,4 +128,21 @@ /** | ||
/** | ||
* Convenient assertion if you are not using an assertion framework | ||
* such as chai | ||
*/ | ||
export function rugAssert(statement: () => boolean, message: string) { | ||
if (!statement.apply(null)) { | ||
throw new Error(`Assertion failed: ${message}. Code was [${statement}]`); | ||
} | ||
} | ||
export function rugAssertEqual(a, b) { | ||
if (!(a === b)) { | ||
throw new Error(`Assertion failed: ${a} did not equal ${b}`); | ||
} | ||
} | ||
// Import well-known step definitions. It's nicer | ||
// to have them in a separate file. | ||
import "./WellKnownSteps.js" |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Core_1 = require("./Core"); | ||
@@ -3,0 +4,0 @@ // Register well-known steps |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function Given(s, f) { | ||
@@ -14,4 +15,20 @@ com_atomist_rug_test_gherkin_GherkinRunner$_definitions.Given(s, f); | ||
exports.Then = Then; | ||
/** | ||
* Convenient assertion if you are not using an assertion framework | ||
* such as chai | ||
*/ | ||
function rugAssert(statement, message) { | ||
if (!statement.apply(null)) { | ||
throw new Error("Assertion failed: " + message + ". Code was [" + statement + "]"); | ||
} | ||
} | ||
exports.rugAssert = rugAssert; | ||
function rugAssertEqual(a, b) { | ||
if (!(a === b)) { | ||
throw new Error("Assertion failed: " + a + " did not equal " + b); | ||
} | ||
} | ||
exports.rugAssertEqual = rugAssertEqual; | ||
// Import well-known step definitions. It's nicer | ||
// to have them in a separate file. | ||
require("./WellKnownSteps.js"); |
@@ -52,9 +52,15 @@ import { Project } from "../../model/Core" | ||
// Callback for given and when steps | ||
type SetupCallback = (Project, ProjectScenarioWorld?, ...args) => void | ||
type ThenCallback = (Project, ProjectScenarioWorld?, ...args) => Result | boolean | void | ||
interface Definitions { | ||
Given(s: string, f: (Project, ProjectScenarioWorld?, ...args) => void): void | ||
Given(s: string, f: SetupCallback): void | ||
When(s: string, f: (Project, ProjectScenarioWorld?, ...args) => void): void | ||
When(s: string, f: SetupCallback): void | ||
Then(s: string, f: (Project, ProjectScenarioWorld?, ...args) => Result | boolean): void | ||
Then(s: string, f: ThenCallback): void | ||
@@ -66,16 +72,33 @@ } | ||
export function Given(s: string, f: (Project, ProjectScenarioWorld?, ...args) => void) { | ||
export function Given(s: string, f: SetupCallback) { | ||
com_atomist_rug_test_gherkin_GherkinRunner$_definitions.Given(s, f) | ||
} | ||
export function When(s: string, f: (Project, ProjectScenarioWorld?, ...args) => void) { | ||
export function When(s: string, f: SetupCallback) { | ||
com_atomist_rug_test_gherkin_GherkinRunner$_definitions.When(s, f) | ||
} | ||
export function Then(s: string, f: (Project, ProjectScenarioWorld?, ...args) => Result | boolean) { | ||
export function Then(s: string, f: ThenCallback) { | ||
com_atomist_rug_test_gherkin_GherkinRunner$_definitions.Then(s, f) | ||
} | ||
/** | ||
* Convenient assertion if you are not using an assertion framework | ||
* such as chai | ||
*/ | ||
export function rugAssert(statement: () => boolean, message: string) { | ||
if (!statement.apply(null)) { | ||
throw new Error(`Assertion failed: ${message}. Code was [${statement}]`); | ||
} | ||
} | ||
export function rugAssertEqual(a, b) { | ||
if (!(a === b)) { | ||
throw new Error(`Assertion failed: ${a} did not equal ${b}`); | ||
} | ||
} | ||
// Import well-known step definitions. It's nicer | ||
// to have them in a separate file. | ||
import "./WellKnownSteps.js" |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -3,0 +4,0 @@ * Pretty list the files in project |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Core_1 = require("./Core"); | ||
@@ -17,2 +18,8 @@ // Register well-known steps | ||
/** | ||
* The contents of this archive, excluding Atomist content | ||
*/ | ||
Core_1.Given("archive non Atomist content", function (p) { | ||
p.copyEditorBackingProject(""); | ||
}); | ||
/** | ||
* Editor made changes | ||
@@ -41,2 +48,15 @@ */ | ||
}); | ||
Core_1.Then("file at ([^ ]+) should exist", function (p, w, path) { | ||
var f = p.findFile(path); | ||
if (f == null) | ||
throw new Error("File at [" + path + "] expected, but not found"); | ||
}); | ||
Core_1.Then("file at ([^ ]+) should contain (.*)", function (p, w, path, lookFor) { | ||
var f = p.findFile(path); | ||
if (f == null) | ||
throw new Error("File at [" + path + "] expected, but not found"); | ||
var idx = f.content.indexOf(lookFor); | ||
if (idx == -1) | ||
throw new Error("File at [" + path + "] did not contain [" + lookFor + "]. Content was\n" + f.content); | ||
}); | ||
/** | ||
@@ -43,0 +63,0 @@ * When step should fail |
@@ -20,2 +20,9 @@ import {Given, When, Then} from "./Core" | ||
/** | ||
* The contents of this archive, excluding Atomist content | ||
*/ | ||
Given("archive non Atomist content", p => { | ||
p.copyEditorBackingProject(""); | ||
}); | ||
/** | ||
* Editor made changes | ||
@@ -48,2 +55,18 @@ */ | ||
Then("file at ([^ ]+) should exist", (p, w, path: string) => { | ||
const f = p.findFile(path); | ||
if (f == null) | ||
throw new Error(`File at [${path}] expected, but not found`); | ||
}); | ||
Then("file at ([^ ]+) should contain (.*)", (p, w, path: string, lookFor: string) => { | ||
const f = p.findFile(path); | ||
if (f == null) | ||
throw new Error(`File at [${path}] expected, but not found`) | ||
const idx = f.content.indexOf(lookFor); | ||
if (idx == -1) | ||
throw new Error(`File at [${path}] did not contain [${lookFor}]. Content was\n${f.content}`) | ||
}); | ||
/** | ||
@@ -50,0 +73,0 @@ * When step should fail |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -3,0 +4,0 @@ * Result of executing a single test. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -8,10 +8,19 @@ | ||
/** | ||
* Get the value of the given key in the scenario, or null | ||
*/ | ||
get(key: string): any | ||
/** | ||
* Bind the value to the given key in the scenario | ||
*/ | ||
put(key: string, what: any): void | ||
/** | ||
* Clear the value of the given key in the scenario | ||
*/ | ||
clear(key: string): void | ||
/** | ||
* Abort execution of the current scenario | ||
* Abort execution of the current scenario. This will cause failure. | ||
*/ | ||
@@ -30,2 +39,3 @@ abort(): void | ||
invalidParameters(): any | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Or = function (alternatives) { | ||
@@ -3,0 +4,0 @@ var or = { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -3,0 +4,0 @@ * Object encapsulating a path expression. Facilitates reuse. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -3,0 +4,0 @@ * Convenient superclass that wraps an existing PathExpressionEngine |
@@ -6,2 +6,3 @@ /** | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function hasTag(n, t) { | ||
@@ -63,1 +64,33 @@ return n.nodeTags().indexOf(t) > -1; | ||
exports.findAncestorWithTag = findAncestorWithTag; | ||
function nodeAndTagsStringifier(tn) { | ||
if (tn.children().length == 0) | ||
return tn.nodeName() + ":[" + tn.value() + "]"; | ||
return tn.nodeName() + ":[" + tn.nodeTags().join(", ") + "]"; | ||
} | ||
exports.nodeAndTagsStringifier = nodeAndTagsStringifier; | ||
function nodeAndValueStringifier(tn, maxLen) { | ||
if (maxLen === void 0) { maxLen = 30; } | ||
if (tn.children().length == 0 || tn.value().length < maxLen) | ||
return tn.nodeName() + ":[" + tn.value() + "]"; | ||
return tn.nodeName() + ":len=" + tn.value().length; | ||
} | ||
exports.nodeAndValueStringifier = nodeAndValueStringifier; | ||
function stringifyInternal(tn, nodeStringifier) { | ||
var shorterString = nodeStringifier(tn); | ||
var lines = [shorterString].concat( | ||
// oh for flatMap... | ||
exports.flatten(tn.children() | ||
.filter(function (k) { return k.value().length > 0; }) | ||
.map(function (k) { return stringifyInternal(k, nodeStringifier); }))); | ||
return lines.filter(function (l) { return l.length > 0; }).map(function (l) { return " " + l; }); | ||
} | ||
// TODO move to a utility module | ||
exports.flatten = function (arr) { return arr.reduce(function (acc, val) { return acc.concat(Array.isArray(val) ? exports.flatten(val) : val); }, []); }; | ||
/** | ||
* Pretty string dump | ||
*/ | ||
function stringify(tn, nodeStringifier) { | ||
if (nodeStringifier === void 0) { nodeStringifier = nodeAndValueStringifier; } | ||
return stringifyInternal(tn, nodeStringifier).join("\n"); | ||
} | ||
exports.stringify = stringify; |
@@ -6,4 +6,5 @@ /** | ||
import {TreeNode,TextTreeNode,ParentAwareTreeNode} from "./PathExpression" | ||
import { TreeNode, TextTreeNode, ParentAwareTreeNode } from "./PathExpression" | ||
export function hasTag(n: TreeNode, t: string): boolean { | ||
@@ -69,1 +70,44 @@ return n.nodeTags().indexOf(t) > -1 | ||
} | ||
export function nodeAndTagsStringifier(tn: TextTreeNode): string { | ||
if (tn.children().length == 0) | ||
return `${tn.nodeName()}:[${tn.value()}]`; | ||
return `${tn.nodeName()}:[${tn.nodeTags().join(", ")}]`; | ||
} | ||
export function nodeAndValueStringifier(tn: TextTreeNode, maxLen: number = 30): string { | ||
if (tn.children().length == 0 || tn.value().length < maxLen) | ||
return `${tn.nodeName()}:[${tn.value()}]`; | ||
return `${tn.nodeName()}:len=${tn.value().length}`; | ||
} | ||
function stringifyInternal(tn: TextTreeNode, nodeStringifier: (TextTreeNode) => string): string[] { | ||
const shorterString = nodeStringifier(tn) | ||
const lines = [ shorterString ].concat( | ||
// oh for flatMap... | ||
flatten(tn.children() | ||
.filter(k => (<TextTreeNode> k).value().length > 0) | ||
.map(k => stringifyInternal(k as TextTreeNode, nodeStringifier))) | ||
); | ||
return lines.filter(l => l.length > 0).map(l => " " + l); | ||
} | ||
// TODO move to a utility module | ||
export const flatten = arr => arr.reduce( | ||
(acc, val) => acc.concat( | ||
Array.isArray(val) ? flatten(val) : val | ||
), | ||
[] | ||
); | ||
/** | ||
* Pretty string dump | ||
*/ | ||
export function stringify(tn: TextTreeNode, nodeStringifier: (TextTreeNode) => string = nodeAndValueStringifier): string { | ||
return stringifyInternal(tn, nodeStringifier).join("\n"); | ||
} |
297111
154
7272