mirror of
https://github.com/web3privacy/explorer-data.git
synced 2024-10-15 12:06:26 +02:00
logos
This commit is contained in:
parent
da7bff71d4
commit
8eead8afcc
4 changed files with 66 additions and 3 deletions
|
@ -289,3 +289,15 @@ properties:
|
|||
type: boolean
|
||||
mainnet:
|
||||
type: boolean
|
||||
logos:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
file:
|
||||
type: string
|
||||
ext:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { emptyDir } from "https://deno.land/std@0.203.0/fs/empty_dir.ts";
|
||||
import { ensureDir } from "https://deno.land/std@0.203.0/fs/ensure_dir.ts";
|
||||
|
||||
import { W3PData } from "./w3pdata.js";
|
||||
|
||||
const w3pd = new W3PData();
|
||||
|
@ -10,6 +12,37 @@ try {
|
|||
await emptyDir(outputDir);
|
||||
} catch {}
|
||||
|
||||
for (const p of w3pd.data.projects) {
|
||||
if (!p.logos) {
|
||||
continue
|
||||
}
|
||||
for (const asset of p.logos) {
|
||||
const src = `${p._path}/${asset.file}`
|
||||
const destDir = `${outputDir}/assets/projects/${p.id}`
|
||||
const dest = `${destDir}/${asset.file}`
|
||||
|
||||
await ensureDir(destDir)
|
||||
await Deno.copyFile(src, dest);
|
||||
|
||||
console.log(`${src} -> ${dest}`)
|
||||
}
|
||||
}
|
||||
|
||||
const bundleFn = `${outputDir}/index.json`;
|
||||
|
||||
const out = {}
|
||||
for (const key of Object.keys(w3pd.data)) {
|
||||
|
||||
const arr = []
|
||||
if (key === 'projects') {
|
||||
for (const p of w3pd.data[key]) {
|
||||
delete p._path
|
||||
arr.push(p)
|
||||
}
|
||||
}
|
||||
|
||||
out[key] = arr
|
||||
}
|
||||
|
||||
await Deno.writeTextFile(bundleFn, JSON.stringify(w3pd.data, null, 2));
|
||||
console.log(`Bundle writed: ${bundleFn}`);
|
||||
|
|
|
@ -34,6 +34,7 @@ for (const col of Object.keys(w3pd.data)) {
|
|||
const ids = []
|
||||
|
||||
for (const item of w3pd.data[col]) {
|
||||
delete item._path
|
||||
const testName = `${col}/${item.id} ` + (col === 'projects' ? `[${item.categories?.join(', ')}]` : '')
|
||||
|
||||
if (ids.includes(item.id)) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import yaml from "npm:js-yaml";
|
||||
|
||||
const DATA_URL = 'https://data.web3privacy.info'
|
||||
|
||||
export class W3PData {
|
||||
constructor() {
|
||||
}
|
||||
|
@ -28,10 +30,25 @@ export class W3PData {
|
|||
const pDir = `${catDir}/${pd.name}`;
|
||||
const indexFn = `${pDir}/index.yaml`;
|
||||
|
||||
const index = yaml.load(
|
||||
const index = Object.assign({ id: pd.name }, yaml.load(
|
||||
await Deno.readTextFile(indexFn),
|
||||
);
|
||||
out.projects.push(Object.assign({ id: pd.name }, index));
|
||||
))
|
||||
|
||||
index._path = pDir
|
||||
|
||||
// read attachments
|
||||
const logos = []
|
||||
for await (const pa of Deno.readDir(pDir)) {
|
||||
const pam = pa.name.match(/^(logo)\.(.+)$/)
|
||||
if (pam && pam[1] === 'logo') {
|
||||
logos.push({ file: pam[0], ext: pam[2], url: `${DATA_URL}/assets/projects/${index.id}/${pam[0]}` })
|
||||
}
|
||||
}
|
||||
if (logos.length > 0) {
|
||||
index.logos = logos
|
||||
}
|
||||
|
||||
out.projects.push(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue