@paklo/core 0.12.0 → 0.13.0
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/azure/index.d.mts +19 -31
- package/dist/azure/index.mjs +74 -68
- package/dist/azure/index.mjs.map +1 -1
- package/dist/dependabot/index.d.mts +3 -3
- package/dist/dependabot/index.mjs +3 -3
- package/dist/{dependabot-KMy1H3XS.mjs → dependabot-Epqz07Sy.mjs} +109 -29
- package/dist/dependabot-Epqz07Sy.mjs.map +1 -0
- package/dist/github/index.d.mts +1 -1
- package/dist/github/index.mjs +2 -2
- package/dist/github/index.mjs.map +1 -1
- package/dist/hono.d.mts +0 -1
- package/dist/{index-BfwWezjJ.d.mts → index-BKTxy7XU.d.mts} +1 -2
- package/dist/{index-flzaUkHI.d.mts → index-CviS_2Dy.d.mts} +142 -68
- package/dist/{job-ClEevC5P.mjs → job-CNRfJDsF.mjs} +15 -10
- package/dist/{job-ClEevC5P.mjs.map → job-CNRfJDsF.mjs.map} +1 -1
- package/dist/keygen.d.mts +1 -3
- package/dist/{logger-3Qfh9NUj.mjs → logger-BV4N2wBl.mjs} +1 -1
- package/dist/{logger-3Qfh9NUj.mjs.map → logger-BV4N2wBl.mjs.map} +1 -1
- package/dist/logger.d.mts +1 -2
- package/dist/logger.mjs +1 -1
- package/dist/usage.d.mts +1 -2
- package/dist/usage.mjs +1 -1
- package/package.json +8 -9
- package/dist/dependabot-KMy1H3XS.mjs.map +0 -1
package/dist/azure/index.d.mts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-
|
|
1
|
+
import { Ft as DependabotExistingPr, G as DependabotUpdatePullRequest, Nt as DependabotExistingGroupPr, Sn as DependabotConfig, Zt as DependabotPersistedPr, p as DependabotCreatePullRequest, qn as VariableFinderFn } from "../index-CviS_2Dy.mjs";
|
|
2
|
+
import "../index-BKTxy7XU.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { KyInstance } from "ky";
|
|
5
5
|
|
|
6
6
|
//#region src/azure/url-parts.d.ts
|
|
7
7
|
type AzureDevOpsOrganizationUrl = {
|
|
8
|
-
/** URL of the organization. This may lack the project name */
|
|
9
|
-
|
|
10
|
-
/** Organization
|
|
11
|
-
|
|
12
|
-
/** Organization API endpoint URL */
|
|
13
|
-
'api-endpoint': string;
|
|
14
|
-
/** Organization name/slug */
|
|
15
|
-
organization: string;
|
|
16
|
-
/** Virtual directory if present (on-premises only) */
|
|
8
|
+
/** URL of the organization. This may lack the project name */value: URL; /** Organization URL hostname */
|
|
9
|
+
hostname: string; /** Organization API endpoint URL */
|
|
10
|
+
'api-endpoint': string; /** Organization name/slug */
|
|
11
|
+
organization: string; /** Virtual directory if present (on-premises only) */
|
|
17
12
|
'virtual-directory'?: string;
|
|
18
13
|
/**
|
|
19
14
|
* Organization Identity API URL (different from the API endpoint).
|
|
@@ -21,39 +16,31 @@ type AzureDevOpsOrganizationUrl = {
|
|
|
21
16
|
*/
|
|
22
17
|
'identity-api-url': URL;
|
|
23
18
|
};
|
|
24
|
-
type
|
|
19
|
+
type AzureDevOpsRepositoryUrl = AzureDevOpsOrganizationUrl & {
|
|
25
20
|
/**
|
|
26
21
|
* Project ID or Name.
|
|
27
22
|
* This value is not URL-encoded, clients must encode it when constructing URLs.
|
|
28
23
|
*/
|
|
29
24
|
project: string;
|
|
30
|
-
};
|
|
31
|
-
type AzureDevOpsRepositoryUrl = AzureDevOpsProjectUrl & {
|
|
32
25
|
/**
|
|
33
26
|
* Repository ID or Name.
|
|
34
27
|
* This value is not URL-encoded, clients must encode it when constructing URLs.
|
|
35
28
|
*/
|
|
36
|
-
repository: string;
|
|
37
|
-
/** Slug of the repository e.g. `contoso/prj1/_git/repo1`, `tfs/contoso/prj1/_git/repo1` */
|
|
29
|
+
repository: string; /** Slug of the repository e.g. `contoso/prj1/_git/repo1`, `tfs/contoso/prj1/_git/repo1` */
|
|
38
30
|
'repository-slug': string;
|
|
39
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Extract organization details from any Azure DevOps URL.
|
|
34
|
+
* Accepts organization, project, or repository URLs.
|
|
35
|
+
*/
|
|
40
36
|
declare function extractOrganizationUrl({
|
|
41
37
|
organizationUrl
|
|
42
38
|
}: {
|
|
43
39
|
organizationUrl: string;
|
|
44
40
|
}): AzureDevOpsOrganizationUrl;
|
|
45
|
-
declare function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}: {
|
|
49
|
-
organizationUrl: string;
|
|
50
|
-
project: string;
|
|
51
|
-
}): AzureDevOpsProjectUrl;
|
|
52
|
-
declare function extractRepositoryUrl({
|
|
53
|
-
organizationUrl,
|
|
54
|
-
project,
|
|
55
|
-
repository
|
|
56
|
-
}: {
|
|
41
|
+
declare function extractRepositoryUrl(options: {
|
|
42
|
+
repositoryUrl: string;
|
|
43
|
+
} | {
|
|
57
44
|
organizationUrl: string;
|
|
58
45
|
project: string;
|
|
59
46
|
repository: string;
|
|
@@ -959,8 +946,9 @@ declare function buildPullRequestProperties(packageManager: string, dependencies
|
|
|
959
946
|
name: string;
|
|
960
947
|
value: string;
|
|
961
948
|
}[];
|
|
962
|
-
declare function
|
|
963
|
-
declare function
|
|
949
|
+
declare function parsePullRequestProps(pr: AzdoPrExtractedWithProperties): DependabotExistingPr | DependabotExistingGroupPr;
|
|
950
|
+
declare function parsePullRequestProperties(pullRequests: AzdoPrExtractedWithProperties[], packageManager: string): (DependabotExistingPr | DependabotExistingGroupPr)[];
|
|
951
|
+
declare function getPullRequestForDependencyNames(existingPullRequests: AzdoPrExtractedWithProperties[], packageManager: string, dependencyNames: string[], dependencyGroupName?: string | null): AzdoPrExtractedWithProperties | undefined;
|
|
964
952
|
declare function getPullRequestChangedFiles(data: DependabotCreatePullRequest | DependabotUpdatePullRequest): {
|
|
965
953
|
changeType: "delete" | "add" | "edit";
|
|
966
954
|
path: string;
|
|
@@ -1723,5 +1711,5 @@ declare const AzdoEventSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
1723
1711
|
}, z.core.$strip>], "eventType">>;
|
|
1724
1712
|
type AzdoEvent = z.infer<typeof AzdoEventSchema>;
|
|
1725
1713
|
//#endregion
|
|
1726
|
-
export { ANONYMOUS_USER_ID, API_VERSION, API_VERSION_PREVIEW, AZDO_PULL_REQUEST_MERGE_STRATEGIES, AzdoCommentThreadStatus, AzdoCommentThreadStatusSchema, AzdoCommentType, AzdoCommentTypeSchema, AzdoConnectionData, AzdoConnectionDataSchema, AzdoEvent, AzdoEventCodePushResource, AzdoEventCodePushResourceSchema, AzdoEventPullRequestCommentEventResource, AzdoEventPullRequestCommentEventResourceSchema, AzdoEventPullRequestResource, AzdoEventPullRequestResourceSchema, AzdoEventRepositoryCreatedResource, AzdoEventRepositoryCreatedResourceSchema, AzdoEventRepositoryDeletedResource, AzdoEventRepositoryDeletedResourceSchema, AzdoEventRepositoryRenamedResource, AzdoEventRepositoryRenamedResourceSchema, AzdoEventRepositorySchema, AzdoEventRepositoryStatusChangedResource, AzdoEventRepositoryStatusChangedResourceSchema, AzdoEventSchema, AzdoEventType, AzdoEventTypeSchema, AzdoFileChange, AzdoGitBranchStats, AzdoGitBranchStatsSchema, AzdoGitChange, AzdoGitChangeSchema, AzdoGitCommitDiffs, AzdoGitCommitDiffsSchema, AzdoGitCommitRef, AzdoGitCommitRefSchema, AzdoGitPush, AzdoGitPushCreate, AzdoGitPushCreateSchema, AzdoGitPushSchema, AzdoGitRef, AzdoGitRefSchema, AzdoGitRefUpdate, AzdoGitRefUpdateResult, AzdoGitRefUpdateResultSchema, AzdoGitRefUpdateSchema, AzdoGitUserDate, AzdoGitUserDateSchema, AzdoIdentity, AzdoIdentityRef, AzdoIdentityRefSchema, AzdoIdentityRefWithVote, AzdoIdentityRefWithVoteSchema, AzdoIdentitySchema, AzdoPrExtractedWithProperties, AzdoProject, AzdoProjectSchema, AzdoProperties, AzdoPropertiesSchema, AzdoPullRequest, AzdoPullRequestAsyncStatus, AzdoPullRequestAsyncStatusSchema, AzdoPullRequestComment, AzdoPullRequestCommentSchema, AzdoPullRequestCommentThread, AzdoPullRequestCommentThreadSchema, AzdoPullRequestMergeStrategy, AzdoPullRequestMergeStrategySchema, AzdoPullRequestSchema, AzdoPullRequestStatus, AzdoPullRequestStatusSchema, AzdoRepository, AzdoRepositoryItem, AzdoRepositoryItemSchema, AzdoRepositorySchema, AzdoResponse, AzdoSubscription, AzdoSubscriptionSchema, AzdoSubscriptionsQuery, AzdoSubscriptionsQueryInputFilter, AzdoSubscriptionsQueryInputFilterSchema, AzdoSubscriptionsQueryResponse, AzdoSubscriptionsQueryResponseSchema, AzdoSubscriptionsQuerySchema, AzdoVersionControlChangeType, AzdoVersionControlChangeTypeSchema, AzureDevOpsClient, AzureDevOpsClientWrapper, type AzureDevOpsOrganizationUrl, type
|
|
1714
|
+
export { ANONYMOUS_USER_ID, API_VERSION, API_VERSION_PREVIEW, AZDO_PULL_REQUEST_MERGE_STRATEGIES, AzdoCommentThreadStatus, AzdoCommentThreadStatusSchema, AzdoCommentType, AzdoCommentTypeSchema, AzdoConnectionData, AzdoConnectionDataSchema, AzdoEvent, AzdoEventCodePushResource, AzdoEventCodePushResourceSchema, AzdoEventPullRequestCommentEventResource, AzdoEventPullRequestCommentEventResourceSchema, AzdoEventPullRequestResource, AzdoEventPullRequestResourceSchema, AzdoEventRepositoryCreatedResource, AzdoEventRepositoryCreatedResourceSchema, AzdoEventRepositoryDeletedResource, AzdoEventRepositoryDeletedResourceSchema, AzdoEventRepositoryRenamedResource, AzdoEventRepositoryRenamedResourceSchema, AzdoEventRepositorySchema, AzdoEventRepositoryStatusChangedResource, AzdoEventRepositoryStatusChangedResourceSchema, AzdoEventSchema, AzdoEventType, AzdoEventTypeSchema, AzdoFileChange, AzdoGitBranchStats, AzdoGitBranchStatsSchema, AzdoGitChange, AzdoGitChangeSchema, AzdoGitCommitDiffs, AzdoGitCommitDiffsSchema, AzdoGitCommitRef, AzdoGitCommitRefSchema, AzdoGitPush, AzdoGitPushCreate, AzdoGitPushCreateSchema, AzdoGitPushSchema, AzdoGitRef, AzdoGitRefSchema, AzdoGitRefUpdate, AzdoGitRefUpdateResult, AzdoGitRefUpdateResultSchema, AzdoGitRefUpdateSchema, AzdoGitUserDate, AzdoGitUserDateSchema, AzdoIdentity, AzdoIdentityRef, AzdoIdentityRefSchema, AzdoIdentityRefWithVote, AzdoIdentityRefWithVoteSchema, AzdoIdentitySchema, AzdoPrExtractedWithProperties, AzdoProject, AzdoProjectSchema, AzdoProperties, AzdoPropertiesSchema, AzdoPullRequest, AzdoPullRequestAsyncStatus, AzdoPullRequestAsyncStatusSchema, AzdoPullRequestComment, AzdoPullRequestCommentSchema, AzdoPullRequestCommentThread, AzdoPullRequestCommentThreadSchema, AzdoPullRequestMergeStrategy, AzdoPullRequestMergeStrategySchema, AzdoPullRequestSchema, AzdoPullRequestStatus, AzdoPullRequestStatusSchema, AzdoRepository, AzdoRepositoryItem, AzdoRepositoryItemSchema, AzdoRepositorySchema, AzdoResponse, AzdoSubscription, AzdoSubscriptionSchema, AzdoSubscriptionsQuery, AzdoSubscriptionsQueryInputFilter, AzdoSubscriptionsQueryInputFilterSchema, AzdoSubscriptionsQueryResponse, AzdoSubscriptionsQueryResponseSchema, AzdoSubscriptionsQuerySchema, AzdoVersionControlChangeType, AzdoVersionControlChangeTypeSchema, AzureDevOpsClient, AzureDevOpsClientWrapper, type AzureDevOpsOrganizationUrl, type AzureDevOpsRepositoryUrl, PR_DESCRIPTION_MAX_LENGTH, PR_PROPERTY_DEPENDABOT_DEPENDENCIES, PR_PROPERTY_DEPENDABOT_PACKAGE_MANAGER, PR_PROPERTY_MICROSOFT_GIT_SOURCE_REF_NAME, buildPullRequestProperties, extractOrganizationUrl, extractRepositoryUrl, getDependabotConfig, getPullRequestChangedFiles, getPullRequestForDependencyNames, parsePullRequestProperties, parsePullRequestProps };
|
|
1727
1715
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/azure/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as logger } from "../logger-
|
|
2
|
-
import {
|
|
3
|
-
import { n as getDependencyNames, o as normalizeBranchName, s as normalizeFilePath, t as areEqual } from "../dependabot-
|
|
1
|
+
import { n as logger } from "../logger-BV4N2wBl.mjs";
|
|
2
|
+
import { D as CONFIG_FILE_PATHS_AZURE, V as parseDependabotConfig, u as DependabotExistingPrDependencySchema, v as DependabotPersistedPrSchema } from "../job-CNRfJDsF.mjs";
|
|
3
|
+
import { n as getDependencyNames, o as normalizeBranchName, s as normalizeFilePath, t as areEqual } from "../dependabot-Epqz07Sy.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import ky, { isHTTPError } from "ky";
|
|
6
6
|
import * as path from "node:path";
|
|
@@ -27,12 +27,12 @@ var BaseAzureDevOpsClient = class {
|
|
|
27
27
|
constructor(client) {
|
|
28
28
|
this.client = client;
|
|
29
29
|
}
|
|
30
|
-
makeUrl(path
|
|
30
|
+
makeUrl(path, params, apiVersion = API_VERSION) {
|
|
31
31
|
if (typeof params === "string") {
|
|
32
32
|
apiVersion = params;
|
|
33
33
|
params = {};
|
|
34
34
|
}
|
|
35
|
-
return `${path
|
|
35
|
+
return `${path}?${Object.entries({
|
|
36
36
|
"api-version": apiVersion,
|
|
37
37
|
...params
|
|
38
38
|
}).filter(([, value]) => value).map(([key, value]) => `${key}=${value}`).join("&")}`;
|
|
@@ -53,10 +53,10 @@ var ConnectionClient = class extends BaseAzureDevOpsClient {
|
|
|
53
53
|
//#endregion
|
|
54
54
|
//#region src/azure/client/client-git.ts
|
|
55
55
|
var GitClient = class extends BaseAzureDevOpsClient {
|
|
56
|
-
async getItem(projectIdOrName, repositoryIdOrName, path
|
|
56
|
+
async getItem(projectIdOrName, repositoryIdOrName, path, includeContent = true, latestProcessedChange = true) {
|
|
57
57
|
try {
|
|
58
58
|
return await this.client.get(this.makeUrl(`${encodeURIComponent(projectIdOrName)}/_apis/git/repositories/${encodeURIComponent(repositoryIdOrName)}/items`, {
|
|
59
|
-
path
|
|
59
|
+
path,
|
|
60
60
|
includeContent,
|
|
61
61
|
latestProcessedChange
|
|
62
62
|
})).json();
|
|
@@ -280,16 +280,16 @@ var AzureDevOpsClient = class AzureDevOpsClient {
|
|
|
280
280
|
Accept: "application/json"
|
|
281
281
|
},
|
|
282
282
|
hooks: {
|
|
283
|
-
beforeRequest: [async (request, options
|
|
283
|
+
beforeRequest: [async (request, options) => {
|
|
284
284
|
if (debug) logger.debug(`🌎 🠊 [${request.method}] ${request.url}`);
|
|
285
285
|
}],
|
|
286
|
-
afterResponse: [async (request, options
|
|
286
|
+
afterResponse: [async (request, options, response) => {
|
|
287
287
|
if (debug) {
|
|
288
288
|
logger.debug(`🌎 🠈 [${response.status}] ${response.statusText}`);
|
|
289
289
|
if (request.body) logger.debug(`REQUEST: ${JSON.stringify(request.body)}`);
|
|
290
290
|
}
|
|
291
291
|
}],
|
|
292
|
-
beforeRetry: [async ({ request, options
|
|
292
|
+
beforeRetry: [async ({ request, options, error, retryCount }) => {
|
|
293
293
|
if (debug && isHTTPError(error)) logger.debug(`⏳ Retrying failed request with status code: ${error.response.status}`);
|
|
294
294
|
}]
|
|
295
295
|
},
|
|
@@ -563,16 +563,29 @@ function buildPullRequestProperties(packageManager, dependencies) {
|
|
|
563
563
|
value: JSON.stringify(dependencies)
|
|
564
564
|
}];
|
|
565
565
|
}
|
|
566
|
+
function parsePullRequestProps(pr) {
|
|
567
|
+
const parsed = z.union([DependabotPersistedPrSchema, DependabotExistingPrDependencySchema.array()]).parse(JSON.parse(pr.properties.find((p) => p.name === PR_PROPERTY_DEPENDABOT_DEPENDENCIES).value));
|
|
568
|
+
if (Array.isArray(parsed)) return {
|
|
569
|
+
"pr-number": pr.pullRequestId,
|
|
570
|
+
dependencies: parsed
|
|
571
|
+
};
|
|
572
|
+
else return {
|
|
573
|
+
"pr-number": pr.pullRequestId,
|
|
574
|
+
...parsed
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function filterPullRequestsByPackageManager(pr, packageManager) {
|
|
578
|
+
return pr.properties?.find((p) => p.name === PR_PROPERTY_DEPENDABOT_PACKAGE_MANAGER && p.value === packageManager);
|
|
579
|
+
}
|
|
566
580
|
function parsePullRequestProperties(pullRequests, packageManager) {
|
|
567
|
-
return
|
|
568
|
-
return pr.properties?.find((p) => p.name === PR_PROPERTY_DEPENDABOT_PACKAGE_MANAGER && (packageManager === null || p.value === packageManager));
|
|
569
|
-
}).map((pr) => {
|
|
570
|
-
return [pr.pullRequestId, DependabotPersistedPrSchema.parse(JSON.parse(pr.properties.find((p) => p.name === PR_PROPERTY_DEPENDABOT_DEPENDENCIES).value))];
|
|
571
|
-
}));
|
|
581
|
+
return pullRequests.filter((pr) => filterPullRequestsByPackageManager(pr, packageManager)).map(parsePullRequestProps);
|
|
572
582
|
}
|
|
573
|
-
function getPullRequestForDependencyNames(existingPullRequests, packageManager, dependencyNames) {
|
|
574
|
-
return existingPullRequests.find((pr) => {
|
|
575
|
-
|
|
583
|
+
function getPullRequestForDependencyNames(existingPullRequests, packageManager, dependencyNames, dependencyGroupName) {
|
|
584
|
+
return existingPullRequests.filter((pr) => filterPullRequestsByPackageManager(pr, packageManager)).find((pr) => {
|
|
585
|
+
const parsedPr = parsePullRequestProps(pr);
|
|
586
|
+
const prGroupName = "dependency-group-name" in parsedPr ? parsedPr["dependency-group-name"] : null;
|
|
587
|
+
if (dependencyGroupName) return prGroupName === dependencyGroupName;
|
|
588
|
+
return !prGroupName && areEqual(getDependencyNames(parsedPr), dependencyNames);
|
|
576
589
|
});
|
|
577
590
|
}
|
|
578
591
|
function getPullRequestChangedFiles(data) {
|
|
@@ -1220,13 +1233,28 @@ const AzdoEventSchema = z.object({
|
|
|
1220
1233
|
|
|
1221
1234
|
//#endregion
|
|
1222
1235
|
//#region src/azure/url-parts.ts
|
|
1236
|
+
/**
|
|
1237
|
+
* Extract organization details from any Azure DevOps URL.
|
|
1238
|
+
* Accepts organization, project, or repository URLs.
|
|
1239
|
+
*/
|
|
1223
1240
|
function extractOrganizationUrl({ organizationUrl }) {
|
|
1224
1241
|
const value = new URL(organizationUrl);
|
|
1225
1242
|
const protocol = value.protocol.slice(0, -1);
|
|
1243
|
+
if (protocol !== "https" && protocol !== "http") throw new Error(`Invalid URL protocol: '${protocol}'. Only 'http' and 'https' are supported.`);
|
|
1226
1244
|
let { hostname } = value;
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
const
|
|
1245
|
+
const visualStudioMatch = hostname.match(/^(\S+)\.visualstudio\.com$/i);
|
|
1246
|
+
if (visualStudioMatch) hostname = "dev.azure.com";
|
|
1247
|
+
const allSegments = value.pathname.split("/").filter(Boolean);
|
|
1248
|
+
const gitIndex = allSegments.indexOf("_git");
|
|
1249
|
+
const segments = gitIndex >= 0 ? allSegments.slice(0, gitIndex) : allSegments;
|
|
1250
|
+
let organization;
|
|
1251
|
+
let virtualDirectory;
|
|
1252
|
+
if (visualStudioMatch) organization = visualStudioMatch[1];
|
|
1253
|
+
else if (segments.length >= 2 && hostname !== "dev.azure.com") {
|
|
1254
|
+
virtualDirectory = segments[0];
|
|
1255
|
+
organization = segments[1];
|
|
1256
|
+
} else if (segments.length >= 1) organization = segments[0];
|
|
1257
|
+
else throw new Error(`Error parsing organization from url: '${organizationUrl}'.`);
|
|
1230
1258
|
const apiEndpoint = `${protocol}://${hostname}${value.port ? `:${value.port}` : ""}/${virtualDirectory ? `${virtualDirectory}/` : ""}`;
|
|
1231
1259
|
const identityApiUrl = hostname === "dev.azure.com" || hostname.endsWith(".visualstudio.com") ? new URL(`https://vssps.dev.azure.com/${organization}/`) : value;
|
|
1232
1260
|
return {
|
|
@@ -1238,58 +1266,36 @@ function extractOrganizationUrl({ organizationUrl }) {
|
|
|
1238
1266
|
"identity-api-url": identityApiUrl
|
|
1239
1267
|
};
|
|
1240
1268
|
}
|
|
1241
|
-
function
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1269
|
+
function extractRepositoryUrl(options) {
|
|
1270
|
+
let project;
|
|
1271
|
+
let repository;
|
|
1272
|
+
let extracted;
|
|
1273
|
+
if ("repositoryUrl" in options) {
|
|
1274
|
+
const url = new URL(options.repositoryUrl);
|
|
1275
|
+
if (!url.pathname.includes("/_git/")) throw new Error(`Invalid repository URL: '${options.repositoryUrl}'. URL must contain '/_git/'.`);
|
|
1276
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
1277
|
+
const gitIndex = segments.indexOf("_git");
|
|
1278
|
+
if (gitIndex === -1 || gitIndex >= segments.length - 1) throw new Error(`Invalid repository URL: '${options.repositoryUrl}'. Repository name must follow '/_git/'.`);
|
|
1279
|
+
project = decodeURIComponent(segments[gitIndex - 1]);
|
|
1280
|
+
repository = decodeURIComponent(segments.slice(gitIndex + 1).join("/"));
|
|
1281
|
+
const orgSegments = segments.slice(0, gitIndex - 1);
|
|
1282
|
+
const orgPath = orgSegments.length > 0 ? `/${orgSegments.join("/")}/` : "/";
|
|
1283
|
+
extracted = extractOrganizationUrl({ organizationUrl: `${url.protocol}//${url.host}${orgPath}` });
|
|
1284
|
+
} else {
|
|
1285
|
+
project = decodeURIComponent(options.project);
|
|
1286
|
+
repository = decodeURIComponent(options.repository);
|
|
1287
|
+
extracted = extractOrganizationUrl({ organizationUrl: options.organizationUrl });
|
|
1288
|
+
}
|
|
1289
|
+
const virtualDirectory = extracted["virtual-directory"];
|
|
1290
|
+
const repoSlug = `${virtualDirectory ? `${virtualDirectory}/` : ""}${extracted.organization}/${encodeURI(project)}/_git/${encodeURI(repository)}`;
|
|
1257
1291
|
return {
|
|
1258
1292
|
...extracted,
|
|
1259
|
-
|
|
1293
|
+
project,
|
|
1294
|
+
repository,
|
|
1260
1295
|
"repository-slug": repoSlug
|
|
1261
1296
|
};
|
|
1262
1297
|
}
|
|
1263
|
-
/**
|
|
1264
|
-
* Extract organization name from organization URL
|
|
1265
|
-
*
|
|
1266
|
-
* @param organizationUrl
|
|
1267
|
-
*
|
|
1268
|
-
* @returns organization name
|
|
1269
|
-
*/
|
|
1270
|
-
function extractOrganization(organizationUrl) {
|
|
1271
|
-
const { hostname, pathname } = new URL(organizationUrl);
|
|
1272
|
-
if (hostname.endsWith(".visualstudio.com")) return hostname.split(".")[0];
|
|
1273
|
-
const pathSegments = pathname.split("/").filter((segment) => segment !== "");
|
|
1274
|
-
if (pathSegments.length >= 2 && hostname !== "dev.azure.com") return pathSegments[1];
|
|
1275
|
-
if (pathSegments.length >= 1) return pathSegments[0];
|
|
1276
|
-
throw new Error(`Error parsing organization from organization url: '${organizationUrl}'.`);
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
* Extract virtual directory from organization URL
|
|
1280
|
-
*
|
|
1281
|
-
* Virtual Directories are sometimes used in on-premises
|
|
1282
|
-
* @param organizationUrl
|
|
1283
|
-
*
|
|
1284
|
-
* @returns virtual directory
|
|
1285
|
-
*
|
|
1286
|
-
* @example URLs typically are like this:`https://server.domain.com/tfs/x/` and `tfs` is the virtual directory
|
|
1287
|
-
*/
|
|
1288
|
-
function extractVirtualDirectory(organizationUrl) {
|
|
1289
|
-
const path$1 = organizationUrl.pathname.split("/");
|
|
1290
|
-
return path$1.length === 4 ? path$1[1] : void 0;
|
|
1291
|
-
}
|
|
1292
1298
|
|
|
1293
1299
|
//#endregion
|
|
1294
|
-
export { ANONYMOUS_USER_ID, API_VERSION, API_VERSION_PREVIEW, AZDO_PULL_REQUEST_MERGE_STRATEGIES, AzdoCommentThreadStatusSchema, AzdoCommentTypeSchema, AzdoConnectionDataSchema, AzdoEventCodePushResourceSchema, AzdoEventPullRequestCommentEventResourceSchema, AzdoEventPullRequestResourceSchema, AzdoEventRepositoryCreatedResourceSchema, AzdoEventRepositoryDeletedResourceSchema, AzdoEventRepositoryRenamedResourceSchema, AzdoEventRepositorySchema, AzdoEventRepositoryStatusChangedResourceSchema, AzdoEventSchema, AzdoEventTypeSchema, AzdoGitBranchStatsSchema, AzdoGitChangeSchema, AzdoGitCommitDiffsSchema, AzdoGitCommitRefSchema, AzdoGitPushCreateSchema, AzdoGitPushSchema, AzdoGitRefSchema, AzdoGitRefUpdateResultSchema, AzdoGitRefUpdateSchema, AzdoGitUserDateSchema, AzdoIdentityRefSchema, AzdoIdentityRefWithVoteSchema, AzdoIdentitySchema, AzdoProjectSchema, AzdoPropertiesSchema, AzdoPullRequestAsyncStatusSchema, AzdoPullRequestCommentSchema, AzdoPullRequestCommentThreadSchema, AzdoPullRequestMergeStrategySchema, AzdoPullRequestSchema, AzdoPullRequestStatusSchema, AzdoRepositoryItemSchema, AzdoRepositorySchema, AzdoSubscriptionSchema, AzdoSubscriptionsQueryInputFilterSchema, AzdoSubscriptionsQueryResponseSchema, AzdoSubscriptionsQuerySchema, AzdoVersionControlChangeTypeSchema, AzureDevOpsClient, AzureDevOpsClientWrapper, PR_DESCRIPTION_MAX_LENGTH, PR_PROPERTY_DEPENDABOT_DEPENDENCIES, PR_PROPERTY_DEPENDABOT_PACKAGE_MANAGER, PR_PROPERTY_MICROSOFT_GIT_SOURCE_REF_NAME, buildPullRequestProperties, extractOrganizationUrl,
|
|
1300
|
+
export { ANONYMOUS_USER_ID, API_VERSION, API_VERSION_PREVIEW, AZDO_PULL_REQUEST_MERGE_STRATEGIES, AzdoCommentThreadStatusSchema, AzdoCommentTypeSchema, AzdoConnectionDataSchema, AzdoEventCodePushResourceSchema, AzdoEventPullRequestCommentEventResourceSchema, AzdoEventPullRequestResourceSchema, AzdoEventRepositoryCreatedResourceSchema, AzdoEventRepositoryDeletedResourceSchema, AzdoEventRepositoryRenamedResourceSchema, AzdoEventRepositorySchema, AzdoEventRepositoryStatusChangedResourceSchema, AzdoEventSchema, AzdoEventTypeSchema, AzdoGitBranchStatsSchema, AzdoGitChangeSchema, AzdoGitCommitDiffsSchema, AzdoGitCommitRefSchema, AzdoGitPushCreateSchema, AzdoGitPushSchema, AzdoGitRefSchema, AzdoGitRefUpdateResultSchema, AzdoGitRefUpdateSchema, AzdoGitUserDateSchema, AzdoIdentityRefSchema, AzdoIdentityRefWithVoteSchema, AzdoIdentitySchema, AzdoProjectSchema, AzdoPropertiesSchema, AzdoPullRequestAsyncStatusSchema, AzdoPullRequestCommentSchema, AzdoPullRequestCommentThreadSchema, AzdoPullRequestMergeStrategySchema, AzdoPullRequestSchema, AzdoPullRequestStatusSchema, AzdoRepositoryItemSchema, AzdoRepositorySchema, AzdoSubscriptionSchema, AzdoSubscriptionsQueryInputFilterSchema, AzdoSubscriptionsQueryResponseSchema, AzdoSubscriptionsQuerySchema, AzdoVersionControlChangeTypeSchema, AzureDevOpsClient, AzureDevOpsClientWrapper, PR_DESCRIPTION_MAX_LENGTH, PR_PROPERTY_DEPENDABOT_DEPENDENCIES, PR_PROPERTY_DEPENDABOT_PACKAGE_MANAGER, PR_PROPERTY_MICROSOFT_GIT_SOURCE_REF_NAME, buildPullRequestProperties, extractOrganizationUrl, extractRepositoryUrl, getDependabotConfig, getPullRequestChangedFiles, getPullRequestForDependencyNames, parsePullRequestProperties, parsePullRequestProps };
|
|
1295
1301
|
//# sourceMappingURL=index.mjs.map
|