@uipath/cli 1.206.0-preview.306 → 1.207.0-preview.307
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/{browser-strategy-p5fhwxqj.js → browser-strategy-5rfwnk5q.js} +1 -1
- package/dist/cli-1jpx8z2w.js +28 -0
- package/dist/cliInstaller-3dxg6fbd.js +23 -0
- package/dist/{contentStore-34hat2cd.js → contentStore-5p86z7qq.js} +7 -6
- package/dist/{environmentInfo-tr3pt6x1.js → environmentInfo-wp5jthdh.js} +6 -6
- package/dist/{feedbackPrompts-bx209g5v.js → feedbackPrompts-fc66gq0p.js} +3 -3
- package/dist/forcedUpdate-fm57455c.js +21 -0
- package/dist/{handlers-jjwt24f2.js → handlers-rg3d62gb.js} +13 -9
- package/dist/index-2f6vv7yr.js +81 -0
- package/dist/index-319vtrwd.js +264 -0
- package/dist/index-33wtbzyw.js +248 -0
- package/dist/index-5dbc9t09.js +41 -0
- package/dist/index-5ygg5mrs.js +1272 -0
- package/dist/{index-99emfvtm.js → index-65pyx6c9.js} +4 -2
- package/dist/{index-rr5hdtcy.js → index-81197qe5.js} +15 -17
- package/dist/{index-2mm750yx.js → index-8n0z4r6f.js} +69 -13
- package/dist/{index-8zhmg5tz.js → index-8pk6n4t9.js} +2 -2
- package/dist/{index-nsrrst23.js → index-ack311y7.js} +12 -2
- package/dist/index-afhekp0a.js +331 -0
- package/dist/{index-szbq3m4j.js → index-bf2mdvne.js} +8 -12
- package/dist/{index-2n2vr5w5.js → index-dt6mjnkf.js} +39 -57
- package/dist/{index-85fgzk87.js → index-dtgfa304.js} +1 -1
- package/dist/{index-y7d0cth0.js → index-e82sznr2.js} +7 -7
- package/dist/index-ej6eeger.js +23 -0
- package/dist/{index-bxc30q35.js → index-gk5pc8xr.js} +2 -2
- package/dist/{index-7q9kcs3w.js → index-h2ctqv68.js} +14 -5
- package/dist/{index-m780gg7f.js → index-hfvbp7ay.js} +30 -14
- package/dist/index-jk7em40j.js +37 -0
- package/dist/{index-691s5342.js → index-jn06044v.js} +2130 -834
- package/dist/{index-vhn8f5d2.js → index-kdr4xvby.js} +5 -5
- package/dist/{index-ckp8r4dh.js → index-mb62swmp.js} +2 -2
- package/dist/index-nzfpbep9.js +14 -0
- package/dist/{index-z070caqq.js → index-p64w2wrt.js} +30 -8
- package/dist/{index-8x2rp038.js → index-petywj9n.js} +81 -58
- package/dist/{index-nn8qzaxe.js → index-phkawd97.js} +2 -2
- package/dist/{index-ede5v6yy.js → index-q3f93ttm.js} +26 -17
- package/dist/{index-3s642t05.js → index-spnvnhbf.js} +7 -10
- package/dist/index-v7yphxb8.js +118 -0
- package/dist/index-vrfbee4d.js +340 -0
- package/dist/{index-69mcde3n.js → index-xw81b1gn.js} +196 -81
- package/dist/{index-wg3cne7n.js → index-xxms6rt8.js} +24 -5
- package/dist/{index-21kns9qg.js → index-y7v9rkq9.js} +1 -1
- package/dist/{index-fdztq951.js → index-zhp702kh.js} +393 -82
- package/dist/index.js +23 -18
- package/dist/{install-kgcwdbqs.js → install-h76qyy1e.js} +6 -7
- package/dist/{node-strategy-p1n8wr5s.js → node-strategy-9t0ttffv.js} +2 -2
- package/dist/{project-context-caht70an.js → project-context-rc4ghykm.js} +13 -5
- package/dist/{prompt-9ze9zy34.js → prompt-5vbvcsds.js} +5 -5
- package/dist/{server-qg4rm5e3.js → server-8c4jwqjh.js} +5 -5
- package/dist/{skillCatalog-fvrcgryd.js → skillCatalog-bqya1aer.js} +8 -7
- package/dist/skillsService-8yjvmz8c.js +35 -0
- package/dist/{telemetry-drain-rt346cfz.js → telemetry-drain-8qr5tzmf.js} +2 -2
- package/dist/tree-fk9gwh4v.js +16 -0
- package/dist/updateService-9qew50s3.js +377 -0
- package/dist/updateService.cli-xtqp78g7.js +15 -0
- package/dist/updateService.skills-e2pbe2w6.js +27 -0
- package/dist/updateService.tools-m58m2fbt.js +19 -0
- package/package.json +2 -2
- package/dist/cli-7rv7qys0.js +0 -23
- package/dist/index-3qp7d08f.js +0 -240
- package/dist/index-3zf0ywpb.js +0 -95
- package/dist/index-753mncpq.js +0 -271
- package/dist/index-w3my9pw8.js +0 -45
- package/dist/skillsService-0387c5f0.js +0 -29
- package/dist/tree-4dhk82fh.js +0 -17
- package/dist/updateService-a3ypvwz8.js +0 -522
- package/dist/updateService.skills-nkdzyrwv.js +0 -22
- package/dist/updateService.tools-3zfct9yk.js +0 -16
|
@@ -0,0 +1,1272 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileSystem2
|
|
3
|
+
} from "./index-p64w2wrt.js";
|
|
4
|
+
import {
|
|
5
|
+
catchError,
|
|
6
|
+
RESULTS,
|
|
7
|
+
carriedInstructions,
|
|
8
|
+
extractErrorDetails,
|
|
9
|
+
logger,
|
|
10
|
+
OUTPUT_FORMATS,
|
|
11
|
+
isOutputFormat,
|
|
12
|
+
OutputFormatter,
|
|
13
|
+
UIPATH_HOME_DIR,
|
|
14
|
+
CONFIG_FILENAME,
|
|
15
|
+
quoteForShell
|
|
16
|
+
} from "./index-zhp702kh.js";
|
|
17
|
+
import {
|
|
18
|
+
CHANNELS
|
|
19
|
+
} from "./index-ej6eeger.js";
|
|
20
|
+
import {
|
|
21
|
+
VERSION_PIN_RE,
|
|
22
|
+
VERSION_PIN_FORM,
|
|
23
|
+
InvalidPinsError,
|
|
24
|
+
listSome,
|
|
25
|
+
validatePins
|
|
26
|
+
} from "./index-v7yphxb8.js";
|
|
27
|
+
import {
|
|
28
|
+
INHERITED_AUTH_PROFILE_ENV2,
|
|
29
|
+
AuthProfileValidationError2,
|
|
30
|
+
normalizeAuthProfileName2,
|
|
31
|
+
isEnvAuthEnabled2
|
|
32
|
+
} from "./index-8n0z4r6f.js";
|
|
33
|
+
import {
|
|
34
|
+
TOOLS_DIRS_ENV_VAR,
|
|
35
|
+
InstallRefusedError
|
|
36
|
+
} from "./index-xw81b1gn.js";
|
|
37
|
+
import {
|
|
38
|
+
samePath
|
|
39
|
+
} from "./index-nzfpbep9.js";
|
|
40
|
+
import {
|
|
41
|
+
string,
|
|
42
|
+
array,
|
|
43
|
+
object,
|
|
44
|
+
record,
|
|
45
|
+
_enum
|
|
46
|
+
} from "./index-bf0e4evz.js";
|
|
47
|
+
import {
|
|
48
|
+
asRecord
|
|
49
|
+
} from "./index-jk7em40j.js";
|
|
50
|
+
|
|
51
|
+
// src/config/configLock.ts
|
|
52
|
+
import { randomUUID } from "node:crypto";
|
|
53
|
+
async function withConfigLock(targetPath, fn) {
|
|
54
|
+
const { getFileSystemAsync } = await import("./index-y7v9rkq9.js");
|
|
55
|
+
const fs = await getFileSystemAsync();
|
|
56
|
+
const dir = fs.path.dirname(targetPath);
|
|
57
|
+
const [mkdirErr] = await catchError(fs.mkdir(dir));
|
|
58
|
+
if (mkdirErr) {
|
|
59
|
+
throw new Error(`Could not create config directory ${dir}: ${mkdirErr.message}`, { cause: mkdirErr });
|
|
60
|
+
}
|
|
61
|
+
const [lockErr, release] = await catchError(fs.acquireLock(targetPath));
|
|
62
|
+
if (lockErr) {
|
|
63
|
+
if (lockErr.message.startsWith("ELOCKED:")) {
|
|
64
|
+
throw Object.assign(new Error("Another uip command is writing the config file.", {
|
|
65
|
+
cause: lockErr
|
|
66
|
+
}), {
|
|
67
|
+
errorCode: "timeout",
|
|
68
|
+
retry: "RetryAfter10Seconds",
|
|
69
|
+
instructions: "Wait for the other uip command to finish, then run this command again."
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const cause = lockErr.message.replace(/, \w+ '.*'$/, "");
|
|
73
|
+
throw new Error(`Could not lock the config file: ${cause}`, {
|
|
74
|
+
cause: lockErr
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return await fn();
|
|
79
|
+
} finally {
|
|
80
|
+
await catchError(release());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function parseConfigJson(content, path) {
|
|
84
|
+
const json = content.startsWith("\uFEFF") ? content.slice(1) : content;
|
|
85
|
+
if (json.trim() === "")
|
|
86
|
+
return {};
|
|
87
|
+
const [err, parsed] = catchError(() => JSON.parse(json));
|
|
88
|
+
if (!err)
|
|
89
|
+
return parsed;
|
|
90
|
+
if (!(err instanceof SyntaxError))
|
|
91
|
+
throw err;
|
|
92
|
+
throw new Error(`Invalid JSON in config file: ${path}
|
|
93
|
+
|
|
94
|
+
Please ensure your config file contains valid JSON.`, { cause: err });
|
|
95
|
+
}
|
|
96
|
+
async function readConfigFileAt(path) {
|
|
97
|
+
const { getFileSystem } = await import("./index-y7v9rkq9.js");
|
|
98
|
+
const fs = getFileSystem();
|
|
99
|
+
if (!await fs.exists(path)) {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
const content = await fs.readFile(path, "utf-8");
|
|
103
|
+
if (content === null) {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
const parsed = parseConfigJson(content, path);
|
|
107
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
108
|
+
return {};
|
|
109
|
+
}
|
|
110
|
+
return parsed;
|
|
111
|
+
}
|
|
112
|
+
async function writeConfigFileAt(path, config) {
|
|
113
|
+
const { getFileSystem } = await import("./index-y7v9rkq9.js");
|
|
114
|
+
const fs = getFileSystem();
|
|
115
|
+
const dir = fs.path.dirname(path);
|
|
116
|
+
await fs.mkdir(dir);
|
|
117
|
+
await writeFileAtomically(path, `${JSON.stringify(config, null, 4)}
|
|
118
|
+
`);
|
|
119
|
+
}
|
|
120
|
+
async function writeFileAtomically(path, content) {
|
|
121
|
+
const { getFileSystem } = await import("./index-y7v9rkq9.js");
|
|
122
|
+
const fs = getFileSystem();
|
|
123
|
+
const tempPath = `${path}.${randomUUID()}.tmp`;
|
|
124
|
+
await fs.writeFile(tempPath, content);
|
|
125
|
+
const [renameErr] = await catchError(fs.rename(tempPath, path));
|
|
126
|
+
if (renameErr) {
|
|
127
|
+
await catchError(fs.rm(tempPath));
|
|
128
|
+
throw renameErr;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/config/homeConfigPath.ts
|
|
133
|
+
function homeConfigPath(fs) {
|
|
134
|
+
return fs.path.join(fs.env.homedir(), UIPATH_HOME_DIR, CONFIG_FILENAME);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/config/configPathForMessage.ts
|
|
138
|
+
function configPathForMessage(path) {
|
|
139
|
+
const fs = getFileSystem2();
|
|
140
|
+
if (samePath(path, homeConfigPath(fs))) {
|
|
141
|
+
return `~/${UIPATH_HOME_DIR}/${CONFIG_FILENAME}`;
|
|
142
|
+
}
|
|
143
|
+
let cwd = fs.env.cwd();
|
|
144
|
+
while (cwd.endsWith("/") || cwd.endsWith("\\"))
|
|
145
|
+
cwd = cwd.slice(0, -1);
|
|
146
|
+
const separator = path.charAt(cwd.length);
|
|
147
|
+
if (cwd !== "" && samePath(path.slice(0, cwd.length), cwd) && (separator === "/" || separator === "\\")) {
|
|
148
|
+
return path.slice(cwd.length + 1);
|
|
149
|
+
}
|
|
150
|
+
const projectToCwd = fs.path.relative(fs.path.dirname(fs.path.dirname(path)), cwd);
|
|
151
|
+
const projectIsAbove = cwd !== "" && projectToCwd !== "" && !projectToCwd.startsWith("..") && !fs.path.isAbsolute(projectToCwd);
|
|
152
|
+
return projectIsAbove ? fs.path.relative(cwd, path) : path;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/config/loadConfig.ts
|
|
156
|
+
var versionPinSchema = (params) => string(params).regex(VERSION_PIN_RE, `must be ${VERSION_PIN_FORM}`);
|
|
157
|
+
var TOOL_PIN_KEY_RE = /^@uipath\/[a-z0-9]+(-[a-z0-9]+)*-tool$/;
|
|
158
|
+
var ConfigSchema = object({
|
|
159
|
+
core: object({
|
|
160
|
+
output: _enum(OUTPUT_FORMATS).optional(),
|
|
161
|
+
logLevel: _enum(["error", "warn", "info", "debug"]).optional(),
|
|
162
|
+
interactive: _enum(["never", "auto", "always"]).optional(),
|
|
163
|
+
updateChannel: _enum(CHANNELS).optional()
|
|
164
|
+
}).optional(),
|
|
165
|
+
auth: object({
|
|
166
|
+
scopes: array(string().min(1)).optional(),
|
|
167
|
+
authority: string().url().optional()
|
|
168
|
+
}).optional(),
|
|
169
|
+
versions: object({
|
|
170
|
+
cli: versionPinSchema({
|
|
171
|
+
error: (issue) => issue.input === undefined ? "is required in a versions block, which pins the CLI version" : undefined
|
|
172
|
+
}),
|
|
173
|
+
skills: versionPinSchema().optional(),
|
|
174
|
+
tools: record(string().regex(TOOL_PIN_KEY_RE), versionPinSchema(), {
|
|
175
|
+
error: (issue) => issue.code === "invalid_key" ? "a tool pin key must be the package name, @uipath/<name>-tool" : undefined
|
|
176
|
+
}).optional()
|
|
177
|
+
}).strict().optional()
|
|
178
|
+
});
|
|
179
|
+
var issueKey = (issue) => issue.path.join(".") || "config";
|
|
180
|
+
var zodProblems = (error) => error.issues.map((issue) => {
|
|
181
|
+
const path = issueKey(issue);
|
|
182
|
+
let message = issue.message;
|
|
183
|
+
if (message.includes("Required")) {
|
|
184
|
+
message = "is required";
|
|
185
|
+
} else if (message.includes("Expected string")) {
|
|
186
|
+
message = "must be a string";
|
|
187
|
+
} else if (message.includes("Invalid url")) {
|
|
188
|
+
message = "must be a valid URL";
|
|
189
|
+
} else if (message.includes("String must contain at least 1 character")) {
|
|
190
|
+
message = "cannot be empty";
|
|
191
|
+
}
|
|
192
|
+
return `${path}: ${message}`;
|
|
193
|
+
});
|
|
194
|
+
var formatZodError = (problems) => `Configuration validation failed:
|
|
195
|
+
` + problems.map((problem) => ` • ${problem}`).join(`
|
|
196
|
+
`) + `
|
|
197
|
+
|
|
198
|
+
Please check your config file and fix the errors above.`;
|
|
199
|
+
|
|
200
|
+
class ConfigValidationError extends Error {
|
|
201
|
+
problems;
|
|
202
|
+
keys;
|
|
203
|
+
constructor(message, problems, keys = []) {
|
|
204
|
+
super(message);
|
|
205
|
+
this.problems = problems;
|
|
206
|
+
this.keys = keys;
|
|
207
|
+
this.name = "ConfigValidationError";
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
var pinProblem = (parsed) => {
|
|
211
|
+
const versions = ConfigSchema.shape.versions.safeParse(parsed?.versions);
|
|
212
|
+
if (!versions.success)
|
|
213
|
+
return;
|
|
214
|
+
const [error] = catchError(() => validatePins(versions.data));
|
|
215
|
+
return error?.message;
|
|
216
|
+
};
|
|
217
|
+
var validateConfig = (parsed) => {
|
|
218
|
+
const result = ConfigSchema.safeParse(parsed);
|
|
219
|
+
if (!result.success) {
|
|
220
|
+
const problems = zodProblems(result.error);
|
|
221
|
+
const keys = result.error.issues.map(issueKey);
|
|
222
|
+
const pin = pinProblem(parsed);
|
|
223
|
+
if (pin !== undefined) {
|
|
224
|
+
problems.push(`versions.pins: ${pin}`);
|
|
225
|
+
keys.push("versions.pins");
|
|
226
|
+
}
|
|
227
|
+
throw new ConfigValidationError(formatZodError(problems), problems, keys);
|
|
228
|
+
}
|
|
229
|
+
return result.data;
|
|
230
|
+
};
|
|
231
|
+
function dropUnknownFrozenValues(parsed) {
|
|
232
|
+
const record2 = asRecord(parsed);
|
|
233
|
+
const versions = asRecord(record2?.versions);
|
|
234
|
+
const result = ConfigSchema.safeParse(parsed);
|
|
235
|
+
if (!record2 || !versions || result.success) {
|
|
236
|
+
return { kept: parsed, ignored: [] };
|
|
237
|
+
}
|
|
238
|
+
const kept = structuredClone(record2);
|
|
239
|
+
const ignored = new Set;
|
|
240
|
+
for (const issue of result.error.issues) {
|
|
241
|
+
const [block, key] = issue.path;
|
|
242
|
+
if (issue.code === "unrecognized_keys" && block === "versions") {
|
|
243
|
+
for (const unknown of issue.keys.filter((k) => !looksLikePinKey(k))) {
|
|
244
|
+
delete kept.versions[unknown];
|
|
245
|
+
ignored.add(`versions.${unknown}`);
|
|
246
|
+
}
|
|
247
|
+
} else if (block === "core" && typeof key === "string") {
|
|
248
|
+
const values = asRecord(kept.core);
|
|
249
|
+
if (values)
|
|
250
|
+
delete values[key];
|
|
251
|
+
ignored.add(`core.${key}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { kept, ignored: [...ignored] };
|
|
255
|
+
}
|
|
256
|
+
var ignoredValuesWarning = (shownPath, ignored) => `${shownPath} has values that this CLI cannot use, so it ignores them and keeps the pins: ${ignored.join(", ")}.`;
|
|
257
|
+
var looksLikePinKey = (key) => ["tools", "skills"].some((pinKey) => editDistance(key.toLowerCase(), pinKey) <= 2);
|
|
258
|
+
var validateWithIgnored = (parsed) => {
|
|
259
|
+
const { kept, ignored } = dropUnknownFrozenValues(parsed);
|
|
260
|
+
const config = validateConfig(kept);
|
|
261
|
+
validatePins(config.versions, config.core?.updateChannel);
|
|
262
|
+
return { config, ignored };
|
|
263
|
+
};
|
|
264
|
+
var validateConfigAndPins = (parsed) => validateWithIgnored(parsed).config;
|
|
265
|
+
function configLoadProblem(parsed) {
|
|
266
|
+
const [invalid] = catchError(() => validateConfigAndPins(parsed));
|
|
267
|
+
if (invalid instanceof InvalidPinsError) {
|
|
268
|
+
return { kind: "pins", detail: invalid.message };
|
|
269
|
+
}
|
|
270
|
+
if (invalid instanceof ConfigValidationError) {
|
|
271
|
+
return {
|
|
272
|
+
kind: "config",
|
|
273
|
+
problems: invalid.problems,
|
|
274
|
+
keys: invalid.keys
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (invalid)
|
|
278
|
+
throw invalid;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
class ConfigReadError extends Error {
|
|
283
|
+
code;
|
|
284
|
+
constructor(path, cause) {
|
|
285
|
+
const { code } = cause;
|
|
286
|
+
const reason = typeof code === "string" ? code : cause.message;
|
|
287
|
+
super(`Could not read the config file ${configPathForMessage(path)}: ${reason}`, { cause });
|
|
288
|
+
this.name = "ConfigReadError";
|
|
289
|
+
if (typeof code === "string")
|
|
290
|
+
this.code = code;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
var CREDENTIAL_AUTH_KEYS = ["clientId", "clientSecret"];
|
|
294
|
+
var LEGACY_TOOLS_KEYS = ["registryUrl", "localToolPaths"];
|
|
295
|
+
var CLEANUP_BLOCKS = [
|
|
296
|
+
["auth", CREDENTIAL_AUTH_KEYS],
|
|
297
|
+
["tools", LEGACY_TOOLS_KEYS]
|
|
298
|
+
];
|
|
299
|
+
var hasKeysIn = (parsed, block, keys) => {
|
|
300
|
+
const blockConfig = parsed?.[block];
|
|
301
|
+
return typeof blockConfig === "object" && blockConfig !== null && keys.some((key) => (key in blockConfig));
|
|
302
|
+
};
|
|
303
|
+
function removeCoreVersion(fileConfig) {
|
|
304
|
+
const core = asRecord(fileConfig.core);
|
|
305
|
+
if (!core || !("version" in core))
|
|
306
|
+
return;
|
|
307
|
+
const { version } = core;
|
|
308
|
+
delete core.version;
|
|
309
|
+
if (Object.keys(core).length === 0)
|
|
310
|
+
delete fileConfig.core;
|
|
311
|
+
const outcome = asRecord(fileConfig.versions) === undefined ? "removed" : "replaced";
|
|
312
|
+
return { version, outcome };
|
|
313
|
+
}
|
|
314
|
+
var cachedConfig = null;
|
|
315
|
+
var deleteKeysRemovedOnLoad = (fileConfig) => CLEANUP_BLOCKS.filter(([block, keys]) => hasKeysIn(fileConfig, block, keys)).flatMap(([block, keys]) => {
|
|
316
|
+
const blockConfig = fileConfig[block];
|
|
317
|
+
const removed = keys.filter((key) => Object.hasOwn(blockConfig, key));
|
|
318
|
+
for (const key of removed)
|
|
319
|
+
delete blockConfig[key];
|
|
320
|
+
if (Object.keys(blockConfig).length === 0)
|
|
321
|
+
delete fileConfig[block];
|
|
322
|
+
return removed.map((key) => `${block}.${key}`);
|
|
323
|
+
});
|
|
324
|
+
var deleteKeysFrom = (absolutePath) => withConfigLock(absolutePath, async () => {
|
|
325
|
+
const fileConfig = await readConfigFileAt(absolutePath);
|
|
326
|
+
if (deleteKeysRemovedOnLoad(fileConfig).length === 0)
|
|
327
|
+
return;
|
|
328
|
+
await writeConfigFileAt(absolutePath, fileConfig);
|
|
329
|
+
});
|
|
330
|
+
var cleanUpConfigKeys = async (parsed, absolutePath) => {
|
|
331
|
+
const blocksWithKeys = CLEANUP_BLOCKS.filter(([block, keys]) => hasKeysIn(parsed, block, keys));
|
|
332
|
+
if (blocksWithKeys.length === 0)
|
|
333
|
+
return;
|
|
334
|
+
const [removeErr] = await catchError(deleteKeysFrom(absolutePath));
|
|
335
|
+
if (removeErr) {
|
|
336
|
+
const paths = blocksWithKeys.flatMap(([block, keys]) => keys.map((key) => `${block}.${key}`));
|
|
337
|
+
logger.debug(`Could not remove ${paths.join(" / ")}: ${removeErr.message}`);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
class CoreVersionError extends ConfigValidationError {
|
|
342
|
+
constructor(version) {
|
|
343
|
+
const [stringifyError, shownVersion] = catchError(() => String(version));
|
|
344
|
+
const problem = `core.version: is the old CLI pin ${stringifyError ? "(invalid value)" : shownVersion}, which this CLI does not read`;
|
|
345
|
+
super(formatZodError([problem]), [problem]);
|
|
346
|
+
this.name = "CoreVersionError";
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
var OLDER_CLIS_LOSE_PIN = "Older CLIs that read this file lose this pin: they do not read the freeze.";
|
|
350
|
+
var getCachedConfig = () => cachedConfig ?? {};
|
|
351
|
+
var ignoreCachedVersions = () => {
|
|
352
|
+
const before = cachedConfig;
|
|
353
|
+
if (cachedConfig)
|
|
354
|
+
cachedConfig = { ...cachedConfig, versions: undefined };
|
|
355
|
+
return () => {
|
|
356
|
+
cachedConfig = before;
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
var replaceCachedVersions = (versions, updateChannel) => {
|
|
360
|
+
if (!cachedConfig)
|
|
361
|
+
return;
|
|
362
|
+
cachedConfig = { ...cachedConfig, versions };
|
|
363
|
+
if (CHANNELS.some((channel) => channel === updateChannel)) {
|
|
364
|
+
cachedConfig.core = {
|
|
365
|
+
...cachedConfig.core,
|
|
366
|
+
updateChannel
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
var getFs = async () => {
|
|
371
|
+
const { getFileSystemAsync } = await import("./index-y7v9rkq9.js");
|
|
372
|
+
return getFileSystemAsync();
|
|
373
|
+
};
|
|
374
|
+
var LOCAL_CONFIG_REL = `${UIPATH_HOME_DIR}/${CONFIG_FILENAME}`;
|
|
375
|
+
var findFileAncestor = async (path) => {
|
|
376
|
+
const fs = await getFs();
|
|
377
|
+
let dir = fs.path.dirname(path);
|
|
378
|
+
while (true) {
|
|
379
|
+
const [, stats] = await catchError(fs.stat(dir));
|
|
380
|
+
if (stats)
|
|
381
|
+
return stats.isFile() ? dir : undefined;
|
|
382
|
+
const parent = fs.path.dirname(dir);
|
|
383
|
+
if (parent === dir)
|
|
384
|
+
return;
|
|
385
|
+
dir = parent;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
var resolveConfigFilePathAsync = async (explicitPath) => {
|
|
389
|
+
const fs = await getFs();
|
|
390
|
+
if (explicitPath !== undefined) {
|
|
391
|
+
const absolutePath = fs.path.resolve(fs.env.cwd(), explicitPath);
|
|
392
|
+
const explicit = { absolutePath, source: "explicit" };
|
|
393
|
+
const [, stats] = await catchError(fs.stat(absolutePath));
|
|
394
|
+
if (stats?.isDirectory()) {
|
|
395
|
+
return {
|
|
396
|
+
...explicit,
|
|
397
|
+
exists: false,
|
|
398
|
+
error: {
|
|
399
|
+
problem: "notAFile",
|
|
400
|
+
path: absolutePath,
|
|
401
|
+
message: `The config file path ${absolutePath} names a folder, not a file.`
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (stats) {
|
|
406
|
+
return { ...explicit, exists: true };
|
|
407
|
+
}
|
|
408
|
+
const fileParent = await findFileAncestor(absolutePath);
|
|
409
|
+
if (fileParent !== undefined) {
|
|
410
|
+
return {
|
|
411
|
+
...explicit,
|
|
412
|
+
exists: false,
|
|
413
|
+
error: {
|
|
414
|
+
problem: "underAFile",
|
|
415
|
+
path: absolutePath,
|
|
416
|
+
message: `The config file path ${absolutePath} is under ${fileParent}, which is a file, not a folder.`
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
...explicit,
|
|
422
|
+
exists: false,
|
|
423
|
+
error: {
|
|
424
|
+
problem: "missing",
|
|
425
|
+
path: absolutePath,
|
|
426
|
+
message: `Config file not found: ${absolutePath}`
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
const homeDir = fs.env.homedir();
|
|
431
|
+
let searchDir = fs.env.cwd();
|
|
432
|
+
while (searchDir !== homeDir) {
|
|
433
|
+
const candidate = fs.path.join(searchDir, LOCAL_CONFIG_REL);
|
|
434
|
+
if (await fs.exists(candidate)) {
|
|
435
|
+
return { absolutePath: candidate, exists: true, source: "local" };
|
|
436
|
+
}
|
|
437
|
+
const parent = fs.path.dirname(searchDir);
|
|
438
|
+
if (parent === searchDir) {
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
searchDir = parent;
|
|
442
|
+
}
|
|
443
|
+
const globalPath = homeConfigPath(fs);
|
|
444
|
+
if (await fs.exists(globalPath)) {
|
|
445
|
+
return { absolutePath: globalPath, exists: true, source: "global" };
|
|
446
|
+
}
|
|
447
|
+
return { absolutePath: undefined, exists: false, source: "none" };
|
|
448
|
+
};
|
|
449
|
+
var resolveConfigWriteTargetAsync = async (explicit) => {
|
|
450
|
+
const homePath = homeConfigPath(await getFs());
|
|
451
|
+
const found = await resolveConfigFilePathAsync(explicit);
|
|
452
|
+
const path = found.absolutePath ?? homePath;
|
|
453
|
+
const target = { path, home: samePath(path, homePath) };
|
|
454
|
+
return found.error === undefined || found.error.problem === "missing" ? target : { ...target, error: found.error };
|
|
455
|
+
};
|
|
456
|
+
var findFrozenConfigNotUsed = async () => {
|
|
457
|
+
const fs = await getFs();
|
|
458
|
+
const found = await resolveConfigFilePathAsync();
|
|
459
|
+
if (found.source !== "local" || found.absolutePath === undefined) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const homeDir = fs.env.homedir();
|
|
463
|
+
const candidates = [];
|
|
464
|
+
let searchDir = fs.path.dirname(fs.path.dirname(fs.path.dirname(found.absolutePath)));
|
|
465
|
+
while (searchDir !== homeDir) {
|
|
466
|
+
candidates.push(fs.path.join(searchDir, LOCAL_CONFIG_REL));
|
|
467
|
+
const parent = fs.path.dirname(searchDir);
|
|
468
|
+
if (parent === searchDir)
|
|
469
|
+
break;
|
|
470
|
+
searchDir = parent;
|
|
471
|
+
}
|
|
472
|
+
candidates.push(homeConfigPath(fs));
|
|
473
|
+
for (const candidate of candidates) {
|
|
474
|
+
const [, config] = await catchError(readConfigFileAt(candidate));
|
|
475
|
+
if (asRecord(config?.versions) !== undefined) {
|
|
476
|
+
return { usedPath: found.absolutePath, frozenPath: candidate };
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return;
|
|
480
|
+
};
|
|
481
|
+
var misspelledVersionsKeys = [];
|
|
482
|
+
var ignoredConfigKeys = [];
|
|
483
|
+
var getIgnoredConfigKeys = () => ignoredConfigKeys;
|
|
484
|
+
var unwarnedIgnoredKeys = (ignored) => ignored.filter((key) => !ignoredConfigKeys.includes(key));
|
|
485
|
+
var getMisspelledVersionsKeys = () => misspelledVersionsKeys;
|
|
486
|
+
function editDistance(a, b) {
|
|
487
|
+
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
488
|
+
for (let i = 1;i <= a.length; i++) {
|
|
489
|
+
const current = [i];
|
|
490
|
+
for (let j = 1;j <= b.length; j++) {
|
|
491
|
+
current[j] = Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
492
|
+
}
|
|
493
|
+
previous = current;
|
|
494
|
+
}
|
|
495
|
+
return previous[b.length] ?? 0;
|
|
496
|
+
}
|
|
497
|
+
var looksLikeVersions = (key) => {
|
|
498
|
+
const lower = key.toLowerCase();
|
|
499
|
+
return key !== "versions" && (lower.startsWith("vers") || editDistance(lower, "versions") <= 2);
|
|
500
|
+
};
|
|
501
|
+
var misspelledVersionsKeysIn = (parsed) => {
|
|
502
|
+
const record2 = asRecord(parsed) ?? {};
|
|
503
|
+
return record2.versions === undefined ? Object.keys(record2).filter(looksLikeVersions) : [];
|
|
504
|
+
};
|
|
505
|
+
var configLoadError;
|
|
506
|
+
var VERSIONS_KEY_RE = /"versions"\s*:/;
|
|
507
|
+
var CORE_VERSION_KEY_RE = /"version"\s*:/;
|
|
508
|
+
var getConfigLoadError = () => configLoadError;
|
|
509
|
+
var parseConfigAsync = async (content, absolutePath) => {
|
|
510
|
+
const parsed = parseConfigJson(content, absolutePath);
|
|
511
|
+
const core = asRecord(asRecord(parsed)?.core);
|
|
512
|
+
if (core && "version" in core)
|
|
513
|
+
throw new CoreVersionError(core.version);
|
|
514
|
+
await cleanUpConfigKeys(parsed, absolutePath);
|
|
515
|
+
const { config, ignored } = validateWithIgnored(parsed);
|
|
516
|
+
misspelledVersionsKeys = misspelledVersionsKeysIn(parsed);
|
|
517
|
+
ignoredConfigKeys = ignored;
|
|
518
|
+
return config;
|
|
519
|
+
};
|
|
520
|
+
var loadConfigAsync = async () => {
|
|
521
|
+
if (cachedConfig) {
|
|
522
|
+
return cachedConfig;
|
|
523
|
+
}
|
|
524
|
+
configLoadError = undefined;
|
|
525
|
+
misspelledVersionsKeys = [];
|
|
526
|
+
ignoredConfigKeys = [];
|
|
527
|
+
const fs = await getFs();
|
|
528
|
+
const { absolutePath, exists: fileExists } = await resolveConfigFilePathAsync();
|
|
529
|
+
if (!absolutePath || !fileExists) {
|
|
530
|
+
cachedConfig = {};
|
|
531
|
+
return cachedConfig;
|
|
532
|
+
}
|
|
533
|
+
const [readErr, content] = await catchError(fs.readFile(absolutePath, "utf-8"));
|
|
534
|
+
if (readErr) {
|
|
535
|
+
configLoadError = new ConfigReadError(absolutePath, readErr);
|
|
536
|
+
throw configLoadError;
|
|
537
|
+
}
|
|
538
|
+
if (content === null) {
|
|
539
|
+
cachedConfig = {};
|
|
540
|
+
return cachedConfig;
|
|
541
|
+
}
|
|
542
|
+
const [loadErr, config] = await catchError(parseConfigAsync(content, absolutePath));
|
|
543
|
+
if (loadErr) {
|
|
544
|
+
if (VERSIONS_KEY_RE.test(content) || CORE_VERSION_KEY_RE.test(content) || loadErr instanceof CoreVersionError) {
|
|
545
|
+
configLoadError = loadErr;
|
|
546
|
+
}
|
|
547
|
+
throw loadErr;
|
|
548
|
+
}
|
|
549
|
+
cachedConfig = config;
|
|
550
|
+
return cachedConfig;
|
|
551
|
+
};
|
|
552
|
+
var reloadConfigAfterWriteAsync = async (path, warnOnFailure = true) => {
|
|
553
|
+
const [error] = await catchError((async () => {
|
|
554
|
+
const active = await resolveConfigWriteTargetAsync();
|
|
555
|
+
if (!samePath(path, active.path))
|
|
556
|
+
return;
|
|
557
|
+
cachedConfig = null;
|
|
558
|
+
await loadConfigAsync();
|
|
559
|
+
})());
|
|
560
|
+
if (error && warnOnFailure) {
|
|
561
|
+
logger.warn(`Failed to reload config: ${error.message}`);
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
// src/utils/globalOptions.ts
|
|
566
|
+
var VALID_LOG_LEVELS = {
|
|
567
|
+
debug: 0,
|
|
568
|
+
info: 1,
|
|
569
|
+
warn: 2,
|
|
570
|
+
error: 3
|
|
571
|
+
};
|
|
572
|
+
var NOT_CONSUMED = { consumed: false, advance: 0 };
|
|
573
|
+
function tryParseOutputFilter(state, args, i) {
|
|
574
|
+
if (args[i] === "--output-filter" && i + 1 < args.length) {
|
|
575
|
+
state.filter = args[i + 1];
|
|
576
|
+
return { consumed: true, advance: 1 };
|
|
577
|
+
}
|
|
578
|
+
if (args[i]?.startsWith("--output-filter=")) {
|
|
579
|
+
state.filter = args[i].substring("--output-filter=".length);
|
|
580
|
+
return { consumed: true, advance: 0 };
|
|
581
|
+
}
|
|
582
|
+
return NOT_CONSUMED;
|
|
583
|
+
}
|
|
584
|
+
function tryParseJson(state, args, i) {
|
|
585
|
+
if (args[i] !== "--json") {
|
|
586
|
+
return NOT_CONSUMED;
|
|
587
|
+
}
|
|
588
|
+
state.sawJsonAlias = true;
|
|
589
|
+
state.format = "json";
|
|
590
|
+
state.formatWasExplicit = true;
|
|
591
|
+
if (state.sawOutputOption) {
|
|
592
|
+
state.outputConflict = true;
|
|
593
|
+
}
|
|
594
|
+
return { consumed: true, advance: 0 };
|
|
595
|
+
}
|
|
596
|
+
function applyOutputValue(state, value) {
|
|
597
|
+
if (!state.sawJsonAlias) {
|
|
598
|
+
state.format = value;
|
|
599
|
+
}
|
|
600
|
+
state.formatWasExplicit = true;
|
|
601
|
+
}
|
|
602
|
+
function tryParseOutputSpace(state, args, i) {
|
|
603
|
+
if (args[i] !== "--output") {
|
|
604
|
+
return NOT_CONSUMED;
|
|
605
|
+
}
|
|
606
|
+
const v = args[i + 1];
|
|
607
|
+
if (v === undefined || !isOutputFormat(v)) {
|
|
608
|
+
return NOT_CONSUMED;
|
|
609
|
+
}
|
|
610
|
+
noteOutputFormatOption(state);
|
|
611
|
+
applyOutputValue(state, v);
|
|
612
|
+
return { consumed: true, advance: 1 };
|
|
613
|
+
}
|
|
614
|
+
function tryParseOutputEquals(state, args, i) {
|
|
615
|
+
if (!args[i]?.startsWith("--output=")) {
|
|
616
|
+
return NOT_CONSUMED;
|
|
617
|
+
}
|
|
618
|
+
const v = args[i].substring("--output=".length);
|
|
619
|
+
if (!isOutputFormat(v)) {
|
|
620
|
+
return NOT_CONSUMED;
|
|
621
|
+
}
|
|
622
|
+
noteOutputFormatOption(state);
|
|
623
|
+
applyOutputValue(state, v);
|
|
624
|
+
return { consumed: true, advance: 0 };
|
|
625
|
+
}
|
|
626
|
+
function noteOutputFormatOption(state) {
|
|
627
|
+
state.sawOutputOption = true;
|
|
628
|
+
if (state.sawJsonAlias) {
|
|
629
|
+
state.outputConflict = true;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
function tryParseLogLevel(state, args, i) {
|
|
633
|
+
if (args[i] === "--log-level" && i + 1 < args.length) {
|
|
634
|
+
const parsed = VALID_LOG_LEVELS[args[i + 1].toLowerCase()];
|
|
635
|
+
if (parsed !== undefined) {
|
|
636
|
+
state.logLevel = parsed;
|
|
637
|
+
}
|
|
638
|
+
return { consumed: true, advance: 1 };
|
|
639
|
+
}
|
|
640
|
+
if (args[i]?.startsWith("--log-level=")) {
|
|
641
|
+
const parsed = VALID_LOG_LEVELS[args[i].substring("--log-level=".length).toLowerCase()];
|
|
642
|
+
if (parsed !== undefined) {
|
|
643
|
+
state.logLevel = parsed;
|
|
644
|
+
}
|
|
645
|
+
return { consumed: true, advance: 0 };
|
|
646
|
+
}
|
|
647
|
+
return NOT_CONSUMED;
|
|
648
|
+
}
|
|
649
|
+
function tryParseLogFile(state, args, i) {
|
|
650
|
+
if (args[i] === "--log-file" && i + 1 < args.length) {
|
|
651
|
+
state.logFile = args[i + 1];
|
|
652
|
+
return { consumed: true, advance: 1 };
|
|
653
|
+
}
|
|
654
|
+
if (args[i]?.startsWith("--log-file=")) {
|
|
655
|
+
state.logFile = args[i].substring("--log-file=".length);
|
|
656
|
+
return { consumed: true, advance: 0 };
|
|
657
|
+
}
|
|
658
|
+
return NOT_CONSUMED;
|
|
659
|
+
}
|
|
660
|
+
function applyProfileValue(state, value, source = 0 /* Flag */) {
|
|
661
|
+
let normalized;
|
|
662
|
+
try {
|
|
663
|
+
normalized = normalizeAuthProfileName2(value);
|
|
664
|
+
} catch (error) {
|
|
665
|
+
if (!(error instanceof AuthProfileValidationError2)) {
|
|
666
|
+
throw error;
|
|
667
|
+
}
|
|
668
|
+
state.profile = undefined;
|
|
669
|
+
state.profileError ??= source === 1 /* Env */ ? `${INHERITED_AUTH_PROFILE_ENV2}: ${error.message}` : error.message;
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
if (state.profileError !== undefined) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
state.profile = normalized;
|
|
676
|
+
}
|
|
677
|
+
function tryParseProfile(state, args, i) {
|
|
678
|
+
if (args[i] === "--profile") {
|
|
679
|
+
state.sawProfileOption = true;
|
|
680
|
+
if (i + 1 >= args.length) {
|
|
681
|
+
state.profile = undefined;
|
|
682
|
+
state.profileError ??= "error: option '--profile <name>' argument missing";
|
|
683
|
+
return { consumed: true, advance: 0 };
|
|
684
|
+
}
|
|
685
|
+
applyProfileValue(state, args[i + 1]);
|
|
686
|
+
return { consumed: true, advance: 1 };
|
|
687
|
+
}
|
|
688
|
+
if (args[i]?.startsWith("--profile=")) {
|
|
689
|
+
state.sawProfileOption = true;
|
|
690
|
+
applyProfileValue(state, args[i].substring("--profile=".length));
|
|
691
|
+
return { consumed: true, advance: 0 };
|
|
692
|
+
}
|
|
693
|
+
return NOT_CONSUMED;
|
|
694
|
+
}
|
|
695
|
+
function tryParseInteractive(state, args, i) {
|
|
696
|
+
if (args[i] === "--interactive") {
|
|
697
|
+
state.interactive = "always";
|
|
698
|
+
return { consumed: true, advance: 0 };
|
|
699
|
+
}
|
|
700
|
+
if (args[i] === "--no-interactive") {
|
|
701
|
+
state.interactive = "never";
|
|
702
|
+
return { consumed: true, advance: 0 };
|
|
703
|
+
}
|
|
704
|
+
return NOT_CONSUMED;
|
|
705
|
+
}
|
|
706
|
+
var MATCHERS = [
|
|
707
|
+
tryParseOutputFilter,
|
|
708
|
+
tryParseJson,
|
|
709
|
+
tryParseOutputSpace,
|
|
710
|
+
tryParseOutputEquals,
|
|
711
|
+
tryParseLogLevel,
|
|
712
|
+
tryParseLogFile,
|
|
713
|
+
tryParseProfile,
|
|
714
|
+
tryParseInteractive
|
|
715
|
+
];
|
|
716
|
+
function stripGlobalOptions(args) {
|
|
717
|
+
const state = {
|
|
718
|
+
cleaned: [],
|
|
719
|
+
format: undefined,
|
|
720
|
+
formatWasExplicit: false,
|
|
721
|
+
sawJsonAlias: false,
|
|
722
|
+
sawOutputOption: false,
|
|
723
|
+
outputConflict: false,
|
|
724
|
+
filter: undefined,
|
|
725
|
+
logLevel: undefined,
|
|
726
|
+
logFile: undefined,
|
|
727
|
+
sawProfileOption: false,
|
|
728
|
+
profile: undefined,
|
|
729
|
+
profileError: undefined,
|
|
730
|
+
interactive: undefined
|
|
731
|
+
};
|
|
732
|
+
for (let i = 0;i < args.length; i++) {
|
|
733
|
+
let matched = false;
|
|
734
|
+
for (const matcher of MATCHERS) {
|
|
735
|
+
const result = matcher(state, args, i);
|
|
736
|
+
if (result.consumed) {
|
|
737
|
+
i += result.advance;
|
|
738
|
+
matched = true;
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (!matched) {
|
|
743
|
+
state.cleaned.push(args[i]);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const envProfile = process.env?.[INHERITED_AUTH_PROFILE_ENV2];
|
|
747
|
+
if (!state.sawProfileOption && envProfile) {
|
|
748
|
+
applyProfileValue(state, envProfile, 1 /* Env */);
|
|
749
|
+
}
|
|
750
|
+
const envDefault = process.env?.UIP_DEFAULT_OUTPUT;
|
|
751
|
+
const resolvedFormat = state.format ?? (envDefault && isOutputFormat(envDefault) ? envDefault : "json");
|
|
752
|
+
return {
|
|
753
|
+
args: state.cleaned,
|
|
754
|
+
format: resolvedFormat,
|
|
755
|
+
formatWasExplicit: state.formatWasExplicit,
|
|
756
|
+
outputConflict: state.outputConflict,
|
|
757
|
+
filter: state.filter,
|
|
758
|
+
logLevel: state.logLevel,
|
|
759
|
+
logFile: state.logFile,
|
|
760
|
+
profile: state.profile,
|
|
761
|
+
profileWasExplicit: state.sawProfileOption,
|
|
762
|
+
profileError: state.profileError,
|
|
763
|
+
interactive: state.interactive
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
var HELP_FLAGS = new Set(["-h", "--help"]);
|
|
767
|
+
var VERSION_FLAGS = new Set(["-v", "--version"]);
|
|
768
|
+
function isHelpOrVersionInvocation(args) {
|
|
769
|
+
for (const token of stripGlobalOptions(args.slice(2)).args) {
|
|
770
|
+
if (token === "--")
|
|
771
|
+
break;
|
|
772
|
+
if (HELP_FLAGS.has(token))
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
return isVersionInvocation(args);
|
|
776
|
+
}
|
|
777
|
+
function isVersionInvocation(args) {
|
|
778
|
+
for (const token of stripGlobalOptions(args.slice(2)).args) {
|
|
779
|
+
if (token === "--" || !token.startsWith("-"))
|
|
780
|
+
return false;
|
|
781
|
+
if (VERSION_FLAGS.has(token))
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
return false;
|
|
785
|
+
}
|
|
786
|
+
function verbAndSubcommand(args) {
|
|
787
|
+
const [verb, subcommand] = stripGlobalOptions(args.slice(2)).args.filter((token) => !token.startsWith("-"));
|
|
788
|
+
return { verb, subcommand };
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// src/services/autoUpdatePolicy.ts
|
|
792
|
+
var DISABLE_VERSION_SYNC_ENV = "UIPATH_CLI_DISABLE_VERSION_SYNC";
|
|
793
|
+
var DISABLE_AUTOINSTALL_ENV = "UIPATH_CLI_DISABLE_AUTOINSTALL";
|
|
794
|
+
var DISABLE_TOOL_LINE_CHECK_ENV = "UIPATH_CLI_DISABLE_TOOL_LINE_CHECK";
|
|
795
|
+
function isTruthyEnv(name) {
|
|
796
|
+
const value = getFileSystem2().env.getenv(name);
|
|
797
|
+
if (!value)
|
|
798
|
+
return false;
|
|
799
|
+
const v = value.trim().toLowerCase();
|
|
800
|
+
return v !== "" && v !== "0" && v !== "false" && v !== "no";
|
|
801
|
+
}
|
|
802
|
+
function isAutoInstallDisabled() {
|
|
803
|
+
return isTruthyEnv(DISABLE_AUTOINSTALL_ENV);
|
|
804
|
+
}
|
|
805
|
+
function isToolLineCheckDisabled() {
|
|
806
|
+
return isTruthyEnv(DISABLE_TOOL_LINE_CHECK_ENV);
|
|
807
|
+
}
|
|
808
|
+
function backgroundUpdateSkipReason(argv) {
|
|
809
|
+
if (getConfigLoadError() !== undefined) {
|
|
810
|
+
return "the config file did not load";
|
|
811
|
+
}
|
|
812
|
+
if (getCachedConfig().versions !== undefined) {
|
|
813
|
+
return "the config is frozen (versions block)";
|
|
814
|
+
}
|
|
815
|
+
if (isTruthyEnv(DISABLE_VERSION_SYNC_ENV)) {
|
|
816
|
+
return `${DISABLE_VERSION_SYNC_ENV} is set`;
|
|
817
|
+
}
|
|
818
|
+
if (isAutoInstallDisabled()) {
|
|
819
|
+
return `${DISABLE_AUTOINSTALL_ENV} is set`;
|
|
820
|
+
}
|
|
821
|
+
if (isEnvAuthEnabled2()) {
|
|
822
|
+
return "env-var auth (CI/headless)";
|
|
823
|
+
}
|
|
824
|
+
if (isHelpOrVersionInvocation(argv)) {
|
|
825
|
+
return "--help or the CLI's own --version";
|
|
826
|
+
}
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// src/services/freezeFailures.ts
|
|
831
|
+
async function classifyError(error) {
|
|
832
|
+
const details = await extractErrorDetails(error);
|
|
833
|
+
return {
|
|
834
|
+
message: error.message,
|
|
835
|
+
errorCode: details.errorCode,
|
|
836
|
+
retry: details.retry,
|
|
837
|
+
instructions: carriedInstructions(error)
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
function renderPinChange({ name, from, to }) {
|
|
841
|
+
return `${name} ${from} → ${to ?? "removed"}`;
|
|
842
|
+
}
|
|
843
|
+
function causeFirst(changes) {
|
|
844
|
+
const rank = (change) => change.to === undefined ? 0 : 1;
|
|
845
|
+
return [...changes].sort((a, b) => rank(a) - rank(b));
|
|
846
|
+
}
|
|
847
|
+
var CONFIG_FROM_PINS_MACHINE = "If that is not this machine, run 'uip config export --output-file <path>' on that machine and 'uip config import --input <path>' on this one.";
|
|
848
|
+
var CONFIG = {
|
|
849
|
+
errorCode: "configuration_error",
|
|
850
|
+
retry: "RetryWillNotFix"
|
|
851
|
+
};
|
|
852
|
+
var INVALID = {
|
|
853
|
+
errorCode: "invalid_argument",
|
|
854
|
+
retry: "RetryWillNotFix"
|
|
855
|
+
};
|
|
856
|
+
var NOT_FOUND = {
|
|
857
|
+
errorCode: "not_found",
|
|
858
|
+
retry: "RetryWillNotFix"
|
|
859
|
+
};
|
|
860
|
+
var FROM_CAUSE = ({ cause }) => cause;
|
|
861
|
+
var FROM_CAUSE_ELSE_CONFIG = ({
|
|
862
|
+
cause
|
|
863
|
+
}) => cause.errorCode === undefined || cause.errorCode === "unknown_error" ? CONFIG : cause;
|
|
864
|
+
var READ_MESSAGE = ({ path, cause }) => `Could not read the config file ${configPathForMessage(path)}: ${cause.message}`;
|
|
865
|
+
var WRITE_MESSAGE = ({ path, cause }) => `Could not write the config file ${configPathForMessage(path)}: ${cause.message}`;
|
|
866
|
+
var FREEZE_AGAIN = "Check that the config file can be written, then run 'uip config freeze --force' to freeze the versions installed now.";
|
|
867
|
+
var TOOL_OPTIONS = new Set(["--name", "--tools-only", "--no-tools"]);
|
|
868
|
+
var pronoun = (items) => items.length === 1 ? "it" : "them";
|
|
869
|
+
var FAILURES = {
|
|
870
|
+
frozenEdit: {
|
|
871
|
+
classify: CONFIG,
|
|
872
|
+
message: ({ path, key }) => `The config ${configPathForMessage(path)} is frozen, so ${key} was not changed.`,
|
|
873
|
+
instructions: ({ key, configFile }) => `Run the command again with --force to change ${key} and keep the freeze.${unfreezeHint(configFile, " To unfreeze this config, run 'uip config unfreeze'.")}`
|
|
874
|
+
},
|
|
875
|
+
movedKey: {
|
|
876
|
+
result: RESULTS.ValidationError,
|
|
877
|
+
classify: INVALID,
|
|
878
|
+
message: ({ key }) => `'${key}' is no longer a config key. The CLI version is now part of the freeze.`,
|
|
879
|
+
instructions: ({ verb }) => ({
|
|
880
|
+
get: "Run 'uip config get' to see the freeze.",
|
|
881
|
+
set: "Run 'uip config freeze' to freeze the running CLI. To freeze the newest CLI instead, run 'uip update --force' first.",
|
|
882
|
+
clear: "Run 'uip config unfreeze' to remove the freeze. To replace an old 'version' setting, run 'uip config freeze'."
|
|
883
|
+
})[verb]
|
|
884
|
+
},
|
|
885
|
+
freezeOnStudio: {
|
|
886
|
+
classify: CONFIG,
|
|
887
|
+
message: () => "This CLI comes with Studio, so it cannot freeze the config: Studio sets the CLI and tool versions.",
|
|
888
|
+
instructions: () => "Install the standalone CLI with 'npm i -g @uipath/cli', then run 'uip config freeze' with it."
|
|
889
|
+
},
|
|
890
|
+
freezeDrift: {
|
|
891
|
+
classify: CONFIG,
|
|
892
|
+
message: ({ path, changes }) => `The config ${configPathForMessage(path)} pins other versions than this freeze would write: ${listSome(causeFirst(changes).map(renderPinChange))}. The config was not changed.`,
|
|
893
|
+
instructions: ({ all = false }) => `Run 'uip config freeze${allFlag(all)} --force' to pin this machine's versions instead, or 'uip update' to move this machine to the config's pins.`
|
|
894
|
+
},
|
|
895
|
+
freezeInvalidPins: {
|
|
896
|
+
classify: CONFIG,
|
|
897
|
+
message: ({ versions, onRegistry }) => onRegistry ? `The version of ${listSome(versions.map(({ name, version }) => `${name} ${version}`))} on the registry cannot be pinned: a pin is an exact version, major.minor.patch. The config was not changed.` : `The config freeze cannot pin ${listSome(versions.map(({ name, version }) => `${name} ${version}`))}: a pin is an exact version, major.minor.patch. The config was not changed.`,
|
|
898
|
+
instructions: ({ versions, onRegistry, all = false }) => {
|
|
899
|
+
const freezeAgain = `uip config freeze${allFlag(all)}`;
|
|
900
|
+
return onRegistry ? `Install a release version of ${listSome(versions.map(({ name }) => name))} with 'uip tools install <tool>@<version>', so the freeze pins the installed version, then run '${freezeAgain}' again.` : `The installed version of ${listSome(versions.map(({ name }) => name))} cannot be pinned: a pin has no build metadata. Reinstall it with a version that can be pinned, then run '${freezeAgain}' again.`;
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
freezeInvalidConfig: {
|
|
904
|
+
classify: CONFIG,
|
|
905
|
+
message: ({ path, problems }) => `The config ${configPathForMessage(path)} has values that the CLI cannot load, so the freeze was not written: ${problems.join("; ").replace(/\.$/, "")}.`,
|
|
906
|
+
instructions: freezeInvalidConfigInstructions
|
|
907
|
+
},
|
|
908
|
+
freezeToolLookup: {
|
|
909
|
+
classify: ({ lookup }) => lookup,
|
|
910
|
+
message: ({ lookup }) => `${lookup.message} The config was not changed.`,
|
|
911
|
+
instructions: ({ lookup }) => lookup.instructions
|
|
912
|
+
},
|
|
913
|
+
freezeAllNothingFound: {
|
|
914
|
+
classify: NOT_FOUND,
|
|
915
|
+
message: ({ registry }) => `The registry${registry ? ` ${registry}` : ""} does not have the @uipath tools, so the config was not changed.`,
|
|
916
|
+
instructions: () => "Check that the registry npm uses for @uipath packages publishes the tools, then run 'uip config freeze --all' again."
|
|
917
|
+
},
|
|
918
|
+
freezeNoTool: {
|
|
919
|
+
classify: CONFIG,
|
|
920
|
+
message: ({ offLine }) => {
|
|
921
|
+
const why = offLine.length === 0 ? "no tool is installed" : `no installed tool is on this CLI's line: ${listSome(offLine)}`;
|
|
922
|
+
return `The config freeze would pin no tool, because ${why}. Under a versions block, a tool that the block does not list does not run, so no tool would run. The config was not changed.`;
|
|
923
|
+
},
|
|
924
|
+
instructions: ({ offLine }) => {
|
|
925
|
+
if (offLine.length === 0) {
|
|
926
|
+
return "Run 'uip config freeze --all' to pin every tool, or install the tools your commands need with 'uip tools install <tool>' first. To freeze only the CLI, run 'uip config freeze --force'.";
|
|
927
|
+
}
|
|
928
|
+
const [only] = offLine;
|
|
929
|
+
const install = offLine.length === 1 && only ? `Run 'uip tools install ${only} --force' to install a version on this CLI's line` : "Run 'uip tools install <tool> --force' for each tool to install a version on this CLI's line";
|
|
930
|
+
return `${install}, then run 'uip config freeze' again. To pin every tool, run 'uip config freeze --all'.`;
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
exportExists: {
|
|
934
|
+
result: RESULTS.ValidationError,
|
|
935
|
+
classify: INVALID,
|
|
936
|
+
message: ({ path }) => `${configPathForMessage(path)} already exists, so nothing was written.`,
|
|
937
|
+
instructions: ({ outputFile }) => `Run 'uip config export --output-file ${quoteForShell(outputFile)} --overwrite' to replace it, or pass another --output-file.`
|
|
938
|
+
},
|
|
939
|
+
exportNoConfig: {
|
|
940
|
+
classify: NOT_FOUND,
|
|
941
|
+
message: ({ path }) => path === undefined ? "No config file was found, so nothing was exported." : `There is no config file at ${configPathForMessage(path)}, so nothing was exported.`,
|
|
942
|
+
instructions: ({ path }) => path === undefined ? "Run it in a folder that has a .uipath/config.json." : "Check that the config file is there, then run the command again."
|
|
943
|
+
},
|
|
944
|
+
exportBadOutputFile: {
|
|
945
|
+
result: RESULTS.ValidationError,
|
|
946
|
+
classify: INVALID,
|
|
947
|
+
message: ({ outputFile, reason }) => `Cannot write the copy to --output-file ${quoteForShell(outputFile)}: ${reason}. Nothing was written.`,
|
|
948
|
+
instructions: () => "Pass --output-file <path> with the path of a file, such as --output-file ci/config.json."
|
|
949
|
+
},
|
|
950
|
+
exportSameFile: {
|
|
951
|
+
result: RESULTS.ValidationError,
|
|
952
|
+
classify: INVALID,
|
|
953
|
+
message: ({ outputFile }) => `Cannot write the copy to --output-file ${quoteForShell(outputFile)}: it is the config file that would be copied. Nothing was written.`,
|
|
954
|
+
instructions: () => "Pass another --output-file, such as --output-file ci/config.json."
|
|
955
|
+
},
|
|
956
|
+
exportWrite: {
|
|
957
|
+
classify: FROM_CAUSE,
|
|
958
|
+
message: ({ path, cause }) => `Could not write the copy to ${configPathForMessage(path)}: ${cause.message}`,
|
|
959
|
+
instructions: ({ outputFile, overwrite }) => `Check that the folder is writable, then run 'uip config export --output-file ${quoteForShell(outputFile)}${overwrite ? " --overwrite" : ""}' again, or pass another --output-file.`
|
|
960
|
+
},
|
|
961
|
+
fileRead: {
|
|
962
|
+
classify: FROM_CAUSE_ELSE_CONFIG,
|
|
963
|
+
message: READ_MESSAGE,
|
|
964
|
+
instructions: ({ path, folder, configFile }) => folder ? `Remove the folder ${configPathForMessage(path)}, or move it, then run the command again.` : configFile !== undefined ? `Fix the file ${configPathForMessage(path)}, then run the command again.` : "Fix the file, or run 'uip config import --input <path>' to replace it with a valid config, then run the command again."
|
|
965
|
+
},
|
|
966
|
+
configFilePath: {
|
|
967
|
+
classify: ({ problem }) => problem === "missing" ? NOT_FOUND : INVALID,
|
|
968
|
+
message: ({ message, problem, path }) => problem === "missing" ? `There is no config file at ${configPathForMessage(path)}.` : message,
|
|
969
|
+
instructions: ({ problem }) => problem === "missing" ? "Pass --config-file <path> with a valid path, or leave it out to use the nearest .uipath/config.json or the home config." : "Pass --config-file <path> with the path of a JSON file."
|
|
970
|
+
},
|
|
971
|
+
channelOffPin: {
|
|
972
|
+
classify: CONFIG,
|
|
973
|
+
message: ({ problem }) => `${problem} The config was not changed.`,
|
|
974
|
+
instructions: ({ configFile }) => `Set the channel the CLI pin is built for${unfreezeHint(configFile, ", or run 'uip config unfreeze' first")}.`
|
|
975
|
+
},
|
|
976
|
+
fileWrite: {
|
|
977
|
+
classify: FROM_CAUSE,
|
|
978
|
+
message: WRITE_MESSAGE,
|
|
979
|
+
instructions: ({ cause }) => cause.instructions ?? "Check that the folder is writable, then run the command again."
|
|
980
|
+
},
|
|
981
|
+
importEmptyFile: {
|
|
982
|
+
result: RESULTS.ValidationError,
|
|
983
|
+
classify: INVALID,
|
|
984
|
+
message: () => "The --input path is empty, so nothing was imported.",
|
|
985
|
+
instructions: () => "Pass the path of the config file to import: --input <path>."
|
|
986
|
+
},
|
|
987
|
+
importNotFound: {
|
|
988
|
+
classify: NOT_FOUND,
|
|
989
|
+
message: ({ path }) => `There is no file at ${configPathForMessage(path)}, so nothing was imported.`,
|
|
990
|
+
instructions: () => "Check the --input path, then run the import again."
|
|
991
|
+
},
|
|
992
|
+
importInvalidJson: {
|
|
993
|
+
classify: CONFIG,
|
|
994
|
+
message: ({ path }) => `${configPathForMessage(path)} is not valid JSON, so nothing was imported.`,
|
|
995
|
+
instructions: () => "Fix the JSON in the file, then run the import again."
|
|
996
|
+
},
|
|
997
|
+
importNotUtf8: {
|
|
998
|
+
classify: CONFIG,
|
|
999
|
+
message: ({ path }) => `${configPathForMessage(path)} is not UTF-8 text, so nothing was imported.`,
|
|
1000
|
+
instructions: () => "Save the file as UTF-8, then run the import again."
|
|
1001
|
+
},
|
|
1002
|
+
importUnreadable: {
|
|
1003
|
+
classify: FROM_CAUSE,
|
|
1004
|
+
message: ({ path, cause }) => `Could not read ${configPathForMessage(path)}, so nothing was imported: ${cause.message}`,
|
|
1005
|
+
instructions: () => "Check that you can read the --input path, then run the import again."
|
|
1006
|
+
},
|
|
1007
|
+
importInvalidConfig: {
|
|
1008
|
+
classify: CONFIG,
|
|
1009
|
+
message: ({ path, problems }) => `${configPathForMessage(path)} is not a valid config, so nothing was imported: ${problems.join("; ")}.`,
|
|
1010
|
+
instructions: () => "Fix these values in the file, then run the import again."
|
|
1011
|
+
},
|
|
1012
|
+
importInvalidPins: {
|
|
1013
|
+
classify: CONFIG,
|
|
1014
|
+
message: ({ path, detail }) => `${configPathForMessage(path)} cannot be imported. ${detail} Nothing was imported.`,
|
|
1015
|
+
instructions: () => "Fix the pins in the file, then run the import again."
|
|
1016
|
+
},
|
|
1017
|
+
cliOffPin: {
|
|
1018
|
+
classify: CONFIG,
|
|
1019
|
+
message: ({ cliVersion, pin }) => `This CLI is ${cliVersion}, but this config freezes the CLI at ${pin}, so the command was not run.`,
|
|
1020
|
+
instructions: ({ pin, hostOwned }) => hostOwned ? hostShipsCliSteps(pin) : `Run 'uip update' to install ${pin}.`
|
|
1021
|
+
},
|
|
1022
|
+
configNotLoaded: {
|
|
1023
|
+
classify: CONFIG,
|
|
1024
|
+
message: ({ path, problem, unreadable, refused }) => {
|
|
1025
|
+
const outcome = refused === "update" ? "nothing was updated" : "the command was not run";
|
|
1026
|
+
if (unreadable) {
|
|
1027
|
+
return `${problem}, so its freeze is unknown and ${outcome}.`;
|
|
1028
|
+
}
|
|
1029
|
+
const file = path ? `file ${configPathForMessage(path)}` : "file";
|
|
1030
|
+
return `The config ${file} could not be loaded, so its freeze is unknown and ${outcome}. ${problem}`;
|
|
1031
|
+
},
|
|
1032
|
+
instructions: ({ path, unreadable, folder, coreVersion, refused }) => {
|
|
1033
|
+
if (coreVersion) {
|
|
1034
|
+
return `Replace core.version with a versions block: run 'uip config freeze --all' on the machine that sets the pins. ${CONFIG_FROM_PINS_MACHINE} Then run the command again.`;
|
|
1035
|
+
}
|
|
1036
|
+
const again = refused === "update" ? ", then run 'uip update' again" : "";
|
|
1037
|
+
if (folder) {
|
|
1038
|
+
const folderPath = path ? configPathForMessage(path) : "at the config path";
|
|
1039
|
+
return `Remove the folder ${folderPath}, or move it${again || ", then run the command again"}.`;
|
|
1040
|
+
}
|
|
1041
|
+
const replace = "'uip config import --input <path>' to replace it with a valid config";
|
|
1042
|
+
const fix = unreadable ? `Run ${replace}` : `Fix ${path ? configPathForMessage(path) : "the config file"}, or run ${replace}`;
|
|
1043
|
+
return `${fix}${again}.`;
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
toolOffPin: {
|
|
1047
|
+
classify: CONFIG,
|
|
1048
|
+
message: ({ verb, packageName, version, pin }) => `'${verb}' runs ${packageName}@${version}, but this config freezes it at ${pin}, so the command was not run.`,
|
|
1049
|
+
instructions: () => "Run 'uip update' to install the frozen versions."
|
|
1050
|
+
},
|
|
1051
|
+
toolShadowed: {
|
|
1052
|
+
classify: CONFIG,
|
|
1053
|
+
message: ({ verb, packageName, pin, found, dirs }) => `'${verb}' still runs ${found} after ${packageName} ${pin} was installed, so the command was not run. Folders searched: ${dirs.join(", ")}.`,
|
|
1054
|
+
instructions: ({ packageName }) => `Remove the other copy of ${packageName} from the folder that comes first, then run the command again.`
|
|
1055
|
+
},
|
|
1056
|
+
toolMissingAfterInstall: {
|
|
1057
|
+
classify: { ...CONFIG, retry: "RetryLater" },
|
|
1058
|
+
message: ({ verb, packageName, pin, dirs }) => `'${verb}' was not found after ${packageName} ${pin} was installed, so the command was not run. Folders searched: ${dirs.join(", ")}.`,
|
|
1059
|
+
instructions: ({ packageName }) => `Check that ${packageName} was installed into one of these folders, then run the command again.`
|
|
1060
|
+
},
|
|
1061
|
+
toolPinInstallFailed: {
|
|
1062
|
+
classify: FROM_CAUSE,
|
|
1063
|
+
message: ({ packageName, pin, cause }) => `Could not install ${packageName} ${pin}, the frozen version: ${cause.message}`,
|
|
1064
|
+
instructions: ({ packageName, pin }) => `Check that the registry is reachable and that ${packageName} ${pin} is published. If the pin is wrong, correct it on the machine that sets the pins: install a published version of ${packageName} and run 'uip config freeze --force'. ${CONFIG_FROM_PINS_MACHINE} Then run the command again.`
|
|
1065
|
+
},
|
|
1066
|
+
toolPinNotInstalled: {
|
|
1067
|
+
classify: CONFIG,
|
|
1068
|
+
message: ({ packageName, pin }) => `${packageName} ${pin} is pinned but not installed, and automatic tool installation is disabled (${DISABLE_AUTOINSTALL_ENV}).`,
|
|
1069
|
+
instructions: () => "Run 'uip update' to install the pins."
|
|
1070
|
+
},
|
|
1071
|
+
unlistedToolRefused: {
|
|
1072
|
+
classify: CONFIG,
|
|
1073
|
+
message: ({ verb, packageName, installed }) => `'${verb}' is ${packageName}@${installed}, which this frozen config does not list, so the command was not run.`,
|
|
1074
|
+
instructions: ({ verb, installed }) => `Run 'uip tools install ${verb}@${installed} --force' to add it to the freeze, or 'uip tools uninstall ${verb} --force' to remove it from this machine.`
|
|
1075
|
+
},
|
|
1076
|
+
unlistedToolNotInstalled: {
|
|
1077
|
+
classify: CONFIG,
|
|
1078
|
+
message: ({ verb, packageName, replacing }) => replacing ? `'${verb}' is ${replacing.packageName}@${replacing.version}, which is not on this CLI's ${replacing.prefix}x line. It was not replaced, because this config is frozen and does not list ${packageName}.` : `'${verb}' is not installed, and it was not installed now, because this config is frozen and does not list ${packageName}.`,
|
|
1079
|
+
instructions: ({ verb }) => `Run 'uip tools install ${verb} --force' to install it and add it to the freeze, then run the command again.`
|
|
1080
|
+
},
|
|
1081
|
+
unlistedTools: {
|
|
1082
|
+
classify: CONFIG,
|
|
1083
|
+
message: ({ tools }) => `This config is frozen, but it does not list these installed tools: ${tools.map((t) => `${t.toolName}@${t.version}`).join(", ")}. Nothing was updated, because the freeze does not move a tool it does not list.`,
|
|
1084
|
+
instructions: ({ tools, cliTarget, linePrefix }) => {
|
|
1085
|
+
if (cliTarget !== undefined) {
|
|
1086
|
+
return `Run 'uip update --no-tools' to install ${cliTarget} first, then run 'uip update' again.`;
|
|
1087
|
+
}
|
|
1088
|
+
const onLine = (t) => t.version.startsWith(linePrefix);
|
|
1089
|
+
const [only] = tools;
|
|
1090
|
+
if (tools.length === 1 && only) {
|
|
1091
|
+
return onLine(only) ? `Run 'uip tools install ${only.toolName}@${only.version} --force' to add it to the freeze, or 'uip tools uninstall ${only.toolName} --force' to remove it.` : `Run 'uip tools install ${only.toolName} --force' to install the newest ${linePrefix}x version and add it to the freeze, or 'uip tools uninstall ${only.toolName} --force' to remove it.`;
|
|
1092
|
+
}
|
|
1093
|
+
const tool = tools.every(onLine) ? "<tool>@<version>" : "<tool>";
|
|
1094
|
+
return `For each tool, run 'uip tools install ${tool} --force' to add it to the freeze, or 'uip tools uninstall <tool> --force' to remove it.`;
|
|
1095
|
+
}
|
|
1096
|
+
},
|
|
1097
|
+
cliPinNotPublished: {
|
|
1098
|
+
classify: { errorCode: "not_found", retry: "RetryWillNotFix" },
|
|
1099
|
+
message: ({ pin }) => `The config pins the CLI at ${pin}, but the registry does not publish @uipath/cli@${pin}.`,
|
|
1100
|
+
instructions: () => `Correct the pin on the machine that sets the pins: install a published version of @uipath/cli and run 'uip config freeze --force'. ${CONFIG_FROM_PINS_MACHINE} Then run 'uip update' again.`
|
|
1101
|
+
},
|
|
1102
|
+
cliPinOnBrew: {
|
|
1103
|
+
classify: CONFIG,
|
|
1104
|
+
message: ({ pin }) => `This CLI is installed with Homebrew, which installs only the newest version of its formula, so it cannot be moved to the pin ${pin}.`,
|
|
1105
|
+
instructions: ({ pin }) => `Install @uipath/cli ${pin} with npm ('npm i -g @uipath/cli@${pin}') and run it from there.`
|
|
1106
|
+
},
|
|
1107
|
+
installRefused: {
|
|
1108
|
+
classify: CONFIG,
|
|
1109
|
+
message: ({ path, packageName, listedPin, requested }) => listedPin === undefined ? `The config ${configPathForMessage(path)} is frozen and does not list ${packageName}, so nothing was installed.` : `The config ${configPathForMessage(path)} freezes ${packageName} at ${listedPin}, not ${requested ?? "another version"}, so nothing was installed.`,
|
|
1110
|
+
instructions: ({ packageArg }) => `Run 'uip tools install ${packageArg} --force' to install it and write its version into the freeze.`
|
|
1111
|
+
},
|
|
1112
|
+
installOffLine: {
|
|
1113
|
+
result: RESULTS.ValidationError,
|
|
1114
|
+
classify: INVALID,
|
|
1115
|
+
message: ({ packageName, requested, prefix }) => `${packageName}@${requested} is not on this CLI's ${prefix}x line, so it cannot be frozen. A tool must be on the same major.minor line as the CLI.`,
|
|
1116
|
+
instructions: ({ prefix }) => `Pass a ${prefix}x version, or leave the version out to install the newest one.`
|
|
1117
|
+
},
|
|
1118
|
+
installPinNotWritten: {
|
|
1119
|
+
classify: FROM_CAUSE,
|
|
1120
|
+
message: ({ packageSpec, cause }) => `${packageSpec} was installed, but its version was not written into the freeze: ${cause.message}`,
|
|
1121
|
+
instructions: () => "Check that the config folder is writable, then run the command again; or run 'uip config freeze --force' to write every installed version."
|
|
1122
|
+
},
|
|
1123
|
+
uninstallRefused: {
|
|
1124
|
+
classify: CONFIG,
|
|
1125
|
+
message: ({ path, packageNames }) => `The config ${configPathForMessage(path)} is frozen, so ${listSome(packageNames)} ${packageNames.length === 1 ? "was" : "were"} not uninstalled.`,
|
|
1126
|
+
instructions: ({ command, listed, packageNames }) => `Run '${command} --force' to remove ${pronoun(packageNames)} from this machine${listed ? " and from the freeze" : ""}.`
|
|
1127
|
+
},
|
|
1128
|
+
uninstallPinNotRemoved: {
|
|
1129
|
+
classify: FROM_CAUSE,
|
|
1130
|
+
message: ({ uninstalled, pinned, cause }) => {
|
|
1131
|
+
const still = `still lists ${pinned.join(", ")}: ${cause.message}`;
|
|
1132
|
+
if (uninstalled.length === 0)
|
|
1133
|
+
return `The freeze ${still}`;
|
|
1134
|
+
return `${uninstalled.join(", ")} ${uninstalled.length === 1 ? "was" : "were"} uninstalled, but the freeze ${still}`;
|
|
1135
|
+
},
|
|
1136
|
+
instructions: ({ pinned }) => pinned.length === 1 ? `Check that the config file can be written, then run 'uip tools uninstall ${pinned[0]} --force' again to remove its pin.` : `Check that the config file can be written, then run 'uip tools uninstall <tool> --force' again for each of ${listSome(pinned)} to remove its pin.`
|
|
1137
|
+
},
|
|
1138
|
+
updateFreezeNotWritten: {
|
|
1139
|
+
classify: FROM_CAUSE,
|
|
1140
|
+
message: ({ cause }) => `The update ran, but its versions were not written into the freeze: ${cause.message}`,
|
|
1141
|
+
instructions: ({ cause }) => cause.instructions ?? FREEZE_AGAIN
|
|
1142
|
+
},
|
|
1143
|
+
updateChannelOffCli: {
|
|
1144
|
+
classify: CONFIG,
|
|
1145
|
+
message: ({ problem, cliVersion, stage }) => `${UPDATE_CHANNEL_OFF_CLI_START[stage]}: the CLI stays on ${cliVersion}. ${problem}`,
|
|
1146
|
+
instructions: ({
|
|
1147
|
+
channel,
|
|
1148
|
+
pinChannel,
|
|
1149
|
+
available,
|
|
1150
|
+
manualCommand,
|
|
1151
|
+
hostOwned
|
|
1152
|
+
}) => {
|
|
1153
|
+
const stay = `To stay on ${pinChannel}, run 'uip update --force --channel ${pinChannel}'.`;
|
|
1154
|
+
if (hostOwned) {
|
|
1155
|
+
return `${stay} ${hostShipsCliSteps(available, channel)}`;
|
|
1156
|
+
}
|
|
1157
|
+
const version = available === undefined ? "" : ` (${available})`;
|
|
1158
|
+
const install = manualCommand !== undefined ? `install a ${channel} CLI with '${manualCommand}'` : `install a ${channel} CLI${version} the way this CLI was installed`;
|
|
1159
|
+
return `${stay} To move to ${channel}, ${install}, then run 'uip update --force --channel ${channel}' again.`;
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
cliUnreadAfterUpdate: {
|
|
1163
|
+
classify: CONFIG,
|
|
1164
|
+
message: ({ pin }) => `After this update, the CLI's package.json could not be read, so the CLI is not known to be on its pin ${pin}.`,
|
|
1165
|
+
instructions: () => "Another command may be replacing the CLI. Run 'uip --version' to check it, then run 'uip update' again, and hold one freeze at a time on this machine."
|
|
1166
|
+
},
|
|
1167
|
+
offPinAfterUpdate: {
|
|
1168
|
+
classify: CONFIG,
|
|
1169
|
+
message: ({ name, installed, pin }) => `After this update, ${name} is ${installed ?? "not installed"}, not on its pin ${pin}.`,
|
|
1170
|
+
instructions: offPinAfterUpdateInstructions
|
|
1171
|
+
},
|
|
1172
|
+
updateForceWithSection: {
|
|
1173
|
+
result: RESULTS.ValidationError,
|
|
1174
|
+
classify: INVALID,
|
|
1175
|
+
message: ({ options }) => `--force cannot be used with ${options.join(", ")}. Under a freeze, --force updates the CLI, every tool and the skills, and writes the result into the freeze.`,
|
|
1176
|
+
instructions: ({ options }) => {
|
|
1177
|
+
const drop = `Drop ${options.join(", ")} to update everything past the freeze.`;
|
|
1178
|
+
return options.some((option) => TOOL_OPTIONS.has(option)) ? `${drop} To move one tool, run 'uip tools install <tool>@<version> --force'.` : drop;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
var UPDATE_CHANNEL_OFF_CLI_START = {
|
|
1183
|
+
dryRun: "The update would not write its versions into the freeze",
|
|
1184
|
+
before: "The update did not run, because it could not write its versions into the freeze",
|
|
1185
|
+
after: "The update ran, but its versions were not written into the freeze"
|
|
1186
|
+
};
|
|
1187
|
+
function freezeInvalidConfigInstructions({
|
|
1188
|
+
path,
|
|
1189
|
+
all,
|
|
1190
|
+
force,
|
|
1191
|
+
keys: problemKeys
|
|
1192
|
+
}) {
|
|
1193
|
+
const keys = [...new Set(problemKeys)];
|
|
1194
|
+
return `Fix ${listSome(keys)} in ${configPathForMessage(path)}, or run 'uip config import --input <path>' to replace it with a valid config, then run 'uip config freeze${allFlag(all)}${force ? " --force" : ""}' again.`;
|
|
1195
|
+
}
|
|
1196
|
+
function hostShipsCliSteps(version, channel) {
|
|
1197
|
+
const install = version ?? `a ${channel} CLI`;
|
|
1198
|
+
const ships = version === undefined ? install : `CLI ${version}`;
|
|
1199
|
+
return `This CLI comes with the program that sets ${TOOLS_DIRS_ENV_VAR}, so 'uip update' cannot install ${install}. Run the command with a version of that program that ships ${ships}.`;
|
|
1200
|
+
}
|
|
1201
|
+
function offPinAfterUpdateInstructions({
|
|
1202
|
+
pin,
|
|
1203
|
+
skippedBy,
|
|
1204
|
+
manualCommand,
|
|
1205
|
+
hostOwned
|
|
1206
|
+
}) {
|
|
1207
|
+
if (hostOwned)
|
|
1208
|
+
return hostShipsCliSteps(pin);
|
|
1209
|
+
if (skippedBy !== undefined) {
|
|
1210
|
+
return `Run 'uip update' without ${skippedBy} to install the pinned CLI.`;
|
|
1211
|
+
}
|
|
1212
|
+
if (manualCommand !== undefined) {
|
|
1213
|
+
return `Install the pinned CLI with '${manualCommand}', then run the command again.`;
|
|
1214
|
+
}
|
|
1215
|
+
return "Another command moved it while this update ran. Run 'uip update' again, and hold one freeze at a time on this machine.";
|
|
1216
|
+
}
|
|
1217
|
+
function allFlag(all) {
|
|
1218
|
+
return all ? " --all" : "";
|
|
1219
|
+
}
|
|
1220
|
+
function unfreezeHint(configFile, hint) {
|
|
1221
|
+
return configFile === undefined ? hint : "";
|
|
1222
|
+
}
|
|
1223
|
+
function freezeFailure(kind, details) {
|
|
1224
|
+
const spec = FAILURES[kind];
|
|
1225
|
+
const { errorCode, retry } = typeof spec.classify === "function" ? spec.classify(details) : spec.classify;
|
|
1226
|
+
return {
|
|
1227
|
+
Result: spec.result ?? RESULTS.Failure,
|
|
1228
|
+
Message: spec.message(details),
|
|
1229
|
+
Instructions: spec.instructions(details),
|
|
1230
|
+
ErrorCode: errorCode,
|
|
1231
|
+
Retry: retry
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
function reportFreezeFailure(kind, details, envelope = {}) {
|
|
1235
|
+
reportFreezeFailureError(freezeFailureError(kind, details, envelope));
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
class FreezeFailureError extends Error {
|
|
1239
|
+
fields;
|
|
1240
|
+
envelope;
|
|
1241
|
+
constructor(fields, envelope) {
|
|
1242
|
+
super(fields.Message);
|
|
1243
|
+
this.fields = fields;
|
|
1244
|
+
this.envelope = envelope;
|
|
1245
|
+
this.name = "FreezeFailureError";
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
function freezeFailureError(kind, details, envelope = {}) {
|
|
1249
|
+
return new FreezeFailureError(freezeFailure(kind, details), envelope);
|
|
1250
|
+
}
|
|
1251
|
+
function reportFreezeFailureError({
|
|
1252
|
+
fields: { Result, ...fields },
|
|
1253
|
+
envelope: { Code, Data }
|
|
1254
|
+
}) {
|
|
1255
|
+
OutputFormatter.error({
|
|
1256
|
+
Result,
|
|
1257
|
+
...Code !== undefined && { Code },
|
|
1258
|
+
...fields,
|
|
1259
|
+
...Data !== undefined && { Data }
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function freezeRefusal(kind, details) {
|
|
1263
|
+
const { Message, Instructions, ErrorCode, Retry } = freezeFailure(kind, details);
|
|
1264
|
+
return new InstallRefusedError(Message, Instructions, {
|
|
1265
|
+
errorCode: ErrorCode,
|
|
1266
|
+
retry: Retry
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
export { withConfigLock, parseConfigJson, readConfigFileAt, writeConfigFileAt, writeFileAtomically, configPathForMessage, ConfigValidationError, dropUnknownFrozenValues, ignoredValuesWarning, configLoadProblem, ConfigReadError, removeCoreVersion, deleteKeysRemovedOnLoad, CoreVersionError, OLDER_CLIS_LOSE_PIN, getCachedConfig, ignoreCachedVersions, replaceCachedVersions, resolveConfigFilePathAsync, resolveConfigWriteTargetAsync, findFrozenConfigNotUsed, getIgnoredConfigKeys, unwarnedIgnoredKeys, getMisspelledVersionsKeys, misspelledVersionsKeysIn, getConfigLoadError, loadConfigAsync, reloadConfigAfterWriteAsync, stripGlobalOptions, isHelpOrVersionInvocation, isVersionInvocation, verbAndSubcommand, DISABLE_VERSION_SYNC_ENV, DISABLE_AUTOINSTALL_ENV, DISABLE_TOOL_LINE_CHECK_ENV, isTruthyEnv, isAutoInstallDisabled, isToolLineCheckDisabled, backgroundUpdateSkipReason, classifyError, renderPinChange, CONFIG_FROM_PINS_MACHINE, allFlag, freezeFailure, reportFreezeFailure, FreezeFailureError, freezeFailureError, reportFreezeFailureError, freezeRefusal };
|
|
1271
|
+
|
|
1272
|
+
//# debugId=486F625725EE4FEC64756E2164756E21
|