@scalar/cli 2.0.1 → 2.1.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 (80) hide show
  1. package/README.md +40 -0
  2. package/chunks/action-45OGQB2M.js +138 -0
  3. package/chunks/action-5R5FDF6S.js +2097 -0
  4. package/chunks/action-ANU5HGC4.js +34 -0
  5. package/chunks/action-BMFXENMX.js +176 -0
  6. package/chunks/action-BNEGJBUH.js +38 -0
  7. package/chunks/action-BYZUBXVB.js +82 -0
  8. package/chunks/action-C5VB4ITT.js +132 -0
  9. package/chunks/action-CCW66QJN.js +72 -0
  10. package/chunks/action-CLSD7O2R.js +60 -0
  11. package/chunks/action-CQ56FVES.js +65 -0
  12. package/chunks/action-CYP4VDK3.js +148 -0
  13. package/chunks/action-DFKHSDFV.js +36 -0
  14. package/chunks/action-F4Y6Q2VB.js +92 -0
  15. package/chunks/action-GB6DM53B.js +70 -0
  16. package/chunks/action-GEBRPNRT.js +87 -0
  17. package/chunks/action-H5OHT2GV.js +56 -0
  18. package/chunks/action-HD2T6BFJ.js +54 -0
  19. package/chunks/action-HNKM3Q65.js +65 -0
  20. package/chunks/action-JOSVV6YA.js +71 -0
  21. package/chunks/action-MENXFJH3.js +204 -0
  22. package/chunks/action-P7LN6FGY.js +13 -0
  23. package/chunks/action-PVDDRIM6.js +130 -0
  24. package/chunks/action-Q5UJ32D6.js +46 -0
  25. package/chunks/action-R6ZZO26F.js +299 -0
  26. package/chunks/action-STIEAXOE.js +53 -0
  27. package/chunks/action-TPBKPHNS.js +110 -0
  28. package/chunks/action-TWFJNQ2R.js +95 -0
  29. package/chunks/action-TZ5KGAQT.js +64 -0
  30. package/chunks/action-UDZUUJSI.js +49 -0
  31. package/chunks/action-W5BATF4Q.js +197 -0
  32. package/chunks/agent-XGLOHXNA.js +112 -0
  33. package/chunks/build.action-LKOILPA6.js +108 -0
  34. package/chunks/chunk-23I5PKZZ.js +78 -0
  35. package/chunks/chunk-2BSG2QHO.js +455 -0
  36. package/chunks/chunk-3MZYUBJ6.js +49 -0
  37. package/chunks/chunk-47Y4L5IT.js +63361 -0
  38. package/chunks/chunk-4DGQIAJX.js +359 -0
  39. package/chunks/chunk-4QS7SJTG.js +138 -0
  40. package/chunks/chunk-5BISXQX4.js +447 -0
  41. package/chunks/chunk-5BPPGTUU.js +463 -0
  42. package/chunks/chunk-AEFPCC4U.js +16 -0
  43. package/chunks/chunk-AHWWJ3MD.js +32 -0
  44. package/chunks/chunk-ASMHW5AY.js +19 -0
  45. package/chunks/chunk-B6QZJWCQ.js +92 -0
  46. package/chunks/chunk-DOVIWNKQ.js +108 -0
  47. package/chunks/chunk-H2WRMLYY.js +13780 -0
  48. package/chunks/chunk-HQKBZOYU.js +34 -0
  49. package/chunks/chunk-ISGLWBXZ.js +4265 -0
  50. package/chunks/chunk-IX7LJ3AD.js +17 -0
  51. package/chunks/chunk-JFIXNSPP.js +26 -0
  52. package/chunks/chunk-K74E42RV.js +7311 -0
  53. package/chunks/chunk-KHDYYVYF.js +16 -0
  54. package/chunks/chunk-KWOL7A6J.js +23 -0
  55. package/chunks/chunk-NUXPNUSS.js +38 -0
  56. package/chunks/chunk-OAXFCOJV.js +25 -0
  57. package/chunks/chunk-P2VH7DOC.js +107 -0
  58. package/chunks/chunk-P646T2WH.js +1608 -0
  59. package/chunks/chunk-SHSHFGA7.js +297 -0
  60. package/chunks/chunk-SXYALPYK.js +2709 -0
  61. package/chunks/chunk-T7B6WNZC.js +18 -0
  62. package/chunks/chunk-T7MDADON.js +17 -0
  63. package/chunks/chunk-TLFMATXR.js +344 -0
  64. package/chunks/chunk-TQ5XC2E3.js +284 -0
  65. package/chunks/chunk-UPUTMFD4.js +465 -0
  66. package/chunks/chunk-VTYTPSXO.js +161 -0
  67. package/chunks/chunk-X4QLDBB5.js +221 -0
  68. package/chunks/chunk-ZTVWAKNJ.js +21 -0
  69. package/chunks/create.action-FFQLBSJH.js +108 -0
  70. package/chunks/delete.action-QNN3LC2F.js +96 -0
  71. package/chunks/delete.action-STHQHP4F.js +88 -0
  72. package/chunks/get.action-OTKYOP3Z.js +87 -0
  73. package/chunks/list.action-6I5EZAVB.js +95 -0
  74. package/chunks/list.action-KDM5RHEH.js +116 -0
  75. package/chunks/publish.action-PODTVRXS.js +182 -0
  76. package/chunks/update.action-4F6STTEQ.js +101 -0
  77. package/chunks/update.action-KMD4ZM75.js +95 -0
  78. package/docs.html +310 -209
  79. package/index.js +645 -99061
  80. package/package.json +13 -11
package/README.md CHANGED
@@ -389,6 +389,8 @@ Commands:
389
389
  create [options] Create a new project that is not linked to a github project.
390
390
  preview [options] [config] Preview scalar guides
391
391
  publish [options] Publish new build for a github sync project that is not linked.
392
+ rollback [options] Roll the live deployment back to a previously deployed build.
393
+ deployments Inspect a project deployment history.
392
394
  upgrade [config] Upgrade scalar project
393
395
  help [command] display help for command
394
396
  ```
@@ -462,6 +464,44 @@ Options:
462
464
  -h, --help display help for command
463
465
  ```
464
466
 
467
+ #### rollback
468
+ ```
469
+ Usage: scalar project rollback [options]
470
+
471
+ Roll the live deployment back to a previously deployed build.
472
+
473
+ Options:
474
+ -s, --slug [slug] Project slug found in Scalar Dashboard
475
+ -t, --to <publishUid> Roll back to a specific build id (defaults to the next older deployed build)
476
+ -y, --yes Skip the confirmation prompt
477
+ -h, --help display help for command
478
+ ```
479
+
480
+ #### deployments
481
+ ```
482
+ Usage: scalar project deployments [options] [command]
483
+
484
+ Inspect a project deployment history.
485
+
486
+ Options:
487
+ -h, --help display help for command
488
+
489
+ Commands:
490
+ list [options] List the production deployment history for a project.
491
+ help [command] display help for command
492
+ ```
493
+
494
+ ##### list
495
+ ```
496
+ Usage: scalar project deployments list [options]
497
+
498
+ List the production deployment history for a project.
499
+
500
+ Options:
501
+ -s, --slug [slug] Project slug found in Scalar Dashboard
502
+ -h, --help display help for command
503
+ ```
504
+
465
505
  #### upgrade
466
506
  ```
467
507
  Usage: scalar project upgrade [options] [config]
@@ -0,0 +1,138 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ loadOpenApiFile,
4
+ printSpecificationBanner
5
+ } from "./chunk-23I5PKZZ.js";
6
+ import {
7
+ watchFile
8
+ } from "./chunk-5BISXQX4.js";
9
+ import "./chunk-OAXFCOJV.js";
10
+ import "./chunk-4DGQIAJX.js";
11
+ import "./chunk-ISGLWBXZ.js";
12
+ import "./chunk-H2WRMLYY.js";
13
+ import "./chunk-IX7LJ3AD.js";
14
+ import {
15
+ output
16
+ } from "./chunk-X4QLDBB5.js";
17
+ import "./chunk-3MZYUBJ6.js";
18
+
19
+ // src/domains/document/mock/action.ts
20
+ import as2 from "ansis";
21
+
22
+ // src/domains/document/mock/helpers.ts
23
+ import { serve } from "@hono/node-server";
24
+ import as from "ansis";
25
+ import { createMockServer } from "@scalar/mock-server";
26
+ var bootServer = async ({
27
+ specification,
28
+ port
29
+ }) => {
30
+ const app = await createMockServer({
31
+ specification,
32
+ onRequest
33
+ });
34
+ return serve(
35
+ {
36
+ fetch: app.fetch,
37
+ port: port ?? 3e3
38
+ },
39
+ (info) => {
40
+ output.info().message(
41
+ `${as.green.bold("\u279C Mock Server")} ${as.white(
42
+ "listening on"
43
+ )} ${as.cyan(`http://localhost:${info.port}`)}`
44
+ ).print();
45
+ }
46
+ );
47
+ };
48
+ var printAvailablePaths = (specification) => {
49
+ output.info().message(as.white.bold("Available Paths")).print();
50
+ if (specification?.paths === void 0 || Object.keys(specification?.paths).length === 0) {
51
+ output.warn().title(as.grey("Could not find any paths in the OpenAPI file.")).print();
52
+ }
53
+ for (const path in specification?.paths ?? []) {
54
+ if (specification?.paths?.[path] === void 0) {
55
+ continue;
56
+ }
57
+ for (const method in specification.paths[path]) {
58
+ if (specification.paths[path][method] === void 0) {
59
+ continue;
60
+ }
61
+ output.info().line(
62
+ `${as[getMethodColor(method)].bold(method.toUpperCase().padEnd(6))} ${as.grey(`${path}`)}`
63
+ ).print();
64
+ }
65
+ }
66
+ output.info().line().print();
67
+ };
68
+ var onRequest = ({
69
+ context,
70
+ operation
71
+ }) => {
72
+ const { method } = context.req;
73
+ output.info().line(
74
+ `${as[getMethodColor(method)].bold(method.toUpperCase().padEnd(6))} ${as.grey(`${context.req.path}`)} ${as.grey("\u2192")} ${operation?.operationId ? as.white(operation.operationId) : as.red("[ERROR] 404 Not Found")}`
75
+ ).print();
76
+ };
77
+ function getMethodColor(method) {
78
+ const colors = {
79
+ get: "green",
80
+ post: "cyan",
81
+ put: "yellow",
82
+ delete: "red",
83
+ patch: "magenta"
84
+ };
85
+ return colors[method.toLowerCase()] ?? "grey";
86
+ }
87
+
88
+ // src/domains/document/mock/action.ts
89
+ async function mockAction(fileArgument, { watch, once, port }) {
90
+ let server;
91
+ const result = await loadOpenApiFile(fileArgument);
92
+ if (!result.valid) {
93
+ return output.error().title("Invalid OpenAPI document").exit("error");
94
+ }
95
+ printSpecificationBanner({
96
+ version: result.version,
97
+ schema: result.schema
98
+ });
99
+ let { specification } = result;
100
+ if (watch) {
101
+ await watchFile(fileArgument, async () => {
102
+ const newResult = await loadOpenApiFile(fileArgument);
103
+ const specificationHasChanged = newResult?.specification && JSON.stringify(specification) !== JSON.stringify(newResult.specification);
104
+ if (specificationHasChanged && newResult.valid) {
105
+ output.info().title(as2.grey("OpenAPI file modified")).print();
106
+ printSpecificationBanner({
107
+ version: newResult.version,
108
+ schema: newResult.schema
109
+ });
110
+ specification = newResult.specification;
111
+ if (specification) {
112
+ server.close();
113
+ server = await bootServer({
114
+ specification,
115
+ port
116
+ });
117
+ }
118
+ }
119
+ });
120
+ }
121
+ if (!specification) {
122
+ output.warn().title("Could not find any paths in the OpenAPI file.").print();
123
+ return;
124
+ }
125
+ printAvailablePaths(specification);
126
+ server = await bootServer({
127
+ specification,
128
+ port
129
+ });
130
+ if (once) {
131
+ setTimeout(() => {
132
+ server.close();
133
+ }, 2e3);
134
+ }
135
+ }
136
+ export {
137
+ mockAction
138
+ };