Add node modules and package files

This commit is contained in:
Rachael Sewell
2019-09-06 15:17:38 -07:00
parent e84489cd02
commit 714607abe9
165 changed files with 2227 additions and 4644 deletions

View File

@@ -42,13 +42,17 @@ request("POST /repos/:owner/:repo/issues/:number/labels", {
mediaType: {
previews: ["symmetra"]
},
owner: "ocotkit",
owner: "octokit",
repo: "request.js",
number: 1,
labels: ["🐛 bug"]
});
```
👶 [Small bundle size](https://bundlephobia.com/result?p=@octokit/request@5.0.3) (\<4kb minified + gzipped)
😎 [Authenticate](#authentication) with any of [GitHubs Authentication Strategies](https://github.com/octokit/auth.js).
👍 Sensible defaults
- `baseUrl`: `https://api.github.com`
@@ -59,8 +63,6 @@ request("POST /repos/:owner/:repo/issues/:number/labels", {
🧐 Simple to debug: Sets `error.request` to request options causing the error (with redacted credentials).
👶 Small bundle size (\<5kb minified + gzipped)
## Usage
<table>
@@ -110,6 +112,8 @@ console.log(`${result.data.length} repos found.`);
### GraphQL example
For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/octokit/graphql.js#readme)
```js
const result = await request("POST /graphql", {
headers: {
@@ -144,6 +148,45 @@ const result = await request({
});
```
## Authentication
The simplest way to authenticate a request is to set the `Authorization` header directly, e.g. to a [personal access token](https://github.com/settings/tokens/).
```js
const requestWithAuth = request.defaults({
headers: {
authorization: "token 0000000000000000000000000000000000000001"
}
});
const result = await request("GET /user");
```
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
```js
const { createAppAuth } = require("@octokit/auth-app");
const auth = createAppAuth({
id: process.env.APP_ID,
privateKey: process.env.PRIVATE_KEY,
installationId: 123
});
const requestWithAuth = request.defaults({
request: {
hook: auth.hook
},
mediaType: {
previews: ["machine-man"]
}
});
const { data: app } = await requestWithAuth("GET /app");
const { data: app } = await requestWithAuth("POST /repos/:owner/:repo/issues", {
owner: "octocat",
repo: "hello-world",
title: "Hello from the engine room"
});
```
## request()
`request(route, options)` or `request(options)`.
@@ -425,10 +468,10 @@ const options = request.endpoint("GET /orgs/:org/repos", {
All of the [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) API can be used:
- [`ocotkitRequest.endpoint()`](#endpoint)
- [`ocotkitRequest.endpoint.defaults()`](#endpointdefaults)
- [`ocotkitRequest.endpoint.merge()`](#endpointdefaults)
- [`ocotkitRequest.endpoint.parse()`](#endpointmerge)
- [`octokitRequest.endpoint()`](#endpoint)
- [`octokitRequest.endpoint.defaults()`](#endpointdefaults)
- [`octokitRequest.endpoint.merge()`](#endpointdefaults)
- [`octokitRequest.endpoint.parse()`](#endpointmerge)
## Special cases

View File

@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var endpoint = require('@octokit/endpoint');
var getUserAgent = _interopDefault(require('universal-user-agent'));
var universalUserAgent = require('universal-user-agent');
var isPlainObject = _interopDefault(require('is-plain-object'));
var nodeFetch = _interopDefault(require('node-fetch'));
var requestError = require('@octokit/request-error');
@@ -136,8 +136,9 @@ function withDefaults(oldEndpoint, newDefaults) {
const request = withDefaults(endpoint.endpoint, {
headers: {
"user-agent": `octokit-request.js/${VERSION} ${getUserAgent()}`
"user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}`
}
});
exports.request = request;
//# sourceMappingURL=index.js.map

1
node_modules/@octokit/request/dist-node/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
import { endpoint } from "@octokit/endpoint";
import getUserAgent from "universal-user-agent";
import { getUserAgent } from "universal-user-agent";
import { VERSION } from "./version";
import withDefaults from "./with-defaults";
export const request = withDefaults(endpoint, {

View File

@@ -1,5 +1,5 @@
import { endpoint } from '@octokit/endpoint';
import getUserAgent from 'universal-user-agent';
import { getUserAgent } from 'universal-user-agent';
import isPlainObject from 'is-plain-object';
import nodeFetch from 'node-fetch';
import { RequestError } from '@octokit/request-error';
@@ -124,3 +124,4 @@ const request = withDefaults(endpoint, {
});
export { request };
//# sourceMappingURL=index.js.map

1
node_modules/@octokit/request/dist-web/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,35 +0,0 @@
language: node_js
cache: npm
# Trigger a push build on master and greenkeeper branches + PRs build on every branches
# Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147)
branches:
only:
- master
- /^greenkeeper.*$/
stages:
- test
- name: release
if: branch = master AND type IN (push)
jobs:
include:
- stage: test
node_js: 12
script: npm run test
- node_js: 8
script: npm run test
- node_js: 10
env: Node 10 & coverage upload
script:
- npm run test
- npm run coverage:upload
- node_js: lts/*
env: browser tests
script: npm run test:browser
- stage: release
node_js: lts/*
env: semantic-release
script: npm run semantic-release

View File

@@ -4,13 +4,13 @@
[![@latest](https://img.shields.io/npm/v/universal-user-agent.svg)](https://www.npmjs.com/package/universal-user-agent)
[![Build Status](https://travis-ci.com/gr2m/universal-user-agent.svg?branch=master)](https://travis-ci.com/gr2m/universal-user-agent)
[![Coverage Status](https://coveralls.io/repos/github/gr2m/universal-user-agent/badge.svg)](https://coveralls.io/github/gr2m/universal-user-agent)
[![Greenkeeper](https://badges.greenkeeper.io/gr2m/universal-user-agent.svg)](https://greenkeeper.io/)
```js
const getUserAgent = require('universal-user-agent')
const userAgent = getUserAgent()
const { getUserAgent } = require("universal-user-agent");
// or import { getUserAgent } from "universal-user-agent";
const userAgent = getUserAgent();
// userAgent will look like this
// in browser: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0"
// in node: Node.js/v8.9.4 (macOS High Sierra; x64)

View File

@@ -1,6 +0,0 @@
module.exports = getUserAgentBrowser
function getUserAgentBrowser () {
/* global navigator */
return navigator.userAgent
}

View File

@@ -1,4 +0,0 @@
{
"integrationFolder": "test",
"video": false
}

View File

@@ -0,0 +1,22 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var osName = _interopDefault(require('os-name'));
function getUserAgent() {
try {
return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`;
} catch (error) {
if (/wmic os get Caption/.test(error.message)) {
return "Windows <version undetectable>";
}
throw error;
}
}
exports.getUserAgent = getUserAgent;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../dist-src/node.js"],"sourcesContent":["import osName from \"os-name\";\nexport function getUserAgent() {\n try {\n return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`;\n }\n catch (error) {\n if (/wmic os get Caption/.test(error.message)) {\n return \"Windows <version undetectable>\";\n }\n throw error;\n }\n}\n"],"names":["getUserAgent","process","version","substr","osName","arch","error","test","message"],"mappings":";;;;;;;;AACO,SAASA,YAAT,GAAwB;MACvB;WACQ,WAAUC,OAAO,CAACC,OAAR,CAAgBC,MAAhB,CAAuB,CAAvB,CAA0B,KAAIC,MAAM,EAAG,KAAIH,OAAO,CAACI,IAAK,GAA1E;GADJ,CAGA,OAAOC,KAAP,EAAc;QACN,sBAAsBC,IAAtB,CAA2BD,KAAK,CAACE,OAAjC,CAAJ,EAA+C;aACpC,gCAAP;;;UAEEF,KAAN;;;;;;"}

View File

@@ -0,0 +1,3 @@
export function getUserAgent() {
return navigator.userAgent;
}

View File

@@ -0,0 +1 @@
export { getUserAgent } from "./node";

View File

@@ -0,0 +1,12 @@
import osName from "os-name";
export function getUserAgent() {
try {
return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`;
}
catch (error) {
if (/wmic os get Caption/.test(error.message)) {
return "Windows <version undetectable>";
}
throw error;
}
}

View File

@@ -0,0 +1 @@
export declare function getUserAgent(): string;

View File

@@ -0,0 +1 @@
export { getUserAgent } from "./node";

View File

@@ -0,0 +1 @@
export declare function getUserAgent(): string;

View File

@@ -0,0 +1,6 @@
function getUserAgent() {
return navigator.userAgent;
}
export { getUserAgent };
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../dist-src/browser.js"],"sourcesContent":["export function getUserAgent() {\n return navigator.userAgent;\n}\n"],"names":[],"mappings":"AAAO,SAAS,YAAY,GAAG;IAC3B,OAAO,SAAS,CAAC,SAAS,CAAC;CAC9B;;;;"}

View File

@@ -1 +0,0 @@
export default function getUserAgentNode(): string;

View File

@@ -1,15 +0,0 @@
module.exports = getUserAgentNode
const osName = require('os-name')
function getUserAgentNode () {
try {
return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`
} catch (error) {
if (/wmic os get Caption/.test(error.message)) {
return 'Windows <version undetectable>'
}
throw error
}
}

View File

@@ -1,85 +1,65 @@
{
"_args": [
[
"universal-user-agent@3.0.0",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "universal-user-agent@3.0.0",
"_id": "universal-user-agent@3.0.0",
"_from": "universal-user-agent@^4.0.0",
"_id": "universal-user-agent@4.0.0",
"_inBundle": false,
"_integrity": "sha512-T3siHThqoj5X0benA5H0qcDnrKGXzU8TKoX15x/tQHw1hQBvIEBHjxQ2klizYsqBOO/Q+WuxoQUihadeeqDnoA==",
"_integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==",
"_location": "/@octokit/request/universal-user-agent",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "universal-user-agent@3.0.0",
"raw": "universal-user-agent@^4.0.0",
"name": "universal-user-agent",
"escapedName": "universal-user-agent",
"rawSpec": "3.0.0",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "3.0.0"
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/@octokit/request"
],
"_resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action",
"author": {
"name": "Gregor Martynus",
"url": "https://github.com/gr2m"
},
"browser": "browser.js",
"_resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz",
"_shasum": "27da2ec87e32769619f68a14996465ea1cb9df16",
"_spec": "universal-user-agent@^4.0.0",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@octokit/request",
"bugs": {
"url": "https://github.com/gr2m/universal-user-agent/issues"
},
"bundleDependencies": false,
"dependencies": {
"os-name": "^3.0.0"
"os-name": "^3.1.0"
},
"deprecated": false,
"description": "Get a user agent string in both browser and node",
"devDependencies": {
"chai": "^4.1.2",
"coveralls": "^3.0.2",
"cypress": "^3.1.0",
"mocha": "^6.0.0",
"nyc": "^14.0.0",
"proxyquire": "^2.1.0",
"@gr2m/pika-plugin-build-web": "^0.6.0-issue-84.1",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.6.0",
"@pika/plugin-ts-standard-pkg": "^0.6.0",
"@types/jest": "^24.0.18",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"semantic-release": "^15.9.15",
"sinon": "^7.2.4",
"sinon-chai": "^3.2.0",
"standard": "^13.0.1",
"test": "^0.6.0",
"travis-deploy-once": "^5.0.7"
"ts-jest": "^24.0.2",
"typescript": "^3.6.2"
},
"files": [
"dist-*/",
"bin/"
],
"homepage": "https://github.com/gr2m/universal-user-agent#readme",
"keywords": [],
"license": "ISC",
"main": "index.js",
"main": "dist-node/index.js",
"module": "dist-web/index.js",
"name": "universal-user-agent",
"pika": true,
"repository": {
"type": "git",
"url": "git+https://github.com/gr2m/universal-user-agent.git"
},
"scripts": {
"coverage": "nyc report --reporter=html && open coverage/index.html",
"coverage:upload": "nyc report --reporter=text-lcov | coveralls",
"pretest": "standard",
"semantic-release": "semantic-release",
"test": "nyc mocha \"test/*-test.js\"",
"test:browser": "cypress run --browser chrome",
"travis-deploy-once": "travis-deploy-once"
},
"standard": {
"globals": [
"describe",
"it",
"beforeEach",
"afterEach",
"expect"
]
},
"types": "index.d.ts",
"version": "3.0.0"
"sideEffects": false,
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"version": "4.0.0"
}

View File

@@ -1,57 +0,0 @@
// make tests run in both Node & Express
if (!global.cy) {
const chai = require('chai')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
chai.use(sinonChai)
global.expect = chai.expect
let sandbox
beforeEach(() => {
sandbox = sinon.createSandbox()
global.cy = {
stub: function () {
return sandbox.stub.apply(sandbox, arguments)
},
log () {
console.log.apply(console, arguments)
}
}
})
afterEach(() => {
sandbox.restore()
})
}
const getUserAgent = require('..')
describe('smoke', () => {
it('works', () => {
expect(getUserAgent()).to.be.a('string')
expect(getUserAgent().length).to.be.above(10)
})
if (!process.browser) { // test on node only
const proxyquire = require('proxyquire').noCallThru()
it('works around wmic error on Windows (#5)', () => {
const getUserAgent = proxyquire('..', {
'os-name': () => {
throw new Error('Command failed: wmic os get Caption')
}
})
expect(getUserAgent()).to.equal('Windows <version undetectable>')
})
it('does not swallow unexpected errors', () => {
const getUserAgent = proxyquire('..', {
'os-name': () => {
throw new Error('oops')
}
})
expect(getUserAgent).to.throw('oops')
})
}
})

View File

@@ -1,39 +1,35 @@
{
"_args": [
[
"@octokit/request@5.0.2",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@octokit/request@5.0.2",
"_id": "@octokit/request@5.0.2",
"_from": "@octokit/request@^5.0.0",
"_id": "@octokit/request@5.1.0",
"_inBundle": false,
"_integrity": "sha512-z1BQr43g4kOL4ZrIVBMHwi68Yg9VbkRUyuAgqCp1rU3vbYa69+2gIld/+gHclw15bJWQnhqqyEb7h5a5EqgZ0A==",
"_integrity": "sha512-I15T9PwjFs4tbWyhtFU2Kq7WDPidYMvRB7spmxoQRZfxSmiqullG+Nz+KbSmpkfnlvHwTr1e31R5WReFRKMXjg==",
"_location": "/@octokit/request",
"_phantomChildren": {
"os-name": "3.1.0"
},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "@octokit/request@5.0.2",
"raw": "@octokit/request@^5.0.0",
"name": "@octokit/request",
"escapedName": "@octokit%2frequest",
"scope": "@octokit",
"rawSpec": "5.0.2",
"rawSpec": "^5.0.0",
"saveSpec": null,
"fetchSpec": "5.0.2"
"fetchSpec": "^5.0.0"
},
"_requiredBy": [
"/@octokit/graphql",
"/@octokit/rest"
],
"_resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.0.2.tgz",
"_spec": "5.0.2",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action",
"_resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.1.0.tgz",
"_shasum": "5609dcc7b5323e529f29d535214383d9eaf0c05c",
"_spec": "@octokit/request@^5.0.0",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@octokit/graphql",
"bugs": {
"url": "https://github.com/octokit/request.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"@octokit/endpoint": "^5.1.0",
"@octokit/request-error": "^1.0.1",
@@ -41,21 +37,25 @@
"is-plain-object": "^3.0.0",
"node-fetch": "^2.3.0",
"once": "^1.4.0",
"universal-user-agent": "^3.0.0"
"universal-user-agent": "^4.0.0"
},
"deprecated": false,
"description": "Send parameterized requests to GitHubs APIs with sensible defaults in browsers and Node",
"devDependencies": {
"@pika/pack": "^0.4.0",
"@pika/plugin-build-node": "^0.5.1",
"@pika/plugin-build-web": "^0.5.1",
"@pika/plugin-ts-standard-pkg": "^0.5.1",
"@octokit/auth-app": "^2.1.2",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.6.0",
"@pika/plugin-build-web": "^0.6.0",
"@pika/plugin-ts-standard-pkg": "^0.6.0",
"@types/fetch-mock": "^7.2.4",
"@types/jest": "^24.0.12",
"@types/lolex": "^3.1.1",
"@types/node": "^12.0.3",
"@types/node-fetch": "^2.3.3",
"@types/once": "^1.4.0",
"fetch-mock": "^7.2.0",
"jest": "^24.7.1",
"lolex": "^4.2.0",
"prettier": "^1.17.0",
"semantic-release": "^15.10.5",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
@@ -88,5 +88,5 @@
"sideEffects": false,
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"version": "5.0.2"
"version": "5.1.0"
}