@atomist/rug
Advanced tools
Comparing version 1.0.0-m.1 to 1.0.0-m.2
"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): N[] { | ||
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"); | ||
@@ -62,3 +68,3 @@ var SourceOps = (function (_super) { | ||
// TODO what if type body is empty? | ||
var firstStatement = this.node.template().children()[0]; | ||
var firstStatement = this.node.template.children()[0]; | ||
firstStatement.update(what + "\n\n" + firstStatement.value()); | ||
@@ -84,5 +90,5 @@ }; | ||
//console.log(`Containing file=${this.containingFile()}`) | ||
var termSelect = this.node.termSelect(); | ||
var termApply = this.node.termApply(); | ||
if (termApply != null && ["be", "equal"].indexOf(termApply.termName().value()) > -1) { | ||
var termSelect = this.node.termSelect; | ||
var termApply = this.node.termApply; | ||
if (termApply != null && ["be", "equal"].indexOf(termApply.termName.value()) > -1) { | ||
var newValue = "assert(" + termSelect.value() + " === " + termApply.children()[1].value() + ")"; | ||
@@ -89,0 +95,0 @@ //console.log(`Replacing [${shouldTerm.value()}] with [${newValue}]`) |
@@ -58,5 +58,5 @@ | ||
typeName(): string | ||
typeName: string | ||
template(): TextTreeNode | ||
template: TextTreeNode | ||
@@ -72,3 +72,3 @@ } | ||
// TODO what if type body is empty? | ||
let firstStatement = this.node.template().children()[0] as TextTreeNode | ||
let firstStatement = this.node.template.children()[0] as TextTreeNode | ||
firstStatement.update(`${what}\n\n${firstStatement.value()}`) | ||
@@ -94,8 +94,7 @@ } | ||
export interface TermApplyInfixNav extends TextTreeNode { | ||
termSelect(): any | ||
termSelect: any | ||
termApply(): any | ||
termApply: any | ||
@@ -108,6 +107,6 @@ } | ||
//console.log(`Containing file=${this.containingFile()}`) | ||
let termSelect = this.node.termSelect(); | ||
let termApply = this.node.termApply(); | ||
let termSelect = this.node.termSelect; | ||
let termApply = this.node.termApply; | ||
if (termApply != null && ["be", "equal"].indexOf(termApply.termName().value()) > -1) { | ||
if (termApply != null && ["be", "equal"].indexOf(termApply.termName.value()) > -1) { | ||
let newValue = `assert(${termSelect.value()} === ${termApply.children()[1].value()})`; | ||
@@ -114,0 +113,0 @@ //console.log(`Replacing [${shouldTerm.value()}] with [${newValue}]`) |
"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 }); |
@@ -56,3 +56,3 @@ /* | ||
* | ||
* @returns {number} | ||
* @property {number} totalFileCount | ||
*/ | ||
@@ -59,0 +59,0 @@ readonly totalFileCount: number; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -54,3 +54,3 @@ /* | ||
* | ||
* @returns {number} | ||
* @property {number} lineCount | ||
*/ | ||
@@ -57,0 +57,0 @@ readonly lineCount: number; |
@@ -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 }); |
@@ -31,3 +31,3 @@ /* | ||
* | ||
* @returns {FormatInfo} | ||
* @property {FormatInfo} formatInfo | ||
*/ | ||
@@ -34,0 +34,0 @@ readonly formatInfo: FormatInfo; |
@@ -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"; | ||
@@ -64,85 +68,47 @@ import { JavaConstructor } from "./JavaConstructor"; | ||
export { ArtifactContainer }; | ||
export { BodyDeclarationView }; | ||
export { BuildViewMutatingFunctions }; | ||
export { BuildViewNonMutatingFunctions }; | ||
export { CSharpFile }; | ||
export { ChangeLogging }; | ||
export { CommonViewOperations }; | ||
export { ContainerTreeNodeView }; | ||
export { Directory }; | ||
export { DockerFile }; | ||
export { EveryPom }; | ||
export { File }; | ||
export { FileAddition }; | ||
export { FileArtifactBacked }; | ||
export { FileImpact }; | ||
export { FileUpdate }; | ||
export { FormatInfoProvider }; | ||
export { FormatInfoProviderSupport }; | ||
export { Impact }; | ||
export { JavaClassOrInterface }; | ||
export { JavaConstructor }; | ||
export { JavaField }; | ||
export { JavaFile }; | ||
export { JavaMethod }; | ||
export { JavaProject }; | ||
export { JavaSource }; | ||
export { JavaType }; | ||
export { Line }; | ||
export { MutableContainer }; | ||
export { MutableTerminal }; | ||
export { MutableView }; | ||
export { OverwritableText }; | ||
export { Pair }; | ||
export { Pom }; | ||
export { PomMutableViewMutatingFunctions }; | ||
export { PomMutableViewNonMutatingFunctions }; | ||
export { Project }; | ||
export { ProjectDecorating }; | ||
export { Properties }; | ||
export { PythonFile }; | ||
export { ScalaFile }; | ||
export { SpringBootProject }; | ||
export { TypeDeclarationView }; | ||
export { ViewSupport }; | ||
export { Xml }; | ||
export { XmlFile }; | ||
export { YamlFile }; |
@@ -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 }); |
@@ -72,3 +72,3 @@ /* | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isJava | ||
*/ | ||
@@ -80,3 +80,3 @@ readonly isJava: boolean; | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isScala | ||
*/ | ||
@@ -95,3 +95,3 @@ readonly isScala: boolean; | ||
* | ||
* @returns {string} | ||
* @property {string} name | ||
*/ | ||
@@ -98,0 +98,0 @@ readonly name: string; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -20,2 +20,3 @@ /* | ||
import { ViewSupport } from "./ViewSupport"; | ||
import { Project } from "./Project"; | ||
@@ -32,3 +33,3 @@ export { FileArtifactBacked }; | ||
* | ||
* @returns {string} | ||
* @property {string} content | ||
*/ | ||
@@ -40,3 +41,3 @@ readonly content: string; | ||
* | ||
* @returns {number} | ||
* @property {number} contentLength | ||
*/ | ||
@@ -48,3 +49,3 @@ readonly contentLength: number; | ||
* | ||
* @returns {string} | ||
* @property {string} filename | ||
*/ | ||
@@ -56,3 +57,3 @@ readonly filename: string; | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isWellFormed | ||
*/ | ||
@@ -64,3 +65,3 @@ readonly isWellFormed: boolean; | ||
* | ||
* @returns {number} | ||
* @property {number} lineCount | ||
*/ | ||
@@ -78,3 +79,3 @@ readonly lineCount: number; | ||
* | ||
* @returns {string} | ||
* @property {string} path | ||
*/ | ||
@@ -86,3 +87,3 @@ readonly path: string; | ||
* | ||
* @returns {number} | ||
* @property {number} permissions | ||
*/ | ||
@@ -92,2 +93,9 @@ readonly permissions: number; | ||
/** | ||
* 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 / | ||
@@ -94,0 +102,0 @@ * |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -31,3 +31,3 @@ /* | ||
* | ||
* @returns {FormatInfo} | ||
* @property {FormatInfo} formatInfo | ||
*/ | ||
@@ -34,0 +34,0 @@ readonly formatInfo: FormatInfo; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -31,3 +31,3 @@ /* | ||
* | ||
* @returns {FormatInfo} | ||
* @property {FormatInfo} formatInfo | ||
*/ | ||
@@ -34,0 +34,0 @@ readonly formatInfo: FormatInfo; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -42,3 +42,3 @@ /* | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isAbstract | ||
*/ | ||
@@ -50,3 +50,3 @@ readonly isAbstract: boolean; | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isInterface | ||
*/ | ||
@@ -58,3 +58,3 @@ readonly isInterface: boolean; | ||
* | ||
* @returns {JavaSource} | ||
* @property {JavaSource} sourceFile | ||
*/ | ||
@@ -61,0 +61,0 @@ readonly sourceFile: JavaSource; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -41,3 +41,3 @@ /* | ||
* | ||
* @returns {JavaClassOrInterface} | ||
* @property {JavaClassOrInterface} type | ||
*/ | ||
@@ -44,0 +44,0 @@ readonly type: JavaClassOrInterface; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -33,3 +33,3 @@ /* | ||
* | ||
* @returns {string} | ||
* @property {string} javadoc | ||
*/ | ||
@@ -41,3 +41,3 @@ readonly javadoc: string; | ||
* | ||
* @returns {string} | ||
* @property {string} name | ||
*/ | ||
@@ -44,0 +44,0 @@ readonly name: string; |
@@ -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 }); |
@@ -42,3 +42,3 @@ /* | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isAbstract | ||
*/ | ||
@@ -50,3 +50,3 @@ readonly isAbstract: boolean; | ||
* | ||
* @returns {boolean} | ||
* @property {boolean} isInterface | ||
*/ | ||
@@ -58,3 +58,3 @@ readonly isInterface: boolean; | ||
* | ||
* @returns {JavaSource} | ||
* @property {JavaSource} sourceFile | ||
*/ | ||
@@ -61,0 +61,0 @@ readonly sourceFile: JavaSource; |
@@ -17,1 +17,2 @@ /* | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -41,3 +41,3 @@ /* | ||
* | ||
* @returns {File} | ||
* @property {File} file | ||
*/ | ||
@@ -49,3 +49,3 @@ readonly file: File; | ||
* | ||
* @returns {number} | ||
* @property {number} length | ||
*/ | ||
@@ -57,3 +57,3 @@ readonly length: number; | ||
* | ||
* @returns {number} | ||
* @property {number} num | ||
*/ | ||
@@ -65,3 +65,3 @@ readonly num: number; | ||
* | ||
* @returns {number} | ||
* @property {number} numFrom1 | ||
*/ | ||
@@ -68,0 +68,0 @@ readonly numFrom1: number; |
@@ -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 }); |
@@ -38,3 +38,3 @@ /* | ||
* | ||
* @returns {FormatInfo} | ||
* @property {FormatInfo} formatInfo | ||
*/ | ||
@@ -41,0 +41,0 @@ readonly formatInfo: FormatInfo; |
@@ -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 }); |
@@ -70,3 +70,3 @@ /* | ||
* | ||
* @returns {ProjectContext} | ||
* @property {ProjectContext} context | ||
*/ | ||
@@ -114,2 +114,8 @@ readonly context: ProjectContext; | ||
/** | ||
* 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 | ||
@@ -179,3 +185,3 @@ * | ||
* | ||
* @returns {number} | ||
* @property {number} fileCount | ||
*/ | ||
@@ -196,3 +202,3 @@ readonly fileCount: number; | ||
* | ||
* @returns {File[]} | ||
* @property {File[]} files | ||
*/ | ||
@@ -236,3 +242,3 @@ readonly files: File[]; | ||
* | ||
* @returns {string} | ||
* @property {string} name | ||
*/ | ||
@@ -239,0 +245,0 @@ readonly name: string; |
@@ -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 }); |
@@ -38,3 +38,3 @@ /* | ||
* | ||
* @returns {string} | ||
* @property {string} name | ||
*/ | ||
@@ -46,3 +46,3 @@ readonly name: string; | ||
* | ||
* @returns {string} | ||
* @property {string} pkg | ||
*/ | ||
@@ -49,0 +49,0 @@ readonly pkg: string; |
@@ -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 }); |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//used by annotation functions | ||
@@ -25,5 +34,6 @@ function set_metadata(obj, key, value) { | ||
} | ||
details["name"] = propertyKey; | ||
details["decorated"] = true; | ||
params.push(details); | ||
var copy = __assign({}, details); | ||
copy["name"] = propertyKey; | ||
copy["decorated"] = true; | ||
params.push(copy); | ||
set_metadata(target, "__parameters", params); | ||
@@ -65,4 +75,2 @@ }; | ||
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"); | ||
@@ -69,0 +77,0 @@ exports.Editor = Editor; |
@@ -32,5 +32,6 @@ import {BaseParameter} from './RugOperation' | ||
} | ||
details["name"] = propertyKey | ||
details["decorated"] = true | ||
params.push(details); | ||
var copy: any = {... details} | ||
copy["name"] = propertyKey | ||
copy["decorated"] = true | ||
params.push(copy); | ||
set_metadata(target, "__parameters", params); | ||
@@ -72,3 +73,2 @@ } | ||
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 +125,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,16 +56,47 @@ Plan.prototype.add = function (thing) { | ||
}; | ||
Plan.ofMessage = function (m) { | ||
return new Plan().add(m); | ||
}; | ||
return Plan; | ||
}()); | ||
exports.Plan = Plan; | ||
var MessageMimetypes = (function () { | ||
function MessageMimetypes() { | ||
/** | ||
* For returning from Event Handlers | ||
*/ | ||
var EventPlan = (function (_super) { | ||
__extends(EventPlan, _super); | ||
function EventPlan() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return MessageMimetypes; | ||
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 () { | ||
function MessageMimeTypes() { | ||
} | ||
return MessageMimeTypes; | ||
}()); | ||
MessageMimetypes.SLACK_JSON = "application/x-atomist-slack+json"; | ||
MessageMimetypes.PLAIN_TEXT = "text/plain"; | ||
exports.MessageMimetypes = MessageMimetypes; | ||
MessageMimeTypes.SLACK_JSON = "application/x-atomist-slack+json"; | ||
MessageMimeTypes.PLAIN_TEXT = "text/plain"; | ||
exports.MessageMimeTypes = MessageMimeTypes; | ||
/** | ||
@@ -66,3 +108,3 @@ * Represents the response to the bot from a command | ||
this.kind = "response"; | ||
this.contentType = MessageMimetypes.PLAIN_TEXT; | ||
this.contentType = MessageMimeTypes.PLAIN_TEXT; | ||
this.usernames = []; | ||
@@ -75,10 +117,11 @@ this.channelNames = []; | ||
} | ||
ResponseMessage.prototype.addUser = function (username) { | ||
this.usernames.push(username); | ||
ResponseMessage.prototype.addAddress = function (address) { | ||
if (address instanceof UserAddress) { | ||
this.usernames.push(address.username); | ||
} | ||
else { | ||
this.channelNames.push(address.channelName); | ||
} | ||
return this; | ||
}; | ||
ResponseMessage.prototype.addChannel = function (channelName) { | ||
this.channelNames.push(channelName); | ||
return this; | ||
}; | ||
return ResponseMessage; | ||
@@ -107,3 +150,3 @@ }()); | ||
this.kind = "directed"; | ||
this.contentType = MessageMimetypes.PLAIN_TEXT; | ||
this.contentType = MessageMimeTypes.PLAIN_TEXT; | ||
this.usernames = []; | ||
@@ -133,6 +176,7 @@ this.channelNames = []; | ||
var LifecycleMessage = (function () { | ||
function LifecycleMessage(node) { | ||
function LifecycleMessage(node, lifecycleId) { | ||
this.kind = "lifecycle"; | ||
this.instructions = []; | ||
this.node = node; | ||
this.lifecycleId = lifecycleId; | ||
} | ||
@@ -139,0 +183,0 @@ LifecycleMessage.prototype.addAction = function (instruction) { |
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,42 +108,68 @@ success | ||
interface Response<T> { | ||
export interface Response<T> { | ||
msg: string | ||
code: number | ||
status: Status | ||
body: T | ||
} | ||
msg(): string | ||
type Respondable = EventRespondable<any> | CommandRespondable<any> | ||
code(): number | ||
status(): Status | ||
body(): T | ||
} | ||
/** | ||
* 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" | ||
export abstract class MessageMimetypes { | ||
export abstract class MessageMimeTypes { | ||
public static SLACK_JSON: MessageMimeType = "application/x-atomist-slack+json" | ||
@@ -186,3 +192,3 @@ public static PLAIN_TEXT: MessageMimeType = "text/plain" | ||
body: string; | ||
contentType: MessageMimeType = MessageMimetypes.PLAIN_TEXT | ||
contentType: MessageMimeType = MessageMimeTypes.PLAIN_TEXT | ||
usernames?: string[] = []; | ||
@@ -198,11 +204,11 @@ channelNames?: string[] = []; | ||
public addUser?(username: string): this { | ||
this.usernames.push(username); | ||
public addAddress?(address: MessageAddress): this { | ||
if (address instanceof UserAddress) { | ||
this.usernames.push(address.username); | ||
} | ||
else { | ||
this.channelNames.push(address.channelName); | ||
} | ||
return this; | ||
} | ||
public addChannel?(channelName: string): this { | ||
this.channelNames.push(channelName); | ||
return this; | ||
} | ||
} | ||
@@ -218,3 +224,3 @@ | ||
export type DirectedMessageAddress = UserAddress | ChannelAddress | ||
export type MessageAddress = UserAddress | ChannelAddress | ||
@@ -227,3 +233,3 @@ /** | ||
kind: "directed" = "directed" | ||
contentType: MessageMimeType = MessageMimetypes.PLAIN_TEXT | ||
contentType: MessageMimeType = MessageMimeTypes.PLAIN_TEXT | ||
body: string; | ||
@@ -233,3 +239,3 @@ usernames?: string[] = []; | ||
constructor(body: string, address: DirectedMessageAddress, contentType?: MessageMimeType, ) { | ||
constructor(body: string, address: MessageAddress, contentType?: MessageMimeType) { | ||
this.body = body; | ||
@@ -242,3 +248,3 @@ if (contentType) { | ||
public addAddress?(address: DirectedMessageAddress): this { | ||
public addAddress?(address: MessageAddress): this { | ||
if (address instanceof UserAddress) { | ||
@@ -262,9 +268,11 @@ this.usernames.push(address.username); | ||
instructions?: Presentable<any>[] = []; | ||
lifecycleId: string; | ||
constructor(node: GraphNode) { | ||
constructor(node: GraphNode, lifecycleId: string) { | ||
this.node = node; | ||
this.lifecycleId = lifecycleId; | ||
} | ||
public addAction?(instruction: Presentable<any>): this { | ||
this.instructions.push(instruction) | ||
this.instructions.push(instruction); | ||
return this; | ||
@@ -276,3 +284,3 @@ } | ||
abstract class MappedParameters { | ||
export abstract class MappedParameters { | ||
static readonly GITHUB_REPO_OWNER: string = "atomist://github/repository/owner" | ||
@@ -286,5 +294,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": "1.0.0-m.1", | ||
"version": "1.0.0-m.2", | ||
"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"); |
@@ -1,5 +0,6 @@ | ||
import { ScenarioWorld } from "../ScenarioWorld" | ||
import { ScenarioWorld, RepoId } 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,12 @@ * be matched by path expressions other than event handler expressions | ||
/** | ||
* Define the given repo | ||
*/ | ||
defineRepo(owner: string, name: string, branchOrSha: string, p: Project); | ||
defineRepo(repoId: RepoId, p: Project); | ||
/** | ||
* Return a single plan. Throws an exception if no plan was recorded | ||
*/ | ||
plan(): Plan | ||
plan(): T | ||
@@ -28,3 +41,3 @@ /** | ||
*/ | ||
planFor(handlerName: string): Plan | ||
planFor(handlerName: string): T | ||
@@ -47,3 +60,3 @@ /** | ||
*/ | ||
export interface CommandHandlerScenarioWorld extends HandlerScenarioWorld { | ||
export interface CommandHandlerScenarioWorld extends HandlerScenarioWorld<CommandPlan> { | ||
@@ -63,3 +76,3 @@ /** | ||
export interface EventHandlerScenarioWorld extends HandlerScenarioWorld { | ||
export interface EventHandlerScenarioWorld extends HandlerScenarioWorld<EventPlan> { | ||
@@ -117,4 +130,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"); |
@@ -1,6 +0,6 @@ | ||
import { Project } from "../../model/Core" | ||
import { ProjectEditor } from "../../operations/ProjectEditor" | ||
import { ProjectGenerator } from "../../operations/ProjectGenerator" | ||
import { ScenarioWorld } from "../ScenarioWorld" | ||
import { Result } from "../Result" | ||
import { Project } from "../../model/Core"; | ||
import { ProjectEditor } from "../../operations/ProjectEditor"; | ||
import { ProjectGenerator } from "../../operations/ProjectGenerator"; | ||
import { ScenarioWorld } from "../ScenarioWorld"; | ||
import { Result } from "../Result"; | ||
@@ -14,5 +14,10 @@ /** | ||
/** | ||
* Set the project fixture | ||
*/ | ||
setProject(p: Project): void; | ||
/** | ||
* Return a project editor from the local context identified by name | ||
*/ | ||
editor(name: string): ProjectEditor | ||
editor(name: string): ProjectEditor; | ||
@@ -22,3 +27,3 @@ /** | ||
*/ | ||
generator(name: string): ProjectGenerator | ||
generator(name: string): ProjectGenerator; | ||
@@ -28,3 +33,3 @@ /** | ||
*/ | ||
editWith(ed: ProjectEditor, params: {}) | ||
editWith(ed: ProjectEditor, params: {}); | ||
@@ -34,3 +39,3 @@ /** | ||
*/ | ||
generateWith(gen: ProjectGenerator, projectName: string, params: {}) | ||
generateWith(gen: ProjectGenerator, projectName: string, params: {}); | ||
@@ -43,3 +48,3 @@ /** | ||
*/ | ||
modificationsMade(): number | ||
modificationsMade(): number; | ||
@@ -49,3 +54,3 @@ /** | ||
*/ | ||
failed(): boolean | ||
failed(): boolean; | ||
@@ -55,12 +60,18 @@ /** | ||
*/ | ||
editorsRun(): number | ||
editorsRun(): number; | ||
} | ||
// 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; | ||
@@ -72,16 +83,33 @@ } | ||
export function Given(s: string, f: (Project, ProjectScenarioWorld?, ...args) => void) { | ||
com_atomist_rug_test_gherkin_GherkinRunner$_definitions.Given(s, f) | ||
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) { | ||
com_atomist_rug_test_gherkin_GherkinRunner$_definitions.When(s, f) | ||
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) { | ||
com_atomist_rug_test_gherkin_GherkinRunner$_definitions.Then(s, f) | ||
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" | ||
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"); | ||
var ScenarioWorld_1 = require("../ScenarioWorld"); | ||
// Register well-known steps | ||
@@ -11,2 +13,15 @@ /** | ||
/** | ||
* Cloned content from GitHub | ||
*/ | ||
Core_1.Given("github ([^/]+)/([^/]+)", function (p, world, owner, name) { | ||
var repo = new ScenarioWorld_1.CloneInfo(owner, name); | ||
var project = world.cloneRepo(repo); | ||
world.setProject(project); | ||
}); | ||
Core_1.Given("github ([^/]+)/([^/]+)/([^/]+)", function (p, world, owner, name, branch) { | ||
var repo = new ScenarioWorld_1.CloneInfo(owner, name).withBranch(branch); | ||
var project = world.cloneRepo(repo); | ||
world.setProject(project); | ||
}); | ||
/** | ||
* ArchiveRoot project | ||
@@ -18,2 +33,8 @@ */ | ||
/** | ||
* The contents of this archive, excluding Atomist content | ||
*/ | ||
Core_1.Given("archive non Atomist content", function (p) { | ||
p.copyEditorBackingProject(""); | ||
}); | ||
/** | ||
* Editor made changes | ||
@@ -42,2 +63,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); | ||
}); | ||
/** | ||
@@ -44,0 +78,0 @@ * When step should fail |
@@ -1,2 +0,3 @@ | ||
import {Given, When, Then} from "./Core" | ||
import { Given, When, Then } from "./Core" | ||
import { CloneInfo } from "../ScenarioWorld" | ||
@@ -13,2 +14,17 @@ // Register well-known steps | ||
/** | ||
* Cloned content from GitHub | ||
*/ | ||
Given("github ([^/]+)/([^/]+)", (p, world, owner: string, name: string) => { | ||
const repo = new CloneInfo(owner, name); | ||
const project = world.cloneRepo(repo); | ||
world.setProject(project); | ||
}); | ||
Given("github ([^/]+)/([^/]+)/([^/]+)", (p, world, owner: string, name: string, branch) => { | ||
const repo = new CloneInfo(owner, name).withBranch(branch); | ||
const project = world.cloneRepo(repo); | ||
world.setProject(project); | ||
}); | ||
/** | ||
* ArchiveRoot project | ||
@@ -21,2 +37,9 @@ */ | ||
/** | ||
* The contents of this archive, excluding Atomist content | ||
*/ | ||
Given("archive non Atomist content", p => { | ||
p.copyEditorBackingProject(""); | ||
}); | ||
/** | ||
* Editor made changes | ||
@@ -49,2 +72,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}`) | ||
}); | ||
/** | ||
@@ -51,0 +90,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 }); | ||
/** | ||
* Information necessary to clone a repo | ||
*/ | ||
var CloneInfo = (function () { | ||
function CloneInfo(owner, name) { | ||
this.owner = owner; | ||
this.name = name; | ||
this.branch = "master"; | ||
this.depth = 10; | ||
} | ||
CloneInfo.prototype.withBranch = function (branch) { | ||
this.branch = branch; | ||
return this; | ||
}; | ||
CloneInfo.prototype.withSha = function (sha) { | ||
this.sha = sha; | ||
return this; | ||
}; | ||
CloneInfo.prototype.withDepth = function (depth) { | ||
this.depth = depth; | ||
return this; | ||
}; | ||
CloneInfo.prototype.withRemote = function (remote) { | ||
this.remote = remote; | ||
return this; | ||
}; | ||
return CloneInfo; | ||
}()); | ||
exports.CloneInfo = CloneInfo; |
import { Project } from "../model/Project"; | ||
/** | ||
@@ -8,12 +10,21 @@ * Superinterface for all worlds: Isolated contexts | ||
get(key: string): any | ||
/** | ||
* Get the value of the given key in the scenario, or null | ||
*/ | ||
get(key: string): any; | ||
put(key: string, what: any): void | ||
/** | ||
* Bind the value to the given key in the scenario | ||
*/ | ||
put(key: string, what: any): void; | ||
clear(key: string): 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. | ||
*/ | ||
abort(): void | ||
abort(): void; | ||
@@ -23,3 +34,3 @@ /** | ||
*/ | ||
aborted(): boolean | ||
aborted(): boolean; | ||
@@ -30,3 +41,61 @@ /** | ||
*/ | ||
invalidParameters(): any | ||
invalidParameters(): any; | ||
/** | ||
* Clone the given repo and provide a reference to the project | ||
*/ | ||
cloneRepo(cloneInfo: CloneInfo): Project; | ||
} | ||
/** | ||
* Identifies a repo | ||
*/ | ||
export interface RepoId { | ||
branch: string; | ||
sha: string; | ||
owner: string; | ||
name: string; | ||
} | ||
/** | ||
* Information necessary to clone a repo | ||
*/ | ||
export class CloneInfo implements RepoId { | ||
public branch = "master"; | ||
public sha: string; | ||
public depth: number = 10; | ||
public remote: string; | ||
constructor(public owner: string, public name: string) {} | ||
public withBranch(branch: string): CloneInfo { | ||
this.branch = branch; | ||
return this; | ||
} | ||
public withSha(sha: string): CloneInfo { | ||
this.sha = sha; | ||
return this; | ||
} | ||
public withDepth(depth: number): CloneInfo { | ||
this.depth = depth; | ||
return this; | ||
} | ||
public withRemote(remote: string): CloneInfo { | ||
this.remote = remote; | ||
return this; | ||
} | ||
} |
"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. |
@@ -6,5 +6,5 @@ /** | ||
root(): R | ||
root: R | ||
matches(): N[] | ||
matches: N[] | ||
} | ||
@@ -11,0 +11,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -18,9 +19,7 @@ * Convenient superclass that wraps an existing PathExpressionEngine | ||
TransformingPathExpressionEngine.prototype.evaluate = function (root, expr) { | ||
var _this = this; | ||
var m1 = this.delegate.evaluate(root, expr); | ||
var m2 = { | ||
root: function () { return this.nodeTransform(m1.root()); }, | ||
matches: function () { | ||
var _this = this; | ||
return m1.matches().map(function (n) { return _this.nodeTransform(n); }); | ||
} | ||
root: this.nodeTransform(m1.root), | ||
matches: m1.matches.map(function (n) { return _this.nodeTransform(n); }) | ||
}; | ||
@@ -27,0 +26,0 @@ return m2; |
@@ -22,6 +22,4 @@ import {PathExpressionEngine,PathExpression,Match,DynamicType,GraphNode,TreeNode} from "./PathExpression" | ||
let m2 = { | ||
root() { return this.nodeTransform(m1.root()) }, | ||
matches() { | ||
return m1.matches().map(n => this.nodeTransform(n)) | ||
} | ||
root: this.nodeTransform(m1.root) as R, | ||
matches: m1.matches.map(n => this.nodeTransform(n)) as any | ||
} | ||
@@ -28,0 +26,0 @@ return m2 |
@@ -6,2 +6,3 @@ /** | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function hasTag(n, t) { | ||
@@ -63,1 +64,61 @@ 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; | ||
/** | ||
* Use as replacer argument in JSON.stringify. | ||
* Essentially a curried functionality, allowing us to pass in a stringifier | ||
*/ | ||
function nodeReplacer(nodeStringifier) { | ||
if (nodeStringifier === void 0) { nodeStringifier = nodeAndValueStringifier; } | ||
return function (key, value) { | ||
if (value.nodeTags && value.value && value.children) { | ||
// TextTreeNode | ||
return { | ||
__kind__: "TextTreeNode", | ||
name: value.nodeName(), | ||
tags: value.nodeTags().join(","), | ||
structure: nodeStringifier(value) | ||
}; | ||
} | ||
else if (value.nodeTags) { | ||
return { | ||
__kind__: "GraphNode", | ||
name: value.nodeName(), | ||
tags: value.nodeTags().join(","), | ||
toString: value + "" | ||
}; | ||
} | ||
return value; | ||
}; | ||
} | ||
exports.nodeReplacer = nodeReplacer; |
@@ -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,75 @@ return n.nodeTags().indexOf(t) > -1 | ||
} | ||
export type NodeStringifier = (TextTreeNode) => string | ||
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: NodeStringifier): 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: NodeStringifier = nodeAndValueStringifier): string { | ||
return stringifyInternal(tn, nodeStringifier).join("\n"); | ||
} | ||
/** | ||
* Use as replacer argument in JSON.stringify. | ||
* Essentially a curried functionality, allowing us to pass in a stringifier | ||
*/ | ||
export function nodeReplacer(nodeStringifier: NodeStringifier = nodeAndValueStringifier) { | ||
return function(key, value) { | ||
if (value.nodeTags && value.value && value.children) { | ||
// TextTreeNode | ||
return { | ||
__kind__: "TextTreeNode", | ||
name: value.nodeName(), | ||
tags: value.nodeTags().join(","), | ||
structure: nodeStringifier(value) | ||
} | ||
} | ||
else if (value.nodeTags) { | ||
return { | ||
__kind__: "GraphNode", | ||
name: value.nodeName(), | ||
tags: value.nodeTags().join(","), | ||
toString: value + "" | ||
} | ||
} | ||
return value; | ||
} | ||
} |
304353
156
7482