Add node modules and package files
This commit is contained in:
parent
e84489cd02
commit
714607abe9
|
@ -0,0 +1 @@
|
||||||
|
../semver/bin/semver
|
|
@ -0,0 +1 @@
|
||||||
|
../which/bin/which
|
|
@ -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.
|
|
@ -1,7 +1,97 @@
|
||||||
# `@actions/core`
|
# `@actions/core`
|
||||||
|
|
||||||
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
||||||
|
|
||||||
## 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
|
||||||
|
})
|
||||||
|
```
|
|
@ -1,16 +1,16 @@
|
||||||
interface CommandProperties {
|
interface CommandProperties {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
* Command Format:
|
* Command Format:
|
||||||
* ##[name key=value;key=value]message
|
* ##[name key=value;key=value]message
|
||||||
*
|
*
|
||||||
* 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 {};
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
* Command Format:
|
* Command Format:
|
||||||
* ##[name key=value;key=value]message
|
* ##[name key=value;key=value]message
|
||||||
*
|
*
|
||||||
* 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;
|
||||||
const CMD_PREFIX = '##[';
|
const CMD_PREFIX = '##[';
|
||||||
class Command {
|
class Command {
|
||||||
constructor(command, properties, message) {
|
constructor(command, properties, message) {
|
||||||
if (!command) {
|
if (!command) {
|
||||||
command = 'missing.command';
|
command = 'missing.command';
|
||||||
}
|
}
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
toString() {
|
toString() {
|
||||||
let cmdStr = CMD_PREFIX + this.command;
|
let cmdStr = CMD_PREFIX + this.command;
|
||||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
if (this.properties && Object.keys(this.properties).length > 0) {
|
||||||
cmdStr += ' ';
|
cmdStr += ' ';
|
||||||
for (const key in this.properties) {
|
for (const key in this.properties) {
|
||||||
if (this.properties.hasOwnProperty(key)) {
|
if (this.properties.hasOwnProperty(key)) {
|
||||||
const val = this.properties[key];
|
const val = this.properties[key];
|
||||||
if (val) {
|
if (val) {
|
||||||
// safely append the val - avoid blowing up when attempting to
|
// safely append the val - avoid blowing up when attempting to
|
||||||
// call .replace() if message is not a string for some reason
|
// call .replace() if message is not a string for some reason
|
||||||
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmdStr += ']';
|
cmdStr += ']';
|
||||||
// safely append the message - avoid blowing up when attempting to
|
// safely append the message - avoid blowing up when attempting to
|
||||||
// call .replace() if message is not a string for some reason
|
// call .replace() if message is not a string for some reason
|
||||||
const message = `${this.message || ''}`;
|
const message = `${this.message || ''}`;
|
||||||
cmdStr += escapeData(message);
|
cmdStr += escapeData(message);
|
||||||
return cmdStr;
|
return cmdStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function escapeData(s) {
|
function escapeData(s) {
|
||||||
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escape(s) {
|
function escape(s) {
|
||||||
return s
|
return s
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
.replace(/]/g, '%5D')
|
.replace(/]/g, '%5D')
|
||||||
.replace(/;/g, '%3B');
|
.replace(/;/g, '%3B');
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=command.js.map
|
//# sourceMappingURL=command.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,OAAe;IACjD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,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"}
|
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,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"}
|
|
@ -1,81 +1,94 @@
|
||||||
/**
|
/**
|
||||||
* Interface for getInput options
|
* Interface for getInput options
|
||||||
*/
|
*/
|
||||||
export interface InputOptions {
|
export interface InputOptions {
|
||||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
*/
|
*/
|
||||||
export declare enum ExitCode {
|
export declare enum ExitCode {
|
||||||
/**
|
/**
|
||||||
* A code indicating that the action was successful
|
* A code indicating that the action was successful
|
||||||
*/
|
*/
|
||||||
Success = 0,
|
Success = 0,
|
||||||
/**
|
/**
|
||||||
* 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
|
/**
|
||||||
*/
|
* sets env variable for this action and future actions in the job
|
||||||
Neutral = 78
|
* @param name the name of the variable to set
|
||||||
}
|
* @param val the value of the variable
|
||||||
/**
|
*/
|
||||||
* sets env variable for this action and future actions in the job
|
export declare function exportVariable(name: string, val: string): void;
|
||||||
* @param name the name of the variable to set
|
/**
|
||||||
* @param val the value of the variable
|
* exports the variable and registers a secret which will get masked from logs
|
||||||
*/
|
* @param name the name of the variable to set
|
||||||
export declare function exportVariable(name: string, val: string): void;
|
* @param val value of the secret
|
||||||
/**
|
*/
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
export declare function exportSecret(name: string, val: string): void;
|
||||||
* @param name the name of the variable to set
|
/**
|
||||||
* @param val value of the secret
|
* Prepends inputPath to the PATH (for this action and future actions)
|
||||||
*/
|
* @param inputPath
|
||||||
export declare function exportSecret(name: string, val: string): void;
|
*/
|
||||||
/**
|
export declare function addPath(inputPath: string): void;
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
/**
|
||||||
* @param inputPath
|
* Gets the value of an input. The value is also trimmed.
|
||||||
*/
|
*
|
||||||
export declare function addPath(inputPath: string): void;
|
* @param name name of the input to get
|
||||||
/**
|
* @param options optional. See InputOptions.
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* @returns string
|
||||||
*
|
*/
|
||||||
* @param name name of the input to get
|
export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
* @param options optional. See InputOptions.
|
/**
|
||||||
* @returns string
|
* Sets the value of an output.
|
||||||
*/
|
*
|
||||||
export declare function getInput(name: string, options?: InputOptions): string;
|
* @param name name of the output to set
|
||||||
/**
|
* @param value value to store
|
||||||
* Sets the value of an output.
|
*/
|
||||||
*
|
export declare function setOutput(name: string, value: string): void;
|
||||||
* @param name name of the output to set
|
/**
|
||||||
* @param value value to store
|
* Sets the action status to failed.
|
||||||
*/
|
* When the action exits it will be with an exit code of 1
|
||||||
export declare function setOutput(name: string, value: string): void;
|
* @param message add error issue message
|
||||||
/**
|
*/
|
||||||
* Sets the action status to neutral
|
export declare function setFailed(message: string): void;
|
||||||
*/
|
/**
|
||||||
export declare function setNeutral(): void;
|
* Writes debug message to user log
|
||||||
/**
|
* @param message debug message
|
||||||
* Sets the action status to failed.
|
*/
|
||||||
* When the action exits it will be with an exit code of 1
|
export declare function debug(message: string): void;
|
||||||
* @param message add error issue message
|
/**
|
||||||
*/
|
* Adds an error issue
|
||||||
export declare function setFailed(message: string): void;
|
* @param message error issue message
|
||||||
/**
|
*/
|
||||||
* Writes debug message to user log
|
export declare function error(message: string): void;
|
||||||
* @param message debug message
|
/**
|
||||||
*/
|
* Adds an warning issue
|
||||||
export declare function debug(message: string): void;
|
* @param message warning issue message
|
||||||
/**
|
*/
|
||||||
* Adds an error issue
|
export declare function warning(message: string): void;
|
||||||
* @param message error issue message
|
/**
|
||||||
*/
|
* Begin an output group.
|
||||||
export declare function error(message: string): void;
|
*
|
||||||
/**
|
* Output until the next `groupEnd` will be foldable in this group
|
||||||
* Adds an warning issue
|
*
|
||||||
* @param message warning issue message
|
* @param name The name of the output group
|
||||||
*/
|
*/
|
||||||
export declare function warning(message: string): void;
|
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>;
|
||||||
|
|
|
@ -1,127 +1,168 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
const command_1 = require("./command");
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
const path = require("path");
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
/**
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
* The code to exit an action
|
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); }
|
||||||
var ExitCode;
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
(function (ExitCode) {
|
});
|
||||||
/**
|
};
|
||||||
* A code indicating that the action was successful
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
*/
|
const command_1 = require("./command");
|
||||||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
const path = require("path");
|
||||||
/**
|
/**
|
||||||
* A code indicating that the action was a failure
|
* The code to exit an action
|
||||||
*/
|
*/
|
||||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
var ExitCode;
|
||||||
/**
|
(function (ExitCode) {
|
||||||
* A code indicating that the action is complete, but neither succeeded nor failed
|
/**
|
||||||
*/
|
* A code indicating that the action was successful
|
||||||
ExitCode[ExitCode["Neutral"] = 78] = "Neutral";
|
*/
|
||||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
ExitCode[ExitCode["Success"] = 0] = "Success";
|
||||||
//-----------------------------------------------------------------------
|
/**
|
||||||
// Variables
|
* A code indicating that the action was a failure
|
||||||
//-----------------------------------------------------------------------
|
*/
|
||||||
/**
|
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
||||||
* sets env variable for this action and future actions in the job
|
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
||||||
* @param name the name of the variable to set
|
//-----------------------------------------------------------------------
|
||||||
* @param val the value of the variable
|
// Variables
|
||||||
*/
|
//-----------------------------------------------------------------------
|
||||||
function exportVariable(name, val) {
|
/**
|
||||||
process.env[name] = val;
|
* sets env variable for this action and future actions in the job
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
* @param name the name of the variable to set
|
||||||
}
|
* @param val the value of the variable
|
||||||
exports.exportVariable = exportVariable;
|
*/
|
||||||
/**
|
function exportVariable(name, val) {
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
process.env[name] = val;
|
||||||
* @param name the name of the variable to set
|
command_1.issueCommand('set-env', { name }, val);
|
||||||
* @param val value of the secret
|
}
|
||||||
*/
|
exports.exportVariable = exportVariable;
|
||||||
function exportSecret(name, val) {
|
/**
|
||||||
exportVariable(name, val);
|
* exports the variable and registers a secret which will get masked from logs
|
||||||
command_1.issueCommand('set-secret', {}, val);
|
* @param name the name of the variable to set
|
||||||
}
|
* @param val value of the secret
|
||||||
exports.exportSecret = exportSecret;
|
*/
|
||||||
/**
|
function exportSecret(name, val) {
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
exportVariable(name, val);
|
||||||
* @param inputPath
|
// the runner will error with not implemented
|
||||||
*/
|
// leaving the function but raising the error earlier
|
||||||
function addPath(inputPath) {
|
command_1.issueCommand('set-secret', {}, val);
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
throw new Error('Not implemented.');
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
}
|
||||||
}
|
exports.exportSecret = exportSecret;
|
||||||
exports.addPath = addPath;
|
/**
|
||||||
/**
|
* Prepends inputPath to the PATH (for this action and future actions)
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* @param inputPath
|
||||||
*
|
*/
|
||||||
* @param name name of the input to get
|
function addPath(inputPath) {
|
||||||
* @param options optional. See InputOptions.
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
* @returns string
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||||
*/
|
}
|
||||||
function getInput(name, options) {
|
exports.addPath = addPath;
|
||||||
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
/**
|
||||||
if (options && options.required && !val) {
|
* Gets the value of an input. The value is also trimmed.
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
*
|
||||||
}
|
* @param name name of the input to get
|
||||||
return val.trim();
|
* @param options optional. See InputOptions.
|
||||||
}
|
* @returns string
|
||||||
exports.getInput = getInput;
|
*/
|
||||||
/**
|
function getInput(name, options) {
|
||||||
* Sets the value of an output.
|
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
||||||
*
|
if (options && options.required && !val) {
|
||||||
* @param name name of the output to set
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
* @param value value to store
|
}
|
||||||
*/
|
return val.trim();
|
||||||
function setOutput(name, value) {
|
}
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
exports.getInput = getInput;
|
||||||
}
|
/**
|
||||||
exports.setOutput = setOutput;
|
* Sets the value of an output.
|
||||||
//-----------------------------------------------------------------------
|
*
|
||||||
// Results
|
* @param name name of the output to set
|
||||||
//-----------------------------------------------------------------------
|
* @param value value to store
|
||||||
/**
|
*/
|
||||||
* Sets the action status to neutral
|
function setOutput(name, value) {
|
||||||
*/
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
function setNeutral() {
|
}
|
||||||
process.exitCode = ExitCode.Neutral;
|
exports.setOutput = setOutput;
|
||||||
}
|
//-----------------------------------------------------------------------
|
||||||
exports.setNeutral = setNeutral;
|
// Results
|
||||||
/**
|
//-----------------------------------------------------------------------
|
||||||
* Sets the action status to failed.
|
/**
|
||||||
* When the action exits it will be with an exit code of 1
|
* Sets the action status to failed.
|
||||||
* @param message add error issue message
|
* When the action exits it will be with an exit code of 1
|
||||||
*/
|
* @param message add error issue message
|
||||||
function setFailed(message) {
|
*/
|
||||||
process.exitCode = ExitCode.Failure;
|
function setFailed(message) {
|
||||||
error(message);
|
process.exitCode = ExitCode.Failure;
|
||||||
}
|
error(message);
|
||||||
exports.setFailed = setFailed;
|
}
|
||||||
//-----------------------------------------------------------------------
|
exports.setFailed = setFailed;
|
||||||
// Logging Commands
|
//-----------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------
|
// Logging Commands
|
||||||
/**
|
//-----------------------------------------------------------------------
|
||||||
* Writes debug message to user log
|
/**
|
||||||
* @param message debug message
|
* Writes debug message to user log
|
||||||
*/
|
* @param message debug message
|
||||||
function debug(message) {
|
*/
|
||||||
command_1.issueCommand('debug', {}, message);
|
function debug(message) {
|
||||||
}
|
command_1.issueCommand('debug', {}, message);
|
||||||
exports.debug = debug;
|
}
|
||||||
/**
|
exports.debug = debug;
|
||||||
* Adds an error issue
|
/**
|
||||||
* @param message error issue message
|
* Adds an error issue
|
||||||
*/
|
* @param message error issue message
|
||||||
function error(message) {
|
*/
|
||||||
command_1.issue('error', message);
|
function error(message) {
|
||||||
}
|
command_1.issue('error', message);
|
||||||
exports.error = error;
|
}
|
||||||
/**
|
exports.error = error;
|
||||||
* Adds an warning issue
|
/**
|
||||||
* @param message warning issue message
|
* Adds an warning issue
|
||||||
*/
|
* @param message warning issue message
|
||||||
function warning(message) {
|
*/
|
||||||
command_1.issue('warning', message);
|
function 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
|
|
@ -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,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;GAEG;AACH,SAAgB,UAAU;IACxB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;AACrC,CAAC;AAFD,gCAEC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC"}
|
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;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;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;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,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,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"}
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
|
@ -1,47 +1,50 @@
|
||||||
# `@actions/github`
|
# `@actions/github`
|
||||||
|
|
||||||
> A hydrated Octokit client.
|
> A hydrated Octokit client.
|
||||||
|
|
||||||
## 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.
|
|
||||||
const myToken = process.env.GITHUB_TOKEN
|
// This should be a token with access to your repository scoped in as a secret.
|
||||||
|
const myToken = core.getInput('myToken');
|
||||||
const octokit = new github.GitHub(myToken)
|
|
||||||
|
const octokit = new github.GitHub(myToken);
|
||||||
const pulls = await octokit.pulls.get({
|
|
||||||
owner: 'octokit',
|
const { data: pullRequest } = await octokit.pulls.get({
|
||||||
repo: 'rest.js',
|
owner: 'octokit',
|
||||||
pull_number: 123,
|
repo: 'rest.js',
|
||||||
mediaType: {
|
pull_number: 123,
|
||||||
format: 'diff'
|
mediaType: {
|
||||||
}
|
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.
|
||||||
```
|
|
||||||
const result = await octokit.graphql(query, variables)
|
You can also make GraphQL requests. See https://github.com/octokit/graphql.js for the API.
|
||||||
```
|
|
||||||
|
```js
|
||||||
Finally, you can get the context of the current action:
|
const result = await octokit.graphql(query, variables);
|
||||||
|
```
|
||||||
```
|
|
||||||
const github = require('@actions/github');
|
Finally, you can get the context of the current action:
|
||||||
|
|
||||||
const context = github.context
|
```js
|
||||||
|
const github = require('@actions/github');
|
||||||
const newIssue = await octokit.issues.create({
|
|
||||||
...context.repo,
|
const context = github.context;
|
||||||
title: 'New issue!',
|
|
||||||
body: 'Hello Universe!'
|
const newIssue = await octokit.issues.create({
|
||||||
})
|
...context.repo,
|
||||||
```
|
title: 'New issue!',
|
||||||
|
body: 'Hello Universe!'
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
import { WebhookPayload } from './interfaces';
|
import { WebhookPayload } from './interfaces';
|
||||||
export declare class Context {
|
export declare class Context {
|
||||||
/**
|
/**
|
||||||
* Webhook payload object that triggered the workflow
|
* Webhook payload object that triggered the workflow
|
||||||
*/
|
*/
|
||||||
payload: WebhookPayload;
|
payload: WebhookPayload;
|
||||||
eventName: string;
|
eventName: string;
|
||||||
sha: string;
|
sha: string;
|
||||||
ref: string;
|
ref: string;
|
||||||
workflow: string;
|
workflow: string;
|
||||||
action: string;
|
action: string;
|
||||||
actor: string;
|
actor: string;
|
||||||
/**
|
/**
|
||||||
* Hydrate the context from the environment
|
* Hydrate the context from the environment
|
||||||
*/
|
*/
|
||||||
constructor();
|
constructor();
|
||||||
readonly issue: {
|
readonly issue: {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
number: number;
|
number: number;
|
||||||
};
|
};
|
||||||
readonly repo: {
|
readonly repo: {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,45 @@
|
||||||
"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");
|
||||||
class Context {
|
const os_1 = require("os");
|
||||||
/**
|
class Context {
|
||||||
* Hydrate the context from the environment
|
/**
|
||||||
*/
|
* Hydrate the context from the environment
|
||||||
constructor() {
|
*/
|
||||||
this.payload = process.env.GITHUB_EVENT_PATH
|
constructor() {
|
||||||
? require(process.env.GITHUB_EVENT_PATH)
|
this.payload = {};
|
||||||
: {};
|
if (process.env.GITHUB_EVENT_PATH) {
|
||||||
this.eventName = process.env.GITHUB_EVENT_NAME;
|
if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) {
|
||||||
this.sha = process.env.GITHUB_SHA;
|
this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' }));
|
||||||
this.ref = process.env.GITHUB_REF;
|
}
|
||||||
this.workflow = process.env.GITHUB_WORKFLOW;
|
else {
|
||||||
this.action = process.env.GITHUB_ACTION;
|
process.stdout.write(`GITHUB_EVENT_PATH ${process.env.GITHUB_EVENT_PATH} does not exist${os_1.EOL}`);
|
||||||
this.actor = process.env.GITHUB_ACTOR;
|
}
|
||||||
}
|
}
|
||||||
get issue() {
|
this.eventName = process.env.GITHUB_EVENT_NAME;
|
||||||
const payload = this.payload;
|
this.sha = process.env.GITHUB_SHA;
|
||||||
return Object.assign({}, this.repo, { number: (payload.issue || payload.pullRequest || payload).number });
|
this.ref = process.env.GITHUB_REF;
|
||||||
}
|
this.workflow = process.env.GITHUB_WORKFLOW;
|
||||||
get repo() {
|
this.action = process.env.GITHUB_ACTION;
|
||||||
if (process.env.GITHUB_REPOSITORY) {
|
this.actor = process.env.GITHUB_ACTOR;
|
||||||
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
|
}
|
||||||
return { owner, repo };
|
get issue() {
|
||||||
}
|
const payload = this.payload;
|
||||||
if (this.payload.repository) {
|
return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pullRequest || payload).number });
|
||||||
return {
|
}
|
||||||
owner: this.payload.repository.owner.login,
|
get repo() {
|
||||||
repo: this.payload.repository.name
|
if (process.env.GITHUB_REPOSITORY) {
|
||||||
};
|
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
|
||||||
}
|
return { owner, repo };
|
||||||
throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'");
|
}
|
||||||
}
|
if (this.payload.repository) {
|
||||||
}
|
return {
|
||||||
exports.Context = Context;
|
owner: this.payload.repository.owner.login,
|
||||||
|
repo: this.payload.repository.name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Context = Context;
|
||||||
//# sourceMappingURL=context.js.map
|
//# sourceMappingURL=context.js.map
|
|
@ -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,CAAA;QACN,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAA2B,CAAA;QACxD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAoB,CAAA;QAC3C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAoB,CAAA;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAyB,CAAA;QACrD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAuB,CAAA;QACjD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAsB,CAAA;IACjD,CAAC;IAED,IAAI,KAAK;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAE5B,yBACK,IAAI,CAAC,IAAI,IACZ,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,CAAC,MAAM,IACjE;IACH,CAAC;IAED,IAAI,IAAI;QACN,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YACjC,MAAM,CAAC,KAAK,EAAE,IAAI,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;AAtDD,0BAsDC"}
|
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAEA,2BAA2C;AAC3C,2BAAsB;AAEtB,MAAa,OAAO;IAalB;;OAEG;IACH;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YACjC,IAAI,eAAU,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;gBAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CACvB,iBAAY,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAChE,CAAA;aACF;iBAAM;gBACL,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,qBACE,OAAO,CAAC,GAAG,CAAC,iBACd,kBAAkB,QAAG,EAAE,CACxB,CAAA;aACF;SACF;QACD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAA2B,CAAA;QACxD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAoB,CAAA;QAC3C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAoB,CAAA;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAyB,CAAA;QACrD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAuB,CAAA;QACjD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAsB,CAAA;IACjD,CAAC;IAED,IAAI,KAAK;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAE5B,uCACK,IAAI,CAAC,IAAI,KACZ,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,CAAC,MAAM,IACjE;IACH,CAAC;IAED,IAAI,IAAI;QACN,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YACjC,MAAM,CAAC,KAAK,EAAE,IAAI,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"}
|
|
@ -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';
|
||||||
export declare class GitHub extends Octokit {
|
import * as Context from './context';
|
||||||
graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>;
|
export declare const context: Context.Context;
|
||||||
constructor(token: string);
|
export declare class GitHub extends Octokit {
|
||||||
}
|
graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>;
|
||||||
|
constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>);
|
||||||
|
}
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
|
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
|
||||||
const graphql_1 = require("@octokit/graphql");
|
const graphql_1 = require("@octokit/graphql");
|
||||||
const rest_1 = __importDefault(require("@octokit/rest"));
|
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}` }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GitHub = GitHub;
|
exports.GitHub = GitHub;
|
||||||
//# sourceMappingURL=github.js.map
|
//# sourceMappingURL=github.js.map
|
|
@ -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"}
|
|
@ -1,36 +1,36 @@
|
||||||
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;
|
||||||
repository?: PayloadRepository;
|
repository?: PayloadRepository;
|
||||||
issue?: {
|
issue?: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
number: number;
|
number: number;
|
||||||
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?: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
type: string;
|
type: string;
|
||||||
};
|
};
|
||||||
action?: string;
|
action?: string;
|
||||||
installation?: {
|
installation?: {
|
||||||
id: number;
|
id: number;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//# sourceMappingURL=interfaces.js.map
|
//# sourceMappingURL=interfaces.js.map
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
@ -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 = {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
export declare function lowercaseKeys(object?: {
|
export declare function lowercaseKeys(object?: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}): {};
|
}): {
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export declare function mergeDeep(defaults: any, options: any): object;
|
|
@ -0,0 +1,3 @@
|
||||||
|
export declare function parseUrl(template: string): {
|
||||||
|
expand: (context: object) => string;
|
||||||
|
};
|
|
@ -1,233 +1,377 @@
|
||||||
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) => {
|
||||||
|
newObj[key.toLowerCase()] = object[key];
|
||||||
|
return newObj;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
return Object.keys(object).reduce((newObj, key) => {
|
function mergeDeep(defaults, options) {
|
||||||
newObj[key.toLowerCase()] = object[key];
|
const result = Object.assign({}, defaults);
|
||||||
return newObj;
|
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];
|
else {
|
||||||
|
options = route || {};
|
||||||
options = Object.assign(url ? {
|
}
|
||||||
method,
|
// lowercase header names before merging with defaults to avoid duplicates
|
||||||
url
|
options.headers = lowercaseKeys(options.headers);
|
||||||
} : {
|
const mergedOptions = mergeDeep(defaults || {}, options);
|
||||||
url: method
|
// mediaType.previews arrays are merged, instead of overwritten
|
||||||
}, options);
|
if (defaults && defaults.mediaType.previews.length) {
|
||||||
} else {
|
mergedOptions.mediaType.previews = defaults.mediaType.previews
|
||||||
options = route || {};
|
.filter(preview => !mergedOptions.mediaType.previews.includes(preview))
|
||||||
} // lowercase header names before merging with defaults to avoid duplicates
|
.concat(mergedOptions.mediaType.previews);
|
||||||
|
}
|
||||||
|
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, ""));
|
||||||
options.headers = lowercaseKeys(options.headers);
|
return mergedOptions;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, ""));
|
|
||||||
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 + separator + names.map(name => {
|
|
||||||
if (name === "q") {
|
|
||||||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
|
||||||
}
|
}
|
||||||
|
return (url +
|
||||||
return "".concat(name, "=").concat(encodeURIComponent(parameters[name]));
|
separator +
|
||||||
}).join("&");
|
names
|
||||||
|
.map(name => {
|
||||||
|
if (name === "q") {
|
||||||
|
return ("q=" +
|
||||||
|
parameters
|
||||||
|
.q.split("+")
|
||||||
|
.map(encodeURIComponent)
|
||||||
|
.join("+"));
|
||||||
|
}
|
||||||
|
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||||||
|
})
|
||||||
|
.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)
|
||||||
obj[key] = object[key];
|
.filter(option => !keysToOmit.includes(option))
|
||||||
return obj;
|
.reduce((obj, key) => {
|
||||||
}, {});
|
obj[key] = object[key];
|
||||||
|
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",
|
||||||
const urlVariableNames = extractUrlVariableNames(url);
|
"baseUrl",
|
||||||
url = urlTemplate.parse(url).expand(parameters);
|
"url",
|
||||||
|
"headers",
|
||||||
if (!/^http/.test(url)) {
|
"request",
|
||||||
url = options.baseUrl + url;
|
"mediaType"
|
||||||
}
|
]);
|
||||||
|
// extract variable names from URL to calculate remaining variables later
|
||||||
const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl");
|
const urlVariableNames = extractUrlVariableNames(url);
|
||||||
const remainingParameters = omit(parameters, omittedParameters);
|
url = parseUrl(url).expand(parameters);
|
||||||
const isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
|
if (!/^http/.test(url)) {
|
||||||
|
url = options.baseUrl + url;
|
||||||
if (!isBinaryRequset) {
|
|
||||||
if (options.mediaType.format) {
|
|
||||||
// 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(",");
|
|
||||||
}
|
}
|
||||||
|
const omittedParameters = Object.keys(options)
|
||||||
if (options.mediaType.previews.length) {
|
.filter(option => urlVariableNames.includes(option))
|
||||||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
.concat("baseUrl");
|
||||||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => {
|
const remainingParameters = omit(parameters, omittedParameters);
|
||||||
const format = options.mediaType.format ? ".".concat(options.mediaType.format) : "+json";
|
const isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
|
||||||
return "application/vnd.github.".concat(preview, "-preview").concat(format);
|
if (!isBinaryRequset) {
|
||||||
}).join(",");
|
if (options.mediaType.format) {
|
||||||
|
// 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.${options.mediaType.format}`))
|
||||||
|
.join(",");
|
||||||
|
}
|
||||||
|
if (options.mediaType.previews.length) {
|
||||||
|
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
||||||
|
headers.accept = previewsFromAcceptHeader
|
||||||
|
.concat(options.mediaType.previews)
|
||||||
|
.map(preview => {
|
||||||
|
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)) {
|
||||||
|
url = addQueryParameters(url, remainingParameters);
|
||||||
if (["GET", "HEAD"].includes(method)) {
|
|
||||||
url = addQueryParameters(url, remainingParameters);
|
|
||||||
} else {
|
|
||||||
if ("data" in remainingParameters) {
|
|
||||||
body = remainingParameters.data;
|
|
||||||
} else {
|
|
||||||
if (Object.keys(remainingParameters).length) {
|
|
||||||
body = remainingParameters;
|
|
||||||
} else {
|
|
||||||
headers["content-length"] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // default content-type for JSON if body is set
|
else {
|
||||||
|
if ("data" in remainingParameters) {
|
||||||
|
body = remainingParameters.data;
|
||||||
if (!headers["content-type"] && typeof body !== "undefined") {
|
}
|
||||||
headers["content-type"] = "application/json; charset=utf-8";
|
else {
|
||||||
} // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
|
if (Object.keys(remainingParameters).length) {
|
||||||
// fetch does not allow to set `content-length` header, but we can set body to an empty string
|
body = remainingParameters;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
headers["content-length"] = 0;
|
||||||
body = "";
|
}
|
||||||
} // Only return body/request keys if present
|
}
|
||||||
|
}
|
||||||
|
// default content-type for JSON if body is set
|
||||||
return Object.assign({
|
if (!headers["content-type"] && typeof body !== "undefined") {
|
||||||
method,
|
headers["content-type"] = "application/json; charset=utf-8";
|
||||||
url,
|
}
|
||||||
headers
|
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
|
||||||
}, typeof body !== "undefined" ? {
|
// fetch does not allow to set `content-length` header, but we can set body to an empty string
|
||||||
body
|
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||||||
} : null, options.request ? {
|
body = "";
|
||||||
request: options.request
|
}
|
||||||
} : null);
|
// Only return body/request keys if present
|
||||||
|
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) {
|
||||||
return parse(merge(defaults, route, options));
|
return parse(merge(defaults, route, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
function withDefaults(oldDefaults, newDefaults) {
|
function withDefaults(oldDefaults, newDefaults) {
|
||||||
const DEFAULTS = merge(oldDefaults, newDefaults);
|
const DEFAULTS = merge(oldDefaults, newDefaults);
|
||||||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
|
const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
|
||||||
return Object.assign(endpoint, {
|
return Object.assign(endpoint, {
|
||||||
DEFAULTS,
|
DEFAULTS,
|
||||||
defaults: withDefaults.bind(null, DEFAULTS),
|
defaults: withDefaults.bind(null, DEFAULTS),
|
||||||
merge: merge.bind(null, DEFAULTS),
|
merge: merge.bind(null, DEFAULTS),
|
||||||
parse
|
parse
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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",
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/vnd.github.v3+json",
|
accept: "application/vnd.github.v3+json",
|
||||||
"user-agent": userAgent
|
"user-agent": userAgent
|
||||||
},
|
},
|
||||||
mediaType: {
|
mediaType: {
|
||||||
format: "",
|
format: "",
|
||||||
previews: []
|
previews: []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const endpoint = withDefaults(null, DEFAULTS);
|
const endpoint = withDefaults(null, DEFAULTS);
|
||||||
|
|
||||||
export { endpoint };
|
export { endpoint };
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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
|
|
|
@ -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)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module.exports = getUserAgentBrowser
|
|
||||||
|
|
||||||
function getUserAgentBrowser () {
|
|
||||||
/* global navigator */
|
|
||||||
return navigator.userAgent
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"integrationFolder": "test",
|
|
||||||
"video": false
|
|
||||||
}
|
|
22
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-node/index.js
generated
vendored
Normal file
22
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-node/index.js
generated
vendored
Normal 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
|
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-node/index.js.map
generated
vendored
Normal 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;;;;;;"}
|
3
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-src/browser.js
generated
vendored
Normal file
3
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-src/browser.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function getUserAgent() {
|
||||||
|
return navigator.userAgent;
|
||||||
|
}
|
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-src/index.js
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-src/index.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { getUserAgent } from "./node";
|
12
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-src/node.js
generated
vendored
Normal file
12
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-src/node.js
generated
vendored
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-types/browser.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-types/browser.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export declare function getUserAgent(): string;
|
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-types/index.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { getUserAgent } from "./node";
|
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-types/node.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-types/node.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export declare function getUserAgent(): string;
|
6
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-web/index.js
generated
vendored
Normal file
6
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-web/index.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
function getUserAgent() {
|
||||||
|
return navigator.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { getUserAgent };
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/node_modules/universal-user-agent/dist-web/index.js.map
generated
vendored
Normal 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;;;;"}
|
|
@ -1 +0,0 @@
|
||||||
export default function getUserAgentNode(): string;
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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"
|
|
||||||
}
|
}
|
||||||
|
|
57
node_modules/@octokit/endpoint/node_modules/universal-user-agent/test/smoke-test.js
generated
vendored
57
node_modules/@octokit/endpoint/node_modules/universal-user-agent/test/smoke-test.js
generated
vendored
|
@ -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')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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, {
|
||||||
|
|
|
@ -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
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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
|
|
|
@ -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)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module.exports = getUserAgentBrowser
|
|
||||||
|
|
||||||
function getUserAgentBrowser () {
|
|
||||||
/* global navigator */
|
|
||||||
return navigator.userAgent
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"integrationFolder": "test",
|
|
||||||
"video": false
|
|
||||||
}
|
|
22
node_modules/@octokit/request/node_modules/universal-user-agent/dist-node/index.js
generated
vendored
Normal file
22
node_modules/@octokit/request/node_modules/universal-user-agent/dist-node/index.js
generated
vendored
Normal 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
|
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-node/index.js.map
generated
vendored
Normal 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;;;;;;"}
|
3
node_modules/@octokit/request/node_modules/universal-user-agent/dist-src/browser.js
generated
vendored
Normal file
3
node_modules/@octokit/request/node_modules/universal-user-agent/dist-src/browser.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function getUserAgent() {
|
||||||
|
return navigator.userAgent;
|
||||||
|
}
|
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-src/index.js
generated
vendored
Normal file
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-src/index.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { getUserAgent } from "./node";
|
12
node_modules/@octokit/request/node_modules/universal-user-agent/dist-src/node.js
generated
vendored
Normal file
12
node_modules/@octokit/request/node_modules/universal-user-agent/dist-src/node.js
generated
vendored
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-types/browser.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-types/browser.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export declare function getUserAgent(): string;
|
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-types/index.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { getUserAgent } from "./node";
|
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-types/node.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-types/node.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export declare function getUserAgent(): string;
|
6
node_modules/@octokit/request/node_modules/universal-user-agent/dist-web/index.js
generated
vendored
Normal file
6
node_modules/@octokit/request/node_modules/universal-user-agent/dist-web/index.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
function getUserAgent() {
|
||||||
|
return navigator.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { getUserAgent };
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/request/node_modules/universal-user-agent/dist-web/index.js.map
generated
vendored
Normal 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;;;;"}
|
|
@ -1 +0,0 @@
|
||||||
export default function getUserAgentNode(): string;
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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"
|
|
||||||
}
|
}
|
||||||
|
|
57
node_modules/@octokit/request/node_modules/universal-user-agent/test/smoke-test.js
generated
vendored
57
node_modules/@octokit/request/node_modules/universal-user-agent/test/smoke-test.js
generated
vendored
|
@ -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')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
|
@ -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 GitHub’s APIs with sensible defaults in browsers and Node",
|
"description": "Send parameterized requests to GitHub’s 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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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
|
|
|
@ -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)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module.exports = getUserAgentBrowser
|
|
||||||
|
|
||||||
function getUserAgentBrowser () {
|
|
||||||
/* global navigator */
|
|
||||||
return navigator.userAgent
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"integrationFolder": "test",
|
|
||||||
"video": false
|
|
||||||
}
|
|
22
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-node/index.js
generated
vendored
Normal file
22
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-node/index.js
generated
vendored
Normal 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
|
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-node/index.js.map
generated
vendored
Normal 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;;;;;;"}
|
3
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-src/browser.js
generated
vendored
Normal file
3
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-src/browser.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function getUserAgent() {
|
||||||
|
return navigator.userAgent;
|
||||||
|
}
|
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-src/index.js
generated
vendored
Normal file
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-src/index.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { getUserAgent } from "./node";
|
12
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-src/node.js
generated
vendored
Normal file
12
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-src/node.js
generated
vendored
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-types/browser.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-types/browser.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export declare function getUserAgent(): string;
|
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-types/index.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-types/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { getUserAgent } from "./node";
|
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-types/node.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-types/node.d.ts
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export declare function getUserAgent(): string;
|
6
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-web/index.js
generated
vendored
Normal file
6
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-web/index.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
function getUserAgent() {
|
||||||
|
return navigator.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { getUserAgent };
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/rest/node_modules/universal-user-agent/dist-web/index.js.map
generated
vendored
Normal 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;;;;"}
|
|
@ -1 +0,0 @@
|
||||||
export default function getUserAgentNode(): string;
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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"
|
|
||||||
}
|
}
|
||||||
|
|
57
node_modules/@octokit/rest/node_modules/universal-user-agent/test/smoke-test.js
generated
vendored
57
node_modules/@octokit/rest/node_modules/universal-user-agent/test/smoke-test.js
generated
vendored
|
@ -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')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue