-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentation.ts
65 lines (55 loc) · 1.75 KB
/
documentation.ts
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
import * as chalk from 'chalk';
import { execSync } from 'child_process';
import { removeSync } from 'fs-extra';
import { join } from 'path';
import { generateCliDocumentation } from './generate-cli-data';
import { generateCnwDocumentation } from './generate-cnw-documentation';
import { generateDevkitDocumentation } from './generate-devkit-documentation';
import { generatePackageSchemas } from './package-schemas/generatePackageSchemas';
async function generate() {
try {
console.log(`${chalk.blue('i')} Generating Documentation`);
const commandsOutputDirectory = join(
__dirname,
'../../docs/',
'generated',
'cli'
);
removeSync(commandsOutputDirectory);
await generateCnwDocumentation(commandsOutputDirectory);
await generateCliDocumentation(commandsOutputDirectory);
generateDevkitDocumentation();
await Promise.all(generatePackageSchemas());
console.log(`\n${chalk.green('✓')} Generated Documentation\n`);
} catch (e) {
console.error(e);
process.exit(1);
}
}
function checkDocumentation() {
const output = execSync('git status --porcelain ./docs').toString('utf-8');
if (output) {
console.log(
`${chalk.red(
'!'
)} 📄 Documentation has been modified, you need to commit the changes. ${chalk.red(
'!'
)} `
);
console.log('\nChanged Docs:');
execSync('git status --porcelain ./docs', { stdio: 'inherit' });
process.exit(1);
} else {
console.log('📄 Documentation not modified');
}
}
generate().then(() => checkDocumentation());
function printInfo(
str: string,
newLine: boolean = true,
newLineAfter: boolean = true
) {
console.log(
`${newLine ? '\n' : ''}${chalk.blue('i')} ${str}${newLineAfter ? '\n' : ''}`
);
}