@scalar/cli 2.12.3 → 2.13.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 (76) hide show
  1. package/README.md +221 -2
  2. package/chunks/{action-JXCU2JKC.js → action-27BJMHFD.js} +38 -6
  3. package/chunks/{action-H4GW3KAI.js → action-4EJA6UEB.js} +7 -7
  4. package/chunks/{action-7CUPRYNA.js → action-5MJTAO5X.js} +29 -16
  5. package/chunks/{action-AYKKHH7A.js → action-6FPGU5SY.js} +44 -17
  6. package/chunks/{action-T4MM4OUS.js → action-6RQDLMOM.js} +42 -19
  7. package/chunks/{action-Y7EBKCUU.js → action-ASBFLTOA.js} +1 -1
  8. package/chunks/{action-6I2PWENU.js → action-AWHBOHGW.js} +60 -81
  9. package/chunks/{action-O7ROX6NF.js → action-ENN7KFBZ.js} +9 -8
  10. package/chunks/{action-M5OUEDV2.js → action-ESVI46KE.js} +4 -4
  11. package/chunks/{action-I2IV4VLL.js → action-EVNUUWR5.js} +23 -7
  12. package/chunks/{action-B74PPGKB.js → action-F6JSCBEU.js} +31 -13
  13. package/chunks/{action-KIOYSVKX.js → action-FZNFBX6U.js} +20 -3
  14. package/chunks/{action-VVKMUOKR.js → action-GNYNOFDK.js} +13 -5
  15. package/chunks/{action-GMJJMZXY.js → action-JSYHIEYP.js} +5 -5
  16. package/chunks/action-KTY5ICV5.js +55 -0
  17. package/chunks/{action-YXRCGKCK.js → action-LVYFHK4D.js} +3 -1
  18. package/chunks/{action-ZBEOLJJR.js → action-NN7QF6MI.js} +6 -3
  19. package/chunks/{action-EWZLVN45.js → action-OD4GNHM3.js} +37 -17
  20. package/chunks/{action-4ESHWOAM.js → action-OZWRV54F.js} +6 -5
  21. package/chunks/{action-BYYKW4S6.js → action-QZV6IPK4.js} +25 -10
  22. package/chunks/{action-D7L757PX.js → action-S7PMEFCE.js} +13 -12
  23. package/chunks/{action-Q3DI54OW.js → action-SZ6SG3RB.js} +6 -6
  24. package/chunks/{action-FBQAU5LV.js → action-U3MQZ5ZQ.js} +5 -5
  25. package/chunks/{action-BDDXF4YV.js → action-UAGYB4ZS.js} +18 -8
  26. package/chunks/{action-HAKFAXTQ.js → action-UVAYACFA.js} +4 -4
  27. package/chunks/{action-6A4NM5WS.js → action-VXEJNBNR.js} +6 -5
  28. package/chunks/{action-ZOYQBWGD.js → action-W24B4YT5.js} +6 -6
  29. package/chunks/{action-GJHOZ6Q5.js → action-WQICTF7K.js} +7 -5
  30. package/chunks/{action-EWDQOX5B.js → action-WUWWJGRJ.js} +3 -1
  31. package/chunks/{action-ED4TSPRZ.js → action-Y4YLWZHL.js} +5 -5
  32. package/chunks/{action-FBOTIFVC.js → action-YEAOKB6V.js} +9 -7
  33. package/chunks/{action-EPGS3U3T.js → action-YFTRHKOK.js} +56 -41
  34. package/chunks/{action-5BJL72JE.js → action-YQSSXJAX.js} +7 -4
  35. package/chunks/{action-RPTLQBMK.js → action-ZL2CXRJR.js} +5 -3
  36. package/chunks/{actions-EXQNVV4T.js → actions-GHHWF4Q2.js} +13 -11
  37. package/chunks/{asyncapi-FNOWXSKB.js → asyncapi-TICSLZRM.js} +6 -4
  38. package/chunks/{build.action-TIKRZPQ5.js → build.action-AURC6QZ6.js} +28 -11
  39. package/chunks/chunk-2XWUFFEZ.js +133 -0
  40. package/chunks/{chunk-I7ZVWF57.js → chunk-7K6I2GUG.js} +14 -8
  41. package/chunks/{chunk-LEECPQZN.js → chunk-7O5H2SQP.js} +1 -1
  42. package/chunks/{chunk-EBNFCIKS.js → chunk-APX65SRT.js} +2 -1
  43. package/chunks/{chunk-UN2AAVO5.js → chunk-B3XOSR6W.js} +1 -1
  44. package/chunks/{chunk-FYMDIB7J.js → chunk-CSJIKXUD.js} +1 -1
  45. package/chunks/{chunk-FI7UKPRF.js → chunk-DDDYR2HF.js} +1 -1
  46. package/chunks/chunk-IRQJDPZE.js +34 -0
  47. package/chunks/chunk-LK2ZIDHH.js +32 -0
  48. package/chunks/{chunk-IOW726L2.js → chunk-NRHHB3YY.js} +1 -1
  49. package/chunks/{chunk-JWNWOK2M.js → chunk-OVKTA5CX.js} +12 -5
  50. package/chunks/chunk-PVDORWEM.js +167 -0
  51. package/chunks/{chunk-V7RTDFHK.js → chunk-RAJM56L7.js} +5 -1
  52. package/chunks/{chunk-CUHVXHIV.js → chunk-RAU5KE6F.js} +1 -1
  53. package/chunks/chunk-SNQFFEYH.js +11 -0
  54. package/chunks/{chunk-EUFK4MVX.js → chunk-TKT5UW3G.js} +2 -2
  55. package/chunks/{chunk-2GKXAGSH.js → chunk-TVPVXL73.js} +2 -2
  56. package/chunks/{chunk-KWIY2QZY.js → chunk-VNF2GRZA.js} +2 -2
  57. package/chunks/chunk-WDFZ7WYJ.js +16 -0
  58. package/chunks/chunk-XUX6JXU5.js +58 -0
  59. package/chunks/{create.action-K7GTWYST.js → create.action-O3HN6GV2.js} +23 -14
  60. package/chunks/{delete.action-JKLXBYRD.js → delete.action-2L2RWLPI.js} +27 -13
  61. package/chunks/{delete.action-E4XRGKQW.js → delete.action-KEBI2QCS.js} +29 -13
  62. package/chunks/{get.action-2AKMD4W3.js → get.action-BUNTDW54.js} +9 -7
  63. package/chunks/{get.action-IY7WSJMX.js → get.action-WDMTCZZR.js} +6 -6
  64. package/chunks/{list.action-44YVCWKN.js → list.action-JNSEJVHX.js} +6 -6
  65. package/chunks/{list.action-NRL2DDL5.js → list.action-NSK7OBRH.js} +7 -7
  66. package/chunks/{publish.action-E76MHLCN.js → publish.action-ZRZQUL7S.js} +38 -18
  67. package/chunks/{update.action-LZCAHAWW.js → update.action-7TA46AE6.js} +27 -13
  68. package/chunks/{update.action-FTTVWVAB.js → update.action-O2R5ODGG.js} +38 -18
  69. package/index.js +210 -125
  70. package/package.json +1 -1
  71. package/skills/scalar-cli/SKILL.md +4 -2
  72. package/template.md +220 -1
  73. package/chunks/chunk-BOPEAS7H.js +0 -38
  74. package/chunks/chunk-EGOXR5FB.js +0 -15
  75. package/chunks/{action-UHXBY3RD.js → action-3P66ZSL3.js} +1 -1
  76. package/chunks/{chunk-OZQPMMTA.js → chunk-M2MMGSLK.js} +3 -3
@@ -0,0 +1,133 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ err,
4
+ ok
5
+ } from "./chunk-5ENKYZA4.js";
6
+
7
+ // src/helpers/input-error.ts
8
+ var causes = {
9
+ ERR_INVALID_URL: {
10
+ reason: "Invalid URL (ERR_INVALID_URL).",
11
+ recovery: "Provide a valid HTTP or HTTPS URL."
12
+ },
13
+ ENOENT: {
14
+ reason: "File not found (ENOENT).",
15
+ recovery: "Check that the file path exists."
16
+ },
17
+ EACCES: {
18
+ reason: "Permission denied (EACCES).",
19
+ recovery: "Check that you have permission to read the file."
20
+ },
21
+ EPERM: {
22
+ reason: "Operation not permitted (EPERM).",
23
+ recovery: "Check that you have permission to read the file."
24
+ },
25
+ EISDIR: {
26
+ reason: "The path is a directory (EISDIR).",
27
+ recovery: "Provide a file path instead of a directory."
28
+ },
29
+ ENOTDIR: {
30
+ reason: "A path component is not a directory (ENOTDIR).",
31
+ recovery: "Check the file path and its parent directories."
32
+ },
33
+ ENOTFOUND: {
34
+ reason: "Host not found (ENOTFOUND).",
35
+ recovery: "Check the URL hostname and your network connection."
36
+ },
37
+ EAI_AGAIN: {
38
+ reason: "DNS lookup failed (EAI_AGAIN).",
39
+ recovery: "Check your network and DNS settings before trying again."
40
+ },
41
+ ECONNREFUSED: {
42
+ reason: "Connection refused (ECONNREFUSED).",
43
+ recovery: "Check the host, port, and whether the server is running."
44
+ },
45
+ ECONNRESET: {
46
+ reason: "Connection reset (ECONNRESET).",
47
+ recovery: "Check your network connection and server availability before trying again."
48
+ },
49
+ ETIMEDOUT: {
50
+ reason: "Connection timed out (ETIMEDOUT).",
51
+ recovery: "Check your network connection and server availability before trying again."
52
+ },
53
+ UND_ERR_CONNECT_TIMEOUT: {
54
+ reason: "Connection timed out (UND_ERR_CONNECT_TIMEOUT).",
55
+ recovery: "Check your network connection and server availability before trying again."
56
+ },
57
+ UND_ERR_SOCKET: {
58
+ reason: "Connection interrupted (UND_ERR_SOCKET).",
59
+ recovery: "Check your network connection and server availability before trying again."
60
+ },
61
+ CERT_HAS_EXPIRED: {
62
+ reason: "The server certificate has expired (CERT_HAS_EXPIRED).",
63
+ recovery: "Ask the server owner to renew its TLS certificate."
64
+ },
65
+ DEPTH_ZERO_SELF_SIGNED_CERT: {
66
+ reason: "The server certificate is not trusted (DEPTH_ZERO_SELF_SIGNED_CERT).",
67
+ recovery: "Check the server certificate and your trusted certificate configuration."
68
+ }
69
+ };
70
+ function quoteInput(input) {
71
+ return JSON.stringify(input).replace(
72
+ /[\p{Cc}\p{Cf}]/gu,
73
+ (character) => character.split("").map((unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, "0")}`).join("")
74
+ );
75
+ }
76
+ function safeInput(input, kind) {
77
+ if (kind === "file" && !/^\s*[a-z][a-z\d+.-]*:\/\//i.test(input))
78
+ return quoteInput(input);
79
+ try {
80
+ const url = new URL(input);
81
+ url.username = "";
82
+ url.password = "";
83
+ url.search = "";
84
+ url.hash = "";
85
+ return quoteInput(url.toString());
86
+ } catch {
87
+ return "[invalid URL]";
88
+ }
89
+ }
90
+ function inputFailure(error, kind) {
91
+ for (let depth = 0, current = error; depth < 5; depth++) {
92
+ if (typeof current !== "object" || current === null) break;
93
+ if ("code" in current && typeof current.code === "string" && Object.hasOwn(causes, current.code)) {
94
+ const cause = causes[current.code];
95
+ return `${cause.reason} ${cause.recovery}`;
96
+ }
97
+ current = "cause" in current ? current.cause : void 0;
98
+ }
99
+ return kind === "file" ? "The file could not be read. Check the path and read permissions." : "The download failed. Check the URL, network connection, and server availability before trying again.";
100
+ }
101
+ function httpFailure(status, registry) {
102
+ const recovery = status === 401 ? registry ? "Run scalar auth login and check your access to this resource." : "Check the credentials required by this URL." : status === 403 ? "Check that you have access to this resource." : status === 404 ? registry ? "Check the namespace, slug, and version." : "Check that the URL points to an existing API description." : "Check the URL and server availability before trying again.";
103
+ return `HTTP ${status}. ${recovery}`;
104
+ }
105
+
106
+ // src/helpers/read-url.ts
107
+ var DOWNLOAD_TIMEOUT_MS = 1e4;
108
+ async function readUrl(input, registryAuth) {
109
+ const signal = AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS);
110
+ const context = safeInput(input, "url");
111
+ const failure = (error) => signal.aborted ? "The download timed out after 10 seconds. Check your network connection and server availability before trying again." : inputFailure(error, "url");
112
+ const response = await fetch(input, {
113
+ signal,
114
+ ...registryAuth ? {
115
+ headers: { "x-scalar-auth": registryAuth.accessToken },
116
+ redirect: "error"
117
+ } : {}
118
+ }).then(ok).catch((error) => err(`${context}: ${failure(error)}`));
119
+ if (!response.ok) return response;
120
+ const body = await response.data.text().then(ok).catch((error) => err(failure(error)));
121
+ if (!response.data.ok) {
122
+ return err(
123
+ `${context}: ${httpFailure(response.data.status, registryAuth !== void 0)}${body.ok ? "" : ` ${body.error}`}`
124
+ );
125
+ }
126
+ return body.ok ? body : err(`${context}: ${body.error}`);
127
+ }
128
+
129
+ export {
130
+ safeInput,
131
+ inputFailure,
132
+ readUrl
133
+ };
@@ -2,6 +2,11 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  safeNormalize
4
4
  } from "./chunk-WKW5W2ZP.js";
5
+ import {
6
+ inputFailure,
7
+ readUrl,
8
+ safeInput
9
+ } from "./chunk-2XWUFFEZ.js";
5
10
  import {
6
11
  isUrl
7
12
  } from "./chunk-4ORL4MST.js";
@@ -38,17 +43,18 @@ import fs from "node:fs";
38
43
  import as2 from "ansis";
39
44
  import { validate } from "@scalar/openapi-validator";
40
45
  var getFileOrUrl = async (input) => {
41
- if (isUrl(input)) {
42
- const response = await fetch(input);
43
- if (!response.ok) {
44
- return output.error().title("Could not fetch the API description from the URL").exit("error");
46
+ if (isUrl(input) || /^\s*https?:/i.test(input)) {
47
+ const result = await readUrl(input);
48
+ if (!result.ok) {
49
+ return output.error().title("Could not fetch the API description from the URL").message(result.error).exit("error");
45
50
  }
46
- return await response.text();
51
+ return result.data;
47
52
  }
48
- if (!fs.existsSync(input)) {
49
- return output.error().title("Could not read the API description file").exit("error");
53
+ try {
54
+ return fs.readFileSync(input, "utf-8");
55
+ } catch (error) {
56
+ return output.error().title("Could not read the API description file").message(`${safeInput(input, "file")}: ${inputFailure(error, "file")}`).exit("error");
50
57
  }
51
- return fs.readFileSync(input, "utf-8");
52
58
  };
53
59
  var loadOpenApiDocument = async (content) => {
54
60
  try {
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  config
4
- } from "./chunk-FYMDIB7J.js";
4
+ } from "./chunk-CSJIKXUD.js";
5
5
  import {
6
6
  RegistryAsset
7
7
  } from "./chunk-TYNF7ROW.js";
@@ -5,7 +5,8 @@ var AGENT_NOTES = [
5
5
  "Run `scalar <command>` when the CLI is installed, or `npx @scalar/cli <command>` when it is not.",
6
6
  "Run `scalar context` for this command tree as JSON, or `scalar <command> --help` for a single command.",
7
7
  "Log in with a personal token: `scalar auth login --token <token>`, or set `SCALAR_API_KEY` and run `scalar auth login`. Both store the session on disk for later commands. Without a token, `scalar auth login` opens a browser and waits for a person to log in, so do not run it that way. Check the session with `scalar auth whoami`.",
8
- "Many commands prompt when a value is left out, such as a slug, a team, or a confirmation before overwriting a file, and a prompt blocks a non-interactive run. Pass every value as an argument or flag: for example `--output` on `document bundle` and `document upgrade`, `--yes` on `project rollback`, and `--force` on `project init`.",
8
+ "Use --no-input before or after subcommands to disable prompts and browser launches, including under a PTY. Supply required values explicitly; missing inputs fail with exit code 1 and guidance. Piped input is never a confirmation. Cancelled prompts and EOF exit with code 1. The flag does not imply --yes or --force and neither option chooses an unspecified target.",
9
+ "Many commands prompt when a value is left out, such as a slug, a team, or a confirmation before overwriting a file, and missing values fail when interaction is disabled. Pass every value as an argument or flag: for example `--output` on `document bundle` and `document upgrade`, `--yes` on `project rollback`, and `--force` on `project init`.",
9
10
  "Results go to stdout. Errors go to stderr, prefixed with `[ERROR]`."
10
11
  ];
11
12
  var EXIT_CODES = {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-TI4NDKQC.js";
5
5
  import {
6
6
  getDatabaseClient
7
- } from "./chunk-JWNWOK2M.js";
7
+ } from "./chunk-OVKTA5CX.js";
8
8
  import {
9
9
  publishRecordSchema
10
10
  } from "./chunk-VRZSDUZK.js";
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  version
4
- } from "./chunk-IOW726L2.js";
4
+ } from "./chunk-NRHHB3YY.js";
5
5
 
6
6
  // src/config.ts
7
7
  import { portNumbers } from "get-port";
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  config
4
- } from "./chunk-FYMDIB7J.js";
4
+ } from "./chunk-CSJIKXUD.js";
5
5
  import {
6
6
  roleSchema
7
7
  } from "./chunk-F3TQHNSQ.js";
@@ -0,0 +1,34 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+
3
+ // src/helpers/input-policy.ts
4
+ import { AsyncLocalStorage } from "node:async_hooks";
5
+ import { Command } from "commander";
6
+ var policy = new AsyncLocalStorage();
7
+ var InputPolicyCommand = class extends Command {
8
+ parse(argv, options) {
9
+ return policy.run(false, () => super.parse(argv, options));
10
+ }
11
+ async parseAsync(argv, options) {
12
+ return policy.run(false, () => super.parseAsync(argv, options));
13
+ }
14
+ };
15
+ var isInputDisabled = () => policy.getStore() ?? false;
16
+ function configureInputPolicy(program) {
17
+ const register = (command) => {
18
+ if (!command.options.some((option) => option.long === "--no-input")) {
19
+ command.option("--no-input", "Disable prompts and browser launches");
20
+ }
21
+ for (const child of command.commands) register(child);
22
+ };
23
+ register(program);
24
+ program.hook("preAction", (_command, actionCommand) => {
25
+ const disabled = (command) => command !== null && (command.opts().input === false || disabled(command.parent));
26
+ policy.enterWith(disabled(actionCommand));
27
+ });
28
+ }
29
+
30
+ export {
31
+ InputPolicyCommand,
32
+ isInputDisabled,
33
+ configureInputPolicy
34
+ };
@@ -0,0 +1,32 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ PRIVACY_VALUES
4
+ } from "./chunk-NAC63XJF.js";
5
+ import {
6
+ err,
7
+ ok
8
+ } from "./chunk-5ENKYZA4.js";
9
+ import {
10
+ external_exports
11
+ } from "./chunk-I57ID5K7.js";
12
+
13
+ // src/helpers/visibility.ts
14
+ var normalizeVisibility = (options) => {
15
+ const legacy = external_exports.enum(PRIVACY_VALUES).optional().safeParse(options.isPrivate);
16
+ if (!legacy.success) return err(legacy.error.issues[0].message);
17
+ if (options.public && options.private) {
18
+ return err("Use either --public or --private, not both.");
19
+ }
20
+ const legacyVisibility = legacy.data === void 0 ? void 0 : legacy.data === "true" || legacy.data === "private";
21
+ const visibility = options.private ? true : options.public ? false : void 0;
22
+ if (visibility !== void 0 && legacyVisibility !== void 0 && visibility !== legacyVisibility) {
23
+ return err(
24
+ "--isPrivate conflicts with the visibility flag. Use matching values or a single visibility option."
25
+ );
26
+ }
27
+ return ok(visibility ?? legacyVisibility);
28
+ };
29
+
30
+ export {
31
+ normalizeVisibility
32
+ };
@@ -2,7 +2,7 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
 
3
3
  // package.json
4
4
  var name = "@scalar/cli";
5
- var version = "2.12.3";
5
+ var version = "2.13.0";
6
6
  var bin = {
7
7
  scalar: "./dist/index.js",
8
8
  "scalar-cli": "./dist/index.js"
@@ -1,10 +1,10 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getAuthData
4
- } from "./chunk-FI7UKPRF.js";
4
+ } from "./chunk-DDDYR2HF.js";
5
5
  import {
6
6
  config
7
- } from "./chunk-FYMDIB7J.js";
7
+ } from "./chunk-CSJIKXUD.js";
8
8
  import {
9
9
  external_exports,
10
10
  objectSchema,
@@ -95,6 +95,7 @@ function createAccess(baseURL) {
95
95
  function makeRequest(options) {
96
96
  return fetch(`${baseURL}${options.url}`, {
97
97
  method: options.method,
98
+ signal: options.signal,
98
99
  headers: {
99
100
  ...options.headers,
100
101
  // An empty bearer token is always rejected — omit the header so the
@@ -110,9 +111,10 @@ function createAccess(baseURL) {
110
111
  return formatResponse({ data: await res.json(), status: res.status }, options.schema);
111
112
  }).catch((err) => formatError(err));
112
113
  }
113
- function get({ collectionPath, query, schema, type }) {
114
+ function get({ collectionPath, query, schema, type, signal }) {
114
115
  const data = schemaModel({ collectionPath, query }, getRecordRequestSchema);
115
116
  return makeRequest({
117
+ signal,
116
118
  url: `/database/get-${type}`,
117
119
  method: "POST",
118
120
  data,
@@ -267,17 +269,22 @@ function initDatabase(baseUrl) {
267
269
  }
268
270
 
269
271
  // src/helpers/database.ts
270
- var getDatabaseClient = async () => {
272
+ function createDatabaseClient(accessToken) {
271
273
  const client = initDatabase(`${config.services.api}/rtdb`);
274
+ client.updateAccessToken(accessToken);
275
+ return client;
276
+ }
277
+ var getDatabaseClient = async () => {
272
278
  const auth = await getAuthData();
279
+ const client = createDatabaseClient(auth.accessToken);
273
280
  auth.addEventListener((state) => {
274
281
  Object.assign(auth, state);
275
282
  client.updateAccessToken(state.accessToken);
276
283
  });
277
- client.updateAccessToken(auth.accessToken);
278
284
  return client;
279
285
  };
280
286
 
281
287
  export {
288
+ createDatabaseClient,
282
289
  getDatabaseClient
283
290
  };
@@ -0,0 +1,167 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ getPublishDeploymentUrl
4
+ } from "./chunk-7S34K2P3.js";
5
+ import {
6
+ writeJson
7
+ } from "./chunk-SNQFFEYH.js";
8
+ import {
9
+ createDatabaseClient
10
+ } from "./chunk-OVKTA5CX.js";
11
+ import {
12
+ publishRecordSchema
13
+ } from "./chunk-VRZSDUZK.js";
14
+ import {
15
+ output
16
+ } from "./chunk-T5HJUAWB.js";
17
+ import {
18
+ external_exports
19
+ } from "./chunk-I57ID5K7.js";
20
+
21
+ // src/domains/project/deployments/observe.ts
22
+ import { performance } from "node:perf_hooks";
23
+ import { setTimeout as sleep } from "node:timers/promises";
24
+ var timeoutSchema = external_exports.coerce.number().positive().finite().max(2147483);
25
+ var defaultWaitSeconds = 600;
26
+ function recoveryCommand(publishUid) {
27
+ return `scalar project deployments get ${publishUid} --wait`;
28
+ }
29
+ function printRecord(record) {
30
+ console.log(`Build ID: ${record.uid}`);
31
+ console.log(`Status: ${record.status}`);
32
+ if (record.message) console.log(record.message);
33
+ if (record.status !== "deployed") return;
34
+ const url = getPublishDeploymentUrl(record);
35
+ if (url)
36
+ console.log(`${record.preview ? "Preview URL" : "Deployment URL"}: ${url}`);
37
+ if (record.hasWarnings) {
38
+ output.warn().title("The build finished with warnings").line("Check the build log in the Scalar Dashboard for details.").print();
39
+ }
40
+ }
41
+ async function observePublish({
42
+ teamUid,
43
+ accessToken,
44
+ publishUid,
45
+ wait = true,
46
+ timeout = defaultWaitSeconds,
47
+ json = false
48
+ }) {
49
+ const controller = new AbortController();
50
+ const deadline = performance.now() + timeout * 1e3;
51
+ const timer = setTimeout(() => controller.abort(), timeout * 1e3);
52
+ const interruption = { code: 0 };
53
+ const interrupt = (code) => {
54
+ interruption.code = code;
55
+ controller.abort();
56
+ };
57
+ const onInterrupt = () => interrupt(130);
58
+ const onTerminate = () => interrupt(143);
59
+ process.once("SIGINT", onInterrupt);
60
+ process.once("SIGTERM", onTerminate);
61
+ function visibilityError(message) {
62
+ console.error(`${message}
63
+ Build ID: ${publishUid}
64
+ Stopping local waiting does not cancel the remote build; deployment may continue.
65
+ Inspect with the original team selected: ${recoveryCommand(publishUid)}`);
66
+ process.exitCode = interruption.code || 1;
67
+ }
68
+ try {
69
+ const client = createDatabaseClient(accessToken);
70
+ const progress = { message: "" };
71
+ while (!controller.signal.aborted) {
72
+ const response = await client.getOne({
73
+ collectionPath: `team/${teamUid}/publish`,
74
+ query: { uid: publishUid },
75
+ schema: publishRecordSchema,
76
+ signal: controller.signal
77
+ });
78
+ if (controller.signal.aborted) break;
79
+ if (response.error) {
80
+ visibilityError(
81
+ "Could not load deployment status. The build outcome is unknown."
82
+ );
83
+ return;
84
+ }
85
+ const parsed = publishRecordSchema.safeParse(response.data);
86
+ if (!parsed.success || parsed.data.uid !== publishUid) {
87
+ visibilityError(
88
+ "Could not read the requested build record. The build outcome is unknown."
89
+ );
90
+ return;
91
+ }
92
+ const record = parsed.data;
93
+ if (!wait || record.status !== "pending" && record.status !== "building") {
94
+ if (json && record.status === "deployed") {
95
+ writeJson({
96
+ uid: record.uid,
97
+ status: "deployed",
98
+ url: getPublishDeploymentUrl(record) ?? null,
99
+ preview: record.preview,
100
+ hasWarnings: record.hasWarnings ?? false
101
+ });
102
+ } else if (!json) {
103
+ printRecord(record);
104
+ }
105
+ if (wait && record.status !== "deployed") {
106
+ console.error(
107
+ `Build ${publishUid} has status ${record.status}; it is not a confirmed deployment. ${record.message}`
108
+ );
109
+ process.exitCode = 1;
110
+ }
111
+ return;
112
+ }
113
+ const message = `${record.status}: ${record.message}`;
114
+ if (!json && message !== progress.message) {
115
+ console.error(message);
116
+ progress.message = message;
117
+ }
118
+ await sleep(
119
+ Math.max(0, Math.min(3e3, deadline - performance.now())),
120
+ void 0,
121
+ { signal: controller.signal }
122
+ );
123
+ }
124
+ visibilityError(
125
+ interruption.code ? "Operation cancelled." : "Timed out waiting for deployment status."
126
+ );
127
+ } catch {
128
+ visibilityError(
129
+ interruption.code ? "Operation cancelled." : controller.signal.aborted ? "Timed out waiting for deployment status." : "Could not load deployment status. The build outcome is unknown."
130
+ );
131
+ } finally {
132
+ clearTimeout(timer);
133
+ process.removeListener("SIGINT", onInterrupt);
134
+ process.removeListener("SIGTERM", onTerminate);
135
+ }
136
+ }
137
+ async function finishPublish(args) {
138
+ if (args.json) {
139
+ if (!args.wait) {
140
+ writeJson({
141
+ uid: args.publishUid,
142
+ status: "accepted"
143
+ });
144
+ return;
145
+ }
146
+ await observePublish(args);
147
+ return;
148
+ }
149
+ console.log(`Build ID: ${args.publishUid}`);
150
+ console.log(
151
+ `Inspect with the original team selected: ${recoveryCommand(args.publishUid)}`
152
+ );
153
+ if (!args.wait) {
154
+ console.log(
155
+ "Publish accepted. Deployment is not yet confirmed; the remote build continues."
156
+ );
157
+ return;
158
+ }
159
+ await observePublish(args);
160
+ }
161
+
162
+ export {
163
+ timeoutSchema,
164
+ defaultWaitSeconds,
165
+ observePublish,
166
+ finishPublish
167
+ };
@@ -1,4 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ isInputDisabled
4
+ } from "./chunk-IRQJDPZE.js";
2
5
  import {
3
6
  err,
4
7
  ok
@@ -7,7 +10,8 @@ import {
7
10
  // src/helpers/url-opener.ts
8
11
  import { spawn } from "node:child_process";
9
12
  var openBrowser = async (url) => {
10
- if (process.env.NODE_ENV === "INTEGRATION") return ok(void 0);
13
+ if (isInputDisabled() || process.env.NODE_ENV === "INTEGRATION")
14
+ return ok(void 0);
11
15
  const platform = process.platform;
12
16
  if (platform !== "darwin" && platform !== "linux" && platform !== "win32") {
13
17
  return err(
@@ -10,7 +10,7 @@ var DownloadIsolateCommand = () => {
10
10
  const cmd = new Command("download-isolate");
11
11
  cmd.description("Download the docs preview server");
12
12
  cmd.action(async () => {
13
- const { downloadIsolate } = await import("./action-M5OUEDV2.js");
13
+ const { downloadIsolate } = await import("./action-ESVI46KE.js");
14
14
  await downloadIsolate();
15
15
  });
16
16
  return cmd;
@@ -0,0 +1,11 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+
3
+ // src/helpers/std-out/json.ts
4
+ function writeJson(result) {
5
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
6
+ `);
7
+ }
8
+
9
+ export {
10
+ writeJson
11
+ };
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  ISOLATE_DIR,
7
7
  ISOLATE_EXTRACTION_DIR
8
- } from "./chunk-CUHVXHIV.js";
8
+ } from "./chunk-RAU5KE6F.js";
9
9
  import {
10
10
  config
11
- } from "./chunk-FYMDIB7J.js";
11
+ } from "./chunk-CSJIKXUD.js";
12
12
  import {
13
13
  output
14
14
  } from "./chunk-T5HJUAWB.js";
@@ -33,10 +33,10 @@ import {
33
33
  needsRenewal,
34
34
  refreshToken,
35
35
  renewAuth
36
- } from "./chunk-FI7UKPRF.js";
36
+ } from "./chunk-DDDYR2HF.js";
37
37
  import {
38
38
  config
39
- } from "./chunk-FYMDIB7J.js";
39
+ } from "./chunk-CSJIKXUD.js";
40
40
  import {
41
41
  UnifiedDocsMigrationStatus,
42
42
  pendingInviteSchema,
@@ -28,7 +28,7 @@ function BundleCommand() {
28
28
  cmd.argument("[file|url]", "API description file path or URL to bundle");
29
29
  cmd.option(
30
30
  "-o, --output <file>",
31
- "Output file, or - for YAML on stdout (required for URLs and non-interactive use; otherwise confirms overwriting the input file)"
31
+ "Output file, or - for stdout in the input format (required for URLs and non-interactive use; otherwise confirms overwriting the input file)"
32
32
  );
33
33
  cmd.option("--treeShake", "Remove unused components from the bundled output");
34
34
  cmd.option(
@@ -42,7 +42,7 @@ function BundleCommand() {
42
42
  );
43
43
  completeFiles(cmd, ["file|url"], ["--output"]);
44
44
  cmd.action(async (...args) => {
45
- const { bundleAction } = await import("./action-B74PPGKB.js");
45
+ const { bundleAction } = await import("./action-F6JSCBEU.js");
46
46
  return bundleAction(...args);
47
47
  });
48
48
  return cmd;
@@ -0,0 +1,16 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ registryUrl
4
+ } from "./chunk-7O5H2SQP.js";
5
+ import {
6
+ readUrl
7
+ } from "./chunk-2XWUFFEZ.js";
8
+
9
+ // src/domains/registry/helpers/fetch.ts
10
+ async function fetchFromRegistry(path, accessToken) {
11
+ return readUrl(registryUrl(path), { accessToken });
12
+ }
13
+
14
+ export {
15
+ fetchFromRegistry
16
+ };