feature/node-rewrite
Sven Slootweg 4 years ago
parent b9fc50c0d2
commit 98a4bcb6d8

@ -1,6 +1,5 @@
MARKER:
- Replace local `unreachable` with @joepie91/unreachable
- Update all Validatem usage to new validateArguments API
- Move to pegjs-import
- LVM / mdraid support and tabs (+ complete refactoring LVM implementation)
- Switch hashing to argon2id
- Switch child_process to execa

@ -15,14 +15,21 @@
"dependencies": {
"@babel/register": "^7.8.3",
"@joepie91/express-react-views": "^1.0.1",
"@joepie91/unreachable": "^1.0.0",
"@validatem/allow-extra-properties": "^0.1.0",
"@validatem/anything": "^0.1.0",
"@validatem/array-of": "^0.1.2",
"@validatem/core": "^0.3.15",
"@validatem/dynamic": "^0.1.2",
"@validatem/either": "^0.1.9",
"@validatem/error": "^1.1.0",
"@validatem/is-array": "^0.1.1",
"@validatem/is-function": "^0.1.0",
"@validatem/is-number": "^0.1.3",
"@validatem/is-plain-object": "^0.1.1",
"@validatem/is-regular-expression": "^0.1.0",
"@validatem/is-string": "^1.0.0",
"@validatem/require-either": "^0.1.0",
"@validatem/required": "^0.1.1",
"@validatem/when": "^0.1.0",
"JSONStream": "^1.1.4",
@ -74,8 +81,7 @@
"sse-channel": "^3.1.1",
"syncpipe": "^1.0.0",
"through2": "^2.0.1",
"uuid": "^2.0.2",
"validatem": "^0.2.0"
"uuid": "^2.0.2"
},
"devDependencies": {
"@babel/core": "^7.8.4",

@ -4,12 +4,12 @@ const Promise = require("bluebird");
const memoizee = require("memoizee");
const asExpression = require("as-expression");
const fs = Promise.promisifyAll(require("fs"));
const unreachable = require("@joepie91/unreachable")("cvm");
const lsblk = require("../../packages/exec-lsblk");
const All = require("../../packages/graphql-interface/symbols/all");
const treecutter = require("../../packages/treecutter");
const findInTree = require("../../packages/find-in-tree");
const shallowMerge = require("../../packages/shallow-merge");
const unreachable = require("../../packages/unreachable");
module.exports = function () {
let lsblkOnce = memoizee(() => {

@ -1,9 +1,13 @@
"use strict";
const { validateOptions, required, isFunction, isString } = require("validatem");
const assureArray = require("assure-array");
const isIterable = require("is-iterable");
const { validateOptions } = require("@validatem/core");
const required = require("@validatem/required");
const isFunction = require("@validatem/is-function");
const isString = require("@validatem/is-string");
module.exports = function findInTree(options) {
validateOptions(arguments, {
tree: [ required ],

@ -9,7 +9,8 @@ ensure NaN is handled correctly
const util = require("util");
const chalk = require("chalk");
const { validateArguments, required } = require("@validatem/core");
const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const arrayOf = require("@validatem/array-of");
const isString = require("@validatem/is-string");
const isNumber = require("@validatem/is-number");

@ -2,14 +2,17 @@
// FIXME: Finish this later
const { validateArguments, required, isString, isFunction } = require("validatem");
const { validateArguments } = require("@validatem/core");
const isString = require("@validatem/is-string");
const isFunction = require("@validatem/is-function");
const required = require("@validatem/required");
module.exports = function mapTree(tree, predicate, childrenProperty) {
validateArguments(arguments, [
[ "tree", required ],
[ "predicate", required, isFunction ],
[ "childrenProperty", isString ]
]);
validateArguments(arguments, {
tree: [ required ],
predicate: [ required, isFunction ],
childrenProperty: [ isString ]
});
};

@ -1,14 +1,15 @@
"use strict";
const { validateArguments, required } = require("@validatem/core");
const { validateArguments } = require("@validatem/core");
const isString = require("@validatem/is-string");
const isRegularExpression = require("@validatem/is-regular-expression");
const required = require("@validatem/required");
module.exports = function matchOrError(regex, string) {
validateArguments(arguments, [
[ "regex", required, isRegularExpression ],
[ "string", required, isString ]
]);
validateArguments(arguments, {
regex: [ required, isRegularExpression ],
string: [ required, isString ]
});
let match = regex.exec(string);

@ -1,6 +1,8 @@
"use strict";
const { validateArguments, required, isString } = require("validatem");
const { validateArguments } = require("@validatem/core");
const isString = require("@validatem/is-string");
const required = require("@validatem/required");
// FIXME: Length validation?
function parseModeDigit(modeDigit) {
@ -65,12 +67,12 @@ function intoDigits(modeString) {
}
module.exports = function parseModeString(modeString, { mask } = {}) {
validateArguments(arguments, [
[ "modeString", required, isString ],
[ "options", {
validateArguments(arguments, {
modeString: [ required, isString ],
options: {
mask: isString
}]
]);
}
});
let hasSpecialBits = (modeString.length === 4);
let modeDigits = intoDigits(modeString);

@ -1,25 +1,24 @@
"use strict";
const pegjs = require("pegjs");
const { validateOptions, either, required, isString, isPlainObject, allowExtraProperties } = require("validatem");
const fs = require("fs");
const moduleEval = require("eval");
const vm = require("vm");
const asExpression = require("as-expression");
const textParser = require("../text-parser");
const { validateOptions } = require("@validatem/core");
const isString = require("@validatem/is-string");
const isPlainObject = require("@validatem/is-plain-object");
const requireEither = require("@validatem/require-either");
module.exports = function createPegParser({ grammar, grammarFile, options }) {
validateOptions(arguments, [
{
grammar: [ isString ],
grammarFile: [ isString ],
options: [ isPlainObject ]
},
// FIXME: require-either
either(
allowExtraProperties({ grammar: [ required ] }),
allowExtraProperties({ grammarFile: [ required ] })
)
}, requireEither([ "grammar", "grammarFile" ])
]);
if (grammarFile != null) {

@ -1,9 +1,14 @@
"use strict";
const { validateArguments, required, isString, isArray, ValidationError } = require("validatem");
const assureArray = require("assure-array");
const shallowMerge = require("../shallow-merge");
const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const isString = require("@validatem/is-string");
const isArray = require("@validatem/is-array");
const ValidationError = require("@validatem/error");
function createListValidator() {
let lastSequenceNumber = null;
@ -32,10 +37,10 @@ function defaultOptions(options = {}) {
module.exports = {
flatten: function (tree, options) {
validateArguments(arguments, [
[ "tree", required ],
[ "options", validateTreecutterOptions ]
]);
validateArguments(arguments, {
tree: [ required ],
options: [ validateTreecutterOptions ]
});
let { childrenProperty } = defaultOptions(options);
@ -69,10 +74,10 @@ module.exports = {
rebuild: function (list, options) {
let isTreecutterList = createListValidator();
validateArguments(arguments, [
[ "list", required, isTreecutterList ],
[ "options", validateTreecutterOptions ]
]);
validateArguments(arguments, {
list: [ required, isTreecutterList ],
options: [ validateTreecutterOptions ]
});
let { childrenProperty } = defaultOptions(options);

@ -1,6 +0,0 @@
"use strict";
module.exports = function unreachable(reason) {
// TODO: Parse the package name out of the stacktrace and include it in the error message?
throw new Error(`${reason} -- this is a bug, please report it!`);
};

@ -968,6 +968,11 @@
lodash.escaperegexp "^4.1.2"
object-assign "^4.1.1"
"@joepie91/unreachable@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@joepie91/unreachable/-/unreachable-1.0.0.tgz#8032bb8a5813e81bbbe516cb3031d60818526687"
integrity sha512-vZRJ5UDq4mqP1vgSrcOLD3aIfS/nzwsvGFOOHv5sj5fa1Ss0dT1xnIzrXKLD9pu5EcUvF3K6n6jdaMW8uXpNEQ==
"@phc/format@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@phc/format/-/format-1.0.0.tgz#b5627003b3216dc4362125b13f48a4daa76680e4"
@ -1076,6 +1081,17 @@
dependencies:
"@validatem/combinator" "^0.1.1"
"@validatem/either@^0.1.9":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@validatem/either/-/either-0.1.9.tgz#0d753ef8fe04486d2b7122de3dd3ac51b3acaacf"
integrity sha512-cUqlRjy02qDcZ166/D6duk8lrtqrHynHuSakU0TvMGMBiLzjWpMJ+3beAWHe+kILB5/dlXVyc68ZIjSNhBi8Kw==
dependencies:
"@validatem/combinator" "^0.1.1"
"@validatem/error" "^1.0.0"
"@validatem/match-validation-error" "^0.1.0"
"@validatem/validation-result" "^0.1.2"
flatten "^1.0.3"
"@validatem/error@^1.0.0", "@validatem/error@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@validatem/error/-/error-1.1.0.tgz#bef46e7066c39761b494ebe3eec2ecdc7348f4ed"
@ -1103,7 +1119,7 @@
default-value "^1.0.0"
flatten "^1.0.3"
"@validatem/is-array@^0.1.0":
"@validatem/is-array@^0.1.0", "@validatem/is-array@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@validatem/is-array/-/is-array-0.1.1.tgz#fbe15ca8c97c30b622a5bbeb536d341e99cfc2c5"
integrity sha512-XD3C+Nqfpnbb4oO//Ufodzvui7SsCIW/stxZ39dP/fyRsBHrdERinkFATH5HepegtDlWMQswm5m1XFRbQiP2oQ==
@ -1208,6 +1224,18 @@
dependencies:
"@validatem/error" "^1.0.0"
"@validatem/require-either@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@validatem/require-either/-/require-either-0.1.0.tgz#250e35ab06f124ea90f3925d74b5f53a083923b0"
integrity sha512-UyZtJieT3aJhO9tj1OJp47V9jpHCE7RSohue9jg3FyDGwmIBVYXCfASeM19mWg9W0lp6IevsqTmaGQhqQOQYJg==
dependencies:
"@validatem/allow-extra-properties" "^0.1.0"
"@validatem/either" "^0.1.9"
"@validatem/forbidden" "^0.1.0"
"@validatem/required" "^0.1.1"
assure-array "^1.0.0"
flatten "^1.0.3"
"@validatem/required@^0.1.0", "@validatem/required@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@validatem/required/-/required-0.1.1.tgz#64f4a87333fc5955511634036b7f8948ed269170"
@ -2087,9 +2115,9 @@ camelcase@^4.0.0:
integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=
caniuse-lite@^1.0.30001135:
version "1.0.30001150"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz#6d0d829da654b0b233576de00335586bc2004df1"
integrity sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==
version "1.0.30001151"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001151.tgz#1ddfde5e6fff02aad7940b4edb7d3ac76b0cb00b"
integrity sha512-Zh3sHqskX6mHNrqUerh+fkf0N72cMxrmflzje/JyVImfpknscMnkeJrlFGJcqTmaa0iszdYptGpWMJCRQDkBVw==
capitalize@^2.0.0:
version "2.0.3"

Loading…
Cancel
Save