@farming-labs/docs 0.2.43 → 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") {
|
|
@@ -634,7 +634,6 @@ function resolveApiReferenceRoot(snapshot) {
|
|
|
634
634
|
return readStringProperty(apiReferenceBlock, "path");
|
|
635
635
|
}
|
|
636
636
|
function resolveConnectedDocsProfile(params) {
|
|
637
|
-
if (params.explicit) return params.explicit;
|
|
638
637
|
if (!(params.snapshot.content?.includes(FUMADOCS_CONNECT_MARKER) || !params.snapshot.path)) return void 0;
|
|
639
638
|
const detectedProfile = detectConnectedFumadocsProfile(params.rootDir);
|
|
640
639
|
if (detectedProfile) return detectedProfile;
|
|
@@ -665,8 +664,9 @@ function resolveDocsRoot(rootDir, snapshot, existing, docsInfraProfile) {
|
|
|
665
664
|
return fs.existsSync(path.join(rootDir, "app", entry)) ? path.join("app", entry) : entry;
|
|
666
665
|
}
|
|
667
666
|
function resolveDocsBlock(rootDir, snapshot, existing, docsInfraProfile) {
|
|
668
|
-
const detectedFramework = detectFramework(rootDir);
|
|
669
667
|
const existingDocs = existing?.docs;
|
|
668
|
+
if (!snapshot.path && existingDocs) return existingDocs;
|
|
669
|
+
const detectedFramework = detectFramework(rootDir);
|
|
670
670
|
const runtime = detectedFramework ?? docsInfraProfile?.runtime ?? existingDocs?.runtime ?? "nextjs";
|
|
671
671
|
if (!Boolean(snapshot.path || detectedFramework) && existingDocs) return existingDocs;
|
|
672
672
|
return {
|
|
@@ -675,10 +675,10 @@ function resolveDocsBlock(rootDir, snapshot, existing, docsInfraProfile) {
|
|
|
675
675
|
root: existingDocs?.root || "."
|
|
676
676
|
};
|
|
677
677
|
}
|
|
678
|
-
function resolveExtensions(existing, docsInfraProfile) {
|
|
678
|
+
function resolveExtensions(existing, docsInfraProfile, options = {}) {
|
|
679
679
|
const existingExtensions = toJsonRecord(existing?.extensions);
|
|
680
680
|
if (!docsInfraProfile) {
|
|
681
|
-
if (!existingExtensions?.docsInfraProfile) return existingExtensions;
|
|
681
|
+
if (!existingExtensions?.docsInfraProfile || options.dropStaleDocsInfraProfile === false) return existingExtensions;
|
|
682
682
|
const { docsInfraProfile: _staleDocsInfraProfile, ...rest } = existingExtensions;
|
|
683
683
|
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
684
684
|
}
|
|
@@ -689,17 +689,16 @@ function resolveExtensions(existing, docsInfraProfile) {
|
|
|
689
689
|
}
|
|
690
690
|
function materializeDocsJsonObject(params) {
|
|
691
691
|
const cloud = resolveCloudConfig(params.snapshot, params.existing);
|
|
692
|
-
const docsInfraProfile = resolveConnectedDocsProfile({
|
|
692
|
+
const docsInfraProfile = params.docsInfraProfile ?? (params.detectConnectedDocsProfile === false ? void 0 : resolveConnectedDocsProfile({
|
|
693
693
|
rootDir: params.rootDir,
|
|
694
694
|
snapshot: params.snapshot,
|
|
695
|
-
existing: params.existing
|
|
696
|
-
|
|
697
|
-
});
|
|
695
|
+
existing: params.existing
|
|
696
|
+
}));
|
|
698
697
|
const docsRoot = resolveDocsRoot(params.rootDir, params.snapshot, params.existing, docsInfraProfile);
|
|
699
698
|
const apiReferenceRoot = resolveApiReferenceRoot(params.snapshot);
|
|
700
699
|
const existingContent = toJsonRecord(params.existing?.content);
|
|
701
700
|
const site = resolveSiteConfig(params.rootDir, params.snapshot, params.existing);
|
|
702
|
-
const extensions = resolveExtensions(params.existing, docsInfraProfile);
|
|
701
|
+
const extensions = resolveExtensions(params.existing, docsInfraProfile, { dropStaleDocsInfraProfile: params.dropStaleDocsInfraProfile });
|
|
703
702
|
const content = {
|
|
704
703
|
...existingContent,
|
|
705
704
|
docsRoot,
|
|
@@ -719,29 +718,55 @@ function materializeDocsJsonObject(params) {
|
|
|
719
718
|
function serializeMaterializedDocsJson(config) {
|
|
720
719
|
return `${JSON.stringify(config, null, 2)}\n`;
|
|
721
720
|
}
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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) {
|
|
727
733
|
const config = materializeDocsJsonObject({
|
|
728
|
-
rootDir,
|
|
729
|
-
snapshot,
|
|
730
|
-
existing,
|
|
731
|
-
docsInfraProfile:
|
|
734
|
+
rootDir: params.rootDir,
|
|
735
|
+
snapshot: params.snapshot,
|
|
736
|
+
existing: params.existing,
|
|
737
|
+
docsInfraProfile: params.docsInfraProfile,
|
|
738
|
+
detectConnectedDocsProfile: params.detectConnectedDocsProfile,
|
|
739
|
+
dropStaleDocsInfraProfile: params.dropStaleDocsInfraProfile
|
|
732
740
|
});
|
|
741
|
+
if (params.cloudInitApiKeyEnv) config.cloud = withCloudInitDefaults(config.cloud, params.existing?.cloud, params.cloudInitApiKeyEnv);
|
|
733
742
|
const serialized = serializeMaterializedDocsJson(config);
|
|
734
|
-
const updated = (existing ? fs.readFileSync(docsJsonPath, "utf-8") : void 0) !== serialized;
|
|
735
|
-
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");
|
|
736
745
|
return {
|
|
737
|
-
configPath: snapshot.path ?? docsJsonPath,
|
|
738
|
-
docsJsonPath,
|
|
746
|
+
configPath: params.snapshot.path ?? params.docsJsonPath,
|
|
747
|
+
docsJsonPath: params.docsJsonPath,
|
|
739
748
|
config,
|
|
740
749
|
apiKeyEnv: config.cloud?.apiKey?.env ?? DOCS_CLOUD_DEFAULT_API_KEY_ENV,
|
|
741
|
-
created: !existing,
|
|
750
|
+
created: !params.existing,
|
|
742
751
|
updated
|
|
743
752
|
};
|
|
744
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
|
+
}
|
|
745
770
|
function readCombinedEnv(rootDir) {
|
|
746
771
|
const env = { ...loadProjectEnv(rootDir) };
|
|
747
772
|
for (const [key, value] of Object.entries(process.env)) if (typeof value === "string") env[key] = value;
|
|
@@ -1415,9 +1440,35 @@ async function syncCloudConfig(options = {}) {
|
|
|
1415
1440
|
}
|
|
1416
1441
|
async function initCloudConfig(options = {}) {
|
|
1417
1442
|
const rootDir = options.rootDir ?? process.cwd();
|
|
1443
|
+
const docsJsonPath = path.join(rootDir, DOCS_JSON_FILE);
|
|
1444
|
+
const existingDocsJson = readExistingDocsJson(docsJsonPath);
|
|
1418
1445
|
const apiKeyEnv = normalizeEnvName(options.apiKeyEnv, DOCS_CLOUD_DEFAULT_API_KEY_ENV);
|
|
1419
1446
|
const existingConfigPath = tryResolveDocsConfigPath(rootDir, options.configPath);
|
|
1420
|
-
const
|
|
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
|
+
}
|
|
1421
1472
|
const configUpdate = ensureDocsConfigCloudInit({
|
|
1422
1473
|
rootDir,
|
|
1423
1474
|
configPath: options.configPath,
|
|
@@ -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)
|