@mintlify/cli 4.0.1812 → 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 +43 -36
- 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/signup.js
DELETED
|
@@ -1,118 +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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { input } from '@inquirer/prompts';
|
|
12
|
-
import { addLog, addLogs, ErrorLog, SuccessLog } from '@mintlify/previewing';
|
|
13
|
-
import { Box, Text } from 'ink';
|
|
14
|
-
import { calculatePKCECodeChallenge, randomNonce, randomPKCECodeVerifier, randomState, } from 'openid-client';
|
|
15
|
-
import { isCI } from './agent.js';
|
|
16
|
-
import { startCallbackServer } from './callbackServer.js';
|
|
17
|
-
import { clearConfigValue, hasShownPublishPrompt, markPublishPromptShown } from './config.js';
|
|
18
|
-
import { API_URL, TOKEN_ENDPOINT } from './constants.js';
|
|
19
|
-
import { CMD_EXEC_PATH, isAI } from './helpers.js';
|
|
20
|
-
import { getEmailFromIdToken } from './idToken.js';
|
|
21
|
-
import { getAccessToken, storeCredentials } from './keyring.js';
|
|
22
|
-
export const AUTH_MD_URL = 'https://mintlify.com/auth.md';
|
|
23
|
-
const sendAIUsageMessage = () => {
|
|
24
|
-
addLogs(_jsx(Text, { children: "Agent Detected - sending AI friendly prompt" }), _jsx(Text, { children: '<mint-cli-instructions>' }), _jsxs(Text, { children: ["Could not fetch the agent signup guide. Read ", AUTH_MD_URL, " directly, or create a site without an account by running `mint deploy --subdomain [subdomain]` from the documentation directory and following the instructions it prints."] }), _jsx(Text, { children: "To hand the site to the user, ask for their email (never invent one) and run `mint claim --email [email]`." }), _jsx(Text, { children: '</mint-cli-instructions>' }));
|
|
25
|
-
};
|
|
26
|
-
export const sendPublishPrompt = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
if (!isAI() ||
|
|
28
|
-
isCI() ||
|
|
29
|
-
process.env.MINTLIFY_SESSION_TOKEN ||
|
|
30
|
-
(yield getAccessToken().catch(() => undefined))) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (hasShownPublishPrompt(CMD_EXEC_PATH)) {
|
|
34
|
-
addLog(_jsx(Text, { children: "Not published yet. Run `mint signup` or `mint login` to publish." }));
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
addLogs(_jsx(Text, { children: '<mint-cli-instructions>' }), _jsx(Text, { children: "Ready to publish? The Starter plan is free, no credit card needed." }), _jsx(Text, { children: "Offer to create the user's Mintlify account: run `mint signup` and follow the instructions it prints." }), _jsx(Text, { children: "Have an account: `mint login`." }), _jsx(Text, { children: "Your site will then be live at https://[subdomain].mintlify.site (`mint status` shows the exact URL)." }), _jsx(Text, { children: '</mint-cli-instructions>' }));
|
|
38
|
-
yield markPublishPromptShown(CMD_EXEC_PATH).catch(() => undefined);
|
|
39
|
-
});
|
|
40
|
-
// Agents sign up through auth.md, so give them that guide instead of the email flow.
|
|
41
|
-
const sendAuthMd = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
try {
|
|
43
|
-
const res = yield fetch(AUTH_MD_URL, { signal: AbortSignal.timeout(30000) });
|
|
44
|
-
if (!res.ok)
|
|
45
|
-
throw new Error(`auth.md returned ${res.status}`);
|
|
46
|
-
process.stdout.write(`${yield res.text()}\n`);
|
|
47
|
-
}
|
|
48
|
-
catch (_a) {
|
|
49
|
-
sendAIUsageMessage();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
export function signup() {
|
|
53
|
-
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
54
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
55
|
-
if (isAI()) {
|
|
56
|
-
yield sendAuthMd();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const firstName = (_a = options.firstName) !== null && _a !== void 0 ? _a : (yield input({ message: 'First name' }));
|
|
60
|
-
const lastName = (_b = options.lastName) !== null && _b !== void 0 ? _b : (yield input({ message: 'Last name' }));
|
|
61
|
-
const company = (_c = options.company) !== null && _c !== void 0 ? _c : (yield input({ message: 'Company name' }));
|
|
62
|
-
const email = (_d = options.email) !== null && _d !== void 0 ? _d : (yield input({ message: 'Email' }));
|
|
63
|
-
const codeVerifier = randomPKCECodeVerifier();
|
|
64
|
-
const codeChallenge = yield calculatePKCECodeChallenge(codeVerifier);
|
|
65
|
-
const nonce = randomNonce();
|
|
66
|
-
const clientState = randomState();
|
|
67
|
-
const state = Buffer.from(JSON.stringify({ nonce, clientState })).toString('base64url');
|
|
68
|
-
const { codePromise, close: closeServer } = yield startCallbackServer();
|
|
69
|
-
codePromise.catch(() => { });
|
|
70
|
-
try {
|
|
71
|
-
const res = yield fetch(`${API_URL}/api/cli-onboarding/signup`, {
|
|
72
|
-
method: 'POST',
|
|
73
|
-
headers: { 'Content-Type': 'application/json' },
|
|
74
|
-
body: JSON.stringify({ firstName, lastName, company, email, state, codeChallenge }),
|
|
75
|
-
});
|
|
76
|
-
if (!res.ok) {
|
|
77
|
-
const body = yield res.json().catch(() => ({}));
|
|
78
|
-
closeServer();
|
|
79
|
-
addLog(_jsx(ErrorLog, { message: `signup failed: ${(_e = body.error) !== null && _e !== void 0 ? _e : 'unknown error'}` }));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (_j) {
|
|
84
|
-
closeServer();
|
|
85
|
-
addLog(_jsx(ErrorLog, { message: "signup failed: could not reach the server" }));
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
addLog(_jsxs(Box, { flexDirection: "column", gap: 1, paddingY: 1, children: [_jsxs(Text, { bold: true, children: [_jsx(Text, { color: "green", children: "\u25C6 " }), "Check your email to verify your account"] }), _jsx(Box, { flexDirection: "column", paddingLeft: 3, gap: 1, children: _jsxs(Text, { dimColor: true, children: ["We sent a verification link to ", email, ". Click it to continue."] }) })] }));
|
|
89
|
-
let code;
|
|
90
|
-
try {
|
|
91
|
-
code = yield codePromise;
|
|
92
|
-
}
|
|
93
|
-
catch (_k) {
|
|
94
|
-
addLog(_jsx(ErrorLog, { message: "signup cancelled" }));
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const res = yield fetch(TOKEN_ENDPOINT, {
|
|
98
|
-
method: 'POST',
|
|
99
|
-
headers: { 'Content-Type': 'application/json' },
|
|
100
|
-
body: JSON.stringify({
|
|
101
|
-
grant_type: 'authorization_code',
|
|
102
|
-
code,
|
|
103
|
-
code_verifier: codeVerifier,
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
106
|
-
const body = yield res.json().catch(() => ({}));
|
|
107
|
-
if (!res.ok) {
|
|
108
|
-
const reason = (_g = (_f = body.error_message) !== null && _f !== void 0 ? _f : body.error) !== null && _g !== void 0 ? _g : 'unknown error';
|
|
109
|
-
addLog(_jsx(ErrorLog, { message: `signup failed: ${reason}` }));
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const token = body;
|
|
113
|
-
yield storeCredentials(token.access_token, token.refresh_token, (_h = getEmailFromIdToken(token.id_token)) !== null && _h !== void 0 ? _h : email);
|
|
114
|
-
yield clearConfigValue('subdomain').catch(() => undefined);
|
|
115
|
-
addLog(_jsx(SuccessLog, { message: "account created and logged in successfully" }));
|
|
116
|
-
addLog(_jsx(Text, { children: "Continue in the browser tab where you verified your email to connect GitHub." }));
|
|
117
|
-
});
|
|
118
|
-
}
|
package/bin/start.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var _a;
|
|
12
|
-
import { cli } from './cli.js';
|
|
13
|
-
import { shutdownPostHog } from './telemetry/client.js';
|
|
14
|
-
const packageName = (_a = process.env.MINTLIFY_PACKAGE_NAME) !== null && _a !== void 0 ? _a : 'mint';
|
|
15
|
-
cli({ packageName }).catch((err) => {
|
|
16
|
-
console.error(err instanceof Error ? err.message : err);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
});
|
|
19
|
-
function shutdown(exitCode) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
yield shutdownPostHog();
|
|
22
|
-
process.exit(exitCode);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
process.once('beforeExit', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
yield shutdownPostHog();
|
|
28
|
-
}
|
|
29
|
-
catch (_a) { }
|
|
30
|
-
}));
|
|
31
|
-
process.on('SIGINT', () => {
|
|
32
|
-
void shutdown(130);
|
|
33
|
-
});
|
|
34
|
-
process.on('SIGTERM', () => {
|
|
35
|
-
void shutdown(143);
|
|
36
|
-
});
|
package/bin/status.js
DELETED
|
@@ -1,106 +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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { addLog, ErrorLog } from '@mintlify/previewing';
|
|
12
|
-
import { Box, Text } from 'ink';
|
|
13
|
-
import { z } from 'zod';
|
|
14
|
-
import { authenticatedFetch } from './authenticatedFetch.js';
|
|
15
|
-
import { getConfigValue, setConfigValue } from './config.js';
|
|
16
|
-
import { API_URL } from './constants.js';
|
|
17
|
-
import { getCliVersion } from './helpers.js';
|
|
18
|
-
import { getAccessToken } from './keyring.js';
|
|
19
|
-
const StatusResponseSchema = z.object({
|
|
20
|
-
user: z.object({ email: z.string() }),
|
|
21
|
-
org: z.object({ name: z.string() }),
|
|
22
|
-
subdomains: z.array(z.string()).default([]),
|
|
23
|
-
});
|
|
24
|
-
export function getCliStatus(accessToken) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
const res = yield fetch(`${API_URL}/api/cli/status`, {
|
|
28
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
29
|
-
});
|
|
30
|
-
if (!res.ok)
|
|
31
|
-
return null;
|
|
32
|
-
const json = yield res.json().catch(() => null);
|
|
33
|
-
const parsed = StatusResponseSchema.safeParse(json);
|
|
34
|
-
return parsed.success ? parsed.data : null;
|
|
35
|
-
}
|
|
36
|
-
catch (_a) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Like getCliStatus, but refreshes an expired session and says why it failed, so commands can
|
|
43
|
-
* tell "log in again" apart from "the server is down" and from "not allowed".
|
|
44
|
-
*/
|
|
45
|
-
export function fetchCliStatus(signal) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
let res;
|
|
48
|
-
try {
|
|
49
|
-
res = yield authenticatedFetch(`${API_URL}/api/cli/status`, { signal });
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
53
|
-
if (/not authenticated/i.test(detail))
|
|
54
|
-
return { ok: false, reason: 'unauthenticated' };
|
|
55
|
-
return { ok: false, reason: 'unreachable', detail };
|
|
56
|
-
}
|
|
57
|
-
if (res.status === 401 || res.status === 403)
|
|
58
|
-
return { ok: false, reason: 'unauthenticated' };
|
|
59
|
-
if (!res.ok)
|
|
60
|
-
return { ok: false, reason: 'unreachable', detail: `HTTP ${res.status}` };
|
|
61
|
-
const parsed = StatusResponseSchema.safeParse(yield res.json().catch(() => null));
|
|
62
|
-
if (!parsed.success)
|
|
63
|
-
return { ok: false, reason: 'invalid' };
|
|
64
|
-
return { ok: true, status: parsed.data };
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
export function getCliSubdomains(accessToken) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
var _a;
|
|
70
|
-
const status = yield getCliStatus(accessToken);
|
|
71
|
-
return (_a = status === null || status === void 0 ? void 0 : status.subdomains) !== null && _a !== void 0 ? _a : [];
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export function status() {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const accessToken = (_a = (yield getAccessToken().catch(() => null))) !== null && _a !== void 0 ? _a : process.env.MINTLIFY_SESSION_TOKEN;
|
|
78
|
-
if (!accessToken) {
|
|
79
|
-
addLog(_jsx(ErrorLog, { message: "not logged in. Run `mint login` to authenticate." }));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
const res = yield authenticatedFetch(`${API_URL}/api/cli/status`);
|
|
84
|
-
if (!res.ok) {
|
|
85
|
-
addLog(_jsx(ErrorLog, { message: "not logged in. Run `mint login` to authenticate." }));
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const json = yield res.json().catch(() => null);
|
|
89
|
-
const parsed = StatusResponseSchema.safeParse(json);
|
|
90
|
-
if (!parsed.success) {
|
|
91
|
-
addLog(_jsx(ErrorLog, { message: "unexpected response from server. please try again." }));
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const { user, org, subdomains } = parsed.data;
|
|
95
|
-
const version = getCliVersion();
|
|
96
|
-
const cached = getConfigValue('subdomain');
|
|
97
|
-
const subdomain = (_b = (cached && subdomains.includes(cached) ? cached : subdomains[0])) !== null && _b !== void 0 ? _b : null;
|
|
98
|
-
if (subdomain && subdomain !== cached)
|
|
99
|
-
yield setConfigValue('subdomain', subdomain).catch(() => undefined);
|
|
100
|
-
addLog(_jsxs(Box, { flexDirection: "column", paddingY: 1, children: [version && (_jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Version" }) }), _jsx(Text, { children: version })] })), _jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Email" }) }), _jsx(Text, { children: user.email })] }), _jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Organization" }) }), _jsx(Text, { children: org.name })] }), subdomain && (_jsxs(Box, { children: [_jsx(Box, { minWidth: 16, children: _jsx(Text, { dimColor: true, children: "Subdomain" }) }), _jsx(Text, { children: subdomain })] }))] }));
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
addLog(_jsx(ErrorLog, { message: "unexpected response from server. please try again." }));
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
package/bin/telemetry/client.js
DELETED
|
@@ -1,53 +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 { PostHog } from 'posthog-node';
|
|
11
|
-
const TELEMETRY_ASYNC_TIMEOUT_MS = 10000;
|
|
12
|
-
const POSTHOG_API_KEY = 'phc_eNuN6Ojnk9O7uWfC17z12AK85fNR0BY6IiGVy0Gfwzw';
|
|
13
|
-
const POSTHOG_HOST = 'https://ph.mintlify.com';
|
|
14
|
-
let client = null;
|
|
15
|
-
let pendingWork = Promise.resolve();
|
|
16
|
-
export function getPostHogClient() {
|
|
17
|
-
if (!client) {
|
|
18
|
-
client = new PostHog(POSTHOG_API_KEY, {
|
|
19
|
-
host: POSTHOG_HOST,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return client;
|
|
23
|
-
}
|
|
24
|
-
export function deferShutdownUntil(work) {
|
|
25
|
-
pendingWork = Promise.allSettled([pendingWork, work]).then(() => undefined);
|
|
26
|
-
}
|
|
27
|
-
export function shutdownPostHog() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
try {
|
|
30
|
-
yield Promise.race([
|
|
31
|
-
pendingWork,
|
|
32
|
-
new Promise((resolve) => {
|
|
33
|
-
const t = setTimeout(resolve, TELEMETRY_ASYNC_TIMEOUT_MS);
|
|
34
|
-
t.unref();
|
|
35
|
-
}),
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
catch (_a) { }
|
|
39
|
-
if (!client)
|
|
40
|
-
return;
|
|
41
|
-
try {
|
|
42
|
-
yield Promise.race([
|
|
43
|
-
client.shutdown(),
|
|
44
|
-
new Promise((resolve) => {
|
|
45
|
-
const t = setTimeout(resolve, TELEMETRY_ASYNC_TIMEOUT_MS);
|
|
46
|
-
t.unref();
|
|
47
|
-
}),
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
catch (_b) { }
|
|
51
|
-
client = null;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { CONFIG_DIR } from '../constants.js';
|
|
6
|
-
const ID_FILE = path.join(CONFIG_DIR, 'anonymous-id');
|
|
7
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
8
|
-
function readValidIdFromFile() {
|
|
9
|
-
try {
|
|
10
|
-
const raw = fs.readFileSync(ID_FILE, 'utf-8').trim();
|
|
11
|
-
if (UUID_RE.test(raw))
|
|
12
|
-
return raw;
|
|
13
|
-
}
|
|
14
|
-
catch (_a) { }
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
function stableMachineDistinctId() {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
const h = crypto.createHash('sha256');
|
|
20
|
-
h.update(os.hostname());
|
|
21
|
-
h.update('\0');
|
|
22
|
-
h.update(os.homedir());
|
|
23
|
-
h.update('\0');
|
|
24
|
-
h.update((_b = (_a = process.env.USER) !== null && _a !== void 0 ? _a : process.env.USERNAME) !== null && _b !== void 0 ? _b : '');
|
|
25
|
-
const hex = h.digest('hex').slice(0, 32);
|
|
26
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
|
|
27
|
-
}
|
|
28
|
-
function tryPersistId(id) {
|
|
29
|
-
fs.mkdirSync(path.dirname(ID_FILE), { recursive: true });
|
|
30
|
-
fs.writeFileSync(ID_FILE, id, { flag: 'wx' });
|
|
31
|
-
}
|
|
32
|
-
let createdThisRun = false;
|
|
33
|
-
export function isFirstRun() {
|
|
34
|
-
getDistinctId();
|
|
35
|
-
return createdThisRun;
|
|
36
|
-
}
|
|
37
|
-
export function getDistinctId() {
|
|
38
|
-
var _a, _b, _c;
|
|
39
|
-
const existing = readValidIdFromFile();
|
|
40
|
-
if (existing)
|
|
41
|
-
return existing;
|
|
42
|
-
const randomId = crypto.randomUUID();
|
|
43
|
-
try {
|
|
44
|
-
tryPersistId(randomId);
|
|
45
|
-
createdThisRun = true;
|
|
46
|
-
return (_a = readValidIdFromFile()) !== null && _a !== void 0 ? _a : randomId;
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
const code = err.code;
|
|
50
|
-
if (code === 'EEXIST') {
|
|
51
|
-
const concurrent = readValidIdFromFile();
|
|
52
|
-
if (concurrent)
|
|
53
|
-
return concurrent;
|
|
54
|
-
try {
|
|
55
|
-
fs.writeFileSync(ID_FILE, randomId);
|
|
56
|
-
}
|
|
57
|
-
catch (_d) { }
|
|
58
|
-
return (_b = readValidIdFromFile()) !== null && _b !== void 0 ? _b : randomId;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const stable = stableMachineDistinctId();
|
|
62
|
-
try {
|
|
63
|
-
fs.mkdirSync(path.dirname(ID_FILE), { recursive: true });
|
|
64
|
-
fs.writeFileSync(ID_FILE, stable);
|
|
65
|
-
}
|
|
66
|
-
catch (_e) { }
|
|
67
|
-
return (_c = readValidIdFromFile()) !== null && _c !== void 0 ? _c : stable;
|
|
68
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { CONFIG_DIR } from '../constants.js';
|
|
5
|
-
const SESSION_FILE = path.join(CONFIG_DIR, 'telemetry-session.json');
|
|
6
|
-
const SESSION_IDLE_MS = 30 * 60 * 1000;
|
|
7
|
-
let current;
|
|
8
|
-
function uuidv7(now) {
|
|
9
|
-
const bytes = crypto.randomBytes(16);
|
|
10
|
-
bytes.writeUIntBE(now, 0, 6);
|
|
11
|
-
bytes[6] = (bytes[6] & 0x0f) | 0x70;
|
|
12
|
-
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
13
|
-
const hex = bytes.toString('hex');
|
|
14
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
15
|
-
}
|
|
16
|
-
function readSession() {
|
|
17
|
-
try {
|
|
18
|
-
const { id, lastSeenAt } = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8'));
|
|
19
|
-
return typeof id === 'string' && typeof lastSeenAt === 'number' ? { id, lastSeenAt } : null;
|
|
20
|
-
}
|
|
21
|
-
catch (_a) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function getSessionId(now = Date.now()) {
|
|
26
|
-
if (!current) {
|
|
27
|
-
const saved = readSession();
|
|
28
|
-
current = saved && now - saved.lastSeenAt < SESSION_IDLE_MS ? saved.id : uuidv7(now);
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
32
|
-
fs.writeFileSync(SESSION_FILE, JSON.stringify({ id: current, lastSeenAt: now }));
|
|
33
|
-
}
|
|
34
|
-
catch (_a) { }
|
|
35
|
-
return current;
|
|
36
|
-
}
|
package/bin/telemetry/track.js
DELETED
|
@@ -1,149 +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 os from 'os';
|
|
11
|
-
import { detectAgent, isCI } from '../agent.js';
|
|
12
|
-
import { isTelemetryEnabled } from '../config.js';
|
|
13
|
-
import { TELEMETRY_ASYNC_TIMEOUT_MS, TELEMETRY_IDENTITY_TIMEOUT_MS } from '../constants.js';
|
|
14
|
-
import { getVersions } from '../helpers.js';
|
|
15
|
-
import { getAccessToken, getUserEmail, storeUserEmail } from '../keyring.js';
|
|
16
|
-
import { fetchCliStatus } from '../status.js';
|
|
17
|
-
import { deferShutdownUntil, getPostHogClient } from './client.js';
|
|
18
|
-
import { getDistinctId, isFirstRun } from './distinctId.js';
|
|
19
|
-
import { getSessionId } from './sessionId.js';
|
|
20
|
-
function getEnvironmentProperties() {
|
|
21
|
-
const agent = detectAgent();
|
|
22
|
-
return {
|
|
23
|
-
os: os.platform(),
|
|
24
|
-
arch: os.arch(),
|
|
25
|
-
node_version: process.version,
|
|
26
|
-
is_ai_agent: agent !== undefined,
|
|
27
|
-
ai_agent: agent,
|
|
28
|
-
is_ci: isCI(),
|
|
29
|
-
is_tty: Boolean(process.stdin.isTTY),
|
|
30
|
-
is_first_run: isFirstRun(),
|
|
31
|
-
$session_id: getSessionId(),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function captureWithTimeout(event, properties) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
yield Promise.race([
|
|
37
|
-
getPostHogClient()
|
|
38
|
-
.captureImmediate({
|
|
39
|
-
distinctId: getDistinctId(),
|
|
40
|
-
event,
|
|
41
|
-
properties,
|
|
42
|
-
})
|
|
43
|
-
.catch(() => { }),
|
|
44
|
-
new Promise((resolve) => {
|
|
45
|
-
const t = setTimeout(resolve, TELEMETRY_ASYNC_TIMEOUT_MS);
|
|
46
|
-
t.unref();
|
|
47
|
-
}),
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function getIdentity() {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
try {
|
|
54
|
-
const [accessToken, storedEmail] = yield Promise.all([
|
|
55
|
-
getAccessToken(),
|
|
56
|
-
getUserEmail().catch(() => null),
|
|
57
|
-
]);
|
|
58
|
-
if (!accessToken)
|
|
59
|
-
return { loggedIn: false, email: null };
|
|
60
|
-
if (storedEmail)
|
|
61
|
-
return { loggedIn: true, email: storedEmail };
|
|
62
|
-
const status = yield fetchCliStatus(AbortSignal.timeout(TELEMETRY_IDENTITY_TIMEOUT_MS));
|
|
63
|
-
if (!status.ok)
|
|
64
|
-
return { loggedIn: true, email: null };
|
|
65
|
-
const email = status.status.user.email;
|
|
66
|
-
yield storeUserEmail(email).catch(() => { });
|
|
67
|
-
return { loggedIn: true, email };
|
|
68
|
-
}
|
|
69
|
-
catch (_a) {
|
|
70
|
-
return { loggedIn: false, email: null };
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function getIdentityProperties() {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const { loggedIn, email } = yield getIdentity();
|
|
77
|
-
return Object.assign({ is_logged_in: loggedIn }, (email ? { email, $set: { email } } : {}));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
export function trackCommand(_a) {
|
|
81
|
-
return __awaiter(this, arguments, void 0, function* ({ command, cliVersion, subdomain, }) {
|
|
82
|
-
if (!isTelemetryEnabled())
|
|
83
|
-
return;
|
|
84
|
-
const work = (() => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
try {
|
|
86
|
-
yield captureWithTimeout('cli.command.executed', Object.assign(Object.assign(Object.assign({ command, cli_version: cliVersion }, getEnvironmentProperties()), (yield getIdentityProperties())), { subdomain }));
|
|
87
|
-
}
|
|
88
|
-
catch (_a) { }
|
|
89
|
-
}))();
|
|
90
|
-
deferShutdownUntil(work);
|
|
91
|
-
yield work;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function trackLoginEvent(event, extra) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
if (!isTelemetryEnabled())
|
|
97
|
-
return;
|
|
98
|
-
const work = (() => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
try {
|
|
100
|
-
const { cli: cliVersion } = getVersions();
|
|
101
|
-
yield captureWithTimeout(event, Object.assign(Object.assign(Object.assign(Object.assign({}, extra), { cli_version: cliVersion }), getEnvironmentProperties()), (yield getIdentityProperties())));
|
|
102
|
-
}
|
|
103
|
-
catch (_a) { }
|
|
104
|
-
}))();
|
|
105
|
-
deferShutdownUntil(work);
|
|
106
|
-
yield work;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
export function trackLoginAttempt() {
|
|
110
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
return trackLoginEvent('cli.login.attempted');
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
export function trackLoginSuccess() {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
return trackLoginEvent('cli.login.succeeded');
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
export function trackLoginFailed(reason) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
return trackLoginEvent('cli.login.failed', { reason });
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
export function trackEvent(event, properties) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
if (!isTelemetryEnabled())
|
|
127
|
-
return;
|
|
128
|
-
const work = (() => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
try {
|
|
130
|
-
const { cli: cliVersion } = getVersions();
|
|
131
|
-
yield captureWithTimeout(event, Object.assign(Object.assign(Object.assign(Object.assign({}, properties), { cli_version: cliVersion }), getEnvironmentProperties()), (yield getIdentityProperties())));
|
|
132
|
-
}
|
|
133
|
-
catch (_a) { }
|
|
134
|
-
}))();
|
|
135
|
-
deferShutdownUntil(work);
|
|
136
|
-
yield work;
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
export function trackTelemetryPreferenceChange(options) {
|
|
140
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
if (process.env.CLI_TEST_MODE === 'true')
|
|
142
|
-
return;
|
|
143
|
-
try {
|
|
144
|
-
const { cli: cliVersion } = getVersions();
|
|
145
|
-
yield captureWithTimeout('cli.telemetry.preference_changed', Object.assign({ enabled: options.enabled, cli_version: cliVersion }, getEnvironmentProperties()));
|
|
146
|
-
}
|
|
147
|
-
catch (_a) { }
|
|
148
|
-
});
|
|
149
|
-
}
|