@scalar/cli 2.8.0 → 2.11.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 (111) hide show
  1. package/README.md +84 -1076
  2. package/chunks/action-25QMCP5G.js +122 -0
  3. package/chunks/{action-354TUG4H.js → action-2VF6LODL.js} +20 -16
  4. package/chunks/{action-XIUO64C7.js → action-5I4XDPPG.js} +20 -14
  5. package/chunks/action-6M5PTDF6.js +100 -0
  6. package/chunks/{action-NVI5DWFP.js → action-73ELLN3T.js} +8 -11
  7. package/chunks/{action-Y6NXJQ4H.js → action-7H3AWCHX.js} +21 -16
  8. package/chunks/{action-LLH4QPXM.js → action-BRSLSOE5.js} +19 -18
  9. package/chunks/{action-EOAVVL52.js → action-CQQCKSNS.js} +17 -22
  10. package/chunks/action-D5QWDNQ2.js +65 -0
  11. package/chunks/{action-Y7OUGD56.js → action-DQDHBOLJ.js} +34 -31
  12. package/chunks/{action-5SK5NE7E.js → action-EYPYQQVM.js} +18 -23
  13. package/chunks/{action-YRX6SN5F.js → action-FMA5ECUA.js} +12 -10
  14. package/chunks/{action-7PEQXDWT.js → action-GXDJLF2G.js} +134 -25
  15. package/chunks/action-HUICEXJZ.js +75 -0
  16. package/chunks/action-IH6G77C5.js +38 -0
  17. package/chunks/{action-H3RTILLM.js → action-IIQMZVRJ.js} +1 -1
  18. package/chunks/action-IQM54ITT.js +164 -0
  19. package/chunks/{action-UIKH4SZX.js → action-J5TO3UJW.js} +32 -26
  20. package/chunks/{action-H6OUJWWM.js → action-KC3ZCNDR.js} +17 -22
  21. package/chunks/{action-6BYGBXRC.js → action-L7TMS3Q3.js} +44 -37
  22. package/chunks/{action-GWXLHL2Z.js → action-LAAHRDSR.js} +5 -4
  23. package/chunks/{action-FCAYFPVR.js → action-LR75GHBA.js} +14 -11
  24. package/chunks/action-MJMLQFLT.js +1552 -0
  25. package/chunks/action-NHU4CUKT.js +130 -0
  26. package/chunks/action-NKTFNFU7.js +64 -0
  27. package/chunks/{action-F7A2K74G.js → action-NMW5WPD2.js} +12 -16
  28. package/chunks/{action-VOFDW3U2.js → action-OTPXODUE.js} +8 -7
  29. package/chunks/{action-43YBNBDR.js → action-RPCDNGCI.js} +54 -39
  30. package/chunks/{action-QQZLPI42.js → action-RQCXSJPZ.js} +55 -27
  31. package/chunks/action-SOYSVG67.js +147 -0
  32. package/chunks/action-Y7EBKCUU.js +16 -0
  33. package/chunks/{action-WFDNRA7D.js → action-YN4TE7TG.js} +24 -23
  34. package/chunks/{action-AQRPFQKI.js → action-ZGNVWTHZ.js} +14 -12
  35. package/chunks/action-ZKKRPLDK.js +64 -0
  36. package/chunks/{action-HT2DJ34Z.js → action-ZUZL7R3H.js} +20 -15
  37. package/chunks/{actions-OGIVBQC7.js → actions-S6K76HCW.js} +46 -19
  38. package/chunks/{agent-ASPV3R5U.js → agent-IRNEV4K5.js} +46 -9
  39. package/chunks/{asyncapi-QNFKXHEI.js → asyncapi-WQPIQMEZ.js} +15 -10
  40. package/chunks/{build.action-NM6CAE5F.js → build.action-CLBVKFWD.js} +28 -24
  41. package/chunks/chunk-25XERWCE.js +1058 -0
  42. package/chunks/chunk-3RIUDHLG.js +467 -0
  43. package/chunks/{chunk-MLSZVVTT.js → chunk-3TFOA64C.js} +19 -8
  44. package/chunks/{chunk-HGOD6THU.js → chunk-4JKXZ5CF.js} +12 -25
  45. package/chunks/{chunk-C2KAWRIX.js → chunk-5ENKYZA4.js} +1 -1
  46. package/chunks/{chunk-W24BETFG.js → chunk-5L7V7RCH.js} +10 -10
  47. package/chunks/chunk-6PSYZO3U.js +24 -0
  48. package/chunks/{chunk-IMG35UXX.js → chunk-ALYM4ZB2.js} +1 -1
  49. package/chunks/chunk-AVZFSWPD.js +37 -0
  50. package/chunks/{chunk-5UHLAJQD.js → chunk-BQYVSPAI.js} +36 -10
  51. package/chunks/{chunk-XXSQUBXS.js → chunk-CSSTCHHF.js} +6212 -4642
  52. package/chunks/chunk-DFOZG7ZV.js +15 -0
  53. package/chunks/{chunk-22HYZ7LE.js → chunk-DQD2753S.js} +3 -3
  54. package/chunks/{action-F2ZJNURT.js → chunk-EBNFCIKS.js} +7 -10
  55. package/chunks/{chunk-EXY3ZTV4.js → chunk-F3OPMYME.js} +143 -301
  56. package/chunks/{chunk-FDC2IESH.js → chunk-FG5AOTDN.js} +8519 -14702
  57. package/chunks/chunk-GKCVATQJ.js +92 -0
  58. package/chunks/{chunk-PH3WFNXJ.js → chunk-GMHIK5K2.js} +1 -1
  59. package/chunks/{chunk-GTV2BVXV.js → chunk-GYR5E6RB.js} +2 -2
  60. package/chunks/{chunk-OJ2EWIJH.js → chunk-HZN6IIPZ.js} +11 -6
  61. package/chunks/{chunk-IKT5F47M.js → chunk-I57ID5K7.js} +24 -11
  62. package/chunks/{chunk-BPGFSSUH.js → chunk-KOD2HX5I.js} +1 -1
  63. package/chunks/{chunk-L3UXDCBI.js → chunk-LOLVJNI5.js} +4 -4
  64. package/chunks/{chunk-KCCFN4F7.js → chunk-MN2AFJXM.js} +36 -29
  65. package/chunks/{chunk-UXJ753NV.js → chunk-N5CJ5MTY.js} +5 -13
  66. package/chunks/chunk-NAC63XJF.js +10 -0
  67. package/chunks/{chunk-2OCWX42S.js → chunk-NWJ37GI2.js} +166 -22
  68. package/chunks/{chunk-3ZJYGGAA.js → chunk-ORCUZITN.js} +1 -1
  69. package/chunks/chunk-QMLRYD76.js +24 -0
  70. package/chunks/{chunk-KKRGBXCE.js → chunk-SEURG74P.js} +303 -209
  71. package/chunks/{chunk-R5LK6VPY.js → chunk-SOV4POMS.js} +370 -264
  72. package/chunks/chunk-T34TL6KL.js +222 -0
  73. package/chunks/{chunk-5DEU2DVL.js → chunk-U6VE6JOS.js} +3 -15
  74. package/chunks/{chunk-YILQODZF.js → chunk-UFSFY7Z4.js} +23 -20
  75. package/chunks/{chunk-6YPQGVF4.js → chunk-ULRJZXMS.js} +1 -1
  76. package/chunks/chunk-US54KYOJ.js +131 -0
  77. package/chunks/chunk-V6LUKXBV.js +37 -0
  78. package/chunks/{chunk-5JLVQVKO.js → chunk-VRZSDUZK.js} +190 -152
  79. package/chunks/chunk-VUXPDHTQ.js +22 -0
  80. package/chunks/chunk-XP5UM7SF.js +21 -0
  81. package/chunks/chunk-Y6XGC4K5.js +311 -0
  82. package/chunks/{create.action-FUQ2BVJA.js → create.action-ITEOQ644.js} +34 -30
  83. package/chunks/{delete.action-47E66R3I.js → delete.action-77MFPLUN.js} +30 -26
  84. package/chunks/{delete.action-BTDFH7WY.js → delete.action-C6VX4S5Q.js} +30 -26
  85. package/chunks/{get.action-XC7KC2JO.js → get.action-3BP4FHZC.js} +20 -14
  86. package/chunks/get.action-LNBOWUVE.js +95 -0
  87. package/chunks/list.action-6CRFQPJT.js +156 -0
  88. package/chunks/list.action-KR5YIDR4.js +126 -0
  89. package/chunks/{publish.action-OS27XOX4.js → publish.action-YBORRPBM.js} +49 -42
  90. package/chunks/query-WKATAJJ6.js +129 -0
  91. package/chunks/scripts-6CI6U32J.js +102 -0
  92. package/chunks/{update.action-AEIBLCWD.js → update.action-O7TSXDGV.js} +34 -27
  93. package/chunks/{update.action-ZMS4CQ3T.js → update.action-QZI7M2MV.js} +34 -27
  94. package/index.js +579 -382
  95. package/package.json +15 -14
  96. package/skills/scalar-cli/SKILL.md +52 -46
  97. package/template.md +71 -136
  98. package/chunks/action-CA4QYPI6.js +0 -125
  99. package/chunks/action-JAHFRYWZ.js +0 -423
  100. package/chunks/action-KTYOCA2V.js +0 -229
  101. package/chunks/action-LEUD5P2U.js +0 -92
  102. package/chunks/action-LXGXKXZZ.js +0 -72
  103. package/chunks/action-W3C53GPH.js +0 -54
  104. package/chunks/action-YLF2G4G5.js +0 -37
  105. package/chunks/chunk-6XWCMJDB.js +0 -404
  106. package/chunks/chunk-K74E42RV.js +0 -7311
  107. package/chunks/chunk-QVQ4PNVL.js +0 -610
  108. package/chunks/chunk-XEDGMZJD.js +0 -366
  109. package/chunks/list.action-LXKEUYKO.js +0 -116
  110. package/chunks/list.action-OFGLMRE7.js +0 -95
  111. package/docs.html +0 -6245
@@ -0,0 +1,130 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ createError,
4
+ displayError
5
+ } from "./chunk-ORCUZITN.js";
6
+ import {
7
+ readAndParseConfig,
8
+ renderConfigError
9
+ } from "./chunk-5L7V7RCH.js";
10
+ import {
11
+ CONFIG_FILE_DEFAULT,
12
+ expandFolderGuides,
13
+ findConfig,
14
+ legacyTo2_0_0
15
+ } from "./chunk-CSSTCHHF.js";
16
+ import "./chunk-5ENKYZA4.js";
17
+ import {
18
+ ConfigVersion
19
+ } from "./chunk-VRZSDUZK.js";
20
+ import {
21
+ output
22
+ } from "./chunk-T5HJUAWB.js";
23
+ import "./chunk-I57ID5K7.js";
24
+ import "./chunk-3MZYUBJ6.js";
25
+
26
+ // src/domains/project/upgrade/action.ts
27
+ import { spawnSync } from "node:child_process";
28
+ import { existsSync } from "node:fs";
29
+ import fs from "node:fs/promises";
30
+ import path from "node:path";
31
+ import { text } from "@clack/prompts";
32
+ import as from "ansis";
33
+ import { n } from "neverpanic";
34
+ async function upgradeAction(__configPath) {
35
+ const configPath = __configPath || findConfig() || await text({
36
+ message: "Where is your configuration file located?",
37
+ defaultValue: CONFIG_FILE_DEFAULT,
38
+ placeholder: CONFIG_FILE_DEFAULT
39
+ });
40
+ const parseConfigResult = readAndParseConfig(configPath);
41
+ if (!parseConfigResult.success) {
42
+ renderConfigError(parseConfigResult.error);
43
+ }
44
+ if (parseConfigResult.success) {
45
+ output.info().line(
46
+ `${as.green("[SUCCESS]")} ${as.green("Configuration is valid:")} ${as.green(parseConfigResult.filePath)}`
47
+ ).print();
48
+ }
49
+ const { config } = parseConfigResult;
50
+ if (config.version === ConfigVersion.V2) {
51
+ return output.info().title("Your Scalar configuration is already upgraded").message(
52
+ "You are already on the latest Scalar docs version. No further action required."
53
+ ).exit("success");
54
+ }
55
+ const projectRootDir = path.resolve(
56
+ path.dirname(parseConfigResult.filePath),
57
+ config.root ?? "./"
58
+ );
59
+ const publishedFiles = listGitFiles(projectRootDir);
60
+ const expandedConfigResult = await n.fromUnsafe(
61
+ () => expandFolderGuides(config, async (folderPath) => {
62
+ const entries = await fs.readdir(
63
+ path.join(projectRootDir, folderPath),
64
+ {
65
+ withFileTypes: true
66
+ }
67
+ );
68
+ return entries.filter((entry) => entry.isFile() || entry.isDirectory()).map((entry) => ({
69
+ name: entry.name,
70
+ type: entry.isFile() ? "file" : "dir",
71
+ path: path.posix.join(folderPath, entry.name)
72
+ })).filter(
73
+ (entry) => entry.type === "dir" || !publishedFiles || entry.path.startsWith("..") || publishedFiles.has(entry.path)
74
+ );
75
+ }),
76
+ (originalError) => createError("FAILED_TO_EXPAND_FOLDER_GUIDES", originalError)
77
+ );
78
+ if (!expandedConfigResult.success) {
79
+ return output.error().title("Could not read the folders of your folder-based guides.").message(expandedConfigResult.error.code).message(displayError(expandedConfigResult.error.detail)).exit("error");
80
+ }
81
+ const upgradedConfigResult = n.fromUnsafe(
82
+ () => legacyTo2_0_0(expandedConfigResult.data, {
83
+ isPathTaken: (filePath) => existsSync(path.join(projectRootDir, filePath))
84
+ }),
85
+ (originalError) => createError("FAILED_TO_UPGRADE_CONFIG_V1", originalError)
86
+ );
87
+ if (!upgradedConfigResult.success) {
88
+ return output.error().title("Could not upgrade the configuration").message(upgradedConfigResult.error.code).message(displayError(upgradedConfigResult.error.detail)).exit("error");
89
+ }
90
+ const { upgradedConfig, sideFiles, dropped } = upgradedConfigResult.data;
91
+ for (const sideFile of sideFiles) {
92
+ const writeSideFileResult = await n.fromUnsafe(
93
+ () => fs.writeFile(
94
+ path.join(projectRootDir, sideFile.path),
95
+ sideFile.content,
96
+ { flag: "wx" }
97
+ ),
98
+ (originalError) => createError("FAILED_TO_WRITE_UPGRADED_SIDE_FILE", originalError)
99
+ );
100
+ if (!writeSideFileResult.success) {
101
+ return output.error().title(`Could not save ${sideFile.path}`).message(writeSideFileResult.error.code).message(displayError(writeSideFileResult.error.detail)).exit("error");
102
+ }
103
+ }
104
+ if (dropped.length) {
105
+ output.warn().title("Some settings have no V2 equivalent and were not carried over:").message(dropped.join(", ")).print();
106
+ }
107
+ const writeUpgradedConfigResult = await n.fromUnsafe(
108
+ () => fs.writeFile(
109
+ parseConfigResult.filePath,
110
+ JSON.stringify(upgradedConfig, null, 2)
111
+ ),
112
+ (originalError) => createError("FAILED_TO_WRITE_UPGRADED_CONFIG", originalError)
113
+ );
114
+ if (!writeUpgradedConfigResult.success) {
115
+ return output.error().title("Could not save the upgraded configuration").message(writeUpgradedConfigResult.error.code).message(displayError(writeUpgradedConfigResult.error.detail)).exit("error");
116
+ }
117
+ return output.info().title("Scalar Docs configuration upgraded").message("Run `scalar project preview` to preview your project.").exit("success");
118
+ }
119
+ function listGitFiles(projectRootDir) {
120
+ const result = spawnSync(
121
+ "git",
122
+ ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
123
+ { cwd: projectRootDir, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
124
+ );
125
+ if (result.status !== 0) return null;
126
+ return new Set(result.stdout.split("\0").filter(Boolean));
127
+ }
128
+ export {
129
+ upgradeAction
130
+ };
@@ -0,0 +1,64 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ BaseCollections
4
+ } from "./chunk-NWJ37GI2.js";
5
+ import {
6
+ getDatabaseClient
7
+ } from "./chunk-U6VE6JOS.js";
8
+ import "./chunk-SEURG74P.js";
9
+ import "./chunk-3TFOA64C.js";
10
+ import "./chunk-5ENKYZA4.js";
11
+ import "./chunk-Y6XGC4K5.js";
12
+ import "./chunk-T34TL6KL.js";
13
+ import "./chunk-V6LUKXBV.js";
14
+ import "./chunk-VUXPDHTQ.js";
15
+ import {
16
+ getAuthData
17
+ } from "./chunk-3RIUDHLG.js";
18
+ import "./chunk-N5CJ5MTY.js";
19
+ import "./chunk-US54KYOJ.js";
20
+ import {
21
+ teamSchema
22
+ } from "./chunk-BQYVSPAI.js";
23
+ import "./chunk-VRZSDUZK.js";
24
+ import "./chunk-4ORL4MST.js";
25
+ import "./chunk-MN2AFJXM.js";
26
+ import {
27
+ output
28
+ } from "./chunk-T5HJUAWB.js";
29
+ import "./chunk-25XERWCE.js";
30
+ import "./chunk-AVZFSWPD.js";
31
+ import "./chunk-I57ID5K7.js";
32
+ import "./chunk-3MZYUBJ6.js";
33
+
34
+ // src/domains/team/get/action.ts
35
+ async function getAction(args = {}) {
36
+ const auth = await getAuthData();
37
+ auth.addEventListener((state) => Object.assign(auth, state));
38
+ const client = await getDatabaseClient();
39
+ const team = await client.getOne({
40
+ collectionPath: BaseCollections.Teams,
41
+ query: { uid: auth.teamUid },
42
+ schema: teamSchema
43
+ });
44
+ if (team.error) {
45
+ return output.error().title("Could not load the current team").message(team.message).exit("error");
46
+ }
47
+ const details = {
48
+ uid: team.data.uid,
49
+ name: team.data.name,
50
+ slug: team.data.slug,
51
+ namespaces: team.data.namespaces
52
+ };
53
+ if (args.json) {
54
+ process.stdout.write(`${JSON.stringify(details, null, 2)}
55
+ `);
56
+ return;
57
+ }
58
+ output.info().title(details.name).line(`Team ID: ${details.uid}`).line(`Slug: ${details.slug}`).line(
59
+ `Namespaces: ${details.namespaces.length ? details.namespaces.join(", ") : "None"}`
60
+ ).print();
61
+ }
62
+ export {
63
+ getAction
64
+ };
@@ -1,28 +1,24 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getFileOrUrl
4
- } from "./chunk-HGOD6THU.js";
5
- import {
6
- require_dist
7
- } from "./chunk-K74E42RV.js";
8
- import "./chunk-KCCFN4F7.js";
9
- import "./chunk-6XWCMJDB.js";
4
+ } from "./chunk-4JKXZ5CF.js";
5
+ import "./chunk-QMLRYD76.js";
10
6
  import {
11
7
  isYamlFileName
12
8
  } from "./chunk-4ORL4MST.js";
9
+ import "./chunk-MN2AFJXM.js";
13
10
  import {
14
11
  output
15
12
  } from "./chunk-T5HJUAWB.js";
16
- import "./chunk-XEDGMZJD.js";
17
- import "./chunk-IKT5F47M.js";
18
- import {
19
- __toESM
20
- } from "./chunk-3MZYUBJ6.js";
13
+ import "./chunk-25XERWCE.js";
14
+ import "./chunk-AVZFSWPD.js";
15
+ import "./chunk-I57ID5K7.js";
16
+ import "./chunk-3MZYUBJ6.js";
21
17
 
22
18
  // src/domains/document/postman/action.ts
23
- var import_yaml = __toESM(require_dist(), 1);
24
19
  import fs from "node:fs";
25
20
  import as from "ansis";
21
+ import YAML from "yaml";
26
22
  import { convert } from "@scalar/postman-to-openapi";
27
23
  async function convertAction(inputArgument, {
28
24
  output: outputPath,
@@ -30,7 +26,7 @@ async function convertAction(inputArgument, {
30
26
  }) {
31
27
  const startTime = performance.now();
32
28
  if (!inputArgument) {
33
- return output.error().title("Invalid argument").message("Please provide a Postman collection file path or URL").exit("error");
29
+ return output.error().title("Invalid argument").message("Provide a Postman collection file path or URL.").exit("error");
34
30
  }
35
31
  const collection = await getFileOrUrl(inputArgument);
36
32
  let specification;
@@ -41,13 +37,13 @@ async function convertAction(inputArgument, {
41
37
  } catch {
42
38
  return output.error().title("Failed to convert Postman collection").message("The provided input is not a valid Postman collection").exit("error");
43
39
  }
44
- const openApiDocument = outputPath ? isYamlFileName(outputPath) ? import_yaml.default.stringify(specification) : JSON.stringify(specification, null, 2) : JSON.stringify(specification, null, 2);
40
+ const openApiDocument = outputPath ? isYamlFileName(outputPath) ? YAML.stringify(specification) : JSON.stringify(specification, null, 2) : JSON.stringify(specification, null, 2);
45
41
  if (outputPath) {
46
42
  fs.writeFileSync(outputPath, openApiDocument, "utf8");
47
43
  const endTime = performance.now();
48
44
  output.info().line(
49
- `${as.green("OpenAPI document generated")} ${as.grey(
50
- `in ${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)}`
45
+ `${as.green("OpenAPI description generated")} ${as.grey(
46
+ `(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
51
47
  )}`
52
48
  ).line(`Written to ${as.cyan(outputPath)}`).print();
53
49
  return;
@@ -1,15 +1,16 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getFileOrUrl
4
- } from "./chunk-HGOD6THU.js";
5
- import "./chunk-KCCFN4F7.js";
6
- import "./chunk-6XWCMJDB.js";
4
+ } from "./chunk-4JKXZ5CF.js";
5
+ import "./chunk-QMLRYD76.js";
7
6
  import "./chunk-4ORL4MST.js";
7
+ import "./chunk-MN2AFJXM.js";
8
8
  import {
9
9
  output
10
10
  } from "./chunk-T5HJUAWB.js";
11
- import "./chunk-XEDGMZJD.js";
12
- import "./chunk-IKT5F47M.js";
11
+ import "./chunk-25XERWCE.js";
12
+ import "./chunk-AVZFSWPD.js";
13
+ import "./chunk-I57ID5K7.js";
13
14
  import "./chunk-3MZYUBJ6.js";
14
15
 
15
16
  // src/domains/document/markdown/action.ts
@@ -19,7 +20,7 @@ import { createMarkdownFromOpenApi } from "@scalar/openapi-to-markdown";
19
20
  async function markdownAction(inputArgument, { output: outputPath }) {
20
21
  const startTime = performance.now();
21
22
  if (!inputArgument) {
22
- return output.error().title("Invalid argument").message("Please provide a file path or URL").exit("error");
23
+ return output.error().title("Invalid argument").message("Provide a file path or URL.").exit("error");
23
24
  }
24
25
  const specification = await getFileOrUrl(inputArgument);
25
26
  const markdown = await createMarkdownFromOpenApi(specification);
@@ -28,7 +29,7 @@ async function markdownAction(inputArgument, { output: outputPath }) {
28
29
  const endTime = performance.now();
29
30
  output.info().line(
30
31
  `${as.green("Markdown generated")} ${as.grey(
31
- `in ${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)}`
32
+ `(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
32
33
  )}`
33
34
  ).line(`Written to ${as.cyan(outputPath)}`).print();
34
35
  return;
@@ -1,51 +1,55 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getPublishDeploymentUrl
4
- } from "./chunk-IMG35UXX.js";
5
- import {
6
- resolveProject
7
- } from "./chunk-TSURUX4A.js";
4
+ } from "./chunk-ALYM4ZB2.js";
8
5
  import {
9
6
  readAndParseConfig,
10
7
  renderConfigError
11
- } from "./chunk-W24BETFG.js";
8
+ } from "./chunk-5L7V7RCH.js";
9
+ import {
10
+ resolveProject
11
+ } from "./chunk-TSURUX4A.js";
12
12
  import {
13
13
  DEFAULT_ASSETS_DIR
14
- } from "./chunk-XXSQUBXS.js";
15
- import "./chunk-YILQODZF.js";
14
+ } from "./chunk-CSSTCHHF.js";
15
+ import "./chunk-UFSFY7Z4.js";
16
16
  import {
17
17
  getDatabaseClient
18
- } from "./chunk-5DEU2DVL.js";
18
+ } from "./chunk-U6VE6JOS.js";
19
19
  import {
20
20
  apiService
21
- } from "./chunk-EXY3ZTV4.js";
22
- import "./chunk-KKRGBXCE.js";
23
- import "./chunk-MLSZVVTT.js";
24
- import "./chunk-FDC2IESH.js";
25
- import "./chunk-C2KAWRIX.js";
26
- import "./chunk-R5LK6VPY.js";
21
+ } from "./chunk-F3OPMYME.js";
22
+ import "./chunk-FG5AOTDN.js";
23
+ import "./chunk-SEURG74P.js";
24
+ import "./chunk-3TFOA64C.js";
25
+ import "./chunk-5ENKYZA4.js";
26
+ import "./chunk-Y6XGC4K5.js";
27
+ import "./chunk-SOV4POMS.js";
28
+ import "./chunk-T34TL6KL.js";
29
+ import "./chunk-V6LUKXBV.js";
30
+ import "./chunk-VUXPDHTQ.js";
27
31
  import {
28
32
  getAuthData
29
- } from "./chunk-QVQ4PNVL.js";
30
- import "./chunk-UXJ753NV.js";
31
- import "./chunk-5UHLAJQD.js";
33
+ } from "./chunk-3RIUDHLG.js";
34
+ import "./chunk-N5CJ5MTY.js";
35
+ import "./chunk-US54KYOJ.js";
36
+ import "./chunk-BQYVSPAI.js";
32
37
  import {
33
38
  ConfigVersion,
34
39
  isGithubBackedDocsProject,
35
40
  publishRecordSchema
36
- } from "./chunk-5JLVQVKO.js";
37
- import "./chunk-K74E42RV.js";
38
- import "./chunk-KCCFN4F7.js";
39
- import "./chunk-6XWCMJDB.js";
41
+ } from "./chunk-VRZSDUZK.js";
40
42
  import "./chunk-4ORL4MST.js";
43
+ import "./chunk-MN2AFJXM.js";
41
44
  import {
42
45
  output
43
46
  } from "./chunk-T5HJUAWB.js";
44
- import "./chunk-XEDGMZJD.js";
47
+ import "./chunk-25XERWCE.js";
48
+ import "./chunk-AVZFSWPD.js";
45
49
  import {
46
50
  slugSchema,
47
51
  zod_default
48
- } from "./chunk-IKT5F47M.js";
52
+ } from "./chunk-I57ID5K7.js";
49
53
  import "./chunk-3MZYUBJ6.js";
50
54
 
51
55
  // src/domains/project/publish/action.ts
@@ -395,7 +399,7 @@ async function publishAction(args) {
395
399
  github: zod_default.coerce.boolean().default(false)
396
400
  }).safeParse(args);
397
401
  if (argsParseResult.error)
398
- return output.error().title("Invalid Arguments").message(argsParseResult.error.issues[0].message).exit("error");
402
+ return output.error().title("Invalid arguments").message(argsParseResult.error.issues[0].message).exit("error");
399
403
  const {
400
404
  config: configPathOption,
401
405
  slug,
@@ -406,7 +410,9 @@ async function publishAction(args) {
406
410
  const auth = await getAuthData();
407
411
  auth.addEventListener((state) => Object.assign(auth, state));
408
412
  if (!slug) {
409
- return output.error().title("Invalid argument").message("Slug is required. Try passing --slug flag.").exit("error");
413
+ return output.error().title("Invalid argument").message(
414
+ "Slug is required. Run scalar project list to find your project slug, then pass --slug <slug>."
415
+ ).exit("error");
410
416
  }
411
417
  if (github) {
412
418
  const resolved = await resolveProject(slug, apiClient);
@@ -416,17 +422,17 @@ async function publishAction(args) {
416
422
  if (resolved.kind === "github") {
417
423
  if (!resolved.project.repository) {
418
424
  return output.error().title("Your project is not linked to a GitHub repository").message(
419
- "For a sync publish, please configure your GitHub connection through the dashboard."
425
+ "Connect the project to a GitHub repository in the Scalar Dashboard to publish from GitHub."
420
426
  ).exit("error");
421
427
  }
422
428
  if (resolved.project.repository.expired) {
423
- return output.error().title("Your GitHub repository access is expired.").message(
424
- "Please reconnect your project through the Scalar Dashboard to publish via sync."
429
+ return output.error().title("GitHub repository access has expired").message(
430
+ "Reconnect the GitHub repository in the Scalar Dashboard to publish from GitHub."
425
431
  ).exit("error");
426
432
  }
427
433
  const publishResult3 = await publishGithub({ apiClient, slug, preview });
428
434
  if (!publishResult3.success) {
429
- return output.error().title("Could not publish sync project.").message(publishResult3.error).exit("error");
435
+ return output.error().title("Could not publish from GitHub").message(publishResult3.error).exit("error");
430
436
  }
431
437
  return await waitForPublish({
432
438
  teamUid: auth.teamUid,
@@ -435,12 +441,12 @@ async function publishAction(args) {
435
441
  }
436
442
  if (!isGithubBackedDocsProject(resolved.project)) {
437
443
  return output.error().title("Your project is not linked to a GitHub repository").message(
438
- "For a sync publish, please configure your GitHub connection through the dashboard."
444
+ "Connect the project to a GitHub repository in the Scalar Dashboard to publish from GitHub."
439
445
  ).exit("error");
440
446
  }
441
447
  if (resolved.project.repository.expired) {
442
- return output.error().title("Your GitHub repository access is expired.").message(
443
- "Please reconnect your project through the Scalar Dashboard to publish via sync."
448
+ return output.error().title("GitHub repository access has expired").message(
449
+ "Reconnect the GitHub repository in the Scalar Dashboard to publish from GitHub."
444
450
  ).exit("error");
445
451
  }
446
452
  const publishResult2 = await publishUnifiedDocsProjectFromGithub({
@@ -449,7 +455,7 @@ async function publishAction(args) {
449
455
  preview
450
456
  });
451
457
  if (!publishResult2.success) {
452
- return output.error().title("Could not publish sync project.").message(publishResult2.error).exit("error");
458
+ return output.error().title("Could not publish from GitHub").message(publishResult2.error).exit("error");
453
459
  }
454
460
  return await waitForPublish({
455
461
  teamUid: auth.teamUid,
@@ -461,6 +467,7 @@ async function publishAction(args) {
461
467
  renderConfigError(configResult.error);
462
468
  }
463
469
  const { config, filePath: configPath } = configResult;
470
+ warnIfLegacyConfig(config);
464
471
  const publishResult = await publishProject({
465
472
  config,
466
473
  slug,
@@ -469,7 +476,7 @@ async function publishAction(args) {
469
476
  ...preview && { mode: "preview" }
470
477
  });
471
478
  if (!publishResult.success) {
472
- return output.error().title("Something went wrong while deploying the project").message(
479
+ return output.error().title("Could not deploy the project").message(
473
480
  publishResult.error instanceof Error ? publishResult.error.message : publishResult.error
474
481
  ).exit("error");
475
482
  }
@@ -478,12 +485,18 @@ async function publishAction(args) {
478
485
  publishUid: publishResult.publishUid
479
486
  });
480
487
  }
488
+ function warnIfLegacyConfig(config) {
489
+ if (config.version !== ConfigVersion.V1) return;
490
+ output.warn().title("This project uses a v1 Scalar config").line(
491
+ "It will be upgraded to v2 for this build only. Run `scalar project upgrade` to upgrade the config file."
492
+ ).print();
493
+ }
481
494
  async function waitForPublish({
482
495
  teamUid,
483
496
  publishUid
484
497
  }) {
485
498
  const dbClient = await getDatabaseClient();
486
- const logger = output.info({ animate: true }).loader("Deployment in progress");
499
+ const logger = output.info({ animate: true }).loader("Deploying project\u2026");
487
500
  while (true) {
488
501
  const deployStatus = await getDeployStatus({
489
502
  client: dbClient,
@@ -491,9 +504,7 @@ async function waitForPublish({
491
504
  teamUid
492
505
  });
493
506
  if (deployStatus.error === true) {
494
- return output.error().title(
495
- "Something went wrong while getting information about the deployment"
496
- ).exit("error");
507
+ return output.error().title("Could not load deployment status").exit("error");
497
508
  }
498
509
  logger.update("loader", 0, { content: deployStatus.data.message });
499
510
  if (deployStatus.data.status === "deployed") {
@@ -503,6 +514,9 @@ async function waitForPublish({
503
514
  `${deployStatus.data.preview ? "Preview URL" : "Deployment URL"}: ${deploymentUrl}`
504
515
  ).print();
505
516
  }
517
+ if (deployStatus.data.hasWarnings) {
518
+ output.warn().title("The build finished with warnings").line("Check the build log in the Scalar Dashboard for details.").print();
519
+ }
506
520
  logger.exit("success");
507
521
  return;
508
522
  }
@@ -525,5 +539,6 @@ async function getDeployStatus({
525
539
  }
526
540
  export {
527
541
  publishAction,
528
- waitForPublish
542
+ waitForPublish,
543
+ warnIfLegacyConfig
529
544
  };
@@ -1,42 +1,50 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getProjectDeployments
4
- } from "./chunk-22HYZ7LE.js";
4
+ } from "./chunk-DQD2753S.js";
5
5
  import {
6
6
  resolveProject
7
7
  } from "./chunk-TSURUX4A.js";
8
8
  import {
9
- formatAbsoluteTime
10
- } from "./chunk-AEFPCC4U.js";
11
- import "./chunk-2OCWX42S.js";
12
- import "./chunk-5DEU2DVL.js";
9
+ formatListTime
10
+ } from "./chunk-XP5UM7SF.js";
11
+ import "./chunk-AEFPCC4U.js";
12
+ import {
13
+ getPublishPreviewUrl
14
+ } from "./chunk-UFSFY7Z4.js";
15
+ import "./chunk-NWJ37GI2.js";
16
+ import "./chunk-U6VE6JOS.js";
13
17
  import {
14
18
  apiService
15
- } from "./chunk-EXY3ZTV4.js";
16
- import "./chunk-KKRGBXCE.js";
17
- import "./chunk-MLSZVVTT.js";
18
- import "./chunk-FDC2IESH.js";
19
- import "./chunk-C2KAWRIX.js";
20
- import "./chunk-R5LK6VPY.js";
19
+ } from "./chunk-F3OPMYME.js";
20
+ import "./chunk-FG5AOTDN.js";
21
+ import "./chunk-SEURG74P.js";
22
+ import "./chunk-3TFOA64C.js";
23
+ import "./chunk-5ENKYZA4.js";
24
+ import "./chunk-Y6XGC4K5.js";
25
+ import "./chunk-SOV4POMS.js";
26
+ import "./chunk-T34TL6KL.js";
27
+ import "./chunk-V6LUKXBV.js";
28
+ import "./chunk-VUXPDHTQ.js";
21
29
  import {
22
30
  getAuthData
23
- } from "./chunk-QVQ4PNVL.js";
24
- import "./chunk-UXJ753NV.js";
25
- import "./chunk-5UHLAJQD.js";
26
- import "./chunk-5JLVQVKO.js";
27
- import "./chunk-K74E42RV.js";
28
- import "./chunk-KCCFN4F7.js";
29
- import "./chunk-6XWCMJDB.js";
31
+ } from "./chunk-3RIUDHLG.js";
32
+ import "./chunk-N5CJ5MTY.js";
33
+ import "./chunk-US54KYOJ.js";
34
+ import "./chunk-BQYVSPAI.js";
35
+ import "./chunk-VRZSDUZK.js";
30
36
  import "./chunk-4ORL4MST.js";
37
+ import "./chunk-MN2AFJXM.js";
31
38
  import {
32
39
  output,
33
40
  printTable
34
41
  } from "./chunk-T5HJUAWB.js";
35
- import "./chunk-XEDGMZJD.js";
42
+ import "./chunk-25XERWCE.js";
43
+ import "./chunk-AVZFSWPD.js";
36
44
  import {
37
45
  external_exports,
38
46
  slugSchema
39
- } from "./chunk-IKT5F47M.js";
47
+ } from "./chunk-I57ID5K7.js";
40
48
  import "./chunk-3MZYUBJ6.js";
41
49
 
42
50
  // src/domains/project/deployments/list/action.ts
@@ -58,11 +66,13 @@ function colorStatus(status) {
58
66
  async function listAction(args) {
59
67
  const argsParseResult = external_exports.object({ slug: slugSchema.optional() }).safeParse(args);
60
68
  if (argsParseResult.error) {
61
- return output.error().title("Invalid Arguments").message(argsParseResult.error.issues[0].message).exit("error");
69
+ return output.error().title("Invalid arguments").message(argsParseResult.error.issues[0].message).exit("error");
62
70
  }
63
71
  const { slug } = argsParseResult.data;
64
72
  if (!slug) {
65
- return output.error().title("Invalid argument").message("Slug is required. Try passing --slug flag.").exit("error");
73
+ return output.error().title("Invalid argument").message(
74
+ "Slug is required. Run scalar project list to find your project slug, then pass --slug <slug>."
75
+ ).exit("error");
66
76
  }
67
77
  const apiClient = await apiService();
68
78
  const auth = await getAuthData();
@@ -81,26 +91,44 @@ async function listAction(args) {
81
91
  return output.error().title("Could not load deployment history").message(deploymentsResult.error).exit("error");
82
92
  }
83
93
  if (deploymentsResult.deployments.length === 0) {
84
- output.info().title(`No deployments found for project "${slug}".`).print();
94
+ output.info().message(`No deployments found for project "${slug}".`).print();
85
95
  return;
86
96
  }
97
+ const domains = await apiClient.publish.getProjectDomains(project.uid);
98
+ if (domains.error) {
99
+ console.error(
100
+ "[WARN] Could not load deployment URLs. Build history is still available."
101
+ );
102
+ }
103
+ const scalarDomain = domains.error ? null : domains.data.scalarDomain;
104
+ const now = Date.now();
87
105
  printTable(
88
106
  [
89
- { name: "current", title: " ", alignment: "center" },
107
+ { name: "current", title: "Live", alignment: "center" },
90
108
  { name: "id", title: "Build ID", alignment: "left" },
91
109
  { name: "status", title: "Status", alignment: "left" },
92
110
  { name: "deployed", title: "Deployed", alignment: "left" },
93
- { name: "commit", title: "Commit", alignment: "left" }
111
+ { name: "commit", title: "Commit", alignment: "left" },
112
+ { name: "url", title: "URL", alignment: "left" }
94
113
  ],
95
114
  deploymentsResult.deployments.map((record) => {
96
115
  const isLive = record.uid === activeUid;
97
116
  const deployedAt = record.deployedAt ?? (record.status === "deployed" ? record.createdAt : null);
117
+ const url = (() => {
118
+ if (record.status !== "deployed" || !scalarDomain) return "\u2014";
119
+ try {
120
+ return getPublishPreviewUrl(record.uid, scalarDomain, record.subpath);
121
+ } catch {
122
+ return "\u2014";
123
+ }
124
+ })();
98
125
  return {
99
126
  current: isLive ? as.green("\u279C") : " ",
100
127
  id: isLive ? as.green(record.uid) : record.uid,
101
128
  status: colorStatus(record.status),
102
- deployed: deployedAt ? formatAbsoluteTime(deployedAt * 1e3) : as.dim("\u2014"),
103
- commit: record.commitSha ? record.commitSha.slice(0, 7) : as.dim("\u2014")
129
+ deployed: deployedAt !== null ? formatListTime(deployedAt, now) : as.dim("\u2014"),
130
+ commit: record.commitSha ? record.commitSha.slice(0, 7) : as.dim("\u2014"),
131
+ url
104
132
  };
105
133
  })
106
134
  );