diff --git a/README.md b/README.md index 2b60c76..182447f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ skip-install | skips the automatic installation of project dependencies at the e skip-checks | skips the checks of required tools (yarn, angular-cli) prior to generation skip-cache | forces the regeneration on an exising project (ignore previous answers) skip-styles | skips the generation of style inlining related code (in case you don't use styles) +skip-demo | skips the generation of the demo application npm | forces usage of `npm` to install dependencies @@ -202,9 +203,10 @@ Task | Purpose `gulp test` | Launches the tests (`*.spec.ts`) you wrote in `src/` and run code coverage on them. The coverage report can be found in `coverage/` folder `gulp test:watch` | Launches tests in watch mode. Every changes in `*.spec.ts` `gulp test:watch-no-cc` | Same as `gulp test:watch` but files do not get instrumented for code coverage (useful for debugging) -`gulp test:demo` | Launches demo application tests(same as running `ng test` from `demo/`). **Be sure you installed demo dependencies before** by running `yarn | npm install` inside `demo/` -`gulp serve:demo` | Launches demo application (same as running `ng serve` from `demo/`). **Be sure you installed demo dependencies before** by running `yarn | npm install` inside `demo/` -`gulp serve:doc` | Serves the generated compodoc documentation (from `dist/doc` folder) at https://localhost:8080. **This task is only available if you chose to use compodoc during generator setup** +`gulp test:demo`1 | Launches demo application tests(same as running `ng test` from `demo/`). **Be sure you installed demo dependencies before** by running `yarn | npm install` inside `demo/` +`gulp serve:demo`1 | Launches demo application (same as running `ng serve` from `demo/`). **Be sure you installed demo dependencies before** by running `yarn | npm install` inside `demo/` +`gulp serve:doc`2 | Serves the generated compodoc documentation (from `dist/doc` folder) at https://localhost:8080. + > **Note About compodoc and demo application** : > @@ -218,6 +220,11 @@ Task | Purpose > In production, the generated documentations files are deployed along with the demo application and are available at same url (`/doc/`) from root `index.html` > + +> 1 = This task is only available if you chose not to skip demo app generation during generator setup +> +> 2 = This task is only available if you chose to use compodoc during generator setup + ### Recipes Some useful recipes to help you during the development process can be found [here](recipes/) @@ -268,7 +275,10 @@ Running this task will (in that order) : 6. publish the package :package: on [npm registry](https://npmjs.com) (you must be [logged in](https://docs.npmjs.com/cli/adduser) to npm) 7. build and deploy :rocket: the demo application in `demo/dist` to `gh-pages` branch -The demo application will be available at : `https://USERNAME.github.io/REPO_NAME/` +The demo application will be available at : `https://USERNAME.github.io/REPO_NAME/` (provided you chose to generate one). + +The documentation will be available at : `https://USERNAME.github.io/REPO_NAME/doc/` (provided you chose to generate one) or +at `https://USERNAME.github.io/REPO_NAME/`, if you chose to skip demo application generation. # Support diff --git a/app/index.js b/app/index.js index b041035..b953db8 100644 --- a/app/index.js +++ b/app/index.js @@ -15,14 +15,21 @@ module.exports = class extends Generator { // This adds support for a `--skip-checks` flag this.option('skip-checks', { - description: 'Check the status of the required tools', + description: 'Skip checking the status of the required tools', type: Boolean, defaults: false }); // This adds support for a `--skip-styles` flag this.option('skip-styles', { - description: 'Generate code to inline styles in Angular components', + description: 'Skip generation of code to inline styles in Angular components', + type: Boolean, + defaults: false + }); + + // This adds support for a `--skip-demo` flag + this.option('skip-demo', { + description: 'Skip generation of demo application', type: Boolean, defaults: false }); @@ -38,6 +45,7 @@ module.exports = class extends Generator { this.skipChecks = this.options.skipChecks; this.skipInstall = this.options.skipInstall; this.skipStyles = this.options.skipStyles; + this.skipDemo = this.options.skipDemo; this.skipCache = this.options.skipCache; this.useYarn = !this.options.npm; @@ -255,67 +263,68 @@ module.exports = class extends Generator { this.fs.copyTpl(this.templatePath('src/_index.ts'), this.destinationPath('src/index.ts'), this); this.fs.copyTpl(this.templatePath('src/_moduleName.module.ts'), this.destinationPath(`src/${this.moduleName}.module.ts`), this); - // Create Demo files - this.fs.copyTpl(this.templatePath('demo/e2e/_app.e2e-spec.ts'), this.destinationPath('demo/e2e/app.e2e-spec.ts'), this); - this.fs.copyTpl(this.templatePath('demo/e2e/_app.po.ts'), this.destinationPath('demo/e2e/app.po.ts'), this); - this.fs.copy(this.templatePath('demo/e2e/tsconfig.e2e.json'), this.destinationPath('demo/e2e/tsconfig.e2e.json')); - this.fs.copyTpl(this.templatePath('demo/src/app/getting-started/_getting-started.component.ts'), this.destinationPath('demo/src/app/getting-started/getting-started.component.ts'), this); - this.fs.copy(this.templatePath('demo/src/app/getting-started/getting-started.component.html'), this.destinationPath('demo/src/app/getting-started/getting-started.component.html')); - this.fs.copy(this.templatePath('demo/src/app/getting-started/getting-started.component.scss'), this.destinationPath('demo/src/app/getting-started/getting-started.component.scss')); - this.fs.copy(this.templatePath('demo/src/app/getting-started/getting-started.component.spec.ts'), this.destinationPath('demo/src/app/getting-started/getting-started.component.spec.ts')); - this.fs.copyTpl(this.templatePath('demo/src/app/home/_home.component.html'), this.destinationPath('demo/src/app/home/home.component.html'), this); - this.fs.copyTpl(this.templatePath('demo/src/app/home/_home.component.ts'), this.destinationPath('demo/src/app/home/home.component.ts'), this); - this.fs.copyTpl(this.templatePath('demo/src/app/home/_home.component.spec.ts'), this.destinationPath('demo/src/app/home/home.component.spec.ts'), this); - this.fs.copy(this.templatePath('demo/src/app/home/home.component.scss'), this.destinationPath('demo/src/app/home/home.component.scss')); - this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.ts'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.ts')); - this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.html'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.html')); - this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.scss'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.scss')); - this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.spec.ts'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.spec.ts')); - this.fs.copyTpl(this.templatePath('demo/src/app/shared/footer/_footer.component.html'), this.destinationPath('demo/src/app/shared/footer/footer.component.html'), this); - this.fs.copy(this.templatePath('demo/src/app/shared/footer/footer.component.scss'), this.destinationPath('demo/src/app/shared/footer/footer.component.scss')); - this.fs.copy(this.templatePath('demo/src/app/shared/footer/footer.component.spec.ts'), this.destinationPath('demo/src/app/shared/footer/footer.component.spec.ts')); - this.fs.copy(this.templatePath('demo/src/app/shared/footer/footer.component.ts'), this.destinationPath('demo/src/app/shared/footer/footer.component.ts')); - this.fs.copyTpl(this.templatePath('demo/src/app/shared/header/_header.component.html'), this.destinationPath('demo/src/app/shared/header/header.component.html'), this); - this.fs.copyTpl(this.templatePath('demo/src/app/shared/header/_header.component.spec.ts'), this.destinationPath('demo/src/app/shared/header/header.component.spec.ts'), this); - this.fs.copy(this.templatePath('demo/src/app/shared/header/header.component.scss'), this.destinationPath('demo/src/app/shared/header/header.component.scss')); - this.fs.copy(this.templatePath('demo/src/app/shared/header/header.component.ts'), this.destinationPath('demo/src/app/shared/header/header.component.ts')); - this.fs.copy(this.templatePath('demo/src/app/shared/index.ts'), this.destinationPath('demo/src/app/shared/index.ts')); - this.fs.copy(this.templatePath('demo/src/app/shared/shared.module.ts'), this.destinationPath('demo/src/app/shared/shared.module.ts')); - this.fs.copyTpl(this.templatePath('demo/src/app/_app.component.spec.ts'), this.destinationPath('demo/src/app/app.component.spec.ts'), this); - this.fs.copy(this.templatePath('demo/src/app/app-routing.ts'), this.destinationPath('demo/src/app/app-routing.ts')); - this.fs.copy(this.templatePath('demo/src/app/app.component.html'), this.destinationPath('demo/src/app/app.component.html')); - this.fs.copy(this.templatePath('demo/src/app/app.component.scss'), this.destinationPath('demo/src/app/app.component.scss')); - this.fs.copy(this.templatePath('demo/src/app/app.component.ts'), this.destinationPath('demo/src/app/app.component.ts')); - this.fs.copy(this.templatePath('demo/src/app/app.module.ts'), this.destinationPath('demo/src/app/app.module.ts')); - this.fs.copy(this.templatePath('demo/src/assets/gitkeep'), this.destinationPath('demo/src/assets/.gitkeep')); - this.fs.copy(this.templatePath('demo/src/assets/npmignore'), this.destinationPath('demo/src/assets/.npmignore')); - this.fs.copy(this.templatePath('demo/src/assets/logo.svg'), this.destinationPath('demo/src/assets/logo.svg')); - this.fs.copy(this.templatePath('demo/src/environments/environment.prod.ts'), this.destinationPath('demo/src/environments/environment.prod.ts')); - this.fs.copy(this.templatePath('demo/src/environments/environment.ts'), this.destinationPath('demo/src/environments/environment.ts')); - this.fs.copyTpl(this.templatePath('demo/src/_index.html'), this.destinationPath('demo/src/index.html'), this); - this.fs.copy(this.templatePath('demo/src/_variables.scss'), this.destinationPath('demo/src/_variables.scss')); - this.fs.copy(this.templatePath('demo/src/favicon.ico'), this.destinationPath('demo/src/favicon.ico')); - this.fs.copy(this.templatePath('demo/src/favicon.ico'), this.destinationPath('demo/src/favicon.ico')); - this.fs.copy(this.templatePath('demo/src/main.ts'), this.destinationPath('demo/src/main.ts')); - this.fs.copy(this.templatePath('demo/src/polyfills.ts'), this.destinationPath('demo/src/polyfills.ts')); - this.fs.copy(this.templatePath('demo/src/styles.scss'), this.destinationPath('demo/src/styles.scss')); - this.fs.copy(this.templatePath('demo/src/test.ts'), this.destinationPath('demo/src/test.ts')); - this.fs.copy(this.templatePath('demo/src/tsconfig.app.json'), this.destinationPath('demo/src/tsconfig.app.json')); - this.fs.copy(this.templatePath('demo/src/tsconfig.spec.json'), this.destinationPath('demo/src/tsconfig.spec.json')); - this.fs.copy(this.templatePath('demo/src/typings.d.ts'), this.destinationPath('demo/src/typings.d.ts')); - this.fs.copyTpl(this.templatePath('demo/_angular-cli.json'), this.destinationPath('demo/.angular-cli.json'), this); - this.fs.copyTpl(this.templatePath('demo/_package.json'), this.destinationPath('demo/package.json'), this); - this.fs.copyTpl(this.templatePath('demo/_README.md'), this.destinationPath('demo/README.md'), this); - this.fs.copy(this.templatePath('demo/editorconfig'), this.destinationPath('demo/.editorconfig')); - this.fs.copy(this.templatePath('demo/gitignore'), this.destinationPath('demo/.gitignore')); - this.fs.copy(this.templatePath('demo/karma.conf.js'), this.destinationPath('demo/karma.conf.js')); - this.fs.copy(this.templatePath('demo/protractor.conf.js'), this.destinationPath('demo/protractor.conf.js')); - if (this.useCompodoc) { - this.fs.copy(this.templatePath('demo/proxy.conf.json'), this.destinationPath('demo/proxy.conf.json')); + if (!this.skipDemo) { + // Create Demo files + this.fs.copyTpl(this.templatePath('demo/e2e/_app.e2e-spec.ts'), this.destinationPath('demo/e2e/app.e2e-spec.ts'), this); + this.fs.copyTpl(this.templatePath('demo/e2e/_app.po.ts'), this.destinationPath('demo/e2e/app.po.ts'), this); + this.fs.copy(this.templatePath('demo/e2e/tsconfig.e2e.json'), this.destinationPath('demo/e2e/tsconfig.e2e.json')); + this.fs.copyTpl(this.templatePath('demo/src/app/getting-started/_getting-started.component.ts'), this.destinationPath('demo/src/app/getting-started/getting-started.component.ts'), this); + this.fs.copy(this.templatePath('demo/src/app/getting-started/getting-started.component.html'), this.destinationPath('demo/src/app/getting-started/getting-started.component.html')); + this.fs.copy(this.templatePath('demo/src/app/getting-started/getting-started.component.scss'), this.destinationPath('demo/src/app/getting-started/getting-started.component.scss')); + this.fs.copy(this.templatePath('demo/src/app/getting-started/getting-started.component.spec.ts'), this.destinationPath('demo/src/app/getting-started/getting-started.component.spec.ts')); + this.fs.copyTpl(this.templatePath('demo/src/app/home/_home.component.html'), this.destinationPath('demo/src/app/home/home.component.html'), this); + this.fs.copyTpl(this.templatePath('demo/src/app/home/_home.component.ts'), this.destinationPath('demo/src/app/home/home.component.ts'), this); + this.fs.copyTpl(this.templatePath('demo/src/app/home/_home.component.spec.ts'), this.destinationPath('demo/src/app/home/home.component.spec.ts'), this); + this.fs.copy(this.templatePath('demo/src/app/home/home.component.scss'), this.destinationPath('demo/src/app/home/home.component.scss')); + this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.ts'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.ts')); + this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.html'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.html')); + this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.scss'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.scss')); + this.fs.copy(this.templatePath('demo/src/app/shared/content-wrapper/content-wrapper.component.spec.ts'), this.destinationPath('demo/src/app/shared/content-wrapper/content-wrapper.component.spec.ts')); + this.fs.copyTpl(this.templatePath('demo/src/app/shared/footer/_footer.component.html'), this.destinationPath('demo/src/app/shared/footer/footer.component.html'), this); + this.fs.copy(this.templatePath('demo/src/app/shared/footer/footer.component.scss'), this.destinationPath('demo/src/app/shared/footer/footer.component.scss')); + this.fs.copy(this.templatePath('demo/src/app/shared/footer/footer.component.spec.ts'), this.destinationPath('demo/src/app/shared/footer/footer.component.spec.ts')); + this.fs.copy(this.templatePath('demo/src/app/shared/footer/footer.component.ts'), this.destinationPath('demo/src/app/shared/footer/footer.component.ts')); + this.fs.copyTpl(this.templatePath('demo/src/app/shared/header/_header.component.html'), this.destinationPath('demo/src/app/shared/header/header.component.html'), this); + this.fs.copyTpl(this.templatePath('demo/src/app/shared/header/_header.component.spec.ts'), this.destinationPath('demo/src/app/shared/header/header.component.spec.ts'), this); + this.fs.copy(this.templatePath('demo/src/app/shared/header/header.component.scss'), this.destinationPath('demo/src/app/shared/header/header.component.scss')); + this.fs.copy(this.templatePath('demo/src/app/shared/header/header.component.ts'), this.destinationPath('demo/src/app/shared/header/header.component.ts')); + this.fs.copy(this.templatePath('demo/src/app/shared/index.ts'), this.destinationPath('demo/src/app/shared/index.ts')); + this.fs.copy(this.templatePath('demo/src/app/shared/shared.module.ts'), this.destinationPath('demo/src/app/shared/shared.module.ts')); + this.fs.copyTpl(this.templatePath('demo/src/app/_app.component.spec.ts'), this.destinationPath('demo/src/app/app.component.spec.ts'), this); + this.fs.copy(this.templatePath('demo/src/app/app-routing.ts'), this.destinationPath('demo/src/app/app-routing.ts')); + this.fs.copy(this.templatePath('demo/src/app/app.component.html'), this.destinationPath('demo/src/app/app.component.html')); + this.fs.copy(this.templatePath('demo/src/app/app.component.scss'), this.destinationPath('demo/src/app/app.component.scss')); + this.fs.copy(this.templatePath('demo/src/app/app.component.ts'), this.destinationPath('demo/src/app/app.component.ts')); + this.fs.copy(this.templatePath('demo/src/app/app.module.ts'), this.destinationPath('demo/src/app/app.module.ts')); + this.fs.copy(this.templatePath('demo/src/assets/gitkeep'), this.destinationPath('demo/src/assets/.gitkeep')); + this.fs.copy(this.templatePath('demo/src/assets/npmignore'), this.destinationPath('demo/src/assets/.npmignore')); + this.fs.copy(this.templatePath('demo/src/assets/logo.svg'), this.destinationPath('demo/src/assets/logo.svg')); + this.fs.copy(this.templatePath('demo/src/environments/environment.prod.ts'), this.destinationPath('demo/src/environments/environment.prod.ts')); + this.fs.copy(this.templatePath('demo/src/environments/environment.ts'), this.destinationPath('demo/src/environments/environment.ts')); + this.fs.copyTpl(this.templatePath('demo/src/_index.html'), this.destinationPath('demo/src/index.html'), this); + this.fs.copy(this.templatePath('demo/src/_variables.scss'), this.destinationPath('demo/src/_variables.scss')); + this.fs.copy(this.templatePath('demo/src/favicon.ico'), this.destinationPath('demo/src/favicon.ico')); + this.fs.copy(this.templatePath('demo/src/favicon.ico'), this.destinationPath('demo/src/favicon.ico')); + this.fs.copy(this.templatePath('demo/src/main.ts'), this.destinationPath('demo/src/main.ts')); + this.fs.copy(this.templatePath('demo/src/polyfills.ts'), this.destinationPath('demo/src/polyfills.ts')); + this.fs.copy(this.templatePath('demo/src/styles.scss'), this.destinationPath('demo/src/styles.scss')); + this.fs.copy(this.templatePath('demo/src/test.ts'), this.destinationPath('demo/src/test.ts')); + this.fs.copy(this.templatePath('demo/src/tsconfig.app.json'), this.destinationPath('demo/src/tsconfig.app.json')); + this.fs.copy(this.templatePath('demo/src/tsconfig.spec.json'), this.destinationPath('demo/src/tsconfig.spec.json')); + this.fs.copy(this.templatePath('demo/src/typings.d.ts'), this.destinationPath('demo/src/typings.d.ts')); + this.fs.copyTpl(this.templatePath('demo/_angular-cli.json'), this.destinationPath('demo/.angular-cli.json'), this); + this.fs.copyTpl(this.templatePath('demo/_package.json'), this.destinationPath('demo/package.json'), this); + this.fs.copyTpl(this.templatePath('demo/_README.md'), this.destinationPath('demo/README.md'), this); + this.fs.copy(this.templatePath('demo/editorconfig'), this.destinationPath('demo/.editorconfig')); + this.fs.copy(this.templatePath('demo/gitignore'), this.destinationPath('demo/.gitignore')); + this.fs.copy(this.templatePath('demo/karma.conf.js'), this.destinationPath('demo/karma.conf.js')); + this.fs.copy(this.templatePath('demo/protractor.conf.js'), this.destinationPath('demo/protractor.conf.js')); + if (this.useCompodoc) { + this.fs.copy(this.templatePath('demo/proxy.conf.json'), this.destinationPath('demo/proxy.conf.json')); + } + this.fs.copy(this.templatePath('demo/tsconfig.json'), this.destinationPath('demo/tsconfig.json')); + this.fs.copy(this.templatePath('demo/tslint.json'), this.destinationPath('demo/tslint.json')); } - this.fs.copy(this.templatePath('demo/tsconfig.json'), this.destinationPath('demo/tsconfig.json')); - this.fs.copy(this.templatePath('demo/tslint.json'), this.destinationPath('demo/tslint.json')); - // Create Git files this.fs.copyTpl(this.templatePath('git/_config'), this.destinationPath('.git/config'), this); this.fs.copy(this.templatePath('git/description'), this.destinationPath('.git/description')); diff --git a/app/templates/_gulpfile.js b/app/templates/_gulpfile.js index de6646c..3802eee 100644 --- a/app/templates/_gulpfile.js +++ b/app/templates/_gulpfile.js @@ -304,22 +304,25 @@ pump( ], cb); }); -//Demo Tasks -gulp.task('test:demo', gulpShell.task('ng test', { cwd: `${config.demoDir}` })); +<% if(useCompodoc){ %>//Doc Tasks +gulp.task('build:doc', gulpShell.task(`compodoc -p tsconfig.json --hideGenerator --disableCoverage -d <%= skipDemo ? "${config.outputDir}/doc/": "${config.demoDir}/dist/doc/"%>`)); -gulp.task('serve:demo', gulpShell.task('ng serve<% if(useCompodoc){ %> --proxy-config proxy.conf.json<% } %>', { cwd: `${config.demoDir}` })); +gulp.task('serve:doc', ['clean:doc'], gulpShell.task(`compodoc -p tsconfig.json -s -d ${config.outputDir}/doc/`));<% } if(skipDemo) { %> -gulp.task('build:demo', gulpShell.task(`ng build --prod --aot --base-href https://<%= githubUsername %>.github.io/${LIBRARY_NAME}/`, { cwd: `${config.demoDir}` }));<% if(useCompodoc){ %> +gulp.task('push:doc', gulpShell.task(`ngh --dir ${config.outputDir}/doc/ --message="chore(doc): :rocket: deploy new version"`));<% } %> + +<% if(!skipDemo) { %>//Demo Tasks +gulp.task('test:demo', gulpShell.task('ng test', { cwd: `${config.demoDir}` })); -gulp.task('build:doc', gulpShell.task(`compodoc -p tsconfig.json --hideGenerator --disableCoverage -d ${config.demoDir}/dist/doc/`)); +gulp.task('serve:demo', gulpShell.task('ng serve<% if(useCompodoc){ %> --proxy-config proxy.conf.json<% } %>', { cwd: `${config.demoDir}` })); -gulp.task('serve:doc', <% if(useCompodoc){ %> ['clean:doc'], <% } %>gulpShell.task(`compodoc -p tsconfig.json -s -d ${config.outputDir}/doc/`));<% } %> +gulp.task('build:demo', gulpShell.task(`ng build --prod --aot --base-href https://<%= githubUsername %>.github.io/${LIBRARY_NAME}/`, { cwd: `${config.demoDir}` })); gulp.task('push:demo', gulpShell.task(`ngh --dir ${config.demoDir}/dist --message="chore(demo): :rocket: deploy new version"`)); gulp.task('deploy:demo', (cb) => { - runSequence('build:demo', 'build:doc', 'push:demo', cb); -}); + runSequence('build:demo'<%- (useCompodoc) ? ", 'build:doc'": ""%>, 'push:demo', cb); +});<% } %> // Link 'dist' folder (create a local 'ng-scrollreveal' package that symlinks to it) // This way, we can have the demo project declare a dependency on 'ng-scrollreveal' (as it should) @@ -438,8 +441,8 @@ gulp.task('release', (cb) => { 'push-changes', 'create-new-tag', 'github-release', - 'npm-publish', - 'deploy:demo', + 'npm-publish',<% if(!skipDemo || useCompodoc) { %> + 'deploy:<%= !skipDemo? "demo":"doc" %>',<% } %> (error) => { if (error) { gulpUtil.log(error.message); @@ -448,7 +451,6 @@ gulp.task('release', (cb) => { } cb(error); }); - } }); diff --git a/test/test-app.js b/test/test-app.js index e2f4684..c637f49 100644 --- a/test/test-app.js +++ b/test/test-app.js @@ -32,7 +32,7 @@ describe('ngx-library:app', () => { }); }); - it('creates files', () => { + it('should create files', () => { assert.file([ // Create project 'gulpfile.js', @@ -305,7 +305,7 @@ describe('ngx-library:app', () => { }); describe('check compodoc', () => { - it('should add compodoc-related code in "package.json" & "gulpfile.js" if "useCompodoc" is set to true ', () => { + it('should add compodoc-related code if "useCompodoc" is set to true ', () => { let ngLibraryApp = createNgLibraryApp( { skipInstall: true, @@ -329,11 +329,11 @@ describe('ngx-library:app', () => { assert.equal(ngLibraryApp.generator.useCompodoc, true); assert.file('demo/proxy.conf.json'); assert.fileContent('package.json', ' "@compodoc/compodoc":'); - assert.fileContent('gulpfile.js', `gulp.task('build:doc'`); + assert.fileContent('gulpfile.js', /gulp\.task\('(serve|build|clean):doc'/); }); }); - it('should not add compodoc-related code in "package.json" & "gulpfile.js" if "useCompodoc" is set to false ', () => { + it('should not add compodoc-related code if "useCompodoc" is set to false ', () => { let ngLibraryApp = createNgLibraryApp( { skipInstall: true, @@ -358,12 +358,13 @@ describe('ngx-library:app', () => { assert.noFile('demo/proxy.conf.json'); assert.noFileContent('package.json', ' "@compodoc/compodoc":'); assert.noFileContent('gulpfile.js', `gulp.task('build:doc'`); + assert.noFileContent('gulpfile.js', /gulp\.task\('(serve|build|clean):doc'/); }); }); }); - describe('check skipStyles', () => { - it('should not generate styles-related code in "package.json" & "gulpfile.js" when "skipStyles" is set to true', () => { + describe('check "skipStyles" option', () => { + it('should not generate styles-related code when "skipStyles" is set to true', () => { let ngLibraryApp = createNgLibraryApp({ skipInstall: true, skipChecks: true, @@ -381,7 +382,7 @@ describe('ngx-library:app', () => { }); }); - it('should generate styles-related code in "package.json" & "gulpfile.js" when "skipStyles" is set to true', () => { + it('should generate styles-related code when "skipStyles" is set to false', () => { let ngLibraryApp = createNgLibraryApp({ skipInstall: true, skipChecks: true, @@ -400,4 +401,147 @@ describe('ngx-library:app', () => { }); }); }); + + describe('check "skipDemo" option', () => { + it('should not generate demo-related code when "skipDemo" is set to true', () => { + let ngLibraryApp = createNgLibraryApp({ + skipInstall: true, + skipChecks: true, + skipDemo: true + }); + return ngLibraryApp.then(() => { + assert.equal(ngLibraryApp.generator.skipDemo, true); + assert.noFile([ + 'demo/e2e/app.e2e-spec.ts', + 'demo/e2e/app.po.ts', + 'demo/e2e/tsconfig.e2e.json', + 'demo/src/app/getting-started/getting-started.component.ts', + 'demo/src/app/getting-started/getting-started.component.html', + 'demo/src/app/getting-started/getting-started.component.scss', + 'demo/src/app/getting-started/getting-started.component.spec.ts', + 'demo/src/app/home/home.component.ts', + 'demo/src/app/home/home.component.html', + 'demo/src/app/home/home.component.scss', + 'demo/src/app/home/home.component.spec.ts', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.ts', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.html', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.scss', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.spec.ts', + 'demo/src/app/shared/footer/footer.component.html', + 'demo/src/app/shared/footer/footer.component.scss', + 'demo/src/app/shared/footer/footer.component.spec.ts', + 'demo/src/app/shared/footer/footer.component.ts', + 'demo/src/app/shared/header/header.component.html', + 'demo/src/app/shared/header/header.component.scss', + 'demo/src/app/shared/header/header.component.spec.ts', + 'demo/src/app/shared/header/header.component.ts', + 'demo/src/app/shared/index.ts', + 'demo/src/app/shared/shared.module.ts', + 'demo/src/app/app.component.spec.ts', + 'demo/src/app/app-routing.ts', + 'demo/src/app/app.component.html', + 'demo/src/app/app.component.scss', + 'demo/src/app/app.component.ts', + 'demo/src/app/app.module.ts', + 'demo/src/assets/.gitkeep', + 'demo/src/assets/.npmignore', + 'demo/src/assets/logo.svg', + 'demo/src/environments/environment.prod.ts', + 'demo/src/environments/environment.ts', + 'demo/src/index.html', + 'demo/src/_variables.scss', + 'demo/src/favicon.ico', + 'demo/src/favicon.ico', + 'demo/src/main.ts', + 'demo/src/polyfills.ts', + 'demo/src/styles.scss', + 'demo/src/test.ts', + 'demo/src/tsconfig.app.json', + 'demo/src/tsconfig.spec.json', + 'demo/src/typings.d.ts', + 'demo/package.json', + 'demo/.angular-cli.json', + 'demo/.editorconfig', + 'demo/.gitignore', + 'demo/karma.conf.js', + 'demo/protractor.conf.js', + 'demo/README.md', + 'demo/tsconfig.json', + 'demo/tslint.json' + ]); + assert.noFileContent('gulpfile.js', /gulp\.task\('(test|serve|build|push|deploy):demo'/); + }); + }); + + it('should generate demo-related code when "skipDemo" is set to false', () => { + let ngLibraryApp = createNgLibraryApp({ + skipInstall: true, + skipChecks: true, + skipDemo: false + }); + + return ngLibraryApp.then(() => { + assert.equal(ngLibraryApp.generator.skipDemo, false); + assert.file([ + 'demo/e2e/app.e2e-spec.ts', + 'demo/e2e/app.po.ts', + 'demo/e2e/tsconfig.e2e.json', + 'demo/src/app/getting-started/getting-started.component.ts', + 'demo/src/app/getting-started/getting-started.component.html', + 'demo/src/app/getting-started/getting-started.component.scss', + 'demo/src/app/getting-started/getting-started.component.spec.ts', + 'demo/src/app/home/home.component.ts', + 'demo/src/app/home/home.component.html', + 'demo/src/app/home/home.component.scss', + 'demo/src/app/home/home.component.spec.ts', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.ts', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.html', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.scss', + 'demo/src/app/shared/content-wrapper/content-wrapper.component.spec.ts', + 'demo/src/app/shared/footer/footer.component.html', + 'demo/src/app/shared/footer/footer.component.scss', + 'demo/src/app/shared/footer/footer.component.spec.ts', + 'demo/src/app/shared/footer/footer.component.ts', + 'demo/src/app/shared/header/header.component.html', + 'demo/src/app/shared/header/header.component.scss', + 'demo/src/app/shared/header/header.component.spec.ts', + 'demo/src/app/shared/header/header.component.ts', + 'demo/src/app/shared/index.ts', + 'demo/src/app/shared/shared.module.ts', + 'demo/src/app/app.component.spec.ts', + 'demo/src/app/app-routing.ts', + 'demo/src/app/app.component.html', + 'demo/src/app/app.component.scss', + 'demo/src/app/app.component.ts', + 'demo/src/app/app.module.ts', + 'demo/src/assets/.gitkeep', + 'demo/src/assets/.npmignore', + 'demo/src/assets/logo.svg', + 'demo/src/environments/environment.prod.ts', + 'demo/src/environments/environment.ts', + 'demo/src/index.html', + 'demo/src/_variables.scss', + 'demo/src/favicon.ico', + 'demo/src/favicon.ico', + 'demo/src/main.ts', + 'demo/src/polyfills.ts', + 'demo/src/styles.scss', + 'demo/src/test.ts', + 'demo/src/tsconfig.app.json', + 'demo/src/tsconfig.spec.json', + 'demo/src/typings.d.ts', + 'demo/package.json', + 'demo/.angular-cli.json', + 'demo/.editorconfig', + 'demo/.gitignore', + 'demo/karma.conf.js', + 'demo/protractor.conf.js', + 'demo/README.md', + 'demo/tsconfig.json', + 'demo/tslint.json' + ]); + assert.fileContent('gulpfile.js', /gulp\.task\('(test|serve|build|push|deploy):demo'/); + }); + }); + }); });