From 658bd0ab6d9b63b482b7e2724b5c23758c346a88 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Tue, 13 Aug 2024 18:09:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20make=20implementation=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devTools/syncGraphersToR2/syncGraphersToR2.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/devTools/syncGraphersToR2/syncGraphersToR2.ts b/devTools/syncGraphersToR2/syncGraphersToR2.ts index 7a084d94b36..a34f011e27c 100644 --- a/devTools/syncGraphersToR2/syncGraphersToR2.ts +++ b/devTools/syncGraphersToR2/syncGraphersToR2.ts @@ -3,7 +3,6 @@ import parseArgs from "minimist" import { DeleteObjectCommand, DeleteObjectCommandInput, - ListObjectsCommand, ListObjectsV2Command, ListObjectsV2CommandOutput, PutObjectCommand, @@ -20,23 +19,20 @@ import { } from "../../settings/serverSettings.js" import { knexRaw, + knexRawFirst, KnexReadonlyTransaction, knexReadonlyTransaction, } from "../../db/db.js" import { - base64ToBytes, bytesToBase64, DbRawChartConfig, - differenceOfSets, excludeUndefined, HexString, hexToBytes, R2GrapherConfigDirectory, } from "@ourworldindata/utils" -import { string } from "ts-pattern/dist/patterns.js" -import { chunk, take } from "lodash" +import { chunk } from "lodash" import ProgressBar from "progress" -import { getEnrichedChartBySlug } from "../../db/model/Chart.js" import { exec } from "child_process" type HashAndId = Pick @@ -303,7 +299,7 @@ async function storeDevBySlug( } const fullConfig = JSON.stringify(chart.full) - const command = `npx wrangler r2 object put --local $GRAPHER_CONFIG_R2_BUCKET/$GRAPHER_CONFIG_R2_BUCKET_PATH/grapher/by-slug/${slug}.json --pipe --content-type application/json --persist-to ./cfstorage` + const command = `npx wrangler r2 object put --local ${GRAPHER_CONFIG_R2_BUCKET}/${GRAPHER_CONFIG_R2_BUCKET_PATH}/${R2GrapherConfigDirectory.publishedGrapherBySlug}/${slug}.json --pipe --content-type application/json --persist-to ./cfstorage` const process = exec(command, (error, stdout, stderr) => { if (error) { @@ -319,8 +315,10 @@ async function storeDevBySlug( console.log(`Wrangler stdout: ${stdout}`) }) - process.stdin.write(fullConfig) - process.stdin.end() + if (process.stdin) { + process.stdin.write(fullConfig) + process.stdin.end() + } }) }