Skip to content

Commit

Permalink
Change processjson
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hunt committed Aug 13, 2024
1 parent 6de1efa commit a12d53d
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions processing/processjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ const glob = require("glob");
const { hashElement } = require("folder-hash");
const nextConfig = require("../site/next.config.js")

const jwt = require('jsonwebtoken'),
crypto = require('crypto')

var dir = "./public";

if (!fs.existsSync(dir)) {
Expand All @@ -15,14 +12,6 @@ if (!fs.existsSync(dir + "/icons")) {
fs.mkdirSync(dir + "/icons");
}

function sortKeys(x) {
if (typeof x !== 'object' || !x)
return x;
if (Array.isArray(x))
return x.map(sortKeys);
return Object.keys(x).sort().reduce((o, k) => ({...o, [k]: sortKeys(x[k])}), {});
}

glob("**/workspace.json", async function (err, files) {
if (err) {
console.log(
Expand All @@ -40,8 +29,6 @@ glob("**/workspace.json", async function (err, files) {
encoding: "hex",
};

let channels = new Set()

for (const file of files) {
//files.forEach(async function(file) {

Expand Down Expand Up @@ -81,26 +68,13 @@ glob("**/workspace.json", async function (err, files) {
modified: Date.now(),
workspaces: workspaces,
channels: [...channels],
default_channel: '1.16.0'
default_channel: 'develop'
};

if (channels.size === 0) {
json.default_channel = null
}

let copy_for_signature = JSON.parse(JSON.stringify(json));

for(let i = 0; i < copy_for_signature.workspaces.length; i++) {
delete copy_for_signature.workspaces[i]['description']
delete copy_for_signature.workspaces[i]['notes']
}
const ordered_json = JSON.stringify(sortKeys(copy_for_signature));

const hash = crypto.createHash('sha256').update(ordered_json).digest('hex');
const payload = {
hash: hash
}

let data = JSON.stringify(json);

fs.writeFileSync(dir + "/list.json", data);
Expand Down

0 comments on commit a12d53d

Please sign in to comment.