new-github-issue-url
Advanced tools
Comparing version 0.2.1 to 1.0.0
157
index.d.ts
@@ -1,106 +0,95 @@ | ||
declare namespace newGithubIssueUrl { | ||
interface CommonOptions { | ||
/** | ||
The issue body. | ||
*/ | ||
readonly body?: string; | ||
export interface CommonOptions { | ||
/** | ||
The issue body. | ||
*/ | ||
readonly body?: string; | ||
/** | ||
The issue title. | ||
*/ | ||
readonly title?: string; | ||
/** | ||
The issue title. | ||
*/ | ||
readonly title?: string; | ||
/** | ||
Use an [issue template](https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository/). | ||
/** | ||
Use an [issue template](https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository/). | ||
@example | ||
``` | ||
'unicorn.md' // If you want to use a template at `ISSUE_TEMPLATE/unicorn.md`. | ||
``` | ||
*/ | ||
readonly template?: string; | ||
@example | ||
``` | ||
'unicorn.md' // If you want to use a template at `ISSUE_TEMPLATE/unicorn.md`. | ||
``` | ||
*/ | ||
readonly template?: string; | ||
/** | ||
The labels for the issue. | ||
/** | ||
The labels for the issue. | ||
_Requires the user to have the permission to add labels._ | ||
*/ | ||
readonly labels?: string[]; | ||
_Requires the user to have the permission to add labels._ | ||
*/ | ||
readonly labels?: string[]; | ||
/** | ||
The milestone for the issue. | ||
/** | ||
The milestone for the issue. | ||
_Requires the user to have the permission to add milestone._ | ||
*/ | ||
readonly milestone?: string; | ||
_Requires the user to have the permission to add milestone._ | ||
*/ | ||
readonly milestone?: string; | ||
/** | ||
The user to assign to the issue. | ||
/** | ||
The user to assign to the issue. | ||
_Requires the user to have the permission to add assignee._ | ||
*/ | ||
readonly assignee?: string; | ||
_Requires the user to have the permission to add assignee._ | ||
*/ | ||
readonly assignee?: string; | ||
/** | ||
The projects to add the issue to. | ||
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`. | ||
/** | ||
The projects to add the issue to. | ||
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`. | ||
_Requires the user to have the permission to add projects._ | ||
*/ | ||
readonly projects?: string[]; | ||
} | ||
_Requires the user to have the permission to add projects._ | ||
*/ | ||
readonly projects?: string[]; | ||
} | ||
interface RepoUrlOptions extends CommonOptions { | ||
/** | ||
The full URL to the repo. | ||
*/ | ||
readonly repoUrl: string; | ||
} | ||
export interface RepoUrlOptions extends CommonOptions { | ||
/** | ||
The full URL to the repo. | ||
*/ | ||
readonly repoUrl: string; | ||
} | ||
interface UserAndRepoOptions extends CommonOptions { | ||
/** | ||
GitHub username or organization. | ||
*/ | ||
readonly user: string; | ||
export interface UserAndRepoOptions extends CommonOptions { | ||
/** | ||
GitHub username or organization. | ||
*/ | ||
readonly user: string; | ||
/** | ||
GitHub repo. | ||
*/ | ||
readonly repo: string; | ||
} | ||
/** | ||
You are required to either specify the `repoUrl` option or both the `user` and `repo` options. | ||
GitHub repo. | ||
*/ | ||
type Options = RepoUrlOptions | UserAndRepoOptions; | ||
readonly repo: string; | ||
} | ||
declare const newGithubIssueUrl: { | ||
/** | ||
Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields. | ||
/** | ||
You are required to either specify the `repoUrl` option or both the `user` and `repo` options. | ||
*/ | ||
export type Options = RepoUrlOptions | UserAndRepoOptions; | ||
@example | ||
``` | ||
import newGithubIssueUrl = require('new-github-issue-url'); | ||
import opn = require('opn'); | ||
/** | ||
Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields. | ||
const url = newGithubIssueUrl({ | ||
user: 'sindresorhus', | ||
repo: 'new-github-issue-url', | ||
body: '\n\n\n---\nI\'m a human. Please be nice.' | ||
}); | ||
//=> 'https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.' | ||
@example | ||
``` | ||
import newGithubIssueUrl from 'new-github-issue-url'; | ||
import open from 'open'; | ||
// Then open it | ||
opn(url); | ||
``` | ||
*/ | ||
(options: newGithubIssueUrl.Options): string; | ||
const url = newGithubIssueUrl({ | ||
user: 'sindresorhus', | ||
repo: 'new-github-issue-url', | ||
body: '\n\n\n---\nI\'m a human. Please be nice.' | ||
}); | ||
//=> 'https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.' | ||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function newGithubIssueUrl(options: newGithubIssueUrl.Options): string; | ||
// export = newGithubIssueUrl; | ||
default: typeof newGithubIssueUrl; | ||
}; | ||
export = newGithubIssueUrl; | ||
// Then open it | ||
await open(url); | ||
``` | ||
*/ | ||
export default function newGithubIssueUrl(options: Options): string; |
11
index.js
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
module.exports = (options = {}) => { | ||
export default function newGithubIssueUrl(options = {}) { | ||
let repoUrl; | ||
@@ -22,3 +20,3 @@ if (options.repoUrl) { | ||
'assignee', | ||
'projects' | ||
'projects', | ||
]; | ||
@@ -44,5 +42,2 @@ | ||
return url.toString(); | ||
}; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = module.exports; | ||
} |
{ | ||
"name": "new-github-issue-url", | ||
"version": "0.2.1", | ||
"version": "1.0.0", | ||
"description": "Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields", | ||
"license": "MIT", | ||
"repository": "sindresorhus/new-github-issue-url", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=10" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -35,6 +38,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.18.0", | ||
"xo": "^0.45.0" | ||
} | ||
} |
@@ -1,20 +0,18 @@ | ||
# new-github-issue-url [![Build Status](https://travis-ci.com/sindresorhus/new-github-issue-url.svg?branch=master)](https://travis-ci.com/sindresorhus/new-github-issue-url) | ||
# new-github-issue-url | ||
> Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields | ||
GitHub supports prefilling a new issue by setting [certain search parameters](https://help.github.com/articles/about-automation-for-issues-and-pull-requests-with-query-parameters/). This package simplifies generating such URL. | ||
GitHub supports prefilling a new issue by setting [certain search parameters](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue#creating-an-issue-from-a-url-query). This package simplifies generating such URL. | ||
## Install | ||
```sh | ||
npm install new-github-issue-url | ||
``` | ||
$ npm install new-github-issue-url | ||
``` | ||
## Usage | ||
```js | ||
const newGithubIssueUrl = require('new-github-issue-url'); | ||
const opn = require('opn'); | ||
import newGithubIssueUrl from 'new-github-issue-url'; | ||
import open from 'open'; | ||
@@ -29,10 +27,10 @@ const url = newGithubIssueUrl({ | ||
// Then open it | ||
opn(url); | ||
await open(url); | ||
``` | ||
[Try the URL](https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.)<br>*(Don't click the "Submit new issue" button!)* | ||
[Try the URL](https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.)\ | ||
*(Don't click the "Submit new issue" button!)* | ||
If you use Electron, check out `electron-util`'s [`openNewGitHubIssue()` method](https://github.com/sindresorhus/electron-util#opennewgithubissueoptions). | ||
## API | ||
@@ -46,3 +44,3 @@ | ||
Type: `Object` | ||
Type: `object` | ||
@@ -119,14 +117,8 @@ You are required to either specify the `repoUrl` option or both the `user` and `repo` options. | ||
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`. | ||
The project reference format is `user/repo/<project-number>`, for example, if the URL to the project is `https://github.com/sindresorhus/some-repo/projects/3`, the project reference would be `sindresorhus/some-repo/3`. | ||
*Requires the user to have the permission to add projects.* | ||
## Related | ||
- [new-github-release-url](https://github.com/sindresorhus/new-github-release-url) - Generate a URL for opening a new GitHub release with prefilled tag, body, and other fields | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
Yes
7754
110
122