Code Monkey home page Code Monkey logo

swiff's Introduction

Swiff

npm version

Swiff saves you time with common SSH tasks during the development of websites/apps

πŸš€ Folder push and pull
Keep folders in sync between servers

πŸ’« Database push and pull
Manage the database between servers (auto backup)

🎩 Composer file push and pull
Move composer files between servers (auto backup)

πŸ’» Remote terminal connection
Launch a SSH session directly into the remote site/app folder

Getting started

  1. Install Swiff globally with npm:
    npm install --global swiff

  2. Run swiff within a project folder to start the task interface

Run swiff --help for a list of flags to run a specific task

Additional features

  • Custom SSH identity: Swiff will attempt to use your identity located at: /Users/[currentUser]/.ssh/id_rsa
    You can specify a custom SSH key path in your .env file with:
    SWIFF_CUSTOM_KEY="/Users/[your-user]/.ssh/[key-filename]"
  • Gzipped backups: Your files and database get backed up and gzipped whenever they change
  • Disable specific tasks: Specify the tasks to disable with a config setting

Requirements

Swiff requires MySQL to use the database features. We recommend using MariaDB, an enhanced, drop-in replacement for MySQL. brew install [email protected] (latest as of April 2019)

For the Database & Composer tasks, a PEM format SSH key is required
Read about how to create and add a new SSH key

Running Windows or Linux? Swiff has been tested on macOS so issues are likely on other operating systems

Technology

  • Node.js - A JavaScript runtime built on Chrome's V8 JavaScript engine
  • Ink 2 - React for interactive command-line apps
  • Babel - JavaScript transpiling
  • Prettier - Code cleaning

Credits

Sounds by Emoji Sounds
Created by @benrogerson and Sam Stevens

Swiff has been agency battletested by Simple who specialise in Craft CMS websites

swiff's People

Contributors

ben-rogerson avatar bighoho123 avatar chrisrowe avatar dependabot-preview[bot] avatar dependabot[bot] avatar loilo avatar samstevens avatar simpleim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swiff's Issues

Add a pre-push to production confirmation

Pushing to production isn't the safest / best thing to do so I'm thinking of adding 'are you sure' prompt before it sync up the files.
That'll make it harder to accidentally ruin your week :)

I'm getting: "TypeError: ssh.dispose is not a function"

After installing Swiff and setting up the config, I received an error when running Pull, Push and Database. It says "Performing pre-task checks" and then fails with this message:

TypeError: ssh.dispose is not a function
    at /Users/matthewblode/.nvm/versions/node/v11.7.0/lib/node_modules/swiff/dist/ssh.js:136:11
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/matthewblode/.nvm/versions/node/v11.7.0/lib/node_modules/swiff/dist/ssh.js:32:103)
    at _next (/Users/matthewblode/.nvm/versions/node/v11.7.0/lib/node_modules/swiff/dist/ssh.js:34:194)

I'm running Node 11.7.0, the latest version. Thank you! Great concept and super easy to set-up if it works... 😬

Add the ability to extend and add your own tasks

Thanks to @samstevens for this great idea.

Basically you'd be able to add additional tasks to Swiff yourself.
You'd also be able to customise the menu to show only the tasks you'd use.
Perhaps being able to npm install -g swiff-plugin for the more popular extensions?

Open to suggestions/ideas.

Package yoga-layout-prebuilt throws exception when trying to run tasks from the command line.

Package yoga-layout-prebuilt throws exception when trying to run tasks from the command line.

Tested on fresh installs of swiff on fresh installs of nodejs versions 8.16.1, 10.16.3, 10.17.0, and 12.13.1.

Stack trace from trying to run '$ swiff --composerPull'

/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

TypeError: Cannot read property 'yogaNode' of undefined
    at squashTextNodes (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/render-node-to-output.js:47:38)
    at squashTextNodes (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/render-node-to-output.js:59:43)
    at renderNodeToOutput (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/render-node-to-output.js:134:18)
    at renderNodeToOutput (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/render-node-to-output.js:154:7)
    at renderNodeToOutput (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/render-node-to-output.js:154:7)
    at renderNodeToOutput (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/render-node-to-output.js:154:7)
    at Instance.node [as renderer] (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/renderer.js:108:37)
    at Instance.onRender (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/instance.js:105:14)
    at resetAfterCommit (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/ink/build/reconciler.js:24:14)
    at commitRootImpl (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/react-reconciler/cjs/react-reconciler.development.js:13367:5)
    at unstable_runWithPriority (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/scheduler/cjs/scheduler.development.js:643:12)
    at runWithPriority (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/react-reconciler/cjs/react-reconciler.development.js:1796:10)
    at commitRoot (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/react-reconciler/cjs/react-reconciler.development.js:13211:3)
    at runRootCallback (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/react-reconciler/cjs/react-reconciler.development.js:12346:20)
    at /Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/react-reconciler/cjs/react-reconciler.development.js:1844:24
    at unstable_runWithPriority (/Users/nicholas/.nvm/versions/node/v10.17.0/lib/node_modules/swiff/node_modules/scheduler/cjs/scheduler.development.js:643:12)

Add support for encrypted ssh keys

If the ssh key is protected by a passphrase, it fails (gracefully) with this message :

πŸ’β€ Error: Encrypted private key detected, but no passphrase given

It would be great if support for encrypted key would be added (either by just asking for the passphrase, or in my case the passphrase is stored in the OSX keychain so I usually just do a ssh-add -K at the beginning of my session and don't have to worry about it after

Enable multiple environments per project

I would love a feature where I could have multiple environments setup in the config (for example a dev environment, a staging environment and even the prod environment).
Each should have its own push and pull folders.

Swiff doesn't exit after performing a database pull

After pulling a remote DB, I have to Ctrl + C to get my prompt back. I'm guessing (without checking into the source) that perhaps you're not sending the proper exit codes to the terminal after performing the DB pull, so it never knows that the task is done.

Database push command breaks receiving Craft CMS DB

Steps to reproduce:

Prereq: Have an identical database for Craft CMS installed both locally and remotely, aka on the "receiving" server

  1. From your local terminal, go to your Craft folder and open swiff with swiff
  2. Choose "Database Pull" from the menu
  3. Observe the local database is still functional.
  4. Choose "Database Push" from the menu
  5. Observe the following error immediately after push:
Exception 'yii\web\ServerErrorHttpException' with message 'The info table is missing its row'

in /storage/av05666/www/public_html/vendor/craftcms/cms/src/base/ApplicationTrait.php:635

Stack trace:
#0 /storage/av05666/www/public_html/vendor/craftcms/cms/src/base/ApplicationTrait.php(286): craft\console\Application->getInfo(true)
#1 /storage/av05666/www/public_html/vendor/craftcms/cms/src/helpers/App.php(538): craft\console\Application->getIsInstalled()
#2 /storage/av05666/www/public_html/vendor/craftcms/cms/src/config/app.php(219): craft\helpers\App::logConfig()
#3 [internal function]: {closure}()
#4 /storage/av05666/www/public_html/vendor/yiisoft/yii2/di/Container.php(524): call_user_func_array(Object(Closure), Array)
#5 /storage/av05666/www/public_html/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->invoke(Object(Closure), Array)
#6 /storage/av05666/www/public_html/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Object(Closure))
#7 /storage/av05666/www/public_html/vendor/yiisoft/yii2/base/Module.php(742): yii\di\ServiceLocator->get('log', true)
#8 /storage/av05666/www/public_html/vendor/craftcms/cms/src/console/Application.php(156): yii\base\Module->get('log', true)
#9 /storage/av05666/www/public_html/vendor/yiisoft/yii2/base/Application.php(508): craft\console\Application->get('log')
#10 /storage/av05666/www/public_html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1381): yii\base\Application->getLog()
#11 /storage/av05666/www/public_html/vendor/craftcms/cms/src/console/Application.php(57): craft\console\Application->_preInit()
#12 /storage/av05666/www/public_html/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\console\Application->init()
#13 /storage/av05666/www/public_html/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)
#14 /storage/av05666/www/public_html/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#15 /storage/av05666/www/public_html/vendor/craftcms/cms/src/console/Application.php(48): yii\console\Application->__construct(Array)
#16 [internal function]: craft\console\Application->__construct(Array)
#17 /storage/av05666/www/public_html/vendor/yiisoft/yii2/di/Container.php(400): ReflectionClass->newInstanceArgs(Array)
#18 /storage/av05666/www/public_html/vendor/yiisoft/yii2/di/Container.php(159): yii\di\Container->build('craft\\console\\A...', Array, Array)
#19 /storage/av05666/www/public_html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\console\\A...', Array, Array)
#20 /storage/av05666/www/public_html/vendor/craftcms/cms/bootstrap/bootstrap.php(245): yii\BaseYii::createObject(Array)
#21 /storage/av05666/www/public_html/vendor/craftcms/cms/bootstrap/console.php(43): require('/storage/av0566...')
#22 /storage/av05666/www/public_html/craft(21): require('/storage/av0566...')

Craft CMS commands via the CLI and the admin interface both become unusable entirely.

I can see the info table is indeed completely empty, after the push:

mysql> select * from info;
Empty set (0.00 sec)

Locally, the info table is correct.

Error: All configured authentication methods failed

Trying to use on a newly configured server. Keep getting the following error when trying to pull the database.

Error: All configured authentication methods failed

My ssh key is installed on the server and everything is set up the same way as other sites.

Only difference is that this is the first site that's on Craft 4 - could that be an issue?

Where are backups stored?

"πŸƒ Backing up the remote live database"

I thought they'd be in storage/backups but not seeing them there.

Thanks!

Add ESC to quit

Ctrl+C just won't cut it - let's add an easier way to close

Change default colours?

Hi,
Using nicely with a few projects. One thing, the teal font colour on the task interface is difficult to read on a white background. Is there a way to change?

Screenshot 2019-05-16 at 11 35 15

Project.yaml push/pull

Not sure if it would be difficult to add, but might be useful to be able to push the project.yaml. I find myself git commiting project.yaml file just so it will deploy through build process, but that takes a bit longer to execute...

Support custom SSH port

I have SSH running on a non-standard port and it doesn't appear that I can specify it in swiff.config.js. I'm otherwise trying to authenticate with a valid username and key. I attempted to append the port to the hostname (foo.dev:1234) but it resulted in the same response when I attempt a Pull:

Haven’t added your key to the server?
Add your key to the remote server with ssh-copy-id:
ssh-copy-id foo.dev:1234

swiff --version
1.1.3

Unsupported key format

We are getting a privateKey error when running the database sync:

Error: Cannot parse privateKey: Unsupported key format

For info, i'm on a fresh install of osx and have just added new keys and verified they are working on the remote server.

Add support for pushing the database

This would definitely have to be in conjunction with #4, but it would be useful during initial developments of a site to push a local database to a remote environment (99% of the time, a staging server).

Currently, since multi-environments aren't supported, our staging site is configured in swiff, and we're manually uploading the local database to the staging server to let the client see incremental work.

Support DB_DSN for Craft 3.4+ Installs

In Craft 3.4, the ENV variables changed from using DB_DRIVER, DB_SERVER, DB_DATABASE, and DB_PORT to define your database config to just DB_DSN.

It would be great if Swiff could check for and use that value first and then fallback to searching for the old ENV variables (so older installs would continue to be supported).

Add a working directory

Not all projects have a mirrored project structure on the remote server so a remote working directory is a setting worth adding.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.