@uipath/packager-tool-webapp 1.202.0-preview.140 → 1.202.0-preview.142
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/package.json +4 -8
- package/src/constants.ts +0 -81
- package/src/index.ts +0 -9
- package/src/models/webapp-manifest.ts +0 -46
- package/src/strategies/coded-app-strategy.ts +0 -475
- package/src/strategies/js-apps-strategy.ts +0 -378
- package/src/strategies/variant-strategy-factory.ts +0 -38
- package/src/strategies/variant-strategy.ts +0 -67
- package/src/utils/fs-helpers.ts +0 -58
- package/src/utils/manifest-loader.ts +0 -63
- package/src/webapp-tool-factory.ts +0 -23
- package/src/webapp-tool.ts +0 -269
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/packager-tool-webapp",
|
|
3
|
-
"version": "1.202.0-preview.
|
|
3
|
+
"version": "1.202.0-preview.142",
|
|
4
4
|
"description": "UiPath WebApp tool implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
-
".":
|
|
8
|
-
"source": "./src/index.ts",
|
|
9
|
-
"default": "./dist/index.js"
|
|
10
|
-
}
|
|
7
|
+
".": "./dist/index.js"
|
|
11
8
|
},
|
|
12
9
|
"repository": {
|
|
13
10
|
"type": "git",
|
|
@@ -19,13 +16,12 @@
|
|
|
19
16
|
},
|
|
20
17
|
"types": "./dist/index.d.ts",
|
|
21
18
|
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
"src"
|
|
19
|
+
"dist"
|
|
24
20
|
],
|
|
25
21
|
"author": "",
|
|
26
22
|
"license": "ISC",
|
|
27
23
|
"peerDependencies": {
|
|
28
24
|
"@uipath/solutionpackager-tool-core": "1.202.0"
|
|
29
25
|
},
|
|
30
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "2f7204440851d62ecc9f2d2e202c863293821d90"
|
|
31
27
|
}
|
package/src/constants.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constants used throughout the WebApp tool implementation
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* File names
|
|
7
|
-
*/
|
|
8
|
-
export const PROJECT_JSON_FILE = "project.json";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Default bundle path if not specified in manifest
|
|
12
|
-
*/
|
|
13
|
-
export const DEFAULT_BUNDLE_PATH = "source/dist";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Pre-built app folder for the JS variant (source)
|
|
17
|
-
*/
|
|
18
|
-
export const APP_FOLDER_NAME = ".app";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Destination folder inside the NuGet content folder for the JS variant
|
|
22
|
-
*/
|
|
23
|
-
export const CONTENT_APP_FOLDER_NAME = "app";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Target runtime for operate.json
|
|
27
|
-
*/
|
|
28
|
-
export const TARGET_RUNTIME = "Coded";
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Target runtime for operate.json
|
|
32
|
-
*/
|
|
33
|
-
export const TARGET_JS_RUNTIME = "JS";
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Default entry point type
|
|
37
|
-
*/
|
|
38
|
-
export const DEFAULT_ENTRY_POINT_TYPE = "api";
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Error messages
|
|
42
|
-
*/
|
|
43
|
-
export const ERROR_MESSAGES = {
|
|
44
|
-
MANIFEST_NOT_FOUND: (file: string): string =>
|
|
45
|
-
`WebApp manifest not found: ${file}. This file is required for WebApp projects.`,
|
|
46
|
-
|
|
47
|
-
PROJECT_JSON_FOUND:
|
|
48
|
-
"project.json found in WebApp project. The WebApp tool only supports Coded web apps without project.json.",
|
|
49
|
-
|
|
50
|
-
MANIFEST_LOAD_FAILED: (file: string): string =>
|
|
51
|
-
`Failed to load or parse ${file}`,
|
|
52
|
-
|
|
53
|
-
BUNDLE_NOT_FOUND: (path: string): string =>
|
|
54
|
-
`Compiled bundle not found at ${path}. Ensure the project is built before packing.`,
|
|
55
|
-
|
|
56
|
-
BUNDLE_NOT_DIRECTORY: (path: string): string =>
|
|
57
|
-
`Bundle path ${path} exists but is not a directory.`,
|
|
58
|
-
|
|
59
|
-
APP_FOLDER_NOT_FOUND: (path: string): string =>
|
|
60
|
-
`.app folder not found at ${path}. Ensure the project contains a .app folder.`,
|
|
61
|
-
|
|
62
|
-
APP_FOLDER_NOT_DIRECTORY: (path: string): string =>
|
|
63
|
-
`.app path ${path} exists but is not a directory.`,
|
|
64
|
-
|
|
65
|
-
BUILD_NOT_SUPPORTED:
|
|
66
|
-
"Build execution (isCompiled=false) is not yet supported. Please build the project manually and set isCompiled=true.",
|
|
67
|
-
|
|
68
|
-
VALIDATION_FAILED: (context: string): string =>
|
|
69
|
-
`Validation failed: ${context}`,
|
|
70
|
-
|
|
71
|
-
PACKING_FAILED: (context: string): string =>
|
|
72
|
-
`An error occurred while packing WebApp project: ${context}`,
|
|
73
|
-
|
|
74
|
-
PACKAGE_NAME_REQUIRED: "Package name is required",
|
|
75
|
-
|
|
76
|
-
PACKAGE_VERSION_REQUIRED: "Package version is required",
|
|
77
|
-
|
|
78
|
-
PROJECT_PATH_REQUIRED: "Project path is required",
|
|
79
|
-
|
|
80
|
-
OUTPUT_PATH_REQUIRED: "Output path is required",
|
|
81
|
-
} as const;
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// WebApp tool factory. Consumers register it explicitly via
|
|
2
|
-
// `toolsFactoryRepository.registerProjectToolFactory(new WebAppToolFactory())`.
|
|
3
|
-
export type { WebAppManifest } from "./models/webapp-manifest.js";
|
|
4
|
-
export {
|
|
5
|
-
WEBAPP_MANIFEST_FILE_NAME,
|
|
6
|
-
WebAppVariantType,
|
|
7
|
-
} from "./models/webapp-manifest.js";
|
|
8
|
-
export { WebAppTool } from "./webapp-tool.js";
|
|
9
|
-
export { WebAppToolFactory } from "./webapp-tool-factory.js";
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export enum WebAppVariantType {
|
|
2
|
-
Coded = "Coded",
|
|
3
|
-
JS = "JS",
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/** @public */
|
|
7
|
-
export enum AppSubType {
|
|
8
|
-
/** Coded app subtype that is registered with Solutions */
|
|
9
|
-
Coded = "Coded",
|
|
10
|
-
/** CodedAction app subtype that is registered with Solutions */
|
|
11
|
-
CodedAction = "CodedAction",
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Variant-specific configurations
|
|
16
|
-
*/
|
|
17
|
-
export interface CodedAppConfig {
|
|
18
|
-
/** If true: pack only; If false: build → pack (future) */
|
|
19
|
-
isCompiled?: boolean;
|
|
20
|
-
/** Compiled bundle folder location (default: dist/) */
|
|
21
|
-
bundlePath?: string;
|
|
22
|
-
/** Optional build command for future scenarios */
|
|
23
|
-
buildCommand?: string;
|
|
24
|
-
isActionApp?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface JsConfig {
|
|
28
|
-
// Placeholder for future properties specific to JS variant
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Map each variant to its specific config type */
|
|
33
|
-
type ManifestConfigMap = {
|
|
34
|
-
[WebAppVariantType.Coded]: CodedAppConfig;
|
|
35
|
-
[WebAppVariantType.JS]: JsConfig;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/** WebApp manifest type parameterized by variant */
|
|
39
|
-
export type WebAppManifest<T extends WebAppVariantType = WebAppVariantType> = {
|
|
40
|
-
type: T;
|
|
41
|
-
solutionResourceSubType: string;
|
|
42
|
-
config?: ManifestConfigMap[T];
|
|
43
|
-
projectId?: string;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const WEBAPP_MANIFEST_FILE_NAME = "webAppManifest.json";
|
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IFileSystem,
|
|
3
|
-
OperateFileModel,
|
|
4
|
-
PackageDescriptorFileModel,
|
|
5
|
-
} from "@uipath/solutionpackager-tool-core";
|
|
6
|
-
import {
|
|
7
|
-
NugetConstants,
|
|
8
|
-
NugetPackager,
|
|
9
|
-
Path,
|
|
10
|
-
ProjectTypes,
|
|
11
|
-
TargetFramework,
|
|
12
|
-
} from "@uipath/solutionpackager-tool-core";
|
|
13
|
-
import {
|
|
14
|
-
DEFAULT_BUNDLE_PATH,
|
|
15
|
-
DEFAULT_ENTRY_POINT_TYPE,
|
|
16
|
-
ERROR_MESSAGES,
|
|
17
|
-
TARGET_RUNTIME,
|
|
18
|
-
} from "../constants.js";
|
|
19
|
-
import type { WebAppManifest } from "../models/webapp-manifest.js";
|
|
20
|
-
import {
|
|
21
|
-
WEBAPP_MANIFEST_FILE_NAME,
|
|
22
|
-
type WebAppVariantType,
|
|
23
|
-
} from "../models/webapp-manifest.js";
|
|
24
|
-
import { copyDirectoryAsync } from "../utils/fs-helpers.js";
|
|
25
|
-
import { ensureWebAppProjectId } from "../utils/manifest-loader.js";
|
|
26
|
-
import type { PackageArgs, VariantStrategy } from "./variant-strategy.js";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Coded app strategy for Coded variant
|
|
30
|
-
* Supports isCompiled=true (v1) and isCompiled=false (future)
|
|
31
|
-
*/
|
|
32
|
-
export class CodedAppStrategy implements VariantStrategy {
|
|
33
|
-
constructor(private readonly fileSystem: IFileSystem) {}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Variant-specific validation: warn if compiled bundle is expected but missing
|
|
37
|
-
*/
|
|
38
|
-
async validateAsync(args: {
|
|
39
|
-
fileSystem: IFileSystem;
|
|
40
|
-
projectPath: string;
|
|
41
|
-
manifest: WebAppManifest;
|
|
42
|
-
logger?: {
|
|
43
|
-
info: (message: string) => void;
|
|
44
|
-
error: (message: string) => void;
|
|
45
|
-
progress: (message: string) => void;
|
|
46
|
-
};
|
|
47
|
-
}): Promise<void> {
|
|
48
|
-
const { projectPath, manifest, logger } = args;
|
|
49
|
-
|
|
50
|
-
// Narrow manifest to Coded to read typed config safely
|
|
51
|
-
const typed = manifest as WebAppManifest<WebAppVariantType.Coded>;
|
|
52
|
-
let bundlePath = typed.config?.bundlePath;
|
|
53
|
-
if (typeof bundlePath !== "string" || bundlePath.length === 0) {
|
|
54
|
-
bundlePath = DEFAULT_BUNDLE_PATH;
|
|
55
|
-
}
|
|
56
|
-
const isCompiled = typed.config?.isCompiled ?? true;
|
|
57
|
-
|
|
58
|
-
if (isCompiled) {
|
|
59
|
-
const fullBundlePath = Path.join(projectPath, bundlePath);
|
|
60
|
-
const exists = await this.fileSystem.exists(fullBundlePath);
|
|
61
|
-
if (!exists) {
|
|
62
|
-
const message = ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath);
|
|
63
|
-
|
|
64
|
-
// Prefer `warn` if available on the provided logger, otherwise fall back to `info`.
|
|
65
|
-
const warnable = logger as
|
|
66
|
-
| { warn?: (message: string) => void }
|
|
67
|
-
| undefined;
|
|
68
|
-
if (warnable?.warn) {
|
|
69
|
-
warnable.warn(message);
|
|
70
|
-
} else {
|
|
71
|
-
logger?.info(`Warning: ${message}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async packageAsync(args: PackageArgs): Promise<string> {
|
|
78
|
-
const { projectPath, manifest, outputPath, packageInfo, logger } = args;
|
|
79
|
-
|
|
80
|
-
logger?.info(
|
|
81
|
-
`Packaging Coded variant: ${packageInfo.id}@${packageInfo.version}`,
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
// Get bundle path from manifest or use default
|
|
85
|
-
let bundlePath = (manifest as WebAppManifest<WebAppVariantType.Coded>)
|
|
86
|
-
.config?.bundlePath;
|
|
87
|
-
if (typeof bundlePath !== "string" || bundlePath.length === 0) {
|
|
88
|
-
bundlePath = DEFAULT_BUNDLE_PATH;
|
|
89
|
-
}
|
|
90
|
-
const isCompiled =
|
|
91
|
-
(manifest as WebAppManifest<WebAppVariantType.Coded>).config
|
|
92
|
-
?.isCompiled ?? true;
|
|
93
|
-
|
|
94
|
-
const fullBundlePath = Path.join(projectPath, bundlePath);
|
|
95
|
-
|
|
96
|
-
// Validate compiled bundle exists (for v1, isCompiled=true)
|
|
97
|
-
if (isCompiled) {
|
|
98
|
-
logger?.progress("Validating compiled bundle...");
|
|
99
|
-
const bundleExists = await this.fileSystem.exists(fullBundlePath);
|
|
100
|
-
if (!bundleExists) {
|
|
101
|
-
throw new Error(
|
|
102
|
-
ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath),
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const bundleStat = await this.fileSystem.stat(fullBundlePath);
|
|
107
|
-
if (!bundleStat?.isDirectory()) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
ERROR_MESSAGES.BUNDLE_NOT_DIRECTORY(fullBundlePath),
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
// Future: Run build command
|
|
114
|
-
logger?.info(
|
|
115
|
-
"Build mode (isCompiled=false) is not yet implemented in v1.",
|
|
116
|
-
);
|
|
117
|
-
throw new Error(ERROR_MESSAGES.BUILD_NOT_SUPPORTED);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Create bundle directory structure (similar to api-workflow)
|
|
121
|
-
const localBuildFolder = Path.join(
|
|
122
|
-
outputPath,
|
|
123
|
-
NugetConstants.OutputFolderName,
|
|
124
|
-
);
|
|
125
|
-
const contentFolder = Path.join(
|
|
126
|
-
localBuildFolder,
|
|
127
|
-
NugetConstants.ContentFolderName,
|
|
128
|
-
);
|
|
129
|
-
await this.fileSystem.mkdir(contentFolder);
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
// Copy bundle to content folder
|
|
133
|
-
logger?.progress("Copying bundle to content folder...");
|
|
134
|
-
await copyDirectoryAsync(
|
|
135
|
-
this.fileSystem,
|
|
136
|
-
fullBundlePath,
|
|
137
|
-
contentFolder,
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
// Prepare metadata files
|
|
141
|
-
logger?.progress("Preparing metadata files...");
|
|
142
|
-
await this.prepareMetadataFiles(
|
|
143
|
-
localBuildFolder,
|
|
144
|
-
contentFolder,
|
|
145
|
-
packageInfo,
|
|
146
|
-
manifest,
|
|
147
|
-
projectPath,
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
// Create the NuGet package using native packager
|
|
151
|
-
logger?.progress("Creating NuGet package...");
|
|
152
|
-
const nupkgFileName = `${packageInfo.id}.${packageInfo.version}.nupkg`;
|
|
153
|
-
const nupkgPath = Path.join(outputPath, nupkgFileName);
|
|
154
|
-
|
|
155
|
-
const packager = new NugetPackager(this.fileSystem);
|
|
156
|
-
const result = await packager.packAsync(
|
|
157
|
-
localBuildFolder,
|
|
158
|
-
packageInfo,
|
|
159
|
-
nupkgPath,
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
logger?.info(`Package created successfully: ${result.outputPath}`);
|
|
163
|
-
return result.outputPath;
|
|
164
|
-
} finally {
|
|
165
|
-
// Always cleanup the temporary build folder
|
|
166
|
-
try {
|
|
167
|
-
await this.fileSystem.rm(localBuildFolder);
|
|
168
|
-
} catch (cleanupError) {
|
|
169
|
-
logger?.error(
|
|
170
|
-
`Failed to cleanup build folder: ${
|
|
171
|
-
cleanupError instanceof Error
|
|
172
|
-
? cleanupError.message
|
|
173
|
-
: String(cleanupError)
|
|
174
|
-
}`,
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Prepare metadata files (operate.json, package-descriptor.json, bindings.json, bindings_v2.json, entry-points.json)
|
|
182
|
-
*/
|
|
183
|
-
private async prepareMetadataFiles(
|
|
184
|
-
_localBuildFolder: string,
|
|
185
|
-
contentFolder: string,
|
|
186
|
-
_packageInfo: {
|
|
187
|
-
id: string;
|
|
188
|
-
version: string;
|
|
189
|
-
author?: string;
|
|
190
|
-
description?: string;
|
|
191
|
-
},
|
|
192
|
-
_manifest: WebAppManifest,
|
|
193
|
-
projectPath: string,
|
|
194
|
-
): Promise<void> {
|
|
195
|
-
// Determine main file - check for index.html or use default
|
|
196
|
-
let mainFile = "index.html";
|
|
197
|
-
const indexHtmlPath = Path.join(contentFolder, "index.html");
|
|
198
|
-
const indexHtmlExists = await this.fileSystem.exists(indexHtmlPath);
|
|
199
|
-
if (!indexHtmlExists) {
|
|
200
|
-
// Check for other common entry points
|
|
201
|
-
const possibleEntries = ["index.html", "main.html", "app.html"];
|
|
202
|
-
for (const entry of possibleEntries) {
|
|
203
|
-
const entryPath = Path.join(contentFolder, entry);
|
|
204
|
-
if (await this.fileSystem.exists(entryPath)) {
|
|
205
|
-
mainFile = entry;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Create operate.json in content folder
|
|
212
|
-
const operatePath = Path.join(
|
|
213
|
-
contentFolder,
|
|
214
|
-
NugetConstants.OperateFileName,
|
|
215
|
-
);
|
|
216
|
-
const operateModel: OperateFileModel & { targetRuntime: string } = {
|
|
217
|
-
projectId: await ensureWebAppProjectId(
|
|
218
|
-
this.fileSystem,
|
|
219
|
-
projectPath,
|
|
220
|
-
),
|
|
221
|
-
main: mainFile,
|
|
222
|
-
contentType: ProjectTypes.WebApp,
|
|
223
|
-
targetFramework: TargetFramework.Portable,
|
|
224
|
-
targetRuntime: TARGET_RUNTIME,
|
|
225
|
-
runtimeOptions: {
|
|
226
|
-
requiresUserInteraction: false,
|
|
227
|
-
isAttended: false,
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const operateJson = JSON.stringify(operateModel, null, 2);
|
|
232
|
-
await this.fileSystem.writeFile(operatePath, operateJson);
|
|
233
|
-
|
|
234
|
-
// Copy webAppManifest.json from project root into content (as-is)
|
|
235
|
-
const manifestSourcePath = Path.join(
|
|
236
|
-
projectPath,
|
|
237
|
-
WEBAPP_MANIFEST_FILE_NAME,
|
|
238
|
-
);
|
|
239
|
-
const manifestDestPath = Path.join(
|
|
240
|
-
contentFolder,
|
|
241
|
-
WEBAPP_MANIFEST_FILE_NAME,
|
|
242
|
-
);
|
|
243
|
-
const manifestExists = await this.fileSystem.exists(manifestSourcePath);
|
|
244
|
-
if (manifestExists) {
|
|
245
|
-
const manifestContent = await this.fileSystem.readFile(
|
|
246
|
-
manifestSourcePath,
|
|
247
|
-
"utf-8",
|
|
248
|
-
);
|
|
249
|
-
if (manifestContent) {
|
|
250
|
-
await this.fileSystem.writeFile(
|
|
251
|
-
manifestDestPath,
|
|
252
|
-
manifestContent,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Copy uipath.json from project root into content (if it exists)
|
|
258
|
-
const uipathJsonSourcePath = Path.join(projectPath, "uipath.json");
|
|
259
|
-
const uipathJsonDestPath = Path.join(contentFolder, "uipath.json");
|
|
260
|
-
const uipathJsonExists =
|
|
261
|
-
await this.fileSystem.exists(uipathJsonSourcePath);
|
|
262
|
-
if (uipathJsonExists) {
|
|
263
|
-
const uipathJsonContent = await this.fileSystem.readFile(
|
|
264
|
-
uipathJsonSourcePath,
|
|
265
|
-
"utf-8",
|
|
266
|
-
);
|
|
267
|
-
if (uipathJsonContent) {
|
|
268
|
-
await this.fileSystem.writeFile(
|
|
269
|
-
uipathJsonDestPath,
|
|
270
|
-
uipathJsonContent,
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Copy action-schema.json from project root into content (if it exists)
|
|
276
|
-
const actionSchemaSourcePath = Path.join(
|
|
277
|
-
projectPath,
|
|
278
|
-
"action-schema.json",
|
|
279
|
-
);
|
|
280
|
-
const actionSchemaDestPath = Path.join(
|
|
281
|
-
contentFolder,
|
|
282
|
-
"action-schema.json",
|
|
283
|
-
);
|
|
284
|
-
const actionSchemaExists = await this.fileSystem.exists(
|
|
285
|
-
actionSchemaSourcePath,
|
|
286
|
-
);
|
|
287
|
-
if (actionSchemaExists) {
|
|
288
|
-
const actionSchemaContent = await this.fileSystem.readFile(
|
|
289
|
-
actionSchemaSourcePath,
|
|
290
|
-
"utf-8",
|
|
291
|
-
);
|
|
292
|
-
if (actionSchemaContent) {
|
|
293
|
-
await this.fileSystem.writeFile(
|
|
294
|
-
actionSchemaDestPath,
|
|
295
|
-
actionSchemaContent,
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Create or copy bindings.json (version 1.0)
|
|
301
|
-
const bindingsPath = Path.join(contentFolder, "bindings.json");
|
|
302
|
-
const bindingsExists = await this.fileSystem.exists(bindingsPath);
|
|
303
|
-
|
|
304
|
-
if (!bindingsExists) {
|
|
305
|
-
const bindingsJson = JSON.stringify(
|
|
306
|
-
{
|
|
307
|
-
version: "1.0",
|
|
308
|
-
resources: [],
|
|
309
|
-
},
|
|
310
|
-
null,
|
|
311
|
-
2,
|
|
312
|
-
);
|
|
313
|
-
await this.fileSystem.writeFile(bindingsPath, bindingsJson);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Create or copy bindings_v2.json (version 2.0)
|
|
317
|
-
const bindingsV2Path = Path.join(contentFolder, "bindings_v2.json");
|
|
318
|
-
const bindingsCandidatePaths = [
|
|
319
|
-
Path.join(projectPath, "source", "bindings_v2.json"),
|
|
320
|
-
Path.join(projectPath, "source", "bindings.json"),
|
|
321
|
-
Path.join(projectPath, "bindings.json"),
|
|
322
|
-
Path.join(projectPath, "bindings_v2.json"),
|
|
323
|
-
];
|
|
324
|
-
|
|
325
|
-
let bindingsV2Json: string | null = null;
|
|
326
|
-
for (const candidate of bindingsCandidatePaths) {
|
|
327
|
-
if (await this.fileSystem.exists(candidate)) {
|
|
328
|
-
bindingsV2Json = await this.fileSystem.readFile(
|
|
329
|
-
candidate,
|
|
330
|
-
"utf-8",
|
|
331
|
-
);
|
|
332
|
-
if (bindingsV2Json) break;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (!bindingsV2Json && (await this.fileSystem.exists(bindingsV2Path))) {
|
|
337
|
-
bindingsV2Json = await this.fileSystem.readFile(
|
|
338
|
-
bindingsV2Path,
|
|
339
|
-
"utf-8",
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (!bindingsV2Json) {
|
|
344
|
-
bindingsV2Json = JSON.stringify(
|
|
345
|
-
{
|
|
346
|
-
version: "2.0",
|
|
347
|
-
resources: [],
|
|
348
|
-
},
|
|
349
|
-
null,
|
|
350
|
-
2,
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
await this.fileSystem.writeFile(bindingsV2Path, bindingsV2Json);
|
|
354
|
-
|
|
355
|
-
// Create or copy entry-points.json
|
|
356
|
-
const entryPointsPath = Path.join(contentFolder, "entry-points.json");
|
|
357
|
-
const projectEntryPointsPath = Path.join(
|
|
358
|
-
projectPath,
|
|
359
|
-
"entry-points.json",
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
let entryPointsContent: string;
|
|
363
|
-
const projectEntryPointsExists = await this.fileSystem.exists(
|
|
364
|
-
projectEntryPointsPath,
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
if (projectEntryPointsExists) {
|
|
368
|
-
const entryPointsData = await this.fileSystem.readFile(
|
|
369
|
-
projectEntryPointsPath,
|
|
370
|
-
"utf-8",
|
|
371
|
-
);
|
|
372
|
-
if (entryPointsData) {
|
|
373
|
-
entryPointsContent = entryPointsData;
|
|
374
|
-
} else {
|
|
375
|
-
entryPointsContent = this.createDefaultEntryPoints(mainFile);
|
|
376
|
-
}
|
|
377
|
-
} else {
|
|
378
|
-
entryPointsContent = this.createDefaultEntryPoints(mainFile);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
await this.fileSystem.writeFile(entryPointsPath, entryPointsContent);
|
|
382
|
-
|
|
383
|
-
// Create package-descriptor.json in content folder
|
|
384
|
-
const packageDescriptorPath = Path.join(
|
|
385
|
-
contentFolder,
|
|
386
|
-
NugetConstants.PackageDescriptorFileName,
|
|
387
|
-
);
|
|
388
|
-
const packageDescriptor: PackageDescriptorFileModel = {
|
|
389
|
-
$schema:
|
|
390
|
-
"https://cloud.uipath.com/draft/2024-12/package-descriptor",
|
|
391
|
-
files: {
|
|
392
|
-
[NugetConstants.OperateFileName]: Path.join(
|
|
393
|
-
NugetConstants.ContentFolderName,
|
|
394
|
-
NugetConstants.OperateFileName,
|
|
395
|
-
),
|
|
396
|
-
"entry-points.json": Path.join(
|
|
397
|
-
NugetConstants.ContentFolderName,
|
|
398
|
-
"entry-points.json",
|
|
399
|
-
),
|
|
400
|
-
"bindings.json": Path.join(
|
|
401
|
-
NugetConstants.ContentFolderName,
|
|
402
|
-
"bindings_v2.json",
|
|
403
|
-
),
|
|
404
|
-
},
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
const packageDescriptorJson = JSON.stringify(
|
|
408
|
-
packageDescriptor,
|
|
409
|
-
null,
|
|
410
|
-
2,
|
|
411
|
-
);
|
|
412
|
-
await this.fileSystem.writeFile(
|
|
413
|
-
packageDescriptorPath,
|
|
414
|
-
packageDescriptorJson,
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Create default entry-points.json structure
|
|
420
|
-
*/
|
|
421
|
-
private createDefaultEntryPoints(mainFile: string): string {
|
|
422
|
-
const uniqueId = this.generateUniqueId();
|
|
423
|
-
|
|
424
|
-
const entryPoints = {
|
|
425
|
-
$schema: "https://cloud.uipath.com/draft/2024-12/entry-point",
|
|
426
|
-
$id: "entry-points-doc-001",
|
|
427
|
-
entryPoints: [
|
|
428
|
-
{
|
|
429
|
-
filePath: mainFile,
|
|
430
|
-
uniqueId: uniqueId,
|
|
431
|
-
type: DEFAULT_ENTRY_POINT_TYPE,
|
|
432
|
-
input: {
|
|
433
|
-
amount: { type: "integer" },
|
|
434
|
-
id: { type: "string" },
|
|
435
|
-
},
|
|
436
|
-
output: {
|
|
437
|
-
status: { type: "string" },
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
],
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
return JSON.stringify(entryPoints, null, 2);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Generate a cryptographically secure unique ID (UUID v4-like format)
|
|
448
|
-
*/
|
|
449
|
-
private generateUniqueId(): string {
|
|
450
|
-
const randomBytes = new Uint8Array(16);
|
|
451
|
-
|
|
452
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
453
|
-
crypto.getRandomValues(randomBytes);
|
|
454
|
-
} else {
|
|
455
|
-
throw new Error("crypto.getRandomValues is not available");
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// Set version (4) and variant bits according to UUID v4 spec
|
|
459
|
-
randomBytes[6] = (randomBytes[6] & 0x0f) | 0x40; // Version 4
|
|
460
|
-
randomBytes[8] = (randomBytes[8] & 0x3f) | 0x80; // Variant 10
|
|
461
|
-
|
|
462
|
-
// Convert to UUID string format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
|
|
463
|
-
const hex = Array.from(randomBytes)
|
|
464
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
465
|
-
.join("");
|
|
466
|
-
|
|
467
|
-
return [
|
|
468
|
-
hex.substring(0, 8),
|
|
469
|
-
hex.substring(8, 12),
|
|
470
|
-
hex.substring(12, 16),
|
|
471
|
-
hex.substring(16, 20),
|
|
472
|
-
hex.substring(20, 32),
|
|
473
|
-
].join("-");
|
|
474
|
-
}
|
|
475
|
-
}
|