Minor improvements to TravisCi-Node

This commit is contained in:
Jan Oberhauser 2020-08-04 15:53:34 +02:00
parent 3dfa55d850
commit 26f3f949aa
4 changed files with 28 additions and 23 deletions

View file

@ -48,9 +48,9 @@ export const buildOperations = [
export const buildFields = [ export const buildFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* build:cancel */ /* build:cancel */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Build ID', displayName: 'Build ID',
name: 'buildId', name: 'buildId',
@ -68,9 +68,10 @@ export const buildFields = [
default: '', default: '',
description: 'Value uniquely identifying the build.', description: 'Value uniquely identifying the build.',
}, },
/* -------------------------------------------------------------------------- */
/* build:get */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* build:get */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Build ID', displayName: 'Build ID',
name: 'buildId', name: 'buildId',
@ -115,9 +116,10 @@ export const buildFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* build:getAll */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* build:getAll */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Return All', displayName: 'Return All',
name: 'returnAll', name: 'returnAll',
@ -235,9 +237,10 @@ export const buildFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* build:restart */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* build:restart */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Build ID', displayName: 'Build ID',
name: 'buildId', name: 'buildId',
@ -255,9 +258,10 @@ export const buildFields = [
default: '', default: '',
description: 'Value uniquely identifying the build.', description: 'Value uniquely identifying the build.',
}, },
/* -------------------------------------------------------------------------- */
/* build:trigger */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* build:trigger */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Slug', displayName: 'Slug',
name: 'slug', name: 'slug',
@ -272,6 +276,7 @@ export const buildFields = [
], ],
}, },
}, },
placeholder: 'n8n-io/n8n',
default: '', default: '',
description: 'Same as {ownerName}/{repositoryName}', description: 'Same as {ownerName}/{repositoryName}',
}, },

View file

@ -15,9 +15,9 @@ import {
import { import {
get, get,
} from 'lodash'; } from 'lodash';
import * as querystring from 'querystring'; import * as querystring from 'querystring';
export async function travisciApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function travisciApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('travisCiApi'); const credentials = this.getCredentials('travisCiApi');
@ -34,7 +34,7 @@ export async function travisciApiRequest(this: IHookFunctions | IExecuteFunction
method, method,
qs, qs,
body, body,
uri: uri ||`https://api.travis-ci.com${resource}`, uri: uri || `https://api.travis-ci.com${resource}`,
json: true json: true
}; };
options = Object.assign({}, options, option); options = Object.assign({}, options, option);
@ -58,7 +58,7 @@ export async function travisciApiRequest(this: IHookFunctions | IExecuteFunction
* Make an API request to paginated TravisCI endpoint * Make an API request to paginated TravisCI endpoint
* and return all results * and return all results
*/ */
export async function travisciApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function travisciApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];

View file

@ -23,14 +23,14 @@ export class TravisCi implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {
displayName: 'TravisCI', displayName: 'TravisCI',
name: 'travisCi', name: 'travisCi',
icon: 'file:travisCi.png', icon: 'file:travisci.png',
group: ['output'], group: ['output'],
version: 1, version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume TravisCI API', description: 'Consume TravisCI API',
defaults: { defaults: {
name: 'TravisCI', name: 'TravisCI',
color: '#FF0000', color: '#666666',
}, },
inputs: ['main'], inputs: ['main'],
outputs: ['main'], outputs: ['main'],
@ -126,7 +126,7 @@ export class TravisCi implements INodeType {
slug = slug.replace(new RegExp(/\//g), '%2F'); slug = slug.replace(new RegExp(/\//g), '%2F');
const request: IDataObject = { const request: IDataObject = {
branch, branch,
}; };
if (additionalFields.message) { if (additionalFields.message) {
@ -137,7 +137,7 @@ export class TravisCi implements INodeType {
request.merge_mode = additionalFields.mergeMode as string; request.merge_mode = additionalFields.mergeMode as string;
} }
responseData = await travisciApiRequest.call(this, 'POST', `/repo/${slug}/requests`, JSON.stringify({request})); responseData = await travisciApiRequest.call(this, 'POST', `/repo/${slug}/requests`, JSON.stringify({ request }));
} }
} }
if (Array.isArray(responseData)) { if (Array.isArray(responseData)) {

View file

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB