├── CONTRIBUTING.md ├── Gruntfile.js ├── LICENSE.md ├── README.md ├── RELEASENOTES.md ├── THIRDPARTYLICENSE.txt ├── common ├── component.js ├── hookRunner.js ├── index.js ├── messages.js ├── restore.js ├── template │ ├── blank.js │ ├── common.js │ ├── index.js │ ├── local.js │ ├── npm.js │ └── url.js └── test.js ├── generators ├── add-component │ └── index.js ├── add-hybrid │ └── index.js ├── add-sass │ └── index.js ├── add-theme │ ├── index.js │ └── templates │ │ └── mytheme │ │ ├── android │ │ └── mytheme.scss │ │ ├── ios │ │ └── mytheme.scss │ │ ├── theme.json │ │ ├── web │ │ └── mytheme.scss │ │ └── windows │ │ └── mytheme.scss ├── app │ ├── index.js │ └── templates │ │ ├── blank │ │ ├── index.html │ │ └── js │ │ │ ├── main.js │ │ │ └── path_mapping.json │ │ └── common │ │ ├── package.json │ │ └── src │ │ └── css │ │ └── images │ │ └── favicon.ico ├── hybrid │ ├── index.js │ └── templates │ │ ├── blank │ │ ├── index.html │ │ └── js │ │ │ ├── main.js │ │ │ └── path_mapping.json │ │ └── common │ │ ├── package.json │ │ ├── res │ │ ├── icon │ │ │ ├── android │ │ │ │ ├── icon-hdpi.png │ │ │ │ ├── icon-ldpi.png │ │ │ │ ├── icon-mdpi.png │ │ │ │ ├── icon-xhdpi.png │ │ │ │ ├── icon-xxhdpi.png │ │ │ │ └── icon-xxxhdpi.png │ │ │ ├── ios │ │ │ │ ├── icon-40.png │ │ │ │ ├── icon-40@2x.png │ │ │ │ ├── icon-40@3x.png │ │ │ │ ├── icon-50.png │ │ │ │ ├── icon-50@2x.png │ │ │ │ ├── icon-60.png │ │ │ │ ├── icon-60@2x.png │ │ │ │ ├── icon-60@3x.png │ │ │ │ ├── icon-72.png │ │ │ │ ├── icon-72@2x.png │ │ │ │ ├── icon-76.png │ │ │ │ ├── icon-76@2x.png │ │ │ │ ├── icon-83.5@2x.png │ │ │ │ ├── icon-small.png │ │ │ │ ├── icon-small@2x.png │ │ │ │ ├── icon-small@3x.png │ │ │ │ ├── icon.png │ │ │ │ └── icon@2x.png │ │ │ └── windows │ │ │ │ ├── Square150x150Logo.scale-100.png │ │ │ │ ├── Square150x150Logo.scale-240.png │ │ │ │ ├── Square30x30Logo.scale-100.png │ │ │ │ ├── Square310x310Logo.scale-100.png │ │ │ │ ├── Square44x44Logo.scale-100.png │ │ │ │ ├── Square44x44Logo.scale-240.png │ │ │ │ ├── Square70x70Logo.scale-100.png │ │ │ │ ├── Square71x71Logo.scale-100.png │ │ │ │ ├── Square71x71Logo.scale-240.png │ │ │ │ ├── Wide310x150Logo.scale-100.png │ │ │ │ └── Wide310x150Logo.scale-240.png │ │ └── screen │ │ │ ├── android │ │ │ ├── splash-land-hdpi.9.png │ │ │ ├── splash-land-ldpi.9.png │ │ │ ├── splash-land-mdpi.9.png │ │ │ ├── splash-land-xhdpi.9.png │ │ │ ├── splash-land-xxhdpi.9.png │ │ │ ├── splash-land-xxxhdpi.9.png │ │ │ ├── splash-port-hdpi.9.png │ │ │ ├── splash-port-ldpi.9.png │ │ │ ├── splash-port-mdpi.9.png │ │ │ ├── splash-port-xhdpi.9.png │ │ │ ├── splash-port-xxhdpi.9.png │ │ │ └── splash-port-xxxhdpi.9.png │ │ │ ├── ios │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Portrait-iphone-x-1125h.png │ │ │ ├── Default-Portrait-iphone-x-2436h.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default@2x~iphone.png │ │ │ └── Default~iphone.png │ │ │ └── windows │ │ │ ├── SplashScreen.scale-100.png │ │ │ └── SplashScreenPhone.scale-240.png │ │ └── src │ │ ├── css │ │ └── images │ │ │ └── favicon.ico │ │ └── js │ │ └── cordovaMocks.js ├── restore-hybrid │ └── index.js ├── restore-web │ └── index.js └── restore │ └── index.js ├── hybrid ├── cordova.js ├── graphics.js ├── index.js └── platforms.js ├── package.json ├── template ├── common │ ├── Gruntfile.js │ ├── _gitignore │ ├── oraclejetconfig.json │ └── scripts │ │ ├── config │ │ ├── oraclejet-build.js │ │ └── oraclejet-serve.js │ │ └── hooks │ │ ├── after_app_create.js │ │ ├── after_app_restore.js │ │ ├── after_build.js │ │ ├── after_component_build.js │ │ ├── after_component_create.js │ │ ├── after_serve.js │ │ ├── before_build.js │ │ ├── before_hybrid_build.js │ │ ├── before_release_build.js │ │ ├── before_serve.js │ │ └── hooks.json ├── component │ ├── @component@-styles.css │ ├── @component@-view.html │ ├── @component@-viewModel.js │ ├── README.md │ ├── component.json │ ├── loader.js │ └── resources │ │ └── nls │ │ └── @component@-strings.js └── test │ ├── index.html │ └── js │ ├── main.js │ └── test.js ├── test ├── commonTest.js ├── hybridTest.js ├── util │ └── index.js └── webTest.js └── util ├── constants.js ├── fetchZip.js ├── index.js └── paths.js /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to generator-oraclejet 2 | 3 | *Copyright (c) 2014, 2019 Oracle and/or its affiliates 4 | The Universal Permissive License (UPL), Version 1.0* 5 | 6 | **Pull requests are currently not being accepted for the Oracle JET project.** 7 | 8 | We plan to provide this functionality in the future. At that time, you will need to follow [The Oracle Contributor Agreement](https://www.oracle.com/technetwork/community/oca-486395.html) 9 | (OCA). 10 | 11 | If you have ideas, comments, or issues to discuss, swing on by the [Oracle JET discussion forum.](https://community.oracle.com/community/development_tools/oracle-jet/generators) 12 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | module.exports = function (grunt) { 6 | grunt.initConfig({ 7 | }); 8 | 9 | 10 | // Load grunt tasks from NPM packages 11 | require("load-grunt-tasks")(grunt); 12 | 13 | // Merge sub configs 14 | var options = { 15 | config : { 16 | src : "build/generator.js" 17 | }, 18 | pkg: grunt.file.readJSON("package.json") 19 | } 20 | var configs = require('load-grunt-configs')(grunt, options); 21 | grunt.config.merge(configs); 22 | 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # generator-oraclejet 2 | 3 | You may not use the identified files except in compliance with the 4 | Universal Permissive License (UPL), Version 1.0 (the "License.") 5 | 6 | You may obtain a copy of the License at 7 | https://opensource.org/licenses/UPL. A copy of the license is 8 | also reproduced below. 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | implied. 14 | 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | 19 | ``` 20 | Copyright (c) 2014, 2019 Oracle and/or its affiliates 21 | The Universal Permissive License (UPL), Version 1.0 22 | 23 | Subject to the condition set forth below, permission is hereby granted to any person obtaining 24 | a copy of this software, associated documentation and/or data (collectively the "Software"), 25 | free of charge and under any and all copyright rights in the Software, and any and all patent 26 | rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified 27 | Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), 28 | to deal in both 29 | 30 | (a) the Software, and (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 31 | one is included with the Software (each a “Larger Work” to which the Software is contributed by such licensors), 32 | without restriction, including without limitation the rights to copy, create derivative works of, 33 | display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, 34 | have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights 35 | on either these or other terms. 36 | 37 | This license is subject to the following condition: 38 | 39 | The above copyright notice and either this complete permission notice or at a minimum a reference 40 | to the UPL must be included in all copies or substantial portions of the Software. 41 | 42 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 43 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 44 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 45 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 46 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 47 | ``` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @oracle/generator-oraclejet 6.2.0 2 | 3 | ## About the generator 4 | This Yeoman generator for Oracle JET lets you quickly set up a project for use as a web application or hybrid mobile application for Android, iOS or Windows 10. 5 | 6 | This is an open source project maintained by Oracle Corp. 7 | 8 | ## Installation 9 | This module will be automatically installed as a dependency of the Oracle JET command-line interface [@oracle/ojet-cli](https://github.com/oracle/ojet-cli), and should not be installed directly. 10 | 11 | ## [Contributing](https://github.com/oracle/generator-oraclejet/tree/master/CONTRIBUTING.md) 12 | Oracle JET is an open source project. Pull Requests are currently not being accepted. See 13 | [CONTRIBUTING](https://github.com/oracle/generator-oraclejet/tree/master/CONTRIBUTING.md) 14 | for details. 15 | 16 | ## [License](https://github.com/oracle/generator-oraclejet/tree/master/LICENSE.md) 17 | Copyright (c) 2014, 2019 Oracle and/or its affiliates 18 | The Universal Permissive License (UPL), Version 1.0 19 | -------------------------------------------------------------------------------- /RELEASENOTES.md: -------------------------------------------------------------------------------- 1 | ## Release Notes for generator-oraclejet ## 2 | 3 | ### 6.2.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/generator-oraclejet 23 | * This module should no longer be installed directly. Use @oracle/ojet-cli instead for scaffolding JET apps. 24 | 25 | ### 3.2.0 26 | * No changes 27 | 28 | ### 3.1.0 29 | * No changes 30 | 31 | ### 3.0.0 32 | * Replaced bower with npm 33 | * SASS tasks now run in CCA directories also 34 | * Added --destination=server-only option for web apps 35 | * Removed --destination=deviceOrEmulatorName option 36 | * Added ability to cutomize serve tasks such as watching additional files 37 | * Added gap://ready to inserted CSP meta tag for iOS 10 compatibility 38 | * Requires Node.js v4.0.0+ and npm v3.0.0+ 39 | * Known issue: grunt serve to iOS device requires developer profile 40 | 41 | ### 2.3.0 42 | * Allow local files as scaffolding starting templates 43 | * Provide the ability to specify the Windows hybrid platform architecture 44 | * Better handling for determining which browser is launched when serving a hybrid app 45 | * Please use the latest version of yeoman as some earlier versions can cause issues with scaffolding 46 | 47 | ### 2.2.0 48 | 49 | * Provide help page for generator 50 | -------------------------------------------------------------------------------- /THIRDPARTYLICENSE.txt: -------------------------------------------------------------------------------- 1 | DO NOT TRANSLATE OR LOCALIZE. 2 | 3 | ******************************************************************************** 4 | Oracle elects to use only the GNU Lesser General Public License version 2.1 5 | (LGPL) for any software where a choice of LGPL/GPL license versions are made 6 | available with the language indicating that LGPLv2.1/GPLv2 or any later version 7 | may be used, or where a choice of which version of the LGPL/GPL is applied is 8 | unspecified. 9 | ******************************************************************************** 10 | 11 | THIRD-PARTY COMPONENT LICENSE 12 | (path in the installation) (see license text reproduced below) 13 | -------------------------------------------------------------------------------- 14 | node_modules/yeoman-generator/ BSD-2-Clause 15 | node_modules/adm-zip/ MIT 16 | node_modules/fs-extra/ MIT 17 | node_modules/xmldom/ MIT 18 | node_modules/request/ Apache-2.0 19 | 20 | Copyright (c) 2015, Google 21 | All rights reserved. 22 | 23 | Redistribution and use in source and binary forms, with or without 24 | modification, are permitted provided that the following conditions are met: 25 | 26 | 1. Redistributions of source code must retain the above copyright notice, this 27 | list of conditions and the following disclaimer. 28 | 2. Redistributions in binary form must reproduce the above copyright notice, 29 | this list of conditions and the following disclaimer in the documentation 30 | and/or other materials provided with the distribution. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 33 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 36 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 37 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 38 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 39 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | 43 | (The MIT License) 44 | 45 | Copyright (c) 2011-2016 JP Richardson 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 48 | (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, 49 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 50 | furnished to do so, subject to the following conditions: 51 | 52 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 53 | 54 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 55 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 56 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 57 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 58 | 59 | You can choose any one of those: 60 | 61 | The MIT License (MIT): 62 | 63 | link:http://opensource.org/licenses/MIT 64 | 65 | LGPL: 66 | http://www.gnu.org/licenses/lgpl.html 67 | 68 | Apache License 69 | 70 | Version 2.0, January 2004 71 | 72 | http://www.apache.org/licenses/ 73 | 74 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 75 | 76 | 1. Definitions. 77 | 78 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 79 | 80 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 81 | 82 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 83 | 84 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 85 | 86 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 87 | 88 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 89 | 90 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 91 | 92 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 93 | 94 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 95 | 96 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 97 | 98 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 99 | 100 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 103 | 104 | You must give any other recipients of the Work or Derivative Works a copy of this License; and 105 | 106 | You must cause any modified files to carry prominent notices stating that You changed the files; and 107 | 108 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 109 | 110 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 111 | 112 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 113 | 114 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 115 | 116 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 117 | 118 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 119 | 120 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 121 | 122 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /common/component.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const CONSTANTS = require('../util/constants'); 10 | const paths = require('../util/paths'); 11 | 12 | module.exports = 13 | { 14 | writeComponentTemplate: function _writeComponentTemplate(generator) { 15 | return new Promise((resolve) => { 16 | if (generator.options.component) { 17 | const templateSrc = path.join(generator.templatePath(), '../../../template/component'); 18 | const isApp = fs.existsSync(path.join(process.cwd(), CONSTANTS.APP_CONFIG_JSON)) 19 | || generator.appDir !== undefined; 20 | 21 | if (!isApp) return resolve(generator); 22 | 23 | const destDirectory = _getComponentDestPath(generator); 24 | // avoid overwrite component 25 | if (fs.existsSync(destDirectory)) { 26 | console.log('Component already exists. '); 27 | return resolve(generator); 28 | } 29 | 30 | fs.ensureDirSync(destDirectory); 31 | fs.copySync(templateSrc, destDirectory); 32 | if (generator.options.pack) _updatePackInfo(generator); 33 | _renamePrefix(generator); 34 | _replaceComponentTemplateToken(generator); 35 | } 36 | 37 | return resolve(generator); 38 | }); 39 | } 40 | }; 41 | 42 | function _getComponentDestPath(generator) { 43 | let destBase = _getCompositesBasePath(generator); 44 | 45 | if (generator.options.pack) { 46 | const packPath = path.join(destBase, generator.options.pack); 47 | fs.ensureDirSync(packPath); 48 | destBase = path.join(destBase, generator.options.pack); 49 | } 50 | return path.join(destBase, generator.options.component); 51 | } 52 | 53 | function _replaceComponentTemplateToken(generator) { 54 | const componentName = _getComponentName(generator); 55 | const base = _getComponentDestPath(generator); 56 | _replaceComponentTokenInFileList(base, componentName); 57 | _replaceComponentTokenInFileList(path.join(base, 'resources/nls'), componentName); 58 | } 59 | 60 | function _replaceComponentTokenInFileList(base, componentName) { 61 | fs.readdirSync(base).forEach((file) => { 62 | if (path.extname(file).length !== 0) { 63 | const fileContent = fs.readFileSync(path.join(base, file), 'utf-8'); 64 | fs.outputFileSync(path.join(base, file), fileContent.replace(new RegExp('@component@', 'g'), componentName)); 65 | } 66 | }); 67 | } 68 | 69 | function _getCompositesBasePath(generator) { 70 | const appDir = generator.appDir === undefined 71 | ? process.cwd() : generator.destinationPath(generator.appDir); 72 | 73 | const _configPaths = generator.appDir === undefined 74 | ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); 75 | 76 | return path.join(appDir, _configPaths.source, 77 | _configPaths.sourceJavascript, CONSTANTS.JET_COMPOSITES); 78 | } 79 | 80 | function _getComponentName(generator) { 81 | return generator.componentName || generator.options.component; 82 | } 83 | 84 | function _renamePrefix(generator) { 85 | let base = _getComponentDestPath(generator); 86 | const componentName = _getComponentName(generator); 87 | fs.readdirSync(base).forEach((file) => { 88 | if (/@component@/.test(file)) _renamePrefixFile(generator, base, file, componentName); 89 | }); 90 | 91 | base = path.join(base, 'resources/nls'); 92 | if (fs.existsSync(base)) { 93 | fs.readdirSync(base).forEach((file) => { 94 | if (/@component@/.test(file)) _renamePrefixFile(generator, base, file, componentName); 95 | }); 96 | } 97 | } 98 | 99 | // replace prefix to include the component name 100 | function _renamePrefixFile(generator, fileDir, file, componentName) { 101 | const oldPath = path.join(fileDir, file); 102 | let newPath = file.replace('@component@', componentName); 103 | newPath = path.join(fileDir, newPath); 104 | fs.renameSync(oldPath, newPath); 105 | } 106 | 107 | function _updatePackInfo(generator) { 108 | const jsonPath = path.join(_getComponentDestPath(generator), 'component.json'); 109 | const componentJson = fs.readJsonSync(jsonPath); 110 | componentJson.pack = generator.options.pack; 111 | fs.outputJsonSync(jsonPath, componentJson); 112 | } 113 | 114 | -------------------------------------------------------------------------------- /common/hookRunner.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const CONSTANTS = require('../util/constants'); 8 | const fs = require('fs'); 9 | const path = require('path'); 10 | 11 | module.exports = { 12 | runAfterAppCreateHook() { 13 | return new Promise((resolve, reject) => { 14 | // Get hooks config 15 | const hooksConfig = _getHooksConfigObj(); 16 | // Get after_app_prepare hook's path 17 | const hookPath = hooksConfig.after_app_create; 18 | if (hookPath && fs.existsSync(path.resolve(hookPath))) { 19 | const hook = require(path.resolve(hookPath)); // eslint-disable-line 20 | // Execute hook 21 | hook() 22 | .then(() => resolve()) 23 | .catch(err => reject(err)); 24 | } else { 25 | console.warn('Hook \'after_app_create\' not defined.'); 26 | resolve(); 27 | } 28 | }); 29 | } 30 | }; 31 | 32 | module.exports = { 33 | runAfterComponentCreateHook() { 34 | return new Promise((resolve, reject) => { 35 | // Get hooks config 36 | const hooksConfig = _getHooksConfigObj(); 37 | // Get after_app_prepare hook's path 38 | const hookPath = hooksConfig.after_component_create; 39 | if (hookPath && fs.existsSync(path.resolve(hookPath))) { 40 | const hook = require(path.resolve(hookPath)); // eslint-disable-line 41 | // Execute hook 42 | hook() 43 | .then(() => resolve()) 44 | .catch(err => reject(err)); 45 | } else { 46 | console.warn('Hook \'after_component_create\' not defined.'); 47 | resolve(); 48 | } 49 | }); 50 | } 51 | }; 52 | 53 | /** 54 | * ## _getHooksConfigObj 55 | * Reads the hooks.json file 56 | * 57 | * @private 58 | */ 59 | function _getHooksConfigObj() { 60 | const configFilePath = path.resolve(CONSTANTS.PATH_TO_HOOKS_CONFIG); 61 | if (fs.existsSync(configFilePath)) { 62 | const configFileContent = fs.readFileSync(configFilePath, 'utf8'); 63 | let configFileContentAsJson = {}; 64 | try { 65 | configFileContentAsJson = JSON.parse(configFileContent); 66 | // If came to here, then valid json 67 | } catch (e) { 68 | console.error(`\x1b[31mError: File '${configFilePath}' is not of type 'json'.\x1b[0m`); 69 | process.exit(1); 70 | } 71 | return configFileContentAsJson.hooks || {}; 72 | } 73 | return {}; 74 | } 75 | -------------------------------------------------------------------------------- /common/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const commonMessages = require('./messages'); 10 | const CONSTANTS = require('../util/constants'); 11 | 12 | module.exports = 13 | { 14 | gruntSpawnCommandPromise: function _gruntSpawnCommandPromise(context, cmd, args, log, options) { 15 | const generator = context.generator; 16 | const newArgs = args || []; 17 | 18 | generator.log(log); 19 | 20 | return new Promise((resolve, reject) => { 21 | // close event is fired after all stdio, which can catch errors from any 22 | // additional childProcesses inovked 23 | generator.spawnCommand(cmd, newArgs, options) 24 | .on('close', (err) => { 25 | if (err) { 26 | reject(commonMessages.error(err, log)); 27 | } else { 28 | resolve(context); 29 | } 30 | }) 31 | .on('error', (err) => { 32 | reject(commonMessages.error(err, log)); 33 | }); 34 | }); 35 | }, 36 | 37 | writeGitIgnore: function _writeGitIgnore(generator) { 38 | const gitSource = generator.destinationPath('_gitignore'); 39 | const gitDest = generator.destinationPath('.gitignore'); 40 | 41 | return new Promise((resolve, reject) => { 42 | fs.move(gitSource, gitDest, (err) => { 43 | if (err) { 44 | reject(commonMessages.error(err, 'writeGitIgnore')); 45 | } else { 46 | resolve(generator); 47 | } 48 | }); 49 | }); 50 | }, 51 | 52 | writeCommonTemplates: function _writeCommonTemplates(generator) { 53 | const templateSrc = path.join(generator.templatePath(), '../../../template/common'); 54 | const templateDest = generator.destinationPath(); 55 | 56 | return new Promise((resolve, reject) => { 57 | fs.copy(templateSrc, templateDest, (err) => { 58 | if (err) { 59 | reject(commonMessages.error(err, 'writeCommonTemplates')); 60 | } else { 61 | resolve(generator); 62 | } 63 | }); 64 | }); 65 | }, 66 | 67 | updatePackageJSON: function _updatePacakgeJSON(generator) { 68 | return new Promise((resolve) => { 69 | _updateJSONAppName(generator, 'package.json'); 70 | resolve(generator); 71 | }); 72 | }, 73 | 74 | validateAppDirNotExistsOrIsEmpty: function _validateAppDirNotExistsOrIsEmpty(generator) { 75 | return new Promise((resolve, reject) => { 76 | const appDir = _handleAbsoluteOrMissingPath(generator); 77 | fs.stat(appDir, (err) => { 78 | if (err) { 79 | // Proceed to scaffold if appDir directory doesn't exist 80 | resolve(appDir); 81 | } else { 82 | fs.readdir(appDir, (readErr, items) => { 83 | const isEmpty = (!items || !items.length); 84 | if (isEmpty) { 85 | // Proceed to scaffold if appDir directory is empty 86 | resolve(appDir); 87 | } else { 88 | items.forEach((filename) => { 89 | if (_fileNotHidden(filename)) { 90 | const error = `path already exists and is not empty: ${path.resolve(appDir)}`; 91 | reject(commonMessages.error(error, 'validateAppDir')); 92 | } else if (filename === '.gitignore') { 93 | const error = 'path already exists and contains a .gitignore file'; 94 | reject(commonMessages.error(error, 'validateAppDir')); 95 | } 96 | }); 97 | resolve(appDir); 98 | } 99 | }); 100 | } 101 | }); 102 | }); 103 | }, 104 | 105 | switchToAppDirectory: function _switchToAppDirectory(generator) { 106 | generator.destinationRoot(generator.destinationPath( 107 | path.basename(path.resolve(generator.appDir)))); 108 | return Promise.resolve(generator); 109 | }, 110 | 111 | validateArgs: function _validateArgs(generator) { 112 | return new Promise((resolve, reject) => { 113 | const args = generator.arguments; 114 | const validLength = _getValidArgLength(generator.options.namespace); 115 | 116 | if (args.length > validLength) { 117 | reject(commonMessages.error(`Invalid additional arguments: ${args.splice(validLength)}`, 'validateArgs')); 118 | } else { 119 | resolve(generator); 120 | } 121 | }); 122 | }, 123 | 124 | validateFlags: function _validateFlags(generator) { 125 | return new Promise((resolve, reject) => { 126 | const flags = generator.options; 127 | const SUPPORTED_FLAGS = CONSTANTS.SUPPORTED_FLAGS(flags.namespace); 128 | Object.keys(flags).forEach((key) => { 129 | if (SUPPORTED_FLAGS.indexOf(key) === -1) { 130 | if (['platforms', 'platform', 'appid', 'appname'].indexOf(key) !== -1) { 131 | reject(commonMessages.error(`Invalid flag: ${key} without flag --hybrid`, 'validateFlags')); 132 | } 133 | reject(commonMessages.error(`Invalid flag: ${key}`, 'validateFlags')); 134 | } 135 | }); 136 | 137 | resolve(generator); 138 | }); 139 | }, 140 | 141 | fsExistsSync(filePath) { 142 | try { 143 | fs.statSync(filePath); 144 | return true; 145 | } catch (err) { 146 | // file/directory does not exist 147 | return false; 148 | } 149 | } 150 | }; 151 | 152 | function _getValidArgLength(namespace) { 153 | // add-hybrid, restore, restore-web, restore-hybrid, add-sass, allow no argument 154 | // add-theme, app, hybrid, optional to take 1 argument 155 | return (/add-hybrid/.test(namespace) || /restore/.test(namespace) || /add-sass/.test(namespace)) 156 | ? 0 : 1; 157 | } 158 | 159 | function _fileNotHidden(filename) { 160 | return !/^\..*/.test(filename); 161 | } 162 | 163 | function _handleAbsoluteOrMissingPath(generator) { 164 | let appDir = generator.appDir; 165 | const appDirObj = path.parse(appDir); 166 | // appDir is absolute or missing 167 | if (path.isAbsolute(appDir) || appDirObj.dir) { 168 | const parentDir = path.resolve(appDir, '..'); 169 | fs.ensureDirSync(parentDir); 170 | generator.destinationRoot(parentDir); 171 | appDir = appDirObj.base; 172 | } else if (appDirObj.name === '.') { 173 | const absolutePath = path.resolve(appDir); 174 | generator.destinationRoot(path.resolve(absolutePath, '..')); 175 | appDir = path.basename(absolutePath); 176 | } 177 | return appDir; 178 | } 179 | 180 | function _updateJSONAppName(generator, jsonPath) { 181 | const json = fs.readJSONSync(generator.destinationPath(jsonPath)); 182 | // space in app name will result in npm install failure 183 | json.name = _removeSpaceInAppName(generator.options.appname); 184 | fs.writeJSONSync(jsonPath, json); 185 | } 186 | 187 | function _removeSpaceInAppName(appName) { 188 | return appName.replace(' ', '-'); 189 | } 190 | -------------------------------------------------------------------------------- /common/messages.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | module.exports = 8 | { 9 | error: function _error(error, task) { 10 | return _getError(error, task); 11 | }, 12 | 13 | prefixError: function _prefixError(error) { 14 | return _getPrefixError(error); 15 | }, 16 | 17 | scaffoldComplete: function _scaffoldComplete() { 18 | return _getScaffoldComplete(); 19 | }, 20 | 21 | restoreComplete: function _restoreComplete(invokedByRestore, appDir) { 22 | return _getRestoreComplete(invokedByRestore, appDir); 23 | }, 24 | 25 | appendJETPrefix: function _appendJETPrefix(message) { 26 | return _appendSuccessPrefix(message || ''); 27 | } 28 | }; 29 | 30 | function _getScaffoldComplete() { 31 | return _appendSuccessPrefix('Your app structure is generated. Continuing with library install.'); 32 | } 33 | 34 | function _getRestoreComplete(invokedByRestore, appDir) { 35 | if (invokedByRestore) { 36 | return _appendSuccessPrefix('\x1b[32mYour app restore finished successfully.\x1b[0m'); 37 | } 38 | return _appendSuccessPrefix(`\x1b[32mYour app is ready! Change to your new app directory '${appDir}' and try 'ojet build' and 'ojet serve'.\x1b[0m`); 39 | } 40 | 41 | function _getPrefixError(error) { 42 | if (error !== null && typeof error === 'object') { 43 | const newErr = Object.assign({}, error); 44 | newErr.message = _appendErrorPrefix(error.message); 45 | return newErr; 46 | } 47 | 48 | return _appendErrorPrefix(error); 49 | } 50 | 51 | function _getError(error, task) { 52 | const taskName = task ? `(during ${task}) ` : ''; 53 | if (error !== null && typeof error === 'object') { 54 | const newErr = Object.assign({}, error); 55 | newErr.message = taskName + error.message; 56 | return newErr; 57 | } 58 | 59 | return taskName + error; 60 | } 61 | 62 | function _appendSuccessPrefix(message) { 63 | return `${message}`; 64 | } 65 | 66 | function _appendErrorPrefix(message) { 67 | return `${message}`; 68 | } 69 | -------------------------------------------------------------------------------- /common/restore.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const common = require('./index'); 10 | const commonMessages = require('./messages'); 11 | const generatorJSON = require('../package.json'); 12 | 13 | const ORACLE_JET_CONFIG_FILE = 'oraclejetconfig.json'; 14 | 15 | module.exports = 16 | { 17 | writeOracleJetConfigFile: function _writeOracleJetConfigFile(context) { 18 | const generator = context.generator; 19 | 20 | const destinationRoot = generator.destinationRoot(); 21 | const configPath = path.resolve(destinationRoot, ORACLE_JET_CONFIG_FILE); 22 | 23 | return new Promise((resolve) => { 24 | generator.log('Writing:', ORACLE_JET_CONFIG_FILE); 25 | 26 | // need to place the oracletjetconfig.json at origDestRoot 27 | 28 | fs.stat(configPath, (err) => { 29 | const generatorVersion = _getOracleJetGeneratorVersion(generator); 30 | if (err) { 31 | generator.log(`${commonMessages.appendJETPrefix()}No config file. Writing the default config.`); 32 | fs.writeJSONSync(configPath, { generatorVersion }); 33 | } else { 34 | const configJson = fs.readJSONSync(configPath); 35 | configJson.generatorVersion = generatorVersion; 36 | fs.writeJSONSync(configPath, configJson); 37 | generator.log(`${commonMessages.appendJETPrefix() + ORACLE_JET_CONFIG_FILE} file exists. Checking config.`); 38 | } 39 | resolve(context); 40 | }); 41 | }); 42 | }, 43 | 44 | npmInstall: function _npmInstall(context) { 45 | return new Promise((resolve, reject) => { 46 | Promise.all([ 47 | common.gruntSpawnCommandPromise(context, 'npm', ['install'], 'Invoking npm install.') 48 | ]) 49 | .then(() => { 50 | // rejection will be handled by each promise which will 51 | // halt the generator 52 | resolve(context); 53 | }) 54 | .catch((err) => { 55 | reject(err); 56 | }); 57 | }); 58 | } 59 | }; 60 | 61 | /* 62 | * Gets the generator version 63 | */ 64 | function _getOracleJetGeneratorVersion() { 65 | // We intend to read the top level package.json for the generator-oraclejet module. 66 | // Note this path to package.json depends on the location of this file within the 67 | // module (common/restore.js) 68 | return generatorJSON.version; 69 | } 70 | 71 | -------------------------------------------------------------------------------- /common/template/blank.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | 10 | module.exports = 11 | { 12 | BLANK_TEMPLATE: 'blank', 13 | 14 | handle: function _handle(generator, destination, templateType) { 15 | let templatePath; 16 | 17 | if (templateType === 'web') { 18 | templatePath = '../../app/templates/'; 19 | } else { 20 | templatePath = '../../hybrid/templates/'; 21 | } 22 | 23 | templatePath += this.BLANK_TEMPLATE; 24 | const source = path.resolve(generator.sourceRoot(), templatePath); 25 | 26 | return new Promise((resolve, reject) => { 27 | try { 28 | fs.copySync(source, destination, { clobber: true }); 29 | resolve(generator); 30 | } catch (err) { 31 | return reject(err); 32 | } 33 | return resolve(); 34 | }); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /common/template/common.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const graphics = require('../../hybrid/graphics'); 10 | 11 | module.exports = 12 | { 13 | handle: function _handle(baseTemplateHandler) { 14 | return new Promise((resolve, reject) => { 15 | baseTemplateHandler 16 | .then((generator) => { 17 | const common = generator.templatePath('common'); 18 | const commonDest = generator.destinationPath(`${generator.appDir}/`); 19 | 20 | fs.copySync(common, commonDest, { filter(file) { 21 | return (file.indexOf(`${graphics.PATH + path.sep}screen`) === -1) && 22 | (file.indexOf(`${graphics.PATH + path.sep}icon`) === -1); 23 | } }); 24 | // copySync filter doesn't handle directories 25 | fs.removeSync(commonDest + graphics.PATH); 26 | 27 | resolve(generator); 28 | }) 29 | .catch((err) => { 30 | reject(err); 31 | }); 32 | }); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /common/template/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const blankTemplate = require('./blank'); 8 | const urlTemplate = require('./url'); 9 | const commonTemplate = require('./common'); 10 | const npmTemplate = require('./npm'); 11 | const localTemplate = require('./local'); 12 | const path = require('path'); 13 | const util = require('../../util'); 14 | 15 | const _HYBRID = 'hybrid'; 16 | const _WEB = 'web'; 17 | 18 | const BLANK_TEMPLATE = blankTemplate.BLANK_TEMPLATE; 19 | 20 | const _TEMPLATES_NPM_URL = '@oracle/oraclejet-templates@~6.2.0'; 21 | 22 | const _TEMPLATES = [BLANK_TEMPLATE, 'basic', 'navbar', 'navdrawer']; 23 | 24 | 25 | module.exports = 26 | { 27 | handleTemplate: function _handleTemplate(generator, templateDestDirectory) { 28 | const template = generator.options.template || BLANK_TEMPLATE; 29 | generator.log('Processing template:', template); 30 | const templateHandler = _getHandler(generator, template, templateDestDirectory); 31 | return commonTemplate.handle(templateHandler); 32 | } 33 | }; 34 | 35 | function _getHandler(generator, template, templateDestDirectory) { 36 | const templateUrl = _toTemplateUrl(template, generator.options.namespace); 37 | const templateLocalPath = _getLocalFileAbsolutePath(generator, template); 38 | 39 | if (templateUrl) { 40 | return urlTemplate.handle(generator, templateUrl, templateDestDirectory); 41 | } 42 | 43 | if (templateLocalPath) { 44 | return localTemplate.handle(generator, templateLocalPath, templateDestDirectory); 45 | } 46 | const templateSpec = _resolveTemplateSpec(generator, template); 47 | if (templateSpec.name === BLANK_TEMPLATE) { 48 | return blankTemplate.handle(generator, templateDestDirectory, templateSpec.type); 49 | } 50 | return npmTemplate.handle(generator, _TEMPLATES_NPM_URL, templateDestDirectory, templateSpec); 51 | } 52 | 53 | function _isUrl(url) { 54 | return /^https?:\/\/[^\s$.?#].[^\s]*$/i.test(url); 55 | } 56 | 57 | function _toTemplateUrl(template) { 58 | if (_isUrl(template)) { 59 | return template; 60 | } 61 | 62 | return null; 63 | } 64 | 65 | function _resolveTemplateSpec(generator, template) { 66 | const res = template.split(':'); 67 | 68 | const templateName = res[0]; 69 | const templateType = (res.length > 1) ? res[1] : _getGeneratorType(generator.options.namespace); 70 | 71 | _validateTemplateName(templateName); 72 | _validateTemplateType(templateType); 73 | 74 | return { name: templateName, type: templateType }; 75 | } 76 | 77 | function _validateTemplateName(templateName) { 78 | if (_TEMPLATES.indexOf(templateName) < 0) { 79 | let templateList = ''; 80 | _TEMPLATES.forEach((value) => { 81 | templateList += `\n ${value}`; 82 | }); 83 | const msg = `\nA URL or one of the following names is expected: ${templateList}`; 84 | throw new Error(`Invalid template name: ${templateName}. ${msg}`); 85 | } 86 | } 87 | 88 | function _getGeneratorType(generatorNameSpace) { 89 | return /hybrid/.test(generatorNameSpace) ? _HYBRID : _WEB; 90 | } 91 | 92 | function _validateTemplateType(templateType) { 93 | if (templateType !== _WEB && templateType !== _HYBRID) { 94 | throw new Error(`Invalid template type: ${templateType}`); 95 | } 96 | } 97 | 98 | function _getLocalFileAbsolutePath(generator, templatePath) { 99 | const tempPath = (templatePath[0] !== '~') ? templatePath 100 | : path.join(process.env.HOME, templatePath.slice(1)); 101 | const absolutePath = path.isAbsolute(tempPath) ? tempPath 102 | : path.resolve(process.cwd(), tempPath); 103 | return util.fsExistsSync(absolutePath) ? absolutePath : null; 104 | } 105 | -------------------------------------------------------------------------------- /common/template/local.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const Admzip = require('adm-zip'); 10 | 11 | module.exports = { 12 | 13 | handle: function _handle(yoGenerator, templatePath, destination) { 14 | return new Promise((resolve, reject) => { 15 | _copyLocalTemplate(yoGenerator, templatePath, destination) 16 | .then(() => { 17 | resolve(yoGenerator); 18 | }) 19 | .catch((err) => { 20 | reject(err); 21 | }); 22 | }); 23 | } 24 | }; 25 | 26 | function _copyLocalTemplate(yoGenerator, templatePath, destination) { 27 | return new Promise((resolve, reject) => { 28 | try { 29 | if (fs.statSync(templatePath).isDirectory()) { 30 | fs.copySync(templatePath, destination); 31 | } else if (path.extname(templatePath) === '.zip') { 32 | const zip = new Admzip(templatePath); 33 | zip.extractAllTo(destination, true); 34 | } else { 35 | throw new Error(`template path ${templatePath} is not valid`); 36 | } 37 | resolve(); 38 | } catch (err) { 39 | reject(err); 40 | } 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /common/template/npm.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const exec = require('child_process').exec; 10 | 11 | module.exports = { 12 | 13 | handle: function _handle(yoGenerator, npmUrl, destination, templateSpec) { 14 | return new Promise((resolve, reject) => { 15 | _installNpmTemplate(yoGenerator, npmUrl) 16 | .then(() => { 17 | _copyNpmTemplate(yoGenerator, templateSpec, destination); 18 | return resolve(yoGenerator); 19 | }) 20 | .catch(err => reject(err)); 21 | }); 22 | } 23 | }; 24 | 25 | /** 26 | * ## _copyNpmTemplate 27 | * Copies template files. 28 | * 29 | * The templates are found in the installed oraclejet-templates module. 30 | * The source template directory is determined as follows: 31 | * 1. check if the templateName/type directory exists in oraclejet-templates 32 | * e.g. 'navbar/hybrid'. 33 | * 2. if not, use the content of the templateName directory (only common content 34 | * exists for both 'web' and 'hybrid' templates). 35 | * 36 | * @param {Object} yoGenerator - parent generator 37 | * @param {Object} templateSpec - template specification 38 | * @param {string} destination - destination path 39 | */ 40 | function _copyNpmTemplate(yoGenerator, templateSpec, destination) { 41 | const templateRoot = path.join(yoGenerator.destinationPath(yoGenerator.appDir), 42 | 'node_modules', '@oracle/oraclejet-templates'); 43 | const src = _getTemplateFromTypeSpecificDirectory(templateRoot, templateSpec) || 44 | _getTemplateFromGenericDirectory(templateRoot, templateSpec); 45 | 46 | if (!src) { 47 | const msg = `${templateSpec.name}:${templateSpec.type}`; 48 | throw new Error(`Could not find source for template: ${msg}`); 49 | } 50 | 51 | fs.copySync(src, destination); 52 | } 53 | 54 | function _getTemplateFromTypeSpecificDirectory(templateRoot, templateSpec) { 55 | const src = path.join(templateRoot, templateSpec.name, templateSpec.type); 56 | if (!_checkDirExists(src)) { 57 | return null; 58 | } 59 | return src; 60 | } 61 | 62 | function _getTemplateFromGenericDirectory(templateRoot, templateSpec) { 63 | const src = path.join(templateRoot, templateSpec.name); 64 | if (!_checkDirExists(src)) { 65 | return null; 66 | } 67 | return src; 68 | } 69 | 70 | function _checkDirExists(filePath) { 71 | try { 72 | // check if the directory exists 73 | const stats = fs.statSync(filePath); 74 | if (stats.isDirectory()) { 75 | return true; 76 | } 77 | } catch (err) { 78 | return false; 79 | } 80 | return false; 81 | } 82 | 83 | function _installNpmTemplate(yoGenerator, npmUrl) { 84 | return new Promise((resolve, reject) => { 85 | const cmd = `npm install ${npmUrl}`; 86 | const appDir = yoGenerator.destinationPath(yoGenerator.appDir); 87 | fs.ensureDirSync(path.join(appDir, 'node_modules')); 88 | exec(cmd, { cwd: appDir }, (err) => { 89 | if (err) return reject(err); 90 | return resolve(); 91 | }); 92 | }); 93 | } 94 | -------------------------------------------------------------------------------- /common/template/url.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const fetchZip = require('../../util/fetchZip'); 9 | 10 | module.exports = { 11 | 12 | handle: function _handle(generator, template, destination) { 13 | const temp = generator.destinationPath(`${generator.appDir}/temp`); 14 | 15 | return new Promise((resolve, reject) => { 16 | fetchZip(template) 17 | .then((values) => { 18 | _processFetchedTemplateZip(values, temp, destination); 19 | return resolve(generator); 20 | }) 21 | .catch(err => reject(err)); 22 | }); 23 | } 24 | }; 25 | 26 | function _processFetchedTemplateZip(values, temp, destination) { 27 | fs.mkdirsSync(temp); 28 | values.extractAllTo(temp); 29 | fs.copySync(temp, destination); 30 | fs.removeSync(temp); 31 | } 32 | -------------------------------------------------------------------------------- /common/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const CONSTANTS = require('../util/constants'); 10 | const paths = require('../util/paths'); 11 | 12 | module.exports = 13 | { 14 | writeTestTemplate: function _writeTestTemplates(generator) { 15 | return new Promise((resolve) => { 16 | if (generator.options.component) { 17 | const isApp = fs.existsSync(path.join(process.cwd(), CONSTANTS.APP_CONFIG_JSON)) 18 | || generator.appDir !== undefined; 19 | 20 | if (!isApp) return resolve(generator); 21 | 22 | const appDir = generator.appDir === undefined 23 | ? process.cwd() : generator.destinationPath(generator.appDir); 24 | 25 | const _configPaths = generator.appDir === undefined 26 | ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); 27 | 28 | const templateSrc = path.join(generator.templatePath(), '../../../template/test'); 29 | const destDirectory = generator.destinationPath( 30 | path.join(appDir, _configPaths.source, _configPaths.sourceTests)); 31 | 32 | // avoid overwrite test 33 | if (fs.existsSync(destDirectory)) { 34 | resolve(generator); 35 | } else { 36 | fs.ensureDirSync(destDirectory); 37 | fs.copySync(templateSrc, destDirectory); 38 | _replaceTestHTMLToken(generator); 39 | } 40 | } 41 | return resolve(generator); 42 | }); 43 | }, 44 | }; 45 | 46 | function _replaceTestHTMLToken(generator) { 47 | const componentName = generator.componentName || generator.options.component; 48 | 49 | const appDir = generator.appDir === undefined 50 | ? process.cwd() : generator.destinationPath(generator.appDir); 51 | 52 | const _configPaths = generator.appDir === undefined 53 | ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); 54 | 55 | const htmlPath = path.join(appDir, _configPaths.source, _configPaths.sourceTests, 'index.html'); 56 | const html = fs.readFileSync(htmlPath, 'utf-8'); 57 | fs.outputFileSync(htmlPath, html.replace(new RegExp('@component@', 'g'), componentName)); 58 | } 59 | -------------------------------------------------------------------------------- /generators/add-component/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const common = require('../../common'); 9 | const commonComponent = require('../../common/component'); 10 | const commonHookRunner = require('../../common/hookRunner'); 11 | const commonMessages = require('../../common/messages'); 12 | const commonTest = require('../../common/test'); 13 | const fs2 = require('fs'); 14 | const path = require('path'); 15 | /* 16 | * Generator for the add-component step 17 | */ 18 | const OracleJetAddComponentGenerator = generators.Base.extend( 19 | { 20 | initializing: function () { //eslint-disable-line 21 | const done = this.async(); 22 | common.validateArgs(this) 23 | .then(common.validateFlags) 24 | .then(() => { 25 | done(); 26 | }) 27 | .catch((err) => { 28 | this.env.error(commonMessages.prefixError(err)); 29 | }); 30 | }, 31 | 32 | constructor: function() { //eslint-disable-line 33 | generators.Base.apply(this, arguments); //eslint-disable-line 34 | try { 35 | this.argument('componentName', { type: String, required: true }); 36 | } catch (err) { 37 | this.env.error('Missing component name.'); 38 | } 39 | _validateComponentName(this); 40 | }, 41 | 42 | writing: function() { //eslint-disable-line 43 | const done = this.async(); 44 | this.options.component = this.componentName; 45 | commonComponent.writeComponentTemplate(this) 46 | .then(commonTest.writeTestTemplate) 47 | .then(commonHookRunner.runAfterComponentCreateHook) 48 | .then(() => { 49 | done(); 50 | }) 51 | .catch((err) => { 52 | if (err) { 53 | this.env.error(commonMessages.prefixError(err)); 54 | } 55 | }); 56 | }, 57 | 58 | end: function() { //eslint-disable-line 59 | const cwd = process.cwd(); 60 | const isApp = fs2.existsSync(path.join(cwd, 'oraclejetconfig.json')); 61 | if (!isApp) { 62 | this.composeWith('@oracle/oraclejet:app', { options: this.options }); 63 | } else { 64 | console.log(commonMessages.appendJETPrefix(`Add component ${this.componentName} finished.`)); 65 | } 66 | if (isApp) process.exit(0); 67 | } 68 | 69 | }); 70 | 71 | module.exports = OracleJetAddComponentGenerator; 72 | 73 | function _validateComponentName(generator) { 74 | const name = generator.componentName; 75 | if (name !== name.toLowerCase() || name.indexOf('-') < 0 || !/^[a-z]/.test(name)) { 76 | const message = 'Invalid component name. Must be all lowercase letters and contain at least one hyphen.'; 77 | generator.env.error(`\x1b[31m${new Error(message)}\x1b[0m`); //eslint-disable-line 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /generators/add-hybrid/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const childProcess = require('child_process'); 8 | const generators = require('yeoman-generator'); 9 | const fs = require('fs-extra'); 10 | const path = require('path'); 11 | const common = require('../../common'); 12 | const paths = require('../../util/paths'); 13 | const commonMessages = require('../../common/messages'); 14 | const commonHybrid = require('../../hybrid'); 15 | const cordovaHelper = require('../../hybrid/cordova'); 16 | const platformsHelper = require('../../hybrid/platforms'); 17 | 18 | const _configPaths = {}; 19 | 20 | /* 21 | * Generator for the add-hybrid step 22 | */ 23 | const OracleJetAddHybridGenerator = generators.Base.extend( 24 | { 25 | constructor: function() { //eslint-disable-line 26 | generators.Base.apply(this, arguments); //eslint-disable-line 27 | 28 | this.option('platforms', { 29 | desc: 'Specify the platforms to be supported by the scaffolded hybrid app [android, ios, windows]', 30 | }); 31 | this.option('platform', { 32 | desc: 'Alias for --platforms if the user wishes to specify a single hybrid platform [android, ios, windows]' 33 | }); 34 | this.option('appid', { 35 | desc: 'Specify the app ID for scaffolded hybrid app' 36 | }); 37 | // Deprecated version 38 | this.option('appId', { desc: 'Deprecated. Use --appid instead.' }); 39 | this.option('appname', { 40 | desc: 'Specify the app name for scaffolded hybrid app' 41 | }); 42 | // Deprecated version 43 | this.option('appName', { desc: 'Deprecated. Use --appname instead.' }); 44 | }, 45 | 46 | initializing: function () { //eslint-disable-line 47 | const done = this.async(); 48 | _setConfigPaths(paths.getConfiguredPaths(this.destinationPath())); 49 | common.validateArgs(this) 50 | .then(_checkIfCordovaIsInstalled) 51 | .then(common.validateFlags) 52 | .then(_validateAppDirForAddHybrid) 53 | .then(() => { 54 | this.appDir = path.basename(this.destinationRoot()); 55 | commonHybrid.setupHybridEnv(this); 56 | done(); 57 | }) 58 | .catch((err) => { 59 | this.env.error(commonMessages.prefixError(err)); 60 | }); 61 | }, 62 | 63 | prompting: function () { //eslint-disable-line 64 | const done = this.async(); 65 | 66 | platformsHelper.getPlatforms(this) 67 | .then(() => { 68 | done(); 69 | }); 70 | }, 71 | 72 | writing: function() { //eslint-disable-line 73 | const done = this.async(); 74 | 75 | _createExtraSrcDirs(this) 76 | .then(cordovaHelper.create.bind(this)) 77 | .then(commonHybrid.copyHooks.bind(this)) 78 | .then(commonHybrid.copyResources.bind(this)) 79 | .then(_copyCordovaMocks.bind(this)) 80 | .then(commonHybrid.removeExtraCordovaFiles.bind(this)) 81 | .then(platformsHelper.addPlatforms.bind(this)) 82 | .then(commonHybrid.updateConfigXml.bind(this)) 83 | .then(() => { 84 | done(); 85 | }) 86 | .catch((err) => { 87 | if (err) { 88 | this.env.error(commonMessages.prefixError(err)); 89 | } 90 | }); 91 | }, 92 | 93 | end: function() { //eslint-disable-line 94 | this.log(commonMessages.appendJETPrefix('Add-hybrid finished.')); 95 | } 96 | 97 | }); 98 | 99 | function _checkIfCordovaIsInstalled(generator) { 100 | return new Promise((resolve, reject) => { 101 | childProcess.exec('cordova', (error) => { 102 | if (error) { 103 | reject('Cordova not installed. Please install by: "npm install -g cordova"'); 104 | } else { 105 | resolve(generator); 106 | } 107 | }); 108 | }); 109 | } 110 | 111 | function _setConfigPaths(configPathObj) { 112 | Object.keys(configPathObj).forEach((key) => { 113 | _configPaths[key] = configPathObj[key]; 114 | }); 115 | } 116 | 117 | function _validateAppDirForAddHybrid(generator) { 118 | return _validateSrcDirExists(generator) 119 | .then(_validateHybridDirDoesNotExist.bind(generator)); 120 | } 121 | 122 | 123 | function _createExtraSrcDirs(generator) { 124 | let srcHybridPath = _configPaths.sourceHybrid; 125 | let srcWebPath = _configPaths.sourceWeb; 126 | srcWebPath = generator.destinationPath(srcWebPath); 127 | srcHybridPath = generator.destinationPath(srcHybridPath); 128 | fs.ensureDirSync(srcHybridPath); 129 | fs.ensureDirSync(srcWebPath); 130 | 131 | return Promise.resolve(generator); 132 | } 133 | 134 | function _validateSrcDirExists(generator) { 135 | let errorMsg; 136 | const appSrcPath = _configPaths.source; 137 | try { 138 | fs.statSync(generator.destinationPath(appSrcPath)); 139 | return Promise.resolve(generator); 140 | } catch (err) { 141 | errorMsg = `Missing '${appSrcPath}' directory. ` 142 | + 'Invalid JET project structure.'; 143 | return Promise.reject(commonMessages.error(errorMsg, 'validateSrcDirExists')); 144 | } 145 | } 146 | 147 | function _validateHybridDirDoesNotExist(generator) { 148 | let stats; 149 | let errorMsg; 150 | 151 | try { 152 | const hybridPath = _configPaths.stagingHybrid; 153 | stats = fs.statSync(generator.destinationPath(hybridPath)); 154 | if (stats.isDirectory) { 155 | errorMsg = `The project already contains the '${hybridPath 156 | }' directory.`; 157 | return Promise.reject(commonMessages.error(errorMsg, 'validateHybridDirDoesNotExist')); 158 | } 159 | } catch (err) { 160 | // hybrid dir does not exist, OK to proceed 161 | } 162 | return Promise.resolve(generator); 163 | } 164 | 165 | function _copyCordovaMocks(generator) { 166 | const source = generator.templatePath('../../hybrid/templates/common/src/js/'); 167 | const srcHybridPath = _configPaths.sourceHybrid; 168 | const srcJsPath = _configPaths.sourceJavascript; 169 | const dest = generator.destinationPath(`./${srcHybridPath}/${srcJsPath}/`); 170 | 171 | return new Promise((resolve, reject) => { 172 | if (common.fsExistsSync(source)) { 173 | fs.copy(source, dest, (err) => { 174 | if (err) { 175 | reject(err); 176 | return; 177 | } 178 | resolve(generator); 179 | }); 180 | } else { 181 | reject('Missing file \'cordovaMocks.js\'.'); 182 | } 183 | }); 184 | } 185 | 186 | module.exports = OracleJetAddHybridGenerator; 187 | -------------------------------------------------------------------------------- /generators/add-sass/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const common = require('../../common'); 9 | const commonMessages = require('../../common/messages'); 10 | 11 | /* 12 | * Generator for the add-sass step 13 | */ 14 | const OracleJetAddSassGenerator = generators.Base.extend( 15 | { 16 | initializing: function () { //eslint-disable-line 17 | const done = this.async(); 18 | common.validateArgs(this) 19 | .then(common.validateFlags) 20 | .then(() => { 21 | done(); 22 | }) 23 | .catch((err) => { 24 | this.env.error(commonMessages.prefixError(err)); 25 | }); 26 | }, 27 | 28 | constructor: function() { //eslint-disable-line 29 | generators.Base.apply(this, arguments); //eslint-disable-line 30 | }, 31 | 32 | writing: function() { //eslint-disable-line 33 | const done = this.async(); 34 | 35 | _npmInstallNodeSass(this) 36 | .then(() => { 37 | done(); 38 | }) 39 | .catch((err) => { 40 | if (err) { 41 | this.env.error(commonMessages.prefixError(err)); 42 | } 43 | }); 44 | }, 45 | 46 | end: function() { //eslint-disable-line 47 | console.log(commonMessages.appendJETPrefix('add-sass finished.')); 48 | process.exit(0); 49 | } 50 | 51 | }); 52 | 53 | module.exports = OracleJetAddSassGenerator; 54 | 55 | 56 | function _npmInstallNodeSass(generator) { 57 | try { 58 | generator.npmInstall(['node-sass@4.7.2'], { saveDev: true }); 59 | return Promise.resolve(generator); 60 | } catch (err) { 61 | return Promise.reject(commonMessages.error(err, 'install node-sass')); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /generators/add-theme/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const fs = require('fs-extra'); 9 | const path = require('path'); 10 | const constants = require('../../util/constants'); 11 | const common = require('../../common'); 12 | const paths = require('../../util/paths'); 13 | const commonMessages = require('../../common/messages'); 14 | 15 | const DEFAULT_THEME = 'mytheme'; 16 | const JET_SCSS_SRC_PATH = 'node_modules/@oracle/oraclejet/dist/scss'; 17 | const PLATFORM_TOKEN = '<%= platform %>'; 18 | const JET_VERSION_TOKEN = '<%= jetversion %>'; 19 | const THEMENAME_TOKEN = '<%= themename %>'; 20 | /* 21 | * Generator for the add-theme step 22 | */ 23 | const OracleJetAddThemeGenerator = generators.Base.extend( 24 | { 25 | initializing: function () { //eslint-disable-line 26 | const done = this.async(); 27 | common.validateArgs(this) 28 | .then(common.validateFlags) 29 | .then(() => { 30 | done(); 31 | }) 32 | .catch((err) => { 33 | this.env.error(commonMessages.prefixError(err)); 34 | }); 35 | }, 36 | constructor: function () { //eslint-disable-line 37 | generators.Base.apply(this, arguments);//eslint-disable-line 38 | try { 39 | this.argument('themeName', { type: String, required: true }); 40 | } catch (err) { 41 | this.env.error(commonMessages.prefixError(err)); 42 | } 43 | if (this.themeName === constants.DEFAULT_THEME) { 44 | this.env.error(commonMessages.prefixError(`Theme ${constants.DEFAULT_THEME} is reserved.`)); 45 | } 46 | 47 | if (!_isValidThemeName(this.themeName)) { 48 | this.env.error(commonMessages.prefixError(`Special characters invalid in theme name ${this.themeName}.`)); 49 | } 50 | }, 51 | 52 | writing: function () { //eslint-disable-line 53 | const done = this.async(); 54 | _addSassTheme(this) 55 | .then(() => { 56 | done(); 57 | }) 58 | .catch((err) => { 59 | if (err) { 60 | this.env.error(commonMessages.prefixError(err)); 61 | } 62 | }); 63 | }, 64 | 65 | end: function () { //eslint-disable-line 66 | this.log(commonMessages.appendJETPrefix(`${this.themeName} theme added.`)); 67 | process.exit(0); 68 | } 69 | 70 | }); 71 | 72 | module.exports = OracleJetAddThemeGenerator; 73 | 74 | function _addSassTheme(generator) { 75 | const themeName = generator.themeName; 76 | const _configPaths = paths.getConfiguredPaths(generator.destinationPath()); 77 | const srcPath = _configPaths.source; 78 | const srcThemes = _configPaths.sourceThemes; 79 | const themeDestPath = path.resolve(srcPath, srcThemes, themeName); 80 | fs.ensureDirSync(themeDestPath); 81 | 82 | const source = generator.templatePath(DEFAULT_THEME); 83 | 84 | return new Promise((resolve, reject) => { 85 | try { 86 | // first copy over templates 87 | fs.copySync(source, themeDestPath); 88 | _copySettingsFilesFromJETSrc(themeName, themeDestPath, generator); 89 | _renameFilesAllPlatforms(themeName, themeDestPath, generator); 90 | return resolve(generator); 91 | } catch (err) { 92 | return reject(commonMessages.error(err, 'add-theme')); 93 | } 94 | }); 95 | } 96 | 97 | function _renameFilesAllPlatforms(themeName, dest, generator) { 98 | const platforms = _getAllSupportedPlatforms(); 99 | 100 | platforms.forEach((platform) => { 101 | _renameFileOnePlatform(themeName, dest, platform, generator); 102 | }); 103 | } 104 | 105 | function _getAllSupportedPlatforms() { 106 | return constants.SUPPORTED_PLATFORMS; 107 | } 108 | 109 | function _renameFileOnePlatform(themeName, dest, platform, generator) { 110 | const fileDir = path.join(dest, platform); 111 | const fileList = fs.readdirSync(fileDir); 112 | const scssFiles = fileList.filter(_isScssFile); 113 | 114 | scssFiles.forEach((file) => { 115 | const newPath = _renameFile(themeName, fileDir, file); 116 | _replaceTokens(newPath, generator, themeName, platform); 117 | }); 118 | } 119 | 120 | // replace mytheme.css to the actual themeName.css 121 | function _renameFile(themeName, fileDir, file) { 122 | const oldPath = path.join(fileDir, file); 123 | let newPath = file.replace(DEFAULT_THEME, themeName); 124 | newPath = path.join(fileDir, newPath); 125 | fs.renameSync(oldPath, newPath); 126 | return newPath; 127 | } 128 | 129 | function _isScssFile(file) { 130 | return /scss/.test(path.extname(file)); 131 | } 132 | 133 | function _isValidThemeName(string) { 134 | return !(/[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]/.test(string)); //eslint-disable-line 135 | } 136 | 137 | function _getJetVersion(generator) { 138 | let packageJSON = generator.destinationPath('node_modules/@oracle/oraclejet/package.json'); 139 | packageJSON = fs.readJsonSync(packageJSON); 140 | return packageJSON.version; 141 | } 142 | 143 | // default marker <%= jetversion %> <%= themename %> <%= platform %> 144 | // are used to inject jet version and themename 145 | function _replaceTokens(filePath, generator, themeName, platform) { 146 | let fileContent = fs.readFileSync(filePath, 'utf-8'); 147 | const jetVersion = _getJetVersion(generator); 148 | fileContent = fileContent.replace(new RegExp(JET_VERSION_TOKEN, 'g'), jetVersion); 149 | fileContent = fileContent.replace(new RegExp(THEMENAME_TOKEN, 'g'), themeName); 150 | fileContent = fileContent.replace(new RegExp(PLATFORM_TOKEN, 'g'), platform); 151 | fs.outputFileSync(filePath, fileContent); 152 | } 153 | 154 | function _copySettingsFilesFromJETSrc(themeName, dest) { 155 | const settingsFileName = `_oj.alta.${PLATFORM_TOKEN}settings.scss`; 156 | 157 | constants.SUPPORTED_PLATFORMS.forEach((platform) => { 158 | const platformPath = _getPlatformPath(platform); 159 | const srcSettingFileName = _getSrcSettingFileName(platform); 160 | const srcPath = path.join(JET_SCSS_SRC_PATH, platformPath, srcSettingFileName); 161 | 162 | const destSettingFileName = _getDestSettingFileName(DEFAULT_THEME, platform); 163 | const destPath = path.join(dest, platform, destSettingFileName); 164 | 165 | fs.copySync(srcPath, destPath); 166 | _injectDefaultValues(destPath); 167 | }); 168 | 169 | function _getDestSettingFileName(name, platform) { 170 | return `_${name}.${platform}.settings.scss`; 171 | } 172 | 173 | function _getSrcSettingFileName(platform) { 174 | const platformName = (platform === 'web') ? '' : `${platform}.`; 175 | return settingsFileName.replace(PLATFORM_TOKEN, platformName); 176 | } 177 | 178 | function _getPlatformPath(platform) { 179 | return (platform === 'web') ? 'alta' : `alta-${platform}`; 180 | } 181 | 182 | function _injectDefaultValues(filePath) { 183 | let fileContent = fs.readFileSync(filePath, 'utf-8'); 184 | const valuePairs = _getValuePairsArray(); 185 | valuePairs.forEach((valuePair) => { 186 | fileContent = fileContent.replace(valuePair.str, valuePair.newStr); 187 | }); 188 | fs.outputFileSync(filePath, fileContent); 189 | } 190 | 191 | function _getValuePairsArray() { 192 | return [ 193 | { 194 | str: new RegExp('@import\ \"\.\.\/utilities', 'g'), //eslint-disable-line 195 | newStr: '@import "../../../../node_modules/@oracle/oraclejet/dist/scss/utilities', 196 | }, 197 | { 198 | str: new RegExp('.*\\$themeName.*'), 199 | newStr: `$themeName: ${THEMENAME_TOKEN} !default;`, 200 | }, 201 | { 202 | str: new RegExp('.*\\$imageDir.*'), 203 | newStr: `$imageDir: "../../../alta/${JET_VERSION_TOKEN}/${PLATFORM_TOKEN}/images/" !default;`, 204 | }, 205 | { 206 | str: new RegExp('.*\\$fontDir.*'), 207 | newStr: `$fontDir: "../../../alta/${JET_VERSION_TOKEN}/${PLATFORM_TOKEN}/fonts/" !default;`, 208 | }, 209 | { 210 | str: new RegExp('.*\\$commonImageDir.*'), 211 | newStr: `$commonImageDir: "../../../alta/${JET_VERSION_TOKEN}/common/images/" !default;`, 212 | }, 213 | ]; 214 | } 215 | } 216 | 217 | -------------------------------------------------------------------------------- /generators/add-theme/templates/mytheme/android/mytheme.scss: -------------------------------------------------------------------------------- 1 | 2 | // Note that the order in the aggregating file is important 3 | // 4 | // 1. custom variables file: Due to the way sass default works, 5 | // the custom variable file must be imported before the platform theme 6 | // aggregating file (where the platform variable file will be imported). 7 | // 2. platform theme aggregating file 8 | 9 | //import custom variable overrides 10 | @import "<%= themename %>.android.settings"; 11 | 12 | // import alta-android aggregating file 13 | @import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta-android/oj-alta"; 14 | -------------------------------------------------------------------------------- /generators/add-theme/templates/mytheme/ios/mytheme.scss: -------------------------------------------------------------------------------- 1 | 2 | // Note that the order in the aggregating file is important 3 | // 4 | // 1. custom variables file: Due to the way sass default works, 5 | // the custom variable file must be imported before the platform theme 6 | // aggregating file (where the platform variable file will be imported). 7 | // 2. platform theme aggregating file 8 | 9 | //import custom variable overrides 10 | @import "<%= themename %>.ios.settings"; 11 | 12 | // import alta-ios aggregating file 13 | @import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta-ios/oj-alta"; 14 | -------------------------------------------------------------------------------- /generators/add-theme/templates/mytheme/theme.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1" 3 | } -------------------------------------------------------------------------------- /generators/add-theme/templates/mytheme/web/mytheme.scss: -------------------------------------------------------------------------------- 1 | 2 | // Note that the order in the aggregating file is important 3 | // 4 | // 1. custom variables file: Due to the way sass default works, 5 | // the custom variable file must be imported before the platform theme 6 | // aggregating file (where the platform variable file will be imported). 7 | // 2. platform theme aggregating file 8 | 9 | //import custom variable overrides 10 | @import "<%= themename %>.web.settings"; 11 | 12 | // import alta aggregating file 13 | @import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta/oj-alta"; 14 | -------------------------------------------------------------------------------- /generators/add-theme/templates/mytheme/windows/mytheme.scss: -------------------------------------------------------------------------------- 1 | 2 | // Note that the order in the aggregating file is important 3 | // 4 | // 1. custom variables file: Due to the way sass default works, 5 | // the custom variable file must be imported before the platform theme 6 | // aggregating file (where the platform variable file will be imported). 7 | // 2. platform theme aggregating file 8 | 9 | //import custom variable overrides 10 | @import "<%= themename %>.windows.settings"; 11 | 12 | // import alta-windows aggregating file 13 | @import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta-windows/oj-alta"; 14 | -------------------------------------------------------------------------------- /generators/app/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const common = require('../../common'); 9 | const commonComponent = require('../../common/component'); 10 | const commonMessages = require('../../common/messages'); 11 | const commonTest = require('../../common/test'); 12 | const templateHandler = require('../../common/template'); 13 | const path = require('path'); 14 | 15 | /* 16 | * Generator for the create step 17 | * Mainly to: 18 | * 1) copy the template in 19 | */ 20 | const OracleJetWebCreateGenerator = generators.Base.extend( 21 | { 22 | initializing: function () { //eslint-disable-line 23 | const done = this.async(); 24 | if (this.options.component) { 25 | this.appDir = this.options.component; 26 | } 27 | common.validateArgs(this) 28 | .then(common.validateFlags) 29 | .then(common.validateAppDirNotExistsOrIsEmpty) 30 | .then((validAppDir) => { 31 | this.appDir = path.basename(validAppDir); 32 | this.options.appname = this.appDir; 33 | return Promise.resolve(this); 34 | }) 35 | .then(() => { 36 | done(); 37 | }) 38 | .catch((err) => { 39 | console.error(`\x1b[31mError: ${commonMessages.prefixError(err)}\x1b[0m`); 40 | process.exit(1); 41 | }); 42 | }, 43 | 44 | constructor: function () { //eslint-disable-line 45 | generators.Base.apply(this, arguments); //eslint-disable-line 46 | 47 | this.argument( 48 | 'appDir', 49 | { 50 | type: String, 51 | required: false, 52 | optional: true, 53 | defaults: '.', 54 | desc: 'Application directory to contain the scaffold content' 55 | }); 56 | 57 | this.option('template', { 58 | desc: 'blank, basic[:web|:hybrid], navbar[:web|:hybrid], navdrawer[:web|:hybrid], or ' 59 | }); 60 | }, 61 | 62 | writing: function () { //eslint-disable-line 63 | const done = this.async(); 64 | const self = this; 65 | 66 | _writeTemplate(self) 67 | .then(common.switchToAppDirectory.bind(this)) 68 | .then(common.writeCommonTemplates) 69 | .then(common.writeGitIgnore) 70 | .then(common.updatePackageJSON) 71 | .then(() => { 72 | done(); 73 | }) 74 | .catch((err) => { 75 | if (err) { 76 | self.log.error(err); 77 | process.exit(1); 78 | } 79 | }); 80 | }, 81 | 82 | end: function () { //eslint-disable-line 83 | if (this.options.component) { 84 | this.log(`Your component ${this.options.component} project is scaffolded. Performing npm install may take a bit.`); 85 | } else { 86 | this.log(commonMessages.scaffoldComplete()); 87 | } 88 | 89 | if (!this.options.norestore) { 90 | this.composeWith('@oracle/oraclejet:restore-web', { options: this.options }); 91 | } 92 | } 93 | }); 94 | 95 | module.exports = OracleJetWebCreateGenerator; 96 | 97 | function _writeTemplate(generator) { 98 | return new Promise((resolve, reject) => { 99 | const appDirectory = generator.destinationPath(path.join(generator.appDir, 'src')); 100 | 101 | templateHandler.handleTemplate(generator, appDirectory) 102 | .then(commonComponent.writeComponentTemplate) 103 | .then(commonTest.writeTestTemplate) 104 | .then(() => { 105 | resolve(generator); 106 | }) 107 | .catch((err) => { 108 | reject(err); 109 | }); 110 | }); 111 | } 112 | 113 | -------------------------------------------------------------------------------- /generators/app/templates/blank/index.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 24 | 25 | 26 | Oracle JET Starter Template - Web Blank 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /generators/app/templates/blank/js/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | /** 8 | * Example of Require.js boostrap javascript 9 | */ 10 | /* eslint-disable quote-props */ 11 | 12 | requirejs.config( 13 | { 14 | baseUrl: 'js', 15 | 16 | // Path mappings for the logical module names 17 | // Update the main-release-paths.json for release mode when updating the mappings 18 | paths: 19 | //injector:mainReleasePaths 20 | { 21 | 'knockout': 'libs/knockout/knockout-3.4.2.debug', 22 | 'jquery': 'libs/jquery/jquery-3.3.1', 23 | 'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.1', 24 | 'promise': 'libs/es6-promise/es6-promise', 25 | 'hammerjs': 'libs/hammer/hammer-2.0.8', 26 | 'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0', 27 | 'ojs': 'libs/oj/v6.2.0/debug', 28 | 'ojL10n': 'libs/oj/v6.2.0/ojL10n', 29 | 'ojtranslations': 'libs/oj/v6.2.0/resources', 30 | 'text': 'libs/require/text', 31 | 'signals': 'libs/js-signals/signals', 32 | 'customElements': 'libs/webcomponents/custom-elements.min', 33 | 'proj4': 'libs/proj4js/dist/proj4-src', 34 | 'css': 'libs/require-css/css', 35 | 'touchr': 'libs/touchr/touchr', 36 | 'persist': 'libs/persist/min' 37 | } 38 | //endinjector 39 | , 40 | 41 | // Shim configurations for modules that do not expose AMD 42 | shim: 43 | { 44 | 'jquery': 45 | { 46 | exports: ['jQuery', '$'] 47 | } 48 | } 49 | } 50 | ); 51 | 52 | require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout'], 53 | function (oj, ko, $) { 54 | $(function () { 55 | function init() { 56 | } 57 | 58 | // If running in a hybrid (e.g. Cordova) environment, we need to wait for the deviceready 59 | // event before executing any code that might interact with Cordova APIs or plugins. 60 | if ($(document.body).hasClass('oj-hybrid')) { 61 | document.addEventListener('deviceready', init); 62 | } else { 63 | init(); 64 | } 65 | }); 66 | } 67 | ); 68 | -------------------------------------------------------------------------------- /generators/app/templates/blank/js/path_mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "js", 3 | "use": "local", 4 | 5 | "cdns": { 6 | "jet": "https://static.oracle.com/cdn/jet/v6.2.0/default/js", 7 | "3rdparty": "https://static.oracle.com/cdn/jet/v6.2.0/3rdparty" 8 | }, 9 | 10 | "libs": { 11 | 12 | "knockout": { 13 | "cdn": "3rdparty", 14 | "cwd": "node_modules/knockout/build/output", 15 | "debug": { 16 | "src": "knockout-latest.debug.js", 17 | "path": "libs/knockout/knockout-#{version}.debug.js", 18 | "cdnPath": "knockout/knockout-3.4.2.debug" 19 | }, 20 | "release": { 21 | "src": "knockout-latest.js", 22 | "path": "libs/knockout/knockout-#{version}.js", 23 | "cdnPath": "knockout/knockout-3.4.2" 24 | } 25 | }, 26 | 27 | "jquery": { 28 | "cdn": "3rdparty", 29 | "cwd": "node_modules/jquery/dist", 30 | "debug": { 31 | "src": "jquery.js", 32 | "path": "libs/jquery/jquery-#{version}.js", 33 | "cdnPath": "jquery/jquery-3.3.1" 34 | }, 35 | "release": { 36 | "src": "jquery.min.js", 37 | "path": "libs/jquery/jquery-#{version}.min.js", 38 | "cdnPath": "jquery/jquery-3.3.1.min" 39 | } 40 | }, 41 | 42 | "jqueryui-amd": { 43 | "cdn": "3rdparty", 44 | "cwd": "node_modules/jquery-ui/ui", 45 | "debug": { 46 | "src": ["*.js", "widgets/draggable.js", "widgets/mouse.js", "widgets/sortable.js"], 47 | "path": "libs/jquery/jqueryui-amd-#{version}", 48 | "cdnPath": "jquery/jqueryui-amd-1.12.1" 49 | }, 50 | "release": { 51 | "src": ["*.js", "widgets/draggable.js", "widgets/mouse.js", "widgets/sortable.js"], 52 | "path": "libs/jquery/jqueryui-amd-#{version}.min", 53 | "cdnPath": "jquery/jqueryui-amd-1.12.1.min" 54 | } 55 | }, 56 | 57 | "promise": { 58 | "cdn": "3rdparty", 59 | "cwd": "node_modules/es6-promise/dist", 60 | "debug": { 61 | "src": ["es6-promise.js", "es6-promise.map"], 62 | "path": "libs/es6-promise/es6-promise.js", 63 | "cdnPath": "es6-promise/es6-promise" 64 | }, 65 | "release": { 66 | "src": ["es6-promise.min.js", "es6-promise.min.map"], 67 | "path": "libs/es6-promise/es6-promise.min.js", 68 | "cdnPath": "es6-promise/es6-promise.min" 69 | } 70 | }, 71 | 72 | "hammerjs": { 73 | "cdn": "3rdparty", 74 | "cwd": "node_modules/hammerjs", 75 | "debug": { 76 | "src": "hammer.js", 77 | "path": "libs/hammer/hammer-#{version}.js", 78 | "cdnPath": "hammer/hammer-2.0.8" 79 | }, 80 | "release": { 81 | "src": "hammer.min.js", 82 | "path": "libs/hammer/hammer-#{version}.min.js", 83 | "cdnPath": "hammer/hammer-2.0.8.min" 84 | } 85 | }, 86 | 87 | "ojdnd": { 88 | "cdn": "3rdparty", 89 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/dnd-polyfill", 90 | "debug": { 91 | "src": "dnd-polyfill-1.0.0.js", 92 | "path": "libs/dnd-polyfill/dnd-polyfill-1.0.0.js", 93 | "cdnPath": "dnd-polyfill/dnd-polyfill-1.0.0" 94 | }, 95 | "release": { 96 | "src": "dnd-polyfill-1.0.0.min.js", 97 | "path": "libs/dnd-polyfill/dnd-polyfill-1.0.0.min.js", 98 | "cdnPath": "dnd-polyfill/dnd-polyfill-1.0.0.min" 99 | } 100 | }, 101 | 102 | "persist": { 103 | "cdn": "3rdparty", 104 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/persist", 105 | "debug": { 106 | "cwd": "debug", 107 | "src": ["**"], 108 | "path": "libs/persist/debug", 109 | "cdnPath": "persist/debug" 110 | }, 111 | "release": { 112 | "cwd": "min", 113 | "src": ["**"], 114 | "path": "libs/persist/min", 115 | "cdnPath": "persist/min" 116 | } 117 | }, 118 | 119 | "ojs": { 120 | "cdn": "jet", 121 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/oj", 122 | "debug": { 123 | "cwd": "debug", 124 | "src": ["**"], 125 | "path": "libs/oj/v#{version}/debug", 126 | "cdnPath": "debug" 127 | }, 128 | "release": { 129 | "cwd": "min", 130 | "src": ["**"], 131 | "path": "libs/oj/v#{version}/min", 132 | "cdnPath": "min" 133 | } 134 | }, 135 | 136 | "ojL10n": { 137 | "cdn": "jet", 138 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/oj", 139 | "debug": { 140 | "src": "ojL10n.js", 141 | "path": "libs/oj/v#{version}/ojL10n.js", 142 | "cdnPath": "ojL10n" 143 | }, 144 | "release": { 145 | "src": "ojL10n.js", 146 | "path": "libs/oj/v#{version}/ojL10n.js", 147 | "cdnPath": "ojL10n" 148 | } 149 | }, 150 | 151 | "ojtranslations": { 152 | "cdn": "jet", 153 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/oj/resources", 154 | "debug": { 155 | "src": ["**"], 156 | "path": "libs/oj/v#{version}/resources", 157 | "cdnPath": "resources" 158 | }, 159 | "release": { 160 | "src": ["**"], 161 | "path": "libs/oj/v#{version}/resources", 162 | "cdnPath": "resources" 163 | } 164 | }, 165 | 166 | "text": { 167 | "cdn": "3rdparty", 168 | "cwd": "node_modules/requirejs-text", 169 | "debug": { 170 | "src": "text.js", 171 | "path": "libs/require/text.js", 172 | "cdnPath": "require/text" 173 | }, 174 | "release": { 175 | "src": "text.js", 176 | "path": "libs/require/text.js", 177 | "cdnPath": "require/text" 178 | } 179 | }, 180 | 181 | "signals": { 182 | "cdn": "3rdparty", 183 | "cwd": "node_modules/signals/dist", 184 | "debug": { 185 | "src": "signals.js", 186 | "path": "libs/js-signals/signals.js", 187 | "cdnPath": "js-signals/signals" 188 | }, 189 | "release": { 190 | "src": "signals.min.js", 191 | "path": "libs/js-signals/signals.min.js", 192 | "cdnPath": "js-signals/signals.min" 193 | } 194 | }, 195 | 196 | "touchr": { 197 | "cdn": "3rdparty", 198 | "cwd": "node_modules/touchr/js", 199 | "debug": { 200 | "src": "touchr.js", 201 | "path": "libs/touchr/touchr.js", 202 | "cdnPath": "touchr/touchr" 203 | }, 204 | "release": { 205 | "src": "touchr.js", 206 | "path": "libs/touchr/touchr.js", 207 | "cdnPath": "touchr/touchr" 208 | } 209 | }, 210 | 211 | "customElements": { 212 | "cdn": "3rdparty", 213 | "cwd": "node_modules/@webcomponents/custom-elements", 214 | "debug": { 215 | "src": ["custom-elements.min.js", "custom-elements.min.js.map"], 216 | "path": "libs/webcomponents/custom-elements.min.js", 217 | "cdnPath": "webcomponents/custom-elements.min" 218 | }, 219 | "release": { 220 | "src": ["custom-elements.min.js", "custom-elements.min.js.map"], 221 | "path": "libs/webcomponents/custom-elements.min.js", 222 | "cdnPath": "webcomponents/custom-elements.min" 223 | } 224 | }, 225 | 226 | "css": { 227 | "cdn": "3rdparty", 228 | "cwd": "node_modules/require-css", 229 | "debug": { 230 | "src": ["css.js", "css-builder.js", "normalize.js"], 231 | "path": "libs/require-css/css.js", 232 | "cdnPath": "require-css/css" 233 | }, 234 | "release": { 235 | "src": ["css.min.js", "css-builder.js", "normalize.js"], 236 | "path": "libs/require-css/css.min.js", 237 | "cdnPath": "require-css/css.min" 238 | } 239 | } 240 | } 241 | } -------------------------------------------------------------------------------- /generators/app/templates/common/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oraclejet-app", 3 | "version": "1.0.0", 4 | "description": "An Oracle JavaScript Extension Toolkit(JET) web app", 5 | "dependencies": { 6 | "@oracle/oraclejet": "~6.2.0" 7 | }, 8 | "devDependencies": { 9 | "grunt": "^1.0.1", 10 | "@oracle/grunt-oraclejet": "~6.2.0", 11 | "load-grunt-config": "0.19.2", 12 | "@oracle/oraclejet-tooling": "~6.2.0", 13 | "qunit-reporter-junit": "^1.1.1", 14 | "qunit": "^2.4.1" 15 | }, 16 | "engines": { 17 | "node": ">=0.10.0" 18 | }, 19 | "private": true 20 | } 21 | -------------------------------------------------------------------------------- /generators/app/templates/common/src/css/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/app/templates/common/src/css/images/favicon.ico -------------------------------------------------------------------------------- /generators/hybrid/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const paths = require('../../util/paths'); 9 | const path = require('path'); 10 | const templateHandler = require('../../common/template/'); 11 | const common = require('../../common'); 12 | const commonHybrid = require('../../hybrid'); 13 | const commonComponent = require('../../common/component'); 14 | const commonMessages = require('../../common/messages'); 15 | const commonTest = require('../../common/test'); 16 | const cordovaHelper = require('../../hybrid/cordova'); 17 | const platformsHelper = require('../../hybrid/platforms'); 18 | 19 | /* 20 | * Generator for the create step 21 | * Mainly to: 22 | * 1) copy the template in 23 | * 2) perform cordova create 24 | * 3) perform cordova add 25 | */ 26 | const OracleJetHybridCreateGenerator = generators.Base.extend( 27 | { 28 | constructor: function () { //eslint-disable-line 29 | generators.Base.apply(this, arguments); //eslint-disable-line 30 | 31 | this.argument( 32 | 'appDir', 33 | { 34 | type: String, 35 | required: false, 36 | optional: true, 37 | defaults: '.', 38 | desc: 'Application directory to contain the scaffold content' 39 | }); 40 | 41 | this.option('platforms', { 42 | desc: 'Specify the platforms to be supported by the scaffolded hybrid app [android, ios, windows]', 43 | }); 44 | this.option('platform', { 45 | desc: 'Alias for --platforms if the user wishes to specify a single hybrid platform [android, ios, windows]' 46 | }); 47 | this.option('template', { 48 | desc: 'Specify the starter template that is used to scaffold the app [blank, basic[:web|:hybrid], navbar[:web|:hybrid], navdrawer[:web|:hybrid], or ' 49 | }); 50 | this.option('appid', { 51 | desc: 'Specify the app ID for scaffolded hybrid app', 52 | }); 53 | // Deprecated version 54 | this.option('appId', { desc: 'Deprecated. Use --appid instead.' }); 55 | this.option('appname', { 56 | desc: 'Specify the app name for scaffolded hybrid app' 57 | }); 58 | // Deprecated vrsion 59 | this.option('appName', { desc: 'Deprecated. Use --appname instead.' }); 60 | }, 61 | 62 | initializing: function () { //eslint-disable-line 63 | const done = this.async(); 64 | if (this.options.component) { 65 | this.appDir = this.options.component; 66 | } 67 | common.validateArgs(this) 68 | .then(common.validateFlags) 69 | .then(common.validateAppDirNotExistsOrIsEmpty) 70 | .then((validAppDir) => { 71 | this.appDir = path.basename(validAppDir); 72 | 73 | commonHybrid.setupHybridEnv(this); 74 | 75 | done(); 76 | }) 77 | .catch((err) => { 78 | console.error(`\x1b[31mError: ${commonMessages.prefixError(err)}\x1b[0m`); 79 | process.exit(1); 80 | }); 81 | }, 82 | 83 | prompting: function () { //eslint-disable-line 84 | const done = this.async(); 85 | 86 | platformsHelper.getPlatforms(this) 87 | .then(() => { 88 | done(); 89 | }); 90 | }, 91 | 92 | writing: function () { //eslint-disable-line 93 | const done = this.async(); 94 | _writeTemplate(this) 95 | .then(common.switchToAppDirectory.bind(this)) 96 | .then(common.writeCommonTemplates) 97 | .then(common.writeGitIgnore) 98 | .then(common.updatePackageJSON) 99 | .then(cordovaHelper.create) 100 | .then(commonHybrid.copyResources.bind(this)) 101 | .then(commonHybrid.removeExtraCordovaFiles.bind(this)) 102 | .then(platformsHelper.addPlatforms.bind(this)) 103 | .then(commonHybrid.updateConfigXml.bind(this)) 104 | .then(() => { 105 | done(); 106 | }) 107 | .catch((err) => { 108 | if (err) { 109 | this.log.error(err); 110 | process.exit(1); 111 | } 112 | }); 113 | }, 114 | 115 | end() { 116 | if (this.options.component) { 117 | this.log(`Your component ${this.options.component} project is scaffolded. Performing npm install may take a bit.`); 118 | } else { 119 | this.log(commonMessages.scaffoldComplete()); 120 | } 121 | 122 | if (!this.options.norestore) { 123 | this.composeWith('@oracle/oraclejet:restore-hybrid', { options: this.options }); 124 | } 125 | } 126 | }); 127 | 128 | module.exports = OracleJetHybridCreateGenerator; 129 | 130 | function _writeTemplate(generator) { 131 | return new Promise((resolve, reject) => { 132 | const appDir = generator.appDir; 133 | const appSrc = paths.getDefaultPaths().source; 134 | 135 | templateHandler.handleTemplate(generator, generator.destinationPath(`${appDir}/${appSrc}/`)) 136 | .then(commonComponent.writeComponentTemplate) 137 | .then(commonTest.writeTestTemplate) 138 | .then(() => { 139 | resolve(generator); 140 | }) 141 | .catch((err) => { 142 | reject(err); 143 | }); 144 | }); 145 | } 146 | 147 | -------------------------------------------------------------------------------- /generators/hybrid/templates/blank/index.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 24 | 25 | 26 | Oracle JET Starter Template - Hybrid Mobile Blank 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /generators/hybrid/templates/blank/js/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | /** 8 | * Example of Require.js boostrap javascript 9 | */ 10 | /* eslint-disable quote-props */ 11 | 12 | requirejs.config( 13 | { 14 | baseUrl: 'js', 15 | 16 | // Path mappings for the logical module names 17 | // Update the main-release-paths.json for release mode when updating the mappings 18 | paths: 19 | //injector:mainReleasePaths 20 | { 21 | 'knockout': 'libs/knockout/knockout-3.4.2.debug', 22 | 'jquery': 'libs/jquery/jquery-3.3.1', 23 | 'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.1', 24 | 'promise': 'libs/es6-promise/es6-promise', 25 | 'hammerjs': 'libs/hammer/hammer-2.0.8', 26 | 'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0', 27 | 'ojs': 'libs/oj/v6.2.0/debug', 28 | 'ojL10n': 'libs/oj/v6.2.0/ojL10n', 29 | 'ojtranslations': 'libs/oj/v6.2.0/resources', 30 | 'text': 'libs/require/text', 31 | 'signals': 'libs/js-signals/signals', 32 | 'customElements': 'libs/webcomponents/custom-elements.min', 33 | 'proj4': 'libs/proj4js/dist/proj4-src', 34 | 'css': 'libs/require-css/css', 35 | 'touchr': 'libs/touchr/touchr', 36 | 'persist': 'libs/persist/debug' 37 | } 38 | //endinjector 39 | , 40 | // Shim configurations for modules that do not expose AMD 41 | shim: 42 | { 43 | jquery: 44 | { 45 | exports: ['jQuery', '$'] 46 | } 47 | } 48 | } 49 | ); 50 | 51 | require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout'], 52 | function (oj, ko, $) { 53 | $(function () { 54 | function init() { 55 | } 56 | 57 | // If running in a hybrid (e.g. Cordova) environment, we need to wait for the deviceready 58 | // event before executing any code that might interact with Cordova APIs or plugins. 59 | if ($(document.body).hasClass('oj-hybrid')) { 60 | document.addEventListener('deviceready', init); 61 | } else { 62 | init(); 63 | } 64 | }); 65 | } 66 | ); 67 | -------------------------------------------------------------------------------- /generators/hybrid/templates/blank/js/path_mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "js", 3 | "use": "local", 4 | 5 | "cdns": { 6 | "jet": "https://static.oracle.com/cdn/jet/v6.2.0/default/js", 7 | "3rdparty": "https://static.oracle.com/cdn/jet/v6.2.0/3rdparty" 8 | }, 9 | 10 | "libs": { 11 | 12 | "knockout": { 13 | "cdn": "3rdparty", 14 | "cwd": "node_modules/knockout/build/output", 15 | "debug": { 16 | "src": "knockout-latest.debug.js", 17 | "path": "libs/knockout/knockout-#{version}.debug.js", 18 | "cdnPath": "knockout/knockout-3.4.2.debug" 19 | }, 20 | "release": { 21 | "src": "knockout-latest.js", 22 | "path": "libs/knockout/knockout-#{version}.js", 23 | "cdnPath": "knockout/knockout-3.4.2" 24 | } 25 | }, 26 | 27 | "jquery": { 28 | "cdn": "3rdparty", 29 | "cwd": "node_modules/jquery/dist", 30 | "debug": { 31 | "src": "jquery.js", 32 | "path": "libs/jquery/jquery-#{version}.js", 33 | "cdnPath": "jquery/jquery-3.3.1" 34 | }, 35 | "release": { 36 | "src": "jquery.min.js", 37 | "path": "libs/jquery/jquery-#{version}.min.js", 38 | "cdnPath": "jquery/jquery-3.3.1.min" 39 | } 40 | }, 41 | 42 | "jqueryui-amd": { 43 | "cdn": "3rdparty", 44 | "cwd": "node_modules/jquery-ui/ui", 45 | "debug": { 46 | "src": ["*.js", "widgets/draggable.js", "widgets/mouse.js", "widgets/sortable.js"], 47 | "path": "libs/jquery/jqueryui-amd-#{version}", 48 | "cdnPath": "jquery/jqueryui-amd-1.12.1" 49 | }, 50 | "release": { 51 | "src": ["*.js", "widgets/draggable.js", "widgets/mouse.js", "widgets/sortable.js"], 52 | "path": "libs/jquery/jqueryui-amd-#{version}.min", 53 | "cdnPath": "jquery/jqueryui-amd-1.12.1.min" 54 | } 55 | }, 56 | 57 | "promise": { 58 | "cdn": "3rdparty", 59 | "cwd": "node_modules/es6-promise/dist", 60 | "debug": { 61 | "src": ["es6-promise.js", "es6-promise.map"], 62 | "path": "libs/es6-promise/es6-promise.js", 63 | "cdnPath": "es6-promise/es6-promise" 64 | }, 65 | "release": { 66 | "src": ["es6-promise.min.js", "es6-promise.min.map"], 67 | "path": "libs/es6-promise/es6-promise.min.js", 68 | "cdnPath": "es6-promise/es6-promise.min" 69 | } 70 | }, 71 | 72 | "hammerjs": { 73 | "cdn": "3rdparty", 74 | "cwd": "node_modules/hammerjs", 75 | "debug": { 76 | "src": "hammer.js", 77 | "path": "libs/hammer/hammer-#{version}.js", 78 | "cdnPath": "hammer/hammer-2.0.8" 79 | }, 80 | "release": { 81 | "src": "hammer.min.js", 82 | "path": "libs/hammer/hammer-#{version}.min.js", 83 | "cdnPath": "hammer/hammer-2.0.8.min" 84 | } 85 | }, 86 | 87 | "ojdnd": { 88 | "cdn": "3rdparty", 89 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/dnd-polyfill", 90 | "debug": { 91 | "src": "dnd-polyfill-1.0.0.js", 92 | "path": "libs/dnd-polyfill/dnd-polyfill-1.0.0.js", 93 | "cdnPath": "dnd-polyfill/dnd-polyfill-1.0.0" 94 | }, 95 | "release": { 96 | "src": "dnd-polyfill-1.0.0.min.js", 97 | "path": "libs/dnd-polyfill/dnd-polyfill-1.0.0.min.js", 98 | "cdnPath": "dnd-polyfill/dnd-polyfill-1.0.0.min" 99 | } 100 | }, 101 | 102 | "persist": { 103 | "cdn": "3rdparty", 104 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/persist", 105 | "debug": { 106 | "cwd": "debug", 107 | "src": ["**"], 108 | "path": "libs/persist/debug", 109 | "cdnPath": "persist/debug" 110 | }, 111 | "release": { 112 | "cwd": "min", 113 | "src": ["**"], 114 | "path": "libs/persist/min", 115 | "cdnPath": "persist/min" 116 | } 117 | }, 118 | 119 | "ojs": { 120 | "cdn": "jet", 121 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/oj", 122 | "debug": { 123 | "cwd": "debug", 124 | "src": ["**"], 125 | "path": "libs/oj/v#{version}/debug", 126 | "cdnPath": "debug" 127 | }, 128 | "release": { 129 | "cwd": "min", 130 | "src": ["**"], 131 | "path": "libs/oj/v#{version}/min", 132 | "cdnPath": "min" 133 | } 134 | }, 135 | 136 | "ojL10n": { 137 | "cdn": "jet", 138 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/oj", 139 | "debug": { 140 | "src": "ojL10n.js", 141 | "path": "libs/oj/v#{version}/ojL10n.js", 142 | "cdnPath": "ojL10n" 143 | }, 144 | "release": { 145 | "src": "ojL10n.js", 146 | "path": "libs/oj/v#{version}/ojL10n.js", 147 | "cdnPath": "ojL10n" 148 | } 149 | }, 150 | 151 | "ojtranslations": { 152 | "cdn": "jet", 153 | "cwd": "node_modules/@oracle/oraclejet/dist/js/libs/oj/resources", 154 | "debug": { 155 | "src": ["**"], 156 | "path": "libs/oj/v#{version}/resources", 157 | "cdnPath": "resources" 158 | }, 159 | "release": { 160 | "src": ["**"], 161 | "path": "libs/oj/v#{version}/resources", 162 | "cdnPath": "resources" 163 | } 164 | }, 165 | 166 | "text": { 167 | "cdn": "3rdparty", 168 | "cwd": "node_modules/requirejs-text", 169 | "debug": { 170 | "src": "text.js", 171 | "path": "libs/require/text.js", 172 | "cdnPath": "require/text" 173 | }, 174 | "release": { 175 | "src": "text.js", 176 | "path": "libs/require/text.js", 177 | "cdnPath": "require/text" 178 | } 179 | }, 180 | 181 | "signals": { 182 | "cdn": "3rdparty", 183 | "cwd": "node_modules/signals/dist", 184 | "debug": { 185 | "src": "signals.js", 186 | "path": "libs/js-signals/signals.js", 187 | "cdnPath": "js-signals/signals" 188 | }, 189 | "release": { 190 | "src": "signals.min.js", 191 | "path": "libs/js-signals/signals.min.js", 192 | "cdnPath": "js-signals/signals.min" 193 | } 194 | }, 195 | 196 | "touchr": { 197 | "cdn": "3rdparty", 198 | "cwd": "node_modules/touchr/js", 199 | "debug": { 200 | "src": "touchr.js", 201 | "path": "libs/touchr/touchr.js", 202 | "cdnPath": "touchr/touchr" 203 | }, 204 | "release": { 205 | "src": "touchr.js", 206 | "path": "libs/touchr/touchr.js", 207 | "cdnPath": "touchr/touchr" 208 | } 209 | }, 210 | 211 | "customElements": { 212 | "cdn": "3rdparty", 213 | "cwd": "node_modules/@webcomponents/custom-elements", 214 | "debug": { 215 | "src": ["custom-elements.min.js", "custom-elements.min.js.map"], 216 | "path": "libs/webcomponents/custom-elements.min.js", 217 | "cdnPath": "webcomponents/custom-elements.min" 218 | }, 219 | "release": { 220 | "src": ["custom-elements.min.js", "custom-elements.min.js.map"], 221 | "path": "libs/webcomponents/custom-elements.min.js", 222 | "cdnPath": "webcomponents/custom-elements.min" 223 | } 224 | }, 225 | 226 | "css": { 227 | "cdn": "3rdparty", 228 | "cwd": "node_modules/require-css", 229 | "debug": { 230 | "src": ["css.js", "css-builder.js", "normalize.js"], 231 | "path": "libs/require-css/css.js", 232 | "cdnPath": "css" 233 | }, 234 | "release": { 235 | "src": ["css.min.js", "css-builder.js", "normalize.js"], 236 | "path": "libs/require-css/css.min.js", 237 | "cdnPath": "css.min" 238 | } 239 | } 240 | } 241 | } -------------------------------------------------------------------------------- /generators/hybrid/templates/common/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oraclejet-app", 3 | "version": "1.0.0", 4 | "description": "An Oracle JavaScript Extension Toolkit (JET) mobile app", 5 | "dependencies": { 6 | "@oracle/oraclejet": "~6.2.0" 7 | }, 8 | "devDependencies": { 9 | "fs-extra": "0.30.0", 10 | "grunt": "^1.0.1", 11 | "@oracle/grunt-oraclejet": "~6.2.0", 12 | "load-grunt-config": "0.19.2", 13 | "@oracle/oraclejet-tooling": "~6.2.0", 14 | "qunit-reporter-junit": "^1.1.1", 15 | "qunit": "^2.4.1" 16 | }, 17 | "engines": { 18 | "node": ">=0.10.0" 19 | }, 20 | "private": true 21 | } 22 | -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/android/icon-hdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/android/icon-hdpi.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/android/icon-ldpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/android/icon-ldpi.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/android/icon-mdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/android/icon-mdpi.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/android/icon-xhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/android/icon-xhdpi.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/android/icon-xxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/android/icon-xxhdpi.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/android/icon-xxxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/android/icon-xxxhdpi.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-40.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-40@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-40@3x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-50.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-50@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-60.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-60@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-60@3x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-72.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-72@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-76.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-76@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-83.5@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-small.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-small@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon-small@3x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/ios/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/ios/icon@2x.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square150x150Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square150x150Logo.scale-240.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square30x30Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square30x30Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square310x310Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square310x310Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square44x44Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square44x44Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square44x44Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square44x44Logo.scale-240.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square70x70Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square70x70Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square71x71Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square71x71Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Square71x71Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Square71x71Logo.scale-240.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Wide310x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Wide310x150Logo.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/icon/windows/Wide310x150Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/icon/windows/Wide310x150Logo.scale-240.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-land-hdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-land-hdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-land-ldpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-land-ldpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-land-mdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-land-mdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-land-xhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-land-xhdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-land-xxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-land-xxhdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-land-xxxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-land-xxxhdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-port-hdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-port-hdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-port-ldpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-port-ldpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-port-mdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-port-mdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-port-xhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-port-xhdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-port-xxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-port-xxhdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/android/splash-port-xxxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/android/splash-port-xxxhdpi.9.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-667h.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-736h.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Landscape-736h.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Portrait-iphone-x-1125h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Portrait-iphone-x-1125h.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Portrait-iphone-x-2436h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Portrait-iphone-x-2436h.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default@2x~iphone.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/ios/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/ios/Default~iphone.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/windows/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/windows/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/res/screen/windows/SplashScreenPhone.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/res/screen/windows/SplashScreenPhone.scale-240.png -------------------------------------------------------------------------------- /generators/hybrid/templates/common/src/css/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/generator-oraclejet/6dfa1f942aaa01d8ba682ef1c47439b4d95ca95a/generators/hybrid/templates/common/src/css/images/favicon.ico -------------------------------------------------------------------------------- /generators/hybrid/templates/common/src/js/cordovaMocks.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | /* 6 | * Add any object Cordova plugin might need 7 | * and which is normally unavailable in browser mode. 8 | */ 9 | -------------------------------------------------------------------------------- /generators/restore-hybrid/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const exec = require('child_process').exec; 8 | const generators = require('yeoman-generator'); 9 | const common = require('../../common'); 10 | const commonHookRunner = require('../../common/hookRunner'); 11 | const commonHybrid = require('../../hybrid'); 12 | const commonMessages = require('../../common/messages'); 13 | const commonRestore = require('../../common/restore'); 14 | const path = require('path'); 15 | const paths = require('../../util/paths'); 16 | const fs = require('fs-extra'); 17 | 18 | /* 19 | * Generator for the restore step 20 | * Mainly to: 21 | * 1) invoke npm install 22 | * 2) write oraclejetconfig.json file 23 | */ 24 | const OracleJetHybridRestoreGenerator = generators.Base.extend( 25 | { 26 | initializing: function() { //eslint-disable-line 27 | const done = this.async(); 28 | common.validateArgs(this) 29 | .then(common.validateFlags) 30 | .then(() => { 31 | done(); 32 | }) 33 | .catch((err) => { 34 | this.env.error(commonMessages.prefixError(err)); 35 | }); 36 | }, 37 | constructor: function () { //eslint-disable-line 38 | generators.Base.apply(this, arguments); //eslint-disable-line 39 | }, 40 | 41 | install: function() { //eslint-disable-line 42 | this.log('Performing npm install may take a bit.'); 43 | const done = this.async(); 44 | 45 | commonRestore.npmInstall({ generator: this }) 46 | .then(commonHybrid.copyHooks) 47 | .then(commonHybrid.copyResources) 48 | .then(commonRestore.writeOracleJetConfigFile) 49 | .then(_invokeCordovaPrepare) 50 | .then(commonHookRunner.runAfterAppCreateHook) 51 | .then(() => { 52 | done(); 53 | }) 54 | .catch((err) => { 55 | if (err) { 56 | console.error(`\x1b[31mError: ${commonMessages.prefixError(err)}\x1b[0m`); 57 | process.exit(1); 58 | } 59 | }); 60 | }, 61 | 62 | end: function() { //eslint-disable-line 63 | this.log(commonMessages.restoreComplete( 64 | this.options.invokedByRestore, path.basename(this.env.cwd))); 65 | process.exit(0); 66 | } 67 | 68 | }); 69 | 70 | function _invokeCordovaPrepare(context) { 71 | const generator = context.generator || context; 72 | const isIOS = generator.options.platform === 'ios' || 73 | (generator.options.platforms && generator.options.platforms.indexOf('ios') !== -1); 74 | if (!isIOS && !generator.options.invokedByRestore) return Promise.resolve(context); 75 | 76 | const cwd = paths.getConfiguredPaths(generator.destinationPath()).stagingHybrid; 77 | fs.ensureDirSync(path.join(cwd, 'www')); 78 | 79 | console.log('Restoring hybrid plugins and platforms....'); 80 | return new Promise((resolve, reject) => { 81 | const cmd = 'cordova prepare'; 82 | const cmdOpts = { cwd, stdio: [0, 'pipe', 'pipe'], maxBuffer: 1024 * 20000 }; 83 | exec(cmd, cmdOpts, (error) => { 84 | // When www/index.html files are missing, cordova reports error 85 | if (error && !/index\.html/.test(error)) { 86 | reject(error); 87 | } 88 | resolve(context); 89 | }); 90 | }); 91 | } 92 | 93 | module.exports = OracleJetHybridRestoreGenerator; 94 | -------------------------------------------------------------------------------- /generators/restore-web/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const common = require('../../common'); 9 | const commonHookRunner = require('../../common/hookRunner'); 10 | const commonMessages = require('../../common/messages'); 11 | const commonRestore = require('../../common/restore'); 12 | const path = require('path'); 13 | 14 | /* 15 | * Generator for the restore step 16 | * Mainly to: 17 | * 1) invoke npm install 18 | * 2) write oraclejetconfig.json file 19 | */ 20 | const OracleJetWebRestoreGenerator = generators.Base.extend( 21 | { 22 | initializing: function () { //eslint-disable-line 23 | const done = this.async(); 24 | common.validateArgs(this) 25 | .then(common.validateFlags) 26 | .then(() => { 27 | done(); 28 | }) 29 | .catch((err) => { 30 | this.env.error(commonMessages.prefixError(err)); 31 | }); 32 | }, 33 | constructor: function() { //eslint-disable-line 34 | generators.Base.apply(this, arguments); //eslint-disable-line 35 | }, 36 | 37 | install: function() { //eslint-disable-line 38 | // since both will be performing npm install initially just log here 39 | this.log('Performing npm install may take a bit.'); 40 | const done = this.async(); 41 | commonRestore.npmInstall({ generator: this }) 42 | .then(commonRestore.writeOracleJetConfigFile) 43 | .then(commonHookRunner.runAfterAppCreateHook) 44 | .then(() => { 45 | done(); 46 | }) 47 | .catch((err) => { 48 | if (err) { 49 | console.error(`\x1b[31mError: ${commonMessages.prefixError(err)}\x1b[0m`); 50 | process.exit(1); 51 | } 52 | }); 53 | }, 54 | 55 | end: function() { //eslint-disable-line 56 | this.log(commonMessages.restoreComplete( 57 | this.options.invokedByRestore, path.basename(this.env.cwd))); 58 | process.exit(0); 59 | } 60 | }); 61 | 62 | module.exports = OracleJetWebRestoreGenerator; 63 | -------------------------------------------------------------------------------- /generators/restore/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const generators = require('yeoman-generator'); 8 | const fs = require('fs-extra'); 9 | const path = require('path'); 10 | const paths = require('../../util/paths'); 11 | const constants = require('../../util/constants'); 12 | 13 | /* 14 | * Compose with oraclejet:restore-web or oraclejet:restore-hybrid 15 | */ 16 | const OracleJetRestoreGenerator = generators.Base.extend( 17 | { 18 | constructor: function () { //eslint-disable-line 19 | generators.Base.apply(this, arguments); //eslint-disable-line 20 | }, 21 | 22 | initializing: function () { //eslint-disable-line 23 | // if the project contains cordova's config.xml, consider it to be a hybrid; otherwise web 24 | const cordovaDir = paths.getConfiguredPaths(this.destinationPath()).stagingHybrid; 25 | this._hybrid = fs.existsSync(path.resolve(cordovaDir, constants.CORDOVA_CONFIG_XML)); 26 | }, 27 | 28 | end: function () { //eslint-disable-line 29 | const appType = constants.APP_TYPE; 30 | const restoreType = this._hybrid ? appType.HYBRID : appType.WEB; 31 | this.options.invokedByRestore = true; 32 | 33 | this.composeWith( 34 | `@oracle/oraclejet:restore-${restoreType}`, 35 | { options: this.options, arguments: this.arguments }); 36 | } 37 | }); 38 | 39 | module.exports = OracleJetRestoreGenerator; 40 | -------------------------------------------------------------------------------- /hybrid/cordova.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const paths = require('../util/paths'); 8 | const fs = require('fs-extra'); 9 | 10 | module.exports = 11 | { 12 | create: function _create(generator) { 13 | return new Promise((resolve, reject) => { 14 | const cordovaDir = paths.getConfiguredPaths(generator.destinationPath()).stagingHybrid; 15 | fs.ensureDirSync(cordovaDir); 16 | let args = ['create', cordovaDir]; 17 | 18 | const appid = generator.options.appid; 19 | const appname = generator.options.appname; 20 | 21 | if (appid && appname) { 22 | args = args.concat([appid, appname]); 23 | } else if (appname) { 24 | // will stop the generator since invalid option set 25 | reject(new Error('Error: appid option must be provided if appname is provided')); 26 | } else if (appid) { 27 | // will stop the generator since invalid option set 28 | reject(new Error('Error: appname option must be provided if appid is provided')); 29 | } 30 | 31 | // invoke cordova create for the skeleton 32 | generator.spawnCommand('cordova', args) 33 | .on('exit', (err) => { 34 | if (err) { 35 | // stop the generator as cordova create failed 36 | reject(err); 37 | } 38 | 39 | resolve(generator); 40 | }) 41 | .on('error', (err) => { 42 | reject(err); 43 | }); 44 | }); 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /hybrid/graphics.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | // icons and graphics for the generator 8 | 9 | module.exports = { 10 | PATH: 'res', 11 | ICONS: { 12 | ios: 13 | [{ file: 'icon-small.png', width: '29', height: '29' }, 14 | { file: 'icon-small@2x.png', width: '58', height: '58' }, 15 | { file: 'icon-small@3x.png', width: '87', height: '87' }, 16 | { file: 'icon-40.png', width: '40', height: '40' }, 17 | { file: 'icon-40@2x.png', width: '80', height: '80' }, 18 | { file: 'icon-40@3x.png', width: '120', height: '120' }, 19 | { file: 'icon-50.png', width: '50', height: '50' }, 20 | { file: 'icon-50@2x.png', width: '100', height: '100' }, 21 | { file: 'icon.png', width: '57', height: '57' }, 22 | { file: 'icon@2x.png', width: '114', height: '114' }, 23 | { file: 'icon-72.png', width: '72', height: '72' }, 24 | { file: 'icon-72@2x.png', width: '144', height: '144' }, 25 | { file: 'icon-76.png', width: '76', height: '76' }, 26 | { file: 'icon-76@2x.png', width: '152', height: '152' }, 27 | { file: 'icon-83.5@2x.png', width: '167', height: '167' }, 28 | { file: 'icon-60.png', width: '60', height: '60' }, 29 | { file: 'icon-60@2x.png', width: '120', height: '120' }, 30 | { file: 'icon-60@3x.png', width: '180', height: '180' }], 31 | android: 32 | [{ file: 'icon-ldpi.png', width: '36', height: '36' }, 33 | { file: 'icon-mdpi.png', width: '48', height: '48' }, 34 | { file: 'icon-hdpi.png', width: '72', height: '72' }, 35 | { file: 'icon-xhdpi.png', width: '96', height: '96' }, 36 | { file: 'icon-xxhdpi.png', width: '144', height: '144' }, 37 | { file: 'icon-xxxhdpi.png', width: '192', height: '192' }], 38 | windows: 39 | [{ file: 'Square30x30Logo.scale-100.png', width: '30', height: '30' }, 40 | { file: 'Square44x44Logo.scale-100.png', width: '44', height: '44' }, 41 | { file: 'Square44x44Logo.scale-240.png', width: '106', height: '106' }, 42 | { file: 'Square70x70Logo.scale-100.png', width: '70', height: '70' }, 43 | { file: 'Square71x71Logo.scale-100.png', width: '71', height: '71' }, 44 | { file: 'Square71x71Logo.scale-240.png', width: '170', height: '170' }, 45 | { file: 'Square150x150Logo.scale-100.png', width: '150', height: '150' }, 46 | { file: 'Square150x150Logo.scale-240.png', width: '360', height: '360' }, 47 | { file: 'Square310x310Logo.scale-100.png', width: '310', height: '310' }, 48 | { file: 'Wide310x150Logo.scale-100.png', width: '310', height: '150' }, 49 | { file: 'Wide310x150Logo.scale-240.png', width: '744', height: '360' } 50 | ] }, 51 | SPLASH: { 52 | ios: 53 | [{ src: 'Default@2x~iphone.png', width: '640', height: '960' }, 54 | { src: 'Default-568h@2x~iphone.png', width: '640', height: '1136' }, 55 | { src: 'Default-667h.png', width: '750', height: '1334' }, 56 | { src: 'Default-736h.png', width: '1242', height: '2208' }, 57 | { src: 'Default~iphone.png', width: '320', height: '480' }, 58 | { src: 'Default-Landscape~ipad.png', width: '1024', height: '768' }, 59 | { src: 'Default-Landscape@2x~ipad.png', width: '2048', height: '1536' }, 60 | { src: 'Default-Landscape-736h.png', width: '2208', height: '1242' }, 61 | { src: 'Default-Portrait@2x~ipad.png', width: '1536', height: '2048' }, 62 | { src: 'Default-Portrait~ipad.png', width: '768', height: '1024' }, 63 | { src: 'Default-Portrait-iphone-x-2436h.png', width: '1125', height: '2436' }, 64 | { src: 'Default-Portrait-iphone-x-1125h.png', width: '2436', height: '1125' } 65 | ], 66 | android: 67 | [{ src: 'splash-land-ldpi.9.png', density: 'land-ldpi' }, 68 | { src: 'splash-land-mdpi.9.png', density: 'land-mdpi' }, 69 | { src: 'splash-land-hdpi.9.png', density: 'land-hdpi' }, 70 | { src: 'splash-land-xhdpi.9.png', density: 'land-xhdpi' }, 71 | { src: 'splash-land-xxhdpi.9.png', density: 'land-xxhdpi' }, 72 | { src: 'splash-land-xxxhdpi.9.png', density: 'land-xxxhdpi' }, 73 | { src: 'splash-port-hdpi.9.png', density: 'port-hdpi' }, 74 | { src: 'splash-port-ldpi.9.png', density: 'port-ldpi' }, 75 | { src: 'splash-port-mdpi.9.png', density: 'port-mdpi' }, 76 | { src: 'splash-port-xhdpi.9.png', density: 'port-xhdpi' }, 77 | { src: 'splash-port-xxhdpi.9.png', density: 'port-xxhdpi' }, 78 | { src: 'splash-port-xxxhdpi.9.png', density: 'port-xxxhdpi' } 79 | ], 80 | windows: 81 | [{ src: 'SplashScreen.scale-100.png', width: '620', height: '300' }, 82 | { src: 'SplashScreenPhone.scale-240.png', width: '1152', height: '1920' } 83 | ] } 84 | }; 85 | 86 | -------------------------------------------------------------------------------- /hybrid/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const fs = require('fs-extra'); 8 | const path = require('path'); 9 | const common = require('../common'); 10 | const constants = require('../util/constants'); 11 | const commonMessages = require('../common/messages'); 12 | const DOMParser = require('xmldom').DOMParser; 13 | const endOfLine = require('os').EOL; 14 | const graphics = require('./graphics'); 15 | const paths = require('../util/paths'); 16 | 17 | const ORACLEJET_APP_ID = 'org.oraclejet.'; 18 | const iOSPlugins = ['cordova-plugin-wkwebview-file-xhr', 19 | 'cordova-plugin-wkwebview-engine']; 20 | 21 | const CORDOVA_HOOKS = 22 | [ 23 | { 24 | type: 'after_prepare', src: 'scripts/hooks/jetAfterPrepare.js' 25 | } 26 | ]; 27 | 28 | 29 | module.exports = 30 | { 31 | setupHybridEnv: function _setupHybridEnv(generatorArg) { 32 | // platforms that will be added by cordova API. 33 | // note if this.options.platforms is not provided 34 | // it will test out the platform candidates during the prompting 35 | // lifecycle; otherwise it will parse the provided 36 | // platforms options and filter to those that are capable 37 | // on the user's machine 38 | const generator = generatorArg; 39 | generator._platformsToInstall = []; 40 | 41 | // prefer appname but support appName 42 | const appname = generator.options.appname ? 43 | generator.options.appname : generator.options.appName; 44 | if (!appname) { 45 | generator.options.appname = _getAppBaseName(generator.appDir); 46 | } else { 47 | generator.options.appname = appname; 48 | } 49 | 50 | // prefer appid but support appId 51 | const appid = generator.options.appid ? generator.options.appid : generator.options.appId; 52 | if (!appid) { 53 | generator.options.appid = _getDefaultAppId(generator.appDir); 54 | } else { 55 | generator.options.appid = appid; 56 | } 57 | }, 58 | 59 | removeExtraCordovaFiles: function _removeExtraCordovaFiles(generator) { 60 | const cordovaDir = _getHybridPath(generator); 61 | return new Promise((resolve, reject) => { 62 | try { 63 | fs.removeSync(path.resolve(cordovaDir, 'hooks')); 64 | fs.removeSync(path.resolve(cordovaDir, 'www/*')); 65 | resolve(generator); 66 | } catch (err) { 67 | reject(commonMessages.error(err, 'removeExtraCordovaFiles')); 68 | } 69 | }); 70 | }, 71 | 72 | copyResources: function _copyResources(context) { 73 | const generator = context.generator || context; 74 | const source = generator.templatePath('../../hybrid/templates/common/res'); 75 | const dest = _getHybridPath(generator, 'res/'); 76 | fs.emptyDirSync(dest); 77 | return new Promise((resolve, reject) => { 78 | fs.copy(source, dest, { overwrite: false }, (err) => { 79 | if (err) { 80 | reject(err); 81 | return; 82 | } 83 | resolve(context); 84 | }); 85 | }); 86 | }, 87 | 88 | updateConfigXml: function _updateConfigXml(generator) { 89 | const cordovaDir = _getHybridPath(generator); 90 | const configXml = generator.destinationPath(`${cordovaDir}/${constants.CORDOVA_CONFIG_XML}`); 91 | 92 | return new Promise((resolve, reject) => { 93 | try { 94 | const configRead = fs.readFileSync(configXml, 'utf-8'); 95 | const document = new DOMParser().parseFromString(configRead, 'text/xml'); 96 | _addCordovaConfigDescription(document); 97 | _addCordovaConfigHooks(document); 98 | if (generator.options.platform === 'ios' 99 | || (generator.options.platforms && generator.options.platforms.indexOf('ios') !== -1)) { 100 | _addIosPlugins(document); 101 | } 102 | _addIosOrientationPreference(document); 103 | _addIosOverscrollPreference(document); 104 | _addAndroidOverscrollPreference(document); 105 | _addWindowsPreferences(document); 106 | _addIcons(document); 107 | _addSplash(document); 108 | fs.writeFileSync(configXml, document); 109 | resolve(generator); 110 | } catch (err) { 111 | reject(commonMessages.error(err, 'updateConfigXml')); 112 | } 113 | }); 114 | }, 115 | 116 | copyHooks(context) { 117 | // 'Generator' may be passed as {generator: generator} or {generator} 118 | const generator = context.generator || context; 119 | const source = generator.destinationPath('node_modules/@oracle/oraclejet-tooling/hooks/'); 120 | const dest = _getHybridPath(generator, 'scripts/hooks/'); 121 | 122 | return new Promise((resolve, reject) => { 123 | if (common.fsExistsSync(source)) { 124 | fs.copy(source, dest, (err) => { 125 | if (err) { 126 | reject(err); 127 | return; 128 | } 129 | resolve(context); 130 | }); 131 | } else { 132 | reject('Missing folder \'@oracle/oraclejet-tooling/hooks/\'.'); 133 | } 134 | }); 135 | } 136 | }; 137 | 138 | 139 | function _getDefaultAppId(appDirArg) { 140 | const appDir = _getAppBaseName(appDirArg); 141 | 142 | // strip non-word chars 143 | let appId = appDir.replace(/\W/g, ''); 144 | 145 | // make sure the id does not start with a digit or underscore 146 | if (/^[\d_]+/.test(appId)) { 147 | appId = `oj${appId}`; 148 | } 149 | 150 | return ORACLEJET_APP_ID + appId.toLowerCase(); 151 | } 152 | 153 | 154 | function _getAppBaseName(appDir) { 155 | return path.basename(path.resolve(appDir)); 156 | } 157 | 158 | 159 | function _addCordovaConfigDescription(document) { 160 | const widget = _getFirstElementByTagName(document, 'widget'); 161 | const packageJSON = fs.readJSONSync(path.resolve('package.json')); 162 | _updateCordovaConfigDescription(widget, packageJSON); 163 | } 164 | 165 | function _updateCordovaConfigDescription(widget, packageJSON) { 166 | const description = packageJSON.description; 167 | const descriptionElement = _getFirstElementByTagName(widget, 'description'); 168 | descriptionElement.childNodes[0].data = `\n ${description}\n `; 169 | } 170 | 171 | function _addCordovaConfigHooks(document) { 172 | const widget = _getFirstElementByTagName(document, 'widget'); 173 | 174 | CORDOVA_HOOKS.forEach((value) => { 175 | widget.appendChild(_createHookElement(document, value)); 176 | widget.appendChild(_createNewLineElement(document)); 177 | }); 178 | } 179 | 180 | function _addIosOrientationPreference(document) { 181 | _addPlatformElement(document, 'ios', 'preference', 'Orientation', 'all'); 182 | } 183 | 184 | function _addIosOverscrollPreference(document) { 185 | _addPlatformElement(document, 'ios', 'preference', 'DisallowOverscroll', 'true'); 186 | } 187 | 188 | function _addIosPlugins(document) { 189 | iOSPlugins.forEach((plugin) => { 190 | _addPluginElement(document, plugin); 191 | }); 192 | } 193 | 194 | function _addPluginElement(document, pluginName) { 195 | const widget = _getFirstElementByTagName(document, 'widget'); 196 | const elementNode = document.createElement('plugin'); 197 | elementNode.setAttribute('name', pluginName); 198 | widget.appendChild(elementNode); 199 | widget.appendChild(_createNewLineElement(document)); 200 | } 201 | 202 | 203 | function _addAndroidOverscrollPreference(document) { 204 | _addPlatformElement(document, 'android', 'preference', 'DisallowOverscroll', 'true'); 205 | } 206 | 207 | function _addPlatformElement(document, platform, element, attribute, value) { 208 | const platforms = document.getElementsByTagName('platform'); 209 | 210 | for (let i = 0; i < platforms.length; i += 1) { 211 | if (platforms[i].getAttribute('name') === platform) { 212 | const elementNode = document.createElement(element); 213 | elementNode.setAttribute('name', attribute); 214 | elementNode.setAttribute('value', value); 215 | 216 | platforms[i].appendChild(elementNode); 217 | break; 218 | } 219 | } 220 | } 221 | 222 | function _addIcons(document) { 223 | const platforms = document.getElementsByTagName('platform'); 224 | 225 | for (let i = 0; i < platforms.length; i += 1) { 226 | const platform = platforms[i].getAttribute('name'); 227 | const platformIcons = graphics.ICONS[platform]; 228 | for (let j = 0; j < platformIcons.length; j += 1) { 229 | const icon = document.createElement('icon'); 230 | icon.setAttribute('src', path.posix.join(graphics.PATH, 'icon', platform, platformIcons[j].file)); 231 | icon.setAttribute('width', platformIcons[j].width); 232 | icon.setAttribute('height', platformIcons[j].height); 233 | platforms[i].appendChild(icon); 234 | } 235 | } 236 | } 237 | 238 | function _addSplash(document) { 239 | const platforms = document.getElementsByTagName('platform'); 240 | 241 | for (let i = 0; i < platforms.length; i += 1) { 242 | const platform = platforms[i].getAttribute('name'); 243 | const platformSplash = graphics.SPLASH[platform]; 244 | for (let j = 0; j < platformSplash.length; j += 1) { 245 | const splash = document.createElement('splash'); 246 | Object.keys(platformSplash[j]).forEach((prop) => { 247 | if (prop === 'src') { 248 | splash.setAttribute(prop, path.posix.join(graphics.PATH, 'screen', platform, platformSplash[j].src)); 249 | } else { 250 | splash.setAttribute(prop, platformSplash[j][prop]); 251 | } 252 | }); 253 | platforms[i].appendChild(splash); 254 | } 255 | } 256 | } 257 | 258 | function _addWindowsPreferences(document) { 259 | const windowsPlatformElem = _getWindowsPreferencesSection(document); 260 | const preference = document.createElement('preference'); 261 | preference.setAttribute('name', 'windows-target-version'); 262 | preference.setAttribute('value', '10.0'); 263 | windowsPlatformElem.appendChild(preference); 264 | const preference2 = document.createElement('preference'); 265 | preference2.setAttribute('name', 'SplashScreenDelay'); 266 | preference2.setAttribute('value', '0'); 267 | windowsPlatformElem.appendChild(preference2); 268 | const preference3 = document.createElement('preference'); 269 | preference3.setAttribute('name', 'SplashScreenBackgroundColor'); 270 | preference3.setAttribute('value', ''); 271 | windowsPlatformElem.appendChild(preference3); 272 | } 273 | 274 | function _getWindowsPreferencesSection(document) { 275 | const platforms = document.getElementsByTagName('platform'); 276 | 277 | for (let i = 0; i < platforms.length; i += 1) { 278 | if (platforms[i].getAttribute('name') === 'windows') { 279 | return platforms[i]; 280 | } 281 | } 282 | const windowsPlatformElem = document.createElement('platform'); 283 | windowsPlatformElem.setAttribute('name', 'windows'); 284 | document.insertBefore(windowsPlatformElem, platforms[0]); 285 | return windowsPlatformElem; 286 | } 287 | 288 | function _createHookElement(document, value) { 289 | const hook = document.createElement('hook'); 290 | hook.setAttribute('type', value.type); 291 | hook.setAttribute('src', value.src); 292 | 293 | return hook; 294 | } 295 | 296 | function _createNewLineElement(document) { 297 | return document.createTextNode(endOfLine); 298 | } 299 | 300 | function _getFirstElementByTagName(node, tag) { 301 | return node.getElementsByTagName(tag)[0]; 302 | } 303 | 304 | function _getHybridPath(generator, subDir) { 305 | const appDir = generator.destinationPath(); 306 | const hybridRoot = paths.getConfiguredPaths(appDir).stagingHybrid; 307 | return (subDir) ? path.join(hybridRoot, subDir) : hybridRoot; 308 | } 309 | -------------------------------------------------------------------------------- /hybrid/platforms.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const constants = require('../util/constants'); 8 | const paths = require('../util/paths'); 9 | const common = require('../common'); 10 | const commonMessages = require('../common/messages'); 11 | 12 | const SUPPORTED_PLATFORMS_PROMP_CHOICES = 13 | [ 14 | { 15 | name: 'Android', 16 | value: 'android' 17 | }, 18 | { 19 | name: 'iOS', 20 | value: 'ios' 21 | }, 22 | { 23 | name: 'Windows', 24 | value: 'windows' 25 | } 26 | ]; 27 | 28 | const TEST_COMMAND = 29 | [ 30 | { 31 | platform: 'android', 32 | testCommand: 'adb', 33 | testCommandArgs: ['devices'] 34 | }, 35 | { 36 | platform: 'ios', 37 | testCommand: 'xcrun', 38 | testCommandArgs: ['simctl', 'help', 'create'] 39 | }, 40 | { 41 | platform: 'windows', 42 | testCommand: 'reg.exe', 43 | testCommandArgs: ['query', 44 | 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\ Kits\\Installed\ Roots', // eslint-disable-line 45 | '/v', 'KitsRoot10'] 46 | } 47 | ]; 48 | 49 | module.exports = 50 | { 51 | getPlatforms: function _getPlatforms(generatorArg) { 52 | let platforms; 53 | const generator = generatorArg; 54 | 55 | if (generator.options.platforms || generator.options.platform) { 56 | platforms = generator.options.platforms || generator.options.platform; 57 | 58 | return new Promise((resolve) => { 59 | _validatePlatforms(generator, platforms) 60 | .then((processedPlatforms) => { 61 | generator._platformsToInstall = processedPlatforms; 62 | resolve(generator); 63 | }); 64 | }); 65 | } 66 | 67 | return new Promise((resolve, reject) => { 68 | // if platforms option is not provided do prompt 69 | 70 | _testPlatforms(generator, constants.SUPPORTED_HYBRID_PLATFORMS) 71 | .then((possiblePlatforms) => { 72 | if (!possiblePlatforms.length) { 73 | resolve(generator); 74 | return; 75 | } 76 | 77 | generator.prompt([{ 78 | type: 'checkbox', 79 | name: 'platforms', 80 | choices: _filterPromptingPlatforms(possiblePlatforms), 81 | message: 'Please choose the platforms you want to install' 82 | }]).then((answers) => { 83 | // preserve the values for the corodva add part 84 | generator._platformsToInstall = answers.platforms; 85 | resolve(generator); 86 | }); 87 | }) 88 | .catch((err) => { 89 | reject(commonMessages.error(err, 'testPlatforms')); 90 | }); 91 | }); 92 | }, 93 | 94 | addPlatforms: function _addPlatforms(generator) { 95 | const platforms = generator._platformsToInstall; 96 | const context = { generator }; 97 | 98 | // always add the browser platform 99 | platforms.push('browser'); 100 | const cordovaDir = paths.getConfiguredPaths(generator.destinationPath()).stagingHybrid; 101 | const appRoot = generator.destinationPath(); 102 | generator.destinationRoot(generator.destinationPath(cordovaDir)); 103 | 104 | 105 | return new Promise((resolve, reject) => { 106 | let p = Promise.resolve(); 107 | platforms.forEach((value) => { 108 | p = p.then(() => common.gruntSpawnCommandPromise(context, 'cordova', 109 | ['platform', 'add', value, '--save'], `Adding platform: ${value}`)); 110 | }); 111 | 112 | p.then(() => { 113 | generator.destinationRoot(appRoot); 114 | resolve(generator); 115 | }) 116 | .catch((err) => { 117 | reject(commonMessages.error(err, 'addPlatforms')); 118 | }); 119 | }); 120 | } 121 | }; 122 | 123 | /** 124 | * Returns an array of platforms to be installed. 125 | * An error is thrown when an invalid platform is requested. 126 | * A warning is displayed for valid platforms that do not appear 127 | * to be supported in the environment. 128 | * 129 | * @param {type} generator 130 | * @return {Promise} 131 | */ 132 | function _validatePlatforms(generator) { 133 | const platformOptions = generator.options.platforms || generator.options.platform; 134 | const platforms = _processPlatformOptions(generator, platformOptions); 135 | 136 | return new Promise((resolve) => { 137 | _testPlatforms(generator, platforms) 138 | .then((availablePlatforms) => { 139 | const failedPlatforms = []; 140 | platforms.forEach((entry) => { 141 | if (availablePlatforms.indexOf(entry) < 0) { 142 | failedPlatforms.push(entry); 143 | } 144 | }); 145 | 146 | if (failedPlatforms.length > 0) { 147 | let msg = 'WARNING: Could not detect support for the following platform(s):'; 148 | failedPlatforms.forEach((entry) => { 149 | msg += `\n ${entry}`; 150 | }); 151 | msg += '\nThe platform(s) will be installed, but may not work properly.'; 152 | generator.log(commonMessages.appendJETPrefix() + msg); 153 | } 154 | resolve(platforms); 155 | } 156 | ); 157 | }); 158 | } 159 | 160 | /** 161 | * Tests if the requested platforms are supported in the current environment. 162 | * Returns an array of detected valid platforms. 163 | * 164 | * @param {Object} generator 165 | * @param {Array} platforms array of requested platforms 166 | * @return {Promise} a promise object 167 | */ 168 | function _testPlatforms(generator, platforms) { 169 | const filteredTestCommands = _getFilteredTestCommands(platforms); 170 | const platformTests = _getPlatformTests(generator, filteredTestCommands); 171 | 172 | // note there exists no reject since want to test all the filteredTestCommands 173 | // and when there are errors (i.e. test command fails) it will resolve w/o that platform 174 | return new Promise((resolve) => { 175 | Promise.all(platformTests) 176 | .then((platformResults) => { 177 | // note platformResults is an array with those that passed to be populated 178 | // and those not passed to be undefined (with resolve()) 179 | // as mentioned since one needs to test for every platform passed in the 180 | // user's environment need the tests to go through w/ resolve and not 181 | // reject 182 | resolve(platformResults.filter(entry => 183 | // return only entries that resulted in success 184 | !!entry)); 185 | }); 186 | }); 187 | } 188 | 189 | function _filterPromptingPlatforms(promptPlatforms) { 190 | // simple function to return prompt choices based on supported platforms 191 | return SUPPORTED_PLATFORMS_PROMP_CHOICES.filter(type => 192 | promptPlatforms.indexOf(type.value) !== -1); 193 | } 194 | 195 | function _processPlatformOptions(generator, platforms) { 196 | if (!platforms) { 197 | return []; 198 | } 199 | 200 | const splitted = platforms.split(','); 201 | const trimmed = splitted.map(val => val.trim()); 202 | 203 | // now filter the content to only supported ones 204 | return trimmed.filter((val) => { 205 | const supportedValue = constants.SUPPORTED_HYBRID_PLATFORMS.indexOf(val); 206 | if (supportedValue === -1) { 207 | generator.env.error(`ERROR: Passed in unsupported platform - ${val}`); 208 | } 209 | 210 | return supportedValue !== -1; 211 | }); 212 | } 213 | 214 | 215 | function _getFilteredTestCommands(platforms) { 216 | // need to use filter and not map since the passed in content can 217 | // be a subset of TEST_COMMAND 218 | return TEST_COMMAND.filter(type => platforms.indexOf(type.platform) !== -1); 219 | } 220 | 221 | function _getPlatformTests(generator, platforms) { 222 | const platformTests = []; 223 | 224 | platforms.forEach((info) => { 225 | platformTests.push(_createPlatformTest(generator, info)); 226 | }); 227 | 228 | return platformTests; 229 | } 230 | 231 | function _createPlatformTest(generator, info) { 232 | return new Promise((resolve) => { 233 | generator.spawnCommand(info.testCommand, info.testCommandArgs, { stdio: ['pipe', 'ignore', 'pipe'] }) 234 | .on('exit', (err) => { 235 | if (err) { 236 | // note as mentioned just resolve 237 | resolve(); 238 | } 239 | 240 | resolve(info.platform); 241 | }) 242 | .on('error', () => { 243 | // intentionally resolve it since these are tests and want to proceed through 244 | // all the promises 245 | resolve(); 246 | }); 247 | }); 248 | } 249 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@oracle/generator-oraclejet", 3 | "version": "6.2.0", 4 | "license": "UPL-1.0", 5 | "description": "Yeoman generator for Oracle JET web and mobile applications", 6 | "homepage": "http://oraclejet.org", 7 | "keywords": [ 8 | "yeoman-generator" 9 | ], 10 | "main": "common/index.js", 11 | "files": [ 12 | "RELEASENOTES.md", 13 | "generators", 14 | "common", 15 | "util", 16 | "hybrid", 17 | "template" 18 | ], 19 | "dependencies": { 20 | "yeoman-generator": "^0.24.1", 21 | "adm-zip": "~0.4.7", 22 | "fs-extra": "^1.0.0", 23 | "xmldom": "^0.1.27", 24 | "request": "^2.79.0" 25 | }, 26 | "engines": { 27 | "node": ">=3.0.0" 28 | }, 29 | "devDependencies": { 30 | "eslint": "~3.19.0", 31 | "grunt-eslint": "^19.0.0", 32 | "grunt": "^1.0.1", 33 | "grunt-contrib-clean": "^1.0.0", 34 | "grunt-contrib-copy": "^1.0.0", 35 | "grunt-download": "^0.2.0", 36 | "grunt-mkdir": "^1.0.0", 37 | "grunt-mocha-test": "^0.13.2", 38 | "grunt-zip": "^0.17.1", 39 | "load-grunt-configs": "^1.0.0", 40 | "load-grunt-tasks": "^3.5.2", 41 | "minimatch": "~3.0.3", 42 | "node-sass": "4.7.2", 43 | "yeoman-assert": "^2.1.1", 44 | "yeoman-test": "^1.5.1" 45 | }, 46 | "preferGlobal": true 47 | } 48 | -------------------------------------------------------------------------------- /template/common/Gruntfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | var path = require('path'); 8 | 9 | module.exports = function(grunt) { 10 | 11 | require('load-grunt-config')(grunt, { 12 | configPath: path.join(process.cwd(), 'scripts/grunt/config') 13 | }); 14 | 15 | grunt.loadNpmTasks("@oracle/grunt-oraclejet"); 16 | 17 | grunt.registerTask("build", "Public task. Calls oraclejet-build to build the oraclejet application. Can be customized with additional build tasks.", function (buildType) { 18 | grunt.task.run([`oraclejet-build:${buildType}`]); 19 | }); 20 | 21 | grunt.registerTask("serve", "Public task. Calls oraclejet-serve to serve the oraclejet application. Can be customized with additional serve tasks.", function (buildType) { 22 | grunt.task.run([`oraclejet-serve:${buildType}`]); 23 | }); 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /template/common/_gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /bower_components 3 | /web 4 | /themes 5 | 6 | /hybrid/node_modules 7 | /hybrid/platforms 8 | /hybrid/www/* 9 | 10 | !hybrid/plugins 11 | hybrid/plugins/* 12 | !hybrid/plugins/fetch.json 13 | 14 | .DS_Store 15 | Thumbs.db -------------------------------------------------------------------------------- /template/common/oraclejetconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "paths": { 3 | "source": { 4 | "common": "src", 5 | "web": "src-web", 6 | "hybrid": "src-hybrid", 7 | "javascript": "js", 8 | "styles": "css", 9 | "themes": "themes", 10 | "tests": "tests" 11 | }, 12 | 13 | "staging": { 14 | "web": "web", 15 | "hybrid": "hybrid", 16 | "themes": "themes" 17 | } 18 | }, 19 | 20 | "defaultBrowser": "chrome" 21 | } 22 | -------------------------------------------------------------------------------- /template/common/scripts/config/oraclejet-build.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | /** 7 | * # oraclejet-build.js 8 | * This script allows users to configure and customize the grunt build tasks. 9 | * Configurable tasks include: 10 | * copySrcToStaging 11 | * copyCustomLibsToStaging 12 | * injectTheme 13 | * injectPaths 14 | * uglify 15 | * requireJs 16 | * sass 17 | * To configure a task, uncomment the corresponding sections below, and pass in your configurations. 18 | * Any options will be merged with default configuration found in node_modules/@oracle/oraclejet-tooling/lib/defaultconfig.js 19 | * Any fileList options will replace the corresponding option defined by the default configuration in its entirety - ie. arrays are not merged. 20 | */ 21 | 22 | module.exports = function () { 23 | return { 24 | 25 | /** 26 | * # copyCustomLibsToStaging 27 | * This task copies any custom libraries that are not provided by JET to staging directory. 28 | * This task supports a single option: fileList. The fileList option defines an array of file objects. 29 | * Each file object contains the following properties: 30 | * cwd, current working directory 31 | * dest, destination path 32 | * src, array of source file patterns 33 | * rename, function to return the full path of desired destination 34 | * If a fileList value is specified, it completely replaces the default fileList value defined by JET 35 | * Example: {cwd: 'app', src: ['**', '!test.js'], dest: 'staging', rename: function (dest, file) {return renamed path}} 36 | */ 37 | // copyCustomLibsToStaging: { 38 | // fileList: [ 39 | // { 40 | // cwd:'node_modules/oraclejet/', 41 | // src: ['*'], 42 | // dest: 'web/js/libs/oraclejet' 43 | // } 44 | // ] 45 | // } 46 | 47 | /** 48 | * # copySrcToStaging 49 | * This task copies all source files and libraries to staging directory. 50 | * This task supports a single option: fileList. The fileList option defines an array of file objects. 51 | * See descriptions and example in copyCustomLibsToStaging for configuring the fileList. 52 | */ 53 | // copySrcToStaging: { 54 | // fileList: [], 55 | // }, 56 | 57 | /** 58 | * # injectTheme 59 | * This task injects css stylesheet links for the current theme into index.html using the injection start and end markers defined below. 60 | */ 61 | // injectTheme: { 62 | // startTag: '', 63 | // endTag: '' 64 | // } 65 | 66 | /** 67 | * # injectPaths 68 | * Configuration for path injection during build in release mode 69 | * This task reads the release paths from the mainReleasePaths json file and injects the path configuration in main.js when run in release mode. 70 | */ 71 | // injectPaths: paths => ({ 72 | // startTag: '//injector:mainReleasePaths', 73 | // endTag: '//endinjector', 74 | // mainJs: 'path to mainjs', 75 | // destMainJs: 'path to the inject destination', 76 | // mainReleasePaths: 'path to the main-release-paths.json' 77 | // }), 78 | 79 | /** 80 | * # uglify 81 | * This task minifies source files and libraries that don't have minified distributions. 82 | * It runs only when build in release mode. Support input of fileList that contains an array of file objects. 83 | * See the example in copyCustomLibsToStaging for configuring the fileList. 84 | * See detailed uglify options at https://github.com/mishoo/UglifyJS 85 | */ 86 | // uglify: { 87 | // fileList: [{}], 88 | // options: {} 89 | // }, 90 | 91 | /** 92 | * # requireJs 93 | * This task runs requirejs optimizer to bundle all scripts in to a large minified main.js for release. 94 | * It runs only when build in release mode. 95 | * The task mirrors the configuration in this link https://github.com/gruntjs/grunt-contrib-requirejs 96 | */ 97 | // requireJs: { 98 | // baseUrl: 'path to the js directory in staging area', 99 | // name: 'the main.js file name', 100 | // mainConfigFile: `the main configuration file`, 101 | // optimize: 'option for optimize', 102 | // out: 'output file path' 103 | // }, 104 | 105 | /** 106 | * # sass 107 | * This task runs sass compile for scss files. 108 | * It takes a fileList as input, see copyCustomLibsToStaging section for examples of fileList 109 | * See detailed node sass options available here https://github.com/sass/node-sass 110 | */ 111 | // sass: { 112 | // fileList: [], 113 | // options: {} 114 | // }, 115 | 116 | /** 117 | * This is the web specific configuration. You can specify configurations targeted only for web apps. 118 | * The web specific configurations will override the general configuration. 119 | */ 120 | web: { 121 | // copyCustomLibsToStaging: { 122 | // fileList: [ 123 | // { 124 | // cwd:'node_modules/oraclejet/', 125 | // src: ['*'], 126 | // dest: 'web/js/libs/oraclejet' 127 | // } 128 | // ] 129 | // } 130 | }, 131 | 132 | /** 133 | * This is the hybrid specific configuration. You can specify configurations targeted only hybrid apps. 134 | * The hybrid specific configurations will override the general configuration. 135 | */ 136 | hybrid: { 137 | // copyCustomLibsToStaging: { 138 | // fileList: [ 139 | // { 140 | // cwd:'node_modules/oraclejet/', 141 | // src: ['*'], 142 | // dest: 'hybrid/www/js/libs/oraclejet' 143 | // } 144 | // ] 145 | // } 146 | } 147 | }; 148 | }; 149 | -------------------------------------------------------------------------------- /template/common/scripts/config/oraclejet-serve.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | /** 7 | * # oraclejet-serve.js 8 | * This script allows users to configure and customize the grunt serve tasks. 9 | * Configurable tasks: connect, watch. 10 | * To configure a task, uncomment the corresponding sections below, and pass in your configurations. 11 | * Any options will be merged with default configuration found in node_modules/@oracle/oraclejet-tooling/lib/defaultconfig.js 12 | * Any fileList will replace the default configuration. 13 | */ 14 | 15 | module.exports = function () { 16 | return { 17 | /** 18 | * # watch 19 | * This task watches a set of files and defines a series of customizable tasks if a change is detected. 20 | * Within the watch task config, by default there are three targets, sourceFiles, sass, themes. 21 | * Users are encouraged to edit or add their own watch targets, be careful if rewrite the three default targets. 22 | * Within each watch target, users can specify three properties. 23 | * 1. The files entry takes a list of glob patterns that identifies the set of files to watch 24 | * 2. The options.livereload specifies a boolean that indicates whether the browser should reload when files in this target are modified. 25 | * 3. The options.tasks property specifies custom commands to run. 'compileSass' and 'copyThemes' are reserved internal tasks. 26 | * Example commands: ['grunt copy', 'mocha test]. Once a change is detected, it will run grunt copy followed by mocha test 27 | * once the custom tasks completed, tooling will reload the browser if liverealod is set to true, then resume watching 28 | */ 29 | // // Sub task watch default options 30 | // watch: { 31 | // sourceFiles: 32 | // { 33 | // files: [], 34 | // options: { 35 | // livereload: true 36 | // } 37 | // }, 38 | 39 | // sass: { 40 | // files: [], 41 | // commands: ['compileSass'] 42 | // }, 43 | 44 | // themes: { 45 | // files: [], 46 | // options: { 47 | // livereload: true 48 | // }, 49 | // commands: ['copyThemes'] 50 | // }, 51 | // } 52 | 53 | /** 54 | * This is the web specific configuration. You can specify configurations targeted only for web apps. 55 | * The web specific configurations will override the general configuration. 56 | */ 57 | web: { 58 | /** 59 | * # connect 60 | * This task launches a web server for web App, does not work for hybrid App. 61 | * Support five connect options: 62 | * port, port number, default 8000 63 | * hostname, a string of the domain name, default localhost 64 | * livereload, a boolean for livereload, default true in dev mode, false in release mode (overwritten when ) 65 | * open, a boolean for wheather to launch browser, default to true 66 | * base, a string of the target directory to be served, default to the staging area 67 | */ 68 | // connect: { 69 | // options: {} 70 | // }, 71 | }, 72 | 73 | /** 74 | * This is the hybrid specific configuration. You can specify configurations targeted only for hybrid apps. 75 | * The hybrid specific configurations will override the general configuration. 76 | */ 77 | hybrid: { 78 | } 79 | }; 80 | }; 81 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/after_app_create.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | module.exports = function () { 8 | return new Promise((resolve) => { 9 | console.log('Running after_app_create hook.'); 10 | resolve(); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/after_app_restore.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | module.exports = function () { 8 | return new Promise((resolve) => { 9 | console.log('Running after_app_restore hook.'); 10 | resolve(); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/after_build.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running after_build hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/after_component_build.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running after_component_build hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/after_component_create.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | module.exports = function () { 8 | return new Promise((resolve) => { 9 | console.log('Running after_component_create hook.'); 10 | resolve(); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/after_serve.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running after_serve hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/before_build.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running before_build hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/before_hybrid_build.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running before_hybrid_build hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/before_release_build.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running before_release_build hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/before_serve.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (configObj) { 9 | return new Promise((resolve, reject) => { 10 | console.log("Running before_serve hook."); 11 | resolve(); 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /template/common/scripts/hooks/hooks.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "OJET-CLI hooks configuration file", 3 | "hooks": { 4 | "after_app_create": "scripts/hooks/after_app_create.js", 5 | "after_app_restore": "scripts/hooks/after_app_restore.js", 6 | "after_component_create": "scripts/hooks/after_component_create.js", 7 | "before_build": "scripts/hooks/before_build.js", 8 | "before_release": "scripts/hooks/before_release.js", 9 | "after_build": "scripts/hooks/after_build.js", 10 | "after_component_build": "scripts/hooks/after_component_build.js", 11 | "before_hybrid_build": "scripts/hooks/before_hybrid_build.js", 12 | "before_release_build": "scripts/hooks/before_release_build.js", 13 | "before_serve": "scripts/hooks/before_serve.js", 14 | "after_serve": "scripts/hooks/after_serve.js" 15 | } 16 | } -------------------------------------------------------------------------------- /template/component/@component@-styles.css: -------------------------------------------------------------------------------- 1 | @component@:not(.oj-complete){ 2 | visibility: hidden; 3 | } 4 | 5 | @component@{ 6 | min-height: 50px; 7 | width: 50px; 8 | } -------------------------------------------------------------------------------- /template/component/@component@-view.html: -------------------------------------------------------------------------------- 1 | 5 |

-------------------------------------------------------------------------------- /template/component/@component@-viewModel.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | define( 7 | ['knockout', 'jquery', 'ojL10n!./resources/nls/@component@-strings'], function (ko, $, componentStrings) { 8 | 9 | function ExampleComponentModel(context) { 10 | var self = this; 11 | 12 | //At the start of your viewModel constructor 13 | var busyContext = oj.Context.getContext(context.element).getBusyContext(); 14 | var options = {"description": "CCA Startup - Waiting for data"}; 15 | self.busyResolve = busyContext.addBusyState(options); 16 | 17 | self.composite = context.element; 18 | 19 | //Example observable 20 | self.messageText = ko.observable('Hello from Example Component'); 21 | self.properties = context.properties; 22 | self.res = componentStrings['@component@']; 23 | // Example for parsing context properties 24 | // if (context.properties.name) { 25 | // parse the context properties here 26 | // } 27 | 28 | //Once all startup and async activities have finished, relocate if there are any async activities 29 | self.busyResolve(); 30 | }; 31 | 32 | //Lifecycle methods - uncomment and implement if necessary 33 | //ExampleComponentModel.prototype.activated = function(context){ 34 | //}; 35 | 36 | //ExampleComponentModel.prototype.connected = function(context){ 37 | //}; 38 | 39 | //ExampleComponentModel.prototype.bindingsApplied = function(context){ 40 | //}; 41 | 42 | //ExampleComponentModel.prototype.disconnect = function(context){ 43 | //}; 44 | 45 | //ExampleComponentModel.prototype.propertyChanged = function(context){ 46 | //}; 47 | 48 | return ExampleComponentModel; 49 | }); -------------------------------------------------------------------------------- /template/component/README.md: -------------------------------------------------------------------------------- 1 | # ojet component template 2 | 3 | ## Usage 4 | Refer to the oj.Composite jsdoc 5 | http://www.oracle.com/webfolder/technetwork/jet/jsdocs/oj.Composite.html -------------------------------------------------------------------------------- /template/component/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@component@", 3 | "version": "1.0.0", 4 | "jetVersion": "^6.2.0", 5 | "displayName": "A user friendly, translatable name of the pack.", 6 | "description": "A translatable high-level description for the pack.", 7 | "properties": { 8 | 9 | }, 10 | "methods": { 11 | 12 | }, 13 | "events": { 14 | 15 | }, 16 | "slots": { 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /template/component/loader.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | define(['ojs/ojcomposite', 'text!./@component@-view.html', './@component@-viewModel', 'text!./component.json', 'css!./@component@-styles'], 6 | function(Composite, view, viewModel, metadata) { 7 | Composite.register('@component@', { 8 | view: view, 9 | viewModel: viewModel, 10 | metadata: JSON.parse(metadata) 11 | }); 12 | } 13 | ); -------------------------------------------------------------------------------- /template/component/resources/nls/@component@-strings.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | define({ 6 | "root": { 7 | "@component@" : { 8 | "sampleString": "The strings file can be used to manage translatable resources" 9 | } 10 | } 11 | }); -------------------------------------------------------------------------------- /template/test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | Oracle JET Starter QUnit - Common Composite Component 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | 32 |

Composite Component Tests

33 | 34 |

35 |
36 |

37 |
    38 |
    39 | 40 |
    41 | 42 |
    43 | 44 | 57 | 58 |
    59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /template/test/js/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | requirejs.config( 8 | { 9 | baseUrl : '../../js', 10 | // Path mappings for the logical module names 11 | paths : 12 | { 13 | 'knockout' : 'libs/knockout/knockout-3.4.2.debug', 14 | 'jquery' : 'libs/jquery/jquery-3.3.1', 15 | 'jqueryui-amd' : 'libs/jquery/jqueryui-amd-1.12.1', 16 | 'promise' : 'libs/es6-promise/es6-promise', 17 | 'hammerjs' : 'libs/hammer/hammer-2.0.8', 18 | 'ojdnd' : 'libs/dnd-polyfill/dnd-polyfill-1.0.0', 19 | 'ojs' : 'libs/oj/v6.2.0/debug', 20 | 'ojL10n' : 'libs/oj/v6.2.0/ojL10n', 21 | 'ojtranslations' : 'libs/oj/v6.2.0/resources', 22 | 'text' : 'libs/require/text', 23 | 'css' : 'libs/require-css/css', 24 | 'signals' : 'libs/js-signals/signals', 25 | 'touchr' : 'libs/touchr/touchr', 26 | 'persist': 'libs/persist/debug', 27 | 'customElements': 'libs/webcomponents/custom-elements.min', 28 | 'test' : '../tests/js/test', 29 | } 30 | , 31 | // Shim configurations for modules that do not expose AMD 32 | shim : 33 | { 34 | 'jquery' : 35 | { 36 | exports : ['jQuery', '$'] 37 | }, 38 | 'simulate' : 39 | { 40 | deps : ['jquery'] 41 | }, 42 | 'test' : 43 | { 44 | deps : ['jquery', 'knockout', 'ojs/ojcore', 'ojs/ojknockout', 'ojs/ojcomponentcore'] 45 | } 46 | } 47 | } 48 | ); 49 | 50 | require(['ojs/ojcore', 'knockout', 'ojs/ojknockout', 'test'], 51 | function (oj, ko) 52 | { 53 | $(function () 54 | { 55 | QUnit.load(); 56 | QUnit.start(); 57 | }); 58 | } 59 | ); 60 | -------------------------------------------------------------------------------- /template/test/js/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | (function ($) 6 | { 7 | QUnit.module("composite component"); 8 | QUnit.test("example test", function (assert) 9 | { 10 | var done = assert.async(); 11 | assert.expect(1); 12 | assert.ok(true); 13 | done(); 14 | }); 15 | })(jQuery); -------------------------------------------------------------------------------- /test/commonTest.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | var env = process.env, 6 | assert = require('assert'), 7 | path = require('path'), 8 | exec = require('child_process').exec, 9 | execOptions = { 10 | cwd:path.resolve('./dist/generator-oraclejet') 11 | }; 12 | 13 | describe("Example Test", function() 14 | { 15 | it("basic example", function() 16 | { 17 | var foo = "bar"; 18 | assert.equal(foo, 'bar','foo equals to bar'); 19 | }); 20 | }); 21 | 22 | describe("Npm Packages", function() 23 | { 24 | it("check yeoman plugin is installed", function(done) 25 | { 26 | this.timeout(30000); 27 | exec('npm list', execOptions, function(error, stdout) 28 | { 29 | assert.equal( 30 | stdout.indexOf('yeoman-generator') > -1, 31 | true, 32 | 'yeoman installed' + stdout 33 | ); 34 | done(); 35 | }); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /test/hybridTest.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | /** 6 | Copyright (c) 2015, 2017, Oracle and/or its affiliates. 7 | The Universal Permissive License (UPL), Version 1.0 8 | */ 9 | var env = process.env, 10 | assert = require('assert'), 11 | fs = require('fs-extra'), 12 | path = require('path'), 13 | hybridDirectory = "hybrid", 14 | exec = require('child_process').exec, 15 | util = require('./util'), 16 | execOptions = 17 | { 18 | cwd: path.resolve('test_result/test/generator/test') 19 | }; 20 | 21 | var filelist; 22 | var hybridFileList; 23 | var testDir = path.resolve('test_result/test/generator/test/hybridTest'); 24 | var hybridTestDir = path.resolve('test_result/test/generator/test/hybridTest/' + hybridDirectory); 25 | var utilDir = path.resolve('test_result/test/generator/util/hybrid'); 26 | var platform = util.getPlatform(env.OS); 27 | 28 | describe("Hybrid Test", function () 29 | { 30 | 31 | before(function(){ 32 | console.log(testDir); 33 | fs.ensureDirSync(testDir); 34 | fs.emptyDirSync(testDir); 35 | }); 36 | 37 | describe("Scaffold", function(){ 38 | 39 | it("Generate android/ios app", function (done) 40 | { 41 | var timeOutLimit = util.isNoRestoreTest() ? 320000 : 520000; 42 | this.timeout(timeOutLimit); 43 | var command = 'yo @oracle/oraclejet:hybrid hybridTest --template=navbar --appid=my.id --appName=testcase --platforms=' + platform; 44 | command = util.isNoRestoreTest() ? command + ' --norestore' : command; 45 | 46 | exec(command, execOptions, function (error, stdout) 47 | { 48 | filelist = fs.readdirSync(testDir); 49 | hybridFileList = fs.readdirSync(hybridTestDir); 50 | assert.equal(util.norestoreSuccess(stdout) || /Your app is/.test(stdout), true, error); 51 | done(); 52 | }); 53 | }); 54 | }); 55 | 56 | describe("Run Tests", function(){ 57 | 58 | it("Copy npm modules", function(done){ 59 | this.timeout(200000); 60 | //copy Npm and bower modules 61 | if (util.isNoRestoreTest()){ 62 | fs.copy(utilDir, testDir, function(err){ 63 | done(); 64 | }); 65 | } else { 66 | done(); 67 | } 68 | }); 69 | 70 | describe("Invalid arugments & Check error messages", function () { 71 | 72 | it("complain generating app to non-empty appDir", function (done) 73 | { 74 | this.timeout(300000); 75 | exec('yo @oracle/oraclejet:hybrid hybridTest --platforms=' + platform, execOptions, function (error, stdout) 76 | { 77 | var errLogCorrect = /path already exists/.test(error.message); 78 | assert.equal(errLogCorrect, true, error); 79 | done(); 80 | }); 81 | }); 82 | 83 | it("complain about unsupported platform android1", function (done) 84 | { 85 | this.timeout(150000); 86 | exec('grunt build --force=true --platform=' + 'android1', {cwd: testDir}, function (error, stdout) 87 | { 88 | 89 | var errLogCorrect = /Invalid platform/i.test(stdout); 90 | assert.equal(errLogCorrect, true, stdout); 91 | done(); 92 | }); 93 | }); 94 | 95 | it("complain about unsupported server port", function (done) 96 | { 97 | this.timeout(20000); 98 | exec('grunt serve --force=true --platform=' + platform + ' --server-port=' + '12we', {cwd: testDir,}, function (error, stdout) 99 | { 100 | 101 | var errLogCorrect = /not valid/.test(stdout); 102 | assert.equal(errLogCorrect, true, stdout); 103 | done(); 104 | }); 105 | }); 106 | 107 | it("complain about unsupported build argument", function (done) 108 | { 109 | this.timeout(150000); 110 | exec('grunt build:xyz --force=true --platform=' + platform, {cwd: testDir}, function (error, stdout) 111 | { 112 | 113 | var errLogCorrect = /buildType xyz is invalid/.test(stdout); 114 | assert.equal(errLogCorrect, true, stdout); 115 | done(); 116 | }); 117 | }); 118 | }); 119 | 120 | describe("Build", function () 121 | { 122 | it("Grunt build android/ios --force=true", function (done) 123 | { 124 | this.timeout(2400000); 125 | exec('grunt build --platform=' + platform, {cwd: testDir, maxBuffer: 1024 * 20000 }, function (error, stdout) 126 | { 127 | assert.equal(util.buildSuccess(stdout), true, error); 128 | done(); 129 | }); 130 | }); 131 | 132 | it("Grunt build android/ios for device", function (done) 133 | { 134 | this.timeout(2400000); 135 | exec(`grunt build --platform=${platform} --destination=device --force=true`, {cwd: testDir, maxBuffer: 1024 * 20000 }, function (error, stdout) 136 | { 137 | assert.equal(util.buildSuccess(stdout), true, error); 138 | done(); 139 | }); 140 | }); 141 | }); 142 | 143 | describe("Check essential files", function () 144 | { 145 | it("config.xml exists and is correct", function () 146 | { 147 | filelist = fs.readdirSync(testDir); 148 | hybridFileList = fs.readdirSync(hybridTestDir); 149 | var inlist = hybridFileList.indexOf("config.xml") > -1; 150 | assert.equal(inlist, true, path.resolve(hybridTestDir, 'config.xml') + " missing"); 151 | if (inlist) { 152 | // Check contents of config.xml 153 | var configRead = fs.readFileSync(path.resolve(hybridTestDir, 'config.xml'), "utf-8"); 154 | assert.equal(configRead.indexOf("testcase") > -1, true, "config.xml missing "); 155 | assert.equal(configRead.indexOf('id="my.id"') > -1, true, "config.xml missing correct id value"); 156 | } 157 | }); 158 | 159 | it("package.json exists", function () 160 | { 161 | var inlist = filelist.indexOf("package.json") > -1; 162 | assert.equal(inlist, true, path.resolve(testDir, 'package.json') + " missing"); 163 | }); 164 | 165 | it(".gitignore exists", function () 166 | { 167 | var inlist = filelist.indexOf(".gitignore") > -1; 168 | assert.equal(inlist, true, path.resolve(testDir, '.gitignore') + " missing"); 169 | }); 170 | 171 | if (platform == 'android') 172 | { 173 | it(".apk exists", function () 174 | { 175 | var apkList = fs.readdirSync(path.resolve(testDir, hybridDirectory, 'platforms/android/build/outputs/apk')); 176 | var inlist = false; 177 | apkList.forEach(function (value) 178 | { 179 | inlist = inlist || /.apk/.test(value); 180 | }); 181 | assert.equal(inlist, true, path.resolve(testDir, hybridDirectory, 'platforms/android/build/outputs/apk', 'android.apk') + " missing"); 182 | }); 183 | } 184 | 185 | }); 186 | }); 187 | 188 | describe("serve", () => { 189 | it("Grunt serve android/ios without platform", function (done) 190 | { 191 | this.timeout(2400000); 192 | const cmd = 'grunt serve --force=true'; 193 | exec(cmd, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:100000, killSignal:'SIGTERM' }, function (error, stdout) 194 | { 195 | assert.equal((util.noError(stdout) || /Build SUCCEEDED/.test(stdout) || /Deploying to /.test(stdout)), true, stdout); 196 | done(); 197 | }); 198 | }); 199 | }); 200 | 201 | describe("add-sass", () => { 202 | it("add sass generator", function (done) 203 | { 204 | this.timeout(2400000); 205 | exec(`yo @oracle/oraclejet:add-sass`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:200000, killSignal:'SIGTERM' }, function (error, stdout) 206 | { 207 | assert.equal(/add-sass finished/.test(stdout) || /add-sass finished/.test(error), true, stdout); 208 | done(); 209 | }); 210 | }); 211 | }); 212 | 213 | describe("add-theme", () => { 214 | it("add add-theme generator", function (done) 215 | { 216 | this.timeout(2400000); 217 | exec(`yo @oracle/oraclejet:add-theme green`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:50000, killSignal:'SIGTERM' }, function (error, stdout) 218 | { 219 | assert.equal(util.noError(stdout), true, error); 220 | done(); 221 | }); 222 | }); 223 | }); 224 | 225 | describe("compile sass", () => { 226 | it("compile sass", function (done) 227 | { 228 | this.timeout(2400000); 229 | exec(`grunt build --theme=green`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:100000, killSignal:'SIGTERM' }, function (error, stdout) 230 | { 231 | assert.equal(util.noError(stdout) || /Cordova compile finished/.test(stdout), true, stdout); 232 | done(); 233 | }); 234 | }); 235 | }); 236 | 237 | describe("Clean hybridTest", function () { 238 | 239 | it("Kill adb process to release", function (done) { 240 | var killAdbCommand = util.isWindows(env.OS) ? "taskkill /IM adb.exe /T /F" : "killall adb.exe"; 241 | this.timeout(500); 242 | exec(killAdbCommand, execOptions, function (error, stdout) 243 | { 244 | done(); 245 | }); 246 | }); 247 | 248 | it("Clean cordova platform", function (done) { 249 | this.timeout(40000); 250 | exec("cordova platform remove " + platform, {cwd: hybridTestDir}, function (error, stdout) 251 | { 252 | done(); 253 | var success = error ? false : true; 254 | //assert.equal(success,true, error); 255 | }); 256 | }); 257 | 258 | it("Clean cordova platform try #2", function (done) { 259 | this.timeout(40000); 260 | exec("cordova platform remove " + platform, {cwd: hybridTestDir}, function (error, stdout) 261 | { 262 | done(); 263 | var success = error ? false : true; 264 | //assert.equal(success,true, error); 265 | }); 266 | }); 267 | 268 | it("Clean cordova ", function (done) { 269 | this.timeout(40000); 270 | exec("cordova clean", {cwd: hybridTestDir}, function (error, stdout) 271 | { 272 | done(); 273 | var success = error ? false : true; 274 | //assert.equal(success,true, error); 275 | }); 276 | }); 277 | 278 | it("Clean cordova try #2", function (done) { 279 | this.timeout(40000); 280 | exec("cordova clean", {cwd: hybridTestDir}, function (error, stdout) 281 | { 282 | done(); 283 | var success = error ? false : true; 284 | //assert.equal(success,true, error); 285 | }); 286 | }); 287 | }); 288 | }); -------------------------------------------------------------------------------- /test/util/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | //common helpers for generator tests 7 | var fs = require('fs-extra'); 8 | var path = require('path'); 9 | var net = require('net'); 10 | module.exports = { 11 | 12 | isSuccess: function _isSuccess(std) 13 | { 14 | return (std.indexOf("without errors") > -1 ? true : false); 15 | }, 16 | 17 | buildSuccess: function _isSuccess(std) 18 | { 19 | return (std.indexOf("BUILD SUCCE") > -1 || std.indexOf('Code signing') > -1 || std.indexOf("Code Sign") > -1); 20 | }, 21 | 22 | norestoreSuccess: function _yoSuccess(std) 23 | { 24 | return (std.indexOf("Oracle JET Error") > -1 ? false : true); 25 | }, 26 | noError: function _noError(std) 27 | { 28 | return !(/error/i.test(std)); 29 | }, 30 | bowerCopySuccess: function _bowerCopySuccess(std) 31 | { 32 | return (std.indexOf("All modules accounted") > -1 ? true : false); 33 | }, 34 | 35 | isWindows:function _isWindows(OS) 36 | { 37 | return /^Windows/.test(OS); 38 | }, 39 | 40 | getJetVersion: function _getJetVersion(filePath, file) 41 | { 42 | return fs.readdirSync(path.join(filePath,file)); 43 | }, 44 | 45 | getPlatform: function _getPlatform(OS) 46 | { 47 | var isWindows = /^Windows/.test(OS); 48 | return isWindows ? 'android' : 'ios'; 49 | }, 50 | 51 | isCheckedOut: function(std) 52 | { 53 | return (std.indexOf("Checked out revision") > -1 ? true : false); 54 | }, 55 | 56 | matchInArray: function(string, arrayOfStrings) 57 | { 58 | for (var i=0; i < arrayOfStrings.length; i++) 59 | { 60 | if (arrayOfStrings[i].match(new RegExp(string))) 61 | { 62 | return true; 63 | } 64 | } 65 | return false; 66 | }, 67 | 68 | isCordovaSuccess: function _isCordovaSuccess(std) 69 | { 70 | return (std.indexOf("BUILD SUCCESSFUL") > -1 ? true : false); 71 | }, 72 | 73 | isNoRestoreTest: function _isNoRestoreTest() 74 | { 75 | return process.env["expressTest"]==='true'; 76 | } 77 | 78 | }; 79 | -------------------------------------------------------------------------------- /test/webTest.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | /** 6 | Copyright (c) 2015, 2017, Oracle and/or its affiliates. 7 | The Universal Permissive License (UPL), Version 1.0 8 | */ 9 | var env = process.env, 10 | assert = require('assert'), 11 | fs = require('fs-extra'), 12 | path = require('path'), 13 | exec = require('child_process').exec, 14 | util = require('./util'), 15 | helpers = require('yeoman-test'), 16 | yoAssert = require('yeoman-assert'), 17 | execOptions = 18 | { 19 | cwd: path.resolve('test_result/test/generator/test/') 20 | }; 21 | 22 | var filelist; 23 | var testDir = path.resolve('test_result/test/generator/test', 'webTest'); 24 | var utilDir = path.resolve('test_result/test/generator/util/web'); 25 | 26 | describe("Web Test", function () 27 | { 28 | before(function(){ 29 | fs.ensureDirSync(testDir); 30 | fs.emptyDirSync(testDir); 31 | }); 32 | 33 | describe("Scaffold with norestore flag", function(){ 34 | 35 | it("Generate web app", function (done) 36 | { 37 | this.timeout(520000); 38 | exec('yo @oracle/oraclejet webTest --norestore=true', execOptions, function (error, stdout) 39 | { 40 | done(); 41 | assert.equal(util.norestoreSuccess(stdout), true, error); 42 | filelist = fs.readdirSync(testDir); 43 | }); 44 | }); 45 | }) 46 | 47 | describe("Run Tests", function(){ 48 | 49 | it("Copy npm and bower modules", function(done){ 50 | this.timeout(200000); 51 | //copy Npm and bower modules 52 | fs.copy(utilDir, testDir, function(err){ 53 | done(); 54 | }); 55 | }); 56 | 57 | describe("Check essential files", function (){ 58 | 59 | it("package.json exists", function () { 60 | var inlist = filelist.indexOf("package.json") > -1; 61 | assert.equal(inlist, true, path.resolve(testDir, 'package.json') + " missing"); 62 | }); 63 | 64 | it("Gruntfile.js exists", function () { 65 | var inlist = filelist.indexOf("Gruntfile.js") > -1; 66 | assert.equal(inlist, true, path.resolve(testDir, 'Gruntfile.js') + " missing"); 67 | }); 68 | 69 | it(".gitignore exists", function () 70 | { 71 | var inlist = filelist.indexOf(".gitignore") > -1; 72 | assert.equal(inlist, true, path.resolve(testDir, '.gitignore') + " missing"); 73 | }); 74 | 75 | }); 76 | 77 | describe('Extend to hybrid', function () { 78 | it('Add hybrid', function (done) { 79 | this.timeout(2400000); 80 | exec(`yo @oracle/oraclejet:add-hybrid --platform=${util.getPlatform(env.OS)}`, { cwd: testDir }, (error, stdout) => { 81 | filelist = fs.readdirSync(testDir); 82 | const inlist = filelist.indexOf('hybrid') > -1; 83 | assert.equal(inlist, true, `${testDir}/hybrid missing`); 84 | done(); 85 | }); 86 | }); 87 | }); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /util/constants.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | // constants to be used for the yeoman generator 8 | 9 | module.exports = { 10 | SUPPORTED_PLATFORMS: ['android', 'ios', 'windows', 'web'], 11 | SUPPORTED_HYBRID_PLATFORMS: ['android', 'ios', 'windows'], 12 | CORDOVA_CONFIG_XML: 'config.xml', 13 | DEFAULT_THEME: 'alta', 14 | APP_CONFIG_JSON: 'oraclejetconfig.json', 15 | JET_COMPOSITES: 'jet-composites', 16 | COMPONENT_FILES: ['component.json', 'loader.js', 'styles.css'], 17 | PATH_TO_HOOKS_CONFIG: 'scripts/hooks/hooks.json', 18 | APP_TYPE: 19 | { 20 | HYBRID: 'hybrid', 21 | WEB: 'web' 22 | }, 23 | 24 | SUPPORTED_FLAGS: (namespace) => { 25 | const systemFlags = [ 26 | 'env', 27 | 'resolved', 28 | 'namespace', 29 | 'help', 30 | 'argv', 31 | 'skip-cache', 32 | 'skip-install', 33 | 'app-name', 34 | 'app-id', 35 | 'insight', 36 | 'component', 37 | 'hybrid', 38 | 'platform', 39 | 'platforms', 40 | 'pack' 41 | ]; 42 | 43 | const hybridFlags = [ 44 | 'appid', 45 | 'appId', 46 | 'appname', 47 | 'appName', 48 | 'platform', 49 | 'platforms' 50 | ]; 51 | 52 | const appFlags = [ 53 | 'template', 54 | 'norestore' 55 | ]; 56 | 57 | const restoreFlags = [ 58 | 'invokedByRestore', 59 | ]; 60 | 61 | if (/hybrid/.test(namespace)) { 62 | // for hybrid and add-hybrid 63 | return systemFlags.concat(restoreFlags, hybridFlags, appFlags); 64 | } else if (/app/.test(namespace)) { 65 | // for app 66 | return systemFlags.concat(restoreFlags, appFlags); 67 | } else if (/restore/.test(namespace)) { 68 | // for restore 69 | return systemFlags.concat(restoreFlags, hybridFlags, appFlags); 70 | } 71 | // add-theme, add-sass, no supported flag 72 | return systemFlags.concat(restoreFlags); 73 | } 74 | }; 75 | -------------------------------------------------------------------------------- /util/fetchZip.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const Admzip = require('adm-zip'); 8 | const request = require('request'); 9 | 10 | module.exports = function (url) { 11 | // fetches the zip file 12 | return new Promise((resolve, reject) => { 13 | const data = []; 14 | let dataLen = 0; 15 | 16 | request.get({ url, encoding: null }).on('error', (err) => { 17 | reject(err); 18 | }).on('data', (block) => { 19 | data.push(block); 20 | dataLen += block.length; 21 | }).on('end', (err) => { 22 | if (err) { 23 | reject(err); 24 | } 25 | const buf = new Buffer(dataLen); 26 | 27 | for (let i = 0, len = data.length, pos = 0; i < len; i += 1) { 28 | data[i].copy(buf, pos); 29 | pos += data[i].length; 30 | } 31 | 32 | try { 33 | const zip = new Admzip(buf); 34 | resolve(zip); 35 | } catch (e) { 36 | reject(e); 37 | } 38 | }); 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /util/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const path = require('path'); 8 | const fs = require('fs-extra'); 9 | 10 | module.exports = 11 | { 12 | getDirectories(source) { 13 | // util function to get directories listing 14 | return fs.readdirSync(source).filter(file => 15 | fs.statSync(path.join(source, file)).isDirectory()); 16 | }, 17 | fsExistsSync(filePath) { 18 | try { 19 | fs.statSync(filePath); 20 | return true; 21 | } catch (err) { 22 | // file/directory does not exist 23 | return false; 24 | } 25 | } 26 | }; 27 | 28 | -------------------------------------------------------------------------------- /util/paths.js: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2015, 2019, Oracle and/or its affiliates. 3 | The Universal Permissive License (UPL), Version 1.0 4 | */ 5 | 'use strict'; 6 | 7 | const path = require('path'); 8 | const fs = require('fs-extra'); 9 | const constants = require('./constants'); 10 | const util = require('./index'); 11 | 12 | const _cachedPathsMap = {}; 13 | const _defaultPaths = _getDefaultPaths(); 14 | 15 | module.exports = 16 | { 17 | getConfiguredPaths(appDir) { 18 | let resultPaths = _cachedPathsMap[appDir]; 19 | if (!resultPaths) { 20 | resultPaths = _deriveConfiguredPaths(appDir); 21 | _cachedPathsMap[appDir] = resultPaths; 22 | } 23 | return resultPaths; 24 | }, 25 | 26 | getDefaultPaths() { 27 | return _defaultPaths; 28 | } 29 | }; 30 | 31 | function _deriveConfiguredPaths(appDir) { 32 | const configurePaths = {}; 33 | const conf = _getPathsFromOraclejetConfig(appDir); 34 | Object.defineProperty(configurePaths, 'source', _getValueObj(conf.source.common, _defaultPaths.source)); 35 | Object.defineProperty(configurePaths, 'sourceWeb', _getValueObj(conf.source.web, _defaultPaths.sourceWeb)); 36 | Object.defineProperty(configurePaths, 'sourceHybrid', _getValueObj(conf.source.hybrid, _defaultPaths.sourceHybrid)); 37 | Object.defineProperty(configurePaths, 'sourceJavascript', _getValueObj(conf.source.javascript, _defaultPaths.sourceJavascript)); 38 | Object.defineProperty(configurePaths, 'sourceTests', _getValueObj(conf.source.tests, _defaultPaths.sourceTests)); 39 | Object.defineProperty(configurePaths, 'sourceThemes', _getValueObj(conf.source.themes, _defaultPaths.sourceThemes)); 40 | Object.defineProperty(configurePaths, 'stagingHybrid', _getValueObj(conf.staging.hybrid, _defaultPaths.stagingHybrid)); 41 | Object.defineProperty(configurePaths, 'stagingWeb', _getValueObj(conf.staging.web, _defaultPaths.stagingWeb)); 42 | Object.defineProperty(configurePaths, 'stagingThemes', _getValueObj(conf.staging.themes, _defaultPaths.stagingThemes)); 43 | return configurePaths; 44 | } 45 | 46 | function _getDefaultPaths() { 47 | const defaultPaths = {}; 48 | Object.defineProperty(defaultPaths, 'source', _getValueObj('src')); 49 | Object.defineProperty(defaultPaths, 'sourceWeb', _getValueObj('src-web')); 50 | Object.defineProperty(defaultPaths, 'sourceHybrid', _getValueObj('src-hybrid')); 51 | Object.defineProperty(defaultPaths, 'sourceJavascript', _getValueObj('js')); 52 | Object.defineProperty(defaultPaths, 'sourceTests', _getValueObj('tests')); 53 | Object.defineProperty(defaultPaths, 'sourceThemes', _getValueObj('themes')); 54 | Object.defineProperty(defaultPaths, 'stagingHybrid', _getValueObj('hybrid')); 55 | Object.defineProperty(defaultPaths, 'stagingWeb', _getValueObj('web')); 56 | Object.defineProperty(defaultPaths, 'stagingThemes', _getValueObj('themes')); 57 | return defaultPaths; 58 | } 59 | 60 | function _getValueObj(value, defaultValue) { 61 | return { 62 | value: _normPath(value) || defaultValue, 63 | enumerable: true 64 | }; 65 | } 66 | 67 | function _normPath(rawValue) { 68 | return (rawValue) ? path.normalize(rawValue) : null; 69 | } 70 | 71 | function _getPathsFromOraclejetConfig(appDir) { 72 | const configJsonPath = path.resolve(appDir, constants.APP_CONFIG_JSON); 73 | const configJson = util.fsExistsSync(configJsonPath) ? fs.readJsonSync(configJsonPath) : null; 74 | return configJson.paths || {}; 75 | } 76 | --------------------------------------------------------------------------------