process#stdout TypeScript Examples
The following examples show how to use
process#stdout.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: generate.ts From backstage with Apache License 2.0 | 5 votes |
export default async function generate(opts: OptionValues) {
// Use techdocs-node package to generate docs. Keep consistency between Backstage and CI generating docs.
// Docs can be prepared using actions/checkout or git clone, or similar paradigms on CI. The TechDocs CI workflow
// will run on the CI pipeline containing the documentation files.
const logger = createLogger({ verbose: opts.verbose });
const sourceDir = resolve(opts.sourceDir);
const outputDir = resolve(opts.outputDir);
const omitTechdocsCorePlugin = opts.omitTechdocsCoreMkdocsPlugin;
const dockerImage = opts.dockerImage;
const pullImage = opts.pull;
const legacyCopyReadmeMdToIndexMd = opts.legacyCopyReadmeMdToIndexMd;
logger.info(`Using source dir ${sourceDir}`);
logger.info(`Will output generated files in ${outputDir}`);
logger.verbose('Creating output directory if it does not exist.');
await fs.ensureDir(outputDir);
const config = new ConfigReader({
techdocs: {
generator: {
runIn: opts.docker ? 'docker' : 'local',
dockerImage,
pullImage,
legacyCopyReadmeMdToIndexMd,
mkdocs: {
omitTechdocsCorePlugin,
},
},
},
});
// Docker client (conditionally) used by the generators, based on techdocs.generators config.
const dockerClient = new Docker();
const containerRunner = new DockerContainerRunner({ dockerClient });
let parsedLocationAnnotation = {} as ParsedLocationAnnotation;
if (opts.techdocsRef) {
try {
parsedLocationAnnotation = convertTechDocsRefToLocationAnnotation(
opts.techdocsRef,
);
} catch (err) {
logger.error(err.message);
}
}
// Generate docs using @backstage/plugin-techdocs-node
const techdocsGenerator = await TechdocsGenerator.fromConfig(config, {
logger,
containerRunner,
});
logger.info('Generating documentation...');
await techdocsGenerator.run({
inputDir: sourceDir,
outputDir,
...(opts.techdocsRef
? {
parsedLocationAnnotation,
}
: {}),
logger,
etag: opts.etag,
...(process.env.LOG_LEVEL === 'debug' ? { logStream: stdout } : {}),
});
logger.info('Done!');
}