@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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/helpers/time.ts
|
|
4
|
+
async function measureTime(fn) {
|
|
5
|
+
const start = performance.now();
|
|
6
|
+
const result = await fn();
|
|
7
|
+
const end = performance.now();
|
|
8
|
+
return {
|
|
9
|
+
result,
|
|
10
|
+
executionTimeMs: end - start
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
measureTime
|
|
16
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/domains/project/download-isolate/index.ts
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { Command } from "commander";
|
|
7
|
+
var ISOLATE_EXTRACTION_DIR = path.join(os.homedir(), ".scalar");
|
|
8
|
+
var ISOLATE_DIR = path.join(ISOLATE_EXTRACTION_DIR, "isolate");
|
|
9
|
+
var DownloadIsolateCommand = () => {
|
|
10
|
+
const cmd = new Command("download-isolate");
|
|
11
|
+
cmd.description("Download the docs isolate");
|
|
12
|
+
cmd.action(async () => {
|
|
13
|
+
const { downloadIsolate } = await import("./action-P7LN6FGY.js");
|
|
14
|
+
await downloadIsolate();
|
|
15
|
+
});
|
|
16
|
+
return cmd;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
ISOLATE_EXTRACTION_DIR,
|
|
21
|
+
ISOLATE_DIR,
|
|
22
|
+
DownloadIsolateCommand
|
|
23
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
registryUrl
|
|
4
|
+
} from "./chunk-T7MDADON.js";
|
|
5
|
+
|
|
6
|
+
// src/domains/registry/helpers/fetch.ts
|
|
7
|
+
async function fetchFromRegistry(path, accessToken) {
|
|
8
|
+
let response;
|
|
9
|
+
try {
|
|
10
|
+
response = await fetch(registryUrl(path), {
|
|
11
|
+
headers: {
|
|
12
|
+
"x-scalar-auth": accessToken
|
|
13
|
+
},
|
|
14
|
+
// Should always error on redirect
|
|
15
|
+
redirect: "error"
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return {
|
|
19
|
+
error: true,
|
|
20
|
+
message: error instanceof Error && error.message.length > 0 ? error.message : "Registry request failed before a response was received."
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
const message = await response.text();
|
|
25
|
+
return {
|
|
26
|
+
error: true,
|
|
27
|
+
message: message.length ? message : `Registry request failed with status ${response.status}.`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
error: false,
|
|
32
|
+
data: await response.text()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
fetchFromRegistry
|
|
38
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/config.ts
|
|
4
|
+
import { portNumbers } from "get-port";
|
|
5
|
+
var config = {
|
|
6
|
+
projects: {
|
|
7
|
+
dashboard: process.env.DASHBOARD_URL ?? "https://dashboard.scalar.com",
|
|
8
|
+
sandbox: process.env.SANDBOX_URL ?? "https://sandbox.scalar.com",
|
|
9
|
+
registry: process.env.REGISTRY_URL ?? "https://registry.scalar.com"
|
|
10
|
+
},
|
|
11
|
+
services: {
|
|
12
|
+
api: process.env.BASE_URL ?? "https://services.scalar.com"
|
|
13
|
+
},
|
|
14
|
+
auth: {
|
|
15
|
+
callback: {
|
|
16
|
+
preferredPortRange: process.env.PREFERRED_PORT ? Number.parseInt(process.env.PREFERRED_PORT) : portNumbers(4799, 5100)
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
cdnUrl: process.env.CDN_URL ?? "https://cdn.scalar.com",
|
|
20
|
+
ssgDocsIsolateVersion: process.env.SSG_DOCS_ISOLATE_VERSION ?? "1.4.7"
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
config
|
|
25
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
findConfig,
|
|
4
|
+
parseConfig
|
|
5
|
+
} from "./chunk-47Y4L5IT.js";
|
|
6
|
+
import {
|
|
7
|
+
ConfigVersion
|
|
8
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
9
|
+
import {
|
|
10
|
+
external_exports
|
|
11
|
+
} from "./chunk-H2WRMLYY.js";
|
|
12
|
+
import {
|
|
13
|
+
output
|
|
14
|
+
} from "./chunk-X4QLDBB5.js";
|
|
15
|
+
|
|
16
|
+
// src/domains/project/check-config/parse-config.ts
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
function readAndParseConfig(configPath) {
|
|
19
|
+
const startTime = performance.now();
|
|
20
|
+
const file = findConfig(configPath);
|
|
21
|
+
if (!file) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
error: {
|
|
25
|
+
type: "file-not-found",
|
|
26
|
+
message: "Could not find the Scalar Configuration file",
|
|
27
|
+
inputPath: configPath
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const fileContent = fs.readFileSync(file, "utf-8");
|
|
32
|
+
const parseConfigResult = parseConfig(fileContent);
|
|
33
|
+
if (!parseConfigResult.success) {
|
|
34
|
+
if (parseConfigResult.errorType === "validation") {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: {
|
|
38
|
+
type: "validation-error",
|
|
39
|
+
message: "The given Scalar Configuration is invalid",
|
|
40
|
+
filePath: file,
|
|
41
|
+
prettyError: external_exports.prettifyError(parseConfigResult.error),
|
|
42
|
+
version: parseConfigResult.version
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
error: {
|
|
49
|
+
type: "parse-error",
|
|
50
|
+
message: "Could not parse the Scalar Configuration file",
|
|
51
|
+
filePath: file,
|
|
52
|
+
detail: typeof parseConfigResult.error === "string" ? parseConfigResult.error : parseConfigResult.error instanceof Error ? parseConfigResult.error.message : void 0
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
filePath: file,
|
|
59
|
+
validationTime: Math.round(performance.now() - startTime),
|
|
60
|
+
config: parseConfigResult.config
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/domains/project/render-config-error.ts
|
|
65
|
+
import as from "ansis";
|
|
66
|
+
function renderConfigError(error) {
|
|
67
|
+
if (error.type === "file-not-found") {
|
|
68
|
+
return output.error().title("Scalar Configuration file not found").message(error.inputPath).line(
|
|
69
|
+
as.grey(
|
|
70
|
+
"Create a `scalar.config.json`, or pass the path to your configuration file as an argument."
|
|
71
|
+
)
|
|
72
|
+
).exit("error");
|
|
73
|
+
}
|
|
74
|
+
if (error.type === "parse-error") {
|
|
75
|
+
const block2 = output.error().title("Invalid configuration file").message("Could not parse the Scalar Configuration file:").line(error.filePath);
|
|
76
|
+
if (error.detail) {
|
|
77
|
+
block2.message(error.detail);
|
|
78
|
+
}
|
|
79
|
+
return block2.exit("error");
|
|
80
|
+
}
|
|
81
|
+
const block = output.error().title("The given Scalar Configuration is invalid").message(error.filePath);
|
|
82
|
+
const note = versionNote(error.version);
|
|
83
|
+
if (note) {
|
|
84
|
+
block.line(note);
|
|
85
|
+
}
|
|
86
|
+
block.line("");
|
|
87
|
+
for (const line of error.prettyError.split("\n")) {
|
|
88
|
+
block.line(line);
|
|
89
|
+
}
|
|
90
|
+
return block.exit("error");
|
|
91
|
+
}
|
|
92
|
+
function versionNote(version) {
|
|
93
|
+
if (version === ConfigVersion.V2) {
|
|
94
|
+
return as.grey("Validated as Scalar Configuration v2.0.0.");
|
|
95
|
+
}
|
|
96
|
+
if (version === ConfigVersion.V1) {
|
|
97
|
+
return as.grey(
|
|
98
|
+
'Validated as a legacy (V1) configuration. If this should be a v2 config, add a top-level `scalar: "2.0.0"` field.'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
readAndParseConfig,
|
|
106
|
+
renderConfigError
|
|
107
|
+
};
|