@uipath/function-tool 1.202.0-preview.155 → 1.202.0-preview.157

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __require
3
- } from "./packager-tool-1bx83sw4.js";
3
+ } from "./packager-tool-1de529jm.js";
4
4
 
5
5
  // ../../node_modules/fflate/esm/index.mjs
6
6
  import { createRequire } from "module";
@@ -1884,34 +1884,110 @@ if (!_global[REGISTRY_KEY]) {
1884
1884
  var toolsFactoryRepository = _global[REGISTRY_KEY];
1885
1885
 
1886
1886
  // ../packager/packager-tool-functions/dist/index.js
1887
- var EXCLUDED_NAMES = new Set([
1888
- "node_modules",
1889
- ".git",
1890
- ".env",
1891
- ".deno",
1892
- "dist",
1893
- ".uipath"
1894
- ]);
1895
- var EXCLUDED_EXTENSIONS = [".nupkg"];
1896
- var NPMRC = ".npmrc";
1897
- var UIPATH_SCOPE = "@uipath:";
1887
+ var npm = { name: "npm", lockFile: "package-lock.json", installHint: "npm install" };
1888
+ var bun = { name: "bun", lockFile: "bun.lock", installHint: "bun install" };
1889
+ var SUPPORTED_MANAGERS = [npm, bun];
1890
+ var RECOGNIZED_UNSUPPORTED_LOCK_FILES = ["yarn.lock", "pnpm-lock.yaml", "bun.lockb"];
1891
+ function detectPackageManager(present) {
1892
+ const supported = SUPPORTED_MANAGERS.filter((manager) => present.has(manager.lockFile));
1893
+ if (supported.length > 1)
1894
+ return { kind: "ambiguous", managers: supported };
1895
+ if (supported.length === 1)
1896
+ return { kind: "found", manager: supported[0] };
1897
+ const unsupported = RECOGNIZED_UNSUPPORTED_LOCK_FILES.filter((name) => present.has(name));
1898
+ return unsupported.length > 0 ? { kind: "unsupported", fileNames: unsupported } : { kind: "none" };
1899
+ }
1900
+ var CANDIDATE_LOCK_FILES = [
1901
+ ...SUPPORTED_MANAGERS.map((manager) => manager.lockFile),
1902
+ ...RECOGNIZED_UNSUPPORTED_LOCK_FILES
1903
+ ];
1904
+ async function probeLockFiles(reader) {
1905
+ const present = new Set;
1906
+ for (const fileName of CANDIDATE_LOCK_FILES) {
1907
+ if (await reader.fileExists(fileName))
1908
+ present.add(fileName);
1909
+ }
1910
+ return present;
1911
+ }
1912
+ function supportedLockFilesLabel() {
1913
+ return SUPPORTED_MANAGERS.map((manager) => `${manager.lockFile} (${manager.name})`).join(" or ");
1914
+ }
1915
+ function describeDependencyProblem(detection) {
1916
+ const defaultHint = SUPPORTED_MANAGERS[0].installHint;
1917
+ switch (detection.kind) {
1918
+ case "none":
1919
+ return {
1920
+ problem: `No dependency lock file found; expected ${supportedLockFilesLabel()}.`,
1921
+ remedyCommand: defaultHint
1922
+ };
1923
+ case "unsupported": {
1924
+ const names = detection.fileNames.join(" and ");
1925
+ return {
1926
+ problem: `Found ${names}, which cannot be installed from; expected ${supportedLockFilesLabel()}. ` + `Create a supported lock file, then delete ${names}.`,
1927
+ remedyCommand: defaultHint
1928
+ };
1929
+ }
1930
+ case "ambiguous":
1931
+ return {
1932
+ problem: `Found ${detection.managers.map((manager) => manager.lockFile).join(" and ")}. Keep exactly one: ` + `with two lock files the installer that runs on the pod picks one and the other's resolution ` + `is silently ignored.`,
1933
+ remedyCommand: null
1934
+ };
1935
+ }
1936
+ }
1937
+ var REGISTRY_CONFIG_FILE = ".npmrc";
1938
+ function isRegistryConfigFile(fileName) {
1939
+ return fileName === REGISTRY_CONFIG_FILE;
1940
+ }
1898
1941
  var CREDENTIAL_KEYS = ["_authtoken", "_auth", "_password"];
1899
1942
  function isComment(line) {
1900
1943
  return line === "" || line.startsWith("#") || line.startsWith(";");
1901
1944
  }
1902
- function isOurs(line) {
1945
+ function settingKey(line) {
1903
1946
  const trimmed = line.trim();
1904
1947
  if (isComment(trimmed))
1905
- return false;
1906
- const key = (trimmed.split("=")[0] ?? "").trim().toLowerCase();
1907
- return key.startsWith(UIPATH_SCOPE) || CREDENTIAL_KEYS.some((c) => key.endsWith(c));
1948
+ return null;
1949
+ return (trimmed.split("=")[0] ?? "").trim().toLowerCase();
1908
1950
  }
1909
- function sanitizeNpmrc(content) {
1910
- const kept = content.split(/\r?\n/).filter((line) => !isOurs(line));
1951
+ function sanitizeRegistryConfig(content, stripScopes) {
1952
+ const stripped = stripScopes.map((scope) => `${scope.replace(/:$/, "")}:`.toLowerCase());
1953
+ const kept = content.split(/\r?\n/).filter((line) => {
1954
+ const key = settingKey(line);
1955
+ if (key === null)
1956
+ return true;
1957
+ if (stripped.some((scope) => key.startsWith(scope)))
1958
+ return false;
1959
+ return !CREDENTIAL_KEYS.some((credential) => key.endsWith(credential));
1960
+ });
1911
1961
  return kept.some((line) => !isComment(line.trim())) ? kept.join(`
1912
1962
  `) : null;
1913
1963
  }
1914
- var LOCK_FILES = new Set(["bun.lock", "package-lock.json", "deno.lock", "yarn.lock"]);
1964
+ function ifsProjectFileReader(fs, projectPath) {
1965
+ return {
1966
+ async fileExists(fileName) {
1967
+ try {
1968
+ return await fs.exists(fs.path.join(projectPath, fileName));
1969
+ } catch {
1970
+ return false;
1971
+ }
1972
+ },
1973
+ async readFile(fileName) {
1974
+ const content = await fs.readFile(fs.path.join(projectPath, fileName), "utf-8");
1975
+ if (content === null)
1976
+ throw new Error(`${fileName} not found in ${projectPath}.`);
1977
+ return content;
1978
+ }
1979
+ };
1980
+ }
1981
+ var EXCLUDED_NAMES = new Set([
1982
+ "node_modules",
1983
+ ".git",
1984
+ ".env",
1985
+ ".deno",
1986
+ "dist",
1987
+ ".uipath"
1988
+ ]);
1989
+ var EXCLUDED_EXTENSIONS = [".nupkg"];
1990
+ var SCOPES_NOT_PACKAGED = ["@uipath"];
1915
1991
  async function buildFunctionsPackage(fs, options) {
1916
1992
  const { projectPath, outputPath, projectStorageId } = options;
1917
1993
  const contentPath = fs.path.join(outputPath, "content");
@@ -1935,8 +2011,16 @@ async function buildFunctionsPackage(fs, options) {
1935
2011
  const packageJsonRaw = await fs.readFile(fs.path.join(projectPath, "package.json"), "utf-8");
1936
2012
  const packageDependencies = packageJsonRaw ? JSON.parse(packageJsonRaw).dependencies ?? {} : {};
1937
2013
  const targetRuntime = detectRuntime(uipathJson.functions);
1938
- const includeLockFile = options.excludeLockFile ? false : uipathJson.packOptions?.includeLockFile ?? true;
1939
- await copyProjectFiles(fs, projectPath, contentPath, includeLockFile, uipathJson.packOptions);
2014
+ const detection = detectPackageManager(await probeLockFiles(ifsProjectFileReader(fs, projectPath)));
2015
+ if (detection.kind !== "found") {
2016
+ const { problem, remedyCommand } = describeDependencyProblem(detection);
2017
+ throw new Error(remedyCommand !== null ? `${problem} Run '${remedyCommand}' in the project, then pack again.` : `${problem} Then pack again.`);
2018
+ }
2019
+ const lockFile = detection.manager.lockFile;
2020
+ if (uipathJson.packOptions?.includeLockFile === false) {
2021
+ console.warn(`uipath.json packOptions.includeLockFile is ignored: ${lockFile} is always packaged.`);
2022
+ }
2023
+ await copyProjectFiles(fs, projectPath, contentPath, lockFile, uipathJson.packOptions);
1940
2024
  const operateJson = {
1941
2025
  $schema: "https://cloud.uipath.com/draft/2024-12/operate",
1942
2026
  projectId: projectStorageId,
@@ -1982,9 +2066,10 @@ function detectRuntime(functions) {
1982
2066
  return "python";
1983
2067
  return "javascript";
1984
2068
  }
1985
- async function copyProjectFiles(fs, sourcePath, destPath, includeLockFile, packOptions) {
2069
+ async function copyProjectFiles(fs, sourcePath, destPath, lockFile, packOptions) {
1986
2070
  const extraExcludedDirs = new Set(packOptions?.directoriesExcluded ?? []);
1987
2071
  const extraExcludedFiles = new Set(packOptions?.filesExcluded ?? []);
2072
+ const otherLockFiles = new Set(CANDIDATE_LOCK_FILES.filter((name) => name !== lockFile));
1988
2073
  async function walk(src, dest) {
1989
2074
  await fs.mkdir(dest);
1990
2075
  const entries = await fs.readdir(src);
@@ -1997,15 +2082,16 @@ async function copyProjectFiles(fs, sourcePath, destPath, includeLockFile, packO
1997
2082
  continue;
1998
2083
  if (EXCLUDED_EXTENSIONS.some((ext) => name.endsWith(ext)))
1999
2084
  continue;
2000
- if (!includeLockFile && LOCK_FILES.has(name))
2085
+ if (otherLockFiles.has(name))
2001
2086
  continue;
2002
2087
  const srcEntry = fs.path.join(src, name);
2003
2088
  const destEntry = fs.path.join(dest, name);
2004
2089
  const stat = await fs.stat(srcEntry);
2005
2090
  if (stat?.isDirectory()) {
2006
2091
  await walk(srcEntry, destEntry);
2007
- } else if (name === NPMRC) {
2008
- const sanitized = sanitizeNpmrc(await fs.readFile(srcEntry, "utf-8") ?? "");
2092
+ } else if (isRegistryConfigFile(name)) {
2093
+ const raw = await fs.readFile(srcEntry, "utf-8") ?? "";
2094
+ const sanitized = sanitizeRegistryConfig(raw, SCOPES_NOT_PACKAGED);
2009
2095
  if (sanitized !== null)
2010
2096
  await fs.writeFile(destEntry, sanitized);
2011
2097
  } else if (stat?.isFile()) {
@@ -2312,7 +2398,7 @@ function createManifestGeneratingFunctionsToolFactory() {
2312
2398
  if (language === Languages.JavaScript) {
2313
2399
  this.logger.progress("Generating Functions manifests...");
2314
2400
  try {
2315
- const { generateManifests } = await import("./cliRunner-gtb0dftd.js");
2401
+ const { generateManifests } = await import("./cliRunner-bxxtxqc3.js");
2316
2402
  await generateManifests(options.projectPath);
2317
2403
  } catch (error) {
2318
2404
  const errorMessage = error instanceof Error ? error.toString() : String(error);
@@ -2340,4 +2426,4 @@ export {
2340
2426
  registerPackagerFactories
2341
2427
  };
2342
2428
 
2343
- //# debugId=F1DD9E77602436F664756E2164756E21
2429
+ //# debugId=EFD595DCE5DAE45864756E2164756E21