Skip to content

Commit e59d6e2

Browse files
committed
test(warnings): added expected warnings
- added deprecated-warnings task
1 parent c8ce243 commit e59d6e2

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

packages/zeebe-element-templates-json-schema/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"test:integration": "mocha --reporter=spec --recursive test/integration",
1111
"dev": "npm run test -- --watch",
1212
"all": "run-s build test",
13-
"build": "run-s build:error-messages build:schema",
13+
"build": "run-s build:error-messages build:deprecated-warnings build:schema",
1414
"build:error-messages": "node ../../tasks/generate-error-messages.js --input=./src/error-messages.json --output=./resources/error-messages.json",
15+
"build:deprecated-warnings": "node ../../tasks/generate-deprecated-warnings.js --input=./src/deprecated-warnings.json --output=./resources/deprecated-warnings.json",
1516
"build:schema": "node ../../tasks/generate-schema.js --input=./src/schema.json --output=./resources/schema.json",
1617
"prepare": "run-s build"
1718
},
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"path": [
4+
"definitions",
5+
"properties",
6+
"allOf",
7+
1,
8+
"items",
9+
"allOf",
10+
23,
11+
"then",
12+
"anyOf",
13+
2
14+
],
15+
"warningMessage": "Hidden property must specify either \"value\" or \"generatedValue\""
16+
}
17+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const readFile = require('fs').readFileSync,
2+
writeFile = require('fs').writeFileSync,
3+
mkdir = require('fs').mkdirSync;
4+
5+
const pathJoin = require('path').join,
6+
dirname = require('path').dirname;
7+
8+
const mri = require('mri');
9+
10+
const argv = process.argv.slice(2);
11+
12+
async function bundleWarnings(warningMessages, path) {
13+
return writeWarnings(warningMessages, path);
14+
}
15+
16+
17+
function writeWarnings(warningMessages, path) {
18+
const filePath = pathJoin(path);
19+
20+
try {
21+
mkdir(dirname(filePath));
22+
} catch {
23+
24+
// directory may already exist
25+
}
26+
27+
writeFile(filePath, JSON.stringify(warningMessages, 0, 2));
28+
29+
return filePath;
30+
}
31+
32+
33+
const {
34+
input,
35+
output
36+
} = mri(argv, {
37+
alias: {
38+
i: 'input',
39+
o: 'output'
40+
}
41+
});
42+
43+
if (!input || !output) {
44+
console.error('Arguments missing.');
45+
console.error('Example: node tasks/generate-error-messages.js --input=./src/error-messages.json --output=./resources/error-messages.json');
46+
process.exit(1);
47+
}
48+
49+
bundleWarnings(JSON.parse(readFile(input)), output);

0 commit comments

Comments
 (0)