|
| 1 | +interface CommonOptions { |
| 2 | + /** |
| 3 | + * The issue body. |
| 4 | + */ |
| 5 | + readonly body?: string; |
| 6 | + |
| 7 | + /** |
| 8 | + * The issue title. |
| 9 | + */ |
| 10 | + readonly title?: string; |
| 11 | + |
| 12 | + /** |
| 13 | + * Use an [issue template](https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository/). |
| 14 | + * |
| 15 | + * @example |
| 16 | + * |
| 17 | + * 'unicorn.md' // If you want to use a template at `ISSUE_TEMPLATE/unicorn.md`. |
| 18 | + */ |
| 19 | + readonly template?: string; |
| 20 | + |
| 21 | + /** |
| 22 | + * The labels for the issue. |
| 23 | + * |
| 24 | + * *Requires the user to have the permission to add labels.* |
| 25 | + */ |
| 26 | + readonly labels?: string[]; |
| 27 | + |
| 28 | + /** |
| 29 | + * The milestone for the issue. |
| 30 | + * |
| 31 | + * *Requires the user to have the permission to add milestone.* |
| 32 | + */ |
| 33 | + readonly milestone?: string; |
| 34 | + |
| 35 | + /** |
| 36 | + * The user to assign to the issue. |
| 37 | + * |
| 38 | + * *Requires the user to have the permission to add assignee.* |
| 39 | + */ |
| 40 | + readonly assignee?: string; |
| 41 | + |
| 42 | + /** |
| 43 | + * The projects to add the issue to. |
| 44 | + * The project reference format is `user/<project-number>`, for example, if the URL to the project is `https://github.com/sindresorhus/some-repo/projects/3`, the project reference would be `some-repo/3`. |
| 45 | + * |
| 46 | + * *Requires the user to have the permission to add projects.* |
| 47 | + */ |
| 48 | + readonly projects?: string[]; |
| 49 | +} |
| 50 | + |
| 51 | +interface RepoUrlOptions extends CommonOptions { |
| 52 | + /** |
| 53 | + * The full URL to the repo. |
| 54 | + */ |
| 55 | + readonly repoUrl: string; |
| 56 | +} |
| 57 | + |
| 58 | +interface UserAndRepoOptions extends CommonOptions { |
| 59 | + /** |
| 60 | + * GitHub username or organization. |
| 61 | + */ |
| 62 | + readonly user: string; |
| 63 | + |
| 64 | + /** |
| 65 | + * GitHub repo. |
| 66 | + */ |
| 67 | + readonly repo: string; |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * You are required to either specify the `repoUrl` option or both the `user` and `repo` options. |
| 72 | + */ |
| 73 | +export type Options = RepoUrlOptions | UserAndRepoOptions |
| 74 | + |
| 75 | +/** |
| 76 | + * Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields. |
| 77 | + * |
| 78 | + * @example |
| 79 | + * |
| 80 | + * import newGithubIssueUrl from 'new-github-issue-url'; |
| 81 | + * import opn from 'opn'; |
| 82 | + * |
| 83 | + * const url = newGithubIssueUrl({ |
| 84 | + * user: 'sindresorhus', |
| 85 | + * repo: 'new-github-issue-url', |
| 86 | + * body: '\n\n\n---\nI\'m a human. Please be nice.' |
| 87 | + * }); |
| 88 | + * //=> 'https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.' |
| 89 | + * |
| 90 | + * // Then open it |
| 91 | + * opn(url); |
| 92 | + */ |
| 93 | +export default function newGithubIssueUrl(options: Options): string; |
0 commit comments