diff --git a/.evergreen/config.in.yml b/.evergreen/config.in.yml index bae7dede801..96297139a4d 100644 --- a/.evergreen/config.in.yml +++ b/.evergreen/config.in.yml @@ -723,6 +723,16 @@ functions: args: - .evergreen/docker/alpine.sh + "build documentation": + - command: subprocess.exec + type: test + params: + working_dir: "src" + binary: bash + args: + - "-c" + - "npm run build:docs -- --yes" + tasks: - name: "test-atlas-data-lake" tags: ["datalake", "mongohouse"] diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 7fafbd1d63d..0f4e6dc6f9c 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -658,6 +658,15 @@ functions: add_expansions_to_env: true args: - .evergreen/docker/alpine.sh + build documentation: + - command: subprocess.exec + type: test + params: + working_dir: src + binary: bash + args: + - '-c' + - npm run build:docs -- --yes tasks: - name: test-atlas-data-lake tags: @@ -2038,6 +2047,17 @@ tasks: - func: install dependencies - func: bootstrap mongo-orchestration - func: check resource management feature integration + - name: test-build-docs + tags: + - lint-checks + commands: + - command: expansions.update + type: setup + params: + updates: + - {key: NODE_LTS_VERSION, value: '22'} + - func: install dependencies + - func: build documentation - name: check-types-typescript-next-node-types-22.15.3 tags: - check-types-typescript-next diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js index a26908a8ee2..01f22ac8216 100644 --- a/.evergreen/generate_evergreen_tasks.js +++ b/.evergreen/generate_evergreen_tasks.js @@ -571,6 +571,17 @@ SINGLETON_TASKS.push( { func: 'check resource management feature integration' } ] }, + { + name: 'test-build-docs', + tags: ['lint-checks'], + commands: [ + updateExpansions({ + NODE_LTS_VERSION: LATEST_LTS + }), + { func: 'install dependencies' }, + { func: 'build documentation' } + ] + }, ...Array.from(makeTypescriptTasks()) ] ); diff --git a/etc/docs/build.ts b/etc/docs/build.mts similarity index 94% rename from etc/docs/build.ts rename to etc/docs/build.mts index 8989fef950f..194a9ffb68f 100755 --- a/etc/docs/build.ts +++ b/etc/docs/build.mts @@ -3,6 +3,7 @@ import { parse, stringify } from '@iarna/toml'; import { exec as execCb } from 'child_process'; import { readFile, writeFile } from 'fs/promises'; +import { basename, dirname, join } from 'path'; import { chdir } from 'process'; import { promisify } from 'util'; @@ -15,7 +16,7 @@ import { log, type TomlVersionSchema, type VersionSchema -} from './utils'; +} from './utils.mts'; const exec = promisify(execCb); @@ -73,8 +74,10 @@ async function updateSiteTemplateForNewVersion( } async function main() { + const __dirname = import.meta.dirname; + try { - await exec('bash ./etc/check-remote.sh'); + await exec(`bash ${join(__dirname, '../check-remote.sh')}`); } catch (error) { console.error(error.stdout); process.exit(1); @@ -82,7 +85,7 @@ async function main() { chdir(__dirname); - const { tag, status, skipPrompts } = getCommandLineArguments(); + const { tag, status, skipPrompts } = await getCommandLineArguments(); const newVersion: VersionSchema = { version: `${tag} Driver`, diff --git a/etc/docs/preview.ts b/etc/docs/preview.mts similarity index 83% rename from etc/docs/preview.ts rename to etc/docs/preview.mts index 0df46b4e2a5..2e8c8b69de4 100644 --- a/etc/docs/preview.ts +++ b/etc/docs/preview.mts @@ -1,6 +1,6 @@ -import * as express from 'express'; +import express from 'express'; -import { log } from './utils'; +import { log } from './utils.mts'; const app = express(); diff --git a/etc/docs/utils.ts b/etc/docs/utils.mts similarity index 97% rename from etc/docs/utils.ts rename to etc/docs/utils.mts index 7a7a2a03d2b..f835ced80b4 100644 --- a/etc/docs/utils.ts +++ b/etc/docs/utils.mts @@ -54,11 +54,11 @@ export async function confirm(message: string) { } } -export function getCommandLineArguments(): { +export async function getCommandLineArguments(): Promise<{ tag: string; status: VersionSchema['status']; skipPrompts; -} { +}> { const { status, tag, diff --git a/package.json b/package.json index 9e730ce194f..0f4d31dd2cf 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "build:evergreen": "node .evergreen/generate_evergreen_tasks.js", "build:ts": "node ./node_modules/typescript/bin/tsc", "build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs && ESLINT_USE_FLAT_CONFIG=false eslint --no-ignore --fix mongodb.d.ts lib/beta.d.ts", - "build:docs": "./etc/docs/build.ts", + "build:docs": "cd etc/docs && node --loader ts-node/esm build.mts", "build:typedoc": "typedoc", "build:nightly": "node ./.github/scripts/nightly.mjs", "check:bench": "npm --prefix test/benchmarks/driver_bench start", @@ -161,7 +161,7 @@ "check:x509": "nyc mocha test/manual/x509_auth.test.ts", "fix:eslint": "npm run check:eslint -- --fix", "prepare": "node etc/prepare.js", - "preview:docs": "ts-node etc/docs/preview.ts", + "preview:docs": "cd etc/docs && node --loader ts-node/esm preview.mts", "test": "npm run check:lint && npm run test:all", "test:all": "npm run check:unit && npm run check:test", "update:docs": "npm run build:docs -- --yes" @@ -175,4 +175,4 @@ "moduleResolution": "node" } } -} +} \ No newline at end of file