Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
remove self updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed May 23, 2018
1 parent 186783b commit 8207e70
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 54 deletions.
14 changes: 0 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"assets": "./build/**/*"
},
"devDependencies": {
"@types/adm-zip": "^0.4.31",
"@types/commander": "^2.12.2",
"@types/form-data": "^2.2.1",
"@types/lowdb": "^1.0.1",
Expand All @@ -65,7 +64,6 @@
"webpack": "^3.10.0"
},
"dependencies": {
"adm-zip": "0.4.7",
"chalk": "2.4.1",
"commander": "2.15.1",
"form-data": "2.3.2",
Expand Down
34 changes: 0 additions & 34 deletions src/commands/update.command.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as AdmZip from 'adm-zip';
import * as program from 'commander';
import * as fs from 'fs';
import * as fetch from 'node-fetch';
import * as path from 'path';

import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';

Expand Down Expand Up @@ -56,29 +53,6 @@ export class UpdateCommand {
}
}

if ((cmd.self || false) && this.inPkg && process.platform !== 'win32') {
const zipResponse = await fetch.default(downloadUrl);
if (zipResponse.status === 200) {
const currentDir = path.dirname(process.execPath);
try {
const zipBuffer = await zipResponse.buffer();
const zip = new AdmZip(zipBuffer);
const stats = fs.statSync(process.execPath);
zip.extractAllTo(currentDir, true);
fs.chmodSync(path.join(currentDir, 'bw'), stats.mode);
res.title = 'Updated self to ' + tagName + '.';
if (responseJson.body != null && responseJson.body !== '') {
res.message = responseJson.body;
}
return Response.success(res);
} catch {
return Response.error('Error extracting update to ' + currentDir);
}
} else {
return Response.error('Error downloading update: ' + zipResponse.status);
}
}

res.title = 'A new version is available: ' + tagName;
if (downloadUrl == null) {
downloadUrl = 'https://github.com/bitwarden/cli/releases';
Expand All @@ -92,14 +66,6 @@ export class UpdateCommand {

res.message += 'You can download this update at ' + downloadUrl;

if ((cmd.self || false) && process.platform === 'win32') {
res.message += '\n`--self` updates are not available on Windows.';
} else if ((cmd.self || false) && !this.inPkg) {
res.message += '\n`--self` updates are only available in packaged executables.';
} else if (process.platform !== 'win32') {
res.message += '\nor just run `bw update --self`';
}

if (this.inPkg) {
res.message += '\n\nIf you installed this CLI through a package manager ' +
'you should probably update using its update command instead.';
Expand Down
4 changes: 0 additions & 4 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,17 @@ export class Program {
program
.command('update')
.description('Check for updates.')
.option('--self', 'Attempt to automatically update self.')
.on('--help', () => {
writeLn('\n Notes:');
writeLn('');
writeLn(' Returns the URL to download the newest version of this CLI tool.');
writeLn('');
writeLn(' Use the `--raw` option to return only the download URL for the update.');
writeLn('');
writeLn(' `--self` updates are not available on Windows.');
writeLn('');
writeLn(' Examples:');
writeLn('');
writeLn(' bw update');
writeLn(' bw update --raw');
writeLn(' bw update --self');
writeLn('', true);
})
.action(async (cmd) => {
Expand Down

0 comments on commit 8207e70

Please sign in to comment.