@uipath/codedapp-tool 1.203.0-preview.203 → 1.204.0-preview.206
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/THIRD-PARTY-NOTICES.md +40 -2
- package/dist/{embedded-file-reader-0sjt4nkj.js → embedded-file-reader-v8c2yj2a.js} +2 -2
- package/dist/{index-6zef5vcv.js → index-1k95y97e.js} +432 -95
- package/dist/{index-8yrjtchg.js → index-gqak49gg.js} +6 -3
- package/dist/index.js +10 -9
- package/dist/{node-strategy-bpshtz02.js → node-strategy-gc4sg6a2.js} +6 -4
- package/dist/{packager-tool-qyctya2j.js → packager-tool-0v3s8r01.js} +2 -30
- package/dist/{packager-tool-shwgy5p6.js → packager-tool-7qmpp7hj.js} +701 -12638
- package/dist/{packager-tool-p1rgpgd7.js → packager-tool-kxgaaq38.js} +425 -125
- package/dist/packager-tool-qa9gftnj.js +31 -0
- package/dist/{packager-tool-bvm4jqr1.js → packager-tool-qc7sff2j.js} +27 -10
- package/dist/packager-tool-vxegnq74.js +340 -0
- package/dist/{packager-tool-f1ptyxe1.js → packager-tool-w5fry52f.js} +2436 -484
- package/dist/packager-tool.js +4 -3
- package/dist/tool.js +8 -7
- package/package.json +2 -2
- package/dist/packager-tool-aybzcdfg.js +0 -1514
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// ../auth/src/catch-error.ts
|
|
2
|
+
function isPromiseLike(value) {
|
|
3
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
4
|
+
}
|
|
5
|
+
function catchError(fnOrPromise) {
|
|
6
|
+
if (isPromiseLike(fnOrPromise)) {
|
|
7
|
+
return settlePromiseLike(fnOrPromise);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const result = fnOrPromise();
|
|
11
|
+
if (isPromiseLike(result)) {
|
|
12
|
+
return settlePromiseLike(result);
|
|
13
|
+
}
|
|
14
|
+
return [undefined, result];
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return [
|
|
17
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
18
|
+
undefined
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function settlePromiseLike(thenable) {
|
|
23
|
+
return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
|
|
24
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
25
|
+
undefined
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { catchError };
|
|
30
|
+
|
|
31
|
+
//# debugId=CD090F76722F72E364756E2164756E21
|
|
@@ -3,15 +3,17 @@ import {
|
|
|
3
3
|
isBrowser
|
|
4
4
|
} from "./packager-tool-0gctz400.js";
|
|
5
5
|
import {
|
|
6
|
-
catchError
|
|
7
|
-
|
|
8
|
-
} from "./packager-tool-qyctya2j.js";
|
|
6
|
+
catchError
|
|
7
|
+
} from "./packager-tool-qa9gftnj.js";
|
|
9
8
|
import {
|
|
10
9
|
AUTH_FILENAME,
|
|
11
10
|
DEFAULT_BASE_URL,
|
|
12
11
|
DEFAULT_REDIRECT_URI,
|
|
13
12
|
UIPATH_HOME_DIR
|
|
14
13
|
} from "./packager-tool-yc4kw997.js";
|
|
14
|
+
import {
|
|
15
|
+
getFileSystem
|
|
16
|
+
} from "./packager-tool-0v3s8r01.js";
|
|
15
17
|
import {
|
|
16
18
|
__require
|
|
17
19
|
} from "./packager-tool-1yh8g550.js";
|
|
@@ -730,6 +732,11 @@ var pickName = (claims) => {
|
|
|
730
732
|
const username = asString(claims?.preferred_username);
|
|
731
733
|
return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
|
|
732
734
|
};
|
|
735
|
+
var pickScopes = (claims) => {
|
|
736
|
+
const raw = claims?.scope;
|
|
737
|
+
const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
|
|
738
|
+
return scopes.length > 0 ? scopes : undefined;
|
|
739
|
+
};
|
|
733
740
|
var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
734
741
|
const claims = accessToken ? decodeClaims(accessToken) : undefined;
|
|
735
742
|
const email = pickEmail(claims);
|
|
@@ -755,6 +762,7 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
|
755
762
|
identity.clientId = clientId;
|
|
756
763
|
return identity;
|
|
757
764
|
};
|
|
765
|
+
var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
|
|
758
766
|
|
|
759
767
|
// ../auth/src/envAuth.ts
|
|
760
768
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
@@ -827,6 +835,7 @@ var readAuthFromEnv = () => {
|
|
|
827
835
|
const expiration = getTokenExpiration(accessToken);
|
|
828
836
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
829
837
|
const identity = resolveSessionIdentity(accessToken);
|
|
838
|
+
const scopes = readTokenScopes(accessToken);
|
|
830
839
|
return {
|
|
831
840
|
loginStatus,
|
|
832
841
|
accessToken,
|
|
@@ -837,7 +846,8 @@ var readAuthFromEnv = () => {
|
|
|
837
846
|
tenantId,
|
|
838
847
|
expiration,
|
|
839
848
|
source: "env-vars" /* EnvironmentVariables */,
|
|
840
|
-
...identity ? { identity } : {}
|
|
849
|
+
...identity ? { identity } : {},
|
|
850
|
+
...scopes ? { scopes } : {}
|
|
841
851
|
};
|
|
842
852
|
};
|
|
843
853
|
|
|
@@ -1485,10 +1495,15 @@ async function buildFileStatus(tokens, credentials, globalHint) {
|
|
|
1485
1495
|
}
|
|
1486
1496
|
function identityFields(accessToken, credentials) {
|
|
1487
1497
|
const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
|
|
1488
|
-
|
|
1498
|
+
const scopes = readTokenScopes(accessToken);
|
|
1499
|
+
return {
|
|
1500
|
+
...identity ? { identity } : {},
|
|
1501
|
+
...scopes ? { scopes } : {}
|
|
1502
|
+
};
|
|
1489
1503
|
}
|
|
1490
1504
|
function buildRobotStatus(robotCreds) {
|
|
1491
1505
|
const identity = resolveSessionIdentity(robotCreds.accessToken);
|
|
1506
|
+
const scopes = readTokenScopes(robotCreds.accessToken);
|
|
1492
1507
|
return {
|
|
1493
1508
|
loginStatus: "Logged in",
|
|
1494
1509
|
accessToken: robotCreds.accessToken,
|
|
@@ -1500,7 +1515,8 @@ function buildRobotStatus(robotCreds) {
|
|
|
1500
1515
|
issuer: robotCreds.issuer,
|
|
1501
1516
|
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
1502
1517
|
source: "robot" /* Robot */,
|
|
1503
|
-
...identity ? { identity } : {}
|
|
1518
|
+
...identity ? { identity } : {},
|
|
1519
|
+
...scopes ? { scopes } : {}
|
|
1504
1520
|
};
|
|
1505
1521
|
}
|
|
1506
1522
|
var isFileNotFoundError = (error) => {
|
|
@@ -1767,7 +1783,8 @@ var getAuthContext = async (options = {}) => {
|
|
|
1767
1783
|
organizationId: status.organizationId,
|
|
1768
1784
|
organizationName: status.organizationName,
|
|
1769
1785
|
tenantId: status.tenantId,
|
|
1770
|
-
tenantName
|
|
1786
|
+
tenantName,
|
|
1787
|
+
identity: status.identity
|
|
1771
1788
|
};
|
|
1772
1789
|
};
|
|
1773
1790
|
var getAuthEnv = async (options = {}) => {
|
|
@@ -2415,7 +2432,7 @@ var authenticate = async ({
|
|
|
2415
2432
|
const { BrowserAuthStrategy } = await import("./browser-strategy-6atc7v8s.js");
|
|
2416
2433
|
strategy = new BrowserAuthStrategy;
|
|
2417
2434
|
} else {
|
|
2418
|
-
const { NodeAuthStrategy } = await import("./node-strategy-
|
|
2435
|
+
const { NodeAuthStrategy } = await import("./node-strategy-gc4sg6a2.js");
|
|
2419
2436
|
strategy = new NodeAuthStrategy;
|
|
2420
2437
|
}
|
|
2421
2438
|
const code = await strategy.execute(authUrl, effectiveRedirectUriUrl, state, {
|
|
@@ -2435,6 +2452,6 @@ var authenticate = async ({
|
|
|
2435
2452
|
});
|
|
2436
2453
|
};
|
|
2437
2454
|
|
|
2438
|
-
export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, getAuthProfilesRootPath, resolveAuthProfileDirPath, listAuthProfileNamesAsync, authProfileExistsAsync, deleteAuthProfileAsync, parseJWT, parseAuthFlow, resolveSessionIdentity, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, AUTH_FLOW_ENV_VAR, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync, CredentialSource, getLoginStatusAsync, getLoginStatusWithDeps, getAuthContext, getAuthEnv, describeAuthProfilesAsync, ClientCredentialsAuthenticationError, clientCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, FederatedCredentialsAuthenticationError, federatedCredentialsLogin, fetchTenantsAndOrganizations, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
|
|
2455
|
+
export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, getAuthProfilesRootPath, resolveAuthProfileDirPath, listAuthProfileNamesAsync, authProfileExistsAsync, deleteAuthProfileAsync, parseJWT, parseAuthFlow, resolveSessionIdentity, readTokenScopes, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, AUTH_FLOW_ENV_VAR, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync, CredentialSource, getLoginStatusAsync, getLoginStatusWithDeps, getAuthContext, getAuthEnv, describeAuthProfilesAsync, ClientCredentialsAuthenticationError, clientCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, FederatedCredentialsAuthenticationError, federatedCredentialsLogin, fetchTenantsAndOrganizations, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
|
|
2439
2456
|
|
|
2440
|
-
//# debugId=
|
|
2457
|
+
//# debugId=13BF51602EF4AFD864756E2164756E21
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import {
|
|
2
|
+
catchError,
|
|
3
|
+
unsupportedSolutionProjectType
|
|
4
|
+
} from "./packager-tool-w5fry52f.js";
|
|
5
|
+
|
|
6
|
+
// ../solution-sdk/src/solution-file.ts
|
|
7
|
+
var STUDIO_WEB_PROJECT_TYPE_OVERRIDES = {
|
|
8
|
+
ProcessOrchestration: "processOrchestration"
|
|
9
|
+
};
|
|
10
|
+
function normalizeProjectType(projectType) {
|
|
11
|
+
return STUDIO_WEB_PROJECT_TYPE_OVERRIDES[projectType] ?? projectType;
|
|
12
|
+
}
|
|
13
|
+
function toPortableRelativePath(relativePath) {
|
|
14
|
+
return relativePath.replace(/\\/g, "/");
|
|
15
|
+
}
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
async function tryRegisterProjectInParentSolution(fs, projectDir, options) {
|
|
20
|
+
if (options?.skipRegistration) {
|
|
21
|
+
return {
|
|
22
|
+
Status: "OptedOut",
|
|
23
|
+
Message: "Solution auto-registration skipped (--skip-solution-registration).",
|
|
24
|
+
Instructions: buildOptedOutInstructions(fs.path.resolve(projectDir))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const [registrationError, registration] = await catchError(registerProjectInParentSolution(fs, projectDir));
|
|
28
|
+
if (registrationError) {
|
|
29
|
+
return {
|
|
30
|
+
Status: "Failed",
|
|
31
|
+
Message: "Project registration failed.",
|
|
32
|
+
Instructions: buildRegistrationFailureInstructions(projectDir, registrationError.message)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return registration;
|
|
36
|
+
}
|
|
37
|
+
async function registerProjectInParentSolution(fs, projectDir) {
|
|
38
|
+
const resolvedProjectDir = fs.path.resolve(projectDir);
|
|
39
|
+
const discovery = await findNearestParentUipxFile(fs, resolvedProjectDir);
|
|
40
|
+
if (discovery.status === "notFound") {
|
|
41
|
+
return {
|
|
42
|
+
Status: "NotInSolution",
|
|
43
|
+
Message: "Project created in standalone mode; no parent .uipx solution found.",
|
|
44
|
+
Instructions: buildStandaloneInstructions(resolvedProjectDir)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (discovery.status === "skipped") {
|
|
48
|
+
return discovery.registration;
|
|
49
|
+
}
|
|
50
|
+
const solutionFile = discovery.solutionFile;
|
|
51
|
+
const solutionDir = fs.path.dirname(solutionFile);
|
|
52
|
+
const relativeProjectDir = fs.path.relative(solutionDir, resolvedProjectDir);
|
|
53
|
+
if (relativeProjectDir === "" || relativeProjectDir.startsWith("..") || fs.path.isAbsolute(relativeProjectDir)) {
|
|
54
|
+
return {
|
|
55
|
+
Status: "Skipped",
|
|
56
|
+
Message: "Project registration skipped.",
|
|
57
|
+
Solution: solutionFile,
|
|
58
|
+
Instructions: `Project must reside within the solution folder.
|
|
59
|
+
Solution: ${solutionDir}
|
|
60
|
+
Project: ${resolvedProjectDir}`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const [projectFileError, projectFile] = await findProjectFile(fs, resolvedProjectDir);
|
|
64
|
+
if (projectFileError) {
|
|
65
|
+
return {
|
|
66
|
+
Status: "Failed",
|
|
67
|
+
Message: "Project registration failed.",
|
|
68
|
+
Solution: solutionFile,
|
|
69
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, projectFileError.message)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const [projectManifestError, projectManifest] = await readProjectManifest(fs, projectFile.filePath, projectFile.useProjectJson);
|
|
73
|
+
if (projectManifestError) {
|
|
74
|
+
return {
|
|
75
|
+
Status: "Failed",
|
|
76
|
+
Message: "Project registration failed.",
|
|
77
|
+
Solution: solutionFile,
|
|
78
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, projectManifestError.message)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const unsupportedReason = unsupportedSolutionProjectType(projectManifest.projectType);
|
|
82
|
+
if (unsupportedReason) {
|
|
83
|
+
return {
|
|
84
|
+
Status: "Skipped",
|
|
85
|
+
Message: "Project registration skipped.",
|
|
86
|
+
Solution: solutionFile,
|
|
87
|
+
Instructions: unsupportedReason
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const projectRelativePath = toPortableRelativePath(fs.path.join(relativeProjectDir, projectFile.fileName));
|
|
91
|
+
const [solutionError, solution] = await readSolutionManifest(fs, solutionFile);
|
|
92
|
+
if (solutionError) {
|
|
93
|
+
return {
|
|
94
|
+
Status: "Failed",
|
|
95
|
+
Message: "Project registration failed.",
|
|
96
|
+
Solution: solutionFile,
|
|
97
|
+
Project: projectRelativePath,
|
|
98
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, solutionError.message)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const existingProject = solution.projects.find((project) => toPortableRelativePath(project.ProjectRelativePath) === projectRelativePath);
|
|
102
|
+
if (existingProject) {
|
|
103
|
+
return {
|
|
104
|
+
Status: "AlreadyRegistered",
|
|
105
|
+
Message: "Project already registered in solution.",
|
|
106
|
+
Solution: solutionFile,
|
|
107
|
+
Project: projectRelativePath,
|
|
108
|
+
ProjectId: typeof existingProject.Id === "string" ? existingProject.Id : undefined,
|
|
109
|
+
Instructions: buildRegistrationSuccessInstructions(solutionDir)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const projectId = crypto.randomUUID();
|
|
113
|
+
solution.projects.push({
|
|
114
|
+
Type: normalizeProjectType(projectManifest.projectType),
|
|
115
|
+
ProjectRelativePath: projectRelativePath,
|
|
116
|
+
Id: projectId
|
|
117
|
+
});
|
|
118
|
+
solution.content.Projects = solution.projects;
|
|
119
|
+
const [writeError] = await catchError(fs.writeFile(solutionFile, `${JSON.stringify(solution.content, null, 2)}
|
|
120
|
+
`));
|
|
121
|
+
if (writeError) {
|
|
122
|
+
return {
|
|
123
|
+
Status: "Failed",
|
|
124
|
+
Message: "Project registration failed.",
|
|
125
|
+
Solution: solutionFile,
|
|
126
|
+
Project: projectRelativePath,
|
|
127
|
+
Instructions: buildRegistrationFailureInstructions(resolvedProjectDir, writeError.message)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
Status: "Registered",
|
|
132
|
+
Message: "Project registered in parent solution.",
|
|
133
|
+
Solution: solutionFile,
|
|
134
|
+
Project: projectRelativePath,
|
|
135
|
+
ProjectId: projectId,
|
|
136
|
+
Instructions: buildRegistrationSuccessInstructions(solutionDir)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async function findNearestParentUipxFile(fs, projectDir) {
|
|
140
|
+
let currentDir = fs.path.dirname(fs.path.resolve(projectDir));
|
|
141
|
+
while (true) {
|
|
142
|
+
const [readDirError, entries] = await catchError(fs.readdir(currentDir));
|
|
143
|
+
if (readDirError) {
|
|
144
|
+
return {
|
|
145
|
+
status: "skipped",
|
|
146
|
+
registration: {
|
|
147
|
+
Status: "Failed",
|
|
148
|
+
Message: "Project registration failed.",
|
|
149
|
+
Instructions: buildRegistrationFailureInstructions(projectDir, `Could not inspect parent directory for a solution: ${currentDir}
|
|
150
|
+
${readDirError.message}`)
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const solutionFiles = entries.filter((entry) => entry.endsWith(".uipx"));
|
|
155
|
+
if (solutionFiles.length > 1) {
|
|
156
|
+
return {
|
|
157
|
+
status: "skipped",
|
|
158
|
+
registration: {
|
|
159
|
+
Status: "Skipped",
|
|
160
|
+
Message: "Project registration skipped.",
|
|
161
|
+
Instructions: `Found multiple .uipx files in ${currentDir}: ${solutionFiles.join(", ")}. Run 'uip solution projects add "${projectDir}" <solution.uipx>' to choose one.`
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (solutionFiles.length === 1) {
|
|
166
|
+
return {
|
|
167
|
+
status: "found",
|
|
168
|
+
solutionFile: fs.path.join(currentDir, solutionFiles[0])
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const parentDir = fs.path.dirname(currentDir);
|
|
172
|
+
if (parentDir === currentDir) {
|
|
173
|
+
return { status: "notFound" };
|
|
174
|
+
}
|
|
175
|
+
currentDir = parentDir;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function findProjectFile(fs, projectDir) {
|
|
179
|
+
const uiprojPath = fs.path.join(projectDir, "project.uiproj");
|
|
180
|
+
if (await fs.exists(uiprojPath)) {
|
|
181
|
+
return [
|
|
182
|
+
null,
|
|
183
|
+
{
|
|
184
|
+
filePath: uiprojPath,
|
|
185
|
+
fileName: "project.uiproj",
|
|
186
|
+
useProjectJson: false
|
|
187
|
+
}
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
const jsonProjectPath = fs.path.join(projectDir, "project.json");
|
|
191
|
+
if (await fs.exists(jsonProjectPath)) {
|
|
192
|
+
return [
|
|
193
|
+
null,
|
|
194
|
+
{
|
|
195
|
+
filePath: jsonProjectPath,
|
|
196
|
+
fileName: "project.json",
|
|
197
|
+
useProjectJson: true
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
return [
|
|
202
|
+
new Error(`No project file found in ${projectDir}. Expected project.uiproj or project.json.`),
|
|
203
|
+
null
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
async function readProjectManifest(fs, filePath, useProjectJson) {
|
|
207
|
+
const [readError, rawContent] = await catchError(fs.readFile(filePath, "utf-8"));
|
|
208
|
+
if (readError || !rawContent) {
|
|
209
|
+
return [readError ?? new Error(`Unable to read ${filePath}.`), null];
|
|
210
|
+
}
|
|
211
|
+
const [parseError, parsed] = catchError(() => JSON.parse(rawContent));
|
|
212
|
+
if (parseError) {
|
|
213
|
+
return [
|
|
214
|
+
new Error(`Invalid JSON in project file: ${parseError.message}`),
|
|
215
|
+
null
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
if (!isRecord(parsed)) {
|
|
219
|
+
return [new Error(`Invalid project file: ${filePath}`), null];
|
|
220
|
+
}
|
|
221
|
+
const designOptions = parsed.designOptions;
|
|
222
|
+
const outputType = useProjectJson && isRecord(designOptions) ? readString(designOptions.outputType) : undefined;
|
|
223
|
+
const projectType = outputType ?? readString(parsed.ProjectType);
|
|
224
|
+
if (!projectType) {
|
|
225
|
+
return [new Error(`ProjectType not found in ${filePath}`), null];
|
|
226
|
+
}
|
|
227
|
+
return [
|
|
228
|
+
null,
|
|
229
|
+
{
|
|
230
|
+
projectType
|
|
231
|
+
}
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
async function readSolutionManifest(fs, solutionFile) {
|
|
235
|
+
const [readError, rawContent] = await catchError(fs.readFile(solutionFile, "utf-8"));
|
|
236
|
+
if (readError || !rawContent) {
|
|
237
|
+
return [
|
|
238
|
+
readError ?? new Error(`Unable to read solution file: ${solutionFile}`),
|
|
239
|
+
null
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
const [parseError, parsed] = catchError(() => JSON.parse(rawContent));
|
|
243
|
+
if (parseError) {
|
|
244
|
+
return [
|
|
245
|
+
new Error(`Invalid JSON in solution file: ${parseError.message}`),
|
|
246
|
+
null
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
if (!isRecord(parsed)) {
|
|
250
|
+
return [
|
|
251
|
+
new Error(`Invalid solution file: ${solutionFile} must contain a JSON object.`),
|
|
252
|
+
null
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
if (!Array.isArray(parsed.Projects)) {
|
|
256
|
+
return [
|
|
257
|
+
new Error(`Invalid solution file: ${solutionFile} must contain a Projects array.`),
|
|
258
|
+
null
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
const projects = [];
|
|
262
|
+
for (const [index, project] of parsed.Projects.entries()) {
|
|
263
|
+
if (!isRecord(project)) {
|
|
264
|
+
return [
|
|
265
|
+
new Error(`Invalid solution file: Projects[${index}] must be an object.`),
|
|
266
|
+
null
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
const projectRelativePath = readString(project.ProjectRelativePath);
|
|
270
|
+
if (!projectRelativePath) {
|
|
271
|
+
return [
|
|
272
|
+
new Error(`Invalid solution file: Projects[${index}] is missing ProjectRelativePath. Use 'uip solution projects add' to repair the manifest.`),
|
|
273
|
+
null
|
|
274
|
+
];
|
|
275
|
+
}
|
|
276
|
+
projects.push({
|
|
277
|
+
...project,
|
|
278
|
+
Type: readString(project.Type) ?? "",
|
|
279
|
+
ProjectRelativePath: projectRelativePath,
|
|
280
|
+
Id: readString(project.Id) ?? ""
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return [null, { content: parsed, projects }];
|
|
284
|
+
}
|
|
285
|
+
function readString(value) {
|
|
286
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
287
|
+
}
|
|
288
|
+
function buildRegistrationSuccessInstructions(solutionDir) {
|
|
289
|
+
return [
|
|
290
|
+
"The project is listed in the parent solution manifest.",
|
|
291
|
+
"Packing or uploading the solution will sync solution resources automatically.",
|
|
292
|
+
`To sync resources before packaging, run 'uip solution resources refresh --solution-folder "${solutionDir}"'.`
|
|
293
|
+
].join(`
|
|
294
|
+
`);
|
|
295
|
+
}
|
|
296
|
+
function buildRegistrationFailureInstructions(projectDir, details) {
|
|
297
|
+
return [
|
|
298
|
+
"Automatic solution registration could not complete.",
|
|
299
|
+
`Run 'uip solution projects add "${projectDir}" <solution.uipx>' after checking the project and solution files.`,
|
|
300
|
+
`Details: ${details}`
|
|
301
|
+
].join(`
|
|
302
|
+
`);
|
|
303
|
+
}
|
|
304
|
+
function buildStandaloneInstructions(projectDir) {
|
|
305
|
+
return [
|
|
306
|
+
"No parent solution was found by walking ancestor directories.",
|
|
307
|
+
"Studio Web upload, `flow debug`, and packaging require an enclosing solution.",
|
|
308
|
+
`To link this project to a solution, run 'uip solution init "<SolutionName>"' then 'uip solution projects add "${projectDir}" <SolutionName>.uipx'.`
|
|
309
|
+
].join(`
|
|
310
|
+
`);
|
|
311
|
+
}
|
|
312
|
+
function buildOptedOutInstructions(projectDir) {
|
|
313
|
+
return [
|
|
314
|
+
"Automatic solution registration was skipped because --skip-solution-registration was passed.",
|
|
315
|
+
`To register this project later, run 'uip solution projects add "${projectDir}" <SolutionName>.uipx' from within the solution.`
|
|
316
|
+
].join(`
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
319
|
+
async function findSolutionFileUpward(fs, startDir) {
|
|
320
|
+
let dir = startDir;
|
|
321
|
+
while (true) {
|
|
322
|
+
const entries = await fs.readdir(dir);
|
|
323
|
+
const files = entries.filter((f) => f.endsWith(".uipx"));
|
|
324
|
+
if (files.length === 1) {
|
|
325
|
+
return fs.path.join(dir, files[0]);
|
|
326
|
+
}
|
|
327
|
+
if (files.length > 1) {
|
|
328
|
+
throw new Error(`Multiple .uipx files found in ${dir}. Please specify which solution file to use.`);
|
|
329
|
+
}
|
|
330
|
+
const parent = fs.path.dirname(dir);
|
|
331
|
+
if (parent === dir) {
|
|
332
|
+
throw new Error(`No .uipx solution file found (searched from ${startDir} to filesystem root)`);
|
|
333
|
+
}
|
|
334
|
+
dir = parent;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export { normalizeProjectType, toPortableRelativePath, tryRegisterProjectInParentSolution, findNearestParentUipxFile, findSolutionFileUpward };
|
|
339
|
+
|
|
340
|
+
//# debugId=CF42DF39BC13F8BB64756E2164756E21
|