From 7310c2dc9d99da21a66b9ead948a0c072eb13a18 Mon Sep 17 00:00:00 2001 From: masudrehman Date: Sun, 24 Jul 2022 17:00:10 +0500 Subject: [PATCH] added baseURIChanger baseUri can now be changed without needing of _metadata.json or config settings. --- utils/updateBaseUri.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 utils/updateBaseUri.js diff --git a/utils/updateBaseUri.js b/utils/updateBaseUri.js new file mode 100644 index 000000000..de6ad642e --- /dev/null +++ b/utils/updateBaseUri.js @@ -0,0 +1,19 @@ +"use strict"; + +const fs = require("fs"); +const path = require("path"); +const isLocal = typeof process.pkg === "undefined"; +const basePath = isLocal ? process.cwd() : path.dirname(process.execPath); + +// const { baseUri } = require("../src/config.js"); +const baseUri = "https://ipfs"; + +// change 10000 to the number of metadata files.. +for (let i = 1; i <= 10000; i++) { + let rawdata = fs.readFileSync(`${basePath}/build/json/${i}.json`); + let data = JSON.parse(rawdata); + let uri = `${baseUri}/${i}.png`; + data.image = uri; + fs.writeFileSync(`${basePath}/build/json/${i}.json`, JSON.stringify(data, null, 2)); + console.log(`Updated baseUri for ${i}.json to ===> ${baseUri}`); + }