@farming-labs/docs 0.2.42 → 0.2.44
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/dist/cli/index.mjs
CHANGED
|
@@ -105,36 +105,36 @@ async function main() {
|
|
|
105
105
|
]
|
|
106
106
|
};
|
|
107
107
|
if (!parsedCommand.command || parsedCommand.command === "init") {
|
|
108
|
-
const { init } = await import("../init-
|
|
108
|
+
const { init } = await import("../init-Drt3Q3Y7.mjs");
|
|
109
109
|
await init(initOptions);
|
|
110
110
|
} else if (parsedCommand.command === "dev") {
|
|
111
111
|
const { dev } = await import("../dev-CBha7knT.mjs");
|
|
112
112
|
await dev(devOptions);
|
|
113
113
|
} else if (parsedCommand.command === "deploy") {
|
|
114
|
-
const { runCloudDeploy } = await import("../cloud-
|
|
114
|
+
const { runCloudDeploy } = await import("../cloud-C_Ok9rC5.mjs");
|
|
115
115
|
await runCloudDeploy(cloudOptions);
|
|
116
116
|
} else if (parsedCommand.command === "preview") {
|
|
117
|
-
const { runCloudPreview } = await import("../cloud-
|
|
117
|
+
const { runCloudPreview } = await import("../cloud-C_Ok9rC5.mjs");
|
|
118
118
|
await runCloudPreview(cloudOptions);
|
|
119
119
|
} else if (parsedCommand.command === "cloud" && subcommand === "deploy") {
|
|
120
|
-
const { runCloudDeploy } = await import("../cloud-
|
|
120
|
+
const { runCloudDeploy } = await import("../cloud-C_Ok9rC5.mjs");
|
|
121
121
|
await runCloudDeploy(cloudOptions);
|
|
122
122
|
} else if (parsedCommand.command === "cloud" && subcommand === "preview") {
|
|
123
|
-
const { runCloudPreview } = await import("../cloud-
|
|
123
|
+
const { runCloudPreview } = await import("../cloud-C_Ok9rC5.mjs");
|
|
124
124
|
await runCloudPreview(cloudOptions);
|
|
125
125
|
} else if (parsedCommand.command === "cloud" && subcommand === "init") {
|
|
126
|
-
const { runCloudInit } = await import("../cloud-
|
|
126
|
+
const { runCloudInit } = await import("../cloud-C_Ok9rC5.mjs");
|
|
127
127
|
await runCloudInit(cloudOptions);
|
|
128
128
|
} else if (parsedCommand.command === "cloud" && subcommand === "sync") {
|
|
129
|
-
const { syncCloudConfig } = await import("../cloud-
|
|
129
|
+
const { syncCloudConfig } = await import("../cloud-C_Ok9rC5.mjs");
|
|
130
130
|
await syncCloudConfig(cloudOptions);
|
|
131
131
|
} else if (parsedCommand.command === "cloud" && subcommand === "check") {
|
|
132
|
-
const { runCloudCheck } = await import("../cloud-
|
|
132
|
+
const { runCloudCheck } = await import("../cloud-C_Ok9rC5.mjs");
|
|
133
133
|
await runCloudCheck(cloudOptions);
|
|
134
134
|
} else if (parsedCommand.command === "cloud") {
|
|
135
135
|
console.error(pc.red(`Unknown cloud subcommand: ${subcommand ?? "(missing)"}`));
|
|
136
136
|
console.error();
|
|
137
|
-
const { printCloudHelp } = await import("../cloud-
|
|
137
|
+
const { printCloudHelp } = await import("../cloud-C_Ok9rC5.mjs");
|
|
138
138
|
printCloudHelp();
|
|
139
139
|
process.exit(1);
|
|
140
140
|
} else if (parsedCommand.command === "mcp") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as markCliErrorReported } from "./errors-CW1LnxaQ.mjs";
|
|
2
2
|
import { a as loadProjectEnv, c as readNavTitle, d as readTopLevelBooleanProperty, f as readTopLevelStringProperty, i as loadDocsConfigModule, m as resolveDocsContentDir, p as resolveDocsConfigPath, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-tiQCZ46q.mjs";
|
|
3
|
-
import { t as detectFramework } from "./utils-D-xTRNuh.mjs";
|
|
3
|
+
import { i as detectPackageManagerFromProject, t as detectFramework } from "./utils-D-xTRNuh.mjs";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import pc from "picocolors";
|
|
@@ -31,6 +31,7 @@ const CLOUD_CHECK_TARGETS = [
|
|
|
31
31
|
"analytics",
|
|
32
32
|
"ask-ai"
|
|
33
33
|
];
|
|
34
|
+
const FUMADOCS_CONNECT_MARKER = "@farming-labs/docs cloud connect: fumadocs";
|
|
34
35
|
function isRecord(value) {
|
|
35
36
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
36
37
|
}
|
|
@@ -51,6 +52,100 @@ function readPackageName(rootDir) {
|
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
55
|
+
function readPackageJsonRecord(rootDir) {
|
|
56
|
+
const packagePath = path.join(rootDir, "package.json");
|
|
57
|
+
if (!fs.existsSync(packagePath)) return void 0;
|
|
58
|
+
try {
|
|
59
|
+
const parsed = JSON.parse(fs.readFileSync(packagePath, "utf-8"));
|
|
60
|
+
return isRecord(parsed) ? parsed : void 0;
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function readPackageDependencies(rootDir) {
|
|
66
|
+
const packageJson = readPackageJsonRecord(rootDir);
|
|
67
|
+
const names = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const key of [
|
|
69
|
+
"dependencies",
|
|
70
|
+
"devDependencies",
|
|
71
|
+
"peerDependencies",
|
|
72
|
+
"optionalDependencies"
|
|
73
|
+
]) {
|
|
74
|
+
const dependencies = packageJson?.[key];
|
|
75
|
+
if (!isRecord(dependencies)) continue;
|
|
76
|
+
for (const name of Object.keys(dependencies)) names.add(name);
|
|
77
|
+
}
|
|
78
|
+
return names;
|
|
79
|
+
}
|
|
80
|
+
function hasFumadocsDependency(dependencies) {
|
|
81
|
+
return [...dependencies].some((name) => name === "fumadocs-core" || name === "fumadocs-ui" || name === "fumadocs-mdx" || name === "fumadocs-openapi" || name === "fumadocs-docgen");
|
|
82
|
+
}
|
|
83
|
+
function firstExistingFile(rootDir, candidates) {
|
|
84
|
+
return candidates.find((candidate) => fs.existsSync(path.join(rootDir, candidate)));
|
|
85
|
+
}
|
|
86
|
+
function hasMarkdownDescendant(rootDir, relativeDir) {
|
|
87
|
+
const absoluteDir = path.join(rootDir, relativeDir);
|
|
88
|
+
if (!fs.existsSync(absoluteDir)) return false;
|
|
89
|
+
const queue = [absoluteDir];
|
|
90
|
+
while (queue.length > 0) {
|
|
91
|
+
const current = queue.shift();
|
|
92
|
+
let entries;
|
|
93
|
+
try {
|
|
94
|
+
entries = fs.readdirSync(current, { withFileTypes: true });
|
|
95
|
+
} catch {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
const fullPath = path.join(current, entry.name);
|
|
100
|
+
if (entry.isDirectory()) {
|
|
101
|
+
queue.push(fullPath);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (entry.isFile() && /\.(?:md|mdx)$/i.test(entry.name)) return true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
function detectFumadocsContentRoots(rootDir) {
|
|
110
|
+
const roots = [
|
|
111
|
+
"content/docs",
|
|
112
|
+
"src/content/docs",
|
|
113
|
+
"docs",
|
|
114
|
+
"content"
|
|
115
|
+
].filter((candidate) => hasMarkdownDescendant(rootDir, candidate));
|
|
116
|
+
return roots.filter((root) => !roots.some((other) => other !== root && other.startsWith(`${root}/`)));
|
|
117
|
+
}
|
|
118
|
+
function detectConnectedFumadocsProfile(rootDir) {
|
|
119
|
+
const dependencies = readPackageDependencies(rootDir);
|
|
120
|
+
const sourceConfig = firstExistingFile(rootDir, [
|
|
121
|
+
"source.config.ts",
|
|
122
|
+
"source.config.tsx",
|
|
123
|
+
"source.config.js",
|
|
124
|
+
"source.config.mjs",
|
|
125
|
+
"source.config.cjs"
|
|
126
|
+
]);
|
|
127
|
+
const sourceFile = firstExistingFile(rootDir, [
|
|
128
|
+
"lib/source.ts",
|
|
129
|
+
"lib/source.tsx",
|
|
130
|
+
"src/lib/source.ts",
|
|
131
|
+
"src/lib/source.tsx"
|
|
132
|
+
]);
|
|
133
|
+
const contentRoots = detectFumadocsContentRoots(rootDir);
|
|
134
|
+
if (!(hasFumadocsDependency(dependencies) || Boolean(sourceConfig) || Boolean(sourceFile)) || contentRoots.length === 0) return;
|
|
135
|
+
const framework = detectFramework(rootDir) ?? "nextjs";
|
|
136
|
+
const configFiles = [sourceConfig, sourceFile].filter((file) => Boolean(file));
|
|
137
|
+
const packageManager = detectPackageManagerFromProject(rootDir)?.packageManager;
|
|
138
|
+
return {
|
|
139
|
+
engine: "fumadocs",
|
|
140
|
+
runtime: framework,
|
|
141
|
+
appRoot: ".",
|
|
142
|
+
contentRoots,
|
|
143
|
+
configFiles,
|
|
144
|
+
...packageManager ? { packageManager } : {},
|
|
145
|
+
confidence: sourceConfig || sourceFile ? "high" : "medium",
|
|
146
|
+
reason: sourceConfig ? `Detected Fumadocs source config at ${sourceConfig}.` : "Detected Fumadocs dependencies and markdown content."
|
|
147
|
+
};
|
|
148
|
+
}
|
|
54
149
|
function runGit(rootDir, args) {
|
|
55
150
|
try {
|
|
56
151
|
return execFileSync("git", [
|
|
@@ -363,6 +458,19 @@ ${renderCloudConfigProperty(" ", apiKeyEnv)}
|
|
|
363
458
|
});
|
|
364
459
|
`;
|
|
365
460
|
}
|
|
461
|
+
function renderFumadocsConnectDocsConfig(apiKeyEnv, profile) {
|
|
462
|
+
const contentDir = profile.contentRoots[0] ?? "content/docs";
|
|
463
|
+
return `// ${FUMADOCS_CONNECT_MARKER}
|
|
464
|
+
import { defineDocs } from "@farming-labs/docs";
|
|
465
|
+
|
|
466
|
+
export default defineDocs({
|
|
467
|
+
entry: "docs",
|
|
468
|
+
contentDir: ${JSON.stringify(contentDir)},
|
|
469
|
+
${renderAnalyticsConfigProperty(" ")}
|
|
470
|
+
${renderCloudConfigProperty(" ", apiKeyEnv)}
|
|
471
|
+
});
|
|
472
|
+
`;
|
|
473
|
+
}
|
|
366
474
|
function normalizeEnvName(value, fallback) {
|
|
367
475
|
const normalized = value?.trim();
|
|
368
476
|
if (!normalized) return fallback;
|
|
@@ -373,7 +481,7 @@ function ensureDocsConfigCloudInit(options) {
|
|
|
373
481
|
const resolvedConfigPath = tryResolveDocsConfigPath(options.rootDir, options.configPath);
|
|
374
482
|
const configPath = resolvedConfigPath ?? path.join(options.rootDir, "docs.config.ts");
|
|
375
483
|
if (!resolvedConfigPath) {
|
|
376
|
-
fs.writeFileSync(configPath, renderCloudInitDocsConfig(options.apiKeyEnv), "utf-8");
|
|
484
|
+
fs.writeFileSync(configPath, options.docsInfraProfile ? renderFumadocsConnectDocsConfig(options.apiKeyEnv, options.docsInfraProfile) : renderCloudInitDocsConfig(options.apiKeyEnv), "utf-8");
|
|
377
485
|
return {
|
|
378
486
|
configPath,
|
|
379
487
|
created: true,
|
|
@@ -525,6 +633,13 @@ function resolveApiReferenceRoot(snapshot) {
|
|
|
525
633
|
if (!apiReferenceBlock) return void 0;
|
|
526
634
|
return readStringProperty(apiReferenceBlock, "path");
|
|
527
635
|
}
|
|
636
|
+
function resolveConnectedDocsProfile(params) {
|
|
637
|
+
if (!(params.snapshot.content?.includes(FUMADOCS_CONNECT_MARKER) || !params.snapshot.path)) return void 0;
|
|
638
|
+
const detectedProfile = detectConnectedFumadocsProfile(params.rootDir);
|
|
639
|
+
if (detectedProfile) return detectedProfile;
|
|
640
|
+
const existingProfile = params.existing?.extensions?.docsInfraProfile;
|
|
641
|
+
if (isRecord(existingProfile) && existingProfile.engine === "fumadocs" && Array.isArray(existingProfile.contentRoots)) return existingProfile;
|
|
642
|
+
}
|
|
528
643
|
function resolveSiteConfig(rootDir, snapshot, existing) {
|
|
529
644
|
const existingSite = toJsonRecord(existing?.site);
|
|
530
645
|
const navTitle = isRecord(snapshot.config?.nav) && typeof snapshot.config.nav.title === "string" ? snapshot.config.nav.title : readNavTitle(snapshot.content ?? "");
|
|
@@ -540,17 +655,19 @@ function resolveSiteConfig(rootDir, snapshot, existing) {
|
|
|
540
655
|
...typeof description === "string" ? { description } : {}
|
|
541
656
|
};
|
|
542
657
|
}
|
|
543
|
-
function resolveDocsRoot(rootDir, snapshot, existing) {
|
|
658
|
+
function resolveDocsRoot(rootDir, snapshot, existing, docsInfraProfile) {
|
|
659
|
+
if (docsInfraProfile?.contentRoots[0]) return docsInfraProfile.contentRoots[0];
|
|
544
660
|
const entry = snapshot.config?.entry ?? readTopLevelStringProperty(snapshot.content ?? "", "entry") ?? "docs";
|
|
545
661
|
if (snapshot.config?.contentDir) return snapshot.config.contentDir;
|
|
546
662
|
if (snapshot.content) return resolveDocsContentDir(rootDir, snapshot.content, entry);
|
|
547
663
|
if (typeof existing?.content?.docsRoot === "string") return existing.content.docsRoot;
|
|
548
664
|
return fs.existsSync(path.join(rootDir, "app", entry)) ? path.join("app", entry) : entry;
|
|
549
665
|
}
|
|
550
|
-
function resolveDocsBlock(rootDir, snapshot, existing) {
|
|
551
|
-
const detectedFramework = detectFramework(rootDir);
|
|
666
|
+
function resolveDocsBlock(rootDir, snapshot, existing, docsInfraProfile) {
|
|
552
667
|
const existingDocs = existing?.docs;
|
|
553
|
-
|
|
668
|
+
if (!snapshot.path && existingDocs) return existingDocs;
|
|
669
|
+
const detectedFramework = detectFramework(rootDir);
|
|
670
|
+
const runtime = detectedFramework ?? docsInfraProfile?.runtime ?? existingDocs?.runtime ?? "nextjs";
|
|
554
671
|
if (!Boolean(snapshot.path || detectedFramework) && existingDocs) return existingDocs;
|
|
555
672
|
return {
|
|
556
673
|
mode: "framework",
|
|
@@ -558,12 +675,30 @@ function resolveDocsBlock(rootDir, snapshot, existing) {
|
|
|
558
675
|
root: existingDocs?.root || "."
|
|
559
676
|
};
|
|
560
677
|
}
|
|
678
|
+
function resolveExtensions(existing, docsInfraProfile, options = {}) {
|
|
679
|
+
const existingExtensions = toJsonRecord(existing?.extensions);
|
|
680
|
+
if (!docsInfraProfile) {
|
|
681
|
+
if (!existingExtensions?.docsInfraProfile || options.dropStaleDocsInfraProfile === false) return existingExtensions;
|
|
682
|
+
const { docsInfraProfile: _staleDocsInfraProfile, ...rest } = existingExtensions;
|
|
683
|
+
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
684
|
+
}
|
|
685
|
+
return {
|
|
686
|
+
...existingExtensions,
|
|
687
|
+
docsInfraProfile: toJsonRecord(docsInfraProfile)
|
|
688
|
+
};
|
|
689
|
+
}
|
|
561
690
|
function materializeDocsJsonObject(params) {
|
|
562
691
|
const cloud = resolveCloudConfig(params.snapshot, params.existing);
|
|
563
|
-
const
|
|
692
|
+
const docsInfraProfile = params.docsInfraProfile ?? (params.detectConnectedDocsProfile === false ? void 0 : resolveConnectedDocsProfile({
|
|
693
|
+
rootDir: params.rootDir,
|
|
694
|
+
snapshot: params.snapshot,
|
|
695
|
+
existing: params.existing
|
|
696
|
+
}));
|
|
697
|
+
const docsRoot = resolveDocsRoot(params.rootDir, params.snapshot, params.existing, docsInfraProfile);
|
|
564
698
|
const apiReferenceRoot = resolveApiReferenceRoot(params.snapshot);
|
|
565
699
|
const existingContent = toJsonRecord(params.existing?.content);
|
|
566
700
|
const site = resolveSiteConfig(params.rootDir, params.snapshot, params.existing);
|
|
701
|
+
const extensions = resolveExtensions(params.existing, docsInfraProfile, { dropStaleDocsInfraProfile: params.dropStaleDocsInfraProfile });
|
|
567
702
|
const content = {
|
|
568
703
|
...existingContent,
|
|
569
704
|
docsRoot,
|
|
@@ -573,37 +708,65 @@ function materializeDocsJsonObject(params) {
|
|
|
573
708
|
...params.existing,
|
|
574
709
|
$schema: params.existing?.$schema ?? DOCS_CLOUD_SCHEMA_URL,
|
|
575
710
|
version: 1,
|
|
576
|
-
docs: resolveDocsBlock(params.rootDir, params.snapshot, params.existing),
|
|
711
|
+
docs: resolveDocsBlock(params.rootDir, params.snapshot, params.existing, docsInfraProfile),
|
|
577
712
|
content,
|
|
578
713
|
...site ? { site } : {},
|
|
579
|
-
cloud
|
|
714
|
+
cloud,
|
|
715
|
+
...extensions ? { extensions } : {}
|
|
580
716
|
};
|
|
581
717
|
}
|
|
582
718
|
function serializeMaterializedDocsJson(config) {
|
|
583
719
|
return `${JSON.stringify(config, null, 2)}\n`;
|
|
584
720
|
}
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
721
|
+
function withCloudInitDefaults(cloud, existingCloud, apiKeyEnv) {
|
|
722
|
+
const normalized = normalizeCloudConfig(cloud);
|
|
723
|
+
if (!existingCloud?.apiKey?.env) normalized.apiKey = { env: apiKeyEnv };
|
|
724
|
+
if (!normalized.deploy) normalized.deploy = { enabled: true };
|
|
725
|
+
if (typeof normalized.analytics === "undefined") normalized.analytics = {
|
|
726
|
+
enabled: true,
|
|
727
|
+
console: false,
|
|
728
|
+
includeInputs: false
|
|
729
|
+
};
|
|
730
|
+
return normalizeCloudConfig(normalized);
|
|
731
|
+
}
|
|
732
|
+
function writeMaterializedCloudConfig(params) {
|
|
590
733
|
const config = materializeDocsJsonObject({
|
|
591
|
-
rootDir,
|
|
592
|
-
snapshot,
|
|
593
|
-
existing
|
|
734
|
+
rootDir: params.rootDir,
|
|
735
|
+
snapshot: params.snapshot,
|
|
736
|
+
existing: params.existing,
|
|
737
|
+
docsInfraProfile: params.docsInfraProfile,
|
|
738
|
+
detectConnectedDocsProfile: params.detectConnectedDocsProfile,
|
|
739
|
+
dropStaleDocsInfraProfile: params.dropStaleDocsInfraProfile
|
|
594
740
|
});
|
|
741
|
+
if (params.cloudInitApiKeyEnv) config.cloud = withCloudInitDefaults(config.cloud, params.existing?.cloud, params.cloudInitApiKeyEnv);
|
|
595
742
|
const serialized = serializeMaterializedDocsJson(config);
|
|
596
|
-
const updated = (existing ? fs.readFileSync(docsJsonPath, "utf-8") : void 0) !== serialized;
|
|
597
|
-
if (updated) fs.writeFileSync(docsJsonPath, serialized, "utf-8");
|
|
743
|
+
const updated = (params.existing ? fs.readFileSync(params.docsJsonPath, "utf-8") : void 0) !== serialized;
|
|
744
|
+
if (updated) fs.writeFileSync(params.docsJsonPath, serialized, "utf-8");
|
|
598
745
|
return {
|
|
599
|
-
configPath: snapshot.path ?? docsJsonPath,
|
|
600
|
-
docsJsonPath,
|
|
746
|
+
configPath: params.snapshot.path ?? params.docsJsonPath,
|
|
747
|
+
docsJsonPath: params.docsJsonPath,
|
|
601
748
|
config,
|
|
602
749
|
apiKeyEnv: config.cloud?.apiKey?.env ?? DOCS_CLOUD_DEFAULT_API_KEY_ENV,
|
|
603
|
-
created: !existing,
|
|
750
|
+
created: !params.existing,
|
|
604
751
|
updated
|
|
605
752
|
};
|
|
606
753
|
}
|
|
754
|
+
async function materializeCloudConfig(options = {}) {
|
|
755
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
756
|
+
const docsJsonPath = path.join(rootDir, DOCS_JSON_FILE);
|
|
757
|
+
const existing = readExistingDocsJson(docsJsonPath);
|
|
758
|
+
const snapshot = await loadDocsConfigSnapshot(rootDir, options.configPath);
|
|
759
|
+
const useDocsJsonAsSource = Boolean(existing && !snapshot.path);
|
|
760
|
+
return writeMaterializedCloudConfig({
|
|
761
|
+
rootDir,
|
|
762
|
+
docsJsonPath,
|
|
763
|
+
existing,
|
|
764
|
+
snapshot,
|
|
765
|
+
docsInfraProfile: options.docsInfraProfile,
|
|
766
|
+
detectConnectedDocsProfile: !useDocsJsonAsSource,
|
|
767
|
+
dropStaleDocsInfraProfile: !useDocsJsonAsSource
|
|
768
|
+
});
|
|
769
|
+
}
|
|
607
770
|
function readCombinedEnv(rootDir) {
|
|
608
771
|
const env = { ...loadProjectEnv(rootDir) };
|
|
609
772
|
for (const [key, value] of Object.entries(process.env)) if (typeof value === "string") env[key] = value;
|
|
@@ -1277,16 +1440,46 @@ async function syncCloudConfig(options = {}) {
|
|
|
1277
1440
|
}
|
|
1278
1441
|
async function initCloudConfig(options = {}) {
|
|
1279
1442
|
const rootDir = options.rootDir ?? process.cwd();
|
|
1443
|
+
const docsJsonPath = path.join(rootDir, DOCS_JSON_FILE);
|
|
1444
|
+
const existingDocsJson = readExistingDocsJson(docsJsonPath);
|
|
1280
1445
|
const apiKeyEnv = normalizeEnvName(options.apiKeyEnv, DOCS_CLOUD_DEFAULT_API_KEY_ENV);
|
|
1446
|
+
const existingConfigPath = tryResolveDocsConfigPath(rootDir, options.configPath);
|
|
1447
|
+
const useDocsJsonAsSource = Boolean(existingDocsJson && !existingConfigPath);
|
|
1448
|
+
const docsInfraProfile = options.docsInfraProfile ?? (existingConfigPath || existingDocsJson ? void 0 : detectConnectedFumadocsProfile(rootDir));
|
|
1449
|
+
if (useDocsJsonAsSource) {
|
|
1450
|
+
const materialized = writeMaterializedCloudConfig({
|
|
1451
|
+
rootDir,
|
|
1452
|
+
docsJsonPath,
|
|
1453
|
+
existing: existingDocsJson,
|
|
1454
|
+
snapshot: {},
|
|
1455
|
+
docsInfraProfile,
|
|
1456
|
+
cloudInitApiKeyEnv: apiKeyEnv,
|
|
1457
|
+
detectConnectedDocsProfile: false,
|
|
1458
|
+
dropStaleDocsInfraProfile: false
|
|
1459
|
+
});
|
|
1460
|
+
return {
|
|
1461
|
+
configPath: materialized.configPath,
|
|
1462
|
+
docsJsonPath: materialized.docsJsonPath,
|
|
1463
|
+
apiKeyEnv: materialized.apiKeyEnv,
|
|
1464
|
+
analyticsProjectIdEnv: DOCS_CLOUD_DEFAULT_ANALYTICS_PROJECT_ID_ENV,
|
|
1465
|
+
configCreated: false,
|
|
1466
|
+
configUpdated: false,
|
|
1467
|
+
docsJsonCreated: false,
|
|
1468
|
+
docsJsonUpdated: materialized.updated,
|
|
1469
|
+
...docsInfraProfile ? { docsInfraProfile } : {}
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1281
1472
|
const configUpdate = ensureDocsConfigCloudInit({
|
|
1282
1473
|
rootDir,
|
|
1283
1474
|
configPath: options.configPath,
|
|
1284
|
-
apiKeyEnv
|
|
1475
|
+
apiKeyEnv,
|
|
1476
|
+
docsInfraProfile
|
|
1285
1477
|
});
|
|
1286
1478
|
const materialized = await materializeCloudConfig({
|
|
1287
1479
|
...options,
|
|
1288
1480
|
rootDir,
|
|
1289
|
-
configPath: path.relative(rootDir, configUpdate.configPath)
|
|
1481
|
+
configPath: path.relative(rootDir, configUpdate.configPath),
|
|
1482
|
+
docsInfraProfile
|
|
1290
1483
|
});
|
|
1291
1484
|
return {
|
|
1292
1485
|
configPath: configUpdate.configPath,
|
|
@@ -1296,7 +1489,8 @@ async function initCloudConfig(options = {}) {
|
|
|
1296
1489
|
configCreated: configUpdate.created,
|
|
1297
1490
|
configUpdated: configUpdate.updated,
|
|
1298
1491
|
docsJsonCreated: materialized.created,
|
|
1299
|
-
docsJsonUpdated: materialized.updated
|
|
1492
|
+
docsJsonUpdated: materialized.updated,
|
|
1493
|
+
...docsInfraProfile ? { docsInfraProfile } : {}
|
|
1300
1494
|
};
|
|
1301
1495
|
}
|
|
1302
1496
|
async function runCloudInit(options = {}) {
|
|
@@ -1311,6 +1505,7 @@ async function runCloudInit(options = {}) {
|
|
|
1311
1505
|
const docsJsonAction = result.docsJsonCreated ? "created" : result.docsJsonUpdated ? "updated" : "checked";
|
|
1312
1506
|
console.log(`${pc.green("ok")} ${configAction} ${pc.cyan(relativeConfigPath)}`);
|
|
1313
1507
|
console.log(`${pc.green("ok")} ${docsJsonAction} ${pc.cyan(relativeDocsJsonPath)}`);
|
|
1508
|
+
if (result.docsInfraProfile?.engine === "fumadocs") console.log(`${pc.green("ok")} Connected existing ${pc.cyan("Fumadocs")} content at ${pc.cyan(result.docsInfraProfile.contentRoots.join(", "))}`);
|
|
1314
1509
|
console.log();
|
|
1315
1510
|
console.log(pc.bold("Add these env vars"));
|
|
1316
1511
|
console.log(`${pc.cyan(result.apiKeyEnv)}=${pc.dim("paste_your_docs_cloud_api_key")}`);
|
|
@@ -188,7 +188,7 @@ async function configureDocsCloudOnboarding(options) {
|
|
|
188
188
|
enabled = cloudAnswer;
|
|
189
189
|
}
|
|
190
190
|
if (!enabled) return;
|
|
191
|
-
const { initCloudConfig } = await import("./cloud-
|
|
191
|
+
const { initCloudConfig } = await import("./cloud-C_Ok9rC5.mjs");
|
|
192
192
|
printDocsCloudOnboardingInstructions(await initCloudConfig({
|
|
193
193
|
rootDir: options.rootDir,
|
|
194
194
|
configPath: getDocsCloudConfigPathForFramework(options.framework)
|