scancscode 1.0.8 → 1.0.10
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/dist/CSCodeScanner.js
CHANGED
|
@@ -35,7 +35,7 @@ class CSCodeScanner {
|
|
|
35
35
|
let lineColumn = content.lastIndexOf('\n', index);
|
|
36
36
|
return [lineIndex + 1, index - lineColumn];
|
|
37
37
|
}
|
|
38
|
-
static scanFile(filePath, content) {
|
|
38
|
+
static scanFile(filePath, content, trclassname) {
|
|
39
39
|
const snippets = [];
|
|
40
40
|
const assignMatches = [...content.matchAll(CSCodeScanner.assignmentPattern)];
|
|
41
41
|
for (let j = 0; j < assignMatches.length; j++) {
|
|
@@ -177,7 +177,7 @@ class CSCodeScanner {
|
|
|
177
177
|
else {
|
|
178
178
|
convertedAssignLine = assignLine;
|
|
179
179
|
}
|
|
180
|
-
let convertedAssignLine2 = convertedAssignLine.replaceAll(this.stringFormatPattern,
|
|
180
|
+
let convertedAssignLine2 = convertedAssignLine.replaceAll(this.stringFormatPattern, `${trclassname}.Format`);
|
|
181
181
|
snippets.push({
|
|
182
182
|
originalIndex: assignMatch.index,
|
|
183
183
|
originalCode: assignLine,
|
package/dist/CmdExecutor.js
CHANGED
|
@@ -29,6 +29,7 @@ class CmdExecutor {
|
|
|
29
29
|
{ name: "langs", type: String, multiple: true, defaultOption: true },
|
|
30
30
|
{ name: "verbose", alias: 'v', type: Boolean },
|
|
31
31
|
{ name: "scanonly", type: Boolean, defaultOption: false },
|
|
32
|
+
{ name: "trclassname", type: String }
|
|
32
33
|
];
|
|
33
34
|
const options = (0, command_line_args_1.default)(optionDefinitions);
|
|
34
35
|
let cscodedir = options.cscodedir ?? [];
|
|
@@ -37,6 +38,7 @@ class CmdExecutor {
|
|
|
37
38
|
let langs = options.langs ?? ["zh_cn"];
|
|
38
39
|
let verbose = options.verbose ?? false;
|
|
39
40
|
let scanonly = options.scanonly ?? false;
|
|
41
|
+
let trclassname = options.trclassname ?? "Tr";
|
|
40
42
|
let argv = process.argv;
|
|
41
43
|
if (isNullOrEmpty(cscodedir) && isNullOrEmpty(configdir)) {
|
|
42
44
|
if (isNullOrEmpty(cscodedir)) {
|
|
@@ -58,7 +60,7 @@ class CmdExecutor {
|
|
|
58
60
|
}
|
|
59
61
|
console.log(`convert cmd options: `, cscodedir, configdir, outcsv, langs, verbose);
|
|
60
62
|
let literalCollector = new LiteralCollector_1.LiteralCollector();
|
|
61
|
-
await literalCollector.convert(cscodedir, configdir, outcsv, langs, scanonly, verbose);
|
|
63
|
+
await literalCollector.convert(cscodedir, configdir, outcsv, langs, trclassname, scanonly, verbose);
|
|
62
64
|
console.log("convert done.");
|
|
63
65
|
}
|
|
64
66
|
static testSlimCsv() {
|
package/dist/LiteralCollector.js
CHANGED
|
@@ -40,14 +40,14 @@ const CSCodeScanner_1 = require("./CSCodeScanner");
|
|
|
40
40
|
const CSVUtils_1 = require("./CSVUtils");
|
|
41
41
|
const TableScanner_1 = require("./TableScanner");
|
|
42
42
|
class LiteralCollector {
|
|
43
|
-
scanCodeInFolder(folder, literals, unexpects, scanonly, verbose) {
|
|
43
|
+
scanCodeInFolder(folder, literals, unexpects, trclassname, scanonly, verbose) {
|
|
44
44
|
if (fs.existsSync(folder) == false) {
|
|
45
45
|
console.warn(`代码目录不存在: ${folder}`);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
let files = glob_1.glob.sync("**/*.cs", { cwd: folder });
|
|
49
|
-
|
|
50
|
-
let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/ShopCommon/ShopCommonDialog.cs";
|
|
49
|
+
let testFullPath = "@";
|
|
50
|
+
// let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/ShopCommon/ShopCommonDialog.cs";
|
|
51
51
|
for (const filePath of files) {
|
|
52
52
|
let fullPath = folder + filePath;
|
|
53
53
|
if (testFullPath != "@") {
|
|
@@ -57,7 +57,7 @@ class LiteralCollector {
|
|
|
57
57
|
console.log(`处理文件: ${filePath}`);
|
|
58
58
|
}
|
|
59
59
|
const content = fs.readFileSync(fullPath, "utf-8");
|
|
60
|
-
const snippets = CSCodeScanner_1.CSCodeScanner.scanFile(fullPath, content);
|
|
60
|
+
const snippets = CSCodeScanner_1.CSCodeScanner.scanFile(fullPath, content, trclassname);
|
|
61
61
|
if (snippets.length > 0) {
|
|
62
62
|
if (!scanonly) {
|
|
63
63
|
let convertedContent = CSCodeScanner_1.CSCodeScanner.replaceInFile(content, snippets);
|
|
@@ -94,11 +94,11 @@ class LiteralCollector {
|
|
|
94
94
|
literals.length = 0;
|
|
95
95
|
literals.push(...literalsSet);
|
|
96
96
|
}
|
|
97
|
-
async convert(cscodeFolders, gameConfigFolders, outCsvFile, langs, scanonly = false, verbose = false) {
|
|
97
|
+
async convert(cscodeFolders, gameConfigFolders, outCsvFile, langs, trclassname = "Tr", scanonly = false, verbose = false) {
|
|
98
98
|
let literals = [];
|
|
99
99
|
let unexpects = [];
|
|
100
100
|
for (const cscodeFolder of cscodeFolders) {
|
|
101
|
-
this.scanCodeInFolder(cscodeFolder, literals, unexpects, scanonly, verbose);
|
|
101
|
+
this.scanCodeInFolder(cscodeFolder, literals, unexpects, trclassname, scanonly, verbose);
|
|
102
102
|
}
|
|
103
103
|
for (const gameConfigFolder of gameConfigFolders) {
|
|
104
104
|
this.scanTablesInFolder(gameConfigFolder, literals, verbose);
|
package/package.json
CHANGED
package/src/CSCodeScanner.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class CSCodeScanner {
|
|
|
41
41
|
return [lineIndex + 1, index - lineColumn];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
public static scanFile(filePath: string, content: string): CodeSnippet[] {
|
|
44
|
+
public static scanFile(filePath: string, content: string, trclassname: string): CodeSnippet[] {
|
|
45
45
|
const snippets: CodeSnippet[] = [];
|
|
46
46
|
|
|
47
47
|
const assignMatches = [...content.matchAll(CSCodeScanner.assignmentPattern)];
|
|
@@ -186,7 +186,7 @@ export class CSCodeScanner {
|
|
|
186
186
|
convertedAssignLine = assignLine;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
let convertedAssignLine2 = convertedAssignLine.replaceAll(this.stringFormatPattern,
|
|
189
|
+
let convertedAssignLine2 = convertedAssignLine.replaceAll(this.stringFormatPattern, `${trclassname}.Format`);
|
|
190
190
|
snippets.push({
|
|
191
191
|
originalIndex: assignMatch.index,
|
|
192
192
|
originalCode: assignLine,
|
package/src/CmdExecutor.ts
CHANGED
|
@@ -25,6 +25,7 @@ export class CmdExecutor {
|
|
|
25
25
|
{ name: "langs", type: String, multiple: true, defaultOption: true },
|
|
26
26
|
{ name: "verbose", alias: 'v', type: Boolean },
|
|
27
27
|
{ name: "scanonly", type: Boolean, defaultOption: false },
|
|
28
|
+
{ name: "trclassname", type: String }
|
|
28
29
|
]
|
|
29
30
|
const options = commandLineArgs(optionDefinitions)
|
|
30
31
|
let cscodedir: string[] = options.cscodedir ?? []
|
|
@@ -33,6 +34,7 @@ export class CmdExecutor {
|
|
|
33
34
|
let langs: string[] = options.langs ?? ["zh_cn"]
|
|
34
35
|
let verbose: boolean = options.verbose ?? false
|
|
35
36
|
let scanonly: boolean = options.scanonly ?? false
|
|
37
|
+
let trclassname: string = options.trclassname ?? "Tr"
|
|
36
38
|
|
|
37
39
|
let argv = process.argv
|
|
38
40
|
if (isNullOrEmpty(cscodedir) && isNullOrEmpty(configdir)) {
|
|
@@ -55,7 +57,7 @@ export class CmdExecutor {
|
|
|
55
57
|
}
|
|
56
58
|
console.log(`convert cmd options: `, cscodedir, configdir, outcsv, langs, verbose)
|
|
57
59
|
let literalCollector = new LiteralCollector();
|
|
58
|
-
await literalCollector.convert(cscodedir, configdir, outcsv, langs, scanonly, verbose)
|
|
60
|
+
await literalCollector.convert(cscodedir, configdir, outcsv, langs, trclassname, scanonly, verbose)
|
|
59
61
|
console.log("convert done.")
|
|
60
62
|
}
|
|
61
63
|
static testSlimCsv() {
|
package/src/LiteralCollector.ts
CHANGED
|
@@ -7,15 +7,15 @@ import { TableScanner } from "./TableScanner";
|
|
|
7
7
|
|
|
8
8
|
export class LiteralCollector {
|
|
9
9
|
|
|
10
|
-
scanCodeInFolder(folder: string, literals: string[], unexpects: string[], scanonly: boolean, verbose: boolean) {
|
|
10
|
+
scanCodeInFolder(folder: string, literals: string[], unexpects: string[], trclassname: string, scanonly: boolean, verbose: boolean) {
|
|
11
11
|
if (fs.existsSync(folder) == false) {
|
|
12
12
|
console.warn(`代码目录不存在: ${folder}`);
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
let files = glob.sync("**/*.cs", { cwd: folder });
|
|
17
|
-
|
|
18
|
-
let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/ShopCommon/ShopCommonDialog.cs";
|
|
17
|
+
let testFullPath = "@";
|
|
18
|
+
// let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/ShopCommon/ShopCommonDialog.cs";
|
|
19
19
|
for (const filePath of files) {
|
|
20
20
|
let fullPath = folder + filePath;
|
|
21
21
|
if (testFullPath != "@") {
|
|
@@ -25,7 +25,7 @@ export class LiteralCollector {
|
|
|
25
25
|
console.log(`处理文件: ${filePath}`);
|
|
26
26
|
}
|
|
27
27
|
const content = fs.readFileSync(fullPath, "utf-8");
|
|
28
|
-
const snippets = CSCodeScanner.scanFile(fullPath, content);
|
|
28
|
+
const snippets = CSCodeScanner.scanFile(fullPath, content, trclassname);
|
|
29
29
|
if (snippets.length > 0) {
|
|
30
30
|
if (!scanonly) {
|
|
31
31
|
let convertedContent = CSCodeScanner.replaceInFile(content, snippets);
|
|
@@ -69,12 +69,12 @@ export class LiteralCollector {
|
|
|
69
69
|
literals.push(...literalsSet);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
async convert(cscodeFolders: string[], gameConfigFolders: string[], outCsvFile: string, langs: string[], scanonly: boolean = false, verbose: boolean = false) {
|
|
72
|
+
async convert(cscodeFolders: string[], gameConfigFolders: string[], outCsvFile: string, langs: string[], trclassname: string = "Tr", scanonly: boolean = false, verbose: boolean = false) {
|
|
73
73
|
|
|
74
74
|
let literals: string[] = [];
|
|
75
75
|
let unexpects: string[] = [];
|
|
76
76
|
for (const cscodeFolder of cscodeFolders) {
|
|
77
|
-
this.scanCodeInFolder(cscodeFolder, literals, unexpects, scanonly, verbose);
|
|
77
|
+
this.scanCodeInFolder(cscodeFolder, literals, unexpects, trclassname, scanonly, verbose);
|
|
78
78
|
}
|
|
79
79
|
for (const gameConfigFolder of gameConfigFolders) {
|
|
80
80
|
this.scanTablesInFolder(gameConfigFolder, literals, verbose);
|