@mui/internal-docs-infra 0.10.1-canary.0 → 0.10.1-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/loadNextConfig.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ export type ExtractedNextConfigOptions = {
|
|
|
4
4
|
ordering?: OrderingConfig;
|
|
5
5
|
descriptionReplacements?: DescriptionReplacement[];
|
|
6
6
|
useVisibleDescription?: boolean;
|
|
7
|
+
socketDir?: string;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Dynamically imports the next config from the given directory and extracts
|
package/cli/loadNextConfig.mjs
CHANGED
|
@@ -29,7 +29,8 @@ function extractUseVisibleDescriptionFromRemarkPlugins(remarkPlugins) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Extracts
|
|
32
|
+
* Extracts docs-infra options (ordering, descriptionReplacements, socketDir,
|
|
33
|
+
* useVisibleDescription) from loader options in a single pass.
|
|
33
34
|
*/
|
|
34
35
|
function extractOptionsFromLoaderEntries(loaders) {
|
|
35
36
|
const result = {};
|
|
@@ -43,6 +44,9 @@ function extractOptionsFromLoaderEntries(loaders) {
|
|
|
43
44
|
if (!result.descriptionReplacements && loader.loader === TYPES_LOADER && loader.options?.descriptionReplacements) {
|
|
44
45
|
result.descriptionReplacements = loader.options.descriptionReplacements;
|
|
45
46
|
}
|
|
47
|
+
if (!result.socketDir && loader.loader === TYPES_LOADER && typeof loader.options?.socketDir === 'string') {
|
|
48
|
+
result.socketDir = loader.options.socketDir;
|
|
49
|
+
}
|
|
46
50
|
if (result.useVisibleDescription === undefined && loader.options?.remarkPlugins) {
|
|
47
51
|
const extracted = extractUseVisibleDescriptionFromRemarkPlugins(loader.options.remarkPlugins);
|
|
48
52
|
if (typeof extracted === 'boolean') {
|
|
@@ -54,7 +58,8 @@ function extractOptionsFromLoaderEntries(loaders) {
|
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
/**
|
|
57
|
-
* Searches turbopack rules for docs-infra options (ordering
|
|
61
|
+
* Searches turbopack rules for docs-infra options (ordering,
|
|
62
|
+
* descriptionReplacements, socketDir, useVisibleDescription).
|
|
58
63
|
*/
|
|
59
64
|
function extractOptionsFromTurbopack(config) {
|
|
60
65
|
const rules = config?.turbopack?.rules;
|
|
@@ -71,13 +76,15 @@ function extractOptionsFromTurbopack(config) {
|
|
|
71
76
|
merged.ordering ??= extracted.ordering;
|
|
72
77
|
merged.descriptionReplacements ??= extracted.descriptionReplacements;
|
|
73
78
|
merged.useVisibleDescription ??= extracted.useVisibleDescription;
|
|
79
|
+
merged.socketDir ??= extracted.socketDir;
|
|
74
80
|
}
|
|
75
81
|
return merged;
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
/**
|
|
79
85
|
* Calls the webpack function with a minimal config and extracts docs-infra
|
|
80
|
-
* options (ordering
|
|
86
|
+
* options (ordering, descriptionReplacements, socketDir, useVisibleDescription)
|
|
87
|
+
* from the resulting rules.
|
|
81
88
|
*/
|
|
82
89
|
function extractOptionsFromWebpack(config) {
|
|
83
90
|
if (typeof config?.webpack !== 'function') {
|
|
@@ -105,6 +112,7 @@ function extractOptionsFromWebpack(config) {
|
|
|
105
112
|
merged.ordering ??= extracted.ordering;
|
|
106
113
|
merged.descriptionReplacements ??= extracted.descriptionReplacements;
|
|
107
114
|
merged.useVisibleDescription ??= extracted.useVisibleDescription;
|
|
115
|
+
merged.socketDir ??= extracted.socketDir;
|
|
108
116
|
}
|
|
109
117
|
return merged;
|
|
110
118
|
} catch {
|
|
@@ -131,7 +139,8 @@ export async function extractDocsInfraOptionsFromNextConfig(dir) {
|
|
|
131
139
|
return {
|
|
132
140
|
ordering: turbopack.ordering ?? webpack.ordering,
|
|
133
141
|
descriptionReplacements: turbopack.descriptionReplacements ?? webpack.descriptionReplacements,
|
|
134
|
-
useVisibleDescription: turbopack.useVisibleDescription ?? webpack.useVisibleDescription
|
|
142
|
+
useVisibleDescription: turbopack.useVisibleDescription ?? webpack.useVisibleDescription,
|
|
143
|
+
socketDir: turbopack.socketDir ?? webpack.socketDir
|
|
135
144
|
};
|
|
136
145
|
} catch {
|
|
137
146
|
// Config not importable — use defaults
|
package/cli/runValidate.mjs
CHANGED
|
@@ -85,8 +85,10 @@ const runValidate = {
|
|
|
85
85
|
const {
|
|
86
86
|
ordering,
|
|
87
87
|
descriptionReplacements,
|
|
88
|
-
useVisibleDescription = false
|
|
88
|
+
useVisibleDescription = false,
|
|
89
|
+
socketDir: configSocketDir
|
|
89
90
|
} = await extractDocsInfraOptionsFromNextConfig(cwd);
|
|
91
|
+
const socketDir = configSocketDir ? path.resolve(cwd, configSocketDir) : undefined;
|
|
90
92
|
|
|
91
93
|
// If neither flag is set, run both. If one is set, run only that one.
|
|
92
94
|
const runIndexes = !typesOnly || indexesOnly;
|
|
@@ -282,7 +284,8 @@ const runValidate = {
|
|
|
282
284
|
markerDir: typesMarkerDir
|
|
283
285
|
},
|
|
284
286
|
ordering,
|
|
285
|
-
descriptionReplacements
|
|
287
|
+
descriptionReplacements,
|
|
288
|
+
socketDir
|
|
286
289
|
}
|
|
287
290
|
});
|
|
288
291
|
}));
|
package/cli/validateWorker.mjs
CHANGED
|
@@ -73,7 +73,8 @@ if (parentPort) {
|
|
|
73
73
|
watchSourceDirectly: Boolean(typesMetaCall.structuredOptions?.watchSourceDirectly),
|
|
74
74
|
updateParentIndex: excludeFromIndex ? undefined : task.syncTypesOptions.updateParentIndex,
|
|
75
75
|
ordering: task.syncTypesOptions.ordering,
|
|
76
|
-
descriptionReplacements: task.syncTypesOptions.descriptionReplacements
|
|
76
|
+
descriptionReplacements: task.syncTypesOptions.descriptionReplacements,
|
|
77
|
+
socketDir: task.syncTypesOptions.socketDir
|
|
77
78
|
});
|
|
78
79
|
parentPort.postMessage({
|
|
79
80
|
type: 'types',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.10.1-canary.
|
|
3
|
+
"version": "0.10.1-canary.2",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -643,5 +643,5 @@
|
|
|
643
643
|
"bin": {
|
|
644
644
|
"docs-infra": "./cli/index.mjs"
|
|
645
645
|
},
|
|
646
|
-
"gitSha": "
|
|
646
|
+
"gitSha": "7c06e2fc2908c14730ae31975a4e6fa27955fdcf"
|
|
647
647
|
}
|
|
@@ -25,7 +25,9 @@ export declare function getLockPath(socketDir?: string): string;
|
|
|
25
25
|
export declare function ensureSocketDir(socketDir?: string): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Wait for the IPC endpoint to become available.
|
|
28
|
-
* On Unix:
|
|
28
|
+
* On Unix: Polls the filesystem for the socket file to appear. We avoid
|
|
29
|
+
* `fs.watch` here because on macOS it does not reliably fire events when a
|
|
30
|
+
* unix domain socket file is created.
|
|
29
31
|
* On Windows: Polls by attempting to connect to the named pipe.
|
|
30
32
|
* @param socketDir - Optional custom directory for socket files (Unix only)
|
|
31
33
|
* @param timeoutMs - Timeout in milliseconds (default: 5000)
|
|
@@ -9,13 +9,20 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { connect } from 'node:net';
|
|
12
|
-
import { watch } from 'node:fs';
|
|
13
12
|
import { mkdir, stat } from 'node:fs/promises';
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
14
|
import { tmpdir } from 'node:os';
|
|
15
15
|
import { join } from 'node:path';
|
|
16
16
|
import lockfile from 'proper-lockfile';
|
|
17
17
|
const isWindows = process.platform === 'win32';
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Short, stable hash of the current project directory. Used to scope shared
|
|
21
|
+
* temp directories (CI runners, system tmp) so concurrent docs-infra processes
|
|
22
|
+
* from different projects don't collide on the same socket/lock files.
|
|
23
|
+
*/
|
|
24
|
+
const projectHash = createHash('sha256').update(process.cwd()).digest('hex').slice(0, 8);
|
|
25
|
+
|
|
19
26
|
/**
|
|
20
27
|
* Get the default socket directory.
|
|
21
28
|
* On Unix: Prefers CI-specific temp directories, then falls back to system temp.
|
|
@@ -32,17 +39,18 @@ function getDefaultSocketDir() {
|
|
|
32
39
|
|
|
33
40
|
/**
|
|
34
41
|
* Get the effective socket directory for Unix sockets and lock files.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
42
|
+
* An explicit `socketDir` is always used as-is (assumed to be project-scoped,
|
|
43
|
+
* e.g. inside `.next/`). When no `socketDir` is given, shared temp directories
|
|
44
|
+
* (CI runner temp or system tmp) are namespaced with a short hash of the project
|
|
45
|
+
* directory so concurrent docs-infra processes from different projects don't
|
|
46
|
+
* collide on the same socket/lock files.
|
|
37
47
|
* @param socketDir - Optional custom directory for socket files
|
|
38
48
|
*/
|
|
39
49
|
function getEffectiveSocketDir(socketDir) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (ciTempDir) {
|
|
43
|
-
return `${ciTempDir}/mui-docs-infra`;
|
|
50
|
+
if (socketDir) {
|
|
51
|
+
return socketDir;
|
|
44
52
|
}
|
|
45
|
-
return
|
|
53
|
+
return `${getDefaultSocketDir()}/mui-docs-infra-${projectHash}`;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/**
|
|
@@ -119,57 +127,42 @@ function sleep(ms) {
|
|
|
119
127
|
|
|
120
128
|
/**
|
|
121
129
|
* Wait for the IPC endpoint to become available.
|
|
122
|
-
* On Unix:
|
|
130
|
+
* On Unix: Polls the filesystem for the socket file to appear. We avoid
|
|
131
|
+
* `fs.watch` here because on macOS it does not reliably fire events when a
|
|
132
|
+
* unix domain socket file is created.
|
|
123
133
|
* On Windows: Polls by attempting to connect to the named pipe.
|
|
124
134
|
* @param socketDir - Optional custom directory for socket files (Unix only)
|
|
125
135
|
* @param timeoutMs - Timeout in milliseconds (default: 5000)
|
|
126
136
|
*/
|
|
127
137
|
export async function waitForSocketFile(socketDir, timeoutMs = 5000) {
|
|
128
138
|
const socketPath = getSocketPath(socketDir);
|
|
139
|
+
const pollInterval = 50;
|
|
140
|
+
const startTime = Date.now();
|
|
129
141
|
if (isWindows) {
|
|
130
|
-
// On Windows, named pipes don't create files - poll by trying to connect
|
|
131
|
-
const startTime = Date.now();
|
|
132
|
-
const pollInterval = 100; // ms
|
|
133
|
-
|
|
134
142
|
while (Date.now() - startTime < timeoutMs) {
|
|
135
143
|
// eslint-disable-next-line no-await-in-loop
|
|
136
144
|
if (await tryConnectToPipe(socketPath)) {
|
|
137
145
|
return;
|
|
138
146
|
}
|
|
139
|
-
|
|
140
|
-
// Wait before next poll
|
|
141
147
|
// eslint-disable-next-line no-await-in-loop
|
|
142
148
|
await sleep(pollInterval);
|
|
143
149
|
}
|
|
144
150
|
throw new Error(`Named pipe did not become available within ${timeoutMs}ms`);
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Ensure the directory exists before watching
|
|
153
|
-
const dir = getEffectiveSocketDir(socketDir);
|
|
154
|
-
await mkdir(dir, {
|
|
153
|
+
// Ensure the directory exists so the first stat doesn't fail spuriously
|
|
154
|
+
await mkdir(getEffectiveSocketDir(socketDir), {
|
|
155
155
|
recursive: true
|
|
156
156
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
timer = setTimeout(() => {
|
|
169
|
-
watcher.close();
|
|
170
|
-
reject(new Error(`Socket file did not appear within ${timeoutMs}ms`));
|
|
171
|
-
}, timeoutMs);
|
|
172
|
-
});
|
|
157
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
158
|
+
// eslint-disable-next-line no-await-in-loop
|
|
159
|
+
if (await fileExists(socketPath)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// eslint-disable-next-line no-await-in-loop
|
|
163
|
+
await sleep(pollInterval);
|
|
164
|
+
}
|
|
165
|
+
throw new Error(`Socket file did not appear within ${timeoutMs}ms`);
|
|
173
166
|
}
|
|
174
167
|
|
|
175
168
|
// Store the release function globally so we can call it when needed
|