@skypilot/steampress
Advanced tools
Comparing version 0.3.1-alpha to 0.4.0-alpha
import { ParseExcelSheetOptions } from './parseExcelSheet'; | ||
import { TypeScriptFormatterOptions } from '../exporters/formatAsTypeScript'; | ||
export interface ConvertExcelSheetToJsonOptions { | ||
@@ -9,4 +10,6 @@ noEmit?: boolean; | ||
outFile?: string; | ||
outFormat?: 'json' | 'typescript'; | ||
formatterOptions: TypeScriptFormatterOptions | {}; | ||
parserOptions: ParseExcelSheetOptions; | ||
} | ||
export declare function convertExcelSheetToJson(options: ConvertExcelSheetToJsonOptions): object[]; |
@@ -12,4 +12,19 @@ "use strict"; | ||
var _writeToFile = require("../filesystem/writeToFile"); | ||
var _formatAsJson = require("../exporters/formatAsJson"); | ||
var _formatAsTypeScript = require("../exporters/formatAsTypeScript"); | ||
var _writeTextToFile = require("../filesystem/writeTextToFile"); | ||
const formats = { | ||
json: { | ||
extension: 'json', | ||
formatter: _formatAsJson.formatAsJson | ||
}, | ||
typescript: { | ||
extension: 'ts', | ||
formatter: _formatAsTypeScript.formatAsTypeScript | ||
} | ||
}; | ||
function convertExcelSheetToJson(options) { | ||
@@ -22,5 +37,6 @@ const { | ||
outFile = '', | ||
outFormat = 'json', | ||
formatterOptions = {}, | ||
parserOptions | ||
} = options; | ||
const baseName = outFile || sheetName; | ||
const excelAsJson = (0, _excelSheetToJson.excelSheetToJson)({ | ||
@@ -37,6 +53,11 @@ source, | ||
(0, _writeToFile.writeToFile)(parsedExcel, { | ||
baseName, | ||
format: 'json', | ||
outDir | ||
const { | ||
extension, | ||
formatter | ||
} = formats[outFormat]; | ||
const outputText = formatter(parsedExcel, formatterOptions); | ||
const fileName = outFile || `${sheetName}.${extension}`; | ||
(0, _writeTextToFile.writeTextToFile)(outputText, { | ||
dirName: outDir, | ||
fileName | ||
}); | ||
@@ -43,0 +64,0 @@ } |
{ | ||
"name": "@skypilot/steampress", | ||
"version": "0.3.1-alpha", | ||
"version": "0.4.0-alpha", | ||
"description": "Parse, filter, and transform messy spreadsheets into clean object data", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
24038
29
494
5