diff --git a/config.js b/config.js index 05b56b0601e3..3d1f0a86cc90 100644 --- a/config.js +++ b/config.js @@ -8,4 +8,5 @@ module.exports = { categoryPagesPath: './docs/categories/', hostPath: '/tracker-radar-wiki', appendTrackerRadarRevisions: [], // in addition to all Git tags, checkout these tracker-radar revisions + region: 'US', }; diff --git a/scripts/generateHistoricalData.js b/scripts/generateHistoricalData.js index 46e1b3c1d2de..ec92d11f3214 100644 --- a/scripts/generateHistoricalData.js +++ b/scripts/generateHistoricalData.js @@ -9,7 +9,6 @@ const getListOfJSONPathsFromFolder = require('./helpers/getListOfJSONPathsFromFo const TRACKER_RADAR_DOMAINS_PATH = path.join(config.trackerRadarRepoPath, '/domains/'); const TRACKER_RADAR_ENTITIES_PATH = path.join(config.trackerRadarRepoPath, '/entities/'); -const REGION = 'US'; const domainMap = new Map(); const entityMap = new Map(); @@ -135,8 +134,8 @@ async function main() { await git.raw('checkout', tag, '--force'); let domainPath = TRACKER_RADAR_DOMAINS_PATH; - if (fs.existsSync(path.join(domainPath, REGION))) { - domainPath = path.join(domainPath, REGION); + if (fs.existsSync(path.join(domainPath, config.region))) { + domainPath = path.join(domainPath, config.region); } const domainFiles = getListOfJSONPathsFromFolder(domainPath); diff --git a/scripts/generateIndexPage.js b/scripts/generateIndexPage.js index 645d3652f79c..1a7f527a0d2c 100644 --- a/scripts/generateIndexPage.js +++ b/scripts/generateIndexPage.js @@ -15,11 +15,10 @@ const lastTagInfo = { let TRACKER_RADAR_DOMAINS_PATH = path.join(config.trackerRadarRepoPath, '/domains/'); const TRACKER_RADAR_ENTITIES_PATH = path.join(config.trackerRadarRepoPath, '/entities/'); -const REGION = 'US'; // Backwards compatibility for regions updates -if (fs.existsSync(path.join(TRACKER_RADAR_DOMAINS_PATH, REGION))) { - TRACKER_RADAR_DOMAINS_PATH = path.join(TRACKER_RADAR_DOMAINS_PATH, REGION); +if (fs.existsSync(path.join(TRACKER_RADAR_DOMAINS_PATH, config.region))) { + TRACKER_RADAR_DOMAINS_PATH = path.join(TRACKER_RADAR_DOMAINS_PATH, config.region); } const domainFiles = getListOfJSONPathsFromFolder(TRACKER_RADAR_DOMAINS_PATH); @@ -89,7 +88,8 @@ const renderData = { categories: Array.from(categories.values()), lastTagInfo, historicDataString, - hostPath: config.hostPath + hostPath: config.hostPath, + region: config.region, }; try { @@ -106,7 +106,8 @@ fs.writeFileSync(path.join(config.basePagesPath, 'index.html'), output); const top100RenderData = { domains: domains.slice(0, 100), entities: entities.slice(0, 100), - hostPath: config.hostPath + hostPath: config.hostPath, + region: config.region, }; const top100Output = mustache.render(getTemplate('top100'), top100RenderData, getTemplate); @@ -122,7 +123,8 @@ const apiHistoryRenderData = { .map(item => ({api: item.api, entries: item.entries, lastValue: item.entries[item.entries.length - 1].value})) .sort((a, b) => b.lastValue - a.lastValue), apiHistoryString, - hostPath: config.hostPath + hostPath: config.hostPath, + region: config.region, }; const apiHistoryOutput = mustache.render(getTemplate('apiHistory'), apiHistoryRenderData, getTemplate); diff --git a/scripts/generateSearchIndex.js b/scripts/generateSearchIndex.js index 3f25c978274f..1fb7e2c265d5 100644 --- a/scripts/generateSearchIndex.js +++ b/scripts/generateSearchIndex.js @@ -8,11 +8,10 @@ const getListOfJSONPathsFromFolder = require('./helpers/getListOfJSONPathsFromFo let TRACKER_RADAR_DOMAINS_PATH = path.join(config.trackerRadarRepoPath, '/domains/'); const TRACKER_RADAR_ENTITIES_PATH = path.join(config.trackerRadarRepoPath, '/entities/'); -const REGION = 'US'; // Backwards compatibility for regions updates -if (fs.existsSync(path.join(TRACKER_RADAR_DOMAINS_PATH, REGION))) { - TRACKER_RADAR_DOMAINS_PATH = path.join(TRACKER_RADAR_DOMAINS_PATH, REGION); +if (fs.existsSync(path.join(TRACKER_RADAR_DOMAINS_PATH, config.region))) { + TRACKER_RADAR_DOMAINS_PATH = path.join(TRACKER_RADAR_DOMAINS_PATH, config.region); } const domainFiles = getListOfJSONPathsFromFolder(TRACKER_RADAR_DOMAINS_PATH); diff --git a/scripts/generateSubpages.js b/scripts/generateSubpages.js index bd6ebb0525b7..2e3c3d639f08 100644 --- a/scripts/generateSubpages.js +++ b/scripts/generateSubpages.js @@ -10,11 +10,10 @@ const escapeEntityName = require('./helpers/escapeEntityName'); let TRACKER_RADAR_DOMAINS_PATH = path.join(config.trackerRadarRepoPath, '/domains/'); const TRACKER_RADAR_ENTITIES_PATH = path.join(config.trackerRadarRepoPath, '/entities/'); -const REGION = 'US'; // Backwards compatibility for regions updates -if (fs.existsSync(path.join(TRACKER_RADAR_DOMAINS_PATH, REGION))) { - TRACKER_RADAR_DOMAINS_PATH = path.join(TRACKER_RADAR_DOMAINS_PATH, REGION); +if (fs.existsSync(path.join(TRACKER_RADAR_DOMAINS_PATH, config.region))) { + TRACKER_RADAR_DOMAINS_PATH = path.join(TRACKER_RADAR_DOMAINS_PATH, config.region); } const fingerprintTexts = [ @@ -140,6 +139,8 @@ domainFiles.forEach(({file, resolvedPath}) => { sites: res.sites }; }).sort((a, b) => b.sites - a.sites); + + data.region = config.region; const output = mustache.render(getTemplate('domain'), data, getTemplate); @@ -203,6 +204,7 @@ entityFiles.forEach(({file, resolvedPath}) => { } data.hostPath = config.hostPath; + data.region = config.region; const output = mustache.render(getTemplate('entity'), data, getTemplate); @@ -238,6 +240,7 @@ Array.from(categories.values()).forEach(data => { } data.hostPath = config.hostPath; + data.region = config.region; const output = mustache.render(getTemplate('category'), data, getTemplate); diff --git a/scripts/helpers/getListOfJSONPathsFromFolder.js b/scripts/helpers/getListOfJSONPathsFromFolder.js index 789bcdced509..2e765718150f 100644 --- a/scripts/helpers/getListOfJSONPathsFromFolder.js +++ b/scripts/helpers/getListOfJSONPathsFromFolder.js @@ -12,8 +12,7 @@ module.exports = function getListOfJSONPathsFromFolder(folderPath) { return true; } - console.trace('Skipping path', resolvedPath, stat); - process.exit(1); + console.log('Skipping path', resolvedPath, stat); return false; }) // map file names to full paths