mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IBinaryData,
|
||||
@@ -11,11 +9,7 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
readFile,
|
||||
rm,
|
||||
writeFile,
|
||||
} from 'fs/promises';
|
||||
import { readFile, rm, writeFile } from 'fs/promises';
|
||||
|
||||
import { file } from 'tmp-promise';
|
||||
|
||||
@@ -42,9 +36,7 @@ export class Ssh implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'password',
|
||||
],
|
||||
authentication: ['password'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -53,9 +45,7 @@ export class Ssh implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'privateKey',
|
||||
],
|
||||
authentication: ['privateKey'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -101,9 +91,7 @@ export class Ssh implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'command',
|
||||
],
|
||||
resource: ['command'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -122,12 +110,8 @@ export class Ssh implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'command',
|
||||
],
|
||||
operation: [
|
||||
'execute',
|
||||
],
|
||||
resource: ['command'],
|
||||
operation: ['execute'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -139,12 +123,8 @@ export class Ssh implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'command',
|
||||
],
|
||||
operation: [
|
||||
'execute',
|
||||
],
|
||||
resource: ['command'],
|
||||
operation: ['execute'],
|
||||
},
|
||||
},
|
||||
default: '/',
|
||||
@@ -157,9 +137,7 @@ export class Ssh implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -186,16 +164,13 @@ export class Ssh implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
placeholder: '',
|
||||
description: 'Name of the binary property which contains the data for the file to be uploaded',
|
||||
description:
|
||||
'Name of the binary property which contains the data for the file to be uploaded',
|
||||
},
|
||||
{
|
||||
displayName: 'Target Directory',
|
||||
@@ -203,48 +178,38 @@ export class Ssh implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
required: true,
|
||||
placeholder: '/home/user',
|
||||
description: 'The directory to upload the file to. The name of the file does not need to be specified, it\'s taken from the binary data file name. To override this behavior, set the parameter "File Name" under options.',
|
||||
description:
|
||||
'The directory to upload the file to. The name of the file does not need to be specified, it\'s taken from the binary data file name. To override this behavior, set the parameter "File Name" under options.',
|
||||
},
|
||||
{
|
||||
displayName: 'Path',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['download'],
|
||||
},
|
||||
},
|
||||
name: 'path',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '/home/user/invoice.txt',
|
||||
description: 'The file path of the file to download. Has to contain the full path including file name.',
|
||||
description:
|
||||
'The file path of the file to download. Has to contain the full path including file name.',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Binary Property',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['download'],
|
||||
},
|
||||
},
|
||||
name: 'binaryPropertyName',
|
||||
@@ -260,12 +225,8 @@ export class Ssh implements INodeType {
|
||||
placeholder: 'Add Option',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -297,7 +258,6 @@ export class Ssh implements INodeType {
|
||||
|
||||
try {
|
||||
if (authentication === 'password') {
|
||||
|
||||
const credentials = await this.getCredentials('sshPassword');
|
||||
|
||||
await ssh.connect({
|
||||
@@ -306,12 +266,10 @@ export class Ssh implements INodeType {
|
||||
port: credentials.port as number,
|
||||
password: credentials.password as string,
|
||||
});
|
||||
|
||||
} else if (authentication === 'privateKey') {
|
||||
|
||||
const credentials = await this.getCredentials('sshPrivateKey');
|
||||
|
||||
const { path, } = await file({ prefix: 'n8n-ssh-' });
|
||||
const { path } = await file({ prefix: 'n8n-ssh-' });
|
||||
temporaryFiles.push(path);
|
||||
await writeFile(path, credentials.privateKey as string);
|
||||
|
||||
@@ -332,13 +290,11 @@ export class Ssh implements INodeType {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
if (resource === 'command') {
|
||||
|
||||
if (operation === 'execute') {
|
||||
|
||||
const command = this.getNodeParameter('command', i) as string;
|
||||
const cwd = this.getNodeParameter('cwd', i) as string;
|
||||
returnItems.push({
|
||||
json: await ssh.execCommand(command, { cwd, }),
|
||||
json: await ssh.execCommand(command, { cwd }),
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
@@ -347,10 +303,11 @@ export class Ssh implements INodeType {
|
||||
}
|
||||
|
||||
if (resource === 'file') {
|
||||
|
||||
if (operation === 'download') {
|
||||
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
i,
|
||||
) as string;
|
||||
const parameterPath = this.getNodeParameter('path', i) as string;
|
||||
|
||||
const { path } = await file({ prefix: 'n8n-ssh-' });
|
||||
@@ -377,18 +334,22 @@ export class Ssh implements INodeType {
|
||||
|
||||
const data = await readFile(path as string);
|
||||
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data, parameterPath);
|
||||
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
|
||||
data,
|
||||
parameterPath,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'upload') {
|
||||
|
||||
const parameterPath = this.getNodeParameter('path', i) as string;
|
||||
const fileName = this.getNodeParameter('options.fileName', i, '') as string;
|
||||
|
||||
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 propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
@@ -396,7 +357,11 @@ export class Ssh implements INodeType {
|
||||
const binaryData = item.binary[propertyNameUpload] as IBinaryData;
|
||||
|
||||
if (item.binary[propertyNameUpload] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${propertyNameUpload}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const dataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload);
|
||||
@@ -405,7 +370,12 @@ export class Ssh implements INodeType {
|
||||
temporaryFiles.push(path);
|
||||
await writeFile(path, dataBuffer);
|
||||
|
||||
await ssh.putFile(path, `${parameterPath}${(parameterPath.charAt(parameterPath.length - 1) === '/') ? '' : '/'}${fileName || binaryData.fileName}`);
|
||||
await ssh.putFile(
|
||||
path,
|
||||
`${parameterPath}${
|
||||
parameterPath.charAt(parameterPath.length - 1) === '/' ? '' : '/'
|
||||
}${fileName || binaryData.fileName}`,
|
||||
);
|
||||
|
||||
returnItems.push({
|
||||
json: {
|
||||
|
||||
Reference in New Issue
Block a user