Skip to content

Commit

Permalink
Add more information about versions of TARS and TARS-CLI
Browse files Browse the repository at this point in the history
Then you are in project folder, tar -v will return version of TARS in current project
and information about updating for your local project.
  • Loading branch information
artem-malko committed Apr 16, 2016
1 parent 71e83dc commit b5a6dc5
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ script:
- mkdir tars-temp
- cd tars-temp
- tars init --silent
- tars -v
- tars update-project
- tars -v
- tars upgrade-project -f
- tars -v
- tars add-module new -e
- tars add-module new_ --empty
- tars add-module new1 -f
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ All commands have similar template of executing:

You can run the `tars --help` or `tars -h` or just `tars` without additional command and flags at any moment. This command displays information about all available commands and flags. Also you can add the `--help` key or `-h` key to any command to get full description of this command.

`tars -v` or `tars --version` will display current version of TARS-CLI installed on your computer. Also, you will be informed about updating, if it is available.
`tars -v` or `tars --version` will display current version of TARS-CLI installed on your computer and current version of TARS in current project. Also, you will be informed about updating, if it is available.

Almost all command has the interactive mode. In this mode you can to communicate with CLI like it has its own GUI. If you are using interactive mode you don’t need to know what the flags are responsible for, because you are communicate with CLI with natural language. Interactive mode is easy to disable if you use automatic testing or something else that doesn’t require the human presence.

Expand Down
2 changes: 1 addition & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tars init

В любой момент можно запустить `tars --help` или `tars -h` или просто `tars`, без дополнительных комманд и флагов. Данная команда выведет информацию о всех доступных командах. Также можно добавить ключ `--help` или `-h` к любой команде, чтобы получить наиболее полное описание команды.

`tars -v` или `tars --version` выведет текущую установленную версию TARS-CLI. Также будет выведена информация по обновлению, если оно доступно.
`tars -v` или `tars --version` выведет текущую установленную версию TARS-CLI и версию TARS в текущем проекте. Также будет выведена информация по обновлению, если оно доступно.

Практически во всех командах доступен интерактивный режим. В данном режиме вы сможете взаимодействовать с CLI через подобие графического интерфейса. При использовании интерактивного режима вам не нужно знать, какие флаги за что отвечают, так как вы общаетесь с CLI на естественном языке. Интерактивный режим легко отключить, если вам необходимо проводить автоматическое тестирование или что-то еще, что не требует присутствие человека.

Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
- cmd: mkdir tars-temp
- cmd: cd tars-temp
- cmd: tars init --silent
- cmd: tars -v
- cmd: tars update-project
- cmd: tars -v
- cmd: tars upgrade-project -f
- cmd: tars -v
- cmd: tars add-module new -e
- cmd: tars add-module new_ --empty
- cmd: tars add-module new1 -f
Expand Down
60 changes: 46 additions & 14 deletions lib/command-actions/get-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,57 @@ const Download = require('download');
* Get version of tars-cli
*/
module.exports = function getVersion() {
console.log('\n');
const installedTarsCliVersion = require(`${process.env.cliRoot}/package.json`).version;
tarsUtils.tarsSay(`TARS-CLI version: "${chalk.cyan.bold(installedTarsCliVersion)}"`, true);

console.log('\n');
tarsUtils.tarsSay(`Tars-cli version: "${chalk.cyan.bold(installedTarsCliVersion)}"`, true);
Promise
.resolve()
.then(() => new Promise(resolve => {
new Download({ extract: true, mode: '755' })
.get('https://raw.githubusercontent.com/tars/tars-cli/master/package.json')
.run((error, files) => {
if (error) {
return resolve();
}

new Download({ extract: true, mode: '755' })
.get('https://raw.githubusercontent.com/tars/tars-cli/master/package.json')
.run((error, files) => {
if (error) {
return false;
}
const latestTarsCliVersion = JSON.parse(files[0].contents.toString()).version;

const latestTarsCliVersion = JSON.parse(files[0].contents.toString()).version;
if (installedTarsCliVersion < latestTarsCliVersion) {
tarsUtils.tarsSay(`Update available for TARS-CLI! New version is: "${chalk.cyan.bold(latestTarsCliVersion)}"`, true);
tarsUtils.tarsSay(`Run the command "${chalk.cyan.bold('tars update')}" to update TARS-CLI. \n`, true);
}
return resolve();
});
}))
.then(() => {
let installedTarsVersion;

if (installedTarsCliVersion < latestTarsCliVersion) {
tarsUtils.tarsSay(`Update available! New version is: ${chalk.cyan.bold(latestTarsCliVersion)}`, true);
tarsUtils.tarsSay(`Run the command ${chalk.cyan.bold('tars update')} to update TARS-cli. \n`, true);
try {
installedTarsVersion = require(`${process.cwd()}/tars.json`).version;
tarsUtils.tarsSay(`TARS version in current project: "${chalk.cyan.bold(installedTarsVersion)}"`, true);
} catch (error) {
/* eslint-disable no-undefined */
installedTarsVersion = undefined;
/* eslint-enable no-undefined */
}
});

console.log('\n');
new Download({ extract: true, mode: '755' })
.get('https://raw.githubusercontent.com/tars/tars/master/package.json')
.run((error, files) => {
if (error || !installedTarsVersion) {
return false;
}

const latestTarsVersion = JSON.parse(files[0].contents.toString()).version;

if (installedTarsVersion < latestTarsVersion) {
tarsUtils.tarsSay(`Update available for TARS! New version is: "${chalk.cyan.bold(latestTarsVersion)}"`, true);
tarsUtils.tarsSay(`Run the command "${chalk.cyan.bold('tars update-project')}" to update TARS in current project. \n`, true);
}
});
})
.catch(error => {
console.log(error);
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tars-cli",
"version": "1.7.2",
"version": "1.7.3",
"engines": {
"npm": "^3.x.x",
"node": "^4.x.x"
Expand Down

0 comments on commit b5a6dc5

Please sign in to comment.