MCPcopy
hub / github.com/mongodb/node-mongodb-native / main

Function main

etc/docs/build.ts:74–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72}
73
74async function main() {
75 try {
76 await exec('bash ./etc/check-remote.sh');
77 } catch (error) {
78 console.error(error.stdout);
79 process.exit(1);
80 }
81
82 const { stdout } = await exec('hugo version', { encoding: 'utf8' });
83 if (!stdout.includes('0.150.0')) throw new Error('`hugo` version must be 0.150.0.');
84
85 chdir(__dirname);
86
87 const { tag, status, skipPrompts } = getCommandLineArguments();
88
89 const newVersion: VersionSchema = {
90 version: `${tag} Driver`,
91 status,
92 api: `./${tag}`,
93 usesMongoDBManual: true,
94 tag
95 };
96
97 if (!skipPrompts) {
98 await confirm(`
99 Generating docs for the following configuration.\n${JSON.stringify(newVersion, null, 2)}
100 Does this look right? [y/n] `);
101 }
102
103 log('Installing dependencies...');
104 await installDependencies();
105
106 log('Building docs for current branch');
107 await buildDocs(newVersion);
108
109 log('Generating new static site...');
110
111 const tomlVersions = parse(
112 await readFile(RELEASES_TOML_FILE, { encoding: 'utf8' })
113 ) as unknown as TomlVersionSchema;
114 const jsonVersions = JSON.parse(
115 await readFile(RELEASES_JSON_FILE, { encoding: 'utf8' })
116 ) as unknown as JsonVersionSchema[];
117
118 const versionAlreadyExists = jsonVersions.some(({ version }) => version === tag);
119
120 if (versionAlreadyExists && !skipPrompts) {
121 await confirm(
122 `Version ${tag} already exists. Do you want to override the existing docs? [y/n] `
123 );
124 }
125
126 await updateSiteTemplateForNewVersion(newVersion, tomlVersions, jsonVersions);
127 await copyNewDocsToGeneratedSite(newVersion);
128 await copyGeneratedDocsToDocsFolder();
129 await removeTempDirectory();
130
131 log('Successfully generated api documentation and updated the doc site.');

Callers 1

build.tsFile · 0.70

Calls 12

getCommandLineArgumentsFunction · 0.90
confirmFunction · 0.90
logFunction · 0.90
installDependenciesFunction · 0.85
buildDocsFunction · 0.85
parseFunction · 0.85
removeTempDirectoryFunction · 0.85
errorMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected