├── .editorconfig ├── .gitignore ├── .husky ├── pre-commit └── skip.js ├── .lintstagedrc.json ├── .ncurc.json ├── .prettierignore ├── .prettierrc.json ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── __tests__ └── app.js ├── eslint.config.js ├── generators └── app │ ├── index.js │ ├── templates-theme │ └── src │ │ └── _library_ │ │ └── themes │ │ └── _theme_ │ │ └── library.source.less │ └── templates │ ├── LICENSE │ ├── README.md │ ├── _.editorconfig │ ├── _.gitignore │ ├── eslint.config.js │ ├── karma-ci-cov.conf.js │ ├── karma-ci.conf.js │ ├── karma.conf.js │ ├── package.json │ ├── src │ └── _library_ │ │ ├── Example.js │ │ ├── ExampleRenderer.js │ │ ├── _.library │ │ ├── library.js │ │ ├── messagebundle.properties │ │ ├── messagebundle_de.properties │ │ ├── messagebundle_en.properties │ │ └── themes │ │ └── base │ │ ├── Example.less │ │ └── library.source.less │ ├── test │ └── _library_ │ │ ├── Example.html │ │ ├── Example.js │ │ └── qunit │ │ ├── Example.qunit.js │ │ ├── testsuite.qunit.html │ │ └── testsuite.qunit.js │ ├── ui5-dist.yaml │ └── ui5.yaml ├── package-lock.json ├── package.json └── test └── .keepme /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | # We recommend you to keep these unchanged 9 | max_line_length = 200 10 | end_of_line = lf 11 | charset = utf-8 12 | trim_trailing_whitespace = true 13 | insert_final_newline = true 14 | 15 | # Change these settings to your own preference 16 | indent_style = tab 17 | indent_size = 2 18 | 19 | [*.{yaml,yml}] 20 | indent_style = space 21 | 22 | [*.md] 23 | indent_style = unset 24 | trim_trailing_whitespace = false 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Hidden Files 2 | _ 3 | test/*/ 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Dependency directories 13 | node_modules/ 14 | 15 | .DS_Store 16 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npm run hooks:pre-commit 2 | -------------------------------------------------------------------------------- /.husky/skip.js: -------------------------------------------------------------------------------- 1 | if (process.env.HUSKY_SKIP || process.env.NODE_ENV === "production") { 2 | process.exit(0); 3 | } else { 4 | process.exit(1); 5 | } 6 | -------------------------------------------------------------------------------- /.lintstagedrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.js": "eslint" 3 | } 4 | -------------------------------------------------------------------------------- /.ncurc.json: -------------------------------------------------------------------------------- 1 | { 2 | "reject": ["yeoman-generator", "yeoman-assert", "yeoman-test", "yosay"] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore test files 2 | test/*/ 3 | 4 | # Ignore all source files using the placeholders to kill the syntax 5 | generators/app/templates/karma-ci-cov.conf.js 6 | generators/app/templates/src/_library_/library.js 7 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": false, 3 | "trailingComma": "none", 4 | "overrides": [ 5 | { 6 | "files": ["*.xml"], 7 | "options": { 8 | "xmlWhitespaceSensitivity": "ignore" 9 | } 10 | }, 11 | { 12 | "files": ["*.properties"], 13 | "options": { 14 | "keySeparator": "=" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-ui5-library 2 | 3 | [![License Status][license-image]][license-url] 4 | 5 | [Yeoman](https://yeoman.io/) generator kickstarting the development of UI5 libraries. The generator incorporates the latest best-practices, is using the [UI5 Tooling](https://sap.github.io/ui5-tooling/) and the UI5 Tooling extensions provided by the [UI5 community](https://github.com/ui5-community/ui5-ecosystem-showcase/). It is maintained by the UI5 community and [OpenUI5](https://openui5.org)/[SAPUI5](https://ui5.sap.com) developers. This generator was build as a plug-in for the community project [Easy-UI5](https://github.com/SAP/generator-easy-ui5/) by [SAP](https://github.com/SAP/). 6 | 7 | ## Usage with Easy-UI5 8 | 9 | ```bash 10 | $> npm i -g yo generator-easy-ui5 11 | $> yo easy-ui5 library 12 | 13 | _-----_ 14 | | | ╭──────────────────────────╮ 15 | |--(o)--| │ Welcome to the easy-ui5 │ 16 | `---------´ │ generator! │ 17 | ( _´U`_ ) ╰──────────────────────────╯ 18 | /___A___\ / 19 | | ~ | 20 | __'.___.'__ 21 | ´ ` |° ´ Y ` 22 | ``` 23 | 24 | After the generation of your project you can use `npm start` (or `yarn start`) to start the local development server. 25 | 26 | ## Standalone usage 27 | 28 | Note the different greeting when the generator starts: 29 | 30 | ```bash 31 | $> npm i -g yo 32 | $> yo ./generator-ui5-library 33 | 34 | _-----_ ╭───────────────────────╮ 35 | | | │ Welcome to the │ 36 | |--(o)--| │ generator-ui5-library │ 37 | `---------´ │ generator! │ 38 | ( _´U`_ ) ╰───────────────────────╯ 39 | /___A___\ / 40 | | ~ | 41 | __'.___.'__ 42 | ´ ` |° ´ Y ` 43 | ``` 44 | 45 | ## Support 46 | 47 | Please use the GitHub bug tracking system to post questions, bug reports or to create pull requests. 48 | 49 | ## Contributing 50 | 51 | We welcome any type of contribution (code contributions, pull requests, issues) to this generator equally. 52 | 53 | ## License 54 | 55 | This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file. 56 | 57 | [license-image]: https://img.shields.io/github/license/ui5-community/generator-ui5-library.svg 58 | [license-url]: https://github.com/ui5-community/generator-ui5-library/blob/main/LICENSE 59 | 60 | --- 61 | 62 | ###### This generator is provided to you by Geert-Jan Klaps and contributors :wink: 63 | -------------------------------------------------------------------------------- /__tests__/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const path = require("path"); 3 | const assert = require("yeoman-assert"); 4 | const helpers = require("yeoman-test"); 5 | 6 | describe("generator-ui5-library:app", () => { 7 | beforeAll(() => { 8 | return helpers.run(path.join(__dirname, "../generators/app")).withPrompts({ someAnswer: true }); 9 | }); 10 | 11 | it("creates files", () => { 12 | assert.file(["dummyfile.txt"]); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import globals from "globals"; 2 | import js from "@eslint/js"; 3 | import jsdoc from "eslint-plugin-jsdoc"; 4 | 5 | export default [ 6 | js.configs.recommended, 7 | jsdoc.configs["flat/recommended"], 8 | { 9 | languageOptions: { 10 | globals: { 11 | ...globals.node 12 | }, 13 | ecmaVersion: 2023, 14 | sourceType: "module" 15 | }, 16 | rules: { 17 | "no-unused-vars": "warn" 18 | } 19 | }, 20 | { 21 | ignores: [ 22 | "eslint.config.js", 23 | 24 | // Ignore node_files 25 | "node_modules/", 26 | 27 | // Ignore templates 28 | "generators/*/templates/", 29 | "generators/*/templates-theme/", 30 | 31 | // Ignore test files 32 | "test/", 33 | "__tests__/" 34 | ] 35 | } 36 | ]; 37 | -------------------------------------------------------------------------------- /generators/app/index.js: -------------------------------------------------------------------------------- 1 | import url from "url"; 2 | 3 | // all below required dependencies need to be listed 4 | // as dependencies in the package.json (not devDeps!) 5 | import Generator from "yeoman-generator"; 6 | import yosay from "yosay"; 7 | import chalk from "chalk"; 8 | import { glob } from "glob"; 9 | import packageJson from "package-json"; 10 | import semver from "semver"; 11 | import upath from "upath"; 12 | 13 | const __dirname = url.fileURLToPath(new URL(".", import.meta.url)); 14 | 15 | export default class extends Generator { 16 | static displayName = "Create a new UI5 library"; 17 | 18 | constructor(args, opts) { 19 | super(args, opts, { 20 | // disable the Yeoman 5 package-manager logic (auto install)! 21 | customInstallTask: "disabled" 22 | }); 23 | } 24 | 25 | prompting() { 26 | // Have Yeoman greet the user. 27 | if (!this.options.embedded) { 28 | this.log(yosay(`Welcome to the ${chalk.red("generator-ui5-library")} generator!`)); 29 | } 30 | 31 | const fwkInfo = { 32 | OpenUI5: { 33 | minVersion: "1.60.0", 34 | cdnDomain: "sdk.openui5.org", 35 | npmPackage: "@openui5/sap.ui.core" 36 | }, 37 | SAPUI5: { 38 | minVersion: "1.77.0", 39 | cdnDomain: "ui5.sap.com", 40 | npmPackage: "@sapui5/distribution-metadata" 41 | } 42 | }; 43 | 44 | const prompts = [ 45 | { 46 | type: "input", 47 | name: "namespace", 48 | message: "What is the namespace of your library?", 49 | validate: (s) => { 50 | if (/^[a-zA-Z0-9][a-zA-Z0-9_.]*$/g.test(s)) { 51 | return true; 52 | } 53 | 54 | return "Please use alpha numeric characters and dots only for the namespace."; 55 | }, 56 | default: "com.myorg.mylib" 57 | }, 58 | { 59 | type: "list", 60 | name: "framework", 61 | message: "Which framework do you want to use?", 62 | choices: Object.keys(fwkInfo), 63 | default: Object.keys(fwkInfo)[0] 64 | }, 65 | { 66 | when: (response) => { 67 | this._minFwkVersion = fwkInfo[response.framework].minVersion; 68 | return true; 69 | }, 70 | type: "input", // HINT: we could also use the version info from OpenUI5/SAPUI5 to provide a selection! 71 | name: "frameworkVersion", 72 | message: "Which framework version do you want to use?", 73 | default: async (answers) => { 74 | const minVersion = fwkInfo[answers.framework].minVersion; 75 | const npmPackage = fwkInfo[answers.framework].npmPackage; 76 | try { 77 | return ( 78 | await packageJson(npmPackage, { 79 | version: "*" // use highest version, not latest! 80 | }) 81 | ).version; 82 | } catch (ex) { 83 | chalk.red("Failed to lookup latest version for ${npmPackage}! Fallback to min version..."); 84 | return minVersion[answers.framework]; 85 | } 86 | }, 87 | validate: (v) => { 88 | return (v && semver.valid(v) && semver.gte(v, this._minFwkVersion)) || chalk.red(`Framework requires the min version ${this._minFwkVersion} due to the availability of the NPM packages!`); 89 | } 90 | }, 91 | { 92 | type: "confirm", 93 | name: "flat", 94 | message: "Would you like to omit the namespace in the src and test folder?", 95 | default: true 96 | }, 97 | { 98 | type: "input", 99 | name: "author", 100 | message: "Who is the author of the application?", 101 | default: this.user.git.name() 102 | }, 103 | { 104 | type: "confirm", 105 | name: "newdir", 106 | message: "Would you like to create a new directory for the application?", 107 | default: true 108 | }, 109 | { 110 | type: "confirm", 111 | name: "initrepo", 112 | message: "Would you like to initialize a local github repository for the application?", 113 | default: true 114 | } 115 | ]; 116 | 117 | return this.prompt(prompts).then((props) => { 118 | // use the namespace and the application name as new subdirectory 119 | if (props.newdir) { 120 | this.destinationRoot(this.destinationPath(`${props.namespace}`)); 121 | } 122 | delete props.newdir; 123 | 124 | // apply the properties 125 | this.config.set(props); 126 | 127 | // libId + libURI + libBasePath 128 | this.config.set("libId", `${props.namespace}`); 129 | this.config.set("libURI", `${props.namespace.split(".").join("/")}`); 130 | this.config.set( 131 | "libBasePath", 132 | `${props.namespace 133 | .split(".") 134 | // eslint-disable-next-line no-unused-vars 135 | .map((_) => "..") 136 | .join("/")}` 137 | ); 138 | 139 | // CDN domain 140 | this.config.set("cdnDomain", fwkInfo[props.framework].cdnDomain); 141 | 142 | // default theme 143 | if (semver.gte(props.frameworkVersion, "1.108.0")) { 144 | this.config.set("defaultTheme", "sap_horizon"); 145 | this.config.set("availableThemes", { 146 | sap_horizon: ["sap_horizon", "sap_horizon_dark", "sap_horizon_hcw", "sap_horizon_hcb"], 147 | sap_fiori_3: ["sap_fiori_3", "sap_fiori_3_dark", "sap_fiori_3_hcw", "sap_fiori_3_hcb"] 148 | }); 149 | } else { 150 | this.config.set("defaultTheme", "sap_fiori_3"); 151 | this.config.set("availableThemes", { 152 | sap_fiori_3: ["sap_fiori_3", "sap_fiori_3_dark", "sap_fiori_3_hcw", "sap_fiori_3_hcb"], 153 | sap_belize: ["sap_belize", "sap_belize_plus", "sap_belize_hcw", "sap_belize_hcb"] 154 | }); 155 | } 156 | }); 157 | } 158 | 159 | writing() { 160 | const oConfig = this.config.getAll(); 161 | const libPath = oConfig.flat ? "" : oConfig.libURI; 162 | 163 | // write library 164 | this.sourceRoot(upath.join(__dirname, "templates")); 165 | glob 166 | .sync("**", { 167 | cwd: this.sourceRoot(), 168 | nodir: true 169 | }) 170 | .forEach((file) => { 171 | const sOrigin = this.templatePath(file); 172 | const sTarget = this.destinationPath( 173 | file 174 | .replace(/^_/, "") 175 | .replace("_library_", libPath) 176 | .replace(/[\\/]_/, "/") 177 | ); 178 | this.fs.copyTpl(sOrigin, sTarget, oConfig); 179 | }); 180 | 181 | // write the available themes 182 | this.sourceRoot(upath.join(__dirname, "templates-theme")); 183 | const themes = []; 184 | Object.values(oConfig.availableThemes).forEach((v) => themes.push(...v)); 185 | themes.forEach((theme) => { 186 | glob 187 | .sync("**", { 188 | cwd: this.sourceRoot(), 189 | nodir: true 190 | }) 191 | .forEach((file) => { 192 | const sOrigin = this.templatePath(file); 193 | const sTarget = this.destinationPath(file.replace("_library_", libPath).replace("_theme_", theme)); 194 | this.fs.copyTpl(sOrigin, sTarget, Object.assign({ themeName: theme }, oConfig)); 195 | }); 196 | }); 197 | } 198 | 199 | install() { 200 | this.config.set("setupCompleted", true); 201 | this.spawnCommandSync("npm", ["install"], { 202 | cwd: this.destinationPath() 203 | }); 204 | } 205 | 206 | end() { 207 | if (this.config.get("initrepo")) { 208 | this.spawnCommandSync("git", ["init", "--quiet"], { 209 | cwd: this.destinationPath() 210 | }); 211 | this.spawnCommandSync("git", ["add", "."], { 212 | cwd: this.destinationPath() 213 | }); 214 | this.spawnCommandSync("git", ["commit", "--quiet", "--allow-empty", "-m", "Initial commit"], { 215 | cwd: this.destinationPath() 216 | }); 217 | } 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /generators/app/templates-theme/src/_library_/themes/_theme_/library.source.less: -------------------------------------------------------------------------------- 1 | @import "../<%= themeName === 'sap_belize_plus' ? 'sap_belize' : 'base' /* special case for sap_belize_plus being based on sap_belize */ %>/library.source.less"; 2 | @import "/resources/sap/ui/core/themes/<%= themeName %>/base.less"; 3 | @import "/resources/sap/ui/core/themes/<%= themeName %>/global.less"; 4 | -------------------------------------------------------------------------------- /generators/app/templates/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /generators/app/templates/README.md: -------------------------------------------------------------------------------- 1 | # UI5 Library <%= namespace %> 2 | 3 | Insert the purpose of this project and some interesting info here... 4 | 5 | ## Description 6 | 7 | This app demonstrates a setup for developing UI5 libraries. 8 | 9 | ## Requirements 10 | 11 | Either [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) for dependency management. 12 | 13 | ## Preparation 14 | 15 | Use `npm` (or `yarn`) to install the dependencies: 16 | 17 | ```sh 18 | npm install 19 | ``` 20 | 21 | (To use yarn, just do `yarn` instead.) 22 | 23 | ## Run the Library 24 | 25 | Execute the following command to run the library locally for development in watch mode (the browser reloads the app automatically when there are changes in the source code): 26 | 27 | ```sh 28 | npm start 29 | ``` 30 | 31 | As shown in the terminal after executing this command, the app is then running on http://localhost:8080/. A browser window with the URL pointing to your controls' test page should automatically open. 32 | 33 | (When using yarn, do `yarn start` instead.) 34 | 35 | ## Build the Library 36 | 37 | ### Unoptimized (but quick) 38 | 39 | Execute the following command to build the project and get an app that can be deployed: 40 | 41 | ```sh 42 | npm run build 43 | ``` 44 | 45 | The result is placed into the `dist` folder. To start the generated package, just run 46 | 47 | ```sh 48 | npm run start:dist 49 | ``` 50 | 51 | Note that HTML page still loads the UI5 framework from the relative URL `resources/...`, which does not physically exist, but is only provided dynamically by the UI5 tooling. So for an actual deployment you should change this URL to either [the CDN](https://sdk.openui5.org/#/topic/2d3eb2f322ea4a82983c1c62a33ec4ae) or your local deployment of UI5. 52 | 53 | (When using yarn, do `yarn build` and `yarn start:dist` instead.) 54 | 55 | ## Check the Code 56 | 57 | To lint the code, do: 58 | 59 | ```sh 60 | npm run lint 61 | ``` 62 | 63 | (Again, when using yarn, do `yarn lint` instead.) 64 | 65 | ## License 66 | 67 | This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file. 68 | 69 | --- 70 | 71 | ###### This template is provided to you by Geert-Jan Klaps and contributors :wink: 72 | -------------------------------------------------------------------------------- /generators/app/templates/_.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | # We recommend you to keep these unchanged 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | 14 | # Change these settings to your own preference 15 | indent_style = tab 16 | 17 | [*.{yaml,yml,md,json,xml,properties}] 18 | indent_size = 2 19 | indent_style = space 20 | 21 | [*.md] 22 | trim_trailing_whitespace = false 23 | -------------------------------------------------------------------------------- /generators/app/templates/_.gitignore: -------------------------------------------------------------------------------- 1 | # build results 2 | dist 3 | coverage 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Dependency directories 13 | node_modules/ 14 | 15 | .DS_Store 16 | .env 17 | tmp/ 18 | -------------------------------------------------------------------------------- /generators/app/templates/eslint.config.js: -------------------------------------------------------------------------------- 1 | const globals = require("globals"); 2 | const js = require("@eslint/js"); 3 | const jsdoc = require("eslint-plugin-jsdoc"); 4 | 5 | module.exports = [ 6 | js.configs.recommended, 7 | jsdoc.configs["flat/recommended"], 8 | { 9 | languageOptions: { 10 | globals: { 11 | ...globals.browser, 12 | sap: "readonly" 13 | }, 14 | ecmaVersion: 2023, 15 | sourceType: "script" 16 | }, 17 | rules: { 18 | "brace-style": [ 19 | 2, 20 | "1tbs", 21 | { 22 | allowSingleLine: true 23 | } 24 | ], 25 | "consistent-this": 2, 26 | "no-div-regex": 2, 27 | "no-floating-decimal": 2, 28 | "no-self-compare": 2, 29 | "no-mixed-spaces-and-tabs": [2, true], 30 | "no-nested-ternary": 2, 31 | radix: 2, 32 | "keyword-spacing": 2, 33 | "space-unary-ops": 2, 34 | "wrap-iife": [2, "any"], 35 | camelcase: 1, 36 | "consistent-return": 1, 37 | "max-nested-callbacks": [1, 3], 38 | "new-cap": 1, 39 | "no-extra-boolean-cast": 1, 40 | "no-lonely-if": 1, 41 | "no-new": 1, 42 | "no-new-wrappers": 1, 43 | "no-redeclare": 1, 44 | "no-unused-expressions": 1, 45 | "no-use-before-define": [1, "nofunc"], 46 | "no-warning-comments": 1, 47 | strict: 1, 48 | "default-case": 1, 49 | "dot-notation": 0, 50 | "eol-last": 0, 51 | eqeqeq: 0, 52 | "no-trailing-spaces": 0, 53 | "no-underscore-dangle": 0, 54 | quotes: 0, 55 | "key-spacing": 0, 56 | "comma-spacing": 0, 57 | "no-multi-spaces": 0, 58 | "no-shadow": 0, 59 | "no-irregular-whitespace": 0, 60 | "no-var": 2, 61 | "no-const-assign": 2, 62 | "prefer-const": 2 63 | } 64 | }, 65 | { 66 | ignores: ["eslint.config.js"] 67 | } 68 | ]; 69 | -------------------------------------------------------------------------------- /generators/app/templates/karma-ci-cov.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | "use strict"; 3 | 4 | require("./karma-ci.conf")(config); 5 | config.set({ 6 | reporters: ["progress", "coverage"], 7 | preprocessors: { 8 | "src/**/*.js": ["coverage"], 9 | "test/**/*.js": ["coverage"] 10 | },<% if (flat) { %> 11 | proxies: { 12 | '/resources/<%= libURI %>/': '/base/src/', 13 | '/test-resources/<%= libURI %>/': '/base/test/', 14 | },<% } %> 15 | coverageReporter: { 16 | dir: "coverage", 17 | reporters: [ 18 | { type: "html", subdir: "report-html" }, 19 | { type: "cobertura", subdir: ".", file: "cobertura.txt" }, 20 | { type: "lcovonly", subdir: ".", file: "report-lcovonly.txt" }, 21 | { type: "text-summary" } 22 | ] 23 | } 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /generators/app/templates/karma-ci.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | "use strict"; 3 | 4 | require("./karma.conf")(config); 5 | config.set({ 6 | browsers: ["ChromeHeadless"], 7 | singleRun: true 8 | }); 9 | }; 10 | -------------------------------------------------------------------------------- /generators/app/templates/karma.conf.js: -------------------------------------------------------------------------------- 1 | // karma-ui5 usage: https://github.com/SAP/karma-ui5 2 | module.exports = function (config) { 3 | "use strict"; 4 | 5 | config.set({ 6 | frameworks: ["ui5"], 7 | browsers: ["Chrome"] 8 | }); 9 | }; 10 | -------------------------------------------------------------------------------- /generators/app/templates/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= libId %>", 3 | "version": "1.0.0", 4 | "description": "UI5 Library: <%= libId %>", 5 | "author": "<%= author %>", 6 | "license": "Apache-2.0", 7 | "scripts": { 8 | "clean": "rimraf dist coverage", 9 | "build": "ui5 build --clean-dest", 10 | "start": "ui5 serve -o test-resources/<%= libURI %>/Example.html", 11 | "start:dist": "npm start -- --config ui5-dist.yaml", 12 | "testsuite": "ui5 serve -o test-resources/<%= libURI %>/qunit/testsuite.qunit.html", 13 | "lint": "eslint src test", 14 | "karma": "karma start", 15 | "karma-ci": "karma start karma-ci.conf.js", 16 | "karma-ci-cov": "karma start karma-ci-cov.conf.js", 17 | "test": "npm run lint && npm run karma-ci-cov" 18 | }, 19 | "devDependencies": { 20 | "@ui5/cli": "^4.0.6", 21 | "@ui5/middleware-code-coverage": "^2.0.0", 22 | "eslint": "^9.9.1", 23 | "eslint-plugin-jsdoc": "^50.2.2", 24 | "globals": "^15.9.0", 25 | "karma": "^6.4.4", 26 | "karma-chrome-launcher": "^3.2.0", 27 | "karma-coverage": "^2.2.1", 28 | "karma-ui5": "^4.0.1", 29 | "rimraf": "^6.0.1", 30 | "ui5-middleware-livereload": "^3.0.3" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/Example.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * ${copyright} 3 | */ 4 | 5 | // Provides control <%= libId %>.Example. 6 | sap.ui.define(["./library", "sap/ui/core/Control", "./ExampleRenderer"], function (library, Control, ExampleRenderer) { 7 | "use strict"; 8 | 9 | // refer to library types 10 | const ExampleColor = library.ExampleColor; 11 | 12 | /** 13 | * Constructor for a new <%= libId %>.Example control. 14 | * 15 | * @param {string} [sId] id for the new control, generated automatically if no id is given 16 | * @param {object} [mSettings] initial settings for the new control 17 | * 18 | * @class 19 | * Some class description goes here. 20 | * @extends sap.ui.core.Control 21 | * 22 | * @author <%= author %> 23 | * @version ${version} 24 | * 25 | * @constructor 26 | * @public 27 | * @alias <%= libId %>.Example 28 | */ 29 | const Example = Control.extend( 30 | "<%= libId %>.Example", 31 | /** @lends <%= libId %>.Example.prototype */ { 32 | metadata: { 33 | library: "<%= libId %>", 34 | properties: { 35 | /** 36 | * The text to display. 37 | */ 38 | text: { 39 | type: "string", 40 | group: "Data", 41 | defaultValue: null 42 | }, 43 | /** 44 | * The color to use (default to "Default" color). 45 | */ 46 | color: { 47 | type: "<%= libId %>.ExampleColor", 48 | group: "Appearance", 49 | defaultValue: ExampleColor.Default 50 | } 51 | }, 52 | events: { 53 | /** 54 | * Event is fired when the user clicks the control. 55 | */ 56 | press: {} 57 | } 58 | }, 59 | renderer: ExampleRenderer, 60 | onclick: function () { 61 | this.firePress(); 62 | } 63 | } 64 | ); 65 | return Example; 66 | }); 67 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/ExampleRenderer.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * ${copyright} 3 | */ 4 | 5 | sap.ui.define(["sap/ui/core/Core", "./library"], function (Core, library) { 6 | "use strict"; 7 | 8 | // refer to library types 9 | const ExampleColor = library.ExampleColor; 10 | 11 | /** 12 | * Example renderer. 13 | * @namespace 14 | */ 15 | const ExampleRenderer = { 16 | apiVersion: 2 // usage of DOM Patcher 17 | }; 18 | 19 | /** 20 | * Renders the HTML for the given control, using the provided 21 | * {@link sap.ui.core.RenderManager}. 22 | * 23 | * @param {sap.ui.core.RenderManager} rm The reference to the sap.ui.core.RenderManager 24 | * @param {sap.ui.core.Control} control The control instance to be rendered 25 | */ 26 | ExampleRenderer.render = function (rm, control) { 27 | const i18n = Core.getLibraryResourceBundle("<%= libId %>"); 28 | 29 | rm.openStart("div", control); 30 | if (control.getColor() === ExampleColor.Highlight) { 31 | rm.class("myLibPrefixExampleHighlight"); 32 | } else { 33 | rm.class("myLibPrefixExample"); 34 | } 35 | rm.openEnd(); 36 | rm.text(i18n.getText("ANY_TEXT") + ": " + control.getText()); 37 | rm.close("div"); 38 | }; 39 | 40 | return ExampleRenderer; 41 | }); 42 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/_.library: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= libId %> 4 | <%= author %> 5 | ${version} 6 | ${copyright} 7 | <%= libId %> 8 | Some description about <%= libId %> 9 | 10 | 11 | sap.ui.core 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/library.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * ${copyright} 3 | */ 4 | 5 | /** 6 | * Initialization Code and shared classes of library <%= libId %>. 7 | */ 8 | sap.ui.define([ 9 | "sap/base/util/ObjectPath", 10 | "sap/ui/core/library" 11 | ], function (ObjectPath) { 12 | "use strict"; 13 | 14 | // delegate further initialization of this library to the Core 15 | // Hint: sap.ui.getCore() must still be used to support preload with sync bootstrap! 16 | sap.ui.getCore().initLibrary({ 17 | name: "<%= libId %>", 18 | version: "${version}", 19 | dependencies: [ // keep in sync with the ui5.yaml and .library files 20 | "sap.ui.core" 21 | ], 22 | types: [ 23 | "<%= libId %>.ExampleColor" 24 | ], 25 | interfaces: [], 26 | controls: [ 27 | "<%= libId %>.Example" 28 | ], 29 | elements: [], 30 | noLibraryCSS: false // if no CSS is provided, you can disable the library.css load here 31 | }); 32 | 33 | /** 34 | * Some description about <%= libId %> 35 | * 36 | * @namespace 37 | * @alias <%= libId %> 38 | * @author <%= author %> 39 | * @version ${version} 40 | * @public 41 | */ 42 | const thisLib = ObjectPath.get("<%= libId %>"); 43 | 44 | /** 45 | * Semantic Colors of the <%= libId %>.Example. 46 | * 47 | * @enum {string} 48 | * @public 49 | */ 50 | thisLib.ExampleColor = { 51 | 52 | /** 53 | * Default color (brand color) 54 | * @public 55 | */ 56 | Default : "Default", 57 | 58 | /** 59 | * Highlight color 60 | * @public 61 | */ 62 | Highlight : "Highlight" 63 | 64 | }; 65 | 66 | return thisLib; 67 | 68 | }); 69 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/messagebundle.properties: -------------------------------------------------------------------------------- 1 | # Translation file of library <%= libId %>. 2 | ANY_TEXT=AnyText 3 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/messagebundle_de.properties: -------------------------------------------------------------------------------- 1 | # Translation file of library <%= libId %>. 2 | ANY_TEXT=EinText 3 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/messagebundle_en.properties: -------------------------------------------------------------------------------- 1 | # Translation file of library <%= libId %>. 2 | ANY_TEXT=AnyText 3 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/themes/base/Example.less: -------------------------------------------------------------------------------- 1 | /* Theme Parameter Toolbox: https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/theming/webapp/index.html */ 2 | 3 | .myLibPrefixExample, 4 | .myLibPrefixExampleHighlight { 5 | color: @sapUiText; 6 | background-color: @sapUiNeutralBG; 7 | border: 1rem solid @sapUiContentForegroundBorderColor; 8 | border-radius: 1rem; 9 | opacity: 0.8; 10 | padding: 2rem; 11 | margin: 2rem 8rem; 12 | text-align: center; 13 | font-size: 2em; 14 | line-height: 3em; 15 | } 16 | 17 | .myLibPrefixExampleHighlight { 18 | background-color: @sapUiSuccessBG; 19 | } 20 | -------------------------------------------------------------------------------- /generators/app/templates/src/_library_/themes/base/library.source.less: -------------------------------------------------------------------------------- 1 | @import "/resources/sap/ui/core/themes/base/base.less"; 2 | @import "/resources/sap/ui/core/themes/base/global.less"; 3 | 4 | @import "Example.less"; 5 | -------------------------------------------------------------------------------- /generators/app/templates/test/_library_/Example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test Page for <%= libId %>.Example 6 | 7 | 16 | 17 | 18 |

Test Page for <%= libId %>.Example

19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /generators/app/templates/test/_library_/Example.js: -------------------------------------------------------------------------------- 1 | sap.ui.define(["<%= libURI %>/library", "<%= libURI %>/Example"], function (library, Example) { 2 | "use strict"; 3 | 4 | // refer to library types 5 | const ExampleColor = library.ExampleColor; 6 | 7 | // create a new instance of the Example control and 8 | // place it into the DOM element with the id "content" 9 | new Example({ 10 | text: "Example", 11 | color: ExampleColor.Highlight, 12 | press: function (event) { 13 | alert(event.getSource()); 14 | } 15 | }).placeAt("content"); 16 | }); 17 | -------------------------------------------------------------------------------- /generators/app/templates/test/_library_/qunit/Example.qunit.js: -------------------------------------------------------------------------------- 1 | /*global QUnit, jQuery */ 2 | sap.ui.define(["<%= libURI %>/library", "<%= libURI %>/Example"], function (library, Example) { 3 | "use strict"; 4 | 5 | // refer to library types 6 | const ExampleColor = library.ExampleColor; 7 | 8 | // prepare DOM 9 | const oDiv = document.createElement("div"); 10 | oDiv.id = "uiArea1"; 11 | document.body.appendChild(oDiv); 12 | 13 | // module for basic checks 14 | QUnit.module("Example Tests"); 15 | 16 | // example sync test 17 | QUnit.test("Sync", function (assert) { 18 | assert.expect(1); 19 | assert.ok(true, "ok"); 20 | }); 21 | 22 | // example async test 23 | QUnit.test("Async", function (assert) { 24 | assert.expect(1); 25 | return new Promise(function (resolve /*, reject*/) { 26 | assert.ok(true, "ok"); 27 | resolve(); 28 | }); 29 | }); 30 | 31 | // module for basic checks 32 | QUnit.module("Basic Control Checks"); 33 | 34 | // some basic control checks 35 | QUnit.test("Test get properties", function (assert) { 36 | assert.expect(2); 37 | const oExample = new Example({ 38 | text: "Example" 39 | }); 40 | assert.equal(oExample.getText(), "Example", "Check text equals 'Example'"); 41 | assert.equal(oExample.getColor(), ExampleColor.Default, "Check color equals 'Default'"); 42 | }); 43 | 44 | // some basic eventing check 45 | QUnit.test("Test click event", function (assert) { 46 | assert.expect(1); 47 | const oExample = new Example("example", { 48 | text: "Example", 49 | press: function () { 50 | assert.ok(true, "Event has been fired!"); 51 | } 52 | }).placeAt("uiArea1"); 53 | return new Promise(function (resolve /*, reject*/) { 54 | setTimeout(function () { 55 | // eslint-disable-next-line new-cap 56 | oExample.$().trigger(jQuery.Event("click")); 57 | resolve(); 58 | }, 100); 59 | }); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /generators/app/templates/test/_library_/qunit/testsuite.qunit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | QUnit TestSuite for <%= libId %> 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /generators/app/templates/test/_library_/qunit/testsuite.qunit.js: -------------------------------------------------------------------------------- 1 | sap.ui.define(function () { 2 | "use strict"; 3 | 4 | return { 5 | name: "QUnit TestSuite for <%= libId %>", 6 | defaults: { 7 | ui5: { 8 | libs: ["sap.ui.core", "<%= libId %>"], 9 | theme: "<%= defaultTheme %>" 10 | }, 11 | qunit: { 12 | version: 2, 13 | reorder: false 14 | }, 15 | sinon: { 16 | version: 4, 17 | qunitBridge: true, 18 | useFakeTimers: false 19 | }, 20 | coverage: { 21 | only: ["<%= libURI %>/"], 22 | never: ["test-resources/"] 23 | } 24 | }, 25 | tests: { 26 | // test file for the Example control 27 | Example: { 28 | title: "QUnit Test for Example", 29 | _alternativeTitle: "QUnit tests: <%= libId %>.Example" 30 | } 31 | } 32 | }; 33 | }); 34 | -------------------------------------------------------------------------------- /generators/app/templates/ui5-dist.yaml: -------------------------------------------------------------------------------- 1 | specVersion: "4.0" 2 | metadata: 3 | name: <%= libId %> 4 | type: library 5 | resources: 6 | configuration: 7 | paths: 8 | src: dist/resources/<%= libURI %>/ 9 | test: dist/test-resources/<%= libURI %>/ 10 | framework: 11 | name: <%= framework %> 12 | version: <%= frameworkVersion %> 13 | libraries: 14 | - name: sap.ui.core<% Object.keys(availableThemes).forEach((theme) => { %> 15 | - name: themelib_<%= theme %><% }) %> 16 | -------------------------------------------------------------------------------- /generators/app/templates/ui5.yaml: -------------------------------------------------------------------------------- 1 | specVersion: "4.0" 2 | metadata: 3 | name: <%= libId %> 4 | type: library 5 | framework: 6 | name: <%= framework %> 7 | version: <%= frameworkVersion %> 8 | libraries: 9 | - name: sap.ui.core<% Object.keys(availableThemes).forEach((theme) => { %> 10 | - name: themelib_<%= theme %><% }) %> 11 | server: 12 | customMiddleware: 13 | - name: "@ui5/middleware-code-coverage" 14 | afterMiddleware: compression 15 | - name: ui5-middleware-livereload 16 | afterMiddleware: compression 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-ui5-library", 3 | "version": "1.1.0", 4 | "description": "Yeoman-based (sub-)generator for a basic UI5 library", 5 | "main": "generators/app/index.js", 6 | "type": "module", 7 | "scripts": { 8 | "lint": "eslint .", 9 | "lint:fix": "eslint . --fix", 10 | "lint:staged": "lint-staged", 11 | "format": "prettier --write .", 12 | "format:staged": "pretty-quick --staged --verbose", 13 | "test": "cd test && yo ../generators/app/index.js", 14 | "prepare": "node ./.husky/skip.js || husky", 15 | "hooks:pre-commit": "npm run format:staged && npm run lint:staged" 16 | }, 17 | "keywords": [ 18 | "yeoman-generator", 19 | "ui5", 20 | "openui5", 21 | "sapui5", 22 | "library" 23 | ], 24 | "author": { 25 | "name": "Geert-Jan Klaps", 26 | "email": "geert-jan@klaps.org", 27 | "url": "https://www.linkedin.com/in/geertjanklaps" 28 | }, 29 | "license": "Apache-2.0", 30 | "repository": { 31 | "type": "git", 32 | "url": "https://github.com/ui5-community/generator-ui5-library.git" 33 | }, 34 | "bugs": { 35 | "url": "https://github.com/ui5-community/generator-ui5-library/issues" 36 | }, 37 | "homepage": "https://github.com/ui5-community/generator-ui5-library#readme", 38 | "dependencies": { 39 | "chalk": "^5.3.0", 40 | "glob": "^11.0.0", 41 | "package-json": "^10.0.1", 42 | "semver": "^7.6.3", 43 | "upath": "^2.0.1", 44 | "yeoman-generator": "^5.9.0", 45 | "yosay": "^2.0.2" 46 | }, 47 | "devDependencies": { 48 | "@prettier/plugin-xml": "^3.4.1", 49 | "eslint": "^9.9.1", 50 | "eslint-plugin-jsdoc": "^50.2.2", 51 | "husky": "^9.1.5", 52 | "lint-staged": "^15.2.10", 53 | "prettier": "^3.3.3", 54 | "prettier-plugin-properties": "^0.3.0", 55 | "pretty-quick": "^4.0.0", 56 | "yeoman-assert": "^3.1.1", 57 | "yeoman-test": "^7.4.0" 58 | }, 59 | "overrides": { 60 | "minimist": ">=1.2.6" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test/.keepme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ui5-community/generator-ui5-library/acc5714d0f67b78f89b1bb311484e1aca69f702f/test/.keepme --------------------------------------------------------------------------------