@flydocs/cli 0.6.0-alpha.26 → 0.6.0-alpha.27
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.js +65 -20
- package/package.json +1 -1
- package/template/.flydocs/config.json +1 -1
- package/template/.flydocs/version +1 -1
- package/template/manifest.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ var CLI_VERSION, CLI_NAME, PACKAGE_NAME, POSTHOG_API_KEY;
|
|
|
15
15
|
var init_constants = __esm({
|
|
16
16
|
"src/lib/constants.ts"() {
|
|
17
17
|
"use strict";
|
|
18
|
-
CLI_VERSION = "0.6.0-alpha.
|
|
18
|
+
CLI_VERSION = "0.6.0-alpha.27";
|
|
19
19
|
CLI_NAME = "flydocs";
|
|
20
20
|
PACKAGE_NAME = "@flydocs/cli";
|
|
21
21
|
POSTHOG_API_KEY = "phc_v1MSJTQDFkMS90CBh3mxIz3v8bYCCnKU6v1ir6bz0Xn";
|
|
@@ -2928,12 +2928,14 @@ var init_global_config = __esm({
|
|
|
2928
2928
|
function resolveRelayUrl() {
|
|
2929
2929
|
return process.env.FLYDOCS_RELAY_URL?.replace(/\/$/, "") ?? DEFAULT_RELAY_URL;
|
|
2930
2930
|
}
|
|
2931
|
-
function headers(apiKey) {
|
|
2932
|
-
|
|
2931
|
+
function headers(apiKey, workspaceId) {
|
|
2932
|
+
const h = {
|
|
2933
2933
|
Authorization: `Bearer ${apiKey}`,
|
|
2934
2934
|
"Content-Type": "application/json",
|
|
2935
2935
|
Accept: "application/json"
|
|
2936
2936
|
};
|
|
2937
|
+
if (workspaceId) h["X-Workspace"] = workspaceId;
|
|
2938
|
+
return h;
|
|
2937
2939
|
}
|
|
2938
2940
|
async function fetchConfigV2(apiKey, options = {}) {
|
|
2939
2941
|
const baseUrl = resolveRelayUrl();
|
|
@@ -2941,7 +2943,7 @@ async function fetchConfigV2(apiKey, options = {}) {
|
|
|
2941
2943
|
if (options.includeContext) params.set("includeContext", "true");
|
|
2942
2944
|
const response = await fetch(`${baseUrl}/config/generate?${params}`, {
|
|
2943
2945
|
method: "GET",
|
|
2944
|
-
headers: headers(apiKey),
|
|
2946
|
+
headers: headers(apiKey, options.workspaceId),
|
|
2945
2947
|
signal: AbortSignal.timeout(3e4)
|
|
2946
2948
|
});
|
|
2947
2949
|
if (!response.ok) {
|
|
@@ -2954,11 +2956,11 @@ async function fetchConfigV2(apiKey, options = {}) {
|
|
|
2954
2956
|
}
|
|
2955
2957
|
return await response.json();
|
|
2956
2958
|
}
|
|
2957
|
-
async function fetchTemplates(apiKey, sinceVersion) {
|
|
2959
|
+
async function fetchTemplates(apiKey, sinceVersion, workspaceId) {
|
|
2958
2960
|
const baseUrl = resolveRelayUrl();
|
|
2959
2961
|
const response = await fetch(`${baseUrl}/templates?since=${sinceVersion}`, {
|
|
2960
2962
|
method: "GET",
|
|
2961
|
-
headers: headers(apiKey),
|
|
2963
|
+
headers: headers(apiKey, workspaceId),
|
|
2962
2964
|
signal: AbortSignal.timeout(15e3)
|
|
2963
2965
|
});
|
|
2964
2966
|
if (!response.ok) {
|
|
@@ -3140,7 +3142,7 @@ __export(init_exports, {
|
|
|
3140
3142
|
default: () => init_default
|
|
3141
3143
|
});
|
|
3142
3144
|
import { defineCommand as defineCommand2 } from "citty";
|
|
3143
|
-
import { text as text2, confirm as confirm3, isCancel as isCancel4, cancel as cancel3 } from "@clack/prompts";
|
|
3145
|
+
import { text as text2, confirm as confirm3, select as select2, isCancel as isCancel4, cancel as cancel3 } from "@clack/prompts";
|
|
3144
3146
|
import pc7 from "picocolors";
|
|
3145
3147
|
import { join as join19 } from "path";
|
|
3146
3148
|
import { mkdir as mkdir9, writeFile as writeFile12 } from "fs/promises";
|
|
@@ -3188,22 +3190,46 @@ async function resolveAndValidateKey(keyArg, targetDir) {
|
|
|
3188
3190
|
);
|
|
3189
3191
|
process.exit(1);
|
|
3190
3192
|
}
|
|
3193
|
+
const workspaces = await fetchWorkspaces(apiKey);
|
|
3194
|
+
let workspaceId;
|
|
3195
|
+
if (workspaces.length === 0) {
|
|
3196
|
+
printError("No workspaces found. Create one at app.flydocs.ai first.");
|
|
3197
|
+
process.exit(1);
|
|
3198
|
+
} else if (workspaces.length === 1) {
|
|
3199
|
+
workspaceId = workspaces[0].id;
|
|
3200
|
+
printStatus(`Workspace: ${pc7.bold(workspaces[0].name)}`);
|
|
3201
|
+
} else {
|
|
3202
|
+
const choice = await select2({
|
|
3203
|
+
message: "Select workspace",
|
|
3204
|
+
options: workspaces.map((ws) => ({
|
|
3205
|
+
value: ws.id,
|
|
3206
|
+
label: ws.name
|
|
3207
|
+
}))
|
|
3208
|
+
});
|
|
3209
|
+
if (isCancel4(choice)) {
|
|
3210
|
+
cancel3("Init cancelled.");
|
|
3211
|
+
process.exit(0);
|
|
3212
|
+
}
|
|
3213
|
+
workspaceId = choice;
|
|
3214
|
+
}
|
|
3191
3215
|
await writeGlobalCredential({
|
|
3192
3216
|
apiKey,
|
|
3217
|
+
workspaceId,
|
|
3193
3218
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3194
3219
|
lastValidated: (/* @__PURE__ */ new Date()).toISOString()
|
|
3195
3220
|
});
|
|
3196
3221
|
await checkCredentialPermissions();
|
|
3197
|
-
return apiKey;
|
|
3222
|
+
return { apiKey, workspaceId };
|
|
3198
3223
|
}
|
|
3199
|
-
async function pullServerConfig(apiKey, targetDir) {
|
|
3224
|
+
async function pullServerConfig(apiKey, targetDir, workspaceId) {
|
|
3200
3225
|
printInfo("Pulling config from server...");
|
|
3201
3226
|
const isFirstInit = !await pathExists(
|
|
3202
3227
|
join19(targetDir, ".flydocs", "config.json")
|
|
3203
3228
|
);
|
|
3204
3229
|
try {
|
|
3205
3230
|
const response = await fetchConfigV2(apiKey, {
|
|
3206
|
-
includeContext: isFirstInit
|
|
3231
|
+
includeContext: isFirstInit,
|
|
3232
|
+
workspaceId
|
|
3207
3233
|
});
|
|
3208
3234
|
if (!response.valid) {
|
|
3209
3235
|
printError("Server returned invalid config. Contact support.");
|
|
@@ -3288,7 +3314,10 @@ async function runMultiRepoInit(parentDir, keyArg) {
|
|
|
3288
3314
|
process.exit(0);
|
|
3289
3315
|
}
|
|
3290
3316
|
const firstRepoDir = join19(parentDir, repoNames[0]);
|
|
3291
|
-
const apiKey = await resolveAndValidateKey(
|
|
3317
|
+
const { apiKey, workspaceId } = await resolveAndValidateKey(
|
|
3318
|
+
keyArg,
|
|
3319
|
+
firstRepoDir
|
|
3320
|
+
);
|
|
3292
3321
|
const allActions = [
|
|
3293
3322
|
"Stored credential globally (~/.flydocs/credentials)"
|
|
3294
3323
|
];
|
|
@@ -3299,7 +3328,7 @@ async function runMultiRepoInit(parentDir, keyArg) {
|
|
|
3299
3328
|
const repoDir = join19(parentDir, repoName);
|
|
3300
3329
|
console.log();
|
|
3301
3330
|
printInfo(`Initializing ${pc7.bold(repoName)}...`);
|
|
3302
|
-
const serverResponse = await pullServerConfig(apiKey, repoDir);
|
|
3331
|
+
const serverResponse = await pullServerConfig(apiKey, repoDir, workspaceId);
|
|
3303
3332
|
if (!firstResponse) firstResponse = serverResponse;
|
|
3304
3333
|
const { actions, skipped } = await initSingleRepo(
|
|
3305
3334
|
repoDir,
|
|
@@ -3404,8 +3433,15 @@ var init_init = __esm({
|
|
|
3404
3433
|
await runMultiRepoInit(targetDir, args.key);
|
|
3405
3434
|
return;
|
|
3406
3435
|
}
|
|
3407
|
-
const apiKey = await resolveAndValidateKey(
|
|
3408
|
-
|
|
3436
|
+
const { apiKey, workspaceId } = await resolveAndValidateKey(
|
|
3437
|
+
args.key,
|
|
3438
|
+
targetDir
|
|
3439
|
+
);
|
|
3440
|
+
const serverResponse = await pullServerConfig(
|
|
3441
|
+
apiKey,
|
|
3442
|
+
targetDir,
|
|
3443
|
+
workspaceId
|
|
3444
|
+
);
|
|
3409
3445
|
const { actions, skipped } = await initSingleRepo(
|
|
3410
3446
|
targetDir,
|
|
3411
3447
|
apiKey,
|
|
@@ -3446,7 +3482,7 @@ __export(update_exports, {
|
|
|
3446
3482
|
import { defineCommand as defineCommand3 } from "citty";
|
|
3447
3483
|
import { resolve as resolve4, join as join20 } from "path";
|
|
3448
3484
|
import { mkdir as mkdir10, cp as cp2, readFile as readFile14, readdir as readdir5, rm as rm4 } from "fs/promises";
|
|
3449
|
-
import { select as
|
|
3485
|
+
import { select as select3, text as text3, confirm as confirm4, isCancel as isCancel5, cancel as cancel4 } from "@clack/prompts";
|
|
3450
3486
|
import pc8 from "picocolors";
|
|
3451
3487
|
var update_default;
|
|
3452
3488
|
var init_update = __esm({
|
|
@@ -3515,7 +3551,7 @@ var init_update = __esm({
|
|
|
3515
3551
|
} else if (args.here) {
|
|
3516
3552
|
targetDir = process.cwd();
|
|
3517
3553
|
} else {
|
|
3518
|
-
const choice = await
|
|
3554
|
+
const choice = await select3({
|
|
3519
3555
|
message: "Which project would you like to update?",
|
|
3520
3556
|
options: [
|
|
3521
3557
|
{
|
|
@@ -3891,7 +3927,7 @@ __export(uninstall_exports, {
|
|
|
3891
3927
|
import { defineCommand as defineCommand4 } from "citty";
|
|
3892
3928
|
import { resolve as resolve5, join as join21 } from "path";
|
|
3893
3929
|
import { readdir as readdir6, rm as rm5, rename as rename2 } from "fs/promises";
|
|
3894
|
-
import { confirm as confirm5, select as
|
|
3930
|
+
import { confirm as confirm5, select as select4, isCancel as isCancel6, cancel as cancel5 } from "@clack/prompts";
|
|
3895
3931
|
import pc9 from "picocolors";
|
|
3896
3932
|
async function removeOwnedSkills(targetDir) {
|
|
3897
3933
|
const skillsDir = join21(targetDir, ".claude", "skills");
|
|
@@ -4037,7 +4073,7 @@ var init_uninstall = __esm({
|
|
|
4037
4073
|
if (removeAll) {
|
|
4038
4074
|
contentAction = "remove";
|
|
4039
4075
|
} else if (!skipPrompts) {
|
|
4040
|
-
const choice = await
|
|
4076
|
+
const choice = await select4({
|
|
4041
4077
|
message: "What should happen to your flydocs/ content (project docs, knowledge base)?",
|
|
4042
4078
|
options: [
|
|
4043
4079
|
{
|
|
@@ -4682,6 +4718,14 @@ var init_sync = __esm({
|
|
|
4682
4718
|
process.exit(1);
|
|
4683
4719
|
}
|
|
4684
4720
|
const apiKey = resolved.key;
|
|
4721
|
+
const cred = await readGlobalCredential();
|
|
4722
|
+
const workspaceId = cred?.workspaceId;
|
|
4723
|
+
if (!workspaceId) {
|
|
4724
|
+
printError(
|
|
4725
|
+
"No workspace ID found. Run `flydocs init` to set up your workspace."
|
|
4726
|
+
);
|
|
4727
|
+
process.exit(1);
|
|
4728
|
+
}
|
|
4685
4729
|
let currentTemplateVersion = 0;
|
|
4686
4730
|
try {
|
|
4687
4731
|
const currentConfig = await readAnyConfig(targetDir);
|
|
@@ -4692,7 +4736,7 @@ var init_sync = __esm({
|
|
|
4692
4736
|
}
|
|
4693
4737
|
let serverResponse;
|
|
4694
4738
|
try {
|
|
4695
|
-
serverResponse = await fetchConfigV2(apiKey);
|
|
4739
|
+
serverResponse = await fetchConfigV2(apiKey, { workspaceId });
|
|
4696
4740
|
} catch (err) {
|
|
4697
4741
|
if (err instanceof RelayError) {
|
|
4698
4742
|
printWarning(
|
|
@@ -4717,7 +4761,8 @@ var init_sync = __esm({
|
|
|
4717
4761
|
try {
|
|
4718
4762
|
const templatesResponse = await fetchTemplates(
|
|
4719
4763
|
apiKey,
|
|
4720
|
-
currentTemplateVersion
|
|
4764
|
+
currentTemplateVersion,
|
|
4765
|
+
workspaceId
|
|
4721
4766
|
);
|
|
4722
4767
|
if (templatesResponse.templates.length > 0) {
|
|
4723
4768
|
const templatesDir = join23(
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.6.0-alpha.
|
|
1
|
+
0.6.0-alpha.27
|
package/template/manifest.json
CHANGED