Skip to content

Commit d231d56

Browse files
committed
Release 5.0.0
1 parent 57166b1 commit d231d56

33 files changed

+2949
-526
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# @oracle/oraclejet-tooling 4.2.0
1+
# @oracle/oraclejet-tooling 5.0.0
22

33
## About the tooling API
44
This tooling API contains methods to build and serve Oracle JET web and hybrid mobile apps. It is intended to be used with task running tools such as grunt or gulp. The APIs can also be invoked directly.
55

66
This is an open source project maintained by Oracle Corp.
77

88
## Installation
9-
This module will be automatically installed when you scaffold a web or hybrid mobile app following the [Oracle JET Developers Guide](http://www.oracle.com/pls/topic/lookup?ctx=jet420).
9+
This module will be automatically installed when you scaffold a web or hybrid mobile app following the [Oracle JET Developers Guide](http://www.oracle.com/pls/topic/lookup?ctx=jet500&id=homepage).
1010

1111
## [Contributing](https://github.com/oracle/oraclejet-tooling/tree/master/CONTRIBUTING.md)
1212
Oracle JET is an open source project. Pull Requests are currently not being accepted. See

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Release Notes for oraclejet-tooling ##
22

3+
### 5.0.0
4+
* No changes
5+
36
### 4.2.0
47
* No changes
58

hooks/jetInjector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ function _getIndexHtmlPath(platform, external) {
111111
const prefix = external ? `${process.env.cordovaDirectory}/` : '';
112112

113113
if (platform === 'android') {
114+
const android700Path = `${prefix}platforms/android/app/src/main/assets/www/`;
114115
root = `${prefix}platforms/android/assets/www/`;
116+
root = fs.existsSync(root) ? root : android700Path;
115117
} else if (platform === 'ios') {
116118
root = `${prefix}platforms/ios/www/`;
117119
} else if (platform === 'windows') {

lib/build.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
const buildWeb = require('./buildWeb');
88
const buildHybrid = require('./buildHybrid');
9-
const util = require('./util');
109
const valid = require('./validations');
1110
const config = require('./config');
1211
/**
@@ -32,12 +31,11 @@ const config = require('./config');
3231
* @returns {Promise}
3332
*/
3433
module.exports = function build(platform, options) {
35-
util.logModuleName();
3634
config.loadOraclejetConfig(platform);
3735
const validPlatform = valid.platform(platform);
3836
const validOptions = valid.buildOptions(options, validPlatform);
3937
const validBuildType = valid.buildType(validOptions);
40-
38+
config.set('platform', validPlatform);
4139
if (platform === 'web') {
4240
return buildWeb(validBuildType, validOptions);
4341
}

lib/buildCommon.js

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ const requirejs = require('requirejs');
1313
const util = require('./util');
1414
const config = require('./config');
1515

16-
const npmCopy = require('./npmCopyConfig');
16+
const npmCopy = require('./npmCopy');
1717
const mainJsInjector = require('./mainJsInjector');
1818
const indexHtmlInjector = require('./indexHtmlInjector');
19-
const CONSTANTS = require('./constants');
2019
const svg = require('./svg');
20+
const CONSTANTS = require('./constants');
2121

2222
function _getUglyCode(file, uglifyOptions) {
2323
const code = fs.readFileSync(file, 'utf-8');
@@ -138,7 +138,7 @@ function _copyFilesExcludeScss(srcBase, destBase) {
138138
});
139139
}
140140
} catch (err) {
141-
console.log(err);
141+
util.log(err);
142142
}
143143
}
144144

@@ -228,7 +228,7 @@ function _renameNlsDirs() {
228228

229229
module.exports = {
230230
clean: function _clean(context) {
231-
console.log('cleaning staging path.....');
231+
util.log('Cleaning staging path.');
232232
const opts = context.opts;
233233
const stagingPath = opts.stagingPath;
234234
const filePath = util.destPath(stagingPath);
@@ -242,83 +242,95 @@ module.exports = {
242242
},
243243

244244
copy: function _copySrcToStaging(context) {
245-
console.log('copy files to staging directory.....');
245+
util.log('Copy files to staging directory.');
246246
const fileResult = util.getFileList(context.buildType, context.opts.copySrcToStaging.fileList);
247247
return _copyFileToStaging(fileResult)
248248
.then(() => {
249-
console.log('copy finished...');
249+
util.log('Copy finished.');
250250
return context;
251251
});
252252
},
253253

254254
copyLibs: function _copyLibsToStaging(context) {
255-
console.log('copy library files to staging directory.....');
255+
util.log('Copy library files to staging directory.');
256256
const opts = context.opts;
257257
const buildType = context.buildType;
258258
const platform = context.platform;
259-
const ojetLibs = npmCopy.getCopyLibFileList(platform, buildType);
260-
const thirdPartyLibs = util.getFileList(buildType, opts.copyLibsToStaging.fileList);
259+
const pathMappingLibs = util.getFileList(buildType,
260+
npmCopy.getMappingLibsList(buildType, platform));
261+
const nonMappingLibs = npmCopy.getNonMappingFileList(buildType, platform);
261262
const customLibs = util.getFileList(buildType, opts.copyCustomLibsToStaging.fileList);
262-
return _copyFileToStaging(ojetLibs.concat(thirdPartyLibs, customLibs))
263+
return _copyFileToStaging(nonMappingLibs.concat(pathMappingLibs, customLibs))
263264
.then(() => {
264-
console.log('copy finished...');
265+
util.log('Copy finished.');
265266
npmCopy.renameAltaThemeFiles(config('paths'));
266267
return context;
267268
});
268269
},
269270

270271
injectPaths: function _injectMainPaths(context) {
271-
console.log('running injection task.....');
272+
util.log('Running injection tasks.');
272273
return new Promise((resolve, reject) => {
273274
mainJsInjector.injectPaths(context)
274275
.then(() => {
275-
console.log('mainJs paths injection finished..');
276+
util.log('Task main.js paths injection finished.');
276277
resolve(context);
277278
})
278279
.catch(err => reject(err));
279280
});
280281
},
281282

282283
injectLocalhostCspRule: function _injectLocalhostCspRule(context) {
283-
console.log('running localhost csp rule injection task.....');
284+
util.log('Running localhost csp rule injection task.');
284285

285286
return new Promise((resolve, reject) => {
286287
indexHtmlInjector.injectLocalhostCspRule(context)
287288
.then(() => {
288-
console.log('indexHtml localhost csp rule injection finished..');
289+
util.log('Task index.html localhost csp rule injection finished.');
290+
resolve(context);
291+
})
292+
.catch(err => reject(err));
293+
});
294+
},
295+
296+
injectCdnBundleScript: function _injectCdnBundleScript(context) {
297+
return new Promise((resolve, reject) => {
298+
indexHtmlInjector.injectCdnBundleScript(context)
299+
.then(() => {
300+
util.log('Task index.html cdn bundle injection finished.');
289301
resolve(context);
290302
})
291303
.catch(err => reject(err));
292304
});
293305
},
294306

295307
injectTheme: function _injectTheme(context) {
296-
console.log('running theme injection task.....');
308+
util.log('Running theme injection task.');
297309

298310
return new Promise((resolve, reject) => {
299311
indexHtmlInjector.injectThemePath(context)
300312
.then(() => {
301-
console.log('indexHtml theme path injection finished..');
313+
util.log('Task index.html theme path injection finished.');
302314
resolve(context);
303315
})
304316
.catch(err => reject(err));
305317
});
306318
},
307319

308320
copyThemes: function _copyThemes(context) {
309-
console.log('running theme copy task.....');
321+
util.log('Running theme copy task.');
310322
return new Promise((resolve, reject) => {
311323
_copyThemesToStaging(context)
312324
.then(() => {
313-
console.log('theme copy finished...');
325+
util.log('Theme copy task finished.');
314326
resolve(context);
315327
})
316328
.catch(err => reject(err));
317329
});
318330
},
319331

320332
uglify: function _uglify(context) {
321-
console.log('running uglify tasks.....');
333+
util.log('Running uglify task.');
322334

323335
const opts = context.opts;
324336
const buildType = context.buildType;
@@ -329,44 +341,44 @@ module.exports = {
329341
return new Promise((resolve, reject) => {
330342
_writeUglyCodeToFile(fileResult, uglifyConfig.options)
331343
.then(() => {
332-
console.log('uglify finished...');
344+
util.log('Task uglify finished.');
333345
resolve(context);
334346
})
335347
.catch(err => reject(err));
336348
});
337349
},
338350

339351
requireJs: function _requireJs(context) {
340-
console.log('running requirejs tasks.....');
352+
util.log('Running requirejs task.');
341353

342354
const opts = context.opts;
343355
const requireConfig = opts.requireJs;
344356

345357
return new Promise((resolve, reject) => {
346358
requirejs.optimize(requireConfig, () => {
347-
console.log('requireJs finished...');
359+
util.log('Task requirejs finished.');
348360
resolve(context);
349361
}, (err) => {
350-
console.log(err);
362+
util.log(err);
351363
reject(err);
352364
});
353365
});
354366
},
355367

356368
sass: function _compileSass(context) {
357-
console.log('compiling sass....');
369+
util.log('Compiling sass.');
358370

359371
return new Promise((resolve, reject) => {
360372
if (context.opts.sassCompile === false && svg !== true) {
361-
console.log('sass compile skipped...');
373+
util.log('Sass compile skipped.');
362374
resolve(context);
363375
} else {
364376
// require sass here to avoid depency error if node-sass is not installed
365377
const sass = require('./sass'); // eslint-disable-line global-require
366378
const sassPromises = sass.getPromises(context);
367379
Promise.all(sassPromises)
368380
.then(() => {
369-
console.log('sass compile finished...');
381+
util.log('Sass compile finished.');
370382
resolve(context);
371383
})
372384
.catch(err => reject(err));
@@ -375,7 +387,7 @@ module.exports = {
375387
},
376388

377389
cleanTemp: function _cleanTemp(context) {
378-
console.log('cleaning mainTemp.....');
390+
util.log('Cleaning mainTemp.');
379391
const opts = context.opts;
380392
let tempPath = opts.stagingPath;
381393
let tempName = opts.injectPaths;
@@ -387,18 +399,18 @@ module.exports = {
387399
fs.remove(filePath, (err) => {
388400
if (err) reject(err);
389401
});
390-
console.log('cleanMainTemp task finished...');
402+
util.log('Task cleanMainTemp finished.');
391403
resolve(context);
392404
});
393405
},
394406

395407
spriteSvg: function _spriteSvg(context) {
396-
console.log('optimizing svg into SVG sprites.....');
408+
util.log('Optimizing svg into SVG sprites.');
397409
return new Promise((resolve, reject) => {
398410
svg.spriteSvg(context, (err) => {
399411
if (err) reject(err);
400412
});
401-
console.log('svg task finished...');
413+
util.log('Svg optimisation task finished.');
402414
resolve(context);
403415
});
404416
},

lib/buildHybrid.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ const CONSTANTS = require('./constants');
88
const exec = require('child_process').exec;
99
const indexHtmlInjector = require('./indexHtmlInjector');
1010
const buildCommon = require('./buildCommon');
11+
const hookRunner = require('./hookRunner');
1112
const path = require('path');
1213
const util = require('./util');
1314
const fs = require('fs-extra');
1415

1516
function _injectScriptTags(context) {
16-
console.log('injecting index.html with cordova script...');
17+
console.log('Injecting index.html with cordova script.');
1718
return indexHtmlInjector.injectScriptTags(context);
1819
}
1920

2021
function _invokeCordovaPrepare(context) {
21-
console.log('invoke cordova prepare.....');
22+
console.log('Invoke cordova prepare.');
2223
const platform = context.platform;
2324
let cwd = context.opts.stagingPath;
2425
cwd = path.resolve(cwd, '..');
@@ -31,7 +32,7 @@ function _invokeCordovaPrepare(context) {
3132
console.log(error);
3233
reject(error);
3334
}
34-
console.log('cordova prepare finished....');
35+
console.log('Cordova prepare finished.');
3536
resolve(context);
3637
});
3738

@@ -68,7 +69,7 @@ function _getCordovaPlatformOptions(platformOptions) {
6869
}
6970

7071
function _invokeCordovaCompile(context) {
71-
console.log('invoke cordova compile.....');
72+
console.log('Invoke cordova compile.');
7273
const platform = context.platform;
7374
const opts = context.opts;
7475
let cwd = opts.stagingPath;
@@ -86,7 +87,7 @@ function _invokeCordovaCompile(context) {
8687
const cmdOpts = { cwd: util.destPath(cwd), stdio: ['pipe', 'pipe', 'pipe'], maxBuffer: 1024 * 20000 };
8788
const cordova = exec(cmd, cmdOpts, (error) => {
8889
if (error) reject(error);
89-
console.log('Cordova compile finished....');
90+
console.log('Cordova compile finished.');
9091
resolve(context);
9192
});
9293

@@ -102,7 +103,8 @@ function _runCordovaBuildTasks(context) {
102103
if (opts.buildForServe) {
103104
resolve(context);
104105
} else {
105-
_invokeCordovaPrepare(context)
106+
hookRunner('before_release_build', context)
107+
.then(_invokeCordovaPrepare)
106108
.then(_invokeCordovaCompile)
107109
.then(data => resolve(data))
108110
.catch(err => reject(err));
@@ -113,16 +115,19 @@ function _runCordovaBuildTasks(context) {
113115
function _runCommonBuildTasks(context) {
114116
return new Promise((resolve, reject) => {
115117
buildCommon.clean(context)
116-
.then(buildCommon.copy)
117-
.then(buildCommon.copyLibs)
118-
.then(buildCommon.spriteSvg)
119-
.then(buildCommon.sass)
120-
.then(buildCommon.copyThemes)
121-
.then(buildCommon.injectTheme)
122-
.then(_injectScriptTags)
123-
.then(buildCommon.injectPaths)
124-
.then(data => resolve(data))
125-
.catch(err => reject(err));
118+
.then(hookRunner('before_build', context))
119+
.then(buildCommon.clean)
120+
.then(buildCommon.copy)
121+
.then(buildCommon.copyLibs)
122+
.then(buildCommon.spriteSvg)
123+
.then(buildCommon.sass)
124+
.then(buildCommon.injectCdnBundleScript)
125+
.then(buildCommon.copyThemes)
126+
.then(buildCommon.injectTheme)
127+
.then(_injectScriptTags)
128+
.then(buildCommon.injectPaths)
129+
.then(data => resolve(data))
130+
.catch(err => reject(err));
126131
});
127132
}
128133

@@ -132,7 +137,8 @@ function _runReleaseBuildTasks(context) {
132137
if (opts.buildType !== 'release') {
133138
resolve(context);
134139
} else {
135-
buildCommon.uglify(context)
140+
hookRunner('before_release', context)
141+
.then(buildCommon.uglify)
136142
.then(buildCommon.requireJs)
137143
.then(buildCommon.cleanTemp)
138144
.then(data => resolve(data))
@@ -157,7 +163,10 @@ module.exports = function buildHybrid(buildType, platform, opts) {
157163
.then(_runWindowsLocaleFix)
158164
.then(_runReleaseBuildTasks)
159165
.then(_runCordovaBuildTasks)
160-
.then(data => resolve(data))
166+
.then((data) => {
167+
hookRunner('after_build', data);
168+
resolve(data);
169+
})
161170
.catch(err => reject(err));
162171
});
163172
};

0 commit comments

Comments
 (0)