Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from godaddy/charts
Charts
- Loading branch information
Showing
16 changed files
with
911 additions
and
1,445 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
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
graph LR | ||
A(fa:fa-server warehouse.ai) | ||
B{fa:fa-database No-SQL Database} | ||
C(fa:fa-lightbulb web service) | ||
D[fa:fa-laptop visitor browser] | ||
|
||
C --> |"serve response with CDN assets"| D | ||
B --> |"fetch metadata"| A | ||
C --> |"fetch build CDN metadata - wrhs.ai-client"| A |
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,15 @@ | ||
graph LR | ||
A>BUILD] | ||
B(fa:fa-toolbox carpenterd) | ||
C{fa:fa-broadcast-tower NSQ} | ||
D(fa:fa-spinner carpenterd-worker) | ||
E{fa:fa-box-open S3 compatible CDN} | ||
F{fa:fa-database No-SQL Database} | ||
|
||
A -.-> |"<small>{ NODE_ENV: env, LOCALE: locale }</small>"| B | ||
B --> |"enqueue build"|C | ||
D --> |"subscribe"| C | ||
D --> |"store build output"| E | ||
D --> |"build metadata"| F | ||
|
||
style A fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5 |
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,12 @@ | ||
graph LR | ||
B(fa:fa-server warehouse.ai) | ||
C{fa:fa-database No-SQL Database} | ||
D{fa:fa-database npm-like registry} | ||
E>BUILD] | ||
|
||
E -.-> |"trigger dependent builds"| B | ||
C --> |"fetch dependent metadata"| B | ||
D --> |"fetch dependent tarball"| B | ||
B -.-> |"provide { tarball, metadata }"| E | ||
|
||
style E fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5 |
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,12 @@ | ||
graph LR | ||
A(npm dist-tag add) | ||
B(fa:fa-server warehouse.ai) | ||
C{fa:fa-database npm-like registry} | ||
D>BUILD] | ||
|
||
B -.-> |"{NODE_ENV=env, ...metadata}"| D | ||
C --> |"fetch @version tarball"| B | ||
B --> |"store dist-tag"| C | ||
A --> |"module@version env"| B | ||
|
||
style D fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5 |
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,11 @@ | ||
graph LR | ||
A(npm publish) | ||
B(fa:fa-server warehouse.ai) | ||
C{fa:fa-database npm-like registry} | ||
D>BUILD] | ||
|
||
A --> |"publish tarball"| B | ||
B --> |"store tarball"| C | ||
B --> |"duplicate tarball"| D | ||
|
||
style D fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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,105 @@ | ||
#!/usr/bin/env node | ||
|
||
const canihaz = require('canihaz'); | ||
const path = require('path'); | ||
const fs = require('fs').promises; | ||
let browser; | ||
|
||
const source = path.join(__dirname, '..', 'assets', 'diagrams'); | ||
const template = chart => ` | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.1/css/all.min.css"> | ||
<style> | ||
html, * { | ||
font-family: 'monaco'; | ||
} | ||
.node { | ||
text-align: center; | ||
} | ||
i.fa { | ||
display: block; | ||
margin: 5px; | ||
} | ||
.edgeLabel:not(:empty) { | ||
padding: 0px 8px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<script src="https://unpkg.com/mermaid/dist/mermaid.min.js" charset="utf-8"></script> | ||
<script> | ||
const diagram = document.createElement('div'); | ||
window.mermaid.mermaidAPI.initialize({ theme: 'forest' }); | ||
window.mermaid.mermaidAPI.render('container', \`${chart}\`, svg => { | ||
diagram.innerHTML = svg; | ||
diagram.id = 'container'; | ||
document.body.appendChild(diagram); | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
`; | ||
|
||
async function snapshot(browser, file) { | ||
try { | ||
const chart = await fs.readFile(path.join(source, file), 'utf-8'); | ||
const output = path.join(source, '..', `${ path.basename(file, '.mmd') }.png`); | ||
const page = await browser.newPage(); | ||
|
||
console.log(`Rendering ${ file }`); | ||
|
||
await page.setViewport({ width: 1920, height: 1080 }); | ||
await page.setContent(template(chart), { waitUntil: ['networkidle0'] }); | ||
|
||
const clip = await page.$eval('svg', svg => { | ||
const box = svg.getBoundingClientRect(); | ||
return { x: box.left, y: box.top, width: box.width, height: box.height }; | ||
}); | ||
|
||
await page.screenshot({ path: output, clip, omitBackground: true }); | ||
} catch (error) { | ||
throw new Error(`Snapshot of diagram failed: ${ error.message }`); | ||
} | ||
} | ||
|
||
console.log('Requesting availability of puppeteer, it will be installed if unavailable.'); // eslint-disable-line | ||
|
||
canihaz({ | ||
key: 'cliDependencies' | ||
}).puppeteer(async function puppetmaster(error, puppeteer) { | ||
if (error) throw error; | ||
const input = process.argv.slice(2); | ||
|
||
try { | ||
browser = await puppeteer.launch(); | ||
|
||
const diagrams = input.length | ||
? input.map(file => path.extname(file) === '.mmd' ? file : `${ file }.mmd`) | ||
: await fs.readdir(source); | ||
|
||
for (const file of diagrams) { | ||
if (path.extname(file) === '.mmd') await snapshot(browser, file); | ||
} | ||
|
||
await browser.close(); | ||
|
||
console.log('Chart images generated.'); // eslint-disable-line | ||
} catch (error) { | ||
throw new Error(`Puppeteer failed: ${ error.message }`); | ||
} | ||
}); | ||
|
||
// | ||
// Ensure Chromium process is closed. | ||
// | ||
process.once('SIGINT', async function kill() { | ||
if (!browser) process.exit(); // eslint-disable-line | ||
await browser.close(); | ||
}); |
Oops, something went wrong.