@uipath/solutionpackager-tool-core 0.0.26
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/README.md +308 -0
- package/dist/filesystem/file-system.d.ts +1 -0
- package/dist/filesystem/file-system.js +0 -0
- package/dist/filesystem/index.d.ts +5 -0
- package/dist/filesystem/index.js +3 -0
- package/dist/filesystem/path.d.ts +53 -0
- package/dist/filesystem/path.js +47 -0
- package/dist/filesystem/temporary-storage-service.d.ts +31 -0
- package/dist/filesystem/temporary-storage-service.js +46 -0
- package/dist/filesystem/zip-service.d.ts +25 -0
- package/dist/filesystem/zip-service.js +41 -0
- package/dist/i18n/i18n-manager.d.ts +128 -0
- package/dist/i18n/i18n-manager.js +104 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/index.js +34 -0
- package/dist/i18n/locales/de.d.ts +37 -0
- package/dist/i18n/locales/de.js +38 -0
- package/dist/i18n/locales/en.d.ts +43 -0
- package/dist/i18n/locales/en.js +38 -0
- package/dist/i18n/locales/es-MX.d.ts +37 -0
- package/dist/i18n/locales/es-MX.js +38 -0
- package/dist/i18n/locales/es.d.ts +37 -0
- package/dist/i18n/locales/es.js +38 -0
- package/dist/i18n/locales/fr.d.ts +37 -0
- package/dist/i18n/locales/fr.js +38 -0
- package/dist/i18n/locales/ja.d.ts +37 -0
- package/dist/i18n/locales/ja.js +38 -0
- package/dist/i18n/locales/ko.d.ts +37 -0
- package/dist/i18n/locales/ko.js +38 -0
- package/dist/i18n/locales/pt-BR.d.ts +37 -0
- package/dist/i18n/locales/pt-BR.js +38 -0
- package/dist/i18n/locales/pt.d.ts +37 -0
- package/dist/i18n/locales/pt.js +38 -0
- package/dist/i18n/locales/ro.d.ts +37 -0
- package/dist/i18n/locales/ro.js +38 -0
- package/dist/i18n/locales/ru.d.ts +37 -0
- package/dist/i18n/locales/ru.js +38 -0
- package/dist/i18n/locales/tr.d.ts +37 -0
- package/dist/i18n/locales/tr.js +38 -0
- package/dist/i18n/locales/zh-CN.d.ts +37 -0
- package/dist/i18n/locales/zh-CN.js +38 -0
- package/dist/i18n/locales/zh-TW.d.ts +37 -0
- package/dist/i18n/locales/zh-TW.js +38 -0
- package/dist/i18n/locales/zu.d.ts +37 -0
- package/dist/i18n/locales/zu.js +38 -0
- package/dist/i18n/translation-service.d.ts +61 -0
- package/dist/i18n/translation-service.js +29 -0
- package/dist/i18n/types.d.ts +61 -0
- package/dist/i18n/types.js +20 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/models/build-configuration.d.ts +7 -0
- package/dist/models/build-configuration.js +6 -0
- package/dist/models/connection-info.d.ts +26 -0
- package/dist/models/connection-info.js +9 -0
- package/dist/models/index.d.ts +18 -0
- package/dist/models/index.js +8 -0
- package/dist/models/log-message.d.ts +28 -0
- package/dist/models/log-message.js +48 -0
- package/dist/models/nuget-constants.d.ts +34 -0
- package/dist/models/nuget-constants.js +10 -0
- package/dist/models/nuget-feed-model.d.ts +25 -0
- package/dist/models/nuget-feed-model.js +0 -0
- package/dist/models/nuget-package-info.d.ts +63 -0
- package/dist/models/nuget-package-info.js +0 -0
- package/dist/models/package-info.d.ts +29 -0
- package/dist/models/package-info.js +0 -0
- package/dist/models/project-options.d.ts +126 -0
- package/dist/models/project-options.js +7 -0
- package/dist/models/project-type.d.ts +21 -0
- package/dist/models/project-type.js +16 -0
- package/dist/models/solution-options.d.ts +72 -0
- package/dist/models/solution-options.js +0 -0
- package/dist/models/target-frameworks.d.ts +7 -0
- package/dist/models/target-frameworks.js +6 -0
- package/dist/models/tool-error-code.d.ts +18 -0
- package/dist/models/tool-error-code.js +7 -0
- package/dist/models/tool-result.d.ts +31 -0
- package/dist/models/tool-result.js +21 -0
- package/dist/models/uipath-project.d.ts +26 -0
- package/dist/models/uipath-project.js +0 -0
- package/dist/models/uipath-solution.d.ts +14 -0
- package/dist/models/uipath-solution.js +0 -0
- package/dist/package-descriptor/entry-points-file-model.d.ts +26 -0
- package/dist/package-descriptor/entry-points-file-model.js +0 -0
- package/dist/package-descriptor/index.d.ts +5 -0
- package/dist/package-descriptor/index.js +1 -0
- package/dist/package-descriptor/operate-file-model.d.ts +38 -0
- package/dist/package-descriptor/operate-file-model.js +0 -0
- package/dist/package-descriptor/package-descriptor-file-model.d.ts +12 -0
- package/dist/package-descriptor/package-descriptor-file-model.js +0 -0
- package/dist/package-descriptor/project-bindings-file-model.d.ts +82 -0
- package/dist/package-descriptor/project-bindings-file-model.js +7 -0
- package/dist/services/index.d.ts +10 -0
- package/dist/services/index.js +4 -0
- package/dist/services/nuget-packager.d.ts +39 -0
- package/dist/services/nuget-packager.js +105 -0
- package/dist/services/project-operation-context.d.ts +37 -0
- package/dist/services/project-operation-context.js +0 -0
- package/dist/services/project-tool-factory.d.ts +21 -0
- package/dist/services/project-tool-factory.js +0 -0
- package/dist/services/project-tool.d.ts +32 -0
- package/dist/services/project-tool.js +27 -0
- package/dist/services/solution-tool-factory.d.ts +14 -0
- package/dist/services/solution-tool-factory.js +0 -0
- package/dist/services/solution-tool.d.ts +32 -0
- package/dist/services/solution-tool.js +27 -0
- package/dist/services/tool-logger.d.ts +44 -0
- package/dist/services/tool-logger.js +0 -0
- package/dist/services/tools-factory-repository.d.ts +84 -0
- package/dist/services/tools-factory-repository.js +34 -0
- package/package.json +45 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { zipSync } from "fflate";
|
|
2
|
+
import { Path } from "../filesystem/path.js";
|
|
3
|
+
function escapeXml(str) {
|
|
4
|
+
if (null == str) return "";
|
|
5
|
+
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
6
|
+
}
|
|
7
|
+
function optionalElement(name, value) {
|
|
8
|
+
if (void 0 === value || "" === value) return "";
|
|
9
|
+
return ` <${name}>${escapeXml(value)}</${name}>\n`;
|
|
10
|
+
}
|
|
11
|
+
function generateDependenciesXml(dependencies) {
|
|
12
|
+
if (!dependencies || 0 === dependencies.length) return "";
|
|
13
|
+
const deps = dependencies.map((d)=>` <dependency id="${escapeXml(d.id)}" version="${escapeXml(d.version)}" />`).join("\n");
|
|
14
|
+
return ` <dependencies>\n${deps}\n </dependencies>\n`;
|
|
15
|
+
}
|
|
16
|
+
function generateRepositoryXml(packageInfo) {
|
|
17
|
+
if (!packageInfo.repositoryType || !packageInfo.repositoryUrl) return "";
|
|
18
|
+
let repoXml = ` <repository type="${escapeXml(packageInfo.repositoryType)}" url="${escapeXml(packageInfo.repositoryUrl)}"`;
|
|
19
|
+
if (packageInfo.repositoryBranch) repoXml += ` branch="${escapeXml(packageInfo.repositoryBranch)}"`;
|
|
20
|
+
if (packageInfo.repositoryCommit) repoXml += ` commit="${escapeXml(packageInfo.repositoryCommit)}"`;
|
|
21
|
+
repoXml += " />\n";
|
|
22
|
+
return repoXml;
|
|
23
|
+
}
|
|
24
|
+
function generateNuspecXml(packageInfo) {
|
|
25
|
+
const author = packageInfo.author?.trim() || "UiPath";
|
|
26
|
+
const description = packageInfo.description?.trim() || "Created by UiPath";
|
|
27
|
+
const title = packageInfo.title?.trim() || packageInfo.id;
|
|
28
|
+
const requireLicenseAcceptance = true === packageInfo.requireLicenseAcceptance ? "true" : "false";
|
|
29
|
+
const releaseNotes = packageInfo.releaseNotes ?? "";
|
|
30
|
+
const xml = `\uFEFF<?xml version="1.0" encoding="utf-8"?>
|
|
31
|
+
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
|
32
|
+
<metadata>
|
|
33
|
+
<id>${escapeXml(packageInfo.id)}</id>
|
|
34
|
+
<version>${escapeXml(packageInfo.version)}</version>
|
|
35
|
+
<title>${escapeXml(title)}</title>
|
|
36
|
+
<authors>${escapeXml(author)}</authors>
|
|
37
|
+
<requireLicenseAcceptance>${requireLicenseAcceptance}</requireLicenseAcceptance>
|
|
38
|
+
<description>${escapeXml(description)}</description>
|
|
39
|
+
<releaseNotes>${escapeXml(releaseNotes)}</releaseNotes>
|
|
40
|
+
${optionalElement("tags", packageInfo.tags)}${optionalElement("iconUrl", packageInfo.iconUrl)}${optionalElement("projectUrl", packageInfo.projectUrl)}${optionalElement("licenseUrl", packageInfo.licenseUrl)}${optionalElement("copyright", packageInfo.copyright)}${generateRepositoryXml(packageInfo)}${generateDependenciesXml(packageInfo.dependencies)} </metadata>
|
|
41
|
+
</package>
|
|
42
|
+
`;
|
|
43
|
+
return xml;
|
|
44
|
+
}
|
|
45
|
+
function generatePsmdcpXml(packageInfo) {
|
|
46
|
+
const author = packageInfo.author?.trim() || "UiPath";
|
|
47
|
+
const description = packageInfo.description?.trim() || "Created by UiPath";
|
|
48
|
+
return `<?xml version="1.0" encoding="utf-8"?>
|
|
49
|
+
<coreProperties xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">
|
|
50
|
+
<dc:creator>${escapeXml(author)}</dc:creator>
|
|
51
|
+
<dc:description>${escapeXml(description)}</dc:description>
|
|
52
|
+
<dc:identifier>${escapeXml(packageInfo.id)}</dc:identifier>
|
|
53
|
+
<version>${escapeXml(packageInfo.version)}</version>
|
|
54
|
+
<keywords></keywords>
|
|
55
|
+
<lastModifiedBy>NuGet.Packaging, Version=6.12.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35;.NET 5.0</lastModifiedBy>
|
|
56
|
+
</coreProperties>`;
|
|
57
|
+
}
|
|
58
|
+
class NugetPackager {
|
|
59
|
+
fileSystem;
|
|
60
|
+
constructor(fileSystem){
|
|
61
|
+
this.fileSystem = fileSystem;
|
|
62
|
+
}
|
|
63
|
+
async packAsync(rootPath, packageInfo, outputPath) {
|
|
64
|
+
const normalizedOutputPath = Path.normalize(outputPath);
|
|
65
|
+
const nuspecXml = generateNuspecXml(packageInfo);
|
|
66
|
+
const nuspecFileName = `${packageInfo.id}.nuspec`;
|
|
67
|
+
const fileEntries = await Path.walkDirectory(this.fileSystem, rootPath);
|
|
68
|
+
const zipContents = {};
|
|
69
|
+
const encoder = new TextEncoder();
|
|
70
|
+
const psmdcpId = Array.from({
|
|
71
|
+
length: 4
|
|
72
|
+
}, ()=>Math.floor(0x100000000 * Math.random()).toString(16).padStart(8, "0")).join("");
|
|
73
|
+
const psmdcpFileName = `${psmdcpId}.psmdcp`;
|
|
74
|
+
const psmdcpPath = `package/services/metadata/core-properties/${psmdcpFileName}`;
|
|
75
|
+
const contentTypesXml = `<?xml version="1.0" encoding="utf-8"?>
|
|
76
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
77
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
|
|
78
|
+
<Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
|
|
79
|
+
<Default Extension="uiproj" ContentType="application/octet" />
|
|
80
|
+
<Default Extension="json" ContentType="application/octet" />
|
|
81
|
+
<Default Extension="nuspec" ContentType="application/octet" />
|
|
82
|
+
</Types>`;
|
|
83
|
+
zipContents["[Content_Types].xml"] = encoder.encode(contentTypesXml);
|
|
84
|
+
const manifestRelId = `R${Date.now().toString(16).toUpperCase()}`;
|
|
85
|
+
const corePropsRelId = `R${(Date.now() + 1).toString(16).toUpperCase()}`;
|
|
86
|
+
const relsXml = `<?xml version="1.0" encoding="utf-8"?>
|
|
87
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
88
|
+
<Relationship Type="http://schemas.microsoft.com/packaging/2010/07/manifest" Target="/${nuspecFileName}" Id="${manifestRelId}" />
|
|
89
|
+
<Relationship Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="/${psmdcpPath}" Id="${corePropsRelId}" />
|
|
90
|
+
</Relationships>`;
|
|
91
|
+
zipContents["_rels/.rels"] = encoder.encode(relsXml);
|
|
92
|
+
zipContents[psmdcpPath] = encoder.encode(generatePsmdcpXml(packageInfo));
|
|
93
|
+
zipContents[nuspecFileName] = encoder.encode(nuspecXml);
|
|
94
|
+
for (const entry of fileEntries){
|
|
95
|
+
const content = await this.fileSystem.readFile(entry.absolutePath);
|
|
96
|
+
if (null !== content) zipContents[entry.relativePath] = content;
|
|
97
|
+
}
|
|
98
|
+
const zippedData = zipSync(zipContents);
|
|
99
|
+
await this.fileSystem.writeFile(normalizedOutputPath, zippedData);
|
|
100
|
+
return {
|
|
101
|
+
outputPath: normalizedOutputPath
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export { NugetPackager };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ConnectionInfo } from "../models/connection-info.js";
|
|
2
|
+
import type { TargetFramework } from "../models/target-frameworks.js";
|
|
3
|
+
import type { UiPathSolution } from "../models/uipath-solution.js";
|
|
4
|
+
import type { IToolLogger } from "./tool-logger.js";
|
|
5
|
+
/**
|
|
6
|
+
* Context for a project operation, providing information about the solution and all projects involved
|
|
7
|
+
*/
|
|
8
|
+
export interface ProjectOperationContext {
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for the operation
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* Solution containing the projects involved in the operation
|
|
15
|
+
*/
|
|
16
|
+
solution: UiPathSolution;
|
|
17
|
+
/**
|
|
18
|
+
* URL to download the solution snapshot for remote packing
|
|
19
|
+
*/
|
|
20
|
+
downloadUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Build configuration (e.g. "Debug", "Release")
|
|
23
|
+
*/
|
|
24
|
+
configuration: string;
|
|
25
|
+
/**
|
|
26
|
+
* Target framework for the package
|
|
27
|
+
*/
|
|
28
|
+
targetFramework: TargetFramework;
|
|
29
|
+
/**
|
|
30
|
+
* Connection information for the remote service
|
|
31
|
+
*/
|
|
32
|
+
connection?: ConnectionInfo;
|
|
33
|
+
/**
|
|
34
|
+
* Logger for the operation
|
|
35
|
+
*/
|
|
36
|
+
logger?: IToolLogger;
|
|
37
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IFileSystem } from "../filesystem/file-system.js";
|
|
2
|
+
import type { ProjectType } from "../models/project-type.js";
|
|
3
|
+
import type { ProjectOperationContext } from "./project-operation-context.js";
|
|
4
|
+
import type { ProjectTool } from "./project-tool.js";
|
|
5
|
+
import type { IToolLogger } from "./tool-logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Factory interface for creating ProjectTool instances
|
|
8
|
+
*/
|
|
9
|
+
export interface IProjectToolFactory {
|
|
10
|
+
/**
|
|
11
|
+
* The project types this factory can handle
|
|
12
|
+
*/
|
|
13
|
+
readonly supportedTypes: readonly ProjectType[];
|
|
14
|
+
/**
|
|
15
|
+
* Create a project tool instance with the provided logger
|
|
16
|
+
* @param logger - The tool logger
|
|
17
|
+
* @param fileSystem - The file system instance
|
|
18
|
+
* @param context - Optional operation context with id and sibling project info
|
|
19
|
+
*/
|
|
20
|
+
createAsync(logger: IToolLogger, fileSystem: IFileSystem, context?: ProjectOperationContext): Promise<ProjectTool>;
|
|
21
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IFileSystem } from "../filesystem/file-system.js";
|
|
2
|
+
import type { IProjectBuildOptions, IProjectPackOptions, IProjectRestoreOptions, IProjectValidateOptions } from "../models/project-options.js";
|
|
3
|
+
import { ToolResult } from "../models/tool-result.js";
|
|
4
|
+
import type { IToolLogger } from "./tool-logger.js";
|
|
5
|
+
/**
|
|
6
|
+
* Base class for project tools.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class ProjectTool {
|
|
9
|
+
protected readonly fileSystem: IFileSystem;
|
|
10
|
+
protected readonly logger: IToolLogger;
|
|
11
|
+
constructor(fileSystem: IFileSystem, logger: IToolLogger);
|
|
12
|
+
/**
|
|
13
|
+
* Restore project dependencies
|
|
14
|
+
*/
|
|
15
|
+
restoreAsync(_options: IProjectRestoreOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Validate project
|
|
18
|
+
*/
|
|
19
|
+
validateAsync(_options: IProjectValidateOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Build project
|
|
22
|
+
*/
|
|
23
|
+
buildAsync(_options: IProjectBuildOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Pack project
|
|
26
|
+
*/
|
|
27
|
+
packAsync(_options: IProjectPackOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Dispose resources - override in derived classes to clean up
|
|
30
|
+
*/
|
|
31
|
+
dispose(): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ToolResult } from "../models/tool-result.js";
|
|
2
|
+
class ProjectTool {
|
|
3
|
+
fileSystem;
|
|
4
|
+
logger;
|
|
5
|
+
constructor(fileSystem, logger){
|
|
6
|
+
this.fileSystem = fileSystem;
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
}
|
|
9
|
+
async restoreAsync(_options, _cancellationToken) {
|
|
10
|
+
this.logger.info("Restore operation is a noop");
|
|
11
|
+
return ToolResult.success();
|
|
12
|
+
}
|
|
13
|
+
async validateAsync(_options, _cancellationToken) {
|
|
14
|
+
this.logger.info("Validate operation is a noop");
|
|
15
|
+
return ToolResult.success();
|
|
16
|
+
}
|
|
17
|
+
async buildAsync(_options, _cancellationToken) {
|
|
18
|
+
this.logger.info("Build operation is a noop");
|
|
19
|
+
return ToolResult.success();
|
|
20
|
+
}
|
|
21
|
+
async packAsync(_options, _cancellationToken) {
|
|
22
|
+
this.logger.info("Pack operation is a noop");
|
|
23
|
+
return ToolResult.success();
|
|
24
|
+
}
|
|
25
|
+
async dispose() {}
|
|
26
|
+
}
|
|
27
|
+
export { ProjectTool };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IFileSystem } from "../filesystem/file-system.js";
|
|
2
|
+
import type { SolutionTool } from "./solution-tool.js";
|
|
3
|
+
import type { IToolLogger } from "./tool-logger.js";
|
|
4
|
+
/**
|
|
5
|
+
* Factory interface for creating SolutionTool instances
|
|
6
|
+
*/
|
|
7
|
+
export interface ISolutionToolFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Create a solution tool instance with the provided logger
|
|
10
|
+
* @param logger - The tool logger
|
|
11
|
+
* @param fileSystem - The file system instance
|
|
12
|
+
*/
|
|
13
|
+
createAsync(logger: IToolLogger, fileSystem: IFileSystem): Promise<SolutionTool>;
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IFileSystem } from "../filesystem/file-system.js";
|
|
2
|
+
import type { ISolutionBuildOptions, ISolutionPackOptions, ISolutionRestoreOptions, ISolutionValidateOptions } from "../models/solution-options.js";
|
|
3
|
+
import { ToolResult } from "../models/tool-result.js";
|
|
4
|
+
import type { IToolLogger } from "./tool-logger.js";
|
|
5
|
+
/**
|
|
6
|
+
* Base class for solution tools.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class SolutionTool {
|
|
9
|
+
protected readonly fileSystem: IFileSystem;
|
|
10
|
+
protected readonly logger: IToolLogger;
|
|
11
|
+
constructor(fileSystem: IFileSystem, logger: IToolLogger);
|
|
12
|
+
/**
|
|
13
|
+
* Restore solution dependencies
|
|
14
|
+
*/
|
|
15
|
+
restoreAsync(_options: ISolutionRestoreOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Validate solution
|
|
18
|
+
*/
|
|
19
|
+
validateAsync(_options: ISolutionValidateOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Build solution
|
|
22
|
+
*/
|
|
23
|
+
buildAsync(_options: ISolutionBuildOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Pack solution
|
|
26
|
+
*/
|
|
27
|
+
packAsync(_options: ISolutionPackOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Dispose resources
|
|
30
|
+
*/
|
|
31
|
+
dispose(): void | Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ToolResult } from "../models/tool-result.js";
|
|
2
|
+
class SolutionTool {
|
|
3
|
+
fileSystem;
|
|
4
|
+
logger;
|
|
5
|
+
constructor(fileSystem, logger){
|
|
6
|
+
this.fileSystem = fileSystem;
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
}
|
|
9
|
+
async restoreAsync(_options, _cancellationToken) {
|
|
10
|
+
this.logger.info("Restore operation is a noop");
|
|
11
|
+
return ToolResult.success();
|
|
12
|
+
}
|
|
13
|
+
async validateAsync(_options, _cancellationToken) {
|
|
14
|
+
this.logger.info("Validate operation is a noop");
|
|
15
|
+
return ToolResult.success();
|
|
16
|
+
}
|
|
17
|
+
async buildAsync(_options, _cancellationToken) {
|
|
18
|
+
this.logger.info("Build operation is a noop");
|
|
19
|
+
return ToolResult.success();
|
|
20
|
+
}
|
|
21
|
+
async packAsync(_options, _cancellationToken) {
|
|
22
|
+
this.logger.info("Pack operation is a noop");
|
|
23
|
+
return ToolResult.success();
|
|
24
|
+
}
|
|
25
|
+
dispose() {}
|
|
26
|
+
}
|
|
27
|
+
export { SolutionTool };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { LogLevel, LogMessage } from "../models/log-message.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for log messages
|
|
4
|
+
*/
|
|
5
|
+
export interface LogOptions {
|
|
6
|
+
code?: string;
|
|
7
|
+
filePath?: string;
|
|
8
|
+
line?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Interface for a logger that creates and outputs LogMessage instances
|
|
13
|
+
* Implementation is provided by the consumer (e.g., solutionpackager)
|
|
14
|
+
*/
|
|
15
|
+
export interface IToolLogger {
|
|
16
|
+
/**
|
|
17
|
+
* Log a debug level message
|
|
18
|
+
*/
|
|
19
|
+
debug(message: string, options?: LogOptions): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log an info level message
|
|
22
|
+
*/
|
|
23
|
+
info(message: string, options?: LogOptions): void;
|
|
24
|
+
/**
|
|
25
|
+
* Log a warning level message
|
|
26
|
+
*/
|
|
27
|
+
warn(message: string, options?: LogOptions): void;
|
|
28
|
+
/**
|
|
29
|
+
* Log an error level message
|
|
30
|
+
*/
|
|
31
|
+
error(message: string, options?: LogOptions): void;
|
|
32
|
+
/**
|
|
33
|
+
* Log a progress message
|
|
34
|
+
*/
|
|
35
|
+
progress(message: string, options?: LogOptions): void;
|
|
36
|
+
/**
|
|
37
|
+
* Log a message with a specific log level
|
|
38
|
+
*/
|
|
39
|
+
log(message: string, logLevel: LogLevel, options?: LogOptions): void;
|
|
40
|
+
/**
|
|
41
|
+
* Log a pre-constructed LogMessage
|
|
42
|
+
*/
|
|
43
|
+
logMessage(message: LogMessage): void;
|
|
44
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ProjectType } from "../models/project-type.js";
|
|
2
|
+
import type { IProjectToolFactory } from "./project-tool-factory.js";
|
|
3
|
+
import type { ISolutionToolFactory } from "./solution-tool-factory.js";
|
|
4
|
+
/**
|
|
5
|
+
* Configurator interface for registering tool factories.
|
|
6
|
+
* Allows tools to register their project and solution tool factories.
|
|
7
|
+
*/
|
|
8
|
+
export interface IToolsFactoryRepositoryConfigurator {
|
|
9
|
+
/**
|
|
10
|
+
* Register a project tool factory
|
|
11
|
+
*/
|
|
12
|
+
registerProjectToolFactory(factory: IProjectToolFactory): void;
|
|
13
|
+
/**
|
|
14
|
+
* Register the solution tool factory
|
|
15
|
+
*/
|
|
16
|
+
registerSolutionToolFactory(factory: ISolutionToolFactory): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Repository interface providing access to registered project and solution tool factories.
|
|
20
|
+
*/
|
|
21
|
+
export interface IToolsFactoryRepository {
|
|
22
|
+
/**
|
|
23
|
+
* Get the solution tool factory
|
|
24
|
+
* @returns The registered solution tool factory
|
|
25
|
+
* @throws Error if no solution tool factory is registered
|
|
26
|
+
*/
|
|
27
|
+
getSolutionToolFactory(): ISolutionToolFactory;
|
|
28
|
+
/**
|
|
29
|
+
* Check if there is a registered project tool factory for the specified project type
|
|
30
|
+
* @param projectType - The type of project
|
|
31
|
+
* @returns True if a factory is registered for the project type, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
canHandleProject(projectType: ProjectType): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get the registered project tool factory for the specified project type
|
|
36
|
+
* @param projectType - The type of project
|
|
37
|
+
* @throws Error if no factory is registered for the project type
|
|
38
|
+
* @returns The registered factory
|
|
39
|
+
*/
|
|
40
|
+
getProjectToolFactory(projectType: ProjectType): IProjectToolFactory;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Repository for managing tool factories.
|
|
44
|
+
* Implements both the configurator (for registration) and repository (for lookup) interfaces.
|
|
45
|
+
*/
|
|
46
|
+
export declare class ToolsFactoryRepository implements IToolsFactoryRepository, IToolsFactoryRepositoryConfigurator {
|
|
47
|
+
private projectFactoryMap;
|
|
48
|
+
private solutionFactory;
|
|
49
|
+
/**
|
|
50
|
+
* Register a project tool factory.
|
|
51
|
+
* Maps each of the factory's supported types to the factory.
|
|
52
|
+
* @throws Error if a project type is already registered by another factory
|
|
53
|
+
*/
|
|
54
|
+
registerProjectToolFactory(factory: IProjectToolFactory): void;
|
|
55
|
+
/**
|
|
56
|
+
* Register the solution tool factory
|
|
57
|
+
*/
|
|
58
|
+
registerSolutionToolFactory(factory: ISolutionToolFactory): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get the solution tool factory
|
|
61
|
+
* @returns The registered solution tool factory
|
|
62
|
+
* @throws Error if no solution tool factory is registered
|
|
63
|
+
*/
|
|
64
|
+
getSolutionToolFactory(): ISolutionToolFactory;
|
|
65
|
+
/**
|
|
66
|
+
* Check if there is a registered project tool factory for the specified project type
|
|
67
|
+
* @param projectType - The type of project
|
|
68
|
+
* @returns True if a factory is registered for the project type, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
canHandleProject(projectType: ProjectType): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get the registered project tool factory for the specified project type
|
|
73
|
+
* @param projectType - The type of project
|
|
74
|
+
* @throws Error if no factory is registered for the project type
|
|
75
|
+
* @returns The registered factory
|
|
76
|
+
*/
|
|
77
|
+
getProjectToolFactory(projectType: ProjectType): IProjectToolFactory;
|
|
78
|
+
/**
|
|
79
|
+
* Reset the repository by clearing all registered factories.
|
|
80
|
+
* Intended for use in tests only.
|
|
81
|
+
*/
|
|
82
|
+
reset(): void;
|
|
83
|
+
}
|
|
84
|
+
export declare const toolsFactoryRepository: ToolsFactoryRepository;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class ToolsFactoryRepository {
|
|
2
|
+
projectFactoryMap = new Map();
|
|
3
|
+
solutionFactory = null;
|
|
4
|
+
registerProjectToolFactory(factory) {
|
|
5
|
+
for (const type of factory.supportedTypes){
|
|
6
|
+
if (this.projectFactoryMap.has(type)) throw new Error(`A factory is already registered for project type '${type}'.`);
|
|
7
|
+
this.projectFactoryMap.set(type, factory);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
registerSolutionToolFactory(factory) {
|
|
11
|
+
this.solutionFactory = factory;
|
|
12
|
+
}
|
|
13
|
+
getSolutionToolFactory() {
|
|
14
|
+
if (!this.solutionFactory) throw new Error("No solution tool factory is registered");
|
|
15
|
+
return this.solutionFactory;
|
|
16
|
+
}
|
|
17
|
+
canHandleProject(projectType) {
|
|
18
|
+
return this.projectFactoryMap.has(projectType);
|
|
19
|
+
}
|
|
20
|
+
getProjectToolFactory(projectType) {
|
|
21
|
+
const factory = this.projectFactoryMap.get(projectType);
|
|
22
|
+
if (!factory) throw new Error(`No tool factory found for project type '${projectType}'`);
|
|
23
|
+
return factory;
|
|
24
|
+
}
|
|
25
|
+
reset() {
|
|
26
|
+
this.projectFactoryMap.clear();
|
|
27
|
+
this.solutionFactory = null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const REGISTRY_KEY = Symbol.for("@uipath/solutionpackager-tool-core/toolsFactoryRepository");
|
|
31
|
+
const _global = globalThis;
|
|
32
|
+
if (!_global[REGISTRY_KEY]) _global[REGISTRY_KEY] = new ToolsFactoryRepository();
|
|
33
|
+
const toolsFactoryRepository = _global[REGISTRY_KEY];
|
|
34
|
+
export { ToolsFactoryRepository, toolsFactoryRepository };
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uipath/solutionpackager-tool-core",
|
|
3
|
+
"version": "0.0.26",
|
|
4
|
+
"description": "UiPath contracts for solution packager tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "rslib build",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:browser": "vitest run --config=vitest.browser.config.ts",
|
|
17
|
+
"lint": "biome check ."
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/UiPath/Studio.Common.git",
|
|
27
|
+
"directory": "packager/uipath-solutionpackager-tool-core"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"registry": "https://registry.npmjs.org/"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@rslib/core": "^0.20.0",
|
|
34
|
+
"@types/node": "^25.5.0",
|
|
35
|
+
"@vitest/browser": "^4.0.14",
|
|
36
|
+
"@vitest/browser-playwright": "^4.0.14",
|
|
37
|
+
"@vitest/coverage-v8": "^4.0.14",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^4.0.14"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@uipath/filesystem": "^0.0.5",
|
|
43
|
+
"fflate": "^0.8.2"
|
|
44
|
+
}
|
|
45
|
+
}
|