@uipath/maestro-tool 0.1.10 → 0.1.12
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/packager-tool.js +168 -0
- package/dist/tool.js +233 -352
- package/package.json +9 -9
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// ../packager/packager-tool-bpmn/src/index.ts
|
|
2
|
+
import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
|
|
3
|
+
|
|
4
|
+
// ../packager/packager-tool-bpmn/src/bpmn-tool-factory.ts
|
|
5
|
+
import {
|
|
6
|
+
ProjectTypes as ProjectTypes2
|
|
7
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
8
|
+
|
|
9
|
+
// ../packager/packager-tool-bpmn/src/bpmn-tool.ts
|
|
10
|
+
import {
|
|
11
|
+
NugetConstants,
|
|
12
|
+
NugetPackager,
|
|
13
|
+
Path,
|
|
14
|
+
ProjectTool,
|
|
15
|
+
ProjectTypes,
|
|
16
|
+
TemporaryStorageService,
|
|
17
|
+
ToolErrorCodes,
|
|
18
|
+
ToolResult
|
|
19
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
20
|
+
var BpmnConstants = {
|
|
21
|
+
EntryPointsFileName: "entry-points.json",
|
|
22
|
+
BindingsV2FileName: "bindings_v2.json"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
class BpmnTool extends ProjectTool {
|
|
26
|
+
_temporaryStorage;
|
|
27
|
+
constructor(fileSystem, logger) {
|
|
28
|
+
super(fileSystem, logger);
|
|
29
|
+
this._temporaryStorage = new TemporaryStorageService(fileSystem);
|
|
30
|
+
}
|
|
31
|
+
async restoreAsync(_options, _cancellationToken) {
|
|
32
|
+
this.logger.info("Restore operation is not required for ProcessOrchestration projects");
|
|
33
|
+
return ToolResult.success();
|
|
34
|
+
}
|
|
35
|
+
async validateAsync(_options, _cancellationToken) {
|
|
36
|
+
this.logger.info("Validate operation is not required for ProcessOrchestration projects");
|
|
37
|
+
return ToolResult.success();
|
|
38
|
+
}
|
|
39
|
+
async buildAsync(options, _cancellationToken) {
|
|
40
|
+
const tempFolder = await this._temporaryStorage.getTempFolderPath();
|
|
41
|
+
const localBuildFolder = Path.join(tempFolder, NugetConstants.OutputFolderName);
|
|
42
|
+
const contentFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName);
|
|
43
|
+
try {
|
|
44
|
+
this.logger.progress("Copying files...");
|
|
45
|
+
await this.copyFiles(options.projectPath, contentFolder);
|
|
46
|
+
this.logger.progress("Creating operate.json file...");
|
|
47
|
+
await this.createOperateFile(options, contentFolder);
|
|
48
|
+
this.logger.progress("Creating package-descriptor.json file...");
|
|
49
|
+
await this.createPackageDescriptor(localBuildFolder, contentFolder);
|
|
50
|
+
return new ToolResult(ToolErrorCodes.Success, "done", [
|
|
51
|
+
localBuildFolder
|
|
52
|
+
]);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.toString() : String(error);
|
|
55
|
+
this.logger.error(errorMessage);
|
|
56
|
+
return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while building ProcessOrchestration project files");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async packAsync(options, cancellationToken) {
|
|
60
|
+
const buildResult = await this.buildAsync(options, cancellationToken);
|
|
61
|
+
if (!buildResult.isSuccess) {
|
|
62
|
+
return buildResult;
|
|
63
|
+
}
|
|
64
|
+
const localBuildFolder = buildResult.packages[0];
|
|
65
|
+
try {
|
|
66
|
+
this.logger.progress("Creating NuGet package...");
|
|
67
|
+
const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
|
|
68
|
+
const nupkgPath = Path.join(options.outputPath, nupkgFileName);
|
|
69
|
+
const packager = new NugetPackager(this.fileSystem);
|
|
70
|
+
const result = await packager.packAsync(localBuildFolder, options.package, nupkgPath);
|
|
71
|
+
this.logger.progress("Package created successfully");
|
|
72
|
+
return new ToolResult(ToolErrorCodes.Success, "done", [
|
|
73
|
+
result.outputPath
|
|
74
|
+
]);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const errorMessage = error instanceof Error ? error.toString() : String(error);
|
|
77
|
+
this.logger.error(errorMessage);
|
|
78
|
+
return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while packing ProcessOrchestration project");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async dispose() {
|
|
82
|
+
this.logger.info("Disposing ProcessOrchestration Tool");
|
|
83
|
+
try {
|
|
84
|
+
await this._temporaryStorage.cleanup();
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
async copyFiles(sourcePath, destinationPath) {
|
|
88
|
+
await this.fileSystem.mkdir(destinationPath);
|
|
89
|
+
const files = await this.fileSystem.readdir(sourcePath);
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
const sourceFile = Path.join(sourcePath, file);
|
|
92
|
+
const destinationFile = Path.join(destinationPath, file);
|
|
93
|
+
const stat = await this.fileSystem.stat(sourceFile);
|
|
94
|
+
if (stat?.isFile()) {
|
|
95
|
+
const content = await this.fileSystem.readFile(sourceFile);
|
|
96
|
+
if (content) {
|
|
97
|
+
await this.fileSystem.writeFile(destinationFile, content);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async createOperateFile(options, contentFolder) {
|
|
103
|
+
const operateJsonFilePath = Path.join(contentFolder, NugetConstants.OperateFileName);
|
|
104
|
+
const exists = await this.fileSystem.exists(operateJsonFilePath);
|
|
105
|
+
if (!exists) {
|
|
106
|
+
await this.createOperateJsonFile(contentFolder, options.projectStorageId ?? "", operateJsonFilePath);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async createOperateJsonFile(projectPath, projectId, filePath) {
|
|
110
|
+
const entryPointsFilePath = Path.join(projectPath, BpmnConstants.EntryPointsFileName);
|
|
111
|
+
let mainPath = "";
|
|
112
|
+
const entryPointsExists = await this.fileSystem.exists(entryPointsFilePath);
|
|
113
|
+
if (entryPointsExists) {
|
|
114
|
+
const entryPointsContent = await this.fileSystem.readFile(entryPointsFilePath);
|
|
115
|
+
if (entryPointsContent) {
|
|
116
|
+
try {
|
|
117
|
+
const entryPointsText = new TextDecoder().decode(entryPointsContent);
|
|
118
|
+
const entryPoints = JSON.parse(entryPointsText);
|
|
119
|
+
mainPath = entryPoints.entryPoints?.[0]?.filePath ?? "";
|
|
120
|
+
} catch {}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const operateFileModel = {
|
|
124
|
+
$schema: "https://cloud.uipath.com/draft/2024-12/operate",
|
|
125
|
+
contentType: ProjectTypes.ProcessOrchestration,
|
|
126
|
+
projectId,
|
|
127
|
+
main: mainPath,
|
|
128
|
+
targetFramework: "Portable",
|
|
129
|
+
runtimeOptions: {
|
|
130
|
+
isAttended: false,
|
|
131
|
+
requiresUserInteraction: false
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const operateJsonString = JSON.stringify(operateFileModel, null, 2);
|
|
135
|
+
await this.fileSystem.writeFile(filePath, operateJsonString);
|
|
136
|
+
}
|
|
137
|
+
async createPackageDescriptor(localBuildFolder, contentFolder) {
|
|
138
|
+
const descriptorFiles = {};
|
|
139
|
+
descriptorFiles[NugetConstants.OperateFileName] = Path.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName);
|
|
140
|
+
descriptorFiles[BpmnConstants.EntryPointsFileName] = Path.join(NugetConstants.ContentFolderName, BpmnConstants.EntryPointsFileName);
|
|
141
|
+
descriptorFiles[NugetConstants.BindingsFileId] = Path.join(NugetConstants.ContentFolderName, BpmnConstants.BindingsV2FileName);
|
|
142
|
+
const contentFiles = await this.fileSystem.readdir(contentFolder);
|
|
143
|
+
for (const file of contentFiles) {
|
|
144
|
+
if (file.endsWith(".bpmn")) {
|
|
145
|
+
descriptorFiles[file] = Path.join(NugetConstants.ContentFolderName, file);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName);
|
|
149
|
+
const packageDescriptorJson = JSON.stringify({
|
|
150
|
+
$schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor",
|
|
151
|
+
files: descriptorFiles
|
|
152
|
+
}, null, 2);
|
|
153
|
+
await this.fileSystem.writeFile(packageDescriptorPath, packageDescriptorJson);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ../packager/packager-tool-bpmn/src/bpmn-tool-factory.ts
|
|
158
|
+
class BpmnToolFactory {
|
|
159
|
+
supportedTypes = [
|
|
160
|
+
ProjectTypes2.ProcessOrchestration
|
|
161
|
+
];
|
|
162
|
+
async createAsync(logger, fileSystem) {
|
|
163
|
+
return new BpmnTool(fileSystem, logger);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ../packager/packager-tool-bpmn/src/index.ts
|
|
168
|
+
toolsFactoryRepository.registerProjectToolFactory(new BpmnToolFactory);
|