New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

fis-command-upgrade

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fis-command-upgrade - npm Package Compare versions

Comparing version

to
0.0.5

@@ -31,4 +31,5 @@ /*

var tmp = group[1].split('/');
v = 'static/common/ui/' + group[1] + '/' + tmp[tmp.length-1] + '.css';
return '/*@require common:' + v + '*/';
v = 'common:static/common/ui/' + group[1] + '/' + tmp[tmp.length-1] + '.css';
v = util.getStandardPath(v, namespace);
return '/*@require ' + v + '*/';
}else if(group[0] == 'macro'){

@@ -43,4 +44,8 @@ return '';

}else{
group = v.split('/');
v = 'static/' + namespace + '/ui/' + v + '/' + group[group.length-1] + '.css';
if(v.substr(0, 1) !== '/'){
group = v.split('/');
v = 'static/' + namespace + '/ui/' + v + '/' + group[group.length-1] + '.css';
}else{
v = v.substring(1);
}
}

@@ -54,5 +59,5 @@ var suffix = '.css';

if(group[group.length-2] == pth.basename(v, suffix)){
return '/*@require ' + namespace + ':' + v + '*/';
return '/*@require ' + util.getStandardPath(namespace + ':' + v, namespace) + '*/';
}else{
return m.replace(tmp, '\'/' + v +'?__inline\'');
return m.replace(tmp, '\'' + v +'?__inline\'');
}

@@ -59,0 +64,0 @@ }

@@ -22,6 +22,4 @@ /*

function inArray (needle, haystack, argStrict) {
// http://kevin.vanzonneveld.net
var key = '',
strict = !! argStrict;
if (strict) {

@@ -40,3 +38,2 @@ for (key in haystack) {

}
return false;

@@ -47,3 +44,4 @@ }

var group = '';
if ( v.indexOf(':') == -1) {
//没有:
if(v.indexOf(':') == -1) {
if(v.indexOf('.js') == -1){

@@ -69,3 +67,3 @@ group = v.split('/');

v = tpmnamespace + ":static/" + tpmnamespace + '/ui/' + group[1] + '/' + grouptmp[grouptmp.length-1] + '.js';
}else if (tpmnamespace == 'tangram' || tpmnamespace == 'magic') {
}else if (inArray(tpmnamespace, libs)) {
if(group[1] == '' && tpmnamespace == 'magic'){

@@ -80,2 +78,3 @@ v = 'common:static/common/lib/magic/magic.js';

}
v = util.getStandardPath(v, namespace);
return v;

@@ -82,0 +81,0 @@ }

@@ -13,3 +13,3 @@ /*

content = replaceWidget(content, namespace, ld, rd, widgetInline);
content = replaceExtends(content, ld, rd, filepath, root)
content = replaceExtends(content, ld, rd, filepath, root, namespace)
content = replaceInclude(content, namespace, ld, rd, filepath, root)

@@ -42,3 +42,3 @@ content = replaceHTML(content, ld, rd);

v = namespace+':'+v;
m1 = 'name=' + info.quote + v + info.quote + ' ';
m1 = 'name=' + info.quote + util.removeModuleName(v, namespace) + info.quote + ' ';
}

@@ -59,3 +59,3 @@ return m1;

v = namespace+':'+v;
m1 = 'name=' + info.quote + v + info.quote + ' ';
m1 = 'name=' + info.quote + util.removeModuleName(v, namespace) + info.quote + ' ';
}else{

@@ -69,3 +69,3 @@ var group = v.split(':');

path = v;
m1 = 'name=' + info.quote + group[0] + ':' + v + info.quote + ' ';
m1 = 'name=' + info.quote + group[0] + ':' + util.removeModuleName(v, namespace) + info.quote + ' ';
}

@@ -98,3 +98,3 @@ }

function replaceExtends(content, ld, rd, filepath, root){
function replaceExtends(content, ld, rd, filepath, root, namespace){
var l_ld = pregQuote(ld);

@@ -109,4 +109,4 @@ var l_rd = pregQuote(rd);

var v1 = value.replace(regfile, function (m1, v) {
if(v.indexOf(':') != -1){
return m1;
if(v.indexOf(':') !== -1){
return util.removeModuleName(m1, namespace);
}

@@ -121,5 +121,5 @@ v = v.substring(1, v.length-1);

if(group[1] == 'common'){
return 'file=\'' + group[1] + ':' + v + '\'';
return 'file=\'' + util.removeModuleName(group[1] + ':' + v, namespace) + '\'';
}
return 'file=\'' + v + '\'';
return 'file=\'' + util.removeModuleName(v, namespace) + '\'';
});

@@ -150,3 +150,3 @@ return m.replace(value, v1);

if(v.indexOf(':') != -1){
return m1;
return util.removeModuleName(m1, namespace);
}

@@ -162,5 +162,5 @@ v = v.substring(1, v.length-1);

if(group[1] == 'common'){
return 'file=\'' + group[1] + ':' + v + '\'';
return 'file=\'' + util.removeModuleName(group[1] + ':' + v, namespace) + '\'';
}
return 'file=\'' + v + '\'';
return 'file=\'' + util.removeModuleName(v, namespace) + '\'';
}

@@ -167,0 +167,0 @@ path = v;

@@ -13,3 +13,3 @@ /*

if(reg.test(content)){
return true;
return true;
}

@@ -20,3 +20,3 @@ return false;

util.detMarco = function(content){
var reg = /\{[^}]+{/;
var reg = /\{[^}]+{/;
if(reg.test(content)){

@@ -83,2 +83,82 @@ return true;

return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}
function inArray (needle, haystack, argStrict) {
var key = '',
strict = !! argStrict;
if (strict) {
for (key in haystack) {
if (haystack[key] === needle) {
return true;
}
}
} else {
for (key in haystack) {
if (haystack[key] == needle) {
return true;
}
}
}
return false;
}
/**
* 去掉模块名那一层 common:static/common/ui/a/a.js => common:static/ui/a/a.js
* @param v
* @param namespace
* @returns {string}
*/
util.removeModuleName = function(v, namespace){
if (typeof(v) === "undefined") return '';
var pathSplit = [];
if(v.indexOf(':') !== -1) {
var group = v.split(':');
var tpmnamespace = util.trim(group[0]);
pathSplit = group[1].split('/');
if(pathSplit[1] == tpmnamespace){
pathSplit.splice(1, 1);
v = tpmnamespace + ':' + pathSplit.join('/');
return v;
}
}else{
pathSplit = v.split('/');
if(pathSplit[1] == namespace || pathSplit[1] == 'common'){
pathSplit.splice(1, 1);
v = pathSplit.join('/');
return v;
}
}
return v;
}
/**
* 将common:static/ui/a/a.js 组件化放到widget下 common:widget/ui/a/a.js
* common:static/lib/tangram/base.js => common:widget/lib/tangram/base.js ????
* @param v
* @param namespace
*/
function moveUiToWidget(v, namespace){
if (typeof(v) === "undefined") return '';
var tpmnamespace = '';
var pathSplit = [];
if(v.indexOf(':') !== -1){
var group = v.split(':');
tpmnamespace = util.trim(group[0]);
pathSplit = group[1].split('/');
}else{
pathSplit = v.split('/');
}
if(pathSplit[0] == 'static' && inArray(pathSplit[1], ['ui', 'lib'])){
pathSplit.splice(0, 1, 'widget');
v = tpmnamespace ? tpmnamespace + ':' + pathSplit.join('/') : pathSplit.join('/');
}
return v;
}
util.getStandardPath = function(v, namespace){
if (typeof(v) === "undefined") return '';
v = util.removeModuleName(v, namespace);
v = moveUiToWidget(v, namespace);
return v;
}
{
"name": "fis-command-upgrade",
"version": "0.0.4",
"version": "0.0.5",
"description": "This tool can help you upgrade your project from FIS-1.x to FIS-2.x.",

@@ -5,0 +5,0 @@ "main": "upgrade.js",

@@ -28,3 +28,2 @@ /*

.option('--rd <smarty right delimiter>', 'smarty right delimiter', String, '%}')
.option('--model <Upgrade model>', 'Upgrade model', String, '0')
.action(function(options) {

@@ -38,2 +37,5 @@ namespace = options.namespace;

var xmlpath = root + '/config/fis-config.xml';
var rootSplit = root.split('/');
rootSplit.splice(rootSplit.length - 1, 1, rootSplit[rootSplit.length - 1] + '_2.0');
var projectRoot = rootSplit.join('/');
if(_exists(xmlpath)){

@@ -74,33 +76,58 @@ xmlreader.read(fis.util.read(xmlpath), function(errors, res){

var jsContext = new Array();
fis.util.find(root, /.*\.(tpl|js|html|css)$/).forEach(function(filepath) {
var content = fis.util.read(filepath);
content = js.update(content, namespace,filepath, root);
filepath = filepath.replace(/[\/\\]+/g, '/');
content = css.update(content, namespace, filepath, root);
if(/\.tpl$/.test(filepath)){
content = tpl.update(content, namespace, ld, rd, filepath, root, widgetInline);
fis.util.find(root).forEach(function(filepath) {
if(fis.util.isImageFile(filepath)) {
fis.util.copy(filepath, projectRoot + '/' + util.getStandardPath(filepath.replace(root + '/', ''), namespace));
}
if(model == 1){
filepath = root + '/' + namespace + '_2' +filepath.replace(root, '');
}
fis.util.write(filepath, content);
if(/.*\.(tpl|js|html|css)$/.test(filepath)){
var content = fis.util.read(filepath);
content = js.update(content, namespace,filepath, root);
filepath = filepath.replace(/[\/\\]+/g, '/');
content = css.update(content, namespace, filepath, root);
if(/\.tpl$/.test(filepath)){
content = tpl.update(content, namespace, ld, rd, filepath, root, widgetInline);
}
filepath = projectRoot + '/' + util.getStandardPath(filepath.replace(root + '/', ''), namespace);
fis.util.write(filepath, content);
if(/\.tpl$/.test(filepath) && util.detWidgetExtends(content, ld, rd)){
widget.push(filepath);
if(/\.tpl$/.test(filepath) && util.detWidgetExtends(content, ld, rd)){
widget.push(filepath);
}
if(/\.css$/.test(filepath) && util.detMarco(content)){
fs.renameSync(filepath, filepath.replace(/\.css/, '.less'));
macro.push(filepath);
}
if(util.detContext(content)){
jsContext.push(filepath);
}
}
if(/\.css$/.test(filepath) && util.detMarco(content)){
fs.renameSync(filepath, filepath.replace(/\.css/, '.less'));
macro.push(filepath);
}
if(util.detContext(content)){
jsContext.push(filepath);
}
});
if(fis.util.isDir(root + "/test")){
fis.util.find(root + "/test").forEach(function(filepath) {
var content = fis.util.read(filepath);
filepath = filepath.replace(/[\/\\]+/g, '/');
filepath = projectRoot + '/test/' + util.getStandardPath(filepath.replace(root + '/test/', ''), namespace);
fis.util.write(filepath, content);
});
}
if(fis.util.isDir(root + "/plugin")){
fis.util.find(root + "/plugin").forEach(function(filepath) {
var content = fis.util.read(filepath);
filepath = filepath.replace(/[\/\\]+/g, '/');
filepath = filepath.replace(root, projectRoot);
fis.util.write(filepath, content);
});
}
fis.util.find(root + "/config", /.*\.(conf)$/).forEach(function(filepath) {
var content = fis.util.read(filepath);
filepath = filepath.replace(/[\/\\]+/g, '/');
filepath = projectRoot + '/' + util.getStandardPath(filepath.replace(root + '/', ''), namespace);
fis.util.write(filepath, content);
});
var config = 'fis.config.merge({\n'
+ ' namespace : \'' + namespace +'\',\n'
+ '});';
var configPath = root + '/fis-conf.js';
var configPath = projectRoot + '/fis-conf.js';
fis.util.write(configPath, config);
if(macro.length >0 && widget.length > 0){
fis.util.write(root + '/detect.html', createHTML(macro, widget,jsContext));
fis.util.write(projectRoot + '/detect.html', createHTML(macro, widget,jsContext));
}

@@ -107,0 +134,0 @@ });

Sorry, the diff of this file is not supported yet