forked from newrelic/docs-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverifyInstallPage.js
More file actions
67 lines (57 loc) · 1.73 KB
/
Copy pathverifyInstallPage.js
File metadata and controls
67 lines (57 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* eslint-disable no-console */
const fs = require('fs');
const yaml = require('js-yaml');
const path = require('path');
const glob = require('glob');
const { validateYamlFields } = require('./validate-install/schema');
const { verifyImages, verifyMDX } = require('./utils/verify-mdx-utils');
const verifyInstall = async () => {
const installPage = process.argv.slice(2);
if (installPage.length === 0) {
// just a little styling for the output
console.error(
'\x1b[31m%s\x1b[0m',
'\n (!)',
'Please provide the name of the agent/install page',
'\n eg. yarn verify-install-page java \n'
);
process.exit(1);
}
// VERIFY MDX CONTENT
const filePaths = glob.sync(`${__dirname}/../${installPage}/**/*.mdx`);
verifyImages(filePaths);
await verifyMDX(filePaths);
// VERIFY INSTALL
try {
const file = fs.readFileSync(
path.join(process.cwd(), `/src/install/config/${installPage}.yaml`),
'utf8'
);
try {
const data = yaml.load(file);
const isValid = validateYamlFields(data);
if (!isValid) {
process.exit(1);
}
} catch (e) {
console.error(
'\x1b[31m%s\x1b[0m%s\x1b[31m%s\x1b[0m%s',
'\n(!)',
`There is a syntax issue in ${installPage}.yaml \n These are sometimes caused by apostrophes. Be sure to use double quotes around any strings with apostrophes \n`,
'\nerror message: ',
`${e.message} \n`
);
process.exit(1);
}
} catch (e) {
console.error(
'\x1b[31m%s\x1b[0m',
'\n (!)',
`Cannot parse ${installPage}.yaml, make sure the file exists \n`,
`${e.message} \n`
);
process.exit(1);
}
console.log('\n🎉 No install issues found!');
};
verifyInstall();