@@ -21,7 +21,6 @@ const url = require('url');
21
21
const path = require ( 'path' ) ;
22
22
const globby = require ( 'globby' ) ;
23
23
const md5File = require ( 'md5-file' ) ;
24
- const { template, object : zipObject } = require ( 'underscore' ) ;
25
24
26
25
const { ConfigParser, events } = require ( 'cordova-common' ) ;
27
26
const cordovaServe = require ( 'cordova-serve' ) ;
@@ -32,60 +31,50 @@ const HooksRunner = require('../hooks/HooksRunner');
32
31
33
32
let projectRoot , installedPlatforms ;
34
33
35
- const INDEX_TEMPLATE = `
34
+ const renderIndex = ( { config , plugins , platforms } ) => `
36
35
<!doctype html>
37
36
<html>
38
37
<head>
39
38
<meta charset=utf-8>
40
- <title>{{ metaData .name } }</title>
39
+ <title>${ config . name ( ) } </title>
41
40
</head>
42
41
<body>
43
42
<h3>Package Metadata</h3>
44
43
<table style="text-align: left">
45
- {% for (const key in metaData) { %}
46
- <tr>
47
- <th>{{ key }}</th><td>{{ metaData[key] }}</td>
48
- </tr>
49
- {% } %}
44
+ ${ [ 'name' , 'packageName' , 'version' ] . map ( key =>
45
+ `<tr><th>${ key } </th><td>${ config [ key ] ( ) } </td></tr>`
46
+ ) . join ( '\n' ) }
50
47
</table>
51
48
52
49
<h3>Platforms</h3>
53
50
<ul>
54
- {% for (const platform of platforms) { %}
55
- <li>
56
- {% if (platform.url) { %}
57
- <a href="{{ platform.url }}">{{ platform.name }}</a>
58
- {% } else { %}
59
- <em>{{ platform.name }}</em>
60
- {% } %}
61
- </li>
62
- {% } %}
51
+ ${ platforms . map ( platform =>
52
+ `<li>${
53
+ platform . url
54
+ ? `<a href="${ platform . url } ">${ platform . name } </a>`
55
+ : `<em>${ platform . name } </em>`
56
+ } </li>`) . join ( '\n' ) }
63
57
</ul>
64
58
65
59
<h3>Plugins</h3>
66
60
<ul>
67
- {% for (const plugin of plugins) { %}
68
- <li>{{ plugin }} </li>
69
- {% } % }
61
+ ${ plugins . map ( plugin =>
62
+ ` <li>${ plugin } </li>`
63
+ ) . join ( '\n' ) }
70
64
</ul>
71
65
</body>
72
66
</html>
73
67
` ;
74
- const renderIndex = template ( INDEX_TEMPLATE , {
75
- escape : / \{ \{ ( .+ ?) \} \} / g,
76
- evaluate : / \{ % ( .+ ?) % \} / g
77
- } ) ;
78
68
79
69
function handleRoot ( request , response ) {
80
70
const config = new ConfigParser ( cordovaUtil . projectConfig ( projectRoot ) ) ;
81
71
const contentNode = config . doc . find ( 'content' ) ;
82
72
const contentSrc = ( contentNode && contentNode . attrib . src ) || 'index.html' ;
83
- const metaDataKeys = [ 'name' , 'packageName' , 'version' ] ;
84
73
const platformUrl = name => installedPlatforms . includes ( name )
85
74
? `${ name } /www/${ contentSrc } ` : null ;
86
75
87
76
response . send ( renderIndex ( {
88
- metaData : zipObject ( metaDataKeys , metaDataKeys . map ( k => config [ k ] ( ) ) ) ,
77
+ config,
89
78
plugins : cordovaUtil . findPlugins ( path . join ( projectRoot , 'plugins' ) ) ,
90
79
platforms : Object . keys ( platforms ) . map ( name => ( {
91
80
name, url : platformUrl ( name )
0 commit comments