@mintlify/cli 4.0.1813 → 4.1.1
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/dist/assets/export-scripts/README.classic.md +15 -0
- package/dist/assets/export-scripts/README.md +14 -0
- package/dist/assets/export-scripts/serve.js +114 -0
- package/dist/assets/export-scripts/start-docs.bat +10 -0
- package/dist/assets/export-scripts/start-docs.sh +9 -0
- package/dist/assets/og/Inter-Bold.ttf +0 -0
- package/dist/assets/og/Inter-Medium.ttf +0 -0
- package/dist/assets/og/Inter-Regular.ttf +0 -0
- package/dist/assets/og/Inter-SemiBold.ttf +0 -0
- package/dist/assets/og/PaperMono-Regular.ttf +0 -0
- package/dist/assets/og/index_bg.wasm +0 -0
- package/dist/assets/openChrome.applescript +94 -0
- package/dist/assets/socket.io/socket.io.esm.min.js +7 -0
- package/dist/assets/socket.io/socket.io.esm.min.js.map +1 -0
- package/dist/assets/socket.io/socket.io.js +4907 -0
- package/dist/assets/socket.io/socket.io.js.map +1 -0
- package/dist/assets/socket.io/socket.io.min.js +7 -0
- package/dist/assets/socket.io/socket.io.min.js.map +1 -0
- package/dist/assets/socket.io/socket.io.msgpack.min.js +7 -0
- package/dist/assets/socket.io/socket.io.msgpack.min.js.map +1 -0
- package/dist/assets/xdg-open +1066 -0
- package/dist/assets/yargs-locales/be.json +46 -0
- package/dist/assets/yargs-locales/cs.json +51 -0
- package/dist/assets/yargs-locales/de.json +46 -0
- package/dist/assets/yargs-locales/en.json +55 -0
- package/dist/assets/yargs-locales/es.json +46 -0
- package/dist/assets/yargs-locales/fi.json +49 -0
- package/dist/assets/yargs-locales/fr.json +53 -0
- package/dist/assets/yargs-locales/hi.json +49 -0
- package/dist/assets/yargs-locales/hu.json +46 -0
- package/dist/assets/yargs-locales/id.json +50 -0
- package/dist/assets/yargs-locales/it.json +46 -0
- package/dist/assets/yargs-locales/ja.json +51 -0
- package/dist/assets/yargs-locales/ko.json +49 -0
- package/dist/assets/yargs-locales/nb.json +44 -0
- package/dist/assets/yargs-locales/nl.json +49 -0
- package/dist/assets/yargs-locales/nn.json +44 -0
- package/dist/assets/yargs-locales/pirate.json +13 -0
- package/dist/assets/yargs-locales/pl.json +49 -0
- package/dist/assets/yargs-locales/pt.json +45 -0
- package/dist/assets/yargs-locales/pt_BR.json +48 -0
- package/dist/assets/yargs-locales/ru.json +51 -0
- package/dist/assets/yargs-locales/th.json +46 -0
- package/dist/assets/yargs-locales/tr.json +48 -0
- package/dist/assets/yargs-locales/uk_UA.json +51 -0
- package/dist/assets/yargs-locales/uz.json +52 -0
- package/dist/assets/yargs-locales/zh_CN.json +48 -0
- package/dist/assets/yargs-locales/zh_TW.json +51 -0
- package/dist/converter-d8O3xkdU.js +102 -0
- package/dist/devtools-CGNZQKFV.js +24 -0
- package/dist/index.js +8 -0
- package/dist/rolldown-runtime-CEAe2Uac.js +7 -0
- package/dist/schemas-CBsmCNpK.js +372 -0
- package/dist/start.js +2310 -0
- package/package.json +38 -31
- package/.oxlintrc.json +0 -5
- package/.prettierignore +0 -2
- package/.turbo/turbo-build.log +0 -1
- package/CONTRIBUTING.md +0 -45
- package/__test__/agent-auth.test.ts +0 -114
- package/__test__/agent-claim.test.ts +0 -164
- package/__test__/agent-credentials.test.ts +0 -149
- package/__test__/agent-deployment.test.ts +0 -106
- package/__test__/agent-setup-config.test.ts +0 -324
- package/__test__/agent-setup.test.ts +0 -207
- package/__test__/agent.test.ts +0 -64
- package/__test__/analytics/client.test.ts +0 -180
- package/__test__/analytics/dates.test.ts +0 -12
- package/__test__/analytics/filters.test.ts +0 -116
- package/__test__/analytics/format.test.ts +0 -137
- package/__test__/authenticatedFetch.test.ts +0 -182
- package/__test__/brokenLinks.test.ts +0 -283
- package/__test__/checkPort.test.ts +0 -92
- package/__test__/deploy-github-actions.test.ts +0 -202
- package/__test__/deploy-github-setup.test.ts +0 -240
- package/__test__/deploy-instructions.test.ts +0 -155
- package/__test__/deploy.test.ts +0 -202
- package/__test__/feedback.test.ts +0 -34
- package/__test__/foreignSyntax.test.ts +0 -73
- package/__test__/format.test.ts +0 -72
- package/__test__/helpers.test.ts +0 -52
- package/__test__/init.test.ts +0 -119
- package/__test__/instructions.test.ts +0 -53
- package/__test__/keyring.test.ts +0 -82
- package/__test__/mdxAccessibility.test.ts +0 -81
- package/__test__/migrate.test.ts +0 -186
- package/__test__/openApiCheck.test.ts +0 -185
- package/__test__/pathValidation.test.ts +0 -25
- package/__test__/resolveFiles.test.ts +0 -70
- package/__test__/sessionId.test.ts +0 -46
- package/__test__/signup.test.ts +0 -36
- package/__test__/update.test.ts +0 -117
- package/__test__/utils.ts +0 -25
- package/__test__/validateCommand.test.ts +0 -647
- package/__test__/validateEngine.test.ts +0 -245
- package/__test__/validateRules.test.ts +0 -1275
- package/__test__/welcome.test.ts +0 -15
- package/__test__/workflows/client.test.ts +0 -126
- package/bin/accessibility.js +0 -111
- package/bin/accessibilityCheck.js +0 -82
- package/bin/addDomain.js +0 -130
- package/bin/agent-auth.js +0 -104
- package/bin/agent-claim.js +0 -97
- package/bin/agent-credentials.js +0 -124
- package/bin/agent-deployment.js +0 -96
- package/bin/agent-http.js +0 -45
- package/bin/agent-setup-config.js +0 -141
- package/bin/agent-setup.js +0 -146
- package/bin/agent.js +0 -42
- package/bin/analytics/client.js +0 -60
- package/bin/analytics/dates.js +0 -6
- package/bin/analytics/filters.js +0 -27
- package/bin/analytics/format.js +0 -13
- package/bin/analytics/index.js +0 -496
- package/bin/analytics/output.js +0 -75
- package/bin/analytics/types.js +0 -1
- package/bin/authenticatedFetch.js +0 -46
- package/bin/brokenLinks.js +0 -122
- package/bin/callbackServer.js +0 -65
- package/bin/cli.js +0 -813
- package/bin/comingSoon.js +0 -26
- package/bin/config.js +0 -78
- package/bin/constants.js +0 -16
- package/bin/deploy-base.js +0 -20
- package/bin/deploy-github-actions.js +0 -102
- package/bin/deploy-github-setup.js +0 -165
- package/bin/deploy-instructions.js +0 -71
- package/bin/deploy.js +0 -123
- package/bin/feedback.js +0 -36
- package/bin/format.js +0 -121
- package/bin/helpers.js +0 -238
- package/bin/idToken.js +0 -14
- package/bin/index.js +0 -102
- package/bin/init.js +0 -182
- package/bin/instructions.js +0 -101
- package/bin/keyring.js +0 -78
- package/bin/login.js +0 -123
- package/bin/logout.js +0 -18
- package/bin/mdxAccessibility.js +0 -113
- package/bin/mdxLinter.js +0 -55
- package/bin/middlewares/subdomainMiddleware.js +0 -28
- package/bin/middlewares/telemetryMiddleware.js +0 -61
- package/bin/migrate.js +0 -54
- package/bin/og.js +0 -145
- package/bin/openApiCheck.js +0 -99
- package/bin/resolveFiles.js +0 -114
- package/bin/score/client.js +0 -40
- package/bin/score/index.js +0 -211
- package/bin/score/types.js +0 -1
- package/bin/signup.js +0 -118
- package/bin/start.js +0 -36
- package/bin/status.js +0 -106
- package/bin/telemetry/client.js +0 -53
- package/bin/telemetry/distinctId.js +0 -68
- package/bin/telemetry/sessionId.js +0 -36
- package/bin/telemetry/track.js +0 -149
- package/bin/templates.js +0 -127
- package/bin/tokenRefresh.js +0 -50
- package/bin/tsconfig.build.tsbuildinfo +0 -1
- package/bin/update.js +0 -65
- package/bin/validate/command.js +0 -127
- package/bin/validate/engine.js +0 -154
- package/bin/validate/files.js +0 -163
- package/bin/validate/mdx.js +0 -238
- package/bin/validate/output.js +0 -44
- package/bin/validate/report.js +0 -11
- package/bin/validate/rules/build.js +0 -102
- package/bin/validate/rules/content/duplicateH1.js +0 -57
- package/bin/validate/rules/content/foreignSyntax.js +0 -120
- package/bin/validate/rules/content/katex.js +0 -34
- package/bin/validate/rules/content/missingSnippet.js +0 -34
- package/bin/validate/rules/content/undefinedVariable.js +0 -13
- package/bin/validate/rules/content/unknownComponent.js +0 -121
- package/bin/validate/rules/content/voidTags.js +0 -38
- package/bin/validate/rules/index.js +0 -21
- package/bin/validate/rules/openapi.js +0 -50
- package/bin/validate/rules/parseError.js +0 -7
- package/bin/validate/site.js +0 -57
- package/bin/validate/types.js +0 -1
- package/bin/vendor/converter.js +0 -30882
- package/bin/welcome.js +0 -108
- package/bin/workflows/client.js +0 -34
- package/bin/workflows/index.js +0 -269
- package/bin/workflows/types.js +0 -11
- package/scripts/bundle-converter.mjs +0 -26
- package/scripts/generate-logo.mjs +0 -79
- package/src/accessibility.ts +0 -180
- package/src/accessibilityCheck.tsx +0 -150
- package/src/addDomain.tsx +0 -206
- package/src/agent-auth.ts +0 -119
- package/src/agent-claim.ts +0 -124
- package/src/agent-credentials.ts +0 -104
- package/src/agent-deployment.ts +0 -116
- package/src/agent-http.ts +0 -34
- package/src/agent-setup-config.ts +0 -144
- package/src/agent-setup.ts +0 -165
- package/src/agent.ts +0 -56
- package/src/analytics/client.ts +0 -153
- package/src/analytics/dates.ts +0 -6
- package/src/analytics/filters.ts +0 -50
- package/src/analytics/format.ts +0 -13
- package/src/analytics/index.tsx +0 -599
- package/src/analytics/output.ts +0 -99
- package/src/analytics/types.ts +0 -145
- package/src/authenticatedFetch.ts +0 -42
- package/src/brokenLinks.tsx +0 -152
- package/src/callbackServer.ts +0 -64
- package/src/cli.tsx +0 -1105
- package/src/comingSoon.tsx +0 -29
- package/src/config.ts +0 -75
- package/src/constants.ts +0 -28
- package/src/deploy-base.ts +0 -18
- package/src/deploy-github-actions.ts +0 -139
- package/src/deploy-github-setup.ts +0 -189
- package/src/deploy-instructions.ts +0 -76
- package/src/deploy.ts +0 -165
- package/src/feedback.tsx +0 -31
- package/src/format.tsx +0 -82
- package/src/helpers.tsx +0 -279
- package/src/idToken.ts +0 -17
- package/src/index.ts +0 -109
- package/src/init.tsx +0 -237
- package/src/instructions.ts +0 -99
- package/src/keyring.ts +0 -65
- package/src/login.tsx +0 -166
- package/src/logout.tsx +0 -8
- package/src/mdxAccessibility.ts +0 -134
- package/src/mdxLinter.tsx +0 -88
- package/src/middlewares/subdomainMiddleware.ts +0 -20
- package/src/middlewares/telemetryMiddleware.ts +0 -55
- package/src/migrate.ts +0 -76
- package/src/og.tsx +0 -185
- package/src/openApiCheck.tsx +0 -125
- package/src/resolveFiles.ts +0 -101
- package/src/score/client.ts +0 -36
- package/src/score/index.tsx +0 -205
- package/src/score/types.ts +0 -15
- package/src/signup.tsx +0 -172
- package/src/start.ts +0 -27
- package/src/status.tsx +0 -129
- package/src/telemetry/client.ts +0 -46
- package/src/telemetry/distinctId.ts +0 -70
- package/src/telemetry/sessionId.ts +0 -40
- package/src/telemetry/track.ts +0 -163
- package/src/templates.tsx +0 -143
- package/src/tokenRefresh.ts +0 -53
- package/src/update.tsx +0 -89
- package/src/validate/command.tsx +0 -135
- package/src/validate/engine.ts +0 -210
- package/src/validate/files.ts +0 -249
- package/src/validate/mdx.ts +0 -290
- package/src/validate/output.tsx +0 -76
- package/src/validate/report.ts +0 -40
- package/src/validate/rules/build.ts +0 -146
- package/src/validate/rules/content/duplicateH1.ts +0 -78
- package/src/validate/rules/content/foreignSyntax.ts +0 -144
- package/src/validate/rules/content/katex.ts +0 -33
- package/src/validate/rules/content/missingSnippet.ts +0 -36
- package/src/validate/rules/content/undefinedVariable.ts +0 -20
- package/src/validate/rules/content/unknownComponent.ts +0 -130
- package/src/validate/rules/content/voidTags.ts +0 -43
- package/src/validate/rules/index.ts +0 -23
- package/src/validate/rules/openapi.ts +0 -59
- package/src/validate/rules/parseError.ts +0 -9
- package/src/validate/site.ts +0 -53
- package/src/validate/types.ts +0 -102
- package/src/vendor/converter.ts +0 -1
- package/src/welcome.ts +0 -154
- package/src/workflows/client.ts +0 -39
- package/src/workflows/index.tsx +0 -287
- package/src/workflows/types.ts +0 -73
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -10
- package/vitest.config.ts +0 -9
package/bin/og.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { parseFrontmatter, slugToTitle } from '@mintlify/common';
|
|
12
|
-
import { renderOgCardPng } from '@mintlify/og';
|
|
13
|
-
import { applyCardThemeOverride, applyThumbnailOverride, buildOgCardInput, checkOgCard, createLocalAssetLoaders, deriveOgThemeParams, getOgPageParams, MAX_OG_ASSET_BYTES, toOgFontAsset, toOgImageAsset, } from '@mintlify/og/config';
|
|
14
|
-
import { getConfigObj } from '@mintlify/prebuild';
|
|
15
|
-
import { addLog, ErrorLog, SuccessLog, WarningLog } from '@mintlify/previewing';
|
|
16
|
-
import { validateDocsConfig } from '@mintlify/validation';
|
|
17
|
-
import { mkdir, mkdtemp, readFile, writeFile } from 'node:fs/promises';
|
|
18
|
-
import os from 'node:os';
|
|
19
|
-
import path from 'node:path';
|
|
20
|
-
import open from 'open';
|
|
21
|
-
import { CMD_EXEC_PATH } from './helpers.js';
|
|
22
|
-
const REMOTE_TIMEOUT_MS = 5000;
|
|
23
|
-
const PAGE_EXTENSIONS = ['.mdx', '.md'];
|
|
24
|
-
const MAX_REPORTED_ISSUES = 5;
|
|
25
|
-
const readLimited = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const declared = Number(response.headers.get('content-length'));
|
|
27
|
-
if (declared > MAX_OG_ASSET_BYTES || !response.body)
|
|
28
|
-
return null;
|
|
29
|
-
const reader = response.body.getReader();
|
|
30
|
-
const chunks = [];
|
|
31
|
-
let size = 0;
|
|
32
|
-
for (let result = yield reader.read(); !result.done; result = yield reader.read()) {
|
|
33
|
-
size += result.value.byteLength;
|
|
34
|
-
if (size > MAX_OG_ASSET_BYTES) {
|
|
35
|
-
yield reader.cancel();
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
chunks.push(result.value);
|
|
39
|
-
}
|
|
40
|
-
const bytes = new Uint8Array(size);
|
|
41
|
-
let offset = 0;
|
|
42
|
-
for (const chunk of chunks) {
|
|
43
|
-
bytes.set(chunk, offset);
|
|
44
|
-
offset += chunk.byteLength;
|
|
45
|
-
}
|
|
46
|
-
return bytes;
|
|
47
|
-
});
|
|
48
|
-
const fetchAsset = (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
var _a;
|
|
50
|
-
try {
|
|
51
|
-
const response = yield fetch(src, { signal: AbortSignal.timeout(REMOTE_TIMEOUT_MS) });
|
|
52
|
-
if (!response.ok)
|
|
53
|
-
return null;
|
|
54
|
-
const bytes = yield readLimited(response);
|
|
55
|
-
return bytes && { bytes, contentType: (_a = response.headers.get('content-type')) !== null && _a !== void 0 ? _a : undefined };
|
|
56
|
-
}
|
|
57
|
-
catch (_b) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
const remoteLoaders = {
|
|
62
|
-
image: (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const asset = yield fetchAsset(src);
|
|
64
|
-
return asset && toOgImageAsset(asset.bytes, asset.contentType);
|
|
65
|
-
}),
|
|
66
|
-
font: (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
const asset = yield fetchAsset(src);
|
|
68
|
-
return asset && toOgFontAsset(asset.bytes);
|
|
69
|
-
}),
|
|
70
|
-
};
|
|
71
|
-
const normalizePagePath = (page) => path.posix
|
|
72
|
-
.normalize(`/${(page !== null && page !== void 0 ? page : '').replace(/\\/g, '/')}`)
|
|
73
|
-
.replace(/^\/+|\/+$/g, '')
|
|
74
|
-
.replace(/\.mdx?$/, '') || 'index';
|
|
75
|
-
const pageHref = (pagePath) => pagePath.replace(/(^|\/)index$/, '');
|
|
76
|
-
const pageCandidates = (pagePath) => [pagePath, `${pagePath}/index`].flatMap((base) => PAGE_EXTENSIONS.map((extension) => `${base}${extension}`));
|
|
77
|
-
const readPage = (pagePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
const root = path.resolve(CMD_EXEC_PATH);
|
|
79
|
-
for (const candidate of pageCandidates(pagePath)) {
|
|
80
|
-
const filePath = path.resolve(root, candidate);
|
|
81
|
-
if (!filePath.startsWith(`${root}${path.sep}`))
|
|
82
|
-
return null;
|
|
83
|
-
try {
|
|
84
|
-
return yield readFile(filePath, 'utf-8');
|
|
85
|
-
}
|
|
86
|
-
catch (_a) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
});
|
|
92
|
-
const stringAttribute = (attributes, key) => {
|
|
93
|
-
const value = attributes[key];
|
|
94
|
-
return typeof value === 'string' && value ? value : undefined;
|
|
95
|
-
};
|
|
96
|
-
const defaultOutputPath = (pagePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
return path.join(yield mkdtemp(path.join(os.tmpdir(), 'mintlify-og-')), `${pagePath.replace(/\//g, '-')}.png`);
|
|
98
|
-
});
|
|
99
|
-
export function ogCommand(options) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
var _a, _b;
|
|
102
|
-
const rawConfig = yield getConfigObj(CMD_EXEC_PATH, 'docs');
|
|
103
|
-
if (!rawConfig) {
|
|
104
|
-
addLog(_jsx(ErrorLog, { message: "No docs.json found. Run mint og from your docs directory." }));
|
|
105
|
-
return 1;
|
|
106
|
-
}
|
|
107
|
-
const validation = validateDocsConfig(rawConfig);
|
|
108
|
-
if (!validation.success) {
|
|
109
|
-
const issues = validation.error.issues
|
|
110
|
-
.slice(0, MAX_REPORTED_ISSUES)
|
|
111
|
-
.map((issue) => `${issue.path.join('.') || 'docs.json'}: ${issue.message}`);
|
|
112
|
-
addLog(_jsx(ErrorLog, { message: `docs.json is invalid:\n${issues.join('\n')}` }));
|
|
113
|
-
return 1;
|
|
114
|
-
}
|
|
115
|
-
const docsConfig = validation.data;
|
|
116
|
-
const pagePath = normalizePagePath(options.page);
|
|
117
|
-
const contents = yield readPage(pagePath);
|
|
118
|
-
if (contents === null) {
|
|
119
|
-
addLog(_jsx(ErrorLog, { message: `Couldn't find a page at ${pageCandidates(pagePath).join(', ')}.` }));
|
|
120
|
-
return 1;
|
|
121
|
-
}
|
|
122
|
-
const { attributes } = parseFrontmatter(contents);
|
|
123
|
-
const pageParams = getOgPageParams({
|
|
124
|
-
path: pagePath,
|
|
125
|
-
title: (_b = (_a = stringAttribute(attributes, 'title')) !== null && _a !== void 0 ? _a : stringAttribute(attributes, 'sidebarTitle')) !== null && _b !== void 0 ? _b : slugToTitle(pageHref(pagePath)),
|
|
126
|
-
description: stringAttribute(attributes, 'description'),
|
|
127
|
-
thumbnail: attributes.thumbnail,
|
|
128
|
-
}, docsConfig);
|
|
129
|
-
const themeParams = applyThumbnailOverride(applyCardThemeOverride(deriveOgThemeParams(docsConfig), pageParams.thumbnail), options);
|
|
130
|
-
const input = yield buildOgCardInput(pageParams, themeParams, createLocalAssetLoaders(CMD_EXEC_PATH, remoteLoaders));
|
|
131
|
-
const png = yield renderOgCardPng(input);
|
|
132
|
-
const outputPath = options.output
|
|
133
|
-
? path.resolve(options.output)
|
|
134
|
-
: yield defaultOutputPath(pagePath);
|
|
135
|
-
yield mkdir(path.dirname(outputPath), { recursive: true });
|
|
136
|
-
yield writeFile(outputPath, new Uint8Array(png));
|
|
137
|
-
for (const warning of checkOgCard(input, themeParams)) {
|
|
138
|
-
addLog(_jsx(WarningLog, { message: warning }));
|
|
139
|
-
}
|
|
140
|
-
addLog(_jsx(SuccessLog, { message: `Wrote ${outputPath}` }));
|
|
141
|
-
if (options.open && !process.env.CI)
|
|
142
|
-
yield open(outputPath);
|
|
143
|
-
return 0;
|
|
144
|
-
});
|
|
145
|
-
}
|
package/bin/openApiCheck.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { applyOverlays, createOverlayRegistry, getOpenApiDocumentFromUrl, isAllowedLocalSchemaUrl, resolveOverlaysForSpec, validate, } from '@mintlify/common';
|
|
12
|
-
import { discoverOverlayFiles, getMintIgnore, resolveFileRefs } from '@mintlify/prebuild';
|
|
13
|
-
import { addLog, ErrorLog, SuccessLog, WarningLog } from '@mintlify/previewing';
|
|
14
|
-
import { collectOpenApiOverlayConfig, extractOpenApiEntries, } from '@mintlify/validation';
|
|
15
|
-
import { promises as fs } from 'fs';
|
|
16
|
-
import path from 'path';
|
|
17
|
-
import { CMD_EXEC_PATH, readLocalOpenApiFile } from './helpers.js';
|
|
18
|
-
export const getOpenApiFilenamesFromDocsConfig = (config) => {
|
|
19
|
-
var _a;
|
|
20
|
-
return extractOpenApiEntries((_a = config.api) === null || _a === void 0 ? void 0 : _a.openapi).map((entry) => entry.source);
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Builds the overlay registry so checks validate specs with overlays applied.
|
|
24
|
-
* Throws when docs.json configures conflicting overlay lists, matching the build.
|
|
25
|
-
*/
|
|
26
|
-
export const buildOverlayRegistryForCheck = (localSchema) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
// Discovery failures propagate and fail the check: silently skipping overlays would
|
|
28
|
-
// validate a different document than the one the build produces.
|
|
29
|
-
const mintIgnore = yield getMintIgnore(CMD_EXEC_PATH);
|
|
30
|
-
const discovered = yield discoverOverlayFiles(CMD_EXEC_PATH, mintIgnore);
|
|
31
|
-
let rawConfig;
|
|
32
|
-
try {
|
|
33
|
-
rawConfig = JSON.parse(yield fs.readFile(path.join(CMD_EXEC_PATH, 'docs.json'), 'utf-8'));
|
|
34
|
-
}
|
|
35
|
-
catch (_a) {
|
|
36
|
-
rawConfig = undefined;
|
|
37
|
-
}
|
|
38
|
-
if (rawConfig !== undefined) {
|
|
39
|
-
try {
|
|
40
|
-
rawConfig = (yield resolveFileRefs(rawConfig, CMD_EXEC_PATH)).resolved;
|
|
41
|
-
}
|
|
42
|
-
catch (_b) {
|
|
43
|
-
// Broken $refs are reported by regular config validation; collect from the root file.
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const explicit = rawConfig == undefined ? undefined : collectOpenApiOverlayConfig(rawConfig);
|
|
47
|
-
if (explicit == undefined && discovered.length === 0)
|
|
48
|
-
return undefined;
|
|
49
|
-
return createOverlayRegistry({
|
|
50
|
-
explicit,
|
|
51
|
-
discovered,
|
|
52
|
-
localSchema,
|
|
53
|
-
loadLocalDocument: (normalizedPath) => readLocalOpenApiFile(normalizedPath),
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
const logOpenApiMessage = ({ level, message }) => {
|
|
57
|
-
addLog(level === 'success' ? (_jsx(SuccessLog, { message: message })) : level === 'warning' ? (_jsx(WarningLog, { message: message })) : (_jsx(ErrorLog, { message: message })));
|
|
58
|
-
};
|
|
59
|
-
export const checkOpenApiFile = (filename_1, localSchema_1, overlayRegistry_1, ...args_1) => __awaiter(void 0, [filename_1, localSchema_1, overlayRegistry_1, ...args_1], void 0, function* (filename, localSchema, overlayRegistry, report = logOpenApiMessage) {
|
|
60
|
-
try {
|
|
61
|
-
const overlays = overlayRegistry ? yield resolveOverlaysForSpec(overlayRegistry, filename) : [];
|
|
62
|
-
if (isAllowedLocalSchemaUrl(filename, localSchema)) {
|
|
63
|
-
yield getOpenApiDocumentFromUrl(filename, { overlays });
|
|
64
|
-
report({ level: 'success', message: 'OpenAPI definition is valid.' });
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
if (filename.startsWith('http://') && !localSchema) {
|
|
68
|
-
report({
|
|
69
|
-
level: 'warning',
|
|
70
|
-
message: 'include the --local-schema flag to check locally hosted OpenAPI files',
|
|
71
|
-
});
|
|
72
|
-
report({ level: 'warning', message: 'only https protocol is supported in production' });
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
const document = yield readLocalOpenApiFile(filename);
|
|
76
|
-
if (!document) {
|
|
77
|
-
throw new Error('failed to parse OpenAPI spec: could not parse file correctly, please check for any syntax errors.');
|
|
78
|
-
}
|
|
79
|
-
const overlaid = overlays.length > 0 ? applyOverlays(document, overlays) : document;
|
|
80
|
-
if (overlaid == undefined || typeof overlaid !== 'object') {
|
|
81
|
-
throw new Error('applying overlays produced an invalid OpenAPI document.');
|
|
82
|
-
}
|
|
83
|
-
yield validate(overlaid);
|
|
84
|
-
report({ level: 'success', message: 'OpenAPI definition is valid.' });
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
if (err && typeof err === 'object' && 'code' in err && err.code === 'ENOENT') {
|
|
89
|
-
report({
|
|
90
|
-
level: 'error',
|
|
91
|
-
message: `file not found, please check the path provided: ${filename}`,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
report({ level: 'error', message: err instanceof Error ? err.message : 'unknown error' });
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
});
|
package/bin/resolveFiles.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import fs from 'node:fs/promises';
|
|
11
|
-
import path from 'node:path';
|
|
12
|
-
const GLOB_CHARS = /[*?]/;
|
|
13
|
-
const DOCS_FILE = /\.mdx?$/i;
|
|
14
|
-
const REGEX_SPECIAL = /[.+^${}()|\\[\]]/;
|
|
15
|
-
const SKIPPED_DIRS = new Set(['.git', 'node_modules']);
|
|
16
|
-
function toPosix(filePath) {
|
|
17
|
-
return filePath.split(path.sep).join('/');
|
|
18
|
-
}
|
|
19
|
-
function normalizeArg(arg) {
|
|
20
|
-
return toPosix(arg).replace(/^\.\//, '');
|
|
21
|
-
}
|
|
22
|
-
function globToRegExp(pattern) {
|
|
23
|
-
let source = '';
|
|
24
|
-
let i = 0;
|
|
25
|
-
while (i < pattern.length) {
|
|
26
|
-
const char = pattern[i];
|
|
27
|
-
if (char === '*') {
|
|
28
|
-
if (pattern[i + 1] === '*') {
|
|
29
|
-
if (pattern[i + 2] === '/') {
|
|
30
|
-
source += '(?:[^/]+/)*';
|
|
31
|
-
i += 3;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
source += '.*';
|
|
35
|
-
i += 2;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
source += '[^/]*';
|
|
40
|
-
i += 1;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (char === '?') {
|
|
44
|
-
source += '[^/]';
|
|
45
|
-
i += 1;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
source += REGEX_SPECIAL.test(char) ? `\\${char}` : char;
|
|
49
|
-
i += 1;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return new RegExp(`^${source}$`);
|
|
53
|
-
}
|
|
54
|
-
function isFile(filePath) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
try {
|
|
57
|
-
return (yield fs.stat(filePath)).isFile();
|
|
58
|
-
}
|
|
59
|
-
catch (_a) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function walk(baseDir_1) {
|
|
65
|
-
return __awaiter(this, arguments, void 0, function* (baseDir, dir = '') {
|
|
66
|
-
const entries = yield fs.readdir(path.join(baseDir, dir), { withFileTypes: true });
|
|
67
|
-
const files = [];
|
|
68
|
-
for (const entry of entries) {
|
|
69
|
-
if (SKIPPED_DIRS.has(entry.name))
|
|
70
|
-
continue;
|
|
71
|
-
const rel = dir ? `${dir}/${entry.name}` : entry.name;
|
|
72
|
-
if (entry.isDirectory()) {
|
|
73
|
-
files.push(...(yield walk(baseDir, rel)));
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
files.push(rel);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return files;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
export class NoMatchingFilesError extends Error {
|
|
83
|
-
}
|
|
84
|
-
export function resolveExplicitFiles(baseDir, args) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
let allFiles = null;
|
|
87
|
-
const matched = [];
|
|
88
|
-
const unmatched = [];
|
|
89
|
-
for (const arg of args) {
|
|
90
|
-
const pattern = normalizeArg(arg);
|
|
91
|
-
if (GLOB_CHARS.test(pattern)) {
|
|
92
|
-
allFiles = allFiles !== null && allFiles !== void 0 ? allFiles : (yield walk(baseDir));
|
|
93
|
-
const regex = globToRegExp(pattern);
|
|
94
|
-
const hits = allFiles.filter((file) => DOCS_FILE.test(file) && regex.test(file)).sort();
|
|
95
|
-
if (hits.length === 0) {
|
|
96
|
-
unmatched.push(arg);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
matched.push(...hits);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (yield isFile(path.join(baseDir, pattern))) {
|
|
103
|
-
matched.push(pattern);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
unmatched.push(arg);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (unmatched.length > 0) {
|
|
110
|
-
throw new NoMatchingFilesError(`No matching files for: ${unmatched.join(', ')} (globs match .md and .mdx files)`);
|
|
111
|
-
}
|
|
112
|
-
return [...new Set(matched)];
|
|
113
|
-
});
|
|
114
|
-
}
|
package/bin/score/client.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { authenticatedFetch } from '../authenticatedFetch.js';
|
|
11
|
-
import { API_URL } from '../constants.js';
|
|
12
|
-
export function resolveScoreForUrl(url) {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
const endpoint = new URL(`${API_URL}/api/cli/score`);
|
|
15
|
-
endpoint.searchParams.set('url', url);
|
|
16
|
-
const res = yield authenticatedFetch(endpoint.toString(), {
|
|
17
|
-
headers: { Accept: 'application/json' },
|
|
18
|
-
});
|
|
19
|
-
if (res.status !== 200 && res.status !== 202) {
|
|
20
|
-
const body = yield res.text().catch(() => '');
|
|
21
|
-
throw new Error(`API error (${res.status}): ${body || res.statusText}`);
|
|
22
|
-
}
|
|
23
|
-
return res.json();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export function fetchScoreBySlug(slug) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const endpoint = new URL(`${API_URL}/api/cli/score/${encodeURIComponent(slug)}`);
|
|
29
|
-
const res = yield authenticatedFetch(endpoint.toString(), {
|
|
30
|
-
headers: { Accept: 'application/json' },
|
|
31
|
-
});
|
|
32
|
-
if (res.status === 202)
|
|
33
|
-
return null;
|
|
34
|
-
if (!res.ok) {
|
|
35
|
-
const body = yield res.text().catch(() => '');
|
|
36
|
-
throw new Error(`API error (${res.status}): ${body || res.statusText}`);
|
|
37
|
-
}
|
|
38
|
-
return res.json();
|
|
39
|
-
});
|
|
40
|
-
}
|
package/bin/score/index.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { addLog, ErrorLog, SpinnerLog, removeLastLog } from '@mintlify/previewing';
|
|
12
|
-
import chalk from 'chalk';
|
|
13
|
-
import { Text } from 'ink';
|
|
14
|
-
import { getConfigValue } from '../config.js';
|
|
15
|
-
import { terminate } from '../helpers.js';
|
|
16
|
-
import { getAccessToken } from '../keyring.js';
|
|
17
|
-
import { getCliSubdomains } from '../status.js';
|
|
18
|
-
import { trackEvent } from '../telemetry/track.js';
|
|
19
|
-
import { fetchScoreBySlug, resolveScoreForUrl } from './client.js';
|
|
20
|
-
const POLL_INTERVAL_MS = 3000;
|
|
21
|
-
const POLL_TIMEOUT_MS = 120000;
|
|
22
|
-
function resolveFormat(argv) {
|
|
23
|
-
if (argv.format === 'table' || argv.format === 'plain' || argv.format === 'json')
|
|
24
|
-
return argv.format;
|
|
25
|
-
return 'table';
|
|
26
|
-
}
|
|
27
|
-
function statusIcon(status) {
|
|
28
|
-
switch (status) {
|
|
29
|
-
case 'pass':
|
|
30
|
-
return chalk.green('✓');
|
|
31
|
-
case 'warn':
|
|
32
|
-
return chalk.yellow('⚠');
|
|
33
|
-
case 'skip':
|
|
34
|
-
return chalk.dim('○');
|
|
35
|
-
case 'fail':
|
|
36
|
-
case 'error':
|
|
37
|
-
return chalk.red('✗');
|
|
38
|
-
default: {
|
|
39
|
-
const _exhaustive = status;
|
|
40
|
-
void _exhaustive;
|
|
41
|
-
return chalk.dim('?');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function plainStatusLabel(status) {
|
|
46
|
-
return status.toUpperCase();
|
|
47
|
-
}
|
|
48
|
-
function formatCheckName(name) {
|
|
49
|
-
return name
|
|
50
|
-
.replace(/[-_]+/g, ' ')
|
|
51
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
52
|
-
.replace(/^./, (c) => c.toUpperCase())
|
|
53
|
-
.trim();
|
|
54
|
-
}
|
|
55
|
-
function renderChecks(checks, indent = 0) {
|
|
56
|
-
const lines = [];
|
|
57
|
-
const pad = ' '.repeat(indent + 1);
|
|
58
|
-
for (const check of checks) {
|
|
59
|
-
lines.push(`${pad}${statusIcon(check.status)} ${formatCheckName(check.name)}`);
|
|
60
|
-
if (check.children && check.children.length > 0) {
|
|
61
|
-
lines.push(...renderChecks(check.children, indent + 1));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return lines;
|
|
65
|
-
}
|
|
66
|
-
function renderPlain(checks, prefix = '') {
|
|
67
|
-
const lines = [];
|
|
68
|
-
for (const check of checks) {
|
|
69
|
-
lines.push(`${prefix}${plainStatusLabel(check.status)}\t${check.name}`);
|
|
70
|
-
if (check.children && check.children.length > 0) {
|
|
71
|
-
lines.push(...renderPlain(check.children, prefix + ' '));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return lines;
|
|
75
|
-
}
|
|
76
|
-
function renderTable(score, opts) {
|
|
77
|
-
const scoreColor = score.overallScore >= 70 ? 'green' : score.overallScore >= 40 ? 'yellow' : 'red';
|
|
78
|
-
const header = (opts === null || opts === void 0 ? void 0 : opts.stale)
|
|
79
|
-
? chalk.bold(`\nAgent Readiness Score — ${score.canonicalUrl}`) +
|
|
80
|
-
chalk.dim(` (last run ${new Date(score.computedAt).toLocaleString()})\n`)
|
|
81
|
-
: chalk.bold(`\nAgent Readiness Score — ${score.canonicalUrl}\n`);
|
|
82
|
-
const lines = [header];
|
|
83
|
-
lines.push(` Score: ${chalk[scoreColor].bold(`${score.overallScore}%`)}\n`);
|
|
84
|
-
lines.push(chalk.bold(' Checks'));
|
|
85
|
-
lines.push(...renderChecks(score.checks));
|
|
86
|
-
return lines.join('\n');
|
|
87
|
-
}
|
|
88
|
-
function output(format, text) {
|
|
89
|
-
if (format === 'table') {
|
|
90
|
-
addLog(_jsx(Text, { children: text }));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
process.stdout.write(text + '\n');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function sleep(ms) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function pollForScore(slug, afterIso, onAttempt) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
104
|
-
while (Date.now() < deadline) {
|
|
105
|
-
yield sleep(POLL_INTERVAL_MS);
|
|
106
|
-
onAttempt === null || onAttempt === void 0 ? void 0 : onAttempt();
|
|
107
|
-
const score = yield fetchScoreBySlug(slug);
|
|
108
|
-
if (!score)
|
|
109
|
-
continue;
|
|
110
|
-
if (afterIso === null)
|
|
111
|
-
return score;
|
|
112
|
-
if (new Date(score.computedAt).getTime() > new Date(afterIso).getTime())
|
|
113
|
-
return score;
|
|
114
|
-
}
|
|
115
|
-
throw new Error(`Score did not complete within ${POLL_TIMEOUT_MS / 1000}s`);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function resolveDefaultSubdomain() {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const fromConfig = getConfigValue('subdomain');
|
|
121
|
-
if (fromConfig)
|
|
122
|
-
return fromConfig;
|
|
123
|
-
const accessToken = yield getAccessToken();
|
|
124
|
-
if (!accessToken)
|
|
125
|
-
return undefined;
|
|
126
|
-
const subdomains = yield getCliSubdomains(accessToken);
|
|
127
|
-
return subdomains[0];
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
export const scoreHandler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
-
const format = resolveFormat(argv);
|
|
132
|
-
try {
|
|
133
|
-
let url = argv.url;
|
|
134
|
-
if (!url) {
|
|
135
|
-
const subdomain = yield resolveDefaultSubdomain();
|
|
136
|
-
if (!subdomain) {
|
|
137
|
-
throw new Error('No URL provided and no default subdomain set. Run `mint login` to set one, or pass a URL: `mint score <url>`.');
|
|
138
|
-
}
|
|
139
|
-
url = `${subdomain}.mintlify.site`;
|
|
140
|
-
}
|
|
141
|
-
if (format === 'table')
|
|
142
|
-
addLog(_jsx(SpinnerLog, { message: "Checking agent readiness..." }));
|
|
143
|
-
const resolved = yield resolveScoreForUrl(url);
|
|
144
|
-
let final;
|
|
145
|
-
if (resolved.status === 'ready') {
|
|
146
|
-
const score = yield fetchScoreBySlug(resolved.slug);
|
|
147
|
-
if (format === 'table')
|
|
148
|
-
removeLastLog();
|
|
149
|
-
if (!score)
|
|
150
|
-
throw new Error('Score was unexpectedly unavailable');
|
|
151
|
-
final = score;
|
|
152
|
-
}
|
|
153
|
-
else if (resolved.status === 'stale_refresh_queued') {
|
|
154
|
-
const stale = yield fetchScoreBySlug(resolved.slug);
|
|
155
|
-
if (format === 'table')
|
|
156
|
-
removeLastLog();
|
|
157
|
-
if (!stale)
|
|
158
|
-
throw new Error('Stale score was unexpectedly unavailable');
|
|
159
|
-
if (format === 'table') {
|
|
160
|
-
output('table', renderTable(stale, { stale: true }));
|
|
161
|
-
addLog(_jsx(SpinnerLog, { message: "Refreshing score in the background..." }));
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
process.stderr.write('Refreshing score in the background...\n');
|
|
165
|
-
}
|
|
166
|
-
final = yield pollForScore(resolved.slug, stale.computedAt);
|
|
167
|
-
if (format === 'table')
|
|
168
|
-
removeLastLog();
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
if (format === 'table') {
|
|
172
|
-
removeLastLog();
|
|
173
|
-
addLog(_jsx(SpinnerLog, { message: "Queued a new scoring run. Waiting for first result..." }));
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
process.stderr.write('Queued a new scoring run. Waiting for first result...\n');
|
|
177
|
-
}
|
|
178
|
-
final = yield pollForScore(resolved.slug, null);
|
|
179
|
-
if (format === 'table')
|
|
180
|
-
removeLastLog();
|
|
181
|
-
}
|
|
182
|
-
void trackEvent('cli.score.executed', {
|
|
183
|
-
url,
|
|
184
|
-
score: final.overallScore,
|
|
185
|
-
format,
|
|
186
|
-
status: resolved.status,
|
|
187
|
-
});
|
|
188
|
-
if (format === 'json') {
|
|
189
|
-
output(format, JSON.stringify(final, null, 2));
|
|
190
|
-
}
|
|
191
|
-
else if (format === 'plain') {
|
|
192
|
-
const lines = [`SCORE\t${final.overallScore}`, ...renderPlain(final.checks)];
|
|
193
|
-
output(format, lines.join('\n'));
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
output(format, renderTable(final));
|
|
197
|
-
}
|
|
198
|
-
yield terminate(0);
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
const message = err instanceof Error ? err.message : 'unknown error';
|
|
202
|
-
if (format === 'table') {
|
|
203
|
-
removeLastLog();
|
|
204
|
-
addLog(_jsx(ErrorLog, { message: message }));
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
process.stderr.write(`Error: ${message}\n`);
|
|
208
|
-
}
|
|
209
|
-
yield terminate(1);
|
|
210
|
-
}
|
|
211
|
-
});
|
package/bin/score/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|