nx/scripts/documentation/documentation.ts
Miroslav Jonaš 9e06020575
feat(core): toggle additional prompts in CNW with a flag (#9546)
* feat(core): toggle additional prompts in CNW with a flag

* feat(repo): handle cli params with yargs

* feat(core): add docs generation

* chore(repo): add colors

* fix(core): migrate to yargs 17.x

* fix(core): update markup generation
2022-03-29 14:00:07 -04:00

67 lines
1.7 KiB
TypeScript

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 { generateCNWocumentation } 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`);
generatePackageSchemas();
generateDevkitDocumentation();
const commandsOutputDirectory = join(
__dirname,
'../../docs/',
'generated',
'cli'
);
removeSync(commandsOutputDirectory);
await generateCNWocumentation(commandsOutputDirectory);
await generateCLIDocumentation(commandsOutputDirectory);
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' : ''}`
);
}