Skip to content

Commit

Permalink
fix(ssr): fix --no-docs (rename to --skip-docs) (#11973)
Browse files Browse the repository at this point in the history
And ssr spas in `yarn start`.
This should be changed to be ad hoc ssred in the future.
  • Loading branch information
fiji-flo authored Oct 17, 2024
1 parent e0c5575 commit 69ca945
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build/ssr-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ if (SENTRY_DSN_BUILD) {
}

program
.option("-n, --no-docs", "Do not build docs (only spas, blog...)", {
.option("-s, --skip-docs", "Do not build docs (only spas, blog...)", {
default: false,
})
.action(async ({ options }) => {
await ssrAllDocuments({ noDocs: Boolean(options?.noDocs) });
await ssrAllDocuments({ skipDocs: Boolean(options?.skipDocs) });
});

program.run();
15 changes: 9 additions & 6 deletions build/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ export function ssrDocument(context: HydrationData) {
}

interface SSROptions {
noDocs?: boolean;
skipDocs?: boolean;
}

export async function ssrAllDocuments({ noDocs = false }: SSROptions = {}) {
const files = await findDocuments({ noDocs });
export async function ssrAllDocuments({
skipDocs: skipDocs = false,
}: SSROptions = {}) {
const files = await findDocuments({ skipDocs });

const start = Date.now();

Expand All @@ -41,14 +43,15 @@ export async function ssrAllDocuments({ noDocs = false }: SSROptions = {}) {
);
}

async function findDocuments(options: Pick<SSROptions, "noDocs">) {
async function findDocuments(options: Pick<SSROptions, "skipDocs">) {
const api = new fdir()
.withFullPaths()
.withErrors()
.exclude((dirName) => options.noDocs && dirName === "docs")
.exclude((dirName) => options.skipDocs && dirName === "docs")
.filter(
(filePath) =>
filePath.endsWith("index.json") || filePath.endsWith("404.json")
!filePath.endsWith("search-index.json") &&
(filePath.endsWith("index.json") || filePath.endsWith("404.json"))
)
.crawl(BUILD_OUT_ROOT);
const docs = await api.withPromise();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"prettier-check": "prettier --check .",
"prettier-format": "prettier --write .",
"render:html": "cross-env NODE_ENV=production NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node build/ssr-cli.ts",
"start": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && (test -f popularities.json || yarn tool popularities) && (test -d client/build/en-us/_spas || yarn tool spas) && nf -j Procfile.start start",
"start": "(test -f client/build/asset-manifest.json || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && (test -f popularities.json || yarn tool popularities) && (test -d client/build/en-us/_spas || yarn tool spas) && (test -d client/build/en-us/_spas/404.html || yarn render:html -s) && nf -j Procfile.start start",
"start:client": "cd client && cross-env NODE_ENV=development BABEL_ENV=development PORT=3000 node scripts/start.js",
"start:server": "node-dev --experimental-loader ts-node/esm server/index.ts",
"start:static-server": "cross-env NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node server/static.ts",
Expand Down

0 comments on commit 69ca945

Please sign in to comment.