Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boom-deploy

Package Overview
Dependencies
Maintainers
1
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boom-deploy - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

.jscsrc

10

libs/fiber.js

@@ -1,4 +0,6 @@

var Fiber = require('fibers');
var Future = require('fibers/future');
'use strict';
const Fiber = require('fibers');
const Future = require('fibers/future');
// обернуть фибер в callback-функцию

@@ -8,3 +10,3 @@ exports.async = function(func, args, callback){

try {
var result = func.apply(null, args);
let result = func.apply(null, args);
callback(null, result);

@@ -20,3 +22,3 @@ } catch (e) {

return function(){
var future = new Future;
let future = new Future;
func(function (err, out) {

@@ -23,0 +25,0 @@ if (err) future.throw(err);

124

libs/github.js

@@ -1,14 +0,20 @@

var _ = require('lodash');
var fs = require('fs');
var path = require('path');
var async = require('async');
var GitHubApi = require('github');
var config = require('./config');
var readline = require('./readline');
'use strict';
const _ = require('lodash');
const fs = require('fs');
const path = require('path');
const async = require('async');
const GitHubApi = require('github');
const config = require('./config');
const readline = require('./readline');
let owner = config.get('owner');
let repo = config.get('name');
module.exports = {
token_path: path.resolve(config.userdir, '.github_token'),
token_path : path.resolve(config.userdir, '.github_token'),
token : null,
api: new GitHubApi({
api : new GitHubApi({
version : '3.0.0',

@@ -18,16 +24,8 @@ protocol : 'https'

data: {},
defaults: function(data){
return _.assign(data || {}, {
user : config.get('owner'),
repo : config.get('name')
})
},
login: function(cb){
var self = this;
self.getToken(function(err, token){
if (err) return cb(err);
self.api.authenticate({
login: function(callback){
this.getToken((err, token) => {
if (err) {
return callback(err);
}
this.api.authenticate({
type : 'token',

@@ -37,24 +35,22 @@ token : token

async.parallel({
repo : self.api.repos.get.bind(self.api.repos, self.defaults()),
user : self.api.user.get.bind(self.api.user, self.defaults())
}, function(err, data){
repo : this.api.repos.get.bind(this.api.repos, { owner, repo }),
user : this.api.user.get.bind(this.api.user, { owner, repo })
}, (err, data) => {
if (err) {
if (err.code == 401) {
self.removeTokenFile();
self.login(cb);
this.removeTokenFile();
this.login(callback);
return;
}
return cb(err);
return callback(err);
}
self.data.user = data.user;
self.data.repo = data.repo;
var login = data.user.login;
var defaultBranch = data.repo.default_branch;
var cloneUrl = data.repo.clone_url;
cloneUrl = cloneUrl.replace(/^(https?\:\/\/)(.*)/, '$1' + login + ':' + self.token + '@$2');
let login = data.user.login;
let defaultBranch = data.repo.default_branch;
let cloneUrl = data.repo.clone_url;
cloneUrl = cloneUrl.replace(/^(https?\:\/\/)(.*)/, `$1${login}:${this.token}@$2`);
config.set('login', login);
config.set('token', self.token);
config.set('token', this.token);
config.set('defaultBranch', defaultBranch);
config.set('cloneUrl', cloneUrl);
cb(null);
callback(null);
});

@@ -83,15 +79,15 @@ });

getToken: function(cb){
var self = this;
getToken: function(callback){
this.token = config.get('github_token') || this.readTokenFile();
self.token = config.get('github_token') || self.readTokenFile();
if (self.token) {
cb(null, self.token);
if (this.token) {
callback(null, this.token);
} else {
self.createToken(function(err, token){
if (err) return cb(err);
self.writeTokenFile(token);
self.token = token;
cb(null, token);
this.createToken((err, token) => {
if (err) {
return callback(err);
}
this.writeTokenFile(token);
this.token = token;
callback(null, token);
});

@@ -102,5 +98,4 @@ }

createToken: function(callback){
var self = this;
readline.askGithubHttpAuth(function(err, username, password){
self.api.authenticate({
readline.askGithubHttpAuth((err, username, password) => {
this.api.authenticate({
type : 'basic',

@@ -111,19 +106,19 @@ username : username,

var otp_code = null;
let otp_code = null;
function create(cb){
self.api.authorization.create({
this.api.authorization.create({
scopes : ['user', 'repo'],
note : 'boom-deploy',
headers : otp_code === null ? undefined : { 'X-GitHub-OTP': otp_code }
}, function(err, res) {
}, (err, res) => {
if (err) { // если ощибка при создании токена
var msg = JSON.parse(err.message);
let msg = JSON.parse(err.message);
// если токен для boom-deploy уже существует
if (err.code == 422) {
self.api.authorization.getAll({ headers: { 'X-GitHub-OTP': otp_code } }, function(err, res){
this.api.authorization.getAll({ headers: { 'X-GitHub-OTP': otp_code } }, (err, res) => {
if (err) return callback(err);
var token = _.find(res, { note: 'boom-deploy' });
let token = _.find(res, { note: 'boom-deploy' });
if (!token) {

@@ -134,3 +129,3 @@ return callback(new Error('Cannot find token on first page.'));

// удаляем токен
remove(token.id, function(err){
remove(token.id, err => {
if (err) return callback(err);

@@ -148,3 +143,3 @@ // создаем новый токен

}
readline.askOTPcode(function(err, code){
readline.askOTPcode((err, code) => {
if (err) return callback(err);

@@ -167,3 +162,3 @@ otp_code = code;

function remove(id, cb){
self.api.authorization.delete({
this.api.authorization.delete({
id : id,

@@ -180,6 +175,7 @@ headers : otp_code === null ? undefined : { 'X-GitHub-OTP': otp_code }

getCommits: function(branch, callback){
var self = this;
var options = self.defaults({ sha: branch, per_page: 15 });
self.api.repos.getCommits(options, function(err, commits){
if (err) return callback(err);
this.api.repos.getCommits({ owner, repo, sha: branch, per_page: 15 }, (err, commits) => {
if (err) {
return callback(err);
}
callback(null, commits);

@@ -186,0 +182,0 @@ })

{
"name": "boom-deploy",
"main": "boom.js",
"version": "0.5.0",
"version": "0.5.1",
"description": "deploy your app",

@@ -17,3 +17,3 @@ "keywords": [

"async": "0.9.0",
"fibers": "1.0.13",
"fibers": "1.0.15",
"github": "0.2.4",

@@ -20,0 +20,0 @@ "lodash": "3.3.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc