Skip to content

Commit

Permalink
🔨 make implementation work
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Aug 13, 2024
1 parent 8cfd937 commit 658bd0a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions devTools/syncGraphersToR2/syncGraphersToR2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import parseArgs from "minimist"
import {
DeleteObjectCommand,
DeleteObjectCommandInput,
ListObjectsCommand,
ListObjectsV2Command,
ListObjectsV2CommandOutput,
PutObjectCommand,
Expand All @@ -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<DbRawChartConfig, "fullMd5" | "id">
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
}
})
}

Expand Down

0 comments on commit 658bd0a

Please sign in to comment.