@uipath/packager-tool-connector 0.0.17

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 ADDED
@@ -0,0 +1,44 @@
1
+ # UiPath Connector Tool
2
+
3
+ A specialized Project Tool for building and packaging **UiPath Connector** projects.
4
+
5
+ ## Overview
6
+
7
+ The Connector Tool handles the specific requirements of Connector projects, including asset management and manifest validation. It is built on top of the `@uipath/solutionpackager-tool-core` framework.
8
+
9
+ ## Capabilities
10
+
11
+ - **Project Identification**: Automatically detects Connector projects based on project structure.
12
+ - **Build Process**:
13
+ - Validates connector assets
14
+ - Copies resource files recursively
15
+ - Flattens directory structures where required
16
+ - **Packaging**:
17
+ - Generates standard NuGet packages (`.nupkg`) suitable for UiPath Orchestrator or Marketplace.
18
+
19
+ ## Architecture
20
+
21
+ This package exports a `ConnectorToolFactory` which is registered with the main Solution Packager at runtime.
22
+
23
+ ### Key Classes
24
+
25
+ - **`ConnectorTool`**: Implements `buildAsync` and `packAsync`.
26
+ - **`ConnectorToolFactory`**: Checked against `ProjectTypes.Connector`.
27
+
28
+ ## Development
29
+
30
+ **Build:**
31
+
32
+ ```bash
33
+ npm run build
34
+ ```
35
+
36
+ **Test:**
37
+
38
+ ```bash
39
+ # Node.js environment
40
+ npm run test
41
+
42
+ # Browser environment (via Vitest/Playwright)
43
+ npm run test:browser
44
+ ```
@@ -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 Connector project tools
4
+ */
5
+ export declare class ConnectorToolFactory implements IProjectToolFactory {
6
+ readonly supportedTypes: readonly ProjectType[];
7
+ createAsync(logger: IToolLogger, fileSystem: IFileSystem): Promise<ProjectTool>;
8
+ }
@@ -0,0 +1,22 @@
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
+ * Connector project tool implementation
5
+ *
6
+ * Handles build and pack operations for Connector projects.
7
+ * Build copies the 'app' folder to the output content folder.
8
+ */
9
+ export declare class ConnectorTool extends ProjectTool {
10
+ private static readonly AppFolderName;
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
+ * Recursively copy a directory and its contents
20
+ */
21
+ private copyDirectory;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ // src/index.ts
2
+ import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
3
+
4
+ // src/connector-tool-factory.ts
5
+ import {
6
+ ProjectTypes
7
+ } from "@uipath/solutionpackager-tool-core";
8
+
9
+ // src/connector-tool.ts
10
+ import {
11
+ NugetConstants,
12
+ NugetPackager,
13
+ Path,
14
+ ProjectTool,
15
+ TemporaryStorageService,
16
+ ToolErrorCodes,
17
+ ToolResult
18
+ } from "@uipath/solutionpackager-tool-core";
19
+
20
+ class ConnectorTool extends ProjectTool {
21
+ static AppFolderName = "app";
22
+ _temporaryStorage;
23
+ constructor(fileSystem, logger) {
24
+ super(fileSystem, logger);
25
+ this._temporaryStorage = new TemporaryStorageService(fileSystem);
26
+ }
27
+ async restoreAsync(_options, _cancellationToken) {
28
+ this.logger.info("Restore operation is not required for Connector projects");
29
+ return ToolResult.success();
30
+ }
31
+ async validateAsync(_options, _cancellationToken) {
32
+ this.logger.info("Validate operation is not required for Connector projects");
33
+ return ToolResult.success();
34
+ }
35
+ async buildAsync(options, _cancellationToken) {
36
+ const tempFolder = await this._temporaryStorage.getTempFolderPath();
37
+ const localBuildFolder = Path.join(tempFolder, NugetConstants.OutputFolderName);
38
+ const appProjectFolder = Path.join(options.projectPath, ConnectorTool.AppFolderName);
39
+ const destinationFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName, ConnectorTool.AppFolderName);
40
+ try {
41
+ this.logger.progress("Copying app folder...");
42
+ await this.copyDirectory(appProjectFolder, destinationFolder);
43
+ return new ToolResult(ToolErrorCodes.Success, "done", [
44
+ localBuildFolder
45
+ ]);
46
+ } catch (error) {
47
+ const errorMessage = error instanceof Error ? error.toString() : String(error);
48
+ this.logger.error(errorMessage);
49
+ return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while building Connector project");
50
+ }
51
+ }
52
+ async packAsync(options, cancellationToken) {
53
+ const buildResult = await this.buildAsync(options, cancellationToken);
54
+ if (!buildResult.isSuccess) {
55
+ return buildResult;
56
+ }
57
+ const localBuildFolder = buildResult.packages[0];
58
+ try {
59
+ this.logger.progress("Creating NuGet package...");
60
+ const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
61
+ const nupkgPath = Path.join(options.outputPath, nupkgFileName);
62
+ const packager = new NugetPackager(this.fileSystem);
63
+ const result = await packager.packAsync(localBuildFolder, options.package, nupkgPath);
64
+ this.logger.progress("Package created successfully");
65
+ return new ToolResult(ToolErrorCodes.Success, "done", [
66
+ result.outputPath
67
+ ]);
68
+ } catch (error) {
69
+ const errorMessage = error instanceof Error ? error.toString() : String(error);
70
+ this.logger.error(errorMessage);
71
+ return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while packing Connector project");
72
+ }
73
+ }
74
+ async dispose() {
75
+ this.logger.info("Disposing Connector Tool");
76
+ try {
77
+ await this._temporaryStorage.cleanup();
78
+ } catch {}
79
+ }
80
+ async copyDirectory(sourcePath, destinationPath) {
81
+ await this.fileSystem.mkdir(destinationPath);
82
+ const entries = await this.fileSystem.readdir(sourcePath);
83
+ for (const entry of entries) {
84
+ const sourceEntry = Path.join(sourcePath, entry);
85
+ const destinationEntry = Path.join(destinationPath, entry);
86
+ const stat = await this.fileSystem.stat(sourceEntry);
87
+ if (stat?.isDirectory()) {
88
+ await this.copyDirectory(sourceEntry, destinationEntry);
89
+ } else if (stat?.isFile()) {
90
+ const content = await this.fileSystem.readFile(sourceEntry);
91
+ if (content) {
92
+ await this.fileSystem.writeFile(destinationEntry, content);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ // src/connector-tool-factory.ts
100
+ class ConnectorToolFactory {
101
+ supportedTypes = [ProjectTypes.Connector];
102
+ async createAsync(logger, fileSystem) {
103
+ return new ConnectorTool(fileSystem, logger);
104
+ }
105
+ }
106
+
107
+ // src/index.ts
108
+ toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory);
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@uipath/packager-tool-connector",
3
+ "version": "0.0.17",
4
+ "description": "UiPath Connector 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-connector"
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,23 @@
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 { ConnectorTool } from "./connector-tool.js";
10
+
11
+ /**
12
+ * Factory for creating Connector project tools
13
+ */
14
+ export class ConnectorToolFactory implements IProjectToolFactory {
15
+ readonly supportedTypes: readonly ProjectType[] = [ProjectTypes.Connector];
16
+
17
+ async createAsync(
18
+ logger: IToolLogger,
19
+ fileSystem: IFileSystem,
20
+ ): Promise<ProjectTool> {
21
+ return new ConnectorTool(fileSystem, logger);
22
+ }
23
+ }
@@ -0,0 +1,169 @@
1
+ import type {
2
+ IProjectBuildOptions,
3
+ IProjectPackOptions,
4
+ IProjectRestoreOptions,
5
+ IProjectValidateOptions,
6
+ } from "@uipath/solutionpackager-tool-core";
7
+ import {
8
+ type IFileSystem,
9
+ type IToolLogger,
10
+ NugetConstants,
11
+ NugetPackager,
12
+ Path,
13
+ ProjectTool,
14
+ TemporaryStorageService,
15
+ ToolErrorCodes,
16
+ ToolResult,
17
+ } from "@uipath/solutionpackager-tool-core";
18
+
19
+ /**
20
+ * Connector project tool implementation
21
+ *
22
+ * Handles build and pack operations for Connector projects.
23
+ * Build copies the 'app' folder to the output content folder.
24
+ */
25
+ export class ConnectorTool extends ProjectTool {
26
+ private static readonly AppFolderName = "app";
27
+ private readonly _temporaryStorage: TemporaryStorageService;
28
+
29
+ constructor(fileSystem: IFileSystem, logger: IToolLogger) {
30
+ super(fileSystem, logger);
31
+ this._temporaryStorage = new TemporaryStorageService(fileSystem);
32
+ }
33
+
34
+ override async restoreAsync(
35
+ _options: IProjectRestoreOptions,
36
+ _cancellationToken?: AbortSignal,
37
+ ): Promise<ToolResult> {
38
+ this.logger.info(
39
+ "Restore operation is not required for Connector projects",
40
+ );
41
+ return ToolResult.success();
42
+ }
43
+
44
+ override async validateAsync(
45
+ _options: IProjectValidateOptions,
46
+ _cancellationToken?: AbortSignal,
47
+ ): Promise<ToolResult> {
48
+ this.logger.info(
49
+ "Validate operation is not required for Connector projects",
50
+ );
51
+ return ToolResult.success();
52
+ }
53
+
54
+ override async buildAsync(
55
+ options: IProjectBuildOptions,
56
+ _cancellationToken?: AbortSignal,
57
+ ): Promise<ToolResult> {
58
+ const tempFolder = await this._temporaryStorage.getTempFolderPath();
59
+ const localBuildFolder = Path.join(
60
+ tempFolder,
61
+ NugetConstants.OutputFolderName,
62
+ );
63
+ const appProjectFolder = Path.join(
64
+ options.projectPath,
65
+ ConnectorTool.AppFolderName,
66
+ );
67
+ const destinationFolder = Path.join(
68
+ localBuildFolder,
69
+ NugetConstants.ContentFolderName,
70
+ ConnectorTool.AppFolderName,
71
+ );
72
+
73
+ try {
74
+ this.logger.progress("Copying app folder...");
75
+ await this.copyDirectory(appProjectFolder, destinationFolder);
76
+
77
+ return new ToolResult(ToolErrorCodes.Success, "done", [
78
+ localBuildFolder,
79
+ ]);
80
+ } catch (error) {
81
+ const errorMessage =
82
+ error instanceof Error ? error.toString() : String(error);
83
+ this.logger.error(errorMessage);
84
+ return ToolResult.error(
85
+ ToolErrorCodes.InternalError,
86
+ "An error occurred while building Connector project",
87
+ );
88
+ }
89
+ }
90
+
91
+ override async packAsync(
92
+ options: IProjectPackOptions,
93
+ cancellationToken?: AbortSignal,
94
+ ): Promise<ToolResult> {
95
+ // First, run the build step to prepare the bundle content
96
+ const buildResult = await this.buildAsync(options, cancellationToken);
97
+ if (!buildResult.isSuccess) {
98
+ return buildResult;
99
+ }
100
+
101
+ const localBuildFolder = buildResult.packages[0];
102
+
103
+ try {
104
+ // Create the NuGet package
105
+ this.logger.progress("Creating NuGet package...");
106
+
107
+ const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
108
+ const nupkgPath = Path.join(options.outputPath, nupkgFileName);
109
+
110
+ const packager = new NugetPackager(this.fileSystem);
111
+ const result = await packager.packAsync(
112
+ localBuildFolder,
113
+ options.package,
114
+ nupkgPath,
115
+ );
116
+
117
+ this.logger.progress("Package created successfully");
118
+ return new ToolResult(ToolErrorCodes.Success, "done", [
119
+ result.outputPath,
120
+ ]);
121
+ } catch (error) {
122
+ const errorMessage =
123
+ error instanceof Error ? error.toString() : String(error);
124
+ this.logger.error(errorMessage);
125
+ return ToolResult.error(
126
+ ToolErrorCodes.InternalError,
127
+ "An error occurred while packing Connector project",
128
+ );
129
+ }
130
+ }
131
+
132
+ override async dispose(): Promise<void> {
133
+ this.logger.info("Disposing Connector Tool");
134
+ try {
135
+ await this._temporaryStorage.cleanup();
136
+ } catch {
137
+ // Ignore errors during cleanup
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Recursively copy a directory and its contents
143
+ */
144
+ private async copyDirectory(
145
+ sourcePath: string,
146
+ destinationPath: string,
147
+ ): Promise<void> {
148
+ await this.fileSystem.mkdir(destinationPath);
149
+
150
+ const entries = await this.fileSystem.readdir(sourcePath);
151
+
152
+ for (const entry of entries) {
153
+ const sourceEntry = Path.join(sourcePath, entry);
154
+ const destinationEntry = Path.join(destinationPath, entry);
155
+
156
+ const stat = await this.fileSystem.stat(sourceEntry);
157
+ if (stat?.isDirectory()) {
158
+ // Recursively copy subdirectories
159
+ await this.copyDirectory(sourceEntry, destinationEntry);
160
+ } else if (stat?.isFile()) {
161
+ // Copy file
162
+ const content = await this.fileSystem.readFile(sourceEntry);
163
+ if (content) {
164
+ await this.fileSystem.writeFile(destinationEntry, content);
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ // Self-register Connector tool factory with the singleton repository
2
+ import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
3
+ import { ConnectorToolFactory } from "./connector-tool-factory.js";
4
+
5
+ toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory());