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

tpm

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tpm - npm Package Compare versions

Comparing version 1.0.26 to 1.1.0

4

package.json
{
"name": "tpm",
"version": "1.0.26",
"version": "1.1.0",
"description": "Static Package Manager",

@@ -22,3 +22,3 @@ "author": "Longhao Luo <lhluo@tudou.com>",

"less": "~1.4.0-b2",
"ozma-tudou": ">=1.4.3",
"ozma-tudou": ">=1.5.1",
"uglify-js": "~2.3.6",

@@ -25,0 +25,0 @@ "clean-css": "0.9.1",

@@ -82,5 +82,5 @@ var Path = require('path');

}
if (value) {
result[path] = value;
}
result[path] = value;
pathCount--;

@@ -95,4 +95,6 @@ if (pathCount === 0) {

cp.stderr.on('data', function(stderr){
result[path] = null;
pathCount--;
Util.error('[SVN] ' + stderr);
Util.error('[SVN] get info failed, please commit "' + path + '"');
});

@@ -102,2 +104,14 @@ });

// 优化图片
function optimizeImg(distPath) {
// 在Windows下优化PNG
if (process.platform === 'win32' && /\.png$/i.test(distPath)) {
var cmd = '"' + Path.resolve(__dirname + '/../bin/PngOptimizerCL').replace(/\\/g, '\\\\') + '" -file:"' + distPath.replace(/\\/g, '\\\\') + '"';
console.log(cmd);
ChildProcess.exec(cmd);
}
}
// 图片版本化

@@ -147,5 +161,10 @@ function renameAssets(cssPath, content, callback) {

_.each(data, function(version, path) {
var buildPath = addVersion(getBuildPath(path), version);
var distPath = addVersion(getDistPath(path), version);
var buildPath = getBuildPath(path);
var distPath = getDistPath(path);
if (version) {
buildPath = addVersion(buildPath, version);
distPath = addVersion(distPath, version);
}
if (!Fs.existsSync(buildPath) || Util.mtime(path) >= Util.mtime(buildPath)) {

@@ -157,11 +176,3 @@ Util.copyFile(path, buildPath);

Util.copyFile(path, distPath);
// 在Windows下优化PNG
if (process.platform === 'win32' && /\.png$/i.test(distPath)) {
var cmd = '"' + Path.resolve(__dirname + '/../bin/PngOptimizerCL').replace(/\\/g, '\\\\') + '" -file:"' + distPath.replace(/\\/g, '\\\\') + '"';
console.log(cmd);
var cp = ChildProcess.exec(cmd);
}
optimizeImg(distPath);
}

@@ -224,2 +235,8 @@ });

Util.setSvnKeywords(distPath);
// 检测测试用alert
var match = /\balert\(\d+\)/.exec(Util.readFileSync(buildPath, 'utf-8'));
if (match) {
Util.error('[ERROR] detected debug code "' + match[0] + '" at "' + buildPath + '"');
}
});

@@ -261,2 +278,4 @@ }

Util.copyFile(path, distPath);
optimizeImg(distPath);
}

@@ -263,0 +282,0 @@

@@ -43,3 +43,5 @@

}
contentList.push(line);
if (line) {
contentList.push(line);
}
pathCount--;

@@ -58,3 +60,3 @@ if (pathCount === 0) {

pathCount--;
Util.error('[SVN] ' + stderr);
Util.error('[SVN] get info failed, please commit "' + path + '"');
});

@@ -72,18 +74,7 @@ });

var distDirPath = Path.resolve(config.root + '/dist');
if (args.length < 1) {
console.log(DIFF_USAGE);
return;
}
// 列出未上线的所有图片文件
if (args[0] == 'img') {
var env = args[1] || '';
var imgList = Util.grepPaths(distDirPath + '/img', function(path) {
return /\.(jpg|png|gif|ico|swf)$/.test(path);
});
var pathCount = imgList.length;
// 列出未上线的文件
function listNoDeployedFiles(fileList, env) {
var pathCount = fileList.length;
var pathList = [];
imgList.forEach(function(path) {
fileList.forEach(function(path) {
var url = 'http://css' + env + '.tudouui.com/v3/' + getRelativePath(path);

@@ -105,2 +96,8 @@ Request(url, function (error, response, body) {

});
}
var distDirPath = Path.resolve(config.root + '/dist');
if (args.length < 1) {
console.log(DIFF_USAGE);
return;

@@ -113,3 +110,3 @@ }

var cmd = 'svn diff -r' + revision + ':HEAD --summarize --no-diff-deleted "' + distDirPath.replace(/\\/g, '\\\\') + '"';
var cmd = 'svn diff -r' + (revision - 1) + ':HEAD --summarize --no-diff-deleted "' + distDirPath.replace(/\\/g, '\\\\') + '"';

@@ -152,9 +149,59 @@ console.log(cmd);

// 根据项目文件输出列表
var path = args[0];
if (Util.indir(args[0], config.root + '/project')) {
var projectPath = args[0];
var pathList = Util.readProjectFile(config, path, 'dist');
var pathList = Util.readProjectFile(config, projectPath, 'dist');
var basename = Path.basename(path, '.txt');
var basename = Path.basename(projectPath, '.txt');
openEmail(config, basename, pathList);
openEmail(config, basename, pathList);
return;
}
// 根据CSS文件,列出未上线的所有图片文件
if (Util.indir(args[0], config.root + '/dist/css')) {
var cssPath = args[0];
var env = args[1] || '';
var dirPath = Path.dirname(cssPath);
function url2path(url) {
var path = '';
if (url.charAt(0) == '.') {
path = Path.resolve(dirPath + '/' + url);
} else if (url.charAt(0) == '/') {
path = Path.resolve(config.root + '/../' + url);
}
return path;
}
var content = Util.readFileSync(cssPath, 'utf-8');
content = content.replace(/\/\*[\S\s]*?\*\//g, '');
var match;
var regExp = /url\("?((?:\\"|[^"\)])+)"?\)/g;
var pathList = [];
while((match = regExp.exec(content))) {
var url = match[1];
var path = url2path(url);
if (path) {
pathList.push(path);
}
}
listNoDeployedFiles(pathList, env);
return;
}
// 直接指定路径,列出所有未上线的文件
if (Util.indir(args[0], config.root + '/dist')) {
var dirPath = args[0];
var env = args[1] || '';
var pathList = Util.grepPaths(dirPath, function(path) {
return /\.(jpg|png|gif|ico|swf|swz|eot|svg|ttf|woff)$/i.test(path);
});
listNoDeployedFiles(pathList, env);
}
};
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