@scalar/cli 1.9.9 → 2.0.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.
Files changed (4) hide show
  1. package/README.md +24 -6
  2. package/docs.html +145 -100
  3. package/index.js +401 -269
  4. package/package.json +6 -6
package/index.js CHANGED
@@ -6890,14 +6890,14 @@ var require_parser = __commonJS({
6890
6890
  case "scalar":
6891
6891
  case "single-quoted-scalar":
6892
6892
  case "double-quoted-scalar": {
6893
- const fs21 = this.flowScalar(this.type);
6893
+ const fs22 = this.flowScalar(this.type);
6894
6894
  if (atNextItem || it.value) {
6895
- map2.items.push({ start, key: fs21, sep: [] });
6895
+ map2.items.push({ start, key: fs22, sep: [] });
6896
6896
  this.onKeyLine = true;
6897
6897
  } else if (it.sep) {
6898
- this.stack.push(fs21);
6898
+ this.stack.push(fs22);
6899
6899
  } else {
6900
- Object.assign(it, { key: fs21, sep: [] });
6900
+ Object.assign(it, { key: fs22, sep: [] });
6901
6901
  this.onKeyLine = true;
6902
6902
  }
6903
6903
  return;
@@ -7025,13 +7025,13 @@ var require_parser = __commonJS({
7025
7025
  case "scalar":
7026
7026
  case "single-quoted-scalar":
7027
7027
  case "double-quoted-scalar": {
7028
- const fs21 = this.flowScalar(this.type);
7028
+ const fs22 = this.flowScalar(this.type);
7029
7029
  if (!it || it.value)
7030
- fc.items.push({ start: [], key: fs21, sep: [] });
7030
+ fc.items.push({ start: [], key: fs22, sep: [] });
7031
7031
  else if (it.sep)
7032
- this.stack.push(fs21);
7032
+ this.stack.push(fs22);
7033
7033
  else
7034
- Object.assign(it, { key: fs21, sep: [] });
7034
+ Object.assign(it, { key: fs22, sep: [] });
7035
7035
  return;
7036
7036
  }
7037
7037
  case "flow-map-end":
@@ -11822,7 +11822,7 @@ var require_parse2 = __commonJS({
11822
11822
  var require_gray_matter = __commonJS({
11823
11823
  "../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/index.js"(exports2, module2) {
11824
11824
  "use strict";
11825
- var fs21 = __require("fs");
11825
+ var fs22 = __require("fs");
11826
11826
  var sections = require_section_matter();
11827
11827
  var defaults = require_defaults();
11828
11828
  var stringify = require_stringify3();
@@ -11906,7 +11906,7 @@ var require_gray_matter = __commonJS({
11906
11906
  return stringify(file2, data, options2);
11907
11907
  };
11908
11908
  matter2.read = function(filepath, options2) {
11909
- const str2 = fs21.readFileSync(filepath, "utf8");
11909
+ const str2 = fs22.readFileSync(filepath, "utf8");
11910
11910
  const file2 = matter2(str2, options2);
11911
11911
  file2.path = filepath;
11912
11912
  return file2;
@@ -69163,18 +69163,18 @@ Visit https://nodejs.org to download the latest version.`
69163
69163
  }
69164
69164
 
69165
69165
  // src/program.ts
69166
- import { Command as Command50 } from "commander";
69166
+ import { Command as Command51 } from "commander";
69167
69167
 
69168
69168
  // package.json
69169
69169
  var name = "@scalar/cli";
69170
- var version = "1.9.9";
69170
+ var version = "2.0.0";
69171
69171
  var bin = {
69172
69172
  scalar: "./dist/index.js",
69173
69173
  "scalar-cli": "./dist/index.js"
69174
69174
  };
69175
69175
 
69176
69176
  // src/domains/schema/index.ts
69177
- import { Command as Command6 } from "commander";
69177
+ import { Command as Command7 } from "commander";
69178
69178
 
69179
69179
  // src/domains/schema/delete.ts
69180
69180
  import { select } from "@clack/prompts";
@@ -86697,6 +86697,9 @@ var siteDeploySchema = entitySchema.extend({
86697
86697
  projectUid: nanoidSchema,
86698
86698
  subpaths: subpathSchema.array().default([])
86699
86699
  }).meta({ id: "site-deploy" });
86700
+ var searchConfigResponseSchema = external_exports.object({
86701
+ subpaths: subpathSchema.array()
86702
+ }).meta({ id: "search-config-response" });
86700
86703
 
86701
86704
  // ../../packages/entities/dist/login-portals/customization.js
86702
86705
  var loginPortalEmailSchema = external_exports.object({
@@ -87724,11 +87727,22 @@ var docsProjectRepositorySchema = external_exports.discriminatedUnion("provider"
87724
87727
  githubRepositorySchema,
87725
87728
  bitbucketRepositorySchema
87726
87729
  ]);
87730
+ var remoteActivitySchema = external_exports.object({
87731
+ at: timestampSchema,
87732
+ branch: external_exports.string().nullable(),
87733
+ sha: external_exports.string().nullable(),
87734
+ actorName: external_exports.string().nullable()
87735
+ }).meta({ id: "docs-project-remote-activity" });
87727
87736
  var docsProjectSchema = sharedProjectSchema.extend({
87728
87737
  slug: slugSchema,
87729
87738
  publishStatus: external_exports.string().default(""),
87730
87739
  publishMessage: external_exports.string().default(""),
87731
- repository: docsProjectRepositorySchema
87740
+ repository: docsProjectRepositorySchema,
87741
+ /**
87742
+ * `.catch(undefined)` so a malformed bump degrades to "no signal" instead
87743
+ * of failing the schema parse inside every subscribed dashboard.
87744
+ */
87745
+ remoteActivity: remoteActivitySchema.optional().catch(void 0)
87732
87746
  }).meta({ id: "docs-project" });
87733
87747
  function isGithubBackedDocsProject(project) {
87734
87748
  return project.repository.provider === "github";
@@ -87785,13 +87799,13 @@ var signupDataSchema = external_exports.object({
87785
87799
  yjsReferences: external_exports.record(external_exports.string(), external_exports.string())
87786
87800
  }).meta({ id: "signup-data" });
87787
87801
 
87802
+ // ../../packages/entities/dist/sdk/helpers.js
87803
+ import semver3 from "semver";
87804
+
87788
87805
  // ../../packages/entities/dist/sdk/scalar-config.js
87789
87806
  var import_yaml = __toESM(require_dist(), 1);
87790
87807
  import semver4 from "semver";
87791
87808
 
87792
- // ../../packages/entities/dist/sdk/helpers.js
87793
- import semver3 from "semver";
87794
-
87795
87809
  // ../../packages/entities/dist/sdk/schema.js
87796
87810
  var SdkLanguage;
87797
87811
  (function(SdkLanguage2) {
@@ -88157,7 +88171,8 @@ var billingInfoSchema = external_exports.preprocess((arg) => {
88157
88171
  billingId: nanoidSchema.optional(),
88158
88172
  email: emailSchema,
88159
88173
  plan: billingPlanSchema,
88160
- expires: external_exports.number().optional()
88174
+ expires: external_exports.number().optional(),
88175
+ sdkTrialReminderSentAt: external_exports.number().optional()
88161
88176
  })).meta({ id: "billing-info" });
88162
88177
  var invoiceStatusSchema = external_exports.enum(["open", "paid", "draft", "void", "uncollectible"]).meta({ id: "invoice-status" });
88163
88178
  var billingInvoiceSchema = external_exports.object({
@@ -89493,6 +89508,16 @@ function sdksApiFactory(requestService) {
89493
89508
  schema: external_exports.unknown()
89494
89509
  });
89495
89510
  }
89511
+ async function transformConfig(data) {
89512
+ return await requestService.request({
89513
+ url: "sdk-generator/transform-config",
89514
+ method: "post",
89515
+ data,
89516
+ schema: external_exports.object({
89517
+ config: external_exports.string().nullable()
89518
+ })
89519
+ });
89520
+ }
89496
89521
  async function del(uid) {
89497
89522
  return await requestService.request({
89498
89523
  url: `core/v1/sdks/${uid}`,
@@ -89594,6 +89619,7 @@ function sdksApiFactory(requestService) {
89594
89619
  fromConfig,
89595
89620
  createVersion,
89596
89621
  previewCodeSamples,
89622
+ transformConfig,
89597
89623
  update,
89598
89624
  delete: del,
89599
89625
  discardDraft,
@@ -89792,12 +89818,13 @@ function formatApiResponse(data, status, headers) {
89792
89818
  error: false
89793
89819
  };
89794
89820
  }
89795
- function formatApiError(message, status, error48 = null) {
89821
+ function formatApiError(message, status, error48 = null, code) {
89796
89822
  return {
89797
89823
  status,
89798
89824
  message,
89799
89825
  error: true,
89800
- originalError: error48
89826
+ originalError: error48,
89827
+ code
89801
89828
  };
89802
89829
  }
89803
89830
  function requestServiceFactory(baseUrl, getAuthToken) {
@@ -89832,8 +89859,10 @@ function requestServiceFactory(baseUrl, getAuthToken) {
89832
89859
  }).then(async (response) => {
89833
89860
  const isJson = response.headers.get("content-type")?.includes("application/json");
89834
89861
  if (!response.ok) {
89835
- const message = isJson ? String((await response.json().catch(() => ({ message: "Invalid response" }))).message) || "Unknown Error" : await response.text().catch(() => "Invalid response");
89836
- return formatApiError(message, response.status);
89862
+ const body = isJson ? await response.json().catch(() => ({ message: "Invalid response" })) : { message: await response.text().catch(() => "Invalid response") };
89863
+ const message = String(body.message ?? "") || "Unknown Error";
89864
+ const code = typeof body.code === "string" ? body.code : void 0;
89865
+ return formatApiError(message, response.status, null, code);
89837
89866
  }
89838
89867
  if (stream2)
89839
89868
  return response.body ?? new ReadableStream();
@@ -90730,13 +90759,14 @@ function publishApiFactory(requestService) {
90730
90759
  })
90731
90760
  });
90732
90761
  }
90733
- async function unpublish(projectUid, githubProjectUid) {
90762
+ async function unpublish(projectUid, githubProjectUid, unifiedProjectUid) {
90734
90763
  return await requestService.request({
90735
90764
  url: "core/unpublish",
90736
90765
  method: "delete",
90737
90766
  data: {
90738
90767
  projectUid,
90739
- githubProjectUid
90768
+ githubProjectUid,
90769
+ unifiedProjectUid
90740
90770
  },
90741
90771
  schema: external_exports.null()
90742
90772
  });
@@ -91258,7 +91288,7 @@ var config2 = {
91258
91288
  }
91259
91289
  },
91260
91290
  cdnUrl: process.env.CDN_URL ?? "https://cdn.scalar.com",
91261
- ssgDocsIsolateVersion: process.env.SSG_DOCS_ISOLATE_VERSION ?? "1.4.4"
91291
+ ssgDocsIsolateVersion: process.env.SSG_DOCS_ISOLATE_VERSION ?? "1.4.5"
91262
91292
  };
91263
91293
 
91264
91294
  // src/domains/auth/login/helpers/personal-token-generate-access.ts
@@ -91890,71 +91920,9 @@ var DeleteSchemaCommand = () => {
91890
91920
  return cmd2;
91891
91921
  };
91892
91922
 
91893
- // src/domains/schema/list.ts
91894
- import as2 from "ansis";
91923
+ // src/domains/schema/get.ts
91924
+ import fs3 from "node:fs/promises";
91895
91925
  import { Command as Command2 } from "commander";
91896
- var ListSchemaCommand = () => {
91897
- const cmd2 = new Command2("list");
91898
- cmd2.description("List all schemas for a team namespace");
91899
- cmd2.option("--namespace <namespace>", "Team namespace");
91900
- cmd2.action(async (args) => {
91901
- const { error: error48, data } = external_exports.object({
91902
- namespace: namespaceSchema.optional()
91903
- }).safeParse({
91904
- namespace: args.namespace
91905
- });
91906
- if (error48)
91907
- return output.error().title("Invalid input").message(error48.issues[0].message).exit("error");
91908
- const auth = await getAuthData();
91909
- auth.addEventListener((state) => Object.assign(auth, state));
91910
- const client = await getDatabaseClient();
91911
- const team = await client.getOne({
91912
- collectionPath: BaseCollections.Teams,
91913
- query: {
91914
- uid: auth.teamUid
91915
- },
91916
- schema: teamSchema
91917
- });
91918
- if (team.error)
91919
- return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
91920
- const namespace = data.namespace || team.data.namespaces.at(0);
91921
- if (!namespace) {
91922
- return output.error().title("Missing namespace").message(
91923
- "Could not find a valid namespace for your API. Please specify a namespace or contact support."
91924
- ).exit("error");
91925
- }
91926
- const apiClient = await apiService();
91927
- const schemas = await apiClient.managedSchemas.getSchemas(namespace);
91928
- if (schemas.error)
91929
- return output.error().title(schemas.message).exit("error");
91930
- output.info().table(
91931
- [
91932
- [
91933
- as2.underline.bold("Slug"),
91934
- as2.underline.bold("Title"),
91935
- as2.underline.bold("Version")
91936
- ],
91937
- ...schemas.data.map((schema) => {
91938
- return [
91939
- as2.blue(schema.slug),
91940
- as2.blue(schema.title),
91941
- schema.isPrivate ? as2.green("Private") : as2.yellow("Public")
91942
- ];
91943
- })
91944
- ],
91945
- { padding: 2 }
91946
- ).print();
91947
- });
91948
- return cmd2;
91949
- };
91950
-
91951
- // src/domains/schema/publish.ts
91952
- import { text } from "@clack/prompts";
91953
- import as6 from "ansis";
91954
- import { Command as Command4 } from "commander";
91955
- import { bundle as bundle2 } from "@scalar/json-magic/bundle";
91956
- import { fetchUrls as fetchUrls2, readFiles as readFiles2 } from "@scalar/json-magic/bundle/plugins/node";
91957
- import { parseJsonOrYaml } from "@scalar/oas-utils/helpers";
91958
91926
 
91959
91927
  // ../../packages/urls/dist/publish/full.js
91960
91928
  function getPublishUrl(domain2, subpath) {
@@ -92047,14 +92015,184 @@ function registry2(teamNamespace) {
92047
92015
  };
92048
92016
  }
92049
92017
 
92018
+ // src/domains/registry/helpers/links.ts
92019
+ function registryUrl(path13) {
92020
+ return `${config2.projects.registry}/${path13}`;
92021
+ }
92022
+ function dashboardUrl(asset, uid) {
92023
+ return `${config2.projects.dashboard}/registry/${asset}/${uid}`;
92024
+ }
92025
+
92026
+ // src/domains/registry/helpers/fetch.ts
92027
+ async function fetchFromRegistry(path13, accessToken) {
92028
+ let response;
92029
+ try {
92030
+ response = await fetch(registryUrl(path13), {
92031
+ headers: {
92032
+ "x-scalar-auth": accessToken
92033
+ },
92034
+ // Should always error on redirect
92035
+ redirect: "error"
92036
+ });
92037
+ } catch (error48) {
92038
+ return {
92039
+ error: true,
92040
+ message: error48 instanceof Error && error48.message.length > 0 ? error48.message : "Registry request failed before a response was received."
92041
+ };
92042
+ }
92043
+ if (!response.ok) {
92044
+ const message = await response.text();
92045
+ return {
92046
+ error: true,
92047
+ message: message.length ? message : `Registry request failed with status ${response.status}.`
92048
+ };
92049
+ }
92050
+ return {
92051
+ error: false,
92052
+ data: await response.text()
92053
+ };
92054
+ }
92055
+
92056
+ // src/domains/schema/get.ts
92057
+ var versionSchema3 = external_exports.union([docVersionSchema, external_exports.literal("latest")]);
92058
+ var GetSchemaCommand = () => {
92059
+ const cmd2 = new Command2("get");
92060
+ cmd2.description("Get a schema document version from the Scalar registry");
92061
+ cmd2.argument("[namespace]", "Team namespace");
92062
+ cmd2.argument("[slug]", "Schema slug");
92063
+ cmd2.option("--version <version>", "Schema version (defaults to latest)");
92064
+ cmd2.option("--format <format>", "Output format (json or yaml)", "json");
92065
+ cmd2.option("-o, --output <file>", "Output file (defaults to stdout)");
92066
+ cmd2.action(async (namespace, slug, args) => {
92067
+ if (!namespace) {
92068
+ output.error().title("Invalid input").message("Please provide namespace of the schema").exit("error");
92069
+ return;
92070
+ }
92071
+ if (!slug) {
92072
+ output.error().title("Invalid input").message("Please provide slug of the schema").exit("error");
92073
+ return;
92074
+ }
92075
+ const result = external_exports.object({
92076
+ version: versionSchema3,
92077
+ format: external_exports.enum(["json", "yaml"]),
92078
+ output: external_exports.string().min(1).optional()
92079
+ }).safeParse({
92080
+ version: args.version ?? "latest",
92081
+ format: args.format,
92082
+ output: args.output
92083
+ });
92084
+ if (result.error) {
92085
+ output.error().title("Invalid input").message(result.error.issues[0].message).exit("error");
92086
+ return;
92087
+ }
92088
+ const auth = await getAuthData();
92089
+ auth.addEventListener((state) => Object.assign(auth, state));
92090
+ const fetchResult = await fetchFromRegistry(
92091
+ registry2(namespace).schemas(slug).url({
92092
+ version: result.data.version,
92093
+ format: result.data.format
92094
+ }),
92095
+ auth.accessToken
92096
+ );
92097
+ if (fetchResult.error) {
92098
+ output.error().title("Unable to download schema").message(fetchResult.message).exit("error");
92099
+ return;
92100
+ }
92101
+ const document2 = fetchResult.data;
92102
+ const withTrailingNewline = document2.endsWith("\n") ? document2 : `${document2}
92103
+ `;
92104
+ if (result.data.output) {
92105
+ try {
92106
+ await fs3.writeFile(result.data.output, withTrailingNewline, "utf8");
92107
+ } catch (error48) {
92108
+ const message = error48 instanceof Error && error48.message.length > 0 ? error48.message : `Could not write to ${result.data.output}.`;
92109
+ output.error().title("Unable to write schema to file").message(message).exit("error");
92110
+ return;
92111
+ }
92112
+ output.info().line(
92113
+ `Downloaded ${namespace}/${slug}@${result.data.version} (${result.data.format})`
92114
+ ).line(`Written to ${result.data.output}`).print();
92115
+ return;
92116
+ }
92117
+ process.stdout.write(withTrailingNewline);
92118
+ });
92119
+ return cmd2;
92120
+ };
92121
+
92122
+ // src/domains/schema/list.ts
92123
+ import as2 from "ansis";
92124
+ import { Command as Command3 } from "commander";
92125
+ var ListSchemaCommand = () => {
92126
+ const cmd2 = new Command3("list");
92127
+ cmd2.description("List all schemas for a team namespace");
92128
+ cmd2.option("--namespace <namespace>", "Team namespace");
92129
+ cmd2.action(async (args) => {
92130
+ const { error: error48, data } = external_exports.object({
92131
+ namespace: namespaceSchema.optional()
92132
+ }).safeParse({
92133
+ namespace: args.namespace
92134
+ });
92135
+ if (error48)
92136
+ return output.error().title("Invalid input").message(error48.issues[0].message).exit("error");
92137
+ const auth = await getAuthData();
92138
+ auth.addEventListener((state) => Object.assign(auth, state));
92139
+ const client = await getDatabaseClient();
92140
+ const team = await client.getOne({
92141
+ collectionPath: BaseCollections.Teams,
92142
+ query: {
92143
+ uid: auth.teamUid
92144
+ },
92145
+ schema: teamSchema
92146
+ });
92147
+ if (team.error)
92148
+ return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
92149
+ const namespace = data.namespace || team.data.namespaces.at(0);
92150
+ if (!namespace) {
92151
+ return output.error().title("Missing namespace").message(
92152
+ "Could not find a valid namespace for your API. Please specify a namespace or contact support."
92153
+ ).exit("error");
92154
+ }
92155
+ const apiClient = await apiService();
92156
+ const schemas = await apiClient.managedSchemas.getSchemas(namespace);
92157
+ if (schemas.error)
92158
+ return output.error().title(schemas.message).exit("error");
92159
+ output.info().table(
92160
+ [
92161
+ [
92162
+ as2.underline.bold("Slug"),
92163
+ as2.underline.bold("Title"),
92164
+ as2.underline.bold("Version")
92165
+ ],
92166
+ ...schemas.data.map((schema) => {
92167
+ return [
92168
+ as2.blue(schema.slug),
92169
+ as2.blue(schema.title),
92170
+ schema.isPrivate ? as2.green("Private") : as2.yellow("Public")
92171
+ ];
92172
+ })
92173
+ ],
92174
+ { padding: 2 }
92175
+ ).print();
92176
+ });
92177
+ return cmd2;
92178
+ };
92179
+
92180
+ // src/domains/schema/publish.ts
92181
+ import { text } from "@clack/prompts";
92182
+ import as6 from "ansis";
92183
+ import { Command as Command5 } from "commander";
92184
+ import { bundle as bundle2 } from "@scalar/json-magic/bundle";
92185
+ import { fetchUrls as fetchUrls2, readFiles as readFiles2 } from "@scalar/json-magic/bundle/plugins/node";
92186
+ import { parseJsonOrYaml } from "@scalar/oas-utils/helpers";
92187
+
92050
92188
  // src/domains/document/bundle/index.ts
92051
92189
  var import_yaml2 = __toESM(require_dist(), 1);
92052
- import fs4 from "node:fs/promises";
92190
+ import fs5 from "node:fs/promises";
92053
92191
  import path3 from "node:path";
92054
92192
  import { cwd } from "node:process";
92055
92193
  import { confirm } from "@clack/prompts";
92056
92194
  import as5 from "ansis";
92057
- import { Command as Command3 } from "commander";
92195
+ import { Command as Command4 } from "commander";
92058
92196
  import { bundle } from "@scalar/json-magic/bundle";
92059
92197
  import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
92060
92198
 
@@ -92076,7 +92214,7 @@ var printSpecificationBanner = (result) => {
92076
92214
  };
92077
92215
 
92078
92216
  // src/domains/document/helpers/imports.ts
92079
- import fs3 from "node:fs";
92217
+ import fs4 from "node:fs";
92080
92218
  import as4 from "ansis";
92081
92219
  import { load, validate } from "@scalar/openapi-parser";
92082
92220
  var getFileOrUrl = async (input) => {
@@ -92087,10 +92225,10 @@ var getFileOrUrl = async (input) => {
92087
92225
  }
92088
92226
  return await response.text();
92089
92227
  }
92090
- if (!fs3.existsSync(input)) {
92228
+ if (!fs4.existsSync(input)) {
92091
92229
  return output.error().title("Could not read file.").exit("error");
92092
92230
  }
92093
- return fs3.readFileSync(input, "utf-8");
92231
+ return fs4.readFileSync(input, "utf-8");
92094
92232
  };
92095
92233
  var loadOpenApiFile = async (input) => {
92096
92234
  const specification = await getFileOrUrl(input);
@@ -92137,7 +92275,7 @@ async function measureTime(fn) {
92137
92275
  // src/domains/document/bundle/index.ts
92138
92276
  var DEFAULT_FETCH_CONCURRENCY = 5;
92139
92277
  function BundleCommand() {
92140
- const cmd2 = new Command3("bundle");
92278
+ const cmd2 = new Command4("bundle");
92141
92279
  cmd2.description(
92142
92280
  "Bundle an OpenAPI specification by resolving all references and external dependencies"
92143
92281
  );
@@ -92192,7 +92330,7 @@ function BundleCommand() {
92192
92330
  urlMap: !!urlMap
92193
92331
  })
92194
92332
  );
92195
- await fs4.writeFile(
92333
+ await fs5.writeFile(
92196
92334
  outputFilePath ?? input,
92197
92335
  isYaml ? import_yaml2.default.stringify(result) : JSON.stringify(result),
92198
92336
  "utf8"
@@ -92205,17 +92343,9 @@ function BundleCommand() {
92205
92343
  return cmd2;
92206
92344
  }
92207
92345
 
92208
- // src/domains/registry/helpers/links.ts
92209
- function registryUrl(path13) {
92210
- return `${config2.projects.registry}/${path13}`;
92211
- }
92212
- function dashboardUrl(asset, uid) {
92213
- return `${config2.projects.dashboard}/registry/${asset}/${uid}`;
92214
- }
92215
-
92216
92346
  // src/domains/schema/publish.ts
92217
92347
  var PublishSchemaCommand = () => {
92218
- const cmd2 = new Command4("publish");
92348
+ const cmd2 = new Command5("publish");
92219
92349
  cmd2.description("Publish a shared schema to the Scalar registry");
92220
92350
  cmd2.argument("[file]", "OpenAPI file to upload");
92221
92351
  cmd2.option(
@@ -92306,7 +92436,9 @@ var PublishSchemaCommand = () => {
92306
92436
  const matchingSchema = namespaceSchemaRes.data.find(
92307
92437
  (schema2) => schema2.slug === slug
92308
92438
  );
92309
- const title = matchingSchema || data.title ? data.title : (await text({
92439
+ const documentTitle = result?.info?.title;
92440
+ const providedTitle = data.title ?? documentTitle;
92441
+ const title = matchingSchema || providedTitle ? providedTitle : (await text({
92310
92442
  message: "Please provide a title for your schema",
92311
92443
  validate(value) {
92312
92444
  if (value.length === 0) return "Title is required.";
@@ -92361,9 +92493,9 @@ var PublishSchemaCommand = () => {
92361
92493
 
92362
92494
  // src/domains/schema/update.ts
92363
92495
  import { select as select2 } from "@clack/prompts";
92364
- import { Command as Command5 } from "commander";
92496
+ import { Command as Command6 } from "commander";
92365
92497
  var UpdateSchemaCommand = () => {
92366
- const cmd2 = new Command5("update");
92498
+ const cmd2 = new Command6("update");
92367
92499
  cmd2.description("Update schema metadata.");
92368
92500
  cmd2.option("-s, --slug <slug>", "Schema slug");
92369
92501
  cmd2.option("-n, --namespace <namespace>", "Team namespace");
@@ -92431,21 +92563,22 @@ var schemaCommands = [
92431
92563
  DeleteSchemaCommand,
92432
92564
  UpdateSchemaCommand,
92433
92565
  ListSchemaCommand,
92566
+ GetSchemaCommand,
92434
92567
  PublishSchemaCommand
92435
92568
  ];
92436
- var schemaDomain = new Command6("schema");
92569
+ var schemaDomain = new Command7("schema");
92437
92570
  schemaDomain.description("Manage your Scalar schemas");
92438
- schemaCommands.forEach((command) => schemaDomain.addCommand(command()));
92571
+ schemaCommands.forEach((command) => void schemaDomain.addCommand(command()));
92439
92572
  var schema_default = schemaDomain;
92440
92573
 
92441
92574
  // src/domains/sdk/index.ts
92442
- import { Command as Command12 } from "commander";
92575
+ import { Command as Command13 } from "commander";
92443
92576
 
92444
92577
  // src/domains/sdk/build.ts
92445
92578
  import { select as select3 } from "@clack/prompts";
92446
- import { Command as Command7 } from "commander";
92579
+ import { Command as Command8 } from "commander";
92447
92580
  var BuildSdkCommand = () => {
92448
- const cmd2 = new Command7("build");
92581
+ const cmd2 = new Command8("build");
92449
92582
  cmd2.description("Create an SDK build.");
92450
92583
  cmd2.option("-s, --slug <slug>", "SDK slug");
92451
92584
  cmd2.option("-n, --namespace <namespace>", "Team namespace");
@@ -92518,9 +92651,9 @@ var BuildSdkCommand = () => {
92518
92651
  // src/domains/sdk/create.ts
92519
92652
  import { select as select4, text as text2 } from "@clack/prompts";
92520
92653
  import as7 from "ansis";
92521
- import { Command as Command8, Option } from "commander";
92654
+ import { Command as Command9, Option } from "commander";
92522
92655
  var CreateSdkCommand = () => {
92523
- const cmd2 = new Command8("create");
92656
+ const cmd2 = new Command9("create");
92524
92657
  cmd2.description("Create a new SDK.");
92525
92658
  cmd2.option("-a, --api <api>", "Registry API slug");
92526
92659
  cmd2.option("-n, --namespace <namespace>", "Team namespace");
@@ -92596,9 +92729,9 @@ var CreateSdkCommand = () => {
92596
92729
 
92597
92730
  // src/domains/sdk/delete.ts
92598
92731
  import { select as select5 } from "@clack/prompts";
92599
- import { Command as Command9 } from "commander";
92732
+ import { Command as Command10 } from "commander";
92600
92733
  var DeleteSdkCommand = () => {
92601
- const cmd2 = new Command9("delete");
92734
+ const cmd2 = new Command10("delete");
92602
92735
  cmd2.description("Delete an SDK.");
92603
92736
  cmd2.option("-s, --slug <slug>", "SDK slug");
92604
92737
  cmd2.option("-n, --namespace <namespace>", "Team namespace");
@@ -92658,9 +92791,9 @@ var DeleteSdkCommand = () => {
92658
92791
 
92659
92792
  // src/domains/sdk/update.ts
92660
92793
  import { select as select6 } from "@clack/prompts";
92661
- import { Command as Command10 } from "commander";
92794
+ import { Command as Command11 } from "commander";
92662
92795
  var UpdateSdkCommand = () => {
92663
- const cmd2 = new Command10("update");
92796
+ const cmd2 = new Command11("update");
92664
92797
  cmd2.description("Update SDK metadata.");
92665
92798
  cmd2.option("-s, --slug <slug>", "SDK slug");
92666
92799
  cmd2.option("-n, --namespace <namespace>", "Team namespace");
@@ -92727,9 +92860,9 @@ var UpdateSdkCommand = () => {
92727
92860
 
92728
92861
  // src/domains/sdk/list.ts
92729
92862
  import as8 from "ansis";
92730
- import { Command as Command11 } from "commander";
92863
+ import { Command as Command12 } from "commander";
92731
92864
  var ListSdkCommand = () => {
92732
- const cmd2 = new Command11("list");
92865
+ const cmd2 = new Command12("list");
92733
92866
  cmd2.description("List all SDKs for a team namespace");
92734
92867
  cmd2.option("--namespace <namespace>", "Team namespace");
92735
92868
  cmd2.action(async (args) => {
@@ -92797,17 +92930,17 @@ var sdkCommands = [
92797
92930
  DeleteSdkCommand,
92798
92931
  BuildSdkCommand
92799
92932
  ];
92800
- var sdkDomain = new Command12("sdk");
92933
+ var sdkDomain = new Command13("sdk");
92801
92934
  sdkDomain.description("Manage your Scalar SDKs (Enterprise Only)");
92802
92935
  sdkCommands.forEach((command) => sdkDomain.addCommand(command()));
92803
92936
  var sdk_default = sdkDomain;
92804
92937
 
92805
92938
  // src/domains/auth/index.ts
92806
- import { Command as Command16 } from "commander";
92939
+ import { Command as Command17 } from "commander";
92807
92940
 
92808
92941
  // src/domains/auth/login/index.ts
92809
92942
  import as10 from "ansis";
92810
- import { Command as Command13 } from "commander";
92943
+ import { Command as Command14 } from "commander";
92811
92944
 
92812
92945
  // ../../packages/mongobase-client/dist/auth/node/exchange-callback-server.js
92813
92946
  import getPort from "get-port";
@@ -92951,7 +93084,7 @@ var emailPasswordAuth = async ({
92951
93084
 
92952
93085
  // src/domains/auth/login/index.ts
92953
93086
  var LoginCommand = () => {
92954
- const cmd2 = new Command13("login");
93087
+ const cmd2 = new Command14("login");
92955
93088
  cmd2.description("Login to scalar");
92956
93089
  cmd2.option("--email <email>", "Email");
92957
93090
  cmd2.option("--password <password>", "Password");
@@ -93012,9 +93145,9 @@ var LoginCommand = () => {
93012
93145
  };
93013
93146
 
93014
93147
  // src/domains/auth/logout/index.ts
93015
- import { Command as Command14 } from "commander";
93148
+ import { Command as Command15 } from "commander";
93016
93149
  var LogoutCommand = () => {
93017
- const cmd2 = new Command14("logout");
93150
+ const cmd2 = new Command15("logout");
93018
93151
  cmd2.description("Logout from scalar");
93019
93152
  cmd2.action(async () => {
93020
93153
  await clearAuthData();
@@ -93025,9 +93158,9 @@ var LogoutCommand = () => {
93025
93158
 
93026
93159
  // src/domains/auth/whoami/index.ts
93027
93160
  import as11 from "ansis";
93028
- import { Command as Command15 } from "commander";
93161
+ import { Command as Command16 } from "commander";
93029
93162
  var WhoAmICommand = () => {
93030
- const cmd2 = new Command15("whoami");
93163
+ const cmd2 = new Command16("whoami");
93031
93164
  cmd2.description("Display the current user");
93032
93165
  cmd2.action(async () => {
93033
93166
  const auth = await getAuthData({ skipRefresh: true });
@@ -93040,19 +93173,19 @@ var WhoAmICommand = () => {
93040
93173
 
93041
93174
  // src/domains/auth/index.ts
93042
93175
  var authCommands = [LoginCommand, WhoAmICommand, LogoutCommand];
93043
- var authDomain = new Command16("auth");
93176
+ var authDomain = new Command17("auth");
93044
93177
  authDomain.description("Manage authorization on scalar platform");
93045
93178
  authCommands.forEach((command) => authDomain.addCommand(command()));
93046
93179
  var auth_default = authDomain;
93047
93180
 
93048
93181
  // src/domains/document/index.ts
93049
- import { Command as Command29 } from "commander";
93182
+ import { Command as Command30 } from "commander";
93050
93183
 
93051
93184
  // src/domains/document/join/index.ts
93052
93185
  var import_yaml3 = __toESM(require_dist(), 1);
93053
- import fs5 from "node:fs/promises";
93186
+ import fs6 from "node:fs/promises";
93054
93187
  import as12 from "ansis";
93055
- import { Command as Command17 } from "commander";
93188
+ import { Command as Command18 } from "commander";
93056
93189
  import { join, normalize as normalize2 } from "@scalar/openapi-parser";
93057
93190
 
93058
93191
  // src/domains/document/join/helpers.ts
@@ -93088,7 +93221,7 @@ var formatErrorMessage = (conflicts) => {
93088
93221
  });
93089
93222
  };
93090
93223
  function JoinCommand() {
93091
- const cmd2 = new Command17("join");
93224
+ const cmd2 = new Command18("join");
93092
93225
  cmd2.description(
93093
93226
  "Merge multiple OpenAPI documents into a single unified document"
93094
93227
  );
@@ -93112,7 +93245,7 @@ function JoinCommand() {
93112
93245
  optsError.issues.map((e) => `${e.message} property: '${e.path}'`).join("\n")
93113
93246
  ).line("").exit("error");
93114
93247
  }
93115
- const files = (await Promise.all(input.map((file2) => fs5.readFile(file2, "utf-8")))).map((it) => normalize2(it));
93248
+ const files = (await Promise.all(input.map((file2) => fs6.readFile(file2, "utf-8")))).map((it) => normalize2(it));
93116
93249
  const prefixes = opts.prefixComponentsWithPathValue ? getPrefixes(files, opts.prefixComponentsWithPathValue) : [];
93117
93250
  const { executionTimeMs, result } = await measureTime(
93118
93251
  () => join(files, { prefixComponents: prefixes })
@@ -93122,7 +93255,7 @@ function JoinCommand() {
93122
93255
  ${formatErrorMessage(result.conflicts).join("\n")}`).line().exit("error");
93123
93256
  }
93124
93257
  const isYaml = isYamlFileName(opts.output);
93125
- await fs5.writeFile(
93258
+ await fs6.writeFile(
93126
93259
  opts.output,
93127
93260
  isYaml ? import_yaml3.default.stringify(result.document) : JSON.stringify(result.document, null, 2),
93128
93261
  "utf8"
@@ -93135,18 +93268,18 @@ ${formatErrorMessage(result.conflicts).join("\n")}`).line().exit("error");
93135
93268
  }
93136
93269
 
93137
93270
  // src/domains/document/split/index.ts
93138
- import fs6 from "node:fs/promises";
93271
+ import fs7 from "node:fs/promises";
93139
93272
  import path4 from "node:path";
93140
93273
  import { text as text3 } from "@clack/prompts";
93141
93274
  import as13 from "ansis";
93142
- import { Command as Command18 } from "commander";
93275
+ import { Command as Command19 } from "commander";
93143
93276
  import { normalize as normalize3 } from "@scalar/openapi-parser";
93144
93277
  import {
93145
93278
  createServerWorkspaceStore,
93146
93279
  WORKSPACE_FILE_NAME
93147
93280
  } from "@scalar/workspace-store/server";
93148
93281
  function SplitCommand() {
93149
- const cmd2 = new Command18("split");
93282
+ const cmd2 = new Command19("split");
93150
93283
  cmd2.description("Split your OpenAPI documents on small chunks");
93151
93284
  cmd2.argument("[file|url]", "Path to OpenAPI file or URL to split");
93152
93285
  cmd2.option("-o, --output <path>", "Path to save the chunks");
@@ -93186,13 +93319,13 @@ function SplitCommand() {
93186
93319
  await store.generateWorkspaceChunks();
93187
93320
  const workspaceFilePath = path4.join(outputPath, WORKSPACE_FILE_NAME);
93188
93321
  const sparseDocument = JSON.parse(
93189
- await fs6.readFile(workspaceFilePath, { encoding: "utf-8" })
93322
+ await fs7.readFile(workspaceFilePath, { encoding: "utf-8" })
93190
93323
  );
93191
- await fs6.writeFile(
93324
+ await fs7.writeFile(
93192
93325
  path4.join(outputPath, "out.json"),
93193
93326
  JSON.stringify(sparseDocument.documents[documentName])
93194
93327
  );
93195
- await fs6.rm(workspaceFilePath);
93328
+ await fs7.rm(workspaceFilePath);
93196
93329
  });
93197
93330
  output.info().line().title(as13.green("Document Split Successfully! \u{1F389}")).line().message(`\u2728 Chunks have been generated at: ${as13.blue(outputPath)}`).line(`\u23F1\uFE0F Split completed in ${as13.yellow(executionTimeMs.toFixed(2))}ms`).line("").print();
93198
93331
  });
@@ -93200,12 +93333,12 @@ function SplitCommand() {
93200
93333
  }
93201
93334
 
93202
93335
  // src/domains/document/format/index.ts
93203
- import fs7 from "node:fs";
93336
+ import fs8 from "node:fs";
93204
93337
  import as14 from "ansis";
93205
- import { Command as Command19 } from "commander";
93338
+ import { Command as Command20 } from "commander";
93206
93339
  import { normalize as normalize4, toJson, toYaml } from "@scalar/openapi-parser";
93207
93340
  function FormatCommand() {
93208
- const cmd2 = new Command19("format");
93341
+ const cmd2 = new Command20("format");
93209
93342
  cmd2.description("Format an OpenAPI file");
93210
93343
  cmd2.argument("[file|url]", "File or URL to format");
93211
93344
  cmd2.option("-o, --output <file>", "Output file");
@@ -93218,9 +93351,9 @@ function FormatCommand() {
93218
93351
  const specification = await getFileOrUrl(inputArgument);
93219
93352
  const newContent = isYamlFileName(outputPath || inputArgument) ? toYaml(normalize4(specification)) : toJson(normalize4(specification));
93220
93353
  if (outputPath) {
93221
- fs7.writeFileSync(outputPath, newContent, "utf8");
93354
+ fs8.writeFileSync(outputPath, newContent, "utf8");
93222
93355
  } else if (!isUrl(inputArgument)) {
93223
- fs7.writeFileSync(inputArgument, newContent, "utf8");
93356
+ fs8.writeFileSync(inputArgument, newContent, "utf8");
93224
93357
  } else {
93225
93358
  return output.error().title("Invalid argument").message().message(
93226
93359
  "Output file is required for URLs. Try passing --output file flag."
@@ -93240,7 +93373,7 @@ function FormatCommand() {
93240
93373
  // src/domains/document/lint/index.ts
93241
93374
  import spectralCore from "@stoplight/spectral-core";
93242
93375
  import as15 from "ansis";
93243
- import { Command as Command20 } from "commander";
93376
+ import { Command as Command21 } from "commander";
93244
93377
 
93245
93378
  // src/domains/document/lint/helpers.ts
93246
93379
  import { bundleAndLoadRuleset } from "@stoplight/spectral-ruleset-bundler/with-loader";
@@ -93272,7 +93405,7 @@ var severityToLabel = (severity) => {
93272
93405
  var { Spectral } = spectralCore;
93273
93406
  var spectral = new Spectral();
93274
93407
  function LintCommand() {
93275
- const cmd2 = new Command20("lint");
93408
+ const cmd2 = new Command21("lint");
93276
93409
  cmd2.description("Lint your OpenAPI file using spectral rules");
93277
93410
  cmd2.argument("[file|url]", "OpenAPI file path or url");
93278
93411
  cmd2.option("-r, --rule <file|url>", "Rule path or url");
@@ -93308,12 +93441,12 @@ function LintCommand() {
93308
93441
  }
93309
93442
 
93310
93443
  // src/domains/document/markdown/index.ts
93311
- import fs8 from "node:fs";
93444
+ import fs9 from "node:fs";
93312
93445
  import as16 from "ansis";
93313
- import { Command as Command21 } from "commander";
93446
+ import { Command as Command22 } from "commander";
93314
93447
  import { createMarkdownFromOpenApi } from "@scalar/openapi-to-markdown";
93315
93448
  function MarkdownCommand() {
93316
- const cmd2 = new Command21("markdown");
93449
+ const cmd2 = new Command22("markdown");
93317
93450
  cmd2.description("Generate Markdown from an OpenAPI file");
93318
93451
  cmd2.argument("[file|url]", "OpenAPI file path or URL to convert");
93319
93452
  cmd2.option("-o, --output <file>", "Output file (defaults to stdout)");
@@ -93326,7 +93459,7 @@ function MarkdownCommand() {
93326
93459
  const specification = await getFileOrUrl(inputArgument);
93327
93460
  const markdown = await createMarkdownFromOpenApi(specification);
93328
93461
  if (outputPath) {
93329
- fs8.writeFileSync(outputPath, markdown, "utf8");
93462
+ fs9.writeFileSync(outputPath, markdown, "utf8");
93330
93463
  const endTime = performance.now();
93331
93464
  output.info().line(
93332
93465
  `${as16.green("Markdown generated")} ${as16.grey(
@@ -93343,7 +93476,7 @@ function MarkdownCommand() {
93343
93476
 
93344
93477
  // src/domains/document/mock/index.ts
93345
93478
  import as18 from "ansis";
93346
- import { Command as Command22 } from "commander";
93479
+ import { Command as Command23 } from "commander";
93347
93480
 
93348
93481
  // src/domains/document/mock/helpers.ts
93349
93482
  import { serve } from "@hono/node-server";
@@ -93413,7 +93546,7 @@ function getMethodColor(method) {
93413
93546
 
93414
93547
  // src/domains/document/mock/index.ts
93415
93548
  function MockCommand() {
93416
- const cmd2 = new Command22("mock");
93549
+ const cmd2 = new Command23("mock");
93417
93550
  cmd2.description("Mock an API from an OpenAPI file");
93418
93551
  cmd2.argument("[file|url]", "OpenAPI file or URL to mock the server for");
93419
93552
  cmd2.option("-w, --watch", "watch the file for changes");
@@ -93473,12 +93606,12 @@ function MockCommand() {
93473
93606
 
93474
93607
  // src/domains/document/postman/index.ts
93475
93608
  var import_yaml4 = __toESM(require_dist(), 1);
93476
- import fs9 from "node:fs";
93609
+ import fs10 from "node:fs";
93477
93610
  import as19 from "ansis";
93478
- import { Command as Command23 } from "commander";
93611
+ import { Command as Command24 } from "commander";
93479
93612
  import { convert } from "@scalar/postman-to-openapi";
93480
93613
  function ConvertCommand() {
93481
- const cmd2 = new Command23("convert");
93614
+ const cmd2 = new Command24("convert");
93482
93615
  cmd2.description("Convert a Postman collection to an OpenAPI document");
93483
93616
  cmd2.argument("[file|url]", "Postman collection file path or URL to convert");
93484
93617
  cmd2.option("-o, --output <file>", "Output file (defaults to stdout)");
@@ -93506,7 +93639,7 @@ function ConvertCommand() {
93506
93639
  }
93507
93640
  const openApiDocument = outputPath ? isYamlFileName(outputPath) ? import_yaml4.default.stringify(specification) : JSON.stringify(specification, null, 2) : JSON.stringify(specification, null, 2);
93508
93641
  if (outputPath) {
93509
- fs9.writeFileSync(outputPath, openApiDocument, "utf8");
93642
+ fs10.writeFileSync(outputPath, openApiDocument, "utf8");
93510
93643
  const endTime = performance.now();
93511
93644
  output.info().line(
93512
93645
  `${as19.green("OpenAPI document generated")} ${as19.grey(
@@ -93525,11 +93658,11 @@ function ConvertCommand() {
93525
93658
  // src/domains/document/serve/index.ts
93526
93659
  import { serve as serve2 } from "@hono/node-server";
93527
93660
  import as20 from "ansis";
93528
- import { Command as Command24 } from "commander";
93661
+ import { Command as Command25 } from "commander";
93529
93662
  import { Hono } from "hono";
93530
93663
  import { stream } from "hono/streaming";
93531
93664
  function ServeCommand() {
93532
- const cmd2 = new Command24("serve");
93665
+ const cmd2 = new Command25("serve");
93533
93666
  cmd2.description("Serve an API Reference from an OpenAPI file");
93534
93667
  cmd2.argument("[file|url]", "OpenAPI file or URL to show the reference for");
93535
93668
  cmd2.option("-w, --watch", "watch the file for changes");
@@ -93648,9 +93781,9 @@ var getHtmlDocument = (specification, watch = false) => {
93648
93781
 
93649
93782
  // src/domains/document/share/index.ts
93650
93783
  import as21 from "ansis";
93651
- import { Command as Command25 } from "commander";
93784
+ import { Command as Command26 } from "commander";
93652
93785
  function ShareCommand() {
93653
- const cmd2 = new Command25("share");
93786
+ const cmd2 = new Command26("share");
93654
93787
  cmd2.description("Share an OpenAPI file");
93655
93788
  cmd2.argument("[file]", "file to share");
93656
93789
  cmd2.option(
@@ -93709,13 +93842,13 @@ function ShareCommand() {
93709
93842
 
93710
93843
  // src/domains/document/upgrade/index.ts
93711
93844
  var import_yaml5 = __toESM(require_dist(), 1);
93712
- import fs10 from "node:fs/promises";
93845
+ import fs11 from "node:fs/promises";
93713
93846
  import { confirm as confirm2 } from "@clack/prompts";
93714
93847
  import as22 from "ansis";
93715
- import { Command as Command26 } from "commander";
93848
+ import { Command as Command27 } from "commander";
93716
93849
  import { normalize as normalize5, upgrade } from "@scalar/openapi-parser";
93717
93850
  function UpgradeCommand() {
93718
- const cmd2 = new Command26("upgrade");
93851
+ const cmd2 = new Command27("upgrade");
93719
93852
  cmd2.description("Upgrade OpenAPI document to version 3.1");
93720
93853
  cmd2.argument("[file|url]", "File or URL to validate");
93721
93854
  cmd2.option("-o, --output <file>", "Path to save the upgraded output file");
@@ -93744,7 +93877,7 @@ function UpgradeCommand() {
93744
93877
  () => upgrade(document2)
93745
93878
  );
93746
93879
  const isYaml = isYamlFileName(outputFileName);
93747
- await fs10.writeFile(
93880
+ await fs11.writeFile(
93748
93881
  outputFileName,
93749
93882
  isYaml ? import_yaml5.default.stringify(result.specification) : JSON.stringify(result.specification, null, 2)
93750
93883
  );
@@ -93757,13 +93890,13 @@ function UpgradeCommand() {
93757
93890
 
93758
93891
  // src/domains/document/validate/index.ts
93759
93892
  import as23 from "ansis";
93760
- import { Command as Command27 } from "commander";
93893
+ import { Command as Command28 } from "commander";
93761
93894
  import prettyjson from "prettyjson";
93762
93895
  import { bundle as bundle3 } from "@scalar/json-magic/bundle";
93763
93896
  import { fetchUrls as fetchUrls3, readFiles as readFiles3 } from "@scalar/json-magic/bundle/plugins/node";
93764
93897
  import { validate as validate2 } from "@scalar/openapi-parser";
93765
93898
  function ValidateCommand() {
93766
- const cmd2 = new Command27("validate");
93899
+ const cmd2 = new Command28("validate");
93767
93900
  cmd2.description("Validate an OpenAPI file");
93768
93901
  cmd2.argument("[file|url]", "File or URL to validate");
93769
93902
  cmd2.action(async (inputArgument) => {
@@ -93810,10 +93943,10 @@ function ValidateCommand() {
93810
93943
  // src/domains/document/void/index.ts
93811
93944
  import { serve as serve3 } from "@hono/node-server";
93812
93945
  import as24 from "ansis";
93813
- import { Command as Command28 } from "commander";
93946
+ import { Command as Command29 } from "commander";
93814
93947
  import { createVoidServer } from "@scalar/void-server";
93815
93948
  function VoidCommand() {
93816
- const cmd2 = new Command28("void");
93949
+ const cmd2 = new Command29("void");
93817
93950
  cmd2.description("Boot a server to mirror HTTP requests");
93818
93951
  cmd2.option("-o, --once", "run the server only once and exit after that");
93819
93952
  cmd2.option("-p, --port <port>", "set the HTTP port for the mock server");
@@ -93870,23 +94003,23 @@ var documentCommands = [
93870
94003
  LintCommand,
93871
94004
  UpgradeCommand
93872
94005
  ];
93873
- var documentDomain = new Command29("document");
94006
+ var documentDomain = new Command30("document");
93874
94007
  documentDomain.description("Manage local openapi file");
93875
94008
  documentCommands.forEach((command) => documentDomain.addCommand(command()));
93876
94009
  var document_default = documentDomain;
93877
94010
 
93878
94011
  // src/domains/project/index.ts
93879
- import { Command as Command37 } from "commander";
94012
+ import { Command as Command38 } from "commander";
93880
94013
 
93881
94014
  // src/domains/project/preview/index.ts
93882
94015
  import { text as text4 } from "@clack/prompts";
93883
94016
  import as27 from "ansis";
93884
- import { Command as Command32 } from "commander";
94017
+ import { Command as Command33 } from "commander";
93885
94018
 
93886
94019
  // src/domains/project/check-config/index.ts
93887
- import fs12 from "node:fs";
94020
+ import fs13 from "node:fs";
93888
94021
  import as25 from "ansis";
93889
- import { Command as Command30 } from "commander";
94022
+ import { Command as Command31 } from "commander";
93890
94023
 
93891
94024
  // ../../packages/helpers/dist/parse/parse.js
93892
94025
  var import_json5 = __toESM(require_lib(), 1);
@@ -94517,6 +94650,9 @@ var linkSchema2 = zod_default.object({
94517
94650
  var headerSpacerSchema = zod_default.object({
94518
94651
  type: zod_default.literal("spacer")
94519
94652
  });
94653
+ var headerVersionSelectorSchema = zod_default.object({
94654
+ type: zod_default.literal("version-selector").describe("Renders the version selector dropdown at this position in the header")
94655
+ });
94520
94656
  var headerItem = zod_default.discriminatedUnion("type", [
94521
94657
  linkSchema2,
94522
94658
  headerSpacerSchema
@@ -94529,7 +94665,8 @@ var headerGroupSchema = zod_default.object({
94529
94665
  });
94530
94666
  var headerItemSchema = zod_default.discriminatedUnion("type", [
94531
94667
  headerItem,
94532
- headerGroupSchema
94668
+ headerGroupSchema,
94669
+ headerVersionSelectorSchema
94533
94670
  ]);
94534
94671
 
94535
94672
  // ../../packages/scalar-config/dist/schema/navigation/navigation.js
@@ -95162,7 +95299,7 @@ function generateGuideHeader({ header, guides, invalidRefs, references, isGroup
95162
95299
  invalidRefs,
95163
95300
  references,
95164
95301
  isGroup: true
95165
- }).filter((item2) => item2.type !== "group")
95302
+ }).filter((item2) => item2.type !== "group" && item2.type !== "version-selector")
95166
95303
  });
95167
95304
  }
95168
95305
  if (item.type === "guide") {
@@ -95197,6 +95334,11 @@ function generateGuideHeader({ header, guides, invalidRefs, references, isGroup
95197
95334
  type: "spacer"
95198
95335
  });
95199
95336
  }
95337
+ if (item.type === "version-selector") {
95338
+ headerItems.push({
95339
+ type: "version-selector"
95340
+ });
95341
+ }
95200
95342
  });
95201
95343
  if (!isGroup && !headerItems.some((item) => item.type === "spacer")) {
95202
95344
  headerItems.push({
@@ -95441,7 +95583,7 @@ var wysiwygProjectToV2 = n.safeFn(({ project, invalidRefs, theme }) => {
95441
95583
  }, (originalError) => createError("FAILED_TO_CONVERT_WYSIWYG_TO_V2", originalError));
95442
95584
 
95443
95585
  // src/domains/project/helpers.ts
95444
- import fs11 from "node:fs";
95586
+ import fs12 from "node:fs";
95445
95587
  import path5 from "node:path";
95446
95588
  var DEFAULT_MARKDOWN_FILE_NAME = "docs-quickstart.md";
95447
95589
  var DEFAULT_OPENAPI_FILE_NAME = "docs-openapi.json";
@@ -95453,7 +95595,7 @@ function findConfig(searchPath) {
95453
95595
  return searchInDirectory(process.cwd());
95454
95596
  }
95455
95597
  const searchPathResolved = path5.resolve(searchPath);
95456
- const stat = fs11.statSync(searchPathResolved, { throwIfNoEntry: false });
95598
+ const stat = fs12.statSync(searchPathResolved, { throwIfNoEntry: false });
95457
95599
  if (!stat) {
95458
95600
  return null;
95459
95601
  }
@@ -95470,7 +95612,7 @@ function getCurrentFolderName() {
95470
95612
  }
95471
95613
  function searchInDirectory(directory) {
95472
95614
  try {
95473
- const entries = fs11.readdirSync(directory);
95615
+ const entries = fs12.readdirSync(directory);
95474
95616
  for (const entry of entries) {
95475
95617
  if (entry === CONFIG_FILE_NAME || entry.startsWith(`${CONFIG_FILE_NAME}.`)) {
95476
95618
  return path5.join(directory, entry);
@@ -95496,7 +95638,7 @@ function readAndParseConfig(configPath) {
95496
95638
  }
95497
95639
  };
95498
95640
  }
95499
- const fileContent = fs12.readFileSync(file2, "utf-8");
95641
+ const fileContent = fs13.readFileSync(file2, "utf-8");
95500
95642
  const parseConfigResult = parseConfig(fileContent);
95501
95643
  if (!parseConfigResult.success) {
95502
95644
  return {
@@ -95516,7 +95658,7 @@ function readAndParseConfig(configPath) {
95516
95658
  };
95517
95659
  }
95518
95660
  function CheckConfigCommand() {
95519
- const cmd2 = new Command30("check-config");
95661
+ const cmd2 = new Command31("check-config");
95520
95662
  cmd2.description("Check a Scalar Configuration file");
95521
95663
  cmd2.argument("[file]", "File to check");
95522
95664
  cmd2.action(async (inputArgument) => {
@@ -95562,12 +95704,12 @@ import path7 from "node:path";
95562
95704
 
95563
95705
  // src/domains/project/download-isolate/index.ts
95564
95706
  import { execFile } from "node:child_process";
95565
- import fs13 from "node:fs/promises";
95707
+ import fs14 from "node:fs/promises";
95566
95708
  import os2 from "node:os";
95567
95709
  import path6 from "node:path";
95568
95710
  import { Readable } from "node:stream";
95569
95711
  import zlib from "node:zlib";
95570
- import { Command as Command31 } from "commander";
95712
+ import { Command as Command32 } from "commander";
95571
95713
  import tar from "tar-fs";
95572
95714
 
95573
95715
  // src/helpers/run-command.ts
@@ -95591,7 +95733,7 @@ var ISOLATE_EXTRACTION_DIR = path6.join(os2.homedir(), ".scalar");
95591
95733
  var ISOLATE_DIR = path6.join(ISOLATE_EXTRACTION_DIR, "isolate");
95592
95734
  async function getExistingIsolateVersion() {
95593
95735
  try {
95594
- const packageJsonString = await fs13.readFile(
95736
+ const packageJsonString = await fs14.readFile(
95595
95737
  path6.join(ISOLATE_DIR, "package.json"),
95596
95738
  "utf8"
95597
95739
  );
@@ -95646,7 +95788,7 @@ Remove-Item $tempFile
95646
95788
  async function downloadIsolate() {
95647
95789
  const existingIsolateVersion = await getExistingIsolateVersion();
95648
95790
  if (config2.ssgDocsIsolateVersion === existingIsolateVersion) return;
95649
- await fs13.rm(ISOLATE_EXTRACTION_DIR, { force: true, recursive: true });
95791
+ await fs14.rm(ISOLATE_EXTRACTION_DIR, { force: true, recursive: true });
95650
95792
  const logger = output.info({ animate: true }).loader("Downloading docs isolate. This may take a minute...");
95651
95793
  const ISOLATE_URL = `${config2.cdnUrl}/isolates/${config2.ssgDocsIsolateVersion}-isolate.tar.gz`;
95652
95794
  if (process.platform === "win32") {
@@ -95663,7 +95805,7 @@ async function downloadIsolate() {
95663
95805
  logger.finish();
95664
95806
  }
95665
95807
  var DownloadIsolateCommand = () => {
95666
- const cmd2 = new Command31("download-isolate");
95808
+ const cmd2 = new Command32("download-isolate");
95667
95809
  cmd2.description("Download the docs isolate");
95668
95810
  cmd2.action(async () => {
95669
95811
  await downloadIsolate();
@@ -95721,7 +95863,7 @@ async function previewV2Project({
95721
95863
 
95722
95864
  // src/domains/project/preview/index.ts
95723
95865
  var PreviewCommand = () => {
95724
- const cmd2 = new Command32("preview");
95866
+ const cmd2 = new Command33("preview");
95725
95867
  cmd2.description("Preview scalar guides");
95726
95868
  cmd2.argument(
95727
95869
  "[config]",
@@ -95814,9 +95956,9 @@ var PreviewCommand = () => {
95814
95956
  // src/domains/project/create/index.ts
95815
95957
  import { text as text5 } from "@clack/prompts";
95816
95958
  import as28 from "ansis";
95817
- import { Command as Command33 } from "commander";
95959
+ import { Command as Command34 } from "commander";
95818
95960
  var CreateCommand = () => {
95819
- const cmd2 = new Command33("create");
95961
+ const cmd2 = new Command34("create");
95820
95962
  cmd2.description(
95821
95963
  "Create a new project that is not linked to a github project."
95822
95964
  );
@@ -95861,11 +96003,11 @@ Project slug: ${as28.cyan(response.data.slug)}`
95861
96003
  };
95862
96004
 
95863
96005
  // src/domains/project/init/index.ts
95864
- import fs14 from "node:fs/promises";
96006
+ import fs15 from "node:fs/promises";
95865
96007
  import path8 from "node:path";
95866
96008
  import { cancel, confirm as confirm3, isCancel, text as text6 } from "@clack/prompts";
95867
96009
  import as29 from "ansis";
95868
- import { Command as Command34 } from "commander";
96010
+ import { Command as Command35 } from "commander";
95869
96011
 
95870
96012
  // ../../node_modules/.pnpm/@scalar+galaxy@0.6.7/node_modules/@scalar/galaxy/dist/3.1.json
95871
96013
  var __default = {
@@ -97823,14 +97965,14 @@ We're here to help:
97823
97965
  // src/domains/project/init/index.ts
97824
97966
  async function fileExists2(path13) {
97825
97967
  try {
97826
- await fs14.access(path13, fs14.constants.F_OK);
97968
+ await fs15.access(path13, fs15.constants.F_OK);
97827
97969
  return true;
97828
97970
  } catch {
97829
97971
  return false;
97830
97972
  }
97831
97973
  }
97832
97974
  var InitCommand = () => {
97833
- const cmd2 = new Command34("init");
97975
+ const cmd2 = new Command35("init");
97834
97976
  cmd2.description("Create a new Scalar Docs project.");
97835
97977
  cmd2.option("-s, --subdomain [url]", "subdomain to publish on");
97836
97978
  cmd2.option("--force", "override existing configuration");
@@ -97919,12 +98061,12 @@ var InitCommand = () => {
97919
98061
  }
97920
98062
  configuration.siteConfig.subdomain = subdomain.trim();
97921
98063
  const content = JSON.stringify(configuration, null, 2);
97922
- await fs14.writeFile(configFile, content);
97923
- await fs14.writeFile(
98064
+ await fs15.writeFile(configFile, content);
98065
+ await fs15.writeFile(
97924
98066
  path8.join(currentDir, DEFAULT_MARKDOWN_FILE_NAME),
97925
98067
  quickstartMarkdown
97926
98068
  );
97927
- await fs14.writeFile(
98069
+ await fs15.writeFile(
97928
98070
  path8.join(currentDir, DEFAULT_OPENAPI_FILE_NAME),
97929
98071
  JSON.stringify(__default, null, 2)
97930
98072
  );
@@ -97941,12 +98083,12 @@ var InitCommand = () => {
97941
98083
  };
97942
98084
 
97943
98085
  // src/domains/project/publish/index.ts
97944
- import fs16 from "node:fs";
98086
+ import fs17 from "node:fs";
97945
98087
  import { dirname } from "node:path";
97946
- import { Command as Command35 } from "commander";
98088
+ import { Command as Command36 } from "commander";
97947
98089
 
97948
98090
  // src/domains/project/publish/publish.ts
97949
- import fs15 from "node:fs";
98091
+ import fs16 from "node:fs";
97950
98092
  import path9 from "node:path";
97951
98093
  import { Readable as Readable2 } from "node:stream";
97952
98094
  import ignore from "ignore";
@@ -97957,7 +98099,7 @@ function isErrnoException(error48) {
97957
98099
  }
97958
98100
  async function readGitIgnore(configDir) {
97959
98101
  try {
97960
- const gitignore = await fs15.promises.readFile(
98102
+ const gitignore = await fs16.promises.readFile(
97961
98103
  path9.resolve(configDir, ".gitignore"),
97962
98104
  "utf8"
97963
98105
  );
@@ -98069,7 +98211,7 @@ var sleep = (ms) => {
98069
98211
 
98070
98212
  // src/domains/project/publish/index.ts
98071
98213
  var PublishCommand = () => {
98072
- const cmd2 = new Command35("publish");
98214
+ const cmd2 = new Command36("publish");
98073
98215
  cmd2.description(
98074
98216
  "Publish new build for a github sync project that is not linked."
98075
98217
  );
@@ -98150,10 +98292,10 @@ var PublishCommand = () => {
98150
98292
  });
98151
98293
  }
98152
98294
  const configPath = configPathOption ?? findConfig();
98153
- if (!configPath || !fs16.existsSync(configPath)) {
98295
+ if (!configPath || !fs17.existsSync(configPath)) {
98154
98296
  return output.error().title("Invalid configuration file").message("Could not find the Scalar Configuration file:").message(configPath ?? "").exit("error");
98155
98297
  }
98156
- const rawConfig = fs16.readFileSync(configPath, "utf-8");
98298
+ const rawConfig = fs17.readFileSync(configPath, "utf-8");
98157
98299
  const configParseResult = parseConfig(rawConfig);
98158
98300
  if (!configParseResult.success) {
98159
98301
  return output.error().title("Invalid configuration file").line(
@@ -98237,11 +98379,11 @@ async function getDeployStatus({
98237
98379
  }
98238
98380
 
98239
98381
  // src/domains/project/upgrade/index.ts
98240
- import fs17 from "node:fs/promises";
98382
+ import fs18 from "node:fs/promises";
98241
98383
  import path10 from "node:path";
98242
98384
  import { text as text7 } from "@clack/prompts";
98243
98385
  import as30 from "ansis";
98244
- import { Command as Command36 } from "commander";
98386
+ import { Command as Command37 } from "commander";
98245
98387
  import { n as n2 } from "neverpanic";
98246
98388
 
98247
98389
  // src/errors.ts
@@ -98270,7 +98412,7 @@ function displayError(error48, fallback = "Unknown error occurred. Please contac
98270
98412
 
98271
98413
  // src/domains/project/upgrade/index.ts
98272
98414
  var UpgradeCommand2 = () => {
98273
- const cmd2 = new Command36("upgrade");
98415
+ const cmd2 = new Command37("upgrade");
98274
98416
  cmd2.description("Upgrade scalar project");
98275
98417
  cmd2.argument(
98276
98418
  "[config]",
@@ -98326,7 +98468,7 @@ var UpgradeCommand2 = () => {
98326
98468
  const { upgradedConfig, legacyTheme, legacyFooter, legacyScript } = upgradedConfigResult.data;
98327
98469
  if (legacyTheme) {
98328
98470
  const writeUpgradedThemeResult = await n2.fromUnsafe(
98329
- () => fs17.writeFile(
98471
+ () => fs18.writeFile(
98330
98472
  path10.resolve(
98331
98473
  path10.dirname(parseConfigResult.filePath),
98332
98474
  config3.root ?? "./",
@@ -98342,7 +98484,7 @@ var UpgradeCommand2 = () => {
98342
98484
  }
98343
98485
  if (legacyFooter) {
98344
98486
  const writeUpgradedFooterResult = await n2.fromUnsafe(
98345
- () => fs17.writeFile(
98487
+ () => fs18.writeFile(
98346
98488
  path10.resolve(
98347
98489
  path10.dirname(parseConfigResult.filePath),
98348
98490
  config3.root ?? "./",
@@ -98358,7 +98500,7 @@ var UpgradeCommand2 = () => {
98358
98500
  }
98359
98501
  if (legacyScript) {
98360
98502
  const writeUpgradedScriptResult = await n2.fromUnsafe(
98361
- () => fs17.writeFile(
98503
+ () => fs18.writeFile(
98362
98504
  path10.resolve(
98363
98505
  path10.dirname(parseConfigResult.filePath),
98364
98506
  config3.root ?? "./",
@@ -98373,7 +98515,7 @@ var UpgradeCommand2 = () => {
98373
98515
  }
98374
98516
  }
98375
98517
  const writeUpgradedConfigResult = await n2.fromUnsafe(
98376
- () => fs17.writeFile(
98518
+ () => fs18.writeFile(
98377
98519
  parseConfigResult.filePath,
98378
98520
  JSON.stringify(upgradedConfig, null, 2)
98379
98521
  ),
@@ -98396,22 +98538,22 @@ var projectCommands = [
98396
98538
  PublishCommand,
98397
98539
  UpgradeCommand2
98398
98540
  ];
98399
- var projectDomain = new Command37("project");
98541
+ var projectDomain = new Command38("project");
98400
98542
  projectDomain.description("Manage scalar project");
98401
98543
  projectCommands.forEach((command) => projectDomain.addCommand(command()));
98402
98544
  projectDomain.addCommand(DownloadIsolateCommand(), { hidden: true });
98403
98545
  var project_default = projectDomain;
98404
98546
 
98405
98547
  // src/domains/readme/index.ts
98406
- import { Command as Command39 } from "commander";
98548
+ import { Command as Command40 } from "commander";
98407
98549
 
98408
98550
  // src/domains/readme/generate.ts
98409
98551
  import { text as text8 } from "@clack/prompts";
98410
98552
  import as31 from "ansis";
98411
- import { Command as Command38 } from "commander";
98553
+ import { Command as Command39 } from "commander";
98412
98554
 
98413
98555
  // src/helpers/documentation/index.ts
98414
- import fs18 from "node:fs/promises";
98556
+ import fs19 from "node:fs/promises";
98415
98557
  import path11 from "node:path";
98416
98558
  var generateDocs = (command, depth = 0) => {
98417
98559
  if (command._hidden) return [];
@@ -98441,13 +98583,13 @@ ${docs.content}${codeBlock}`);
98441
98583
  };
98442
98584
  var generateDocumentationFile = async (outputPath) => {
98443
98585
  const commandDocumentation = generateCommandDocumentation(getProgram());
98444
- const template = await fs18.readFile(
98586
+ const template = await fs19.readFile(
98445
98587
  path11.join(import.meta.dirname, "template.md"),
98446
98588
  {
98447
98589
  encoding: "utf-8"
98448
98590
  }
98449
98591
  );
98450
- await fs18.writeFile(
98592
+ await fs19.writeFile(
98451
98593
  outputPath,
98452
98594
  template.replace("<COMMANDS>", commandDocumentation)
98453
98595
  );
@@ -98455,7 +98597,7 @@ var generateDocumentationFile = async (outputPath) => {
98455
98597
 
98456
98598
  // src/domains/readme/generate.ts
98457
98599
  function GenerateReadmeCommand() {
98458
- const cmd2 = new Command38("generate");
98600
+ const cmd2 = new Command39("generate");
98459
98601
  cmd2.description("Self generate documentation for the cli");
98460
98602
  cmd2.option(
98461
98603
  "-o, --output [file]",
@@ -98488,12 +98630,12 @@ function GenerateReadmeCommand() {
98488
98630
  }
98489
98631
 
98490
98632
  // src/domains/readme/serve.ts
98491
- import fs19 from "node:fs/promises";
98633
+ import fs20 from "node:fs/promises";
98492
98634
  import path12 from "node:path";
98493
98635
  import as32 from "ansis";
98494
98636
  var fileExists3 = async (filePath) => {
98495
98637
  try {
98496
- await fs19.access(filePath);
98638
+ await fs20.access(filePath);
98497
98639
  return true;
98498
98640
  } catch {
98499
98641
  return false;
@@ -98518,23 +98660,23 @@ function ServeReadmeCommand(cmd2) {
98518
98660
  }
98519
98661
 
98520
98662
  // src/domains/readme/index.ts
98521
- var readmeDomain = new Command39("readme");
98663
+ var readmeDomain = new Command40("readme");
98522
98664
  readmeDomain.addCommand(GenerateReadmeCommand());
98523
98665
  ServeReadmeCommand(readmeDomain);
98524
98666
  var readme_default = readmeDomain;
98525
98667
 
98526
98668
  // src/domains/registry/index.ts
98527
- import { Command as Command45 } from "commander";
98669
+ import { Command as Command46 } from "commander";
98528
98670
 
98529
98671
  // src/domains/registry/publish/index.ts
98530
98672
  import { text as text9 } from "@clack/prompts";
98531
98673
  import as33 from "ansis";
98532
- import { Command as Command40 } from "commander";
98674
+ import { Command as Command41 } from "commander";
98533
98675
  import { bundle as bundle4 } from "@scalar/json-magic/bundle";
98534
98676
  import { fetchUrls as fetchUrls4, readFiles as readFiles4 } from "@scalar/json-magic/bundle/plugins/node";
98535
98677
  import { parseJsonOrYaml as parseJsonOrYaml2 } from "@scalar/oas-utils/helpers";
98536
98678
  var PublishCommand2 = () => {
98537
- const cmd2 = new Command40("publish");
98679
+ const cmd2 = new Command41("publish");
98538
98680
  cmd2.description("Publish an OpenAPI document to the Scalar registry");
98539
98681
  cmd2.argument("[file]", "OpenAPI file to upload");
98540
98682
  cmd2.option(
@@ -98677,9 +98819,9 @@ var PublishCommand2 = () => {
98677
98819
  };
98678
98820
 
98679
98821
  // src/domains/registry/delete/index.ts
98680
- import { Command as Command41 } from "commander";
98822
+ import { Command as Command42 } from "commander";
98681
98823
  var DeleteCommand = () => {
98682
- const cmd2 = new Command41("delete");
98824
+ const cmd2 = new Command42("delete");
98683
98825
  cmd2.description("Delete a document from scalar registry");
98684
98826
  cmd2.argument("[namespace]", "Team namespace");
98685
98827
  cmd2.argument("[slug]", "Managed doc slug");
@@ -98696,11 +98838,11 @@ var DeleteCommand = () => {
98696
98838
  };
98697
98839
 
98698
98840
  // src/domains/registry/get/index.ts
98699
- import fs20 from "node:fs";
98700
- import { Command as Command42 } from "commander";
98701
- var versionSchema3 = external_exports.union([docVersionSchema, external_exports.literal("latest")]);
98841
+ import fs21 from "node:fs/promises";
98842
+ import { Command as Command43 } from "commander";
98843
+ var versionSchema4 = external_exports.union([docVersionSchema, external_exports.literal("latest")]);
98702
98844
  var GetCommand = () => {
98703
- const cmd2 = new Command42("get");
98845
+ const cmd2 = new Command43("get");
98704
98846
  cmd2.description("Get a document version from scalar registry");
98705
98847
  cmd2.argument("[namespace]", "Team namespace");
98706
98848
  cmd2.argument("[slug]", "Managed doc slug");
@@ -98717,7 +98859,7 @@ var GetCommand = () => {
98717
98859
  return;
98718
98860
  }
98719
98861
  const result = external_exports.object({
98720
- version: versionSchema3,
98862
+ version: versionSchema4,
98721
98863
  format: external_exports.enum(["json", "yaml"]),
98722
98864
  output: external_exports.string().min(1).optional()
98723
98865
  }).safeParse({
@@ -98731,38 +98873,28 @@ var GetCommand = () => {
98731
98873
  }
98732
98874
  const auth = await getAuthData();
98733
98875
  auth.addEventListener((state) => Object.assign(auth, state));
98734
- const registryDocumentUrl = registryUrl(
98876
+ const fetchResult = await fetchFromRegistry(
98735
98877
  registry2(namespace).apis(slug).url({
98736
98878
  version: result.data.version,
98737
98879
  format: result.data.format
98738
- })
98880
+ }),
98881
+ auth.accessToken
98739
98882
  );
98740
- let getDocument;
98741
- try {
98742
- getDocument = await fetch(registryDocumentUrl, {
98743
- headers: {
98744
- "x-scalar-auth": auth.accessToken
98745
- },
98746
- // Should always error on redirect
98747
- redirect: "error"
98748
- });
98749
- } catch (error48) {
98750
- const message = error48 instanceof Error && error48.message.length > 0 ? error48.message : "Registry request failed before a response was received.";
98751
- output.error().title("Unable to download document").message(message).exit("error");
98752
- return;
98753
- }
98754
- if (!getDocument.ok) {
98755
- const message = await getDocument.text();
98756
- output.error().title("Unable to download document").message(
98757
- message.length ? message : `Registry request failed with status ${getDocument.status}.`
98758
- ).exit("error");
98883
+ if (fetchResult.error) {
98884
+ output.error().title("Unable to download document").message(fetchResult.message).exit("error");
98759
98885
  return;
98760
98886
  }
98761
- const document2 = await getDocument.text();
98887
+ const document2 = fetchResult.data;
98762
98888
  const withTrailingNewline = document2.endsWith("\n") ? document2 : `${document2}
98763
98889
  `;
98764
98890
  if (result.data.output) {
98765
- fs20.writeFileSync(result.data.output, withTrailingNewline, "utf8");
98891
+ try {
98892
+ await fs21.writeFile(result.data.output, withTrailingNewline, "utf8");
98893
+ } catch (error48) {
98894
+ const message = error48 instanceof Error && error48.message.length > 0 ? error48.message : `Could not write to ${result.data.output}.`;
98895
+ output.error().title("Unable to write document to file").message(message).exit("error");
98896
+ return;
98897
+ }
98766
98898
  output.info().line(
98767
98899
  `Downloaded ${namespace}/${slug}@${result.data.version} (${result.data.format})`
98768
98900
  ).line(`Written to ${result.data.output}`).print();
@@ -98775,9 +98907,9 @@ var GetCommand = () => {
98775
98907
 
98776
98908
  // src/domains/registry/list/index.ts
98777
98909
  import as34 from "ansis";
98778
- import { Command as Command43 } from "commander";
98910
+ import { Command as Command44 } from "commander";
98779
98911
  var ListCommand = () => {
98780
- const cmd2 = new Command43("list");
98912
+ const cmd2 = new Command44("list");
98781
98913
  cmd2.description("List all registry APIs for a team namespace");
98782
98914
  cmd2.option("--namespace <namespace>", "Team namespace");
98783
98915
  cmd2.action(async (args) => {
@@ -98836,9 +98968,9 @@ var ListCommand = () => {
98836
98968
  // src/domains/registry/update/index.ts
98837
98969
  import { text as text10 } from "@clack/prompts";
98838
98970
  import as35 from "ansis";
98839
- import { Command as Command44 } from "commander";
98971
+ import { Command as Command45 } from "commander";
98840
98972
  var UpdateCommand = () => {
98841
- const cmd2 = new Command44("update");
98973
+ const cmd2 = new Command45("update");
98842
98974
  cmd2.description("Update document metadata on scalar registry");
98843
98975
  cmd2.argument("[namespace]", "namespace of document you want to update");
98844
98976
  cmd2.argument("[slug]", "slug of document you want to update");
@@ -98892,17 +99024,17 @@ var registryCommands = [
98892
99024
  ListCommand,
98893
99025
  GetCommand
98894
99026
  ];
98895
- var registryDomain = new Command45("registry");
99027
+ var registryDomain = new Command46("registry");
98896
99028
  registryDomain.description("Manage your scalar registry");
98897
99029
  registryCommands.forEach((command) => registryDomain.addCommand(command()));
98898
99030
  var registry_default = registryDomain;
98899
99031
 
98900
99032
  // src/domains/team/index.ts
98901
- import { Command as Command48 } from "commander";
99033
+ import { Command as Command49 } from "commander";
98902
99034
 
98903
99035
  // src/domains/team/list/index.ts
98904
99036
  import as36 from "ansis";
98905
- import { Command as Command46 } from "commander";
99037
+ import { Command as Command47 } from "commander";
98906
99038
 
98907
99039
  // src/domains/team/helpers.ts
98908
99040
  var getUserTeams = async (client, email3) => {
@@ -98917,7 +99049,7 @@ var getUserTeams = async (client, email3) => {
98917
99049
 
98918
99050
  // src/domains/team/list/index.ts
98919
99051
  var ListCommand2 = () => {
98920
- const cmd2 = new Command46("list");
99052
+ const cmd2 = new Command47("list");
98921
99053
  cmd2.description("List all teams current user is part of");
98922
99054
  cmd2.action(async () => {
98923
99055
  const auth = await getAuthData();
@@ -98943,9 +99075,9 @@ var ListCommand2 = () => {
98943
99075
  // src/domains/team/set/index.ts
98944
99076
  import { select as select7 } from "@clack/prompts";
98945
99077
  import as37 from "ansis";
98946
- import { Command as Command47 } from "commander";
99078
+ import { Command as Command48 } from "commander";
98947
99079
  var SetCommand = () => {
98948
- const cmd2 = new Command47("set");
99080
+ const cmd2 = new Command48("set");
98949
99081
  cmd2.description("Set current active team for the user");
98950
99082
  cmd2.option("--team <team>", "Team uid");
98951
99083
  cmd2.action(async ({ team }) => {
@@ -98985,7 +99117,7 @@ var SetCommand = () => {
98985
99117
 
98986
99118
  // src/domains/team/index.ts
98987
99119
  var teamCommands = [ListCommand2, SetCommand];
98988
- var teamDomain = new Command48("team");
99120
+ var teamDomain = new Command49("team");
98989
99121
  teamDomain.description("Manage user teams");
98990
99122
  teamCommands.forEach((command) => teamDomain.addCommand(command()));
98991
99123
  var team_default = teamDomain;
@@ -98993,7 +99125,7 @@ var team_default = teamDomain;
98993
99125
  // src/domains/upgrade/index.ts
98994
99126
  import { execSync } from "node:child_process";
98995
99127
  import as39 from "ansis";
98996
- import { Command as Command49 } from "commander";
99128
+ import { Command as Command50 } from "commander";
98997
99129
 
98998
99130
  // src/helpers/upgrade.ts
98999
99131
  import as38 from "ansis";
@@ -99049,7 +99181,7 @@ async function checkUpgrade() {
99049
99181
  }
99050
99182
 
99051
99183
  // src/domains/upgrade/index.ts
99052
- var cmd = new Command49("upgrade");
99184
+ var cmd = new Command50("upgrade");
99053
99185
  cmd.description("Upgrade current version of your cli");
99054
99186
  cmd.action(async () => {
99055
99187
  const upgradeStatus = await getUpgradeInformation();
@@ -99087,7 +99219,7 @@ var domains_default = domains;
99087
99219
 
99088
99220
  // src/program.ts
99089
99221
  var getProgram = () => {
99090
- const program2 = new Command50();
99222
+ const program2 = new Command51();
99091
99223
  program2.enablePositionalOptions().name(Object.keys(bin)[0]).description("CLI to work with your OpenAPI files").version(version, "-v, --version");
99092
99224
  program2.showHelpAfterError();
99093
99225
  domains_default.forEach((domain2) => program2.addCommand(domain2));