-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.js
119 lines (110 loc) · 2.77 KB
/
tools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* eslint-env es6 */
'use strict';
const fs = require('fs');
const path = require('path');
const resolver = require('opensphere-build-resolver/utils');
/**
* Directory containing build artifacts generated by `opensphere-build-resolver`.
* @type {string}
*/
const buildDir = '.build';
/**
* Path to the build directory.
* @type {string}
*/
const buildPath = path.join(process.cwd(), buildDir);
/**
* Path to the version file.
* @type {string}
*/
const versionFile = path.join(buildPath, 'version');
/**
* Relative path of the version directory.
* @type {string}
*/
const version = fs.readFileSync(versionFile, 'utf8').trim().replace(/.*\//, '');
const appPath = resolver.resolveModulePath('opensphere');
const sharedResources = require(appPath).sharedResources;
/**
* Resources for `opensphere-build-index` to include in `tools.html`.
* @type {Array<Object>}
*/
const toolsResources = sharedResources.concat([
{
source: resolver.resolveModulePath('golden-layout/dist', __dirname),
target: 'vendor/golden-layout',
scripts: [
'goldenlayout.min.js'
]
},
{
source: resolver.resolveModulePath('golden-layout/src/css', __dirname),
target: 'vendor/golden-layout',
css: [
'goldenlayout-base.css',
'goldenlayout-dark-theme.css'
]
},
{
source: resolver.resolveModulePath('milsymbol/dist', __dirname),
target: 'vendor/milsymbol',
scripts: [
'milsymbol.js'
]
},
{
source: resolver.resolveModulePath('milstd/', __dirname),
target: 'vendor/milstd',
scripts: [
'milstd.js'
]
},
{
source: resolver.resolveModulePath('vega/build', __dirname),
target: 'vendor/vega',
scripts: [
'vega.min.js'
],
files: [
'vega-schema.json'
]
}
]);
module.exports = {
appVersion: version,
basePath: __dirname,
appPath: appPath,
distPath: path.join(appPath, 'dist', 'opensphere'),
templates: [
{
// Add resources to the main page.
id: 'index',
skip: true,
resources: [
{
source: resolver.resolveModulePath('milsymbol/dist', __dirname),
target: 'vendor/milsymbol',
scripts: [
'milsymbol.js'
]
},
{
source: resolver.resolveModulePath('milstd/', __dirname),
target: 'vendor/milstd',
scripts: [
'milstd.js'
]
}
]
},
{
id: 'tools',
file: 'tools-template.html',
resources: toolsResources
}
],
debugCss: path.relative(__dirname, path.join(buildPath, 'themes', 'default.combined.css')),
compiledCss: path.join(version, 'styles', 'themes', 'default.min.css'),
debugJs: path.relative(__dirname, path.join(buildPath, 'opensphere.js')),
compiledJs: path.join(version, 'opensphere.min.js')
};