@boll/core
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Tue, 27 Oct 2020 20:20:29 GMT", | ||
"date": "Fri, 13 Nov 2020 22:24:33 GMT", | ||
"tag": "@boll/core_v1.4.1", | ||
"version": "1.4.1", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "Allow boll to exclude git ignored files", | ||
"author": "email not defined", | ||
"commit": "368e8332d8350c3fed57f35fb132a528262e8825", | ||
"package": "@boll/core" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 27 Oct 2020 20:21:24 GMT", | ||
"tag": "@boll/core_v1.4.0", | ||
@@ -8,0 +23,0 @@ "version": "1.4.0", |
# Change Log - @boll/core | ||
This log was last generated on Tue, 27 Oct 2020 20:20:29 GMT and should not be manually modified. | ||
This log was last generated on Fri, 13 Nov 2020 22:24:33 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 1.4.1 | ||
Fri, 13 Nov 2020 22:24:33 GMT | ||
### Patches | ||
- Allow boll to exclude git ignored files (email not defined) | ||
## 1.4.0 | ||
Tue, 27 Oct 2020 20:20:29 GMT | ||
Tue, 27 Oct 2020 20:21:24 GMT | ||
@@ -11,0 +19,0 @@ ### Minor changes |
@@ -12,5 +12,6 @@ import { ConfigDefinition } from "./types"; | ||
private configuration; | ||
private ignoredFiles; | ||
constructor(configRegistry: ConfigRegistry, ruleRegistry: RuleRegistry, logger: Logger); | ||
buildSuite(): Suite; | ||
loadRuleSets(): RuleSet[]; | ||
buildSuite(): Promise<Suite>; | ||
loadRuleSets(): Promise<RuleSet[]>; | ||
load(def: ConfigDefinition): void; | ||
@@ -17,0 +18,0 @@ resolvedConfiguration(): ConfigDefinition; |
@@ -13,2 +13,38 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
@@ -25,2 +61,4 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
var suite_1 = require("./suite"); | ||
var ignore_1 = require("./ignore"); | ||
var git_utils_1 = require("./git-utils"); | ||
var Config = /** @class */ (function () { | ||
@@ -32,28 +70,58 @@ function Config(configRegistry, ruleRegistry, logger) { | ||
this.configuration = {}; | ||
this.ignoredFiles = new ignore_1.IgnoredFiles({ root: git_utils_1.getRepoRoot() }); | ||
} | ||
Config.prototype.buildSuite = function () { | ||
var suite = new suite_1.Suite(); | ||
suite.ruleSets = this.loadRuleSets(); | ||
return suite; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var suite, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
suite = new suite_1.Suite(); | ||
_a = suite; | ||
return [4 /*yield*/, this.loadRuleSets()]; | ||
case 1: | ||
_a.ruleSets = _b.sent(); | ||
return [2 /*return*/, suite]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Config.prototype.loadRuleSets = function () { | ||
var _this = this; | ||
var config = this.resolvedConfiguration(); | ||
return (config.ruleSets || []).map(function (ruleSetConfig) { | ||
var exclude = __spreadArrays((ruleSetConfig.exclude || []), (config.exclude || [])); | ||
if (ruleSetConfig.name && | ||
config.configuration && | ||
config.configuration.ruleSets && | ||
config.configuration.ruleSets[ruleSetConfig.name]) { | ||
exclude = __spreadArrays(exclude, (config.configuration.ruleSets[ruleSetConfig.name].exclude || [])); | ||
} | ||
var glob = ruleSetConfig.fileLocator; | ||
glob.exclude = exclude; | ||
glob.include = ruleSetConfig.include || []; | ||
var checks = (ruleSetConfig.checks || []).map(function (check) { | ||
var optionsFromConfig = (config.configuration && config.configuration.rules && config.configuration.rules[check.rule]) || {}; | ||
var options = __assign(__assign({}, check.options), optionsFromConfig); | ||
return _this.ruleRegistry.get(check.rule)(_this.logger, options); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var config, gitIgnoredFiles, _a; | ||
var _this = this; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
config = this.resolvedConfiguration(); | ||
if (!config.excludeGitControlledFiles) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.ignoredFiles.getIgnoredFiles()]; | ||
case 1: | ||
_a = _b.sent(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
_a = []; | ||
_b.label = 3; | ||
case 3: | ||
gitIgnoredFiles = _a; | ||
return [2 /*return*/, (config.ruleSets || []).map(function (ruleSetConfig) { | ||
var exclude = __spreadArrays((ruleSetConfig.exclude || []), (config.exclude || []), gitIgnoredFiles); | ||
if (ruleSetConfig.name && | ||
config.configuration && | ||
config.configuration.ruleSets && | ||
config.configuration.ruleSets[ruleSetConfig.name]) { | ||
exclude = __spreadArrays(exclude, (config.configuration.ruleSets[ruleSetConfig.name].exclude || [])); | ||
} | ||
var glob = ruleSetConfig.fileLocator; | ||
glob.exclude = exclude; | ||
glob.include = ruleSetConfig.include || []; | ||
var checks = (ruleSetConfig.checks || []).map(function (check) { | ||
var optionsFromConfig = (config.configuration && config.configuration.rules && config.configuration.rules[check.rule]) || {}; | ||
var options = __assign(__assign({}, check.options), optionsFromConfig); | ||
return _this.ruleRegistry.get(check.rule)(_this.logger, options); | ||
}); | ||
return new rule_set_1.RuleSet(glob, checks); | ||
})]; | ||
} | ||
}); | ||
return new rule_set_1.RuleSet(glob, checks); | ||
}); | ||
@@ -60,0 +128,0 @@ }; |
@@ -41,3 +41,5 @@ "use strict"; | ||
var format_test_1 = require("./format.test"); | ||
var git_utils_test_1 = require("./git-utils.test"); | ||
var glob_test_1 = require("./glob.test"); | ||
var ignore_test_1 = require("./ignore.test"); | ||
var pragma_test_1 = require("./pragma.test"); | ||
@@ -54,8 +56,14 @@ function suite() { | ||
_a.sent(); | ||
return [4 /*yield*/, glob_test_1.test.run()]; | ||
return [4 /*yield*/, git_utils_test_1.test.run()]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, pragma_test_1.test.run()]; | ||
return [4 /*yield*/, glob_test_1.test.run()]; | ||
case 4: | ||
_a.sent(); | ||
return [4 /*yield*/, ignore_test_1.test.run()]; | ||
case 5: | ||
_a.sent(); | ||
return [4 /*yield*/, pragma_test_1.test.run()]; | ||
case 6: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
@@ -62,0 +70,0 @@ } |
@@ -111,11 +111,20 @@ "use strict"; | ||
}); | ||
exports.test("should apply exclude/include across extended config", function () { | ||
var configRegistry = new config_registry_1.ConfigRegistry(); | ||
var ruleSets = [{ exclude: ["testme"], fileLocator: new FakeGlob() }]; | ||
configRegistry.register({ name: "base", ruleSets: ruleSets }); | ||
var config = new config_1.Config(configRegistry, new rule_registry_1.RuleRegistry(), logger_1.NullLogger); | ||
config.load({ extends: "base" }); | ||
var suite = config.buildSuite(); | ||
assert.deepStrictEqual(suite.ruleSets[0].fileGlob.exclude, ["testme"]); | ||
}); | ||
exports.test("should apply exclude/include across extended config", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var configRegistry, ruleSets, config, suite; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
configRegistry = new config_registry_1.ConfigRegistry(); | ||
ruleSets = [{ exclude: ["testme"], fileLocator: new FakeGlob() }]; | ||
configRegistry.register({ name: "base", ruleSets: ruleSets }); | ||
config = new config_1.Config(configRegistry, new rule_registry_1.RuleRegistry(), logger_1.NullLogger); | ||
config.load({ extends: "base" }); | ||
return [4 /*yield*/, config.buildSuite()]; | ||
case 1: | ||
suite = _a.sent(); | ||
assert.deepStrictEqual(suite.ruleSets[0].fileGlob.exclude, ["testme"]); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
exports.test("gives options to factory function", function () { | ||
@@ -136,50 +145,68 @@ var configRegistry = new config_registry_1.ConfigRegistry(); | ||
}); | ||
exports.test("downstream rules configuration applies to rules", function () { | ||
var configRegistry = new config_registry_1.ConfigRegistry(); | ||
configRegistry.register({ | ||
name: "base", | ||
ruleSets: [{ fileLocator: new FakeGlob(), checks: [{ rule: "foo", options: { bar: "baz" } }] }] | ||
exports.test("downstream rules configuration applies to rules", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var configRegistry, ruleRegistry, config, myConfig, suite, fakeRuleInstance; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
configRegistry = new config_registry_1.ConfigRegistry(); | ||
configRegistry.register({ | ||
name: "base", | ||
ruleSets: [{ fileLocator: new FakeGlob(), checks: [{ rule: "foo", options: { bar: "baz" } }] }] | ||
}); | ||
ruleRegistry = new rule_registry_1.RuleRegistry(); | ||
ruleRegistry.register("foo", function (l, options) { | ||
return new FakeRule(options); | ||
}); | ||
config = new config_1.Config(configRegistry, ruleRegistry, logger_1.NullLogger); | ||
myConfig = { | ||
extends: "base", | ||
configuration: { | ||
rules: { | ||
foo: { some: "rule" } | ||
} | ||
} | ||
}; | ||
config.load(myConfig); | ||
return [4 /*yield*/, config.buildSuite()]; | ||
case 1: | ||
suite = _a.sent(); | ||
fakeRuleInstance = suite.ruleSets[0].checks[0]; | ||
assert.deepStrictEqual(fakeRuleInstance.options, { bar: "baz", some: "rule" }); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
var ruleRegistry = new rule_registry_1.RuleRegistry(); | ||
ruleRegistry.register("foo", function (l, options) { | ||
return new FakeRule(options); | ||
}); | ||
var config = new config_1.Config(configRegistry, ruleRegistry, logger_1.NullLogger); | ||
var myConfig = { | ||
extends: "base", | ||
configuration: { | ||
rules: { | ||
foo: { some: "rule" } | ||
} | ||
}); }); | ||
exports.test("downstream ruleSet configuration applies to ruleSets", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var configRegistry, config, myConfig, suite, ruleSet; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
configRegistry = new config_registry_1.ConfigRegistry(); | ||
configRegistry.register({ | ||
name: "base", | ||
ruleSets: [{ fileLocator: new FakeGlob(), name: "fake", exclude: ["bar"] }], | ||
exclude: ["baz"] | ||
}); | ||
config = new config_1.Config(configRegistry, new rule_registry_1.RuleRegistry(), logger_1.NullLogger); | ||
myConfig = { | ||
extends: "base", | ||
exclude: ["foo2"], | ||
configuration: { | ||
ruleSets: { | ||
fake: { | ||
exclude: ["foo"] | ||
} | ||
} | ||
} | ||
}; | ||
config.load(myConfig); | ||
return [4 /*yield*/, config.buildSuite()]; | ||
case 1: | ||
suite = _a.sent(); | ||
ruleSet = suite.ruleSets[0]; | ||
assert.deepStrictEqual(ruleSet.fileGlob.exclude, ["bar", "foo2", "baz", "foo"]); | ||
return [2 /*return*/]; | ||
} | ||
}; | ||
config.load(myConfig); | ||
var suite = config.buildSuite(); | ||
var fakeRuleInstance = suite.ruleSets[0].checks[0]; | ||
assert.deepStrictEqual(fakeRuleInstance.options, { bar: "baz", some: "rule" }); | ||
}); | ||
exports.test("downstream ruleSet configuration applies to ruleSets", function () { | ||
var configRegistry = new config_registry_1.ConfigRegistry(); | ||
configRegistry.register({ | ||
name: "base", | ||
ruleSets: [{ fileLocator: new FakeGlob(), name: "fake", exclude: ["bar"] }], | ||
exclude: ["baz"] | ||
}); | ||
var config = new config_1.Config(configRegistry, new rule_registry_1.RuleRegistry(), logger_1.NullLogger); | ||
var myConfig = { | ||
extends: "base", | ||
exclude: ["foo2"], | ||
configuration: { | ||
ruleSets: { | ||
fake: { | ||
exclude: ["foo"] | ||
} | ||
} | ||
} | ||
}; | ||
config.load(myConfig); | ||
var suite = config.buildSuite(); | ||
var ruleSet = suite.ruleSets[0]; | ||
assert.deepStrictEqual(ruleSet.fileGlob.exclude, ["bar", "foo2", "baz", "foo"]); | ||
}); | ||
}); }); | ||
exports.test("resolveConfiguration merges exclude", function () { | ||
@@ -186,0 +213,0 @@ var configRegistry = new config_registry_1.ConfigRegistry(); |
@@ -20,2 +20,3 @@ import { BollFile } from "./boll-file"; | ||
ruleSets?: RuleSetConfiguration[]; | ||
excludeGitControlledFiles?: boolean; | ||
configuration?: { | ||
@@ -22,0 +23,0 @@ rules?: {}; |
@@ -9,2 +9,3 @@ { | ||
"graceful-fs": "4.2.4", | ||
"parse-gitignore": "^1.0.1", | ||
"typescript": "^3.9.7", | ||
@@ -19,2 +20,3 @@ "yaml": "^1.10.0" | ||
"@types/graceful-fs": "4.1.3", | ||
"@types/parse-gitignore": "^1.0.0", | ||
"baretest": "^2.0.0", | ||
@@ -48,3 +50,3 @@ "prettier": "^2.0.5", | ||
}, | ||
"version": "1.4.0" | ||
"version": "1.4.1" | ||
} |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
201272
54
3751
2
5
11
1
+ Addedparse-gitignore@^1.0.1
+ Addedparse-gitignore@1.0.1(transitive)