Skip to content
Permalink
Browse files

[fix] allround fixes

  • Loading branch information...
Swaagie committed May 8, 2019
1 parent 1893903 commit bb8b3301c6415c7b585fb4dd1935f033fbe1c771
@@ -12,8 +12,6 @@ The goal of the Warehouse is to support modular UI development by:

In other words the Warehouse is designed to give as many programmatic guarantees that it is safe to "always be on latest" and make rolling back as painless as possible when issues arise.

![](assets/workflow.png)

- [Developer Experience](#developer-experience)
- [Releasing code](#releasing-code)
- [Rolling back to previous versions](#rolling-back-to-previous-versions)
@@ -53,6 +51,7 @@ The release process for any module using the Warehouse is:
cd /path/to/my/front-end/module
npm publish
```
![](assets/publish.png)
3. Perform any manual QA in your DEV environment.
4. Promote the `module@version` to production using `npm dist-tag add`
```
BIN +14.9 KB (170%) assets/assets.png
Binary file not shown.
BIN +2.39 KB (100%) assets/build.png
Binary file not shown.
BIN +1.78 KB (100%) assets/dependent.png
Binary file not shown.
@@ -1,9 +1,9 @@
graph LR
A(fa:fa-server warehouse.ai)
B(fa:fa-opencart web service)
C{fa:fa-database No-SQL Database}
D[fa:fa-laptop browser]
B{fa:fa-database No-SQL Database}
C(fa:fa-lightbulb web service)
D[fa:fa-laptop visitor browser]

B --> |"get assets from CDN"| D
C --> |"fetch metadata"| A
A --> |"get CDN metadata - wrhs.ai-client"| B
C --> |"serve response with CDN assets"| D
B --> |"fetch metadata"| A
C --> |"fetch build CDN metadata - wrhs.ai-client"| A
@@ -1,14 +1,12 @@
graph LR
A>FINISHED BUILD]
B(fa:fa-server warehouse.ai)
C{fa:fa-database No-SQL Database}
D{fa:fa-database Artifactory}
D{fa:fa-database npm-like registry}
E>BUILD]

A -.-> |"trigger builds"| B
E -.-> |"trigger dependent builds"| B
C --> |"fetch dependent metadata"| B
D --> |"fetch dependent tarball"| B
B -.-> |"provide { tarball, metadata }"| E

style A fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5
style E fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5
@@ -2,7 +2,7 @@ graph LR
A(npm dist-tag add)
B(fa:fa-server warehouse.ai)
C{fa:fa-database No-SQL Database}
D{fa:fa-database Artifactory}
D{fa:fa-database npm-like registry}
E>BUILD]

B -.-> E
@@ -1,7 +1,7 @@
graph LR
A(npm publish)
B(fa:fa-server warehouse.ai)
C{fa:fa-database Artifactory}
C{fa:fa-database npm-like registry}
D>BUILD]

A --> |"publish tarball"| B
BIN +1.01 KB (100%) assets/promote.png
Binary file not shown.
BIN +1.48 KB (110%) assets/publish.png
Binary file not shown.
BIN -104 KB assets/workflow.png
Binary file not shown.
@@ -3,9 +3,10 @@
const canihaz = require('canihaz');
const path = require('path');
const fs = require('fs').promises;
let browser;

const source = path.join(__dirname, '..', 'assets', 'diagrams');
const template = `
const template = chart => `
<!doctype html>
<html>
<head>
@@ -30,34 +31,38 @@ const template = `
</style>
</head>
<body>
<div id="container" class="mermaid"></div>
<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(page, file) {
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.setContent(template, { waitUntil: ['load', 'networkidle0', 'domcontentloaded'] });
await page.setViewport({ width: 1920, height: 1080 });
await page.evaluate(chart => {
window.mermaid.mermaidAPI.initialize({ theme: 'forest' });
window.mermaid.mermaidAPI.render('id1', chart, svg => {
document.getElementById('container').innerHTML = svg;
});
}, chart);
await page.setContent(template(chart), { waitUntil: ['networkidle0'] });

const clip = await page.$eval('#container svg', svg => {
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 new Promise(resolve => setTimeout(resolve, 500));
await page.screenshot({ path: output, clip, omitBackground: true });
} catch (error) {
throw new Error(`Snapshot of diagram failed: ${ error.message }`);
@@ -73,14 +78,14 @@ canihaz({
const input = process.argv.slice(2);

try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
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(page, file);
if (path.extname(file) === '.mmd') await snapshot(browser, file);
}

await browser.close();
@@ -90,3 +95,11 @@ canihaz({
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();
});

0 comments on commit bb8b330

Please sign in to comment.
You can’t perform that action at this time.