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

gulp-deploy-http-push

Package Overview
Dependencies
Maintainers
7
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-deploy-http-push - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

.eslintrc.json

56

dist/deploy.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Token = require("./token");
var upload_1 = require("./upload");

@@ -8,3 +7,2 @@ var util_1 = require("./util");

function Deploy(options, modified, total, callback) {
var info = Token.getToken();
var steps = [];

@@ -28,40 +26,26 @@ modified.forEach(function (file, index) {

steps.push(function reduce(next) {
upload_1.upload(receiver, to, info, file.getHashRelease ? file.getHashRelease() : file.relative, file.contents, file, function (error) {
if (error) {
if (error.errno > 100000) {
// 检测到后端限制了上传,要求用户输入信息再继续。
if (!authApi || !validateApi) {
throw new Error('options.authApi and options.validateApi is required!');
}
if (info.email) {
console.error('\nToken is invalid: ', error.errmsg, '\n');
}
util_1.requireEmail(authApi, validateApi, info, function (err) {
if (err) {
throw new Error('Auth failed! ' + error.errmsg);
}
else {
reduce(next);
}
});
upload_1.upload(receiver, to, file.getHashRelease ? file.getHashRelease() : file.relative, file.contents, file, function (error) { return error ? errorHandler(file, error, function () { return reduce(next); }) : next(); });
});
function errorHandler(f, error, next) {
if (error.errno > 100000) {
// 检测到后端限制了上传,要求用户输入信息再继续。
util_1.requireEmail(authApi, validateApi, error, function (err) {
if (err) {
throw new Error('Auth failed! ' + error.errmsg);
}
else if (option.retry && !--reTryCount) {
throw new Error(error.errmsg || error);
}
else {
reduce(next);
}
}
else {
return next();
}
});
});
next();
});
}
else if (option.retry && !--reTryCount) {
throw new Error(error.errmsg || error);
}
else {
next();
}
}
});
steps.reduceRight(function (next, current, currentIndex, arr) {
return function () {
current(next);
};
steps.reduceRight(function (next, current) {
return function () { return current(next); };
}, callback)();
}
exports.Deploy = Deploy;

@@ -14,11 +14,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
/*
* @Author: qiansc
* @Date: 2019-05-07 14:31:35
* @Last Modified by: qiansc
* @Last Modified time: 2019-05-09 18:54:15
*
* fis3插件重构而来,实现不是很优雅
*/
var Url = require("url");
function fetch(url, data, callback) {

@@ -46,3 +37,3 @@ // var endl = '\r\n';

.on('end', function () {
if (status >= 200 && status < 300 || status === 304) {
if ((status >= 200 && status < 300) || status === 304) {
var json = false;

@@ -76,3 +67,3 @@ try {

opt = opt || {};
url = Url.parse(url);
url = url.URL(url);
var ssl = url.protocol === 'https:';

@@ -79,0 +70,0 @@ opt.host = opt.host || opt.hostname || ((ssl || url.protocol === 'http:') ? url.hostname : 'localhost');

@@ -9,5 +9,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var stream = require("readable-stream");
var filter_1 = require("./filter");
var restrictor_1 = require("./restrictor");
var stream = require("readable-stream");
var Transform = stream.Transform;

@@ -23,3 +23,3 @@ function httpPush(options) {

if (!option.match || (option.match && filter_1.include(file.path, option.match, {
root: file.base,
root: file.base
}))) {

@@ -29,6 +29,6 @@ restrictor.add({

retry: 2,
to: option.to,
to: option.to
}, {
contents: file.contents,
relative: '/' + file.relative,
relative: '/' + file.relative
});

@@ -41,5 +41,5 @@ // 在match名单中

callback();
},
}
});
}
exports.httpPush = httpPush;

@@ -14,12 +14,12 @@ "use strict";

retry: 2,
to: options.to,
to: options.to
}, {
contents: file.contents,
relative: '/' + file.relative,
relative: '/' + file.relative
});
}
callback();
},
}
});
}
exports.push = push;

@@ -19,9 +19,11 @@ "use strict";

var TOKEN_PATH = path_1.resolve(TOKEN_FILE);
var token = null;
function getToken() {
if (fs_1.existsSync(TOKEN_PATH)) {
return JSON.parse(fs_1.readFileSync(TOKEN_PATH).toString() || '{}');
if (token !== null) {
return token;
}
else {
return {};
}
token = fs_1.existsSync(TOKEN_PATH)
? JSON.parse(fs_1.readFileSync(TOKEN_PATH).toString() || '{}')
: {};
return token;
}

@@ -31,3 +33,4 @@ exports.getToken = getToken;

fs_1.writeFileSync(TOKEN_PATH, JSON.stringify(options, null, 2));
token = options;
}
exports.writeToken = writeToken;
import { IFile } from './file';
export declare function upload(receiver: any, to: any, data: any, release: any, content: any, file: IFile, callback: any): void;
export declare function upload(receiver: any, to: any, release: any, content: any, file: IFile, callback: any): void;

@@ -21,4 +21,5 @@ "use strict";

var fetch_1 = require("./fetch");
var token_1 = require("./token");
var util_1 = require("./util");
function upload(receiver, to, data, release, content, file, callback) {
function upload(receiver, to, release, content, file, callback) {
var subpath = file.subpath || file.relative;

@@ -28,3 +29,3 @@ if (!subpath) {

}
data.to = to + release;
var data = __assign(__assign({}, token_1.getToken()), { to: to + release });
fupload(

@@ -44,5 +45,5 @@ // url, request options, post data, file

}
else if (err || !json && res !== '0') {
callback('upload file [' + subpath + '] to [' + to + '] by receiver [' +
receiver + '] error [' + (err || res) + ']');
else if (err || (!json && res !== '0')) {
var info = 'upload file [' + subpath + '] to [' + to + '] by receiver [' + receiver + '] error [' + (err || res) + ']';
callback(info);
}

@@ -75,3 +76,3 @@ else {

if (typeof content === 'string') {
content = new Buffer(content, 'utf8');
content = Buffer.from(content, 'utf8');
}

@@ -105,3 +106,3 @@ else if (!(content instanceof Buffer)) {

if (typeof ele === 'string') {
length += new Buffer(ele).length;
length += Buffer.from(ele).length;
}

@@ -124,3 +125,3 @@ else {

.on('end', function () {
if (status >= 200 && status < 300 || status === 304) {
if ((status >= 200 && status < 300) || status === 304) {
callback(null, body);

@@ -127,0 +128,0 @@ }

@@ -1,2 +0,3 @@

export declare function requireEmail(authApi: any, validateApi: any, info: any, cb: any): void;
declare type Callback = (error?: Error) => void;
export declare function requireEmail(authApi: any, validateApi: any, prevError: any, cb: Callback): void;
export declare const Text: {

@@ -3,0 +4,0 @@ blod: typeof blod;

@@ -11,5 +11,22 @@ "use strict";

var fetch_1 = require("./fetch");
var Token = require("./token");
var token_1 = require("./token");
var waiting = [];
prompt.start();
function requireEmail(authApi, validateApi, info, cb) {
function resolve(err) {
while (waiting.length) {
waiting.pop()(err);
}
}
function requireEmail(authApi, validateApi, prevError, cb) {
if (!authApi || !validateApi) {
throw new Error('options.authApi and options.validateApi is required!');
}
waiting.push(cb);
if (waiting.length > 1) { // already getting
return;
}
var info = token_1.getToken();
if (info.email) {
console.error('\nToken is invalid: ', prevError.errmsg, '\n');
}
prompt.get({

@@ -21,21 +38,21 @@ properties: {

message: 'The specified value must be a valid email address.',
// tslint:disable-next-line:max-line-length
// eslint-disable-next-line
pattern: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
required: true,
},
},
required: true
}
}
}, function (error, ret) {
if (error) {
return cb(error);
return resolve(error);
}
info.email = ret.email;
Token.writeToken(info);
token_1.writeToken(info);
fetch_1.fetch(authApi, {
email: ret.email,
email: ret.email
}, function (err) {
if (err) {
return cb(error);
return resolve(error);
}
console.log('We\'re already sent the code to your email.');
requireToken(validateApi, info, cb);
requireToken(validateApi, info, resolve);
});

@@ -51,5 +68,5 @@ });

hide: true,
required: true,
},
},
required: true
}
}
}, function (error, ret) {

@@ -60,6 +77,6 @@ if (error) {

info.code = ret.code;
Token.writeToken(info);
token_1.writeToken(info);
fetch_1.fetch(validateApi, {
code: info.code,
email: info.email,
email: info.email
}, function (err, rs) {

@@ -70,3 +87,3 @@ if (err) {

info.token = rs.data.token;
Token.writeToken(info);
token_1.writeToken(info);
cb(null, info);

@@ -80,3 +97,3 @@ });

grey: grey,
yellow: yellow,
yellow: yellow
};

@@ -83,0 +100,0 @@ function green(str) {

{
"name": "gulp-deploy-http-push",
"version": "0.0.5",
"version": "0.1.0",
"discription": "gulp-deploy-http-push",
"scripts": {
"preversion": "npm run lint && npm run cover",
"lint": "tslint src/**/*.ts test/**/*.ts",
"lint": "eslint 'src/**/*.ts'",
"doc": "gulp doc",

@@ -17,10 +17,31 @@ "conf": "tsc && node_modules/ts-node/dist/bin.js src/configuration/generate.ts",

"watch": "gulp watch & npm start",
"start": "npm run url && http-server ./ -c-1 -p 8077"
"start": "npm run url && http-server ./ -c-1 -p 8077",
"commit": "git-cz",
"semantic-release": "semantic-release"
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
},
"repository": {
"type": "git",
"url": "git+http://xxx.com/demo"
"url": "https://github.com/searchfe/gulp-deploy-http-push"
},
"homepage": "http://xxx.com/demo",
"homepage": "https://github.com/searchfe/gulp-deploy-http-push",
"devDependencies": {
"eslint": "^5.16.0",
"@semantic-release/changelog": "^3.0.2",
"@semantic-release/commit-analyzer": "^6.1.0",
"@semantic-release/git": "^7.0.8",
"@semantic-release/npm": "^5.1.7",
"@semantic-release/release-notes-generator": "^7.1.4",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^2.3.0",
"@typescript-eslint/parser": "^2.3.0",
"@types/chai": "^4.1.4",

@@ -51,7 +72,17 @@ "@types/ftp": "^0.3.29",

"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typedoc": "^0.12.0",
"typedoc-plugin-markdown": "^1.1.15",
"typescript": "^3.1.6"
"typescript": "^3.1.6",
"semantic-release": "^15.13.27"
},
"release": {
"branch": "master",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
]
},
"dependencies": {

@@ -58,0 +89,0 @@ "prompt": "^1.0.0",

Sorry, the diff of this file is too big to display

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