-
Notifications
You must be signed in to change notification settings - Fork 18
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
1 parent
00d77b9
commit 8ff76c0
Showing
36 changed files
with
430 additions
and
355 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,80 @@ | ||
const fs = require('fs'); | ||
const { exec } = require('child-process-promise'); | ||
const path = require('path'); | ||
|
||
const generateArchitectureDoc = () => { | ||
const packages = []; | ||
const peerDependencies = []; | ||
const packagesFolder = './packages'; | ||
|
||
const dirents = fs.readdirSync(packagesFolder, { withFileTypes: true }); | ||
dirents.forEach((dirent) => { | ||
if (dirent.isDirectory()) { | ||
packages.push(dirent.name); | ||
|
||
const packageContent = JSON.parse( | ||
fs.readFileSync(packagesFolder + '/' + dirent.name + '/package.json') | ||
); | ||
|
||
const removeOrganizationName = (string) => { | ||
return string.replace('@ud-viz/', ''); | ||
}; | ||
|
||
const namePackage = removeOrganizationName(packageContent.name); | ||
|
||
for (const peerDepName in packageContent.peerDependencies) { | ||
if (peerDepName.startsWith('@ud-viz/')) { | ||
peerDependencies.push( | ||
namePackage + '-->' + removeOrganizationName(peerDepName) | ||
); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// @ud-viz packages architecture | ||
|
||
const filePath = './docs/static/architecture.md'; | ||
|
||
fs.writeFileSync(filePath, '# @ud-viz packages architecture\n\n'); | ||
|
||
// mermaid graph generation | ||
[ | ||
'```mermaid', | ||
'flowchart TB', | ||
'subgraph ud-viz/packages', | ||
...packages, | ||
'end', | ||
...peerDependencies, | ||
'```', | ||
'>This file is auto generated', | ||
].forEach((line) => { | ||
fs.appendFileSync(filePath, '\n' + line, (err) => { | ||
if (err) throw err; | ||
}); | ||
}); | ||
}; | ||
|
||
const generatePackagesArchitectureDoc = async () => { | ||
const packagesFolderPath = path.resolve(__dirname, '../packages'); | ||
|
||
fs.readdirSync(packagesFolderPath).forEach(async (packageName) => { | ||
const packagePath = path.join(packagesFolderPath, packageName); | ||
const lstat = fs.lstatSync(packagePath); | ||
const isDirectory = lstat.isDirectory(); | ||
|
||
if (!isDirectory) { | ||
return; | ||
} | ||
|
||
const autoMermaidCommand = `node ${packagesFolderPath}/utils_node/bin/autoMermaid.js -e ${packagePath}/src -o ${packagePath}/architecture.md`; | ||
|
||
const result = await exec(autoMermaidCommand); | ||
|
||
console.log(result.stdout); | ||
console.error(result.stderr); | ||
}); | ||
}; | ||
|
||
generatePackagesArchitectureDoc(); | ||
generateArchitectureDoc(); |
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
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
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
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
Oops, something went wrong.