From 4b3be9fbd919ca3fe1ef691bbfb5004ef011a691 Mon Sep 17 00:00:00 2001 From: blm7 Date: Fri, 17 May 2019 13:45:40 -0700 Subject: [PATCH] Release 7.0.0 --- README.md | 4 +- RELEASENOTES.md | 17 +----- THIRDPARTYLICENSE.txt | 2 +- config.json | 3 + config/eslintcustom.js | 2 +- hooks/jetAfterPrepare.js | 2 +- hooks/jetInjector.js | 2 +- lib/add.js | 2 +- lib/addsass.js | 23 ++++++++ lib/build.js | 2 +- lib/buildCommon.js | 92 ++++++++++++++++++++++++----- lib/buildComponent.js | 2 +- lib/buildHybrid.js | 2 +- lib/buildWeb.js | 3 +- lib/clean.js | 2 +- lib/config.js | 2 +- lib/configure.js | 2 +- lib/constants.js | 3 +- lib/create.js | 2 +- lib/defaultconfig.js | 11 +++- lib/hookRunner.js | 2 +- lib/indexHtmlInjector.js | 2 +- lib/injectorUtil.js | 2 +- lib/list.js | 2 +- lib/mainJsInjector.js | 42 +++++++++++-- lib/npmCopy.js | 2 +- lib/parser/dom-parser.js | 2 +- lib/parser/dom.js | 2 +- lib/parser/sax.js | 2 +- lib/publish.js | 2 +- lib/remove.js | 2 +- lib/rjsConfigGenerator.js | 86 +++++++++++++++++++++------ lib/sass.js | 2 +- lib/scopes/component.js | 2 +- lib/scopes/exchange.js | 2 +- lib/scopes/pack.js | 2 +- lib/search.js | 2 +- lib/serve.js | 2 +- lib/serve/connect.js | 2 +- lib/serve/watch.js | 2 +- lib/serveHybrid.js | 2 +- lib/serveHybridFileChangeHandler.js | 2 +- lib/serveWeb.js | 2 +- lib/serveWebFileChangeHandler.js | 2 +- lib/strip.js | 2 +- lib/svg.js | 2 +- lib/templates/pack/component.json | 2 +- lib/util.js | 82 ++++++++++++++++++++++++- lib/utils.exchange.js | 14 ++++- lib/validations.js | 2 +- oraclejet-tooling.js | 3 +- package.json | 6 +- test/config.js | 2 +- test/hook.js | 2 +- test/paths.js | 2 +- test/serve.js | 2 +- test/util.js | 2 +- test/utilTests.js | 2 +- 58 files changed, 364 insertions(+), 113 deletions(-) create mode 100644 config.json create mode 100644 lib/addsass.js diff --git a/README.md b/README.md index 90ec178..7a89f7b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# @oracle/oraclejet-tooling 6.2.0 +# @oracle/oraclejet-tooling 7.0.0 ## About the tooling API 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. @@ -6,7 +6,7 @@ This tooling API contains methods to build and serve Oracle JET web and hybrid m This is an open source project maintained by Oracle Corp. ## Installation -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=jet620&id=homepage). +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=jet700&id=homepage). ## [Contributing](https://github.com/oracle/oraclejet-tooling/tree/master/CONTRIBUTING.md) Oracle JET is an open source project. Pull Requests are currently not being accepted. See diff --git a/RELEASENOTES.md b/RELEASENOTES.md index b614545..92ba8ed 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,21 +1,6 @@ ## Release Notes for oraclejet-tooling ## -### 6.2.0 -* No changes - -### 5.2.0 -* No changes - -### 5.1.0 -* No changes - -### 5.0.0 -* No changes - -### 4.2.0 -* No changes - -### 4.1.0 +### 7.0.0 * No changes ### 4.0.0 diff --git a/THIRDPARTYLICENSE.txt b/THIRDPARTYLICENSE.txt index 4aa882f..f9b74e0 100644 --- a/THIRDPARTYLICENSE.txt +++ b/THIRDPARTYLICENSE.txt @@ -119,7 +119,7 @@ terms above. /** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.3.5 Copyright jQuery Foundation and other contributors. + * @license RequireJS 2.3.6 Copyright jQuery Foundation and other contributors. * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE */ diff --git a/config.json b/config.json new file mode 100644 index 0000000..9b23275 --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +{"eslintDirs": ["lib", "hooks"], + "eslintFilter": ["!**/parser/**"], + "fixup": ["package.json"]} \ No newline at end of file diff --git a/config/eslintcustom.js b/config/eslintcustom.js index ba49f28..3af2358 100644 --- a/config/eslintcustom.js +++ b/config/eslintcustom.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ // diff --git a/hooks/jetAfterPrepare.js b/hooks/jetAfterPrepare.js index 9e08d10..0bc9234 100644 --- a/hooks/jetAfterPrepare.js +++ b/hooks/jetAfterPrepare.js @@ -1,6 +1,6 @@ #!/usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/hooks/jetInjector.js b/hooks/jetInjector.js index fb826fc..6428cf4 100644 --- a/hooks/jetInjector.js +++ b/hooks/jetInjector.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/add.js b/lib/add.js index 63e8a37..5d85b89 100644 --- a/lib/add.js +++ b/lib/add.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/addsass.js b/lib/addsass.js new file mode 100644 index 0000000..d97f05b --- /dev/null +++ b/lib/addsass.js @@ -0,0 +1,23 @@ +#! /usr/bin/env node +/** + Copyright (c) 2015, 2019, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ + +'use strict'; + +/** + * ## Dependencies + */ +const util = require('./util'); + +/** + * # 'addSass' + * + * @public + * @returns {Promise} + */ +module.exports = function () { + util.log('Performing \'npm install node-sass\''); + return util.spawn('npm', ['install', 'node-sass@4.11.0', '--save-dev=true']); +}; diff --git a/lib/build.js b/lib/build.js index d87d27f..e62de44 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/buildCommon.js b/lib/buildCommon.js index 53f0ad1..2b85d23 100644 --- a/lib/buildCommon.js +++ b/lib/buildCommon.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; @@ -263,7 +263,6 @@ function _renameNlsDirs() { } module.exports = { - clean: function _clean(context) { util.log('Cleaning staging path.'); const opts = context.opts; @@ -441,7 +440,6 @@ module.exports = { } }); }, - cleanTemp: function _cleanTemp(context) { util.log('Cleaning mainTemp.'); const opts = context.opts; @@ -509,6 +507,36 @@ module.exports = { return resolve(context); }); }, + + // + // Copy the reference component from the npm path into the staging directory. + // + // For reference components, the preferred configuration will select the minified component. + // (provided that it exists). + // E.g., even if the --release flag is not present, + // we still will use the minified component. + // + // jet_components/oj-ref-showdown/component.json + // jet_components/oj-ref-showdown + // + // Example component.json: + // { + // "name": "oj-ref-showdown", + // "type": "reference", + // "package":"showdown", + // "version": "1.9.0", + // "paths": { + // "npm": { + // "min": "dist/showdown.min", + // "debug": "dist/showdown" + // }, + // "cdn": { + // "min": "https://static.oracle.com/cdn/jet/packs/3rdparty/showdown/1.9.0/showdown.min", + // "debug": "https://static.oracle.com/cdn/jet/packs/3rdparty/showdown/1.9.0/showdown.min" + // } + // } + // } + copyReferenceCca(context) { return new Promise((resolve) => { util.log('Copy reference components to staging directory.'); @@ -518,17 +546,53 @@ module.exports = { const componentJson = util.readJsonAndReturnObject(`${componentDirPath}`); if (componentJson.type === 'reference') { const npmPckgName = componentJson.package; - const npmPckgInitFileRelativePath = componentJson.paths.npm[context.buildType === 'release' ? 'min' : 'debug']; - - // Get only the file name - const npmPckgInitFileNameArray = npmPckgInitFileRelativePath.split('/'); - const npmPckgInitFileName = npmPckgInitFileNameArray[npmPckgInitFileNameArray.length - 1]; - - // Copy - const npmPckgSrcPath = `./${CONSTANTS.NODE_MODULES_DIRECTORY}/${npmPckgName}/${npmPckgInitFileRelativePath}`; - const destBasePath = path.join(config('paths').staging.stagingPath, config('paths').src.javascript, 'libs'); - const destNpmpckgDirPath = `${destBasePath}/${npmPckgName}/${npmPckgInitFileName}`; - fs.copySync(npmPckgSrcPath, destNpmpckgDirPath); + const retObj = util.getNpmPckgInitFileRelativePath(componentJson, context.buildType); + const npmPckgInitFileRelativePath = retObj.npmPckgInitFileRelativePath; + + // + // Select the the minimized path (if defined). + // Otherwise select the debug path. + // Example path from component.json: + // + // "paths": { + // "npm": { + // "min": "dist/showdown.min", + // "debug": "dist/showdown" + // } + // } + // + + // Copy is only necessary for npm paths. + // (no copy is necessary for cdn paths). + if (npmPckgInitFileRelativePath !== undefined && retObj.npm) { + // Extract out the filename portion of the path. + const npmPckgInitFileNameArray = npmPckgInitFileRelativePath.split('/'); + const npmPckgInitFileName = npmPckgInitFileNameArray[npmPckgInitFileNameArray.length - 1]; // eslint-disable-line max-len + const npmPckgSrcPath = `./${CONSTANTS.NODE_MODULES_DIRECTORY}/${npmPckgName}/${npmPckgInitFileRelativePath}`; // eslint-disable-line max-len + // + // Construct the npm path (node_modules) to the component file. + // E.g: + // ./node_modules/showdown/dist/showdown + // Then copy this file to + // /web/js/libs/showdown/showdown.js + // + // Note - the component.json npm path does not necessarily have the .js extension, + // so we handle this if necessary. + // + + const destBasePath = path.join(config('paths').staging.stagingPath, config('paths').src.javascript, 'libs'); + // + // If npmPckgSrcPath is a directory (containing multiple files), + // then we need to copy the entire directory. + // + const destNpmpckgDirPath = `${destBasePath}/${npmPckgName}/${npmPckgInitFileName}`; + + if (util.fsExistsSync(npmPckgSrcPath)) { + fs.copySync(npmPckgSrcPath, destNpmpckgDirPath); + } else if (util.fsExistsSync(npmPckgSrcPath.concat('.js'))) { + fs.copySync(npmPckgSrcPath.concat('.js'), destNpmpckgDirPath.concat('.js')); + } + } } }); util.log('Copy finished.'); diff --git a/lib/buildComponent.js b/lib/buildComponent.js index a6dc2ae..85aaa1b 100644 --- a/lib/buildComponent.js +++ b/lib/buildComponent.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/buildHybrid.js b/lib/buildHybrid.js index db9ab1c..1973721 100644 --- a/lib/buildHybrid.js +++ b/lib/buildHybrid.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/buildWeb.js b/lib/buildWeb.js index bc70248..2f10f23 100644 --- a/lib/buildWeb.js +++ b/lib/buildWeb.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; @@ -44,6 +44,7 @@ function _runCommonBuildTasks(context) { module.exports = function buildWeb(buildType, opts) { const context = { buildType, opts, platform: 'web' }; + return new Promise((resolve, reject) => { _runCommonBuildTasks(context) .then(_runReleaseBuildTasks) diff --git a/lib/clean.js b/lib/clean.js index 1a3f62b..4845f3e 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/config.js b/lib/config.js index e447665..b5ef212 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/configure.js b/lib/configure.js index 83606aa..205773e 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/constants.js b/lib/constants.js index d278230..b5a12e4 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; @@ -47,6 +47,7 @@ module.exports = { API_TASKS: { ADD: 'add', + ADDSASS: 'addsass', CONFIGURE: 'configure', CREATE: 'create', LIST: 'list', diff --git a/lib/create.js b/lib/create.js index 3849e3c..1229c48 100644 --- a/lib/create.js +++ b/lib/create.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/defaultconfig.js b/lib/defaultconfig.js index 05f6365..57f849d 100644 --- a/lib/defaultconfig.js +++ b/lib/defaultconfig.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; @@ -16,15 +16,22 @@ module.exports = { startTag: '//injector:mainReleasePaths', endTag: '//endinjector', mainJs: `${paths.staging.stagingPath}/${paths.src.javascript}/main.js`, + testJs: `${paths.staging.stagingPath}/${paths.src.tests}/${paths.src.javascript}/main.js`, destMainJs: `${paths.staging.stagingPath}/${paths.src.javascript}/main-temp.js`, mainReleasePaths: `${paths.src.common}/${paths.src.javascript}/main-release-paths.json` }), + // + // The first block directive copies all .js from src dir, (excluding main.js + // and also excluding the jet-composites/ directory). + // We exclude the jet-composites/ dir because the component + // version naming is not identical under the src/ and web/ path. + // uglify: paths => ({ fileList: [ { cwd: `${paths.src.common}/${paths.src.javascript}`, - src: ['**/*.js', '!main.js'], + src: ['**/*.js', '!main.js', `!${paths.composites}/**/*.js`], dest: `${paths.staging.stagingPath}/${paths.src.javascript}` }, { diff --git a/lib/hookRunner.js b/lib/hookRunner.js index 431c17f..a3de179 100644 --- a/lib/hookRunner.js +++ b/lib/hookRunner.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/indexHtmlInjector.js b/lib/indexHtmlInjector.js index 0c5a3c6..ac33421 100644 --- a/lib/indexHtmlInjector.js +++ b/lib/indexHtmlInjector.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/injectorUtil.js b/lib/injectorUtil.js index 575210f..9fbcc8c 100644 --- a/lib/injectorUtil.js +++ b/lib/injectorUtil.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/list.js b/lib/list.js index c712d65..7ff2ee2 100644 --- a/lib/list.js +++ b/lib/list.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/mainJsInjector.js b/lib/mainJsInjector.js index 978b1d9..8572a98 100644 --- a/lib/mainJsInjector.js +++ b/lib/mainJsInjector.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; @@ -25,8 +25,8 @@ function _getInjectContent(buildType, mainPathMapping) { return injectCode; } -function _replaceReleasePath(buildType, config, platform) { - const injectSrc = _getInjectSource(config.mainJs); +function _replaceReleasePath(buildType, config, platform, injectedFile) { + const injectSrc = _getInjectSource(injectedFile); const startTag = config.startTag; const endTag = config.endTag; const pattern = injectorUtil.getInjectorTagsRegExp(startTag, endTag); @@ -75,6 +75,11 @@ function _replaceReleasePath(buildType, config, platform) { return injectResult; } +// +// Update config.mainJs, replacing the path mappings that are delimited by +// the "injector" comment tags. +// (see defaultconfig.js for the default tags (look for "injectPaths")). +// function _writeRequirePathToFile(context) { const config = context.opts.injectPaths; const buildType = context.buildType; @@ -84,11 +89,37 @@ function _writeRequirePathToFile(context) { let destDir = (buildType === 'release') ? config.destMainJs : config.mainJs; destDir = util.destPath(destDir); - const injectedContent = _replaceReleasePath(buildType, config, platform); + if (!fs.existsSync(config.mainJs)) resolve(context); + + const injectedContent = _replaceReleasePath(buildType, config, platform, config.mainJs); + + fs.outputFile(destDir, injectedContent, (err) => { + if (err) reject(err); + resolve(context); + }); + }); +} + +// +// Update config.testJs, replacing the path mappings. +// (This code is similar to the above _writeRequirePathToFile() function). +// +function _writeRequirePathToTestFile(context) { + const config = context.opts.injectPaths; + const buildType = context.buildType; + const platform = context.platform; + + return new Promise((resolve, reject) => { + let destDir = config.testJs; + destDir = util.destPath(destDir); + + if (!fs.existsSync(config.testJs)) resolve(context); + + const injectedContent = _replaceReleasePath(buildType, config, platform, config.testJs); fs.outputFile(destDir, injectedContent, (err) => { if (err) reject(err); - resolve(config); + resolve(context); }); }); } @@ -172,6 +203,7 @@ module.exports = { newContext.opts.requireJs = pathGenerator.updateRJsOptimizerConfig(context); _setMainPathMapping(newContext, pathsObj) .then(_writeRequirePathToFile) + .then(_writeRequirePathToTestFile) .then(() => { resolve(newContext); }); diff --git a/lib/npmCopy.js b/lib/npmCopy.js index bf1dd7b..700bc0c 100644 --- a/lib/npmCopy.js +++ b/lib/npmCopy.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/parser/dom-parser.js b/lib/parser/dom-parser.js index 9e8da8f..ea18cad 100644 --- a/lib/parser/dom-parser.js +++ b/lib/parser/dom-parser.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ function DOMParser(options){ diff --git a/lib/parser/dom.js b/lib/parser/dom.js index 8c17112..56896bf 100644 --- a/lib/parser/dom.js +++ b/lib/parser/dom.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /* diff --git a/lib/parser/sax.js b/lib/parser/sax.js index 8de6bb6..e6ac8dc 100644 --- a/lib/parser/sax.js +++ b/lib/parser/sax.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] diff --git a/lib/publish.js b/lib/publish.js index 0b3e87b..90efcdc 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/remove.js b/lib/remove.js index 168b8f1..6c7ff6e 100644 --- a/lib/remove.js +++ b/lib/remove.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/rjsConfigGenerator.js b/lib/rjsConfigGenerator.js index 609ffa2..9b4494f 100644 --- a/lib/rjsConfigGenerator.js +++ b/lib/rjsConfigGenerator.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ @@ -45,6 +45,7 @@ function _getLibPath(buildType, libObj, useCdn, cdnUrls, libName) { if (path.extname(libPath) === '.js') { libPath = path.join(libPath, '..', path.basename(libPath, path.extname(libPath))); } + return libPath; } @@ -108,7 +109,7 @@ function _getCcaRJsConfig(buildType, masterJson, oldConfig) { if (masterJson.use === 'cdn' && componentJson.cdn) { // Is either release or debug url available? if (componentJson.cdn.min || componentJson.cdn.debug) { - newConfig.paths[componentJson.paths.name || component] = 'empty:'; + newConfig.paths[(componentJson.paths && componentJson.paths.name) || component] = 'empty:'; } } } @@ -129,6 +130,21 @@ function _getCcaRJsConfig(buildType, masterJson, oldConfig) { return newConfig; } +function _constructComponentPath(retObj, npmPackageName) { + let finalPath = ''; + if (!retObj.npmPckgInitFileRelativePath) return finalPath; + if (retObj.npm) { + // Get only the file name + const npmPckgInitFileNameArray = retObj.npmPckgInitFileRelativePath.split('/'); + let npmPckgInitFileName = npmPckgInitFileNameArray[npmPckgInitFileNameArray.length - 1]; + npmPckgInitFileName = npmPckgInitFileName.replace('.js', ''); + finalPath = `libs/${npmPackageName}/${npmPckgInitFileName}`; + } else { + finalPath = retObj.npmPckgInitFileRelativePath; + } + return finalPath; +} + /** * ## _getCcaPathMapping * @private @@ -138,6 +154,7 @@ function _getCcaRJsConfig(buildType, masterJson, oldConfig) { function _getCcaPathMapping(buildType) { const pathMappingObj = {}; const dependenciesObj = util.readJsonAndReturnObject(`./${CONSTANTS.ORACLE_JET_CONFIG_JSON}`).components; + if (!dependenciesObj) return pathMappingObj; Object.keys(dependenciesObj).forEach((dependency) => { let dependencyPath = `${CONSTANTS.JET_COMPOSITE_DIRECTORY}/${dependency}`; @@ -145,21 +162,13 @@ function _getCcaPathMapping(buildType) { const dependencyComponentJson = util.readJsonAndReturnObject(dependencyComponentJsonPath); if (dependencyComponentJson.type === 'reference') { const npmPackageName = `${dependencyComponentJson.package}`; - - // Use debug path by default - let npmPckgInitFileRelativePath = dependencyComponentJson.paths.npm.debug; - // For release, use minified version if available - if (buildType === 'release' && dependencyComponentJson.paths.npm.min) { - npmPckgInitFileRelativePath = dependencyComponentJson.paths.npm.min; - } - - // Get only the file name - const npmPckgInitFileNameArray = npmPckgInitFileRelativePath.split('/'); - let npmPckgInitFileName = npmPckgInitFileNameArray[npmPckgInitFileNameArray.length - 1]; - npmPckgInitFileName = npmPckgInitFileName.replace('.js', ''); - - // Set mapping - pathMappingObj[dependencyComponentJson.paths.name || dependency] = `libs/${npmPackageName}/${npmPckgInitFileName}`; + const retObj = util.getNpmPckgInitFileRelativePath(dependencyComponentJson, buildType); + const finalPath = _constructComponentPath(retObj, npmPackageName); + // + // For reference components, the pathMappingObject property is set to: + // (a) paths.name (if it exists), otherwise (b) the package name. + // + pathMappingObj[(dependencyComponentJson.paths && dependencyComponentJson.paths.name) || npmPackageName] = finalPath; // eslint-disable-line } else { const version = _getValidVersion(dependencyComponentJson.version); dependencyPath += `/${version}`; @@ -170,6 +179,43 @@ function _getCcaPathMapping(buildType) { return pathMappingObj; } +/** + * ## _getReferencePathMapping + * @private + * @param {Object} dependency + * @returns {Object} + * + * Return a pathMappingObj that contains all reference components. + * The approach used to discover the reference components is to traverse + * the JET_COMPONENTS_DIRECTORY. + * This approach ensures that all reference components are discovered. + * + * For example, the oj-sample-calendar component will pull in two reference components, + * oj-ref-calendar and oj-ref-moment. + * These two reference components will be returned in the pathMappingObj and + * subsequently injected into the main.js pathMapping. + * + * "fullcalendar":"libs/fullcalendar/dist", + * "moment":"libs/moment/moment.min" + * +*/ +function _getReferencePathMapping(buildType) { + const pathMappingObj = {}; + const componentList = util.getDirectories(`./${CONSTANTS.JET_COMPONENTS_DIRECTORY}`); + componentList.forEach((component) => { + const componentDirPath = `./${CONSTANTS.JET_COMPONENTS_DIRECTORY}/${component}/${CONSTANTS.JET_COMPONENT_JSON}`; + const componentJson = util.readJsonAndReturnObject(`${componentDirPath}`); + if (componentJson.type === 'reference') { + const npmPathOrPackageName = + (componentJson.paths && componentJson.paths.name) || componentJson.package; + const retObj = util.getNpmPckgInitFileRelativePath(componentJson, buildType); + const finalPath = _constructComponentPath(retObj, npmPathOrPackageName); + pathMappingObj[npmPathOrPackageName] = finalPath; + } + }); + return pathMappingObj; +} + function _getValidVersion(version) { return !isNaN(version.charAt(0)) ? version : version.substring(1); } @@ -268,8 +314,10 @@ module.exports = { getPathsMapping: function _getPathsMapping(context) { const masterJson = util.readPathMappingJson(); const buildType = context.buildType === 'release' ? 'release' : 'debug'; - const pathMappingObj = Object.assign({}, _getPathMappingObj(buildType, masterJson), - _getCcaPathMapping(buildType), _getLocalCcaPathMapping(buildType)); + const pathMappingObj = + Object.assign({}, _getPathMappingObj(buildType, masterJson), + _getCcaPathMapping(buildType), _getReferencePathMapping(buildType), + _getLocalCcaPathMapping(buildType)); return pathMappingObj; }, diff --git a/lib/sass.js b/lib/sass.js index e0d2810..6838677 100644 --- a/lib/sass.js +++ b/lib/sass.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/scopes/component.js b/lib/scopes/component.js index b8272c2..51312f9 100644 --- a/lib/scopes/component.js +++ b/lib/scopes/component.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/scopes/exchange.js b/lib/scopes/exchange.js index 8853604..bb878e8 100644 --- a/lib/scopes/exchange.js +++ b/lib/scopes/exchange.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/scopes/pack.js b/lib/scopes/pack.js index d645e9e..41d00b4 100644 --- a/lib/scopes/pack.js +++ b/lib/scopes/pack.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/search.js b/lib/search.js index aec9af5..9935590 100644 --- a/lib/search.js +++ b/lib/search.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/serve.js b/lib/serve.js index eb97928..342087c 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/serve/connect.js b/lib/serve/connect.js index 783b665..76a7537 100644 --- a/lib/serve/connect.js +++ b/lib/serve/connect.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/serve/watch.js b/lib/serve/watch.js index 71d2e4c..6f88f7e 100644 --- a/lib/serve/watch.js +++ b/lib/serve/watch.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/serveHybrid.js b/lib/serveHybrid.js index 0381dc8..ef16a51 100644 --- a/lib/serveHybrid.js +++ b/lib/serveHybrid.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/serveHybridFileChangeHandler.js b/lib/serveHybridFileChangeHandler.js index fe12f61..aaafdaf 100644 --- a/lib/serveHybridFileChangeHandler.js +++ b/lib/serveHybridFileChangeHandler.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/serveWeb.js b/lib/serveWeb.js index fed5084..2972ab1 100644 --- a/lib/serveWeb.js +++ b/lib/serveWeb.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/serveWebFileChangeHandler.js b/lib/serveWebFileChangeHandler.js index 4e7d152..e31c1c2 100644 --- a/lib/serveWebFileChangeHandler.js +++ b/lib/serveWebFileChangeHandler.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/lib/strip.js b/lib/strip.js index 9ce22e9..563b34a 100644 --- a/lib/strip.js +++ b/lib/strip.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/svg.js b/lib/svg.js index 4b553c6..a1a6110 100644 --- a/lib/svg.js +++ b/lib/svg.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ diff --git a/lib/templates/pack/component.json b/lib/templates/pack/component.json index 8608733..9861289 100644 --- a/lib/templates/pack/component.json +++ b/lib/templates/pack/component.json @@ -1,7 +1,7 @@ { "name": "@pack@", "version": "1.0.0", - "jetVersion": "6.2.0", + "jetVersion": "7.0.0", "type": "pack", "displayName": "A user friendly, translatable name of the pack.", "description": "A translatable high-level description for the pack.", diff --git a/lib/util.js b/lib/util.js index 268247b..c91fef3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ @@ -1286,3 +1286,83 @@ util.getJetpackCompNameFromConfigObj = function (configComponentVersionObj, path const matchingName = Object.keys(configComponentVersionObj).find(key => pathComponentsEnd.indexOf(`/${key.toString()}/`) !== -1); return matchingName; }; + +/** + * ## getNpmPckgInitFileRelativePath + * + * @private + * @param {String} componentJson component json file + * @param {String} buildType build type + * @returns {Object} with two fields, npmPckgInitFileRelativePath which is the file path, + * and a boolean cdn, which is true if the path is a cdn path. + * + * Return the preferred component path. + * The component path is returned as a relative path. + * + * Example path from component.json: + * + * "paths": { + * "npm": { + * "min": "dist/showdown.min", + * "debug": "dist/showdown" + * } + * "cdn": { + * "min": "https://static.oracle.com/cdn/jet/packs/3rdparty/showdown/1.9.0/showdown.min", + * "debug": "https://static.oracle.com/cdn/jet/packs/3rdparty/showdown/1.9.0/showdown.min" + * } + * } + * + * The path selected to return is based on the following search pattern: + * + * For ojet build: + * 1. npm.min + * 2. npm.debug + * 3. cdn.debug + * 4. cdn.min + * + * For ojet build --release: + * 1. cdn.min + * 2. cdn.debug + * 3. npm.min + * 4. npm.debug + */ +util.getNpmPckgInitFileRelativePath = function (componentJson, buildType) { + const retObj = {}; + retObj.npmPckgInitFileRelativePath = undefined; + retObj.npm = true; + + if (!componentJson.paths) return retObj; + if (buildType === 'release') { + if (componentJson.paths.cdn !== undefined) { + retObj.npm = false; + if (componentJson.paths.cdn.min !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.cdn.min; + } else if (componentJson.paths.cdn.debug !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.cdn.debug; + } + } else if (componentJson.paths.npm !== undefined) { + if (componentJson.paths.npm.min !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.npm.min; + } else if (componentJson.paths.npm.debug !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.npm.debug; + } + } + } else { + if (componentJson.paths.npm !== undefined) { // eslint-disable-line no-lonely-if + if (componentJson.paths.npm.min !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.npm.min; + } else if (componentJson.paths.npm.debug !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.npm.debug; + } + } else if (componentJson.paths.cdn !== undefined) { + retObj.npm = false; + if (componentJson.paths.cdn.debug !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.cdn.debug; + } else if (componentJson.paths.cdn.min !== undefined) { + retObj.npmPckgInitFileRelativePath = componentJson.paths.cdn.min; + } + } + } + return retObj; +}; + diff --git a/lib/utils.exchange.js b/lib/utils.exchange.js index 83cea37..f2fb25e 100644 --- a/lib/utils.exchange.js +++ b/lib/utils.exchange.js @@ -1,6 +1,6 @@ #! /usr/bin/env node /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ @@ -195,7 +195,12 @@ function _resolveDependencies() { util.log('Response body'); util.log(responseBody); } - util.log('Dependencies resolved.'); + const res = JSON.parse(responseBody); + if (res.solutions && res.solutions.length === 0) { + util.log.warning('Requested component(s)/version(s) or their dependencies cannot be found in Exchange or are in conflict with already installed components.'); + } else { + util.log('Dependencies resolved.'); + } resolve(JSON.parse(responseBody)); }); response.on('error', (error) => { @@ -227,7 +232,10 @@ exchangeUtils.getAccessToken = function (user, pass) { util.request({ method: 'POST', - path: '/auth/token' + path: '/auth/token', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } }, body) .then((response) => { let responseBody = ''; diff --git a/lib/validations.js b/lib/validations.js index b5ffa85..d9039c1 100644 --- a/lib/validations.js +++ b/lib/validations.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ 'use strict'; diff --git a/oraclejet-tooling.js b/oraclejet-tooling.js index b6015ff..f0a7626 100644 --- a/oraclejet-tooling.js +++ b/oraclejet-tooling.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /** @@ -22,6 +22,7 @@ const CONSTANTS = require('./lib/constants'); */ [ CONSTANTS.API_TASKS.ADD, + CONSTANTS.API_TASKS.ADDSASS, 'build', 'clean', 'config', diff --git a/package.json b/package.json index 659a817..29be250 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oracle/oraclejet-tooling", - "version": "6.2.0", + "version": "7.0.0", "license": "UPL-1.0", "description": "Programmatic API to build and serve Oracle JET web and mobile applications", "keywords": [ @@ -24,6 +24,7 @@ "requirejs": "^2.2.0", "uglify-es": "^3.3.5", "gaze": "^1.1.2", + "js-yaml":"~3.13.0", "connect": "^3.5.0", "connect-livereload": "^0.6.0", "tiny-lr": "^1.0.3", @@ -38,8 +39,5 @@ }, "engines": { "node": ">=4.0.0" - }, - "devDependencies": { - "eslint": "~3.19.0" } } diff --git a/test/config.js b/test/config.js index 2a2db5e..f5f3578 100644 --- a/test/config.js +++ b/test/config.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /** diff --git a/test/hook.js b/test/hook.js index 0ccd694..6d782fc 100644 --- a/test/hook.js +++ b/test/hook.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /** diff --git a/test/paths.js b/test/paths.js index 81178ed..3b169cb 100644 --- a/test/paths.js +++ b/test/paths.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /** diff --git a/test/serve.js b/test/serve.js index 66b3b16..3fd2cda 100644 --- a/test/serve.js +++ b/test/serve.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /** diff --git a/test/util.js b/test/util.js index a4df04e..7695434 100644 --- a/test/util.js +++ b/test/util.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /** diff --git a/test/utilTests.js b/test/utilTests.js index 0e62b02..e0731e9 100644 --- a/test/utilTests.js +++ b/test/utilTests.js @@ -1,5 +1,5 @@ /** - Copyright (c) 2015, 2019, Oracle and/or its affiliates. + Copyright (c) 2015, 2019, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ /**