export-table-pulgin-csharp 1.0.2 → 1.0.6
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/index.d.ts +5 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -23
- package/package.json +8 -2
- package/src/index.ts +13 -27
- package/test/dist/SceneConfig.cs +55 -0
- package/test/dist/SceneConfig.csharp +0 -0
- package/test/dist/SceneConfig.csx +55 -0
- package/test/src/SceneConfig.xlsx +0 -0
- package/test/test.bat +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function st(f: (a?: any) => string): string;
|
|
5
|
-
export declare function foreach<T>(ls: T[], f: (e: T) => string): string;
|
|
6
|
-
export declare type ExportParams = {
|
|
1
|
+
import { HandleSheetParams, PluginBase } from "windy-quicktable";
|
|
2
|
+
export declare function export_stuff(paras: HandleSheetParams): string | null;
|
|
3
|
+
export declare class ExportPlugin extends PluginBase {
|
|
7
4
|
name: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
datas: any[][];
|
|
11
|
-
objects: any[];
|
|
12
|
-
xxtea: (str: string, key: string, deflate: boolean) => string;
|
|
13
|
-
inject: {
|
|
14
|
-
[key: string]: boolean;
|
|
15
|
-
};
|
|
16
|
-
packagename: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
export declare function export_stuff(paras: ExportParams): string | null;
|
|
19
|
-
export declare class ExportPlugin implements IPlugin {
|
|
20
|
-
cs(paras: ExportParams): string | null;
|
|
5
|
+
tags: string[];
|
|
6
|
+
handleSheet(paras: HandleSheetParams): string | null;
|
|
21
7
|
}
|
|
22
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlG,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+JpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExportPlugin = exports.export_stuff =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function st(f) {
|
|
7
|
-
return f();
|
|
8
|
-
}
|
|
9
|
-
exports.st = st;
|
|
10
|
-
function foreach(ls, f) {
|
|
11
|
-
return ls.map(e => f(e)).join("\n");
|
|
12
|
-
}
|
|
13
|
-
exports.foreach = foreach;
|
|
22
|
+
exports.ExportPlugin = exports.export_stuff = void 0;
|
|
23
|
+
const windy_quicktable_1 = require("windy-quicktable");
|
|
24
|
+
const fs = __importStar(require("fs"));
|
|
14
25
|
function export_stuff(paras) {
|
|
15
26
|
let { datas, fields, inject, name, objects, packagename, tables, xxtea, } = paras;
|
|
16
27
|
let firstLetterUpper = function (str) {
|
|
@@ -129,18 +140,18 @@ public class ${RowClass} {
|
|
|
129
140
|
|
|
130
141
|
public static List<${RowClass}> Configs = new List<${RowClass}>()
|
|
131
142
|
{
|
|
132
|
-
${foreach(datas, data => ` new ${RowClass}(${st(() => fields.map((f, index) => genValue(data[index], f.type)).join(", "))}),`)}
|
|
143
|
+
${(0, windy_quicktable_1.foreach)(datas, data => ` new ${RowClass}(${(0, windy_quicktable_1.st)(() => fields.map((f, index) => genValue(data[index], f.type)).join(", "))}),`)}
|
|
133
144
|
};
|
|
134
145
|
|
|
135
146
|
public ${RowClass}() { }
|
|
136
|
-
public ${RowClass}(${st(() => fields.map(f => `${getFieldType(f.type)} ${convVarName(f.name)}`).join(", "))})
|
|
147
|
+
public ${RowClass}(${(0, windy_quicktable_1.st)(() => fields.map(f => `${getFieldType(f.type)} ${convVarName(f.name)}`).join(", "))})
|
|
137
148
|
{
|
|
138
|
-
${foreach(fields, f => ` this.${convMemberName(f.name)} = ${convVarName(f.name)};`)}
|
|
149
|
+
${(0, windy_quicktable_1.foreach)(fields, f => ` this.${convMemberName(f.name)} = ${convVarName(f.name)};`)}
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
public virtual ${RowClass} MergeFrom(${RowClass} source)
|
|
142
153
|
{
|
|
143
|
-
${foreach(fields, f => ` this.${convMemberName(f.name)} = source.${convMemberName(f.name)};`)}
|
|
154
|
+
${(0, windy_quicktable_1.foreach)(fields, f => ` this.${convMemberName(f.name)} = source.${convMemberName(f.name)};`)}
|
|
144
155
|
return this;
|
|
145
156
|
}
|
|
146
157
|
|
|
@@ -151,25 +162,34 @@ ${foreach(fields, f => ` this.${convMemberName(f.name)} = source.${convMemberNa
|
|
|
151
162
|
return config;
|
|
152
163
|
}
|
|
153
164
|
|
|
154
|
-
${cmm( /**生成字段 */)}
|
|
155
|
-
${foreach(fields, f => `
|
|
165
|
+
${(0, windy_quicktable_1.cmm)( /**生成字段 */)}
|
|
166
|
+
${(0, windy_quicktable_1.foreach)(fields, f => `
|
|
156
167
|
/// <summary>
|
|
157
|
-
${foreach(getDescripts(f), line => ` /// ${line}`)}
|
|
168
|
+
${(0, windy_quicktable_1.foreach)(getDescripts(f), line => ` /// ${line}`)}
|
|
158
169
|
/// </summary>
|
|
159
170
|
public ${getFieldType(f.type)} ${convMemberName(f.name)};`)}
|
|
160
171
|
|
|
161
|
-
${cmm( /**生成get字段 */)}
|
|
172
|
+
${(0, windy_quicktable_1.cmm)( /**生成get字段 */)}
|
|
162
173
|
#region get字段
|
|
163
|
-
${foreach(fields, f => ` public ${getFieldType(f.type)} ${getTitle(f).replace(" ", "_")} => ${convMemberName(f.name)};`)}
|
|
174
|
+
${(0, windy_quicktable_1.foreach)(fields, f => ` public ${getFieldType(f.type)} ${getTitle(f).replace(" ", "_")} => ${convMemberName(f.name)};`)}
|
|
164
175
|
#endregion
|
|
165
176
|
}
|
|
166
177
|
`;
|
|
167
178
|
return temp;
|
|
168
179
|
}
|
|
169
180
|
exports.export_stuff = export_stuff;
|
|
170
|
-
class ExportPlugin {
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
class ExportPlugin extends windy_quicktable_1.PluginBase {
|
|
182
|
+
constructor() {
|
|
183
|
+
super(...arguments);
|
|
184
|
+
this.name = "csharp";
|
|
185
|
+
this.tags = ["cs"];
|
|
186
|
+
}
|
|
187
|
+
handleSheet(paras) {
|
|
188
|
+
let content = export_stuff(paras);
|
|
189
|
+
if (content != null) {
|
|
190
|
+
fs.writeFileSync(paras.outFilePath, content, "utf-8");
|
|
191
|
+
}
|
|
192
|
+
return content;
|
|
173
193
|
}
|
|
174
194
|
}
|
|
175
195
|
exports.ExportPlugin = ExportPlugin;
|
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "export-table-pulgin-csharp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/windyuuy/export-table-pulgin-csharp.git"
|
|
12
|
+
},
|
|
9
13
|
"author": "windyuuy",
|
|
10
14
|
"license": "ISC",
|
|
11
15
|
"dependencies": {
|
|
12
|
-
"
|
|
16
|
+
"@types/node": "^17.0.18",
|
|
17
|
+
"fs": "^0.0.1-security",
|
|
18
|
+
"windy-quicktable": "^1.3.34"
|
|
13
19
|
}
|
|
14
20
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase } from "windy-quicktable"
|
|
3
|
+
import * as fs from "fs"
|
|
4
4
|
|
|
5
|
-
export function
|
|
6
|
-
export function st(f: (a?: any) => string) {
|
|
7
|
-
return f()
|
|
8
|
-
}
|
|
9
|
-
export function foreach<T>(ls: T[], f: (e: T) => string) {
|
|
10
|
-
return ls.map(e => f(e)).join("\n")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type ExportParams = {
|
|
14
|
-
name: string
|
|
15
|
-
tables: DataTable[]
|
|
16
|
-
fields: Field[]
|
|
17
|
-
datas: any[][]
|
|
18
|
-
objects: any[]
|
|
19
|
-
xxtea: (str: string, key: string, deflate: boolean) => string
|
|
20
|
-
inject: {
|
|
21
|
-
[key: string]: boolean;
|
|
22
|
-
}
|
|
23
|
-
packagename: string | undefined
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function export_stuff(paras: ExportParams): string | null {
|
|
5
|
+
export function export_stuff(paras: HandleSheetParams): string | null {
|
|
27
6
|
let {
|
|
28
7
|
datas,
|
|
29
8
|
fields,
|
|
@@ -184,8 +163,15 @@ ${foreach(fields, f =>
|
|
|
184
163
|
|
|
185
164
|
}
|
|
186
165
|
|
|
187
|
-
export class ExportPlugin
|
|
188
|
-
|
|
189
|
-
|
|
166
|
+
export class ExportPlugin extends PluginBase {
|
|
167
|
+
name = "csharp"
|
|
168
|
+
tags: string[] = ["cs"]
|
|
169
|
+
|
|
170
|
+
handleSheet(paras: HandleSheetParams) {
|
|
171
|
+
let content = export_stuff(paras)
|
|
172
|
+
if (content != null) {
|
|
173
|
+
fs.writeFileSync(paras.outFilePath, content, "utf-8")
|
|
174
|
+
}
|
|
175
|
+
return content
|
|
190
176
|
}
|
|
191
177
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
|
|
4
|
+
public class SceneConfig {
|
|
5
|
+
|
|
6
|
+
public static List<SceneConfig> Configs = new List<SceneConfig>()
|
|
7
|
+
{
|
|
8
|
+
new SceneConfig(1, "第1章 格莫拉城", 1000),
|
|
9
|
+
new SceneConfig(2, "第2章 纳皮尔乐园", 1200),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
public SceneConfig() { }
|
|
13
|
+
public SceneConfig(int uid, string sceneId, double outingBaseGold)
|
|
14
|
+
{
|
|
15
|
+
this.Uid = uid;
|
|
16
|
+
this.SceneId = sceneId;
|
|
17
|
+
this.OutingBaseGold = outingBaseGold;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public virtual SceneConfig MergeFrom(SceneConfig source)
|
|
21
|
+
{
|
|
22
|
+
this.Uid = source.Uid;
|
|
23
|
+
this.SceneId = source.SceneId;
|
|
24
|
+
this.OutingBaseGold = source.OutingBaseGold;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public virtual SceneConfig Clone()
|
|
29
|
+
{
|
|
30
|
+
var config = new SceneConfig();
|
|
31
|
+
config.MergeFrom(this);
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
/// uid
|
|
37
|
+
/// </summary>
|
|
38
|
+
public int Uid;
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// 场景名
|
|
42
|
+
/// </summary>
|
|
43
|
+
public string SceneId;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
/// 出行基础金币收益
|
|
47
|
+
/// </summary>
|
|
48
|
+
public double OutingBaseGold;
|
|
49
|
+
|
|
50
|
+
#region get字段
|
|
51
|
+
public int uid => Uid;
|
|
52
|
+
public string 场景名 => SceneId;
|
|
53
|
+
public double 出行基础金币收益 => OutingBaseGold;
|
|
54
|
+
#endregion
|
|
55
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
|
|
4
|
+
public class SceneConfig {
|
|
5
|
+
|
|
6
|
+
public static List<SceneConfig> Configs = new List<SceneConfig>()
|
|
7
|
+
{
|
|
8
|
+
new SceneConfig(1, "第1章 格莫拉城", 1000),
|
|
9
|
+
new SceneConfig(2, "第2章 纳皮尔乐园", 1200),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
public SceneConfig() { }
|
|
13
|
+
public SceneConfig(int uid, string sceneId, double outingBaseGold)
|
|
14
|
+
{
|
|
15
|
+
this.Uid = uid;
|
|
16
|
+
this.SceneId = sceneId;
|
|
17
|
+
this.OutingBaseGold = outingBaseGold;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public virtual SceneConfig MergeFrom(SceneConfig source)
|
|
21
|
+
{
|
|
22
|
+
this.Uid = source.Uid;
|
|
23
|
+
this.SceneId = source.SceneId;
|
|
24
|
+
this.OutingBaseGold = source.OutingBaseGold;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public virtual SceneConfig Clone()
|
|
29
|
+
{
|
|
30
|
+
var config = new SceneConfig();
|
|
31
|
+
config.MergeFrom(this);
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
/// uid
|
|
37
|
+
/// </summary>
|
|
38
|
+
public int Uid;
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// 场景名
|
|
42
|
+
/// </summary>
|
|
43
|
+
public string SceneId;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
/// 出行基础金币收益
|
|
47
|
+
/// </summary>
|
|
48
|
+
public double OutingBaseGold;
|
|
49
|
+
|
|
50
|
+
#region get字段
|
|
51
|
+
public int uid => Uid;
|
|
52
|
+
public string 场景名 => SceneId;
|
|
53
|
+
public double 出行基础金币收益 => OutingBaseGold;
|
|
54
|
+
#endregion
|
|
55
|
+
}
|
|
Binary file
|
package/test/test.bat
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
call quicktable export src --one csharp:cs dist
|