@scalar/cli 2.0.0 → 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.
- package/README.md +42 -2
- package/chunks/action-45OGQB2M.js +138 -0
- package/chunks/action-5R5FDF6S.js +2097 -0
- package/chunks/action-ANU5HGC4.js +34 -0
- package/chunks/action-BMFXENMX.js +176 -0
- package/chunks/action-BNEGJBUH.js +38 -0
- package/chunks/action-BYZUBXVB.js +82 -0
- package/chunks/action-C5VB4ITT.js +132 -0
- package/chunks/action-CCW66QJN.js +72 -0
- package/chunks/action-CLSD7O2R.js +60 -0
- package/chunks/action-CQ56FVES.js +65 -0
- package/chunks/action-CYP4VDK3.js +148 -0
- package/chunks/action-DFKHSDFV.js +36 -0
- package/chunks/action-F4Y6Q2VB.js +92 -0
- package/chunks/action-GB6DM53B.js +70 -0
- package/chunks/action-GEBRPNRT.js +87 -0
- package/chunks/action-H5OHT2GV.js +56 -0
- package/chunks/action-HD2T6BFJ.js +54 -0
- package/chunks/action-HNKM3Q65.js +65 -0
- package/chunks/action-JOSVV6YA.js +71 -0
- package/chunks/action-MENXFJH3.js +204 -0
- package/chunks/action-P7LN6FGY.js +13 -0
- package/chunks/action-PVDDRIM6.js +130 -0
- package/chunks/action-Q5UJ32D6.js +46 -0
- package/chunks/action-R6ZZO26F.js +299 -0
- package/chunks/action-STIEAXOE.js +53 -0
- package/chunks/action-TPBKPHNS.js +110 -0
- package/chunks/action-TWFJNQ2R.js +95 -0
- package/chunks/action-TZ5KGAQT.js +64 -0
- package/chunks/action-UDZUUJSI.js +49 -0
- package/chunks/action-W5BATF4Q.js +197 -0
- package/chunks/agent-XGLOHXNA.js +112 -0
- package/chunks/build.action-LKOILPA6.js +108 -0
- package/chunks/chunk-23I5PKZZ.js +78 -0
- package/chunks/chunk-2BSG2QHO.js +455 -0
- package/chunks/chunk-3MZYUBJ6.js +49 -0
- package/chunks/chunk-47Y4L5IT.js +63361 -0
- package/chunks/chunk-4DGQIAJX.js +359 -0
- package/chunks/chunk-4QS7SJTG.js +138 -0
- package/chunks/chunk-5BISXQX4.js +447 -0
- package/chunks/chunk-5BPPGTUU.js +463 -0
- package/chunks/chunk-AEFPCC4U.js +16 -0
- package/chunks/chunk-AHWWJ3MD.js +32 -0
- package/chunks/chunk-ASMHW5AY.js +19 -0
- package/chunks/chunk-B6QZJWCQ.js +92 -0
- package/chunks/chunk-DOVIWNKQ.js +108 -0
- package/chunks/chunk-H2WRMLYY.js +13780 -0
- package/chunks/chunk-HQKBZOYU.js +34 -0
- package/chunks/chunk-ISGLWBXZ.js +4265 -0
- package/chunks/chunk-IX7LJ3AD.js +17 -0
- package/chunks/chunk-JFIXNSPP.js +26 -0
- package/chunks/chunk-K74E42RV.js +7311 -0
- package/chunks/chunk-KHDYYVYF.js +16 -0
- package/chunks/chunk-KWOL7A6J.js +23 -0
- package/chunks/chunk-NUXPNUSS.js +38 -0
- package/chunks/chunk-OAXFCOJV.js +25 -0
- package/chunks/chunk-P2VH7DOC.js +107 -0
- package/chunks/chunk-P646T2WH.js +1608 -0
- package/chunks/chunk-SHSHFGA7.js +297 -0
- package/chunks/chunk-SXYALPYK.js +2709 -0
- package/chunks/chunk-T7B6WNZC.js +18 -0
- package/chunks/chunk-T7MDADON.js +17 -0
- package/chunks/chunk-TLFMATXR.js +344 -0
- package/chunks/chunk-TQ5XC2E3.js +284 -0
- package/chunks/chunk-UPUTMFD4.js +465 -0
- package/chunks/chunk-VTYTPSXO.js +161 -0
- package/chunks/chunk-X4QLDBB5.js +221 -0
- package/chunks/chunk-ZTVWAKNJ.js +21 -0
- package/chunks/create.action-FFQLBSJH.js +108 -0
- package/chunks/delete.action-QNN3LC2F.js +96 -0
- package/chunks/delete.action-STHQHP4F.js +88 -0
- package/chunks/get.action-OTKYOP3Z.js +87 -0
- package/chunks/list.action-6I5EZAVB.js +95 -0
- package/chunks/list.action-KDM5RHEH.js +116 -0
- package/chunks/publish.action-PODTVRXS.js +182 -0
- package/chunks/update.action-4F6STTEQ.js +101 -0
- package/chunks/update.action-KMD4ZM75.js +95 -0
- package/docs.html +393 -230
- package/index.js +645 -98865
- package/package.json +16 -14
package/README.md
CHANGED
|
@@ -170,7 +170,7 @@ Options:
|
|
|
170
170
|
-h, --help display help for command
|
|
171
171
|
|
|
172
172
|
Commands:
|
|
173
|
-
bundle [options] [file|url] Bundle an OpenAPI
|
|
173
|
+
bundle [options] [file|url] Bundle an OpenAPI document by resolving all references and external dependencies
|
|
174
174
|
split [options] [file|url] Split your OpenAPI documents on small chunks
|
|
175
175
|
join [options] <files...> Merge multiple OpenAPI documents into a single unified document
|
|
176
176
|
format [options] [file|url] Format an OpenAPI file
|
|
@@ -190,7 +190,7 @@ Commands:
|
|
|
190
190
|
```
|
|
191
191
|
Usage: scalar document bundle [options] [file|url]
|
|
192
192
|
|
|
193
|
-
Bundle an OpenAPI
|
|
193
|
+
Bundle an OpenAPI document by resolving all references and external dependencies
|
|
194
194
|
|
|
195
195
|
Arguments:
|
|
196
196
|
file|url Path to OpenAPI file or URL to bundle
|
|
@@ -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
|
+
};
|