@@ -6,12 +6,27 @@ This package provides a comprehensive set of TypeScript utilities for interactin
66
77## Features
88
9- - ✅ ** Sticky Comments** - Create and manage persistent, updatable comments
10- - ✅ ** Pull Request Utilities** - Find, label, and manage pull requests
11- - ✅ ** Comment Search** - Search and filter issue/PR comments
9+ ### 📋 Complete Function Reference
10+
11+ | Category | Functions | Description |
12+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
13+ | ** 💬 Comments** | ` createStickyComment ` , ` findCommentByIdentifier ` , ` searchComments ` , ` deleteComment ` , ` deleteStickyComment ` | Create, find, search, and manage issue/PR comments |
14+ | ** 🔀 Pull Requests** | ` findPullRequestsByLabels ` , ` getPullRequest ` , ` addLabelsToPullRequest ` , ` removeLabelsFromPullRequest ` , ` pullRequestHasLabels ` , ` getPullRequestFiles ` | Find, manage, and interact with pull requests |
15+ | ** 🔍 Advanced PR Search** | ` findPRsWithLabels ` , ` searchPullRequests ` , ` findOpenPRsWithLabel ` , ` checkLabelConflicts ` | Advanced pull request search and label conflict detection |
16+ | ** 🌿 Branch Management** | ` checkBranchExists ` , ` listAllBranches ` , ` getBranchProtection ` , ` getDefaultBranch ` | Branch existence, listing, and protection management |
17+ | ** 🚀 Deployments** | ` listDeployments ` , ` getDeploymentStatuses ` , ` setDeploymentStatus ` , ` deleteDeployment ` , ` createDeployment ` | Deployment lifecycle management |
18+ | ** 🔧 Context & Utils** | ` getRepoInfo ` , ` getCurrentPullRequestNumber ` , ` getCurrentIssueNumber ` , ` isPullRequestContext ` , ` isIssueContext ` , ` getCurrentSHA ` , ` getCurrentBranch ` , ` getRepositoryUrl ` , ` getIssueUrl ` , ` getPullRequestUrl ` | GitHub Actions context extraction and URL helpers |
19+ | ** 📝 Text & Formatting** | ` escapeMarkdown ` , ` codeBlock ` , ` createMarkdownTable ` , ` truncateText ` , ` formatDate ` , ` parseGitHubDate ` , ` delay ` | Text formatting, markdown utilities, and date handling |
20+ | ** 🔤 String Utilities** | ` snakeToCamel ` , ` camelToSnake ` , ` kebabToCamel ` , ` camelToKebab ` , ` capitalize ` , ` toTitleCase ` | String case conversion and text transformation |
21+ | ** ⚙️ Input Processing** | ` sanitizeInput ` , ` sanitizeInputs ` , ` getBranch ` | Input sanitization and branch extraction from various GitHub events |
22+
23+ ### ✨ Key Features
24+
1225- ✅ ** Type Safety** - Full TypeScript support with comprehensive type definitions
13- - ✅ ** Context Helpers** - Extract repository and event information from GitHub Actions context
14- - ✅ ** Markdown Utilities** - Format and escape content for GitHub markdown
26+ - ✅ ** Universal Compatibility** - Works with all GitHub event types and contexts
27+ - ✅ ** Comprehensive Testing** - 110+ tests with 94%+ code coverage
28+ - ✅ ** GitHub API Optimized** - Efficient API usage with proper error handling and pagination support
29+ - ✅ ** Developer Friendly** - Intuitive APIs with TypeScript intellisense and JSDoc documentation
1530
1631---
1732
@@ -278,6 +293,180 @@ const table = createMarkdownTable(
278293const short = truncateText (" Very long text..." , 50 );
279294```
280295
296+ ### String Utilities
297+
298+ #### Case Conversion
299+
300+ ``` ts
301+ import {
302+ snakeToCamel ,
303+ camelToSnake ,
304+ kebabToCamel ,
305+ camelToKebab ,
306+ capitalize ,
307+ toTitleCase ,
308+ } from " github-typescript-utils" ;
309+
310+ // Convert between naming conventions
311+ const camelCase = snakeToCamel (" hello_world" ); // "helloWorld"
312+ const snakeCase = camelToSnake (" helloWorld" ); // "hello_world"
313+ const kebabCase = camelToKebab (" helloWorld" ); // "hello-world"
314+ const camelFromKebab = kebabToCamel (" hello-world" ); // "helloWorld"
315+
316+ // Text transformation
317+ const capitalized = capitalize (" hello" ); // "Hello"
318+ const titleCase = toTitleCase (" hello world" ); // "Hello World"
319+ ```
320+
321+ ### Branch Management
322+
323+ #### Branch Operations
324+
325+ ``` ts
326+ import {
327+ checkBranchExists ,
328+ listAllBranches ,
329+ getBranchProtection ,
330+ getDefaultBranch ,
331+ } from " github-typescript-utils" ;
332+
333+ // Check if branch exists
334+ const exists = await checkBranchExists ({
335+ ctx: { core , github , context },
336+ repo ,
337+ branch: " feature-branch" ,
338+ });
339+
340+ // List all branches
341+ const branches = await listAllBranches ({
342+ ctx: { core , github , context },
343+ repo ,
344+ limit: 50 ,
345+ });
346+
347+ // Get branch protection rules
348+ const protection = await getBranchProtection ({
349+ ctx: { core , github , context },
350+ repo ,
351+ branch: " main" ,
352+ });
353+
354+ // Get default branch
355+ const defaultBranch = await getDefaultBranch ({
356+ ctx: { core , github , context },
357+ repo ,
358+ });
359+ ```
360+
361+ ### Deployment Management
362+
363+ #### Deployment Lifecycle
364+
365+ ``` ts
366+ import {
367+ listDeployments ,
368+ createDeployment ,
369+ setDeploymentStatus ,
370+ getDeploymentStatuses ,
371+ deleteDeployment ,
372+ } from " github-typescript-utils" ;
373+
374+ // Create a deployment
375+ const deployment = await createDeployment ({
376+ ctx: { core , github , context },
377+ repo ,
378+ ref: " main" ,
379+ environment: " production" ,
380+ description: " Deploy v1.0.0" ,
381+ });
382+
383+ // Set deployment status
384+ await setDeploymentStatus ({
385+ ctx: { core , github , context },
386+ repo ,
387+ deploymentId: deployment .id ,
388+ state: " success" ,
389+ description: " Deployment completed successfully" ,
390+ });
391+
392+ // List deployments
393+ const deployments = await listDeployments ({
394+ ctx: { core , github , context },
395+ repo ,
396+ environment: " production" ,
397+ });
398+ ```
399+
400+ ### Advanced PR Search
401+
402+ #### Enhanced PR Operations
403+
404+ ``` ts
405+ import {
406+ findPRsWithLabels ,
407+ searchPullRequests ,
408+ checkLabelConflicts ,
409+ findOpenPRsWithLabel ,
410+ } from " github-typescript-utils" ;
411+
412+ // Find PRs with multiple labels
413+ const prs = await findPRsWithLabels ({
414+ ctx: { core , github , context },
415+ repo ,
416+ labels: [" bug" , " urgent" ],
417+ excludePRs: [123 ], // Exclude specific PR numbers
418+ });
419+
420+ // Advanced PR search
421+ const searchResults = await searchPullRequests ({
422+ ctx: { core , github , context },
423+ repo ,
424+ options: {
425+ labels: [" feature" ],
426+ author: " dependabot[bot]" ,
427+ state: " open" ,
428+ },
429+ });
430+
431+ // Check for label conflicts
432+ const conflict = await checkLabelConflicts ({
433+ ctx: { core , github , context },
434+ repo ,
435+ prNumber: 123 ,
436+ label: " sync-branch: main" ,
437+ });
438+
439+ if (conflict .hasConflict ) {
440+ core .warning (` Label conflict with PR #${conflict .conflictingPR ?.number } ` );
441+ }
442+ ```
443+
444+ ### Input Processing
445+
446+ #### Input Sanitization and Branch Extraction
447+
448+ ``` ts
449+ import {
450+ sanitizeInput ,
451+ sanitizeInputs ,
452+ getBranch ,
453+ } from " github-typescript-utils" ;
454+
455+ // Remove quotes from workflow inputs
456+ const cleanInput = sanitizeInput (' "quoted-value"' ); // "quoted-value"
457+
458+ // Sanitize all string properties in an object
459+ const cleanInputs = sanitizeInputs ({
460+ name: ' "John"' ,
461+ age: 30 ,
462+ title: ' "Developer"' ,
463+ }); // { name: "John", age: 30, title: "Developer" }
464+
465+ // Extract branch from any GitHub event
466+ const branch = getBranch ({ core , github , context });
467+ // Works with: pull_request, push, workflow_run, etc.
468+ ```
469+
281470---
282471
283472## Type Definitions
@@ -286,13 +475,24 @@ The package exports comprehensive TypeScript types:
286475
287476``` ts
288477import type {
478+ // Core types
289479 GitHubContext ,
290480 RepoInfo ,
291481 PullRequest ,
292482 IssueComment ,
483+
484+ // Comment types
293485 StickyCommentOptions ,
294486 CommentSearchOptions ,
487+
488+ // Pull request types
295489 PullRequestSearchOptions ,
490+ PullRequestFile ,
491+ AdvancedPRSearchOptions ,
492+
493+ // Deployment types
494+ Deployment ,
495+ DeploymentStatus ,
296496} from " github-typescript-utils" ;
297497```
298498
0 commit comments