@uipath/cli 0.2.0 → 0.2.2
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/index.js +156 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47604,7 +47604,7 @@ var package_default;
|
|
|
47604
47604
|
var init_package = __esm(() => {
|
|
47605
47605
|
package_default = {
|
|
47606
47606
|
name: "@uipath/cli",
|
|
47607
|
-
version: "0.2.
|
|
47607
|
+
version: "0.2.2",
|
|
47608
47608
|
description: "Cross platform CLI for UiPath",
|
|
47609
47609
|
repository: {
|
|
47610
47610
|
type: "git",
|
|
@@ -82938,6 +82938,70 @@ Supported agents:
|
|
|
82938
82938
|
` + " Codex .agents/skills/<skill>/";
|
|
82939
82939
|
});
|
|
82940
82940
|
|
|
82941
|
+
// src/utils/globalNpmRoot.ts
|
|
82942
|
+
async function getGlobalNpmUipathDir() {
|
|
82943
|
+
if (cachedLookup)
|
|
82944
|
+
return cachedLookup;
|
|
82945
|
+
cachedLookup = resolveGlobalNpmUipathDir();
|
|
82946
|
+
return cachedLookup;
|
|
82947
|
+
}
|
|
82948
|
+
async function resolveGlobalNpmUipathDir() {
|
|
82949
|
+
const root = await runNpmRootGlobal();
|
|
82950
|
+
if (!root) {
|
|
82951
|
+
logger.debug("npm root -g lookup failed; skipping global plugin fallback");
|
|
82952
|
+
return null;
|
|
82953
|
+
}
|
|
82954
|
+
const fs7 = getFileSystem();
|
|
82955
|
+
const candidate = fs7.path.join(root, "@uipath");
|
|
82956
|
+
const [existsError, exists] = await catchError(fs7.exists(candidate));
|
|
82957
|
+
if (existsError) {
|
|
82958
|
+
logger.debug(`fs.exists check failed for ${candidate}: ${String(existsError)}`);
|
|
82959
|
+
return null;
|
|
82960
|
+
}
|
|
82961
|
+
if (!exists) {
|
|
82962
|
+
logger.debug(`Global @uipath not present at ${candidate}`);
|
|
82963
|
+
return null;
|
|
82964
|
+
}
|
|
82965
|
+
logger.debug(`Global @uipath resolved via npm root -g: ${candidate}`);
|
|
82966
|
+
return candidate;
|
|
82967
|
+
}
|
|
82968
|
+
async function runNpmRootGlobal() {
|
|
82969
|
+
const { spawn: spawn2 } = await import("node:child_process");
|
|
82970
|
+
const isWindows = process.platform === "win32";
|
|
82971
|
+
return new Promise((resolve2) => {
|
|
82972
|
+
const proc = isWindows ? spawn2("npm", ["root", "-g"], {
|
|
82973
|
+
shell: true,
|
|
82974
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
82975
|
+
windowsHide: true
|
|
82976
|
+
}) : spawn2("npm", ["root", "-g"], {
|
|
82977
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
82978
|
+
});
|
|
82979
|
+
let stdout = "";
|
|
82980
|
+
proc.stdout?.on("data", (d) => {
|
|
82981
|
+
stdout += d.toString();
|
|
82982
|
+
});
|
|
82983
|
+
proc.stderr?.on("data", () => {});
|
|
82984
|
+
const timer = setTimeout(() => {
|
|
82985
|
+
proc.kill("SIGTERM");
|
|
82986
|
+
resolve2(null);
|
|
82987
|
+
}, NPM_ROOT_TIMEOUT_MS);
|
|
82988
|
+
proc.on("error", () => {
|
|
82989
|
+
clearTimeout(timer);
|
|
82990
|
+
resolve2(null);
|
|
82991
|
+
});
|
|
82992
|
+
proc.on("close", (code) => {
|
|
82993
|
+
clearTimeout(timer);
|
|
82994
|
+
const trimmed = stdout.trim();
|
|
82995
|
+
resolve2(code === 0 && trimmed ? trimmed : null);
|
|
82996
|
+
});
|
|
82997
|
+
});
|
|
82998
|
+
}
|
|
82999
|
+
var NPM_ROOT_TIMEOUT_MS = 5000, cachedLookup = null;
|
|
83000
|
+
var init_globalNpmRoot = __esm(() => {
|
|
83001
|
+
init_src();
|
|
83002
|
+
init_src2();
|
|
83003
|
+
});
|
|
83004
|
+
|
|
82941
83005
|
// src/services/tools-whitelist.ts
|
|
82942
83006
|
var TOOLS_WHITELIST, WHITELIST_BY_COMMAND, WHITELIST_BY_SHORT_NAME;
|
|
82943
83007
|
var init_tools_whitelist = __esm(() => {
|
|
@@ -83346,13 +83410,25 @@ ${errors5.map((e) => ` - ${e}`).join(`
|
|
|
83346
83410
|
}
|
|
83347
83411
|
async uninstall(packageName, destination, options) {
|
|
83348
83412
|
const fs7 = getFileSystem();
|
|
83349
|
-
|
|
83350
|
-
|
|
83351
|
-
if (
|
|
83352
|
-
|
|
83413
|
+
let containerDir;
|
|
83414
|
+
let relativeName;
|
|
83415
|
+
if (options?.global) {
|
|
83416
|
+
const globalUipathDir = await getGlobalNpmUipathDir();
|
|
83417
|
+
if (!globalUipathDir) {
|
|
83418
|
+
throw new Error(`Cannot locate '${packageName}': npm root -g unavailable`);
|
|
83419
|
+
}
|
|
83420
|
+
containerDir = globalUipathDir;
|
|
83421
|
+
relativeName = packageName.replace(/^@uipath\//, "");
|
|
83422
|
+
} else {
|
|
83423
|
+
containerDir = fs7.path.resolve(destination, "node_modules");
|
|
83424
|
+
relativeName = packageName;
|
|
83425
|
+
}
|
|
83426
|
+
const packageDir = fs7.path.resolve(fs7.path.join(containerDir, relativeName));
|
|
83427
|
+
if (!packageDir.startsWith(`${containerDir}/`) && !packageDir.startsWith(`${containerDir}\\`)) {
|
|
83428
|
+
throw new Error(`Refusing to uninstall '${packageName}': resolved path escapes ${containerDir}`);
|
|
83353
83429
|
}
|
|
83354
83430
|
if (!await fs7.exists(packageDir)) {
|
|
83355
|
-
throw new Error(`Package '${packageName}' is not installed at ${
|
|
83431
|
+
throw new Error(`Package '${packageName}' is not installed at ${packageDir}`);
|
|
83356
83432
|
}
|
|
83357
83433
|
const [statError, stat2] = await catchError(fs7.stat(packageDir));
|
|
83358
83434
|
if (!statError && !stat2) {
|
|
@@ -83398,6 +83474,7 @@ var SEMVER_RE, SAFE_PACKAGE_SPEC, SAFE_VERSION, NPM_TIMEOUT_MS = 180000, NPM_MAX
|
|
|
83398
83474
|
var init_toolService = __esm(() => {
|
|
83399
83475
|
init_src();
|
|
83400
83476
|
init_src2();
|
|
83477
|
+
init_globalNpmRoot();
|
|
83401
83478
|
init_tools_whitelist();
|
|
83402
83479
|
init_tools_whitelist();
|
|
83403
83480
|
SEMVER_RE = /^\d+\.\d+\.\d+(-[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?(\+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?$/;
|
|
@@ -83729,6 +83806,47 @@ var init_tools = __esm(() => {
|
|
|
83729
83806
|
init_update2();
|
|
83730
83807
|
});
|
|
83731
83808
|
|
|
83809
|
+
// src/utils/localWorkspace.ts
|
|
83810
|
+
function isInsideNodeModules(dir) {
|
|
83811
|
+
const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
83812
|
+
return segments.includes("node_modules");
|
|
83813
|
+
}
|
|
83814
|
+
async function isLocalWorkspaceDir(dir) {
|
|
83815
|
+
const fs7 = getFileSystem();
|
|
83816
|
+
const pkgJsonPath = fs7.path.join(dir, "package.json");
|
|
83817
|
+
const [, exists] = await catchError(fs7.exists(pkgJsonPath));
|
|
83818
|
+
if (!exists)
|
|
83819
|
+
return false;
|
|
83820
|
+
const [, raw] = await catchError(fs7.readFile(pkgJsonPath, "utf-8"));
|
|
83821
|
+
if (!raw)
|
|
83822
|
+
return false;
|
|
83823
|
+
const [, pkg] = catchError(() => JSON.parse(raw));
|
|
83824
|
+
if (!pkg)
|
|
83825
|
+
return false;
|
|
83826
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
83827
|
+
return CLI_PACKAGE_NAME in deps || !!pkg.workspaces;
|
|
83828
|
+
}
|
|
83829
|
+
async function hasGoverningLocalProject(startDir) {
|
|
83830
|
+
const fs7 = getFileSystem();
|
|
83831
|
+
const { dirname: dirname3 } = fs7.path;
|
|
83832
|
+
let path4 = startDir;
|
|
83833
|
+
for (let i2 = 0;i2 < MAX_WALK_DEPTH; i2++) {
|
|
83834
|
+
if (!isInsideNodeModules(path4) && await isLocalWorkspaceDir(path4)) {
|
|
83835
|
+
return true;
|
|
83836
|
+
}
|
|
83837
|
+
const parent = dirname3(path4);
|
|
83838
|
+
if (parent === path4)
|
|
83839
|
+
break;
|
|
83840
|
+
path4 = parent;
|
|
83841
|
+
}
|
|
83842
|
+
return false;
|
|
83843
|
+
}
|
|
83844
|
+
var MAX_WALK_DEPTH = 10, CLI_PACKAGE_NAME = "@uipath/cli";
|
|
83845
|
+
var init_localWorkspace = __esm(() => {
|
|
83846
|
+
init_src();
|
|
83847
|
+
init_src2();
|
|
83848
|
+
});
|
|
83849
|
+
|
|
83732
83850
|
// src/services/installPath.ts
|
|
83733
83851
|
function createInstallPathResolver(toolsDir, isBrowser3) {
|
|
83734
83852
|
return async (packageName) => {
|
|
@@ -83741,32 +83859,13 @@ function createInstallPathResolver(toolsDir, isBrowser3) {
|
|
|
83741
83859
|
const { dirname: dirnameFn, join: joinFn } = fsLocal.path;
|
|
83742
83860
|
if (toolsDir) {
|
|
83743
83861
|
let path4 = dirnameFn(dirnameFn(toolsDir));
|
|
83744
|
-
while (
|
|
83862
|
+
while (isInsideNodeModules(path4)) {
|
|
83745
83863
|
const parent = dirnameFn(path4);
|
|
83746
83864
|
if (parent === path4)
|
|
83747
83865
|
break;
|
|
83748
83866
|
path4 = parent;
|
|
83749
83867
|
}
|
|
83750
|
-
|
|
83751
|
-
const pkgJsonPath = joinFn(path4, "package.json");
|
|
83752
|
-
if (await fsLocal.exists(pkgJsonPath)) {
|
|
83753
|
-
const [, raw] = await catchError(fsLocal.readFile(pkgJsonPath, "utf-8"));
|
|
83754
|
-
if (raw) {
|
|
83755
|
-
const [, pkgJson] = catchError(() => JSON.parse(raw));
|
|
83756
|
-
if (pkgJson) {
|
|
83757
|
-
const deps = {
|
|
83758
|
-
...pkgJson.dependencies,
|
|
83759
|
-
...pkgJson.devDependencies
|
|
83760
|
-
};
|
|
83761
|
-
if (deps && "@uipath/cli" in deps) {
|
|
83762
|
-
isGlobal = false;
|
|
83763
|
-
}
|
|
83764
|
-
if (pkgJson.workspaces) {
|
|
83765
|
-
isGlobal = false;
|
|
83766
|
-
}
|
|
83767
|
-
}
|
|
83768
|
-
}
|
|
83769
|
-
}
|
|
83868
|
+
const isGlobal = !await isLocalWorkspaceDir(path4);
|
|
83770
83869
|
logger.debug(`Install path resolved: ${path4} (global: ${isGlobal})`);
|
|
83771
83870
|
return { path: path4, global: isGlobal };
|
|
83772
83871
|
}
|
|
@@ -83786,9 +83885,9 @@ function createInstallPathResolver(toolsDir, isBrowser3) {
|
|
|
83786
83885
|
throw new Error("Unable to determine install location. No node_modules found in parent directories.");
|
|
83787
83886
|
};
|
|
83788
83887
|
}
|
|
83789
|
-
var insideNodeModules = (dir) => /[\\/]node_modules([\\/]|$)/.test(dir);
|
|
83790
83888
|
var init_installPath = __esm(() => {
|
|
83791
83889
|
init_src();
|
|
83890
|
+
init_localWorkspace();
|
|
83792
83891
|
});
|
|
83793
83892
|
|
|
83794
83893
|
// src/services/storage.ts
|
|
@@ -84013,10 +84112,6 @@ async function discoverTools(toolsDirs) {
|
|
|
84013
84112
|
}
|
|
84014
84113
|
return tools;
|
|
84015
84114
|
}
|
|
84016
|
-
function isInsideNodeModules(dir) {
|
|
84017
|
-
const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
84018
|
-
return segments.includes("node_modules");
|
|
84019
|
-
}
|
|
84020
84115
|
async function findNearestToolsDir(startDir, seen) {
|
|
84021
84116
|
const fs7 = getFileSystem();
|
|
84022
84117
|
const { dirname: dirname3, join: join2 } = fs7.path;
|
|
@@ -84049,17 +84144,44 @@ async function resolveToolsDirs(cliFilePath, cwd) {
|
|
|
84049
84144
|
const { dirname: dirname3 } = fs7.path;
|
|
84050
84145
|
const seen = new Set;
|
|
84051
84146
|
const dirs = [];
|
|
84052
|
-
|
|
84147
|
+
const cliDir = dirname3(cliFilePath);
|
|
84148
|
+
dirs.push(...await findNearestToolsDir(cliDir, seen));
|
|
84053
84149
|
dirs.push(...await findNearestToolsDir(cwd, seen));
|
|
84150
|
+
if (!await hasGoverningLocalProject(cliDir) && !await dirsContainAnyPlugin(dirs)) {
|
|
84151
|
+
const globalUipath = await getGlobalNpmUipathDir();
|
|
84152
|
+
if (globalUipath && !seen.has(globalUipath)) {
|
|
84153
|
+
seen.add(globalUipath);
|
|
84154
|
+
dirs.push(globalUipath);
|
|
84155
|
+
}
|
|
84156
|
+
}
|
|
84054
84157
|
return dirs;
|
|
84055
84158
|
}
|
|
84056
|
-
|
|
84159
|
+
async function dirsContainAnyPlugin(dirs) {
|
|
84160
|
+
if (dirs.length === 0)
|
|
84161
|
+
return false;
|
|
84162
|
+
const fs7 = getFileSystem();
|
|
84163
|
+
for (const dir of dirs) {
|
|
84164
|
+
const [error48, entries] = await catchError(fs7.readdir(dir));
|
|
84165
|
+
if (error48) {
|
|
84166
|
+
logger.debug(`fs.readdir failed for ${dir}: ${String(error48)}`);
|
|
84167
|
+
continue;
|
|
84168
|
+
}
|
|
84169
|
+
for (const entry of entries) {
|
|
84170
|
+
if (WHITELIST_BY_SHORT_NAME.has(entry))
|
|
84171
|
+
return true;
|
|
84172
|
+
}
|
|
84173
|
+
}
|
|
84174
|
+
return false;
|
|
84175
|
+
}
|
|
84176
|
+
var _isRunningFromSource, _isBrowser;
|
|
84057
84177
|
var init_toolLoader = __esm(() => {
|
|
84058
84178
|
init_src();
|
|
84059
84179
|
init_src2();
|
|
84060
84180
|
init_esm();
|
|
84061
84181
|
init_storage();
|
|
84062
84182
|
init_toolService();
|
|
84183
|
+
init_globalNpmRoot();
|
|
84184
|
+
init_localWorkspace();
|
|
84063
84185
|
_isRunningFromSource = isRunningFromSource();
|
|
84064
84186
|
_isBrowser = !(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
84065
84187
|
});
|