actbase-cli
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -82,2 +82,31 @@ "use strict"; | ||
const parseGJson = json => { | ||
var _json$feed, _json$feed$entry; | ||
let rows = []; | ||
let column = []; | ||
json === null || json === void 0 ? void 0 : (_json$feed = json.feed) === null || _json$feed === void 0 ? void 0 : (_json$feed$entry = _json$feed.entry) === null || _json$feed$entry === void 0 ? void 0 : _json$feed$entry.forEach(v => { | ||
const cell = v['gs$cell']; | ||
if (parseInt(cell.row) === 1) { | ||
column[parseInt(cell.col) - 1] = cell.inputValue; | ||
} else { | ||
if (!rows[parseInt(cell.row) - 2]) rows[parseInt(cell.row) - 2] = []; | ||
rows[parseInt(cell.row) - 2][parseInt(cell.col) - 1] = cell.inputValue; | ||
} | ||
}); | ||
let files = {}; | ||
for (let i = 1; i < column.length; i++) { | ||
files[column[i]] = {}; | ||
} | ||
rows.forEach(data => { | ||
for (let i = 1; i < column.length; i++) { | ||
files[column[i]][data[0]] = data[i] || "$$" + data[0]; | ||
} | ||
}); | ||
return files; | ||
}; | ||
const App = | ||
@@ -174,3 +203,3 @@ /*#__PURE__*/ | ||
for (let i = 0; i < (fnames === null || fnames === void 0 ? void 0 : fnames.length); i++) { | ||
const text = JSON.stringify(files[fnames[i]], null, 2); | ||
const text = JSON.stringify(files[fnames[i]], null, ' '); | ||
const savePath = `${_config.output}/${fnames[i]}.json`.replace(/\/\//g, "/"); | ||
@@ -180,2 +209,34 @@ yield writeFile(savePath, text); | ||
} | ||
} else if (_config.path.indexOf('/edit#gid=') >= 0) { | ||
let key = _config.path.substring(39); | ||
key = key.substring(0, key.indexOf("/")); | ||
const uri = `https://spreadsheets.google.com/feeds/cells/${key}/1/public/full?alt=json`; | ||
const response = yield fetch(uri); | ||
let data = yield response.text(); | ||
let json = null; | ||
try { | ||
json = JSON.parse(data); | ||
} catch (e) { | ||
console.error('Publish 모ëę° ěë ę˛ ę°ěľëë¤. íě¸í ë¤ě ěëí´ěŁźě¸ě.\ně°¸ęł URL: https://www.freecodecamp.org/news/cjn-google-sheets-as-json-endpoint/'); | ||
process.exit(1); | ||
} | ||
const files = parseGJson(json); | ||
const fnames = Object.keys(files); | ||
if (!fs.existsSync(`${_config.output}`)) { | ||
fs.mkdirSync(`${_config.output}`); | ||
} | ||
for (let i = 0; i < (fnames === null || fnames === void 0 ? void 0 : fnames.length); i++) { | ||
const text = JSON.stringify(files[fnames[i]], null, ' '); | ||
const savePath = `${_config.output}/${fnames[i]}.json`.replace(/\/\//g, "/"); | ||
yield writeFile(savePath, text); | ||
console.log(savePath + " ě ěĽ ěëŁ!"); | ||
} | ||
} else { | ||
console.error('ęľŹę¸ ę˛˝ëĄę° ěëę°ë´ ëë¤.'); | ||
process.exit(1); | ||
} | ||
@@ -196,2 +257,2 @@ | ||
var pkgs = program.args; | ||
App(pkgs, process.argv.indexOf('-r') > 0 || process.argv.indexOf('--reset') >= 0); // | ||
App(pkgs, process.argv.indexOf('-r') > 0 || process.argv.indexOf('--reset') >= 0); |
{ | ||
"name": "actbase-cli", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Actbase Command Line Interface", | ||
@@ -19,3 +19,7 @@ "author": "Trabricks LLC", | ||
"React-Native", | ||
"Actbase" | ||
"Actbase", | ||
"CLI", | ||
"boilerplate", | ||
"i18n", | ||
"i18n-generator" | ||
], | ||
@@ -22,0 +26,0 @@ "dependencies": { |
10037
210
5
2