diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f4e653..efc4d1c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,11 +1,11 @@ -# Contributing to generator-oraclejet - -*Copyright (c) 2014, 2017 Oracle and/or its affiliates -The Universal Permissive License (UPL), Version 1.0* - -**Pull requests are currently not being accepted for the Oracle JET project.** - -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) -(OCA). - -If you have ideas, comments, or issues related to generator, swing on by the [Oracle JET discussion forum.](https://community.oracle.com/community/development_tools/oracle-jet/generators) +# Contributing to generator-oraclejet + +*Copyright (c) 2014, 2017 Oracle and/or its affiliates +The Universal Permissive License (UPL), Version 1.0* + +**Pull requests are currently not being accepted for the Oracle JET project.** + +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) +(OCA). + +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) diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..10d7a70 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,24 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +module.exports = function (grunt) { + grunt.initConfig({ + }); + + + // Load grunt tasks from NPM packages + require("load-grunt-tasks")(grunt); + + // Merge sub configs + var options = { + config : { + src : "build/generator.js" + }, + pkg: grunt.file.readJSON("package.json") + } + var configs = require('load-grunt-configs')(grunt, options); + grunt.config.merge(configs); + +}; + diff --git a/README.md b/README.md index 70c1b4f..c370916 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,18 @@ -# generator-oraclejet 3.2.0 - -## About the generator -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. - -This is an open source project maintained by Oracle Corp. - -## Installation -For step-by-step instructions on using Yeoman and this generator to build an Oracle JET application, including possible pre-requisites for installation, please see the [Oracle JET Developers Guide](http://docs.oracle.com/middleware/jet320/jet/) -```bash -npm install -g generator-oraclejet -``` - -## Usage -Once you have the generator installed, the following commands will scaffold up a JET based application. See the [Oracle JET Developers Guide](http://docs.oracle.com/middleware/jet320/jet/) for information about all of the available command line options as well as details on pre-requisites for installation. - -```bash -# Generate a web application with default blank template -yo oraclejet -``` -```bash -# Generate a web application with default basic template -yo oraclejet --template=basic -``` -```bash -# Generate a hybrid mobile application for Android with default navdrawer template -yo oraclejet:hybrid myApp --appid=com.oracle.samples.myapp --appname=MyApp --template=navdrawer --platform=android -``` - -## [Contributing](https://github.com/oracle/generator-oraclejet/tree/master/CONTRIBUTING.md) -Oracle JET is an open source project. Pull Requests are currently not being accepted. See -[CONTRIBUTING](https://github.com/oracle/generator-oraclejet/tree/master/CONTRIBUTING.md) -for details. - -## [License](https://github.com/oracle/generator-oraclejet/tree/master/LICENSE.md) -Copyright (c) 2014, 2017 Oracle and/or its affiliates -The Universal Permissive License (UPL), Version 1.0 \ No newline at end of file +# @oracle/generator-oraclejet 4.0.0 + +## About the generator +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. + +This is an open source project maintained by Oracle Corp. + +## Installation +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. + +## [Contributing](https://github.com/oracle/generator-oraclejet/tree/master/CONTRIBUTING.md) +Oracle JET is an open source project. Pull Requests are currently not being accepted. See +[CONTRIBUTING](https://github.com/oracle/generator-oraclejet/tree/master/CONTRIBUTING.md) +for details. + +## [License](https://github.com/oracle/generator-oraclejet/tree/master/LICENSE.md) +Copyright (c) 2014, 2017 Oracle and/or its affiliates +The Universal Permissive License (UPL), Version 1.0 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 67c0a96..4645f6d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,9 @@ ## Release Notes for generator-oraclejet ## +### 4.0.0 +* Moved module into @oracle scope, changing the name to @oracle/generator-oraclejet +* This module should no longer be installed directly. Use @oracle/ojet-cli instead for scaffolding JET apps. + ### 3.2.0 * No changes diff --git a/common/component.js b/common/component.js new file mode 100644 index 0000000..78f3ea8 --- /dev/null +++ b/common/component.js @@ -0,0 +1,64 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +'use strict'; + +const fs = require('fs-extra'); +const path = require('path'); +const CONSTANTS = require('../util/constants'); +const paths = require('../util/paths'); + +module.exports = +{ + writeComponentTemplate: function _writeComponentTemplate(generator) { + return new Promise((resolve) => { + if (generator.options.component) { + const templateSrc = path.join(generator.templatePath(), '../../../template/component'); + const isApp = fs.existsSync(path.join(process.cwd(), CONSTANTS.APP_CONFIG_JSON)) + || generator.appDir !== undefined; + + if (!isApp) return resolve(generator); + + const appDir = generator.appDir === undefined + ? process.cwd() : generator.destinationPath(generator.appDir); + + const _configPaths = generator.appDir === undefined + ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); + + const destDirectory = generator.destinationPath( + path.join(appDir, _configPaths.source, + _configPaths.sourceJavascript, CONSTANTS.JET_COMPOSITES, generator.options.component)); + + // avoid overwrite component + if (fs.existsSync(destDirectory)) { + console.log('Component already exists. '); + return resolve(generator); + } + fs.ensureDirSync(destDirectory); + fs.copySync(templateSrc, destDirectory); + _replaceComponentTemplateToken(generator); + } + + return resolve(generator); + }); + } +}; + +function _replaceComponentTemplateToken(generator) { + const componentName = generator.componentName || generator.options.component; + + const appDir = generator.appDir === undefined + ? process.cwd() : generator.destinationPath(generator.appDir); + + const _configPaths = generator.appDir === undefined + ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); + + const base = path.join(appDir, _configPaths.source, + _configPaths.sourceJavascript, CONSTANTS.JET_COMPOSITES, componentName); + + CONSTANTS.COMPONENT_FILES.forEach((file) => { + const fileContent = fs.readFileSync(path.join(base, file), 'utf-8'); + fs.outputFileSync(path.join(base, file), fileContent.replace(new RegExp('@component@', 'g'), componentName)); + }); +} diff --git a/common/index.js b/common/index.js index b91ce1b..9f250d0 100644 --- a/common/index.js +++ b/common/index.js @@ -50,7 +50,7 @@ module.exports = }, writeCommonTemplates: function _writeCommonTemplates(generator) { - const templateSrc = path.join(generator.templatePath(), '../../../template'); + const templateSrc = path.join(generator.templatePath(), '../../../template/common'); const templateDest = generator.destinationPath(); return new Promise((resolve, reject) => { @@ -89,6 +89,9 @@ module.exports = if (_fileNotHidden(filename)) { const error = `path already exists and is not empty: ${path.resolve(appDir)}`; reject(commonMessages.error(error, 'validateAppDir')); + } else if (filename === '.gitignore') { + const error = 'path already exists and contains a .gitignore file'; + reject(commonMessages.error(error, 'validateAppDir')); } }); resolve(appDir); @@ -173,6 +176,11 @@ function _handleAbsoluteOrMissingPath(generator) { function _updateJSONAppName(generator, jsonPath) { const json = fs.readJSONSync(generator.destinationPath(jsonPath)); - json.name = generator.options.appname; + // space in app name will result in npm install failure + json.name = _removeSpaceInAppName(generator.options.appname); fs.writeJSONSync(jsonPath, json); } + +function _removeSpaceInAppName(appName) { + return appName.replace(' ', '-'); +} diff --git a/common/messages.js b/common/messages.js index 4b4d015..4a5c758 100644 --- a/common/messages.js +++ b/common/messages.js @@ -35,7 +35,7 @@ function _getRestoreComplete(invokedByRestore, appDir) { if (invokedByRestore) { return _appendSuccessPrefix('Your app restore finished successfully...'); } - return _appendSuccessPrefix(`Your app is ready! Change to your new app directory ${appDir} and try grunt build and serve...`); + return _appendSuccessPrefix(`Your app is ready! Change to your new app directory ${appDir} and try ojet build and serve...`); } function _getPrefixError(error) { diff --git a/common/template/index.js b/common/template/index.js index a4d0a1d..a507fc2 100644 --- a/common/template/index.js +++ b/common/template/index.js @@ -9,7 +9,6 @@ const urlTemplate = require('./url'); const commonTemplate = require('./common'); const npmTemplate = require('./npm'); const localTemplate = require('./local'); -const commonMessages = require('../messages'); const path = require('path'); const util = require('../../util'); @@ -18,7 +17,7 @@ const _WEB = 'web'; const BLANK_TEMPLATE = blankTemplate.BLANK_TEMPLATE; -const _TEMPLATES_NPM_URL = 'oraclejet-templates@~3.2.0'; +const _TEMPLATES_NPM_URL = '@oracle/oraclejet-templates@~4.0.0'; const _TEMPLATES = [BLANK_TEMPLATE, 'basic', 'navbar', 'navdrawer']; @@ -29,11 +28,7 @@ module.exports = const template = generator.options.template || BLANK_TEMPLATE; generator.log('Processing template...', template); const templateHandler = _getHandler(generator, template, templateDestDirectory); - try { - return commonTemplate.handle(templateHandler); - } catch (err) { - return Promise.reject(commonMessages.error(err, 'processing template')); - } + return commonTemplate.handle(templateHandler); } }; diff --git a/common/template/npm.js b/common/template/npm.js index 2477e94..ecca7b4 100644 --- a/common/template/npm.js +++ b/common/template/npm.js @@ -39,7 +39,7 @@ module.exports = { */ function _copyNpmTemplate(yoGenerator, templateSpec, destination) { const templateRoot = path.join(yoGenerator.destinationPath(yoGenerator.appDir), - 'node_modules', 'oraclejet-templates'); + 'node_modules', '@oracle/oraclejet-templates'); const src = _getTemplateFromTypeSpecificDirectory(templateRoot, templateSpec) || _getTemplateFromGenericDirectory(templateRoot, templateSpec); diff --git a/common/test.js b/common/test.js new file mode 100644 index 0000000..ee9fb59 --- /dev/null +++ b/common/test.js @@ -0,0 +1,56 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +'use strict'; + +const fs = require('fs-extra'); +const path = require('path'); +const CONSTANTS = require('../util/constants'); +const paths = require('../util/paths'); + +module.exports = +{ + writeTestTemplate: function _writeTestTemplates(generator) { + return new Promise((resolve) => { + if (generator.options.component) { + const isApp = fs.existsSync(path.join(process.cwd(), CONSTANTS.APP_CONFIG_JSON)) + || generator.appDir !== undefined; + + if (!isApp) return resolve(generator); + + const appDir = generator.appDir === undefined + ? process.cwd() : generator.destinationPath(generator.appDir); + + const _configPaths = generator.appDir === undefined + ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); + + const templateSrc = path.join(generator.templatePath(), '../../../template/test'); + const destDirectory = generator.destinationPath( + path.join(appDir, _configPaths.source, _configPaths.sourceTests)); + + // avoid overwrite test + if (fs.existsSync(destDirectory)) resolve(generator); + + fs.ensureDirSync(destDirectory); + fs.copySync(templateSrc, destDirectory); + _replaceTestHTMLToken(generator); + } + return resolve(generator); + }); + }, +}; + +function _replaceTestHTMLToken(generator) { + const componentName = generator.componentName || generator.options.component; + + const appDir = generator.appDir === undefined + ? process.cwd() : generator.destinationPath(generator.appDir); + + const _configPaths = generator.appDir === undefined + ? paths.getConfiguredPaths(appDir) : paths.getDefaultPaths(); + + const htmlPath = path.join(appDir, _configPaths.source, _configPaths.sourceTests, 'index.html'); + const html = fs.readFileSync(htmlPath, 'utf-8'); + fs.outputFileSync(htmlPath, html.replace(new RegExp('@component@', 'g'), componentName)); +} diff --git a/config/eslintcustom.js b/config/eslintcustom.js deleted file mode 100644 index 63e9abf..0000000 --- a/config/eslintcustom.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - Copyright (c) 2015, 2017, Oracle and/or its affiliates. - The Universal Permissive License (UPL), Version 1.0 -*/ -// -// Custom eslint rules file, used to deal with linbreak-style -// -module.exports = { - "installedESLint": true, - "extends": "airbnb-base", - "plugins": [ - ], - "rules": { - "comma-dangle": "off", - "no-underscore-dangle": "off", - "vars-on-top": "off", - "func-names": "off", -// "linebreak-style": ["warn", "unix"], // currently evaluating this rule in the oraclejet-tooling repos. - "linebreak-style": ["error", "unix"], // currently evaluating this rule in the oraclejet-tooling repos. - "no-console" : "off", - "strict" : "off", - "import/no-unresolved" : [2, {ignore: ['oraclejet-tooling']}], // since oraclejet-tooling is defined as a url, we need it in the ignore list. - "no-use-before-define" : ["error", {"functions" : false, "classes" : true}], - "no-plusplus": ["off", {"allowForLoopAfterthoughts": true }] // allow ++ in loops - } -}; diff --git a/generators/add-component/index.js b/generators/add-component/index.js new file mode 100644 index 0000000..13efd67 --- /dev/null +++ b/generators/add-component/index.js @@ -0,0 +1,82 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ + +'use strict'; + +const generators = require('yeoman-generator'); +const common = require('../../common'); +const commonComponent = require('../../common/component'); +const commonMessages = require('../../common/messages'); +const commonTest = require('../../common/test'); +const fs2 = require('fs'); +const path = require('path'); +/* + * Generator for the add-component step + */ +const OracleJetAddComponentGenerator = generators.Base.extend( + { + initializing: function () { //eslint-disable-line + const done = this.async(); + common.validateArgs(this) + .then(common.validateFlags) + .then(() => { + done(); + }) + .catch((err) => { + this.env.error(commonMessages.prefixError(err)); + }); + }, + + constructor: function() { //eslint-disable-line + generators.Base.apply(this, arguments); //eslint-disable-line + try { + this.argument('componentName', { type: String, required: true }); + } catch (err) { + this.env.error('Missing component name.'); + } + _validateComponentName(this); + }, + + writing: function() { //eslint-disable-line + const done = this.async(); + this.options.component = this.componentName; + commonComponent.writeComponentTemplate(this) + .then(commonTest.writeTestTemplate) + .then(() => { + done(); + }) + .catch((err) => { + if (err) { + this.env.error(commonMessages.prefixError(err)); + } + }); + }, + + end: function() { //eslint-disable-line + const cwd = process.cwd(); + const isApp = fs2.existsSync(path.join(cwd, 'oraclejetconfig.json')); + if (!isApp) { + this.composeWith('@oracle/oraclejet:app', { options: this.options }); + } else { + console.log(commonMessages.appendJETPrefix(`add component ${this.componentName} finished.`)); + } + if (isApp) process.exit(1); + } + + }); + +module.exports = OracleJetAddComponentGenerator; + +function _validateComponentName(generator) { + const name = generator.componentName; + if (name !== name.toLowerCase() || name.indexOf('-') < 0 || !/^[a-z]/.test(name)) { + const message = 'Invalid component name. Must be all lowercase letters and contain at least one hyphen.'; + throw `\x1b[31m${new Error(message)}\x1b[0m`; //eslint-disable-line + } +} diff --git a/generators/add-sass/index.js b/generators/add-sass/index.js index 25da3aa..631140b 100644 --- a/generators/add-sass/index.js +++ b/generators/add-sass/index.js @@ -55,7 +55,7 @@ module.exports = OracleJetAddSassGenerator; function _npmInstallNodeSass(generator) { try { - generator.npmInstall(['node-sass@4.2.0'], { saveDev: true }); + generator.npmInstall(['node-sass@4.5.3'], { saveDev: true }); return Promise.resolve(generator); } catch (err) { return Promise.reject(commonMessages.error(err, 'install node-sass')); diff --git a/generators/add-theme/index.js b/generators/add-theme/index.js index 77bf15d..07fa5ed 100644 --- a/generators/add-theme/index.js +++ b/generators/add-theme/index.js @@ -13,7 +13,7 @@ const paths = require('../../util/paths'); const commonMessages = require('../../common/messages'); const DEFAULT_THEME = 'mytheme'; -const JET_SCSS_SRC_PATH = 'node_modules/oraclejet/dist/scss'; +const JET_SCSS_SRC_PATH = 'node_modules/@oracle/oraclejet/dist/scss'; const PLATFORM_TOKEN = '<%= platform %>'; const JET_VERSION_TOKEN = '<%= jetversion %>'; const THEMENAME_TOKEN = '<%= themename %>'; @@ -135,7 +135,7 @@ function _isValidThemeName(string) { } function _getJetVersion(generator) { - let packageJSON = generator.destinationPath('node_modules/oraclejet/package.json'); + let packageJSON = generator.destinationPath('node_modules/@oracle/oraclejet/package.json'); packageJSON = fs.readJsonSync(packageJSON); return packageJSON.version; } @@ -192,7 +192,7 @@ function _copySettingsFilesFromJETSrc(themeName, dest) { return [ { str: new RegExp('@import\ \"\.\.\/utilities', 'g'), //eslint-disable-line - newStr: '@import "../../../../node_modules/oraclejet/dist/scss/utilities', + newStr: '@import "../../../../node_modules/@oracle/oraclejet/dist/scss/utilities', }, { str: new RegExp('.*\\$themeName.*'), diff --git a/generators/add-theme/templates/mytheme/android/_mytheme.android.overrides.scss b/generators/add-theme/templates/mytheme/android/_mytheme.android.overrides.scss deleted file mode 100644 index 7ed2e7e..0000000 --- a/generators/add-theme/templates/mytheme/android/_mytheme.android.overrides.scss +++ /dev/null @@ -1,2 +0,0 @@ -// NOTE: JET component dom and/or selector names can change between releases, -// so each time JET is updated any overrides must be rechecked. \ No newline at end of file diff --git a/generators/add-theme/templates/mytheme/android/mytheme.scss b/generators/add-theme/templates/mytheme/android/mytheme.scss index a98990d..de86865 100644 --- a/generators/add-theme/templates/mytheme/android/mytheme.scss +++ b/generators/add-theme/templates/mytheme/android/mytheme.scss @@ -5,17 +5,9 @@ // the custom variable file must be imported before the platform theme // aggregating file (where the platform variable file will be imported). // 2. platform theme aggregating file -// 3. custom override file(s): In case of specificity equality -// the last declaration found in the CSS file wins, so you want -// your overrides imported last so they have higher specificity. - //import custom variable overrides @import "<%= themename %>.android.settings"; // import alta-android aggregating file -@import "../../../../node_modules/oraclejet/dist/scss/alta-android/oj-alta"; - -// import custom css overrides -@import "<%= themename %>.android.overrides"; - +@import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta-android/oj-alta"; diff --git a/generators/add-theme/templates/mytheme/ios/_mytheme.ios.overrides.scss b/generators/add-theme/templates/mytheme/ios/_mytheme.ios.overrides.scss deleted file mode 100644 index 7ed2e7e..0000000 --- a/generators/add-theme/templates/mytheme/ios/_mytheme.ios.overrides.scss +++ /dev/null @@ -1,2 +0,0 @@ -// NOTE: JET component dom and/or selector names can change between releases, -// so each time JET is updated any overrides must be rechecked. \ No newline at end of file diff --git a/generators/add-theme/templates/mytheme/ios/mytheme.scss b/generators/add-theme/templates/mytheme/ios/mytheme.scss index b75f9b7..0cf3c24 100644 --- a/generators/add-theme/templates/mytheme/ios/mytheme.scss +++ b/generators/add-theme/templates/mytheme/ios/mytheme.scss @@ -5,17 +5,9 @@ // the custom variable file must be imported before the platform theme // aggregating file (where the platform variable file will be imported). // 2. platform theme aggregating file -// 3. custom override file(s): In case of specificity equality -// the last declaration found in the CSS file wins, so you want -// your overrides imported last so they have higher specificity. - //import custom variable overrides @import "<%= themename %>.ios.settings"; // import alta-ios aggregating file -@import "../../../../node_modules/oraclejet/dist/scss/alta-ios/oj-alta"; - -// import custom css overrides -@import "<%= themename %>.ios.overrides"; - +@import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta-ios/oj-alta"; diff --git a/generators/add-theme/templates/mytheme/web/_mytheme.web.overrides.scss b/generators/add-theme/templates/mytheme/web/_mytheme.web.overrides.scss deleted file mode 100644 index 7ed2e7e..0000000 --- a/generators/add-theme/templates/mytheme/web/_mytheme.web.overrides.scss +++ /dev/null @@ -1,2 +0,0 @@ -// NOTE: JET component dom and/or selector names can change between releases, -// so each time JET is updated any overrides must be rechecked. \ No newline at end of file diff --git a/generators/add-theme/templates/mytheme/web/mytheme.scss b/generators/add-theme/templates/mytheme/web/mytheme.scss index 9554ed2..924f421 100644 --- a/generators/add-theme/templates/mytheme/web/mytheme.scss +++ b/generators/add-theme/templates/mytheme/web/mytheme.scss @@ -5,16 +5,9 @@ // the custom variable file must be imported before the platform theme // aggregating file (where the platform variable file will be imported). // 2. platform theme aggregating file -// 3. custom override file(s): In case of specificity equality -// the last declaration found in the CSS file wins, so you want -// your overrides imported last so they have higher specificity. //import custom variable overrides @import "<%= themename %>.web.settings"; // import alta aggregating file -@import "../../../../node_modules/oraclejet/dist/scss/alta/oj-alta"; - -// import custom css overrides -@import "<%= themename %>.web.overrides"; - +@import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta/oj-alta"; diff --git a/generators/add-theme/templates/mytheme/windows/_mytheme.windows.overrides.scss b/generators/add-theme/templates/mytheme/windows/_mytheme.windows.overrides.scss deleted file mode 100644 index 7ed2e7e..0000000 --- a/generators/add-theme/templates/mytheme/windows/_mytheme.windows.overrides.scss +++ /dev/null @@ -1,2 +0,0 @@ -// NOTE: JET component dom and/or selector names can change between releases, -// so each time JET is updated any overrides must be rechecked. \ No newline at end of file diff --git a/generators/add-theme/templates/mytheme/windows/mytheme.scss b/generators/add-theme/templates/mytheme/windows/mytheme.scss index 825f68a..3e6cfb8 100644 --- a/generators/add-theme/templates/mytheme/windows/mytheme.scss +++ b/generators/add-theme/templates/mytheme/windows/mytheme.scss @@ -5,17 +5,9 @@ // the custom variable file must be imported before the platform theme // aggregating file (where the platform variable file will be imported). // 2. platform theme aggregating file -// 3. custom override file(s): In case of specificity equality -// the last declaration found in the CSS file wins, so you want -// your overrides imported last so they have higher specificity. - //import custom variable overrides @import "<%= themename %>.windows.settings"; // import alta-windows aggregating file -@import "../../../../node_modules/oraclejet/dist/scss/alta-windows/oj-alta"; - -// import custom css overrides -@import "<%= themename %>.windows.overrides"; - +@import "../../../../node_modules/@oracle/oraclejet/dist/scss/alta-windows/oj-alta"; diff --git a/generators/app/index.js b/generators/app/index.js index def1862..07d8ec0 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -6,7 +6,9 @@ const generators = require('yeoman-generator'); const common = require('../../common'); +const commonComponent = require('../../common/component'); const commonMessages = require('../../common/messages'); +const commonTest = require('../../common/test'); const templateHandler = require('../../common/template'); const path = require('path'); @@ -19,6 +21,9 @@ const OracleJetWebCreateGenerator = generators.Base.extend( { initializing: function () { //eslint-disable-line const done = this.async(); + if (this.options.component) { + this.appDir = this.options.component; + } common.validateArgs(this) .then(common.validateFlags) .then(common.validateAppDirNotExistsOrIsEmpty) @@ -67,16 +72,21 @@ const OracleJetWebCreateGenerator = generators.Base.extend( }) .catch((err) => { if (err) { - self.env.error(commonMessages.prefixError(err)); + self.log.error(err); + process.exit(1); } }); }, end: function () { //eslint-disable-line - this.log(commonMessages.scaffoldComplete()); + if (this.options.component) { + this.log(`Oracle JET: Your component ${this.options.component} project is scaffolded. Performing npm install may take a bit...`); + } else { + this.log(commonMessages.scaffoldComplete()); + } if (!this.options.norestore) { - this.composeWith('oraclejet:restore-web', { options: this.options }); + this.composeWith('@oracle/oraclejet:restore-web', { options: this.options }); } } }); @@ -88,11 +98,13 @@ function _writeTemplate(generator) { const appDirectory = generator.destinationPath(path.join(generator.appDir, 'src')); templateHandler.handleTemplate(generator, appDirectory) + .then(commonComponent.writeComponentTemplate) + .then(commonTest.writeTestTemplate) .then(() => { resolve(generator); }) .catch((err) => { - reject(commonMessages.error(err, 'writeTemplate')); + reject(err); }); }); } diff --git a/generators/app/templates/blank/css/override.css b/generators/app/templates/blank/css/override.css deleted file mode 100644 index 519f1a8..0000000 --- a/generators/app/templates/blank/css/override.css +++ /dev/null @@ -1,7 +0,0 @@ -/* - Document : override - Created on : - Author : - Description: - This is where any of your application specific styles should be included -*/ \ No newline at end of file diff --git a/generators/app/templates/blank/index.html b/generators/app/templates/blank/index.html index feea98c..fc66fc4 100644 --- a/generators/app/templates/blank/index.html +++ b/generators/app/templates/blank/index.html @@ -32,16 +32,13 @@ - + - - - - - + + diff --git a/generators/app/templates/blank/js/main-release-paths.json b/generators/app/templates/blank/js/main-release-paths.json index e657cf0..7bfc927 100644 --- a/generators/app/templates/blank/js/main-release-paths.json +++ b/generators/app/templates/blank/js/main-release-paths.json @@ -5,12 +5,12 @@ "promise": "libs/es6-promise/es6-promise.min", "hammerjs": "libs/hammer/hammer-2.0.8.min", "ojdnd": "libs/dnd-polyfill/dnd-polyfill-1.0.0.min", - "ojs": "libs/oj/v3.2.0/min", - "ojL10n": "libs/oj/v3.2.0/ojL10n", - "ojtranslations": "libs/oj/v3.2.0/resources", + "ojs": "libs/oj/v4.0.0/min", + "ojL10n": "libs/oj/v4.0.0/ojL10n", + "ojtranslations": "libs/oj/v4.0.0/resources", "text": "libs/require/text", "signals": "libs/js-signals/signals.min", - "customElements": "libs/webcomponents/CustomElements.min", + "customElements": "libs/webcomponents/custom-elements.min", "proj4": "libs/proj4js/dist/proj4", "css": "libs/require-css/css.min" } \ No newline at end of file diff --git a/generators/app/templates/blank/js/main.js b/generators/app/templates/blank/js/main.js index 3ededfd..5b9f59a 100644 --- a/generators/app/templates/blank/js/main.js +++ b/generators/app/templates/blank/js/main.js @@ -9,58 +9,56 @@ */ requirejs.config( -{ - baseUrl: 'js', - - // Path mappings for the logical module names - // Update the main-release-paths.json for release mode when updating the mappings - paths: - //injector:mainReleasePaths - { - 'knockout': 'libs/knockout/knockout-3.4.0.debug', - 'jquery': 'libs/jquery/jquery-3.1.1', - 'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.0', - 'promise': 'libs/es6-promise/es6-promise', - 'hammerjs': 'libs/hammer/hammer-2.0.8', - 'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0', - 'ojs': 'libs/oj/v3.2.0/debug', - 'ojL10n': 'libs/oj/v3.2.0/ojL10n', - 'ojtranslations': 'libs/oj/v3.2.0/resources', - 'text': 'libs/require/text', - 'signals': 'libs/js-signals/signals', - 'customElements': 'libs/webcomponents/CustomElements', - 'proj4': 'libs/proj4js/dist/proj4-src', - 'css': 'libs/require-css/css' - } - //endinjector - , - // Shim configurations for modules that do not expose AMD - shim: { - 'jquery': + baseUrl: 'js', + + // Path mappings for the logical module names + // Update the main-release-paths.json for release mode when updating the mappings + paths: + //injector:mainReleasePaths + { + 'knockout': 'libs/knockout/knockout-3.4.0.debug', + 'jquery': 'libs/jquery/jquery-3.1.1', + 'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.0', + 'promise': 'libs/es6-promise/es6-promise', + 'hammerjs': 'libs/hammer/hammer-2.0.8', + 'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0', + 'ojs': 'libs/oj/v4.0.0/debug', + 'ojL10n': 'libs/oj/v4.0.0/ojL10n', + 'ojtranslations': 'libs/oj/v4.0.0/resources', + 'text': 'libs/require/text', + 'signals': 'libs/js-signals/signals', + 'customElements': 'libs/webcomponents/custom-elements.min', + 'proj4': 'libs/proj4js/dist/proj4-src', + 'css': 'libs/require-css/css' + } + //endinjector + , + + // Shim configurations for modules that do not expose AMD + shim: { - exports: ['jQuery', '$'] + 'jquery': + { + exports: ['jQuery', '$'] + } } } -} ); require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout'], - function(oj, ko, $) - { - $(function() - { + function (oj, ko, $) { + $(function () { function init() { } - - // If running in a hybrid (e.g. Cordova) environment, we need to wait for the deviceready + + // If running in a hybrid (e.g. Cordova) environment, we need to wait for the deviceready // event before executing any code that might interact with Cordova APIs or plugins. if ($(document.body).hasClass('oj-hybrid')) { - document.addEventListener("deviceready", init); + document.addEventListener('deviceready', init); } else { init(); } - }); } ); diff --git a/generators/app/templates/common/package.json b/generators/app/templates/common/package.json index f1efd5e..1ea0e56 100644 --- a/generators/app/templates/common/package.json +++ b/generators/app/templates/common/package.json @@ -1,19 +1,17 @@ { "name": "oraclejet-app", "version": "1.0.0", - "description": "A sample Oracle JavaScript Extension Toolkit (JET) web app", - "author": { - "name": "Oracle Jet Team", - "homepage": "http://www.oraclejet.org" - }, + "description": "An Oracle JavaScript Extension Toolkit(JET) web app", "dependencies": { - "oraclejet": "~3.2.0" + "@oracle/oraclejet": "~4.0.0" }, "devDependencies": { "grunt": "^1.0.1", - "grunt-oraclejet": "~3.2.0", + "@oracle/grunt-oraclejet": "~4.0.0", "load-grunt-config": "0.19.2", - "oraclejet-tooling": "~3.2.0" + "@oracle/oraclejet-tooling": "~4.0.0", + "qunit-reporter-junit": "^1.1.1", + "qunitjs": "^2.3.3" }, "engines": { "node": ">=0.10.0" diff --git a/generators/hybrid/index.js b/generators/hybrid/index.js index 5e267db..034df20 100644 --- a/generators/hybrid/index.js +++ b/generators/hybrid/index.js @@ -10,7 +10,9 @@ const path = require('path'); const templateHandler = require('../../common/template/'); const common = require('../../common'); const commonHybrid = require('../../hybrid'); +const commonComponent = require('../../common/component'); const commonMessages = require('../../common/messages'); +const commonTest = require('../../common/test'); const cordovaHelper = require('../../hybrid/cordova'); const platformsHelper = require('../../hybrid/platforms'); @@ -59,6 +61,9 @@ const OracleJetHybridCreateGenerator = generators.Base.extend( initializing: function () { //eslint-disable-line const done = this.async(); + if (this.options.component) { + this.appDir = this.options.component; + } common.validateArgs(this) .then(common.validateFlags) .then(common.validateAppDirNotExistsOrIsEmpty) @@ -85,7 +90,6 @@ const OracleJetHybridCreateGenerator = generators.Base.extend( writing: function () { //eslint-disable-line const done = this.async(); - _writeTemplate(this) .then(common.switchToAppDirectory.bind(this)) .then(common.writeCommonTemplates) @@ -101,15 +105,21 @@ const OracleJetHybridCreateGenerator = generators.Base.extend( }) .catch((err) => { if (err) { - this.env.error(commonMessages.prefixError(err)); + this.log.error(err); + process.exit(1); } }); }, end() { - this.log(commonMessages.scaffoldComplete()); + if (this.options.component) { + this.log(`Oracle JET: Your component ${this.options.component} project is scaffolded. Performing npm install may take a bit...`); + } else { + this.log(commonMessages.scaffoldComplete()); + } + if (!this.options.norestore) { - this.composeWith('oraclejet:restore-hybrid', { options: this.options }); + this.composeWith('@oracle/oraclejet:restore-hybrid', { options: this.options }); } } }); @@ -122,11 +132,13 @@ function _writeTemplate(generator) { const appSrc = paths.getDefaultPaths().source; templateHandler.handleTemplate(generator, generator.destinationPath(`${appDir}/${appSrc}/`)) + .then(commonComponent.writeComponentTemplate) + .then(commonTest.writeTestTemplate) .then(() => { resolve(generator); }) .catch((err) => { - reject(commonMessages.error(err, 'writeTemplate')); + reject(err); }); }); } diff --git a/generators/hybrid/templates/blank/css/override.css b/generators/hybrid/templates/blank/css/override.css deleted file mode 100644 index 519f1a8..0000000 --- a/generators/hybrid/templates/blank/css/override.css +++ /dev/null @@ -1,7 +0,0 @@ -/* - Document : override - Created on : - Author : - Description: - This is where any of your application specific styles should be included -*/ \ No newline at end of file diff --git a/generators/hybrid/templates/blank/index.html b/generators/hybrid/templates/blank/index.html index 9538037..140902f 100644 --- a/generators/hybrid/templates/blank/index.html +++ b/generators/hybrid/templates/blank/index.html @@ -30,11 +30,8 @@ - + - - - diff --git a/generators/hybrid/templates/blank/js/main-debug-paths-windows.json b/generators/hybrid/templates/blank/js/main-debug-paths-windows.json deleted file mode 100644 index 68c4f54..0000000 --- a/generators/hybrid/templates/blank/js/main-debug-paths-windows.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "knockout": "libs/knockout/knockout-3.4.0.debug", - "jquery": "libs/jquery/jquery-3.1.1", - "jqueryui-amd": "libs/jquery/jqueryui-amd-1.12.0", - "promise": "libs/es6-promise/es6-promise", - "hammerjs": "libs/hammer/hammer-2.0.8", - "ojdnd": "libs/dnd-polyfill/dnd-polyfill-1.0.0", - "ojs": "libs/oj/v3.2.0/debug", - "ojL10n": "libs/oj/v3.2.0/ojL10n", - "ojtranslations": "libs/oj/v3.2.0/resources", - "ojtranslations/nls/ojtranslations": "libs/oj/v3.2.0/resources/root/ojtranslations", - "ojtranslations/nls/localeElements": "libs/oj/v3.2.0/resources/root/localeElements", - "ojtranslations/nls/timezoneData": "libs/oj/v3.2.0/resources/root/timezoneData", - "text": "libs/require/text", - "signals": "libs/js-signals/signals", - "customElements": "libs/webcomponents/CustomElements.min", - "proj4": "libs/proj4js/dist/proj4", - "css": "libs/require-css/css.min" -} diff --git a/generators/hybrid/templates/blank/js/main-release-paths-windows.json b/generators/hybrid/templates/blank/js/main-release-paths-windows.json deleted file mode 100644 index a828b87..0000000 --- a/generators/hybrid/templates/blank/js/main-release-paths-windows.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "knockout": "libs/knockout/knockout-3.4.0", - "jquery": "libs/jquery/jquery-3.1.1.min", - "jqueryui-amd": "libs/jquery/jqueryui-amd-1.12.0.min", - "promise": "libs/es6-promise/es6-promise.min", - "hammerjs": "libs/hammer/hammer-2.0.8.min", - "ojdnd": "libs/dnd-polyfill/dnd-polyfill-1.0.0.min", - "ojs": "libs/oj/v3.2.0/min", - "ojL10n": "libs/oj/v3.2.0/ojL10n", - "ojtranslations": "libs/oj/v3.2.0/resources", - "ojtranslations/nls/ojtranslations": "libs/oj/v3.2.0/resources/root/ojtranslations", - "ojtranslations/nls/localeElements": "libs/oj/v3.2.0/resources/root/localeElements", - "ojtranslations/nls/timezoneData": "libs/oj/v3.2.0/resources/root/timezoneData", - "text": "libs/require/text", - "signals": "libs/js-signals/signals.min", - "customElements": "libs/webcomponents/CustomElements.min", - "proj4": "libs/proj4js/dist/proj4", - "css": "libs/require-css/css.min" -} diff --git a/generators/hybrid/templates/blank/js/main-release-paths.json b/generators/hybrid/templates/blank/js/main-release-paths.json index e657cf0..7bfc927 100644 --- a/generators/hybrid/templates/blank/js/main-release-paths.json +++ b/generators/hybrid/templates/blank/js/main-release-paths.json @@ -5,12 +5,12 @@ "promise": "libs/es6-promise/es6-promise.min", "hammerjs": "libs/hammer/hammer-2.0.8.min", "ojdnd": "libs/dnd-polyfill/dnd-polyfill-1.0.0.min", - "ojs": "libs/oj/v3.2.0/min", - "ojL10n": "libs/oj/v3.2.0/ojL10n", - "ojtranslations": "libs/oj/v3.2.0/resources", + "ojs": "libs/oj/v4.0.0/min", + "ojL10n": "libs/oj/v4.0.0/ojL10n", + "ojtranslations": "libs/oj/v4.0.0/resources", "text": "libs/require/text", "signals": "libs/js-signals/signals.min", - "customElements": "libs/webcomponents/CustomElements.min", + "customElements": "libs/webcomponents/custom-elements.min", "proj4": "libs/proj4js/dist/proj4", "css": "libs/require-css/css.min" } \ No newline at end of file diff --git a/generators/hybrid/templates/blank/js/main.js b/generators/hybrid/templates/blank/js/main.js index 8f25e97..672a3ca 100644 --- a/generators/hybrid/templates/blank/js/main.js +++ b/generators/hybrid/templates/blank/js/main.js @@ -12,10 +12,10 @@ requirejs.config( { baseUrl: 'js', - // Path mappings for the logical module names - // Update the main-release-paths.json for release mode when updating the mappings + // Path mappings for the logical module names + // Update the main-release-paths.json for release mode when updating the mappings paths: - //injector:mainReleasePaths + //injector:mainReleasePaths { 'knockout': 'libs/knockout/knockout-3.4.0.debug', 'jquery': 'libs/jquery/jquery-3.1.1', @@ -23,18 +23,18 @@ requirejs.config( 'promise': 'libs/es6-promise/es6-promise', 'hammerjs': 'libs/hammer/hammer-2.0.8', 'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0', - 'ojs': 'libs/oj/v3.2.0/debug', - 'ojL10n': 'libs/oj/v3.2.0/ojL10n', - 'ojtranslations': 'libs/oj/v3.2.0/resources', + 'ojs': 'libs/oj/v4.0.0/debug', + 'ojL10n': 'libs/oj/v4.0.0/ojL10n', + 'ojtranslations': 'libs/oj/v4.0.0/resources', 'text': 'libs/require/text', 'signals': 'libs/js-signals/signals', - 'customElements': 'libs/webcomponents/CustomElements', + 'customElements': 'libs/webcomponents/custom-elements.min', 'proj4': 'libs/proj4js/dist/proj4-src', 'css': 'libs/require-css/css' } //endinjector , - // Shim configurations for modules that do not expose AMD + // Shim configurations for modules that do not expose AMD shim: { jquery: @@ -46,10 +46,8 @@ requirejs.config( ); require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout'], - function(oj, ko, $) - { - $(function() - { + function (oj, ko, $) { + $(function () { function init() { } diff --git a/generators/hybrid/templates/common/package.json b/generators/hybrid/templates/common/package.json index 955f24c..cc3cf1e 100644 --- a/generators/hybrid/templates/common/package.json +++ b/generators/hybrid/templates/common/package.json @@ -1,20 +1,18 @@ { "name": "oraclejet-app", "version": "1.0.0", - "description": "A sample Oracle JavaScript Extension Toolkit (JET) mobile app based on Cordova", - "author": { - "name": "Oracle Jet Team", - "homepage": "http://www.oraclejet.org" - }, + "description": "An Oracle JavaScript Extension Toolkit (JET) mobile app", "dependencies": { - "oraclejet": "~3.2.0" + "@oracle/oraclejet": "~4.0.0" }, "devDependencies": { "fs-extra": "0.30.0", "grunt": "^1.0.1", - "grunt-oraclejet": "~3.2.0", + "@oracle/grunt-oraclejet": "~4.0.0", "load-grunt-config": "0.19.2", - "oraclejet-tooling": "~3.2.0" + "@oracle/oraclejet-tooling": "~4.0.0", + "qunit-reporter-junit": "^1.1.1", + "qunitjs": "^2.3.3" }, "engines": { "node": ">=0.10.0" diff --git a/generators/restore-hybrid/index.js b/generators/restore-hybrid/index.js index 99ee877..db0d9fc 100644 --- a/generators/restore-hybrid/index.js +++ b/generators/restore-hybrid/index.js @@ -69,6 +69,7 @@ function _invokeCordovaPrepare(context) { if (!generator.options.invokedByRestore) return Promise.resolve(context); const cwd = paths.getConfiguredPaths(generator.destinationPath()).stagingHybrid; fs.ensureDirSync(path.join(cwd, 'www')); + console.log('Restoring hybrid plugins and platforms....'); return new Promise((resolve, reject) => { const cmd = 'cordova prepare'; diff --git a/generators/restore/index.js b/generators/restore/index.js index cf67e16..dc910f2 100644 --- a/generators/restore/index.js +++ b/generators/restore/index.js @@ -31,7 +31,7 @@ const OracleJetRestoreGenerator = generators.Base.extend( this.options.invokedByRestore = true; this.composeWith( - `oraclejet:restore-${restoreType}`, + `@oracle/oraclejet:restore-${restoreType}`, { options: this.options, arguments: this.arguments }); } }); diff --git a/hybrid/index.js b/hybrid/index.js index 33bb92f..a6e182a 100644 --- a/hybrid/index.js +++ b/hybrid/index.js @@ -71,9 +71,8 @@ module.exports = const generator = context.generator || context; const source = generator.templatePath('../../hybrid/templates/common/res'); const dest = _getHybridPath(generator, 'res/'); - + fs.emptyDirSync(dest); return new Promise((resolve, reject) => { - // do not overwrite existing icons fs.copy(source, dest, { overwrite: false }, (err) => { if (err) { reject(err); @@ -92,7 +91,7 @@ module.exports = try { const configRead = fs.readFileSync(configXml, 'utf-8'); const document = new DOMParser().parseFromString(configRead, 'text/xml'); - _addCordovaConfigDescriptionAndAuthor(document); + _addCordovaConfigDescription(document); _addCordovaConfigHooks(document); _addIosOrientationPreference(document); _addIosOverscrollPreference(document); @@ -111,7 +110,7 @@ module.exports = copyHooks(context) { // 'Generator' may be passed as {generator: generator} or {generator} const generator = context.generator || context; - const source = generator.destinationPath('node_modules/oraclejet-tooling/hooks/'); + const source = generator.destinationPath('node_modules/@oracle/oraclejet-tooling/hooks/'); const dest = _getHybridPath(generator, 'scripts/hooks/'); return new Promise((resolve, reject) => { @@ -124,7 +123,7 @@ module.exports = resolve(context); }); } else { - reject('Missing folder \'oraclejet-tooling/hooks/\'.'); + reject('Missing folder \'@oracle/oraclejet-tooling/hooks/\'.'); } }); } @@ -151,21 +150,12 @@ function _getAppBaseName(appDir) { } -function _addCordovaConfigDescriptionAndAuthor(document) { +function _addCordovaConfigDescription(document) { const widget = _getFirstElementByTagName(document, 'widget'); const packageJSON = fs.readJSONSync(path.resolve('package.json')); - _updateCordovaConfigAuthor(widget, packageJSON); _updateCordovaConfigDescription(widget, packageJSON); } -function _updateCordovaConfigAuthor(widget, packageJSON) { - const author = packageJSON.author; - const authorElement = _getFirstElementByTagName(widget, 'author'); - authorElement.childNodes[0].data = `\n ${author.name}\n `; - authorElement.setAttribute('email', author.email); - authorElement.setAttribute('href', author.homepage); -} - function _updateCordovaConfigDescription(widget, packageJSON) { const description = packageJSON.description; const descriptionElement = _getFirstElementByTagName(widget, 'description'); diff --git a/package.json b/package.json index 3c2e93b..8a85795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "generator-oraclejet", - "version": "3.2.0", + "name": "@oracle/generator-oraclejet", + "version": "4.0.0", "license": "UPL-1.0", "description": "Yeoman generator for Oracle JET web and mobile applications", "homepage": "http://oraclejet.org", @@ -27,7 +27,7 @@ "node": ">=3.0.0" }, "devDependencies": { - "eslint": "^3.11.0", + "eslint": "~3.19.0", "grunt-eslint": "^19.0.0", "grunt": "^1.0.1", "grunt-contrib-clean": "^1.0.0", @@ -38,11 +38,12 @@ "grunt-zip": "^0.17.1", "load-grunt-configs": "^1.0.0", "load-grunt-tasks": "^3.5.2", + "minimatch": "~3.0.3", "node-sass": "^4.2.0", "yeoman-assert": "^2.1.1", "yeoman-test": "^1.5.1" }, "preferGlobal": true, - "jetversion": "3.2.0", - "jetdocversion": "320" + "jetversion": "4.0.0", + "jetdocversion": "400" } diff --git a/template/Gruntfile.js b/template/common/Gruntfile.js similarity index 94% rename from template/Gruntfile.js rename to template/common/Gruntfile.js index cb9d8df..c9d12f1 100644 --- a/template/Gruntfile.js +++ b/template/common/Gruntfile.js @@ -12,7 +12,7 @@ module.exports = function(grunt) { configPath: path.join(process.cwd(), 'scripts/grunt/config') }); - grunt.loadNpmTasks("grunt-oraclejet"); + grunt.loadNpmTasks("@oracle/grunt-oraclejet"); grunt.registerTask("build", "Public task. Calls oraclejet-build to build the oraclejet application. Can be customized with additional build tasks.", function (buildType) { grunt.task.run([`oraclejet-build:${buildType}`]); diff --git a/template/_gitignore b/template/common/_gitignore similarity index 65% rename from template/_gitignore rename to template/common/_gitignore index 2dbca92..52d7e11 100644 --- a/template/_gitignore +++ b/template/common/_gitignore @@ -1,8 +1,9 @@ -node_modules/* -bower_components/* +/node_modules +/bower_components /web /themes - + +/hybrid/node_modules /hybrid/platforms /hybrid/www/* diff --git a/template/oraclejetconfig.json b/template/common/oraclejetconfig.json similarity index 73% rename from template/oraclejetconfig.json rename to template/common/oraclejetconfig.json index 1c07bf4..cb326bc 100644 --- a/template/oraclejetconfig.json +++ b/template/common/oraclejetconfig.json @@ -6,15 +6,16 @@ "hybrid": "src-hybrid", "javascript": "js", "styles": "css", - "themes": "themes" + "themes": "themes", + "tests": "tests" }, "staging": { "web": "web", "hybrid": "hybrid", "themes": "themes" - }, - - "defaultBrowser": "chrome" - } + } + }, + + "defaultBrowser": "chrome" } diff --git a/template/scripts/grunt/config/oraclejet-build.js b/template/common/scripts/config/oraclejet-build.js similarity index 97% rename from template/scripts/grunt/config/oraclejet-build.js rename to template/common/scripts/config/oraclejet-build.js index a4ee0e3..e4677b2 100644 --- a/template/scripts/grunt/config/oraclejet-build.js +++ b/template/common/scripts/config/oraclejet-build.js @@ -2,6 +2,7 @@ Copyright (c) 2015, 2017, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ +'use strict'; /** * # oraclejet-build.js * This script allows users to configure and customize the grunt build tasks. @@ -14,11 +15,11 @@ * requireJs * sass * To configure a task, uncomment the corresponding sections below, and pass in your configurations. - * Any options will be merged with default configuration found in node_modules/oraclejet-tooling/lib/defaultconfig.js + * Any options will be merged with default configuration found in node_modules/@oracle/oraclejet-tooling/lib/defaultconfig.js * Any fileList options will replace the corresponding option defined by the default configuration in its entirety - ie. arrays are not merged. */ -module.exports = function (grunt) { +module.exports = function () { return { /** diff --git a/template/scripts/grunt/config/oraclejet-serve.js b/template/common/scripts/config/oraclejet-serve.js similarity index 97% rename from template/scripts/grunt/config/oraclejet-serve.js rename to template/common/scripts/config/oraclejet-serve.js index 88f6a58..431860f 100644 --- a/template/scripts/grunt/config/oraclejet-serve.js +++ b/template/common/scripts/config/oraclejet-serve.js @@ -2,12 +2,13 @@ Copyright (c) 2015, 2017, Oracle and/or its affiliates. The Universal Permissive License (UPL), Version 1.0 */ +'use strict'; /** * # oraclejet-serve.js * This script allows users to configure and customize the grunt serve tasks. * Configurable tasks: connect, watch. * To configure a task, uncomment the corresponding sections below, and pass in your configurations. - * Any options will be merged with default configuration found in node_modules/oraclejet-tooling/lib/defaultconfig.js + * Any options will be merged with default configuration found in node_modules/@oracle/oraclejet-tooling/lib/defaultconfig.js * Any fileList will replace the default configuration. */ diff --git a/template/component/README.md b/template/component/README.md new file mode 100644 index 0000000..d93da49 --- /dev/null +++ b/template/component/README.md @@ -0,0 +1,5 @@ +# ojet component template + +## Usage +Refer to the oj.Composite jsdoc +http://www.oracle.com/webfolder/technetwork/jet/jsdocs/oj.Composite.html \ No newline at end of file diff --git a/template/component/component.json b/template/component/component.json new file mode 100644 index 0000000..c5fe54a --- /dev/null +++ b/template/component/component.json @@ -0,0 +1,18 @@ +{ + "name": "@component@", + "displayName": "@component@", + "description": "Describe your component here", + "version": "1.0.0", + "jetVersion": "^4.0.0", + "properties": { + }, + "methods": { + + }, + "events": { + + }, + "slots": { + + } +} \ No newline at end of file diff --git a/template/component/loader.js b/template/component/loader.js new file mode 100644 index 0000000..ad7df91 --- /dev/null +++ b/template/component/loader.js @@ -0,0 +1,13 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +define(['ojs/ojcore', 'text!./view.html', './viewModel', 'text!./component.json', 'css!./styles', 'ojs/ojcomposite'], + function(oj, view, viewModel, metadata) { + oj.Composite.register('@component@', { + view: {inline: view}, + viewModel: {inline: viewModel}, + metadata: {inline: JSON.parse(metadata)} + }); + } +); \ No newline at end of file diff --git a/template/component/styles.css b/template/component/styles.css new file mode 100644 index 0000000..64126db --- /dev/null +++ b/template/component/styles.css @@ -0,0 +1,7 @@ +@component@:not(.oj-complete){ + visibility: hidden; +} + +@component@{ + +} \ No newline at end of file diff --git a/template/component/view.html b/template/component/view.html new file mode 100644 index 0000000..42d1c8e --- /dev/null +++ b/template/component/view.html @@ -0,0 +1,5 @@ + +

\ No newline at end of file diff --git a/template/component/viewModel.js b/template/component/viewModel.js new file mode 100644 index 0000000..21fdd3d --- /dev/null +++ b/template/component/viewModel.js @@ -0,0 +1,38 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +define( + ['ojs/ojcore', 'knockout', 'jquery'], function (oj, ko, $) { + 'use strict'; + + function ExampleComponentModel(context) { + var self = this; + self.composite = context.element; + //Example observable + self.messageText = ko.observable('Hello from Example Component'); + + context.props.then(function (propertyMap) { + //Store a reference to the properties for any later use + self.properties = propertyMap; + + //Parse your component properties here + + }); + }; + + //Lifecycle methods - uncomment and implement if necessary + //ExampleComponentModel.prototype.activated = function(context){ + //}; + + //ExampleComponentModel.prototype.attached = function(context){ + //}; + + //ExampleComponentModel.prototype.bindingsApplied = function(context){ + //}; + + //ExampleComponentModel.prototype.detached = function(context){ + //}; + + return ExampleComponentModel; +}); \ No newline at end of file diff --git a/template/test/index.html b/template/test/index.html new file mode 100644 index 0000000..20d1c6d --- /dev/null +++ b/template/test/index.html @@ -0,0 +1,62 @@ + + + + + + + Oracle JET Starter QUnit - Common Composite Component + + + + + + + + + + + + + + + +
+ +

Composite Component Tests

+ +

+
+

+
    +
    + +
    + +
    + + + +
    + + + + \ No newline at end of file diff --git a/template/test/js/main.js b/template/test/js/main.js new file mode 100644 index 0000000..d8480cf --- /dev/null +++ b/template/test/js/main.js @@ -0,0 +1,57 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +'use strict'; + +requirejs.config( + { + baseUrl : '../../js', + // Path mappings for the logical module names + paths : + { + 'knockout' : 'libs/knockout/knockout-3.4.0.debug', + 'jquery' : 'libs/jquery/jquery-3.1.1', + 'jqueryui-amd' : 'libs/jquery/jqueryui-amd-1.12.0', + 'promise' : 'libs/es6-promise/es6-promise', + 'hammerjs' : 'libs/hammer/hammer-2.0.8', + 'ojdnd' : 'libs/dnd-polyfill/dnd-polyfill-1.0.0', + 'ojs' : 'libs/oj/v4.0.0/debug', + 'ojL10n' : 'libs/oj/v4.0.0/ojL10n', + 'ojtranslations' : 'libs/oj/v4.0.0/resources', + 'text' : 'libs/require/text', + 'css' : 'libs/require-css/css', + 'signals' : 'libs/js-signals/signals', + 'customElements': 'libs/webcomponents/custom-elements.min', + 'test' : '../tests/js/test' + } + , + // Shim configurations for modules that do not expose AMD + shim : + { + 'jquery' : + { + exports : ['jQuery', '$'] + }, + 'simulate' : + { + deps : ['jquery'] + }, + 'test' : + { + deps : ['jquery', 'knockout', 'ojs/ojcore', 'ojs/ojknockout', 'ojs/ojcomponentcore'] + } + } + } + ); + + require(['ojs/ojcore', 'knockout', 'ojs/ojknockout', 'test'], + function (oj, ko) + { + $(function () + { + QUnit.load(); + QUnit.start(); + }); + } + ); diff --git a/template/test/js/test.js b/template/test/js/test.js new file mode 100644 index 0000000..a7ed853 --- /dev/null +++ b/template/test/js/test.js @@ -0,0 +1,15 @@ +/** + Copyright (c) 2015, 2017, Oracle and/or its affiliates. + The Universal Permissive License (UPL), Version 1.0 +*/ +(function ($) +{ + QUnit.module("composite component"); + QUnit.test("example test", function (assert) + { + var done = assert.async(); + assert.expect(1); + assert.ok(true); + done(); + }); +})(jQuery); \ No newline at end of file diff --git a/test/hybridTest.js b/test/hybridTest.js index 24903f0..51cb0ae 100644 --- a/test/hybridTest.js +++ b/test/hybridTest.js @@ -38,17 +38,16 @@ describe("Hybrid Test", function () it("Generate android/ios app", function (done) { - var timeOutLimit = util.isNoRestoreTest() ? 120000 : 520000; + var timeOutLimit = util.isNoRestoreTest() ? 320000 : 520000; this.timeout(timeOutLimit); - var command = 'yo oraclejet:hybrid hybridTest --template=navbar --appid=my.id --appName=testcase --platforms=' + platform; + var command = 'yo @oracle/oraclejet:hybrid hybridTest --template=navbar --appid=my.id --appName=testcase --platforms=' + platform; command = util.isNoRestoreTest() ? command + ' --norestore' : command; exec(command, execOptions, function (error, stdout) { - if(error) {assert.equal(error, undefined, error);} filelist = fs.readdirSync(testDir); hybridFileList = fs.readdirSync(hybridTestDir); - assert.equal(util.norestoreSuccess(stdout), true, error); + assert.equal(util.norestoreSuccess(stdout) || /Your app is/.test(stdout), true, error); done(); }); }); @@ -73,7 +72,7 @@ describe("Hybrid Test", function () it("complain generating app to non-empty appDir", function (done) { this.timeout(300000); - exec('yo oraclejet:hybrid hybridTest --platforms=' + platform, execOptions, function (error, stdout) + exec('yo @oracle/oraclejet:hybrid hybridTest --platforms=' + platform, execOptions, function (error, stdout) { var errLogCorrect = /path already exists and is not empty/.test(error.message); assert.equal(errLogCorrect, true, error); @@ -84,7 +83,7 @@ describe("Hybrid Test", function () it("complain about unsupported platform android1", function (done) { this.timeout(150000); - exec('grunt build --platform=' + 'android1', {cwd: testDir}, function (error, stdout) + exec('grunt build --force=true --platform=' + 'android1', {cwd: testDir}, function (error, stdout) { var errLogCorrect = /Invalid platform/i.test(stdout); @@ -96,7 +95,7 @@ describe("Hybrid Test", function () it("complain about unsupported server port", function (done) { this.timeout(20000); - exec('grunt serve --platform=' + platform + ' --server-port=' + '12we', {cwd: testDir,}, function (error, stdout) + exec('grunt serve --force=true --platform=' + platform + ' --server-port=' + '12we', {cwd: testDir,}, function (error, stdout) { var errLogCorrect = /not valid/.test(stdout); @@ -108,7 +107,7 @@ describe("Hybrid Test", function () it("complain about unsupported build argument", function (done) { this.timeout(150000); - exec('grunt build:xyz --platform=' + platform, {cwd: testDir}, function (error, stdout) + exec('grunt build:xyz --force=true --platform=' + platform, {cwd: testDir}, function (error, stdout) { var errLogCorrect = /buildType xyz is invalid/.test(stdout); @@ -120,7 +119,7 @@ describe("Hybrid Test", function () describe("Build", function () { - it("Grunt build android/ios", function (done) + it("Grunt build android/ios --force=true", function (done) { this.timeout(2400000); exec('grunt build --platform=' + platform, {cwd: testDir, maxBuffer: 1024 * 20000 }, function (error, stdout) @@ -133,7 +132,7 @@ describe("Hybrid Test", function () it("Grunt build android/ios for device", function (done) { this.timeout(2400000); - exec(`grunt build --platform=${platform} --destination=device`, {cwd: testDir, maxBuffer: 1024 * 20000 }, function (error, stdout) + exec(`grunt build --platform=${platform} --destination=device --force=true`, {cwd: testDir, maxBuffer: 1024 * 20000 }, function (error, stdout) { assert.equal(util.buildSuccess(stdout), true, error); done(); @@ -190,10 +189,10 @@ describe("Hybrid Test", function () it("Grunt serve android/ios without platform", function (done) { this.timeout(2400000); - const cmd = 'grunt serve'; + const cmd = 'grunt serve --force=true'; exec(cmd, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:100000, killSignal:'SIGTERM' }, function (error, stdout) { - assert.equal((util.noError(stdout) || /watch:sourceFiles/.test(stdout)), true, error); + assert.equal((util.noError(stdout) || /Build SUCCEEDED/.test(stdout) || /Deploying to /.test(stdout)), true, stdout); done(); }); }); @@ -203,9 +202,9 @@ describe("Hybrid Test", function () it("add sass generator", function (done) { this.timeout(2400000); - exec(`yo oraclejet:add-sass`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:100000, killSignal:'SIGTERM' }, function (error, stdout) + exec(`yo @oracle/oraclejet:add-sass`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:200000, killSignal:'SIGTERM' }, function (error, stdout) { - assert.equal(/add-sass finished/.test(stdout) || /add-sass finished/.test(error), true, error); + assert.equal(/add-sass finished/.test(stdout) || /add-sass finished/.test(error), true, stdout); done(); }); }); @@ -215,7 +214,7 @@ describe("Hybrid Test", function () it("add add-theme generator", function (done) { this.timeout(2400000); - exec(`yo oraclejet:add-theme green`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:50000, killSignal:'SIGTERM' }, function (error, stdout) + exec(`yo @oracle/oraclejet:add-theme green`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:50000, killSignal:'SIGTERM' }, function (error, stdout) { assert.equal(util.noError(stdout), true, error); done(); @@ -229,7 +228,7 @@ describe("Hybrid Test", function () this.timeout(2400000); exec(`grunt build --theme=green`, {cwd: testDir, maxBuffer: 1024 * 20000, timeout:100000, killSignal:'SIGTERM' }, function (error, stdout) { - assert.equal(util.noError(stdout), true, stdout); + assert.equal(util.noError(stdout) || /Cordova compile finished/.test(stdout), true, stdout); done(); }); }); diff --git a/test/util/index.js b/test/util/index.js index 9e96c52..e4760c5 100644 --- a/test/util/index.js +++ b/test/util/index.js @@ -16,7 +16,7 @@ module.exports = { buildSuccess: function _isSuccess(std) { - return ((std.indexOf("BUILD SUCCE") > -1 || std.indexOf("Code Sign error"))? true : false); + return (std.indexOf("BUILD SUCCE") > -1 || std.indexOf('Code signing') > -1 || std.indexOf("Code Sign") > -1); }, norestoreSuccess: function _yoSuccess(std) diff --git a/test/webTest.js b/test/webTest.js index fc84a25..721897d 100644 --- a/test/webTest.js +++ b/test/webTest.js @@ -35,7 +35,7 @@ describe("Web Test", function () it("Generate web app", function (done) { this.timeout(520000); - exec('yo oraclejet webTest --norestore=true', execOptions, function (error, stdout) + exec('yo @oracle/oraclejet webTest --norestore=true', execOptions, function (error, stdout) { done(); assert.equal(util.norestoreSuccess(stdout), true, error); @@ -77,7 +77,7 @@ describe("Web Test", function () describe('Extend to hybrid', function () { it('Add hybrid', function (done) { this.timeout(2400000); - exec(`yo oraclejet:add-hybrid --platform=${util.getPlatform(env.OS)}`, { cwd: testDir }, (error, stdout) => { + exec(`yo @oracle/oraclejet:add-hybrid --platform=${util.getPlatform(env.OS)}`, { cwd: testDir }, (error, stdout) => { filelist = fs.readdirSync(testDir); const inlist = filelist.indexOf('hybrid') > -1; assert.equal(inlist, true, `${testDir}/hybrid missing`); diff --git a/util/constants.js b/util/constants.js index 67cec51..3583f02 100644 --- a/util/constants.js +++ b/util/constants.js @@ -12,7 +12,8 @@ module.exports = { CORDOVA_CONFIG_XML: 'config.xml', DEFAULT_THEME: 'alta', APP_CONFIG_JSON: 'oraclejetconfig.json', - + JET_COMPOSITES: 'jet-composites', + COMPONENT_FILES: ['component.json', 'loader.js', 'styles.css'], APP_TYPE: { HYBRID: 'hybrid', @@ -30,7 +31,11 @@ module.exports = { 'skip-install', 'app-name', 'app-id', - 'insight' + 'insight', + 'component', + 'hybrid', + 'platfrom', + 'platfroms' ]; const hybridFlags = [ @@ -39,12 +44,12 @@ module.exports = { 'appname', 'appName', 'platform', - 'platforms', + 'platforms' ]; const appFlags = [ 'template', - 'norestore', + 'norestore' ]; const restoreFlags = [ diff --git a/util/paths.js b/util/paths.js index 66c2674..3be0f80 100644 --- a/util/paths.js +++ b/util/paths.js @@ -17,7 +17,8 @@ module.exports = getConfiguredPaths(appDir) { let resultPaths = _cachedPathsMap[appDir]; if (!resultPaths) { - _cachedPathsMap[appDir] = resultPaths = _deriveConfiguredPaths(appDir); + resultPaths = _deriveConfiguredPaths(appDir); + _cachedPathsMap[appDir] = resultPaths; } return resultPaths; }, @@ -34,6 +35,7 @@ function _deriveConfiguredPaths(appDir) { Object.defineProperty(configurePaths, 'sourceWeb', _getValueObj(conf.source.web, _defaultPaths.sourceWeb)); Object.defineProperty(configurePaths, 'sourceHybrid', _getValueObj(conf.source.hybrid, _defaultPaths.sourceHybrid)); Object.defineProperty(configurePaths, 'sourceJavascript', _getValueObj(conf.source.javascript, _defaultPaths.sourceJavascript)); + Object.defineProperty(configurePaths, 'sourceTests', _getValueObj(conf.source.tests, _defaultPaths.sourceTests)); Object.defineProperty(configurePaths, 'sourceThemes', _getValueObj(conf.source.themes, _defaultPaths.sourceThemes)); Object.defineProperty(configurePaths, 'stagingHybrid', _getValueObj(conf.staging.hybrid, _defaultPaths.stagingHybrid)); Object.defineProperty(configurePaths, 'stagingWeb', _getValueObj(conf.staging.web, _defaultPaths.stagingWeb)); @@ -47,6 +49,7 @@ function _getDefaultPaths() { Object.defineProperty(defaultPaths, 'sourceWeb', _getValueObj('src-web')); Object.defineProperty(defaultPaths, 'sourceHybrid', _getValueObj('src-hybrid')); Object.defineProperty(defaultPaths, 'sourceJavascript', _getValueObj('js')); + Object.defineProperty(defaultPaths, 'sourceTests', _getValueObj('tests')); Object.defineProperty(defaultPaths, 'sourceThemes', _getValueObj('themes')); Object.defineProperty(defaultPaths, 'stagingHybrid', _getValueObj('hybrid')); Object.defineProperty(defaultPaths, 'stagingWeb', _getValueObj('web'));