Skip to content

Commit

Permalink
feat: add other frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Ellison committed May 29, 2023
1 parent a4c45d6 commit 7d9ffdd
Show file tree
Hide file tree
Showing 17 changed files with 263,792 additions and 12 deletions.
50 changes: 50 additions & 0 deletions backend/frameworks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// utils/frameworks.js

import fs from 'fs';
import path from 'path';
import glob from 'glob';

import { buffer } from 'sharp/lib/is';

export function getBaseFramework() {
const filePath = path.join(process.cwd(), 'content/frameworks/primary-dataset.json');
const fileContents = fs.readFileSync(filePath, 'utf8');
const data = JSON.parse(fileContents);

return data; // Assuming the "business-units" key holds the array of business-units
}

export function getFrameworkMappingByName(id) {
const filePath = path.join(process.cwd(), 'content/frameworks/secondary/' + id + '/mapping.json');
const fileContents = fs.readFileSync(filePath, 'utf8');
const data = JSON.parse(fileContents);
return data; // Assuming the "business-units" key holds the array of business-units
}

export function getFrameworkByName(id) {
const filePath = path.join(process.cwd(), 'content/frameworks/secondary/' + id + '/framework.json');
const fileContents = fs.readFileSync(filePath, 'utf8');
const data = JSON.parse(fileContents);
return data; // Assuming the "business-units" key holds the array of business-units
}

export async function getFrameworks() {
const contentDir = 'content/frameworks/secondary'
const globmatcher = '/**/framework.json'
const targetDir = path.join(process.cwd(), contentDir)

return new Promise((resolve, reject) => {
glob(targetDir + globmatcher, (err, files) => {
if (err) {
reject(err)
} else {
const relativeFiles = files.map((file) => {
const relativePath = path.relative(process.cwd(), file)
return relativePath.replace(contentDir , "")

})
resolve(relativeFiles.filter(Boolean))
}
})
})
}
Loading

0 comments on commit 7d9ffdd

Please sign in to comment.