You've already forked gnatdashboard
mirror of
https://github.com/AdaCore/gnatdashboard.git
synced 2026-02-12 12:30:42 -08:00
This commit transition the application to Angular 13, and refactors the
build process to use the Angular CLI instead of hacking a webpack config.
It also removes a lot of things: junk code, or features that are no longer
needed, like the following:
* The Codepeer history view of the various runs is removed
* The refresh review / add review buttons with their associated dialog
are removed
Change-Id: I8adb19aa2ec8303aa23bd38a916fac35947ee69a
Depends-On: Ie50b0def8c0c2485f890eb46317b53b62b4382dd
TN: V316-059
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
const cheerio = require('cheerio');
|
|
const fs = require('fs');
|
|
const indexFilePath = 'dist/webui/index.html';
|
|
|
|
console.log('After build script started...');
|
|
|
|
// read our index file
|
|
console.log('About to rewrite file: ', indexFilePath);
|
|
fs.readFile(indexFilePath, 'utf8', function (err, data) {
|
|
if (err) {
|
|
return console.log(err);
|
|
}
|
|
|
|
// load html into cheerio so we can manipulate DOM
|
|
const $ = cheerio.load(data);
|
|
|
|
// Angular now inserts a type="module" attribute in script tags. As we want to get a static index.html,
|
|
// we remove this attribute. Otherwise, the browser will emit cross-origin request to get the script, which
|
|
// violates the same origin policy in the browser (and prevents us from loading the script without launching
|
|
// a server).
|
|
$('html').find('script').removeAttr('type');
|
|
|
|
// As we are generating a static html page, we can't load scripts through HTTP request. Highlight.js
|
|
// relies on such a mechanism to load its scripts. To work around that, we will load the generated scripts
|
|
// preemptively, so that they are not loaded later through HTTP requests.
|
|
$('html').append(
|
|
'<script src=node_modules_highlight_js_es_core_js.js></script>'
|
|
);
|
|
$('html').append(
|
|
'<script src=node_modules_highlight_js_es_languages_ada_js.js></script>'
|
|
);
|
|
|
|
fs.writeFile(indexFilePath, $.html(), function (err) {
|
|
if (err) return console.log(err);
|
|
console.log('Successfully rewrote index html');
|
|
});
|
|
});
|