Giter VIP home page Giter VIP logo

syncano-cli's Introduction

Syncano command line tool

Table of contents

  1. Build Status
  2. Installation
  3. Documentation
  4. Registration
  5. Instances
  6. Syncano sync
  7. Syncano Parse migration tool
  8. Syncano Hosting
  9. Sockets
  10. Config
  11. Running Scripts
  12. Issues

Build Status

Master

https://circleci.com/gh/Syncano/syncano-cli/tree/master.svg?style=svg

Develop

https://circleci.com/gh/Syncano/syncano-cli/tree/develop.svg?style=svg

Installation

To install Syncano CLI tool:

pip install syncano-cli

Usage:

First you need to login into your Syncano account

syncano login --instance-name patient-resonance-4283

It will ask you for your email and password. After successfully logging in your Account Key (admin key) will be stored in ${HOME}/.syncano file. You can also override an Account Key later with --key option.

The Instance name will be set as default and used in all CLI commands.

If you want to override this setting for a specific command, use --instance-name eg:

syncano sync --instance-name new-instance-1234 pull

If you need to change default Instance name, used for all future commands, use:

syncano default name_of_new_default_instance

If you do not have an Syncano account use syncano init command:

syncano init

And follow the steps. CLI will ask you about email and password, it will also create an Instance for you. After syncano init you can start with getting the list of your Instances:

syncano instances list

To obtain a help, type:

syncano --help

To display a help for specific command, type:

syncano instances --help

And:

syncano instances list --help

Documentation

You can read detailed documentation here.

Registration

You can register into Syncano using CLI:

syncano register [email protected]

You will be asked about password in prompt. Provide it. When you see the information about successful registration - you can start using CLI.

The following options can be used (but this is not obligatory):

--first-name        # this is your first name;
--last-name         # this is yout last name;
--invitation-key    # the invitation key if someone invite you to using Syncano;

When registration is successful - the api_key will be set in CLI config - and it's ready to use. The next step should be - creating an Instance - please see below.

Instances

How CLI handles connection?

Almost each (except some global commands - like register) CLI command will send a request to the Syncano Instance. To handle this properly - you can specify --instance-name when login (if you already have one). This Instance will be used in all API calls then. You can check which Instance is default by listing the instances:

syncano instances list

In the output - if the Instance is default - there will be a (default) string near the instance name.

The Instance name can be also overwritten on particular call:

syncano sockets --instance-name my_custom_instance list

Eg.: if your default Instance is my_instance_name and you run above command - the Sockets from instance my_custom_instance will be displayed, and again:

syncano sockets list

Will display Sockets from my_instance_name - because it is set to be a default one.

After a registration - there's no default Instance set. So it's desired to create one and set it as default:

syncano instances create my_new_instance
syncano instances default my_new_instance

It's worth to note that instance_name must be unique - but you will get appropriate message if you encounter such case.

CLI provides an interface for managing Instances. The commands are:

  • Instance create:

    syncano instances create my_instance_name
    
  • Instance list:

    syncano instances list
    
  • Instance delete:

    syncano delete my_instance_name
    
  • Instance details:

    syncano details my_instance_name
    
  • Set Instance as default for using in CLI commands:

    syncano default my_instance_name
    

In delete and details argument my_instance_name - can be omitted, the default Instance will be used. Deletion will ask you for confirmation - as deleting an Instance is quite a big thing.

Syncano sync

Pulling your Instance Classes and Scripts

In order to pull your Instance configuration, execute

syncano sync pull

This will fetch all Classes and Scripts into the current working directory, and store configuration in syncano.yml file. If you want to pull only selected classes/scripts you can add -c/--class or -s/--script option e.g.

syncano sync pull -c Class1 -c Class2 -s script_label_1 -s "script label 2"

The Scripts' source code is stored in the scripts subdirectory. Their names are based on script labels. Keep in mind that script labels in Syncano are not unique, and this tool cannot yet handle this kind of situation when pulling a Script from Syncano.

Classes and Scripts configuration is stored in syncano.yml file. If this file already exists, only Classes and Scripts stored in this file will be pulled and updated. If you want to pull the whole Instance you can use -a/--all switch flag.

Pushing your changes

After you have made changes to syncano.yml or any of the script's source code, you can push the changes to Syncano using

syncano sync push

It will push only changes newer than the last synchronization time. As last synchronization time we use .sync file last modification time. If syncano.yml has changed, it will try to push all data to Syncano. Otherwise, it will just push the source code files for scripts that were changed. If you want to force push all changes you can use -a/--all option.

If you only want to push changes from selected Classes/Scripts you can provide them with -c/--class or -s/--script options like in the pull example above.

Synchronize changes in real-time

There is an option to synchronize your project in real-time. When you change syncano.yml or the source code of a script described in syncano.yml, your changes will be automatically pushed to Syncano.

syncano sync watch

This command will push all of your project's configuration to Syncano and will wait for changes made to project files. When it detects that any file was modified, it will push those changes to Syncano.

Syncano Parse migration tool

This tool will help you to move your data from Parse to Syncano.

Usage:

Currently supports only transferring data. This tool takes the Parse schemas and transforms them to Syncano Classes. The next step is to move all of the data between Parse and Syncano. The last step is rebuilding the relations between objects.

Configuration

syncano migrate configure

Will run the configuration that will ask you for the following variables:

  • PARSE_MASTER_KEY: the master key of your PARSE account;
  • PARSE_APPLICATION_ID: the application ID of the application that you want to transfer;
  • SYNCANO_ADMIN_API_KEY: Syncano Account Key;
  • SYNCANO_INSTANCE_NAME: the Syncano Instance name to which the transfer will be made;

syncano migrate configure command will take following parameters:

  • -c (--current) which will display the current configuration;
  • -f (--force) which allow to override the previously set configuration;

The configuration will be stored in your home directory in the .syncano file under the P2S section. It's used to call the Parse API and Syncano API as well.

Run migration

syncano migrate parse

This command will run the synchronization process between Parse and Syncano. Sit back, relax, and read the output.

Tips & Troubleshooting

  1. This tool currently does not support checking if an object is already present in the Syncano Instance. If the sync is run twice, the data will be duplicated. To avoid this, simply remove your Instance using Syncano dashboard;
  2. The whole process can be quite slow because of the throttling on both sides: Parse and Syncano on free trial accounts (which is the bottom boundary for scripts);

Syncano Hosting

Syncano Hosting is a simple way to host your static files on Syncano servers. The CLI supports it in the following way:

This command will list currently defined Hosting Sockets in the Instance:

syncano hosting list

This command will list files for currently hosted website (for default Hosting Socket):

syncano hosting list files

This command will publish all files inside <base_dir> to the default Syncano Hosting Instance. When publishing the whole directory, the structure will be mapped on Syncano.:

syncano hosting publish <base_dir>

This command will permamently delete the Hosting Socket:

syncano hosting delete

This command will delete the specified file:

syncano hosting delete hosting/file/path

This command will update single file:

syncano hosting update hosting/file/path local/file/path

For each of the above command you can specify the domain to change just after hosting command, example:

syncano hosting --domain staging publish <base_dir>

Will create a new Hosting Socket which will be available under: <instance_name>--staging.syncano.site If this Hosting Socket is also a default one, it will be available under: <instance_name>.syncano.site.

Sockets

This is a list of commands available for Sockets. If you want to know more about Sockets, read the detailed docs here.

To install a Sockets from a local file:

syncano sockets install /path/to/dir

To install a Sockets from a URL:

syncano sockets install https://web.path.to/your.file

List all Sockets:

syncano sockets list

List all defined endpoints (for all Sockets):

syncano sockets list endpoints

Display chosen Sockets details:

syncano sockets details socket_name

Display Sockets config (with name: socket_name):

syncano sockets config socket_name

Delete a Sockets:

syncano sockets delete socket_name

Create a template from a template stored in Syncano CLI:

syncano sockets template /path/to/output_dir

Create a template from an existing Sockets:

syncano sockets template /path/to/out --socket socket_name

Run endpoint defined in Sockets:

syncano sockets run socket_name/endpoint_name

Run endpoint providing POST data:

syncano sockets run socket_name/my_endpoint_12 POST -d one=1

In all of the above cases you can override the Syncano Instance being used:

--instance-name my_instance_name

eg.:

syncano sockets --instance-name my_instance_name run socket_name/my_endpoint_12 POST -d one=1

Providing the Instance name this way will override the default instance name defined during initial setup (syncano login --instance-name my_instance)

Config

To display current Instance config:

syncano config

To add variable with name name and value value to the config:

syncano config add name value

To modify existing config variable:

syncano config modify name value

To delete existing config variable:

syncano config delete name

Running Scripts

This command will allow you to execute any Script Endpoint with optional payload and read the output.

Usage:

syncano execute <instance_name> <script_endpoint_name> -d key=value

Issues

  1. If you encounter any problems, have some improvement ideas or just wanna talk, please write to me directly: [email protected];
  2. Syncano team can be reached in multiple ways. Please do not hesitate to ask for help or share your thoughts. You can find us on:

syncano-cli's People

Contributors

adamwardecki avatar andjelx avatar dancio avatar forgems avatar ilu2112 avatar mariuszwisniewski avatar opalczynski avatar twack05 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syncano-cli's Issues

There should be possibility to use logger with any name

For now we can only use logger with name syncano-sync. It causes small inconsistency in module syncano_cli.parse_to_syncano (messages are being logged by syncano-sync logger but they come from totally different module) and it will lead to the same inconsistency in any new future modules.

It would be nice if we could create new logger with any name with no need to duplicate any code.

syncano cli not working

โ‡’  syncano sync push
Traceback (most recent call last):
  File "/usr/local/bin/syncano", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/syncano_cli/main.py", line 37, in main
    raise CLIBaseException(e.message)
syncano_cli.base.exceptions.CLIBaseException: source


Syncano Hosting - missing info what to do after uploading website

See screenshot - after uploading website I don't even know how to open the website - we should have at least a link + some info what to do next, how to edit/update website, how to download it to hard drive, how to stop hosting - right now I don't get that information.

screen shot 2016-08-25 at 2 26 30 pm

Config missing new class definition (after pull)

  1. syncano pull (on empty instance)
  2. add class via dashboard (name "order", only one field: "author" which is reference to "user_profile")
  3. syncano pull (no error)
  4. class "order" missing in the config file

Summary of pull

When CLI is pulling data and introducing changes in a config file, it would be great to have some summary of the changes.

No 'sync' subcommand in cli.

Gents,
in your docs you advise to use syncano sync pull <instance_name> to get desired instance, but no such subcommand as sync exists in the program. syncano pull <instance_name> works just fine however. Is this a planned future and you've just left it here or maybe some omission?

ConfigParser error on login

Installed the cli on my mac with pip (python3.5)

When i try to log in with
syncano login --instance-name patient-resonance-4283

i get the following error

Traceback (most recent call last):
  File "/usr/local/bin/syncano", line 7, in <module>
    from syncano_cli.main import main
  File "/usr/local/lib/python3.5/site-packages/syncano_cli/main.py", line 6, in <module>
    from syncano_cli.account.commands import top_account
  File "/usr/local/lib/python3.5/site-packages/syncano_cli/account/commands.py", line 2, in <module>
    from syncano_cli.account.command import AccountCommands
  File "/usr/local/lib/python3.5/site-packages/syncano_cli/account/command.py", line 4, in <module>
    from syncano_cli.config import ACCOUNT_CONFIG
  File "/usr/local/lib/python3.5/site-packages/syncano_cli/config.py", line 4, in <module>
    from ConfigParser import ConfigParser
ImportError: No module named 'ConfigParser'

Error when trying to host content

I try hosting a simple app in my folder named "hosting" using the syncano host command.
But its not working:

Previous conv:
me:

I heard you guys are working on webhosting, file storage etc. I would
love to host some files on syncano. Could you tell me something about
the plans for webhosting?

Syncano

..
...
I can, you can actually already start using it! :) We're in the process
of adding it to the Dashboard - for now, the easiest way to host files
on Syncano is by using our CLI.

You can read about installing it here:
https://github.com/Syncano/syncano-cli#installation and then just skipp
directly to https://github.com/Syncano/syncano-cli#syncano-hosting to
read about hosting.

In short you need to:

  1. Install it

pip install syncano-cli

  1. Login to your instance

syncano login --instance-name your-instance-name

  1. syncano hosting publish /path/to/directory

Wait until it finishes and that's it!

Your website will be available under your-instance-name.syncano.site
domain, with SSL. We'll be adding custom domains later, sometime in Q4.

Let me know if that works for you!

Thanks for creating an issue on GitHub. I assigned our developer to it
and will test it and fix it when we find the bug. Thanks again!

I try hosting a simple app in my folder named "hosting" using the syncano host command.
When i type:

syncano hosting publish hosting  

I get the following error

INFO: Uploading file: json_viewer/favicon.ico
INFO: Uploading file: json_viewer/index.html
INFO: Uploading file: json_viewer/static/css/main.cacbacc7.css
INFO: Uploading file: json_viewer/static/css/main.cacbacc7.css.map
INFO: Uploading file: json_viewer/static/js/main.97bcc040.js
INFO: Uploading file: json_viewer/static/js/main.97bcc040.js.map
INFO: Uploading file: json_viewer/static/media/logo.5d5d9eef.svg
Traceback (most recent call last):
  File "/usr/local/bin/syncano", line 11, in <module>
    load_entry_point('syncano-cli==0.7', 'console_scripts', 'syncano')()
  File "/usr/local/lib/python2.7/site-packages/syncano_cli/main.py", line 34, in main
    cli(obj={})
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/syncano_cli/hosting/commands.py", line 43, in publish
    domain=domain
KeyError: 'instance_name'

Comments with examples in config file

Config file should contain few comments with example configuration, right now it is not obvious how this configuration should look like (especially if you are pulling from empty instance)

Can't successfully upload on a windows box

folderstructure
I'm submitting the following cmd: syncano hosting publish dist

It uploads the files that are on top level of dist but it doesn't go into my subfolders.
this is the error I get.

INFO: Uploading file: favicon.ico
INFO: Uploading file: index.html
Error: Unicode characters in path are not supported. Check the files names.

I'm assuming the regex used to validate the pathname doesn't take windows paths into account?
My folder structure is attaached

Syncano Execute not finding the Script

syncano execute UseInvitationCode
Returns: ERROR: UseInvitationCode not found.

The syncano.yml

classes:
  invite:
    fields:
      code: integer
      prospect: reference prospect
      sent: boolean
      used: boolean
    group_permissions: create_objects
    other_permissions: create_objects
  prospect:
    fields:
      email: string
      name: string
    group_permissions: create_objects
    other_permissions: create_objects
  user_profile:
    fields: {}
    group_permissions: create_objects
    other_permissions: create_objects
scripts:
- label: CreateAndSentInviteCode
  runtime: python3
  script: scripts/CreateAndSentInviteCode.py
- endpoints:
  - createprospect
  label: CreateUniqueProspect
  runtime: python3
  script: scripts/CreateUniqueProspect.py
- config:
    apiKey: #######
    bcc: ''
    cc: ''
    date: ''
    from: #######
    fromName: #######
    html: ''
    replyTo: ''
    subject: ''
    text: ''
    to: ''
    toName: ''
  endpoints:
  - send_email
  label: SendGrid Mailer
  runtime: nodejs
  script: scripts/SendGrid_Mailer.js
- label: UseInvitationCode
  runtime: python3
  script: scripts/UseInvitationCode.py

error when publishing files to hosting

Windows 10 command-line

I also tried windows bash shell and received the same error

syncano hosting publish .
Traceback (most recent call last):
File "C:\Python27\Scripts\syncano-script.py", line 9, in
load_entry_point('syncano-cli==0.8', 'console_scripts', 'syncano')()
File "c:\python27\lib\site-packages\syncano_cli\main.py", line 40, in main
raise SyncanoLibraryException(e.reason)
syncano_cli.base.exceptions.SyncanoLibraryException: This field is required.

Syncano Sync Push not sending the changes

Run
syncano sync pull
Result:

INFO: Pulling instance data from syncano
INFO: Creating scripts directory
WARN: Saving script "CreateAndSentInviteCode" as "CreateAndSentInviteCode.py"
WARN: Saving script "CreateUniqueProspect" as "CreateUniqueProspect.py"
WARN: Saving script "SendGrid Mailer" as "SendGrid_Mailer.js"
WARN: Saving script "UseInvitationCode" as "UseInvitationCode.py"
INFO: Finished pulling instance data from syncano

Changed UseInvitationCode.py and saved

Run
syncano sync push
Result:

Nothing to sync.

Opened the Dashboard and the script still the old one.

Did syncano sync watch solved and sent my version.

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.