Code Monkey home page Code Monkey logo

vip-cli's Introduction

VIP-CLI

VIP-CLI is a tool for interacting with and managing your WordPress VIP applications.

Further documentation

  • SETUP.md for installation and setup instructions, basic usage and environmental variables.
  • ARCHITECTURE.md for information on architecture, code structure, data storage and security.
  • CONTRIBUTING.md for information on how to contribute patches and features, also issue and pull request labels.
  • DEBUGGING.md for information on how to debug the software.
  • TESTING.md for details on testing the software and individual tasks.
  • RELEASING.md for details on deploying a new release.
  • SECURITY.md for information if you found a security issue.

Further information

vip-cli's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vip-cli's Issues

Check all git remotes

When we automatically detect the repo, we should look at all git remotes and use the first one that matches wpcomvip/*. This will resolve any issues where our repo is not the "origin".

Filter parent sites out of childEnvContext

Right now we filter environment_name === 'production' out of the environment list for childEnvContext, but we should really filter out parent sites. There are some edge cases where parent sites have environment_name == 'testing'.

npm install fails with permission denied during keytar

Running sudo npm install -g @automattic/vip ends with:

prebuild-install WARN install EACCES: permission denied, access '/Users/nickdaugherty/.npm'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@automattic/vip/node_modules/keytar/build'
gyp ERR! System Darwin 17.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/@automattic/vip/node_modules/keytar
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@automattic/vip/node_modules/keytar):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `prebuild-install || node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

Improved login flow

We should open a browser to the VIP Go Dashboard's new token interface and prompt the user to copy the token.

sync: Clearer message when no child environments found

$ vip sync --app 309
Could not find any child environments for ellaminnowpea-xyz
  • Change "child" to "non-production"
  • Prefix with "Error:"?
  • Suffix with next steps: "To set up development environment, please contact VIP Support"

Cannot delete property '0' of [object Array]

I can't easily reproduce this now (I think I was in a non-Go git repo), but flagging for investigation:

$ vip sync

  โœ•  Please contact VIP Support with the following error:
  TypeError: Cannot delete property '0' of [object Array]
    at Array.pop (<anonymous>)
    at Args._args2.default.argv (~/.nvm/versions/node/v8.9.4/lib/node_modules/@automattic/vip/dist/lib/cli/command.js:214:42)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Customize app query per command

There's an early query on commands that have app context. The app object that's returned ends up being passed into the command. The problem is that every command needs different things. For example, the sync command needs syncProgress. We should be able to specify the query when we define the command.

Uninstalling VIP tool does not remove config

I uninstalled the vip tool with npm uninstall -g @automattic/vip, then reinstalled with npm install -g @automattic/vip and was still logged in.

I think the tool should remove all config, tokens, etc, when uninstalled, leaving a clean slate.

Installation issue

Can we catch this and give the operator a useful path forward?

SWTBMBP:~ simonwheatley$ npm install -g @automattic/vip
module.js:557
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)

Strengthen the confirm step in `vip sync`

  1. Enter vip sync --app $APP_ID
  2. Hold down return quite hard ๐Ÿ˜†
  3. Confirmation shows up and "yes" is filled, effectively bypassing the confirmation

Tricky to reproduce, but by holding/hitting return you can kind of accidentally skate through the environment selection and (more worrying) the confirm step.

Perhaps we should only accept "y" or "n" for the confirm, rather than having "return" map to "yes"?

push and pull commands

  • vip pull - Pulls the repo from the wpcomvip repo
  • vip push - Pushes the repo to the wpcomvip repo

Use git locally to create commits and interact with the git tree.

sync: Don't show non-WordPress apps

For example, I see api in the list.

Mostly an issue for internal use right now, but since we don't have any specific support for non-WordPress sync, we should probably exclude them from the list.

Maybe invalid app ID fail?

$ vip sync --app 99999999999999999

  โœ•  Please contact VIP Support with the following error:
  Error: GraphQL error: Argument "id" has invalid value 100000000000000000.
Expected type "Int", found 100000000000000000.
    at new ApolloError (/Users/user/some/path/vip/node_modules/apollo-client/bundle.umd.js:76:28)
    at /Users/user/some/path/vip/node_modules/apollo-client/bundle.umd.js:952:41
    at /Users/user/some/path/vip/node_modules/apollo-client/bundle.umd.js:1333:17
    at Array.forEach (<anonymous>)
    at /Users/user/some/path/vip/node_modules/apollo-client/bundle.umd.js:1332:18
    at Map.forEach (<anonymous>)
    at QueryManager.broadcastQueries (/Users/user/some/path/vip/node_modules/apollo-client/bundle.umd.js:1327:22)
    at Object.next (/Users/user/some/path/vip/node_modules/apollo-client/bundle.umd.js:1361:31)
    at SubscriptionObserver.next (/Users/user/some/path/vip/node_modules/zen-observable/zen-observable.js:158:20)
    at /Users/user/some/path/vip/node_modules/apollo-link-dedup/lib/bundle.umd.js:54:76

  โœ•  Please contact VIP Support with the following error:
  Error: Response not successful: Received status code 400
    at throwServerError (/Users/user/some/path/vip/node_modules/apollo-link-http/lib/bundle.umd.js:35:17)
    at /Users/user/some/path/vip/node_modules/apollo-link-http/lib/bundle.umd.js:58:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

Add an intro/welcome message on first run

This is a bit abrupt and unclear why I need an access token:

$ vip
 This will open https://ui.go-vip.co/me/cli/2 in your web browser. Follow the instructions there to acquire an access token. Continue? (Y/n)

Detect and gracefully fail when offline

$ vip app 309
App 309 does not exist

$ vip app list
Error: Network error: request to https://api.wpvip.com/graphql failed, reason: getaddrinfo ENOTFOUND api.wpvip.com api.wpvip.com:443

Infer app from current directory

If you're in a VIP Go repo, we'll automatically figure out what apps you might be actioning. If there's only one app, we'll assume you want to action that unless you set --app. For any destructive actions, we'll prompt for confirmation unless you set --force which requires --app.

Data Sync UI

Syncing vip-test.go-vip.co (production) to vip-test.go-vip.co (develop)

โœ“ Prepare environment
โ ‹ Search-replace URLs
โ—‹ Update options
โ—‹ Run `wp dfm clean_db`
โ—‹ Run `wp dfm do_other_thing`
โ—‹ Restore environment

[==========          ] 50%

Press ^C to hide progress. Data Sync will continue in the background.
Syncing vip-test.go-vip.co (production) to vip-test.go-vip.co (develop)

โœ“ Prepare environment
โœ• Search-replace URLs
โ—‹ Update options
โ—‹ Run `wp dfm clean_db`
โ—‹ Run `wp dfm do_other_thing`
โ—‹ Restore environment

Data Sync failed at 'Search-replace URLs'. Please try again or contact VIP Support.
Syncing vip-test.go-vip.co (production) to vip-test.go-vip.co (develop)

โœ“ Prepare environment
โœ“ Search-replace URLs
โœ“ Update options
โœ“ Run `wp dfm clean_db`
โœ“ Run `wp dfm do_other_thing`
โœ“ Restore environment

Success: Data Sync is finished for https://vip-test.go-vip.co

Promisify with util.promisify

We have promises wrapping some async functions. It would be nice to simplify that with util.promisify. The keychain code comes to mind.

Handle "no config" errors and guide the user appropriately

If a sync is attempted with no config it is likely there will be no good outcome, particularly for WordPress multisite. We should detect when a sync is attempted with no config, and direct the user to documentation to create some (for now, ideally we'd be much more helpful).

Compile to a single binary

It turns out npm install is not great. It would be helpful to compile the CLI to a single binary so we can offer an alternative way to install it.

https://github.com/pmq20/node-packer

We should explore a fully compiled version, i.e. including V8 and maybe just building the JavaScript to a single file. In the first case, node wouldnโ€™t even need to be installed to run it. That could become a big download and may be unnecessary though.

Fix dependency on C compiler

The dependency on node-keytar means we need a C compiler in order to install this package. Ideally we can distribute binaries of node-keytar to remove the need for a compiler.

Handle Network Disconnects

If the network disconnects during a vip sync, there's an uncaught error. We should catch that and gracefully hide the sync progress.

Browser tests

We need to ensure the libs all (except the ones specifically for CLI) work for browsers.

Force Updates

VIP CLi should fail if the current version is older than the n-1 version.

sync: Unauthorized error

My test account has read access to the wpcomvip/vip-go-test-03 repo (site 103). Running sync without params throws an error instead of the environment list.

$ vip sync
Error: GraphQL error: Unauthorized

Running sync --app 103 gives the following output (unsure if related to permissions or sync issues on the site):

$ vip sync --app 103
===================================
+ app: test-03
+ environment: staging
===================================
 Are you sure you want to sync from production? Yes
Note: Someone recently ran a data sync on this site
Note: Please wait a few minutes before trying again

  syncing: test-03
     from: PRODUCTION
       to: staging


โœ“ Data Sync is finished for test-03

App/Env "dropdown" selector

  • If there are multiple apps and none is specified for the current repo, show a selection dialogue
  • If the user has access to multiple apps and none is specified, show a selection dialogue
  • If there are multiple environment options and none is specified, show a selection dialogue

Add custom description to confirmation prompt

We should allow commands to define a description of what will happen during the confirmation prompt. For example, data syncs would be something like:

Syncing data from production
app: vip-test
environment: preprod

Flag unknown commands

When I type vip blah which is not a registered command, we output usage instructions. This is not super helpful as it doesn't really tell me what I'm doing wrong.

It would be better to show an error instead, similar to wp-cli:

$ wp blah
Error: 'blah' is not a registered wp command. See 'wp help'.

Switch to Inquirer.js from Promptly

We're using inquirer for dropdowns, but it also supports confirm, password, auto-complete, and custom types. Would be good to standardize and also remove an unnecessary dependency.

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.