Retire js-generator-openstack
This repository is unused, retire it. Change-Id: Ib6b55e118b7092a05dfe6bcbb6bcb66a8b20fdc2 Depends-On: https://review.openstack.org/597370/
This commit is contained in:
		| @@ -1,12 +0,0 @@ | ||||
| root = true | ||||
|  | ||||
| [*] | ||||
| end_of_line = lf | ||||
| insert_final_newline = true | ||||
| charset = utf-8 | ||||
| indent_style = space | ||||
| indent_size = 2 | ||||
| trim_trailing_whitespace = true | ||||
|  | ||||
| [*.md] | ||||
| trim_trailing_whitespace = false | ||||
| @@ -1,6 +0,0 @@ | ||||
| ./dist | ||||
| .npm | ||||
| cover | ||||
| node_modules | ||||
| npm-debug.log | ||||
| package | ||||
| @@ -1,6 +0,0 @@ | ||||
| extends: openstack | ||||
| env: | ||||
|   node: true | ||||
|   jasmine: true | ||||
| rules: | ||||
|   strict: ["error", "global"] | ||||
							
								
								
									
										45
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,45 +0,0 @@ | ||||
| # Logs | ||||
| logs | ||||
| *.log | ||||
| npm-debug.log* | ||||
|  | ||||
| # Runtime data | ||||
| pids | ||||
| *.pid | ||||
| *.seed | ||||
|  | ||||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||||
| lib-cov | ||||
|  | ||||
| # Test reporting directories used by zuul | ||||
| cover | ||||
| reports | ||||
|  | ||||
| # Project output directories | ||||
| package | ||||
| dist | ||||
| www | ||||
| build | ||||
| doc/source/jsdoc | ||||
| *-compiled.js | ||||
| *.js.map | ||||
| *.tgz | ||||
| .vagrant | ||||
|  | ||||
| # Dependency directories | ||||
| node_modules | ||||
| bower_components | ||||
|  | ||||
| # Optional npm cache directory | ||||
| .npm | ||||
|  | ||||
| # Optional REPL history | ||||
| .node_repl_history | ||||
|  | ||||
| # Dev Environment Excludes | ||||
| *.iml | ||||
| .idea | ||||
| clouds.yaml | ||||
|  | ||||
| # OS-specific | ||||
| .DS_Store | ||||
| @@ -1,30 +0,0 @@ | ||||
| verbose: false | ||||
| instrumentation: | ||||
|     root: . | ||||
|     include-all-sources: true | ||||
|     excludes: ['spec/**', 'doc/build/**', 'jsdoc_build/**'] | ||||
|     default-excludes: true | ||||
| reporting: | ||||
|     print: detail | ||||
|     reports: | ||||
|         - lcov | ||||
|         - html | ||||
|     dir: ./cover | ||||
|     watermarks: | ||||
|         statements: [80, 100] | ||||
|         lines: [80, 100] | ||||
|         functions: [80, 100] | ||||
|         branches: [80, 100] | ||||
| check: | ||||
|     global: | ||||
|         statements: 100 | ||||
|         lines: 100 | ||||
|         branches: 100 | ||||
|         functions: 100 | ||||
|         excludes: [] | ||||
|     each: | ||||
|         statements: 100 | ||||
|         lines: 100 | ||||
|         branches: 100 | ||||
|         functions: 100 | ||||
|         excludes: [] | ||||
| @@ -1,9 +0,0 @@ | ||||
| { | ||||
|   "generator-openstack": { | ||||
|     "srcDir": "./generators", | ||||
|     "distDir": "./dist", | ||||
|     "testDir": "./spec", | ||||
|     "engine": "node", | ||||
|     "language": "es5" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										174
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										174
									
								
								LICENSE
									
									
									
									
									
								
							| @@ -1,174 +0,0 @@ | ||||
|                                  Apache License | ||||
|                            Version 2.0, January 2004 | ||||
|                         http://www.apache.org/licenses/ | ||||
|  | ||||
|    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||||
|  | ||||
|    1. Definitions. | ||||
|  | ||||
|       "License" shall mean the terms and conditions for use, reproduction, | ||||
|       and distribution as defined by Sections 1 through 9 of this document. | ||||
|  | ||||
|       "Licensor" shall mean the copyright owner or entity authorized by | ||||
|       the copyright owner that is granting the License. | ||||
|  | ||||
|       "Legal Entity" shall mean the union of the acting entity and all | ||||
|       other entities that control, are controlled by, or are under common | ||||
|       control with that entity. For the purposes of this definition, | ||||
|       "control" means (i) the power, direct or indirect, to cause the | ||||
|       direction or management of such entity, whether by contract or | ||||
|       otherwise, or (ii) ownership of fifty percent (50%) or more of the | ||||
|       outstanding shares, or (iii) beneficial ownership of such entity. | ||||
|  | ||||
|       "You" (or "Your") shall mean an individual or Legal Entity | ||||
|       exercising permissions granted by this License. | ||||
|  | ||||
|       "Source" form shall mean the preferred form for making modifications, | ||||
|       including but not limited to software source code, documentation | ||||
|       source, and configuration files. | ||||
|  | ||||
|       "Object" form shall mean any form resulting from mechanical | ||||
|       transformation or translation of a Source form, including but | ||||
|       not limited to compiled object code, generated documentation, | ||||
|       and conversions to other media types. | ||||
|  | ||||
|       "Work" shall mean the work of authorship, whether in Source or | ||||
|       Object form, made available under the License, as indicated by a | ||||
|       copyright notice that is included in or attached to the work | ||||
|       (an example is provided in the Appendix below). | ||||
|  | ||||
|       "Derivative Works" shall mean any work, whether in Source or Object | ||||
|       form, that is based on (or derived from) the Work and for which the | ||||
|       editorial revisions, annotations, elaborations, or other modifications | ||||
|       represent, as a whole, an original work of authorship. For the purposes | ||||
|       of this License, Derivative Works shall not include works that remain | ||||
|       separable from, or merely link (or bind by name) to the interfaces of, | ||||
|       the Work and Derivative Works thereof. | ||||
|  | ||||
|       "Contribution" shall mean any work of authorship, including | ||||
|       the original version of the Work and any modifications or additions | ||||
|       to that Work or Derivative Works thereof, that is intentionally | ||||
|       submitted to Licensor for inclusion in the Work by the copyright owner | ||||
|       or by an individual or Legal Entity authorized to submit on behalf of | ||||
|       the copyright owner. For the purposes of this definition, "submitted" | ||||
|       means any form of electronic, verbal, or written communication sent | ||||
|       to the Licensor or its representatives, including but not limited to | ||||
|       communication on electronic mailing lists, source code control systems, | ||||
|       and issue tracking systems that are managed by, or on behalf of, the | ||||
|       Licensor for the purpose of discussing and improving the Work, but | ||||
|       excluding communication that is conspicuously marked or otherwise | ||||
|       designated in writing by the copyright owner as "Not a Contribution." | ||||
|  | ||||
|       "Contributor" shall mean Licensor and any individual or Legal Entity | ||||
|       on behalf of whom a Contribution has been received by Licensor and | ||||
|       subsequently incorporated within the Work. | ||||
|  | ||||
|    2. Grant of Copyright License. Subject to the terms and conditions of | ||||
|       this License, each Contributor hereby grants to You a perpetual, | ||||
|       worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||||
|       copyright license to reproduce, prepare Derivative Works of, | ||||
|       publicly display, publicly perform, sublicense, and distribute the | ||||
|       Work and such Derivative Works in Source or Object form. | ||||
|  | ||||
|    3. Grant of Patent License. Subject to the terms and conditions of | ||||
|       this License, each Contributor hereby grants to You a perpetual, | ||||
|       worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||||
|       (except as stated in this section) patent license to make, have made, | ||||
|       use, offer to sell, sell, import, and otherwise transfer the Work, | ||||
|       where such license applies only to those patent claims licensable | ||||
|       by such Contributor that are necessarily infringed by their | ||||
|       Contribution(s) alone or by combination of their Contribution(s) | ||||
|       with the Work to which such Contribution(s) was submitted. If You | ||||
|       institute patent litigation against any entity (including a | ||||
|       cross-claim or counterclaim in a lawsuit) alleging that the Work | ||||
|       or a Contribution incorporated within the Work constitutes direct | ||||
|       or contributory patent infringement, then any patent licenses | ||||
|       granted to You under this License for that Work shall terminate | ||||
|       as of the date such litigation is filed. | ||||
|  | ||||
|    4. Redistribution. You may reproduce and distribute copies of the | ||||
|       Work or Derivative Works thereof in any medium, with or without | ||||
|       modifications, and in Source or Object form, provided that You | ||||
|       meet the following conditions: | ||||
|  | ||||
|       (a) You must give any other recipients of the Work or | ||||
|           Derivative Works a copy of this License; and | ||||
|  | ||||
|       (b) You must cause any modified files to carry prominent notices | ||||
|           stating that You changed the files; and | ||||
|  | ||||
|       (c) You must retain, in the Source form of any Derivative Works | ||||
|           that You distribute, all copyright, patent, trademark, and | ||||
|           attribution notices from the Source form of the Work, | ||||
|           excluding those notices that do not pertain to any part of | ||||
|           the Derivative Works; and | ||||
|  | ||||
|       (d) If the Work includes a "NOTICE" text file as part of its | ||||
|           distribution, then any Derivative Works that You distribute must | ||||
|           include a readable copy of the attribution notices contained | ||||
|           within such NOTICE file, excluding those notices that do not | ||||
|           pertain to any part of the Derivative Works, in at least one | ||||
|           of the following places: within a NOTICE text file distributed | ||||
|           as part of the Derivative Works; within the Source form or | ||||
|           documentation, if provided along with the Derivative Works; or, | ||||
|           within a display generated by the Derivative Works, if and | ||||
|           wherever such third-party notices normally appear. The contents | ||||
|           of the NOTICE file are for informational purposes only and | ||||
|           do not modify the License. You may add Your own attribution | ||||
|           notices within Derivative Works that You distribute, alongside | ||||
|           or as an addendum to the NOTICE text from the Work, provided | ||||
|           that such additional attribution notices cannot be construed | ||||
|           as modifying the License. | ||||
|  | ||||
|       You may add Your own copyright statement to Your modifications and | ||||
|       may provide additional or different license terms and conditions | ||||
|       for use, reproduction, or distribution of Your modifications, or | ||||
|       for any such Derivative Works as a whole, provided Your use, | ||||
|       reproduction, and distribution of the Work otherwise complies with | ||||
|       the conditions stated in this License. | ||||
|  | ||||
|    5. Submission of Contributions. Unless You explicitly state otherwise, | ||||
|       any Contribution intentionally submitted for inclusion in the Work | ||||
|       by You to the Licensor shall be under the terms and conditions of | ||||
|       this License, without any additional terms or conditions. | ||||
|       Notwithstanding the above, nothing herein shall supersede or modify | ||||
|       the terms of any separate license agreement you may have executed | ||||
|       with Licensor regarding such Contributions. | ||||
|  | ||||
|    6. Trademarks. This License does not grant permission to use the trade | ||||
|       names, trademarks, service marks, or product names of the Licensor, | ||||
|       except as required for reasonable and customary use in describing the | ||||
|       origin of the Work and reproducing the content of the NOTICE file. | ||||
|  | ||||
|    7. Disclaimer of Warranty. Unless required by applicable law or | ||||
|       agreed to in writing, Licensor provides the Work (and each | ||||
|       Contributor provides its Contributions) on an "AS IS" BASIS, | ||||
|       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||
|       implied, including, without limitation, any warranties or conditions | ||||
|       of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | ||||
|       PARTICULAR PURPOSE. You are solely responsible for determining the | ||||
|       appropriateness of using or redistributing the Work and assume any | ||||
|       risks associated with Your exercise of permissions under this License. | ||||
|  | ||||
|    8. Limitation of Liability. In no event and under no legal theory, | ||||
|       whether in tort (including negligence), contract, or otherwise, | ||||
|       unless required by applicable law (such as deliberate and grossly | ||||
|       negligent acts) or agreed to in writing, shall any Contributor be | ||||
|       liable to You for damages, including any direct, indirect, special, | ||||
|       incidental, or consequential damages of any character arising as a | ||||
|       result of this License or out of the use or inability to use the | ||||
|       Work (including but not limited to damages for loss of goodwill, | ||||
|       work stoppage, computer failure or malfunction, or any and all | ||||
|       other commercial damages or losses), even if such Contributor | ||||
|       has been advised of the possibility of such damages. | ||||
|  | ||||
|    9. Accepting Warranty or Additional Liability. While redistributing | ||||
|       the Work or Derivative Works thereof, You may choose to offer, | ||||
|       and charge a fee for, acceptance of support, warranty, indemnity, | ||||
|       or other liability obligations and/or rights consistent with this | ||||
|       License. However, in accepting such obligations, You may act only | ||||
|       on Your own behalf and on Your sole responsibility, not on behalf | ||||
|       of any other Contributor, and only if You agree to indemnify, | ||||
|       defend, and hold each Contributor harmless for any liability | ||||
|       incurred by, or claims asserted against, such Contributor by reason | ||||
|       of your accepting any such warranty or additional liability. | ||||
							
								
								
									
										53
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,53 +0,0 @@ | ||||
| # generator-openstack | ||||
|  | ||||
| `generator-openstack` is OpenStack's JavaScript project templating and maintenance engine. It permits you to: | ||||
|  | ||||
| 1. ...create a new OpenStack JavaScript project. | ||||
| 2. ...update an existing project with new settings, requirements, and tools. | ||||
|  | ||||
| ## Quick Start | ||||
|  | ||||
| Creating and updating a project follows the exact same steps: | ||||
|  | ||||
| 1. Prerequisites: `nodejs`, `npm` | ||||
| 2. `npm install -g yo generator-openstack` | ||||
| 3. `cd my_project_directory` | ||||
| 4. `yo openstack` | ||||
|  | ||||
| The generator also provides a non-interactive mode: `yo openstack --non-interactive` | ||||
|  | ||||
| ## Contributing | ||||
|  | ||||
| This project uses itself as a code management tool. In order to set up your environment for development, please follow these steps: | ||||
|  | ||||
| 1. Prerequisites: `nodejs`, `npm`, `git`, `git review` | ||||
| 2. `npm install -g yo` | ||||
| 3. `git clone git://git.openstack.org/openstack/js-generator-openstack` | ||||
| 4. `cd js-generator-openstack` | ||||
| 5. `npm install` | ||||
| 8. `git review -s` | ||||
|  | ||||
| This should set up your project directory and make it ready for development. | ||||
|  | ||||
| ### Some useful development commands | ||||
|  | ||||
| * `npm link` - Link this project into your global npm runtime. This allows you to run the project (via `yo openstack`) as if it was installed via `npm install -g` | ||||
| * `npm test` - Run all the tests. | ||||
| * `npm run lint` - Perform a linting check. | ||||
|  | ||||
| ## TODO List | ||||
|  | ||||
| Looking for something to add? Please check [StoryBoard](https://storyboard.openstack.org/#!/project/842) | ||||
|  | ||||
| ## Project Resources | ||||
|  | ||||
|   - [Source code](https://git.openstack.org/cgit/openstack/js-generator-openstack) | ||||
|   - [Code review](https://review.openstack.org/#/admin/projects/openstack-infra/js-generator-openstack) | ||||
|   - [Task tracking (StoryBoard)](https://storyboard.openstack.org/#!/project/842) | ||||
|   - Discussion on [openstack develop mailing list](http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev) with tag `[javascript]` | ||||
|   - IRC: `#openstack-javascript` on freenode.net | ||||
|  | ||||
| ## Workflow | ||||
|  | ||||
|   - [How to contribute to OpenStack](http://docs.openstack.org/infra/manual/developers.html) | ||||
|   - [Code reviews workflow](http://docs.openstack.org/infra/manual/developers.html#development-workflow) | ||||
							
								
								
									
										10
									
								
								README.rst
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								README.rst
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| This project is no longer maintained. | ||||
|  | ||||
| The contents of this repository are still available in the Git | ||||
| source code management system.  To see the contents of this | ||||
| repository before it reached its end of life, please check out the | ||||
| previous commit with "git checkout HEAD^1". | ||||
|  | ||||
| For any further questions, please email | ||||
| openstack-dev@lists.openstack.org or join #openstack-dev on | ||||
| Freenode. | ||||
							
								
								
									
										43
									
								
								bindep.txt
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								bindep.txt
									
									
									
									
									
								
							| @@ -1,43 +0,0 @@ | ||||
| # This is a cross-platform list tracking distribution packages needed by tests; | ||||
| # see http://docs.openstack.org/infra/bindep/ for additional information. | ||||
|  | ||||
| apt-transport-https | ||||
| lsb-release | ||||
| ant | ||||
| build-essential [platform:dpkg] | ||||
| chromium-browser | ||||
| curl | ||||
| cyrus-sasl-devel [platform:rpm] | ||||
| dbus | ||||
| firefox [!platform:debian] | ||||
| gawk | ||||
| iceweasel [platform:debian] | ||||
| language-pack-en [platform:ubuntu] | ||||
| libcurl-devel [platform:rpm] | ||||
| libcurl4-gnutls-dev [platform:dpkg] | ||||
| libffi-dev [platform:dpkg] | ||||
| libffi-devel [platform:rpm] | ||||
| libjpeg-dev [platform:dpkg] | ||||
| libjpeg-turbo-devel [platform:rpm] | ||||
| libldap2-dev [platform:dpkg] | ||||
| libsasl2-dev [platform:dpkg] | ||||
| libselinux-python [platform:rpm] | ||||
| libuuid-devel [platform:rpm] | ||||
| locales [platform:debian] | ||||
| pkg-config [platform:dpkg] | ||||
| pkgconfig [platform:rpm] | ||||
| python-dev [platform:dpkg] | ||||
| python-devel [platform:rpm] | ||||
| python-libvirt [platform:dpkg] | ||||
| python-lxml | ||||
| python-sphinx [platform:dpkg] | ||||
| python-oslosphinx [platform:dpkg] | ||||
| python3-all-dev [platform:ubuntu-trusty] | ||||
| python3-dev [platform:dpkg] | ||||
| python3-devel [platform:fedora] | ||||
| python3.4 [platform:ubuntu-trusty] | ||||
| python34-devel [platform:centos] | ||||
| unzip | ||||
| uuid-dev [platform:dpkg] | ||||
| xorg-x11-server-Xvfb [platform:rpm] | ||||
| xvfb [platform:dpkg] | ||||
							
								
								
									
										227
									
								
								doc/Makefile
									
									
									
									
									
								
							
							
						
						
									
										227
									
								
								doc/Makefile
									
									
									
									
									
								
							| @@ -1,227 +0,0 @@ | ||||
| # Makefile for Sphinx documentation | ||||
| # | ||||
|  | ||||
| # You can set these variables from the command line. | ||||
| SPHINXOPTS    = | ||||
| SPHINXBUILD   = sphinx-build | ||||
| PAPER         = | ||||
| BUILDDIR      = build | ||||
| VENVDIR       = .venv | ||||
|  | ||||
| # Internal variables. | ||||
| PAPEROPT_a4     = -D latex_paper_size=a4 | ||||
| PAPEROPT_letter = -D latex_paper_size=letter | ||||
| ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source | ||||
| # the i18n builder cannot share the environment and doctrees with the others | ||||
| I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source | ||||
|  | ||||
|  | ||||
| .PHONY: help | ||||
| help: | ||||
| 	@echo "Please use \`make <target>' where <target> is one of" | ||||
| 	@echo "  html       to make standalone HTML files" | ||||
| 	@echo "  dirhtml    to make HTML files named index.html in directories" | ||||
| 	@echo "  singlehtml to make a single large HTML file" | ||||
| 	@echo "  pickle     to make pickle files" | ||||
| 	@echo "  json       to make JSON files" | ||||
| 	@echo "  htmlhelp   to make HTML files and a HTML help project" | ||||
| 	@echo "  qthelp     to make HTML files and a qthelp project" | ||||
| 	@echo "  applehelp  to make an Apple Help Book" | ||||
| 	@echo "  devhelp    to make HTML files and a Devhelp project" | ||||
| 	@echo "  epub       to make an epub" | ||||
| 	@echo "  epub3      to make an epub3" | ||||
| 	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter" | ||||
| 	@echo "  latexpdf   to make LaTeX files and run them through pdflatex" | ||||
| 	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx" | ||||
| 	@echo "  text       to make text files" | ||||
| 	@echo "  man        to make manual pages" | ||||
| 	@echo "  texinfo    to make Texinfo files" | ||||
| 	@echo "  info       to make Texinfo files and run them through makeinfo" | ||||
| 	@echo "  gettext    to make PO message catalogs" | ||||
| 	@echo "  changes    to make an overview of all changed/added/deprecated items" | ||||
| 	@echo "  xml        to make Docutils-native XML files" | ||||
| 	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes" | ||||
| 	@echo "  linkcheck  to check all external links for integrity" | ||||
| 	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)" | ||||
| 	@echo "  coverage   to run coverage check of the documentation (if enabled)" | ||||
| 	@echo "  dummy      to check syntax errors of document sources" | ||||
|  | ||||
| .PHONY: clean | ||||
| clean: | ||||
| 	rm -rf $(BUILDDIR)/* | ||||
|  | ||||
| .PHONY: html | ||||
| html: | ||||
| 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html | ||||
| 	@echo | ||||
| 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." | ||||
|  | ||||
| .PHONY: dirhtml | ||||
| dirhtml: | ||||
| 	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml | ||||
| 	@echo | ||||
| 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." | ||||
|  | ||||
| .PHONY: singlehtml | ||||
| singlehtml: | ||||
| 	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml | ||||
| 	@echo | ||||
| 	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." | ||||
|  | ||||
| .PHONY: pickle | ||||
| pickle: | ||||
| 	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle | ||||
| 	@echo | ||||
| 	@echo "Build finished; now you can process the pickle files." | ||||
|  | ||||
| .PHONY: json | ||||
| json: | ||||
| 	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json | ||||
| 	@echo | ||||
| 	@echo "Build finished; now you can process the JSON files." | ||||
|  | ||||
| .PHONY: htmlhelp | ||||
| htmlhelp: | ||||
| 	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp | ||||
| 	@echo | ||||
| 	@echo "Build finished; now you can run HTML Help Workshop with the" \ | ||||
| 	      ".hhp project file in $(BUILDDIR)/htmlhelp." | ||||
|  | ||||
| .PHONY: qthelp | ||||
| qthelp: | ||||
| 	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp | ||||
| 	@echo | ||||
| 	@echo "Build finished; now you can run "qcollectiongenerator" with the" \ | ||||
| 	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:" | ||||
| 	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/generator-openstack.qhcp" | ||||
| 	@echo "To view the help file:" | ||||
| 	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/generator-openstack.qhc" | ||||
|  | ||||
| .PHONY: applehelp | ||||
| applehelp: | ||||
| 	$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp | ||||
| 	@echo | ||||
| 	@echo "Build finished. The help book is in $(BUILDDIR)/applehelp." | ||||
| 	@echo "N.B. You won't be able to view it unless you put it in" \ | ||||
| 	      "~/Library/Documentation/Help or install it in your application" \ | ||||
| 	      "bundle." | ||||
|  | ||||
| .PHONY: devhelp | ||||
| devhelp: | ||||
| 	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp | ||||
| 	@echo | ||||
| 	@echo "Build finished." | ||||
| 	@echo "To view the help file:" | ||||
| 	@echo "# mkdir -p $$HOME/.local/share/devhelp/generator-openstack" | ||||
| 	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/generator-openstack" | ||||
| 	@echo "# devhelp" | ||||
|  | ||||
| .PHONY: epub | ||||
| epub: | ||||
| 	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub | ||||
| 	@echo | ||||
| 	@echo "Build finished. The epub file is in $(BUILDDIR)/epub." | ||||
|  | ||||
| .PHONY: epub3 | ||||
| epub3: | ||||
| 	$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 | ||||
| 	@echo | ||||
| 	@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." | ||||
|  | ||||
| .PHONY: latex | ||||
| latex: | ||||
| 	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||||
| 	@echo | ||||
| 	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." | ||||
| 	@echo "Run \`make' in that directory to run these through (pdf)latex" \ | ||||
| 	      "(use \`make latexpdf' here to do that automatically)." | ||||
|  | ||||
| .PHONY: latexpdf | ||||
| latexpdf: | ||||
| 	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||||
| 	@echo "Running LaTeX files through pdflatex..." | ||||
| 	$(MAKE) -C $(BUILDDIR)/latex all-pdf | ||||
| 	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." | ||||
|  | ||||
| .PHONY: latexpdfja | ||||
| latexpdfja: | ||||
| 	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||||
| 	@echo "Running LaTeX files through platex and dvipdfmx..." | ||||
| 	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja | ||||
| 	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." | ||||
|  | ||||
| .PHONY: text | ||||
| text: | ||||
| 	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text | ||||
| 	@echo | ||||
| 	@echo "Build finished. The text files are in $(BUILDDIR)/text." | ||||
|  | ||||
| .PHONY: man | ||||
| man: | ||||
| 	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man | ||||
| 	@echo | ||||
| 	@echo "Build finished. The manual pages are in $(BUILDDIR)/man." | ||||
|  | ||||
| .PHONY: texinfo | ||||
| texinfo: | ||||
| 	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo | ||||
| 	@echo | ||||
| 	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." | ||||
| 	@echo "Run \`make' in that directory to run these through makeinfo" \ | ||||
| 	      "(use \`make info' here to do that automatically)." | ||||
|  | ||||
| .PHONY: info | ||||
| info: | ||||
| 	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo | ||||
| 	@echo "Running Texinfo files through makeinfo..." | ||||
| 	make -C $(BUILDDIR)/texinfo info | ||||
| 	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." | ||||
|  | ||||
| .PHONY: gettext | ||||
| gettext: | ||||
| 	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale | ||||
| 	@echo | ||||
| 	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." | ||||
|  | ||||
| .PHONY: changes | ||||
| changes: | ||||
| 	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes | ||||
| 	@echo | ||||
| 	@echo "The overview file is in $(BUILDDIR)/changes." | ||||
|  | ||||
| .PHONY: linkcheck | ||||
| linkcheck: | ||||
| 	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | ||||
| 	@echo | ||||
| 	@echo "Link check complete; look for any errors in the above output " \ | ||||
| 	      "or in $(BUILDDIR)/linkcheck/output.txt." | ||||
|  | ||||
| .PHONY: doctest | ||||
| doctest: | ||||
| 	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest | ||||
| 	@echo "Testing of doctests in the sources finished, look at the " \ | ||||
| 	      "results in $(BUILDDIR)/doctest/output.txt." | ||||
|  | ||||
| .PHONY: coverage | ||||
| coverage: | ||||
| 	$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage | ||||
| 	@echo "Testing of coverage in the sources finished, look at the " \ | ||||
| 	      "results in $(BUILDDIR)/coverage/python.txt." | ||||
|  | ||||
| .PHONY: xml | ||||
| xml: | ||||
| 	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml | ||||
| 	@echo | ||||
| 	@echo "Build finished. The XML files are in $(BUILDDIR)/xml." | ||||
|  | ||||
| .PHONY: pseudoxml | ||||
| pseudoxml: | ||||
| 	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml | ||||
| 	@echo | ||||
| 	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." | ||||
|  | ||||
| .PHONY: dummy | ||||
| dummy: | ||||
| 	$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy | ||||
| 	@echo | ||||
| 	@echo "Build finished. Dummy builder generates no files." | ||||
| @@ -1,87 +0,0 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| # you may not use this file except in compliance with the License. | ||||
| # You may obtain a copy of the License at | ||||
| # | ||||
| #    http://www.apache.org/licenses/LICENSE-2.0 | ||||
| # | ||||
| # Unless required by applicable law or agreed to in writing, software | ||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||
| # implied. | ||||
| # See the License for the specific language governing permissions and | ||||
| # limitations under the License. | ||||
|  | ||||
| import datetime | ||||
| import os | ||||
| import sys | ||||
|  | ||||
| sys.path.insert(0, os.path.abspath('../..')) | ||||
| # -- General configuration ---------------------------------------------------- | ||||
|  | ||||
| # Add any Sphinx extension module names here, as strings. They can be | ||||
| # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. | ||||
| extensions = [ | ||||
|     'sphinx.ext.autodoc', | ||||
|     'oslosphinx' | ||||
| ] | ||||
|  | ||||
| exclude_patterns = [ | ||||
|     'template.rst', | ||||
| ] | ||||
|  | ||||
| # Optionally allow the use of sphinxcontrib.spelling to verify the | ||||
| # spelling of the documents. | ||||
| try: | ||||
|     import sphinxcontrib.spelling | ||||
|     extensions.append('sphinxcontrib.spelling') | ||||
| except ImportError: | ||||
|     pass | ||||
|  | ||||
| # autodoc generation is a bit aggressive and a nuisance when doing heavy | ||||
| # text edit cycles. | ||||
| # execute "export SPHINX_DEBUG=1" in your terminal to disable | ||||
|  | ||||
| # The suffix of source filenames. | ||||
| source_suffix = '.rst' | ||||
|  | ||||
| # The master toctree document. | ||||
| master_doc = 'index' | ||||
|  | ||||
| # General information about the project. | ||||
| project = u'js-generator-openstack' | ||||
| copyright = u'%s, OpenStack Foundation' % datetime.date.today().year | ||||
|  | ||||
| # If true, '()' will be appended to :func: etc. cross-reference text. | ||||
| add_function_parentheses = True | ||||
|  | ||||
| # If true, the current module name will be prepended to all description | ||||
| # unit titles (such as .. function::). | ||||
| add_module_names = True | ||||
|  | ||||
| # The name of the Pygments (syntax highlighting) style to use. | ||||
| pygments_style = 'sphinx' | ||||
|  | ||||
| # -- Options for HTML output -------------------------------------------------- | ||||
|  | ||||
| # The theme to use for HTML and HTML Help pages.  Major themes that come with | ||||
| # Sphinx are currently 'default' and 'sphinxdoc'. | ||||
| # html_theme_path = ["."] | ||||
| # html_theme = '_theme' | ||||
| # html_static_path = ['static'] | ||||
|  | ||||
| # Output file base name for HTML help builder. | ||||
| htmlhelp_basename = '%sdoc' % project | ||||
|  | ||||
| # Grouping the document tree into LaTeX files. List of tuples | ||||
| # (source start file, target name, title, author, documentclass | ||||
| # [howto/manual]). | ||||
| latex_documents = [ | ||||
|     ('index', | ||||
|      '%s.tex' % project, | ||||
|      u'%s Documentation' % project, | ||||
|      u'OpenStack Foundation', 'manual'), | ||||
| ] | ||||
|  | ||||
| # Example configuration for intersphinx: refer to the Python standard library. | ||||
| #intersphinx_mapping = {'http://docs.python.org/': None} | ||||
| @@ -1,55 +0,0 @@ | ||||
| ================= | ||||
| Development Guide | ||||
| ================= | ||||
|  | ||||
| If you would like to contribute to the development of this project, | ||||
| you must follow the steps on this page: | ||||
|  | ||||
|    http://docs.openstack.org/infra/manual/developers.html | ||||
|  | ||||
| If you already have a good understanding of how the system works and your | ||||
| OpenStack accounts are set up, you can skip to the development workflow section | ||||
| of this documentation to learn how changes to OpenStack should be submitted for | ||||
| review via the Gerrit tool: | ||||
|  | ||||
|    http://docs.openstack.org/infra/manual/developers.html#development-workflow | ||||
|  | ||||
| Install Prerequisites | ||||
| ===================== | ||||
|  | ||||
| .. code:: bash | ||||
|  | ||||
|    # Instructions for Ubuntu | ||||
|  | ||||
|    sudo apt-get install nodejs nodejs-legacy npm git git-review pip | ||||
|  | ||||
|    pip install Sphinx oslosphinx | ||||
|  | ||||
|    npm install -g yo | ||||
|  | ||||
|  | ||||
| Bootstrap the Project | ||||
| ===================== | ||||
|  | ||||
| .. code:: bash | ||||
|  | ||||
|    # Clone the repository. | ||||
|    git clone git://git.openstack.org/openstack/js-generator-openstack | ||||
|    cd js-generator-openstack | ||||
|  | ||||
|    # Install project dependencies | ||||
|    npm install | ||||
|  | ||||
|    # Initialize Gerrit | ||||
|    git review -s | ||||
|  | ||||
| This should set up your project directory and make it ready for development. | ||||
|  | ||||
| Useful Commands for Development | ||||
| =============================== | ||||
|  | ||||
| * ``npm link`` - Link this project into your global npm runtime. This allows you to run the project | ||||
|   (via ``yo openstack``) as if it was installed via ``npm install -g`` | ||||
| * ``npm test`` - Run all the tests. | ||||
| * ``npm run lint`` - Perform a linting check. | ||||
| * ``npm run doc`` - Build this documentation (requires Sphinx and oslosphinx) | ||||
| @@ -1,52 +0,0 @@ | ||||
| ========================== | ||||
| OpenStack Yeoman Generator | ||||
| ========================== | ||||
|  | ||||
| Welcome to the documentation for the OpenStack Yeoman Project Generator. This project | ||||
| allows you to create a new OpenStack JavaScript project, and update an existing project | ||||
| with new settings, dependencies, and tools. | ||||
|  | ||||
| Quickstart | ||||
| ========== | ||||
|  | ||||
| If you'd just like to create a new project, you can do so quickly and easily with the following | ||||
| steps: | ||||
|  | ||||
| .. code:: bash | ||||
|  | ||||
|    npm install -g yo generator-openstack | ||||
|  | ||||
|    cd my_project_directory | ||||
|  | ||||
|    yo openstack | ||||
|  | ||||
| From here, you'll be asked a few basic questions about your new project, and once completed, your | ||||
| project will be ready to go! | ||||
|  | ||||
| Contributing | ||||
| ============ | ||||
|  | ||||
| There are several quick and easy ways that you can contribute to this project: | ||||
|  | ||||
| 1. File Bugs on StoryBoard_. | ||||
| 2. Chat on IRC in `#openstack-javascript`_. | ||||
| 3. Review code on gerrit_. | ||||
|  | ||||
| If you'd like to contribute code, and for more information on project tooling, conventions, and | ||||
| setup, please see our :doc:`./development_guide`. | ||||
|  | ||||
| Topics | ||||
| ====== | ||||
|  | ||||
| .. toctree:: | ||||
|      :maxdepth: 2 | ||||
|  | ||||
|      development_guide | ||||
|      specs | ||||
|      reference_documentation | ||||
|  | ||||
|  | ||||
| .. _StoryBoard: https://storyboard.openstack.org/#!/project/842 | ||||
| .. _gerrit: https://review.openstack.org/#/q/status:open+AND+project:openstack/js-generator-openstack,n,z | ||||
| .. _#openstack-javascript: http://webchat.freenode.net/?channels=openstack-javascript | ||||
| .. _Community Code of Conduct: https://www.openstack.org/legal/community-code-of-conduct/ | ||||
| @@ -1,12 +0,0 @@ | ||||
| ======================= | ||||
| Reference Documentation | ||||
| ======================= | ||||
|  | ||||
| Below you will find reference documentation for individual components of the generator. For | ||||
| detailed, method-specific documentation, select the appropriate method below. | ||||
|  | ||||
| .. toctree:: | ||||
|    :maxdepth: 2 | ||||
|    :glob: | ||||
|  | ||||
|    jsdoc/module-* | ||||
| @@ -1,44 +0,0 @@ | ||||
| ===================== | ||||
| Design Specifications | ||||
| ===================== | ||||
|  | ||||
| Priority Specifications | ||||
| ======================= | ||||
|  | ||||
| This is a list of approved design specifications, which are considered | ||||
| high-priority for this project. It is very likely that work is already in | ||||
| progress, however contributions and reviews are always welcome. | ||||
|  | ||||
| .. If you add additional projects to this list, please update the gerrit | ||||
|    query block. | ||||
|  | ||||
| .. toctree:: | ||||
|    :maxdepth: 1 | ||||
|  | ||||
|  | ||||
| Gerrit query for all changes related to priority efforts:: | ||||
|  | ||||
|   status:open AND project:openstack/js-generator-openstack | ||||
|  | ||||
| https://review.openstack.org/#/q/status:open+AND+project:openstack/js-generator-openstack,n,z | ||||
|  | ||||
| Approved Specifications | ||||
| ======================= | ||||
|  | ||||
| These are specifications that have been approved; work may or may not | ||||
| have started on these.  Reviewers will review related changes as time | ||||
| permits. | ||||
|  | ||||
| .. toctree:: | ||||
|    :glob: | ||||
|    :maxdepth: 1 | ||||
|  | ||||
|  | ||||
| Implemented Specifications | ||||
| ========================== | ||||
|  | ||||
| These specifications have already been implemented and are listed here | ||||
| for historical purposes. | ||||
|  | ||||
| .. toctree:: | ||||
|    :maxdepth: 1 | ||||
| @@ -1,107 +0,0 @@ | ||||
| :: | ||||
|  | ||||
|   Copyright <YEARS> <HOLDER>  <--UPDATE THESE | ||||
|  | ||||
|   This work is licensed under a Creative Commons Attribution 3.0 | ||||
|   Unported License. | ||||
|   http://creativecommons.org/licenses/by/3.0/legalcode | ||||
|  | ||||
| .. | ||||
|   This template should be in ReSTructured text. Please do not delete | ||||
|   any of the sections in this template.  If you have nothing to say | ||||
|   for a whole section, just write: "None". For help with syntax, see | ||||
|   http://sphinx-doc.org/rest.html To test out your formatting, see | ||||
|   http://www.tele3.cz/jbar/rest/rest.html | ||||
|  | ||||
| =============================== | ||||
| The Title of Your Specification | ||||
| =============================== | ||||
|  | ||||
| Include the URL of your StoryBoard story: | ||||
|  | ||||
| https://storyboard.openstack.org/... | ||||
|  | ||||
| Introduction paragraph -- why are we doing anything? | ||||
|  | ||||
| Problem Description | ||||
| =================== | ||||
|  | ||||
| A detailed description of the problem. | ||||
|  | ||||
| Proposed Change | ||||
| =============== | ||||
|  | ||||
| Here is where you cover the change you propose to make in detail. How do you | ||||
| propose to solve this problem? | ||||
|  | ||||
| If this is one part of a larger effort make it clear where this piece ends. In | ||||
| other words, what's the scope of this effort? | ||||
|  | ||||
| Alternatives | ||||
| ------------ | ||||
|  | ||||
| This is an optional section, where it does apply we'd just like a demonstration | ||||
| that some thought has been put into why the proposed approach is the best one. | ||||
|  | ||||
| Implementation | ||||
| ============== | ||||
|  | ||||
| Assignee(s) | ||||
| ----------- | ||||
|  | ||||
| Who is leading the writing of the code? Or is this a blueprint where you're | ||||
| throwing it out there to see who picks it up? | ||||
|  | ||||
| If more than one person is working on the implementation, please designate the | ||||
| primary author and contact. | ||||
|  | ||||
| Primary assignee: | ||||
|   <launchpad-id or None> | ||||
|  | ||||
| Can optionally list additional ids if they intend on doing substantial | ||||
| implementation work on this blueprint. | ||||
|  | ||||
| Gerrit Topic | ||||
| ------------ | ||||
|  | ||||
| Use Gerrit topic "<topic_name>" for all patches related to this spec. | ||||
|  | ||||
| .. code-block:: bash | ||||
|  | ||||
|     git-review -t <topic_name> | ||||
|  | ||||
| Work Items | ||||
| ---------- | ||||
|  | ||||
| Work items or tasks -- break the feature up into the things that need to be | ||||
| done to implement it. Those parts might end up being done by different people, | ||||
| but we're mostly trying to understand the timeline for implementation. | ||||
|  | ||||
| Documentation | ||||
| ------------- | ||||
|  | ||||
| Will this require a documentation change?  If so, which documents? | ||||
| Will it impact developer workflow?  Will additional communication need | ||||
| to be made? | ||||
|  | ||||
| Security | ||||
| -------- | ||||
|  | ||||
| Does this introduce any additional security risks, or are there | ||||
| security-related considerations which should be discussed? | ||||
|  | ||||
| Testing | ||||
| ------- | ||||
|  | ||||
| What tests will be available or need to be constructed in order to | ||||
| validate this?  Unit/functional tests, development | ||||
| environments/servers, etc. | ||||
|  | ||||
| Dependencies | ||||
| ============ | ||||
|  | ||||
| - Include specific references to specs and/or stories in storyboard, or in | ||||
|   other projects, that this one either depends on or is related to. | ||||
|  | ||||
| - Does this feature require any new library or program dependencies | ||||
|   not already in use? | ||||
| @@ -1,129 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var yeoman = require('yeoman-generator'); | ||||
| var projectBuilder = require('./lib/project_builder'); | ||||
| var Q = require('q'); | ||||
|  | ||||
| var pkg = require('./lib/component/pkg'); | ||||
| var gerrit = require('./lib/component/gerrit'); | ||||
| var editorconfig = require('./lib/component/editorconfig'); | ||||
| var license = require('./lib/component/license'); | ||||
| var structure = require('./lib/component/structure'); | ||||
| var eslint = require('./lib/component/eslint'); | ||||
| var gitignore = require('./lib/component/gitignore'); | ||||
| var nsp = require('./lib/component/nsp'); | ||||
|  | ||||
| module.exports = yeoman.Base.extend({ | ||||
|  | ||||
|   constructor: function () { | ||||
|     yeoman.Base.apply(this, arguments); | ||||
|  | ||||
|     // Add support for a `--non-interactive` flag | ||||
|     this.option('non-interactive'); | ||||
|  | ||||
|     // If non-interactive is set, force-override all files. | ||||
|     this.conflicter.force = this.options['non-interactive']; | ||||
|   }, | ||||
|  | ||||
|   initializing: function () { | ||||
|     var done = this.async(); | ||||
|  | ||||
|     // Initialize components. | ||||
|     Q(this) | ||||
|       .then(pkg.init)             // Package.json | ||||
|       .then(gerrit.init)          // Gerrit | ||||
|       .then(editorconfig.init)    // Editorconfig | ||||
|       .then(license.init)         // Licensing | ||||
|       .then(structure.init)       // Project Structure | ||||
|       .then(eslint.init)          // Linting | ||||
|       .then(gitignore.init)       // Gitignore | ||||
|       .then(nsp.init)             // NSP | ||||
|       .then(function () { | ||||
|         done(); | ||||
|       }); | ||||
|   }, | ||||
|  | ||||
|   prompting: function () { | ||||
|     var done = this.async(); | ||||
|  | ||||
|     // Prompt components. | ||||
|     Q(this) | ||||
|       .then(pkg.prompt)             // Package.json | ||||
|       .then(gerrit.prompt)          // Gerrit | ||||
|       .then(editorconfig.prompt)    // Editorconfig | ||||
|       .then(license.prompt)         // Licensing | ||||
|       .then(structure.prompt)       // Project Structure | ||||
|       .then(eslint.prompt)          // Linting | ||||
|       .then(gitignore.prompt)       // Gitignore | ||||
|       .then(nsp.prompt)             // NSP | ||||
|       .then(function () { | ||||
|         done(); | ||||
|       }); | ||||
|   }, | ||||
|  | ||||
|   configuring: function () { | ||||
|     var done = this.async(); | ||||
|  | ||||
|     // Configure components. | ||||
|     Q(this) | ||||
|       .then(pkg.configure)             // Package.json | ||||
|       .then(gerrit.configure)          // Gerrit | ||||
|       .then(editorconfig.configure)    // Editorconfig | ||||
|       .then(license.configure)         // Licensing | ||||
|       .then(structure.configure)       // Project Structure | ||||
|       .then(eslint.configure)          // Linting | ||||
|       .then(gitignore.configure)       // Gitignore | ||||
|       .then(nsp.configure)             // NSP | ||||
|       .then(function () { | ||||
|         done(); | ||||
|       }); | ||||
|   }, | ||||
|  | ||||
|   writing: function () { | ||||
|     var self = this; | ||||
|     var config = self.config.getAll(); | ||||
|     var included = projectBuilder.getIncludedFiles(); | ||||
|     var excluded = projectBuilder.getExcludedFiles(); | ||||
|  | ||||
|     // Write out all files included in the project builder. | ||||
|     included.forEach(function (fileRef) { | ||||
|       if (fileRef.hasOwnProperty('content')) { | ||||
|         var content = typeof fileRef.content === 'function' | ||||
|           ? "" + fileRef.content() | ||||
|           : "" + fileRef.content; | ||||
|         self.fs.write(fileRef.to, content); | ||||
|       } else { | ||||
|         self.fs.copyTpl( | ||||
|           self.templatePath(fileRef.from), | ||||
|           self.destinationPath(fileRef.to), | ||||
|           config | ||||
|         ); | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|     // Delete all files explicitly excluded in the project builder. | ||||
|     excluded.forEach(function (path) { | ||||
|       self.fs.delete(self.destinationPath(path)); | ||||
|     }); | ||||
|   }, | ||||
|  | ||||
|   install: function () { | ||||
|     this.npmInstall(); | ||||
|   } | ||||
| }); | ||||
| @@ -1,54 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * editorconfig module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var projectBuilder = require('../project_builder'); | ||||
|  | ||||
| /** | ||||
|  * No-op placeholder method, for handlers we don't need. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function noop (generator) { | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Configure the project by adding required files. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   projectBuilder.addFile('.editorconfig'); | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/editorconfig~noop} */ | ||||
|   init: noop, | ||||
|   /** @see {@link module:component/editorconfig~noop} */ | ||||
|   prompt: noop, | ||||
|   /** @see {@link module:component/editorconfig~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,134 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * eslint module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var pkgBuilder = require('../pkg_builder'); | ||||
| var projectBuilder = require('../project_builder'); | ||||
| var yaml = require('js-yaml'); | ||||
|  | ||||
| var excludedPaths = []; | ||||
| var ignoreFile = '.eslintignore'; | ||||
| var rcFile = '.eslintrc'; | ||||
| var rcContent = {extends: 'openstack'}; | ||||
|  | ||||
| /** | ||||
|  * This method configures the package builder with all options necessary to support eslint. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function prompt (generator) { | ||||
|   // At this time, we don't actually need to prompt the user. | ||||
|  | ||||
|   // Add the dependencies. | ||||
|   pkgBuilder.addDependencies(['eslint', 'eslint-config-openstack'], 'devDependencies'); | ||||
|   pkgBuilder.addCommand('lint', 'eslint ./'); | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Read the existing .eslintrc and .eslintignore files, and populate our initial configuration | ||||
|  * with them. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function init (generator) { | ||||
|   var fs = generator.fs; | ||||
|  | ||||
|   // Re-initialize excluded paths. | ||||
|   excludedPaths = []; | ||||
|  | ||||
|   // Read .eslintignore. | ||||
|   if (fs.exists(ignoreFile)) { | ||||
|     var paths = fs.read(ignoreFile) | ||||
|       .split('\n') | ||||
|       .filter(function (item) { | ||||
|         // Remove empty lines. | ||||
|         return item.length > 0; | ||||
|       }); | ||||
|  | ||||
|     paths.forEach(function (item) { | ||||
|       excludedPaths.push(item); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   // Read .eslintrc | ||||
|   if (fs.exists(rcFile)) { | ||||
|     rcContent = yaml.safeLoad(fs.read(rcFile)); | ||||
|   } | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Configure the project by adding required files. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   if (buildIgnore().length === 0) { | ||||
|     projectBuilder.removeFile('.eslintignore'); | ||||
|   } else { | ||||
|     projectBuilder.writeFile('.eslintignore', buildIgnore); | ||||
|   } | ||||
|   projectBuilder.writeFile('.eslintrc', buildRc); | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Generate the content of our .eslintignore file from the configured list of excluded paths, | ||||
|  * as well as any project-level configured ignoreFiles. | ||||
|  * | ||||
|  * @returns {string} The content of the .eslintignore file. | ||||
|  */ | ||||
| function buildIgnore () { | ||||
|   var ignoredFiles = projectBuilder.getIgnoredFiles(); | ||||
|   ignoredFiles.forEach(function (item) { | ||||
|     if (excludedPaths.indexOf(item) === -1) { | ||||
|       excludedPaths.push(item); | ||||
|     } | ||||
|   }); | ||||
|  | ||||
|   return excludedPaths.sort().join('\n'); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Generate the content of our .eslintrc file from the current configuration. | ||||
|  * | ||||
|  * @returns {string} The content of the .eslintrc file. | ||||
|  */ | ||||
| function buildRc () { | ||||
|   return yaml.safeDump(rcContent); | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/eslint~init} */ | ||||
|   init: init, | ||||
|   /** @see {@link module:component/eslint~prompt} */ | ||||
|   prompt: prompt, | ||||
|   /** @see {@link module:component/eslint~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,152 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * gerrit module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var projectBuilder = require('../project_builder'); | ||||
| var pkgBuilder = require('../pkg_builder'); | ||||
| var ini = require('ini'); | ||||
| var Q = require('q'); | ||||
|  | ||||
| var gerritFile = '.gitreview'; | ||||
| var iniContent; | ||||
| var gerritFileExists = false; | ||||
|  | ||||
| /** | ||||
|  * Internal helper method. Returns true if gerrit has been enabled. | ||||
|  * | ||||
|  * @param {String} answers The collection of answers. | ||||
|  * @returns {Function} True if enableGerrit is set, otherwise false. | ||||
|  */ | ||||
| var gerritEnabled = function(answers) { | ||||
|   return !!answers.enableGerrit; | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Initialize the gerrit component of this generator. In this case, we're | ||||
|  * only adding default configuration values. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function init (generator) { | ||||
|   // Define our defaults | ||||
|   iniContent = { | ||||
|     gerrit: { | ||||
|       host: 'review.openstack.org', | ||||
|       port: '29418', | ||||
|       project: 'openstack/test-project.git' | ||||
|     } | ||||
|   }; | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Initialize the gerrit component of this generator. In this case, we're | ||||
|  * only adding default configuration values. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function prompt (generator) { | ||||
|  | ||||
|   // Read the existing file and populate it as defaults. | ||||
|   if (generator.fs.exists(gerritFile)) { | ||||
|     gerritFileExists = true; | ||||
|     iniContent = ini.parse(generator.fs.read(gerritFile)); | ||||
|   } else { | ||||
|     // Create project name from package name if gerrit file does not exist | ||||
|     var projectName = pkgBuilder.getValue("name"); | ||||
|     iniContent.gerrit.project = 'openstack/' + projectName + '.git'; | ||||
|   } | ||||
|  | ||||
|   var deferred = Q.defer(); | ||||
|  | ||||
|   if (!generator.options['non-interactive']) { | ||||
|     // Go through the prompts. | ||||
|     generator.prompt( | ||||
|       [{ | ||||
|         type: 'confirm', | ||||
|         name: 'enableGerrit', | ||||
|         message: 'Gerrit- Enable:', | ||||
|         default: gerritFileExists | ||||
|       }, { | ||||
|         when: gerritEnabled, | ||||
|         type: 'input', | ||||
|         name: 'gerritHost', | ||||
|         message: 'Gerrit- Host:', | ||||
|         default: iniContent.gerrit.host | ||||
|       }, { | ||||
|         when: gerritEnabled, | ||||
|         type: 'input', | ||||
|         name: 'gerritPort', | ||||
|         message: 'Gerrit- Port:', | ||||
|         default: iniContent.gerrit.port | ||||
|       }, { | ||||
|         when: gerritEnabled, | ||||
|         type: 'input', | ||||
|         name: 'gerritProject', | ||||
|         message: 'Gerrit- Project Path:', | ||||
|         default: iniContent.gerrit.project | ||||
|       }], | ||||
|       function(answers) { | ||||
|         gerritFileExists = answers.enableGerrit; | ||||
|         iniContent.gerrit = { | ||||
|           host: answers.gerritHost, | ||||
|           port: answers.gerritPort, | ||||
|           project: answers.gerritProject | ||||
|         }; | ||||
|         deferred.resolve(generator); | ||||
|       }); | ||||
|   } else { | ||||
|     deferred.resolve(generator); | ||||
|   } | ||||
|   return deferred.promise; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Configure gerrit | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   if (gerritFileExists) { | ||||
|     projectBuilder.writeFile(gerritFile, buildGerritFile); | ||||
|   } else { | ||||
|     projectBuilder.removeFile(gerritFile); | ||||
|   } | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| function buildGerritFile () { | ||||
|   return ini.stringify(iniContent); | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/gerrit~init} */ | ||||
|   init: init, | ||||
|   /** @see {@link module:component/gerrit~prompt} */ | ||||
|   prompt: prompt, | ||||
|   /** @see {@link module:component/gerrit~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,111 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * gitignore module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var projectBuilder = require('../project_builder'); | ||||
|  | ||||
| var excludedPaths = {}; | ||||
| var filePath = '.gitignore'; | ||||
|  | ||||
| /** | ||||
|  * No-op placeholder method, for handlers we don't need. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function noop (generator) { | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Read the existing .gitignore file, and populate our current list of ignores. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function init (generator) { | ||||
|   var fs = generator.fs; | ||||
|  | ||||
|   // Reinitialize the ignore map. | ||||
|   excludedPaths = {}; | ||||
|  | ||||
|   // Read .gitignore. | ||||
|   if (fs.exists(filePath)) { | ||||
|     fs.read(filePath) | ||||
|       // Split into lines | ||||
|       .split('\n') | ||||
|       // Remove empty lines and comments. | ||||
|       .filter(function (item) { | ||||
|         return item.length > 0 && !item.match(/\s*#/); | ||||
|       }) | ||||
|       // Add to our list. | ||||
|       .map(function (line) { | ||||
|         excludedPaths[line] = true; | ||||
|       }); | ||||
|   } | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Generate the .gitignore file from the data we've imported. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   var ignoreContent = buildGitignore(); | ||||
|   if (ignoreContent.length === 0) { | ||||
|     // Delete the file if there's nothing to ignore. | ||||
|     projectBuilder.removeFile(filePath); | ||||
|   } else { | ||||
|     projectBuilder.writeFile(filePath, buildGitignore); | ||||
|   } | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Generate the content of our .gitignore file from the configured list of excluded paths, | ||||
|  * as well as any project-level configured ignoreFiles. | ||||
|  * | ||||
|  * @returns {string} The content of the .eslintignore file. | ||||
|  */ | ||||
| function buildGitignore () { | ||||
|   var ignoredFiles = projectBuilder.getIgnoredFiles(); | ||||
|   for (var i = 0; i < ignoredFiles.length; i++) { | ||||
|     if (!excludedPaths.hasOwnProperty(ignoredFiles[i])) { | ||||
|       excludedPaths[ignoredFiles[i]] = true; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   return Object.keys(excludedPaths).sort().join('\n'); | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/gitignore~init} */ | ||||
|   init: init, | ||||
|   /** @see {@link module:component/gitignore~noop} */ | ||||
|   prompt: noop, | ||||
|   /** @see {@link module:component/gitignore~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,57 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * licence module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var projectBuilder = require('../project_builder'); | ||||
| var pkgBuilder = require('../pkg_builder'); | ||||
|  | ||||
| /** | ||||
|  * No-op placeholder method, for handlers we don't need. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function noop (generator) { | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Configure the project by adding required files. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   projectBuilder.addFile('LICENSE'); | ||||
|   pkgBuilder.setValues({license: 'Apache-2.0'}); | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/license~noop} */ | ||||
|   init: noop, | ||||
|   /** @see {@link module:component/license~noop} */ | ||||
|   prompt: noop, | ||||
|   /** @see {@link module:component/license~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,74 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * This module adds the Node Security commandline tool (nsp) to the project. | ||||
|  * Its job is to identify known vulnerabilities by scanning the projects | ||||
|  * source and dependencies. | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var projectBuilder = require('../project_builder'); | ||||
| var pkgBuilder = require('../pkg_builder'); | ||||
|  | ||||
| /** | ||||
|  * No-op placeholder method, for handlers we don't need. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function noop (generator) { | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * This method configures the package builder with all options necessary | ||||
|  * to run nsp. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function prompt (generator) { | ||||
|   // At this time, we don't actually need to prompt the user. | ||||
|  | ||||
|   // Add the dependencies. | ||||
|   pkgBuilder.addDependencies(['nsp'], 'devDependencies'); | ||||
|   pkgBuilder.addCommand('prepublish', 'nsp check'); | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Configure the project by adding required files. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   projectBuilder.addFile('.nsprc'); | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/nsp~noop} */ | ||||
|   init: noop, | ||||
|   /** @see {@link module:component/nsp~prompt} */ | ||||
|   prompt: prompt, | ||||
|   /** @see {@link module:component/nsp~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,129 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * package module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var Q = require('q'); | ||||
| var hyphenize = require('hyphenize'); | ||||
| var pkgBuilder = require('../pkg_builder'); | ||||
| var projectBuilder = require('../project_builder'); | ||||
|  | ||||
| var packagePath = 'package.json'; | ||||
|  | ||||
| /** | ||||
|  * Iterate over needed package components, ensuring that required | ||||
|  * parameters are set. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function prompt (generator) { | ||||
|   var deferred = Q.defer(); | ||||
|  | ||||
|   if (!generator.options['non-interactive']) { | ||||
|     generator.prompt( | ||||
|       [{ | ||||
|         type: 'input', | ||||
|         name: 'name', | ||||
|         message: 'Project- Name:', | ||||
|         default: pkgBuilder.getValue('name', hyphenize(generator.appname)) | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'description', | ||||
|         message: 'Project- Description:', | ||||
|         default: pkgBuilder.getValue('description') | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'version', | ||||
|         message: 'Project- Version:', | ||||
|         default: pkgBuilder.getValue('version', '0.0.1') | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'homepage', | ||||
|         message: 'Project- Homepage:', | ||||
|         default: pkgBuilder.getValue('homepage', 'http://www.openstack.org/') | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'author', | ||||
|         message: 'Project- Author:', | ||||
|         default: pkgBuilder.getValue('author', | ||||
|           'OpenStack <openstack-dev@lists.openstack.org> (http://www.openstack.org/)') | ||||
|       }], | ||||
|       function (answers) { | ||||
|         pkgBuilder.setValues(answers); | ||||
|         deferred.resolve(generator); | ||||
|       }); | ||||
|   } else { | ||||
|     deferred.resolve(generator); | ||||
|   } | ||||
|  | ||||
|   return deferred.promise; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Read any existing package.json file, to set our defaults. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function init (generator) { | ||||
|   var fs = generator.fs; | ||||
|  | ||||
|   // Read package.json | ||||
|   if (fs.exists(packagePath)) { | ||||
|     pkgBuilder.fromJSON(fs.read(packagePath)); | ||||
|   } | ||||
|  | ||||
|   // Add files that should be ignored overall. | ||||
|   projectBuilder.ignoreFile('node_modules'); | ||||
|   // NPM execution failures. | ||||
|   projectBuilder.ignoreFile('npm-debug.log'); | ||||
|   // If you unzip something generated by npm pack, this is the directory it ends up in. | ||||
|   projectBuilder.ignoreFile('package'); | ||||
|   // Local .npm cache | ||||
|   projectBuilder.ignoreFile('.npm'); | ||||
|  | ||||
|   var devDeps = ['istanbul', 'jasmine']; | ||||
|  | ||||
|   pkgBuilder.addDependencies(devDeps, 'devDependencies'); | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Configure the project by adding required files. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   projectBuilder.writeFile('package.json', pkgBuilder.toJSON); | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:component/pkg~init} */ | ||||
|   init: init, | ||||
|   /** @see {@link module:component/pkg~prompt} */ | ||||
|   prompt: prompt, | ||||
|   /** @see {@link module:component/pkg~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,142 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * This generator module handles questions regarding the project's structure, | ||||
|  * such as engine, common output directories, and language level. It informs | ||||
|  * other generators, such as test framework generation, packaging tools, | ||||
|  * and/or configuration files. | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var Q = require('q'); | ||||
| var projectBuilder = require('../project_builder'); | ||||
|  | ||||
| /** | ||||
|  * Initialize the component by setting configuration defaults. These, or previously set | ||||
|  * versions, will be accessible immediately, however it's good practice not to access them | ||||
|  * until after the prompting phase, as we cannot guarantee that they will be properly set. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function init (generator) { | ||||
|  | ||||
|   // Set our defaults: | ||||
|   generator.config.defaults({ | ||||
|     engine: 'browser', | ||||
|     language: 'es5', | ||||
|     srcDir: './src', | ||||
|     distDir: './dist', | ||||
|     testDir: './test' | ||||
|   }); | ||||
|  | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * If applicable, prompt the user for a project type. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function prompt (generator) { | ||||
|   var deferred = Q.defer(); | ||||
|  | ||||
|   // We default to a node.js project. | ||||
|   if (!generator.options['non-interactive']) { | ||||
|     // Go through the prompts. | ||||
|     generator.prompt( | ||||
|       [{ | ||||
|         type: 'list', | ||||
|         name: 'engine', | ||||
|         message: 'Structure- Runtime Engine:', | ||||
|         choices: [ | ||||
|           { | ||||
|             name: 'Browser', | ||||
|             value: 'browser' | ||||
|           }, | ||||
|           { | ||||
|             name: 'Node.js', | ||||
|             value: 'node' | ||||
|           } | ||||
|         ], | ||||
|         default: generator.config.get('engine') | ||||
|       }, { | ||||
|         type: 'list', | ||||
|         name: 'language', | ||||
|         message: 'Structure- Language:', | ||||
|         choices: [ | ||||
|           { | ||||
|             name: 'ECMAScript 5', | ||||
|             value: 'es5' | ||||
|           }, | ||||
|           { | ||||
|             name: 'ECMAScript 6', | ||||
|             value: 'es6' | ||||
|           } | ||||
|         ], | ||||
|         default: generator.config.get('language') | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'srcDir', | ||||
|         message: 'Structure- Source Directory:', | ||||
|         default: generator.config.get('srcDir') | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'testDir', | ||||
|         message: 'Structure- Test Directory:', | ||||
|         default: generator.config.get('testDir') | ||||
|       }, { | ||||
|         type: 'input', | ||||
|         name: 'distDir', | ||||
|         message: 'Structure- Dist Directory:', | ||||
|         default: generator.config.get('distDir'), | ||||
|         when: function (answers) { | ||||
|           return answers.engine === 'browser'; | ||||
|         } | ||||
|       }], | ||||
|       function (answers) { | ||||
|         generator.config.set(answers); | ||||
|         deferred.resolve(generator); | ||||
|       }); | ||||
|   } else { | ||||
|     deferred.resolve(generator); | ||||
|   } | ||||
|   return deferred.promise; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Add any output directories to the ignore files. | ||||
|  * | ||||
|  * @param {generator} generator The currently active generator. | ||||
|  * @returns {generator} The passed generator, for promise chaining. | ||||
|  */ | ||||
| function configure (generator) { | ||||
|   projectBuilder.ignoreFile(generator.config.get('distDir')); | ||||
|   return generator; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:structure~init} */ | ||||
|   init: init, | ||||
|   /** @see {@link module:structure~prompt} */ | ||||
|   prompt: prompt, | ||||
|   /** @see {@link module:structure~configure} */ | ||||
|   configure: configure | ||||
| }; | ||||
| @@ -1,75 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
| /** | ||||
|  * Access to the global-dependencies.json file. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Global dependency module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var globalDependencies = require('../../../global-dependencies.json'); | ||||
|  | ||||
| /** | ||||
|  * Returns whether a dependency is in the global-dependencies list. | ||||
|  * | ||||
|  * @param {String} name The name of the dependency. | ||||
|  * @returns {Boolean} True if the dependency exists, otherwise false. | ||||
|  */ | ||||
| function contains (name) { | ||||
|   return globalDependencies.hasOwnProperty(name); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Return the current acceptable version of the dependencies, or null. | ||||
|  * | ||||
|  * @param {String} name The dependency name. | ||||
|  * @returns {String|undefined} The version, or undefined. | ||||
|  */ | ||||
| function read (name) { | ||||
|   return globalDependencies[name] || undefined; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Given a list of dependencies, updates this list of dependencies to the versions that are | ||||
|  * currently set in global-dependencies. | ||||
|  * | ||||
|  * @param {{}} dependencies The list of dependencies. | ||||
|  * @returns {{}} The above list of dependencies, with only the appropriate versions updated. | ||||
|  */ | ||||
| function synchronize (dependencies) { | ||||
|   var results = {}; | ||||
|   for (var key in dependencies) { | ||||
|     if (globalDependencies.hasOwnProperty(key)) { | ||||
|       results[key] = globalDependencies[key]; | ||||
|     } else { | ||||
|       results[key] = dependencies[key]; | ||||
|     } | ||||
|   } | ||||
|   return results; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:global_dependencies~contains} */ | ||||
|   contains: contains, | ||||
|   /** @see {@link module:global_dependencies~read} */ | ||||
|   read: read, | ||||
|   /** @see {@link module:global_dependencies~synchronize} */ | ||||
|   synchronize: synchronize | ||||
| }; | ||||
| @@ -1,176 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Package builder module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var dependencies = require('./global_dependencies'); | ||||
| var pkgContent = {}; | ||||
|  | ||||
| /** | ||||
|  * Convert a package.json formatted list of dependencies and update them to the versions | ||||
|  * listed in our global dependencies. | ||||
|  * | ||||
|  * @param {{}} dependencyMap The map of dependencies. | ||||
|  * @returns {{}} A clone of the map, updated with current common versions. | ||||
|  */ | ||||
| function synchronizeDependencies (dependencyMap) { | ||||
|   if (!dependencyMap) { | ||||
|     return undefined; | ||||
|   } | ||||
|  | ||||
|   // Cloning not necessary, handled in dependencies.synchronize(); | ||||
|   return dependencies.synchronize(dependencyMap); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Initialize this builder from a JSON string. | ||||
|  * | ||||
|  * @param {String} pkgString The package string content. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function fromJSON (pkgString) { | ||||
|   pkgContent = JSON.parse(pkgString); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Write the package content to a JSON string. | ||||
|  * | ||||
|  * @returns {String} The JSON content of the package, as a string. | ||||
|  */ | ||||
| function toJSON () { | ||||
|   // Clone the package content so we don't destroy what's in memory... | ||||
|   var newContent = JSON.parse(JSON.stringify(pkgContent)); | ||||
|  | ||||
|   // Synchronize all the dependencies. | ||||
|   newContent.peerDependencies = synchronizeDependencies(newContent.peerDependencies); | ||||
|   newContent.dependencies = synchronizeDependencies(newContent.dependencies); | ||||
|   newContent.devDependencies = synchronizeDependencies(newContent.devDependencies); | ||||
|   return JSON.stringify(newContent, null, 2); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Add libraries to the package dependencies. | ||||
|  * | ||||
|  * @param {Array|String} libraryNames A list of all libraries to add to the dependencies. | ||||
|  * @param {String} type The type of dependency. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function addDependencies (libraryNames, type) { | ||||
|   // Default the type. | ||||
|   type = type || 'dependencies'; | ||||
|  | ||||
|   // Valuecheck type. | ||||
|   if (['devDependencies', 'peerDependencies', 'dependencies'].indexOf(type) === -1) { | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   // Default the array. | ||||
|   if (!Array.isArray(libraryNames)) { | ||||
|     libraryNames = [libraryNames]; | ||||
|   } | ||||
|  | ||||
|   // Make sure the property exists. | ||||
|   if (!pkgContent.hasOwnProperty(type)) { | ||||
|     pkgContent[type] = {}; | ||||
|   } | ||||
|  | ||||
|   // Add the dependency | ||||
|   libraryNames.forEach(function (library) { | ||||
|     var version = dependencies.read(library); | ||||
|     if (version && !pkgContent[type].hasOwnProperty(library)) { | ||||
|       pkgContent[type][library] = version; | ||||
|     } | ||||
|   }); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Set values on the current package. | ||||
|  * | ||||
|  * @param {{}} values A map of values. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function setValues (values) { | ||||
|   for (var key in values) { | ||||
|     // Filter out things from prototype. | ||||
|     if (values.hasOwnProperty(key)) { | ||||
|       pkgContent[key] = values[key]; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get the values of the current package. | ||||
|  * | ||||
|  * @returns {{}} A cloned map of the values. | ||||
|  */ | ||||
| function getValues () { | ||||
|   return JSON.parse(JSON.stringify(pkgContent)); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get a specific value from the package.json file, or a default if the | ||||
|  * value is not set. | ||||
|  * | ||||
|  * @param {String} name The name of the value. | ||||
|  * @param {String} defaultValue A default value to return. | ||||
|  * @returns {{}} A clone of the referenced value. | ||||
|  */ | ||||
| function getValue (name, defaultValue) { | ||||
|   if (pkgContent.hasOwnProperty(name)) { | ||||
|     return JSON.parse(JSON.stringify(pkgContent[name])); | ||||
|   } | ||||
|   return defaultValue || undefined; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Create a specific NPM script command, invoked by 'npm run <name>' or 'npm <name>'. | ||||
|  * | ||||
|  * @param {String} name The name of the script. | ||||
|  * @param {String} command The command to invoke. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function addCommand (name, command) { | ||||
|  | ||||
|   // sanity check, does 'scripts' exist? | ||||
|   if (!pkgContent.hasOwnProperty('scripts')) { | ||||
|     pkgContent.scripts = {}; | ||||
|   } | ||||
|  | ||||
|   // Save/Override the command. | ||||
|   pkgContent.scripts[name] = command; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:pkg_builder~fromJSON} */ | ||||
|   fromJSON: fromJSON, | ||||
|   /** @see {@link module:pkg_builder~toJSON} */ | ||||
|   toJSON: toJSON, | ||||
|   /** @see {@link module:pkg_builder~setValues} */ | ||||
|   setValues: setValues, | ||||
|   /** @see {@link module:pkg_builder~getValues} */ | ||||
|   getValues: getValues, | ||||
|   /** @see {@link module:pkg_builder~getValue} */ | ||||
|   getValue: getValue, | ||||
|   /** @see {@link module:pkg_builder~addDependencies} */ | ||||
|   addDependencies: addDependencies, | ||||
|   /** @see {@link module:pkg_builder~addCommand} */ | ||||
|   addCommand: addCommand | ||||
| }; | ||||
| @@ -1,129 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Project builder module | ||||
|  * @module | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var includedFiles = []; | ||||
| var excludedFiles = []; | ||||
| var ignoredFiles = []; | ||||
|  | ||||
| /** | ||||
|  * Ensure that a file is removed, or not present, in the project. | ||||
|  * | ||||
|  * @param {String} destinationPath Path to the file, relative to output root. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function removeFile (destinationPath) { | ||||
|   excludedFiles.push(destinationPath); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Flag a file path as 'ignored'. | ||||
|  * | ||||
|  * This does not have a real impact on which files are created/removed from the bootstrapped | ||||
|  * project, however it does permit other modules to retrieve this list and modify their | ||||
|  * behavior accordingly. For example, eslint could use this to generate .eslintignore | ||||
|  * | ||||
|  * @param {String} destinationPath Path to the file, relative to output root. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function ignoreFile (destinationPath) { | ||||
|   ignoredFiles.push(destinationPath); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Add a file to the project. | ||||
|  * | ||||
|  * @param {String} sourcePath Path to the file, relative to ./templates/ | ||||
|  * @param {String} destinationPath Destination path relative to output root. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function addFile (sourcePath, destinationPath) { | ||||
|   includedFiles.push({from: sourcePath, to: destinationPath || sourcePath}); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Write a file to the project. | ||||
|  * | ||||
|  * @param {String} destinationPath The destination for the file. | ||||
|  * @param {String|Function} content A string of content, or method that returns one. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function writeFile (destinationPath, content) { | ||||
|   includedFiles.push({to: destinationPath, content: content}); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get a list of all files that are to be included. | ||||
|  * | ||||
|  * @returns {Array} A list of all file mappings: {from:, to:} | ||||
|  */ | ||||
| function getIncludedFiles () { | ||||
|   return includedFiles; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get a list of all file paths that should be excluded. | ||||
|  * | ||||
|  * @returns {Array} A list of file paths. | ||||
|  */ | ||||
| function getExcludedFiles () { | ||||
|   return excludedFiles; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get a list of all file paths that should be ignored. | ||||
|  * | ||||
|  * @returns {Array} A list of file paths. | ||||
|  */ | ||||
| function getIgnoredFiles () { | ||||
|   return ignoredFiles; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Clear the current configuration. | ||||
|  * | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function clear () { | ||||
|   includedFiles = []; | ||||
|   excludedFiles = []; | ||||
|   ignoredFiles = []; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   /** @see {@link module:project_builder~addFile} */ | ||||
|   addFile: addFile, | ||||
|   /** @see {@link module:project_builder~writeFile} */ | ||||
|   writeFile: writeFile, | ||||
|   /** @see {@link module:project_builder~removeFile} */ | ||||
|   removeFile: removeFile, | ||||
|   /** @see {@link module:project_builder~ignoreFile} */ | ||||
|   ignoreFile: ignoreFile, | ||||
|   /** @see {@link module:project_builder~getIncludedFiles} */ | ||||
|   getIncludedFiles: getIncludedFiles, | ||||
|   /** @see {@link module:project_builder~getIgnoredFiles} */ | ||||
|   getIgnoredFiles: getIgnoredFiles, | ||||
|   /** @see {@link module:project_builder~getExcludedFiles} */ | ||||
|   getExcludedFiles: getExcludedFiles, | ||||
|   /** @see {@link module:project_builder~clear} */ | ||||
|   clear: clear | ||||
| }; | ||||
| @@ -1,12 +0,0 @@ | ||||
| root = true | ||||
|  | ||||
| [*] | ||||
| end_of_line = lf | ||||
| insert_final_newline = true | ||||
| charset = utf-8 | ||||
| indent_style = space | ||||
| indent_size = 2 | ||||
| trim_trailing_whitespace = true | ||||
|  | ||||
| [*.md] | ||||
| trim_trailing_whitespace = false | ||||
							
								
								
									
										45
									
								
								generators/app/templates/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								generators/app/templates/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,45 +0,0 @@ | ||||
| # Logs | ||||
| logs | ||||
| *.log | ||||
| npm-debug.log* | ||||
|  | ||||
| # Runtime data | ||||
| pids | ||||
| *.pid | ||||
| *.seed | ||||
|  | ||||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||||
| lib-cov | ||||
|  | ||||
| # Test reporting directories used by zuul | ||||
| cover | ||||
| reports | ||||
|  | ||||
| # Project output directories | ||||
| package | ||||
| dist | ||||
| www | ||||
| build | ||||
| doc/source/jsdoc | ||||
| *-compiled.js | ||||
| *.js.map | ||||
| *.tgz | ||||
| .vagrant | ||||
|  | ||||
| # Dependency directories | ||||
| node_modules | ||||
| bower_components | ||||
|  | ||||
| # Optional npm cache directory | ||||
| .npm | ||||
|  | ||||
| # Optional REPL history | ||||
| .node_repl_history | ||||
|  | ||||
| # Dev Environment Excludes | ||||
| *.iml | ||||
| .idea | ||||
| clouds.yaml | ||||
|  | ||||
| # OS-specific | ||||
| .DS_Store | ||||
| @@ -1,174 +0,0 @@ | ||||
|                                  Apache License | ||||
|                            Version 2.0, January 2004 | ||||
|                         http://www.apache.org/licenses/ | ||||
|  | ||||
|    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||||
|  | ||||
|    1. Definitions. | ||||
|  | ||||
|       "License" shall mean the terms and conditions for use, reproduction, | ||||
|       and distribution as defined by Sections 1 through 9 of this document. | ||||
|  | ||||
|       "Licensor" shall mean the copyright owner or entity authorized by | ||||
|       the copyright owner that is granting the License. | ||||
|  | ||||
|       "Legal Entity" shall mean the union of the acting entity and all | ||||
|       other entities that control, are controlled by, or are under common | ||||
|       control with that entity. For the purposes of this definition, | ||||
|       "control" means (i) the power, direct or indirect, to cause the | ||||
|       direction or management of such entity, whether by contract or | ||||
|       otherwise, or (ii) ownership of fifty percent (50%) or more of the | ||||
|       outstanding shares, or (iii) beneficial ownership of such entity. | ||||
|  | ||||
|       "You" (or "Your") shall mean an individual or Legal Entity | ||||
|       exercising permissions granted by this License. | ||||
|  | ||||
|       "Source" form shall mean the preferred form for making modifications, | ||||
|       including but not limited to software source code, documentation | ||||
|       source, and configuration files. | ||||
|  | ||||
|       "Object" form shall mean any form resulting from mechanical | ||||
|       transformation or translation of a Source form, including but | ||||
|       not limited to compiled object code, generated documentation, | ||||
|       and conversions to other media types. | ||||
|  | ||||
|       "Work" shall mean the work of authorship, whether in Source or | ||||
|       Object form, made available under the License, as indicated by a | ||||
|       copyright notice that is included in or attached to the work | ||||
|       (an example is provided in the Appendix below). | ||||
|  | ||||
|       "Derivative Works" shall mean any work, whether in Source or Object | ||||
|       form, that is based on (or derived from) the Work and for which the | ||||
|       editorial revisions, annotations, elaborations, or other modifications | ||||
|       represent, as a whole, an original work of authorship. For the purposes | ||||
|       of this License, Derivative Works shall not include works that remain | ||||
|       separable from, or merely link (or bind by name) to the interfaces of, | ||||
|       the Work and Derivative Works thereof. | ||||
|  | ||||
|       "Contribution" shall mean any work of authorship, including | ||||
|       the original version of the Work and any modifications or additions | ||||
|       to that Work or Derivative Works thereof, that is intentionally | ||||
|       submitted to Licensor for inclusion in the Work by the copyright owner | ||||
|       or by an individual or Legal Entity authorized to submit on behalf of | ||||
|       the copyright owner. For the purposes of this definition, "submitted" | ||||
|       means any form of electronic, verbal, or written communication sent | ||||
|       to the Licensor or its representatives, including but not limited to | ||||
|       communication on electronic mailing lists, source code control systems, | ||||
|       and issue tracking systems that are managed by, or on behalf of, the | ||||
|       Licensor for the purpose of discussing and improving the Work, but | ||||
|       excluding communication that is conspicuously marked or otherwise | ||||
|       designated in writing by the copyright owner as "Not a Contribution." | ||||
|  | ||||
|       "Contributor" shall mean Licensor and any individual or Legal Entity | ||||
|       on behalf of whom a Contribution has been received by Licensor and | ||||
|       subsequently incorporated within the Work. | ||||
|  | ||||
|    2. Grant of Copyright License. Subject to the terms and conditions of | ||||
|       this License, each Contributor hereby grants to You a perpetual, | ||||
|       worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||||
|       copyright license to reproduce, prepare Derivative Works of, | ||||
|       publicly display, publicly perform, sublicense, and distribute the | ||||
|       Work and such Derivative Works in Source or Object form. | ||||
|  | ||||
|    3. Grant of Patent License. Subject to the terms and conditions of | ||||
|       this License, each Contributor hereby grants to You a perpetual, | ||||
|       worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||||
|       (except as stated in this section) patent license to make, have made, | ||||
|       use, offer to sell, sell, import, and otherwise transfer the Work, | ||||
|       where such license applies only to those patent claims licensable | ||||
|       by such Contributor that are necessarily infringed by their | ||||
|       Contribution(s) alone or by combination of their Contribution(s) | ||||
|       with the Work to which such Contribution(s) was submitted. If You | ||||
|       institute patent litigation against any entity (including a | ||||
|       cross-claim or counterclaim in a lawsuit) alleging that the Work | ||||
|       or a Contribution incorporated within the Work constitutes direct | ||||
|       or contributory patent infringement, then any patent licenses | ||||
|       granted to You under this License for that Work shall terminate | ||||
|       as of the date such litigation is filed. | ||||
|  | ||||
|    4. Redistribution. You may reproduce and distribute copies of the | ||||
|       Work or Derivative Works thereof in any medium, with or without | ||||
|       modifications, and in Source or Object form, provided that You | ||||
|       meet the following conditions: | ||||
|  | ||||
|       (a) You must give any other recipients of the Work or | ||||
|           Derivative Works a copy of this License; and | ||||
|  | ||||
|       (b) You must cause any modified files to carry prominent notices | ||||
|           stating that You changed the files; and | ||||
|  | ||||
|       (c) You must retain, in the Source form of any Derivative Works | ||||
|           that You distribute, all copyright, patent, trademark, and | ||||
|           attribution notices from the Source form of the Work, | ||||
|           excluding those notices that do not pertain to any part of | ||||
|           the Derivative Works; and | ||||
|  | ||||
|       (d) If the Work includes a "NOTICE" text file as part of its | ||||
|           distribution, then any Derivative Works that You distribute must | ||||
|           include a readable copy of the attribution notices contained | ||||
|           within such NOTICE file, excluding those notices that do not | ||||
|           pertain to any part of the Derivative Works, in at least one | ||||
|           of the following places: within a NOTICE text file distributed | ||||
|           as part of the Derivative Works; within the Source form or | ||||
|           documentation, if provided along with the Derivative Works; or, | ||||
|           within a display generated by the Derivative Works, if and | ||||
|           wherever such third-party notices normally appear. The contents | ||||
|           of the NOTICE file are for informational purposes only and | ||||
|           do not modify the License. You may add Your own attribution | ||||
|           notices within Derivative Works that You distribute, alongside | ||||
|           or as an addendum to the NOTICE text from the Work, provided | ||||
|           that such additional attribution notices cannot be construed | ||||
|           as modifying the License. | ||||
|  | ||||
|       You may add Your own copyright statement to Your modifications and | ||||
|       may provide additional or different license terms and conditions | ||||
|       for use, reproduction, or distribution of Your modifications, or | ||||
|       for any such Derivative Works as a whole, provided Your use, | ||||
|       reproduction, and distribution of the Work otherwise complies with | ||||
|       the conditions stated in this License. | ||||
|  | ||||
|    5. Submission of Contributions. Unless You explicitly state otherwise, | ||||
|       any Contribution intentionally submitted for inclusion in the Work | ||||
|       by You to the Licensor shall be under the terms and conditions of | ||||
|       this License, without any additional terms or conditions. | ||||
|       Notwithstanding the above, nothing herein shall supersede or modify | ||||
|       the terms of any separate license agreement you may have executed | ||||
|       with Licensor regarding such Contributions. | ||||
|  | ||||
|    6. Trademarks. This License does not grant permission to use the trade | ||||
|       names, trademarks, service marks, or product names of the Licensor, | ||||
|       except as required for reasonable and customary use in describing the | ||||
|       origin of the Work and reproducing the content of the NOTICE file. | ||||
|  | ||||
|    7. Disclaimer of Warranty. Unless required by applicable law or | ||||
|       agreed to in writing, Licensor provides the Work (and each | ||||
|       Contributor provides its Contributions) on an "AS IS" BASIS, | ||||
|       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||
|       implied, including, without limitation, any warranties or conditions | ||||
|       of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | ||||
|       PARTICULAR PURPOSE. You are solely responsible for determining the | ||||
|       appropriateness of using or redistributing the Work and assume any | ||||
|       risks associated with Your exercise of permissions under this License. | ||||
|  | ||||
|    8. Limitation of Liability. In no event and under no legal theory, | ||||
|       whether in tort (including negligence), contract, or otherwise, | ||||
|       unless required by applicable law (such as deliberate and grossly | ||||
|       negligent acts) or agreed to in writing, shall any Contributor be | ||||
|       liable to You for damages, including any direct, indirect, special, | ||||
|       incidental, or consequential damages of any character arising as a | ||||
|       result of this License or out of the use or inability to use the | ||||
|       Work (including but not limited to damages for loss of goodwill, | ||||
|       work stoppage, computer failure or malfunction, or any and all | ||||
|       other commercial damages or losses), even if such Contributor | ||||
|       has been advised of the possibility of such damages. | ||||
|  | ||||
|    9. Accepting Warranty or Additional Liability. While redistributing | ||||
|       the Work or Derivative Works thereof, You may choose to offer, | ||||
|       and charge a fee for, acceptance of support, warranty, indemnity, | ||||
|       or other liability obligations and/or rights consistent with this | ||||
|       License. However, in accepting such obligations, You may act only | ||||
|       on Your own behalf and on Your sole responsibility, not on behalf | ||||
|       of any other Contributor, and only if You agree to indemnify, | ||||
|       defend, and hold each Contributor harmless for any liability | ||||
|       incurred by, or claims asserted against, such Contributor by reason | ||||
|       of your accepting any such warranty or additional liability. | ||||
| @@ -1,12 +0,0 @@ | ||||
| { | ||||
|   "ini": "^1.3.4", | ||||
|   "js-yaml": "^3.5.5", | ||||
|   "q": "^1.4.1", | ||||
|   "eslint": "^3", | ||||
|   "eslint-config-openstack": "4", | ||||
|   "istanbul": "^0.4.2", | ||||
|   "jasmine": "^2.4.1", | ||||
|   "karma": "^0.13.22", | ||||
|   "karma-htmlfile-reporter": "^0.2.2", | ||||
|   "nsp": "^2.3.0" | ||||
| } | ||||
							
								
								
									
										49
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,49 +0,0 @@ | ||||
| { | ||||
|   "name": "generator-openstack", | ||||
|   "homepage": "http://www.openstack.org/", | ||||
|   "version": "1.2.0", | ||||
|   "description": "Yeoman Project Generator for OpenStack JavaScript Projects", | ||||
|   "main": "index.js", | ||||
|   "scripts": { | ||||
|     "test": "istanbul cover jasmine", | ||||
|     "posttest": "istanbul check-coverage", | ||||
|     "prepublish": "nsp check", | ||||
|     "lint": "eslint ./", | ||||
|     "docs": "npm run jsdoc; (cd doc; make html)", | ||||
|     "jsdoc": "jsdoc -t node_modules/jsdoc-sphinx/template -r -d ./doc/source/jsdoc ./generators/app/lib" | ||||
|   }, | ||||
|   "keywords": [ | ||||
|     "yeoman-generator", | ||||
|     "openstack" | ||||
|   ], | ||||
|   "files": [ | ||||
|     "generators", | ||||
|     "global-dependencies.json" | ||||
|   ], | ||||
|   "author": "OpenStack <openstack-dev@lists.openstack.org> (http://www.openstack.org/)", | ||||
|   "license": "Apache-2.0", | ||||
|   "dependencies": { | ||||
|     "hyphenize": "0.0.2", | ||||
|     "ini": "^1.3.4", | ||||
|     "js-yaml": "^3.5.5", | ||||
|     "q": "^1.4.1", | ||||
|     "semver": "^5.1.0", | ||||
|     "yeoman-generator": "^0.24.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^3.3.1", | ||||
|     "eslint-config-openstack": "^4.0.1", | ||||
|     "istanbul": "^0.4.2", | ||||
|     "jasmine": "^2.4.1", | ||||
|     "jsdoc": "^3.4.0", | ||||
|     "jsdoc-sphinx": "0.0.6", | ||||
|     "karma": "^0.13.22", | ||||
|     "karma-htmlfile-reporter": "^0.2.2", | ||||
|     "mem-fs": "^1.1.2", | ||||
|     "mem-fs-editor": "^2.2.0", | ||||
|     "nsp": "^2.3.0", | ||||
|     "yeoman-assert": "^2.1.2", | ||||
|     "yeoman-test": "^1.1.0" | ||||
|   }, | ||||
|   "repository": "git://git.openstack.org/openstack-infra/js-generator-openstack" | ||||
| } | ||||
| @@ -1,112 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var path = require('path'); | ||||
| var assert = require('yeoman-assert'); | ||||
| var helpers = require('yeoman-test'); | ||||
|  | ||||
| var generator = path.join(__dirname, '../../generators/app'); | ||||
| var modules = ['gerrit', 'license', 'editorconfig']; | ||||
| var projectBuilder = require('../../generators/app/lib/project_builder'); | ||||
|  | ||||
| describe('generator-openstack:app', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should call all module lifecycle prompts', | ||||
|     function (done) { | ||||
|       var spies = []; | ||||
|       modules.forEach(function (name) { | ||||
|         var module = require('../../generators/app/lib/component/' + name); | ||||
|         spies.push(spyOn(module, 'init').and.callThrough()); | ||||
|         spies.push(spyOn(module, 'prompt').and.callThrough()); | ||||
|         spies.push(spyOn(module, 'configure').and.callThrough()); | ||||
|       }); | ||||
|  | ||||
|       helpers.run(generator) | ||||
|         .withArguments(['--non-interactive']) | ||||
|         .on('end', function () { | ||||
|           spies.forEach(function (spy) { | ||||
|             expect(spy.calls.any()).toBeTruthy(); | ||||
|           }); | ||||
|  | ||||
|           done(); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|   it('should force overwrite if --non-interactive is set.', | ||||
|     function (done) { | ||||
|       helpers.run(generator) | ||||
|         .withArguments(['--non-interactive']) | ||||
|         .on('ready', function (generator) { | ||||
|           expect(generator.conflicter.force).toBeTruthy(); | ||||
|         }) | ||||
|         .on('end', function () { | ||||
|           done(); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|   describe('writing()', function () { | ||||
|     it('should create all files created in the project builder', | ||||
|       function (done) { | ||||
|         helpers.run(generator) | ||||
|           .withArguments(['--non-interactive']) | ||||
|           .on('end', function () { | ||||
|             assert.file(['package.json']); | ||||
|             done(); | ||||
|           }); | ||||
|       }); | ||||
|  | ||||
|     it('should write any files provided to the content builder', | ||||
|       function (done) { | ||||
|         projectBuilder.writeFile('test.json', function () { | ||||
|           return 'foo'; | ||||
|         }); | ||||
|         projectBuilder.writeFile('test_null.json', function () { | ||||
|           // do nothing. | ||||
|         }); | ||||
|         projectBuilder.writeFile('test_empty.json', function () { | ||||
|           return ''; | ||||
|         }); | ||||
|         projectBuilder.writeFile('test_static.json', 'static_content'); | ||||
|         projectBuilder.writeFile('test_undefined.json'); | ||||
|  | ||||
|         helpers.run(generator) | ||||
|           .withArguments(['--non-interactive']) | ||||
|           .on('end', function () { | ||||
|             assert.file(['test.json', 'test_static.json', 'test_empty.json', 'test_null.json', | ||||
|               'test_undefined.json']); | ||||
|             done(); | ||||
|           }); | ||||
|       }); | ||||
|  | ||||
|     it('should delete all files flagged in the project builder', | ||||
|       function (done) { | ||||
|         projectBuilder.removeFile('test.json'); | ||||
|  | ||||
|         helpers.run(generator) | ||||
|           .withArguments(['--non-interactive']) | ||||
|           .on('end', function () { | ||||
|             assert.noFile(['test.json']); | ||||
|             done(); | ||||
|           }); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,87 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var editorconfig = require(libDir + '/component/editorconfig'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var mockGenerator; | ||||
|  | ||||
| describe('generator-openstack:lib/component/editorconfig', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof editorconfig.init).toBe('function'); | ||||
|       expect(typeof editorconfig.prompt).toBe('function'); | ||||
|       expect(typeof editorconfig.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = editorconfig.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should do nothing', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator.config, 'defaults'); | ||||
|         editorconfig.init(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = editorconfig.prompt(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should do nothing', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator, 'prompt'); | ||||
|         editorconfig.prompt(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = editorconfig.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add editorconfig to the project files.', | ||||
|       function () { | ||||
|         editorconfig.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         expect(files.length).toBe(1); | ||||
|         expect(files[0].from).toBe('.editorconfig'); | ||||
|         expect(files[0].to).toBe('.editorconfig'); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,263 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
| var mockGenerator; | ||||
| var mockEslintIgnore = ['node_modules', 'bower_components', 'dist']; | ||||
|  | ||||
| var eslint = require(libDir + '/component/eslint'); | ||||
| var pkgBuilder = require(libDir + '/pkg_builder'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var yaml = require('js-yaml'); | ||||
|  | ||||
| describe('generator-openstack:lib/component/eslint', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof eslint.init).toBe('function'); | ||||
|       expect(typeof eslint.prompt).toBe('function'); | ||||
|       expect(typeof eslint.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = eslint.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should not interact with config', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator.config, 'defaults'); | ||||
|         eslint.init(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = eslint.prompt(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add eslint and eslint-config-openstack to the project', | ||||
|       function () { | ||||
|         pkgBuilder.fromJSON('{"devDependencies":{}}'); | ||||
|  | ||||
|         var devDeps = pkgBuilder.getValue('devDependencies'); | ||||
|         expect(devDeps.eslint).not.toBeDefined(); | ||||
|         expect(devDeps['eslint-config-openstack']).not.toBeDefined(); | ||||
|  | ||||
|         eslint.prompt(mockGenerator); | ||||
|  | ||||
|         devDeps = pkgBuilder.getValue('devDependencies'); | ||||
|         expect(devDeps.eslint).toBeDefined(); | ||||
|         expect(devDeps['eslint-config-openstack']).toBeDefined(); | ||||
|       }); | ||||
|  | ||||
|     it('should add the lint command to the project', | ||||
|       function () { | ||||
|         pkgBuilder.fromJSON('{}'); | ||||
|  | ||||
|         var scripts = pkgBuilder.getValue('scripts'); | ||||
|         expect(scripts).not.toBeDefined(); | ||||
|  | ||||
|         eslint.prompt(mockGenerator); | ||||
|  | ||||
|         var newScripts = pkgBuilder.getValue('scripts'); | ||||
|         expect(newScripts.lint).toBeDefined(); | ||||
|         expect(newScripts.lint).toEqual('eslint ./'); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = eslint.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add .eslintrc and .eslintignore to the project files.', | ||||
|       function () { | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         expect(files.length).toBe(2); | ||||
|         expect(files[0].to).toBe('.eslintignore'); | ||||
|         expect(files[1].to).toBe('.eslintrc'); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('.eslintrc management', function () { | ||||
|     var mockEslintRc = { | ||||
|       extends: 'openstack', | ||||
|       plugins: ['angular'] | ||||
|     }; | ||||
|  | ||||
|     it('should write a .eslintrc file as valid .yaml', | ||||
|       function () { | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var eslintRcRef = files[1]; | ||||
|         expect(eslintRcRef.to).toBe('.eslintrc'); | ||||
|         expect(yaml.safeLoad(eslintRcRef.content())) | ||||
|           .toEqual({extends: 'openstack'}); | ||||
|       }); | ||||
|  | ||||
|     it('should echo back existing .eslintrc', | ||||
|       function () { | ||||
|         var yamlContent = yaml.safeDump(mockEslintRc); | ||||
|         mockGenerator.fs.write('.eslintrc', yamlContent); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var eslintRcRef = files[1]; | ||||
|         var eslintContent = yaml.safeLoad(eslintRcRef.content()); | ||||
|         expect(mockEslintRc).toEqual(eslintContent); | ||||
|       }); | ||||
|  | ||||
|     it('should convert a json .eslintrc to yaml', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.eslintrc', JSON.stringify(mockEslintRc)); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var eslintRcRef = files[1]; | ||||
|         var eslintContent = yaml.safeLoad(eslintRcRef.content()); | ||||
|         expect(mockEslintRc).toEqual(eslintContent); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('.eslintignore management', function () { | ||||
|  | ||||
|     it('should echo back existing .eslintignore', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.prompt(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(mockEslintIgnore.length); | ||||
|  | ||||
|         ignoreContent.forEach(function (item) { | ||||
|           expect(mockEslintIgnore.indexOf(item)).not.toBe(-1); | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should include any files flagged as ignored in the project builder.', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.eslintignore', ''); | ||||
|         projectBuilder.ignoreFile('foo/bar.json'); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.prompt(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; // There should only be one file. | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(1); | ||||
|  | ||||
|         expect(ignoreContent[0]).toBe('foo/bar.json'); | ||||
|       }); | ||||
|  | ||||
|     it('should de-duplicate file paths from multiple locations.', | ||||
|       function () { | ||||
|         // include 'node_modules' from both an existing file and from the project builder. | ||||
|         mockGenerator.fs.write('.eslintignore', ['node_modules'].join('\n')); | ||||
|         projectBuilder.ignoreFile('node_modules'); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.prompt(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; // There should only be one file. | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(1); | ||||
|  | ||||
|         expect(ignoreContent[0]).toBe('node_modules'); | ||||
|       }); | ||||
|  | ||||
|     it('should sort the ignored files.', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.prompt(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent[0]).toBe('bower_components'); | ||||
|         expect(ignoreContent[1]).toBe('dist'); | ||||
|         expect(ignoreContent[2]).toBe('node_modules'); | ||||
|       }); | ||||
|  | ||||
|     it('should remove any whitespace from the existing .eslintignore', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.eslintignore', ['1_one', '', '2_two', ''].join('\n')); | ||||
|  | ||||
|         eslint.init(mockGenerator); | ||||
|         eslint.prompt(mockGenerator); | ||||
|         eslint.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(2); | ||||
|         expect(ignoreContent[0]).toBe('1_one'); | ||||
|         expect(ignoreContent[1]).toBe('2_two'); | ||||
|       }); | ||||
|  | ||||
|     it('should delete the file if there\'s nothing to ignore', function () { | ||||
|       mockGenerator.fs.write('.eslintignore', ''); | ||||
|  | ||||
|       eslint.init(mockGenerator); | ||||
|       eslint.prompt(mockGenerator); | ||||
|       eslint.configure(mockGenerator); | ||||
|  | ||||
|       var files = projectBuilder.getIncludedFiles(); | ||||
|       expect(files.length).toBe(1); | ||||
|       expect(files[0].to).not.toBe('.eslintignore'); | ||||
|  | ||||
|       var rmFiles = projectBuilder.getExcludedFiles(); | ||||
|       expect(rmFiles.length).toBe(1); | ||||
|       expect(rmFiles[0]).toBe('.eslintignore'); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,272 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var ini = require('ini'); | ||||
|  | ||||
| var gerrit = require(libDir + '/component/gerrit'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var pkgBuilder = require(libDir + '/pkg_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
|  | ||||
| var iniFile = { | ||||
|   gerrit: { | ||||
|     host: 'review.example.org', | ||||
|     port: '1000', | ||||
|     project: 'openstack/test-project.git' | ||||
|   } | ||||
| }; | ||||
|  | ||||
| /** | ||||
|  * Assert that the gerrit file content matches the passed structure. | ||||
|  * | ||||
|  * @param {object} content The expected data structure. | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function expectGerritFileContent (content) { | ||||
|   var files = projectBuilder.getIncludedFiles(); | ||||
|  | ||||
|   // get the .gitreview file | ||||
|   var gitreview = null; | ||||
|   files.forEach(function (fileRef) { | ||||
|     if (fileRef.to === '.gitreview') { | ||||
|       gitreview = ini.parse(fileRef.content()); | ||||
|     } | ||||
|   }); | ||||
|  | ||||
|   // Test the content | ||||
|   expect(gitreview).toBeTruthy(); | ||||
|   expect(gitreview).toEqual(content); | ||||
| } | ||||
|  | ||||
| describe('generator-openstack:lib/component/gerrit', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   afterEach(function () { | ||||
|     pkgBuilder.fromJSON(JSON.stringify({})); | ||||
|   }); | ||||
|  | ||||
|   describe('api', function () { | ||||
|     it('should define init, prompt, and configure', | ||||
|       function () { | ||||
|         expect(typeof gerrit.init).toBe('function'); | ||||
|         expect(typeof gerrit.prompt).toBe('function'); | ||||
|         expect(typeof gerrit.configure).toBe('function'); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('runtime', function () { | ||||
|     it('should not create a new file if one does not exist already.', | ||||
|       function () { | ||||
|         // No answers, non-interactive run. | ||||
|         var mockAnswers = {}; | ||||
|         var generator = mocks.buildGenerator(null, mockAnswers); | ||||
|         generator.fs.delete('.gitreview'); | ||||
|  | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         expect(generator.fs.exists('.gitreview')).toBeFalsy(); | ||||
|       }); | ||||
|  | ||||
|     it('should not delete a file if one exists.', | ||||
|       function () { | ||||
|         // No answers, non-interactive run. | ||||
|         var mockAnswers = {}; | ||||
|         var generator = mocks.buildGenerator(null, mockAnswers); | ||||
|         generator.fs.write('.gitreview', ini.stringify(iniFile)); | ||||
|  | ||||
|         // Set defaults | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         expect(generator.fs.exists('.gitreview')).toBeTruthy(); | ||||
|       }); | ||||
|  | ||||
|     it('should write default values if a new file is requested.', | ||||
|       function () { | ||||
|         // No answers, non-interactive run. | ||||
|         var mockAnswers = {enableGerrit: true}; | ||||
|         var generator = mocks.buildGenerator(null, mockAnswers); | ||||
|         pkgBuilder.fromJSON(JSON.stringify({name: 'generator-openstack'})); | ||||
|  | ||||
|         generator.fs.delete('.gitreview'); | ||||
|  | ||||
|         // Set defaults | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         expectGerritFileContent({ | ||||
|           gerrit: { | ||||
|             host: 'review.openstack.org', | ||||
|             port: '29418', | ||||
|             project: 'openstack/generator-openstack.git' | ||||
|           } | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should read the default project name from the package builder.', | ||||
|       function () { | ||||
|         // No answers, non-interactive run. | ||||
|         var mockAnswers = {enableGerrit: true}; | ||||
|         pkgBuilder.fromJSON(JSON.stringify({name: 'foo'})); | ||||
|  | ||||
|         var generator = mocks.buildGenerator(null, mockAnswers); | ||||
|         generator.fs.delete('.gitreview'); | ||||
|  | ||||
|         // Set defaults | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         expectGerritFileContent({ | ||||
|           gerrit: { | ||||
|             host: 'review.openstack.org', | ||||
|             port: '29418', | ||||
|             project: 'openstack/foo.git' | ||||
|           } | ||||
|         }); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|         var outputGenerator = gerrit.init(generator); | ||||
|         expect(outputGenerator).toEqual(generator); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|     it('should return a promise that resolves with a generator', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|         var outputPromise = gerrit.prompt(generator); | ||||
|         outputPromise.then(function (outputGenerator) { | ||||
|           expect(outputGenerator).toEqual(generator); | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should not show a prompt if non-interactive is set', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(null, null, | ||||
|           {'non-interactive': true}); | ||||
|         var promptSpy = spyOn(generator, 'prompt'); | ||||
|  | ||||
|         generator.fs.write('.gitreview', ini.stringify(iniFile)); | ||||
|  | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|  | ||||
|         expect(promptSpy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|  | ||||
|     it('should use defaults in .gitreview if no answers provided', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|  | ||||
|         generator.fs.write('.gitreview', ini.stringify(iniFile)); | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|         expectGerritFileContent(iniFile); | ||||
|       }); | ||||
|  | ||||
|     it('should configure answers if answers provided', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = { | ||||
|           enableGerrit: true, | ||||
|           gerritHost: 'review.example.org', | ||||
|           gerritPort: '1000', | ||||
|           gerritProject: 'openstack/test.git' | ||||
|         }; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Set defaults | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         expectGerritFileContent({ | ||||
|           gerrit: { | ||||
|             host: mockAnswers.gerritHost, | ||||
|             port: mockAnswers.gerritPort, | ||||
|             project: mockAnswers.gerritProject | ||||
|           } | ||||
|         }); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|         var outputGenerator = gerrit.init(generator); | ||||
|         expect(outputGenerator).toEqual(generator); | ||||
|       }); | ||||
|  | ||||
|     it('should create a .gitreview file if enabled', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(null, {enableGerrit: true}); | ||||
|         pkgBuilder.fromJSON(JSON.stringify({name: 'generator-openstack'})); | ||||
|  | ||||
|         // Make sure we don't have something left over from another test. | ||||
|         generator.fs.delete('.gitreview'); | ||||
|  | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         expectGerritFileContent({ | ||||
|           gerrit: { | ||||
|             host: 'review.openstack.org', | ||||
|             port: '29418', | ||||
|             project: 'openstack/generator-openstack.git' | ||||
|           } | ||||
|         }); | ||||
|  | ||||
|         var excludedFiles = projectBuilder.getExcludedFiles(); | ||||
|         expect(excludedFiles.length).toBe(0); | ||||
|       }); | ||||
|  | ||||
|     it('should delete a .gitreview file if disabled', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(null, {enableGerrit: false}); | ||||
|  | ||||
|         gerrit.init(generator); | ||||
|         gerrit.prompt(generator); | ||||
|         gerrit.configure(generator); | ||||
|  | ||||
|         var includedFiles = projectBuilder.getIncludedFiles(); | ||||
|         expect(includedFiles.length).toBe(0); | ||||
|  | ||||
|         var excludedFiles = projectBuilder.getExcludedFiles(); | ||||
|         expect(excludedFiles.length).toBe(1); | ||||
|         expect(excludedFiles[0]).toBe('.gitreview'); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,222 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var gitignore = require(libDir + '/component/gitignore'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var mockGenerator; | ||||
|  | ||||
| describe('generator-openstack:lib/component/gitignore', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof gitignore.init).toBe('function'); | ||||
|       expect(typeof gitignore.prompt).toBe('function'); | ||||
|       expect(typeof gitignore.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = gitignore.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should not interact with config', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator.config, 'defaults'); | ||||
|         gitignore.init(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = gitignore.prompt(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should do nothing', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator, 'prompt'); | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = gitignore.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add gitignore to the project files.', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ['one', 'two'].join('\n')); | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         expect(files.length).toBe(1); | ||||
|         expect(files[0].to).toBe('.gitignore'); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('.gitignore management', function () { | ||||
|  | ||||
|     it('should echo back existing .gitignore', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ['one', 'two'].join('\n')); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(2); | ||||
|  | ||||
|         expect(ignoreContent[0]).toEqual('one'); | ||||
|         expect(ignoreContent[1]).toEqual('two'); | ||||
|       }); | ||||
|  | ||||
|     it('should include any files flagged as ignored in the project builder.', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ''); | ||||
|         projectBuilder.ignoreFile('foo/bar.json'); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; // There should only be one file. | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(1); | ||||
|  | ||||
|         expect(ignoreContent[0]).toBe('foo/bar.json'); | ||||
|       }); | ||||
|  | ||||
|     it('should de-duplicate file paths from multiple locations.', | ||||
|       function () { | ||||
|         // include 'node_modules' from both an existing file and from the project builder. | ||||
|         mockGenerator.fs.write('.gitignore', ['node_modules'].join('\n')); | ||||
|         projectBuilder.ignoreFile('node_modules'); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; // There should only be one file. | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(1); | ||||
|  | ||||
|         expect(ignoreContent[0]).toBe('node_modules'); | ||||
|       }); | ||||
|  | ||||
|     it('should sort the ignored files.', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ['b_line', 'a_line'].join('\n')); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(2); | ||||
|         expect(ignoreContent[0]).toBe('a_line'); | ||||
|         expect(ignoreContent[1]).toBe('b_line'); | ||||
|       }); | ||||
|  | ||||
|     it('should remove any whitespace from the existing .gitignore', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ['1_one', '', '2_two', ''].join('\n')); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(2); | ||||
|         expect(ignoreContent[0]).toBe('1_one'); | ||||
|         expect(ignoreContent[1]).toBe('2_two'); | ||||
|       }); | ||||
|  | ||||
|     it('should remove any comments from the existing .gitignore', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ['1_one', '# comment', '  #comment'].join('\n')); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(1); | ||||
|         expect(ignoreContent[0]).toBe('1_one'); | ||||
|       }); | ||||
|  | ||||
|     it('should deduplicate content', | ||||
|       function () { | ||||
|         mockGenerator.fs.write('.gitignore', ['1_one', '1_one'].join('\n')); | ||||
|  | ||||
|         gitignore.init(mockGenerator); | ||||
|         gitignore.prompt(mockGenerator); | ||||
|         gitignore.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         var ignoreRef = files[0]; | ||||
|         var ignoreContent = ignoreRef.content().split('\n'); | ||||
|         expect(ignoreContent.length).toBe(1); | ||||
|         expect(ignoreContent[0]).toBe('1_one'); | ||||
|       }); | ||||
|  | ||||
|     it('should delete the file if there\'s nothing to ignore', function () { | ||||
|       mockGenerator.fs.write('.gitignore', ''); | ||||
|  | ||||
|       gitignore.init(mockGenerator); | ||||
|       gitignore.prompt(mockGenerator); | ||||
|       gitignore.configure(mockGenerator); | ||||
|  | ||||
|       var files = projectBuilder.getIncludedFiles(); | ||||
|       expect(files.length).toBe(0); | ||||
|  | ||||
|       var rmFiles = projectBuilder.getExcludedFiles(); | ||||
|       expect(rmFiles.length).toBe(1); | ||||
|       expect(rmFiles[0]).toBe('.gitignore'); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,96 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var license = require(libDir + '/component/license'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var pkgBuilder = require(libDir + '/pkg_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var mockGenerator; | ||||
|  | ||||
| describe('generator-openstack:lib/component/license', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof license.init).toBe('function'); | ||||
|       expect(typeof license.prompt).toBe('function'); | ||||
|       expect(typeof license.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = license.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should do nothing', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator.config, 'defaults'); | ||||
|         license.init(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = license.prompt(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should do nothing', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator, 'prompt'); | ||||
|         license.prompt(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = license.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add license to the project files.', | ||||
|       function () { | ||||
|         license.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         expect(files.length).toBe(1); | ||||
|         expect(files[0].from).toBe('LICENSE'); | ||||
|         expect(files[0].to).toBe('LICENSE'); | ||||
|       }); | ||||
|  | ||||
|     it('should add license to the package.json files.', | ||||
|       function () { | ||||
|         license.configure(mockGenerator); | ||||
|  | ||||
|         var parsedResult = JSON.parse(pkgBuilder.toJSON()); | ||||
|         expect(parsedResult.license).toBe("Apache-2.0"); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,108 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var nsp = require(libDir + '/component/nsp'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var pkgBuilder = require(libDir + '/pkg_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var mockGenerator; | ||||
|  | ||||
| describe('generator-openstack:lib/component/nsp', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     projectBuilder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof nsp.init).toBe('function'); | ||||
|       expect(typeof nsp.prompt).toBe('function'); | ||||
|       expect(typeof nsp.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = nsp.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should do nothing', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator.config, 'defaults'); | ||||
|         nsp.init(mockGenerator); | ||||
|         expect(spy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = nsp.prompt(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add nsp to dependencies', | ||||
|       function () { | ||||
|         pkgBuilder.fromJSON('{"devDependencies":{}}'); | ||||
|  | ||||
|         var devDeps = pkgBuilder.getValue('devDependencies'); | ||||
|         expect(devDeps.nsp).not.toBeDefined(); | ||||
|  | ||||
|         nsp.prompt(mockGenerator); | ||||
|  | ||||
|         devDeps = pkgBuilder.getValue('devDependencies'); | ||||
|         expect(devDeps.nsp).toBeDefined(); | ||||
|       }); | ||||
|  | ||||
|     it('should add the prepublish hook to the project', | ||||
|       function () { | ||||
|         pkgBuilder.fromJSON('{}'); | ||||
|  | ||||
|         var scripts = pkgBuilder.getValue('scripts'); | ||||
|         expect(scripts).not.toBeDefined(); | ||||
|  | ||||
|         nsp.prompt(mockGenerator); | ||||
|  | ||||
|         var newScripts = pkgBuilder.getValue('scripts'); | ||||
|         expect(newScripts.prepublish).toBeDefined(); | ||||
|         expect(newScripts.prepublish).toEqual('nsp check'); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = nsp.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add .nsprc to the project files.', | ||||
|       function () { | ||||
|         nsp.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         expect(files.length).toBe(1); | ||||
|         expect(files[0].from).toBe('.nsprc'); | ||||
|         expect(files[0].to).toBe('.nsprc'); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,189 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var pkg = require(libDir + '/component/pkg'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var pkgBuilder = require(libDir + '/pkg_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var mockGenerator; | ||||
|  | ||||
| var packageFile = {}; | ||||
|  | ||||
| describe('generator-openstack:lib/component/pkg', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     projectBuilder.clear(); | ||||
|     jasmine.clock().install(); | ||||
|   }); | ||||
|  | ||||
|   afterEach(function () { | ||||
|     jasmine.clock().uninstall(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof pkg.init).toBe('function'); | ||||
|       expect(typeof pkg.prompt).toBe('function'); | ||||
|       expect(typeof pkg.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = pkg.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should read an existing package.json file into the package builder', | ||||
|       function () { | ||||
|         mockGenerator.fs.writeJSON("package.json", {name: "foo"}); | ||||
|  | ||||
|         pkg.init(mockGenerator); | ||||
|         var output = JSON.parse(pkgBuilder.toJSON()); | ||||
|         expect(output.name).toBe('foo'); | ||||
|       }); | ||||
|  | ||||
|     it('should add several files to the ignore list.', | ||||
|       function () { | ||||
|         pkg.init(mockGenerator); | ||||
|  | ||||
|         var ignoredFiles = projectBuilder.getIgnoredFiles(); | ||||
|         expect(ignoredFiles.indexOf('node_modules')).not.toBe(-1); | ||||
|         expect(ignoredFiles.indexOf('npm-debug.log')).not.toBe(-1); | ||||
|         expect(ignoredFiles.indexOf('package')).not.toBe(-1); | ||||
|         expect(ignoredFiles.indexOf('.npm')).not.toBe(-1); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|  | ||||
|     it('should return a promise that resolves with a generator', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|         var outputPromise = pkg.prompt(generator); | ||||
|         outputPromise.then(function (outputGenerator) { | ||||
|           expect(outputGenerator).toEqual(generator); | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should revert to config defaults if no answers provided', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = {}; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Start with a blank package file. | ||||
|         generator.fs.write('package.json', JSON.stringify({})); | ||||
|  | ||||
|         // Set defaults | ||||
|         pkg.init(generator); | ||||
|         pkg.configure(generator); | ||||
|         pkg.prompt(generator); | ||||
|  | ||||
|         // Call the generator | ||||
|         expect(pkgBuilder.getValues()).toEqual({ | ||||
|           devDependencies: { istanbul: '^0.4.2', jasmine: '^2.4.1'}, | ||||
|           name: generator.appname, | ||||
|           description: null, | ||||
|           version: '0.0.1', | ||||
|           homepage: 'http://www.openstack.org/', | ||||
|           author: 'OpenStack <openstack-dev@lists.openstack.org> (http://www.openstack.org/)' | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should not show a prompt if non-interactive is set', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(null, null, | ||||
|           {'non-interactive': true}); | ||||
|         var promptSpy = spyOn(generator, 'prompt'); | ||||
|  | ||||
|         generator.fs.write('package.json', JSON.stringify(packageFile)); | ||||
|  | ||||
|         pkg.init(generator); | ||||
|         pkg.prompt(generator); | ||||
|  | ||||
|         expect(promptSpy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|  | ||||
|     it('should use defaults in package.json if no answers provided', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|  | ||||
|         var mockPackage = { | ||||
|           devDependencies: { istanbul: '^0.4.2', jasmine: '^2.4.1'}, | ||||
|           name: 'name', | ||||
|           description: 'description', | ||||
|           version: '0.0.1', | ||||
|           homepage: 'http://www.openstack.org/', | ||||
|           author: 'OpenStack <openstack-dev@lists.openstack.org> (http://www.openstack.org/)' | ||||
|         }; | ||||
|         generator.fs.write('package.json', JSON.stringify(mockPackage)); | ||||
|  | ||||
|         pkg.init(generator); | ||||
|         pkg.configure(generator); | ||||
|         pkg.prompt(generator); | ||||
|  | ||||
|         expect(pkgBuilder.getValues()).toEqual(mockPackage); | ||||
|       }); | ||||
|  | ||||
|     it('should configure answers if answers provided', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = { | ||||
|           devDependencies: { istanbul: '^0.4.2', jasmine: '^2.4.1'}, | ||||
|           name: 'name', | ||||
|           description: 'description', | ||||
|           version: '1.0.0', | ||||
|           homepage: 'http://example.openstack.org/', | ||||
|           author: 'Example Author' | ||||
|         }; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Start with a blank package file. | ||||
|         generator.fs.write('package.json', JSON.stringify({})); | ||||
|  | ||||
|         // Set defaults | ||||
|         pkg.init(generator); | ||||
|         pkg.prompt(generator); | ||||
|         pkg.configure(generator); | ||||
|  | ||||
|         expect(pkgBuilder.getValues()).toEqual(mockAnswers); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = pkg.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add package.json to the project files.', | ||||
|       function () { | ||||
|         pkg.configure(mockGenerator); | ||||
|  | ||||
|         var files = projectBuilder.getIncludedFiles(); | ||||
|         expect(files.length).toBe(1); | ||||
|         expect(files[0].to).toBe('package.json'); | ||||
|         expect(files[0].content).toBe(pkgBuilder.toJSON); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,181 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var libDir = '../../../../generators/app/lib'; | ||||
|  | ||||
| var structure = require(libDir + '/component/structure'); | ||||
| var projectBuilder = require(libDir + '/project_builder'); | ||||
| var mocks = require('../../../helpers/mocks'); | ||||
| var mockGenerator; | ||||
|  | ||||
| var expectedDefaults = { | ||||
|   engine: 'browser', | ||||
|   language: 'es5', | ||||
|   srcDir: './src', | ||||
|   distDir: './dist', | ||||
|   testDir: './test' | ||||
| }; | ||||
|  | ||||
| describe('generator-openstack:lib/component/structure', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     mockGenerator = mocks.buildGenerator(); | ||||
|     jasmine.clock().install(); | ||||
|   }); | ||||
|  | ||||
|   afterEach(function () { | ||||
|     jasmine.clock().uninstall(); | ||||
|   }); | ||||
|  | ||||
|   it('should define init, prompt, and configure', | ||||
|     function () { | ||||
|       expect(typeof structure.init).toBe('function'); | ||||
|       expect(typeof structure.prompt).toBe('function'); | ||||
|       expect(typeof structure.configure).toBe('function'); | ||||
|     }); | ||||
|  | ||||
|   describe('init()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = structure.init(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should set configuration defaults', | ||||
|       function () { | ||||
|         var spy = spyOn(mockGenerator.config, 'defaults'); | ||||
|         structure.init(mockGenerator); | ||||
|         expect(spy).toHaveBeenCalledWith(expectedDefaults); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('prompt()', function () { | ||||
|  | ||||
|     it('should return a promise that resolves with a generator', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(); | ||||
|         var outputPromise = structure.prompt(generator); | ||||
|         outputPromise.then(function (outputGenerator) { | ||||
|           expect(outputGenerator).toEqual(generator); | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should revert to config defaults if no answers provided', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = {}; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Call the component | ||||
|         structure.init(generator); | ||||
|         structure.prompt(generator); | ||||
|         structure.configure(generator); | ||||
|  | ||||
|         Object.keys(expectedDefaults).forEach(function (key) { | ||||
|           expect(generator.config.get(key)).toEqual(expectedDefaults[key]); | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should not show a prompt if non-interactive is set', | ||||
|       function () { | ||||
|         var generator = mocks.buildGenerator(null, null, {'non-interactive': true}); | ||||
|         var promptSpy = spyOn(generator, 'prompt'); | ||||
|  | ||||
|         structure.init(generator); | ||||
|         structure.prompt(generator); | ||||
|  | ||||
|         expect(promptSpy.calls.any()).toBeFalsy(); | ||||
|       }); | ||||
|  | ||||
|     it('should configure answers if answers provided', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = { | ||||
|           language: 'es6', | ||||
|           srcDir: './dir', | ||||
|           distDir: './foo', | ||||
|           testDir: './bar' | ||||
|         }; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Set defaults | ||||
|         structure.init(generator); | ||||
|         structure.prompt(generator); | ||||
|         structure.configure(generator); | ||||
|  | ||||
|         Object.keys(mockAnswers).forEach(function (key) { | ||||
|           expect(generator.config.get(key)).toEqual(mockAnswers[key]); | ||||
|         }); | ||||
|       }); | ||||
|  | ||||
|     it('should not configure the dist directory for a node project', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = { | ||||
|           engine: 'node', | ||||
|           distDir: './foo' // This answer should never be read. | ||||
|         }; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Set defaults | ||||
|         structure.init(generator); | ||||
|         structure.prompt(generator); | ||||
|         structure.configure(generator); | ||||
|  | ||||
|         expect(generator.config.get('distDir')).not.toBe(mockAnswers.distDir); | ||||
|       }); | ||||
|  | ||||
|     it('should configure the dist directory for a browser project', | ||||
|       function () { | ||||
|         var config = {}; | ||||
|         var mockAnswers = { | ||||
|           engine: 'browser', | ||||
|           distDir: './foo' // This answer should never be read. | ||||
|         }; | ||||
|         var generator = mocks.buildGenerator(config, mockAnswers); | ||||
|  | ||||
|         // Set defaults | ||||
|         structure.init(generator); | ||||
|         structure.prompt(generator); | ||||
|         structure.configure(generator); | ||||
|  | ||||
|         expect(generator.config.get('distDir')).toBe(mockAnswers.distDir); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('configure()', function () { | ||||
|     it('should return a generator', | ||||
|       function () { | ||||
|         var outputGenerator = structure.configure(mockGenerator); | ||||
|         expect(outputGenerator).toEqual(mockGenerator); | ||||
|       }); | ||||
|  | ||||
|     it('should add the dist directory to the ignoreFile.', | ||||
|       function () { | ||||
|         var ignoreSpy = spyOn(projectBuilder, 'ignoreFile'); | ||||
|  | ||||
|         var generator = mocks.buildGenerator(); | ||||
|  | ||||
|         structure.init(generator); | ||||
|         structure.prompt(generator); | ||||
|         structure.configure(generator); | ||||
|  | ||||
|         expect(ignoreSpy).toHaveBeenCalledWith('./dist'); | ||||
|       }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,94 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var builder = require('../../../generators/app/lib/global_dependencies'); | ||||
| var globals = require('../../../global-dependencies.json'); | ||||
| var semver = require('semver'); | ||||
|  | ||||
| describe('lib/global_dependencies', function () { | ||||
|  | ||||
|   describe('data', function () { | ||||
|     it('should contain all dependencies from the root global-dependencies.json', | ||||
|       function () { | ||||
|         for (var key in globals) { | ||||
|           if (globals.hasOwnProperty(key)) { | ||||
|             expect(builder.contains(key)).toBe(true); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|  | ||||
|     it('should contain valid semver versions for all dependencies', | ||||
|       function () { | ||||
|         for (var key in globals) { | ||||
|           if (globals.hasOwnProperty(key)) { | ||||
|             var version = builder.read(key); | ||||
|             expect(semver.validRange(version)).toBeTruthy(); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('contains()', function () { | ||||
|     it('should return true when a dependency exists', function () { | ||||
|       expect(builder.contains('eslint')).toBe(true); | ||||
|     }); | ||||
|  | ||||
|     it('should return false when a dependency doesn\'t exist', function () { | ||||
|       expect(builder.contains('notarealdependency')).toBe(false); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('read()', function () { | ||||
|     it('should return the version of a dependency', function () { | ||||
|       expect(builder.read('eslint')).toBe(globals.eslint); | ||||
|     }); | ||||
|  | ||||
|     it('should return undefined when a dependency doesn\'t exist', function () { | ||||
|       expect(builder.read('notarealdependency')).toBeUndefined(); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('synchronize()', function () { | ||||
|     it('should update dependencies that are out of date.', function () { | ||||
|       var testDeps = { | ||||
|         eslint: '0.0.1' | ||||
|       }; | ||||
|       var newDeps = builder.synchronize(testDeps); | ||||
|  | ||||
|       expect(newDeps.eslint).toBeDefined(); | ||||
|       expect(newDeps.eslint).not.toEqual(testDeps.eslint); | ||||
|       expect(newDeps.eslint).toEqual(globals.eslint); | ||||
|     }); | ||||
|  | ||||
|     it('should not update dependencies that are up to date.', function () { | ||||
|       var testDeps = { | ||||
|         eslint: globals.eslint | ||||
|       }; | ||||
|       var newDeps = builder.synchronize(testDeps); | ||||
|       expect(newDeps).toEqual(testDeps); | ||||
|     }); | ||||
|  | ||||
|     it('should not touch unregistered dependencies.', function () { | ||||
|       var testDeps = { | ||||
|         notarealdependency: '0.0.1' | ||||
|       }; | ||||
|       var newDeps = builder.synchronize(testDeps); | ||||
|       expect(newDeps.notarealdependency).toEqual(testDeps.notarealdependency); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,226 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var builder = require('../../../generators/app/lib/pkg_builder'); | ||||
| var dependencies = require('../../../generators/app/lib/global_dependencies'); | ||||
|  | ||||
| describe('generator-openstack:lib/pkg_builder', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     builder.fromJSON("{}"); // Clear | ||||
|   }); | ||||
|  | ||||
|   it('should start as an empty object', | ||||
|     function () { | ||||
|       expect(builder.toJSON()).toBe("{}"); | ||||
|     }); | ||||
|  | ||||
|   it('should honor and echo back any pre-loaded package file', | ||||
|     function () { | ||||
|       var packageString = '{"name":"foo"}'; | ||||
|       builder.fromJSON(packageString); | ||||
|  | ||||
|       var parsedResult = JSON.parse(builder.toJSON()); | ||||
|       expect(parsedResult.name).toBe("foo"); | ||||
|     }); | ||||
|  | ||||
|   it('should permit adding and overriding values.', | ||||
|     function () { | ||||
|       builder.fromJSON('{"name":"foo"}'); | ||||
|       builder.setValues({name: "bar", lol: "cat"}); | ||||
|  | ||||
|       var parsedResult = JSON.parse(builder.toJSON()); | ||||
|       expect(parsedResult.name).toBe("bar"); | ||||
|       expect(parsedResult.lol).toBe("cat"); | ||||
|     }); | ||||
|  | ||||
|   it('should not add parent prototype values.', | ||||
|     function () { | ||||
|       function Thing () { | ||||
|       } | ||||
|  | ||||
|       Thing.prototype.foo = 'bar'; | ||||
|  | ||||
|       var thing = new Thing(); | ||||
|       thing.name = 'bar'; | ||||
|       thing.lol = 'cat'; | ||||
|  | ||||
|       builder.fromJSON('{"name":"foo"}'); | ||||
|       builder.setValues(thing); | ||||
|  | ||||
|       var parsedResult = JSON.parse(builder.toJSON()); | ||||
|       expect(parsedResult.name).toBe("bar"); | ||||
|       expect(parsedResult.lol).toBe("cat"); | ||||
|       expect(parsedResult.foo).toBeUndefined(); | ||||
|     }); | ||||
|  | ||||
|   describe('toJSON()', function () { | ||||
|     it('should update out-of-date dependencies.', | ||||
|       function () { | ||||
|         var testPackage = { | ||||
|           dependencies: { | ||||
|             eslint: "0.0.1" | ||||
|           }, | ||||
|           peerDependencies: { | ||||
|             eslint: "0.0.1" | ||||
|           }, | ||||
|           devDependencies: { | ||||
|             eslint: "0.0.1" | ||||
|           } | ||||
|         }; | ||||
|  | ||||
|         builder.fromJSON(JSON.stringify(testPackage)); | ||||
|         var result = JSON.parse(builder.toJSON()); | ||||
|         expect(result.dependencies.eslint).toBe(dependencies.read('eslint')); | ||||
|         expect(result.peerDependencies.eslint).toBe(dependencies.read('eslint')); | ||||
|         expect(result.devDependencies.eslint).toBe(dependencies.read('eslint')); | ||||
|       }); | ||||
|  | ||||
|     it('should not error if no dependencies are declared.', | ||||
|       function () { | ||||
|         var testPackage = { | ||||
|           dependencies: { | ||||
|             eslint: "0.0.1" | ||||
|           } | ||||
|         }; | ||||
|  | ||||
|         builder.fromJSON(JSON.stringify(testPackage)); | ||||
|         var result = JSON.parse(builder.toJSON()); | ||||
|         expect(result.dependencies.eslint).toBe(dependencies.read('eslint')); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('getValues()', function () { | ||||
|     it('should permit retrieving the entire package block.', | ||||
|       function () { | ||||
|         builder.fromJSON('{"name":"foo"}'); | ||||
|         expect(builder.getValues()).toEqual({name: 'foo'}); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('getValue()', function () { | ||||
|     it('should permit retrieving values from the package.', | ||||
|       function () { | ||||
|         builder.fromJSON('{"name":"foo"}'); | ||||
|         expect(builder.getValue('name')).toBe('foo'); | ||||
|       }); | ||||
|  | ||||
|     it('should return undefined if the value is not set.', | ||||
|       function () { | ||||
|         builder.fromJSON('{"name":"foo"}'); | ||||
|         expect(builder.getValue('invalidname')).toBeUndefined(); | ||||
|       }); | ||||
|  | ||||
|     it('should return a default if provided.', | ||||
|       function () { | ||||
|         builder.fromJSON('{"name":"foo"}'); | ||||
|         expect(builder.getValue('invalidname', 'defaultValue')) | ||||
|           .toBe('defaultValue'); | ||||
|       }); | ||||
|   }); | ||||
|  | ||||
|   describe('addDependencies()', function () { | ||||
|     var eslintVersion = dependencies.read('eslint'); | ||||
|  | ||||
|     it('should be able to add to dependencies', function () { | ||||
|       builder.fromJSON('{"dependencies":{}}'); | ||||
|       builder.addDependencies('eslint'); | ||||
|       expect(builder.getValue('dependencies').eslint).toBe(eslintVersion); | ||||
|  | ||||
|       builder.fromJSON('{"dependencies":{}}'); | ||||
|       builder.addDependencies(['eslint']); | ||||
|       expect(builder.getValue('dependencies').eslint).toBe(eslintVersion); | ||||
|  | ||||
|       builder.fromJSON('{"dependencies":{}}'); | ||||
|       builder.addDependencies('eslint', 'dependencies'); | ||||
|       expect(builder.getValue('dependencies').eslint).toBe(eslintVersion); | ||||
|  | ||||
|       builder.fromJSON('{"dependencies":{}}'); | ||||
|       builder.addDependencies(['eslint'], 'dependencies'); | ||||
|       expect(builder.getValue('dependencies').eslint).toBe(eslintVersion); | ||||
|     }); | ||||
|  | ||||
|     it('should be able to add to devDependencies', function () { | ||||
|       builder.fromJSON('{"devDependencies":{}}'); | ||||
|       builder.addDependencies('eslint', 'devDependencies'); | ||||
|       expect(builder.getValue('devDependencies').eslint).toBe(eslintVersion); | ||||
|  | ||||
|       builder.fromJSON('{"devDependencies":{}}'); | ||||
|       builder.addDependencies(['eslint'], 'devDependencies'); | ||||
|       expect(builder.getValue('devDependencies').eslint).toBe(eslintVersion); | ||||
|     }); | ||||
|  | ||||
|     it('should be able to add to peerDependencies', function () { | ||||
|       builder.fromJSON('{"peerDependencies":{}}'); | ||||
|       builder.addDependencies('eslint', 'peerDependencies'); | ||||
|       expect(builder.getValue('peerDependencies').eslint).toBe(eslintVersion); | ||||
|  | ||||
|       builder.fromJSON('{"peerDependencies":{}}'); | ||||
|       builder.addDependencies(['eslint'], 'peerDependencies'); | ||||
|       expect(builder.getValue('peerDependencies').eslint).toBe(eslintVersion); | ||||
|     }); | ||||
|  | ||||
|     it('should create dependency maps if they don\'t yet exist in the package', function () { | ||||
|       builder.fromJSON('{}'); | ||||
|       builder.addDependencies('eslint'); | ||||
|       builder.addDependencies('eslint', 'devDependencies'); | ||||
|       builder.addDependencies('eslint', 'peerDependencies'); | ||||
|       expect(builder.getValue('dependencies')).not.toBeUndefined(); | ||||
|       expect(builder.getValue('devDependencies')).not.toBeUndefined(); | ||||
|       expect(builder.getValue('peerDependencies')).not.toBeUndefined(); | ||||
|     }); | ||||
|  | ||||
|     it('should not modify things if an invalid section was declared', function () { | ||||
|       builder.fromJSON('{}'); | ||||
|       builder.addDependencies('eslint', 'lol'); | ||||
|       expect(builder.getValues()).toEqual({}); | ||||
|     }); | ||||
|  | ||||
|     it('should not override an existing dependency declaration', function () { | ||||
|       builder.fromJSON('{"dependencies":{"eslint":"0.0.1"}}'); | ||||
|       builder.addDependencies(['eslint'], 'dependencies'); | ||||
|       expect(builder.getValue('dependencies').eslint).toEqual('0.0.1'); | ||||
|     }); | ||||
|  | ||||
|     it('should not add a dependency that is not globally managed', function () { | ||||
|       builder.fromJSON('{}'); | ||||
|       builder.addDependencies('leftpad'); | ||||
|       expect(builder.getValues()).toEqual({dependencies: {}}); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('addCommand', function () { | ||||
|     it('should add a command', function () { | ||||
|       builder.fromJSON('{"scripts":{}}'); | ||||
|       builder.addCommand('foo', 'bar'); | ||||
|       expect(builder.getValue('scripts').foo).toBe('bar'); | ||||
|     }); | ||||
|  | ||||
|     it('should overwrite an existing command', function () { | ||||
|       builder.fromJSON('{"scripts":{"foo":"bar"}}'); | ||||
|       builder.addCommand('foo', 'lol'); | ||||
|       expect(builder.getValue('scripts').foo).toBe('lol'); | ||||
|     }); | ||||
|  | ||||
|     it('should create the scripts hash if it doesn\'t exist', function () { | ||||
|       builder.fromJSON('{}'); | ||||
|       builder.addCommand('foo', 'bar'); | ||||
|       expect(builder.getValue('scripts')).toBeDefined(); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
| @@ -1,73 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| var builder = require('../../../generators/app/lib/project_builder'); | ||||
|  | ||||
| describe('generator-openstack:lib/project_builder', function () { | ||||
|  | ||||
|   beforeEach(function () { | ||||
|     builder.clear(); | ||||
|   }); | ||||
|  | ||||
|   it('should start with an empty list of included files', | ||||
|     function () { | ||||
|       expect(builder.getIncludedFiles().length).toBe(0); | ||||
|     }); | ||||
|  | ||||
|   it('should start with an empty list of excluded files', | ||||
|     function () { | ||||
|       expect(builder.getExcludedFiles().length).toBe(0); | ||||
|     }); | ||||
|  | ||||
|   it('should permit adding a file with only one path.', | ||||
|     function () { | ||||
|       var testFilePath = 'test_path.json'; | ||||
|  | ||||
|       builder.addFile(testFilePath); | ||||
|       var testFile = builder.getIncludedFiles()[0]; | ||||
|  | ||||
|       expect(testFile.from).toBe(testFilePath); | ||||
|       expect(testFile.to).toBe(testFilePath); | ||||
|     }); | ||||
|  | ||||
|   it('should permit adding a file with a different destination path.', | ||||
|     function () { | ||||
|       var testFilePath = 'test_path.json'; | ||||
|       var testFileOutput = 'test_path_output.json'; | ||||
|  | ||||
|       builder.addFile(testFilePath, testFileOutput); | ||||
|       var testFile = builder.getIncludedFiles()[0]; | ||||
|  | ||||
|       expect(testFile.from).toBe(testFilePath); | ||||
|       expect(testFile.to).toBe(testFileOutput); | ||||
|     }); | ||||
|  | ||||
|   it('should permit adding a file to the exclusion list', | ||||
|     function () { | ||||
|       var testFilePath = 'test_path.json'; | ||||
|       builder.removeFile(testFilePath); | ||||
|       expect(builder.getExcludedFiles()[0]).toBe(testFilePath); | ||||
|     }); | ||||
|  | ||||
|   it('should permit adding a file to the ignore list', | ||||
|     function () { | ||||
|       var testFilePath = 'test_path.json'; | ||||
|       builder.ignoreFile(testFilePath); | ||||
|       expect(builder.getIgnoredFiles()[0]).toBe(testFilePath); | ||||
|     }); | ||||
| }); | ||||
| @@ -1,78 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2016 Hewlett Packard Enterprise Development Company, LP | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  * http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| function buildMockGenerator (config, mockAnswers, mockOptions) { | ||||
|   var configDefaults = {}; | ||||
|   var memFs = require('mem-fs'); | ||||
|   var editor = require('mem-fs-editor'); | ||||
|   var store = memFs.create(); | ||||
|  | ||||
|   config = config || {}; | ||||
|   mockAnswers = mockAnswers || {}; | ||||
|   mockOptions = mockOptions || {}; | ||||
|  | ||||
|   return { | ||||
|     fs: editor.create(store), | ||||
|     appname: 'generator-openstack', | ||||
|     async: function () { | ||||
|       return function () { | ||||
|       }; | ||||
|     }, | ||||
|     config: { | ||||
|       defaults: function (values) { | ||||
|         Object.keys(values).forEach(function (key) { | ||||
|           configDefaults[key] = values[key]; | ||||
|         }); | ||||
|       }, | ||||
|       get: function (value) { | ||||
|         return config[value] || configDefaults[value]; | ||||
|       }, | ||||
|       set: function (key, value) { | ||||
|         if (typeof key === 'object') { | ||||
|           Object.keys(key).forEach(function (index) { | ||||
|             config[index] = key[index]; | ||||
|           }); | ||||
|         } else { | ||||
|           config[key] = value; | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     prompt: function (params, callback) { | ||||
|       var answers = {}; | ||||
|       params.forEach(function (param) { | ||||
|  | ||||
|         if (param.when && !param.when(answers)) { | ||||
|           return; | ||||
|         } | ||||
|  | ||||
|         if (mockAnswers.hasOwnProperty(param.name)) { | ||||
|           answers[param.name] = mockAnswers[param.name]; | ||||
|         } else { | ||||
|           answers[param.name] = param.default || null; | ||||
|         } | ||||
|  | ||||
|       }); | ||||
|       callback(answers); | ||||
|     }, | ||||
|     options: mockOptions | ||||
|   }; | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   buildGenerator: buildMockGenerator | ||||
| }; | ||||
| @@ -1,7 +0,0 @@ | ||||
| { | ||||
|   "spec_dir": "spec", | ||||
|   "spec_files": [ | ||||
|     "**/*.js", | ||||
|     "!helpers/**/*.js" | ||||
|   ] | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Andreas Jaeger
					Andreas Jaeger