Skip to content

Commit 8d74970

Browse files
Copilotfregante
andcommitted
Use node --import tsx instead of tsx directly, add as postbuild:typescript script
- Changed build script to use postbuild:typescript hook instead of appending to main build - Use 'node --import tsx' to run TypeScript files with modern Node.js - Script now runs automatically after TypeScript compilation completes Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
1 parent 41cf558 commit 8d74970

4 files changed

Lines changed: 167 additions & 1 deletion

File tree

collector.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */
2+
export declare const testableUrls: any;
3+
export declare function addTests(test: string, urls: string[]): void;
4+
export declare function getTests(detectName: string): string[];
5+
export declare function getAllUrls(): Set<string>;

index.d.ts

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
export declare const is404: () => boolean;
2+
export declare const is500: () => boolean;
3+
export declare const isPasswordConfirmation: () => boolean;
4+
export declare const isLoggedIn: () => boolean;
5+
export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean;
6+
export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
7+
export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
8+
export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
9+
export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean;
10+
export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
11+
export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean;
12+
export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean;
13+
export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
14+
export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
15+
export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean;
16+
export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
17+
export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
18+
export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
19+
export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean;
20+
export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean;
21+
export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean;
22+
export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
23+
export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean;
24+
export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
25+
export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
26+
export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean;
27+
export declare const isOrganizationProfile: () => boolean;
28+
export declare const isOrganizationRepo: () => boolean;
29+
export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
30+
export declare const isOwnUserProfile: () => boolean;
31+
export declare const isOwnOrganizationProfile: () => boolean;
32+
export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean;
33+
export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean;
34+
export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
35+
export declare const isNewDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean;
36+
export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean;
37+
export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
38+
export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean;
39+
/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
40+
export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
41+
export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
42+
export declare const isPRCommit404: () => boolean;
43+
export declare const isPRFile404: () => boolean;
44+
export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean;
45+
export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
46+
export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
47+
export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean;
48+
export declare const isMergedPR: () => boolean;
49+
export declare const isDraftPR: () => boolean;
50+
export declare const isOpenConversation: () => boolean;
51+
export declare const isClosedConversation: () => boolean;
52+
export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean;
53+
export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
54+
export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean;
55+
export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean;
56+
export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
57+
export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
58+
export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
59+
export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean;
60+
export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
61+
export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean;
62+
export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
63+
export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
64+
export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean;
65+
export declare const isEmptyRepoRoot: () => boolean;
66+
export declare const isEmptyRepo: () => boolean;
67+
export declare const isPublicRepo: () => boolean;
68+
export declare const isArchivedRepo: () => boolean;
69+
export declare const isBlank: () => boolean;
70+
export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
71+
export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
72+
export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean;
73+
export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean;
74+
export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean;
75+
export type RepoExplorerInfo = {
76+
nameWithOwner: string;
77+
branch: string;
78+
filePath: string;
79+
};
80+
export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean;
81+
export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean;
82+
export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
83+
export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
84+
export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
85+
export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean;
86+
export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean;
87+
export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean;
88+
export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
89+
export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean;
90+
export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean;
91+
/**
92+
* @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea
93+
* @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx
94+
*/
95+
export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean;
96+
export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean;
97+
export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean;
98+
export declare const isForkedRepo: () => boolean;
99+
export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
100+
export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean;
101+
export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean;
102+
export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean;
103+
export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean;
104+
export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
105+
export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean;
106+
export declare const isUserProfile: () => boolean;
107+
export declare const isPrivateUserProfile: () => boolean;
108+
export declare const isUserProfileMainTab: () => boolean;
109+
export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
110+
export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
111+
export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
112+
export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean;
113+
export declare const isProfileRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean;
114+
export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean;
115+
export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean;
116+
/** Static code, not the code editor */
117+
export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean;
118+
/** Covers blob, trees and blame pages */
119+
export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean;
120+
/** Has a list of files */
121+
export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean;
122+
export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
123+
export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
124+
export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean;
125+
export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean;
126+
export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean;
127+
export declare const isUserTheOrganizationOwner: () => boolean;
128+
export declare const canUserAdminRepo: () => boolean;
129+
/** @deprecated Use `canUserAdminRepo` */
130+
export declare const canUserEditRepo: () => boolean;
131+
export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean;
132+
export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean;
133+
export type NameWithOwner = `${string}/${string}`;
134+
export type RepositoryInfo = {
135+
/** The repo owner/user */
136+
owner: string;
137+
/** The repo name */
138+
name: string;
139+
/** The 'user/repo' part from an URL */
140+
nameWithOwner: NameWithOwner;
141+
/** A repo's subpage
142+
@example '/user/repo/issues/' -> 'issues'
143+
@example '/user/repo/' -> ''
144+
@example '/settings/token/' -> undefined */
145+
path: string;
146+
};
147+
export declare const utils: {
148+
getOrg: (url?: URL | HTMLAnchorElement | Location) => {
149+
name: string;
150+
path: string;
151+
} | undefined;
152+
/** @deprecated Use `getLoggedInUser` */
153+
getUsername: () => string | undefined;
154+
getLoggedInUser: () => string | undefined;
155+
getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string;
156+
getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined;
157+
getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined;
158+
parseRepoExplorerTitle: (pathname: string, title: string) => RepoExplorerInfo | undefined;
159+
};

index.test.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
"distribution/index.d.ts"
2525
],
2626
"scripts": {
27-
"build": "run-p build:esbuild build:typescript build:demo && tsx add-examples-to-dts.ts",
27+
"build": "run-p build:*",
2828
"build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST",
2929
"build:typescript": "tsc --declaration --emitDeclarationOnly",
30+
"postbuild:typescript": "node --import tsx add-examples-to-dts.ts",
3031
"build:demo": "vite build demo",
3132
"try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'",
3233
"fix": "xo --fix",

0 commit comments

Comments
 (0)