Skip to content

Commit faf883c

Browse files
committed
refactor: split generate-messenger-docs into modular folder structure
1 parent b77f821 commit faf883c

10 files changed

Lines changed: 13842 additions & 544 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ docs-site/build/
4444
docs-site/.docusaurus/
4545
docs-site/node_modules/
4646
docs-site/package-lock.json
47+
docs-site/.yarn/
4748

4849
# Emacs
4950
\#*\#

docs-site/yarn.lock

Lines changed: 13292 additions & 0 deletions
Large diffs are not rendered by default.

eslint.config.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ const config = createConfig([
1515
'merged-packages/**',
1616
'.yarn/**',
1717
'scripts/create-package/package-template/**',
18+
'docs-site/docs/**',
19+
'docs-site/sidebars.ts',
20+
'docs-site/build/**',
21+
'docs-site/.docusaurus/**',
22+
'docs-site/node_modules/**',
23+
'docs-site/.yarn/**',
1824
],
1925
},
2026
{
@@ -41,8 +47,7 @@ const config = createConfig([
4147
'**/*.test.{js,ts}',
4248
'**/test/**/*.{js,ts}',
4349
'**/tests/**/*.{js,ts}',
44-
'scripts/*.ts',
45-
'scripts/create-package/**/*.ts',
50+
'scripts/**/*.ts',
4651
],
4752
extends: [nodejs],
4853
},
@@ -125,7 +130,7 @@ const config = createConfig([
125130
},
126131
},
127132
{
128-
files: ['scripts/*.ts'],
133+
files: ['scripts/**/*.ts'],
129134
rules: {
130135
// Scripts may be self-executable and thus have hashbangs.
131136
'n/hashbang': 'off',

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
"changelog:update": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:update",
2222
"changelog:validate": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:validate",
2323
"create-package": "tsx scripts/create-package",
24-
"docs:messenger:build": "yarn docs:messenger:generate && npm --prefix docs-site install && npm --prefix docs-site run build",
25-
"docs:messenger:build:client": "yarn docs:messenger:generate:client && npm --prefix docs-site install && npm --prefix docs-site run build",
26-
"docs:messenger:dev": "yarn docs:messenger:generate && npm --prefix docs-site install && npm --prefix docs-site start",
27-
"docs:messenger:dev:client": "yarn docs:messenger:generate:client && npm --prefix docs-site install && npm --prefix docs-site start",
28-
"docs:messenger:generate": "tsx scripts/generate-messenger-docs.ts",
29-
"docs:messenger:generate:client": "tsx scripts/generate-messenger-docs.ts --client",
30-
"docs:messenger:serve": "yarn docs:messenger:build && npm --prefix docs-site run serve",
31-
"docs:messenger:serve:client": "yarn docs:messenger:build:client && npm --prefix docs-site run serve",
24+
"docs:messenger:build": "yarn docs:messenger:generate && yarn --cwd docs-site install && yarn --cwd docs-site build",
25+
"docs:messenger:build:client": "yarn docs:messenger:generate:client \"$@\" && yarn --cwd docs-site install && yarn --cwd docs-site build",
26+
"docs:messenger:dev": "yarn docs:messenger:generate && yarn --cwd docs-site install && yarn --cwd docs-site start",
27+
"docs:messenger:dev:client": "yarn docs:messenger:generate:client \"$@\" && yarn --cwd docs-site install && yarn --cwd docs-site start",
28+
"docs:messenger:generate": "tsx scripts/generate-messenger-docs/index.ts",
29+
"docs:messenger:generate:client": "tsx scripts/generate-messenger-docs/index.ts --client",
30+
"docs:messenger:serve": "yarn docs:messenger:build && yarn --cwd docs-site serve",
31+
"docs:messenger:serve:client": "yarn docs:messenger:build:client \"$@\" && yarn --cwd docs-site serve",
3232
"generate-method-action-types": "yarn workspaces foreach --all --parallel --interlaced --verbose run generate-method-action-types",
3333
"lint": "yarn lint:eslint && echo && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn lint:teams && yarn generate-method-action-types --check",
3434
"lint:dependencies": "depcheck && yarn dedupe --check",
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* eslint-disable n/no-sync */
2+
3+
import * as fs from 'fs';
4+
import * as path from 'path';
5+
6+
export const SKIP_DIRS = new Set([
7+
'__tests__',
8+
'tests',
9+
'test',
10+
'node_modules',
11+
'dist',
12+
'__mocks__',
13+
]);
14+
15+
/**
16+
* Recursively find all non-test TypeScript files in a directory.
17+
*
18+
* @param dir - The directory to search.
19+
* @returns An array of absolute file paths.
20+
*/
21+
export function findTsFiles(dir: string): string[] {
22+
const results: string[] = [];
23+
24+
function walk(directory: string): void {
25+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
26+
const full = path.join(directory, entry.name);
27+
if (entry.isDirectory()) {
28+
// Skip test dirs, node_modules, dist
29+
if (SKIP_DIRS.has(entry.name)) {
30+
continue;
31+
}
32+
walk(full);
33+
} else if (
34+
entry.name.endsWith('.ts') &&
35+
!entry.name.endsWith('.test.ts') &&
36+
!entry.name.endsWith('.test-d.ts') &&
37+
!entry.name.endsWith('.spec.ts') &&
38+
!entry.name.endsWith('.d.ts')
39+
) {
40+
results.push(full);
41+
}
42+
}
43+
}
44+
45+
walk(dir);
46+
return results;
47+
}
48+
49+
/**
50+
* Recursively find all `.d.cts` declaration files in a directory.
51+
* Skips nested `node_modules` subdirectories.
52+
*
53+
* @param dir - The directory to search.
54+
* @returns An array of absolute file paths.
55+
*/
56+
export function findDtsFiles(dir: string): string[] {
57+
const results: string[] = [];
58+
59+
function walk(directory: string): void {
60+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
61+
const full = path.join(directory, entry.name);
62+
if (entry.isDirectory()) {
63+
if (entry.name === 'node_modules') {
64+
continue;
65+
}
66+
walk(full);
67+
} else if (entry.name.endsWith('.d.cts')) {
68+
results.push(full);
69+
}
70+
}
71+
}
72+
73+
walk(dir);
74+
return results;
75+
}

0 commit comments

Comments
 (0)