@uipath/cli 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +138 -29
- 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.1",
|
|
47608
47608
|
description: "Cross platform CLI for UiPath",
|
|
47609
47609
|
repository: {
|
|
47610
47610
|
type: "git",
|
|
@@ -83729,6 +83729,47 @@ var init_tools = __esm(() => {
|
|
|
83729
83729
|
init_update2();
|
|
83730
83730
|
});
|
|
83731
83731
|
|
|
83732
|
+
// src/utils/localWorkspace.ts
|
|
83733
|
+
function isInsideNodeModules(dir) {
|
|
83734
|
+
const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
83735
|
+
return segments.includes("node_modules");
|
|
83736
|
+
}
|
|
83737
|
+
async function isLocalWorkspaceDir(dir) {
|
|
83738
|
+
const fs7 = getFileSystem();
|
|
83739
|
+
const pkgJsonPath = fs7.path.join(dir, "package.json");
|
|
83740
|
+
const [, exists] = await catchError(fs7.exists(pkgJsonPath));
|
|
83741
|
+
if (!exists)
|
|
83742
|
+
return false;
|
|
83743
|
+
const [, raw] = await catchError(fs7.readFile(pkgJsonPath, "utf-8"));
|
|
83744
|
+
if (!raw)
|
|
83745
|
+
return false;
|
|
83746
|
+
const [, pkg] = catchError(() => JSON.parse(raw));
|
|
83747
|
+
if (!pkg)
|
|
83748
|
+
return false;
|
|
83749
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
83750
|
+
return CLI_PACKAGE_NAME in deps || !!pkg.workspaces;
|
|
83751
|
+
}
|
|
83752
|
+
async function hasGoverningLocalProject(startDir) {
|
|
83753
|
+
const fs7 = getFileSystem();
|
|
83754
|
+
const { dirname: dirname3 } = fs7.path;
|
|
83755
|
+
let path4 = startDir;
|
|
83756
|
+
for (let i2 = 0;i2 < MAX_WALK_DEPTH; i2++) {
|
|
83757
|
+
if (!isInsideNodeModules(path4) && await isLocalWorkspaceDir(path4)) {
|
|
83758
|
+
return true;
|
|
83759
|
+
}
|
|
83760
|
+
const parent = dirname3(path4);
|
|
83761
|
+
if (parent === path4)
|
|
83762
|
+
break;
|
|
83763
|
+
path4 = parent;
|
|
83764
|
+
}
|
|
83765
|
+
return false;
|
|
83766
|
+
}
|
|
83767
|
+
var MAX_WALK_DEPTH = 10, CLI_PACKAGE_NAME = "@uipath/cli";
|
|
83768
|
+
var init_localWorkspace = __esm(() => {
|
|
83769
|
+
init_src();
|
|
83770
|
+
init_src2();
|
|
83771
|
+
});
|
|
83772
|
+
|
|
83732
83773
|
// src/services/installPath.ts
|
|
83733
83774
|
function createInstallPathResolver(toolsDir, isBrowser3) {
|
|
83734
83775
|
return async (packageName) => {
|
|
@@ -83741,32 +83782,13 @@ function createInstallPathResolver(toolsDir, isBrowser3) {
|
|
|
83741
83782
|
const { dirname: dirnameFn, join: joinFn } = fsLocal.path;
|
|
83742
83783
|
if (toolsDir) {
|
|
83743
83784
|
let path4 = dirnameFn(dirnameFn(toolsDir));
|
|
83744
|
-
while (
|
|
83785
|
+
while (isInsideNodeModules(path4)) {
|
|
83745
83786
|
const parent = dirnameFn(path4);
|
|
83746
83787
|
if (parent === path4)
|
|
83747
83788
|
break;
|
|
83748
83789
|
path4 = parent;
|
|
83749
83790
|
}
|
|
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
|
-
}
|
|
83791
|
+
const isGlobal = !await isLocalWorkspaceDir(path4);
|
|
83770
83792
|
logger.debug(`Install path resolved: ${path4} (global: ${isGlobal})`);
|
|
83771
83793
|
return { path: path4, global: isGlobal };
|
|
83772
83794
|
}
|
|
@@ -83786,9 +83808,9 @@ function createInstallPathResolver(toolsDir, isBrowser3) {
|
|
|
83786
83808
|
throw new Error("Unable to determine install location. No node_modules found in parent directories.");
|
|
83787
83809
|
};
|
|
83788
83810
|
}
|
|
83789
|
-
var insideNodeModules = (dir) => /[\\/]node_modules([\\/]|$)/.test(dir);
|
|
83790
83811
|
var init_installPath = __esm(() => {
|
|
83791
83812
|
init_src();
|
|
83813
|
+
init_localWorkspace();
|
|
83792
83814
|
});
|
|
83793
83815
|
|
|
83794
83816
|
// src/services/storage.ts
|
|
@@ -83845,6 +83867,70 @@ var init_storage = __esm(() => {
|
|
|
83845
83867
|
storage = new GeneralizedStorage;
|
|
83846
83868
|
});
|
|
83847
83869
|
|
|
83870
|
+
// src/utils/globalNpmRoot.ts
|
|
83871
|
+
async function getGlobalNpmUipathDir() {
|
|
83872
|
+
if (cachedLookup)
|
|
83873
|
+
return cachedLookup;
|
|
83874
|
+
cachedLookup = resolveGlobalNpmUipathDir();
|
|
83875
|
+
return cachedLookup;
|
|
83876
|
+
}
|
|
83877
|
+
async function resolveGlobalNpmUipathDir() {
|
|
83878
|
+
const root = await runNpmRootGlobal();
|
|
83879
|
+
if (!root) {
|
|
83880
|
+
logger.debug("npm root -g lookup failed; skipping global plugin fallback");
|
|
83881
|
+
return null;
|
|
83882
|
+
}
|
|
83883
|
+
const fs7 = getFileSystem();
|
|
83884
|
+
const candidate = fs7.path.join(root, "@uipath");
|
|
83885
|
+
const [existsError, exists] = await catchError(fs7.exists(candidate));
|
|
83886
|
+
if (existsError) {
|
|
83887
|
+
logger.debug(`fs.exists check failed for ${candidate}: ${String(existsError)}`);
|
|
83888
|
+
return null;
|
|
83889
|
+
}
|
|
83890
|
+
if (!exists) {
|
|
83891
|
+
logger.debug(`Global @uipath not present at ${candidate}`);
|
|
83892
|
+
return null;
|
|
83893
|
+
}
|
|
83894
|
+
logger.debug(`Global @uipath resolved via npm root -g: ${candidate}`);
|
|
83895
|
+
return candidate;
|
|
83896
|
+
}
|
|
83897
|
+
async function runNpmRootGlobal() {
|
|
83898
|
+
const { spawn: spawn2 } = await import("node:child_process");
|
|
83899
|
+
const isWindows = process.platform === "win32";
|
|
83900
|
+
return new Promise((resolve2) => {
|
|
83901
|
+
const proc = isWindows ? spawn2("npm", ["root", "-g"], {
|
|
83902
|
+
shell: true,
|
|
83903
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
83904
|
+
windowsHide: true
|
|
83905
|
+
}) : spawn2("npm", ["root", "-g"], {
|
|
83906
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
83907
|
+
});
|
|
83908
|
+
let stdout = "";
|
|
83909
|
+
proc.stdout?.on("data", (d) => {
|
|
83910
|
+
stdout += d.toString();
|
|
83911
|
+
});
|
|
83912
|
+
proc.stderr?.on("data", () => {});
|
|
83913
|
+
const timer = setTimeout(() => {
|
|
83914
|
+
proc.kill("SIGTERM");
|
|
83915
|
+
resolve2(null);
|
|
83916
|
+
}, NPM_ROOT_TIMEOUT_MS);
|
|
83917
|
+
proc.on("error", () => {
|
|
83918
|
+
clearTimeout(timer);
|
|
83919
|
+
resolve2(null);
|
|
83920
|
+
});
|
|
83921
|
+
proc.on("close", (code) => {
|
|
83922
|
+
clearTimeout(timer);
|
|
83923
|
+
const trimmed = stdout.trim();
|
|
83924
|
+
resolve2(code === 0 && trimmed ? trimmed : null);
|
|
83925
|
+
});
|
|
83926
|
+
});
|
|
83927
|
+
}
|
|
83928
|
+
var NPM_ROOT_TIMEOUT_MS = 5000, cachedLookup = null;
|
|
83929
|
+
var init_globalNpmRoot = __esm(() => {
|
|
83930
|
+
init_src();
|
|
83931
|
+
init_src2();
|
|
83932
|
+
});
|
|
83933
|
+
|
|
83848
83934
|
// src/utils/toolLoader.ts
|
|
83849
83935
|
function isRunningFromSource() {
|
|
83850
83936
|
const [error48, mainUrl] = catchError(() => import.meta.url);
|
|
@@ -84013,10 +84099,6 @@ async function discoverTools(toolsDirs) {
|
|
|
84013
84099
|
}
|
|
84014
84100
|
return tools;
|
|
84015
84101
|
}
|
|
84016
|
-
function isInsideNodeModules(dir) {
|
|
84017
|
-
const segments = dir.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
84018
|
-
return segments.includes("node_modules");
|
|
84019
|
-
}
|
|
84020
84102
|
async function findNearestToolsDir(startDir, seen) {
|
|
84021
84103
|
const fs7 = getFileSystem();
|
|
84022
84104
|
const { dirname: dirname3, join: join2 } = fs7.path;
|
|
@@ -84049,17 +84131,44 @@ async function resolveToolsDirs(cliFilePath, cwd) {
|
|
|
84049
84131
|
const { dirname: dirname3 } = fs7.path;
|
|
84050
84132
|
const seen = new Set;
|
|
84051
84133
|
const dirs = [];
|
|
84052
|
-
|
|
84134
|
+
const cliDir = dirname3(cliFilePath);
|
|
84135
|
+
dirs.push(...await findNearestToolsDir(cliDir, seen));
|
|
84053
84136
|
dirs.push(...await findNearestToolsDir(cwd, seen));
|
|
84137
|
+
if (!await hasGoverningLocalProject(cliDir) && !await dirsContainAnyPlugin(dirs)) {
|
|
84138
|
+
const globalUipath = await getGlobalNpmUipathDir();
|
|
84139
|
+
if (globalUipath && !seen.has(globalUipath)) {
|
|
84140
|
+
seen.add(globalUipath);
|
|
84141
|
+
dirs.push(globalUipath);
|
|
84142
|
+
}
|
|
84143
|
+
}
|
|
84054
84144
|
return dirs;
|
|
84055
84145
|
}
|
|
84056
|
-
|
|
84146
|
+
async function dirsContainAnyPlugin(dirs) {
|
|
84147
|
+
if (dirs.length === 0)
|
|
84148
|
+
return false;
|
|
84149
|
+
const fs7 = getFileSystem();
|
|
84150
|
+
for (const dir of dirs) {
|
|
84151
|
+
const [error48, entries] = await catchError(fs7.readdir(dir));
|
|
84152
|
+
if (error48) {
|
|
84153
|
+
logger.debug(`fs.readdir failed for ${dir}: ${String(error48)}`);
|
|
84154
|
+
continue;
|
|
84155
|
+
}
|
|
84156
|
+
for (const entry of entries) {
|
|
84157
|
+
if (WHITELIST_BY_SHORT_NAME.has(entry))
|
|
84158
|
+
return true;
|
|
84159
|
+
}
|
|
84160
|
+
}
|
|
84161
|
+
return false;
|
|
84162
|
+
}
|
|
84163
|
+
var _isRunningFromSource, _isBrowser;
|
|
84057
84164
|
var init_toolLoader = __esm(() => {
|
|
84058
84165
|
init_src();
|
|
84059
84166
|
init_src2();
|
|
84060
84167
|
init_esm();
|
|
84061
84168
|
init_storage();
|
|
84062
84169
|
init_toolService();
|
|
84170
|
+
init_globalNpmRoot();
|
|
84171
|
+
init_localWorkspace();
|
|
84063
84172
|
_isRunningFromSource = isRunningFromSource();
|
|
84064
84173
|
_isBrowser = !(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
84065
84174
|
});
|