@mui/internal-docs-infra 0.3.1-canary.3 → 0.3.1-canary.5
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/esm/CodeControllerContext/CodeControllerContext.js +2 -2
- package/esm/CodeExternalsContext/CodeExternalsContext.js +1 -1
- package/esm/CodeHighlighter/CodeHighlighter.js +247 -329
- package/esm/CodeHighlighter/CodeHighlighterClient.js +447 -653
- package/esm/CodeHighlighter/CodeHighlighterContext.js +2 -2
- package/esm/CodeHighlighter/CodeHighlighterFallbackContext.js +2 -2
- package/esm/CodeHighlighter/codeToFallbackProps.js +21 -37
- package/esm/CodeHighlighter/errors.js +248 -400
- package/esm/CodeHighlighter/parseControlledCode.js +12 -20
- package/esm/CodeProvider/CodeContext.js +3 -3
- package/esm/CodeProvider/CodeProvider.js +31 -40
- package/esm/abstractCreateDemo/abstractCreateDemo.js +13 -17
- package/esm/abstractCreateDemoClient/abstractCreateDemoClient.js +12 -12
- package/esm/cli/index.js +1 -1
- package/esm/cli/runValidate.js +160 -264
- package/esm/createDemoData/createDemoData.js +11 -12
- package/esm/createSitemap/createSitemap.js +2 -2
- package/esm/pipeline/getFileConventions/fileConventions.js +1 -1
- package/esm/pipeline/getFileConventions/getFileConventions.js +2 -15
- package/esm/pipeline/hastUtils/hastUtils.js +16 -17
- package/esm/pipeline/loadCodeVariant/addCodeVariantPaths.js +24 -24
- package/esm/pipeline/loadCodeVariant/applyCodeTransform.js +12 -22
- package/esm/pipeline/loadCodeVariant/calculateMainFilePath.js +30 -37
- package/esm/pipeline/loadCodeVariant/computeHastDeltas.js +107 -185
- package/esm/pipeline/loadCodeVariant/diffHast.js +18 -53
- package/esm/pipeline/loadCodeVariant/examineCodeVariant.js +24 -27
- package/esm/pipeline/loadCodeVariant/flattenCodeVariant.js +9 -10
- package/esm/pipeline/loadCodeVariant/hasAllCodeVariants.js +5 -5
- package/esm/pipeline/loadCodeVariant/loadCodeFallback.js +516 -731
- package/esm/pipeline/loadCodeVariant/loadCodeVariant.js +679 -1079
- package/esm/pipeline/loadCodeVariant/maybeCodeInitialData.js +14 -20
- package/esm/pipeline/loadCodeVariant/mergeCodeMetadata.js +53 -63
- package/esm/pipeline/loadCodeVariant/parseCode.js +40 -48
- package/esm/pipeline/loadCodeVariant/pathUtils.js +43 -64
- package/esm/pipeline/loadCodeVariant/transformSource.js +55 -125
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +160 -221
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +377 -479
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseFunctionArguments.js +171 -173
- package/esm/pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js +14 -30
- package/esm/pipeline/loadPrecomputedCodeHighlighter/replacePrecomputeValue.js +19 -21
- package/esm/pipeline/loadPrecomputedCodeHighlighter/serializeFunctionArguments.js +37 -71
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/filterRuntimeExternals.js +3 -9
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateImportStatements.js +54 -80
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/generateResolvedExternals.js +71 -98
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/injectImportsIntoSource.js +5 -5
- package/esm/pipeline/loadPrecomputedCodeHighlighterClient/loadPrecomputedCodeHighlighterClient.js +161 -211
- package/esm/pipeline/loadPrecomputedSitemap/loadPrecomputedSitemap.js +159 -207
- package/esm/pipeline/loadServerCodeMeta/loadServerCodeMeta.js +42 -64
- package/esm/pipeline/loadServerCodeMeta/resolveModulePathWithFs.js +20 -96
- package/esm/pipeline/loadServerPageIndex/loadServerPageIndex.js +66 -85
- package/esm/pipeline/loadServerSitemap/loadServerSitemap.js +71 -118
- package/esm/pipeline/loadServerSource/loadServerSource.js +121 -148
- package/esm/pipeline/loaderUtils/externalsToPackages.js +7 -7
- package/esm/pipeline/loaderUtils/extractNameAndSlugFromUrl.js +8 -12
- package/esm/pipeline/loaderUtils/fileUrlToPortablePath.js +5 -5
- package/esm/pipeline/loaderUtils/getFileNameFromUrl.js +19 -29
- package/esm/pipeline/loaderUtils/getLanguageFromExtension.js +3 -4
- package/esm/pipeline/loaderUtils/mergeExternals.js +15 -35
- package/esm/pipeline/loaderUtils/parseImportsAndComments.js +413 -433
- package/esm/pipeline/loaderUtils/processRelativeImports.js +153 -239
- package/esm/pipeline/loaderUtils/resolveModulePath.js +544 -1303
- package/esm/pipeline/loaderUtils/rewriteImports.js +73 -111
- package/esm/pipeline/parseSource/addLineGutters.js +33 -45
- package/esm/pipeline/parseSource/grammars.js +3 -3
- package/esm/pipeline/parseSource/parseSource.js +13 -31
- package/esm/pipeline/syncPageIndex/createMarkdownNodes.js +32 -55
- package/esm/pipeline/syncPageIndex/mergeMetadataMarkdown.js +107 -160
- package/esm/pipeline/syncPageIndex/metadataToMarkdown.js +846 -1033
- package/esm/pipeline/syncPageIndex/syncPageIndex.js +291 -438
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +213 -311
- package/esm/pipeline/transformMarkdownBlockquoteCallouts/transformMarkdownBlockquoteCallouts.js +10 -10
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +133 -193
- package/esm/pipeline/transformMarkdownDemoLinks/transformMarkdownDemoLinks.js +25 -27
- package/esm/pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js +572 -717
- package/esm/pipeline/transformMarkdownRelativePaths/transformMarkdownRelativePaths.js +8 -8
- package/esm/pipeline/transformTypescriptToJavascript/removeTypes.js +84 -113
- package/esm/pipeline/transformTypescriptToJavascript/transformTypescriptToJavascript.js +10 -26
- package/esm/useCode/Pre.js +58 -62
- package/esm/useCode/useCode.js +59 -61
- package/esm/useCode/useCodeUtils.js +54 -63
- package/esm/useCode/useCopyFunctionality.js +10 -9
- package/esm/useCode/useFileNavigation.js +150 -212
- package/esm/useCode/useSourceEditing.js +17 -14
- package/esm/useCode/useTransformManagement.js +23 -26
- package/esm/useCode/useUIState.js +12 -20
- package/esm/useCode/useVariantSelection.js +62 -79
- package/esm/useCopier/index.js +29 -56
- package/esm/useDemo/createCodeSandbox.js +12 -15
- package/esm/useDemo/createStackBlitz.js +14 -20
- package/esm/useDemo/exportVariant.js +200 -180
- package/esm/useDemo/exportVariantAsCra.js +22 -25
- package/esm/useDemo/useDemo.js +80 -84
- package/esm/useErrors/ErrorsContext.js +1 -1
- package/esm/useErrors/useErrors.js +3 -3
- package/esm/useLocalStorageState/useLocalStorageState.js +23 -39
- package/esm/usePreference/PreferencesProvider.js +1 -1
- package/esm/usePreference/usePreference.js +9 -11
- package/esm/useSearch/useSearch.js +290 -387
- package/esm/useUrlHashState/useUrlHashState.js +11 -14
- package/esm/withDocsInfra/withDeploymentConfig.js +26 -21
- package/esm/withDocsInfra/withDocsInfra.js +99 -101
- package/package.json +7 -4
package/esm/cli/runValidate.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
1
|
/* eslint-disable no-console */
|
|
5
2
|
import chalk from 'chalk';
|
|
6
3
|
import { readdir, readFile, rm } from 'node:fs/promises';
|
|
@@ -10,288 +7,187 @@ import remarkParse from 'remark-parse';
|
|
|
10
7
|
import remarkMdx from 'remark-mdx';
|
|
11
8
|
import { nameMark, performanceMeasure } from "../pipeline/loadPrecomputedCodeHighlighter/performanceLogger.js";
|
|
12
9
|
import { transformMarkdownMetadata } from "../pipeline/transformMarkdownMetadata/transformMarkdownMetadata.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
var functionName = 'Run Validate';
|
|
10
|
+
const completeMessage = message => `✓ ${chalk.green(message)}`;
|
|
11
|
+
const functionName = 'Run Validate';
|
|
17
12
|
|
|
18
13
|
/**
|
|
19
14
|
* Recursively find all files matching a specific name in a directory
|
|
20
15
|
*/
|
|
21
|
-
function findFiles(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
withFileTypes: true
|
|
35
|
-
});
|
|
36
|
-
case 2:
|
|
37
|
-
entries = _context5.v;
|
|
38
|
-
_context5.n = 3;
|
|
39
|
-
return Promise.all(entries.map(/*#__PURE__*/function () {
|
|
40
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(entry) {
|
|
41
|
-
var fullPath, subResults;
|
|
42
|
-
return _regenerator().w(function (_context4) {
|
|
43
|
-
while (1) switch (_context4.n) {
|
|
44
|
-
case 0:
|
|
45
|
-
fullPath = path.join(dir, entry.name);
|
|
46
|
-
if (!entry.isDirectory()) {
|
|
47
|
-
_context4.n = 2;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
_context4.n = 1;
|
|
51
|
-
return findFiles(fullPath, fileName);
|
|
52
|
-
case 1:
|
|
53
|
-
subResults = _context4.v;
|
|
54
|
-
results.push.apply(results, _toConsumableArray(subResults));
|
|
55
|
-
_context4.n = 3;
|
|
56
|
-
break;
|
|
57
|
-
case 2:
|
|
58
|
-
if (entry.isFile() && entry.name === fileName) {
|
|
59
|
-
results.push(fullPath);
|
|
60
|
-
}
|
|
61
|
-
case 3:
|
|
62
|
-
return _context4.a(2);
|
|
63
|
-
}
|
|
64
|
-
}, _callee4);
|
|
65
|
-
}));
|
|
66
|
-
return function (_x5) {
|
|
67
|
-
return _ref3.apply(this, arguments);
|
|
68
|
-
};
|
|
69
|
-
}()));
|
|
70
|
-
case 3:
|
|
71
|
-
_context5.n = 5;
|
|
72
|
-
break;
|
|
73
|
-
case 4:
|
|
74
|
-
_context5.p = 4;
|
|
75
|
-
_t3 = _context5.v;
|
|
76
|
-
if (!(_t3.code !== 'ENOENT')) {
|
|
77
|
-
_context5.n = 5;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
throw _t3;
|
|
81
|
-
case 5:
|
|
82
|
-
return _context5.a(2, results);
|
|
16
|
+
async function findFiles(dir, fileName) {
|
|
17
|
+
const results = [];
|
|
18
|
+
try {
|
|
19
|
+
const entries = await readdir(dir, {
|
|
20
|
+
withFileTypes: true
|
|
21
|
+
});
|
|
22
|
+
await Promise.all(entries.map(async entry => {
|
|
23
|
+
const fullPath = path.join(dir, entry.name);
|
|
24
|
+
if (entry.isDirectory()) {
|
|
25
|
+
const subResults = await findFiles(fullPath, fileName);
|
|
26
|
+
results.push(...subResults);
|
|
27
|
+
} else if (entry.isFile() && entry.name === fileName) {
|
|
28
|
+
results.push(fullPath);
|
|
83
29
|
}
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
30
|
+
}));
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// Skip if directory doesn't exist
|
|
33
|
+
if (error.code !== 'ENOENT') {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return results;
|
|
87
38
|
}
|
|
88
|
-
|
|
39
|
+
const runValidate = {
|
|
89
40
|
command: 'validate [paths...]',
|
|
90
41
|
describe: 'Ensures that committed files match expected output',
|
|
91
|
-
builder:
|
|
42
|
+
builder: yargs => {
|
|
92
43
|
return yargs.option('command', {
|
|
93
44
|
type: 'string',
|
|
94
45
|
description: 'Command to suggest when indexes are out of date',
|
|
95
|
-
|
|
46
|
+
default: 'pnpm docs-infra validate'
|
|
96
47
|
}).option('useVisibleDescription', {
|
|
97
48
|
type: 'boolean',
|
|
98
49
|
description: 'Use the first visible paragraph as description in extracted index instead of meta tag',
|
|
99
|
-
|
|
50
|
+
default: false
|
|
100
51
|
}).positional('paths', {
|
|
101
52
|
type: 'string',
|
|
102
53
|
array: true,
|
|
103
54
|
description: 'Optional paths to validate (e.g., docs-infra/components docs-infra/functions)',
|
|
104
|
-
|
|
55
|
+
default: []
|
|
105
56
|
});
|
|
106
57
|
},
|
|
107
|
-
handler:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
58
|
+
handler: async args => {
|
|
59
|
+
const cwd = process.cwd();
|
|
60
|
+
const {
|
|
61
|
+
paths = [],
|
|
62
|
+
command = 'pnpm docs-infra validate',
|
|
63
|
+
useVisibleDescription = false
|
|
64
|
+
} = args;
|
|
65
|
+
const ci = Boolean(process.env.CI);
|
|
66
|
+
await Promise.all([(async () => {
|
|
67
|
+
console.log(chalk.cyan('Validating committed files match expected output...'));
|
|
68
|
+
const startMark = nameMark(functionName, 'Start Validation', []);
|
|
69
|
+
let currentMark = startMark;
|
|
70
|
+
performance.mark(currentMark);
|
|
71
|
+
const markerDir = '.next/cache/docs-infra/index-updates';
|
|
72
|
+
const markerDirPath = path.join(cwd, markerDir);
|
|
73
|
+
|
|
74
|
+
// Remove the marker directory if it exists
|
|
75
|
+
try {
|
|
76
|
+
await rm(markerDirPath, {
|
|
77
|
+
recursive: true,
|
|
78
|
+
force: true
|
|
79
|
+
});
|
|
80
|
+
} catch (error) {
|
|
81
|
+
// Ignore errors if directory doesn't exist
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Find all page.mdx files in src/app/ or app/ directories
|
|
85
|
+
let searchDirs;
|
|
86
|
+
if (paths.length > 0) {
|
|
87
|
+
// If paths are provided, search in those specific paths
|
|
88
|
+
searchDirs = paths.flatMap(p => [path.join(cwd, 'src/app', p), path.join(cwd, 'app', p)]);
|
|
89
|
+
} else {
|
|
90
|
+
// Otherwise search all app directories
|
|
91
|
+
searchDirs = [path.join(cwd, 'src/app'), path.join(cwd, 'app')];
|
|
92
|
+
}
|
|
93
|
+
const pageMdxFilesPerDir = await Promise.all(searchDirs.map(dir => findFiles(dir, 'page.mdx')));
|
|
94
|
+
const pageMdxFiles = pageMdxFilesPerDir.flat();
|
|
95
|
+
console.log(chalk.yellow(`\nProcessing ${pageMdxFiles.length} page.mdx files...\n`));
|
|
96
|
+
|
|
97
|
+
// Process each file through the unified pipeline
|
|
98
|
+
// Auto-detect include paths based on which directories actually contain files
|
|
99
|
+
const hasSrcAppFiles = pageMdxFilesPerDir.slice(0, Math.ceil(searchDirs.length / 2)) // First half are src/app paths
|
|
100
|
+
.some(files => files.length > 0);
|
|
101
|
+
const hasAppFiles = pageMdxFilesPerDir.slice(Math.ceil(searchDirs.length / 2)) // Second half are app paths
|
|
102
|
+
.some(files => files.length > 0);
|
|
103
|
+
const includePatterns = [];
|
|
104
|
+
if (hasSrcAppFiles) {
|
|
105
|
+
includePatterns.push('src/app');
|
|
106
|
+
}
|
|
107
|
+
if (hasAppFiles) {
|
|
108
|
+
includePatterns.push('app');
|
|
109
|
+
}
|
|
110
|
+
// Fallback to 'app' if neither has files (shouldn't happen but be safe)
|
|
111
|
+
if (includePatterns.length === 0) {
|
|
112
|
+
includePatterns.push('app');
|
|
113
|
+
}
|
|
114
|
+
const processor = unified().use(remarkParse).use(remarkMdx).use(transformMarkdownMetadata, {
|
|
115
|
+
extractToIndex: {
|
|
116
|
+
include: includePatterns,
|
|
117
|
+
exclude: [],
|
|
118
|
+
baseDir: cwd,
|
|
119
|
+
onlyUpdateIndexes: true,
|
|
120
|
+
markerDir,
|
|
121
|
+
useVisibleDescription
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
let hasErrors = false;
|
|
125
|
+
await Promise.all(pageMdxFiles.map(async filePath => {
|
|
126
|
+
try {
|
|
127
|
+
const content = await readFile(filePath, 'utf-8');
|
|
128
|
+
const vfile = {
|
|
129
|
+
path: filePath,
|
|
130
|
+
value: content
|
|
131
|
+
};
|
|
132
|
+
// Use run() instead of process() since we don't need HTML output
|
|
133
|
+
await processor.run(processor.parse(vfile), vfile);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
hasErrors = true;
|
|
136
|
+
console.error(chalk.red(`Error processing ${filePath}:`), error);
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
158
139
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
vfile = {
|
|
204
|
-
path: filePath,
|
|
205
|
-
value: content
|
|
206
|
-
}; // Use run() instead of process() since we don't need HTML output
|
|
207
|
-
_context.n = 2;
|
|
208
|
-
return processor.run(processor.parse(vfile), vfile);
|
|
209
|
-
case 2:
|
|
210
|
-
_context.n = 4;
|
|
211
|
-
break;
|
|
212
|
-
case 3:
|
|
213
|
-
_context.p = 3;
|
|
214
|
-
_t = _context.v;
|
|
215
|
-
hasErrors = true;
|
|
216
|
-
console.error(chalk.red("Error processing ".concat(filePath, ":")), _t);
|
|
217
|
-
case 4:
|
|
218
|
-
return _context.a(2);
|
|
219
|
-
}
|
|
220
|
-
}, _callee, null, [[0, 3]]);
|
|
221
|
-
}));
|
|
222
|
-
return function (_x4) {
|
|
223
|
-
return _ref2.apply(this, arguments);
|
|
224
|
-
};
|
|
225
|
-
}()));
|
|
226
|
-
case 6:
|
|
227
|
-
_context2.n = 7;
|
|
228
|
-
return findFiles(markerDirPath, 'page.mdx');
|
|
229
|
-
case 7:
|
|
230
|
-
updatedIndexes = _context2.v;
|
|
231
|
-
if (updatedIndexes.length > 0) {
|
|
232
|
-
console.log(chalk.yellow('\nUpdated index files:'));
|
|
233
|
-
updatedIndexes.forEach(function (markerPath) {
|
|
234
|
-
// Convert marker path back to actual index path
|
|
235
|
-
var relativePath = path.relative(markerDirPath, markerPath);
|
|
236
|
-
console.log(chalk.gray(" ".concat(relativePath)));
|
|
237
|
-
});
|
|
238
|
-
console.log(chalk.yellow("\nTotal: ".concat(updatedIndexes.length, " indexes updated\n")));
|
|
239
|
-
} else {
|
|
240
|
-
console.log(chalk.green('\nNo indexes needed updating\n'));
|
|
241
|
-
}
|
|
242
|
-
generatedFiles = updatedIndexes.length;
|
|
243
|
-
currentMark = performanceMeasure(currentMark, {
|
|
244
|
-
mark: 'Validated Files',
|
|
245
|
-
measure: 'Validating Files'
|
|
246
|
-
}, [functionName], true);
|
|
247
|
-
console.log(completeMessage("".concat(generatedFiles, " index files updated in ").concat((performance.measure(nameMark(functionName, 'Validation', []), startMark, currentMark).duration / 1000).toPrecision(3), "s")));
|
|
248
|
-
if (hasErrors) {
|
|
249
|
-
console.error(chalk.red('\n✗ Validation failed with errors\n'));
|
|
250
|
-
process.exit(1);
|
|
251
|
-
}
|
|
252
|
-
if (ci && generatedFiles > 0) {
|
|
253
|
-
pathsArg = '';
|
|
254
|
-
if (paths.length > 0) {
|
|
255
|
-
// Use the paths that were provided
|
|
256
|
-
pathsArg = " ".concat(paths.join(' '));
|
|
257
|
-
} else {
|
|
258
|
-
// Derive paths from the updated indexes
|
|
259
|
-
updatedPaths = new Set();
|
|
260
|
-
updatedIndexes.forEach(function (markerPath) {
|
|
261
|
-
var relativePath = path.relative(markerDirPath, markerPath);
|
|
262
|
-
// Extract the directory path (e.g., 'app/docs-infra/components/page.mdx' -> 'docs-infra/components')
|
|
263
|
-
var dir = path.dirname(relativePath);
|
|
264
|
-
// Remove 'app/' or 'src/app/' prefix if present
|
|
265
|
-
var cleanDir = dir.replace(/^(src\/)?app\//, '');
|
|
266
|
-
if (cleanDir) {
|
|
267
|
-
updatedPaths.add(cleanDir);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
if (updatedPaths.size > 0) {
|
|
271
|
-
pathsArg = " ".concat(Array.from(updatedPaths).map(function (p) {
|
|
272
|
-
return /^[a-zA-Z0-9/_.-]+$/.test(p) ? p : "\"".concat(p, "\"");
|
|
273
|
-
}).join(' '));
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
console.error(chalk.red('\n✗ Index files are out of date. Run this command locally:\n'));
|
|
277
|
-
console.error(chalk.cyan(" ".concat(command).concat(pathsArg)));
|
|
278
|
-
console.error(chalk.red('\nThen commit the results.\n'));
|
|
279
|
-
process.exit(1);
|
|
280
|
-
}
|
|
281
|
-
case 8:
|
|
282
|
-
return _context2.a(2);
|
|
283
|
-
}
|
|
284
|
-
}, _callee2, null, [[1, 3]]);
|
|
285
|
-
}))()]);
|
|
286
|
-
case 1:
|
|
287
|
-
return _context3.a(2);
|
|
140
|
+
// Find all marker files to see which indexes were updated
|
|
141
|
+
const updatedIndexes = await findFiles(markerDirPath, 'page.mdx');
|
|
142
|
+
if (updatedIndexes.length > 0) {
|
|
143
|
+
console.log(chalk.yellow('\nUpdated index files:'));
|
|
144
|
+
updatedIndexes.forEach(markerPath => {
|
|
145
|
+
// Convert marker path back to actual index path
|
|
146
|
+
const relativePath = path.relative(markerDirPath, markerPath);
|
|
147
|
+
console.log(chalk.gray(` ${relativePath}`));
|
|
148
|
+
});
|
|
149
|
+
console.log(chalk.yellow(`\nTotal: ${updatedIndexes.length} indexes updated\n`));
|
|
150
|
+
} else {
|
|
151
|
+
console.log(chalk.green('\nNo indexes needed updating\n'));
|
|
152
|
+
}
|
|
153
|
+
const generatedFiles = updatedIndexes.length;
|
|
154
|
+
currentMark = performanceMeasure(currentMark, {
|
|
155
|
+
mark: 'Validated Files',
|
|
156
|
+
measure: 'Validating Files'
|
|
157
|
+
}, [functionName], true);
|
|
158
|
+
console.log(completeMessage(`${generatedFiles} index files updated in ${(performance.measure(nameMark(functionName, 'Validation', []), startMark, currentMark).duration / 1000).toPrecision(3)}s`));
|
|
159
|
+
if (hasErrors) {
|
|
160
|
+
console.error(chalk.red('\n✗ Validation failed with errors\n'));
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
if (ci && generatedFiles > 0) {
|
|
164
|
+
let pathsArg = '';
|
|
165
|
+
if (paths.length > 0) {
|
|
166
|
+
// Use the paths that were provided
|
|
167
|
+
pathsArg = ` ${paths.join(' ')}`;
|
|
168
|
+
} else {
|
|
169
|
+
// Derive paths from the updated indexes
|
|
170
|
+
const updatedPaths = new Set();
|
|
171
|
+
updatedIndexes.forEach(markerPath => {
|
|
172
|
+
const relativePath = path.relative(markerDirPath, markerPath);
|
|
173
|
+
// Extract the directory path (e.g., 'app/docs-infra/components/page.mdx' -> 'docs-infra/components')
|
|
174
|
+
const dir = path.dirname(relativePath);
|
|
175
|
+
// Remove 'app/' or 'src/app/' prefix if present
|
|
176
|
+
const cleanDir = dir.replace(/^(src\/)?app\//, '');
|
|
177
|
+
if (cleanDir) {
|
|
178
|
+
updatedPaths.add(cleanDir);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
if (updatedPaths.size > 0) {
|
|
182
|
+
pathsArg = ` ${Array.from(updatedPaths).map(p => /^[a-zA-Z0-9/_.-]+$/.test(p) ? p : `"${p}"`).join(' ')}`;
|
|
183
|
+
}
|
|
288
184
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
185
|
+
console.error(chalk.red('\n✗ Index files are out of date. Run this command locally:\n'));
|
|
186
|
+
console.error(chalk.cyan(` ${command}${pathsArg}`));
|
|
187
|
+
console.error(chalk.red('\nThen commit the results.\n'));
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
})()]);
|
|
191
|
+
}
|
|
296
192
|
};
|
|
297
193
|
export default runValidate;
|
|
@@ -9,26 +9,25 @@ import { extractNameAndSlugFromUrl } from "../pipeline/loaderUtils/index.js";
|
|
|
9
9
|
* @param meta Additional meta for the demo.
|
|
10
10
|
*/
|
|
11
11
|
export function createDemoDataWithVariants(url, variants, meta) {
|
|
12
|
-
var _meta$name, _meta$slug;
|
|
13
12
|
if (!url.startsWith('file:')) {
|
|
14
13
|
throw new Error('createDemoData() requires the `url` argument to be a file URL. Use `import.meta.url` to get the current file URL.');
|
|
15
14
|
}
|
|
16
15
|
if (!meta || !meta.precompute && !meta.skipPrecompute) {
|
|
17
|
-
throw new Error(
|
|
16
|
+
throw new Error(`createDemoData() was unable to precompute the code in ${url}. Ensure the createDemoData() function is called within a path used for demo indexes. This is typically app/**/demos/*/index.ts but may be overridden in next.config.js`);
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
const precompute = meta.precompute;
|
|
20
19
|
|
|
21
20
|
// Generate name and slug from URL if not provided in meta
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const generatedMeta = extractNameAndSlugFromUrl(url);
|
|
22
|
+
const name = meta.name ?? generatedMeta.name;
|
|
23
|
+
const slug = meta.slug ?? generatedMeta.slug;
|
|
24
|
+
const displayName = meta?.displayName || `${name.replace(/ /g, '')}Demo`;
|
|
26
25
|
return {
|
|
27
|
-
name
|
|
28
|
-
slug
|
|
29
|
-
displayName
|
|
30
|
-
precompute
|
|
31
|
-
url
|
|
26
|
+
name,
|
|
27
|
+
slug,
|
|
28
|
+
displayName,
|
|
29
|
+
precompute,
|
|
30
|
+
url,
|
|
32
31
|
components: variants
|
|
33
32
|
};
|
|
34
33
|
}
|
|
@@ -29,14 +29,14 @@ export function createSitemap(sourceUrl, pages, meta) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// If precompute data exists or skipPrecompute is set, use the precomputed data
|
|
32
|
-
if (meta
|
|
32
|
+
if (meta?.precompute || meta?.skipPrecompute) {
|
|
33
33
|
return meta.precompute;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// In Next.js context, precomputation should have happened via webpack loader
|
|
37
37
|
// If it didn't, throw an error to help developers fix their configuration
|
|
38
38
|
if (isNextJsContext()) {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error(`createSitemap() was unable to precompute the sitemap data in ${sourceUrl}. Ensure the createSitemap() function is called within a path used for sitemap indexes. This is typically app/sitemap/index.ts but may be overridden in next.config.js`);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Outside Next.js, return undefined (sync function can't do async loading)
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
1
|
import { fileConventions } from "./fileConventions.js";
|
|
4
|
-
export function getFileConventions() {
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
function _getFileConventions() {
|
|
8
|
-
_getFileConventions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
9
|
-
return _regenerator().w(function (_context) {
|
|
10
|
-
while (1) switch (_context.n) {
|
|
11
|
-
case 0:
|
|
12
|
-
return _context.a(2, fileConventions);
|
|
13
|
-
}
|
|
14
|
-
}, _callee);
|
|
15
|
-
}));
|
|
16
|
-
return _getFileConventions.apply(this, arguments);
|
|
2
|
+
export async function getFileConventions() {
|
|
3
|
+
return fileConventions; // TODO: Parse the next.config.js file to get convention overrides.
|
|
17
4
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
1
|
import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
|
|
3
2
|
import { toText } from 'hast-util-to-text';
|
|
4
3
|
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
|
|
@@ -6,50 +5,50 @@ import { decompressSync, strFromU8 } from 'fflate';
|
|
|
6
5
|
import { decode } from 'uint8-to-base64';
|
|
7
6
|
export function hastToJsx(hast) {
|
|
8
7
|
return toJsxRuntime(hast, {
|
|
9
|
-
Fragment
|
|
10
|
-
jsx
|
|
11
|
-
jsxs
|
|
8
|
+
Fragment,
|
|
9
|
+
jsx,
|
|
10
|
+
jsxs
|
|
12
11
|
});
|
|
13
12
|
}
|
|
14
13
|
export function hastOrJsonToJsx(hastOrJson) {
|
|
15
|
-
|
|
14
|
+
let hast;
|
|
16
15
|
if ('hastJson' in hastOrJson) {
|
|
17
16
|
try {
|
|
18
17
|
hast = JSON.parse(hastOrJson.hastJson);
|
|
19
18
|
} catch (error) {
|
|
20
|
-
throw new Error(
|
|
19
|
+
throw new Error(`Failed to parse hastJson: ${JSON.stringify(error)}`);
|
|
21
20
|
}
|
|
22
21
|
} else if ('hastGzip' in hastOrJson) {
|
|
23
22
|
try {
|
|
24
23
|
hast = JSON.parse(strFromU8(decompressSync(decode(hastOrJson.hastGzip))));
|
|
25
24
|
} catch (error) {
|
|
26
|
-
throw new Error(
|
|
25
|
+
throw new Error(`Failed to parse hastGzip: ${JSON.stringify(error)}`);
|
|
27
26
|
}
|
|
28
27
|
} else {
|
|
29
28
|
hast = hastOrJson;
|
|
30
29
|
}
|
|
31
30
|
return toJsxRuntime(hast, {
|
|
32
|
-
Fragment
|
|
33
|
-
jsx
|
|
34
|
-
jsxs
|
|
31
|
+
Fragment,
|
|
32
|
+
jsx,
|
|
33
|
+
jsxs
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
export function stringOrHastToString(source) {
|
|
38
37
|
if (typeof source === 'string') {
|
|
39
38
|
return source;
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
let hast;
|
|
42
41
|
if ('hastJson' in source) {
|
|
43
42
|
try {
|
|
44
43
|
hast = JSON.parse(source.hastJson);
|
|
45
44
|
} catch (error) {
|
|
46
|
-
throw new Error(
|
|
45
|
+
throw new Error(`Failed to parse hastJson: ${JSON.stringify(error)}`);
|
|
47
46
|
}
|
|
48
47
|
} else if ('hastGzip' in source) {
|
|
49
48
|
try {
|
|
50
49
|
hast = JSON.parse(strFromU8(decompressSync(decode(source.hastGzip))));
|
|
51
50
|
} catch (error) {
|
|
52
|
-
throw new Error(
|
|
51
|
+
throw new Error(`Failed to parse hastGzip: ${JSON.stringify(error)}`);
|
|
53
52
|
}
|
|
54
53
|
} else {
|
|
55
54
|
hast = source;
|
|
@@ -62,23 +61,23 @@ export function stringOrHastToJsx(source, highlighted) {
|
|
|
62
61
|
if (typeof source === 'string') {
|
|
63
62
|
return source;
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
let hast;
|
|
66
65
|
if ('hastJson' in source) {
|
|
67
66
|
try {
|
|
68
67
|
hast = JSON.parse(source.hastJson);
|
|
69
68
|
} catch (error) {
|
|
70
|
-
throw new Error(
|
|
69
|
+
throw new Error(`Failed to parse hastJson: ${JSON.stringify(error)}`);
|
|
71
70
|
}
|
|
72
71
|
} else if ('hastGzip' in source) {
|
|
73
72
|
try {
|
|
74
73
|
hast = JSON.parse(strFromU8(decompressSync(decode(source.hastGzip))));
|
|
75
74
|
} catch (error) {
|
|
76
|
-
throw new Error(
|
|
75
|
+
throw new Error(`Failed to parse hastGzip: ${JSON.stringify(error)}`);
|
|
77
76
|
}
|
|
78
77
|
} else {
|
|
79
78
|
hast = source;
|
|
80
79
|
}
|
|
81
|
-
if (highlighted &&
|
|
80
|
+
if (highlighted && typeof hast === 'object') {
|
|
82
81
|
return hastToJsx(hast);
|
|
83
82
|
}
|
|
84
83
|
return toText(hast, {
|