@uipath/packager-tool-functions 1.202.0 → 1.203.0-preview.160

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.
@@ -5,4 +5,16 @@ compiled into its `dist/` output rather than installed alongside it.
5
5
  Their licences and copyright notices are reproduced here in full, as
6
6
  those licences require.
7
7
 
8
- No third-party code is bundled into this package.
8
+ 1 bundled dependency:
9
+
10
+ - @uipath/coded-functions-js-packager@0.1.10 — see below
11
+
12
+ ---
13
+
14
+ ## @uipath/coded-functions-js-packager@0.1.10
15
+
16
+ SPDX:
17
+
18
+ The upstream package ships no licence file here; `` is the
19
+ licence it is distributed under. The canonical text of that licence
20
+ applies, with copyright held by the package's authors.
package/dist/index.js CHANGED
@@ -11,34 +11,110 @@ import {
11
11
  } from "@uipath/solutionpackager-tool-core";
12
12
 
13
13
  // ../../../node_modules/@uipath/coded-functions-js-packager/dist/index.js
14
- var EXCLUDED_NAMES = new Set([
15
- "node_modules",
16
- ".git",
17
- ".env",
18
- ".deno",
19
- "dist",
20
- ".uipath"
21
- ]);
22
- var EXCLUDED_EXTENSIONS = [".nupkg"];
23
- var NPMRC = ".npmrc";
24
- var UIPATH_SCOPE = "@uipath:";
14
+ var npm = { name: "npm", lockFile: "package-lock.json", installHint: "npm install" };
15
+ var bun = { name: "bun", lockFile: "bun.lock", installHint: "bun install" };
16
+ var SUPPORTED_MANAGERS = [npm, bun];
17
+ var RECOGNIZED_UNSUPPORTED_LOCK_FILES = ["yarn.lock", "pnpm-lock.yaml", "bun.lockb"];
18
+ function detectPackageManager(present) {
19
+ const supported = SUPPORTED_MANAGERS.filter((manager) => present.has(manager.lockFile));
20
+ if (supported.length > 1)
21
+ return { kind: "ambiguous", managers: supported };
22
+ if (supported.length === 1)
23
+ return { kind: "found", manager: supported[0] };
24
+ const unsupported = RECOGNIZED_UNSUPPORTED_LOCK_FILES.filter((name) => present.has(name));
25
+ return unsupported.length > 0 ? { kind: "unsupported", fileNames: unsupported } : { kind: "none" };
26
+ }
27
+ var CANDIDATE_LOCK_FILES = [
28
+ ...SUPPORTED_MANAGERS.map((manager) => manager.lockFile),
29
+ ...RECOGNIZED_UNSUPPORTED_LOCK_FILES
30
+ ];
31
+ async function probeLockFiles(reader) {
32
+ const present = new Set;
33
+ for (const fileName of CANDIDATE_LOCK_FILES) {
34
+ if (await reader.fileExists(fileName))
35
+ present.add(fileName);
36
+ }
37
+ return present;
38
+ }
39
+ function supportedLockFilesLabel() {
40
+ return SUPPORTED_MANAGERS.map((manager) => `${manager.lockFile} (${manager.name})`).join(" or ");
41
+ }
42
+ function describeDependencyProblem(detection) {
43
+ const defaultHint = SUPPORTED_MANAGERS[0].installHint;
44
+ switch (detection.kind) {
45
+ case "none":
46
+ return {
47
+ problem: `No dependency lock file found; expected ${supportedLockFilesLabel()}.`,
48
+ remedyCommand: defaultHint
49
+ };
50
+ case "unsupported": {
51
+ const names = detection.fileNames.join(" and ");
52
+ return {
53
+ problem: `Found ${names}, which cannot be installed from; expected ${supportedLockFilesLabel()}. ` + `Create a supported lock file, then delete ${names}.`,
54
+ remedyCommand: defaultHint
55
+ };
56
+ }
57
+ case "ambiguous":
58
+ return {
59
+ 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.`,
60
+ remedyCommand: null
61
+ };
62
+ }
63
+ }
64
+ var REGISTRY_CONFIG_FILE = ".npmrc";
65
+ function isRegistryConfigFile(fileName) {
66
+ return fileName === REGISTRY_CONFIG_FILE;
67
+ }
25
68
  var CREDENTIAL_KEYS = ["_authtoken", "_auth", "_password"];
26
69
  function isComment(line) {
27
70
  return line === "" || line.startsWith("#") || line.startsWith(";");
28
71
  }
29
- function isOurs(line) {
72
+ function settingKey(line) {
30
73
  const trimmed = line.trim();
31
74
  if (isComment(trimmed))
32
- return false;
33
- const key = (trimmed.split("=")[0] ?? "").trim().toLowerCase();
34
- return key.startsWith(UIPATH_SCOPE) || CREDENTIAL_KEYS.some((c) => key.endsWith(c));
75
+ return null;
76
+ return (trimmed.split("=")[0] ?? "").trim().toLowerCase();
35
77
  }
36
- function sanitizeNpmrc(content) {
37
- const kept = content.split(/\r?\n/).filter((line) => !isOurs(line));
78
+ function sanitizeRegistryConfig(content, stripScopes) {
79
+ const stripped = stripScopes.map((scope) => `${scope.replace(/:$/, "")}:`.toLowerCase());
80
+ const kept = content.split(/\r?\n/).filter((line) => {
81
+ const key = settingKey(line);
82
+ if (key === null)
83
+ return true;
84
+ if (stripped.some((scope) => key.startsWith(scope)))
85
+ return false;
86
+ return !CREDENTIAL_KEYS.some((credential) => key.endsWith(credential));
87
+ });
38
88
  return kept.some((line) => !isComment(line.trim())) ? kept.join(`
39
89
  `) : null;
40
90
  }
41
- var LOCK_FILES = new Set(["bun.lock", "package-lock.json", "deno.lock", "yarn.lock"]);
91
+ function ifsProjectFileReader(fs, projectPath) {
92
+ return {
93
+ async fileExists(fileName) {
94
+ try {
95
+ return await fs.exists(fs.path.join(projectPath, fileName));
96
+ } catch {
97
+ return false;
98
+ }
99
+ },
100
+ async readFile(fileName) {
101
+ const content = await fs.readFile(fs.path.join(projectPath, fileName), "utf-8");
102
+ if (content === null)
103
+ throw new Error(`${fileName} not found in ${projectPath}.`);
104
+ return content;
105
+ }
106
+ };
107
+ }
108
+ var EXCLUDED_NAMES = new Set([
109
+ "node_modules",
110
+ ".git",
111
+ ".env",
112
+ ".deno",
113
+ "dist",
114
+ ".uipath"
115
+ ]);
116
+ var EXCLUDED_EXTENSIONS = [".nupkg"];
117
+ var SCOPES_NOT_PACKAGED = ["@uipath"];
42
118
  async function buildFunctionsPackage(fs, options) {
43
119
  const { projectPath, outputPath, projectStorageId } = options;
44
120
  const contentPath = fs.path.join(outputPath, "content");
@@ -62,8 +138,16 @@ async function buildFunctionsPackage(fs, options) {
62
138
  const packageJsonRaw = await fs.readFile(fs.path.join(projectPath, "package.json"), "utf-8");
63
139
  const packageDependencies = packageJsonRaw ? JSON.parse(packageJsonRaw).dependencies ?? {} : {};
64
140
  const targetRuntime = detectRuntime(uipathJson.functions);
65
- const includeLockFile = options.excludeLockFile ? false : uipathJson.packOptions?.includeLockFile ?? true;
66
- await copyProjectFiles(fs, projectPath, contentPath, includeLockFile, uipathJson.packOptions);
141
+ const detection = detectPackageManager(await probeLockFiles(ifsProjectFileReader(fs, projectPath)));
142
+ if (detection.kind !== "found") {
143
+ const { problem, remedyCommand } = describeDependencyProblem(detection);
144
+ throw new Error(remedyCommand !== null ? `${problem} Run '${remedyCommand}' in the project, then pack again.` : `${problem} Then pack again.`);
145
+ }
146
+ const lockFile = detection.manager.lockFile;
147
+ if (uipathJson.packOptions?.includeLockFile === false) {
148
+ console.warn(`uipath.json packOptions.includeLockFile is ignored: ${lockFile} is always packaged.`);
149
+ }
150
+ await copyProjectFiles(fs, projectPath, contentPath, lockFile, uipathJson.packOptions);
67
151
  const operateJson = {
68
152
  $schema: "https://cloud.uipath.com/draft/2024-12/operate",
69
153
  projectId: projectStorageId,
@@ -109,9 +193,10 @@ function detectRuntime(functions) {
109
193
  return "python";
110
194
  return "javascript";
111
195
  }
112
- async function copyProjectFiles(fs, sourcePath, destPath, includeLockFile, packOptions) {
196
+ async function copyProjectFiles(fs, sourcePath, destPath, lockFile, packOptions) {
113
197
  const extraExcludedDirs = new Set(packOptions?.directoriesExcluded ?? []);
114
198
  const extraExcludedFiles = new Set(packOptions?.filesExcluded ?? []);
199
+ const otherLockFiles = new Set(CANDIDATE_LOCK_FILES.filter((name) => name !== lockFile));
115
200
  async function walk(src, dest) {
116
201
  await fs.mkdir(dest);
117
202
  const entries = await fs.readdir(src);
@@ -124,15 +209,16 @@ async function copyProjectFiles(fs, sourcePath, destPath, includeLockFile, packO
124
209
  continue;
125
210
  if (EXCLUDED_EXTENSIONS.some((ext) => name.endsWith(ext)))
126
211
  continue;
127
- if (!includeLockFile && LOCK_FILES.has(name))
212
+ if (otherLockFiles.has(name))
128
213
  continue;
129
214
  const srcEntry = fs.path.join(src, name);
130
215
  const destEntry = fs.path.join(dest, name);
131
216
  const stat = await fs.stat(srcEntry);
132
217
  if (stat?.isDirectory()) {
133
218
  await walk(srcEntry, destEntry);
134
- } else if (name === NPMRC) {
135
- const sanitized = sanitizeNpmrc(await fs.readFile(srcEntry, "utf-8") ?? "");
219
+ } else if (isRegistryConfigFile(name)) {
220
+ const raw = await fs.readFile(srcEntry, "utf-8") ?? "";
221
+ const sanitized = sanitizeRegistryConfig(raw, SCOPES_NOT_PACKAGED);
136
222
  if (sanitized !== null)
137
223
  await fs.writeFile(destEntry, sanitized);
138
224
  } else if (stat?.isFile()) {
@@ -449,4 +535,4 @@ export {
449
535
  Languages
450
536
  };
451
537
 
452
- //# debugId=79823B003B2CADC564756E2164756E21
538
+ //# debugId=F5FA45901B1BE10264756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/packager-tool-functions",
3
- "version": "1.202.0",
3
+ "version": "1.203.0-preview.160",
4
4
  "description": "UiPath Functions tool implementation",
5
5
  "type": "module",
6
6
  "exports": {
@@ -18,10 +18,10 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "author": "",
21
+ "author": "UiPath",
22
22
  "license": "SEE LICENSE IN LICENSE.txt",
23
23
  "peerDependencies": {
24
- "@uipath/solutionpackager-tool-core": "1.202.0"
24
+ "@uipath/solutionpackager-tool-core": "1.203.0"
25
25
  },
26
- "gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
26
+ "gitHead": "3a42062ba731afca4595ba9aa8a80afc9667528d"
27
27
  }