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

1
node_modules/.bin/semver generated vendored Symbolic link
View File

@ -0,0 +1 @@
../semver/bin/semver

1
node_modules/.bin/which generated vendored Symbolic link
View File

@ -0,0 +1 @@
../which/bin/which

7
node_modules/@actions/core/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,7 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

92
node_modules/@actions/core/README.md generated vendored
View File

@ -4,4 +4,94 @@
## Usage ## Usage
See [src/core.ts](src/core.ts). #### Inputs/Outputs
You can use this library to get inputs or set outputs:
```js
const core = require('@actions/core');
const myInput = core.getInput('inputName', { required: true });
// Do stuff
core.setOutput('outputKey', 'outputVal');
```
#### Exporting variables
You can also export variables for future steps. Variables get set in the environment.
```js
const core = require('@actions/core');
// Do stuff
core.exportVariable('envVar', 'Val');
```
#### PATH Manipulation
You can explicitly add items to the path for all remaining steps in a workflow:
```js
const core = require('@actions/core');
core.addPath('pathToTool');
```
#### Exit codes
You should use this library to set the failing exit code for your action:
```js
const core = require('@actions/core');
try {
// Do stuff
}
catch (err) {
// setFailed logs the message and sets a failing exit code
core.setFailed(`Action failed with error ${err}`);
}
```
#### Logging
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
```js
const core = require('@actions/core');
const myInput = core.getInput('input');
try {
core.debug('Inside try block');
if (!myInput) {
core.warning('myInput was not set');
}
// Do stuff
}
catch (err) {
core.error(`Error ${err}, action may still succeed though`);
}
```
This library can also wrap chunks of output in foldable groups.
```js
const core = require('@actions/core')
// Manually wrap output
core.startGroup('Do some function')
doSomeFunction()
core.endGroup()
// Wrap an asynchronous function call
const result = await core.group('Do something async', async () => {
const response = await doSomeHTTPRequest()
return response
})
```

View File

@ -9,8 +9,8 @@ interface CommandProperties {
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definitelyNotAPassword!
*/ */
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void; export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
export declare function issue(name: string, message: string): void; export declare function issue(name: string, message?: string): void;
export {}; export {};

View File

@ -9,14 +9,14 @@ const os = require("os");
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definitelyNotAPassword!
*/ */
function issueCommand(command, properties, message) { function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message); const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL); process.stdout.write(cmd.toString() + os.EOL);
} }
exports.issueCommand = issueCommand; exports.issueCommand = issueCommand;
function issue(name, message) { function issue(name, message = '') {
issueCommand(name, {}, message); issueCommand(name, {}, message);
} }
exports.issue = issue; exports.issue = issue;

View File

@ -1 +1 @@
{"version":3,"file":"command.js","s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KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}

View File

@ -16,11 +16,7 @@ export declare enum ExitCode {
/** /**
* A code indicating that the action was a failure * A code indicating that the action was a failure
*/ */
Failure = 1, Failure = 1
/**
* A code indicating that the action is complete, but neither succeeded nor failed
*/
Neutral = 78
} }
/** /**
* sets env variable for this action and future actions in the job * sets env variable for this action and future actions in the job
@ -54,10 +50,6 @@ export declare function getInput(name: string, options?: InputOptions): string;
* @param value value to store * @param value value to store
*/ */
export declare function setOutput(name: string, value: string): void; export declare function setOutput(name: string, value: string): void;
/**
* Sets the action status to neutral
*/
export declare function setNeutral(): void;
/** /**
* Sets the action status to failed. * Sets the action status to failed.
* When the action exits it will be with an exit code of 1 * When the action exits it will be with an exit code of 1
@ -79,3 +71,24 @@ export declare function error(message: string): void;
* @param message warning issue message * @param message warning issue message
*/ */
export declare function warning(message: string): void; export declare function warning(message: string): void;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
export declare function startGroup(name: string): void;
/**
* End an output group.
*/
export declare function endGroup(): void;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>;

View File

@ -1,4 +1,13 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("./command"); const command_1 = require("./command");
const path = require("path"); const path = require("path");
@ -15,10 +24,6 @@ var ExitCode;
* A code indicating that the action was a failure * A code indicating that the action was a failure
*/ */
ExitCode[ExitCode["Failure"] = 1] = "Failure"; ExitCode[ExitCode["Failure"] = 1] = "Failure";
/**
* A code indicating that the action is complete, but neither succeeded nor failed
*/
ExitCode[ExitCode["Neutral"] = 78] = "Neutral";
})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Variables // Variables
@ -40,7 +45,10 @@ exports.exportVariable = exportVariable;
*/ */
function exportSecret(name, val) { function exportSecret(name, val) {
exportVariable(name, val); exportVariable(name, val);
// the runner will error with not implemented
// leaving the function but raising the error earlier
command_1.issueCommand('set-secret', {}, val); command_1.issueCommand('set-secret', {}, val);
throw new Error('Not implemented.');
} }
exports.exportSecret = exportSecret; exports.exportSecret = exportSecret;
/** /**
@ -80,13 +88,6 @@ exports.setOutput = setOutput;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Results // Results
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/**
* Sets the action status to neutral
*/
function setNeutral() {
process.exitCode = ExitCode.Neutral;
}
exports.setNeutral = setNeutral;
/** /**
* Sets the action status to failed. * Sets the action status to failed.
* When the action exits it will be with an exit code of 1 * When the action exits it will be with an exit code of 1
@ -124,4 +125,44 @@ function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message);
} }
exports.warning = warning; exports.warning = warning;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
function startGroup(name) {
command_1.issue('group', name);
}
exports.startGroup = startGroup;
/**
* End an output group.
*/
function endGroup() {
command_1.issue('endgroup');
}
exports.endGroup = endGroup;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
function group(name, fn) {
return __awaiter(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
}
finally {
endGroup();
}
return result;
});
}
exports.group = group;
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map

View File

@ -1 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAeX;AAfD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,8CAAY,CAAA;AACd,CAAC,EAfW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAenB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzB,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAHD,oCAGC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,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AC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}

View File

@ -1,35 +1,34 @@
{ {
"_args": [ "_from": "@actions/core",
[ "_id": "@actions/core@1.1.0",
"@actions/core@file:toolkit/actions-core-0.0.0.tgz",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
"_id": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-P+mC79gXC2yvyU0+RDctxKUI1Q3tNruB+aSmFI47j2H0DylxtDEgycW9WXwt/zCY62lfwfvBoGKpuJRvFHDqpw==", "_integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==",
"_location": "/@actions/core", "_location": "/@actions/core",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "tag",
"where": "/Users/rachmari/github-repos/hello-world-javascript-action", "registry": true,
"raw": "@actions/core@file:toolkit/actions-core-0.0.0.tgz", "raw": "@actions/core",
"name": "@actions/core", "name": "@actions/core",
"escapedName": "@actions%2fcore", "escapedName": "@actions%2fcore",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-core-0.0.0.tgz", "rawSpec": "",
"saveSpec": "file:toolkit/actions-core-0.0.0.tgz", "saveSpec": null,
"fetchSpec": "/Users/rachmari/github-repos/hello-world-javascript-action/toolkit/actions-core-0.0.0.tgz" "fetchSpec": "latest"
}, },
"_requiredBy": [ "_requiredBy": [
"#USER",
"/" "/"
], ],
"_spec": "file:toolkit/actions-core-0.0.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz",
"_shasum": "25c3aff43a20f9c5a04e2a3439898a49ba8d3625",
"_spec": "@actions/core",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_where": "/Users/rachmari/github-repos/hello-world-javascript-action",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "Actions core lib", "description": "Actions core lib",
"devDependencies": { "devDependencies": {
"@types/node": "^12.0.2" "@types/node": "^12.0.2"
@ -41,10 +40,12 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core", "homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"keywords": [ "keywords": [
"core", "github",
"actions" "actions",
"core"
], ],
"license": "MIT", "license": "MIT",
"main": "lib/core.js", "main": "lib/core.js",
@ -60,5 +61,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "0.0.0" "version": "1.1.0"
} }

7
node_modules/@actions/github/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,7 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -4,44 +4,47 @@
## Usage ## Usage
Returns an [Octokit SDK] client. See https://octokit.github.io/rest.js for the API. Returns an Octokit client. See https://octokit.github.io/rest.js for the API.
``` ```js
const github = require('@actions/github'); const github = require('@actions/github');
const core = require('@actions/core');
// This should be a token with access to your repository scoped in as a secret. // This should be a token with access to your repository scoped in as a secret.
const myToken = process.env.GITHUB_TOKEN const myToken = core.getInput('myToken');
const octokit = new github.GitHub(myToken) const octokit = new github.GitHub(myToken);
const pulls = await octokit.pulls.get({ const { data: pullRequest } = await octokit.pulls.get({
owner: 'octokit', owner: 'octokit',
repo: 'rest.js', repo: 'rest.js',
pull_number: 123, pull_number: 123,
mediaType: { mediaType: {
format: 'diff' format: 'diff'
} }
}) });
console.log(pulls) console.log(pullRequest);
``` ```
You can also make GraphQL requests: You can pass client options (except `auth`, which is handled by the token argument), as specified by [Octokit](https://octokit.github.io/rest.js/), as a second argument to the `GitHub` constructor.
``` You can also make GraphQL requests. See https://github.com/octokit/graphql.js for the API.
const result = await octokit.graphql(query, variables)
```js
const result = await octokit.graphql(query, variables);
``` ```
Finally, you can get the context of the current action: Finally, you can get the context of the current action:
``` ```js
const github = require('@actions/github'); const github = require('@actions/github');
const context = github.context const context = github.context;
const newIssue = await octokit.issues.create({ const newIssue = await octokit.issues.create({
...context.repo, ...context.repo,
title: 'New issue!', title: 'New issue!',
body: 'Hello Universe!' body: 'Hello Universe!'
}) });
``` ```

View File

@ -1,14 +1,21 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-require-imports */ const fs_1 = require("fs");
const os_1 = require("os");
class Context { class Context {
/** /**
* Hydrate the context from the environment * Hydrate the context from the environment
*/ */
constructor() { constructor() {
this.payload = process.env.GITHUB_EVENT_PATH this.payload = {};
? require(process.env.GITHUB_EVENT_PATH) if (process.env.GITHUB_EVENT_PATH) {
: {}; if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) {
this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' }));
}
else {
process.stdout.write(`GITHUB_EVENT_PATH ${process.env.GITHUB_EVENT_PATH} does not exist${os_1.EOL}`);
}
}
this.eventName = process.env.GITHUB_EVENT_NAME; this.eventName = process.env.GITHUB_EVENT_NAME;
this.sha = process.env.GITHUB_SHA; this.sha = process.env.GITHUB_SHA;
this.ref = process.env.GITHUB_REF; this.ref = process.env.GITHUB_REF;
@ -18,7 +25,7 @@ class Context {
} }
get issue() { get issue() {
const payload = this.payload; const payload = this.payload;
return Object.assign({}, this.repo, { number: (payload.issue || payload.pullRequest || payload).number }); return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pullRequest || payload).number });
} }
get repo() { get repo() {
if (process.env.GITHUB_REPOSITORY) { if (process.env.GITHUB_REPOSITORY) {

View File

@ -1 +1 @@
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAGA,0DAA0D;AAE1D,MAAa,OAAO;IAalB;;OAEG;IACH;QACE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB;YAC1C,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;YACxC,CAAC,CAAC,EAAE,CAA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I,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC9D,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAA;SACrB;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3B,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK;gBAC1C,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI;aACnC,CAAA;SACF;QAED,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAA;IACH,CAAC;CACF;AAjED,0BAiEC"}

View File

@ -1,6 +1,8 @@
import { GraphQlQueryResponse, Variables } from '@octokit/graphql'; import { GraphQlQueryResponse, Variables } from '@octokit/graphql';
import Octokit from '@octokit/rest'; import Octokit from '@octokit/rest';
import * as Context from './context';
export declare const context: Context.Context;
export declare class GitHub extends Octokit { export declare class GitHub extends Octokit {
graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>; graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>;
constructor(token: string); constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>);
} }

View File

@ -16,10 +16,10 @@ const rest_1 = __importDefault(require("@octokit/rest"));
const Context = __importStar(require("./context")); const Context = __importStar(require("./context"));
// We need this in order to extend Octokit // We need this in order to extend Octokit
rest_1.default.prototype = new rest_1.default(); rest_1.default.prototype = new rest_1.default();
module.exports.context = new Context.Context(); exports.context = new Context.Context();
class GitHub extends rest_1.default { class GitHub extends rest_1.default {
constructor(token) { constructor(token, opts = {}) {
super({ auth: `token ${token}` }); super(Object.assign(Object.assign({}, opts), { auth: `token ${token}` }));
this.graphql = graphql_1.defaults({ this.graphql = graphql_1.defaults({
headers: { authorization: `token ${token}` } headers: { authorization: `token ${token}` }
}); });

View File

@ -1 +1 @@
{"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gGAAgG;AAChG,8CAA0E;AAC1E,yDAAmC;AACnC,mDAAoC;AAEpC,0CAA0C;AAC1C,cAAO,CAAC,SAAS,GAAG,IAAI,cAAO,EAAE,CAAA;AAEjC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,CAAA;AAE9C,MAAa,MAAO,SAAQ,cAAO;IAMjC,YAAY,KAAa;QACvB,KAAK,CAAC,EAAC,IAAI,EAAE,SAAS,KAAK,EAAE,EAAC,CAAC,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,kBAAQ,CAAC;YACtB,OAAO,EAAE,EAAC,aAAa,EAAE,SAAS,KAAK,EAAE,EAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF;AAZD,wBAYC"} {"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gGAAgG;AAChG,8CAA0E;AAC1E,yDAAmC;AACnC,mDAAoC;AAEpC,0CAA0C;AAC1C,cAAO,CAAC,SAAS,GAAG,IAAI,cAAO,EAAE,CAAA;AAEpB,QAAA,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,CAAA;AAE5C,MAAa,MAAO,SAAQ,cAAO;IAMjC,YAAY,KAAa,EAAE,OAAsC,EAAE;QACjE,KAAK,iCAAK,IAAI,KAAE,IAAI,EAAE,SAAS,KAAK,EAAE,IAAE,CAAA;QACxC,IAAI,CAAC,OAAO,GAAG,kBAAQ,CAAC;YACtB,OAAO,EAAE,EAAC,aAAa,EAAE,SAAS,KAAK,EAAE,EAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF;AAZD,wBAYC"}

View File

@ -1,13 +1,13 @@
export interface PayloadRepository { export interface PayloadRepository {
[key: string]: any; [key: string]: any;
fullName?: string; full_name?: string;
name: string; name: string;
owner: { owner: {
[key: string]: any; [key: string]: any;
login: string; login: string;
name?: string; name?: string;
}; };
htmlUrl?: string; html_url?: string;
} }
export interface WebhookPayload { export interface WebhookPayload {
[key: string]: any; [key: string]: any;
@ -18,10 +18,10 @@ export interface WebhookPayload {
html_url?: string; html_url?: string;
body?: string; body?: string;
}; };
pullRequest?: { pull_request?: {
[key: string]: any; [key: string]: any;
number: number; number: number;
htmlUrl?: string; html_url?: string;
body?: string; body?: string;
}; };
sender?: { sender?: {

View File

@ -1,39 +1,38 @@
{ {
"_args": [ "_from": "@actions/github",
[ "_id": "@actions/github@1.1.0",
"@actions/github@file:toolkit/actions-github-0.0.0.tgz",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@actions/github@file:toolkit/actions-github-0.0.0.tgz",
"_id": "@actions/github@file:toolkit/actions-github-0.0.0.tgz",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-K13pi9kbZqFnvhe8m6uqfz4kCnB4Ki6fzv4XBae1zDZfn2Si+Qx6j1pAfXSo7QI2+ZWAX/g0paFgcJsS6ZTWZA==", "_integrity": "sha512-cHf6PyoNMdei13jEdGPhKprIMFmjVVW/dnM5/9QmQDJ1ZTaGVyezUSCUIC/ySNLRvDUpeFwPYMdThSEJldSbUw==",
"_location": "/@actions/github", "_location": "/@actions/github",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "file", "type": "tag",
"where": "/Users/rachmari/github-repos/hello-world-javascript-action", "registry": true,
"raw": "@actions/github@file:toolkit/actions-github-0.0.0.tgz", "raw": "@actions/github",
"name": "@actions/github", "name": "@actions/github",
"escapedName": "@actions%2fgithub", "escapedName": "@actions%2fgithub",
"scope": "@actions", "scope": "@actions",
"rawSpec": "file:toolkit/actions-github-0.0.0.tgz", "rawSpec": "",
"saveSpec": "file:toolkit/actions-github-0.0.0.tgz", "saveSpec": null,
"fetchSpec": "/Users/rachmari/github-repos/hello-world-javascript-action/toolkit/actions-github-0.0.0.tgz" "fetchSpec": "latest"
}, },
"_requiredBy": [ "_requiredBy": [
"#USER",
"/" "/"
], ],
"_spec": "file:toolkit/actions-github-0.0.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/github/-/github-1.1.0.tgz",
"_shasum": "06f34e6b0cf07eb2b3641de3e680dbfae6bcd400",
"_spec": "@actions/github",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_where": "/Users/rachmari/github-repos/hello-world-javascript-action",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@octokit/graphql": "^2.0.1", "@octokit/graphql": "^2.0.1",
"@octokit/rest": "^16.15.0" "@octokit/rest": "^16.15.0"
}, },
"deprecated": false,
"description": "Actions github lib", "description": "Actions github lib",
"devDependencies": { "devDependencies": {
"jest": "^24.7.1" "jest": "^24.7.1"
@ -45,6 +44,7 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/github", "homepage": "https://github.com/actions/toolkit/tree/master/packages/github",
"keywords": [ "keywords": [
"github", "github",
@ -65,5 +65,5 @@
"test": "jest", "test": "jest",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "0.0.0" "version": "1.1.0"
} }

View File

@ -4,10 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var deepmerge = _interopDefault(require('deepmerge'));
var isPlainObject = _interopDefault(require('is-plain-object')); var isPlainObject = _interopDefault(require('is-plain-object'));
var urlTemplate = _interopDefault(require('url-template')); var universalUserAgent = require('universal-user-agent');
var getUserAgent = _interopDefault(require('universal-user-agent'));
function lowercaseKeys(object) { function lowercaseKeys(object) {
if (!object) { if (!object) {
@ -20,6 +18,22 @@ function lowercaseKeys(object) {
}, {}); }, {});
} }
function mergeDeep(defaults, options) {
const result = Object.assign({}, defaults);
Object.keys(options).forEach(key => {
if (isPlainObject(options[key])) {
if (!(key in defaults)) Object.assign(result, {
[key]: options[key]
});else result[key] = mergeDeep(defaults[key], options[key]);
} else {
Object.assign(result, {
[key]: options[key]
});
}
});
return result;
}
function merge(defaults, route, options) { function merge(defaults, route, options) {
if (typeof route === "string") { if (typeof route === "string") {
let [method, url] = route.split(" "); let [method, url] = route.split(" ");
@ -35,9 +49,7 @@ function merge(defaults, route, options) {
options.headers = lowercaseKeys(options.headers); options.headers = lowercaseKeys(options.headers);
const mergedOptions = deepmerge.all([defaults, options].filter(Boolean), { const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten
isMergeableObject: isPlainObject
}); // mediaType.previews arrays are merged, instead of overwritten
if (defaults && defaults.mediaType.previews.length) { if (defaults && defaults.mediaType.previews.length) {
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);
@ -87,6 +99,173 @@ function omit(object, keysToOmit) {
}, {}); }, {});
} }
// Based on https://github.com/bramstein/url-template, licensed under BSD
// TODO: create separate package.
//
// Copyright (c) 2012-2014, Bram Stein
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* istanbul ignore file */
function encodeReserved(str) {
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {
if (!/%[0-9A-Fa-f]/.test(part)) {
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
}
return part;
}).join("");
}
function encodeUnreserved(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}
function encodeValue(operator, value, key) {
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
if (key) {
return encodeUnreserved(key) + "=" + value;
} else {
return value;
}
}
function isDefined(value) {
return value !== undefined && value !== null;
}
function isKeyOperator(operator) {
return operator === ";" || operator === "&" || operator === "?";
}
function getValues(context, operator, key, modifier) {
var value = context[key],
result = [];
if (isDefined(value) && value !== "") {
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
value = value.toString();
if (modifier && modifier !== "*") {
value = value.substring(0, parseInt(modifier, 10));
}
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
} else {
if (modifier === "*") {
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function (value) {
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
});
} else {
Object.keys(value).forEach(function (k) {
if (isDefined(value[k])) {
result.push(encodeValue(operator, value[k], k));
}
});
}
} else {
const tmp = [];
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function (value) {
tmp.push(encodeValue(operator, value));
});
} else {
Object.keys(value).forEach(function (k) {
if (isDefined(value[k])) {
tmp.push(encodeUnreserved(k));
tmp.push(encodeValue(operator, value[k].toString()));
}
});
}
if (isKeyOperator(operator)) {
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
} else if (tmp.length !== 0) {
result.push(tmp.join(","));
}
}
}
} else {
if (operator === ";") {
if (isDefined(value)) {
result.push(encodeUnreserved(key));
}
} else if (value === "" && (operator === "&" || operator === "?")) {
result.push(encodeUnreserved(key) + "=");
} else if (value === "") {
result.push("");
}
}
return result;
}
function parseUrl(template) {
return {
expand: expand.bind(null, template)
};
}
function expand(template, context) {
var operators = ["+", "#", ".", "/", ";", "?", "&"];
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
if (expression) {
let operator = "";
const values = [];
if (operators.indexOf(expression.charAt(0)) !== -1) {
operator = expression.charAt(0);
expression = expression.substr(1);
}
expression.split(/,/g).forEach(function (variable) {
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
});
if (operator && operator !== "+") {
var separator = ",";
if (operator === "?") {
separator = "&";
} else if (operator !== "#") {
separator = operator;
}
return (values.length !== 0 ? operator : "") + values.join(separator);
} else {
return values.join(",");
}
} else {
return encodeReserved(literal);
}
});
}
function parse(options) { function parse(options) {
// https://fetch.spec.whatwg.org/#methods // https://fetch.spec.whatwg.org/#methods
let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible
@ -97,7 +276,7 @@ function parse(options) {
let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later
const urlVariableNames = extractUrlVariableNames(url); const urlVariableNames = extractUrlVariableNames(url);
url = urlTemplate.parse(url).expand(parameters); url = parseUrl(url).expand(parameters);
if (!/^http/.test(url)) { if (!/^http/.test(url)) {
url = options.baseUrl + url; url = options.baseUrl + url;
@ -178,7 +357,7 @@ function withDefaults(oldDefaults, newDefaults) {
const VERSION = "0.0.0-development"; const VERSION = "0.0.0-development";
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`; const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`;
const DEFAULTS = { const DEFAULTS = {
method: "GET", method: "GET",
baseUrl: "https://api.github.com", baseUrl: "https://api.github.com",
@ -195,3 +374,4 @@ const DEFAULTS = {
const endpoint = withDefaults(null, DEFAULTS); const endpoint = withDefaults(null, DEFAULTS);
exports.endpoint = endpoint; exports.endpoint = endpoint;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import getUserAgent from "universal-user-agent"; import { getUserAgent } from "universal-user-agent";
import { VERSION } from "./version"; import { VERSION } from "./version";
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`; const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
export const DEFAULTS = { export const DEFAULTS = {

View File

@ -1,6 +1,5 @@
import deepmerge from "deepmerge";
import isPlainObject from "is-plain-object";
import { lowercaseKeys } from "./util/lowercase-keys"; import { lowercaseKeys } from "./util/lowercase-keys";
import { mergeDeep } from "./util/merge-deep";
export function merge(defaults, route, options) { export function merge(defaults, route, options) {
if (typeof route === "string") { if (typeof route === "string") {
let [method, url] = route.split(" "); let [method, url] = route.split(" ");
@ -11,9 +10,7 @@ export function merge(defaults, route, options) {
} }
// lowercase header names before merging with defaults to avoid duplicates // lowercase header names before merging with defaults to avoid duplicates
options.headers = lowercaseKeys(options.headers); options.headers = lowercaseKeys(options.headers);
const mergedOptions = deepmerge.all([defaults, options].filter(Boolean), { const mergedOptions = mergeDeep(defaults || {}, options);
isMergeableObject: isPlainObject
});
// mediaType.previews arrays are merged, instead of overwritten // mediaType.previews arrays are merged, instead of overwritten
if (defaults && defaults.mediaType.previews.length) { if (defaults && defaults.mediaType.previews.length) {
mergedOptions.mediaType.previews = defaults.mediaType.previews mergedOptions.mediaType.previews = defaults.mediaType.previews

View File

@ -1,7 +1,7 @@
import urlTemplate from "url-template";
import { addQueryParameters } from "./util/add-query-parameters"; import { addQueryParameters } from "./util/add-query-parameters";
import { extractUrlVariableNames } from "./util/extract-url-variable-names"; import { extractUrlVariableNames } from "./util/extract-url-variable-names";
import { omit } from "./util/omit"; import { omit } from "./util/omit";
import { parseUrl } from "./util/url-template";
export function parse(options) { export function parse(options) {
// https://fetch.spec.whatwg.org/#methods // https://fetch.spec.whatwg.org/#methods
let method = options.method.toUpperCase(); let method = options.method.toUpperCase();
@ -19,7 +19,7 @@ export function parse(options) {
]); ]);
// extract variable names from URL to calculate remaining variables later // extract variable names from URL to calculate remaining variables later
const urlVariableNames = extractUrlVariableNames(url); const urlVariableNames = extractUrlVariableNames(url);
url = urlTemplate.parse(url).expand(parameters); url = parseUrl(url).expand(parameters);
if (!/^http/.test(url)) { if (!/^http/.test(url)) {
url = options.baseUrl + url; url = options.baseUrl + url;
} }

View File

@ -0,0 +1,16 @@
import isPlainObject from "is-plain-object";
export function mergeDeep(defaults, options) {
const result = Object.assign({}, defaults);
Object.keys(options).forEach(key => {
if (isPlainObject(options[key])) {
if (!(key in defaults))
Object.assign(result, { [key]: options[key] });
else
result[key] = mergeDeep(defaults[key], options[key]);
}
else {
Object.assign(result, { [key]: options[key] });
}
});
return result;
}

View File

@ -0,0 +1,170 @@
// Based on https://github.com/bramstein/url-template, licensed under BSD
// TODO: create separate package.
//
// Copyright (c) 2012-2014, Bram Stein
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* istanbul ignore file */
function encodeReserved(str) {
return str
.split(/(%[0-9A-Fa-f]{2})/g)
.map(function (part) {
if (!/%[0-9A-Fa-f]/.test(part)) {
part = encodeURI(part)
.replace(/%5B/g, "[")
.replace(/%5D/g, "]");
}
return part;
})
.join("");
}
function encodeUnreserved(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return ("%" +
c
.charCodeAt(0)
.toString(16)
.toUpperCase());
});
}
function encodeValue(operator, value, key) {
value =
operator === "+" || operator === "#"
? encodeReserved(value)
: encodeUnreserved(value);
if (key) {
return encodeUnreserved(key) + "=" + value;
}
else {
return value;
}
}
function isDefined(value) {
return value !== undefined && value !== null;
}
function isKeyOperator(operator) {
return operator === ";" || operator === "&" || operator === "?";
}
function getValues(context, operator, key, modifier) {
var value = context[key], result = [];
if (isDefined(value) && value !== "") {
if (typeof value === "string" ||
typeof value === "number" ||
typeof value === "boolean") {
value = value.toString();
if (modifier && modifier !== "*") {
value = value.substring(0, parseInt(modifier, 10));
}
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
}
else {
if (modifier === "*") {
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function (value) {
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
});
}
else {
Object.keys(value).forEach(function (k) {
if (isDefined(value[k])) {
result.push(encodeValue(operator, value[k], k));
}
});
}
}
else {
const tmp = [];
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function (value) {
tmp.push(encodeValue(operator, value));
});
}
else {
Object.keys(value).forEach(function (k) {
if (isDefined(value[k])) {
tmp.push(encodeUnreserved(k));
tmp.push(encodeValue(operator, value[k].toString()));
}
});
}
if (isKeyOperator(operator)) {
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
}
else if (tmp.length !== 0) {
result.push(tmp.join(","));
}
}
}
}
else {
if (operator === ";") {
if (isDefined(value)) {
result.push(encodeUnreserved(key));
}
}
else if (value === "" && (operator === "&" || operator === "?")) {
result.push(encodeUnreserved(key) + "=");
}
else if (value === "") {
result.push("");
}
}
return result;
}
export function parseUrl(template) {
return {
expand: expand.bind(null, template)
};
}
function expand(template, context) {
var operators = ["+", "#", ".", "/", ";", "?", "&"];
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
if (expression) {
let operator = "";
const values = [];
if (operators.indexOf(expression.charAt(0)) !== -1) {
operator = expression.charAt(0);
expression = expression.substr(1);
}
expression.split(/,/g).forEach(function (variable) {
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
});
if (operator && operator !== "+") {
var separator = ",";
if (operator === "?") {
separator = "&";
}
else if (operator !== "#") {
separator = operator;
}
return (values.length !== 0 ? operator : "") + values.join(separator);
}
else {
return values.join(",");
}
}
else {
return encodeReserved(literal);
}
});
}

View File

@ -1,3 +1,5 @@
export declare function lowercaseKeys(object?: { export declare function lowercaseKeys(object?: {
[key: string]: any; [key: string]: any;
}): {}; }): {
[key: string]: any;
};

View File

@ -0,0 +1 @@
export declare function mergeDeep(defaults: any, options: any): object;

View File

@ -0,0 +1,3 @@
export declare function parseUrl(template: string): {
expand: (context: object) => string;
};

View File

@ -1,200 +1,343 @@
import deepmerge from 'deepmerge';
import isPlainObject from 'is-plain-object'; import isPlainObject from 'is-plain-object';
import urlTemplate from 'url-template'; import { getUserAgent } from 'universal-user-agent';
import getUserAgent from 'universal-user-agent';
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
function lowercaseKeys(object) { function lowercaseKeys(object) {
if (!object) { if (!object) {
return {}; return {};
} }
return Object.keys(object).reduce((newObj, key) => { return Object.keys(object).reduce((newObj, key) => {
newObj[key.toLowerCase()] = object[key]; newObj[key.toLowerCase()] = object[key];
return newObj; return newObj;
}, {}); }, {});
} }
function mergeDeep(defaults, options) {
const result = Object.assign({}, defaults);
Object.keys(options).forEach(key => {
if (isPlainObject(options[key])) {
if (!(key in defaults))
Object.assign(result, { [key]: options[key] });
else
result[key] = mergeDeep(defaults[key], options[key]);
}
else {
Object.assign(result, { [key]: options[key] });
}
});
return result;
}
function merge(defaults, route, options) { function merge(defaults, route, options) {
if (typeof route === "string") { if (typeof route === "string") {
let _route$split = route.split(" "), let [method, url] = route.split(" ");
_route$split2 = _slicedToArray(_route$split, 2), options = Object.assign(url ? { method, url } : { url: method }, options);
method = _route$split2[0],
url = _route$split2[1];
options = Object.assign(url ? {
method,
url
} : {
url: method
}, options);
} else {
options = route || {};
} // lowercase header names before merging with defaults to avoid duplicates
options.headers = lowercaseKeys(options.headers);
const mergedOptions = deepmerge.all([defaults, options].filter(Boolean), {
isMergeableObject: isPlainObject
}); // mediaType.previews arrays are merged, instead of overwritten
if (defaults && defaults.mediaType.previews.length) {
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);
} }
else {
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, "")); options = route || {};
}
// lowercase header names before merging with defaults to avoid duplicates
options.headers = lowercaseKeys(options.headers);
const mergedOptions = mergeDeep(defaults || {}, options);
// mediaType.previews arrays are merged, instead of overwritten
if (defaults && defaults.mediaType.previews.length) {
mergedOptions.mediaType.previews = defaults.mediaType.previews
.filter(preview => !mergedOptions.mediaType.previews.includes(preview))
.concat(mergedOptions.mediaType.previews);
}
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, ""));
return mergedOptions; return mergedOptions;
} }
function addQueryParameters(url, parameters) { function addQueryParameters(url, parameters) {
const separator = /\?/.test(url) ? "&" : "?"; const separator = /\?/.test(url) ? "&" : "?";
const names = Object.keys(parameters); const names = Object.keys(parameters);
if (names.length === 0) { if (names.length === 0) {
return url; return url;
} }
return (url +
return url + separator + names.map(name => { separator +
names
.map(name => {
if (name === "q") { if (name === "q") {
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); return ("q=" +
parameters
.q.split("+")
.map(encodeURIComponent)
.join("+"));
} }
return `${name}=${encodeURIComponent(parameters[name])}`;
return "".concat(name, "=").concat(encodeURIComponent(parameters[name])); })
}).join("&"); .join("&"));
} }
const urlVariableRegex = /\{[^}]+\}/g; const urlVariableRegex = /\{[^}]+\}/g;
function removeNonChars(variableName) { function removeNonChars(variableName) {
return variableName.replace(/^\W+|\W+$/g, "").split(/,/); return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
} }
function extractUrlVariableNames(url) { function extractUrlVariableNames(url) {
const matches = url.match(urlVariableRegex); const matches = url.match(urlVariableRegex);
if (!matches) { if (!matches) {
return []; return [];
} }
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
} }
function omit(object, keysToOmit) { function omit(object, keysToOmit) {
return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => { return Object.keys(object)
.filter(option => !keysToOmit.includes(option))
.reduce((obj, key) => {
obj[key] = object[key]; obj[key] = object[key];
return obj; return obj;
}, {}); }, {});
} }
// Based on https://github.com/bramstein/url-template, licensed under BSD
// TODO: create separate package.
//
// Copyright (c) 2012-2014, Bram Stein
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* istanbul ignore file */
function encodeReserved(str) {
return str
.split(/(%[0-9A-Fa-f]{2})/g)
.map(function (part) {
if (!/%[0-9A-Fa-f]/.test(part)) {
part = encodeURI(part)
.replace(/%5B/g, "[")
.replace(/%5D/g, "]");
}
return part;
})
.join("");
}
function encodeUnreserved(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return ("%" +
c
.charCodeAt(0)
.toString(16)
.toUpperCase());
});
}
function encodeValue(operator, value, key) {
value =
operator === "+" || operator === "#"
? encodeReserved(value)
: encodeUnreserved(value);
if (key) {
return encodeUnreserved(key) + "=" + value;
}
else {
return value;
}
}
function isDefined(value) {
return value !== undefined && value !== null;
}
function isKeyOperator(operator) {
return operator === ";" || operator === "&" || operator === "?";
}
function getValues(context, operator, key, modifier) {
var value = context[key], result = [];
if (isDefined(value) && value !== "") {
if (typeof value === "string" ||
typeof value === "number" ||
typeof value === "boolean") {
value = value.toString();
if (modifier && modifier !== "*") {
value = value.substring(0, parseInt(modifier, 10));
}
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
}
else {
if (modifier === "*") {
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function (value) {
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
});
}
else {
Object.keys(value).forEach(function (k) {
if (isDefined(value[k])) {
result.push(encodeValue(operator, value[k], k));
}
});
}
}
else {
const tmp = [];
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function (value) {
tmp.push(encodeValue(operator, value));
});
}
else {
Object.keys(value).forEach(function (k) {
if (isDefined(value[k])) {
tmp.push(encodeUnreserved(k));
tmp.push(encodeValue(operator, value[k].toString()));
}
});
}
if (isKeyOperator(operator)) {
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
}
else if (tmp.length !== 0) {
result.push(tmp.join(","));
}
}
}
}
else {
if (operator === ";") {
if (isDefined(value)) {
result.push(encodeUnreserved(key));
}
}
else if (value === "" && (operator === "&" || operator === "?")) {
result.push(encodeUnreserved(key) + "=");
}
else if (value === "") {
result.push("");
}
}
return result;
}
function parseUrl(template) {
return {
expand: expand.bind(null, template)
};
}
function expand(template, context) {
var operators = ["+", "#", ".", "/", ";", "?", "&"];
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
if (expression) {
let operator = "";
const values = [];
if (operators.indexOf(expression.charAt(0)) !== -1) {
operator = expression.charAt(0);
expression = expression.substr(1);
}
expression.split(/,/g).forEach(function (variable) {
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
});
if (operator && operator !== "+") {
var separator = ",";
if (operator === "?") {
separator = "&";
}
else if (operator !== "#") {
separator = operator;
}
return (values.length !== 0 ? operator : "") + values.join(separator);
}
else {
return values.join(",");
}
}
else {
return encodeReserved(literal);
}
});
}
function parse(options) { function parse(options) {
// https://fetch.spec.whatwg.org/#methods // https://fetch.spec.whatwg.org/#methods
let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible let method = options.method.toUpperCase();
// replace :varname with {varname} to make it RFC 6570 compatible
let url = options.url.replace(/:([a-z]\w+)/g, "{+$1}"); let url = options.url.replace(/:([a-z]\w+)/g, "{+$1}");
let headers = Object.assign({}, options.headers); let headers = Object.assign({}, options.headers);
let body; let body;
let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later let parameters = omit(options, [
"method",
"baseUrl",
"url",
"headers",
"request",
"mediaType"
]);
// extract variable names from URL to calculate remaining variables later
const urlVariableNames = extractUrlVariableNames(url); const urlVariableNames = extractUrlVariableNames(url);
url = urlTemplate.parse(url).expand(parameters); url = parseUrl(url).expand(parameters);
if (!/^http/.test(url)) { if (!/^http/.test(url)) {
url = options.baseUrl + url; url = options.baseUrl + url;
} }
const omittedParameters = Object.keys(options)
const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl"); .filter(option => urlVariableNames.includes(option))
.concat("baseUrl");
const remainingParameters = omit(parameters, omittedParameters); const remainingParameters = omit(parameters, omittedParameters);
const isBinaryRequset = /application\/octet-stream/i.test(headers.accept); const isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
if (!isBinaryRequset) { if (!isBinaryRequset) {
if (options.mediaType.format) { if (options.mediaType.format) {
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw
headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, "application/vnd$1$2.".concat(options.mediaType.format))).join(","); headers.accept = headers.accept
.split(/,/)
.map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`))
.join(",");
} }
if (options.mediaType.previews.length) { if (options.mediaType.previews.length) {
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => { headers.accept = previewsFromAcceptHeader
const format = options.mediaType.format ? ".".concat(options.mediaType.format) : "+json"; .concat(options.mediaType.previews)
return "application/vnd.github.".concat(preview, "-preview").concat(format); .map(preview => {
}).join(","); const format = options.mediaType.format
? `.${options.mediaType.format}`
: "+json";
return `application/vnd.github.${preview}-preview${format}`;
})
.join(",");
} }
} // for GET/HEAD requests, set URL query parameters from remaining parameters }
// for GET/HEAD requests, set URL query parameters from remaining parameters
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters
if (["GET", "HEAD"].includes(method)) { if (["GET", "HEAD"].includes(method)) {
url = addQueryParameters(url, remainingParameters); url = addQueryParameters(url, remainingParameters);
} else { }
else {
if ("data" in remainingParameters) { if ("data" in remainingParameters) {
body = remainingParameters.data; body = remainingParameters.data;
} else { }
else {
if (Object.keys(remainingParameters).length) { if (Object.keys(remainingParameters).length) {
body = remainingParameters; body = remainingParameters;
} else { }
else {
headers["content-length"] = 0; headers["content-length"] = 0;
} }
} }
} // default content-type for JSON if body is set }
// default content-type for JSON if body is set
if (!headers["content-type"] && typeof body !== "undefined") { if (!headers["content-type"] && typeof body !== "undefined") {
headers["content-type"] = "application/json; charset=utf-8"; headers["content-type"] = "application/json; charset=utf-8";
} // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. }
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
// fetch does not allow to set `content-length` header, but we can set body to an empty string // fetch does not allow to set `content-length` header, but we can set body to an empty string
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
body = ""; body = "";
} // Only return body/request keys if present }
// Only return body/request keys if present
return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null);
return Object.assign({
method,
url,
headers
}, typeof body !== "undefined" ? {
body
} : null, options.request ? {
request: options.request
} : null);
} }
function endpointWithDefaults(defaults, route, options) { function endpointWithDefaults(defaults, route, options) {
@ -214,7 +357,7 @@ function withDefaults(oldDefaults, newDefaults) {
const VERSION = "0.0.0-development"; const VERSION = "0.0.0-development";
const userAgent = "octokit-endpoint.js/".concat(VERSION, " ").concat(getUserAgent()); const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
const DEFAULTS = { const DEFAULTS = {
method: "GET", method: "GET",
baseUrl: "https://api.github.com", baseUrl: "https://api.github.com",
@ -231,3 +374,4 @@ const DEFAULTS = {
const endpoint = withDefaults(null, DEFAULTS); const endpoint = withDefaults(null, DEFAULTS);
export { endpoint }; export { endpoint };
//# sourceMappingURL=index.js.map

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

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,58 +1,50 @@
{ {
"_args": [ "_from": "@octokit/endpoint@^5.1.0",
[ "_id": "@octokit/endpoint@5.3.5",
"@octokit/endpoint@5.3.2",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@octokit/endpoint@5.3.2",
"_id": "@octokit/endpoint@5.3.2",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-gRjteEM9I6f4D8vtwU2iGUTn9RX/AJ0SVXiqBUEuYEWVGGAVjSXdT0oNmghH5lvQNWs8mwt6ZaultuG6yXivNw==", "_integrity": "sha512-f8KqzIrnzPLiezDsZZPB+K8v8YSv6aKFl7eOu59O46lmlW4HagWl1U6NWl6LmT8d1w7NsKBI3paVtzcnRGO1gw==",
"_location": "/@octokit/endpoint", "_location": "/@octokit/endpoint",
"_phantomChildren": { "_phantomChildren": {
"os-name": "3.1.0" "os-name": "3.1.0"
}, },
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@octokit/endpoint@5.3.2", "raw": "@octokit/endpoint@^5.1.0",
"name": "@octokit/endpoint", "name": "@octokit/endpoint",
"escapedName": "@octokit%2fendpoint", "escapedName": "@octokit%2fendpoint",
"scope": "@octokit", "scope": "@octokit",
"rawSpec": "5.3.2", "rawSpec": "^5.1.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "5.3.2" "fetchSpec": "^5.1.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@octokit/request" "/@octokit/request"
], ],
"_resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.3.2.tgz", "_resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.3.5.tgz",
"_spec": "5.3.2", "_shasum": "2822c3b01107806dbdce3863b6205e3eff4289ed",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_spec": "@octokit/endpoint@^5.1.0",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@octokit/request",
"bugs": { "bugs": {
"url": "https://github.com/octokit/endpoint.js/issues" "url": "https://github.com/octokit/endpoint.js/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"deepmerge": "4.0.0",
"is-plain-object": "^3.0.0", "is-plain-object": "^3.0.0",
"universal-user-agent": "^3.0.0", "universal-user-agent": "^4.0.0"
"url-template": "^2.0.8"
}, },
"deprecated": false,
"description": "Turns REST API endpoints into generic request options", "description": "Turns REST API endpoints into generic request options",
"devDependencies": { "devDependencies": {
"@octokit/routes": "20.9.2", "@octokit/routes": "20.9.2",
"@pika/pack": "^0.4.0", "@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.4.0", "@pika/plugin-build-node": "^0.6.0",
"@pika/plugin-build-web": "^0.4.0", "@pika/plugin-build-web": "^0.6.0",
"@pika/plugin-ts-standard-pkg": "^0.4.0", "@pika/plugin-ts-standard-pkg": "^0.6.0",
"@types/jest": "^24.0.11", "@types/jest": "^24.0.11",
"@types/url-template": "^2.0.28",
"glob": "^7.1.3",
"handlebars": "^4.1.2", "handlebars": "^4.1.2",
"jest": "^24.7.1", "jest": "^24.7.1",
"lodash.set": "^4.3.2", "lodash.set": "^4.3.2",
"nyc": "^14.0.0",
"pascal-case": "^2.0.1", "pascal-case": "^2.0.1",
"prettier": "1.18.2", "prettier": "1.18.2",
"semantic-release": "^15.13.8", "semantic-release": "^15.13.8",
@ -87,5 +79,5 @@
"sideEffects": false, "sideEffects": false,
"source": "dist-src/index.js", "source": "dist-src/index.js",
"types": "dist-types/index.d.ts", "types": "dist-types/index.d.ts",
"version": "5.3.2" "version": "5.3.5"
} }

View File

@ -1,33 +1,28 @@
{ {
"_args": [ "_from": "@octokit/graphql@^2.0.1",
[
"@octokit/graphql@2.1.3",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@octokit/graphql@2.1.3",
"_id": "@octokit/graphql@2.1.3", "_id": "@octokit/graphql@2.1.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==", "_integrity": "sha512-XoXJqL2ondwdnMIW3wtqJWEwcBfKk37jO/rYkoxNPEVeLBDGsGO1TCWggrAlq3keGt/O+C/7VepXnukUxwt5vA==",
"_location": "/@octokit/graphql", "_location": "/@octokit/graphql",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@octokit/graphql@2.1.3", "raw": "@octokit/graphql@^2.0.1",
"name": "@octokit/graphql", "name": "@octokit/graphql",
"escapedName": "@octokit%2fgraphql", "escapedName": "@octokit%2fgraphql",
"scope": "@octokit", "scope": "@octokit",
"rawSpec": "2.1.3", "rawSpec": "^2.0.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "2.1.3" "fetchSpec": "^2.0.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/@actions/github" "/@actions/github"
], ],
"_resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz", "_resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-2.1.3.tgz",
"_spec": "2.1.3", "_shasum": "60c058a0ed5fa242eca6f938908d95fd1a2f4b92",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_spec": "@octokit/graphql@^2.0.1",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@actions/github",
"author": { "author": {
"name": "Gregor Martynus", "name": "Gregor Martynus",
"url": "https://github.com/gr2m" "url": "https://github.com/gr2m"
@ -35,6 +30,7 @@
"bugs": { "bugs": {
"url": "https://github.com/octokit/graphql.js/issues" "url": "https://github.com/octokit/graphql.js/issues"
}, },
"bundleDependencies": false,
"bundlesize": [ "bundlesize": [
{ {
"path": "./dist/octokit-graphql.min.js.gz", "path": "./dist/octokit-graphql.min.js.gz",
@ -45,6 +41,7 @@
"@octokit/request": "^5.0.0", "@octokit/request": "^5.0.0",
"universal-user-agent": "^2.0.3" "universal-user-agent": "^2.0.3"
}, },
"deprecated": false,
"description": "GitHub GraphQL API client for browsers and Node", "description": "GitHub GraphQL API client for browsers and Node",
"devDependencies": { "devDependencies": {
"chai": "^4.2.0", "chai": "^4.2.0",

View File

@ -1,41 +1,38 @@
{ {
"_args": [ "_from": "@octokit/request-error@^1.0.1",
[
"@octokit/request-error@1.0.4",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@octokit/request-error@1.0.4",
"_id": "@octokit/request-error@1.0.4", "_id": "@octokit/request-error@1.0.4",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-L4JaJDXn8SGT+5G0uX79rZLv0MNJmfGa4vb4vy1NnpjSnWDLJRy6m90udGwvMmavwsStgbv2QNkPzzTCMmL+ig==", "_integrity": "sha512-L4JaJDXn8SGT+5G0uX79rZLv0MNJmfGa4vb4vy1NnpjSnWDLJRy6m90udGwvMmavwsStgbv2QNkPzzTCMmL+ig==",
"_location": "/@octokit/request-error", "_location": "/@octokit/request-error",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@octokit/request-error@1.0.4", "raw": "@octokit/request-error@^1.0.1",
"name": "@octokit/request-error", "name": "@octokit/request-error",
"escapedName": "@octokit%2frequest-error", "escapedName": "@octokit%2frequest-error",
"scope": "@octokit", "scope": "@octokit",
"rawSpec": "1.0.4", "rawSpec": "^1.0.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.0.4" "fetchSpec": "^1.0.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/@octokit/request", "/@octokit/request",
"/@octokit/rest" "/@octokit/rest"
], ],
"_resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.0.4.tgz", "_resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.0.4.tgz",
"_spec": "1.0.4", "_shasum": "15e1dc22123ba4a9a4391914d80ec1e5303a23be",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_spec": "@octokit/request-error@^1.0.1",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@octokit/request",
"bugs": { "bugs": {
"url": "https://github.com/octokit/request-error.js/issues" "url": "https://github.com/octokit/request-error.js/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"deprecation": "^2.0.0", "deprecation": "^2.0.0",
"once": "^1.4.0" "once": "^1.4.0"
}, },
"deprecated": false,
"description": "Error class for Octokit request errors", "description": "Error class for Octokit request errors",
"devDependencies": { "devDependencies": {
"@pika/pack": "^0.3.7", "@pika/pack": "^0.3.7",

View File

@ -42,13 +42,17 @@ request("POST /repos/:owner/:repo/issues/:number/labels", {
mediaType: { mediaType: {
previews: ["symmetra"] previews: ["symmetra"]
}, },
owner: "ocotkit", owner: "octokit",
repo: "request.js", repo: "request.js",
number: 1, number: 1,
labels: ["🐛 bug"] 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 👍 Sensible defaults
- `baseUrl`: `https://api.github.com` - `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). 🧐 Simple to debug: Sets `error.request` to request options causing the error (with redacted credentials).
👶 Small bundle size (\<5kb minified + gzipped)
## Usage ## Usage
<table> <table>
@ -110,6 +112,8 @@ console.log(`${result.data.length} repos found.`);
### GraphQL example ### GraphQL example
For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/octokit/graphql.js#readme)
```js ```js
const result = await request("POST /graphql", { const result = await request("POST /graphql", {
headers: { 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()
`request(route, options)` or `request(options)`. `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: All of the [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) API can be used:
- [`ocotkitRequest.endpoint()`](#endpoint) - [`octokitRequest.endpoint()`](#endpoint)
- [`ocotkitRequest.endpoint.defaults()`](#endpointdefaults) - [`octokitRequest.endpoint.defaults()`](#endpointdefaults)
- [`ocotkitRequest.endpoint.merge()`](#endpointdefaults) - [`octokitRequest.endpoint.merge()`](#endpointdefaults)
- [`ocotkitRequest.endpoint.parse()`](#endpointmerge) - [`octokitRequest.endpoint.parse()`](#endpointmerge)
## Special cases ## 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; } function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var endpoint = require('@octokit/endpoint'); 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 isPlainObject = _interopDefault(require('is-plain-object'));
var nodeFetch = _interopDefault(require('node-fetch')); var nodeFetch = _interopDefault(require('node-fetch'));
var requestError = require('@octokit/request-error'); var requestError = require('@octokit/request-error');
@ -136,8 +136,9 @@ function withDefaults(oldEndpoint, newDefaults) {
const request = withDefaults(endpoint.endpoint, { const request = withDefaults(endpoint.endpoint, {
headers: { headers: {
"user-agent": `octokit-request.js/${VERSION} ${getUserAgent()}` "user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}`
} }
}); });
exports.request = request; 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 { endpoint } from "@octokit/endpoint";
import getUserAgent from "universal-user-agent"; import { getUserAgent } from "universal-user-agent";
import { VERSION } from "./version"; import { VERSION } from "./version";
import withDefaults from "./with-defaults"; import withDefaults from "./with-defaults";
export const request = withDefaults(endpoint, { export const request = withDefaults(endpoint, {

View File

@ -1,5 +1,5 @@
import { endpoint } from '@octokit/endpoint'; import { endpoint } from '@octokit/endpoint';
import getUserAgent from 'universal-user-agent'; import { getUserAgent } from 'universal-user-agent';
import isPlainObject from 'is-plain-object'; import isPlainObject from 'is-plain-object';
import nodeFetch from 'node-fetch'; import nodeFetch from 'node-fetch';
import { RequestError } from '@octokit/request-error'; import { RequestError } from '@octokit/request-error';
@ -124,3 +124,4 @@ const request = withDefaults(endpoint, {
}); });
export { request }; 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) [![@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) [![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/) [![Greenkeeper](https://badges.greenkeeper.io/gr2m/universal-user-agent.svg)](https://greenkeeper.io/)
```js ```js
const getUserAgent = require('universal-user-agent') const { getUserAgent } = require("universal-user-agent");
const userAgent = getUserAgent() // or import { getUserAgent } from "universal-user-agent";
const userAgent = getUserAgent();
// userAgent will look like this // 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 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) // 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": [ "_from": "universal-user-agent@^4.0.0",
[ "_id": "universal-user-agent@4.0.0",
"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",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-T3siHThqoj5X0benA5H0qcDnrKGXzU8TKoX15x/tQHw1hQBvIEBHjxQ2klizYsqBOO/Q+WuxoQUihadeeqDnoA==", "_integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==",
"_location": "/@octokit/request/universal-user-agent", "_location": "/@octokit/request/universal-user-agent",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "universal-user-agent@3.0.0", "raw": "universal-user-agent@^4.0.0",
"name": "universal-user-agent", "name": "universal-user-agent",
"escapedName": "universal-user-agent", "escapedName": "universal-user-agent",
"rawSpec": "3.0.0", "rawSpec": "^4.0.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "3.0.0" "fetchSpec": "^4.0.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@octokit/request" "/@octokit/request"
], ],
"_resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-3.0.0.tgz", "_resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz",
"_spec": "3.0.0", "_shasum": "27da2ec87e32769619f68a14996465ea1cb9df16",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_spec": "universal-user-agent@^4.0.0",
"author": { "_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@octokit/request",
"name": "Gregor Martynus",
"url": "https://github.com/gr2m"
},
"browser": "browser.js",
"bugs": { "bugs": {
"url": "https://github.com/gr2m/universal-user-agent/issues" "url": "https://github.com/gr2m/universal-user-agent/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"os-name": "^3.0.0" "os-name": "^3.1.0"
}, },
"deprecated": false,
"description": "Get a user agent string in both browser and node", "description": "Get a user agent string in both browser and node",
"devDependencies": { "devDependencies": {
"chai": "^4.1.2", "@gr2m/pika-plugin-build-web": "^0.6.0-issue-84.1",
"coveralls": "^3.0.2", "@pika/pack": "^0.5.0",
"cypress": "^3.1.0", "@pika/plugin-build-node": "^0.6.0",
"mocha": "^6.0.0", "@pika/plugin-ts-standard-pkg": "^0.6.0",
"nyc": "^14.0.0", "@types/jest": "^24.0.18",
"proxyquire": "^2.1.0", "jest": "^24.9.0",
"prettier": "^1.18.2",
"semantic-release": "^15.9.15", "semantic-release": "^15.9.15",
"sinon": "^7.2.4", "ts-jest": "^24.0.2",
"sinon-chai": "^3.2.0", "typescript": "^3.6.2"
"standard": "^13.0.1",
"test": "^0.6.0",
"travis-deploy-once": "^5.0.7"
}, },
"files": [
"dist-*/",
"bin/"
],
"homepage": "https://github.com/gr2m/universal-user-agent#readme", "homepage": "https://github.com/gr2m/universal-user-agent#readme",
"keywords": [], "keywords": [],
"license": "ISC", "license": "ISC",
"main": "index.js", "main": "dist-node/index.js",
"module": "dist-web/index.js",
"name": "universal-user-agent", "name": "universal-user-agent",
"pika": true,
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/gr2m/universal-user-agent.git" "url": "git+https://github.com/gr2m/universal-user-agent.git"
}, },
"scripts": { "sideEffects": false,
"coverage": "nyc report --reporter=html && open coverage/index.html", "source": "dist-src/index.js",
"coverage:upload": "nyc report --reporter=text-lcov | coveralls", "types": "dist-types/index.d.ts",
"pretest": "standard", "version": "4.0.0"
"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"
} }

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

View File

@ -1,7 +1,7 @@
module.exports = parseOptions module.exports = parseOptions
const { Deprecation } = require('deprecation') const { Deprecation } = require('deprecation')
const getUserAgent = require('universal-user-agent') const { getUserAgent } = require('universal-user-agent')
const once = require('once') const once = require('once')
const pkg = require('../package.json') const pkg = require('../package.json')

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) [![@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) [![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/) [![Greenkeeper](https://badges.greenkeeper.io/gr2m/universal-user-agent.svg)](https://greenkeeper.io/)
```js ```js
const getUserAgent = require('universal-user-agent') const { getUserAgent } = require("universal-user-agent");
const userAgent = getUserAgent() // or import { getUserAgent } from "universal-user-agent";
const userAgent = getUserAgent();
// userAgent will look like this // 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 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) // 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": [ "_from": "universal-user-agent@^4.0.0",
[ "_id": "universal-user-agent@4.0.0",
"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",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-T3siHThqoj5X0benA5H0qcDnrKGXzU8TKoX15x/tQHw1hQBvIEBHjxQ2klizYsqBOO/Q+WuxoQUihadeeqDnoA==", "_integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==",
"_location": "/@octokit/rest/universal-user-agent", "_location": "/@octokit/rest/universal-user-agent",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "universal-user-agent@3.0.0", "raw": "universal-user-agent@^4.0.0",
"name": "universal-user-agent", "name": "universal-user-agent",
"escapedName": "universal-user-agent", "escapedName": "universal-user-agent",
"rawSpec": "3.0.0", "rawSpec": "^4.0.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "3.0.0" "fetchSpec": "^4.0.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@octokit/rest" "/@octokit/rest"
], ],
"_resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-3.0.0.tgz", "_resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz",
"_spec": "3.0.0", "_shasum": "27da2ec87e32769619f68a14996465ea1cb9df16",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_spec": "universal-user-agent@^4.0.0",
"author": { "_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@octokit/rest",
"name": "Gregor Martynus",
"url": "https://github.com/gr2m"
},
"browser": "browser.js",
"bugs": { "bugs": {
"url": "https://github.com/gr2m/universal-user-agent/issues" "url": "https://github.com/gr2m/universal-user-agent/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"os-name": "^3.0.0" "os-name": "^3.1.0"
}, },
"deprecated": false,
"description": "Get a user agent string in both browser and node", "description": "Get a user agent string in both browser and node",
"devDependencies": { "devDependencies": {
"chai": "^4.1.2", "@gr2m/pika-plugin-build-web": "^0.6.0-issue-84.1",
"coveralls": "^3.0.2", "@pika/pack": "^0.5.0",
"cypress": "^3.1.0", "@pika/plugin-build-node": "^0.6.0",
"mocha": "^6.0.0", "@pika/plugin-ts-standard-pkg": "^0.6.0",
"nyc": "^14.0.0", "@types/jest": "^24.0.18",
"proxyquire": "^2.1.0", "jest": "^24.9.0",
"prettier": "^1.18.2",
"semantic-release": "^15.9.15", "semantic-release": "^15.9.15",
"sinon": "^7.2.4", "ts-jest": "^24.0.2",
"sinon-chai": "^3.2.0", "typescript": "^3.6.2"
"standard": "^13.0.1",
"test": "^0.6.0",
"travis-deploy-once": "^5.0.7"
}, },
"files": [
"dist-*/",
"bin/"
],
"homepage": "https://github.com/gr2m/universal-user-agent#readme", "homepage": "https://github.com/gr2m/universal-user-agent#readme",
"keywords": [], "keywords": [],
"license": "ISC", "license": "ISC",
"main": "index.js", "main": "dist-node/index.js",
"module": "dist-web/index.js",
"name": "universal-user-agent", "name": "universal-user-agent",
"pika": true,
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/gr2m/universal-user-agent.git" "url": "git+https://github.com/gr2m/universal-user-agent.git"
}, },
"scripts": { "sideEffects": false,
"coverage": "nyc report --reporter=html && open coverage/index.html", "source": "dist-src/index.js",
"coverage:upload": "nyc report --reporter=text-lcov | coveralls", "types": "dist-types/index.d.ts",
"pretest": "standard", "version": "4.0.0"
"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"
} }

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,35 +1,30 @@
{ {
"_args": [ "_from": "@octokit/rest@^16.15.0",
[ "_id": "@octokit/rest@16.28.9",
"@octokit/rest@16.28.7",
"/Users/rachmari/github-repos/hello-world-javascript-action"
]
],
"_from": "@octokit/rest@16.28.7",
"_id": "@octokit/rest@16.28.7",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-cznFSLEhh22XD3XeqJw51OLSfyL2fcFKUO+v2Ep9MTAFfFLS1cK1Zwd1yEgQJmJoDnj4/vv3+fGGZweG+xsbIA==", "_integrity": "sha512-IKGnX+Tvzt7XHhs8f4ajqxyJvYAMNX5nWfoJm4CQj8LZToMiaJgutf5KxxpxoC3y5w7JTJpW5rnWnF4TsIvCLA==",
"_location": "/@octokit/rest", "_location": "/@octokit/rest",
"_phantomChildren": { "_phantomChildren": {
"os-name": "3.1.0" "os-name": "3.1.0"
}, },
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@octokit/rest@16.28.7", "raw": "@octokit/rest@^16.15.0",
"name": "@octokit/rest", "name": "@octokit/rest",
"escapedName": "@octokit%2frest", "escapedName": "@octokit%2frest",
"scope": "@octokit", "scope": "@octokit",
"rawSpec": "16.28.7", "rawSpec": "^16.15.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "16.28.7" "fetchSpec": "^16.15.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@actions/github" "/@actions/github"
], ],
"_resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.28.7.tgz", "_resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.28.9.tgz",
"_spec": "16.28.7", "_shasum": "ac8c5f3ff305e9e0a0989a5245e4286f057a95d7",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action", "_spec": "@octokit/rest@^16.15.0",
"_where": "/Users/rachmari/github-repos/hello-world-javascript-action/node_modules/@actions/github",
"author": { "author": {
"name": "Gregor Martynus", "name": "Gregor Martynus",
"url": "https://github.com/gr2m" "url": "https://github.com/gr2m"
@ -37,6 +32,7 @@
"bugs": { "bugs": {
"url": "https://github.com/octokit/rest.js/issues" "url": "https://github.com/octokit/rest.js/issues"
}, },
"bundleDependencies": false,
"bundlesize": [ "bundlesize": [
{ {
"path": "./dist/octokit-rest.min.js.gz", "path": "./dist/octokit-rest.min.js.gz",
@ -73,9 +69,9 @@
"lodash.uniq": "^4.5.0", "lodash.uniq": "^4.5.0",
"octokit-pagination-methods": "^1.1.0", "octokit-pagination-methods": "^1.1.0",
"once": "^1.4.0", "once": "^1.4.0",
"universal-user-agent": "^3.0.0", "universal-user-agent": "^4.0.0"
"url-template": "^2.0.8"
}, },
"deprecated": false,
"description": "GitHub REST API client for Node.js", "description": "GitHub REST API client for Node.js",
"devDependencies": { "devDependencies": {
"@gimenete/type-writer": "^0.1.3", "@gimenete/type-writer": "^0.1.3",
@ -102,8 +98,8 @@
"semantic-release": "^15.0.0", "semantic-release": "^15.0.0",
"sinon": "^7.2.4", "sinon": "^7.2.4",
"sinon-chai": "^3.0.0", "sinon-chai": "^3.0.0",
"sort-keys": "^3.0.0", "sort-keys": "^4.0.0",
"standard": "^13.0.1", "standard": "^14.0.2",
"string-to-arraybuffer": "^1.0.0", "string-to-arraybuffer": "^1.0.0",
"string-to-jsdoc-comment": "^1.0.0", "string-to-jsdoc-comment": "^1.0.0",
"typescript": "^3.3.1", "typescript": "^3.3.1",
@ -185,5 +181,5 @@
] ]
}, },
"types": "index.d.ts", "types": "index.d.ts",
"version": "16.28.7" "version": "16.28.9"
} }

View File

@ -10,20 +10,20 @@ function authenticationBeforeRequest (state, options) {
if (state.auth.type === 'basic') { if (state.auth.type === 'basic') {
const hash = btoa(`${state.auth.username}:${state.auth.password}`) const hash = btoa(`${state.auth.username}:${state.auth.password}`)
options.headers['authorization'] = `Basic ${hash}` options.headers.authorization = `Basic ${hash}`
return return
} }
if (state.auth.type === 'token') { if (state.auth.type === 'token') {
options.headers['authorization'] = `token ${state.auth.token}` options.headers.authorization = `token ${state.auth.token}`
return return
} }
if (state.auth.type === 'app') { if (state.auth.type === 'app') {
options.headers['authorization'] = `Bearer ${state.auth.token}` options.headers.authorization = `Bearer ${state.auth.token}`
const acceptHeaders = options.headers['accept'].split(',') const acceptHeaders = options.headers.accept.split(',')
.concat('application/vnd.github.machine-man-preview+json') .concat('application/vnd.github.machine-man-preview+json')
options.headers['accept'] = uniq(acceptHeaders).filter(Boolean).join(',') options.headers.accept = uniq(acceptHeaders).filter(Boolean).join(',')
return return
} }

View File

@ -6,13 +6,13 @@ const withAuthorizationPrefix = require('./with-authorization-prefix')
function authenticationBeforeRequest (state, options) { function authenticationBeforeRequest (state, options) {
if (typeof state.auth === 'string') { if (typeof state.auth === 'string') {
options.headers['authorization'] = withAuthorizationPrefix(state.auth) options.headers.authorization = withAuthorizationPrefix(state.auth)
// https://developer.github.com/v3/previews/#integrations // https://developer.github.com/v3/previews/#integrations
if (/^bearer /i.test(state.auth) && !/machine-man/.test(options.headers['accept'])) { if (/^bearer /i.test(state.auth) && !/machine-man/.test(options.headers.accept)) {
const acceptHeaders = options.headers['accept'].split(',') const acceptHeaders = options.headers.accept.split(',')
.concat('application/vnd.github.machine-man-preview+json') .concat('application/vnd.github.machine-man-preview+json')
options.headers['accept'] = acceptHeaders.filter(Boolean).join(',') options.headers.accept = acceptHeaders.filter(Boolean).join(',')
} }
return return
@ -20,7 +20,7 @@ function authenticationBeforeRequest (state, options) {
if (state.auth.username) { if (state.auth.username) {
const hash = btoa(`${state.auth.username}:${state.auth.password}`) const hash = btoa(`${state.auth.username}:${state.auth.password}`)
options.headers['authorization'] = `Basic ${hash}` options.headers.authorization = `Basic ${hash}`
if (state.otp) { if (state.otp) {
options.headers['x-github-otp'] = state.otp options.headers['x-github-otp'] = state.otp
} }
@ -40,7 +40,7 @@ function authenticationBeforeRequest (state, options) {
// as well as "/applications/123/tokens/token456" // as well as "/applications/123/tokens/token456"
if (/\/applications\/:?[\w_]+\/tokens\/:?[\w_]+($|\?)/.test(options.url)) { if (/\/applications\/:?[\w_]+\/tokens\/:?[\w_]+($|\?)/.test(options.url)) {
const hash = btoa(`${state.auth.clientId}:${state.auth.clientSecret}`) const hash = btoa(`${state.auth.clientId}:${state.auth.clientSecret}`)
options.headers['authorization'] = `Basic ${hash}` options.headers.authorization = `Basic ${hash}`
return return
} }
@ -56,6 +56,6 @@ function authenticationBeforeRequest (state, options) {
}) })
.then((authorization) => { .then((authorization) => {
options.headers['authorization'] = withAuthorizationPrefix(authorization) options.headers.authorization = withAuthorizationPrefix(authorization)
}) })
} }

Some files were not shown because too many files have changed in this diff Show More