@fern-api/fern-api-dev 3.28.0 → 3.29.0
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/cli.cjs +160 -5
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1413817,7 +1413817,7 @@ var AccessTokenPosthogManager = class {
|
|
|
1413817
1413817
|
properties: {
|
|
1413818
1413818
|
...event,
|
|
1413819
1413819
|
...event.properties,
|
|
1413820
|
-
version: "3.
|
|
1413820
|
+
version: "3.29.0",
|
|
1413821
1413821
|
usingAccessToken: true
|
|
1413822
1413822
|
}
|
|
1413823
1413823
|
});
|
|
@@ -1413916,7 +1413916,7 @@ var UserPosthogManager = class {
|
|
|
1413916
1413916
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
1413917
1413917
|
event: "CLI",
|
|
1413918
1413918
|
properties: {
|
|
1413919
|
-
version: "3.
|
|
1413919
|
+
version: "3.29.0",
|
|
1413920
1413920
|
...event,
|
|
1413921
1413921
|
...event.properties,
|
|
1413922
1413922
|
usingAccessToken: false,
|
|
@@ -1493982,7 +1493982,7 @@ var CliContext = class {
|
|
|
1493982
1493982
|
if (false) {
|
|
1493983
1493983
|
this.logger.error("CLI_VERSION is not defined");
|
|
1493984
1493984
|
}
|
|
1493985
|
-
return "3.
|
|
1493985
|
+
return "3.29.0";
|
|
1493986
1493986
|
}
|
|
1493987
1493987
|
getCliName() {
|
|
1493988
1493988
|
if (false) {
|
|
@@ -1588481,7 +1588481,7 @@ var import_path35 = __toESM(require("path"), 1);
|
|
|
1588481
1588481
|
var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
1588482
1588482
|
var LOGS_FOLDER_NAME = "logs";
|
|
1588483
1588483
|
function getCliSource() {
|
|
1588484
|
-
const version6 = "3.
|
|
1588484
|
+
const version6 = "3.29.0";
|
|
1588485
1588485
|
return `cli@${version6}`;
|
|
1588486
1588486
|
}
|
|
1588487
1588487
|
var DebugLogger = class {
|
|
@@ -1605297,6 +1605297,110 @@ async function previewDocsWorkspace({
|
|
|
1605297
1605297
|
return;
|
|
1605298
1605298
|
}
|
|
1605299
1605299
|
|
|
1605300
|
+
// src/commands/docs-preview/deleteDocsPreview.ts
|
|
1605301
|
+
var PREVIEW_URL_PATTERN = /^[a-z0-9-]+-preview-[a-z0-9]+\.docs\.buildwithfern\.com$/i;
|
|
1605302
|
+
function isPreviewUrl(url2) {
|
|
1605303
|
+
let hostname = url2.toLowerCase().trim();
|
|
1605304
|
+
if (hostname.startsWith("https://")) {
|
|
1605305
|
+
hostname = hostname.slice(8);
|
|
1605306
|
+
} else if (hostname.startsWith("http://")) {
|
|
1605307
|
+
hostname = hostname.slice(7);
|
|
1605308
|
+
}
|
|
1605309
|
+
const slashIndex = hostname.indexOf("/");
|
|
1605310
|
+
if (slashIndex !== -1) {
|
|
1605311
|
+
hostname = hostname.slice(0, slashIndex);
|
|
1605312
|
+
}
|
|
1605313
|
+
return PREVIEW_URL_PATTERN.test(hostname);
|
|
1605314
|
+
}
|
|
1605315
|
+
async function deleteDocsPreview({
|
|
1605316
|
+
cliContext,
|
|
1605317
|
+
previewUrl
|
|
1605318
|
+
}) {
|
|
1605319
|
+
if (!isPreviewUrl(previewUrl)) {
|
|
1605320
|
+
cliContext.failAndThrow(
|
|
1605321
|
+
`Invalid preview URL: ${previewUrl}
|
|
1605322
|
+
Only preview sites can be deleted with this command.
|
|
1605323
|
+
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com
|
|
1605324
|
+
Example: acme-preview-abc123.docs.buildwithfern.com`
|
|
1605325
|
+
);
|
|
1605326
|
+
return;
|
|
1605327
|
+
}
|
|
1605328
|
+
const token = await cliContext.runTask(async (context2) => {
|
|
1605329
|
+
return askToLogin(context2);
|
|
1605330
|
+
});
|
|
1605331
|
+
if (token == null) {
|
|
1605332
|
+
cliContext.failAndThrow("Failed to authenticate. Please run 'fern login' first.");
|
|
1605333
|
+
return;
|
|
1605334
|
+
}
|
|
1605335
|
+
await cliContext.runTask(async (context2) => {
|
|
1605336
|
+
context2.logger.info(`Deleting preview site: ${previewUrl}`);
|
|
1605337
|
+
const fdr = createFdrService({ token: token.value });
|
|
1605338
|
+
const deleteResponse = await fdr.docs.v2.write.deleteDocsSite({
|
|
1605339
|
+
url: previewUrl
|
|
1605340
|
+
});
|
|
1605341
|
+
if (deleteResponse.ok) {
|
|
1605342
|
+
context2.logger.info(source_default.green(`Successfully deleted preview site: ${previewUrl}`));
|
|
1605343
|
+
} else {
|
|
1605344
|
+
switch (deleteResponse.error.error) {
|
|
1605345
|
+
case "UnauthorizedError":
|
|
1605346
|
+
return context2.failAndThrow(
|
|
1605347
|
+
"You do not have permissions to delete this preview site. Reach out to support@buildwithfern.com"
|
|
1605348
|
+
);
|
|
1605349
|
+
case "DocsNotFoundError":
|
|
1605350
|
+
return context2.failAndThrow(`Preview site not found: ${previewUrl}`);
|
|
1605351
|
+
default:
|
|
1605352
|
+
return context2.failAndThrow(`Failed to delete preview site: ${previewUrl}`, deleteResponse.error);
|
|
1605353
|
+
}
|
|
1605354
|
+
}
|
|
1605355
|
+
});
|
|
1605356
|
+
}
|
|
1605357
|
+
|
|
1605358
|
+
// src/commands/docs-preview/listDocsPreview.ts
|
|
1605359
|
+
async function listDocsPreview({
|
|
1605360
|
+
cliContext,
|
|
1605361
|
+
limit,
|
|
1605362
|
+
page
|
|
1605363
|
+
}) {
|
|
1605364
|
+
const token = await cliContext.runTask(async (context2) => {
|
|
1605365
|
+
return askToLogin(context2);
|
|
1605366
|
+
});
|
|
1605367
|
+
if (token == null) {
|
|
1605368
|
+
cliContext.failAndThrow("Failed to authenticate. Please run 'fern login' first.");
|
|
1605369
|
+
return;
|
|
1605370
|
+
}
|
|
1605371
|
+
await cliContext.runTask(async (context2) => {
|
|
1605372
|
+
context2.logger.info("Fetching preview deployments...");
|
|
1605373
|
+
const fdr = createFdrService({ token: token.value });
|
|
1605374
|
+
const listResponse = await fdr.docs.v2.read.listAllDocsUrls({
|
|
1605375
|
+
page,
|
|
1605376
|
+
limit: limit ?? 100
|
|
1605377
|
+
});
|
|
1605378
|
+
if (!listResponse.ok) {
|
|
1605379
|
+
return context2.failAndThrow("Failed to fetch docs URLs", listResponse.error);
|
|
1605380
|
+
}
|
|
1605381
|
+
const previewUrlPattern = /-preview-[a-f0-9]+\.docs\.buildwithfern\.com$/;
|
|
1605382
|
+
const previewDeployments = listResponse.body.urls.filter((item) => previewUrlPattern.test(item.domain)).map((item) => ({
|
|
1605383
|
+
url: item.basePath != null ? `${item.domain}${item.basePath}` : item.domain,
|
|
1605384
|
+
organizationId: item.organizationId,
|
|
1605385
|
+
updatedAt: item.updatedAt
|
|
1605386
|
+
}));
|
|
1605387
|
+
if (previewDeployments.length === 0) {
|
|
1605388
|
+
context2.logger.info("No preview deployments found.");
|
|
1605389
|
+
return;
|
|
1605390
|
+
}
|
|
1605391
|
+
context2.logger.info(source_default.bold(`
|
|
1605392
|
+
Found ${previewDeployments.length} preview deployment(s):
|
|
1605393
|
+
`));
|
|
1605394
|
+
for (const deployment of previewDeployments) {
|
|
1605395
|
+
const updatedDate = new Date(deployment.updatedAt).toLocaleString();
|
|
1605396
|
+
context2.logger.info(` ${source_default.cyan(deployment.url)}`);
|
|
1605397
|
+
context2.logger.info(` Organization: ${deployment.organizationId}`);
|
|
1605398
|
+
context2.logger.info(` Updated: ${updatedDate}
|
|
1605399
|
+
`);
|
|
1605400
|
+
}
|
|
1605401
|
+
});
|
|
1605402
|
+
}
|
|
1605403
|
+
|
|
1605300
1605404
|
// src/commands/downgrade/downgrade.ts
|
|
1605301
1605405
|
var import_promises80 = require("fs/promises");
|
|
1605302
1605406
|
|
|
@@ -1646710,12 +1646814,63 @@ function addWriteDefinitionCommand(cli, cliContext) {
|
|
|
1646710
1646814
|
}
|
|
1646711
1646815
|
function addDocsCommand(cli, cliContext) {
|
|
1646712
1646816
|
cli.command("docs", "Commands for managing your docs", (yargs) => {
|
|
1646713
|
-
|
|
1646817
|
+
addDocsDevCommand(yargs, cliContext);
|
|
1646714
1646818
|
addDocsBrokenLinksCommand(yargs, cliContext);
|
|
1646819
|
+
addDocsPreviewCommand(yargs, cliContext);
|
|
1646715
1646820
|
return yargs;
|
|
1646716
1646821
|
});
|
|
1646717
1646822
|
}
|
|
1646718
1646823
|
function addDocsPreviewCommand(cli, cliContext) {
|
|
1646824
|
+
cli.command("preview", "Commands for managing preview deployments", (yargs) => {
|
|
1646825
|
+
addDocsPreviewListCommand(yargs, cliContext);
|
|
1646826
|
+
addDocsPreviewDeleteCommand(yargs, cliContext);
|
|
1646827
|
+
return yargs;
|
|
1646828
|
+
});
|
|
1646829
|
+
}
|
|
1646830
|
+
function addDocsPreviewListCommand(cli, cliContext) {
|
|
1646831
|
+
cli.command(
|
|
1646832
|
+
"list",
|
|
1646833
|
+
"List all preview deployments",
|
|
1646834
|
+
(yargs) => yargs.option("limit", {
|
|
1646835
|
+
type: "number",
|
|
1646836
|
+
description: "Maximum number of preview deployments to display"
|
|
1646837
|
+
}).option("page", {
|
|
1646838
|
+
type: "number",
|
|
1646839
|
+
description: "Page number for pagination (starts at 1)"
|
|
1646840
|
+
}),
|
|
1646841
|
+
async (argv) => {
|
|
1646842
|
+
await cliContext.instrumentPostHogEvent({
|
|
1646843
|
+
command: "fern docs preview list"
|
|
1646844
|
+
});
|
|
1646845
|
+
await listDocsPreview({
|
|
1646846
|
+
cliContext,
|
|
1646847
|
+
limit: argv.limit,
|
|
1646848
|
+
page: argv.page
|
|
1646849
|
+
});
|
|
1646850
|
+
}
|
|
1646851
|
+
);
|
|
1646852
|
+
}
|
|
1646853
|
+
function addDocsPreviewDeleteCommand(cli, cliContext) {
|
|
1646854
|
+
cli.command(
|
|
1646855
|
+
"delete <url>",
|
|
1646856
|
+
"Delete a preview deployment",
|
|
1646857
|
+
(yargs) => yargs.positional("url", {
|
|
1646858
|
+
type: "string",
|
|
1646859
|
+
description: "The FQDN of the preview deployment to delete (e.g. acme-preview-abc123.docs.buildwithfern.com)",
|
|
1646860
|
+
demandOption: true
|
|
1646861
|
+
}),
|
|
1646862
|
+
async (argv) => {
|
|
1646863
|
+
await cliContext.instrumentPostHogEvent({
|
|
1646864
|
+
command: "fern docs preview delete"
|
|
1646865
|
+
});
|
|
1646866
|
+
await deleteDocsPreview({
|
|
1646867
|
+
cliContext,
|
|
1646868
|
+
previewUrl: argv.url
|
|
1646869
|
+
});
|
|
1646870
|
+
}
|
|
1646871
|
+
);
|
|
1646872
|
+
}
|
|
1646873
|
+
function addDocsDevCommand(cli, cliContext) {
|
|
1646719
1646874
|
cli.command(
|
|
1646720
1646875
|
"dev",
|
|
1646721
1646876
|
"Run a local development server to preview your docs",
|
package/package.json
CHANGED