@zeroheight/adoption-cli 3.0.2 → 3.1.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/cli.d.ts +8 -5
- package/dist/cli.js +12924 -36
- 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,117 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Newline, Text, useApp } from "ink";
|
|
3
|
-
import Spinner from "ink-spinner";
|
|
4
|
-
import { readConfig } from "../../common/config.js";
|
|
5
|
-
import { getAliasesFromExports, getPackageInfo, } from "../../commands/track-package.utils.js";
|
|
6
|
-
import { ResponseStatus, submitPackageDetails } from "../../common/api.js";
|
|
7
|
-
import { ApiError } from "../../common/errors.js";
|
|
8
|
-
var Step;
|
|
9
|
-
(function (Step) {
|
|
10
|
-
Step[Step["COMPLETE"] = 0] = "COMPLETE";
|
|
11
|
-
Step[Step["ERRORED"] = 1] = "ERRORED";
|
|
12
|
-
Step[Step["FINDING_DETAILS"] = 2] = "FINDING_DETAILS";
|
|
13
|
-
Step[Step["MULTIPLE_PACKAGES_FOUND"] = 3] = "MULTIPLE_PACKAGES_FOUND";
|
|
14
|
-
Step[Step["SINGLE_PACKAGE_FOUND"] = 4] = "SINGLE_PACKAGE_FOUND";
|
|
15
|
-
})(Step || (Step = {}));
|
|
16
|
-
export default function NonInteractiveTrackPackage({ allowedPackages, }) {
|
|
17
|
-
const { exit } = useApp();
|
|
18
|
-
const [currentStep, setCurrentStep] = React.useState(Step.FINDING_DETAILS);
|
|
19
|
-
const [errorMessage, setErrorMessage] = React.useState(null);
|
|
20
|
-
const [packageFiles, setPackageFiles] = React.useState([]);
|
|
21
|
-
const [packageName, setPackageName] = React.useState(null);
|
|
22
|
-
const [packageVersion, setPackageVersion] = React.useState(null);
|
|
23
|
-
async function runTrackPackage() {
|
|
24
|
-
const config = (await readConfig()) ?? { token: "temp", client: "temp" };
|
|
25
|
-
const { files, error } = await getPackageInfo(allowedPackages);
|
|
26
|
-
try {
|
|
27
|
-
if (files.length === 1) {
|
|
28
|
-
const { name, path, version, exports } = files[0];
|
|
29
|
-
setPackageName(name);
|
|
30
|
-
setPackageVersion(version);
|
|
31
|
-
setCurrentStep(Step.SINGLE_PACKAGE_FOUND);
|
|
32
|
-
const aliases = getAliasesFromExports(name, exports);
|
|
33
|
-
const response = await submitPackageDetails(name, path, version, aliases, {
|
|
34
|
-
token: config.token,
|
|
35
|
-
client: config.client,
|
|
36
|
-
});
|
|
37
|
-
if (response.status === ResponseStatus.Success) {
|
|
38
|
-
setCurrentStep(Step.COMPLETE);
|
|
39
|
-
exit();
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
setErrorMessage(response.message);
|
|
43
|
-
setCurrentStep(Step.ERRORED);
|
|
44
|
-
exit();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (files.length > 1) {
|
|
48
|
-
setPackageFiles(files);
|
|
49
|
-
setCurrentStep(Step.MULTIPLE_PACKAGES_FOUND);
|
|
50
|
-
await Promise.all(files.map(async (pack) => {
|
|
51
|
-
const aliases = getAliasesFromExports(pack.name, pack.exports);
|
|
52
|
-
await submitPackageDetails(pack.name, pack.path, pack.version, aliases, {
|
|
53
|
-
token: config.token,
|
|
54
|
-
client: config.client,
|
|
55
|
-
});
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
setErrorMessage(error);
|
|
60
|
-
setCurrentStep(Step.ERRORED);
|
|
61
|
-
exit();
|
|
62
|
-
}
|
|
63
|
-
setCurrentStep(Step.COMPLETE);
|
|
64
|
-
exit();
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
let errorMessage = "Failed to send data to zeroheight";
|
|
68
|
-
if (e instanceof ApiError) {
|
|
69
|
-
errorMessage = e.message;
|
|
70
|
-
}
|
|
71
|
-
setErrorMessage(errorMessage);
|
|
72
|
-
setCurrentStep(Step.ERRORED);
|
|
73
|
-
exit();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
React.useEffect(() => {
|
|
77
|
-
runTrackPackage();
|
|
78
|
-
}, []);
|
|
79
|
-
return (React.createElement(React.Fragment, null,
|
|
80
|
-
currentStep === Step.FINDING_DETAILS && (React.createElement(Text, null,
|
|
81
|
-
React.createElement(Text, { color: "green" },
|
|
82
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
83
|
-
" searching for package file...")),
|
|
84
|
-
currentStep === Step.SINGLE_PACKAGE_FOUND && (React.createElement(React.Fragment, null,
|
|
85
|
-
React.createElement(Text, null,
|
|
86
|
-
React.createElement(Text, { color: "green" }, "Details found:"),
|
|
87
|
-
" ",
|
|
88
|
-
packageName,
|
|
89
|
-
"@",
|
|
90
|
-
packageVersion),
|
|
91
|
-
React.createElement(Newline, null),
|
|
92
|
-
React.createElement(Text, null,
|
|
93
|
-
React.createElement(Text, { color: "green" },
|
|
94
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
95
|
-
" sending to zeroheight..."))),
|
|
96
|
-
currentStep === Step.MULTIPLE_PACKAGES_FOUND && (React.createElement(React.Fragment, null,
|
|
97
|
-
React.createElement(Text, { color: "green" },
|
|
98
|
-
packageFiles.length,
|
|
99
|
-
" packages found"),
|
|
100
|
-
React.createElement(Newline, null),
|
|
101
|
-
React.createElement(Text, null,
|
|
102
|
-
React.createElement(Text, { color: "green" },
|
|
103
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
104
|
-
" sending to zeroheight..."))),
|
|
105
|
-
currentStep === Step.COMPLETE && (React.createElement(Text, null,
|
|
106
|
-
"Complete -",
|
|
107
|
-
" ",
|
|
108
|
-
packageFiles.length > 1
|
|
109
|
-
? `details for ${packageFiles.length} packages`
|
|
110
|
-
: "package details",
|
|
111
|
-
" ",
|
|
112
|
-
"sent to your zeroheight account")),
|
|
113
|
-
currentStep === Step.ERRORED && (React.createElement(Text, null,
|
|
114
|
-
React.createElement(Text, { color: "red" }, "Error:"),
|
|
115
|
-
" ",
|
|
116
|
-
errorMessage))));
|
|
117
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Box, Newline, Text, useApp } from "ink";
|
|
3
|
-
import { Checkbox } from "ink-checkbox";
|
|
4
|
-
import SelectInput from "ink-select-input";
|
|
5
|
-
import Spinner from "ink-spinner";
|
|
6
|
-
import ConfirmInput from "../ui/confirm-input.js";
|
|
7
|
-
import { readConfig } from "../../common/config.js";
|
|
8
|
-
import { getAliasesFromExports, getPackageInfo, } from "../../commands/track-package.utils.js";
|
|
9
|
-
import { submitPackageDetails } from "../../common/api.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["MULTIPLE_PACKAGES_FOUND"] = 3] = "MULTIPLE_PACKAGES_FOUND";
|
|
17
|
-
Step[Step["MULTIPLE_PACKAGES_SELECT"] = 4] = "MULTIPLE_PACKAGES_SELECT";
|
|
18
|
-
Step[Step["SENDING_DETAILS"] = 5] = "SENDING_DETAILS";
|
|
19
|
-
Step[Step["SHOULD_SENDING_DETAILS"] = 6] = "SHOULD_SENDING_DETAILS";
|
|
20
|
-
Step[Step["SINGLE_PACKAGE_FOUND"] = 7] = "SINGLE_PACKAGE_FOUND";
|
|
21
|
-
})(Step || (Step = {}));
|
|
22
|
-
export default function TrackPackage() {
|
|
23
|
-
const { exit } = useApp();
|
|
24
|
-
const [currentStep, setCurrentStep] = React.useState(Step.FINDING_DETAILS);
|
|
25
|
-
const [credentials, setCredentials] = React.useState(null);
|
|
26
|
-
const [errorMessage, setErrorMessage] = React.useState(null);
|
|
27
|
-
const [packageFiles, setPackageFiles] = React.useState([]);
|
|
28
|
-
const [packageName, setPackageName] = React.useState(null);
|
|
29
|
-
const [packagePath, setPackagePath] = React.useState(null);
|
|
30
|
-
const [packageVersion, setPackageVersion] = React.useState(null);
|
|
31
|
-
const [packageAliases, setPackageAliases] = React.useState([]);
|
|
32
|
-
const [shouldSend, setShouldSend] = React.useState("");
|
|
33
|
-
const [shouldMultiSelect, setShouldMultiSelect] = React.useState("");
|
|
34
|
-
const [packageSelection, setPackageSelection] = React.useState([]);
|
|
35
|
-
const [selectedFileLabels, setSelectedFileLabels] = React.useState([]);
|
|
36
|
-
async function submitPackage(name, path, version, aliases) {
|
|
37
|
-
await submitPackageDetails(name, path, version, aliases, credentials);
|
|
38
|
-
}
|
|
39
|
-
async function sendData() {
|
|
40
|
-
setCurrentStep(Step.SENDING_DETAILS);
|
|
41
|
-
try {
|
|
42
|
-
if (packageFiles.length > 0) {
|
|
43
|
-
const packagesToSend = packageFiles.filter((p) => selectedFileLabels.includes(`${p.name}@${p.version}`));
|
|
44
|
-
if (packagesToSend.length > 0) {
|
|
45
|
-
await Promise.all(packagesToSend.map(async (pack) => {
|
|
46
|
-
const aliases = getAliasesFromExports(pack.name, pack.exports);
|
|
47
|
-
submitPackage(pack.name, pack.path, pack.version, aliases);
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
await Promise.all(packageFiles.map(async (pack) => {
|
|
52
|
-
const aliases = getAliasesFromExports(pack.name, pack.exports);
|
|
53
|
-
submitPackage(pack.name, pack.path, pack.version, aliases);
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
setCurrentStep(Step.COMPLETE);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
await submitPackage(packageName, packagePath, packageVersion, packageAliases);
|
|
60
|
-
setCurrentStep(Step.COMPLETE);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
let errorMessage = "Failed to send data to zeroheight";
|
|
65
|
-
if (e instanceof ApiError) {
|
|
66
|
-
errorMessage = e.message;
|
|
67
|
-
}
|
|
68
|
-
setErrorMessage(errorMessage);
|
|
69
|
-
setCurrentStep(Step.ERRORED);
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
exit();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const handleSendToZh = async (shouldSendData) => {
|
|
76
|
-
if (shouldSendData)
|
|
77
|
-
return sendData();
|
|
78
|
-
exit();
|
|
79
|
-
};
|
|
80
|
-
const handleShowMultiSelect = (shouldShow) => {
|
|
81
|
-
if (shouldShow) {
|
|
82
|
-
setCurrentStep(Step.MULTIPLE_PACKAGES_SELECT);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
handleSendToZh(true);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const handlePackageSelected = ({ label, }) => {
|
|
89
|
-
if (label === "Continue?") {
|
|
90
|
-
if (selectedFileLabels.length > 0)
|
|
91
|
-
setCurrentStep(Step.SHOULD_SENDING_DETAILS);
|
|
92
|
-
}
|
|
93
|
-
else if (selectedFileLabels.includes(label)) {
|
|
94
|
-
setSelectedFileLabels(selectedFileLabels.filter((f) => f !== label));
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
setSelectedFileLabels([...selectedFileLabels, label]);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
React.useEffect(() => {
|
|
101
|
-
(async () => {
|
|
102
|
-
const config = await readConfig();
|
|
103
|
-
if (config) {
|
|
104
|
-
setCredentials({ token: config.token, client: config.client });
|
|
105
|
-
}
|
|
106
|
-
const { files, error } = await getPackageInfo();
|
|
107
|
-
if (files.length === 1) {
|
|
108
|
-
const { name, path, version, exports } = files[0];
|
|
109
|
-
setPackageName(name);
|
|
110
|
-
setPackagePath(path);
|
|
111
|
-
setPackageVersion(version);
|
|
112
|
-
setPackageAliases(getAliasesFromExports(name, exports));
|
|
113
|
-
setCurrentStep(Step.SINGLE_PACKAGE_FOUND);
|
|
114
|
-
}
|
|
115
|
-
else if (files.length > 1) {
|
|
116
|
-
const filesAsItems = files.map((f) => ({
|
|
117
|
-
label: `${f.name}@${f.version}`,
|
|
118
|
-
value: `${f.name}@${f.version}`,
|
|
119
|
-
}));
|
|
120
|
-
setPackageSelection([
|
|
121
|
-
...filesAsItems,
|
|
122
|
-
{ label: "Continue?", value: "continue" },
|
|
123
|
-
]);
|
|
124
|
-
setPackageFiles(files);
|
|
125
|
-
setCurrentStep(Step.MULTIPLE_PACKAGES_FOUND);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
setErrorMessage(error);
|
|
129
|
-
setCurrentStep(Step.ERRORED);
|
|
130
|
-
}
|
|
131
|
-
})();
|
|
132
|
-
}, []);
|
|
133
|
-
switch (currentStep) {
|
|
134
|
-
case Step.FINDING_DETAILS:
|
|
135
|
-
return (React.createElement(Text, null,
|
|
136
|
-
React.createElement(Text, { color: "green" },
|
|
137
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
138
|
-
" Searching for package file..."));
|
|
139
|
-
case Step.SINGLE_PACKAGE_FOUND:
|
|
140
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
141
|
-
React.createElement(Text, null, "The following package details have been found:"),
|
|
142
|
-
React.createElement(Box, { marginLeft: 1, marginTop: 0.5 },
|
|
143
|
-
React.createElement(Text, null,
|
|
144
|
-
"\uD83D\uDCE6 ",
|
|
145
|
-
packageName,
|
|
146
|
-
"@",
|
|
147
|
-
packageVersion)),
|
|
148
|
-
React.createElement(Newline, null),
|
|
149
|
-
React.createElement(Text, null,
|
|
150
|
-
"Send details to zeroheight? ",
|
|
151
|
-
React.createElement(Text, { dimColor: true }, "(Y/n):")),
|
|
152
|
-
React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldSend, onSubmit: handleSendToZh, value: shouldSend })));
|
|
153
|
-
case Step.MULTIPLE_PACKAGES_FOUND:
|
|
154
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
155
|
-
React.createElement(Text, null,
|
|
156
|
-
React.createElement(Text, { color: "green" },
|
|
157
|
-
"\uD83D\uDCE6 ",
|
|
158
|
-
packageFiles.length,
|
|
159
|
-
" package files found")),
|
|
160
|
-
React.createElement(Newline, null),
|
|
161
|
-
React.createElement(Text, null,
|
|
162
|
-
"Select specific package to send? ",
|
|
163
|
-
React.createElement(Text, { dimColor: true }, "(Y/n):")),
|
|
164
|
-
React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldMultiSelect, onSubmit: handleShowMultiSelect, value: shouldMultiSelect })));
|
|
165
|
-
case Step.MULTIPLE_PACKAGES_SELECT:
|
|
166
|
-
return (React.createElement(React.Fragment, null,
|
|
167
|
-
React.createElement(Box, { marginBottom: 1 },
|
|
168
|
-
React.createElement(Text, null, "Select packages (use the arrow keys/return key)")),
|
|
169
|
-
React.createElement(SelectInput, { items: packageSelection, onSelect: handlePackageSelected, itemComponent: (props) => (React.createElement(FileItem, { ...props, selectedFileLabels: selectedFileLabels })) })));
|
|
170
|
-
case Step.SHOULD_SENDING_DETAILS:
|
|
171
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
172
|
-
React.createElement(Text, null,
|
|
173
|
-
React.createElement(Text, { color: "green" },
|
|
174
|
-
selectedFileLabels.length,
|
|
175
|
-
" ",
|
|
176
|
-
selectedFileLabels.length > 1 ? "packages" : "package",
|
|
177
|
-
" selected")),
|
|
178
|
-
React.createElement(Newline, null),
|
|
179
|
-
React.createElement(Text, null,
|
|
180
|
-
"Send to zeroheight? ",
|
|
181
|
-
React.createElement(Text, { dimColor: true }, "(Y/n):")),
|
|
182
|
-
React.createElement(ConfirmInput, { isChecked: true, onChange: setShouldSend, onSubmit: handleSendToZh, value: shouldSend })));
|
|
183
|
-
case Step.SENDING_DETAILS:
|
|
184
|
-
return (React.createElement(Text, null,
|
|
185
|
-
React.createElement(Text, { color: "green" },
|
|
186
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
187
|
-
" Sending details to zeroheight..."));
|
|
188
|
-
case Step.COMPLETE:
|
|
189
|
-
return React.createElement(Text, null, "Complete - details sent to your zeroheight account");
|
|
190
|
-
case Step.ERRORED:
|
|
191
|
-
return (React.createElement(Text, null,
|
|
192
|
-
React.createElement(Text, { color: "red" }, "Error:"),
|
|
193
|
-
" ",
|
|
194
|
-
errorMessage));
|
|
195
|
-
default:
|
|
196
|
-
return React.createElement(Text, null, "Done");
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function FileItem({ isSelected, label, selectedFileLabels, }) {
|
|
200
|
-
if (label === "Continue?") {
|
|
201
|
-
return React.createElement(Text, { color: "Blue" }, label);
|
|
202
|
-
}
|
|
203
|
-
return (React.createElement(React.Fragment, null,
|
|
204
|
-
React.createElement(Checkbox, { label: label, focused: !!isSelected, checked: selectedFileLabels.includes(label) }),
|
|
205
|
-
React.createElement(Newline, null)));
|
|
206
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
interface InkConfirmInputProps {
|
|
3
|
-
isChecked: boolean;
|
|
4
|
-
onChange: (newValue: string) => void;
|
|
5
|
-
onSubmit: (value: boolean) => void;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
value: string;
|
|
8
|
-
}
|
|
9
|
-
declare const ConfirmInput: ({ isChecked, onChange, onSubmit, placeholder, value, ...props }: InkConfirmInputProps) => React.JSX.Element;
|
|
10
|
-
export default ConfirmInput;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import TextInput from "ink-text-input";
|
|
3
|
-
import yn from "yn";
|
|
4
|
-
const ConfirmInput = ({ isChecked, onChange, onSubmit, placeholder, value, ...props }) => {
|
|
5
|
-
const handleSubmit = React.useCallback((newValue) => {
|
|
6
|
-
onSubmit(yn(newValue, { default: isChecked }));
|
|
7
|
-
}, [isChecked, onSubmit]);
|
|
8
|
-
return (React.createElement(TextInput, { ...props, placeholder: placeholder, value: value, onChange: onChange, onSubmit: handleSubmit }));
|
|
9
|
-
};
|
|
10
|
-
export default ConfirmInput;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import ConfirmInput from "./confirm-input.js";
|
|
4
|
-
export default function ContinuePrompt({ onContinue }) {
|
|
5
|
-
const [shouldContinueText, setShouldContinueText] = React.useState("");
|
|
6
|
-
return (React.createElement(Box, null,
|
|
7
|
-
React.createElement(Text, null,
|
|
8
|
-
"Send this data to ",
|
|
9
|
-
React.createElement(Text, { color: "#f63e7c" }, "zeroheight"),
|
|
10
|
-
"?",
|
|
11
|
-
" ",
|
|
12
|
-
React.createElement(Text, { dimColor: true }, "(Y/n):")),
|
|
13
|
-
React.createElement(ConfirmInput, { isChecked: true, value: shouldContinueText, onChange: setShouldContinueText, onSubmit: (answer) => {
|
|
14
|
-
onContinue(answer);
|
|
15
|
-
} })));
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
export default function UsageTable({ usage }) {
|
|
4
|
-
const rows = Array.from(usage.entries());
|
|
5
|
-
return (React.createElement(Box, { flexDirection: "column" }, rows.map(([filepath, fileUsage]) => {
|
|
6
|
-
return (React.createElement(Box, { key: filepath, flexDirection: "column" },
|
|
7
|
-
React.createElement(Text, { color: "green" }, filepath),
|
|
8
|
-
React.createElement(Box, { flexDirection: "column", marginLeft: 2 }, fileUsage.map(({ name, count }) => {
|
|
9
|
-
return (React.createElement(Box, { gap: 2, key: `${name}-${filepath}` },
|
|
10
|
-
React.createElement(Text, { bold: true }, count),
|
|
11
|
-
React.createElement(Text, null, name)));
|
|
12
|
-
}))));
|
|
13
|
-
})));
|
|
14
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _NPMLockParser_instances, _NPMLockParser_parseV1, _NPMLockParser_parseV2, _NPMLockParser_parseV3, _NPMLockParser_sanitizeName;
|
|
7
|
-
import { LockParser } from "./lock-parser.js";
|
|
8
|
-
class NPMLockParser extends LockParser {
|
|
9
|
-
constructor(lockContent) {
|
|
10
|
-
super();
|
|
11
|
-
_NPMLockParser_instances.add(this);
|
|
12
|
-
Object.defineProperty(this, "packages", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: void 0
|
|
17
|
-
});
|
|
18
|
-
const data = JSON.parse(lockContent);
|
|
19
|
-
switch (data.lockfileVersion) {
|
|
20
|
-
case 1:
|
|
21
|
-
this.packages = __classPrivateFieldGet(this, _NPMLockParser_instances, "m", _NPMLockParser_parseV1).call(this, data);
|
|
22
|
-
break;
|
|
23
|
-
case 2:
|
|
24
|
-
this.packages = __classPrivateFieldGet(this, _NPMLockParser_instances, "m", _NPMLockParser_parseV2).call(this, data);
|
|
25
|
-
break;
|
|
26
|
-
case 3:
|
|
27
|
-
default:
|
|
28
|
-
this.packages = __classPrivateFieldGet(this, _NPMLockParser_instances, "m", _NPMLockParser_parseV3).call(this, data);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
_NPMLockParser_instances = new WeakSet(), _NPMLockParser_parseV1 = function _NPMLockParser_parseV1(data) {
|
|
33
|
-
return Object.entries(data.dependencies).map(([key, properties]) => ({
|
|
34
|
-
name: __classPrivateFieldGet(this, _NPMLockParser_instances, "m", _NPMLockParser_sanitizeName).call(this, key),
|
|
35
|
-
version: properties.version,
|
|
36
|
-
}));
|
|
37
|
-
}, _NPMLockParser_parseV2 = function _NPMLockParser_parseV2(data) {
|
|
38
|
-
const out = Object.entries(data.packages)
|
|
39
|
-
.map(([key, properties]) => ({
|
|
40
|
-
name: __classPrivateFieldGet(this, _NPMLockParser_instances, "m", _NPMLockParser_sanitizeName).call(this, key),
|
|
41
|
-
version: properties.version,
|
|
42
|
-
}))
|
|
43
|
-
.filter((p) => p.name && p.version); // Remove nameless and versionless packages
|
|
44
|
-
return out;
|
|
45
|
-
}, _NPMLockParser_parseV3 = function _NPMLockParser_parseV3(data) {
|
|
46
|
-
return __classPrivateFieldGet(this, _NPMLockParser_instances, "m", _NPMLockParser_parseV2).call(this, data);
|
|
47
|
-
}, _NPMLockParser_sanitizeName = function _NPMLockParser_sanitizeName(name) {
|
|
48
|
-
const nodeModulePath = "node_modules/";
|
|
49
|
-
if (name.startsWith(nodeModulePath)) {
|
|
50
|
-
return name.slice(nodeModulePath.length);
|
|
51
|
-
}
|
|
52
|
-
return name;
|
|
53
|
-
};
|
|
54
|
-
export default NPMLockParser;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _PNPMLockParser_instances, _PNPMLockParser_parseV5, _PNPMLockParser_parseV6;
|
|
7
|
-
import { parse as parseYAML } from "yaml";
|
|
8
|
-
import { LockParser } from "./lock-parser.js";
|
|
9
|
-
class PNPMLockParser extends LockParser {
|
|
10
|
-
constructor(lockContent) {
|
|
11
|
-
super();
|
|
12
|
-
_PNPMLockParser_instances.add(this);
|
|
13
|
-
Object.defineProperty(this, "packages", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: void 0
|
|
18
|
-
});
|
|
19
|
-
this.packages = [];
|
|
20
|
-
const data = parseYAML(lockContent);
|
|
21
|
-
const majorLockfileVersion = parseInt(data.lockfileVersion, 10);
|
|
22
|
-
if (majorLockfileVersion < 6) {
|
|
23
|
-
this.packages = __classPrivateFieldGet(this, _PNPMLockParser_instances, "m", _PNPMLockParser_parseV5).call(this, data);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
this.packages = __classPrivateFieldGet(this, _PNPMLockParser_instances, "m", _PNPMLockParser_parseV6).call(this, data);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
_PNPMLockParser_instances = new WeakSet(), _PNPMLockParser_parseV5 = function _PNPMLockParser_parseV5(data) {
|
|
31
|
-
return Object.entries(data.dependencies)
|
|
32
|
-
.map(([name, version]) => ({
|
|
33
|
-
name,
|
|
34
|
-
version,
|
|
35
|
-
}))
|
|
36
|
-
.filter((p) => p.name && p.version);
|
|
37
|
-
}, _PNPMLockParser_parseV6 = function _PNPMLockParser_parseV6(data) {
|
|
38
|
-
return Object.keys(data.packages)
|
|
39
|
-
.map((packagePair) => {
|
|
40
|
-
const lastIndex = packagePair.lastIndexOf("@");
|
|
41
|
-
let name = packagePair.slice(0, lastIndex);
|
|
42
|
-
const version = packagePair.slice(lastIndex + 1);
|
|
43
|
-
// v6 lockfiles have a leading slash
|
|
44
|
-
if (name.startsWith("/")) {
|
|
45
|
-
name = name.slice(1);
|
|
46
|
-
}
|
|
47
|
-
return { name, version };
|
|
48
|
-
})
|
|
49
|
-
.filter((p) => p.name && p.version);
|
|
50
|
-
};
|
|
51
|
-
export default PNPMLockParser;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _YarnLockParser_instances, _YarnLockParser_parseV1, _YarnLockParser_parseV4, _YarnLockParser_sanitizeName;
|
|
7
|
-
import { parse as parseYAML } from "yaml";
|
|
8
|
-
import { LockParser } from "./lock-parser.js";
|
|
9
|
-
class YarnLockParser extends LockParser {
|
|
10
|
-
constructor(lockContent) {
|
|
11
|
-
super();
|
|
12
|
-
_YarnLockParser_instances.add(this);
|
|
13
|
-
Object.defineProperty(this, "packages", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: void 0
|
|
18
|
-
});
|
|
19
|
-
this.packages = [];
|
|
20
|
-
try {
|
|
21
|
-
const data = parseYAML(lockContent);
|
|
22
|
-
// All version >= 4 use a consistent format
|
|
23
|
-
if (data.__metadata) {
|
|
24
|
-
const packageData = { ...data };
|
|
25
|
-
delete packageData?.__metadata;
|
|
26
|
-
this.packages = __classPrivateFieldGet(this, _YarnLockParser_instances, "m", _YarnLockParser_parseV4).call(this, packageData);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// V1 doesn't use real YAML syntax so wait until error trhown before default to V1
|
|
31
|
-
this.packages = __classPrivateFieldGet(this, _YarnLockParser_instances, "m", _YarnLockParser_parseV1).call(this, lockContent);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
_YarnLockParser_instances = new WeakSet(), _YarnLockParser_parseV1 = function _YarnLockParser_parseV1(rawContent) {
|
|
36
|
-
const groups = rawContent
|
|
37
|
-
.split("\n\n") // Split into groups
|
|
38
|
-
.filter((group) => !group.startsWith("#")) // Remove line-level comments
|
|
39
|
-
.map((group) => group.trimStart()); // Cleanup leading newlines
|
|
40
|
-
const nameMatcher = /[^"\s](\S+)(?<!")(?=@)/gi;
|
|
41
|
-
const versionMatcher = /(?<=")(.+)(?<!")/gi; // Pull out value in quotes
|
|
42
|
-
return groups.reduce((packages, group) => {
|
|
43
|
-
const lines = group.split("\n").map((line) => line.trim());
|
|
44
|
-
const name = lines
|
|
45
|
-
.at(0) // Name should be the first line
|
|
46
|
-
?.match(nameMatcher)?.[0]
|
|
47
|
-
?.replace('"', ""); // Remove quotes if present
|
|
48
|
-
const version = lines
|
|
49
|
-
.slice(1) // Properties are from line 1 onwards
|
|
50
|
-
.find((line) => line.startsWith("version"))
|
|
51
|
-
?.match(versionMatcher)?.[0];
|
|
52
|
-
if (name && version) {
|
|
53
|
-
return packages.concat([{ name, version }]);
|
|
54
|
-
}
|
|
55
|
-
return packages;
|
|
56
|
-
}, []);
|
|
57
|
-
}, _YarnLockParser_parseV4 = function _YarnLockParser_parseV4(data) {
|
|
58
|
-
return Object.entries(data)
|
|
59
|
-
.map(([key, properties]) => ({
|
|
60
|
-
name: __classPrivateFieldGet(this, _YarnLockParser_instances, "m", _YarnLockParser_sanitizeName).call(this, key),
|
|
61
|
-
version: properties.version.toString(),
|
|
62
|
-
}))
|
|
63
|
-
.filter((p) => p.name);
|
|
64
|
-
}, _YarnLockParser_sanitizeName = function _YarnLockParser_sanitizeName(name) {
|
|
65
|
-
if (name.startsWith("@")) {
|
|
66
|
-
return "@" + name.substring(1).split("@").at(0);
|
|
67
|
-
}
|
|
68
|
-
return name.split("@").at(0);
|
|
69
|
-
};
|
|
70
|
-
export default YarnLockParser;
|