@fumadocs/cli 1.0.1 → 1.0.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.
@@ -117,8 +117,9 @@ interface Registry {
117
117
  onResolve?: OnResolve;
118
118
  /**
119
119
  * When a referenced file is not found in component files, this function is called.
120
+ * @returns file, or `false` to mark as external.
120
121
  */
121
- onUnknownFile?: (absolutePath: string) => ComponentFile | undefined;
122
+ onUnknownFile?: (absolutePath: string) => ComponentFile | false | undefined;
122
123
  dependencies?: Record<string, string | null>;
123
124
  devDependencies?: Record<string, string | null>;
124
125
  }
@@ -119,7 +119,9 @@ async function buildFile(file, builder, comp, writeReference) {
119
119
  } else if (specifier.startsWith("./") || specifier.startsWith("../")) {
120
120
  filePath = path.join(path.dirname(sourceFilePath), specifier);
121
121
  } else {
122
- throw new Error("Unknown specifier " + specifier);
122
+ if (!specifier.startsWith("node:"))
123
+ console.warn(`Unknown specifier ${specifier}, skipping for now`);
124
+ return;
123
125
  }
124
126
  if (path.relative(builder.registryDir, filePath).startsWith("../")) {
125
127
  return {
@@ -144,27 +146,25 @@ async function buildFile(file, builder, comp, writeReference) {
144
146
  file: filePath
145
147
  };
146
148
  };
147
- function process2(specifier, getSpecifiedFile) {
149
+ function process2(specifier, specifiedFile) {
148
150
  const onResolve = comp.onResolve ?? builder.registry.onResolve;
149
151
  let resolved = defaultResolve(
150
152
  specifier.getLiteralValue(),
151
- getSpecifiedFile()
153
+ specifiedFile
152
154
  );
155
+ if (!resolved) return;
153
156
  if (onResolve) resolved = onResolve(resolved);
154
157
  const out = writeReference(resolved);
155
158
  if (out) specifier.setLiteralValue(out);
156
159
  }
157
160
  const sourceFile = await builder.createSourceFile(sourceFilePath);
158
161
  for (const item of sourceFile.getImportDeclarations()) {
159
- process2(
160
- item.getModuleSpecifier(),
161
- () => item.getModuleSpecifierSourceFile()
162
- );
162
+ process2(item.getModuleSpecifier(), item.getModuleSpecifierSourceFile());
163
163
  }
164
164
  for (const item of sourceFile.getExportDeclarations()) {
165
165
  const specifier = item.getModuleSpecifier();
166
166
  if (!specifier) continue;
167
- process2(specifier, () => item.getModuleSpecifierSourceFile());
167
+ process2(specifier, item.getModuleSpecifierSourceFile());
168
168
  }
169
169
  const calls = sourceFile.getDescendantsOfKind(ts.SyntaxKind.CallExpression);
170
170
  for (const expression of calls) {
@@ -173,7 +173,7 @@ async function buildFile(file, builder, comp, writeReference) {
173
173
  if (!argument.isKind(ts.SyntaxKind.StringLiteral)) continue;
174
174
  process2(
175
175
  argument,
176
- () => argument.getSymbol()?.getDeclarations()[0].getSourceFile()
176
+ argument.getSymbol()?.getDeclarations()[0].getSourceFile()
177
177
  );
178
178
  }
179
179
  }
@@ -304,6 +304,7 @@ async function buildComponent(component, builder) {
304
304
  queue.push(refFile);
305
305
  return toImportPath(refFile);
306
306
  }
307
+ if (refFile === false) return;
307
308
  throw new Error(
308
309
  `Unknown file ${reference.file} referenced by ${file.path}`
309
310
  );
package/dist/index.js CHANGED
@@ -343,14 +343,14 @@ async function runTree(args) {
343
343
  // package.json
344
344
  var package_default = {
345
345
  name: "@fumadocs/cli",
346
- version: "1.0.1",
346
+ version: "1.0.2",
347
347
  description: "The CLI tool for Fumadocs",
348
348
  keywords: [
349
349
  "NextJs",
350
350
  "Docs",
351
351
  "Fumadocs"
352
352
  ],
353
- homepage: "https://fumadocs.vercel.app",
353
+ homepage: "https://fumadocs.dev",
354
354
  repository: "github:fuma-nama/fumadocs",
355
355
  license: "MIT",
356
356
  author: "Fuma Nama",
@@ -377,17 +377,17 @@ var package_default = {
377
377
  },
378
378
  dependencies: {
379
379
  "@clack/prompts": "^0.11.0",
380
- commander: "^14.0.0",
380
+ commander: "^14.0.1",
381
381
  "package-manager-detector": "^1.3.0",
382
382
  picocolors: "^1.1.1",
383
383
  tinyexec: "^1.0.1",
384
- "ts-morph": "^26.0.0",
385
- zod: "^4.1.4"
384
+ "ts-morph": "^27.0.0",
385
+ zod: "^4.1.11"
386
386
  },
387
387
  devDependencies: {
388
- "@types/node": "24.3.0",
388
+ "@types/node": "24.6.2",
389
389
  "eslint-config-custom": "workspace:*",
390
- shadcn: "3.0.0",
390
+ shadcn: "3.3.1",
391
391
  tsconfig: "workspace:*"
392
392
  },
393
393
  publishConfig: {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@fumadocs/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "The CLI tool for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
7
7
  "Docs",
8
8
  "Fumadocs"
9
9
  ],
10
- "homepage": "https://fumadocs.vercel.app",
10
+ "homepage": "https://fumadocs.dev",
11
11
  "repository": "github:fuma-nama/fumadocs",
12
12
  "license": "MIT",
13
13
  "author": "Fuma Nama",
@@ -27,16 +27,16 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@clack/prompts": "^0.11.0",
30
- "commander": "^14.0.0",
30
+ "commander": "^14.0.1",
31
31
  "package-manager-detector": "^1.3.0",
32
32
  "picocolors": "^1.1.1",
33
33
  "tinyexec": "^1.0.1",
34
- "ts-morph": "^26.0.0",
35
- "zod": "^4.1.4"
34
+ "ts-morph": "^27.0.0",
35
+ "zod": "^4.1.11"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/node": "24.3.0",
39
- "shadcn": "3.0.0",
38
+ "@types/node": "24.6.2",
39
+ "shadcn": "3.3.1",
40
40
  "eslint-config-custom": "0.0.0",
41
41
  "tsconfig": "0.0.0"
42
42
  },