Skip to content

Commit 076c998

Browse files
committed
Release 6.0.0
1 parent b99f1eb commit 076c998

24 files changed

+570
-224
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 5.2.0
1+
# @oracle/oraclejet-tooling 6.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=jet520&id=homepage).
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=jet600&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: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
## Release Notes for oraclejet-tooling ##
2-
3-
### 5.2.0
4-
* No changes
5-
6-
### 5.1.0
7-
* No changes
8-
9-
### 5.0.0
10-
* No changes
11-
12-
### 4.2.0
13-
* No changes
14-
15-
### 4.1.0
16-
* No changes
17-
18-
### 4.0.0
19-
* Moved module into @oracle scope, changing the name to @oracle/oraclejet-tooling
20-
21-
### 3.2.0
22-
* No changes
23-
24-
### 3.1.0
25-
* No changes
26-
27-
### 3.0.0
28-
* Replaced bower with npm
29-
* SASS tasks now run in CCA directories also
30-
* Added --destination=server-only option for web apps
31-
* Removed --destination=deviceOrEmulatorName option
32-
* Added ability to cutomize serve tasks such as watching additional files
33-
* Added gap://ready to inserted CSP meta tag for iOS 10 compatibility
34-
35-
### 2.3.0
36-
* No changes
37-
38-
### 2.2.0
39-
* Allow developers to configure release paths
40-
* Provide help page for tooling tasks
41-
* Allow multiple themes to be included in a built app
42-
* Grunt serve to specific iOS emulator fails
43-
* no-build option missing from grunt serve
44-
>>>>>>> 0f5544d... Merge branch 'master' into ListPacks
1+
## Release Notes for oraclejet-tooling ##
2+
3+
### 6.0.0
4+
* No changes
5+
6+
### 5.2.0
7+
* No changes
8+
9+
### 5.1.0
10+
* No changes
11+
12+
### 5.0.0
13+
* No changes
14+
15+
### 4.2.0
16+
* No changes
17+
18+
### 4.1.0
19+
* No changes
20+
21+
### 4.0.0
22+
* Moved module into @oracle scope, changing the name to @oracle/oraclejet-tooling
23+
24+
### 3.2.0
25+
* No changes
26+
27+
### 3.1.0
28+
* No changes
29+
30+
### 3.0.0
31+
* Replaced bower with npm
32+
* SASS tasks now run in CCA directories also
33+
* Added --destination=server-only option for web apps
34+
* Removed --destination=deviceOrEmulatorName option
35+
* Added ability to cutomize serve tasks such as watching additional files
36+
* Added gap://ready to inserted CSP meta tag for iOS 10 compatibility
37+
38+
### 2.3.0
39+
* No changes
40+
41+
### 2.2.0
42+
* Allow developers to configure release paths
43+
* Provide help page for tooling tasks
44+
* Allow multiple themes to be included in a built app
45+
* Grunt serve to specific iOS emulator fails
46+
* no-build option missing from grunt serve

lib/build.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
const buildWeb = require('./buildWeb');
88
const buildHybrid = require('./buildHybrid');
9+
const buildComponent = require('./buildComponent');
910
const valid = require('./validations');
1011
const config = require('./config');
1112
/**
@@ -31,6 +32,10 @@ const config = require('./config');
3132
* @returns {Promise}
3233
*/
3334
module.exports = function build(platform, options) {
35+
if (Object.prototype.hasOwnProperty.call(options, 'component')) {
36+
config.loadOraclejetConfig('web');
37+
return buildComponent(options.component);
38+
}
3439
config.loadOraclejetConfig(platform);
3540
const validPlatform = valid.platform(platform);
3641
const validOptions = valid.buildOptions(options, validPlatform);

lib/buildCommon.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,4 +453,30 @@ module.exports = {
453453
return resolve(context);
454454
});
455455
},
456+
copyReferenceCca(context) {
457+
return new Promise((resolve) => {
458+
util.log('Copy reference components to staging directory.');
459+
const componentList = util.getDirectories(`./${CONSTANTS.JET_COMPONENTS_DIRECTORY}`);
460+
componentList.forEach((component) => {
461+
const componentDirPath = `./${CONSTANTS.JET_COMPONENTS_DIRECTORY}/${component}/${CONSTANTS.JET_COMPONENT_JSON}`;
462+
const componentJson = util.readJsonAndReturnObject(`${componentDirPath}`);
463+
if (componentJson.type === 'reference') {
464+
const npmPckgName = componentJson.package;
465+
const npmPckgInitFileRelativePath = componentJson.paths.npm[context.buildType === 'release' ? 'min' : 'debug'];
466+
467+
// Get only the file name
468+
const npmPckgInitFileNameArray = npmPckgInitFileRelativePath.split('/');
469+
const npmPckgInitFileName = npmPckgInitFileNameArray[npmPckgInitFileNameArray.length - 1];
470+
471+
// Copy
472+
const npmPckgSrcPath = `./${CONSTANTS.NODE_MODULES_DIRECTORY}/${npmPckgName}/${npmPckgInitFileRelativePath}`;
473+
const destBasePath = path.join(config('paths').staging.stagingPath, config('paths').src.javascript, 'libs');
474+
const destNpmpckgDirPath = `${destBasePath}/${npmPckgName}/${npmPckgInitFileName}`;
475+
fs.copySync(npmPckgSrcPath, destNpmpckgDirPath);
476+
}
477+
});
478+
util.log('Copy finished.');
479+
resolve(context);
480+
});
481+
}
456482
};

lib/buildComponent.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
Copyright (c) 2015, 2018, Oracle and/or its affiliates.
3+
The Universal Permissive License (UPL), Version 1.0
4+
*/
5+
'use strict';
6+
7+
const UglifyJS = require('uglify-es');
8+
const config = require('./config');
9+
const path = require('path');
10+
const util = require('./util');
11+
const fs = require('fs-extra');
12+
const glob = require('glob');
13+
const defaultOption = require('./defaultconfig');
14+
15+
function _uglifyComponent(componentPath) {
16+
return new Promise((resolve, reject) => {
17+
try {
18+
const destPath = _getComponentDest(componentPath);
19+
const files = glob.sync('**/*.js', { cwd: destPath });
20+
const uglifyOptions = defaultOption.build.uglify(config('paths')).options;
21+
files.forEach((file) => {
22+
const dest = path.join(destPath, file);
23+
const data = _getUglyCode(dest, uglifyOptions);
24+
if (data.error) reject(data.error);
25+
fs.writeFileSync(dest, data.code);
26+
});
27+
resolve();
28+
} catch (error) {
29+
reject(error);
30+
}
31+
});
32+
}
33+
34+
function _getComponentDest(componentPath) {
35+
return path.join(componentPath, 'min');
36+
}
37+
38+
function _getUglyCode(file, uglifyOptions) {
39+
const code = fs.readFileSync(file, 'utf-8');
40+
return UglifyJS.minify(code, uglifyOptions);
41+
}
42+
43+
function _copyScriptsToDest(componentPath) {
44+
const destPath = _getComponentDest(componentPath);
45+
fs.removeSync(destPath);
46+
// avoid recursively copy the min directory
47+
const filter = function (src) {
48+
return !/min/.test(src);
49+
};
50+
51+
fs.copySync(componentPath, destPath, { filter });
52+
}
53+
54+
function _getComponentPath(component) {
55+
const basePath = path.join(config('paths').src.common,
56+
config('paths').src.javascript, config('paths').composites);
57+
const componentPath = path.join(basePath, component);
58+
if (!util.fsExistsSync(componentPath)) {
59+
util.log.error(`The component ${component} is not found`);
60+
}
61+
return componentPath;
62+
}
63+
64+
function _copyToStaging(component) {
65+
const componentPath = _getComponentPath(component);
66+
const destPath = path.join(config('paths').staging.web,
67+
config('paths').src.javascript, config('paths').composites, component);
68+
console.log(destPath);
69+
fs.copySync(componentPath, destPath);
70+
}
71+
72+
module.exports = function buildComponent(component) {
73+
return new Promise((resolve, reject) => {
74+
const componentPath = _getComponentPath(component);
75+
_copyScriptsToDest(componentPath);
76+
_uglifyComponent(componentPath)
77+
.then(() => {
78+
_copyToStaging(component);
79+
util.log(`Component ${component} build is finished.`);
80+
resolve();
81+
})
82+
.catch(err => reject(err));
83+
});
84+
};

lib/buildHybrid.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function _runCommonBuildTasks(context) {
119119
.then(buildCommon.clean)
120120
.then(buildCommon.copy)
121121
.then(buildCommon.copyLibs)
122+
.then(buildCommon.copyReferenceCca)
122123
.then(buildCommon.copyLocalCca)
123124
.then(buildCommon.spriteSvg)
124125
.then(buildCommon.sass)

lib/buildWeb.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function _runCommonBuildTasks(context) {
2929
.then(data => hookRunner('before_build', data))
3030
.then(buildCommon.copy)
3131
.then(buildCommon.copyLibs)
32+
.then(buildCommon.copyReferenceCca)
3233
.then(buildCommon.copyLocalCca)
3334
.then(buildCommon.spriteSvg)
3435
.then(buildCommon.sass)

lib/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ module.exports = {
1616
COMMON_THEME_DIRECTORY: 'common',
1717
JET_COMPOSITE_DIRECTORY: 'jet-composites',
1818
JET_COMPONENTS_DIRECTORY: 'jet_components',
19+
NODE_MODULES_DIRECTORY: 'node_modules',
1920
JET_COMPONENT_JSON: 'component.json',
2021
SUPPORTED_PLATFORMS: ['android', 'ios', 'web', 'windows'],
2122
SUPPORTED_THEME_PLATFORMS: ['android', 'ios', 'web', 'windows', 'common'],
2223
SUPPORTED_HYBRID_PLATFORMS: ['android', 'ios', 'windows'],
23-
SUPPORTED_BROWSERS: ['chrome', 'firefox', 'edge', 'ie', 'opera', 'safari'],
24+
SUPPORTED_BROWSERS: ['chrome', 'firefox', 'edge', 'ie', 'safari'],
2425
SUPPORTED_WEB_PLATFORMS: ['web'],
2526

2627
CORDOVA_CONFIG_XML: 'config.xml',
@@ -47,6 +48,7 @@ module.exports = {
4748
API_TASKS: {
4849
ADD: 'add',
4950
CONFIGURE: 'configure',
51+
CREATE: 'create',
5052
LIST: 'list',
5153
PUBLISH: 'publish',
5254
REMOVE: 'remove',

lib/create.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#! /usr/bin/env node
2+
/**
3+
Copyright (c) 2015, 2018, Oracle and/or its affiliates.
4+
The Universal Permissive License (UPL), Version 1.0
5+
*/
6+
7+
'use strict';
8+
9+
/**
10+
* ## Dependencies
11+
*/
12+
const CONSTANTS = require('./constants');
13+
const pack = require('./scopes/pack');
14+
const util = require('./util');
15+
16+
/**
17+
* # Switch for 'ojet.create()'
18+
*
19+
* @public
20+
* @param {string} scope
21+
* @param {string} parameter
22+
* @returns {Promise}
23+
*/
24+
module.exports = function (scope, parameter) {
25+
switch (scope) {
26+
case (CONSTANTS.API_SCOPES.PACK):
27+
return pack.create(parameter);
28+
default:
29+
util.log.error(`Please specify ojet.${CONSTANTS.API_TASKS.CREATE}() 'scope' parameter.`);
30+
return false;
31+
}
32+
};

0 commit comments

Comments
 (0)