apache / cordova-lib

@@ -21,7 +21,6 @@
Loading
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 @@
Loading
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)

@@ -17,7 +17,6 @@
Loading
17 17
    under the License.
18 18
*/
19 19
20 -
const { object: zipObject } = require('underscore');
21 20
const cordova_util = require('./util');
22 21
const { CordovaError } = require('cordova-common');
23 22
const knownPlatforms = require('../platforms/platforms');
@@ -37,7 +36,11 @@
Loading
37 36
38 37
        return Promise.all(
39 38
            normalizedPlatforms.map(getPlatformRequirementsOrError)
40 -
        ).then(results => zipObject(normalizedPlatforms, results));
39 +
        ).then(results =>
40 +
            normalizedPlatforms.reduce((acc, platform, idx) =>
41 +
                Object.assign(acc, { [platform]: results[idx] })
42 +
            , {})
43 +
        );
41 44
    });
42 45
};
43 46
Files Coverage
src 91.22%
cordova-lib.js 50.00%
Project Totals (45 files) 91.13%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading