export-table-pulgin-csharp 1.0.11 → 1.0.14

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.
Files changed (2) hide show
  1. package/package.json +6 -1
  2. package/src/index.ts +7 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.0.11",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -15,6 +15,11 @@
15
15
  "dependencies": {
16
16
  "@types/node": "^17.0.18",
17
17
  "fs": "^0.0.1-security",
18
+ "fs-extra": "^10.0.0",
19
+ "fse": "^4.0.1",
18
20
  "windy-quicktable": "^1.3.34"
21
+ },
22
+ "devDependencies": {
23
+ "@types/fs-extra": "^9.0.13"
19
24
  }
20
25
  }
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams } from "windy-quicktable"
3
- import * as fs from "fs"
3
+ import * as fs from "fs-extra"
4
4
 
5
5
  export function export_stuff(paras: HandleSheetParams): string | null {
6
6
  let {
@@ -62,7 +62,8 @@ export function export_stuff(paras: HandleSheetParams): string | null {
62
62
  return t;
63
63
  }
64
64
 
65
- const genValue = (value: any, t: string): string => {
65
+ const genValue = (value: any, f: Field): string => {
66
+ let t = f.type
66
67
  if (t == "object") {
67
68
  throw new Error("invalid type <object>")
68
69
  } else if (t == "object[]") {
@@ -90,12 +91,12 @@ export function export_stuff(paras: HandleSheetParams): string | null {
90
91
  let values = value as number[]
91
92
  return `new int[]{${values.join(", ")}}`
92
93
  } else if (t == "any") {
93
- throw new Error("invalid type <any>")
94
+ throw new Error(`invalid type ${f.name}:<any>`)
94
95
  } else if (t == "key") {
95
96
  return `${value}`
96
97
  }
97
98
 
98
- throw new Error("invalid type <unkown>")
99
+ throw new Error(`invalid type ${f.name}:<unkown>`)
99
100
  }
100
101
 
101
102
  const getTitle = (v: Field) => {
@@ -114,7 +115,7 @@ public class ${RowClass} {
114
115
  public static List<${RowClass}> Configs = new List<${RowClass}>()
115
116
  {
116
117
  ${foreach(datas, data =>
117
- ` new ${RowClass}(${st(() => fields.map((f, index) => genValue(data[index], f.type)).join(", "))}),`
118
+ ` new ${RowClass}(${st(() => fields.map((f, index) => genValue(data[index], f)).join(", "))}),`
118
119
  )}
119
120
  };
120
121
 
@@ -171,13 +172,10 @@ export class ExportPlugin extends PluginBase {
171
172
  handleSheet(paras: HandleSheetParams) {
172
173
  let content = export_stuff(paras)
173
174
  if (content != null) {
174
- fs.writeFileSync(paras.outFilePath.fullPath, content, "utf-8")
175
+ fs.outputFileSync(paras.outFilePath.fullPath, content, "utf-8")
175
176
  }
176
177
  return content
177
178
  }
178
- handleBatch(paras: HandleBatchParams): void {
179
- console.log("lkwej:", paras.workbookManager.dataTables.length)
180
- }
181
179
  }
182
180
 
183
181
  export const ExportPlugins = [