This repository has been archived by the owner on Dec 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.js
102 lines (78 loc) · 2.94 KB
/
index.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
/* eslint-env node */
'use strict';
const path = require('path');
const getManifestConfiguration = require('./lib/get-manifest-configuration');
const BroccoliMergeTrees = require('broccoli-merge-trees');
const MANIFEST_NAME = 'manifest.webmanifest';
const BROWSERCONFIG_NAME = 'browserconfig.xml';
module.exports = {
name: 'ember-web-app',
shouldIncludeChildAddon(childAddon) {
if (childAddon.name === 'broccoli-asset-rev') {
return false;
}
return this._super.shouldIncludeChildAddon.apply(this, arguments);
},
included(app) {
this.app = app;
app.options = app.options || {};
this.addonBuildConfig = this.app.options['ember-web-app'] || {};
if (!this._disabled()) {
this._configureFingerprint();
this.manifestConfiguration = getManifestConfiguration(this.app.project, this.app.env);
}
this._super.included.apply(this, arguments);
},
treeFor() {
if (this._disabled()) {
return;
}
return this._super.treeFor.apply(this, arguments);
},
treeForPublic() {
const configPath = path.join(this.app.project.root, 'config');
const GenerateManifest = require('./lib/broccoli/generate-manifest-json');
const manifest = new GenerateManifest(configPath, {
manifestName: MANIFEST_NAME,
project: this.app.project,
env: this.app.env,
ui: this.ui
});
const GenerateBrowserconfig = require('./lib/broccoli/generate-browserconfig-xml');
const browserconfig = new GenerateBrowserconfig(configPath, {
browserconfigName: BROWSERCONFIG_NAME,
project: this.app.project,
env: this.app.env,
ui: this.ui
});
return new BroccoliMergeTrees([manifest, browserconfig]);
},
contentFor(section, config) {
if (this._disabled()) {
return;
}
if (section === 'head') {
let tags = [];
tags = tags.concat(require('./lib/android-link-tags')(config, MANIFEST_NAME));
tags = tags.concat(require('./lib/apple-link-tags')(this.manifestConfiguration, config));
tags = tags.concat(require('./lib/safari-pinned-tab-tags')(this.manifestConfiguration, config));
tags = tags.concat(require('./lib/favicon-link-tags')(this.manifestConfiguration, config));
tags = tags.concat(require('./lib/android-meta-tags')(this.manifestConfiguration, config));
tags = tags.concat(require('./lib/apple-meta-tags')(this.manifestConfiguration, config));
tags = tags.concat(require('./lib/ms-meta-tags')(this.manifestConfiguration, config, BROWSERCONFIG_NAME));
return tags.join('\n');
}
},
_configureFingerprint() {
let configureFingerprint = require('./lib/configure-fingerprint');
this.app.options.fingerprint = configureFingerprint(
this.app.options.fingerprint, MANIFEST_NAME
);
this.app.options.fingerprint = configureFingerprint(
this.app.options.fingerprint, BROWSERCONFIG_NAME
);
},
_disabled() {
return this.addonBuildConfig.enabled === false;
}
};