@uipath/packager-tool-webapp 1.206.0-preview.301 → 1.207.0-preview.305
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/action-schema/duplicate-property-names.d.ts +16 -0
- package/dist/action-schema/index.d.ts +1 -0
- package/dist/action-schema/index.js +425 -113
- package/dist/constants.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +368 -82
- package/dist/project-identity.d.ts +21 -0
- package/dist/strategies/coded-app-build-stamp.d.ts +21 -0
- package/dist/strategies/coded-app-build.d.ts +56 -0
- package/dist/strategies/coded-app-strategy.d.ts +19 -2
- package/dist/strategies/command-runner.d.ts +25 -0
- package/dist/strategies/variant-strategy-factory.d.ts +3 -1
- package/dist/strategies/variant-strategy.d.ts +9 -0
- package/dist/webapp-tool-factory.d.ts +7 -0
- package/dist/webapp-tool.d.ts +4 -2
- package/package.json +4 -4
|
@@ -378,22 +378,106 @@ async function describeActionApp(projectDir, fs) {
|
|
|
378
378
|
]
|
|
379
379
|
};
|
|
380
380
|
}
|
|
381
|
+
// src/action-schema/duplicate-property-names.ts
|
|
382
|
+
var ROOT_SECTIONS = [
|
|
383
|
+
"inputs",
|
|
384
|
+
"outputs",
|
|
385
|
+
"inOuts",
|
|
386
|
+
"outcomes"
|
|
387
|
+
];
|
|
388
|
+
function findDuplicateActionPropertyNames(raw) {
|
|
389
|
+
const schema = JsonActionSchemaValidator.parse(JSON.parse(raw));
|
|
390
|
+
const sectionsByName = new Map;
|
|
391
|
+
for (const section of ROOT_SECTIONS) {
|
|
392
|
+
for (const name of Object.keys(schema[section].properties)) {
|
|
393
|
+
const sections = sectionsByName.get(name) ?? [];
|
|
394
|
+
sections.push(section);
|
|
395
|
+
sectionsByName.set(name, sections);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return [...sectionsByName].filter(([, sections]) => sections.length > 1).map(([name, sections]) => ({ name, sections }));
|
|
399
|
+
}
|
|
400
|
+
function describeDuplicateActionPropertyNames(duplicates) {
|
|
401
|
+
return duplicates.map(({ name, sections }) => `'${name}' in ${joinWithAnd(sections)}`).join(", ");
|
|
402
|
+
}
|
|
403
|
+
function joinWithAnd(items) {
|
|
404
|
+
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
405
|
+
}
|
|
381
406
|
// src/webapp-tool-factory.ts
|
|
382
407
|
import {
|
|
383
|
-
ProjectTypes as
|
|
408
|
+
ProjectTypes as ProjectTypes4
|
|
409
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
410
|
+
|
|
411
|
+
// src/project-identity.ts
|
|
412
|
+
import {
|
|
413
|
+
MAX_IDENTITY_FILE_BYTES,
|
|
414
|
+
ProjectTypes
|
|
384
415
|
} from "@uipath/solutionpackager-tool-core";
|
|
385
416
|
|
|
417
|
+
// src/utils/manifest-loader.ts
|
|
418
|
+
import { Path } from "@uipath/solutionpackager-tool-core";
|
|
419
|
+
async function loadWebAppManifest2(fileSystem, projectPath) {
|
|
420
|
+
const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
|
|
421
|
+
const exists = await fileSystem.exists(manifestPath);
|
|
422
|
+
if (!exists) {
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
const content = await fileSystem.readFile(manifestPath);
|
|
426
|
+
if (!content) {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
try {
|
|
430
|
+
const text = new TextDecoder().decode(content);
|
|
431
|
+
const manifest = JSON.parse(text);
|
|
432
|
+
return manifest;
|
|
433
|
+
} catch (error) {
|
|
434
|
+
throw new Error(`Failed to parse ${WEBAPP_MANIFEST_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
async function ensureWebAppProjectId(fileSystem, projectPath) {
|
|
438
|
+
const manifest = await loadWebAppManifest2(fileSystem, projectPath);
|
|
439
|
+
if (manifest && typeof manifest.projectId === "string" && manifest.projectId.length > 0) {
|
|
440
|
+
return manifest.projectId;
|
|
441
|
+
}
|
|
442
|
+
const id = crypto.randomUUID();
|
|
443
|
+
if (manifest) {
|
|
444
|
+
const updated = { ...manifest, projectId: id };
|
|
445
|
+
const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
|
|
446
|
+
await fileSystem.writeFile(manifestPath, `${JSON.stringify(updated, null, 2)}
|
|
447
|
+
`);
|
|
448
|
+
}
|
|
449
|
+
return id;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/project-identity.ts
|
|
453
|
+
var readProjectIdentity = async (target, fs) => {
|
|
454
|
+
const projectDirectory = fs.path.resolve(target);
|
|
455
|
+
const base = { projectDirectory, projectType: ProjectTypes.AppV2 };
|
|
456
|
+
let manifest;
|
|
457
|
+
try {
|
|
458
|
+
const stat = await fs.stat(fs.path.join(projectDirectory, WEBAPP_MANIFEST_FILE_NAME));
|
|
459
|
+
if (stat && stat.size > MAX_IDENTITY_FILE_BYTES) {
|
|
460
|
+
return { ...base, status: "invalid" };
|
|
461
|
+
}
|
|
462
|
+
manifest = await loadWebAppManifest2(fs, projectDirectory);
|
|
463
|
+
} catch {
|
|
464
|
+
return { ...base, status: "invalid" };
|
|
465
|
+
}
|
|
466
|
+
const id = manifest?.projectId;
|
|
467
|
+
return typeof id === "string" && id.length > 0 ? { ...base, id, status: "resolved" } : { ...base, status: "missing" };
|
|
468
|
+
};
|
|
469
|
+
|
|
386
470
|
// src/webapp-tool.ts
|
|
387
471
|
import {
|
|
388
|
-
Path as
|
|
472
|
+
Path as Path8,
|
|
389
473
|
ProjectTool as ProjectTool2,
|
|
390
474
|
TemporaryStorageService,
|
|
391
|
-
ToolErrorCodes,
|
|
475
|
+
ToolErrorCodes as ToolErrorCodes2,
|
|
392
476
|
ToolResult
|
|
393
477
|
} from "@uipath/solutionpackager-tool-core";
|
|
394
478
|
|
|
395
479
|
// src/utils/bundle-path.ts
|
|
396
|
-
import { Path } from "@uipath/solutionpackager-tool-core";
|
|
480
|
+
import { Path as Path2 } from "@uipath/solutionpackager-tool-core";
|
|
397
481
|
function normalizeBundlePath(path) {
|
|
398
482
|
return path.replace(/\\/g, "/");
|
|
399
483
|
}
|
|
@@ -408,7 +492,7 @@ async function isCanonicalBundleChild(fileSystem, projectPath, bundlePath) {
|
|
|
408
492
|
for (const segment of normalizeBundlePath(bundlePath).split("/")) {
|
|
409
493
|
if (!segment || segment === ".")
|
|
410
494
|
continue;
|
|
411
|
-
bundle = normalizeBundlePath(await fileSystem.realpath(
|
|
495
|
+
bundle = normalizeBundlePath(await fileSystem.realpath(Path2.join(bundle, segment))).replace(/\/+$/, "") || "/";
|
|
412
496
|
}
|
|
413
497
|
return bundle !== project && bundle.startsWith(project === "/" ? "/" : `${project}/`);
|
|
414
498
|
}
|
|
@@ -419,11 +503,11 @@ async function resolveHtmlEntryPoint(fileSystem, folder, declaredPath) {
|
|
|
419
503
|
if (!isHtmlEntryPointPath(declaredPath))
|
|
420
504
|
return null;
|
|
421
505
|
const segments = normalizeBundlePath(declaredPath).split("/").filter((part) => part !== "" && part !== ".");
|
|
422
|
-
if (!(await fileSystem.stat(
|
|
506
|
+
if (!(await fileSystem.stat(Path2.join(folder, ...segments)))?.isFile())
|
|
423
507
|
return null;
|
|
424
508
|
const actual = [];
|
|
425
509
|
for (const segment of segments) {
|
|
426
|
-
const entries = await fileSystem.readdir(
|
|
510
|
+
const entries = await fileSystem.readdir(Path2.join(folder, ...actual));
|
|
427
511
|
if (entries.includes(segment)) {
|
|
428
512
|
actual.push(segment);
|
|
429
513
|
continue;
|
|
@@ -472,23 +556,164 @@ var ERROR_MESSAGES = {
|
|
|
472
556
|
OUTPUT_PATH_REQUIRED: "Output path is required"
|
|
473
557
|
};
|
|
474
558
|
|
|
559
|
+
// src/strategies/coded-app-build.ts
|
|
560
|
+
import { Path as Path3, ToolErrorCodes } from "@uipath/solutionpackager-tool-core";
|
|
561
|
+
var LOCKFILE_INSTALLS = [
|
|
562
|
+
{ lockfile: "package-lock.json", manager: "npm", install: ["ci"] },
|
|
563
|
+
{ lockfile: "npm-shrinkwrap.json", manager: "npm", install: ["ci"] },
|
|
564
|
+
{
|
|
565
|
+
lockfile: "pnpm-lock.yaml",
|
|
566
|
+
manager: "pnpm",
|
|
567
|
+
install: ["install", "--frozen-lockfile"]
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
lockfile: "yarn.lock",
|
|
571
|
+
manager: "yarn",
|
|
572
|
+
install: ["install", "--frozen-lockfile"]
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
lockfile: "bun.lock",
|
|
576
|
+
manager: "bun",
|
|
577
|
+
install: ["install", "--frozen-lockfile"]
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
lockfile: "bun.lockb",
|
|
581
|
+
manager: "bun",
|
|
582
|
+
install: ["install", "--frozen-lockfile"]
|
|
583
|
+
}
|
|
584
|
+
];
|
|
585
|
+
var OUTPUT_TAIL_LINES = 20;
|
|
586
|
+
|
|
587
|
+
class CodedAppNotPackableError extends Error {
|
|
588
|
+
instructions;
|
|
589
|
+
errorCode;
|
|
590
|
+
constructor(message, instructions, errorCode = ToolErrorCodes.InvalidProject) {
|
|
591
|
+
super(message);
|
|
592
|
+
this.instructions = instructions;
|
|
593
|
+
this.errorCode = errorCode;
|
|
594
|
+
this.name = "CodedAppNotPackableError";
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function bundleProblemInstructions(bundleFolder, source) {
|
|
598
|
+
const repoint = "point config.bundlePath in webAppManifest.json at the folder the app builds to";
|
|
599
|
+
switch (source) {
|
|
600
|
+
case "built":
|
|
601
|
+
return `The app's build ran but did not leave a usable app (with its HTML entry point) in ${bundleFolder}: make the build write there, or ${repoint}. Then pack again.`;
|
|
602
|
+
case "current":
|
|
603
|
+
return `${bundleFolder} is up to date with the app's sources, so pack did not build it, and it holds no usable app (with its HTML entry point). Delete ${bundleFolder} so pack builds it again, or ${repoint}. Then pack again.`;
|
|
604
|
+
case "no-build-script":
|
|
605
|
+
return `Add a "build" script to the app's package.json that writes ${bundleFolder}, so pack can build it, or ${repoint}. Then pack again.`;
|
|
606
|
+
case "not-building":
|
|
607
|
+
return `Build the app so its output lands in ${bundleFolder}, or ${repoint}. Then pack again.`;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
async function planCodedAppBuildAsync(fileSystem, projectPath, bundlePath) {
|
|
611
|
+
const folder = await findPackageFolderAsync(fileSystem, projectPath, bundlePath);
|
|
612
|
+
if (folder === null)
|
|
613
|
+
return null;
|
|
614
|
+
const packageJsonPath = Path3.join(folder, "package.json");
|
|
615
|
+
const content = await fileSystem.readFile(packageJsonPath);
|
|
616
|
+
let packageJson;
|
|
617
|
+
try {
|
|
618
|
+
packageJson = JSON.parse(new TextDecoder().decode(content ?? new Uint8Array));
|
|
619
|
+
} catch (error) {
|
|
620
|
+
throw new CodedAppNotPackableError(`${packageJsonPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, `Fix ${packageJsonPath}, then pack again.`);
|
|
621
|
+
}
|
|
622
|
+
if (!hasBuildScript(packageJson))
|
|
623
|
+
return null;
|
|
624
|
+
for (const candidate of LOCKFILE_INSTALLS) {
|
|
625
|
+
if (await fileSystem.exists(Path3.join(folder, candidate.lockfile))) {
|
|
626
|
+
return {
|
|
627
|
+
folder,
|
|
628
|
+
manager: candidate.manager,
|
|
629
|
+
lockfile: candidate.lockfile,
|
|
630
|
+
installArgs: candidate.install
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return { folder, manager: "npm", installArgs: ["install"] };
|
|
635
|
+
}
|
|
636
|
+
async function runCodedAppBuildAsync(args) {
|
|
637
|
+
const { fileSystem, runner, plan, logger, signal } = args;
|
|
638
|
+
if (!await fileSystem.exists(Path3.join(plan.folder, "node_modules"))) {
|
|
639
|
+
logger?.progress(`Installing coded app dependencies: ${plan.manager} ${plan.installArgs.join(" ")} (in ${plan.folder})`);
|
|
640
|
+
await runStepAsync(runner, plan, "install", plan.installArgs, signal);
|
|
641
|
+
}
|
|
642
|
+
logger?.progress(`Building coded app: ${plan.manager} run build (in ${plan.folder})`);
|
|
643
|
+
await runStepAsync(runner, plan, "build", ["run", "build"], signal);
|
|
644
|
+
}
|
|
645
|
+
async function runStepAsync(runner, plan, step, stepArgs, signal) {
|
|
646
|
+
const command = [plan.manager, ...stepArgs].join(" ");
|
|
647
|
+
const result = await runner.runAsync(plan.manager, stepArgs, {
|
|
648
|
+
cwd: plan.folder,
|
|
649
|
+
signal
|
|
650
|
+
});
|
|
651
|
+
signal?.throwIfAborted();
|
|
652
|
+
if (result.startError !== undefined) {
|
|
653
|
+
throw new CodedAppNotPackableError(`Could not start '${plan.manager}' to build the coded app in ${plan.folder}: ${result.startError}`, plan.lockfile === undefined || plan.manager === "npm" ? "Install Node.js (it ships npm) and make sure npm is on PATH, then pack again." : `Install ${plan.manager} (the app's ${plan.lockfile} asks for it) and make sure it is on PATH, then pack again.`);
|
|
654
|
+
}
|
|
655
|
+
if (result.exitCode !== 0) {
|
|
656
|
+
const tail = outputTail(result.output);
|
|
657
|
+
const shownTail = tail ? `
|
|
658
|
+
${tail}` : "";
|
|
659
|
+
const exitCode = result.exitCode ?? "none (the process was killed)";
|
|
660
|
+
if (step === "install") {
|
|
661
|
+
throw new CodedAppNotPackableError(`Installing the coded app's dependencies in ${plan.folder} failed: '${command}' ended with exit code ${exitCode}.${shownTail}`, `If the output shows the package registry could not be reached, pack again once it can. Otherwise run '${command}' in ${plan.folder} and fix what it reports, then pack again.`, ToolErrorCodes.DependencyInstallFailed);
|
|
662
|
+
}
|
|
663
|
+
throw new CodedAppNotPackableError(`Building the coded app in ${plan.folder} failed: '${command}' ended with exit code ${exitCode}.${shownTail}`, `Run '${command}' in ${plan.folder} and fix what it reports, then pack again.`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
async function findPackageFolderAsync(fileSystem, projectPath, bundlePath) {
|
|
667
|
+
const root = trimTrailingSlashes(Path3.normalize(projectPath));
|
|
668
|
+
let folder = isBundleRelativePath(bundlePath) ? Path3.dirname(Path3.join(root, normalizeBundlePath(bundlePath))) : root;
|
|
669
|
+
if (folder !== root && !folder.startsWith(`${root}/`))
|
|
670
|
+
folder = root;
|
|
671
|
+
for (;; ) {
|
|
672
|
+
if (await fileSystem.exists(Path3.join(folder, "package.json"))) {
|
|
673
|
+
return folder;
|
|
674
|
+
}
|
|
675
|
+
if (folder === root)
|
|
676
|
+
return null;
|
|
677
|
+
folder = Path3.dirname(folder);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
function trimTrailingSlashes(path) {
|
|
681
|
+
let end = path.length;
|
|
682
|
+
while (end > 0 && path[end - 1] === "/")
|
|
683
|
+
end -= 1;
|
|
684
|
+
return path.slice(0, end);
|
|
685
|
+
}
|
|
686
|
+
function hasBuildScript(packageJson) {
|
|
687
|
+
if (typeof packageJson !== "object" || packageJson === null)
|
|
688
|
+
return false;
|
|
689
|
+
const scripts = packageJson.scripts;
|
|
690
|
+
if (typeof scripts !== "object" || scripts === null)
|
|
691
|
+
return false;
|
|
692
|
+
const build = scripts.build;
|
|
693
|
+
return typeof build === "string" && build.trim() !== "";
|
|
694
|
+
}
|
|
695
|
+
function outputTail(output) {
|
|
696
|
+
return output.trimEnd().split(/\r?\n/).slice(-OUTPUT_TAIL_LINES).join(`
|
|
697
|
+
`);
|
|
698
|
+
}
|
|
699
|
+
|
|
475
700
|
// src/strategies/coded-app-strategy.ts
|
|
476
701
|
import {
|
|
477
702
|
NugetConstants,
|
|
478
703
|
NugetPackager,
|
|
479
|
-
Path as
|
|
480
|
-
ProjectTypes,
|
|
704
|
+
Path as Path6,
|
|
705
|
+
ProjectTypes as ProjectTypes2,
|
|
481
706
|
TargetFramework
|
|
482
707
|
} from "@uipath/solutionpackager-tool-core";
|
|
483
708
|
|
|
484
709
|
// src/utils/fs-helpers.ts
|
|
485
|
-
import { Path as
|
|
710
|
+
import { Path as Path4 } from "@uipath/solutionpackager-tool-core";
|
|
486
711
|
async function copyDirectoryAsync(fileSystem, sourcePath, destinationPath) {
|
|
487
712
|
await fileSystem.mkdir(destinationPath);
|
|
488
713
|
const entries = await fileSystem.readdir(sourcePath);
|
|
489
714
|
for (const entry of entries) {
|
|
490
|
-
const sourceEntry =
|
|
491
|
-
const destEntry =
|
|
715
|
+
const sourceEntry = Path4.join(sourcePath, entry);
|
|
716
|
+
const destEntry = Path4.join(destinationPath, entry);
|
|
492
717
|
const stat = await fileSystem.stat(sourceEntry);
|
|
493
718
|
if (stat?.isDirectory()) {
|
|
494
719
|
await copyDirectoryAsync(fileSystem, sourceEntry, destEntry);
|
|
@@ -501,46 +726,87 @@ async function copyDirectoryAsync(fileSystem, sourcePath, destinationPath) {
|
|
|
501
726
|
}
|
|
502
727
|
}
|
|
503
728
|
|
|
504
|
-
// src/
|
|
505
|
-
import { Path as
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
729
|
+
// src/strategies/coded-app-build-stamp.ts
|
|
730
|
+
import { Path as Path5 } from "@uipath/solutionpackager-tool-core";
|
|
731
|
+
var BUILD_STAMP_FILE_NAME = ".uipath-build.json";
|
|
732
|
+
var SKIPPED_DIRECTORY_NAMES = new Set([
|
|
733
|
+
"node_modules",
|
|
734
|
+
".git"
|
|
735
|
+
]);
|
|
736
|
+
async function isBuildCurrentAsync(fileSystem, plan, bundleFolder) {
|
|
737
|
+
const stamped = await readStampAsync(fileSystem, plan.folder);
|
|
738
|
+
if (stamped === null)
|
|
739
|
+
return false;
|
|
740
|
+
return stamped === await fingerprintAsync(fileSystem, plan, bundleFolder) && await fileSystem.exists(bundleFolder);
|
|
741
|
+
}
|
|
742
|
+
async function writeBuildStampAsync(fileSystem, plan, bundleFolder) {
|
|
743
|
+
const fingerprint = await fingerprintAsync(fileSystem, plan, bundleFolder);
|
|
744
|
+
await fileSystem.writeFile(Path5.join(plan.folder, BUILD_STAMP_FILE_NAME), JSON.stringify({ fingerprint }, null, 4));
|
|
745
|
+
}
|
|
746
|
+
async function readStampAsync(fileSystem, folder) {
|
|
747
|
+
const content = await fileSystem.readFile(Path5.join(folder, BUILD_STAMP_FILE_NAME), "utf-8");
|
|
748
|
+
if (content === null)
|
|
514
749
|
return null;
|
|
515
|
-
}
|
|
516
750
|
try {
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
return
|
|
520
|
-
} catch
|
|
521
|
-
|
|
751
|
+
const stamp = JSON.parse(content);
|
|
752
|
+
const fingerprint = typeof stamp === "object" && stamp !== null ? stamp.fingerprint : undefined;
|
|
753
|
+
return typeof fingerprint === "string" ? fingerprint : null;
|
|
754
|
+
} catch {
|
|
755
|
+
return null;
|
|
522
756
|
}
|
|
523
757
|
}
|
|
524
|
-
async function
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
const manifestPath = Path3.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
|
|
533
|
-
await fileSystem.writeFile(manifestPath, `${JSON.stringify(updated, null, 2)}
|
|
534
|
-
`);
|
|
758
|
+
async function fingerprintAsync(fileSystem, plan, bundleFolder) {
|
|
759
|
+
const root = Path5.normalize(plan.folder);
|
|
760
|
+
const bundle = Path5.normalize(bundleFolder);
|
|
761
|
+
const files = await listAppFilesAsync(fileSystem, root, bundle);
|
|
762
|
+
const digests = [];
|
|
763
|
+
for (const relativePath of files) {
|
|
764
|
+
const content = await fileSystem.readFile(Path5.join(root, relativePath)) ?? new Uint8Array;
|
|
765
|
+
digests.push(`${relativePath} ${await sha256Hex(content)}`);
|
|
535
766
|
}
|
|
536
|
-
return
|
|
767
|
+
return sha256Hex(new TextEncoder().encode(digests.join(`
|
|
768
|
+
`)));
|
|
769
|
+
}
|
|
770
|
+
async function listAppFilesAsync(fileSystem, root, bundleFolder) {
|
|
771
|
+
const files = [];
|
|
772
|
+
const visit = async (directory, prefix) => {
|
|
773
|
+
for (const name of await fileSystem.readdir(directory)) {
|
|
774
|
+
const path = Path5.join(directory, name);
|
|
775
|
+
const relativePath = prefix === "" ? name : `${prefix}/${name}`;
|
|
776
|
+
if (path === bundleFolder)
|
|
777
|
+
continue;
|
|
778
|
+
if (relativePath === BUILD_STAMP_FILE_NAME)
|
|
779
|
+
continue;
|
|
780
|
+
const stats = await fileSystem.stat(path);
|
|
781
|
+
if (stats?.isDirectory()) {
|
|
782
|
+
if (SKIPPED_DIRECTORY_NAMES.has(name))
|
|
783
|
+
continue;
|
|
784
|
+
await visit(path, relativePath);
|
|
785
|
+
} else {
|
|
786
|
+
files.push(relativePath);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
await visit(root, "");
|
|
791
|
+
return files.sort(compareCodeUnits);
|
|
792
|
+
}
|
|
793
|
+
function compareCodeUnits(a, b) {
|
|
794
|
+
if (a < b)
|
|
795
|
+
return -1;
|
|
796
|
+
return a > b ? 1 : 0;
|
|
797
|
+
}
|
|
798
|
+
async function sha256Hex(bytes) {
|
|
799
|
+
const digest = await crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
|
|
800
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
537
801
|
}
|
|
538
802
|
|
|
539
803
|
// src/strategies/coded-app-strategy.ts
|
|
540
804
|
class CodedAppStrategy {
|
|
541
805
|
fileSystem;
|
|
542
|
-
|
|
806
|
+
commandRunner;
|
|
807
|
+
constructor(fileSystem, commandRunner) {
|
|
543
808
|
this.fileSystem = fileSystem;
|
|
809
|
+
this.commandRunner = commandRunner;
|
|
544
810
|
}
|
|
545
811
|
async validateAsync(args) {
|
|
546
812
|
const { projectPath, manifest, logger } = args;
|
|
@@ -550,8 +816,12 @@ class CodedAppStrategy {
|
|
|
550
816
|
bundlePath = DEFAULT_BUNDLE_PATH;
|
|
551
817
|
}
|
|
552
818
|
const isCompiled = typed.config?.isCompiled ?? true;
|
|
553
|
-
if (isCompiled)
|
|
554
|
-
|
|
819
|
+
if (!isCompiled)
|
|
820
|
+
return;
|
|
821
|
+
const fullBundlePath = Path6.join(projectPath, bundlePath);
|
|
822
|
+
const plan = this.commandRunner === undefined ? null : await planCodedAppBuildAsync(this.fileSystem, projectPath, bundlePath);
|
|
823
|
+
const packWillBuild = plan !== null && !await isBuildCurrentAsync(this.fileSystem, plan, fullBundlePath);
|
|
824
|
+
if (!packWillBuild) {
|
|
555
825
|
const message = await this.describeBundleProblemAsync(fullBundlePath, typed.config?.mainFile);
|
|
556
826
|
if (message) {
|
|
557
827
|
const warnable = logger;
|
|
@@ -572,30 +842,19 @@ class CodedAppStrategy {
|
|
|
572
842
|
}
|
|
573
843
|
const isCompiled = manifest.config?.isCompiled ?? true;
|
|
574
844
|
const declaredMainFile = manifest.config?.mainFile;
|
|
575
|
-
const fullBundlePath =
|
|
845
|
+
const fullBundlePath = Path6.join(projectPath, bundlePath);
|
|
576
846
|
if (isBundleRelativePath(bundlePath) && !await isCanonicalBundleChild(this.fileSystem, projectPath, bundlePath)) {
|
|
577
847
|
throw new Error(ERROR_MESSAGES.BUNDLE_OUTSIDE_PROJECT(bundlePath));
|
|
578
848
|
}
|
|
579
849
|
if (isCompiled) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (!bundleExists) {
|
|
583
|
-
throw new Error(ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath));
|
|
584
|
-
}
|
|
585
|
-
const bundleStat = await this.fileSystem.stat(fullBundlePath);
|
|
586
|
-
if (!bundleStat?.isDirectory()) {
|
|
587
|
-
throw new Error(ERROR_MESSAGES.BUNDLE_NOT_DIRECTORY(fullBundlePath));
|
|
588
|
-
}
|
|
589
|
-
const problem = await this.describeBundleEntryProblemAsync(fullBundlePath, declaredMainFile);
|
|
590
|
-
if (problem) {
|
|
591
|
-
throw new Error(problem);
|
|
592
|
-
}
|
|
850
|
+
const bundleSource = await this.prepareBundleAsync(args, bundlePath, fullBundlePath);
|
|
851
|
+
await this.assertBundlePackableAsync(fullBundlePath, declaredMainFile, bundleSource, logger);
|
|
593
852
|
} else {
|
|
594
853
|
logger?.info("Build mode (isCompiled=false) is not yet implemented in v1.");
|
|
595
854
|
throw new Error(ERROR_MESSAGES.BUILD_NOT_SUPPORTED);
|
|
596
855
|
}
|
|
597
|
-
const localBuildFolder =
|
|
598
|
-
const contentFolder =
|
|
856
|
+
const localBuildFolder = Path6.join(outputPath, `${NugetConstants.OutputFolderName}-${crypto.randomUUID()}`);
|
|
857
|
+
const contentFolder = Path6.join(localBuildFolder, NugetConstants.ContentFolderName);
|
|
599
858
|
try {
|
|
600
859
|
await this.fileSystem.mkdir(contentFolder);
|
|
601
860
|
logger?.progress("Copying bundle to content folder...");
|
|
@@ -604,7 +863,7 @@ class CodedAppStrategy {
|
|
|
604
863
|
await this.prepareMetadataFiles(localBuildFolder, contentFolder, packageInfo, manifest, projectPath, fullBundlePath);
|
|
605
864
|
logger?.progress("Creating NuGet package...");
|
|
606
865
|
const nupkgFileName = `${packageInfo.id}.${packageInfo.version}.nupkg`;
|
|
607
|
-
const nupkgPath =
|
|
866
|
+
const nupkgPath = Path6.join(outputPath, nupkgFileName);
|
|
608
867
|
const packager = new NugetPackager(this.fileSystem);
|
|
609
868
|
const result = await packager.packAsync(localBuildFolder, packageInfo, nupkgPath);
|
|
610
869
|
logger?.info(`Package created successfully: ${result.outputPath}`);
|
|
@@ -617,17 +876,53 @@ class CodedAppStrategy {
|
|
|
617
876
|
}
|
|
618
877
|
}
|
|
619
878
|
}
|
|
879
|
+
async prepareBundleAsync(args, bundlePath, fullBundlePath) {
|
|
880
|
+
const runner = args.buildApp ? this.commandRunner : undefined;
|
|
881
|
+
if (runner === undefined)
|
|
882
|
+
return "not-building";
|
|
883
|
+
const plan = await planCodedAppBuildAsync(this.fileSystem, args.projectPath, bundlePath);
|
|
884
|
+
if (plan === null)
|
|
885
|
+
return "no-build-script";
|
|
886
|
+
if (await isBuildCurrentAsync(this.fileSystem, plan, fullBundlePath)) {
|
|
887
|
+
args.logger?.info(`Skipping build: ${bundlePath} was built from the app's current sources`);
|
|
888
|
+
return "current";
|
|
889
|
+
}
|
|
890
|
+
await runCodedAppBuildAsync({
|
|
891
|
+
fileSystem: this.fileSystem,
|
|
892
|
+
runner,
|
|
893
|
+
plan,
|
|
894
|
+
logger: args.logger,
|
|
895
|
+
signal: args.signal
|
|
896
|
+
});
|
|
897
|
+
await writeBuildStampAsync(this.fileSystem, plan, fullBundlePath);
|
|
898
|
+
return "built";
|
|
899
|
+
}
|
|
900
|
+
async assertBundlePackableAsync(fullBundlePath, declaredMainFile, bundleSource, logger) {
|
|
901
|
+
logger?.progress("Validating compiled bundle...");
|
|
902
|
+
const bundleExists = await this.fileSystem.exists(fullBundlePath);
|
|
903
|
+
if (!bundleExists) {
|
|
904
|
+
throw new CodedAppNotPackableError(ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath), bundleProblemInstructions(fullBundlePath, bundleSource));
|
|
905
|
+
}
|
|
906
|
+
const bundleStat = await this.fileSystem.stat(fullBundlePath);
|
|
907
|
+
if (!bundleStat?.isDirectory()) {
|
|
908
|
+
throw new CodedAppNotPackableError(ERROR_MESSAGES.BUNDLE_NOT_DIRECTORY(fullBundlePath), bundleProblemInstructions(fullBundlePath, bundleSource));
|
|
909
|
+
}
|
|
910
|
+
const problem = await this.describeBundleEntryProblemAsync(fullBundlePath, declaredMainFile);
|
|
911
|
+
if (problem) {
|
|
912
|
+
throw new CodedAppNotPackableError(problem, bundleProblemInstructions(fullBundlePath, bundleSource));
|
|
913
|
+
}
|
|
914
|
+
}
|
|
620
915
|
async prepareMetadataFiles(_localBuildFolder, contentFolder, _packageInfo, manifest, projectPath, sourceBundlePath) {
|
|
621
916
|
const declaredMainFile = manifest.config?.mainFile;
|
|
622
917
|
const mainFile = await this.resolveMainFileAsync(contentFolder, declaredMainFile);
|
|
623
918
|
if (!mainFile) {
|
|
624
919
|
throw new Error(declaredMainFile ? ERROR_MESSAGES.MAIN_FILE_LOST(sourceBundlePath, declaredMainFile) : ERROR_MESSAGES.BUNDLE_ENTRY_POINT_LOST(sourceBundlePath));
|
|
625
920
|
}
|
|
626
|
-
const operatePath =
|
|
921
|
+
const operatePath = Path6.join(contentFolder, NugetConstants.OperateFileName);
|
|
627
922
|
const operateModel = {
|
|
628
923
|
projectId: await ensureWebAppProjectId(this.fileSystem, projectPath),
|
|
629
924
|
main: mainFile,
|
|
630
|
-
contentType:
|
|
925
|
+
contentType: ProjectTypes2.WebApp,
|
|
631
926
|
targetFramework: TargetFramework.Portable,
|
|
632
927
|
targetRuntime: TARGET_RUNTIME,
|
|
633
928
|
runtimeOptions: {
|
|
@@ -637,13 +932,13 @@ class CodedAppStrategy {
|
|
|
637
932
|
};
|
|
638
933
|
const operateJson = JSON.stringify(operateModel, null, 2);
|
|
639
934
|
await this.fileSystem.writeFile(operatePath, operateJson);
|
|
640
|
-
await this.fileSystem.writeFile(
|
|
935
|
+
await this.fileSystem.writeFile(Path6.join(contentFolder, WEBAPP_MANIFEST_FILE_NAME), JSON.stringify({
|
|
641
936
|
...manifest,
|
|
642
937
|
config: { ...manifest.config, mainFile },
|
|
643
938
|
projectId: operateModel.projectId
|
|
644
939
|
}, null, 2));
|
|
645
|
-
const uipathJsonSourcePath =
|
|
646
|
-
const uipathJsonDestPath =
|
|
940
|
+
const uipathJsonSourcePath = Path6.join(projectPath, "uipath.json");
|
|
941
|
+
const uipathJsonDestPath = Path6.join(contentFolder, "uipath.json");
|
|
647
942
|
const uipathJsonExists = await this.fileSystem.exists(uipathJsonSourcePath);
|
|
648
943
|
if (uipathJsonExists) {
|
|
649
944
|
const uipathJsonContent = await this.fileSystem.readFile(uipathJsonSourcePath, "utf-8");
|
|
@@ -651,8 +946,8 @@ class CodedAppStrategy {
|
|
|
651
946
|
await this.fileSystem.writeFile(uipathJsonDestPath, uipathJsonContent);
|
|
652
947
|
}
|
|
653
948
|
}
|
|
654
|
-
const actionSchemaSourcePath =
|
|
655
|
-
const actionSchemaDestPath =
|
|
949
|
+
const actionSchemaSourcePath = Path6.join(projectPath, "action-schema.json");
|
|
950
|
+
const actionSchemaDestPath = Path6.join(contentFolder, "action-schema.json");
|
|
656
951
|
const actionSchemaExists = await this.fileSystem.exists(actionSchemaSourcePath);
|
|
657
952
|
if (actionSchemaExists) {
|
|
658
953
|
const actionSchemaContent = await this.fileSystem.readFile(actionSchemaSourcePath, "utf-8");
|
|
@@ -660,7 +955,7 @@ class CodedAppStrategy {
|
|
|
660
955
|
await this.fileSystem.writeFile(actionSchemaDestPath, actionSchemaContent);
|
|
661
956
|
}
|
|
662
957
|
}
|
|
663
|
-
const bindingsPath =
|
|
958
|
+
const bindingsPath = Path6.join(contentFolder, "bindings.json");
|
|
664
959
|
const bindingsExists = await this.fileSystem.exists(bindingsPath);
|
|
665
960
|
if (!bindingsExists) {
|
|
666
961
|
const bindingsJson = JSON.stringify({
|
|
@@ -669,12 +964,12 @@ class CodedAppStrategy {
|
|
|
669
964
|
}, null, 2);
|
|
670
965
|
await this.fileSystem.writeFile(bindingsPath, bindingsJson);
|
|
671
966
|
}
|
|
672
|
-
const bindingsV2Path =
|
|
967
|
+
const bindingsV2Path = Path6.join(contentFolder, "bindings_v2.json");
|
|
673
968
|
const bindingsCandidatePaths = [
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
969
|
+
Path6.join(projectPath, "source", "bindings_v2.json"),
|
|
970
|
+
Path6.join(projectPath, "source", "bindings.json"),
|
|
971
|
+
Path6.join(projectPath, "bindings.json"),
|
|
972
|
+
Path6.join(projectPath, "bindings_v2.json")
|
|
678
973
|
];
|
|
679
974
|
let bindingsV2Json = null;
|
|
680
975
|
for (const candidate of bindingsCandidatePaths) {
|
|
@@ -694,8 +989,8 @@ class CodedAppStrategy {
|
|
|
694
989
|
}, null, 2);
|
|
695
990
|
}
|
|
696
991
|
await this.fileSystem.writeFile(bindingsV2Path, bindingsV2Json);
|
|
697
|
-
const entryPointsPath =
|
|
698
|
-
const projectEntryPointsPath =
|
|
992
|
+
const entryPointsPath = Path6.join(contentFolder, "entry-points.json");
|
|
993
|
+
const projectEntryPointsPath = Path6.join(projectPath, "entry-points.json");
|
|
699
994
|
let entryPointsContent;
|
|
700
995
|
const projectEntryPointsExists = await this.fileSystem.exists(projectEntryPointsPath);
|
|
701
996
|
if (projectEntryPointsExists) {
|
|
@@ -709,13 +1004,13 @@ class CodedAppStrategy {
|
|
|
709
1004
|
entryPointsContent = this.createDefaultEntryPoints(mainFile);
|
|
710
1005
|
}
|
|
711
1006
|
await this.fileSystem.writeFile(entryPointsPath, entryPointsContent);
|
|
712
|
-
const packageDescriptorPath =
|
|
1007
|
+
const packageDescriptorPath = Path6.join(contentFolder, NugetConstants.PackageDescriptorFileName);
|
|
713
1008
|
const packageDescriptor = {
|
|
714
1009
|
$schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor",
|
|
715
1010
|
files: {
|
|
716
|
-
[NugetConstants.OperateFileName]:
|
|
717
|
-
"entry-points.json":
|
|
718
|
-
"bindings.json":
|
|
1011
|
+
[NugetConstants.OperateFileName]: Path6.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName),
|
|
1012
|
+
"entry-points.json": Path6.join(NugetConstants.ContentFolderName, "entry-points.json"),
|
|
1013
|
+
"bindings.json": Path6.join(NugetConstants.ContentFolderName, "bindings_v2.json")
|
|
719
1014
|
}
|
|
720
1015
|
};
|
|
721
1016
|
const packageDescriptorJson = JSON.stringify(packageDescriptor, null, 2);
|
|
@@ -817,8 +1112,8 @@ class CodedAppStrategy {
|
|
|
817
1112
|
import {
|
|
818
1113
|
NugetConstants as NugetConstants2,
|
|
819
1114
|
NugetPackager as NugetPackager2,
|
|
820
|
-
Path as
|
|
821
|
-
ProjectTypes as
|
|
1115
|
+
Path as Path7,
|
|
1116
|
+
ProjectTypes as ProjectTypes3,
|
|
822
1117
|
TargetFramework as TargetFramework2
|
|
823
1118
|
} from "@uipath/solutionpackager-tool-core";
|
|
824
1119
|
class JsAppsStrategy {
|
|
@@ -828,7 +1123,7 @@ class JsAppsStrategy {
|
|
|
828
1123
|
}
|
|
829
1124
|
async validateAsync(args) {
|
|
830
1125
|
const { projectPath, logger } = args;
|
|
831
|
-
const appFolder =
|
|
1126
|
+
const appFolder = Path7.join(projectPath, APP_FOLDER_NAME);
|
|
832
1127
|
const exists = await this.fileSystem.exists(appFolder);
|
|
833
1128
|
if (!exists) {
|
|
834
1129
|
const message = ERROR_MESSAGES.APP_FOLDER_NOT_FOUND(appFolder);
|
|
@@ -852,7 +1147,7 @@ class JsAppsStrategy {
|
|
|
852
1147
|
async packageAsync(args) {
|
|
853
1148
|
const { projectPath, manifest, outputPath, packageInfo, logger } = args;
|
|
854
1149
|
logger?.info(`Packaging JS variant: ${packageInfo.id}@${packageInfo.version}`);
|
|
855
|
-
const appFolder =
|
|
1150
|
+
const appFolder = Path7.join(projectPath, APP_FOLDER_NAME);
|
|
856
1151
|
logger?.progress("Validating .app folder...");
|
|
857
1152
|
const appFolderExists = await this.fileSystem.exists(appFolder);
|
|
858
1153
|
if (!appFolderExists) {
|
|
@@ -862,9 +1157,9 @@ class JsAppsStrategy {
|
|
|
862
1157
|
if (!appFolderStat?.isDirectory()) {
|
|
863
1158
|
throw new Error(ERROR_MESSAGES.APP_FOLDER_NOT_DIRECTORY(appFolder));
|
|
864
1159
|
}
|
|
865
|
-
const localBuildFolder =
|
|
866
|
-
const contentFolder =
|
|
867
|
-
const contentAppFolder =
|
|
1160
|
+
const localBuildFolder = Path7.join(outputPath, NugetConstants2.OutputFolderName);
|
|
1161
|
+
const contentFolder = Path7.join(localBuildFolder, NugetConstants2.ContentFolderName);
|
|
1162
|
+
const contentAppFolder = Path7.join(contentFolder, CONTENT_APP_FOLDER_NAME);
|
|
868
1163
|
await this.fileSystem.mkdir(contentFolder);
|
|
869
1164
|
try {
|
|
870
1165
|
logger?.progress("Copying .app folder into content/app...");
|
|
@@ -873,7 +1168,7 @@ class JsAppsStrategy {
|
|
|
873
1168
|
await this.prepareMetadataFiles(contentFolder, contentAppFolder, packageInfo, manifest, projectPath);
|
|
874
1169
|
logger?.progress("Creating NuGet package...");
|
|
875
1170
|
const nupkgFileName = `${packageInfo.id}.${packageInfo.version}.nupkg`;
|
|
876
|
-
const nupkgPath =
|
|
1171
|
+
const nupkgPath = Path7.join(outputPath, nupkgFileName);
|
|
877
1172
|
const packager = new NugetPackager2(this.fileSystem);
|
|
878
1173
|
const result = await packager.packAsync(localBuildFolder, packageInfo, nupkgPath);
|
|
879
1174
|
logger?.info(`Package created successfully: ${result.outputPath}`);
|
|
@@ -889,11 +1184,11 @@ class JsAppsStrategy {
|
|
|
889
1184
|
async prepareMetadataFiles(contentFolder, _contentAppFolder, _packageInfo, _manifest, projectPath) {
|
|
890
1185
|
const mainFile = "index.html";
|
|
891
1186
|
const mainRelativeToContent = `${CONTENT_APP_FOLDER_NAME}/${mainFile}`;
|
|
892
|
-
const operatePath =
|
|
1187
|
+
const operatePath = Path7.join(contentFolder, NugetConstants2.OperateFileName);
|
|
893
1188
|
const operateModel = {
|
|
894
1189
|
projectId: await ensureWebAppProjectId(this.fileSystem, projectPath),
|
|
895
1190
|
main: mainRelativeToContent,
|
|
896
|
-
contentType:
|
|
1191
|
+
contentType: ProjectTypes3.WebApp,
|
|
897
1192
|
targetFramework: TargetFramework2.Portable,
|
|
898
1193
|
targetRuntime: TARGET_JS_RUNTIME,
|
|
899
1194
|
runtimeOptions: {
|
|
@@ -903,8 +1198,8 @@ class JsAppsStrategy {
|
|
|
903
1198
|
};
|
|
904
1199
|
const operateJson = JSON.stringify(operateModel, null, 2);
|
|
905
1200
|
await this.fileSystem.writeFile(operatePath, operateJson);
|
|
906
|
-
const manifestSourcePath =
|
|
907
|
-
const manifestDestPath =
|
|
1201
|
+
const manifestSourcePath = Path7.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
|
|
1202
|
+
const manifestDestPath = Path7.join(contentFolder, WEBAPP_MANIFEST_FILE_NAME);
|
|
908
1203
|
const manifestExists = await this.fileSystem.exists(manifestSourcePath);
|
|
909
1204
|
if (manifestExists) {
|
|
910
1205
|
const manifestContent = await this.fileSystem.readFile(manifestSourcePath);
|
|
@@ -912,8 +1207,8 @@ class JsAppsStrategy {
|
|
|
912
1207
|
await this.fileSystem.writeFile(manifestDestPath, manifestContent);
|
|
913
1208
|
}
|
|
914
1209
|
}
|
|
915
|
-
const uipathJsonSourcePath =
|
|
916
|
-
const uipathJsonDestPath =
|
|
1210
|
+
const uipathJsonSourcePath = Path7.join(projectPath, "uipath.json");
|
|
1211
|
+
const uipathJsonDestPath = Path7.join(contentFolder, "uipath.json");
|
|
917
1212
|
const uipathJsonExists = await this.fileSystem.exists(uipathJsonSourcePath);
|
|
918
1213
|
if (uipathJsonExists) {
|
|
919
1214
|
const uipathJsonContent = await this.fileSystem.readFile(uipathJsonSourcePath);
|
|
@@ -921,20 +1216,20 @@ class JsAppsStrategy {
|
|
|
921
1216
|
await this.fileSystem.writeFile(uipathJsonDestPath, uipathJsonContent);
|
|
922
1217
|
}
|
|
923
1218
|
}
|
|
924
|
-
const bindingsPath =
|
|
1219
|
+
const bindingsPath = Path7.join(contentFolder, "bindings.json");
|
|
925
1220
|
const bindingsExists = await this.fileSystem.exists(bindingsPath);
|
|
926
1221
|
if (!bindingsExists) {
|
|
927
1222
|
const bindingsJson = JSON.stringify({ version: "1.0", resources: [] }, null, 2);
|
|
928
1223
|
await this.fileSystem.writeFile(bindingsPath, bindingsJson);
|
|
929
1224
|
}
|
|
930
|
-
const bindingsV2Path =
|
|
1225
|
+
const bindingsV2Path = Path7.join(contentFolder, "bindings_v2.json");
|
|
931
1226
|
const bindingsV2Exists = await this.fileSystem.exists(bindingsV2Path);
|
|
932
1227
|
if (!bindingsV2Exists) {
|
|
933
1228
|
const bindingsV2Json = JSON.stringify({ version: "2.0", resources: [] }, null, 2);
|
|
934
1229
|
await this.fileSystem.writeFile(bindingsV2Path, bindingsV2Json);
|
|
935
1230
|
}
|
|
936
|
-
const entryPointsPath =
|
|
937
|
-
const projectEntryPointsPath =
|
|
1231
|
+
const entryPointsPath = Path7.join(contentFolder, "entry-points.json");
|
|
1232
|
+
const projectEntryPointsPath = Path7.join(projectPath, "entry-points.json");
|
|
938
1233
|
let entryPointsContent;
|
|
939
1234
|
const projectEntryPointsExists = await this.fileSystem.exists(projectEntryPointsPath);
|
|
940
1235
|
if (projectEntryPointsExists) {
|
|
@@ -948,12 +1243,12 @@ class JsAppsStrategy {
|
|
|
948
1243
|
entryPointsContent = this.createDefaultEntryPoints(mainRelativeToContent);
|
|
949
1244
|
}
|
|
950
1245
|
await this.fileSystem.writeFile(entryPointsPath, entryPointsContent);
|
|
951
|
-
const packageDescriptorPath =
|
|
1246
|
+
const packageDescriptorPath = Path7.join(contentFolder, NugetConstants2.PackageDescriptorFileName);
|
|
952
1247
|
const packageDescriptor = {
|
|
953
1248
|
files: {
|
|
954
|
-
[NugetConstants2.OperateFileName]:
|
|
955
|
-
"entry-points.json":
|
|
956
|
-
"bindings.json":
|
|
1249
|
+
[NugetConstants2.OperateFileName]: Path7.join(NugetConstants2.ContentFolderName, NugetConstants2.OperateFileName),
|
|
1250
|
+
"entry-points.json": Path7.join(NugetConstants2.ContentFolderName, "entry-points.json"),
|
|
1251
|
+
"bindings.json": Path7.join(NugetConstants2.ContentFolderName, "bindings_v2.json")
|
|
957
1252
|
}
|
|
958
1253
|
};
|
|
959
1254
|
const packageDescriptorJson = JSON.stringify(packageDescriptor, null, 2);
|
|
@@ -1003,11 +1298,11 @@ class JsAppsStrategy {
|
|
|
1003
1298
|
|
|
1004
1299
|
// src/strategies/variant-strategy-factory.ts
|
|
1005
1300
|
class VariantStrategyFactory {
|
|
1006
|
-
static createStrategy(manifest, fileSystem) {
|
|
1301
|
+
static createStrategy(manifest, fileSystem, commandRunner) {
|
|
1007
1302
|
const variant = manifest.type;
|
|
1008
1303
|
switch (variant) {
|
|
1009
1304
|
case "Coded" /* Coded */:
|
|
1010
|
-
return new CodedAppStrategy(fileSystem);
|
|
1305
|
+
return new CodedAppStrategy(fileSystem, commandRunner);
|
|
1011
1306
|
case "JS" /* JS */:
|
|
1012
1307
|
return new JsAppsStrategy(fileSystem);
|
|
1013
1308
|
default:
|
|
@@ -1018,10 +1313,12 @@ class VariantStrategyFactory {
|
|
|
1018
1313
|
|
|
1019
1314
|
// src/webapp-tool.ts
|
|
1020
1315
|
class WebAppTool extends ProjectTool2 {
|
|
1316
|
+
commandRunner;
|
|
1021
1317
|
_temporaryStorage;
|
|
1022
1318
|
_tempBuildFolder = null;
|
|
1023
|
-
constructor(fileSystem, logger) {
|
|
1319
|
+
constructor(fileSystem, logger, commandRunner) {
|
|
1024
1320
|
super(fileSystem, logger);
|
|
1321
|
+
this.commandRunner = commandRunner;
|
|
1025
1322
|
this._temporaryStorage = new TemporaryStorageService(fileSystem);
|
|
1026
1323
|
}
|
|
1027
1324
|
async restoreAsync(_options, _cancellationToken) {
|
|
@@ -1065,7 +1362,7 @@ class WebAppTool extends ProjectTool2 {
|
|
|
1065
1362
|
this.logger.info("Build operation for WebApp is lightweight (metadata preparation only)");
|
|
1066
1363
|
return ToolResult.success();
|
|
1067
1364
|
}
|
|
1068
|
-
async packAsync(options,
|
|
1365
|
+
async packAsync(options, cancellationToken) {
|
|
1069
1366
|
if (!options.projectPath) {
|
|
1070
1367
|
return this.handleError(new Error(ERROR_MESSAGES.PROJECT_PATH_REQUIRED), "Packing");
|
|
1071
1368
|
}
|
|
@@ -1095,11 +1392,16 @@ class WebAppTool extends ProjectTool2 {
|
|
|
1095
1392
|
manifest,
|
|
1096
1393
|
outputPath: options.outputPath,
|
|
1097
1394
|
packageInfo: options.package,
|
|
1395
|
+
buildApp: options.codedBundle === undefined && options.skipBuild !== true,
|
|
1396
|
+
signal: cancellationToken,
|
|
1098
1397
|
logger: this.createStrategyLogger()
|
|
1099
1398
|
});
|
|
1100
1399
|
this.logger.info(`WebApp package created successfully: ${nupkgPath}`);
|
|
1101
|
-
return new ToolResult(
|
|
1400
|
+
return new ToolResult(ToolErrorCodes2.Success, "done", [nupkgPath]);
|
|
1102
1401
|
} catch (error) {
|
|
1402
|
+
if (cancellationToken?.aborted) {
|
|
1403
|
+
return ToolResult.error(ToolErrorCodes2.Canceled, ERROR_MESSAGES.PACKING_FAILED("the pack was canceled"));
|
|
1404
|
+
}
|
|
1103
1405
|
return this.handleError(error, `Packing WebApp project '${options.package.id}'`);
|
|
1104
1406
|
}
|
|
1105
1407
|
}
|
|
@@ -1114,12 +1416,12 @@ class WebAppTool extends ProjectTool2 {
|
|
|
1114
1416
|
} catch {}
|
|
1115
1417
|
}
|
|
1116
1418
|
async getManifestAndStrategy(projectPath, codedBundle) {
|
|
1117
|
-
const manifestPath =
|
|
1419
|
+
const manifestPath = Path8.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
|
|
1118
1420
|
const manifestExists = await this.fileSystem.exists(manifestPath);
|
|
1119
1421
|
if (!manifestExists && !codedBundle) {
|
|
1120
1422
|
throw new Error(ERROR_MESSAGES.MANIFEST_NOT_FOUND(WEBAPP_MANIFEST_FILE_NAME));
|
|
1121
1423
|
}
|
|
1122
|
-
const projectJsonPath =
|
|
1424
|
+
const projectJsonPath = Path8.join(projectPath, PROJECT_JSON_FILE);
|
|
1123
1425
|
if (await this.fileSystem.exists(projectJsonPath)) {
|
|
1124
1426
|
throw new Error(ERROR_MESSAGES.PROJECT_JSON_FOUND);
|
|
1125
1427
|
}
|
|
@@ -1140,7 +1442,7 @@ class WebAppTool extends ProjectTool2 {
|
|
|
1140
1442
|
config: { ...manifest.config, ...codedBundle }
|
|
1141
1443
|
};
|
|
1142
1444
|
}
|
|
1143
|
-
const strategy = VariantStrategyFactory.createStrategy(manifest, this.fileSystem);
|
|
1445
|
+
const strategy = VariantStrategyFactory.createStrategy(manifest, this.fileSystem, this.commandRunner);
|
|
1144
1446
|
return { manifest, strategy };
|
|
1145
1447
|
}
|
|
1146
1448
|
handleError(error, context) {
|
|
@@ -1154,7 +1456,10 @@ class WebAppTool extends ProjectTool2 {
|
|
|
1154
1456
|
} else {
|
|
1155
1457
|
userMessage = errorMessage;
|
|
1156
1458
|
}
|
|
1157
|
-
|
|
1459
|
+
if (error instanceof CodedAppNotPackableError) {
|
|
1460
|
+
return ToolResult.error(error.errorCode, userMessage, error.instructions);
|
|
1461
|
+
}
|
|
1462
|
+
return ToolResult.error(ToolErrorCodes2.InternalError, userMessage);
|
|
1158
1463
|
}
|
|
1159
1464
|
createStrategyLogger() {
|
|
1160
1465
|
return {
|
|
@@ -1168,9 +1473,14 @@ class WebAppTool extends ProjectTool2 {
|
|
|
1168
1473
|
|
|
1169
1474
|
// src/webapp-tool-factory.ts
|
|
1170
1475
|
class WebAppToolFactory {
|
|
1171
|
-
|
|
1476
|
+
commandRunner;
|
|
1477
|
+
readProjectIdentityAsync = readProjectIdentity;
|
|
1478
|
+
supportedTypes = [ProjectTypes4.AppV2];
|
|
1479
|
+
constructor(commandRunner) {
|
|
1480
|
+
this.commandRunner = commandRunner;
|
|
1481
|
+
}
|
|
1172
1482
|
async createAsync(logger, fileSystem) {
|
|
1173
|
-
return new WebAppTool(fileSystem, logger);
|
|
1483
|
+
return new WebAppTool(fileSystem, logger, this.commandRunner);
|
|
1174
1484
|
}
|
|
1175
1485
|
}
|
|
1176
1486
|
|
|
@@ -1192,6 +1502,8 @@ export {
|
|
|
1192
1502
|
WEBAPP_MANIFEST_FILE_NAME,
|
|
1193
1503
|
WebAppContributingToolFactory,
|
|
1194
1504
|
describeActionApp,
|
|
1505
|
+
describeDuplicateActionPropertyNames,
|
|
1506
|
+
findDuplicateActionPropertyNames,
|
|
1195
1507
|
isActionApp,
|
|
1196
1508
|
loadWebAppManifest,
|
|
1197
1509
|
parseActionSchema,
|
|
@@ -1199,4 +1511,4 @@ export {
|
|
|
1199
1511
|
validateActionSchema
|
|
1200
1512
|
};
|
|
1201
1513
|
|
|
1202
|
-
//# debugId=
|
|
1514
|
+
//# debugId=349E870CE8168AF664756E2164756E21
|