-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rob Ellison
committed
May 29, 2023
1 parent
a4c45d6
commit 7d9ffdd
Showing
17 changed files
with
263,792 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
}) | ||
}) | ||
} |
Oops, something went wrong.