Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
];
if (process.env.REACT_APP_SHIRTS_WORKSHEET_ID) {
dataPromises.push(
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_SHIRTS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
);
}
Promise.all(dataPromises)
.then(async ([covers, curiosities, shirts]) => {
// guardo la información en disco para ser usado desde la app
fs.writeFileSync(
path.resolve('./', 'src', 'dataset.json'),
JSON.stringify(
{
positions: await calculatePositions(),
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.POSITIONS_WORKSHEET_ID)
.then((worksheet) => worksheet.data),
// obtenemos las portadas
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.COVERS_WORKSHEET_ID)
.then((worksheet) => worksheet.data),
// obtenemos las curiosidades
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.CURIOSITIES_WORKSHEET_ID)
.then((worksheet) => worksheet.data),
];
if (process.env.SHIRTS_WORKSHEET_ID) {
dataPromises.push(
// obtenemos las camisetas
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.SHIRTS_WORKSHEET_ID)
.then((worksheet) => worksheet.data)
);
}
Promise.all(dataPromises)
.then(([positions, covers, curiosities, shirts]) => {
setTimeout(() => {
// renderizamos las posiciones
renderPositions(positions);
// renderizamos las portadas
renderCovers(covers);
// renderizamos las camisetas si existen
if (shirts) renderShirts(shirts);
// renderizamos las curiosidades si existen
if (curiosities && curiosities.length) {
} else {
// el tema no es válido. Guardamos uno por defecto y lo asignamos al DOM
themeManager.saveAndAssignTheme('theme-yellow');
}
const dataPromises = [
// obtenemos las posiciones
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.POSITIONS_WORKSHEET_ID)
.then((worksheet) => worksheet.data),
// obtenemos las portadas
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.COVERS_WORKSHEET_ID)
.then((worksheet) => worksheet.data),
// obtenemos las curiosidades
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.CURIOSITIES_WORKSHEET_ID)
.then((worksheet) => worksheet.data),
];
if (process.env.SHIRTS_WORKSHEET_ID) {
dataPromises.push(
// obtenemos las camisetas
gsheets
.getWorksheetById(process.env.SPREADSHEET_ID, process.env.SHIRTS_WORKSHEET_ID)
.then((worksheet) => worksheet.data)
);
}
Promise.all(dataPromises)
.then(([positions, covers, curiosities, shirts]) => {
setTimeout(() => {
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
];
if (process.env.REACT_APP_SHIRTS_WORKSHEET_ID) {
dataPromises.push(
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_SHIRTS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
);
}
Promise.all(dataPromises)
.then(([positions, covers, curiosities, shirts]) => {
// guardo la información en disco para ser usado desde la app
fs.writeFileSync(
path.resolve('./', 'src', 'dataset.json'),
JSON.stringify(
{
positions: addInfoToPositions(positions),
require('isomorphic-fetch');
const gsheets = require('gsheets');
const sheetID = process.env.SPREADSHEET_ID;
const getSpreadsheet = gsheets.getSpreadsheet.bind(gsheets);
Promise.resolve(sheetID)
.then(
(sheetID) =>
typeof sheetID === 'undefined'
? Promise.reject('You have to specify a process.env.SPREADSHEET_ID')
: Promise.resolve(sheetID)
)
.then(getSpreadsheet)
.then((response) => response.worksheets)
.then((worksheets) => worksheets.forEach((w) => console.log(`${w.title}: ${w.id}`)))
.catch(console.error);
async function generateData() {
const dataPromises = [
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_POSITIONS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
];
if (process.env.REACT_APP_SHIRTS_WORKSHEET_ID) {
dataPromises.push(
gsheets
async function generateData() {
const dataPromises = [
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_POSITIONS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
];
if (process.env.REACT_APP_SHIRTS_WORKSHEET_ID) {
dataPromises.push(
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_SHIRTS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
);
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
];
if (process.env.REACT_APP_SHIRTS_WORKSHEET_ID) {
dataPromises.push(
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_SHIRTS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
);
}
Promise.all(dataPromises)
.then(([positions, covers, curiosities, shirts]) => {
this.setState({
dataset: { positions, covers, curiosities, shirts },
loading: false
});
})
.catch(() => {
async function generateData() {
const dataPromises = [
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_POSITIONS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
function generateDataset() {
const dataPromises = [
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_COVERS_WORKSHEET_ID
)
.then((worksheet) => worksheet.data),
gsheets
.getWorksheetById(
process.env.REACT_APP_SPREADSHEET_ID,
process.env.REACT_APP_CURIOSITIES_WORKSHEET_ID
)
.then((worksheet) => worksheet.data)
];
if (process.env.REACT_APP_SHIRTS_WORKSHEET_ID) {
dataPromises.push(
gsheets