I advise that if the VSCode plugin supports the ask-cli v2 then use Method 1. If we're not there yet then use Method 2 if you want the VSCode plugin to work. If you don't care about the plugin just go with Method 1.
After following these instructions the old ask-cli v1.7.23 will run via the command ask1 and the latest ask-cli v2 via the command ask. You will be able to update the ask-cli v2 as usual. You can skip all steps below to create the npm package by just doing:
npm install -g https://gist.github.com/germanviscuso/48f5c68f876b31b51ba59f91b49a253f/raw/3a074faf055fe261441964d1ad5894012e716e0c/ask-cli-1-1.7.23.tgz
(This is the file below but whch I already edited for you to install as ask1 rather than ask)
- Download the original npm package of ask-cli v1 without installing it:
wget https://registry.npmjs.org/ask-cli/-/ask-cli-1.7.23.tgz
- Uncompress it and in the Terminal cd to the subdirectory package (this is the project root)
- Edit file package.json and change package name from ask-cli to ask-cli-1
"name": "ask-cli-1"
- Also change bin command from ask to ask1:
"bin": {
"ask1": "bin/ask.js"
}
- While in that directory in the command line do an npm pack. A file called ask-cli-1-1.7.23.tgz will be generated
npm pack
- Install it globally by doing:
npm install -g ask-cli-1-1.7.23.tgz
- You can now execute ask-cli v1 with ask1 (config files with profiles can be shared among v1 and v2 so this will still work)
- And if you still haven't done that go ahead and install/update the latest ask-cli v2 as usual with:
npm install -g ask-cli
The objective of these instructions is to keep the newest ask-cli v2.X.X running with the askx command and the old ask-cli v1.7.23 under the ask command without breaking the cli setup and getting the VSCode plugin to work again. See: (alexa/ask-toolkit-for-vscode#15)
> npm uninstall -g ask-cli-x // in case you still have the beta version installed, no longer used
> npm uninstall -g ask-cli // this will unistall your current ask-cli but won't delete your cli configuration
> npm install -g [email protected] // this will install your ask-cli as the latest v1 version (1.7.23)
> git clone [email protected]:alexa/ask-cli.git // this will clone the latest v2.x.x to you local machine
Go to project root directory and in package.json:
- Change package name from ask-cli to ask-cli-x
"name": "ask-cli-x"
- Change bin command from ask to askx:
"bin": {
"askx": "bin/ask.js"
}
> npm link // this will install the modified package globally (don't delete the project files, the installation links to it)
You're done!
But later, if you want to update the new cli you can't do npm install -g. Instead you have to force an overwrite of you local source files by using the following commands.
git fetch --all
git reset --hard origin/master
WARNING: the above will overwrite any local changes you have made with the latest version of ask-cli from github
But remember that you'll have to edit package.json again (as explained above). After updating and editing then you should install by running:
npm install
locally (not with -g).
If you're interested in automating this process check the comment below (great contribution with scripts!)
For Method 2, please note that if you have changed the package.json to askx when you do a
git pull
it will not update the package.json and hence when you runnpm install
you will still be using the old version.Instead of pull, you have to force an overwrite of you local source files (if that's what is intended) by using the following commands.
WARNING: the above will overwrite any local changes you have made with the latest version of ask-cli from github
then you can update by running
npm install
Also i find changing the ask->askx a repetitive task that is yelling out to be automated so I've written a javascript file that does that... combined together with a bash script. (so 2x files attached) Just drop the 2 files into the root folder of the source ask-cli (where package.json is) and run
./update.sh
(you might need to runchmod 755 ./update.sh
first (in linux/mac terminal) to make the file executable)Files in link below:
https://gist.github.com/goldzulu/3e41a864de6fd5e2b9a9fb3b7cf9bacc