@uipath/project-packager 1.1.4
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/index.js +781 -0
- package/dist/index.js.map +1 -0
- package/dist/node.js +915 -0
- package/dist/node.js.map +1 -0
- package/dist/src/base-node-packager-factory.d.ts +35 -0
- package/dist/src/i18n/index.d.ts +7 -0
- package/dist/src/i18n/locales/en.d.ts +39 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/models/packager-config.d.ts +16 -0
- package/dist/src/models/packager-parameters.d.ts +113 -0
- package/dist/src/models/project-build-options.d.ts +6 -0
- package/dist/src/models/project-models.d.ts +26 -0
- package/dist/src/models/project-pack-options.d.ts +21 -0
- package/dist/src/models/project-restore-options.d.ts +6 -0
- package/dist/src/models/project-validate-options.d.ts +11 -0
- package/dist/src/node-project-packager-factory.d.ts +22 -0
- package/dist/src/node.d.ts +32 -0
- package/dist/src/services/pack-service.d.ts +26 -0
- package/dist/src/services/package-sign-service.d.ts +22 -0
- package/dist/src/services/packager-parameters-validator.d.ts +26 -0
- package/dist/src/services/project-build-options-validator.d.ts +14 -0
- package/dist/src/services/project-loader.d.ts +24 -0
- package/dist/src/services/project-pack-options-builder.d.ts +19 -0
- package/dist/src/services/project-pack-options-validator.d.ts +15 -0
- package/dist/src/services/project-packager.d.ts +146 -0
- package/dist/src/services/project-tool-executor.d.ts +36 -0
- package/dist/src/services/project-validate-options-validator.d.ts +14 -0
- package/dist/src/services/tool-logger.d.ts +26 -0
- package/dist/src/services/tools-factory.d.ts +29 -0
- package/dist/src/telemetry-names.d.ts +11 -0
- package/dist/tests/pack-service.test.d.ts +1 -0
- package/dist/tests/project-loader.test.d.ts +1 -0
- package/dist/tests/project-packager-e2e.test.d.ts +7 -0
- package/dist/tests/project-packager.test.d.ts +1 -0
- package/dist/tests/project-tool-executor.test.d.ts +1 -0
- package/dist/tests/tools-factory-repository.test.d.ts +1 -0
- package/package.json +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
import { I18nManager, LogLevel, LogMessage, NugetPackager, Path, ProjectTypes, TemporaryStorageService, ToolErrorCodes, ToolResult, ZipService, toolsFactoryRepository, translate } from "@uipath/solutionpackager-tool-core";
|
|
2
|
+
var de_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
3
|
+
const en = {
|
|
4
|
+
solutionpackager: {
|
|
5
|
+
projectLoader: {
|
|
6
|
+
errors: {
|
|
7
|
+
pathRequired: "Project directory path is required",
|
|
8
|
+
noProjectFile: "No {projectFile} or {manifestFile} found in directory: {path}",
|
|
9
|
+
readFailed: "Failed to read project file: {path}",
|
|
10
|
+
invalidProject: "Invalid project file: {path}. Missing ProjectType field."
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
validator: {
|
|
14
|
+
errors: {
|
|
15
|
+
destinationNotDefined: "Destination path is not defined",
|
|
16
|
+
governanceRequired: "Governance file path is required when governance file type is not Default",
|
|
17
|
+
governanceFileInfo: "Unable to get file information: {path}",
|
|
18
|
+
governanceInvalidFile: "Governance file path is not a valid file: {path}"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
packager: {
|
|
22
|
+
errors: {
|
|
23
|
+
failedToGetStreams: "Cannot get package streams from failed result. Error code: {errorCode}, message: {message}",
|
|
24
|
+
failedToReadPackage: "Failed to read package file: {path}"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
signing: {
|
|
28
|
+
errors: {
|
|
29
|
+
dotnetNotAvailable: "dotnet CLI is not available. Package signing requires dotnet CLI to be installed."
|
|
30
|
+
},
|
|
31
|
+
info: {
|
|
32
|
+
dotnetNotAvailable: "dotnet CLI is not available. Cannot sign package."
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var es_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
38
|
+
var es_MX_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
39
|
+
var fr_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
40
|
+
var ja_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
41
|
+
var ko_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
42
|
+
var pt_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
43
|
+
var pt_BR_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
44
|
+
var ro_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
45
|
+
var ru_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
46
|
+
var tr_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
47
|
+
var zh_CN_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
48
|
+
var zh_TW_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
49
|
+
var zu_namespaceObject = JSON.parse('{"solutionpackager":{"projectLoader":{"errors":{"pathRequired":"Project directory path is required","noProjectFile":"No {projectFile} or {manifestFile} found in directory: {path}","readFailed":"Failed to read project file: {path}","invalidProject":"Invalid project file: {path}. Missing ProjectType field."}},"validator":{"errors":{"destinationNotDefined":"Destination path is not defined","governanceRequired":"Governance file path is required when governance file type is not Default","governanceFileInfo":"Unable to get file information: {path}","governanceInvalidFile":"Governance file path is not a valid file: {path}"}},"packager":{"errors":{"failedToGetStreams":"Cannot get package streams from failed result. Error code: {errorCode}, message: {message}","failedToReadPackage":"Failed to read package file: {path}"}},"signing":{"errors":{"dotnetNotAvailable":"dotnet CLI is not available. Package signing requires dotnet CLI to be installed."},"info":{"dotnetNotAvailable":"dotnet CLI is not available. Cannot sign package."}}}}');
|
|
50
|
+
I18nManager.registerTranslations("en", en);
|
|
51
|
+
I18nManager.registerTranslations("de", de_namespaceObject);
|
|
52
|
+
I18nManager.registerTranslations("es", es_namespaceObject);
|
|
53
|
+
I18nManager.registerTranslations("es-MX", es_MX_namespaceObject);
|
|
54
|
+
I18nManager.registerTranslations("fr", fr_namespaceObject);
|
|
55
|
+
I18nManager.registerTranslations("ja", ja_namespaceObject);
|
|
56
|
+
I18nManager.registerTranslations("ko", ko_namespaceObject);
|
|
57
|
+
I18nManager.registerTranslations("pt", pt_namespaceObject);
|
|
58
|
+
I18nManager.registerTranslations("pt-BR", pt_BR_namespaceObject);
|
|
59
|
+
I18nManager.registerTranslations("ro", ro_namespaceObject);
|
|
60
|
+
I18nManager.registerTranslations("ru", ru_namespaceObject);
|
|
61
|
+
I18nManager.registerTranslations("tr", tr_namespaceObject);
|
|
62
|
+
I18nManager.registerTranslations("zh-CN", zh_CN_namespaceObject);
|
|
63
|
+
I18nManager.registerTranslations("zh-TW", zh_TW_namespaceObject);
|
|
64
|
+
I18nManager.registerTranslations("zu", zu_namespaceObject);
|
|
65
|
+
function _define_property(obj, key, value) {
|
|
66
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
67
|
+
value: value,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true
|
|
71
|
+
});
|
|
72
|
+
else obj[key] = value;
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
var packager_parameters_RulesConfigFileType = /*#__PURE__*/ function(RulesConfigFileType) {
|
|
76
|
+
RulesConfigFileType["Default"] = "Default";
|
|
77
|
+
RulesConfigFileType["AutomationOps"] = "AutomationOps";
|
|
78
|
+
RulesConfigFileType["Studio"] = "Studio";
|
|
79
|
+
return RulesConfigFileType;
|
|
80
|
+
}({});
|
|
81
|
+
class PackagerParameters {
|
|
82
|
+
constructor(){
|
|
83
|
+
_define_property(this, "inputPath", void 0);
|
|
84
|
+
_define_property(this, "logLevel", LogLevel.Warn);
|
|
85
|
+
_define_property(this, "outputPath", void 0);
|
|
86
|
+
_define_property(this, "targetFramework", void 0);
|
|
87
|
+
_define_property(this, "excludeConfiguredSources", false);
|
|
88
|
+
_define_property(this, "nuGetSourcesConfigPath", void 0);
|
|
89
|
+
_define_property(this, "detailedLogPath", void 0);
|
|
90
|
+
_define_property(this, "connection", void 0);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class ProjectRestoreOptions extends PackagerParameters {
|
|
94
|
+
}
|
|
95
|
+
function project_validate_options_define_property(obj, key, value) {
|
|
96
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
97
|
+
value: value,
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true
|
|
101
|
+
});
|
|
102
|
+
else obj[key] = value;
|
|
103
|
+
return obj;
|
|
104
|
+
}
|
|
105
|
+
class ProjectValidateOptions extends ProjectRestoreOptions {
|
|
106
|
+
constructor(...args){
|
|
107
|
+
super(...args), project_validate_options_define_property(this, "validateOptions", {
|
|
108
|
+
skipAnalyze: false,
|
|
109
|
+
governanceFileType: packager_parameters_RulesConfigFileType.Default
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
class ProjectBuildOptions extends ProjectValidateOptions {
|
|
114
|
+
}
|
|
115
|
+
function project_pack_options_define_property(obj, key, value) {
|
|
116
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
117
|
+
value: value,
|
|
118
|
+
enumerable: true,
|
|
119
|
+
configurable: true,
|
|
120
|
+
writable: true
|
|
121
|
+
});
|
|
122
|
+
else obj[key] = value;
|
|
123
|
+
return obj;
|
|
124
|
+
}
|
|
125
|
+
class ProjectPackOptions extends ProjectBuildOptions {
|
|
126
|
+
constructor(...args){
|
|
127
|
+
super(...args), project_pack_options_define_property(this, "destinationPath", void 0), project_pack_options_define_property(this, "package", void 0), project_pack_options_define_property(this, "signingInfo", void 0), project_pack_options_define_property(this, "packOptions", void 0);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function pack_service_define_property(obj, key, value) {
|
|
131
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
132
|
+
value: value,
|
|
133
|
+
enumerable: true,
|
|
134
|
+
configurable: true,
|
|
135
|
+
writable: true
|
|
136
|
+
});
|
|
137
|
+
else obj[key] = value;
|
|
138
|
+
return obj;
|
|
139
|
+
}
|
|
140
|
+
class PackService {
|
|
141
|
+
sanitizePackageId(packageId) {
|
|
142
|
+
packageId = packageId.trim();
|
|
143
|
+
packageId = packageId.replace(this.spacesDotRegex, ".");
|
|
144
|
+
packageId = packageId.replace(this.dotDashRegex, "-");
|
|
145
|
+
packageId = packageId.replace(this.disallowedCharsRegex, "_");
|
|
146
|
+
if (packageId.length > this.MaxPackageIdLength) throw new Error(`Package id ${packageId} exceeds the characters limit of ${this.MaxPackageIdLength}`);
|
|
147
|
+
return packageId;
|
|
148
|
+
}
|
|
149
|
+
constructor(){
|
|
150
|
+
pack_service_define_property(this, "disallowedCharsRegex", /[^\w.-]/g);
|
|
151
|
+
pack_service_define_property(this, "spacesDotRegex", /[\s.]+/g);
|
|
152
|
+
pack_service_define_property(this, "dotDashRegex", /\.*[-:]\.*/g);
|
|
153
|
+
pack_service_define_property(this, "MaxPackageIdLength", 100);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function packager_parameters_validator_define_property(obj, key, value) {
|
|
157
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
158
|
+
value: value,
|
|
159
|
+
enumerable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true
|
|
162
|
+
});
|
|
163
|
+
else obj[key] = value;
|
|
164
|
+
return obj;
|
|
165
|
+
}
|
|
166
|
+
class PackagerParametersValidator {
|
|
167
|
+
async validateAsync(_options, _cancellationToken) {
|
|
168
|
+
return ToolResult.success();
|
|
169
|
+
}
|
|
170
|
+
validateDestinationPath(destinationPath) {
|
|
171
|
+
if (!destinationPath) {
|
|
172
|
+
const error = translate.t("solutionpackager.validator.errors.destinationNotDefined");
|
|
173
|
+
this.logger.error(error);
|
|
174
|
+
return ToolResult.error(ToolErrorCodes.InternalError, error);
|
|
175
|
+
}
|
|
176
|
+
return ToolResult.success();
|
|
177
|
+
}
|
|
178
|
+
async validateGovernanceOptions(validateOptions) {
|
|
179
|
+
if (validateOptions.governanceFileType === packager_parameters_RulesConfigFileType.Default) {
|
|
180
|
+
if (validateOptions.governanceFilePath) this.logger.warn(`Governance file path '${validateOptions.governanceFilePath}' will be ignored when governance file type is Default`);
|
|
181
|
+
return ToolResult.success();
|
|
182
|
+
}
|
|
183
|
+
if (!validateOptions.governanceFilePath) {
|
|
184
|
+
const error = translate.t("solutionpackager.validator.errors.governanceRequired");
|
|
185
|
+
this.logger.error(error);
|
|
186
|
+
return ToolResult.error(ToolErrorCodes.InternalError, error);
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const stat = await this.fileSystem.stat(validateOptions.governanceFilePath);
|
|
190
|
+
if (!stat) {
|
|
191
|
+
const error = translate.t("solutionpackager.validator.errors.governanceFileInfo", {
|
|
192
|
+
path: validateOptions.governanceFilePath
|
|
193
|
+
});
|
|
194
|
+
this.logger.error(error);
|
|
195
|
+
return ToolResult.error(ToolErrorCodes.InternalError, error);
|
|
196
|
+
}
|
|
197
|
+
if (stat.isDirectory()) {
|
|
198
|
+
const error = translate.t("solutionpackager.validator.errors.governanceInvalidFile", {
|
|
199
|
+
path: validateOptions.governanceFilePath
|
|
200
|
+
});
|
|
201
|
+
this.logger.error(error);
|
|
202
|
+
return ToolResult.error(ToolErrorCodes.InternalError, error);
|
|
203
|
+
}
|
|
204
|
+
} catch (error) {
|
|
205
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
206
|
+
const errorLog = `Governance file not found or inaccessible: ${validateOptions.governanceFilePath}. Error: ${errorMessage}`;
|
|
207
|
+
this.logger.error(errorLog);
|
|
208
|
+
return ToolResult.error(ToolErrorCodes.InternalError, errorLog);
|
|
209
|
+
}
|
|
210
|
+
this.logger.info(`Using Studio governance file: ${validateOptions.governanceFilePath}`);
|
|
211
|
+
return ToolResult.success();
|
|
212
|
+
}
|
|
213
|
+
constructor(logger, fileSystem){
|
|
214
|
+
packager_parameters_validator_define_property(this, "logger", void 0);
|
|
215
|
+
packager_parameters_validator_define_property(this, "fileSystem", void 0);
|
|
216
|
+
this.logger = logger;
|
|
217
|
+
this.fileSystem = fileSystem;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
class ProjectBuildOptionsValidator extends PackagerParametersValidator {
|
|
221
|
+
async validateAsync(options, _cancellationToken) {
|
|
222
|
+
return await this.validateGovernanceOptions(options.validateOptions);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function project_loader_define_property(obj, key, value) {
|
|
226
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
227
|
+
value: value,
|
|
228
|
+
enumerable: true,
|
|
229
|
+
configurable: true,
|
|
230
|
+
writable: true
|
|
231
|
+
});
|
|
232
|
+
else obj[key] = value;
|
|
233
|
+
return obj;
|
|
234
|
+
}
|
|
235
|
+
class ProjectLoader {
|
|
236
|
+
async loadProject(projectPath) {
|
|
237
|
+
if (!projectPath) throw new Error(translate.t("solutionpackager.projectLoader.errors.pathRequired"));
|
|
238
|
+
const projectFilePath = Path.join(projectPath, ProjectLoader.ProjectFileName);
|
|
239
|
+
const projectFileExists = await this.fileSystem.exists(projectFilePath);
|
|
240
|
+
if (projectFileExists) return await this.loadFromProjectFile(projectPath, projectFilePath);
|
|
241
|
+
const webAppManifestPath = Path.join(projectPath, ProjectLoader.WebAppManifestFileName);
|
|
242
|
+
const webAppManifestExists = await this.fileSystem.exists(webAppManifestPath);
|
|
243
|
+
if (webAppManifestExists) return this.loadFromWebAppManifest(projectPath, webAppManifestPath);
|
|
244
|
+
throw new Error(translate.t("solutionpackager.projectLoader.errors.noProjectFile", {
|
|
245
|
+
projectFile: ProjectLoader.ProjectFileName,
|
|
246
|
+
manifestFile: ProjectLoader.WebAppManifestFileName,
|
|
247
|
+
path: projectPath
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
async loadFromProjectFile(projectPath, projectFilePath) {
|
|
251
|
+
const fileContent = await this.fileSystem.readFile(projectFilePath);
|
|
252
|
+
if (!fileContent) throw new Error(translate.t("solutionpackager.projectLoader.errors.readFailed", {
|
|
253
|
+
path: projectFilePath
|
|
254
|
+
}));
|
|
255
|
+
const json = "string" == typeof fileContent ? fileContent : new TextDecoder("utf-8").decode(fileContent);
|
|
256
|
+
const projectData = JSON.parse(json);
|
|
257
|
+
const projectType = projectData?.ProjectType || projectData?.type;
|
|
258
|
+
if (!projectData || !projectType) throw new Error(translate.t("solutionpackager.projectLoader.errors.invalidProject", {
|
|
259
|
+
path: projectFilePath
|
|
260
|
+
}));
|
|
261
|
+
return {
|
|
262
|
+
type: projectType,
|
|
263
|
+
name: projectData.Name || Path.basename(projectPath),
|
|
264
|
+
projectPath,
|
|
265
|
+
projectFilePath
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
loadFromWebAppManifest(projectPath, webAppManifestPath) {
|
|
269
|
+
const folderName = Path.basename(projectPath);
|
|
270
|
+
return {
|
|
271
|
+
type: ProjectTypes.AppV2,
|
|
272
|
+
name: folderName,
|
|
273
|
+
projectPath,
|
|
274
|
+
projectFilePath: webAppManifestPath
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
constructor(fileSystem){
|
|
278
|
+
project_loader_define_property(this, "fileSystem", void 0);
|
|
279
|
+
this.fileSystem = fileSystem;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
project_loader_define_property(ProjectLoader, "ProjectFileName", "project.uiproj");
|
|
283
|
+
project_loader_define_property(ProjectLoader, "WebAppManifestFileName", "webAppManifest.json");
|
|
284
|
+
var telemetry_names_TelemetryNames = /*#__PURE__*/ function(TelemetryNames) {
|
|
285
|
+
TelemetryNames["ProjectToolPack"] = "ProjectPackager.Tool.Pack";
|
|
286
|
+
TelemetryNames["ProjectToolRestore"] = "ProjectPackager.Tool.Restore";
|
|
287
|
+
TelemetryNames["ProjectToolValidate"] = "ProjectPackager.Tool.Validate";
|
|
288
|
+
TelemetryNames["ProjectToolBuild"] = "ProjectPackager.Tool.Build";
|
|
289
|
+
TelemetryNames["ProjectPackagerPack"] = "ProjectPackager.Pack";
|
|
290
|
+
TelemetryNames["ProjectPackagerRestore"] = "ProjectPackager.Restore";
|
|
291
|
+
TelemetryNames["ProjectPackagerValidate"] = "ProjectPackager.Validate";
|
|
292
|
+
TelemetryNames["ProjectPackagerBuild"] = "ProjectPackager.Build";
|
|
293
|
+
TelemetryNames["ProjectPackagerProjectLoaded"] = "ProjectPackager.ProjectLoaded";
|
|
294
|
+
return TelemetryNames;
|
|
295
|
+
}({});
|
|
296
|
+
function project_pack_options_builder_define_property(obj, key, value) {
|
|
297
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
298
|
+
value: value,
|
|
299
|
+
enumerable: true,
|
|
300
|
+
configurable: true,
|
|
301
|
+
writable: true
|
|
302
|
+
});
|
|
303
|
+
else obj[key] = value;
|
|
304
|
+
return obj;
|
|
305
|
+
}
|
|
306
|
+
class ProjectPackOptionsBuilder {
|
|
307
|
+
async buildProjectPackOptions(parameters, project) {
|
|
308
|
+
if (!parameters.outputPath) throw new Error("Output path is required for Pack command");
|
|
309
|
+
await this.fileSystem.mkdir(parameters.outputPath);
|
|
310
|
+
const packageId = parameters.package.id && "" !== parameters.package.id.trim() ? parameters.package.id : project.name;
|
|
311
|
+
const packageInfo = {
|
|
312
|
+
...parameters.package,
|
|
313
|
+
id: this.packService.sanitizePackageId(packageId)
|
|
314
|
+
};
|
|
315
|
+
return {
|
|
316
|
+
projectPath: project.projectPath,
|
|
317
|
+
excludeConfiguredSources: parameters.excludeConfiguredSources ?? false,
|
|
318
|
+
nuGetSourcesConfigPath: parameters.nuGetSourcesConfigPath,
|
|
319
|
+
logLevel: parameters.logLevel,
|
|
320
|
+
skipAnalyze: parameters.validateOptions.skipAnalyze,
|
|
321
|
+
skipValidate: false,
|
|
322
|
+
detailedLogPath: parameters.detailedLogPath,
|
|
323
|
+
policyFilePath: parameters.validateOptions.governanceFilePath,
|
|
324
|
+
policyFileType: parameters.validateOptions.governanceFileType,
|
|
325
|
+
outputPath: parameters.outputPath,
|
|
326
|
+
outputType: void 0,
|
|
327
|
+
projectType: project.type,
|
|
328
|
+
package: packageInfo,
|
|
329
|
+
skipDependencyOptimization: parameters.packOptions?.skipDependencyOptimization ?? false,
|
|
330
|
+
includeSources: parameters.packOptions?.includeSources ?? false,
|
|
331
|
+
splitPackages: parameters.packOptions?.splitPackages ?? false
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
constructor(packService, fileSystem){
|
|
335
|
+
project_pack_options_builder_define_property(this, "packService", void 0);
|
|
336
|
+
project_pack_options_builder_define_property(this, "fileSystem", void 0);
|
|
337
|
+
this.packService = packService;
|
|
338
|
+
this.fileSystem = fileSystem;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
class ProjectPackOptionsValidator extends ProjectBuildOptionsValidator {
|
|
342
|
+
async validateAsync(options, cancellationToken) {
|
|
343
|
+
const destinationResult = this.validateDestinationPath(options.destinationPath);
|
|
344
|
+
if (!destinationResult.isSuccess) return destinationResult;
|
|
345
|
+
return await super.validateAsync(options, cancellationToken);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function project_tool_executor_define_property(obj, key, value) {
|
|
349
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
350
|
+
value: value,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
configurable: true,
|
|
353
|
+
writable: true
|
|
354
|
+
});
|
|
355
|
+
else obj[key] = value;
|
|
356
|
+
return obj;
|
|
357
|
+
}
|
|
358
|
+
class ProjectToolExecutor {
|
|
359
|
+
async restoreAsync(options, project, context, cancellationToken) {
|
|
360
|
+
return await this.executeToolOperationAsync(project, context, (tool)=>this.telemetry.trackDependencyOperation(telemetry_names_TelemetryNames.ProjectToolRestore, project.Type, async ()=>tool.restoreAsync(options, cancellationToken), {
|
|
361
|
+
projectId: project.Id,
|
|
362
|
+
projectType: project.Type
|
|
363
|
+
}));
|
|
364
|
+
}
|
|
365
|
+
async validateAsync(options, project, context, cancellationToken) {
|
|
366
|
+
return await this.executeToolOperationAsync(project, context, (tool)=>this.telemetry.trackDependencyOperation(telemetry_names_TelemetryNames.ProjectToolValidate, project.Type, async ()=>tool.validateAsync(options, cancellationToken), {
|
|
367
|
+
projectId: project.Id,
|
|
368
|
+
projectType: project.Type
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
async buildAsync(options, project, context, cancellationToken) {
|
|
372
|
+
return await this.executeToolOperationAsync(project, context, (tool)=>this.telemetry.trackDependencyOperation(telemetry_names_TelemetryNames.ProjectToolBuild, project.Type, async ()=>tool.buildAsync(options, cancellationToken), {
|
|
373
|
+
projectId: project.Id,
|
|
374
|
+
projectType: project.Type
|
|
375
|
+
}));
|
|
376
|
+
}
|
|
377
|
+
async packAsync(options, project, context, signingInfo, cancellationToken) {
|
|
378
|
+
return await this.executeToolOperationAsync(project, context, async (tool)=>{
|
|
379
|
+
const result = await this.telemetry.trackDependencyOperation(telemetry_names_TelemetryNames.ProjectToolPack, project.Type, async ()=>await tool.packAsync(options, cancellationToken), {
|
|
380
|
+
projectId: project.Id,
|
|
381
|
+
projectType: project.Type
|
|
382
|
+
});
|
|
383
|
+
if (result.isSuccess && signingInfo?.certificatePath && result.packages.length > 0) {
|
|
384
|
+
const signResult = await this.signPackagesAsync(result.packages, signingInfo);
|
|
385
|
+
if (!signResult.isSuccess) return signResult;
|
|
386
|
+
}
|
|
387
|
+
return result;
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
async executeToolOperationAsync(project, context, operation) {
|
|
391
|
+
try {
|
|
392
|
+
const tool = await this.toolsFactory.createProjectToolAsync(project, context);
|
|
393
|
+
try {
|
|
394
|
+
return await operation(tool);
|
|
395
|
+
} finally{
|
|
396
|
+
const disposeResult = tool.dispose();
|
|
397
|
+
if (disposeResult instanceof Promise) await disposeResult;
|
|
398
|
+
}
|
|
399
|
+
} catch (error) {
|
|
400
|
+
return ToolResult.error(ToolErrorCodes.InternalError, error instanceof Error ? error.message : String(error));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
async signPackagesAsync(packages, signingInfo) {
|
|
404
|
+
if (!this.packageSignService) return ToolResult.error(ToolErrorCodes.InternalError, "Package signing is required but signing service is not available. Package signing requires dotnet CLI to be installed in Node.js environment.");
|
|
405
|
+
const certificatePath = signingInfo.certificatePath;
|
|
406
|
+
const signResults = await Promise.all(packages.map((packagePath)=>this.packageSignService?.signPackageAsync(packagePath, certificatePath, signingInfo.certificatePassword, signingInfo.timestampServer)));
|
|
407
|
+
const failedResult = signResults.find((result)=>result && !result.isSuccess);
|
|
408
|
+
if (failedResult) return failedResult;
|
|
409
|
+
return ToolResult.success();
|
|
410
|
+
}
|
|
411
|
+
constructor(toolsFactory, telemetry, packageSignService){
|
|
412
|
+
project_tool_executor_define_property(this, "toolsFactory", void 0);
|
|
413
|
+
project_tool_executor_define_property(this, "telemetry", void 0);
|
|
414
|
+
project_tool_executor_define_property(this, "packageSignService", void 0);
|
|
415
|
+
this.toolsFactory = toolsFactory;
|
|
416
|
+
this.telemetry = telemetry;
|
|
417
|
+
this.packageSignService = packageSignService;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
class ProjectValidateOptionsValidator extends PackagerParametersValidator {
|
|
421
|
+
async validateAsync(options, _cancellationToken) {
|
|
422
|
+
return await this.validateGovernanceOptions(options.validateOptions);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function tool_logger_define_property(obj, key, value) {
|
|
426
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
427
|
+
value: value,
|
|
428
|
+
enumerable: true,
|
|
429
|
+
configurable: true,
|
|
430
|
+
writable: true
|
|
431
|
+
});
|
|
432
|
+
else obj[key] = value;
|
|
433
|
+
return obj;
|
|
434
|
+
}
|
|
435
|
+
let globalLogHandler = (logMessage)=>{
|
|
436
|
+
const formattedMessage = logMessage.toFormattedString();
|
|
437
|
+
switch(logMessage.logLevel){
|
|
438
|
+
case LogLevel.Debug:
|
|
439
|
+
console.debug(formattedMessage);
|
|
440
|
+
break;
|
|
441
|
+
case LogLevel.Info:
|
|
442
|
+
console.info(formattedMessage);
|
|
443
|
+
break;
|
|
444
|
+
case LogLevel.Warn:
|
|
445
|
+
console.warn(formattedMessage);
|
|
446
|
+
break;
|
|
447
|
+
case LogLevel.Error:
|
|
448
|
+
console.error(formattedMessage);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
function setGlobalLogHandler(handler) {
|
|
453
|
+
globalLogHandler = handler;
|
|
454
|
+
}
|
|
455
|
+
class ToolLogger {
|
|
456
|
+
debug(message, options) {
|
|
457
|
+
const logMessage = new LogMessage(message, LogLevel.Debug, {
|
|
458
|
+
source: this.source,
|
|
459
|
+
sourceTarget: this.sourceTarget,
|
|
460
|
+
...options
|
|
461
|
+
});
|
|
462
|
+
globalLogHandler(logMessage);
|
|
463
|
+
}
|
|
464
|
+
info(message, options) {
|
|
465
|
+
const logMessage = new LogMessage(message, LogLevel.Info, {
|
|
466
|
+
source: this.source,
|
|
467
|
+
sourceTarget: this.sourceTarget,
|
|
468
|
+
...options
|
|
469
|
+
});
|
|
470
|
+
globalLogHandler(logMessage);
|
|
471
|
+
}
|
|
472
|
+
warn(message, options) {
|
|
473
|
+
const logMessage = new LogMessage(message, LogLevel.Warn, {
|
|
474
|
+
source: this.source,
|
|
475
|
+
sourceTarget: this.sourceTarget,
|
|
476
|
+
...options
|
|
477
|
+
});
|
|
478
|
+
globalLogHandler(logMessage);
|
|
479
|
+
}
|
|
480
|
+
error(message, options) {
|
|
481
|
+
const logMessage = new LogMessage(message, LogLevel.Error, {
|
|
482
|
+
source: this.source,
|
|
483
|
+
sourceTarget: this.sourceTarget,
|
|
484
|
+
...options
|
|
485
|
+
});
|
|
486
|
+
globalLogHandler(logMessage);
|
|
487
|
+
}
|
|
488
|
+
progress(message, options) {
|
|
489
|
+
const logMessage = new LogMessage(message, LogLevel.Info, {
|
|
490
|
+
source: this.source,
|
|
491
|
+
sourceTarget: this.sourceTarget,
|
|
492
|
+
...options
|
|
493
|
+
});
|
|
494
|
+
globalLogHandler(logMessage);
|
|
495
|
+
}
|
|
496
|
+
log(message, logLevel, options) {
|
|
497
|
+
const logMessage = new LogMessage(message, logLevel, {
|
|
498
|
+
source: this.source,
|
|
499
|
+
sourceTarget: this.sourceTarget,
|
|
500
|
+
...options
|
|
501
|
+
});
|
|
502
|
+
globalLogHandler(logMessage);
|
|
503
|
+
}
|
|
504
|
+
logMessage(message) {
|
|
505
|
+
globalLogHandler(message);
|
|
506
|
+
}
|
|
507
|
+
constructor(source, sourceTarget){
|
|
508
|
+
tool_logger_define_property(this, "source", void 0);
|
|
509
|
+
tool_logger_define_property(this, "sourceTarget", void 0);
|
|
510
|
+
this.source = source;
|
|
511
|
+
this.sourceTarget = sourceTarget;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function tools_factory_define_property(obj, key, value) {
|
|
515
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
516
|
+
value: value,
|
|
517
|
+
enumerable: true,
|
|
518
|
+
configurable: true,
|
|
519
|
+
writable: true
|
|
520
|
+
});
|
|
521
|
+
else obj[key] = value;
|
|
522
|
+
return obj;
|
|
523
|
+
}
|
|
524
|
+
class ToolsFactory {
|
|
525
|
+
async createSolutionToolAsync(solutionName) {
|
|
526
|
+
const logger = new ToolLogger("ResourceBuilder", solutionName);
|
|
527
|
+
const factory = this.repository.getSolutionToolFactory();
|
|
528
|
+
return await factory.createAsync(logger, this.fileSystem);
|
|
529
|
+
}
|
|
530
|
+
async createProjectToolAsync(project, context) {
|
|
531
|
+
const sourceTarget = getSourceTarget();
|
|
532
|
+
const logger = new ToolLogger(project.Type, sourceTarget);
|
|
533
|
+
if (!project.ProjectPath) throw new Error(`Project path not set for project: ${project.Id}`);
|
|
534
|
+
const factory = this.repository.getProjectToolFactory(project.Type);
|
|
535
|
+
return await factory.createAsync(logger, this.fileSystem, context);
|
|
536
|
+
function getSourceTarget() {
|
|
537
|
+
const segments = project.ProjectRelativePath.split(/[/\\]/);
|
|
538
|
+
if (segments.length > 1) return segments[0];
|
|
539
|
+
return project.Id;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
constructor(repository, fileSystem){
|
|
543
|
+
tools_factory_define_property(this, "repository", void 0);
|
|
544
|
+
tools_factory_define_property(this, "fileSystem", void 0);
|
|
545
|
+
this.repository = repository;
|
|
546
|
+
this.fileSystem = fileSystem;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function project_packager_define_property(obj, key, value) {
|
|
550
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
551
|
+
value: value,
|
|
552
|
+
enumerable: true,
|
|
553
|
+
configurable: true,
|
|
554
|
+
writable: true
|
|
555
|
+
});
|
|
556
|
+
else obj[key] = value;
|
|
557
|
+
return obj;
|
|
558
|
+
}
|
|
559
|
+
class ProjectPackager {
|
|
560
|
+
async canPackProjectAsync(projectPath) {
|
|
561
|
+
const project = await this.projectLoader.loadProject(projectPath);
|
|
562
|
+
return this.repository.canHandleProject(project.type);
|
|
563
|
+
}
|
|
564
|
+
async setupAsync(input, operationId) {
|
|
565
|
+
this.telemetryService.setOperationId(operationId);
|
|
566
|
+
await this.temporaryStorage.cleanup();
|
|
567
|
+
if ("string" == typeof input) return input;
|
|
568
|
+
const inputPath = await this.temporaryStorage.getTempSubfolderPathAsync("input");
|
|
569
|
+
await this.zipService.extractAsync(input, inputPath);
|
|
570
|
+
const entries = await this.fileSystem.readdir(inputPath);
|
|
571
|
+
if (1 === entries.length) {
|
|
572
|
+
const innerPath = Path.join(inputPath, entries[0]);
|
|
573
|
+
const stat = await this.fileSystem.stat(innerPath);
|
|
574
|
+
if (stat?.isDirectory()) return innerPath;
|
|
575
|
+
}
|
|
576
|
+
return inputPath;
|
|
577
|
+
}
|
|
578
|
+
async restoreProjectAsync(options, cancellationToken) {
|
|
579
|
+
return await this.executeProjectOperationAsync(options, "Restore", telemetry_names_TelemetryNames.ProjectPackagerRestore, async (uiPathProject, loadedProject)=>{
|
|
580
|
+
const restoreOptions = {
|
|
581
|
+
projectPath: loadedProject.projectPath,
|
|
582
|
+
excludeConfiguredSources: options.excludeConfiguredSources ?? false,
|
|
583
|
+
nuGetSourcesConfigPath: options.nuGetSourcesConfigPath,
|
|
584
|
+
logLevel: options.logLevel,
|
|
585
|
+
outputPath: options.outputPath
|
|
586
|
+
};
|
|
587
|
+
return await this.projectExecutor.restoreAsync(restoreOptions, uiPathProject, void 0, cancellationToken);
|
|
588
|
+
}, cancellationToken);
|
|
589
|
+
}
|
|
590
|
+
async validateProjectAsync(options, cancellationToken) {
|
|
591
|
+
const validationResult = await this.validateOptionsValidator.validateAsync(options, cancellationToken);
|
|
592
|
+
if (!validationResult.isSuccess) return validationResult;
|
|
593
|
+
return await this.executeProjectOperationAsync(options, "Validate", telemetry_names_TelemetryNames.ProjectPackagerValidate, async (uiPathProject, loadedProject)=>{
|
|
594
|
+
const validateOptions = {
|
|
595
|
+
projectPath: loadedProject.projectPath,
|
|
596
|
+
excludeConfiguredSources: options.excludeConfiguredSources ?? false,
|
|
597
|
+
nuGetSourcesConfigPath: options.nuGetSourcesConfigPath,
|
|
598
|
+
logLevel: options.logLevel,
|
|
599
|
+
skipAnalyze: options.validateOptions.skipAnalyze,
|
|
600
|
+
defaultSeverity: options.validateOptions.defaultSeverity,
|
|
601
|
+
detailedLogPath: options.detailedLogPath,
|
|
602
|
+
policyFilePath: options.validateOptions.governanceFilePath,
|
|
603
|
+
policyFileType: options.validateOptions.governanceFileType
|
|
604
|
+
};
|
|
605
|
+
return await this.projectExecutor.validateAsync(validateOptions, uiPathProject, void 0, cancellationToken);
|
|
606
|
+
}, cancellationToken);
|
|
607
|
+
}
|
|
608
|
+
async buildProjectAsync(options, cancellationToken) {
|
|
609
|
+
const validationResult = await this.buildOptionsValidator.validateAsync(options, cancellationToken);
|
|
610
|
+
if (!validationResult.isSuccess) return validationResult;
|
|
611
|
+
return await this.executeProjectOperationAsync(options, "Build", telemetry_names_TelemetryNames.ProjectPackagerBuild, async (uiPathProject, loadedProject)=>{
|
|
612
|
+
if (!options.outputPath) options.outputPath = await this.temporaryStorage.getTempSubfolderPathAsync("output");
|
|
613
|
+
const buildOptions = {
|
|
614
|
+
projectPath: loadedProject.projectPath,
|
|
615
|
+
excludeConfiguredSources: options.excludeConfiguredSources ?? false,
|
|
616
|
+
nuGetSourcesConfigPath: options.nuGetSourcesConfigPath,
|
|
617
|
+
logLevel: options.logLevel,
|
|
618
|
+
skipAnalyze: options.validateOptions.skipAnalyze,
|
|
619
|
+
skipValidate: false,
|
|
620
|
+
detailedLogPath: options.detailedLogPath,
|
|
621
|
+
policyFilePath: options.validateOptions.governanceFilePath,
|
|
622
|
+
policyFileType: options.validateOptions.governanceFileType,
|
|
623
|
+
outputPath: options.outputPath,
|
|
624
|
+
outputType: void 0,
|
|
625
|
+
projectType: uiPathProject.Type
|
|
626
|
+
};
|
|
627
|
+
return await this.projectExecutor.buildAsync(buildOptions, uiPathProject, void 0, cancellationToken);
|
|
628
|
+
}, cancellationToken);
|
|
629
|
+
}
|
|
630
|
+
async packProjectAsync(options, cancellationToken) {
|
|
631
|
+
return await this.telemetryService.trackRequest(telemetry_names_TelemetryNames.ProjectPackagerPack, async ()=>{
|
|
632
|
+
try {
|
|
633
|
+
let result = await this.packOptionsValidator.validateAsync(options, cancellationToken);
|
|
634
|
+
if (!result.isSuccess) return result;
|
|
635
|
+
if (!options.outputPath) options.outputPath = await this.temporaryStorage.getTempSubfolderPathAsync("output");
|
|
636
|
+
const loadedProject = await this.projectLoader.loadProject(options.inputPath);
|
|
637
|
+
this.telemetryService.trackEvent(telemetry_names_TelemetryNames.ProjectPackagerProjectLoaded, {
|
|
638
|
+
projectId: loadedProject.name
|
|
639
|
+
});
|
|
640
|
+
const projectPackOptions = await this.optionsBuilder.buildProjectPackOptions(options, loadedProject);
|
|
641
|
+
const uiPathProject = {
|
|
642
|
+
Type: loadedProject.type,
|
|
643
|
+
ProjectRelativePath: Path.basename(loadedProject.projectFilePath),
|
|
644
|
+
ProjectPath: loadedProject.projectPath,
|
|
645
|
+
Id: loadedProject.name
|
|
646
|
+
};
|
|
647
|
+
result = await this.projectExecutor.packAsync(projectPackOptions, uiPathProject, void 0, options.signingInfo, cancellationToken);
|
|
648
|
+
if (result.isSuccess && result.packages.length > 0) {
|
|
649
|
+
const destinationPackages = await this.copyPackagesToDestination(result.packages, options.destinationPath, projectPackOptions.package);
|
|
650
|
+
result = new ToolResult(ToolErrorCodes.Success, void 0, destinationPackages);
|
|
651
|
+
}
|
|
652
|
+
if (result.isSuccess) this.logger.info(`Project pack completed successfully. Packages: ${result.packages.join(", ")}`);
|
|
653
|
+
else this.logger.error(`Project pack failed with error code ${result.errorCode}: ${result.message}`);
|
|
654
|
+
return result;
|
|
655
|
+
} catch (error) {
|
|
656
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
657
|
+
this.logger.error(`Processing error: ${errorMessage}`);
|
|
658
|
+
return ToolResult.error(ToolErrorCodes.InternalError, `Project pack failed: ${errorMessage}`);
|
|
659
|
+
} finally{
|
|
660
|
+
await this.temporaryStorage.cleanup();
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
async getPackageStreamsAsync(result) {
|
|
665
|
+
if (!result.isSuccess) throw new Error(translate.t("solutionpackager.packager.errors.failedToGetStreams", {
|
|
666
|
+
errorCode: result.errorCode,
|
|
667
|
+
message: result.message ?? ""
|
|
668
|
+
}));
|
|
669
|
+
if (!result.packages || 0 === result.packages.length) return [];
|
|
670
|
+
const packageStreams = [];
|
|
671
|
+
for (const packagePath of result.packages){
|
|
672
|
+
const data = await this.fileSystem.readFile(packagePath);
|
|
673
|
+
if (!data) throw new Error(translate.t("solutionpackager.packager.errors.failedToReadPackage", {
|
|
674
|
+
path: packagePath
|
|
675
|
+
}));
|
|
676
|
+
const name = packagePath.split(/[\\/]/).pop() || packagePath;
|
|
677
|
+
packageStreams.push({
|
|
678
|
+
name,
|
|
679
|
+
data
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
return packageStreams;
|
|
683
|
+
}
|
|
684
|
+
async executeProjectOperationAsync(options, operationName, telemetryName, operation, _cancellationToken) {
|
|
685
|
+
return await this.telemetryService.trackRequest(telemetryName, async ()=>{
|
|
686
|
+
try {
|
|
687
|
+
const loadedProject = await this.projectLoader.loadProject(options.inputPath);
|
|
688
|
+
const uiPathProject = {
|
|
689
|
+
Type: loadedProject.type,
|
|
690
|
+
ProjectRelativePath: Path.basename(loadedProject.projectFilePath),
|
|
691
|
+
ProjectPath: loadedProject.projectPath,
|
|
692
|
+
Id: loadedProject.name
|
|
693
|
+
};
|
|
694
|
+
const operationResult = await operation(uiPathProject, loadedProject);
|
|
695
|
+
if (operationResult.isSuccess) this.logger.info(`Project ${operationName.toLowerCase()} completed successfully.`);
|
|
696
|
+
else this.logger.error(`Project ${operationName.toLowerCase()} failed with error code ${operationResult.errorCode}: ${operationResult.message}`);
|
|
697
|
+
return operationResult;
|
|
698
|
+
} catch (error) {
|
|
699
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
700
|
+
this.logger.error(`Processing error: ${errorMessage}`);
|
|
701
|
+
return ToolResult.error(ToolErrorCodes.InternalError, `Project ${operationName.toLowerCase()} failed: ${errorMessage}`);
|
|
702
|
+
} finally{
|
|
703
|
+
await this.temporaryStorage.cleanup();
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
async copyPackagesToDestination(packagePaths, destinationPath, packageInfo) {
|
|
708
|
+
await this.fileSystem.mkdir(destinationPath);
|
|
709
|
+
const destinationPackages = [];
|
|
710
|
+
for (const packagePath of packagePaths){
|
|
711
|
+
const stat = await this.fileSystem.stat(packagePath);
|
|
712
|
+
if (stat?.isDirectory()) {
|
|
713
|
+
const files = await this.fileSystem.readdir(packagePath);
|
|
714
|
+
const nupkgFiles = files.filter((f)=>f.endsWith(".nupkg"));
|
|
715
|
+
if (nupkgFiles.length > 0) for (const nupkgFile of nupkgFiles){
|
|
716
|
+
const filePath = Path.join(packagePath, nupkgFile);
|
|
717
|
+
const destPath = Path.join(destinationPath, nupkgFile);
|
|
718
|
+
const data = await this.fileSystem.readFile(filePath);
|
|
719
|
+
if (!data) throw new Error(translate.t("solutionpackager.packager.errors.failedToReadPackage", {
|
|
720
|
+
path: filePath
|
|
721
|
+
}));
|
|
722
|
+
await this.fileSystem.writeFile(destPath, data);
|
|
723
|
+
destinationPackages.push(destPath);
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
const nupkgFileName = `${packageInfo.id}.${packageInfo.version}.nupkg`;
|
|
727
|
+
const destPath = Path.join(destinationPath, nupkgFileName);
|
|
728
|
+
const packResult = await this.nugetPackager.packAsync(packagePath, packageInfo, destPath);
|
|
729
|
+
destinationPackages.push(packResult.outputPath);
|
|
730
|
+
}
|
|
731
|
+
} else {
|
|
732
|
+
const fileName = packagePath.split(/[\\/]/).pop() || packagePath;
|
|
733
|
+
const destPath = Path.join(destinationPath, fileName);
|
|
734
|
+
const data = await this.fileSystem.readFile(packagePath);
|
|
735
|
+
if (!data) throw new Error(translate.t("solutionpackager.packager.errors.failedToReadPackage", {
|
|
736
|
+
path: packagePath
|
|
737
|
+
}));
|
|
738
|
+
await this.fileSystem.writeFile(destPath, data);
|
|
739
|
+
destinationPackages.push(destPath);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return destinationPackages;
|
|
743
|
+
}
|
|
744
|
+
constructor(fileSystem, telemetryService, packageSignService){
|
|
745
|
+
project_packager_define_property(this, "fileSystem", void 0);
|
|
746
|
+
project_packager_define_property(this, "telemetryService", void 0);
|
|
747
|
+
project_packager_define_property(this, "packageSignService", void 0);
|
|
748
|
+
project_packager_define_property(this, "repository", void 0);
|
|
749
|
+
project_packager_define_property(this, "temporaryStorage", void 0);
|
|
750
|
+
project_packager_define_property(this, "zipService", void 0);
|
|
751
|
+
project_packager_define_property(this, "logger", void 0);
|
|
752
|
+
project_packager_define_property(this, "optionsBuilder", void 0);
|
|
753
|
+
project_packager_define_property(this, "toolsFactory", void 0);
|
|
754
|
+
project_packager_define_property(this, "projectExecutor", void 0);
|
|
755
|
+
project_packager_define_property(this, "projectLoader", void 0);
|
|
756
|
+
project_packager_define_property(this, "validateOptionsValidator", void 0);
|
|
757
|
+
project_packager_define_property(this, "buildOptionsValidator", void 0);
|
|
758
|
+
project_packager_define_property(this, "packOptionsValidator", void 0);
|
|
759
|
+
project_packager_define_property(this, "nugetPackager", void 0);
|
|
760
|
+
this.fileSystem = fileSystem;
|
|
761
|
+
this.telemetryService = telemetryService;
|
|
762
|
+
this.packageSignService = packageSignService;
|
|
763
|
+
this.repository = toolsFactoryRepository;
|
|
764
|
+
this.temporaryStorage = new TemporaryStorageService(this.fileSystem);
|
|
765
|
+
this.zipService = new ZipService(this.fileSystem);
|
|
766
|
+
this.nugetPackager = new NugetPackager(this.fileSystem);
|
|
767
|
+
this.logger = new ToolLogger("ProjectPackager", "PackProject");
|
|
768
|
+
this.validateOptionsValidator = new ProjectValidateOptionsValidator(this.logger, this.fileSystem);
|
|
769
|
+
this.buildOptionsValidator = new ProjectBuildOptionsValidator(this.logger, this.fileSystem);
|
|
770
|
+
this.packOptionsValidator = new ProjectPackOptionsValidator(this.logger, this.fileSystem);
|
|
771
|
+
const packService = new PackService();
|
|
772
|
+
this.optionsBuilder = new ProjectPackOptionsBuilder(packService, this.fileSystem);
|
|
773
|
+
this.toolsFactory = new ToolsFactory(this.repository, this.fileSystem);
|
|
774
|
+
this.projectExecutor = new ProjectToolExecutor(this.toolsFactory, this.telemetryService, this.packageSignService);
|
|
775
|
+
this.projectLoader = new ProjectLoader(this.fileSystem);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
export { BrowserContextStorage, ConsoleTelemetryProvider, TelemetryService } from "@uipath/telemetry";
|
|
779
|
+
export { PackService, PackagerParameters, PackagerParametersValidator, ProjectBuildOptions, ProjectBuildOptionsValidator, ProjectLoader, ProjectPackOptions, ProjectPackager, ProjectRestoreOptions, ProjectToolExecutor, ProjectValidateOptions, ProjectValidateOptionsValidator, ToolLogger, ToolsFactory, packager_parameters_RulesConfigFileType as RulesConfigFileType, setGlobalLogHandler, telemetry_names_TelemetryNames as TelemetryNames };
|
|
780
|
+
|
|
781
|
+
//# sourceMappingURL=index.js.map
|