Code Monkey home page Code Monkey logo

toolbelt's Introduction

VTEX Toolbelt

Build Status npm version Greenkeeper badge

The CLI that offers all you need to start using the VTEX IO platform efficiently.

Summary

How do we empower you?

VTEX Toolbelt is a command-line program that gives you access to all of the features in the VTEX platform and increases your productivity, allowing you to:

  • Manage your apps quickly: List, install and uninstall available apps in your account;
  • Work safely on your personal environments: List, create and remove workspaces;
  • Easily ship changes to your final user: Promote a workspace to master, making it public in your account URL;
  • See what you are creating in real time: Develop new apps in link mode, using automatic synchronization;
  • Go live from the command line: Publish apps to the VTEX App Store.

Getting started: Installing the VTEX Toolbelt

To use the VTEX Toolbelt, you'll need to install other engines that will also be useful when developing for VTEX.

Node.js to run the tool

  • Install Node.js here: Toolbelt is written in Typescript and designed to run on Node.js. (Node is the runtime that executes the JS and allows our tool to run and work at your computer)
  • Install yarn here: yarn is a way to manage your code, organize content in packages that you can download, share and... install, just like our CLI :)

Now do you have Node.js and Yarn? Let's install the Toolbelt.

Installing the Toolbelt with yarn

yarn powers app development to React, Node and VTEX IO! Install the Toolbelt using yarn and start working with us generating automatically all the files you'll need to create apps in the future. To install it, run:

yarn global add vtex
Alternative installation method using npm You can install using `npm`. But remember, if in the future you want to develop a VTEX IO app, you'll need to install `yarn`

To install with npm, run:

npm install -g vtex

Using the CLI

After installation, run vtex to see our commands and what each one of them does.

Or, check all our commands here
$ vtex
  Welcome to VTEX I/O
  Login with vtex login <account>

  Usage: vtex <command> [options]

  Commands:

    add <app>               Add app(s) to the manifest dependencies
    deprecate [app]         Deprecate app(s)
    init                    Create basic files and folders for your VTEX app
    install [app]           Install an app (defaults to the app in the current directory)
    link                    Start a development session for this app
    setup                   Setup your development environment (configure tsconfig and tslint, run yarn)
    list                    List your installed VTEX apps
    logs                    Show apps production logs
    login                   Log into a VTEX account
    logout                  Logout of the current VTEX account
    promote                 Promote this workspace to master
    publish [path]          Publish the current app or a path containing an app
    switch <account>        Switch to another VTEX account
    test                    Run your VTEX app unit tests
    uninstall [app]         Uninstall an app (defaults to the app in the current directory)
    unlink [app]            Unlink an app on the current directory or a specified one
    update                  Update all installed apps to the latest version
    use <name>              Use a workspace to perform operations
    whoami                  See your credentials current status

    browse [endpoint]       Browse an endpoint of the store under development

    config get <name>                 Gets the current value for the requested configuration
    config set <name> <value>         Sets the current value for the given configuration

    deps list                              List your workspace dependencies
    deps update [app]                      Update all workspace dependencies or a specific app@version
    deps diff [workspace1] [workspace2]    Show dependencies difference between two workspaces

    infra install <name>     Install a service
    infra list [name]        List installed services
    infra update             Update all installed services

    local manifest    Generate manifest from package.json
    local package     Generate package.json from manifest
    local account     Show current account and copy it to clipboard
    local workspace   Show current workspace and copy it to clipboard
    local token       Show user's auth token and copy it to clipboard

    port react       Convert your app from React 0.x to React 2.x

    release [releaseType/Version] [tagName]          Bump app version, commit and push to remote (git only)

    settings <app> [fields]                     Get app settings
    settings set <app> <fields> <value>         Set a value
    settings unset <app> <fields>               Unset a value

    redirects import <csvPath>      Import redirects for the current account and workspace
    redirects export <csvPath>      Export all redirects in the current account and workspace
    redirects delete <csvPath>      Delete redirects in the current account and workspace

    url                               Prints base URL for current account, workspace and account

    workspace                         Alias for vtex workspace info
    workspace create <name>           Create a new workspace with this name
    workspace delete <name>           Delete a single or various workspaces
    workspace info                    Display information about the current workspace
    workspace list                    List workspaces on this account
    workspace promote                 Promote this workspace to master
    workspace reset [name]            Delete and create a workspace
    workspace use <name>              Use a workspace to perform operations

  Options:

    -h, --help  show help information

Second step: log into your VTEX account

Start by using vtex login to receive your credentials and be able to access other features. Simply type this command and follow the instructions.

Having trouble with login? Follow these steps

You can use vtex login to login with your VTEX ID credentials or vtex logout if you're already logged in and want to change credentials.

When logging in, you will be asked for 3 things:

  • The account name of the store you wish to work on, that would be your company's or client's account name;
  • Your VTEX ID email, the one you received access to work with VTEX.
  • Your VTEX ID password, the one you chose when creating your user.

If you wish to work on another account, run vtex switch <account> specifying the account you want to move to.

😉 Note that link and publish implicitly checks if you're logged, and if you're not, it asks your credentials before proceeding.

To develop locally: use vtex link

When you log in to an account, you can create your own workspaces to work on your ideas or see what is in production. To do so:

  1. On an app directory, run vtex link and click on or copy the provided URL into your browser;
  2. Now on, VTEX Toolbelt will monitor your files for change and sync them with what you see automatically.
Know more about local development with Toolbelt

Toolbelt will upload all your app files to the developer environment, print an URL for your use, and watch for any changes you make to the files, which will be automatically synchronized.

Wanna know something cool? You can customize your prompt

You can configure your terminal prompt to display relevant information about your current context, like which account you're logged into and which workspace you are currently using.

Just like knowing which git branch you're currently in, having this info in your prompt will help you avoid mistakes and be faster when using VTEX IO.

How to do so?

bash users

If you are a bash user you can start customizing your command prompt by running the following command:

echo "source $(npm root -g)/vtex/plugins/bash/vtex.bash" >> ~/.bashrc
echo "source $(npm root -g)/vtex/plugins/bash/prompt.bash" >> ~/.bashrc

😉 For fine grained control, use only the first script and add __vtex_ps1 manually to your prompt.

fish users

If you want a pretty, ready-made Git + VTEX prompt you can copy plugins/fish/fish_prompt.fish to the ~/.config/fish/functions folder. To see the changes, simply restart your shell by typing fish.

cp (npm root -g)/vtex/plugins/fish/fish_prompt.fish ~/.config/fish/functions/
fish

💡 If you installed Toolbelt using yarn, you should replace (npm root -g) with (yarn global dir).


Frequently Asked Questions

How do I ignore specific files or directories in my app so that they are not uploaded?

Create a .vtexignore file containing, on each line, paths you wish to ignore. If no .vtexignore is found, your .gitignore file is used instead.

Is there another way to customize the prompt?

You can do so by adding the vtex_get_account and vtex_get_workspace commands to your PS1 environment variable the way it pleases you.


Contributing

Follow the steps on contributing.md.

License

MIT

Tell us what you think about Toolbelt

📡 We are always looking for ways to improve your experience. Please, send us feedback about the VTEX Toolbelt here.

toolbelt's People

Contributors

amoreira avatar arturpimentel avatar brunoabreu avatar dhasuda avatar edufgf avatar greenkeeperio-bot avatar guifromrio avatar iagoaraujo avatar kaisermann avatar lariciamota avatar lbebber avatar lucasecdb avatar lucis avatar m-rodrigues avatar markzeras avatar nataliagodot avatar pedro823 avatar rafaelbac avatar rdumont avatar tamorim avatar thalytafabrine avatar tiagonapoli avatar tlgimenes avatar tribeiral avatar vcalasans avatar verasthiago avatar victorcolombo avatar victorges avatar victoriamolgado avatar vwraposo 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

Watchers

 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  avatar

toolbelt's Issues

Pretty print error messages

When the user tries to publish a version of an app that is already published, Gallery throws and HTTP error:

Publishing storefront-banner 0.2.0
Compressing files...

 53243 total bytes. Publishing...
Sending files...

Failed to publish app
{ status: 409,
  body: '{"id":111,"code":"AppAlreadyInstalled","message":"This app is already installed","details":null}' }

Maybe Toolbelt could print the error message nicely.

.vtexignore not working

I have a file with my ignore files and folders, but the toolbelt is uploading them anyway.

Erro while trying to login

When I type vtex login or any other command, except help, I get:

$ vtex login
module.js:340
    throw err;
          ^
Error: Cannot find module 'Q'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/breno/local/lib/node_modules/vtex/lib/lib/auth.js:9:7)
    at Object.<anonymous> (/home/breno/local/lib/node_modules/vtex/lib/lib/auth.js:225:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Create vtex init

Create a new command, called init that uses the VTEX generator to generate the structure of an VTEX App project.

Change .vtexrc location

Change it to be an user setting, instead of project setting.
Also provide some way to define the same properties to be overriden by project.

Tiny-lr can't find livereload.js on npm v3

Tiny-lr has an issue with npm v3's flat module directory, reference here.

However, the project hasn't been updated in quite some time, and the maintainers have a history of abandoning it. In order to unblock npm v3 users, I've forked the project and released it under the name mini-lr. You can find the new repository here. I recommend updating your project to use the latest release in order to enable npm v3 usage. Thanks!

Suporte a webpack-dev-server

Ao detectar webpack.config.js e devDependencies: webpack-dev-server, rodar webpack-dev-server junto com o watcher de upload.

Discutir como isso vai se comportar com múltiplas apps ao mesmo tempo (#13).

Update toolbelt to new cookieless Storefront model

Let's kill the cookie! 🔪
Here's the to-do list:

watch

  • We're going to use WebSockets (SignalR) for communication with Storefront when running watch
  • Specific headers will be passed, containing e-mail, account and the app: x-vtex-user=<developer-email>, x-vtex-account=<account> and x-vtex-app=<vendor>.<app-name>
  • watch will no longer need a sandbox name, instead it will use an optional argument that will indicate the Workspace which the developer environment will be mirrored (#62)
  • Provide a URL for sharing the developer environment. It will follow like this: <store-url>/?workspace=sb_<developer-email>
  • Check if a workspace of the format sb_<developer-email> exists, if not, create it

login

  • The login will need an argument, this argument is the account of the store
  • Keep the account name somewhere
  • Can only be logged on 1 account at a time

Rodar dois watchs ao mesmo tempo

Ao tentar rodar dois watchs ao mesmo tempo o toolbelt da pau. Provavelmente porque tenta rodar sempre na mesma porta.

O ideal seria fazer um random sempre dentro de um range bom 35000/38000 por exemplo.

screen shot 2015-04-08 at 6 09 25 pm

Remover arquivos remotos desnecessários na sincronização

Quando o comando watch for chamado os arquivos locais e remotos devem ser comparados.
O objetivo é remover todos arquivos lixo de outras sincronizações na sandbox remota.

[user]
vtex watch minha-sandox

[toolbelt]
A toolbelt deverá listar os arquivos da sandbox contidos na gallery.

GET http://api.beta.vtex.com/{owner}/sandboxes/{sandbox}/{app}/files

{
    "meta.json": {
        "hash": "1805fa015ed73aaf3cfec3c56372704a",
        "size": 181
    },
    "package.json": {
        "hash": "89493c4499a09180cb696c4a625b2767",
        "size": 1286
    }
}

Para cada arquivo local deve ser gerado uma hash para comparar os arquivos.
Arquivos remotos com mesmo path mas com hash diferentes devem ser adicionados na sincronização com o @ChangeAction.Remove.

Erro ao fazer re-fresh no browser.

Watching my-first-app

http://localhost:3000/
webpack result is served from /assets/@alphateam.my-first-app/
content is served from /Users/belchior/www/my-first-app
404s will fallback to /index.html
Version: webpack 1.12.1
Time: 10228ms
chunk {0} HomePage.js, HomePage.js.map (HomePage) 233 kB {2} [rendered]
chunk {1} editors/index.js, editors/index.js.map (editors/index) 1.34 kB {2} [rendered]
chunk {2} common.js, common.js.map (common.js) 261 kB [rendered]
webpack: bundle is now VALID.
events.js:141
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open '/opt/local/lib/node_modules/vtex/node_modules/tiny-lr/node_modules/livereload-js/dist/livereload.js'
at Error (native)

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.