jjb-cmd 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/build.js +15 -0
- package/obf.config.json +3 -0
- package/package.json +1 -1
- package/src/new/cmd.auth/index.js +26 -1
- package/src/new/cmd.init/index.js +116 -1
- package/src/new/cmd.install/config.js +70 -1
- package/src/new/cmd.install/index.js +262 -1
- package/src/new/cmd.install/tools.js +230 -1
- package/src/new/cmd.install.app/index.js +27 -1
- package/src/new/cmd.jenkins/index.js +72 -1
- package/src/new/cmd.publish/index.js +197 -1
- package/src/new/cmd.push/index.js +76 -1
- package/src/new/cmd.push/java.js +148 -1
- package/src/new/cmd.push-set/index.js +205 -1
- package/src/new/cmd.refresh/index.js +65 -1
- package/src/new/cmd.reglist/index.js +23 -1
- package/src/new/cmd.rm-rf/index.js +58 -1
- package/src/new/cmd.version/index.js +35 -1
- package/src/old/cli.dva.register.saas.txt +40 -0
- package/src/old/cli.dva.register.spa.txt +22 -0
- package/src/old/cli.dva.router.saas.txt +210 -0
- package/src/old/cli.dva.router.spa.txt +119 -0
- package/src/old/cli.init.js +26 -1
- package/src/old/cli.install/config.js +206 -1
- package/src/old/cli.install/index.js +340 -1
- package/src/old/cli.install/tools.js +230 -1
- package/src/old/cli.merge.js +80 -1
- package/src/old/cli.pull.js +94 -1
- package/src/old/cli.pull2.js +377 -1
- package/src/old/cli.rm-rf.js +88 -1
- package/src/old/progress-bar.js +23 -1
- package/src/old/util.js +149 -1
package/src/old/cli.rm-rf.js
CHANGED
@@ -1 +1,88 @@
|
|
1
|
-
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
const readline = require('readline');
|
4
|
+
const ProgressBar = require('./progress-bar');
|
5
|
+
const io = readline.createInterface({
|
6
|
+
input: process.stdin,
|
7
|
+
output: process.stdout
|
8
|
+
});
|
9
|
+
const progress = new ProgressBar('删除进度', 50);
|
10
|
+
|
11
|
+
let f_total = 0;
|
12
|
+
let f_number = 0;
|
13
|
+
|
14
|
+
module.exports = function () {
|
15
|
+
const root_path = path.resolve('./');
|
16
|
+
|
17
|
+
io.question('是否确认删除?删除后不可恢复![y/n]:', function (answer) {
|
18
|
+
if (answer.trim() === 'y') {
|
19
|
+
console.log('正在计算项目数,请稍等...');
|
20
|
+
setTimeout(() => {
|
21
|
+
// scanner(root_path);
|
22
|
+
// console.log(`计算完成共计[${f_total}]项目。`);
|
23
|
+
setTimeout(() => {
|
24
|
+
console.clear();
|
25
|
+
exec(root_path);
|
26
|
+
setTimeout(() => {
|
27
|
+
console.log('删除完成。');
|
28
|
+
console.clear();
|
29
|
+
process.exit(0);
|
30
|
+
}, 500);
|
31
|
+
}, 500);
|
32
|
+
}, 500);
|
33
|
+
} else if (answer.trim() === 'n') {
|
34
|
+
console.log('取消删除。');
|
35
|
+
process.exit(0);
|
36
|
+
} else {
|
37
|
+
console.log('无效操作。');
|
38
|
+
process.exit(0);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
};
|
42
|
+
|
43
|
+
function exec (path) {
|
44
|
+
if (fs.existsSync(path)) {
|
45
|
+
const list = fs.readdirSync(path);
|
46
|
+
for (let i = 0; i < list.length; i++) {
|
47
|
+
const item = list[ i ];
|
48
|
+
const vPath = `${path}/${item}`;
|
49
|
+
try {
|
50
|
+
if (fs.statSync(vPath).isDirectory()) {
|
51
|
+
exec(vPath);
|
52
|
+
fs.rmdirSync(vPath, { recursive: true });
|
53
|
+
// f_number = f_number + 1;
|
54
|
+
console.log('删除文件夹:' + vPath);
|
55
|
+
} else {
|
56
|
+
fs.unlinkSync(vPath);
|
57
|
+
// f_number = f_number + 1;
|
58
|
+
console.log('删除文件:' + vPath);
|
59
|
+
}
|
60
|
+
// progress.render({
|
61
|
+
// completed: f_number,
|
62
|
+
// total: f_total
|
63
|
+
// });
|
64
|
+
} catch (e) {
|
65
|
+
console.log('删除异常:' + vPath);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
function scanner (path) {
|
72
|
+
if (fs.existsSync(path)) {
|
73
|
+
const list = fs.readdirSync(path);
|
74
|
+
for (let i = 0; i < list.length; i++) {
|
75
|
+
const item = list[ i ];
|
76
|
+
const vPath = `${path}/${item}`;
|
77
|
+
try {
|
78
|
+
if (fs.statSync(vPath).isDirectory()) {
|
79
|
+
scanner(vPath);
|
80
|
+
f_total = f_total + 1;
|
81
|
+
} else {
|
82
|
+
f_total = f_total + 1;
|
83
|
+
}
|
84
|
+
} catch (e) {
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
package/src/old/progress-bar.js
CHANGED
@@ -1 +1,23 @@
|
|
1
|
-
const
|
1
|
+
const slog = require('single-line-log').stdout;
|
2
|
+
|
3
|
+
function ProgressBar (description, bar_length) {
|
4
|
+
this.description = description || 'Progress';
|
5
|
+
this.length = bar_length || 25;
|
6
|
+
this.render = function (opts) {
|
7
|
+
let i;
|
8
|
+
const percent = (opts.completed / opts.total).toFixed(4);
|
9
|
+
const cell_num = Math.floor(percent * this.length);
|
10
|
+
let cell = '';
|
11
|
+
for (i = 0; i < cell_num; i++) {
|
12
|
+
cell += '█';
|
13
|
+
}
|
14
|
+
let empty = '';
|
15
|
+
for (i = 0; i < this.length - cell_num; i++) {
|
16
|
+
empty += '░';
|
17
|
+
}
|
18
|
+
const cmdText = this.description + ': ' + (100 * percent).toFixed(2) + '% ' + cell + empty + ' ' + opts.completed + '/' + opts.total;
|
19
|
+
slog(cmdText);
|
20
|
+
};
|
21
|
+
}
|
22
|
+
|
23
|
+
module.exports = ProgressBar;
|
package/src/old/util.js
CHANGED
@@ -1 +1,149 @@
|
|
1
|
-
'use strict';
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const fs = require('fs');
|
4
|
+
const path = require('path');
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @description 清空当前目录
|
8
|
+
* @param filePath
|
9
|
+
* @param callback
|
10
|
+
* @constructor
|
11
|
+
*/
|
12
|
+
exports.DeleteDirAllFile = (filePath, callback) => {
|
13
|
+
let files = [];
|
14
|
+
const that = this;
|
15
|
+
if(fs.existsSync(filePath)) {
|
16
|
+
files = fs.readdirSync(filePath);
|
17
|
+
files.forEach(function(file, index) {
|
18
|
+
let curPath = filePath + "/" + file;
|
19
|
+
if(fs.statSync(curPath).isDirectory()) {
|
20
|
+
that.DeleteDirAllFile(curPath);
|
21
|
+
} else {
|
22
|
+
fs.unlinkSync(curPath);
|
23
|
+
}
|
24
|
+
});
|
25
|
+
fs.rmdirSync(filePath);
|
26
|
+
callback && callback();
|
27
|
+
} else {
|
28
|
+
callback && callback();
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @description 复制文件夹及子目录文件
|
34
|
+
* @param srcDir
|
35
|
+
* @param tarDir
|
36
|
+
* @param cb
|
37
|
+
*/
|
38
|
+
exports.CopyFolder = (srcDir, tarDir, cb) => {
|
39
|
+
const that = this;
|
40
|
+
fs.readdir(srcDir, function(err, files) {
|
41
|
+
|
42
|
+
let count = 0
|
43
|
+
const checkEnd = function() {
|
44
|
+
++count === files.length && cb && cb()
|
45
|
+
}
|
46
|
+
|
47
|
+
if (err) {
|
48
|
+
checkEnd()
|
49
|
+
return
|
50
|
+
}
|
51
|
+
|
52
|
+
files.forEach(function(file) {
|
53
|
+
const srcPath = path.join(srcDir, file)
|
54
|
+
const tarPath = path.join(tarDir, file)
|
55
|
+
|
56
|
+
fs.stat(srcPath, function(err, stats) {
|
57
|
+
if (stats.isDirectory()) {
|
58
|
+
fs.mkdir(tarPath, function(err) {
|
59
|
+
if (err) {
|
60
|
+
console.log(err)
|
61
|
+
return
|
62
|
+
}
|
63
|
+
|
64
|
+
that.CopyFolder(srcPath, tarPath, checkEnd)
|
65
|
+
})
|
66
|
+
} else {
|
67
|
+
that.CopyFile(srcPath, tarPath, checkEnd)
|
68
|
+
}
|
69
|
+
})
|
70
|
+
})
|
71
|
+
//为空时直接回调
|
72
|
+
files.length === 0 && cb && cb()
|
73
|
+
})
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* @description 复制文件
|
78
|
+
* @param srcPath
|
79
|
+
* @param tarPath
|
80
|
+
* @param cb
|
81
|
+
*/
|
82
|
+
exports.CopyFile = (srcPath, tarPath, cb) => {
|
83
|
+
const rs = fs.createReadStream(srcPath)
|
84
|
+
rs.on('error', function(err) {
|
85
|
+
if (err) {
|
86
|
+
console.log('read error', srcPath)
|
87
|
+
}
|
88
|
+
cb && cb(err)
|
89
|
+
})
|
90
|
+
|
91
|
+
const ws = fs.createWriteStream(tarPath)
|
92
|
+
ws.on('error', function(err) {
|
93
|
+
if (err) {
|
94
|
+
console.log('write error', tarPath)
|
95
|
+
}
|
96
|
+
cb && cb(err)
|
97
|
+
})
|
98
|
+
ws.on('close', function(ex) {
|
99
|
+
cb && cb(ex)
|
100
|
+
})
|
101
|
+
|
102
|
+
rs.pipe(ws)
|
103
|
+
};
|
104
|
+
|
105
|
+
/**
|
106
|
+
* 深度获取目录路径
|
107
|
+
* @param path
|
108
|
+
* @param pathChildren
|
109
|
+
* @constructor
|
110
|
+
*/
|
111
|
+
exports.DeepScanner = (path, pathChildren) => {
|
112
|
+
const that = this;
|
113
|
+
const itemList = fs.readdirSync(path);
|
114
|
+
itemList.forEach(item => {
|
115
|
+
const childPath = `${path}/${item}`;
|
116
|
+
const stat = fs.statSync(childPath);
|
117
|
+
if (stat.isDirectory()) {
|
118
|
+
that.DeepScanner(childPath, pathChildren);
|
119
|
+
} else {
|
120
|
+
pathChildren.push(childPath);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
};
|
124
|
+
|
125
|
+
/**
|
126
|
+
* 创建目录路径
|
127
|
+
* @param pathArr
|
128
|
+
*/
|
129
|
+
exports.CreatePaths = (rootPath, pathArr) => {
|
130
|
+
return new Promise(resolve => {
|
131
|
+
const linkStr = [];
|
132
|
+
pathArr.forEach((item, index) => {
|
133
|
+
const dirPath = rootPath + '/' + linkStr.join('/') + '/' + item;
|
134
|
+
try {
|
135
|
+
const stat = fs.statSync(dirPath);
|
136
|
+
if (stat.isDirectory()) {
|
137
|
+
index === pathArr.length - 1 && resolve();
|
138
|
+
} else {
|
139
|
+
fs.mkdirSync(dirPath);
|
140
|
+
index === pathArr.length - 1 && resolve();
|
141
|
+
}
|
142
|
+
} catch (e) {
|
143
|
+
fs.mkdirSync(dirPath);
|
144
|
+
index === pathArr.length - 1 && resolve();
|
145
|
+
}
|
146
|
+
linkStr.push(item);
|
147
|
+
});
|
148
|
+
});
|
149
|
+
};
|