Skip to content

Commit 19800a1

Browse files
committed
[FIX] Builders: Do not bundle debug files
Temporary fix preventing '*-dbg' files from being included in preload bundles. Resolves #12 for the time being
1 parent 33c8190 commit 19800a1

File tree

7 files changed

+65
-76
lines changed

7 files changed

+65
-76
lines changed

lib/tasks/createDebugFiles.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ const dbg = require("../processors/debugFileCreator");
1010
* @param {string} [parameters.options.pattern] Pattern to locate the files to be processed
1111
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
1212
*/
13-
module.exports = function({workspace, options}) {
14-
return workspace.byGlob(options.pattern)
15-
.then((allResources) => {
16-
return dbg({
17-
resources: allResources
18-
});
19-
})
20-
.then((processedResources) => {
21-
return Promise.all(processedResources.map((resource) => {
22-
return workspace.write(resource);
23-
}));
24-
});
13+
module.exports = async function({workspace, options}) {
14+
let allResources;
15+
if (workspace.byGlobSource) { // API only available on duplex collections
16+
allResources = await workspace.byGlobSource(options.pattern);
17+
} else {
18+
allResources = await workspace.byGlob(options.pattern);
19+
}
20+
return dbg({
21+
resources: allResources
22+
}).then((processedResources) => {
23+
return Promise.all(processedResources.map((resource) => {
24+
return workspace.write(resource);
25+
}));
26+
});
2527
};

lib/types/application/ApplicationBuilder.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class ApplicationBuilder extends AbstractBuilder {
2222
this.availableTasks = [
2323
"replaceCopyright",
2424
"replaceVersion",
25-
"createDebugFiles",
2625
"generateFlexChangesBundle",
2726
"generateManifestBundle",
2827
"generateComponentPreload",
2928
"generateStandaloneAppBundle",
3029
"generateBundle",
30+
"createDebugFiles",
3131
"uglify",
3232
"generateVersionInfo"
3333
];
@@ -52,16 +52,6 @@ class ApplicationBuilder extends AbstractBuilder {
5252
});
5353
});
5454

55-
this.addTask("createDebugFiles", () => {
56-
const createDebugFiles = tasks.createDebugFiles;
57-
return createDebugFiles({
58-
workspace: resourceCollections.workspace,
59-
options: {
60-
pattern: "/**/*.js"
61-
}
62-
});
63-
});
64-
6555
this.addTask("generateFlexChangesBundle", () => {
6656
const generateFlexChangesBundle = tasks.generateFlexChangesBundle;
6757
return generateFlexChangesBundle({
@@ -137,6 +127,16 @@ class ApplicationBuilder extends AbstractBuilder {
137127
});
138128
}
139129

130+
this.addTask("createDebugFiles", () => {
131+
const createDebugFiles = tasks.createDebugFiles;
132+
return createDebugFiles({
133+
workspace: resourceCollections.workspace,
134+
options: {
135+
pattern: "/**/*.js"
136+
}
137+
});
138+
});
139+
140140
this.addTask("uglify", () => {
141141
const uglify = tasks.uglify;
142142
return uglify({

lib/types/library/LibraryBuilder.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class LibraryBuilder extends AbstractBuilder {
2222
this.availableTasks = [
2323
"replaceCopyright",
2424
"replaceVersion",
25-
"createDebugFiles",
2625
"generateComponentPreload",
2726
"generateBundle",
2827
"generateLibraryPreload",
2928
"buildThemes",
29+
"createDebugFiles",
3030
"uglify"
3131
];
3232

@@ -52,16 +52,6 @@ class LibraryBuilder extends AbstractBuilder {
5252
});
5353
});
5454

55-
this.addTask("createDebugFiles", () => {
56-
const createDebugFiles = tasks.createDebugFiles;
57-
return createDebugFiles({
58-
workspace: resourceCollections.workspace,
59-
options: {
60-
pattern: "/resources/**/*.js"
61-
}
62-
});
63-
});
64-
6555
const componentPreload = project.builder && project.builder.componentPreload;
6656
if (componentPreload) {
6757
const generateComponentPreload = tasks.generateComponentPreload;
@@ -120,6 +110,16 @@ class LibraryBuilder extends AbstractBuilder {
120110
});
121111
});
122112

113+
this.addTask("createDebugFiles", () => {
114+
const createDebugFiles = tasks.createDebugFiles;
115+
return createDebugFiles({
116+
workspace: resourceCollections.workspace,
117+
options: {
118+
pattern: "/resources/**/*.js"
119+
}
120+
});
121+
});
122+
123123
this.addTask("uglify", () => {
124124
const uglify = tasks.uglify;
125125
return uglify({

test/expected/build/application.g/dest/Component-preload.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
jQuery.sap.registerPreloadedModules({
22
"version":"2.0",
33
"modules":{
4-
"application/g/Component-dbg.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{metadata:{manifest:"json"}})});
5-
},
64
"application/g/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{metadata:{manifest:"json"}})});
75
},
86
"application/g/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'

test/expected/build/application.g/dest/subcomponentA/Component-preload.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
jQuery.sap.registerPreloadedModules({
22
"version":"2.0",
33
"modules":{
4-
"application/g/subcomponentA/Component-dbg.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.subcomponentA.Component",{metadata:{manifest:"json"}})});
5-
},
64
"application/g/subcomponentA/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.subcomponentA.Component",{metadata:{manifest:"json"}})});
75
},
86
"application/g/subcomponentA/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g.subcomponentA","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'

test/expected/build/application.g/dest/subcomponentB/Component-preload.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
jQuery.sap.registerPreloadedModules({
22
"version":"2.0",
33
"modules":{
4-
"application/g/subcomponentB/Component-dbg.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.subcomponentB.Component",{metadata:{manifest:"json"}})});
5-
},
64
"application/g/subcomponentB/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.subcomponentB.Component",{metadata:{manifest:"json"}})});
75
},
86
"application/g/subcomponentB/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g.subcomponentB","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'

test/lib/tasks/createDebugFiles.js

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ui5Fs = require("@ui5/fs");
66
const resourceFactory = ui5Fs.resourceFactory;
77

88
test("test.js: dbg file creation", (t) => {
9-
const sourceReader = resourceFactory.createAdapter({
9+
const sourceAdapter = resourceFactory.createAdapter({
1010
virBasePath: "/"
1111
});
1212
const content = "console.log('Hello World');";
@@ -16,15 +16,14 @@ test("test.js: dbg file creation", (t) => {
1616
string: content
1717
});
1818

19-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
20-
return workspace.write(resource).then(() => {
19+
return sourceAdapter.write(resource).then(() => {
2120
return tasks.createDebugFiles({
22-
workspace: workspace,
21+
workspace: sourceAdapter,
2322
options: {
2423
pattern: "/**/*.js"
2524
}
2625
}).then(() => {
27-
return workspace.byPath("/test-dbg.js").then((resource) => {
26+
return sourceAdapter.byPath("/test-dbg.js").then((resource) => {
2827
if (!resource) {
2928
t.fail("Could not find /test-dbg.js in target");
3029
} else {
@@ -38,7 +37,7 @@ test("test.js: dbg file creation", (t) => {
3837
});
3938

4039
test("test.view.js: dbg file creation", (t) => {
41-
const sourceReader = resourceFactory.createAdapter({
40+
const sourceAdapter = resourceFactory.createAdapter({
4241
virBasePath: "/"
4342
});
4443
const content = "console.log('Hello World');";
@@ -48,15 +47,14 @@ test("test.view.js: dbg file creation", (t) => {
4847
string: content
4948
});
5049

51-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
52-
return workspace.write(resource).then(() => {
50+
return sourceAdapter.write(resource).then(() => {
5351
return tasks.createDebugFiles({
54-
workspace: workspace,
52+
workspace: sourceAdapter,
5553
options: {
5654
pattern: "/**/*.js"
5755
}
5856
}).then(() => {
59-
return workspace.byPath("/test-dbg.view.js").then((resource) => {
57+
return sourceAdapter.byPath("/test-dbg.view.js").then((resource) => {
6058
if (!resource) {
6159
t.fail("Could not find /test-dbg.view.js in target");
6260
} else {
@@ -70,7 +68,7 @@ test("test.view.js: dbg file creation", (t) => {
7068
});
7169

7270
test("test.controller.js: dbg file creation", (t) => {
73-
const sourceReader = resourceFactory.createAdapter({
71+
const sourceAdapter = resourceFactory.createAdapter({
7472
virBasePath: "/"
7573
});
7674
const content = "console.log('Hello World');";
@@ -80,15 +78,14 @@ test("test.controller.js: dbg file creation", (t) => {
8078
string: content
8179
});
8280

83-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
84-
return workspace.write(resource).then(() => {
81+
return sourceAdapter.write(resource).then(() => {
8582
return tasks.createDebugFiles({
86-
workspace: workspace,
83+
workspace: sourceAdapter,
8784
options: {
8885
pattern: "/**/*.js"
8986
}
9087
}).then(() => {
91-
return workspace.byPath("/test-dbg.controller.js").then((resource) => {
88+
return sourceAdapter.byPath("/test-dbg.controller.js").then((resource) => {
9289
if (!resource) {
9390
t.fail("Could not find /test-dbg.controller.js in target");
9491
} else {
@@ -102,7 +99,7 @@ test("test.controller.js: dbg file creation", (t) => {
10299
});
103100

104101
test("test.fragment.js: dbg file creation", (t) => {
105-
const sourceReader = resourceFactory.createAdapter({
102+
const sourceAdapter = resourceFactory.createAdapter({
106103
virBasePath: "/"
107104
});
108105
const content = "console.log('Hello World');";
@@ -112,15 +109,14 @@ test("test.fragment.js: dbg file creation", (t) => {
112109
string: content
113110
});
114111

115-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
116-
return workspace.write(resource).then(() => {
112+
return sourceAdapter.write(resource).then(() => {
117113
return tasks.createDebugFiles({
118-
workspace: workspace,
114+
workspace: sourceAdapter,
119115
options: {
120116
pattern: "/**/*.js"
121117
}
122118
}).then(() => {
123-
return workspace.byPath("/test-dbg.fragment.js").then((resource) => {
119+
return sourceAdapter.byPath("/test-dbg.fragment.js").then((resource) => {
124120
if (!resource) {
125121
t.fail("Could not find /test-dbg.fragment.js in target locator");
126122
} else {
@@ -134,7 +130,7 @@ test("test.fragment.js: dbg file creation", (t) => {
134130
});
135131

136132
test("test-dbg.js: dbg-dbg file creation", (t) => {
137-
const sourceReader = resourceFactory.createAdapter({
133+
const sourceAdapter = resourceFactory.createAdapter({
138134
virBasePath: "/"
139135
});
140136
const content = "console.log('Hello World');";
@@ -144,15 +140,14 @@ test("test-dbg.js: dbg-dbg file creation", (t) => {
144140
string: content
145141
});
146142

147-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
148-
return workspace.write(resource).then(() => {
143+
return sourceAdapter.write(resource).then(() => {
149144
return tasks.createDebugFiles({
150-
workspace: workspace,
145+
workspace: sourceAdapter,
151146
options: {
152147
pattern: "/**/*.js"
153148
}
154149
}).then(() => {
155-
return workspace.byPath("/test-dbg-dbg.js").then((resource) => {
150+
return sourceAdapter.byPath("/test-dbg-dbg.js").then((resource) => {
156151
if (!resource) {
157152
t.fail("Could not find /test-dbg-dbg.js in target locator");
158153
} else {
@@ -166,7 +161,7 @@ test("test-dbg.js: dbg-dbg file creation", (t) => {
166161
});
167162

168163
test("test.xml: *no* dbg file creation", (t) => {
169-
const sourceReader = resourceFactory.createAdapter({
164+
const sourceAdapter = resourceFactory.createAdapter({
170165
virBasePath: "/"
171166
});
172167
const content = "<xml></xml>";
@@ -176,15 +171,14 @@ test("test.xml: *no* dbg file creation", (t) => {
176171
string: content
177172
});
178173

179-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
180-
return workspace.write(resource).then(() => {
174+
return sourceAdapter.write(resource).then(() => {
181175
return tasks.createDebugFiles({
182-
workspace: workspace,
176+
workspace: sourceAdapter,
183177
options: {
184178
pattern: "/**/*.js"
185179
}
186180
}).then(() => {
187-
return workspace.byPath("/test-dbg.xml").then((resource) => {
181+
return sourceAdapter.byPath("/test-dbg.xml").then((resource) => {
188182
if (!resource) {
189183
t.pass("Could not find /test-dbg.xml in target locator as it is not a JavaScript file");
190184
} else {
@@ -196,7 +190,7 @@ test("test.xml: *no* dbg file creation", (t) => {
196190
});
197191

198192
test("test1.js, test2.js: dbg file creation", (t) => {
199-
const sourceReader = resourceFactory.createAdapter({
193+
const sourceAdapter = resourceFactory.createAdapter({
200194
virBasePath: "/"
201195
});
202196
const content = "console.log('Hello World');";
@@ -212,19 +206,18 @@ test("test1.js, test2.js: dbg file creation", (t) => {
212206
})
213207
];
214208

215-
const workspace = resourceFactory.createWorkspace({reader: sourceReader});
216209
return Promise.all(resources.map((resource) => {
217-
return workspace.write(resource);
210+
return sourceAdapter.write(resource);
218211
})).then(() => {
219212
return tasks.createDebugFiles({
220-
workspace: workspace,
213+
workspace: sourceAdapter,
221214
options: {
222215
pattern: "/**/*.js"
223216
}
224217
}).then(() => {
225218
return Promise.all([
226-
workspace.byPath("/test1-dbg.js"),
227-
workspace.byPath("/test2-dbg.js")
219+
sourceAdapter.byPath("/test1-dbg.js"),
220+
sourceAdapter.byPath("/test2-dbg.js")
228221
]).then((resources) => {
229222
if (!resources || !resources[0] || !resources[1]) {
230223
t.fail("Could not find /test1-dbg.js and/or /test2-dbg.js in target locator");

0 commit comments

Comments
 (0)