-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand file tree
/
Copy pathupdate_info.js
More file actions
56 lines (49 loc) · 1.55 KB
/
update_info.js
File metadata and controls
56 lines (49 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const basePath = process.cwd();
const { NETWORK } = require(`${basePath}/constants/network.js`);
const fs = require("fs");
const {
baseUri,
description,
namePrefix,
network,
solanaMetadata,
} = require(`${basePath}/src/config.js`);
// read json data
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
let data = JSON.parse(rawdata);
// This will force a sort on the _metadata in case shuffleLayerConfigurations was set to true
data.sort(function (a, b) {
return a.edition - b.edition;
});
data.forEach((item) => {
if (network == NETWORK.sol) {
item.name = `${namePrefix} #${item.edition}`;
item.description = description;
item.creators = solanaMetadata.creators;
} else {
item.name = `${namePrefix} #${item.edition}`;
item.description = description;
item.image = `${baseUri}/${item.edition}.png`;
}
fs.writeFileSync(
`${basePath}/build/json/${item.edition}.json`,
JSON.stringify(item, null, 2)
);
});
fs.writeFileSync(
`${basePath}/build/json/_metadata.json`,
JSON.stringify(data, null, 2)
);
if (network == NETWORK.sol) {
console.log(`Updated description for images to ===> ${description}`);
console.log(`Updated name prefix for images to ===> ${namePrefix}`);
console.log(
`Updated creators for images to ===> ${JSON.stringify(
solanaMetadata.creators
)}`
);
} else {
console.log(`Updated baseUri for images to ===> ${baseUri}`);
console.log(`Updated description for images to ===> ${description}`);
console.log(`Updated name prefix for images to ===> ${namePrefix}`);
}