<commit_before>'use babel';

import FS from 'fs-plus';
import Path from 'path';
import { $ } from 'atom-space-pen-views';
import {
  hasProject,
  getObject,
} from '../helpers';

import File from '../file';
import Directory from '../directory';
import DirectoryView from '../views/directory-view';
import AddDialog from '../dialogs/add-dialog';
import MoveDialog from '../dialogs/move-dialog';
import NavigateTo from '../dialogs/navigate-to-dialog';


const init = function INIT() {
  const atom = global.atom;
  const client = atom.project.divinefingers;
  const divinefingers = atom.project['divinefingers-main'];
  const getRemotes = function GETREMOTES(errMessage) {
    const remotes = divinefingers.treeView.getSelected();

    if (!remotes || remotes.length === 0) {
      atom.notifications.addWarning(`${errMessage}`, {
        dismissable: false,
      });
      return false;
    }

    return remotes;
  };

  const createConfig = function CREATECONFIG(obj) {
    if (!hasProject()) return;

    const ftpConfigPath = client.getConfigPath();
    const fileExists = FS.existsSync(ftpConfigPath);
    const json = JSON.stringify(obj, null, 4);

    let writeFile = true;
    if (fileExists) {
      writeFile = atom.confirm({
        message: 'Do you want to overwrite .ftpconfig?',
        detailedMessage: `You are overwriting ${ftpConfigPath}`,
        buttons: {
          Yes: () => true,
          No: () => false,
        },
      });
    }
    if (writeFile) {
      FS.writeFile(ftpConfigPath, json, (err) => {
        if (!err) atom.workspace.open(ftpConfigPath);
      });
    }
  };


  const commands = {
    'divinefingers:create-ftp-config': {
      enabled: true,
      command() {
        createConfig({
          protocol: 'ftp',
          host: 'example.com',
          port: 21,
          user: 'user',
          pass: '<PASSWORD>',
          promptForPass: false,
          remote: '/',
          local: '',
          secure: false,
          secureOptions: null,
          connTimeout: 10000,
          pasvTimeout: 10000,
          keepalive: 10000,
          watch: [],
          watchTimeout: 500,
        });
      },
    },
    'divinefingers:create-sftp-config': {
      enabled: true,
      command() {
        createConfig({
          protocol: 'sftp',
          host: 'example.com',
          port: 22,
          user: 'user',
          pass: '<PASSWORD>',
          promptForPass: false,
          remote: '/',
          local: '',
          agent: '',
          privatekey: '',
          passphrase: '',
          hosthash: '',
          ignorehost: true,
          connTimeout: 10000,
          keepalive: 10000,
          keyboardInteractive: false,
          watch: [],
          watchTimeout: 500,
        });
      },
    },
    'divinefingers:create-ignore-file': {
      enabled: true,
      command() {<commit_msg>Update default SFTP config<commit_after>'use babel';

import FS from 'fs-plus';
import Path from 'path';
import { $ } from 'atom-space-pen-views';
import {
  hasProject,
  getObject,
} from '../helpers';

import File from '../file';
import Directory from '../directory';
import DirectoryView from '../views/directory-view';
import AddDialog from '../dialogs/add-dialog';
import MoveDialog from '../dialogs/move-dialog';
import NavigateTo from '../dialogs/navigate-to-dialog';


const init = function INIT() {
  const atom = global.atom;
  const client = atom.project.divinefingers;
  const divinefingers = atom.project['divinefingers-main'];
  const getRemotes = function GETREMOTES(errMessage) {
    const remotes = divinefingers.treeView.getSelected();

    if (!remotes || remotes.length === 0) {
      atom.notifications.addWarning(`${errMessage}`, {
        dismissable: false,
      });
      return false;
    }

    return remotes;
  };

  const createConfig = function CREATECONFIG(obj) {
    if (!hasProject()) return;

    const ftpConfigPath = client.getConfigPath();
    const fileExists = FS.existsSync(ftpConfigPath);
    const json = JSON.stringify(obj, null, 4);

    let writeFile = true;
    if (fileExists) {
      writeFile = atom.confirm({
        message: 'Do you want to overwrite .ftpconfig?',
        detailedMessage: `You are overwriting ${ftpConfigPath}`,
        buttons: {
          Yes: () => true,
          No: () => false,
        },
      });
    }
    if (writeFile) {
      FS.writeFile(ftpConfigPath, json, (err) => {
        if (!err) atom.workspace.open(ftpConfigPath);
      });
    }
  };


  const commands = {
    'divinefingers:create-ftp-config': {
      enabled: true,
      command() {
        createConfig({
          protocol: 'ftp',
          host: 'example.com',
          port: 21,
          user: 'user',
          pass: '<PASSWORD>',
          promptForPass: false,
          remote: '/',
          local: '',
          secure: false,
          secureOptions: null,
          connTimeout: 10000,
          pasvTimeout: 10000,
          keepalive: 10000,
          watch: [],
          watchTimeout: 500,
        });
      },
    },
    'divinefingers:create-sftp-config': {
      enabled: true,
      command() {
        createConfig({
          protocol: 'sftp',
          host: 'example.com',
          port: 22,
          user: 'user',
          pass: '<PASSWORD>',
          promptForPass: false,
          remote: '/',
          local: '',
          bundle: '',
          agent: '',
          privatekey: '',
          passphrase: '',
          hosthash: '',
          ignorehost: true,
          connTimeout: 2000,
          keepalive: 4000,
          keyboardInteractive: false,
          watch: [],
          watchTimeout: 500,
        });
      },
    },
    'divinefingers:create-ignore-file': {
      enabled: true,
      command() {
{'fraction_non_alphanumeric': 0.13842150910667822, 'fraction_numerical': 0.01248915871639202, 'mean_word_length': 2.025183630640084, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7019269', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1662, 'n_words': 394}