cloudcc-cli 1.7.2 → 1.7.4
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 +1219 -1204
- package/bin/cc.js +49 -49
- package/bin/plugin.js +6 -6
- package/bin/project.js +6 -6
- package/core/core/ServiceResult.java +35 -35
- package/core/core/UserInfo.java +45 -45
- package/package.json +34 -34
- package/src/classes/create.js +40 -40
- package/src/classes/index.js +8 -8
- package/src/classes/publish.js +43 -43
- package/src/config/get.js +20 -20
- package/src/config/index.js +8 -8
- package/src/config/use.js +14 -14
- package/src/object/get.js +14 -14
- package/src/object/index.js +7 -7
- package/src/plugin/create.js +70 -70
- package/src/plugin/create1.js +58 -58
- package/src/plugin/index.js +8 -8
- package/src/plugin/publish.js +262 -262
- package/src/plugin/publish1.js +256 -256
- package/src/project/create.js +87 -87
- package/src/project/create1.js +109 -109
- package/src/project/index.js +7 -7
- package/src/recordType/get.js +13 -13
- package/src/recordType/index.js +7 -7
- package/src/script/create.js +29 -29
- package/src/script/index.js +8 -8
- package/src/script/publish.js +62 -62
- package/src/timer/create.js +26 -26
- package/src/timer/index.js +8 -8
- package/src/timer/publish.js +43 -43
- package/src/token/get.js +11 -11
- package/src/token/index.js +7 -7
- package/src/triggers/create.js +27 -27
- package/src/triggers/index.js +8 -8
- package/src/triggers/publish.js +48 -48
- package/template/Appvue +24 -24
- package/template/babelconfigjs +5 -5
- package/template/demojava +14 -14
- package/template/gitignore +11 -11
- package/template/index.js +57 -57
- package/template/indexhtml +21 -21
- package/template/indexvue +29 -29
- package/template/javaconfigjson +2 -2
- package/template/mainjs +13 -13
- package/template/package-lockjson +13952 -13952
- package/template/packagejson +42 -42
- package/template/vueconfigjs +21 -21
- package/tool/branch/index.js +25 -25
- package/tool/checkLange/checkLang.js +68 -68
- package/tool/checkLange/clearLang.js +85 -85
- package/utils/checkVersion.js +90 -94
- package/utils/config.js +18 -0
- package/utils/http.js +123 -123
- package/utils/utils.js +40 -58
package/template/packagejson
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cloudcc-plugin",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "cloudcc-plugin-dev",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"serve": "vue-cli-service serve"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"element-ui": "2.15.12",
|
|
10
|
-
"vue": "2.6.14",
|
|
11
|
-
"vue-custom-element": "3.3.0"
|
|
12
|
-
},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"@vue/cli-plugin-babel": "~4.5.0",
|
|
15
|
-
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
16
|
-
"@vue/cli-service": "~4.5.0",
|
|
17
|
-
"babel-eslint": "^10.1.0",
|
|
18
|
-
"eslint": "^6.7.2",
|
|
19
|
-
"eslint-plugin-vue": "^6.2.2",
|
|
20
|
-
"sass": "1.26.8",
|
|
21
|
-
"sass-loader": "8.0.2",
|
|
22
|
-
"vue-template-compiler": "2.6.14"
|
|
23
|
-
},
|
|
24
|
-
"eslintConfig": {
|
|
25
|
-
"root": true,
|
|
26
|
-
"env": {
|
|
27
|
-
"node": true
|
|
28
|
-
},
|
|
29
|
-
"extends": [
|
|
30
|
-
"plugin:vue/essential",
|
|
31
|
-
"eslint:recommended"
|
|
32
|
-
],
|
|
33
|
-
"parserOptions": {
|
|
34
|
-
"parser": "babel-eslint"
|
|
35
|
-
},
|
|
36
|
-
"rules": {}
|
|
37
|
-
},
|
|
38
|
-
"browserslist": [
|
|
39
|
-
"> 1%",
|
|
40
|
-
"last 2 versions",
|
|
41
|
-
"not dead"
|
|
42
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"name": "cloudcc-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "cloudcc-plugin-dev",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"element-ui": "2.15.12",
|
|
10
|
+
"vue": "2.6.14",
|
|
11
|
+
"vue-custom-element": "3.3.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@vue/cli-plugin-babel": "~4.5.0",
|
|
15
|
+
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
16
|
+
"@vue/cli-service": "~4.5.0",
|
|
17
|
+
"babel-eslint": "^10.1.0",
|
|
18
|
+
"eslint": "^6.7.2",
|
|
19
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
20
|
+
"sass": "1.26.8",
|
|
21
|
+
"sass-loader": "8.0.2",
|
|
22
|
+
"vue-template-compiler": "2.6.14"
|
|
23
|
+
},
|
|
24
|
+
"eslintConfig": {
|
|
25
|
+
"root": true,
|
|
26
|
+
"env": {
|
|
27
|
+
"node": true
|
|
28
|
+
},
|
|
29
|
+
"extends": [
|
|
30
|
+
"plugin:vue/essential",
|
|
31
|
+
"eslint:recommended"
|
|
32
|
+
],
|
|
33
|
+
"parserOptions": {
|
|
34
|
+
"parser": "babel-eslint"
|
|
35
|
+
},
|
|
36
|
+
"rules": {}
|
|
37
|
+
},
|
|
38
|
+
"browserslist": [
|
|
39
|
+
"> 1%",
|
|
40
|
+
"last 2 versions",
|
|
41
|
+
"not dead"
|
|
42
|
+
]
|
|
43
43
|
}
|
package/template/vueconfigjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const external = process.env.NODE_ENV == 'development' ? {} : {
|
|
2
|
-
"vue": 'Vue',
|
|
3
|
-
"vue-router": 'VueRouter',
|
|
4
|
-
'vue-echarts': 'VueECharts',
|
|
5
|
-
'element-ui': 'ELEMENT',
|
|
6
|
-
"axios": 'axios',
|
|
7
|
-
"d3": 'd3',
|
|
8
|
-
'echarts': 'echarts',
|
|
9
|
-
"jschardet": 'jschardet',
|
|
10
|
-
"crypto-js": 'CryptoJS',
|
|
11
|
-
"vue-i18n": 'VueI18n',
|
|
12
|
-
}
|
|
13
|
-
module.exports = {
|
|
14
|
-
publicPath: '/',
|
|
15
|
-
productionSourceMap: false,
|
|
16
|
-
configureWebpack: {
|
|
17
|
-
},
|
|
18
|
-
css: { extract: false },
|
|
19
|
-
chainWebpack: config => {
|
|
20
|
-
config.externals(external)
|
|
21
|
-
}
|
|
1
|
+
const external = process.env.NODE_ENV == 'development' ? {} : {
|
|
2
|
+
"vue": 'Vue',
|
|
3
|
+
"vue-router": 'VueRouter',
|
|
4
|
+
'vue-echarts': 'VueECharts',
|
|
5
|
+
'element-ui': 'ELEMENT',
|
|
6
|
+
"axios": 'axios',
|
|
7
|
+
"d3": 'd3',
|
|
8
|
+
'echarts': 'echarts',
|
|
9
|
+
"jschardet": 'jschardet',
|
|
10
|
+
"crypto-js": 'CryptoJS',
|
|
11
|
+
"vue-i18n": 'VueI18n',
|
|
12
|
+
}
|
|
13
|
+
module.exports = {
|
|
14
|
+
publicPath: '/',
|
|
15
|
+
productionSourceMap: false,
|
|
16
|
+
configureWebpack: {
|
|
17
|
+
},
|
|
18
|
+
css: { extract: false },
|
|
19
|
+
chainWebpack: config => {
|
|
20
|
+
config.externals(external)
|
|
21
|
+
}
|
|
22
22
|
}
|
package/tool/branch/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
const exec = require('child_process').execSync;
|
|
2
|
-
const fs = require("fs")
|
|
3
|
-
function checkBranch(inBranch, notInBranch, condition = '') {
|
|
4
|
-
exec(`git remote prune origin`)
|
|
5
|
-
let in_branch = exec(`git branch -r --merged origin/${inBranch}`).toString("utf8").trim().split("\n ")
|
|
6
|
-
let guolv = [];
|
|
7
|
-
in_branch.map((branch) => {
|
|
8
|
-
try {
|
|
9
|
-
let containsBranch = ""
|
|
10
|
-
if (branch.indexOf("origin/HEAD") == -1) {
|
|
11
|
-
containsBranch = exec(`git branch -r --contains "${branch}"`).toString("utf8").trim().split("\n ")
|
|
12
|
-
}
|
|
13
|
-
if (branch.indexOf(condition) != -1 && containsBranch.includes("origin/" + inBranch) && !containsBranch.includes("origin/" + notInBranch) && ('origin/' + inBranch) != branch) {
|
|
14
|
-
guolv.push(branch)
|
|
15
|
-
}
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.log(error)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
fs.writeFileSync("./tool/branch/" + inBranch + "_" + notInBranch, guolv.join("\n").toString("utf8").trim(), 'utf-8')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
checkBranch("one-master-B", "one-master-A");
|
|
25
|
-
checkBranch("v17-dev-2024-06-14", "one-master-B");
|
|
1
|
+
const exec = require('child_process').execSync;
|
|
2
|
+
const fs = require("fs")
|
|
3
|
+
function checkBranch(inBranch, notInBranch, condition = '') {
|
|
4
|
+
exec(`git remote prune origin`)
|
|
5
|
+
let in_branch = exec(`git branch -r --merged origin/${inBranch}`).toString("utf8").trim().split("\n ")
|
|
6
|
+
let guolv = [];
|
|
7
|
+
in_branch.map((branch) => {
|
|
8
|
+
try {
|
|
9
|
+
let containsBranch = ""
|
|
10
|
+
if (branch.indexOf("origin/HEAD") == -1) {
|
|
11
|
+
containsBranch = exec(`git branch -r --contains "${branch}"`).toString("utf8").trim().split("\n ")
|
|
12
|
+
}
|
|
13
|
+
if (branch.indexOf(condition) != -1 && containsBranch.includes("origin/" + inBranch) && !containsBranch.includes("origin/" + notInBranch) && ('origin/' + inBranch) != branch) {
|
|
14
|
+
guolv.push(branch)
|
|
15
|
+
}
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.log(error)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
})
|
|
21
|
+
fs.writeFileSync("./tool/branch/" + inBranch + "_" + notInBranch, guolv.join("\n").toString("utf8").trim(), 'utf-8')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
checkBranch("one-master-B", "one-master-A");
|
|
25
|
+
checkBranch("v17-dev-2024-06-14", "one-master-B");
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
const fs = require("fs")
|
|
2
|
-
const path = require("path")
|
|
3
|
-
|
|
4
|
-
const chineseRegex = /[\u4e00-\u9fa5]/;
|
|
5
|
-
|
|
6
|
-
const folderPath = './';
|
|
7
|
-
|
|
8
|
-
const excludeFolders = ['.git',"node_modules"];
|
|
9
|
-
const excludeFiles = ['checkLang.js',];
|
|
10
|
-
|
|
11
|
-
let length = 0;
|
|
12
|
-
|
|
13
|
-
function checkFilesInFolder(folderPath) {
|
|
14
|
-
fs.readdir(folderPath, (err, files) => {
|
|
15
|
-
if (err) {
|
|
16
|
-
console.error('Error reading directory:', err);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
files.forEach(file => {
|
|
21
|
-
const filePath = path.join(folderPath, file);
|
|
22
|
-
|
|
23
|
-
fs.stat(filePath, (err, stats) => {
|
|
24
|
-
if (err) {
|
|
25
|
-
console.error('Error stating file:', err);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (stats.isFile() && (file.endsWith('.vue') || file.endsWith('.js')|| file.endsWith('.scss')|| file.endsWith('.css'))) {
|
|
30
|
-
if (!excludeFiles.includes(file)) {
|
|
31
|
-
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
32
|
-
if (err) {
|
|
33
|
-
console.error('Error reading file:', err);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (chineseRegex.test(data)) {
|
|
38
|
-
length++;
|
|
39
|
-
console.log(`have "${filePath}"`);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
// console.log(`jump filePath"${filePath}"`);
|
|
44
|
-
}
|
|
45
|
-
} else if (stats.isDirectory()) {
|
|
46
|
-
if (!excludeFolders.includes(file)) {
|
|
47
|
-
checkFilesInFolder(filePath);
|
|
48
|
-
} else {
|
|
49
|
-
// console.log(`jump filePath"${filePath}"`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
checkFilesInFolder(folderPath);
|
|
59
|
-
|
|
60
|
-
function getLength() {
|
|
61
|
-
setTimeout(() => {
|
|
62
|
-
console.log(`==============================================================`)
|
|
63
|
-
console.log(`total ${length} files have chinese`);
|
|
64
|
-
console.log(`==============================================================`)
|
|
65
|
-
}, 1000);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
getLength();
|
|
1
|
+
const fs = require("fs")
|
|
2
|
+
const path = require("path")
|
|
3
|
+
|
|
4
|
+
const chineseRegex = /[\u4e00-\u9fa5]/;
|
|
5
|
+
|
|
6
|
+
const folderPath = './';
|
|
7
|
+
|
|
8
|
+
const excludeFolders = ['.git',"node_modules"];
|
|
9
|
+
const excludeFiles = ['checkLang.js',];
|
|
10
|
+
|
|
11
|
+
let length = 0;
|
|
12
|
+
|
|
13
|
+
function checkFilesInFolder(folderPath) {
|
|
14
|
+
fs.readdir(folderPath, (err, files) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
console.error('Error reading directory:', err);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
files.forEach(file => {
|
|
21
|
+
const filePath = path.join(folderPath, file);
|
|
22
|
+
|
|
23
|
+
fs.stat(filePath, (err, stats) => {
|
|
24
|
+
if (err) {
|
|
25
|
+
console.error('Error stating file:', err);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (stats.isFile() && (file.endsWith('.vue') || file.endsWith('.js')|| file.endsWith('.scss')|| file.endsWith('.css'))) {
|
|
30
|
+
if (!excludeFiles.includes(file)) {
|
|
31
|
+
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
32
|
+
if (err) {
|
|
33
|
+
console.error('Error reading file:', err);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (chineseRegex.test(data)) {
|
|
38
|
+
length++;
|
|
39
|
+
console.log(`have "${filePath}"`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
// console.log(`jump filePath"${filePath}"`);
|
|
44
|
+
}
|
|
45
|
+
} else if (stats.isDirectory()) {
|
|
46
|
+
if (!excludeFolders.includes(file)) {
|
|
47
|
+
checkFilesInFolder(filePath);
|
|
48
|
+
} else {
|
|
49
|
+
// console.log(`jump filePath"${filePath}"`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
checkFilesInFolder(folderPath);
|
|
59
|
+
|
|
60
|
+
function getLength() {
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
console.log(`==============================================================`)
|
|
63
|
+
console.log(`total ${length} files have chinese`);
|
|
64
|
+
console.log(`==============================================================`)
|
|
65
|
+
}, 1000);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getLength();
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// /* */
|
|
5
|
-
const reg1 = /\/\*[\s\S]*?\*\//g;
|
|
6
|
-
|
|
7
|
-
// <!-- -->
|
|
8
|
-
const reg2 = /<!--[\s\S]*?-->/gm;
|
|
9
|
-
|
|
10
|
-
// //
|
|
11
|
-
const reg3 =/\/\/(?!.*eslint-disable-next-line).*$/gm;
|
|
12
|
-
|
|
13
|
-
const excludeFolders = ['.git', "node_modules", 'tool', 'public', path.join('src', 'utils', 'i18n')];
|
|
14
|
-
|
|
15
|
-
function readDirectory(directory) {
|
|
16
|
-
fs.readdir(directory, (err, files) => {
|
|
17
|
-
if (err) {
|
|
18
|
-
console.error('can not read dir:', err);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
files.forEach(file => {
|
|
23
|
-
const filePath = path.join(directory, file);
|
|
24
|
-
|
|
25
|
-
if (excludeFolders.some(folder => filePath.startsWith(folder))) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fs.stat(filePath, (err, stats) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
console.error('can not read file:', err);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (stats.isDirectory()) {
|
|
36
|
-
readDirectory(filePath);
|
|
37
|
-
} else if (stats.isFile() && (file.endsWith('.vue') || file.endsWith('.js')|| file.endsWith('.scss')|| file.endsWith('.css'))) {
|
|
38
|
-
removeChineseComments(filePath);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function removeChineseComments(filePath) {
|
|
46
|
-
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
47
|
-
if (err) {
|
|
48
|
-
console.error('can not read file:', err);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const newData = data
|
|
52
|
-
.replace(/\/\*\s*eslint-disable no-useless-escape\s*\*\//g, "https_eslint-disable_no-useless-escape")
|
|
53
|
-
.replace(/<!--\s*eslint-disable-next-line\s*-->/g, "https_eslint-disable-next-line")
|
|
54
|
-
.replace(/http:\/\//g, "http_bimo")
|
|
55
|
-
.replace(/https:\/\//g, "https_bimo")
|
|
56
|
-
.replace(reg1, '')
|
|
57
|
-
.replace(reg2, '')
|
|
58
|
-
.replace(reg3, '')
|
|
59
|
-
.replace(/http_bimo/g, "http://")
|
|
60
|
-
.replace(/https_bimo/g, "https://")
|
|
61
|
-
.replace(/https_eslint-disable_no-useless-escape/g, "/* eslint-disable no-useless-escape */")
|
|
62
|
-
.replace(/https_eslint-disable-next-line/g, "<!-- eslint-disable-next-line -->")
|
|
63
|
-
|
|
64
|
-
fs.writeFile(filePath, newData, 'utf8', (err) => {
|
|
65
|
-
if (err) {
|
|
66
|
-
console.error('can not write file:', err);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
console.log(`done: ${filePath}`);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function main() {
|
|
76
|
-
const directory = "./";
|
|
77
|
-
if (!directory) {
|
|
78
|
-
console.error('pls set dir');
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
readDirectory(directory);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main();
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// /* */
|
|
5
|
+
const reg1 = /\/\*[\s\S]*?\*\//g;
|
|
6
|
+
|
|
7
|
+
// <!-- -->
|
|
8
|
+
const reg2 = /<!--[\s\S]*?-->/gm;
|
|
9
|
+
|
|
10
|
+
// //
|
|
11
|
+
const reg3 =/\/\/(?!.*eslint-disable-next-line).*$/gm;
|
|
12
|
+
|
|
13
|
+
const excludeFolders = ['.git', "node_modules", 'tool', 'public', path.join('src', 'utils', 'i18n')];
|
|
14
|
+
|
|
15
|
+
function readDirectory(directory) {
|
|
16
|
+
fs.readdir(directory, (err, files) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
console.error('can not read dir:', err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
files.forEach(file => {
|
|
23
|
+
const filePath = path.join(directory, file);
|
|
24
|
+
|
|
25
|
+
if (excludeFolders.some(folder => filePath.startsWith(folder))) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fs.stat(filePath, (err, stats) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.error('can not read file:', err);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (stats.isDirectory()) {
|
|
36
|
+
readDirectory(filePath);
|
|
37
|
+
} else if (stats.isFile() && (file.endsWith('.vue') || file.endsWith('.js')|| file.endsWith('.scss')|| file.endsWith('.css'))) {
|
|
38
|
+
removeChineseComments(filePath);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function removeChineseComments(filePath) {
|
|
46
|
+
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
47
|
+
if (err) {
|
|
48
|
+
console.error('can not read file:', err);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const newData = data
|
|
52
|
+
.replace(/\/\*\s*eslint-disable no-useless-escape\s*\*\//g, "https_eslint-disable_no-useless-escape")
|
|
53
|
+
.replace(/<!--\s*eslint-disable-next-line\s*-->/g, "https_eslint-disable-next-line")
|
|
54
|
+
.replace(/http:\/\//g, "http_bimo")
|
|
55
|
+
.replace(/https:\/\//g, "https_bimo")
|
|
56
|
+
.replace(reg1, '')
|
|
57
|
+
.replace(reg2, '')
|
|
58
|
+
.replace(reg3, '')
|
|
59
|
+
.replace(/http_bimo/g, "http://")
|
|
60
|
+
.replace(/https_bimo/g, "https://")
|
|
61
|
+
.replace(/https_eslint-disable_no-useless-escape/g, "/* eslint-disable no-useless-escape */")
|
|
62
|
+
.replace(/https_eslint-disable-next-line/g, "<!-- eslint-disable-next-line -->")
|
|
63
|
+
|
|
64
|
+
fs.writeFile(filePath, newData, 'utf8', (err) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
console.error('can not write file:', err);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(`done: ${filePath}`);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function main() {
|
|
76
|
+
const directory = "./";
|
|
77
|
+
if (!directory) {
|
|
78
|
+
console.error('pls set dir');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
readDirectory(directory);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
main();
|