n8n-3867-progressively-apply-prettier-to-all (#3873)

* 🔨 formatting nodes with prettier
This commit is contained in:
Michael Kret
2022-08-17 18:50:24 +03:00
committed by GitHub
parent f2d326c7f0
commit 91d7e16c81
1072 changed files with 42357 additions and 59109 deletions

View File

@@ -1,13 +1,8 @@
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
IHookFunctions,
} from 'n8n-core';
import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
import {
IDataObject, NodeApiError, NodeOperationError,
} from 'n8n-workflow';
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
/**
* Make an API request to Github
@@ -18,8 +13,15 @@ import {
* @param {object} body
* @returns {Promise<any>}
*/
export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function githubApiRequest(
this: IHookFunctions | IExecuteFunctions,
method: string,
endpoint: string,
body: object,
query?: object,
option: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const options: OptionsWithUri = {
method,
headers: {
@@ -36,7 +38,11 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
}
try {
const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string;
const authenticationMethod = this.getNodeParameter(
'authentication',
0,
'accessToken',
) as string;
let credentialType = '';
if (authenticationMethod === 'accessToken') {
@@ -59,8 +65,6 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
}
}
/**
* Returns the SHA of the given file
*
@@ -72,7 +76,14 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
* @param {string} [branch]
* @returns {Promise<any>}
*/
export async function getFileSha(this: IHookFunctions | IExecuteFunctions, owner: string, repository: string, filePath: string, branch?: string): Promise<any> { // tslint:disable-line:no-any
export async function getFileSha(
this: IHookFunctions | IExecuteFunctions,
owner: string,
repository: string,
filePath: string,
branch?: string,
// tslint:disable-next-line:no-any
): Promise<any> {
const getBody: IDataObject = {};
if (branch !== undefined) {
getBody.branch = branch;
@@ -86,8 +97,15 @@ export async function getFileSha(this: IHookFunctions | IExecuteFunctions, owner
return responseData.sha;
}
export async function githubApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function githubApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
@@ -96,11 +114,11 @@ export async function githubApiRequestAllItems(this: IHookFunctions | IExecuteFu
query.page = 1;
do {
responseData = await githubApiRequest.call(this, method, endpoint, body, query, { resolveWithFullResponse: true });
responseData = await githubApiRequest.call(this, method, endpoint, body, query, {
resolveWithFullResponse: true,
});
query.page++;
returnData.push.apply(returnData, responseData.body);
} while (
responseData.headers.link && responseData.headers.link.includes('next')
);
} while (responseData.headers.link && responseData.headers.link.includes('next'));
return returnData;
}

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -10,15 +8,9 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
getFileSha,
githubApiRequest,
githubApiRequestAllItems,
} from './GenericFunctions';
import { getFileSha, githubApiRequest, githubApiRequestAllItems } from './GenericFunctions';
import {
snakeCase,
} from 'change-case';
import { snakeCase } from 'change-case';
export class Github implements INodeType {
description: INodeTypeDescription = {
@@ -249,7 +241,8 @@ export class Github implements INodeType {
{
name: 'Get License',
value: 'getLicense',
description: 'Returns the contents of the repository\'s license file, if one is detected',
description:
"Returns the contents of the repository's license file, if one is detected",
action: 'Get the license of a repository',
},
{
@@ -290,7 +283,7 @@ export class Github implements INodeType {
name: 'Get Repositories',
value: 'getRepositories',
description: 'Returns the repositories of a user',
action: 'Get a user\'s repositories',
action: "Get a user's repositories",
},
{
name: 'Invite',
@@ -1026,8 +1019,7 @@ export class Github implements INodeType {
name: 'prerelease',
type: 'boolean',
default: false,
description:
'Whether to point out that the release is non-production ready',
description: 'Whether to point out that the release is non-production ready',
},
{
displayName: 'Target Commitish',
@@ -1035,7 +1027,7 @@ export class Github implements INodeType {
type: 'string',
default: '',
description:
'Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository\'s default branch(usually master).',
"Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch(usually master).",
},
],
},
@@ -1105,8 +1097,7 @@ export class Github implements INodeType {
name: 'prerelease',
type: 'boolean',
default: false,
description:
'Whether to point out that the release is non-production ready',
description: 'Whether to point out that the release is non-production ready',
},
{
displayName: 'Tag Name',
@@ -1121,7 +1112,7 @@ export class Github implements INodeType {
type: 'string',
default: '',
description:
'Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository\'s default branch(usually master).',
"Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch(usually master).",
},
],
},
@@ -1741,7 +1732,9 @@ export class Github implements INodeType {
const item = items[i];
if (item.binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
itemIndex: i,
});
}
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
@@ -2104,7 +2097,9 @@ export class Github implements INodeType {
}
}
} else {
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i });
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, {
itemIndex: i,
});
}
if (returnAll === true) {
@@ -2124,7 +2119,9 @@ export class Github implements INodeType {
if (asBinaryProperty === true) {
if (Array.isArray(responseData)) {
throw new NodeOperationError(this.getNode(), 'File Path is a folder, not a file.', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'File Path is a folder, not a file.', {
itemIndex: i,
});
}
// Add the returned data to the item as binary property
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;

View File

@@ -1,7 +1,4 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
import {
IDataObject,
@@ -12,10 +9,7 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
githubApiRequest,
} from './GenericFunctions';
import { githubApiRequest } from './GenericFunctions';
export class GithubTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -24,7 +18,8 @@ export class GithubTrigger implements INodeType {
icon: 'file:github.svg',
group: ['trigger'],
version: 1,
subtitle: '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}',
subtitle:
'={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}',
description: 'Starts the workflow when Github events occur',
defaults: {
name: 'Github Trigger',
@@ -37,9 +32,7 @@ export class GithubTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'accessToken',
],
authentication: ['accessToken'],
},
},
},
@@ -48,9 +41,7 @@ export class GithubTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -111,7 +102,8 @@ export class GithubTrigger implements INodeType {
{
name: 'Check Run',
value: 'check_run',
description: 'Triggered when a check run is created, rerequested, completed, or has a requested_action',
description:
'Triggered when a check run is created, rerequested, completed, or has a requested_action',
},
{
name: 'Check Suite',
@@ -126,7 +118,8 @@ export class GithubTrigger implements INodeType {
{
name: 'Content Reference',
value: 'content_reference',
description: 'Triggered when the body or comment of an issue or pull request includes a URL that matches a configured content reference domain. Only GitHub Apps can receive this event.',
description:
'Triggered when the body or comment of an issue or pull request includes a URL that matches a configured content reference domain. Only GitHub Apps can receive this event.',
},
{
name: 'Create',
@@ -171,7 +164,8 @@ export class GithubTrigger implements INodeType {
{
name: 'Installation',
value: 'installation',
description: 'Triggered when someone installs (created), uninstalls (deleted), or accepts new permissions (new_permissions_accepted) for a GitHub App. When a GitHub App owner requests new permissions, the person who installed the GitHub App must accept the new permissions request.',
description:
'Triggered when someone installs (created), uninstalls (deleted), or accepts new permissions (new_permissions_accepted) for a GitHub App. When a GitHub App owner requests new permissions, the person who installed the GitHub App must accept the new permissions request.',
},
{
name: 'Installation Repositories',
@@ -186,27 +180,31 @@ export class GithubTrigger implements INodeType {
{
name: 'Issues',
value: 'issues',
description: 'Triggered when an issue is opened, edited, deleted, transferred, pinned, unpinned, closed, reopened, assigned, unassigned, labeled, unlabeled, locked, unlocked, milestoned, or demilestoned',
description:
'Triggered when an issue is opened, edited, deleted, transferred, pinned, unpinned, closed, reopened, assigned, unassigned, labeled, unlabeled, locked, unlocked, milestoned, or demilestoned',
},
{
name: 'Label',
value: 'label',
description: 'Triggered when a repository\'s label is created, edited, or deleted',
description: "Triggered when a repository's label is created, edited, or deleted",
},
{
name: 'Marketplace Purchase',
value: 'marketplace_purchase',
description: 'Triggered when someone purchases a GitHub Marketplace plan, cancels their plan, upgrades their plan (effective immediately), downgrades a plan that remains pending until the end of the billing cycle, or cancels a pending plan change',
description:
'Triggered when someone purchases a GitHub Marketplace plan, cancels their plan, upgrades their plan (effective immediately), downgrades a plan that remains pending until the end of the billing cycle, or cancels a pending plan change',
},
{
name: 'Member',
value: 'member',
description: 'Triggered when a user accepts an invitation or is removed as a collaborator to a repository, or has their permissions changed',
description:
'Triggered when a user accepts an invitation or is removed as a collaborator to a repository, or has their permissions changed',
},
{
name: 'Membership',
value: 'membership',
description: 'Triggered when a user is added or removed from a team. Organization hooks only.',
description:
'Triggered when a user is added or removed from a team. Organization hooks only.',
},
{
name: 'Meta',
@@ -216,32 +214,38 @@ export class GithubTrigger implements INodeType {
{
name: 'Milestone',
value: 'milestone',
description: 'Triggered when a milestone is created, closed, opened, edited, or deleted',
description:
'Triggered when a milestone is created, closed, opened, edited, or deleted',
},
{
name: 'Org Block',
value: 'org_block',
description: 'Triggered when an organization blocks or unblocks a user. Organization hooks only.',
description:
'Triggered when an organization blocks or unblocks a user. Organization hooks only.',
},
{
name: 'Organization',
value: 'organization',
description: 'Triggered when an organization is deleted and renamed, and when a user is added, removed, or invited to an organization. Organization hooks only.',
description:
'Triggered when an organization is deleted and renamed, and when a user is added, removed, or invited to an organization. Organization hooks only.',
},
{
name: 'Page Build',
value: 'page_build',
description: 'Triggered on push to a GitHub Pages enabled branch (gh-pages for project pages, master for user and organization pages)',
description:
'Triggered on push to a GitHub Pages enabled branch (gh-pages for project pages, master for user and organization pages)',
},
{
name: 'Project',
value: 'project',
description: 'Triggered when a project is created, updated, closed, reopened, or deleted',
description:
'Triggered when a project is created, updated, closed, reopened, or deleted',
},
{
name: 'Project Card',
value: 'project_card',
description: 'Triggered when a project card is created, edited, moved, converted to an issue, or deleted',
description:
'Triggered when a project card is created, edited, moved, converted to an issue, or deleted',
},
{
name: 'Project Column',
@@ -256,37 +260,44 @@ export class GithubTrigger implements INodeType {
{
name: 'Pull Request',
value: 'pull_request',
description: 'Triggered when a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, locked, unlocked, a pull request review is requested, or a review request is removed',
description:
'Triggered when a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, locked, unlocked, a pull request review is requested, or a review request is removed',
},
{
name: 'Pull Request Review',
value: 'pull_request_review',
description: 'Triggered when a pull request review is submitted into a non-pending state, the body is edited, or the review is dismissed',
description:
'Triggered when a pull request review is submitted into a non-pending state, the body is edited, or the review is dismissed',
},
{
name: 'Pull Request Review Comment',
value: 'pull_request_review_comment',
description: 'Triggered when a comment on a pull request\'s unified diff is created, edited, or deleted (in the Files Changed tab)',
description:
"Triggered when a comment on a pull request's unified diff is created, edited, or deleted (in the Files Changed tab)",
},
{
name: 'Push',
value: 'push',
description: 'Triggered on a push to a repository branch. Branch pushes and repository tag pushes also trigger webhook push events. This is the default event.',
description:
'Triggered on a push to a repository branch. Branch pushes and repository tag pushes also trigger webhook push events. This is the default event.',
},
{
name: 'Release',
value: 'release',
description: 'Triggered when a release is published, unpublished, created, edited, deleted, or prereleased',
description:
'Triggered when a release is published, unpublished, created, edited, deleted, or prereleased',
},
{
name: 'Repository',
value: 'repository',
description: 'Triggered when a repository is created, archived, unarchived, renamed, edited, transferred, made public, or made private. Organization hooks are also triggered when a repository is deleted.',
description:
'Triggered when a repository is created, archived, unarchived, renamed, edited, transferred, made public, or made private. Organization hooks are also triggered when a repository is deleted.',
},
{
name: 'Repository Import',
value: 'repository_import',
description: 'Triggered when a successful, cancelled, or failed repository import finishes for a GitHub organization or a personal repository',
description:
'Triggered when a successful, cancelled, or failed repository import finishes for a GitHub organization or a personal repository',
},
{
name: 'Repository Vulnerability Alert',
@@ -296,7 +307,8 @@ export class GithubTrigger implements INodeType {
{
name: 'Security Advisory',
value: 'security_advisory',
description: 'Triggered when a new security advisory is published, updated, or withdrawn',
description:
'Triggered when a new security advisory is published, updated, or withdrawn',
},
{
name: 'Star',
@@ -311,7 +323,8 @@ export class GithubTrigger implements INodeType {
{
name: 'Team',
value: 'team',
description: 'Triggered when an organization\'s team is created, deleted, edited, added_to_repository, or removed_from_repository. Organization hooks only.',
description:
"Triggered when an organization's team is created, deleted, edited, added_to_repository, or removed_from_repository. Organization hooks only.",
},
{
name: 'Team Add',
@@ -369,7 +382,10 @@ export class GithubTrigger implements INodeType {
const webhookUrl = this.getNodeWebhookUrl('default') as string;
if (webhookUrl.includes('//localhost')) {
throw new NodeOperationError(this.getNode(), 'The Webhook can not work on "localhost". Please, either setup n8n on a custom domain or start with "--tunnel"!');
throw new NodeOperationError(
this.getNode(),
'The Webhook can not work on "localhost". Please, either setup n8n on a custom domain or start with "--tunnel"!',
);
}
const owner = this.getNodeParameter('owner') as string;
@@ -415,7 +431,10 @@ export class GithubTrigger implements INodeType {
}
}
throw new NodeOperationError(this.getNode(), 'A webhook with the identical URL probably exists already. Please delete it manually on Github!');
throw new NodeOperationError(
this.getNode(),
'A webhook with the identical URL probably exists already. Please delete it manually on Github!',
);
}
throw error;
@@ -423,7 +442,9 @@ export class GithubTrigger implements INodeType {
if (responseData.id === undefined || responseData.active !== true) {
// Required data is missing so was not successful
throw new NodeApiError(this.getNode(), responseData, { message: 'Github webhook creation response did not contain the expected data.' });
throw new NodeApiError(this.getNode(), responseData, {
message: 'Github webhook creation response did not contain the expected data.',
});
}
webhookData.webhookId = responseData.id as string;
@@ -457,8 +478,6 @@ export class GithubTrigger implements INodeType {
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData();
@@ -477,18 +496,14 @@ export class GithubTrigger implements INodeType {
// TODO: Add headers & requestPath
const returnData: IDataObject[] = [];
returnData.push(
{
body: bodyData,
headers: this.getHeaderData(),
query: this.getQueryData(),
},
);
returnData.push({
body: bodyData,
headers: this.getHeaderData(),
query: this.getQueryData(),
});
return {
workflowData: [
this.helpers.returnJsonArray(returnData),
],
workflowData: [this.helpers.returnJsonArray(returnData)],
};
}
}