kayvee 3.18.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -202
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/kayvee.d.ts +12 -0
- package/dist/kayvee.d.ts.map +1 -0
- package/{build/lib → dist}/kayvee.js +17 -30
- package/dist/logger/logger.d.ts +49 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/{build/lib → dist}/logger/logger.js +91 -83
- package/dist/middleware.d.ts +23 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +196 -0
- package/dist/package.json +89 -0
- package/dist/router/index.d.ts +23 -0
- package/dist/router/index.d.ts.map +1 -0
- package/{build/lib → dist}/router/index.js +33 -45
- package/package.json +63 -27
- package/.circleci/config.yml +0 -25
- package/.eslintrc.js +0 -124
- package/.github/workflows/notify-ci-status.yml +0 -20
- package/.nvmrc +0 -1
- package/.prettierrc.json +0 -1
- package/Makefile +0 -55
- package/benchmarks/data/.keep +0 -1
- package/benchmarks/data/corpus-basic.json +0 -22
- package/benchmarks/data/corpus-pathological.json +0 -22
- package/benchmarks/data/corpus-realistic.json +0 -22
- package/benchmarks/data/kvconfig-basic.yml +0 -7
- package/benchmarks/data/kvconfig-pathological.yml +0 -222
- package/benchmarks/data/kvconfig-realistic.yml +0 -39
- package/benchmarks/routing.js +0 -116
- package/build/lib/logger/helpers.js +0 -0
- package/build/lib/middleware.js +0 -274
- package/build/package.json +0 -53
- package/build/test/context_logger.js +0 -69
- package/build/test/kayvee.js +0 -36
- package/build/test/logger_test.js +0 -345
- package/build/test/middleware.js +0 -556
- package/build/test/router.js +0 -451
- package/index.js +0 -7
- package/lib/kayvee.ts +0 -73
- package/lib/logger/helpers.ts +0 -0
- package/lib/logger/logger.ts +0 -312
- package/lib/middleware.ts +0 -317
- package/lib/router/index.ts +0 -234
- package/lib/router/schema_definitions.json +0 -158
- package/test/context_logger.ts +0 -76
- package/test/kayvee.ts +0 -50
- package/test/kvconfig.yml +0 -14
- package/test/logger_test.ts +0 -378
- package/test/middleware.ts +0 -632
- package/test/router.ts +0 -558
- package/test/static/empty.css +0 -0
- package/test/static/js/empty.js +0 -0
- package/test/tests.json +0 -100
- package/tsconfig.json +0 -10
- /package/{build/lib → dist}/router/schema_definitions.json +0 -0
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Router = exports.Rule = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const jsonschema_1 = require("jsonschema");
|
|
9
|
+
const js_yaml_1 = require("js-yaml");
|
|
10
|
+
// JSON imports with "with { type: 'json' }" work in both native ESM (Node 24) and
|
|
11
|
+
// TypeScript/ts-node CJS (compiled to require()). This avoids import.meta.url which
|
|
12
|
+
// prevents Node 24 from bypassing ts-node's CJS hook via loadESMFromCJS.
|
|
13
|
+
// @ts-ignore TS1343 - import attributes are supported in TS 5.3+
|
|
14
|
+
const schema_definitions_json_1 = __importDefault(require("./schema_definitions.json"));
|
|
15
|
+
// @ts-ignore TS1343
|
|
16
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
17
|
+
const kvVersion = package_json_1.default.version;
|
|
8
18
|
const teamName = process.env._TEAM_OWNER || "UNSET";
|
|
9
19
|
const reEnvvarTokens = new RegExp("\\$\\{(.+?)\\}", "g");
|
|
10
20
|
const reFieldTokens = new RegExp("%\\{(.+?)\\}", "g");
|
|
11
21
|
// For performance reason this code is intentionally redundant and not-inlined.
|
|
12
|
-
// Removing redundancy and inlining this function
|
|
22
|
+
// Removing redundancy and inlining this function somehow makes performance worst.
|
|
13
23
|
function substituteEnvVars(obj, subber) {
|
|
14
24
|
const rtn = {};
|
|
15
|
-
const replacer = (s) => s.replace(reEnvvarTokens, (__, p1) => subber(p1));
|
|
25
|
+
const replacer = (s) => s.replace(reEnvvarTokens, (__, p1) => subber(p1) ?? "");
|
|
16
26
|
for (const key in obj) {
|
|
17
27
|
const val = obj[key];
|
|
18
28
|
if (Array.isArray(val)) {
|
|
@@ -53,10 +63,10 @@ function fieldMatches(obj, field, values) {
|
|
|
53
63
|
return false;
|
|
54
64
|
}
|
|
55
65
|
class Rule {
|
|
66
|
+
name;
|
|
67
|
+
matchers;
|
|
68
|
+
output;
|
|
56
69
|
constructor(name, matchers, output) {
|
|
57
|
-
this.name = null;
|
|
58
|
-
this.matchers = null;
|
|
59
|
-
this.output = null;
|
|
60
70
|
this.name = name;
|
|
61
71
|
this.matchers = matchers;
|
|
62
72
|
const envMissing = [];
|
|
@@ -82,7 +92,6 @@ class Rule {
|
|
|
82
92
|
}
|
|
83
93
|
this.output.rule = this.name;
|
|
84
94
|
}
|
|
85
|
-
// matches returns true if `msg` matches against this rule
|
|
86
95
|
matches(msg) {
|
|
87
96
|
for (const field in this.matchers) {
|
|
88
97
|
if (!fieldMatches(msg, field, this.matchers[field])) {
|
|
@@ -91,7 +100,6 @@ class Rule {
|
|
|
91
100
|
}
|
|
92
101
|
return true;
|
|
93
102
|
}
|
|
94
|
-
// returns the output with kv substitutions performed
|
|
95
103
|
outputFor(msg) {
|
|
96
104
|
const rtn = {};
|
|
97
105
|
const subst = (__, k) => msg[k] || deepKey(msg, k) || "KEY_NOT_FOUND";
|
|
@@ -112,39 +120,29 @@ class Rule {
|
|
|
112
120
|
return rtn;
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
|
-
|
|
116
|
-
// function instead of just doing a plain jsonschema.validate in order to get
|
|
117
|
-
// better error messages for the "output" object (by default jsonschema would
|
|
118
|
-
// just tell you that the output block doesn't match any of the known output
|
|
119
|
-
// formats, but won't tell you what's wrong because it doesn't let you
|
|
120
|
-
// condition on the output.type property).
|
|
123
|
+
exports.Rule = Rule;
|
|
121
124
|
function validateKVConfig(config) {
|
|
122
|
-
const validator = new
|
|
123
|
-
const results = validator.validate(config,
|
|
125
|
+
const validator = new jsonschema_1.Validator();
|
|
126
|
+
const results = validator.validate(config, schema_definitions_json_1.default);
|
|
124
127
|
return {
|
|
125
128
|
valid: results.valid,
|
|
126
|
-
errors: results.errors.map((err) => err.stack),
|
|
129
|
+
errors: results.errors.map((err) => err.stack ?? ""),
|
|
127
130
|
};
|
|
128
131
|
}
|
|
129
|
-
// parseConfig parses and validates the configuration passed as a string. It
|
|
130
|
-
// returns an object of the form {valid, rules, errors}, where valid is true if
|
|
131
|
-
// it was successfully parsed, rules is an array of rules, and errors is an
|
|
132
|
-
// array of errors.
|
|
133
132
|
function parseConfig(fileString) {
|
|
134
133
|
let config;
|
|
135
134
|
try {
|
|
136
|
-
config =
|
|
135
|
+
config = (0, js_yaml_1.load)(fileString);
|
|
137
136
|
}
|
|
138
137
|
catch (e) {
|
|
139
138
|
return { valid: false, rules: [], errors: [e] };
|
|
140
139
|
}
|
|
141
140
|
const validateRes = validateKVConfig(config);
|
|
142
141
|
if (!validateRes.valid) {
|
|
143
|
-
return
|
|
142
|
+
return Object.assign(validateRes, { rules: [] });
|
|
144
143
|
}
|
|
145
144
|
try {
|
|
146
|
-
const
|
|
147
|
-
const rules = _.values(rulesObj);
|
|
145
|
+
const rules = Object.entries(config.routes).map(([name, elem]) => new Rule(name, elem.matchers, elem.output));
|
|
148
146
|
return { valid: true, rules, errors: [] };
|
|
149
147
|
}
|
|
150
148
|
catch (e) {
|
|
@@ -152,28 +150,21 @@ function parseConfig(fileString) {
|
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
class Router {
|
|
153
|
+
rules;
|
|
155
154
|
constructor(rules) {
|
|
156
|
-
this.rules = null;
|
|
157
155
|
this.rules = rules || [];
|
|
158
156
|
}
|
|
159
|
-
// loadConfig reads in the config located at `filename` and sets the routing
|
|
160
|
-
// rules to what it finds there. It should be a YAML-formatted file with
|
|
161
|
-
// routing rules placed under the `routes` key on the root object.
|
|
162
157
|
loadConfig(filename) {
|
|
163
|
-
const data =
|
|
158
|
+
const data = node_fs_1.default.readFileSync(filename, "utf8");
|
|
164
159
|
this._loadConfigString(data);
|
|
165
160
|
}
|
|
166
161
|
_loadConfigString(configStr) {
|
|
167
162
|
const parsedRules = parseConfig(configStr);
|
|
168
163
|
if (!parsedRules.valid) {
|
|
169
|
-
throw new Error(parsedRules.errors);
|
|
164
|
+
throw new Error(String(parsedRules.errors));
|
|
170
165
|
}
|
|
171
166
|
this.rules = parsedRules.rules;
|
|
172
167
|
}
|
|
173
|
-
// route matches the log line `msg` against all loaded rules and returns a
|
|
174
|
-
// metadata object describing the outputs it should be sent to based on that
|
|
175
|
-
// matching. logger.ts will attach this to log lines under the `_kvmeta`
|
|
176
|
-
// property.
|
|
177
168
|
route(msg) {
|
|
178
169
|
const outputs = [];
|
|
179
170
|
for (let i = 0; i < this.rules.length; i++) {
|
|
@@ -190,7 +181,4 @@ class Router {
|
|
|
190
181
|
};
|
|
191
182
|
}
|
|
192
183
|
}
|
|
193
|
-
|
|
194
|
-
Router,
|
|
195
|
-
Rule,
|
|
196
|
-
};
|
|
184
|
+
exports.Router = Router;
|
package/package.json
CHANGED
|
@@ -1,46 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kayvee",
|
|
3
3
|
"description": "Write data to key=val pairs, for human and machine readability",
|
|
4
|
-
"version": "
|
|
5
|
-
"main": "index.js",
|
|
4
|
+
"version": "4.0.0",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/index.js",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./logger": {
|
|
14
|
+
"require": "./dist/logger/logger.js",
|
|
15
|
+
"import": "./dist/logger/logger.js",
|
|
16
|
+
"types": "./dist/logger/logger.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./middleware": {
|
|
19
|
+
"require": "./dist/middleware.js",
|
|
20
|
+
"import": "./dist/middleware.js",
|
|
21
|
+
"types": "./dist/middleware.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./router": {
|
|
24
|
+
"require": "./dist/router/index.js",
|
|
25
|
+
"import": "./dist/router/index.js",
|
|
26
|
+
"types": "./dist/router/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
"logger": ["dist/logger/logger.d.ts"],
|
|
32
|
+
"middleware": ["dist/middleware.d.ts"],
|
|
33
|
+
"router": ["dist/router/index.d.ts"]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/**/*",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
6
41
|
"repository": {
|
|
7
42
|
"type": "git",
|
|
8
43
|
"url": "git://github.com/Clever/kayvee-js"
|
|
9
44
|
},
|
|
10
45
|
"dependencies": {
|
|
11
|
-
"js-yaml": "^
|
|
12
|
-
"jsonschema": "^1.
|
|
13
|
-
"morgan": "^1.
|
|
14
|
-
"qs": "^6.
|
|
15
|
-
"split": "^1.0.0",
|
|
16
|
-
"underscore": "^1.8.3"
|
|
46
|
+
"js-yaml": "^4.1.0",
|
|
47
|
+
"jsonschema": "^1.5.0",
|
|
48
|
+
"morgan": "^1.10.0",
|
|
49
|
+
"qs": "^6.13.0"
|
|
17
50
|
},
|
|
18
51
|
"devDependencies": {
|
|
19
52
|
"@clever/prettier-config": "1.0.0",
|
|
20
|
-
"@types/
|
|
21
|
-
"@types/
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
53
|
+
"@types/express": "^4.17.23",
|
|
54
|
+
"@types/js-yaml": "^4.0.9",
|
|
55
|
+
"@types/jsonschema": "^1.1.1",
|
|
56
|
+
"@types/mocha": "^10.0.6",
|
|
57
|
+
"@types/morgan": "^1.9.10",
|
|
58
|
+
"@types/node": "^20.11.0",
|
|
59
|
+
"@types/qs": "^6.9.11",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
61
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
25
62
|
"benchmark": "^2.1.1",
|
|
26
|
-
"eslint": "^
|
|
27
|
-
"eslint-config-airbnb": "^
|
|
28
|
-
"eslint-config-prettier": "^
|
|
63
|
+
"eslint": "^8.56.0",
|
|
64
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
65
|
+
"eslint-config-prettier": "^9.1.0",
|
|
29
66
|
"eslint-formatter-summary": "^1.1.0",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"typescript": "^3.9.10"
|
|
67
|
+
"express": "^4.18.2",
|
|
68
|
+
"mocha": "^10.2.0",
|
|
69
|
+
"prettier": "^3.2.5",
|
|
70
|
+
"sinon": "^17.0.1",
|
|
71
|
+
"split": "^1.0.0",
|
|
72
|
+
"supertest": "^6.3.4",
|
|
73
|
+
"ts-node": "^10.9.2",
|
|
74
|
+
"typescript": "^5.3.0",
|
|
75
|
+
"underscore": "^1.8.3"
|
|
40
76
|
},
|
|
41
77
|
"scripts": {
|
|
42
78
|
"test": "make -Br test",
|
|
43
|
-
"
|
|
79
|
+
"prepublishOnly": "make build"
|
|
44
80
|
},
|
|
45
81
|
"author": "Clever <tech-notify@clever.com>",
|
|
46
82
|
"license": "BSD-2-Clause",
|
package/.circleci/config.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
jobs:
|
|
3
|
-
build:
|
|
4
|
-
working_directory: ~/Clever/kayvee-js
|
|
5
|
-
docker:
|
|
6
|
-
- image: circleci/node:12-stretch
|
|
7
|
-
environment:
|
|
8
|
-
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
|
9
|
-
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
|
|
10
|
-
steps:
|
|
11
|
-
- run:
|
|
12
|
-
command: cd $HOME && git clone --depth 1 -v https://github.com/Clever/ci-scripts.git && cd ci-scripts && git show --oneline -s
|
|
13
|
-
name: Clone ci-scripts
|
|
14
|
-
- checkout
|
|
15
|
-
- setup_remote_docker
|
|
16
|
-
- run:
|
|
17
|
-
command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
|
|
18
|
-
name: Set up CircleCI artifacts directories
|
|
19
|
-
- run:
|
|
20
|
-
command: npm install
|
|
21
|
-
name: npm install
|
|
22
|
-
- run: make build
|
|
23
|
-
- run: npm test
|
|
24
|
-
- run: make benchmarks
|
|
25
|
-
- run: if [ "${CIRCLE_BRANCH}" == "master" ]; then $HOME/ci-scripts/circleci/npm-publish $NPM_TOKEN .; fi;
|
package/.eslintrc.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
jasmine: true,
|
|
5
|
-
jest: true,
|
|
6
|
-
mocha: true,
|
|
7
|
-
node: true,
|
|
8
|
-
},
|
|
9
|
-
extends: [
|
|
10
|
-
// https://github.com/eslint/eslint
|
|
11
|
-
"eslint:recommended",
|
|
12
|
-
// https://github.com/yannickcr/eslint-plugin-react
|
|
13
|
-
"plugin:react/recommended",
|
|
14
|
-
// https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
|
|
15
|
-
"plugin:react-hooks/recommended",
|
|
16
|
-
// https: //github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
|
|
17
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
18
|
-
"plugin:@typescript-eslint/recommended",
|
|
19
|
-
// https://github.com/prettier/eslint-config-prettier
|
|
20
|
-
"prettier",
|
|
21
|
-
"prettier/@typescript-eslint",
|
|
22
|
-
],
|
|
23
|
-
parser: "@typescript-eslint/parser",
|
|
24
|
-
parserOptions: {
|
|
25
|
-
ecmaFeatures: {
|
|
26
|
-
jsx: true,
|
|
27
|
-
},
|
|
28
|
-
ecmaVersion: 13,
|
|
29
|
-
sourceType: "module",
|
|
30
|
-
project: "./tsconfig.json",
|
|
31
|
-
},
|
|
32
|
-
plugins: ["react", "react-hooks", "@typescript-eslint"],
|
|
33
|
-
rules: {
|
|
34
|
-
camelcase: "off",
|
|
35
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
36
|
-
eqeqeq: ["error", "smart"],
|
|
37
|
-
"global-require": "off",
|
|
38
|
-
"import/no-unresolved": "off",
|
|
39
|
-
indent: "off",
|
|
40
|
-
"key-spacing": ["error", { mode: "minimum" }],
|
|
41
|
-
"max-len": [
|
|
42
|
-
"error",
|
|
43
|
-
{
|
|
44
|
-
code: 115,
|
|
45
|
-
ignorePattern: "^import",
|
|
46
|
-
ignoreRegExpLiterals: true,
|
|
47
|
-
ignoreStrings: true,
|
|
48
|
-
ignoreTemplateLiterals: true,
|
|
49
|
-
ignoreUrls: true,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
"new-cap": [
|
|
53
|
-
"error",
|
|
54
|
-
{
|
|
55
|
-
capIsNewExceptions: ["immutable.OrderedMap", "OrderedMap"],
|
|
56
|
-
newIsCapExceptions: ["kayvee.logger"],
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
"newline-per-chained-call": "off",
|
|
60
|
-
"no-console": "off",
|
|
61
|
-
"no-multi-spaces": [
|
|
62
|
-
"error",
|
|
63
|
-
{
|
|
64
|
-
exceptions: {
|
|
65
|
-
ImportDeclaration: true,
|
|
66
|
-
VariableDeclarator: true,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
"no-param-reassign": [
|
|
71
|
-
"error",
|
|
72
|
-
{
|
|
73
|
-
props: false,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
"no-restricted-syntax": [
|
|
77
|
-
"error",
|
|
78
|
-
{
|
|
79
|
-
message: "Prefer useTypedDispatch to get a typed version of dispatch.",
|
|
80
|
-
selector: "CallExpression[callee.name='useDispatch']",
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
"no-underscore-dangle": "off",
|
|
84
|
-
"no-unused-vars": "off",
|
|
85
|
-
"no-var": "off",
|
|
86
|
-
quotes: ["error", "double", "avoid-escape"],
|
|
87
|
-
"react/display-name": "off",
|
|
88
|
-
"react/jsx-indent": "off",
|
|
89
|
-
"react/no-did-update-set-state": "off",
|
|
90
|
-
"react/prop-types": "off",
|
|
91
|
-
"react/sort-comp": "off",
|
|
92
|
-
"vars-on-top": "off",
|
|
93
|
-
"@typescript-eslint/ban-ts-comment": [
|
|
94
|
-
"error",
|
|
95
|
-
{
|
|
96
|
-
"ts-ignore": false,
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
"@typescript-eslint/ban-types": "off",
|
|
100
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
101
|
-
"@typescript-eslint/no-empty-function": ["error", { allow: ["arrowFunctions"] }],
|
|
102
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
103
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
104
|
-
"@typescript-eslint/no-floating-promises": "off",
|
|
105
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
106
|
-
"@typescript-eslint/no-unused-vars": ["error", { args: "none" }],
|
|
107
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
108
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
109
|
-
},
|
|
110
|
-
overrides: [
|
|
111
|
-
{
|
|
112
|
-
files: ["*.ts", "*.tsx"],
|
|
113
|
-
rules: {
|
|
114
|
-
"no-undef": "off",
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
settings: {
|
|
119
|
-
"import/resolver": "webpack",
|
|
120
|
-
react: {
|
|
121
|
-
version: "detect",
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: Notify CI status
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
check_suite:
|
|
5
|
-
types: [completed]
|
|
6
|
-
status:
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
call-workflow:
|
|
10
|
-
if: >-
|
|
11
|
-
(github.event.branches[0].name == github.event.repository.default_branch &&
|
|
12
|
-
(github.event.state == 'error' || github.event.state == 'failure')) ||
|
|
13
|
-
(github.event.check_suite.head_branch == github.event.repository.default_branch &&
|
|
14
|
-
github.event.check_suite.conclusion != 'success')
|
|
15
|
-
uses: Clever/ci-scripts/.github/workflows/reusable-notify-ci-status.yml@master
|
|
16
|
-
secrets:
|
|
17
|
-
CIRCLE_CI_INTEGRATIONS_URL: ${{ secrets.CIRCLE_CI_INTEGRATIONS_URL }}
|
|
18
|
-
CIRCLE_CI_INTEGRATIONS_USERNAME: ${{ secrets.CIRCLE_CI_INTEGRATIONS_USERNAME }}
|
|
19
|
-
CIRCLE_CI_INTEGRATIONS_PASSWORD: ${{ secrets.CIRCLE_CI_INTEGRATIONS_PASSWORD }}
|
|
20
|
-
SLACK_BOT_TOKEN: ${{ secrets.DAPPLE_BOT_TOKEN }}
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
14
|
package/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"@clever/prettier-config"
|
package/Makefile
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.PHONY: test build format format-all format-check lint
|
|
2
|
-
TESTS=$(shell cd test && ls *.ts | sed s/\.ts$$//)
|
|
3
|
-
TS_FILES := $(shell find . -name "*.ts" -not -path "./node_modules/*")
|
|
4
|
-
FORMATTED_FILES := $(TS_FILES) # Add other file types as you see fit, e.g. JSON files, config files
|
|
5
|
-
MODIFIED_FORMATTED_FILES := $(shell git diff --name-only master $(FORMATTED_FILES))
|
|
6
|
-
|
|
7
|
-
PRETTIER := ./node_modules/.bin/prettier
|
|
8
|
-
|
|
9
|
-
build: clean
|
|
10
|
-
./node_modules/.bin/tsc --outDir build
|
|
11
|
-
cp ./lib/router/schema_definitions.json ./build/lib/router/
|
|
12
|
-
cp ./package.json ./build/
|
|
13
|
-
|
|
14
|
-
test: lint test/tests.json $(TESTS)
|
|
15
|
-
|
|
16
|
-
$(TESTS):
|
|
17
|
-
_DEPLOY_ENV=testing _EXECUTION_NAME=abc DEBUG=us:progress NODE_ENV=test \
|
|
18
|
-
node_modules/mocha/bin/mocha --require ts-node/register --timeout 60000 test/$@.ts
|
|
19
|
-
|
|
20
|
-
benchmarks: build benchmark-data
|
|
21
|
-
node benchmarks/routing.js
|
|
22
|
-
|
|
23
|
-
clean:
|
|
24
|
-
rm -rf build
|
|
25
|
-
|
|
26
|
-
clean-data:
|
|
27
|
-
rm ./benchmarks/data/*.json ./benchmarks/data/*.yml
|
|
28
|
-
|
|
29
|
-
benchmark-data:
|
|
30
|
-
@# Only download if the files don't exist
|
|
31
|
-
@[ -f ./benchmarks/data/corpus-basic.json ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/corpus-basic.json > ./benchmarks/data/corpus-basic.json
|
|
32
|
-
@[ -f ./benchmarks/data/corpus-pathological.json ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/corpus-pathological.json > ./benchmarks/data/corpus-pathological.json
|
|
33
|
-
@[ -f ./benchmarks/data/corpus-realistic.json ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/corpus-realistic.json > ./benchmarks/data/corpus-realistic.json
|
|
34
|
-
@[ -f ./benchmarks/data/kvconfig-basic.yml ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/kvconfig-basic.yml > ./benchmarks/data/kvconfig-basic.yml
|
|
35
|
-
@[ -f ./benchmarks/data/kvconfig-pathological.yml ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/kvconfig-pathological.yml > ./benchmarks/data/kvconfig-pathological.yml
|
|
36
|
-
@[ -f ./benchmarks/data/kvconfig-realistic.yml ] || curl https://raw.githubusercontent.com/Clever/kayvee/master/data/kvconfig-realistic.yml > ./benchmarks/data/kvconfig-realistic.yml
|
|
37
|
-
|
|
38
|
-
format:
|
|
39
|
-
@echo "Formatting modified files..."
|
|
40
|
-
@$(PRETTIER) --write $(MODIFIED_FORMATTED_FILES)
|
|
41
|
-
|
|
42
|
-
format-all:
|
|
43
|
-
@echo "Formatting all files..."
|
|
44
|
-
@$(PRETTIER) --write $(FORMATTED_FILES)
|
|
45
|
-
|
|
46
|
-
format-check:
|
|
47
|
-
@echo "Running format check..."
|
|
48
|
-
@$(PRETTIER) --list-different $(FORMATTED_FILES) || \
|
|
49
|
-
(echo -e "❌ \033[0;31m Prettier found discrepancies in the above files. Run 'make format' to fix.\033[0m" && false)
|
|
50
|
-
|
|
51
|
-
lint: format-check
|
|
52
|
-
./node_modules/.bin/eslint $(TS_FILES)
|
|
53
|
-
|
|
54
|
-
test/tests.json:
|
|
55
|
-
wget https://raw.githubusercontent.com/Clever/kayvee/master/tests.json -O test/tests.json
|
package/benchmarks/data/.keep
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{ "title": "time" },
|
|
3
|
-
{ "title": "person" },
|
|
4
|
-
{ "title": "year" },
|
|
5
|
-
{ "title": "way" },
|
|
6
|
-
{ "title": "day" },
|
|
7
|
-
{ "title": "thing" },
|
|
8
|
-
{ "title": "man" },
|
|
9
|
-
{ "title": "world" },
|
|
10
|
-
{ "title": "life" },
|
|
11
|
-
{ "title": "hand" },
|
|
12
|
-
{ "title": "part" },
|
|
13
|
-
{ "title": "child" },
|
|
14
|
-
{ "title": "eye" },
|
|
15
|
-
{ "title": "woman" },
|
|
16
|
-
{ "title": "place" },
|
|
17
|
-
{ "title": "work" },
|
|
18
|
-
{ "title": "week" },
|
|
19
|
-
{ "title": "case" },
|
|
20
|
-
{ "title": "point" },
|
|
21
|
-
{ "title": "government" }
|
|
22
|
-
]
|