@uipath/packager-tool-case 0.0.7
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/case-tool-factory.d.ts +8 -0
- package/dist/case-tool.d.ts +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +168 -0
- package/package.json +58 -0
- package/src/case-tool-factory.ts +25 -0
- package/src/case-tool.ts +304 -0
- package/src/index.ts +5 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IFileSystem, type IProjectToolFactory, type IToolLogger, type ProjectTool, type ProjectType } from "@uipath/solutionpackager-tool-core";
|
|
2
|
+
/**
|
|
3
|
+
* Factory for creating Case Management project tools
|
|
4
|
+
*/
|
|
5
|
+
export declare class CaseToolFactory implements IProjectToolFactory {
|
|
6
|
+
readonly supportedTypes: readonly ProjectType[];
|
|
7
|
+
createAsync(logger: IToolLogger, fileSystem: IFileSystem): Promise<ProjectTool>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IProjectBuildOptions, IProjectPackOptions, IProjectRestoreOptions, IProjectValidateOptions } from "@uipath/solutionpackager-tool-core";
|
|
2
|
+
import { type IFileSystem, type IToolLogger, ProjectTool, ToolResult } from "@uipath/solutionpackager-tool-core";
|
|
3
|
+
/**
|
|
4
|
+
* Case Management project tool implementation.
|
|
5
|
+
*
|
|
6
|
+
* Case Management projects use .stage.json source files that are converted
|
|
7
|
+
* to .bpmn format. All files are placed in the content/ folder (no separate
|
|
8
|
+
* source folder like flow_files/).
|
|
9
|
+
*/
|
|
10
|
+
export declare class CaseTool extends ProjectTool {
|
|
11
|
+
private readonly _temporaryStorage;
|
|
12
|
+
constructor(fileSystem: IFileSystem, logger: IToolLogger);
|
|
13
|
+
restoreAsync(_options: IProjectRestoreOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
14
|
+
validateAsync(_options: IProjectValidateOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
15
|
+
buildAsync(options: IProjectBuildOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
16
|
+
packAsync(options: IProjectPackOptions, cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
17
|
+
dispose(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Copy all files from source path to content/.
|
|
20
|
+
* Case Management projects keep all files in content/ (no separate folder).
|
|
21
|
+
*/
|
|
22
|
+
private copyFiles;
|
|
23
|
+
/**
|
|
24
|
+
* Create operate.json file if it doesn't already exist
|
|
25
|
+
*/
|
|
26
|
+
private createOperateFile;
|
|
27
|
+
/**
|
|
28
|
+
* Create the operate.json file with project configuration.
|
|
29
|
+
* Uses contentType "CaseManagement".
|
|
30
|
+
*/
|
|
31
|
+
private createOperateJsonFile;
|
|
32
|
+
/**
|
|
33
|
+
* Create package-descriptor.json file.
|
|
34
|
+
* Lists standard packaging files and .bpmn files from content/.
|
|
35
|
+
*/
|
|
36
|
+
private createPackageDescriptor;
|
|
37
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
|
|
3
|
+
|
|
4
|
+
// src/case-tool-factory.ts
|
|
5
|
+
import {
|
|
6
|
+
ProjectTypes as ProjectTypes2
|
|
7
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
8
|
+
|
|
9
|
+
// src/case-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 CaseConstants = {
|
|
21
|
+
EntryPointsFileName: "entry-points.json",
|
|
22
|
+
BindingsV2FileName: "bindings_v2.json"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
class CaseTool 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 Case Management projects");
|
|
33
|
+
return ToolResult.success();
|
|
34
|
+
}
|
|
35
|
+
async validateAsync(_options, _cancellationToken) {
|
|
36
|
+
this.logger.info("Validate operation is not required for Case Management 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 Case Management 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 Case Management project");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async dispose() {
|
|
82
|
+
this.logger.info("Disposing Case Management Tool");
|
|
83
|
+
try {
|
|
84
|
+
await this._temporaryStorage.cleanup();
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
async copyFiles(sourcePath, contentFolder) {
|
|
88
|
+
await this.fileSystem.mkdir(contentFolder);
|
|
89
|
+
const files = await this.fileSystem.readdir(sourcePath);
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
const sourceFile = Path.join(sourcePath, file);
|
|
92
|
+
const stat = await this.fileSystem.stat(sourceFile);
|
|
93
|
+
if (stat?.isFile()) {
|
|
94
|
+
const content = await this.fileSystem.readFile(sourceFile);
|
|
95
|
+
if (content) {
|
|
96
|
+
const destinationFile = Path.join(contentFolder, file);
|
|
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, CaseConstants.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.CaseManagement,
|
|
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[CaseConstants.EntryPointsFileName] = Path.join(NugetConstants.ContentFolderName, CaseConstants.EntryPointsFileName);
|
|
141
|
+
descriptorFiles[NugetConstants.BindingsFileId] = Path.join(NugetConstants.ContentFolderName, CaseConstants.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
|
+
// src/case-tool-factory.ts
|
|
158
|
+
class CaseToolFactory {
|
|
159
|
+
supportedTypes = [
|
|
160
|
+
ProjectTypes2.CaseManagement
|
|
161
|
+
];
|
|
162
|
+
async createAsync(logger, fileSystem) {
|
|
163
|
+
return new CaseTool(fileSystem, logger);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/index.ts
|
|
168
|
+
toolsFactoryRepository.registerProjectToolFactory(new CaseToolFactory);
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uipath/packager-tool-case",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"description": "UiPath Case Management 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-case"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core && tsc --emitDeclarationOnly --outDir dist",
|
|
23
|
+
"dev": "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --watch",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:browser": "vitest run --config=vitest.browser.config.ts",
|
|
26
|
+
"test:coverage": "vitest run --coverage",
|
|
27
|
+
"test:browser:coverage": "vitest run --config=vitest.browser.config.ts --coverage",
|
|
28
|
+
"test:all": "bun run test && bun run test:browser",
|
|
29
|
+
"test:all:coverage": "bun run test:coverage && bun run test:browser:coverage",
|
|
30
|
+
"prepack": "bun run build",
|
|
31
|
+
"publish:dry": "bun publish --dry-run",
|
|
32
|
+
"publish:gh": "bun publish",
|
|
33
|
+
"version:patch": "bun version patch --no-git-tag-version",
|
|
34
|
+
"version:minor": "bun version minor --no-git-tag-version",
|
|
35
|
+
"version:major": "bun version major --no-git-tag-version",
|
|
36
|
+
"lint": "biome check ."
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"!dist/**/*.map",
|
|
41
|
+
"src"
|
|
42
|
+
],
|
|
43
|
+
"author": "",
|
|
44
|
+
"license": "ISC",
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@uipath/solutionpackager-tool-core": "0.0.31"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^25.5.0",
|
|
50
|
+
"@uipath/solutionpackager-tool-core": "0.0.31",
|
|
51
|
+
"@vitest/browser": "^4.0.14",
|
|
52
|
+
"@vitest/browser-playwright": "^4.0.14",
|
|
53
|
+
"@vitest/coverage-v8": "^4.0.14",
|
|
54
|
+
"playwright": "^1.57.0",
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"vitest": "^4.0.14"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type IFileSystem,
|
|
3
|
+
type IProjectToolFactory,
|
|
4
|
+
type IToolLogger,
|
|
5
|
+
type ProjectTool,
|
|
6
|
+
type ProjectType,
|
|
7
|
+
ProjectTypes,
|
|
8
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
9
|
+
import { CaseTool } from "./case-tool.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Factory for creating Case Management project tools
|
|
13
|
+
*/
|
|
14
|
+
export class CaseToolFactory implements IProjectToolFactory {
|
|
15
|
+
readonly supportedTypes: readonly ProjectType[] = [
|
|
16
|
+
ProjectTypes.CaseManagement,
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
async createAsync(
|
|
20
|
+
logger: IToolLogger,
|
|
21
|
+
fileSystem: IFileSystem,
|
|
22
|
+
): Promise<ProjectTool> {
|
|
23
|
+
return new CaseTool(fileSystem, logger);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/case-tool.ts
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EntryPointsFileModel,
|
|
3
|
+
IProjectBuildOptions,
|
|
4
|
+
IProjectPackOptions,
|
|
5
|
+
IProjectRestoreOptions,
|
|
6
|
+
IProjectValidateOptions,
|
|
7
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
8
|
+
import {
|
|
9
|
+
type IFileSystem,
|
|
10
|
+
type IToolLogger,
|
|
11
|
+
NugetConstants,
|
|
12
|
+
NugetPackager,
|
|
13
|
+
Path,
|
|
14
|
+
ProjectTool,
|
|
15
|
+
ProjectTypes,
|
|
16
|
+
TemporaryStorageService,
|
|
17
|
+
ToolErrorCodes,
|
|
18
|
+
ToolResult,
|
|
19
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Case Management-specific file names
|
|
23
|
+
*/
|
|
24
|
+
const CaseConstants = {
|
|
25
|
+
EntryPointsFileName: "entry-points.json",
|
|
26
|
+
BindingsV2FileName: "bindings_v2.json",
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Case Management project tool implementation.
|
|
31
|
+
*
|
|
32
|
+
* Case Management projects use .stage.json source files that are converted
|
|
33
|
+
* to .bpmn format. All files are placed in the content/ folder (no separate
|
|
34
|
+
* source folder like flow_files/).
|
|
35
|
+
*/
|
|
36
|
+
export class CaseTool extends ProjectTool {
|
|
37
|
+
private readonly _temporaryStorage: TemporaryStorageService;
|
|
38
|
+
|
|
39
|
+
constructor(fileSystem: IFileSystem, logger: IToolLogger) {
|
|
40
|
+
super(fileSystem, logger);
|
|
41
|
+
this._temporaryStorage = new TemporaryStorageService(fileSystem);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override async restoreAsync(
|
|
45
|
+
_options: IProjectRestoreOptions,
|
|
46
|
+
_cancellationToken?: AbortSignal,
|
|
47
|
+
): Promise<ToolResult> {
|
|
48
|
+
this.logger.info(
|
|
49
|
+
"Restore operation is not required for Case Management projects",
|
|
50
|
+
);
|
|
51
|
+
return ToolResult.success();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override async validateAsync(
|
|
55
|
+
_options: IProjectValidateOptions,
|
|
56
|
+
_cancellationToken?: AbortSignal,
|
|
57
|
+
): Promise<ToolResult> {
|
|
58
|
+
this.logger.info(
|
|
59
|
+
"Validate operation is not required for Case Management projects",
|
|
60
|
+
);
|
|
61
|
+
return ToolResult.success();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
override async buildAsync(
|
|
65
|
+
options: IProjectBuildOptions,
|
|
66
|
+
_cancellationToken?: AbortSignal,
|
|
67
|
+
): Promise<ToolResult> {
|
|
68
|
+
const tempFolder = await this._temporaryStorage.getTempFolderPath();
|
|
69
|
+
const localBuildFolder = Path.join(
|
|
70
|
+
tempFolder,
|
|
71
|
+
NugetConstants.OutputFolderName,
|
|
72
|
+
);
|
|
73
|
+
const contentFolder = Path.join(
|
|
74
|
+
localBuildFolder,
|
|
75
|
+
NugetConstants.ContentFolderName,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
this.logger.progress("Copying files...");
|
|
80
|
+
await this.copyFiles(options.projectPath, contentFolder);
|
|
81
|
+
|
|
82
|
+
this.logger.progress("Creating operate.json file...");
|
|
83
|
+
await this.createOperateFile(options, contentFolder);
|
|
84
|
+
|
|
85
|
+
this.logger.progress("Creating package-descriptor.json file...");
|
|
86
|
+
await this.createPackageDescriptor(localBuildFolder, contentFolder);
|
|
87
|
+
|
|
88
|
+
return new ToolResult(ToolErrorCodes.Success, "done", [
|
|
89
|
+
localBuildFolder,
|
|
90
|
+
]);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
const errorMessage =
|
|
93
|
+
error instanceof Error ? error.toString() : String(error);
|
|
94
|
+
this.logger.error(errorMessage);
|
|
95
|
+
return ToolResult.error(
|
|
96
|
+
ToolErrorCodes.InternalError,
|
|
97
|
+
"An error occurred while building Case Management project files",
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
override async packAsync(
|
|
103
|
+
options: IProjectPackOptions,
|
|
104
|
+
cancellationToken?: AbortSignal,
|
|
105
|
+
): Promise<ToolResult> {
|
|
106
|
+
// First, run the build step to prepare the bundle content
|
|
107
|
+
const buildResult = await this.buildAsync(options, cancellationToken);
|
|
108
|
+
if (!buildResult.isSuccess) {
|
|
109
|
+
return buildResult;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const localBuildFolder = buildResult.packages[0];
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
// Create the NuGet package
|
|
116
|
+
this.logger.progress("Creating NuGet package...");
|
|
117
|
+
|
|
118
|
+
const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
|
|
119
|
+
const nupkgPath = Path.join(options.outputPath, nupkgFileName);
|
|
120
|
+
|
|
121
|
+
const packager = new NugetPackager(this.fileSystem);
|
|
122
|
+
const result = await packager.packAsync(
|
|
123
|
+
localBuildFolder,
|
|
124
|
+
options.package,
|
|
125
|
+
nupkgPath,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
this.logger.progress("Package created successfully");
|
|
129
|
+
return new ToolResult(ToolErrorCodes.Success, "done", [
|
|
130
|
+
result.outputPath,
|
|
131
|
+
]);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
const errorMessage =
|
|
134
|
+
error instanceof Error ? error.toString() : String(error);
|
|
135
|
+
this.logger.error(errorMessage);
|
|
136
|
+
return ToolResult.error(
|
|
137
|
+
ToolErrorCodes.InternalError,
|
|
138
|
+
"An error occurred while packing Case Management project",
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override async dispose(): Promise<void> {
|
|
144
|
+
this.logger.info("Disposing Case Management Tool");
|
|
145
|
+
try {
|
|
146
|
+
await this._temporaryStorage.cleanup();
|
|
147
|
+
} catch {
|
|
148
|
+
// Ignore errors during cleanup
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Copy all files from source path to content/.
|
|
154
|
+
* Case Management projects keep all files in content/ (no separate folder).
|
|
155
|
+
*/
|
|
156
|
+
private async copyFiles(
|
|
157
|
+
sourcePath: string,
|
|
158
|
+
contentFolder: string,
|
|
159
|
+
): Promise<void> {
|
|
160
|
+
await this.fileSystem.mkdir(contentFolder);
|
|
161
|
+
|
|
162
|
+
const files = await this.fileSystem.readdir(sourcePath);
|
|
163
|
+
|
|
164
|
+
for (const file of files) {
|
|
165
|
+
const sourceFile = Path.join(sourcePath, file);
|
|
166
|
+
|
|
167
|
+
const stat = await this.fileSystem.stat(sourceFile);
|
|
168
|
+
if (stat?.isFile()) {
|
|
169
|
+
const content = await this.fileSystem.readFile(sourceFile);
|
|
170
|
+
if (content) {
|
|
171
|
+
const destinationFile = Path.join(contentFolder, file);
|
|
172
|
+
await this.fileSystem.writeFile(destinationFile, content);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Create operate.json file if it doesn't already exist
|
|
180
|
+
*/
|
|
181
|
+
private async createOperateFile(
|
|
182
|
+
options: IProjectBuildOptions,
|
|
183
|
+
contentFolder: string,
|
|
184
|
+
): Promise<void> {
|
|
185
|
+
const operateJsonFilePath = Path.join(
|
|
186
|
+
contentFolder,
|
|
187
|
+
NugetConstants.OperateFileName,
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const exists = await this.fileSystem.exists(operateJsonFilePath);
|
|
191
|
+
if (!exists) {
|
|
192
|
+
await this.createOperateJsonFile(
|
|
193
|
+
contentFolder,
|
|
194
|
+
options.projectStorageId ?? "",
|
|
195
|
+
operateJsonFilePath,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Create the operate.json file with project configuration.
|
|
202
|
+
* Uses contentType "CaseManagement".
|
|
203
|
+
*/
|
|
204
|
+
private async createOperateJsonFile(
|
|
205
|
+
projectPath: string,
|
|
206
|
+
projectId: string,
|
|
207
|
+
filePath: string,
|
|
208
|
+
): Promise<void> {
|
|
209
|
+
const entryPointsFilePath = Path.join(
|
|
210
|
+
projectPath,
|
|
211
|
+
CaseConstants.EntryPointsFileName,
|
|
212
|
+
);
|
|
213
|
+
let mainPath = "";
|
|
214
|
+
|
|
215
|
+
const entryPointsExists =
|
|
216
|
+
await this.fileSystem.exists(entryPointsFilePath);
|
|
217
|
+
if (entryPointsExists) {
|
|
218
|
+
const entryPointsContent =
|
|
219
|
+
await this.fileSystem.readFile(entryPointsFilePath);
|
|
220
|
+
if (entryPointsContent) {
|
|
221
|
+
try {
|
|
222
|
+
const entryPointsText = new TextDecoder().decode(
|
|
223
|
+
entryPointsContent,
|
|
224
|
+
);
|
|
225
|
+
const entryPoints: EntryPointsFileModel =
|
|
226
|
+
JSON.parse(entryPointsText);
|
|
227
|
+
mainPath = entryPoints.entryPoints?.[0]?.filePath ?? "";
|
|
228
|
+
} catch {
|
|
229
|
+
// Ignore parsing errors, use empty mainPath
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const operateFileModel = {
|
|
235
|
+
$schema: "https://cloud.uipath.com/draft/2024-12/operate",
|
|
236
|
+
contentType: ProjectTypes.CaseManagement,
|
|
237
|
+
projectId: projectId,
|
|
238
|
+
main: mainPath,
|
|
239
|
+
targetFramework: "Portable",
|
|
240
|
+
runtimeOptions: {
|
|
241
|
+
isAttended: false,
|
|
242
|
+
requiresUserInteraction: false,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const operateJsonString = JSON.stringify(operateFileModel, null, 2);
|
|
247
|
+
await this.fileSystem.writeFile(filePath, operateJsonString);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Create package-descriptor.json file.
|
|
252
|
+
* Lists standard packaging files and .bpmn files from content/.
|
|
253
|
+
*/
|
|
254
|
+
private async createPackageDescriptor(
|
|
255
|
+
localBuildFolder: string,
|
|
256
|
+
contentFolder: string,
|
|
257
|
+
): Promise<void> {
|
|
258
|
+
const descriptorFiles: Record<string, string> = {};
|
|
259
|
+
|
|
260
|
+
// Standard packaging files
|
|
261
|
+
descriptorFiles[NugetConstants.OperateFileName] = Path.join(
|
|
262
|
+
NugetConstants.ContentFolderName,
|
|
263
|
+
NugetConstants.OperateFileName,
|
|
264
|
+
);
|
|
265
|
+
descriptorFiles[CaseConstants.EntryPointsFileName] = Path.join(
|
|
266
|
+
NugetConstants.ContentFolderName,
|
|
267
|
+
CaseConstants.EntryPointsFileName,
|
|
268
|
+
);
|
|
269
|
+
descriptorFiles[NugetConstants.BindingsFileId] = Path.join(
|
|
270
|
+
NugetConstants.ContentFolderName,
|
|
271
|
+
CaseConstants.BindingsV2FileName,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
// Add .bpmn files from content/
|
|
275
|
+
const contentFiles = await this.fileSystem.readdir(contentFolder);
|
|
276
|
+
for (const file of contentFiles) {
|
|
277
|
+
if (file.endsWith(".bpmn")) {
|
|
278
|
+
descriptorFiles[file] = Path.join(
|
|
279
|
+
NugetConstants.ContentFolderName,
|
|
280
|
+
file,
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const packageDescriptorPath = Path.join(
|
|
286
|
+
localBuildFolder,
|
|
287
|
+
NugetConstants.ContentFolderName,
|
|
288
|
+
NugetConstants.PackageDescriptorFileName,
|
|
289
|
+
);
|
|
290
|
+
const packageDescriptorJson = JSON.stringify(
|
|
291
|
+
{
|
|
292
|
+
$schema:
|
|
293
|
+
"https://cloud.uipath.com/draft/2024-12/package-descriptor",
|
|
294
|
+
files: descriptorFiles,
|
|
295
|
+
},
|
|
296
|
+
null,
|
|
297
|
+
2,
|
|
298
|
+
);
|
|
299
|
+
await this.fileSystem.writeFile(
|
|
300
|
+
packageDescriptorPath,
|
|
301
|
+
packageDescriptorJson,
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Self-register Case Management tool factory with the singleton repository
|
|
2
|
+
import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
|
|
3
|
+
import { CaseToolFactory } from "./case-tool-factory.js";
|
|
4
|
+
|
|
5
|
+
toolsFactoryRepository.registerProjectToolFactory(new CaseToolFactory());
|