@zeroheight/adoption-cli 3.0.2 → 3.1.1-rc.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/CHANGELOG.md +4 -0
- package/dist/cli.d.ts +8 -5
- package/dist/cli.js +12924 -35
- package/package.json +11 -6
- package/dist/ast/analyze.d.ts +0 -50
- package/dist/ast/analyze.js +0 -247
- package/dist/ast/parser.d.ts +0 -13
- package/dist/ast/parser.js +0 -14
- package/dist/commands/analyze.d.ts +0 -16
- package/dist/commands/analyze.js +0 -53
- package/dist/commands/analyze.utils.d.ts +0 -27
- package/dist/commands/analyze.utils.js +0 -204
- package/dist/commands/auth.d.ts +0 -9
- package/dist/commands/auth.js +0 -28
- package/dist/commands/monitor-repo.d.ts +0 -10
- package/dist/commands/monitor-repo.js +0 -42
- package/dist/commands/monitor-repo.utils.d.ts +0 -31
- package/dist/commands/monitor-repo.utils.js +0 -81
- package/dist/commands/track-package.d.ts +0 -9
- package/dist/commands/track-package.js +0 -41
- package/dist/commands/track-package.utils.d.ts +0 -25
- package/dist/commands/track-package.utils.js +0 -82
- package/dist/common/api.d.ts +0 -113
- package/dist/common/api.js +0 -174
- package/dist/common/config.d.ts +0 -14
- package/dist/common/config.js +0 -41
- package/dist/common/errors.d.ts +0 -15
- package/dist/common/errors.js +0 -26
- package/dist/common/logging.d.ts +0 -4
- package/dist/common/logging.js +0 -26
- package/dist/common/types/package-file.d.ts +0 -13
- package/dist/common/types/package-file.js +0 -1
- package/dist/components/analyze/analyze.d.ts +0 -14
- package/dist/components/analyze/analyze.js +0 -428
- package/dist/components/analyze/non-interactive-analyze.d.ts +0 -16
- package/dist/components/analyze/non-interactive-analyze.js +0 -164
- package/dist/components/auth/auth.d.ts +0 -7
- package/dist/components/auth/auth.js +0 -119
- package/dist/components/auth/credentials-already-exists.d.ts +0 -13
- package/dist/components/auth/credentials-already-exists.js +0 -16
- package/dist/components/auth/credentials-preview.d.ts +0 -10
- package/dist/components/auth/credentials-preview.js +0 -20
- package/dist/components/auth/no-credentials-onboarding.d.ts +0 -8
- package/dist/components/auth/no-credentials-onboarding.js +0 -62
- package/dist/components/color-usage-table.d.ts +0 -7
- package/dist/components/color-usage-table.js +0 -38
- package/dist/components/help-info.d.ts +0 -5
- package/dist/components/help-info.js +0 -24
- package/dist/components/latest-version-info.d.ts +0 -9
- package/dist/components/latest-version-info.js +0 -27
- package/dist/components/monitor-repo/monitor-repo.d.ts +0 -2
- package/dist/components/monitor-repo/monitor-repo.js +0 -9
- package/dist/components/monitor-repo/non-interactive-monitor-repo.d.ts +0 -7
- package/dist/components/monitor-repo/non-interactive-monitor-repo.js +0 -127
- package/dist/components/repo-name-prompt.d.ts +0 -8
- package/dist/components/repo-name-prompt.js +0 -97
- package/dist/components/track-package/non-interactive-track-package.d.ts +0 -5
- package/dist/components/track-package/non-interactive-track-package.js +0 -117
- package/dist/components/track-package/track-package.d.ts +0 -2
- package/dist/components/track-package/track-package.js +0 -206
- package/dist/components/ui/confirm-input.d.ts +0 -10
- package/dist/components/ui/confirm-input.js +0 -10
- package/dist/components/ui/continue-prompt.d.ts +0 -6
- package/dist/components/ui/continue-prompt.js +0 -16
- package/dist/components/usage-table.d.ts +0 -7
- package/dist/components/usage-table.js +0 -14
- package/dist/lockfile-parsers/lock-parser.d.ts +0 -9
- package/dist/lockfile-parsers/lock-parser.js +0 -5
- package/dist/lockfile-parsers/npm-lock-parser.d.ts +0 -6
- package/dist/lockfile-parsers/npm-lock-parser.js +0 -54
- package/dist/lockfile-parsers/pnpm-lock-parser.d.ts +0 -6
- package/dist/lockfile-parsers/pnpm-lock-parser.js +0 -51
- package/dist/lockfile-parsers/yarn-lock-parser.d.ts +0 -6
- package/dist/lockfile-parsers/yarn-lock-parser.js +0 -70
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Box, Text, useApp } from "ink";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import ConfirmInput from "../ui/confirm-input.js";
|
|
4
|
-
import NoCredentialsOnboarding from "./no-credentials-onboarding.js";
|
|
5
|
-
import { configPath, readConfig, writeConfig, } from "../../common/config.js";
|
|
6
|
-
import CredentialsAlreadyExists from "./credentials-already-exists.js";
|
|
7
|
-
import CredentialsPreview from "./credentials-preview.js";
|
|
8
|
-
import Spinner from "ink-spinner";
|
|
9
|
-
import { getAuthDetails } from "../../common/api.js";
|
|
10
|
-
var Step;
|
|
11
|
-
(function (Step) {
|
|
12
|
-
Step[Step["LOADING_CONFIG"] = 0] = "LOADING_CONFIG";
|
|
13
|
-
Step[Step["PROMPT_OVERWRITE"] = 1] = "PROMPT_OVERWRITE";
|
|
14
|
-
Step[Step["PROMPT_NEW_CREDENTIALS"] = 2] = "PROMPT_NEW_CREDENTIALS";
|
|
15
|
-
Step[Step["DONE_WRITE_FAIL"] = 3] = "DONE_WRITE_FAIL";
|
|
16
|
-
Step[Step["DONE_WRITE_SUCCESS"] = 4] = "DONE_WRITE_SUCCESS";
|
|
17
|
-
Step[Step["DONE_NO_CHANGE"] = 5] = "DONE_NO_CHANGE";
|
|
18
|
-
Step[Step["DONE_AUTH_FAIL"] = 6] = "DONE_AUTH_FAIL";
|
|
19
|
-
})(Step || (Step = {}));
|
|
20
|
-
export default function Auth({ token, client }) {
|
|
21
|
-
const { exit } = useApp();
|
|
22
|
-
const [shouldOverwriteAnswer, setShouldOverwriteAnswer] = React.useState("");
|
|
23
|
-
const [existingConfig, setExistingConfig] = React.useState(null);
|
|
24
|
-
const [currentStep, setCurrentStep] = React.useState(Step.LOADING_CONFIG);
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
readConfig().then((config) => {
|
|
27
|
-
setCurrentStep(Step.LOADING_CONFIG);
|
|
28
|
-
setExistingConfig(config);
|
|
29
|
-
if (!config) {
|
|
30
|
-
setCurrentStep(Step.PROMPT_NEW_CREDENTIALS);
|
|
31
|
-
}
|
|
32
|
-
else if ((config && token) || (config && client)) {
|
|
33
|
-
mergeAndWriteConfig(config, client, token);
|
|
34
|
-
}
|
|
35
|
-
else if (config) {
|
|
36
|
-
setCurrentStep(Step.PROMPT_OVERWRITE);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}, []);
|
|
40
|
-
async function mergeAndWriteConfig(oldConfig, newClient, newToken) {
|
|
41
|
-
const clientToWrite = newClient ?? oldConfig?.client;
|
|
42
|
-
const tokenToWrite = newToken ?? oldConfig?.token;
|
|
43
|
-
if (!clientToWrite || !tokenToWrite) {
|
|
44
|
-
setCurrentStep(Step.DONE_WRITE_FAIL);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const updatedConfig = {
|
|
49
|
-
client: clientToWrite,
|
|
50
|
-
token: tokenToWrite,
|
|
51
|
-
};
|
|
52
|
-
setCurrentStep(Step.LOADING_CONFIG);
|
|
53
|
-
setExistingConfig(updatedConfig);
|
|
54
|
-
await writeConfig(updatedConfig);
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
setCurrentStep(Step.DONE_WRITE_FAIL);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
setCurrentStep(Step.DONE_WRITE_SUCCESS);
|
|
61
|
-
}
|
|
62
|
-
async function handleSubmitOverwrite(override) {
|
|
63
|
-
if (override) {
|
|
64
|
-
setCurrentStep(Step.PROMPT_NEW_CREDENTIALS);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
setCurrentStep(Step.DONE_NO_CHANGE);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function handleCheckCredentials(newClient, newToken) {
|
|
71
|
-
try {
|
|
72
|
-
await getAuthDetails({ token: newToken, client: newClient });
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
setCurrentStep(Step.DONE_AUTH_FAIL);
|
|
76
|
-
return exit();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async function handleSaveCredentials(persist, newClient, newToken) {
|
|
80
|
-
if (persist) {
|
|
81
|
-
await mergeAndWriteConfig(existingConfig, newClient, newToken);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
setCurrentStep(Step.DONE_NO_CHANGE);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
switch (currentStep) {
|
|
88
|
-
case Step.PROMPT_OVERWRITE:
|
|
89
|
-
return (React.createElement(React.Fragment, null,
|
|
90
|
-
existingConfig?.client && existingConfig?.token && (React.createElement(CredentialsAlreadyExists, { configPath: configPath(), existingConfig: existingConfig })),
|
|
91
|
-
React.createElement(Box, null,
|
|
92
|
-
React.createElement(Text, null,
|
|
93
|
-
"Would you like to overwrite these credentials?",
|
|
94
|
-
" ",
|
|
95
|
-
React.createElement(Text, { dimColor: true }, "(y/N)")),
|
|
96
|
-
React.createElement(ConfirmInput, { isChecked: false, value: shouldOverwriteAnswer, onChange: setShouldOverwriteAnswer, onSubmit: handleSubmitOverwrite }))));
|
|
97
|
-
case Step.PROMPT_NEW_CREDENTIALS:
|
|
98
|
-
return (React.createElement(NoCredentialsOnboarding, { onCheckCredentials: handleCheckCredentials, onSaveCredentials: handleSaveCredentials, configPath: configPath() }));
|
|
99
|
-
case Step.DONE_WRITE_SUCCESS:
|
|
100
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
101
|
-
React.createElement(Text, { color: "green" }, "Updated credentials"),
|
|
102
|
-
existingConfig?.client && existingConfig?.token && (React.createElement(CredentialsPreview, { client: existingConfig.client, token: existingConfig.token }))));
|
|
103
|
-
case Step.DONE_NO_CHANGE:
|
|
104
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
105
|
-
React.createElement(Text, { color: "yellow" }, "Credentials are unchanged"),
|
|
106
|
-
existingConfig?.client && existingConfig?.token && (React.createElement(CredentialsPreview, { client: existingConfig.client, token: existingConfig.token }))));
|
|
107
|
-
case Step.DONE_WRITE_FAIL:
|
|
108
|
-
return React.createElement(Text, { color: "yellow" }, "Something went wrong, try again.");
|
|
109
|
-
case Step.DONE_AUTH_FAIL:
|
|
110
|
-
return (React.createElement(Text, { color: "red" }, "Unable to authenticate. Please re-run the command to try again."));
|
|
111
|
-
case Step.LOADING_CONFIG:
|
|
112
|
-
return (React.createElement(Text, null,
|
|
113
|
-
React.createElement(Text, { color: "green" },
|
|
114
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
115
|
-
" Loading config..."));
|
|
116
|
-
default:
|
|
117
|
-
return React.createElement(Text, null, "Done");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
interface CredentialsAlreadyExistsProps {
|
|
3
|
-
configPath: string;
|
|
4
|
-
existingConfig: {
|
|
5
|
-
client: string;
|
|
6
|
-
token: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Show when credentials already exist
|
|
11
|
-
*/
|
|
12
|
-
export default function CredentialsAlreadyExists({ configPath, existingConfig, }: CredentialsAlreadyExistsProps): React.JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Newline, Text } from "ink";
|
|
3
|
-
import Link from "ink-link";
|
|
4
|
-
import CredentialsPreview from "./credentials-preview.js";
|
|
5
|
-
/**
|
|
6
|
-
* Show when credentials already exist
|
|
7
|
-
*/
|
|
8
|
-
export default function CredentialsAlreadyExists({ configPath, existingConfig, }) {
|
|
9
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
10
|
-
React.createElement(Text, { bold: true, color: "yellow" }, "You already have your authentication credentials set up"),
|
|
11
|
-
React.createElement(Newline, null),
|
|
12
|
-
React.createElement(Text, null,
|
|
13
|
-
"You can find them in: ",
|
|
14
|
-
React.createElement(Link, { url: configPath }, configPath)),
|
|
15
|
-
React.createElement(CredentialsPreview, { client: existingConfig.client, token: existingConfig.token })));
|
|
16
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
interface CredentialsPreviewProps {
|
|
3
|
-
client: string;
|
|
4
|
-
token: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Show Client ID and Access Token (redacted/sensitive) for confirmation
|
|
8
|
-
*/
|
|
9
|
-
export default function CredentialsPreview({ client, token, }: CredentialsPreviewProps): React.JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
const REDACT_REVEAL_COUNT = 6;
|
|
4
|
-
/**
|
|
5
|
-
* Show Client ID and Access Token (redacted/sensitive) for confirmation
|
|
6
|
-
*/
|
|
7
|
-
export default function CredentialsPreview({ client, token, }) {
|
|
8
|
-
const asterisks = new Array(Math.max(3, token.length - 2 * REDACT_REVEAL_COUNT)).fill("✲");
|
|
9
|
-
return (React.createElement(Box, { borderStyle: "single", margin: 1, padding: 1 },
|
|
10
|
-
React.createElement(Box, { flexDirection: "column" },
|
|
11
|
-
React.createElement(Box, { gap: 7 },
|
|
12
|
-
React.createElement(Text, { bold: true }, "Client ID:"),
|
|
13
|
-
React.createElement(Text, null, client)),
|
|
14
|
-
React.createElement(Box, { gap: 4 },
|
|
15
|
-
React.createElement(Text, { bold: true }, "Access Token:"),
|
|
16
|
-
React.createElement(Text, null,
|
|
17
|
-
token.slice(0, REDACT_REVEAL_COUNT),
|
|
18
|
-
asterisks,
|
|
19
|
-
token.slice(token.length - REDACT_REVEAL_COUNT, token.length))))));
|
|
20
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
interface NoCredentialsOnboardingProps {
|
|
3
|
-
onCheckCredentials: (client: string, token: string) => Promise<void>;
|
|
4
|
-
onSaveCredentials: (storeCredentials: boolean, client: string, token: string) => Promise<void>;
|
|
5
|
-
configPath: string;
|
|
6
|
-
}
|
|
7
|
-
export default function NoCredentialsOnboarding({ onCheckCredentials, onSaveCredentials, configPath, }: NoCredentialsOnboardingProps): React.JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Newline, Text } from "ink";
|
|
3
|
-
import TextInput from "ink-text-input";
|
|
4
|
-
import Link from "ink-link";
|
|
5
|
-
import Spinner from "ink-spinner";
|
|
6
|
-
import ConfirmInput from "../ui/confirm-input.js";
|
|
7
|
-
import CredentialsPreview from "./credentials-preview.js";
|
|
8
|
-
export default function NoCredentialsOnboarding({ onCheckCredentials, onSaveCredentials, configPath, }) {
|
|
9
|
-
const [client, setClient] = React.useState("");
|
|
10
|
-
const [token, setToken] = React.useState("");
|
|
11
|
-
const [shouldWrite, setShouldWrite] = React.useState("");
|
|
12
|
-
const [field, setField] = React.useState("client");
|
|
13
|
-
const handleCheckCredentials = async () => {
|
|
14
|
-
setField("authenticating");
|
|
15
|
-
await onCheckCredentials(client, token);
|
|
16
|
-
setField("write");
|
|
17
|
-
};
|
|
18
|
-
const handleWriteCredentials = async (answer) => {
|
|
19
|
-
await onSaveCredentials(answer, client.trim(), token.trim());
|
|
20
|
-
};
|
|
21
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
22
|
-
React.createElement(Text, null,
|
|
23
|
-
"\uD83D\uDC4B Welcome to the ",
|
|
24
|
-
React.createElement(Text, { color: "#f63e7c" }, "zeroheight"),
|
|
25
|
-
" adoption CLI tool"),
|
|
26
|
-
React.createElement(Newline, null),
|
|
27
|
-
React.createElement(Text, null,
|
|
28
|
-
"If you need a new auth token, generate them from the",
|
|
29
|
-
" ",
|
|
30
|
-
React.createElement(Link, { url: "https://zeroheight.com/settings/team/developers" },
|
|
31
|
-
React.createElement(Text, { underline: true, color: "#f63e7c" }, "Developer Settings"))),
|
|
32
|
-
React.createElement(Newline, null),
|
|
33
|
-
field === "client" && (React.createElement(Box, null,
|
|
34
|
-
React.createElement(Text, null, "Client ID: "),
|
|
35
|
-
React.createElement(TextInput, { onChange: setClient, value: client, onSubmit: (v) => {
|
|
36
|
-
if (v.trim().length === 0)
|
|
37
|
-
return;
|
|
38
|
-
setField("token");
|
|
39
|
-
} }))),
|
|
40
|
-
field === "token" && (React.createElement(Box, null,
|
|
41
|
-
React.createElement(Text, null, "Access Token:"),
|
|
42
|
-
React.createElement(TextInput, { onChange: setToken, value: token, onSubmit: (v) => {
|
|
43
|
-
if (v.trim().length === 0)
|
|
44
|
-
return;
|
|
45
|
-
handleCheckCredentials();
|
|
46
|
-
} }))),
|
|
47
|
-
field === "authenticating" && (React.createElement(Text, null,
|
|
48
|
-
React.createElement(Text, { color: "green" },
|
|
49
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
50
|
-
" checking authentication details...")),
|
|
51
|
-
field === "write" && (React.createElement(Box, { flexDirection: "column" },
|
|
52
|
-
React.createElement(CredentialsPreview, { client: client, token: token }),
|
|
53
|
-
React.createElement(Text, null,
|
|
54
|
-
"Write updated credentials to",
|
|
55
|
-
" ",
|
|
56
|
-
React.createElement(Link, { url: configPath }, configPath),
|
|
57
|
-
"?",
|
|
58
|
-
" ",
|
|
59
|
-
React.createElement(Text, { dimColor: true }, "(Y/n)")),
|
|
60
|
-
React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldWrite, onSubmit: handleWriteCredentials, value: shouldWrite }))),
|
|
61
|
-
React.createElement(Newline, null)));
|
|
62
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
const colorTypeNameMap = {
|
|
4
|
-
hex: "HEX",
|
|
5
|
-
rgb: "RGB",
|
|
6
|
-
hsla: "HSL",
|
|
7
|
-
oklab: "Oklab",
|
|
8
|
-
hwb: "HWB",
|
|
9
|
-
lab: "LAB",
|
|
10
|
-
lch: "LCH",
|
|
11
|
-
colorSpace: "Color space",
|
|
12
|
-
totalCount: "Total usage",
|
|
13
|
-
};
|
|
14
|
-
export default function ColorUsageTable({ usage }) {
|
|
15
|
-
const rows = Array.from(usage.entries());
|
|
16
|
-
return (React.createElement(Box, { flexDirection: "column" }, rows.map(([filepath, rawColorUsage]) => {
|
|
17
|
-
const rowValues = Object.entries(rawColorUsage);
|
|
18
|
-
return (React.createElement(Box, { key: filepath, flexDirection: "column" },
|
|
19
|
-
React.createElement(Text, { color: "green" }, filepath),
|
|
20
|
-
React.createElement(Box, { flexDirection: "column", marginLeft: 2 },
|
|
21
|
-
React.createElement(Box, { flexDirection: "column", marginLeft: 2 }, rowValues.map(([type, values]) => {
|
|
22
|
-
if (type === "totalCount")
|
|
23
|
-
return null;
|
|
24
|
-
const count = values.length;
|
|
25
|
-
if (count === 0)
|
|
26
|
-
return null;
|
|
27
|
-
const name = colorTypeNameMap[type];
|
|
28
|
-
return (React.createElement(Box, { gap: 2, key: `${type}-${count}` },
|
|
29
|
-
React.createElement(Text, { bold: true },
|
|
30
|
-
name,
|
|
31
|
-
": "),
|
|
32
|
-
React.createElement(Text, null, count)));
|
|
33
|
-
})),
|
|
34
|
-
React.createElement(Text, { bold: true },
|
|
35
|
-
"Total usage: ",
|
|
36
|
-
rawColorUsage.totalCount))));
|
|
37
|
-
})));
|
|
38
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import Link from "ink-link";
|
|
4
|
-
/**
|
|
5
|
-
* Rich help banner with link to help center docs
|
|
6
|
-
*/
|
|
7
|
-
export default function HelpInfo() {
|
|
8
|
-
return (React.createElement(React.Fragment, null,
|
|
9
|
-
React.createElement(Box, { borderStyle: "double", paddingLeft: 1, paddingRight: 1, marginBottom: 1, flexDirection: "column" },
|
|
10
|
-
React.createElement(Box, { justifyContent: "center", marginBottom: 1 },
|
|
11
|
-
React.createElement(Text, { bold: true }, "Welcome \uD83D\uDC4B")),
|
|
12
|
-
React.createElement(Box, { marginBottom: 1 },
|
|
13
|
-
React.createElement(Text, null,
|
|
14
|
-
"Get started with the",
|
|
15
|
-
" ",
|
|
16
|
-
React.createElement(Text, { color: "#f63e7c", bold: true }, "zeroheight"),
|
|
17
|
-
" ",
|
|
18
|
-
"measurement CLI and start tracking your design system's adoption.")),
|
|
19
|
-
React.createElement(Text, null,
|
|
20
|
-
"For more information on how to set this up, check",
|
|
21
|
-
" ",
|
|
22
|
-
React.createElement(Link, { url: "https://zeroheight.com/help/article/adoption-private-beta-overview/" }, "here"),
|
|
23
|
-
"."))));
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
interface LatestVersionInfoProps {
|
|
3
|
-
latestVersion: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Rich help banner with info about the latest version
|
|
7
|
-
*/
|
|
8
|
-
export default function LatestVersionInfo({ latestVersion, }: LatestVersionInfoProps): React.JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import Link from "ink-link";
|
|
4
|
-
import { CURRENT_VERSION } from "../cli.js";
|
|
5
|
-
/**
|
|
6
|
-
* Rich help banner with info about the latest version
|
|
7
|
-
*/
|
|
8
|
-
export default function LatestVersionInfo({ latestVersion, }) {
|
|
9
|
-
const isMajorVersionOut = Number(CURRENT_VERSION.split(".")[0]) < Number(latestVersion.split(".")[0]);
|
|
10
|
-
return (React.createElement(React.Fragment, null,
|
|
11
|
-
React.createElement(Box, { borderStyle: "double", paddingLeft: 1, paddingRight: 1, marginBottom: 1, flexDirection: "column" },
|
|
12
|
-
React.createElement(Box, { justifyContent: "center", marginBottom: 1 },
|
|
13
|
-
React.createElement(Text, null, "\uD83D\uDC4B It seems you're not using the latest version of this package")),
|
|
14
|
-
React.createElement(Box, { flexDirection: "column", alignItems: "center", marginBottom: 1 },
|
|
15
|
-
React.createElement(Box, null,
|
|
16
|
-
React.createElement(Text, { color: isMajorVersionOut ? "redBright" : "blueBright", bold: true }, CURRENT_VERSION),
|
|
17
|
-
React.createElement(Text, { bold: true }, ` -> `),
|
|
18
|
-
React.createElement(Text, { color: "green", bold: true }, latestVersion)),
|
|
19
|
-
React.createElement(Box, null,
|
|
20
|
-
React.createElement(Text, null, "Update using: "),
|
|
21
|
-
React.createElement(Text, { bold: true }, "npm i @zeroheight/adoption-cli"))),
|
|
22
|
-
React.createElement(Box, { flexDirection: "column", alignItems: "center" },
|
|
23
|
-
React.createElement(Text, null,
|
|
24
|
-
"For more information on the latest version, check",
|
|
25
|
-
" ",
|
|
26
|
-
React.createElement(Link, { url: "https://www.npmjs.com/package/@zeroheight/adoption-cli" }, "here"))))));
|
|
27
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Text } from "ink";
|
|
3
|
-
import { findLockfiles } from "../../commands/monitor-repo.utils.js";
|
|
4
|
-
export default function MonitorRepo() {
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
findLockfiles();
|
|
7
|
-
}, []);
|
|
8
|
-
return React.createElement(Text, null, "Monitor Repo");
|
|
9
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface NonInteractiveMonitorRepoProps {
|
|
3
|
-
packageDirs?: string[];
|
|
4
|
-
packageName?: string;
|
|
5
|
-
}
|
|
6
|
-
export default function NonInteractiveMonitorRepo({ packageDirs, packageName, }: NonInteractiveMonitorRepoProps): React.JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import Spinner from "ink-spinner";
|
|
4
|
-
import { basename, join as joinPath } from "path";
|
|
5
|
-
import { findLockfiles, getPackageMeta, groupByBasename, parseLockfile, } from "../../commands/monitor-repo.utils.js";
|
|
6
|
-
import { findPackageFiles } from "../../commands/track-package.utils.js";
|
|
7
|
-
import { ResponseStatus, submitMonitoredRepoDetails, } from "../../common/api.js";
|
|
8
|
-
import { readConfig } from "../../common/config.js";
|
|
9
|
-
import YarnLockParser from "../../lockfile-parsers/yarn-lock-parser.js";
|
|
10
|
-
import { ApiError } from "../../common/errors.js";
|
|
11
|
-
var Step;
|
|
12
|
-
(function (Step) {
|
|
13
|
-
Step[Step["COMPLETE"] = 0] = "COMPLETE";
|
|
14
|
-
Step[Step["ERRORED"] = 1] = "ERRORED";
|
|
15
|
-
Step[Step["FINDING_DETAILS"] = 2] = "FINDING_DETAILS";
|
|
16
|
-
Step[Step["SENDING_DATA"] = 3] = "SENDING_DATA";
|
|
17
|
-
})(Step || (Step = {}));
|
|
18
|
-
export default function NonInteractiveMonitorRepo({ packageDirs, packageName, }) {
|
|
19
|
-
const [errorMessage, setErrorMessage] = React.useState(); // Global error message
|
|
20
|
-
const [repoStatus, setRepoStatus] = React.useState({});
|
|
21
|
-
function updateRepoStatus(name, step, error) {
|
|
22
|
-
// If any error ocurred, return error so pipes failing
|
|
23
|
-
if (error) {
|
|
24
|
-
process.exitCode = 1;
|
|
25
|
-
}
|
|
26
|
-
setRepoStatus((s) => ({ ...s, [name]: { ...s[name], step, error } }));
|
|
27
|
-
}
|
|
28
|
-
async function scanLockfiles() {
|
|
29
|
-
const base = process.cwd();
|
|
30
|
-
let lockfiles = [];
|
|
31
|
-
let packageFiles = [];
|
|
32
|
-
if (packageDirs) {
|
|
33
|
-
packageFiles = (await Promise.all(packageDirs.map(findLockfiles))).flat();
|
|
34
|
-
lockfiles = (await Promise.all(packageDirs.map(findPackageFiles))).flat();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
packageFiles = await findPackageFiles();
|
|
38
|
-
lockfiles = await findLockfiles();
|
|
39
|
-
}
|
|
40
|
-
const groupedFiles = groupByBasename([...lockfiles, ...packageFiles]);
|
|
41
|
-
const config = await readConfig();
|
|
42
|
-
if (Object.keys(groupedFiles).length === 0) {
|
|
43
|
-
setErrorMessage("No NPM packages found");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
// Package file should be in same directory as lockfile, iterate through to send as pairs
|
|
47
|
-
for (const [directory, files] of Object.entries(groupedFiles)) {
|
|
48
|
-
const lockfile = files.filter((f) => f !== "package.json").at(0);
|
|
49
|
-
if (!lockfile)
|
|
50
|
-
continue;
|
|
51
|
-
let packageMeta;
|
|
52
|
-
try {
|
|
53
|
-
packageMeta = await getPackageMeta(joinPath(directory, "package.json"));
|
|
54
|
-
if (packageName) {
|
|
55
|
-
packageMeta.name = packageName;
|
|
56
|
-
}
|
|
57
|
-
if (!packageMeta.name) {
|
|
58
|
-
setErrorMessage(`Name field is missing in your ${basename(directory)}/package.json file. Re-run the command with --package-name <name> to continue.`);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
// package.json doesn't exist or is invalid, skip pair
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
updateRepoStatus(packageMeta.name, Step.FINDING_DETAILS);
|
|
67
|
-
const parser = await parseLockfile(joinPath(directory, lockfile));
|
|
68
|
-
let parsedPackages = parser.packages;
|
|
69
|
-
// Exclude self-named packages (may be used for linking and workspaces)
|
|
70
|
-
if (parser instanceof YarnLockParser) {
|
|
71
|
-
parsedPackages = parser.packages.filter((p) => p.name !== packageMeta.name);
|
|
72
|
-
}
|
|
73
|
-
//TODO: not sure if we want `./` or not, maybe better to leave off for compatibility with windows?
|
|
74
|
-
const relativeLockfilePath = joinPath(directory.split(base).pop() ?? "", lockfile);
|
|
75
|
-
if (!config) {
|
|
76
|
-
setErrorMessage("No credentials, must authenticate to send data to zeroheight.");
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
updateRepoStatus(packageMeta.name, Step.SENDING_DATA);
|
|
81
|
-
const response = await submitMonitoredRepoDetails(packageMeta.name, packageMeta.version, relativeLockfilePath, parsedPackages, {
|
|
82
|
-
token: config.token,
|
|
83
|
-
client: config.client,
|
|
84
|
-
});
|
|
85
|
-
if (response.status === ResponseStatus.Success) {
|
|
86
|
-
updateRepoStatus(packageMeta.name, Step.COMPLETE);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
updateRepoStatus(packageMeta.name, Step.ERRORED, response.message);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
let errorMessage = "Failed to send data to zeroheight";
|
|
94
|
-
if (e instanceof ApiError) {
|
|
95
|
-
errorMessage = e.message;
|
|
96
|
-
}
|
|
97
|
-
updateRepoStatus(packageMeta.name, Step.ERRORED, errorMessage);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
React.useEffect(() => {
|
|
102
|
-
scanLockfiles();
|
|
103
|
-
}, []);
|
|
104
|
-
return (React.createElement(React.Fragment, null,
|
|
105
|
-
Object.entries(repoStatus).map(([name, { step, error }]) => (React.createElement(Box, { key: name, flexDirection: "column" },
|
|
106
|
-
step === Step.FINDING_DETAILS && (React.createElement(Text, null,
|
|
107
|
-
React.createElement(Text, { color: "green" },
|
|
108
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
109
|
-
`${name} - searching for package details...`)),
|
|
110
|
-
step === Step.SENDING_DATA && (React.createElement(Text, null,
|
|
111
|
-
React.createElement(Text, { color: "green" },
|
|
112
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
113
|
-
`${name} - sending data to zeroheight...`)),
|
|
114
|
-
step === Step.COMPLETE && (React.createElement(Box, { flexDirection: "column" },
|
|
115
|
-
React.createElement(Text, { color: "green" }, "Success"),
|
|
116
|
-
React.createElement(Text, null,
|
|
117
|
-
"Packages being used by ",
|
|
118
|
-
name,
|
|
119
|
-
" have been sent to your zeroheight account"))),
|
|
120
|
-
step === Step.ERRORED && (React.createElement(Text, null,
|
|
121
|
-
React.createElement(Text, { color: "red" }, "Error: "),
|
|
122
|
-
`${name} - ${error}`))))),
|
|
123
|
-
errorMessage && (React.createElement(Text, null,
|
|
124
|
-
React.createElement(Text, { color: "red" }, "Error:"),
|
|
125
|
-
" ",
|
|
126
|
-
errorMessage))));
|
|
127
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Credentials } from "../common/config.js";
|
|
3
|
-
interface RepoNamePromptProps {
|
|
4
|
-
credentials: Credentials | null;
|
|
5
|
-
onRepoNameSelected: (repoName: string) => void;
|
|
6
|
-
}
|
|
7
|
-
export default function RepoNamePrompt({ credentials, onRepoNameSelected, }: RepoNamePromptProps): React.JSX.Element | null;
|
|
8
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import Spinner from "ink-spinner";
|
|
4
|
-
import SelectInput from "ink-select-input";
|
|
5
|
-
import { readConfig } from "../common/config.js";
|
|
6
|
-
import { ResponseStatus, getExistingRepoNames } from "../common/api.js";
|
|
7
|
-
import TextInput from "ink-text-input";
|
|
8
|
-
var RepoNamePromptState;
|
|
9
|
-
(function (RepoNamePromptState) {
|
|
10
|
-
RepoNamePromptState["LOADING"] = "LOADING";
|
|
11
|
-
RepoNamePromptState["ERROR"] = "ERROR";
|
|
12
|
-
RepoNamePromptState["SELECT_REPO_NAME"] = "SELECT_REPO_NAME";
|
|
13
|
-
RepoNamePromptState["ENTER_REPO_NAME"] = "ENTER_REPO_NAME";
|
|
14
|
-
})(RepoNamePromptState || (RepoNamePromptState = {}));
|
|
15
|
-
export default function RepoNamePrompt({ credentials, onRepoNameSelected, }) {
|
|
16
|
-
const [state, setState] = React.useState(RepoNamePromptState.LOADING);
|
|
17
|
-
const [repoNames, setRepoNames] = React.useState([]);
|
|
18
|
-
const [repoName, setRepoName] = React.useState("");
|
|
19
|
-
async function loadRepoNames(credentials) {
|
|
20
|
-
try {
|
|
21
|
-
const repoNamesResponse = await getExistingRepoNames(credentials);
|
|
22
|
-
if (repoNamesResponse.status !== ResponseStatus.Success) {
|
|
23
|
-
throw new Error("Failed to get repo names");
|
|
24
|
-
}
|
|
25
|
-
const names = repoNamesResponse.data.repo_names;
|
|
26
|
-
setRepoNames(names);
|
|
27
|
-
if (names.length === 0) {
|
|
28
|
-
setState(RepoNamePromptState.ENTER_REPO_NAME);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
setState(RepoNamePromptState.SELECT_REPO_NAME);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
setState(RepoNamePromptState.ERROR);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
if (!credentials) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
setState(RepoNamePromptState.LOADING);
|
|
43
|
-
readConfig().then((config) => {
|
|
44
|
-
const repoName = config?.repoNames?.[process.cwd()];
|
|
45
|
-
if (repoName) {
|
|
46
|
-
onRepoNameSelected(repoName);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
loadRepoNames(credentials);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}, [credentials]);
|
|
53
|
-
function onSelect(item) {
|
|
54
|
-
if (item.value === "enter-repository-name") {
|
|
55
|
-
setState(RepoNamePromptState.ENTER_REPO_NAME);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
onRepoNameSelected(item.value);
|
|
59
|
-
}
|
|
60
|
-
if (state === RepoNamePromptState.LOADING) {
|
|
61
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
62
|
-
React.createElement(Text, null,
|
|
63
|
-
React.createElement(Text, { color: "cyan" },
|
|
64
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
65
|
-
" ",
|
|
66
|
-
"Fetching repository names...")));
|
|
67
|
-
}
|
|
68
|
-
if (state === RepoNamePromptState.ERROR) {
|
|
69
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
70
|
-
React.createElement(Text, { color: "red" }, "Error:"),
|
|
71
|
-
React.createElement(Box, { flexDirection: "column", marginLeft: 1 },
|
|
72
|
-
React.createElement(Text, null, "- Failed to fetch repository names"))));
|
|
73
|
-
}
|
|
74
|
-
if (state === RepoNamePromptState.SELECT_REPO_NAME) {
|
|
75
|
-
const selectItems = [
|
|
76
|
-
{ label: "Enter repository name", value: "enter-repository-name" },
|
|
77
|
-
...repoNames.map((name) => ({
|
|
78
|
-
label: name,
|
|
79
|
-
value: name,
|
|
80
|
-
})),
|
|
81
|
-
];
|
|
82
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
83
|
-
React.createElement(Text, null, "Select the repository name"),
|
|
84
|
-
React.createElement(SelectInput, { items: selectItems, onSelect: onSelect })));
|
|
85
|
-
}
|
|
86
|
-
if (state === RepoNamePromptState.ENTER_REPO_NAME) {
|
|
87
|
-
return (React.createElement(Box, null,
|
|
88
|
-
React.createElement(Text, null, "Repository name:"),
|
|
89
|
-
React.createElement(TextInput, { value: repoName, onChange: setRepoName, onSubmit: (value) => {
|
|
90
|
-
if (value.trim().length === 0) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
onRepoNameSelected(value);
|
|
94
|
-
} })));
|
|
95
|
-
}
|
|
96
|
-
return null;
|
|
97
|
-
}
|