altair-static 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/267.js +1 -0
- package/build/dist/471.js +1 -1
- package/build/dist/main.js +1 -1
- package/build/dist/styles.css +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +4 -1
- package/build/index.test.d.ts +1 -0
- package/build/index.test.js +17 -6
- package/build/utils/get-altair-html.d.ts +1 -0
- package/build/utils/get-dist.d.ts +1 -0
- package/package.json +4 -4
- package/src/index.test.ts +21 -6
- package/src/index.ts +5 -2
- package/tsconfig.json +1 -0
- package/build/dist/672.js +0 -1
- package/build/index.js.map +0 -1
- package/build/index.test.js.map +0 -1
- package/build/utils/get-altair-html.js.map +0 -1
- package/build/utils/get-dist.js.map +0 -1
- package/scripts/prepare_dist.js +0 -77
package/scripts/prepare_dist.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
const ncp = require('ncp').ncp;
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
ncp.limit = 16;
|
|
6
|
-
|
|
7
|
-
const deleteFolderRecursive = function(path) {
|
|
8
|
-
if (fs.existsSync(path)) {
|
|
9
|
-
fs.readdirSync(path).forEach(function(file, index){
|
|
10
|
-
var curPath = path + "/" + file;
|
|
11
|
-
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
|
12
|
-
deleteFolderRecursive(curPath);
|
|
13
|
-
} else { // delete file
|
|
14
|
-
fs.unlinkSync(curPath);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
fs.rmdirSync(path);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const distSrc = path.join(__dirname, '../node_modules/altair-app/dist'); // From the altair-app dist folder
|
|
22
|
-
const distDestination = path.join(__dirname, '../build/dist'); // To altair-static dist folder
|
|
23
|
-
deleteFolderRecursive(distDestination);
|
|
24
|
-
fs.mkdirSync(distDestination, { recursive: true });
|
|
25
|
-
|
|
26
|
-
const srcDir = path.resolve(__dirname, '../src');
|
|
27
|
-
const buildDir = path.resolve(__dirname, '../build');
|
|
28
|
-
|
|
29
|
-
const indexHtmlFile = path.join(distDestination, 'index.html');
|
|
30
|
-
|
|
31
|
-
// const cdnFile = fileName => `https://cdn.jsdelivr.net/npm/altair-static/dist/${fileName}`;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Copy dist files into dist directory.
|
|
35
|
-
* Set base to ./
|
|
36
|
-
* Set the scripts and styles in template.html
|
|
37
|
-
* Add template.html to dist directory.
|
|
38
|
-
*/
|
|
39
|
-
ncp(distSrc, distDestination, function (err) {
|
|
40
|
-
if (err) {
|
|
41
|
-
return console.error(err);
|
|
42
|
-
}
|
|
43
|
-
console.log('Done copying dist folder!');
|
|
44
|
-
|
|
45
|
-
// let indexHtmlStr = fs.readFileSync(indexHtmlFile, 'utf8');
|
|
46
|
-
|
|
47
|
-
// Adjust the base URL to be relative to the current path
|
|
48
|
-
// indexHtmlStr = indexHtmlStr.replace('<base href="/">', '<base href="https://cdn.jsdelivr.net/npm/altair-static/dist/">'
|
|
49
|
-
// /*'<base href="./">'*/);
|
|
50
|
-
|
|
51
|
-
// Write the new string back to file
|
|
52
|
-
// fs.writeFileSync(indexHtmlFile, indexHtmlStr, 'utf8');
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const stats = JSON.parse(fs.readFileSync(path.resolve(distSrc, 'stats.json')));
|
|
56
|
-
|
|
57
|
-
let htmlString = fs.readFileSync(path.resolve(srcDir, 'index.html'), 'utf8')
|
|
58
|
-
// Set base to ./
|
|
59
|
-
.replace('<base href="/">', '<base href="./">')
|
|
60
|
-
// Set scripts and styles
|
|
61
|
-
.replace('[% STYLES_FILE %]', stats.assetsByChunkName.styles)
|
|
62
|
-
.replace('[% RUNTIME_SCRIPT %]', stats.assetsByChunkName.runtime)
|
|
63
|
-
.replace('[% POLYFILLS_SCRIPT %]', stats.assetsByChunkName.polyfills)
|
|
64
|
-
.replace('[% MAIN_SCRIPT %]', stats.assetsByChunkName.main);
|
|
65
|
-
|
|
66
|
-
fs.writeFileSync(path.join(distDestination, 'index.html'), htmlString);
|
|
67
|
-
|
|
68
|
-
// Remove stats.json after writing index.html file (the file is too big and not useful anymore)
|
|
69
|
-
fs.unlinkSync(path.resolve(distDestination, 'stats.json'));
|
|
70
|
-
|
|
71
|
-
// Remove README assets
|
|
72
|
-
deleteFolderRecursive(path.join(distDestination, 'assets/img/readme'));
|
|
73
|
-
|
|
74
|
-
} catch(err) {
|
|
75
|
-
console.error('stats.json not found', err);
|
|
76
|
-
}
|
|
77
|
-
});
|