@uipath/packager-tool-webapp 1.196.0 → 1.197.0-preview.65

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 CHANGED
@@ -1,11 +1,10 @@
1
- // src/index.ts
2
- import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
3
-
4
- // src/webapp-tool-factory.ts
5
- import {
6
- ProjectTypes as ProjectTypes3
7
- } from "@uipath/solutionpackager-tool-core";
8
-
1
+ // src/models/webapp-manifest.ts
2
+ var WebAppVariantType;
3
+ ((WebAppVariantType2) => {
4
+ WebAppVariantType2["Coded"] = "Coded";
5
+ WebAppVariantType2["JS"] = "JS";
6
+ })(WebAppVariantType ||= {});
7
+ var WEBAPP_MANIFEST_FILE_NAME = "webAppManifest.json";
9
8
  // src/webapp-tool.ts
10
9
  import {
11
10
  Path as Path5,
@@ -40,19 +39,11 @@ var ERROR_MESSAGES = {
40
39
  OUTPUT_PATH_REQUIRED: "Output path is required"
41
40
  };
42
41
 
43
- // src/models/webapp-manifest.ts
44
- var WebAppVariantType;
45
- ((WebAppVariantType2) => {
46
- WebAppVariantType2["Coded"] = "Coded";
47
- WebAppVariantType2["JS"] = "JS";
48
- })(WebAppVariantType ||= {});
49
- var WEBAPP_MANIFEST_FILE_NAME = "webAppManifest.json";
50
-
51
42
  // src/strategies/coded-app-strategy.ts
52
43
  import {
53
44
  NugetConstants,
54
45
  NugetPackager,
55
- Path as Path2,
46
+ Path as Path3,
56
47
  ProjectTypes,
57
48
  TargetFramework
58
49
  } from "@uipath/solutionpackager-tool-core";
@@ -77,6 +68,41 @@ async function copyDirectoryAsync(fileSystem, sourcePath, destinationPath) {
77
68
  }
78
69
  }
79
70
 
71
+ // src/utils/manifest-loader.ts
72
+ import { Path as Path2 } from "@uipath/solutionpackager-tool-core";
73
+ async function loadWebAppManifest(fileSystem, projectPath) {
74
+ const manifestPath = Path2.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
75
+ const exists = await fileSystem.exists(manifestPath);
76
+ if (!exists) {
77
+ return null;
78
+ }
79
+ const content = await fileSystem.readFile(manifestPath);
80
+ if (!content) {
81
+ return null;
82
+ }
83
+ try {
84
+ const text = new TextDecoder().decode(content);
85
+ const manifest = JSON.parse(text);
86
+ return manifest;
87
+ } catch (error) {
88
+ throw new Error(`Failed to parse ${WEBAPP_MANIFEST_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
89
+ }
90
+ }
91
+ async function ensureWebAppProjectId(fileSystem, projectPath) {
92
+ const manifest = await loadWebAppManifest(fileSystem, projectPath);
93
+ if (manifest && typeof manifest.projectId === "string" && manifest.projectId.length > 0) {
94
+ return manifest.projectId;
95
+ }
96
+ const id = crypto.randomUUID();
97
+ if (manifest) {
98
+ const updated = { ...manifest, projectId: id };
99
+ const manifestPath = Path2.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
100
+ await fileSystem.writeFile(manifestPath, `${JSON.stringify(updated, null, 2)}
101
+ `);
102
+ }
103
+ return id;
104
+ }
105
+
80
106
  // src/strategies/coded-app-strategy.ts
81
107
  class CodedAppStrategy {
82
108
  fileSystem;
@@ -92,7 +118,7 @@ class CodedAppStrategy {
92
118
  }
93
119
  const isCompiled = typed.config?.isCompiled ?? true;
94
120
  if (isCompiled) {
95
- const fullBundlePath = Path2.join(projectPath, bundlePath);
121
+ const fullBundlePath = Path3.join(projectPath, bundlePath);
96
122
  const exists = await this.fileSystem.exists(fullBundlePath);
97
123
  if (!exists) {
98
124
  const message = ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath);
@@ -112,7 +138,7 @@ class CodedAppStrategy {
112
138
  bundlePath = DEFAULT_BUNDLE_PATH;
113
139
  }
114
140
  const isCompiled = manifest.config?.isCompiled ?? true;
115
- const fullBundlePath = Path2.join(projectPath, bundlePath);
141
+ const fullBundlePath = Path3.join(projectPath, bundlePath);
116
142
  if (isCompiled) {
117
143
  logger?.progress("Validating compiled bundle...");
118
144
  const bundleExists = await this.fileSystem.exists(fullBundlePath);
@@ -127,8 +153,8 @@ class CodedAppStrategy {
127
153
  logger?.info("Build mode (isCompiled=false) is not yet implemented in v1.");
128
154
  throw new Error(ERROR_MESSAGES.BUILD_NOT_SUPPORTED);
129
155
  }
130
- const localBuildFolder = Path2.join(outputPath, NugetConstants.OutputFolderName);
131
- const contentFolder = Path2.join(localBuildFolder, NugetConstants.ContentFolderName);
156
+ const localBuildFolder = Path3.join(outputPath, NugetConstants.OutputFolderName);
157
+ const contentFolder = Path3.join(localBuildFolder, NugetConstants.ContentFolderName);
132
158
  await this.fileSystem.mkdir(contentFolder);
133
159
  try {
134
160
  logger?.progress("Copying bundle to content folder...");
@@ -137,7 +163,7 @@ class CodedAppStrategy {
137
163
  await this.prepareMetadataFiles(localBuildFolder, contentFolder, packageInfo, manifest, projectPath);
138
164
  logger?.progress("Creating NuGet package...");
139
165
  const nupkgFileName = `${packageInfo.id}.${packageInfo.version}.nupkg`;
140
- const nupkgPath = Path2.join(outputPath, nupkgFileName);
166
+ const nupkgPath = Path3.join(outputPath, nupkgFileName);
141
167
  const packager = new NugetPackager(this.fileSystem);
142
168
  const result = await packager.packAsync(localBuildFolder, packageInfo, nupkgPath);
143
169
  logger?.info(`Package created successfully: ${result.outputPath}`);
@@ -150,23 +176,23 @@ class CodedAppStrategy {
150
176
  }
151
177
  }
152
178
  }
153
- async prepareMetadataFiles(_localBuildFolder, contentFolder, packageInfo, _manifest, projectPath) {
179
+ async prepareMetadataFiles(_localBuildFolder, contentFolder, _packageInfo, _manifest, projectPath) {
154
180
  let mainFile = "index.html";
155
- const indexHtmlPath = Path2.join(contentFolder, "index.html");
181
+ const indexHtmlPath = Path3.join(contentFolder, "index.html");
156
182
  const indexHtmlExists = await this.fileSystem.exists(indexHtmlPath);
157
183
  if (!indexHtmlExists) {
158
184
  const possibleEntries = ["index.html", "main.html", "app.html"];
159
185
  for (const entry of possibleEntries) {
160
- const entryPath = Path2.join(contentFolder, entry);
186
+ const entryPath = Path3.join(contentFolder, entry);
161
187
  if (await this.fileSystem.exists(entryPath)) {
162
188
  mainFile = entry;
163
189
  break;
164
190
  }
165
191
  }
166
192
  }
167
- const operatePath = Path2.join(contentFolder, NugetConstants.OperateFileName);
193
+ const operatePath = Path3.join(contentFolder, NugetConstants.OperateFileName);
168
194
  const operateModel = {
169
- projectId: packageInfo.id,
195
+ projectId: await ensureWebAppProjectId(this.fileSystem, projectPath),
170
196
  main: mainFile,
171
197
  contentType: ProjectTypes.WebApp,
172
198
  targetFramework: TargetFramework.Portable,
@@ -178,25 +204,25 @@ class CodedAppStrategy {
178
204
  };
179
205
  const operateJson = JSON.stringify(operateModel, null, 2);
180
206
  await this.fileSystem.writeFile(operatePath, operateJson);
181
- const manifestSourcePath = Path2.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
182
- const manifestDestPath = Path2.join(contentFolder, WEBAPP_MANIFEST_FILE_NAME);
207
+ const manifestSourcePath = Path3.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
208
+ const manifestDestPath = Path3.join(contentFolder, WEBAPP_MANIFEST_FILE_NAME);
183
209
  const manifestExists = await this.fileSystem.exists(manifestSourcePath);
184
210
  if (manifestExists) {
185
- const manifestContent = await this.fileSystem.readFile(manifestSourcePath);
211
+ const manifestContent = await this.fileSystem.readFile(manifestSourcePath, "utf-8");
186
212
  if (manifestContent) {
187
213
  await this.fileSystem.writeFile(manifestDestPath, manifestContent);
188
214
  }
189
215
  }
190
- const uipathJsonSourcePath = Path2.join(projectPath, "uipath.json");
191
- const uipathJsonDestPath = Path2.join(contentFolder, "uipath.json");
216
+ const uipathJsonSourcePath = Path3.join(projectPath, "uipath.json");
217
+ const uipathJsonDestPath = Path3.join(contentFolder, "uipath.json");
192
218
  const uipathJsonExists = await this.fileSystem.exists(uipathJsonSourcePath);
193
219
  if (uipathJsonExists) {
194
- const uipathJsonContent = await this.fileSystem.readFile(uipathJsonSourcePath);
220
+ const uipathJsonContent = await this.fileSystem.readFile(uipathJsonSourcePath, "utf-8");
195
221
  if (uipathJsonContent) {
196
222
  await this.fileSystem.writeFile(uipathJsonDestPath, uipathJsonContent);
197
223
  }
198
224
  }
199
- const bindingsPath = Path2.join(contentFolder, "bindings.json");
225
+ const bindingsPath = Path3.join(contentFolder, "bindings.json");
200
226
  const bindingsExists = await this.fileSystem.exists(bindingsPath);
201
227
  if (!bindingsExists) {
202
228
  const bindingsJson = JSON.stringify({
@@ -205,11 +231,11 @@ class CodedAppStrategy {
205
231
  }, null, 2);
206
232
  await this.fileSystem.writeFile(bindingsPath, bindingsJson);
207
233
  }
208
- const bindingsV2Path = Path2.join(contentFolder, "bindings_v2.json");
234
+ const bindingsV2Path = Path3.join(contentFolder, "bindings_v2.json");
209
235
  const bindingsCandidatePaths = [
210
- Path2.join(projectPath, "source", "bindings.json"),
211
- Path2.join(projectPath, "bindings.json"),
212
- Path2.join(projectPath, "bindings_v2.json")
236
+ Path3.join(projectPath, "source", "bindings.json"),
237
+ Path3.join(projectPath, "bindings.json"),
238
+ Path3.join(projectPath, "bindings_v2.json")
213
239
  ];
214
240
  let bindingsV2Json = null;
215
241
  for (const candidate of bindingsCandidatePaths) {
@@ -229,14 +255,14 @@ class CodedAppStrategy {
229
255
  }, null, 2);
230
256
  }
231
257
  await this.fileSystem.writeFile(bindingsV2Path, bindingsV2Json);
232
- const entryPointsPath = Path2.join(contentFolder, "entry-points.json");
233
- const projectEntryPointsPath = Path2.join(projectPath, "entry-points.json");
258
+ const entryPointsPath = Path3.join(contentFolder, "entry-points.json");
259
+ const projectEntryPointsPath = Path3.join(projectPath, "entry-points.json");
234
260
  let entryPointsContent;
235
261
  const projectEntryPointsExists = await this.fileSystem.exists(projectEntryPointsPath);
236
262
  if (projectEntryPointsExists) {
237
- const entryPointsData = await this.fileSystem.readFile(projectEntryPointsPath);
263
+ const entryPointsData = await this.fileSystem.readFile(projectEntryPointsPath, "utf-8");
238
264
  if (entryPointsData) {
239
- entryPointsContent = new TextDecoder().decode(entryPointsData);
265
+ entryPointsContent = entryPointsData;
240
266
  } else {
241
267
  entryPointsContent = this.createDefaultEntryPoints(mainFile);
242
268
  }
@@ -244,13 +270,13 @@ class CodedAppStrategy {
244
270
  entryPointsContent = this.createDefaultEntryPoints(mainFile);
245
271
  }
246
272
  await this.fileSystem.writeFile(entryPointsPath, entryPointsContent);
247
- const packageDescriptorPath = Path2.join(contentFolder, NugetConstants.PackageDescriptorFileName);
273
+ const packageDescriptorPath = Path3.join(contentFolder, NugetConstants.PackageDescriptorFileName);
248
274
  const packageDescriptor = {
249
275
  $schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor",
250
276
  files: {
251
- [NugetConstants.OperateFileName]: Path2.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName),
252
- "entry-points.json": Path2.join(NugetConstants.ContentFolderName, "entry-points.json"),
253
- "bindings.json": Path2.join(NugetConstants.ContentFolderName, "bindings_v2.json")
277
+ [NugetConstants.OperateFileName]: Path3.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName),
278
+ "entry-points.json": Path3.join(NugetConstants.ContentFolderName, "entry-points.json"),
279
+ "bindings.json": Path3.join(NugetConstants.ContentFolderName, "bindings_v2.json")
254
280
  }
255
281
  };
256
282
  const packageDescriptorJson = JSON.stringify(packageDescriptor, null, 2);
@@ -302,7 +328,7 @@ class CodedAppStrategy {
302
328
  import {
303
329
  NugetConstants as NugetConstants2,
304
330
  NugetPackager as NugetPackager2,
305
- Path as Path3,
331
+ Path as Path4,
306
332
  ProjectTypes as ProjectTypes2,
307
333
  TargetFramework as TargetFramework2
308
334
  } from "@uipath/solutionpackager-tool-core";
@@ -313,7 +339,7 @@ class JsAppsStrategy {
313
339
  }
314
340
  async validateAsync(args) {
315
341
  const { projectPath, logger } = args;
316
- const appFolder = Path3.join(projectPath, APP_FOLDER_NAME);
342
+ const appFolder = Path4.join(projectPath, APP_FOLDER_NAME);
317
343
  const exists = await this.fileSystem.exists(appFolder);
318
344
  if (!exists) {
319
345
  const message = ERROR_MESSAGES.APP_FOLDER_NOT_FOUND(appFolder);
@@ -337,7 +363,7 @@ class JsAppsStrategy {
337
363
  async packageAsync(args) {
338
364
  const { projectPath, manifest, outputPath, packageInfo, logger } = args;
339
365
  logger?.info(`Packaging JS variant: ${packageInfo.id}@${packageInfo.version}`);
340
- const appFolder = Path3.join(projectPath, APP_FOLDER_NAME);
366
+ const appFolder = Path4.join(projectPath, APP_FOLDER_NAME);
341
367
  logger?.progress("Validating .app folder...");
342
368
  const appFolderExists = await this.fileSystem.exists(appFolder);
343
369
  if (!appFolderExists) {
@@ -347,9 +373,9 @@ class JsAppsStrategy {
347
373
  if (!appFolderStat?.isDirectory()) {
348
374
  throw new Error(ERROR_MESSAGES.APP_FOLDER_NOT_DIRECTORY(appFolder));
349
375
  }
350
- const localBuildFolder = Path3.join(outputPath, NugetConstants2.OutputFolderName);
351
- const contentFolder = Path3.join(localBuildFolder, NugetConstants2.ContentFolderName);
352
- const contentAppFolder = Path3.join(contentFolder, CONTENT_APP_FOLDER_NAME);
376
+ const localBuildFolder = Path4.join(outputPath, NugetConstants2.OutputFolderName);
377
+ const contentFolder = Path4.join(localBuildFolder, NugetConstants2.ContentFolderName);
378
+ const contentAppFolder = Path4.join(contentFolder, CONTENT_APP_FOLDER_NAME);
353
379
  await this.fileSystem.mkdir(contentFolder);
354
380
  try {
355
381
  logger?.progress("Copying .app folder into content/app...");
@@ -358,7 +384,7 @@ class JsAppsStrategy {
358
384
  await this.prepareMetadataFiles(contentFolder, contentAppFolder, packageInfo, manifest, projectPath);
359
385
  logger?.progress("Creating NuGet package...");
360
386
  const nupkgFileName = `${packageInfo.id}.${packageInfo.version}.nupkg`;
361
- const nupkgPath = Path3.join(outputPath, nupkgFileName);
387
+ const nupkgPath = Path4.join(outputPath, nupkgFileName);
362
388
  const packager = new NugetPackager2(this.fileSystem);
363
389
  const result = await packager.packAsync(localBuildFolder, packageInfo, nupkgPath);
364
390
  logger?.info(`Package created successfully: ${result.outputPath}`);
@@ -371,12 +397,12 @@ class JsAppsStrategy {
371
397
  }
372
398
  }
373
399
  }
374
- async prepareMetadataFiles(contentFolder, contentAppFolder, packageInfo, _manifest, projectPath) {
400
+ async prepareMetadataFiles(contentFolder, _contentAppFolder, _packageInfo, _manifest, projectPath) {
375
401
  const mainFile = "index.html";
376
402
  const mainRelativeToContent = `${CONTENT_APP_FOLDER_NAME}/${mainFile}`;
377
- const operatePath = Path3.join(contentFolder, NugetConstants2.OperateFileName);
403
+ const operatePath = Path4.join(contentFolder, NugetConstants2.OperateFileName);
378
404
  const operateModel = {
379
- projectId: packageInfo.id,
405
+ projectId: await ensureWebAppProjectId(this.fileSystem, projectPath),
380
406
  main: mainRelativeToContent,
381
407
  contentType: ProjectTypes2.WebApp,
382
408
  targetFramework: TargetFramework2.Portable,
@@ -388,8 +414,8 @@ class JsAppsStrategy {
388
414
  };
389
415
  const operateJson = JSON.stringify(operateModel, null, 2);
390
416
  await this.fileSystem.writeFile(operatePath, operateJson);
391
- const manifestSourcePath = Path3.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
392
- const manifestDestPath = Path3.join(contentFolder, WEBAPP_MANIFEST_FILE_NAME);
417
+ const manifestSourcePath = Path4.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
418
+ const manifestDestPath = Path4.join(contentFolder, WEBAPP_MANIFEST_FILE_NAME);
393
419
  const manifestExists = await this.fileSystem.exists(manifestSourcePath);
394
420
  if (manifestExists) {
395
421
  const manifestContent = await this.fileSystem.readFile(manifestSourcePath);
@@ -397,8 +423,8 @@ class JsAppsStrategy {
397
423
  await this.fileSystem.writeFile(manifestDestPath, manifestContent);
398
424
  }
399
425
  }
400
- const uipathJsonSourcePath = Path3.join(projectPath, "uipath.json");
401
- const uipathJsonDestPath = Path3.join(contentFolder, "uipath.json");
426
+ const uipathJsonSourcePath = Path4.join(projectPath, "uipath.json");
427
+ const uipathJsonDestPath = Path4.join(contentFolder, "uipath.json");
402
428
  const uipathJsonExists = await this.fileSystem.exists(uipathJsonSourcePath);
403
429
  if (uipathJsonExists) {
404
430
  const uipathJsonContent = await this.fileSystem.readFile(uipathJsonSourcePath);
@@ -406,20 +432,20 @@ class JsAppsStrategy {
406
432
  await this.fileSystem.writeFile(uipathJsonDestPath, uipathJsonContent);
407
433
  }
408
434
  }
409
- const bindingsPath = Path3.join(contentFolder, "bindings.json");
435
+ const bindingsPath = Path4.join(contentFolder, "bindings.json");
410
436
  const bindingsExists = await this.fileSystem.exists(bindingsPath);
411
437
  if (!bindingsExists) {
412
438
  const bindingsJson = JSON.stringify({ version: "1.0", resources: [] }, null, 2);
413
439
  await this.fileSystem.writeFile(bindingsPath, bindingsJson);
414
440
  }
415
- const bindingsV2Path = Path3.join(contentFolder, "bindings_v2.json");
441
+ const bindingsV2Path = Path4.join(contentFolder, "bindings_v2.json");
416
442
  const bindingsV2Exists = await this.fileSystem.exists(bindingsV2Path);
417
443
  if (!bindingsV2Exists) {
418
444
  const bindingsV2Json = JSON.stringify({ version: "2.0", resources: [] }, null, 2);
419
445
  await this.fileSystem.writeFile(bindingsV2Path, bindingsV2Json);
420
446
  }
421
- const entryPointsPath = Path3.join(contentFolder, "entry-points.json");
422
- const projectEntryPointsPath = Path3.join(projectPath, "entry-points.json");
447
+ const entryPointsPath = Path4.join(contentFolder, "entry-points.json");
448
+ const projectEntryPointsPath = Path4.join(projectPath, "entry-points.json");
423
449
  let entryPointsContent;
424
450
  const projectEntryPointsExists = await this.fileSystem.exists(projectEntryPointsPath);
425
451
  if (projectEntryPointsExists) {
@@ -433,12 +459,12 @@ class JsAppsStrategy {
433
459
  entryPointsContent = this.createDefaultEntryPoints(mainRelativeToContent);
434
460
  }
435
461
  await this.fileSystem.writeFile(entryPointsPath, entryPointsContent);
436
- const packageDescriptorPath = Path3.join(contentFolder, NugetConstants2.PackageDescriptorFileName);
462
+ const packageDescriptorPath = Path4.join(contentFolder, NugetConstants2.PackageDescriptorFileName);
437
463
  const packageDescriptor = {
438
464
  files: {
439
- [NugetConstants2.OperateFileName]: Path3.join(NugetConstants2.ContentFolderName, NugetConstants2.OperateFileName),
440
- "entry-points.json": Path3.join(NugetConstants2.ContentFolderName, "entry-points.json"),
441
- "bindings.json": Path3.join(NugetConstants2.ContentFolderName, "bindings_v2.json")
465
+ [NugetConstants2.OperateFileName]: Path4.join(NugetConstants2.ContentFolderName, NugetConstants2.OperateFileName),
466
+ "entry-points.json": Path4.join(NugetConstants2.ContentFolderName, "entry-points.json"),
467
+ "bindings.json": Path4.join(NugetConstants2.ContentFolderName, "bindings_v2.json")
442
468
  }
443
469
  };
444
470
  const packageDescriptorJson = JSON.stringify(packageDescriptor, null, 2);
@@ -501,27 +527,6 @@ class VariantStrategyFactory {
501
527
  }
502
528
  }
503
529
 
504
- // src/utils/manifest-loader.ts
505
- import { Path as Path4 } from "@uipath/solutionpackager-tool-core";
506
- async function loadWebAppManifest(fileSystem, projectPath) {
507
- const manifestPath = Path4.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
508
- const exists = await fileSystem.exists(manifestPath);
509
- if (!exists) {
510
- return null;
511
- }
512
- const content = await fileSystem.readFile(manifestPath);
513
- if (!content) {
514
- return null;
515
- }
516
- try {
517
- const text = new TextDecoder().decode(content);
518
- const manifest = JSON.parse(text);
519
- return manifest;
520
- } catch (error) {
521
- throw new Error(`Failed to parse ${WEBAPP_MANIFEST_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
522
- }
523
- }
524
-
525
530
  // src/webapp-tool.ts
526
531
  class WebAppTool extends ProjectTool {
527
532
  _temporaryStorage;
@@ -658,20 +663,21 @@ class WebAppTool extends ProjectTool {
658
663
  };
659
664
  }
660
665
  }
661
-
662
666
  // src/webapp-tool-factory.ts
667
+ import {
668
+ ProjectTypes as ProjectTypes3
669
+ } from "@uipath/solutionpackager-tool-core";
663
670
  class WebAppToolFactory {
664
671
  supportedTypes = [ProjectTypes3.AppV2];
665
672
  async createAsync(logger, fileSystem) {
666
673
  return new WebAppTool(fileSystem, logger);
667
674
  }
668
675
  }
669
-
670
- // src/index.ts
671
- toolsFactoryRepository.registerProjectToolFactory(new WebAppToolFactory);
672
676
  export {
673
677
  WebAppVariantType,
674
678
  WebAppToolFactory,
675
679
  WebAppTool,
676
680
  WEBAPP_MANIFEST_FILE_NAME
677
681
  };
682
+
683
+ //# debugId=D42E6DA7B2DF063064756E2164756E21
@@ -34,6 +34,7 @@ export type WebAppManifest<T extends WebAppVariantType = WebAppVariantType> = {
34
34
  type: T;
35
35
  solutionResourceSubType: string;
36
36
  config?: ManifestConfigMap[T];
37
+ projectId?: string;
37
38
  };
38
39
  export declare const WEBAPP_MANIFEST_FILE_NAME = "webAppManifest.json";
39
40
  export {};
@@ -4,3 +4,8 @@ import type { WebAppManifest } from "../models/webapp-manifest.js";
4
4
  * Load and parse webAppManifest.json from project path
5
5
  */
6
6
  export declare function loadWebAppManifest(fileSystem: IFileSystem, projectPath: string): Promise<WebAppManifest | null>;
7
+ /**
8
+ * Resolve a stable projectId for a webapp, persisting it to
9
+ * webAppManifest.json so re-packs are stable.
10
+ */
11
+ export declare function ensureWebAppProjectId(fileSystem: IFileSystem, projectPath: string): Promise<string>;
package/package.json CHANGED
@@ -1,42 +1,31 @@
1
1
  {
2
- "name": "@uipath/packager-tool-webapp",
3
- "version": "1.196.0",
4
- "description": "UiPath WebApp tool implementation",
5
- "type": "module",
6
- "exports": {
7
- ".": {
8
- "source": "./src/index.ts",
9
- "default": "./dist/index.js"
10
- }
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/UiPath/cli.git",
15
- "directory": "packages/packager/packager-tool-webapp"
16
- },
17
- "publishConfig": {
18
- "registry": "https://registry.npmjs.org/"
19
- },
20
- "types": "./dist/index.d.ts",
21
- "files": [
22
- "dist",
23
- "!dist/**/*.map",
24
- "src"
25
- ],
26
- "author": "",
27
- "license": "ISC",
28
- "peerDependencies": {
29
- "@uipath/solutionpackager-tool-core": "1.196.0"
30
- },
31
- "devDependencies": {
32
- "@types/node": "^25.5.2",
33
- "@uipath/solutionpackager-tool-core": "1.196.0",
34
- "@vitest/browser": "^4.1.6",
35
- "@vitest/browser-playwright": "^4.1.6",
36
- "@vitest/coverage-v8": "^4.1.6",
37
- "playwright": "^1.57.0",
38
- "typescript": "^6.0.2",
39
- "vitest": "^4.1.6"
40
- },
41
- "gitHead": "bed2b46f1ec33a47a7dcae2e6d4b7ab99bd06981"
2
+ "name": "@uipath/packager-tool-webapp",
3
+ "version": "1.197.0-preview.65",
4
+ "description": "UiPath WebApp tool implementation",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "source": "./src/index.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/UiPath/cli.git",
15
+ "directory": "packages/packager/packager-tool-webapp"
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "author": "",
26
+ "license": "ISC",
27
+ "peerDependencies": {
28
+ "@uipath/solutionpackager-tool-core": "1.197.0"
29
+ },
30
+ "gitHead": "9388ccbe5e739c9578bfd9b5395980fb63e11d9c"
42
31
  }
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
2
- import { WebAppToolFactory } from "./webapp-tool-factory.js";
3
-
1
+ // WebApp tool factory. Consumers register it explicitly via
2
+ // `toolsFactoryRepository.registerProjectToolFactory(new WebAppToolFactory())`.
4
3
  export type { WebAppManifest } from "./models/webapp-manifest.js";
5
4
  export {
6
5
  WEBAPP_MANIFEST_FILE_NAME,
@@ -8,5 +7,3 @@ export {
8
7
  } from "./models/webapp-manifest.js";
9
8
  export { WebAppTool } from "./webapp-tool.js";
10
9
  export { WebAppToolFactory } from "./webapp-tool-factory.js";
11
-
12
- toolsFactoryRepository.registerProjectToolFactory(new WebAppToolFactory());
@@ -40,6 +40,7 @@ export type WebAppManifest<T extends WebAppVariantType = WebAppVariantType> = {
40
40
  type: T;
41
41
  solutionResourceSubType: string;
42
42
  config?: ManifestConfigMap[T];
43
+ projectId?: string;
43
44
  };
44
45
 
45
46
  export const WEBAPP_MANIFEST_FILE_NAME = "webAppManifest.json";
@@ -22,6 +22,7 @@ import {
22
22
  type WebAppVariantType,
23
23
  } from "../models/webapp-manifest.js";
24
24
  import { copyDirectoryAsync } from "../utils/fs-helpers.js";
25
+ import { ensureWebAppProjectId } from "../utils/manifest-loader.js";
25
26
  import type { PackageArgs, VariantStrategy } from "./variant-strategy.js";
26
27
 
27
28
  /**
@@ -179,7 +180,7 @@ export class CodedAppStrategy implements VariantStrategy {
179
180
  private async prepareMetadataFiles(
180
181
  _localBuildFolder: string,
181
182
  contentFolder: string,
182
- packageInfo: {
183
+ _packageInfo: {
183
184
  id: string;
184
185
  version: string;
185
186
  author?: string;
@@ -210,7 +211,10 @@ export class CodedAppStrategy implements VariantStrategy {
210
211
  NugetConstants.OperateFileName,
211
212
  );
212
213
  const operateModel: OperateFileModel & { targetRuntime: string } = {
213
- projectId: packageInfo.id,
214
+ projectId: await ensureWebAppProjectId(
215
+ this.fileSystem,
216
+ projectPath,
217
+ ),
214
218
  main: mainFile,
215
219
  contentType: ProjectTypes.WebApp,
216
220
  targetFramework: TargetFramework.Portable,
@@ -235,8 +239,10 @@ export class CodedAppStrategy implements VariantStrategy {
235
239
  );
236
240
  const manifestExists = await this.fileSystem.exists(manifestSourcePath);
237
241
  if (manifestExists) {
238
- const manifestContent =
239
- await this.fileSystem.readFile(manifestSourcePath);
242
+ const manifestContent = await this.fileSystem.readFile(
243
+ manifestSourcePath,
244
+ "utf-8",
245
+ );
240
246
  if (manifestContent) {
241
247
  await this.fileSystem.writeFile(
242
248
  manifestDestPath,
@@ -251,8 +257,10 @@ export class CodedAppStrategy implements VariantStrategy {
251
257
  const uipathJsonExists =
252
258
  await this.fileSystem.exists(uipathJsonSourcePath);
253
259
  if (uipathJsonExists) {
254
- const uipathJsonContent =
255
- await this.fileSystem.readFile(uipathJsonSourcePath);
260
+ const uipathJsonContent = await this.fileSystem.readFile(
261
+ uipathJsonSourcePath,
262
+ "utf-8",
263
+ );
256
264
  if (uipathJsonContent) {
257
265
  await this.fileSystem.writeFile(
258
266
  uipathJsonDestPath,
@@ -330,9 +338,10 @@ export class CodedAppStrategy implements VariantStrategy {
330
338
  if (projectEntryPointsExists) {
331
339
  const entryPointsData = await this.fileSystem.readFile(
332
340
  projectEntryPointsPath,
341
+ "utf-8",
333
342
  );
334
343
  if (entryPointsData) {
335
- entryPointsContent = new TextDecoder().decode(entryPointsData);
344
+ entryPointsContent = entryPointsData;
336
345
  } else {
337
346
  entryPointsContent = this.createDefaultEntryPoints(mainFile);
338
347
  }
@@ -20,6 +20,7 @@ import {
20
20
  import type { WebAppManifest } from "../models/webapp-manifest.js";
21
21
  import { WEBAPP_MANIFEST_FILE_NAME } from "../models/webapp-manifest.js";
22
22
  import { copyDirectoryAsync } from "../utils/fs-helpers.js";
23
+ import { ensureWebAppProjectId } from "../utils/manifest-loader.js";
23
24
  import type { PackageArgs, VariantStrategy } from "./variant-strategy.js";
24
25
 
25
26
  /**
@@ -156,8 +157,8 @@ export class JsAppsStrategy implements VariantStrategy {
156
157
  */
157
158
  private async prepareMetadataFiles(
158
159
  contentFolder: string,
159
- contentAppFolder: string,
160
- packageInfo: {
160
+ _contentAppFolder: string,
161
+ _packageInfo: {
161
162
  id: string;
162
163
  version: string;
163
164
  author?: string;
@@ -177,7 +178,10 @@ export class JsAppsStrategy implements VariantStrategy {
177
178
  NugetConstants.OperateFileName,
178
179
  );
179
180
  const operateModel: OperateFileModel & { targetRuntime: string } = {
180
- projectId: packageInfo.id,
181
+ projectId: await ensureWebAppProjectId(
182
+ this.fileSystem,
183
+ projectPath,
184
+ ),
181
185
  main: mainRelativeToContent,
182
186
  contentType: ProjectTypes.WebApp,
183
187
  targetFramework: TargetFramework.Portable,
@@ -32,3 +32,32 @@ export async function loadWebAppManifest(
32
32
  );
33
33
  }
34
34
  }
35
+
36
+ /**
37
+ * Resolve a stable projectId for a webapp, persisting it to
38
+ * webAppManifest.json so re-packs are stable.
39
+ */
40
+ export async function ensureWebAppProjectId(
41
+ fileSystem: IFileSystem,
42
+ projectPath: string,
43
+ ): Promise<string> {
44
+ const manifest = await loadWebAppManifest(fileSystem, projectPath);
45
+ if (
46
+ manifest &&
47
+ typeof manifest.projectId === "string" &&
48
+ manifest.projectId.length > 0
49
+ ) {
50
+ return manifest.projectId;
51
+ }
52
+
53
+ const id = crypto.randomUUID();
54
+ if (manifest) {
55
+ const updated: WebAppManifest = { ...manifest, projectId: id };
56
+ const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
57
+ await fileSystem.writeFile(
58
+ manifestPath,
59
+ `${JSON.stringify(updated, null, 2)}\n`,
60
+ );
61
+ }
62
+ return id;
63
+ }