github-url-detection 9.0.1 → 9.0.2
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/distribution/index.d.ts +2 -0
- package/distribution/index.js +20 -5
- package/package.json +1 -1
package/distribution/index.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) =>
|
|
|
118
118
|
export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
119
119
|
export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
120
120
|
export declare const isUserTheOrganizationOwner: () => boolean;
|
|
121
|
+
export declare const canUserAdminRepo: () => boolean;
|
|
122
|
+
/** @deprecated Use `canUserAdminRepo` */
|
|
121
123
|
export declare const canUserEditRepo: () => boolean;
|
|
122
124
|
export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
|
123
125
|
export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
|
package/distribution/index.js
CHANGED
|
@@ -48,10 +48,23 @@ var isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path
|
|
|
48
48
|
var isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
|
|
49
49
|
var isPRFiles = (url = location) => /^pull\/\d+\/files/.test(getRepo(url)?.path) || isPRCommit(url);
|
|
50
50
|
var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
var prStateSelector = [
|
|
52
|
+
".State",
|
|
53
|
+
'[class^="StateLabel"]'
|
|
54
|
+
].join(",");
|
|
55
|
+
var isDraftPR = () => $(prStateSelector).textContent.trim() === "Draft";
|
|
56
|
+
var isOpenPR = () => {
|
|
57
|
+
const status = $(prStateSelector).textContent.trim();
|
|
58
|
+
return status === "Open" || status === "Draft";
|
|
59
|
+
};
|
|
60
|
+
var isMergedPR = () => {
|
|
61
|
+
const status = $(prStateSelector).textContent.trim();
|
|
62
|
+
return status === "Merged";
|
|
63
|
+
};
|
|
64
|
+
var isClosedPR = () => {
|
|
65
|
+
const status = $(prStateSelector).textContent.trim();
|
|
66
|
+
return status === "Closed" || status === "Merged";
|
|
67
|
+
};
|
|
55
68
|
var isClosedIssue = () => exists("#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)");
|
|
56
69
|
var isReleases = (url = location) => getRepo(url)?.path === "releases";
|
|
57
70
|
var isTags = (url = location) => getRepo(url)?.path === "tags";
|
|
@@ -139,7 +152,8 @@ var isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.pat
|
|
|
139
152
|
var isNewAction = (url = location) => getRepo(url)?.path === "actions/new";
|
|
140
153
|
var isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path);
|
|
141
154
|
var isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]');
|
|
142
|
-
var
|
|
155
|
+
var canUserAdminRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
|
|
156
|
+
var canUserEditRepo = canUserAdminRepo;
|
|
143
157
|
var isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
|
|
144
158
|
var isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
|
|
145
159
|
var getLoggedInUser = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
|
|
@@ -193,6 +207,7 @@ var utils = {
|
|
|
193
207
|
getRepositoryInfo: getRepo
|
|
194
208
|
};
|
|
195
209
|
export {
|
|
210
|
+
canUserAdminRepo,
|
|
196
211
|
canUserEditRepo,
|
|
197
212
|
hasCode,
|
|
198
213
|
hasComments,
|