@uipath/cli 1.205.0-preview.276 → 1.206.0-preview.279
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{applicationinsights-s28k1t0d.js → applicationinsights-pwe8sf3y.js} +1269 -1269
- package/dist/{browser-strategy-6atc7v8s.js → browser-strategy-p5fhwxqj.js} +6 -7
- package/dist/cli-q6fp9ccp.js +23 -0
- package/dist/contentStore-c51xqdn2.js +41 -0
- package/dist/environmentInfo-fn0za9jw.js +71 -0
- package/dist/feedbackPrompts-t1enxv1x.js +144 -0
- package/dist/handlers-93z27zrr.js +805 -0
- package/dist/index-16d4evd1.js +1051 -0
- package/dist/index-1vyte4ma.js +14 -0
- package/dist/index-21kns9qg.js +10 -0
- package/dist/{index-yhj4pgvt.js → index-2j7ss97f.js} +331 -2595
- package/dist/index-2k8rhmad.js +274 -0
- package/dist/{index-30618bjs.js → index-2mm750yx.js} +174 -234
- package/dist/{index-622x1qb5.js → index-3fvbddpw.js} +7092 -7092
- package/dist/{index-d3w0wn6k.js → index-5gce5wfd.js} +16 -16
- package/dist/index-5j0bfd3e.js +4744 -0
- package/dist/index-68xmrb9x.js +237 -0
- package/dist/index-6wj58qka.js +59 -0
- package/dist/index-898c4tfz.js +668 -0
- package/dist/index-8gr7ny79.js +365 -0
- package/dist/index-99emfvtm.js +13 -0
- package/dist/{index-pj3g8ftz.js → index-9db5vwx9.js} +2429 -1693
- package/dist/index-ayg25v46.js +151 -0
- package/dist/index-bf0e4evz.js +6180 -0
- package/dist/index-bpqx6f8h.js +92 -0
- package/dist/index-bpxh3fqv.js +392 -0
- package/dist/index-cc653qc1.js +1327 -0
- package/dist/{index-m5nwse9v.js → index-cj4v0jct.js} +21 -69
- package/dist/{index-469jgr1w.js → index-dsj3jrm0.js} +105 -106
- package/dist/{index-1yh8g550.js → index-epsr41wx.js} +8 -12
- package/dist/{index-yb4er9vd.js → index-jjejkkg4.js} +474 -528
- package/dist/index-kg1xrq51.js +171 -0
- package/dist/index-m8vqyv3g.js +72 -0
- package/dist/index-mzqm6xfh.js +45 -0
- package/dist/index-nsrrst23.js +44 -0
- package/dist/{index-h8cph72k.js → index-nzr4mx5p.js} +2 -22
- package/dist/index-p9s0gyrw.js +72 -0
- package/dist/index-qadhm1gn.js +271 -0
- package/dist/index-qwbyt2q5.js +95 -0
- package/dist/index-rbna3w6k.js +200 -0
- package/dist/index-rr5hdtcy.js +95 -0
- package/dist/{index-qa9gftnj.js → index-xd2w5pct.js} +3 -3
- package/dist/index-xpdtagqw.js +30 -0
- package/dist/{index-925304r7.js → index-y085rpen.js} +29 -25
- package/dist/index-y5ncb93a.js +240 -0
- package/dist/index-y7d0cth0.js +93 -0
- package/dist/{index-hdxtgckw.js → index-z070caqq.js} +56 -12
- package/dist/index-zdqbp34f.js +14 -0
- package/dist/index.js +38 -36
- package/dist/install-3gw33jcf.js +558 -0
- package/dist/{jmespath-e4a59c8w.js → jmespath-ab6tdc42.js} +1 -1
- package/dist/js-yaml-0c4svjwq.js +36 -0
- package/dist/{mcp-jssaz3wr.js → mcp-s50h6d56.js} +236 -472
- package/dist/{node-strategy-ggx3nmyj.js → node-strategy-p1n8wr5s.js} +16 -19
- package/dist/project-context-285hydnd.js +94 -0
- package/dist/prompt-hxbzt92e.js +13 -0
- package/dist/{server-nfjr7xrb.js → server-gkr3c7hv.js} +28 -43
- package/dist/skillCatalog-fvw4wgw1.js +22 -0
- package/dist/skillsService-20es18vs.js +29 -0
- package/dist/{stdio-tmngemcz.js → stdio-kpsab5bz.js} +2 -4
- package/dist/{telemetry-drain-r92f0e4r.js → telemetry-drain-bw59e8f5.js} +8 -9
- package/dist/tree-j4w7p0pg.js +17 -0
- package/dist/updateService-pq7pkd42.js +522 -0
- package/dist/updateService.skills-4t1s7z45.js +22 -0
- package/dist/updateService.tools-f7tr6kc6.js +16 -0
- package/package.json +2 -2
- package/dist/cli-r7998zeh.js +0 -19
- package/dist/index-0gctz400.js +0 -17
- package/dist/index-2dp7m4r8.js +0 -9867
- package/dist/index-4cq44eth.js +0 -19427
- package/dist/index-7tshyfxx.js +0 -157
- package/dist/index-g8ck9tv6.js +0 -2
- package/dist/index-ngs0a2he.js +0 -15
- package/dist/index-yc4kw997.js +0 -13
- package/dist/js-yaml-69tsdrrf.js +0 -37
- package/dist/updateService-nrmb1tsc.js +0 -14
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileSystem2
|
|
3
|
+
} from "./index-z070caqq.js";
|
|
4
|
+
import {
|
|
5
|
+
catchError
|
|
6
|
+
} from "./index-9db5vwx9.js";
|
|
7
|
+
|
|
8
|
+
// src/commands/skills/agents/detect.ts
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
var VERSION_TIMEOUT_MS = 5000;
|
|
11
|
+
function windowsExts() {
|
|
12
|
+
const fs = getFileSystem2();
|
|
13
|
+
const raw = fs.env.getenv("PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
|
|
14
|
+
return raw.split(";").map((e) => e.trim().toLowerCase()).filter(Boolean);
|
|
15
|
+
}
|
|
16
|
+
async function commandOnPath(...names) {
|
|
17
|
+
const isWin = process.platform === "win32";
|
|
18
|
+
const fs = getFileSystem2();
|
|
19
|
+
const pathVar = fs.env.getenv("PATH") ?? "";
|
|
20
|
+
if (!pathVar)
|
|
21
|
+
return false;
|
|
22
|
+
const dirs = pathVar.split(isWin ? ";" : ":").filter(Boolean);
|
|
23
|
+
const exts = isWin ? ["", ...windowsExts()] : [""];
|
|
24
|
+
for (const dir of dirs) {
|
|
25
|
+
for (const name of names) {
|
|
26
|
+
for (const ext of exts) {
|
|
27
|
+
const candidate = fs.path.join(dir, `${name}${ext}`);
|
|
28
|
+
const [, exists] = await catchError(fs.exists(candidate));
|
|
29
|
+
if (exists)
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
function runVersion(command, args, timeoutMs = VERSION_TIMEOUT_MS) {
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
const proc = process.platform === "win32" ? spawn([command, ...args].join(" "), [], {
|
|
39
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
40
|
+
shell: true
|
|
41
|
+
}) : spawn(command, [...args], {
|
|
42
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
43
|
+
});
|
|
44
|
+
let out = "";
|
|
45
|
+
let settled = false;
|
|
46
|
+
const finish = (value) => {
|
|
47
|
+
if (settled)
|
|
48
|
+
return;
|
|
49
|
+
settled = true;
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
resolve(value);
|
|
52
|
+
};
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
proc.kill();
|
|
55
|
+
finish(null);
|
|
56
|
+
}, timeoutMs);
|
|
57
|
+
proc.stdout?.on("data", (d) => {
|
|
58
|
+
out += d.toString();
|
|
59
|
+
});
|
|
60
|
+
proc.stderr?.on("data", (d) => {
|
|
61
|
+
out += d.toString();
|
|
62
|
+
});
|
|
63
|
+
proc.on("error", () => finish(null));
|
|
64
|
+
proc.on("close", () => finish(out || null));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async function verifiedCommandOnPath(names, signature, versionArgs = ["--version"]) {
|
|
68
|
+
for (const name of names) {
|
|
69
|
+
if (!await commandOnPath(name))
|
|
70
|
+
continue;
|
|
71
|
+
const out = await runVersion(name, versionArgs);
|
|
72
|
+
if (out && signature.test(out))
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
async function homePathExists(...segments) {
|
|
78
|
+
const fs = getFileSystem2();
|
|
79
|
+
const [, exists] = await catchError(fs.exists(fs.path.join(fs.env.homedir(), ...segments)));
|
|
80
|
+
return exists ?? false;
|
|
81
|
+
}
|
|
82
|
+
async function homeAppDirInstalled(dir) {
|
|
83
|
+
if (!await homePathExists(dir))
|
|
84
|
+
return false;
|
|
85
|
+
const fs = getFileSystem2();
|
|
86
|
+
const [, entries] = await catchError(fs.readdir(fs.path.join(fs.env.homedir(), dir)));
|
|
87
|
+
return (entries ?? []).some((entry) => entry !== "skills" && entry !== ".DS_Store");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { commandOnPath, verifiedCommandOnPath, homePathExists, homeAppDirInstalled };
|
|
91
|
+
|
|
92
|
+
//# debugId=CC702EE4D941A58F64756E2164756E21
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileSystem2,
|
|
3
|
+
getFileSystemAsync2
|
|
4
|
+
} from "./index-z070caqq.js";
|
|
5
|
+
import {
|
|
6
|
+
catchError,
|
|
7
|
+
Command,
|
|
8
|
+
logger,
|
|
9
|
+
REGISTER_EXPORT
|
|
10
|
+
} from "./index-9db5vwx9.js";
|
|
11
|
+
import {
|
|
12
|
+
getGlobalNpmUipathDir,
|
|
13
|
+
getEnvToolsDirsDeclaration,
|
|
14
|
+
TOOLS_WHITELIST,
|
|
15
|
+
WHITELIST_BY_SHORT_NAME
|
|
16
|
+
} from "./index-16d4evd1.js";
|
|
17
|
+
|
|
18
|
+
// src/services/storage.ts
|
|
19
|
+
class GeneralizedStorage {
|
|
20
|
+
_initPromise;
|
|
21
|
+
async init() {
|
|
22
|
+
if (this._initPromise)
|
|
23
|
+
return this._initPromise;
|
|
24
|
+
const promise = getFileSystemAsync2().then(() => {
|
|
25
|
+
return;
|
|
26
|
+
});
|
|
27
|
+
this._initPromise = promise;
|
|
28
|
+
promise.catch(() => {
|
|
29
|
+
this._initPromise = undefined;
|
|
30
|
+
});
|
|
31
|
+
return promise;
|
|
32
|
+
}
|
|
33
|
+
get fs() {
|
|
34
|
+
return getFileSystem2();
|
|
35
|
+
}
|
|
36
|
+
async read(path) {
|
|
37
|
+
const res = await this.fs.readFile(path);
|
|
38
|
+
if (res === null)
|
|
39
|
+
return null;
|
|
40
|
+
if (typeof res === "string") {
|
|
41
|
+
return new TextEncoder().encode(res);
|
|
42
|
+
}
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
async readText(path) {
|
|
46
|
+
return this.fs.readFile(path, "utf-8");
|
|
47
|
+
}
|
|
48
|
+
async write(path, content) {
|
|
49
|
+
await this.fs.writeFile(path, content);
|
|
50
|
+
}
|
|
51
|
+
async exists(path) {
|
|
52
|
+
return this.fs.exists(path);
|
|
53
|
+
}
|
|
54
|
+
async readdir(path) {
|
|
55
|
+
return this.fs.readdir(path);
|
|
56
|
+
}
|
|
57
|
+
async remove(path) {
|
|
58
|
+
if (!await this.fs.exists(path))
|
|
59
|
+
return;
|
|
60
|
+
await this.fs.rm(path);
|
|
61
|
+
}
|
|
62
|
+
async mkdir(path) {
|
|
63
|
+
await this.fs.mkdir(path);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
var storage = new GeneralizedStorage;
|
|
67
|
+
|
|
68
|
+
// src/utils/localWorkspace.ts
|
|
69
|
+
var MAX_WALK_DEPTH = 10;
|
|
70
|
+
var CLI_PACKAGE_NAME = "@uipath/cli";
|
|
71
|
+
function isInsideNodeModules(dir) {
|
|
72
|
+
const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
73
|
+
return segments.includes("node_modules");
|
|
74
|
+
}
|
|
75
|
+
async function isLocalWorkspaceDir(dir) {
|
|
76
|
+
const fs = getFileSystem2();
|
|
77
|
+
const pkgJsonPath = fs.path.join(dir, "package.json");
|
|
78
|
+
const [, exists] = await catchError(fs.exists(pkgJsonPath));
|
|
79
|
+
if (!exists)
|
|
80
|
+
return false;
|
|
81
|
+
const [, raw] = await catchError(fs.readFile(pkgJsonPath, "utf-8"));
|
|
82
|
+
if (!raw)
|
|
83
|
+
return false;
|
|
84
|
+
const [, pkg] = catchError(() => JSON.parse(raw));
|
|
85
|
+
if (!pkg)
|
|
86
|
+
return false;
|
|
87
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
88
|
+
return CLI_PACKAGE_NAME in deps || !!pkg.workspaces;
|
|
89
|
+
}
|
|
90
|
+
async function hasGoverningLocalProject(startDir) {
|
|
91
|
+
const fs = getFileSystem2();
|
|
92
|
+
const { dirname } = fs.path;
|
|
93
|
+
let path = startDir;
|
|
94
|
+
for (let i = 0;i < MAX_WALK_DEPTH; i++) {
|
|
95
|
+
if (!isInsideNodeModules(path) && await isLocalWorkspaceDir(path)) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
const parent = dirname(path);
|
|
99
|
+
if (parent === path)
|
|
100
|
+
break;
|
|
101
|
+
path = parent;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/utils/toolLoader.ts
|
|
107
|
+
function isRunningFromSource() {
|
|
108
|
+
const [error, mainUrl] = catchError(() => import.meta.url);
|
|
109
|
+
if (error) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return mainUrl.endsWith(".ts");
|
|
113
|
+
}
|
|
114
|
+
var _isRunningFromSource = isRunningFromSource();
|
|
115
|
+
var _isBrowser = !(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
116
|
+
function joinPath(...parts) {
|
|
117
|
+
return parts.filter((p) => p).join("/").replace(/\/+/g, "/");
|
|
118
|
+
}
|
|
119
|
+
async function discoverToolPaths(toolsDirs) {
|
|
120
|
+
const [initError] = await catchError(storage.init());
|
|
121
|
+
if (initError) {
|
|
122
|
+
logger.error("Storage initialization failed:", initError);
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const dirs = Array.isArray(toolsDirs) ? toolsDirs : [toolsDirs];
|
|
126
|
+
const discovered = [];
|
|
127
|
+
const seenPrefixes = new Set;
|
|
128
|
+
for (const toolsDir of dirs) {
|
|
129
|
+
if (!await storage.exists(toolsDir)) {
|
|
130
|
+
logger.debug(`Tools directory does not exist, skipping: ${toolsDir}`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const toolNames = [...WHITELIST_BY_SHORT_NAME.keys()];
|
|
134
|
+
const resolvedPaths = await Promise.all(toolNames.map(async (toolName) => {
|
|
135
|
+
const toolDir = joinPath(toolsDir, toolName);
|
|
136
|
+
const possiblePaths = _isRunningFromSource ? [
|
|
137
|
+
joinPath(toolDir, "src", "tool.ts"),
|
|
138
|
+
joinPath(toolDir, "dist", "tool.js"),
|
|
139
|
+
joinPath(toolDir, "tool.js")
|
|
140
|
+
] : [
|
|
141
|
+
joinPath(toolDir, "dist", "tool.js"),
|
|
142
|
+
joinPath(toolDir, "tool.js"),
|
|
143
|
+
joinPath(toolDir, "src", "tool.ts")
|
|
144
|
+
];
|
|
145
|
+
const factoryPaths = _isRunningFromSource ? [
|
|
146
|
+
joinPath(toolDir, "src", "packager-tool.ts"),
|
|
147
|
+
joinPath(toolDir, "dist", "packager-tool.js")
|
|
148
|
+
] : [
|
|
149
|
+
joinPath(toolDir, "dist", "packager-tool.js"),
|
|
150
|
+
joinPath(toolDir, "src", "packager-tool.ts")
|
|
151
|
+
];
|
|
152
|
+
const [existResults, factoryExistResults, pkgJson] = await Promise.all([
|
|
153
|
+
Promise.all(possiblePaths.map((p) => storage.exists(p))),
|
|
154
|
+
Promise.all(factoryPaths.map((p) => storage.exists(p))),
|
|
155
|
+
storage.readText(joinPath(toolDir, "package.json")).catch(() => null)
|
|
156
|
+
]);
|
|
157
|
+
const foundIndex = existResults.indexOf(true);
|
|
158
|
+
const factoryIndex = factoryExistResults.indexOf(true);
|
|
159
|
+
let description = "";
|
|
160
|
+
let version = "";
|
|
161
|
+
if (pkgJson) {
|
|
162
|
+
const [parseErr, pkg] = catchError(() => JSON.parse(pkgJson));
|
|
163
|
+
if (!parseErr) {
|
|
164
|
+
description = pkg.description ?? "";
|
|
165
|
+
version = pkg.version ?? "";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
toolName,
|
|
170
|
+
toolPath: foundIndex >= 0 ? possiblePaths[foundIndex] : null,
|
|
171
|
+
packagerToolPath: factoryIndex >= 0 ? factoryPaths[factoryIndex] : undefined,
|
|
172
|
+
description,
|
|
173
|
+
version
|
|
174
|
+
};
|
|
175
|
+
}));
|
|
176
|
+
for (const {
|
|
177
|
+
toolName,
|
|
178
|
+
toolPath,
|
|
179
|
+
packagerToolPath,
|
|
180
|
+
description,
|
|
181
|
+
version
|
|
182
|
+
} of resolvedPaths) {
|
|
183
|
+
if (!toolPath) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const packageName = WHITELIST_BY_SHORT_NAME.get(toolName);
|
|
187
|
+
const commandPrefix = packageName ? TOOLS_WHITELIST.get(packageName) : undefined;
|
|
188
|
+
if (!commandPrefix || !packageName) {
|
|
189
|
+
logger.warn(`Tool '${toolName}' found at ${toolPath} but not in whitelist, skipping`);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (seenPrefixes.has(commandPrefix)) {
|
|
193
|
+
logger.info(`Tool ${toolName} (command '${commandPrefix}') already found from a higher-priority path, skipping`);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
seenPrefixes.add(commandPrefix);
|
|
197
|
+
logger.debug(`Discovered tool '${toolName}' v${version || "unknown"} at ${toolPath}`);
|
|
198
|
+
discovered.push({
|
|
199
|
+
toolName,
|
|
200
|
+
toolPath,
|
|
201
|
+
commandPrefix,
|
|
202
|
+
packageName,
|
|
203
|
+
description,
|
|
204
|
+
version,
|
|
205
|
+
packagerToolPath
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return discovered;
|
|
210
|
+
}
|
|
211
|
+
async function importModuleByPath(modulePath) {
|
|
212
|
+
const savedTrackedAction = Command.prototype.trackedAction;
|
|
213
|
+
const [error, mod] = await catchError((async () => {
|
|
214
|
+
if (_isBrowser) {
|
|
215
|
+
const content = await storage.readText(modulePath);
|
|
216
|
+
if (!content)
|
|
217
|
+
return;
|
|
218
|
+
const blob = new Blob([content], { type: "text/javascript" });
|
|
219
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
220
|
+
const [importError, imported] = await catchError(import(blobUrl));
|
|
221
|
+
URL.revokeObjectURL(blobUrl);
|
|
222
|
+
if (importError)
|
|
223
|
+
throw importError;
|
|
224
|
+
return imported;
|
|
225
|
+
} else {
|
|
226
|
+
const { pathToFileURL } = await import("node:url");
|
|
227
|
+
const fileUrl = pathToFileURL(modulePath).href;
|
|
228
|
+
return await import(fileUrl);
|
|
229
|
+
}
|
|
230
|
+
})());
|
|
231
|
+
if (savedTrackedAction && Command.prototype.trackedAction !== savedTrackedAction) {
|
|
232
|
+
Command.prototype.trackedAction = savedTrackedAction;
|
|
233
|
+
logger.warn(`Import of ${modulePath} overwrote Command.prototype.trackedAction — restored CLI version.`);
|
|
234
|
+
}
|
|
235
|
+
if (error)
|
|
236
|
+
throw error;
|
|
237
|
+
return mod;
|
|
238
|
+
}
|
|
239
|
+
async function importTool(discovered, options = {}) {
|
|
240
|
+
const { toolName, toolPath } = discovered;
|
|
241
|
+
logger.debug(`Loading tool '${toolName}' from ${toolPath}`);
|
|
242
|
+
const [error, toolModule] = await catchError(importModuleByPath(toolPath));
|
|
243
|
+
if (error) {
|
|
244
|
+
logger.error(`Failed to load tool ${toolName} (version: ${discovered.version || "unknown"}, path: ${toolPath}):`, error);
|
|
245
|
+
if (options.throwOnLoadError) {
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const { metadata, registerCommands } = toolModule ?? {};
|
|
251
|
+
if (!metadata || !registerCommands) {
|
|
252
|
+
logger.warn(`Tool ${toolName} missing required exports (metadata or registerCommands), skipping`);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
logger.debug(`Tool '${toolName}' loaded successfully (prefix: ${metadata.commandPrefix}, version: ${metadata.version ?? "unknown"})`);
|
|
256
|
+
return { metadata, registerCommands };
|
|
257
|
+
}
|
|
258
|
+
async function importPackagerTool(discovered) {
|
|
259
|
+
const { toolName, packagerToolPath } = discovered;
|
|
260
|
+
if (!packagerToolPath)
|
|
261
|
+
return;
|
|
262
|
+
logger.debug(`Loading packager factory for '${toolName}' from ${packagerToolPath}`);
|
|
263
|
+
const [error, mod] = await catchError(importModuleByPath(packagerToolPath));
|
|
264
|
+
if (error) {
|
|
265
|
+
throw new Error(`Failed to load packager factory for '${toolName}' from ${packagerToolPath}: ${error instanceof Error ? error.message : error}`);
|
|
266
|
+
}
|
|
267
|
+
const register = mod?.[REGISTER_EXPORT];
|
|
268
|
+
if (typeof register !== "function") {
|
|
269
|
+
logger.debug(`Packager factory entry point for '${toolName}' (${packagerToolPath}) has no ` + `'${REGISTER_EXPORT}' export — treating it as a legacy entry point that ` + "registered its factories at import.");
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const [registerError] = catchError(() => {
|
|
273
|
+
register();
|
|
274
|
+
});
|
|
275
|
+
if (registerError) {
|
|
276
|
+
throw new Error(`Failed to register packager factories for '${toolName}' from ${packagerToolPath}: ${registerError.message}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function importToolLibraryModule(discovered, moduleName) {
|
|
280
|
+
const { toolName, toolPath } = discovered;
|
|
281
|
+
if (!/^[a-z0-9-]+$/.test(moduleName)) {
|
|
282
|
+
throw new Error(`Invalid tool module name '${moduleName}'.`);
|
|
283
|
+
}
|
|
284
|
+
const modulePath = toolPath.replace(/tool\.(ts|js)$/, `${moduleName}.$1`);
|
|
285
|
+
if (modulePath === toolPath || !await storage.exists(modulePath)) {
|
|
286
|
+
throw new Error(`Tool '${toolName}' has no '${moduleName}' entry point next to ${toolPath}.`);
|
|
287
|
+
}
|
|
288
|
+
logger.debug(`Loading '${moduleName}' for '${toolName}' from ${modulePath}`);
|
|
289
|
+
const [error, mod] = await catchError(importModuleByPath(modulePath));
|
|
290
|
+
if (error) {
|
|
291
|
+
throw new Error(`Failed to load '${moduleName}' for '${toolName}' from ${modulePath}: ${error instanceof Error ? error.message : error}`);
|
|
292
|
+
}
|
|
293
|
+
return mod;
|
|
294
|
+
}
|
|
295
|
+
async function findNearestToolsDir(startDir, seen) {
|
|
296
|
+
const fs = getFileSystem2();
|
|
297
|
+
const { dirname, join } = fs.path;
|
|
298
|
+
const results = [];
|
|
299
|
+
let searchPath = startDir;
|
|
300
|
+
for (let i = 0;i < MAX_WALK_DEPTH; i++) {
|
|
301
|
+
const candidate = join(searchPath, "node_modules", "@uipath");
|
|
302
|
+
const [, exists] = await catchError(fs.exists(candidate));
|
|
303
|
+
if (exists) {
|
|
304
|
+
if (seen.has(candidate)) {
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
seen.add(candidate);
|
|
308
|
+
results.push(candidate);
|
|
309
|
+
if (!isInsideNodeModules(searchPath)) {
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
logger.debug("Search path is inside node_modules, continuing walk for hoisted packages");
|
|
313
|
+
}
|
|
314
|
+
const parentPath = dirname(searchPath);
|
|
315
|
+
if (parentPath === searchPath) {
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
searchPath = parentPath;
|
|
319
|
+
}
|
|
320
|
+
return results;
|
|
321
|
+
}
|
|
322
|
+
async function findNearestLocalCliToolsDir(startDir) {
|
|
323
|
+
const fs = getFileSystem2();
|
|
324
|
+
const { dirname, join } = fs.path;
|
|
325
|
+
let searchPath = startDir;
|
|
326
|
+
for (let i = 0;i < MAX_WALK_DEPTH; i++) {
|
|
327
|
+
const candidate = join(searchPath, "node_modules", "@uipath");
|
|
328
|
+
const cliPackageJson = join(candidate, "cli", "package.json");
|
|
329
|
+
const [error, exists] = await catchError(fs.exists(cliPackageJson));
|
|
330
|
+
if (error) {
|
|
331
|
+
logger.debug(`fs.exists check failed for ${cliPackageJson}: ${String(error)}`);
|
|
332
|
+
} else if (exists) {
|
|
333
|
+
return candidate;
|
|
334
|
+
}
|
|
335
|
+
const parentPath = dirname(searchPath);
|
|
336
|
+
if (parentPath === searchPath) {
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
searchPath = parentPath;
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
async function resolveToolsDirs(cliFilePath, cwd) {
|
|
344
|
+
const fs = getFileSystem2();
|
|
345
|
+
const { dirname } = fs.path;
|
|
346
|
+
const seen = new Set;
|
|
347
|
+
const dirs = [];
|
|
348
|
+
const cliDir = dirname(cliFilePath);
|
|
349
|
+
const declaration = await getEnvToolsDirsDeclaration();
|
|
350
|
+
if (declaration) {
|
|
351
|
+
logger.debug(`Using only the host-declared tool directories: [${declaration.dirs.join(", ")}]`);
|
|
352
|
+
return [...declaration.dirs];
|
|
353
|
+
}
|
|
354
|
+
const localCliToolsDir = await findNearestLocalCliToolsDir(cwd);
|
|
355
|
+
if (localCliToolsDir) {
|
|
356
|
+
seen.add(localCliToolsDir);
|
|
357
|
+
dirs.push(localCliToolsDir);
|
|
358
|
+
logger.debug("CWD has a local @uipath/cli install; skipping CLI-path and global tool discovery");
|
|
359
|
+
return dirs;
|
|
360
|
+
}
|
|
361
|
+
dirs.push(...await findNearestToolsDir(cliDir, seen));
|
|
362
|
+
dirs.push(...await findNearestToolsDir(cwd, seen));
|
|
363
|
+
if (!await hasGoverningLocalProject(cliDir) && !await dirsContainAnyPlugin(dirs)) {
|
|
364
|
+
const globalUipath = await getGlobalNpmUipathDir();
|
|
365
|
+
if (globalUipath && !seen.has(globalUipath)) {
|
|
366
|
+
seen.add(globalUipath);
|
|
367
|
+
dirs.push(globalUipath);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return dirs;
|
|
371
|
+
}
|
|
372
|
+
async function dirsContainAnyPlugin(dirs) {
|
|
373
|
+
if (dirs.length === 0)
|
|
374
|
+
return false;
|
|
375
|
+
const fs = getFileSystem2();
|
|
376
|
+
for (const dir of dirs) {
|
|
377
|
+
const [error, entries] = await catchError(fs.readdir(dir));
|
|
378
|
+
if (error) {
|
|
379
|
+
logger.debug(`fs.readdir failed for ${dir}: ${String(error)}`);
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
for (const entry of entries) {
|
|
383
|
+
if (WHITELIST_BY_SHORT_NAME.has(entry))
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export { storage, isInsideNodeModules, isLocalWorkspaceDir, discoverToolPaths, importTool, importPackagerTool, importToolLibraryModule, resolveToolsDirs };
|
|
391
|
+
|
|
392
|
+
//# debugId=0DD9EAC63C4A8F6364756E2164756E21
|