@mintlify/prebuild 1.0.1383 → 1.0.1385

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.
@@ -1,15 +1,10 @@
1
+ import { parsePackageJsonDependencies } from '@mintlify/common';
1
2
  import { readFile } from 'fs/promises';
2
3
  import { join } from 'path';
3
4
  export const readPackageNames = async (contentDirectoryPath) => {
4
5
  try {
5
- const manifest = JSON.parse(await readFile(join(contentDirectoryPath, 'package.json'), 'utf8'));
6
- if (typeof manifest !== 'object' || manifest === null || !('dependencies' in manifest)) {
7
- return new Set();
8
- }
9
- const { dependencies } = manifest;
10
- return typeof dependencies === 'object' && dependencies !== null
11
- ? new Set(Object.keys(dependencies))
12
- : new Set();
6
+ const content = await readFile(join(contentDirectoryPath, 'package.json'), 'utf8');
7
+ return parsePackageJsonDependencies(content).packageNames;
13
8
  }
14
9
  catch {
15
10
  return new Set();
@@ -1,4 +1,4 @@
1
- import { findPackageSnippets, resolveAllImports, hasImports, findAndRemoveImports, getDecoratedNavPageAndSlug, topologicalSort, stringifyTree, } from '@mintlify/common';
1
+ import { findPackageSnippets, resolveAllImports, resolveSnippetImports, findAndRemoveImports, getDecoratedNavPageAndSlug, stringifyTree, } from '@mintlify/common';
2
2
  import { outputFile } from 'fs-extra';
3
3
  import { join } from 'path';
4
4
  import { addWarning } from '../warnings.js';
@@ -27,27 +27,7 @@ const resolveImportsInSnippets = async (snippetsV2, packages) => {
27
27
  filename: snippet.filename,
28
28
  }));
29
29
  const snippetsWithImports = await Promise.all(snippetsWithImportsPromises);
30
- const graph = {};
31
- snippetsWithImports.forEach((snippetWithImports) => {
32
- graph[snippetWithImports.filename] = Object.keys(snippetWithImports.importMap);
33
- });
34
- const order = topologicalSort(graph).reverse();
35
- const orderedSnippetsWithImports = order
36
- .map((filename) => {
37
- return snippetsWithImports.find((snippet) => snippet.filename === filename);
38
- })
39
- .filter(Boolean);
40
- for (const snippetWithImports of orderedSnippetsWithImports) {
41
- if (hasImports(snippetWithImports)) {
42
- snippetWithImports.tree = await resolveAllImports({
43
- snippets: orderedSnippetsWithImports,
44
- fileWithImports: snippetWithImports,
45
- onWarning: addWarning,
46
- ...(packages && { packages }),
47
- });
48
- }
49
- }
50
- return snippetsWithImports;
30
+ return resolveSnippetImports(snippetsWithImports, { onWarning: addWarning, packages });
51
31
  };
52
32
  const writeSnippets = async (snippetsWithImports) => snippetsWithImports.map(async (snippetWithImports) => {
53
33
  const targetPath = join('public', snippetWithImports.filename);