UNPKG

generator-confit

Version:

Yeoman generator for creating the development process, tools and a sample project for current-generation web applications

518 lines (459 loc) 24.4 kB
# Should only contain config that is for this build tool, which is dependent on project-type documentation: toolModules: - packages: - <<: *pkg_webpack - <<: *pkg_swanky - <<: *pkg_swanky-processor-ngdocs - <<: *pkg_highlightjs - <<: *pkg_http-server - <<: *pkg_latest-version tasks: - name: docs:dev tasks: ['cross-env NODE_ENV=development node <%- paths.config.configDir + resources.documentation.configSubDir %>serve.dev.js'] description: Creates a development-version of the documentation website and watches for changes. - name: docs:build tasks: ['cross-env NODE_ENV=production webpack --progress --config <%- paths.config.configDir + resources.documentation.configSubDir %>swanky.webpack.config.js --colors'] description: Creates a production-version of the documentation website using Swanky in the `<%- documentation.outputDir %>`. - name: docs:build:serve tasks: ['docs:build', 'docs:serve'] description: Builds then serves (via a web server) the production website. - name: docs:clean tasks: ['rimraf <%- documentation.outputDir %>'] description: Cleans the docs folder in preparation for building. - name: docs:serve tasks: ['http-server <%- documentation.outputDir %> -o'] description: Builds then serves (via a web server) the production website. - name: docs:prepublish tasks: ['node <%- paths.config.configDir + resources.documentation.configSubDir %>prepublish.js'] description: Updates the information in `swanky.config.yaml` with production settings. This is designed to allow the documentation to be generated AFTER the NPM package has been successfully published. - name: docs:postpublish tasks: ['node <%- paths.config.configDir + resources.documentation.configSubDir %>postpublish.js'] description: Updates the information in `swanky.config.yaml` back to the development settings. templateFiles: - src: config/serve.dev.js.tpl dest: <%- paths.config.configDir + resources.documentation.configSubDir %>serve.dev.js overwrite: true - src: config/swanky.webpack.config.js.tpl dest: <%- paths.config.configDir + resources.documentation.configSubDir %>swanky.webpack.config.js overwrite: true - src: config/prepublish.js.tpl dest: <%- paths.config.configDir + resources.documentation.configSubDir %>prepublish.js overwrite: true - src: config/postpublish.js.tpl dest: <%- paths.config.configDir + resources.documentation.configSubDir %>postpublish.js overwrite: true # Have a single, common Swanky config file which has logic for each framework. This makes it easier to copy # entire directory trees but treat this single file as special. - src: swanky.config.yaml.tpl dest: <%- documentation.srcDir %>/swanky.config.yaml overwrite: true - condition: <%- documentation.publishMethod === 'manual' %> tasks: - name: docs:publish tasks: ['docs:prepublish', 'docs:clean', 'docs:build', 'docs:_publish', 'docs:postpublish'] description: Publishes the documentation manually (edit <%- link(paths.config.configDir + resources.documentation.configSubDir + 'publish.js') %> to provide your implementation) - name: docs:_publish tasks: ['node <%- paths.config.configDir + resources.documentation.configSubDir %>publish.js'] description: templateFiles: - src: config/publish.js.tpl dest: <%- paths.config.configDir + resources.documentation.configSubDir %>publish.js overwrite: true - condition: <%- documentation.publishMethod === 'GitHub' %> packages: - <<: *pkg_gh-pages tasks: - name: docs:publish tasks: ['docs:prepublish', 'docs:clean', 'docs:build', 'docs:_publish', 'docs:postpublish'] description: Publishes the documentation to GitHub's /gh-pages branch - name: docs:_publish tasks: ['node <%- paths.config.configDir + resources.documentation.configSubDir %>publish.js'] description: templateFiles: - src: config/publish.js.tpl dest: <%- paths.config.configDir + resources.documentation.configSubDir %>publish.js overwrite: true - condition: <%- documentation.publishMethod === 'cloud' %> packages: - <<: *pkg_now tasks: - name: docs:publish tasks: ['docs:prepublish', 'docs:clean', 'docs:build', 'docs:_publish', 'docs:postpublish'] description: Publishes the documentation to the cloud using `now`. This will require some setup when using from a CI server. - name: docs:_publish tasks: ['now <%- documentation.outputDir %>'] description: - condition: <%- documentation.createSampleDocs %> templateFiles: - src: docs/**/* dest: <%- documentation.srcDir %> overwrite: true noParse: true - condition: <%- buildJS.framework.indexOf('AngularJS 1.x') > -1 %> templateFiles: - src: ng1/docs/**/* dest: <%- documentation.srcDir %> overwrite: true noParse: true entryPoint: packageJsonConfig: - main: <%- entryPoint.entryPoints.main[0] %> release: toolModules: - onInstall: - cmd: git # It is safe to run this multiple times args: ['init'] - condition: <%- release.checkCodeCoverage %> packages: - <<: *pkg_husky tasks: - name: prepush tasks: ['npm-run-all verify test:coverage --silent'] description: Git pre-push hook that verifies code and checks unit test coverage meet minimum thresholds. # Coveralls works for BitBucket and GitHub only - condition: <%- release.checkCodeCoverage && (app.repositoryType === 'BitBucket' || app.repositoryType === 'GitHub') && app.publicRepository %> packages: - <<: *pkg_coveralls readmeBadges: - name: Coverage Status image: https://coveralls.io/repos/<%- app.repositoryType.toLowerCase() %>/<%- repoConfig.repository %>/badge.svg?branch=master url: https://coveralls.io/<%- app.repositoryType.toLowerCase() %>/<%- repoConfig.repository %>?branch=master priority: 30 - condition: <%- release.useSemantic %> readmeBadges: - name: semantic-release image: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg url: https://github.com/semantic-release/semantic-release priority: 20 - condition: <%- release.commitMessageFormat === 'Conventional' %> packages: - <<: *pkg_cz-customizable - <<: *pkg_commitizen - <<: *pkg_husky - <<: *pkg_cz-customizable-ghooks tasks: - name: commitmsg tasks: ['cz-customizable-ghooks'] description: Git commit message hook that validates the commit message conforms to your commit message conventions. packageJsonConfig: - config.commitizen.path: node_modules/cz-customizable - config.cz-customizable.config: <%- paths.config.configDir + resources.release.configSubDir %>commitMessageConfig.js templateFiles: - src: commitMessageConfig.js dest: <%- paths.config.configDir + resources.release.configSubDir %>commitMessageConfig.js overwrite: false readme: buildTask: # This is a "special" task in that it is designed to appear only in the Readme, not in package.json commit: commit: command: git cz description: Commit changes to local repository using Commitizen. features: - Asks questions about the change to generate a valid conventional commit message - Can be customised by modifying <%- link(paths.config.configDir + resources.release.configSubDir + 'commitMessageConfig.js') %> readmeBadges: - name: Commitizen friendly image: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg url: http://commitizen.github.io/cz-cli/ priority: 90 - condition: <%- !release.useSemantic %> tasks: - name: release tasks: ['verify', 'test:coverage', 'build', '<% if (config.testSystem) { %>test:system<% }%>'] description: Verify code, run unit tests, check test coverage, build software. features: - Define another script-task called `postrelease` to define the rest of your release process - condition: <%- app.repositoryType === 'GitHub' && release.useSemantic %> packages: - <<: *pkg_semantic-release-cli tasks: - name: pre-release tasks: ['verify', 'test:coverage', 'build', '<% if (config.testSystem) { %>test:system<% }%>'] description: | Verify code, run unit tests, check test coverage, build software. This task is designed to be run before the `semantic-release` task. features: - Run `semantic-release-cli setup` once you have a remote repository. See https://github.com/semantic-release/cli for details. - | Semantic-release integrates with Travis CI (or similar tools) to generate release notes for each release (which appears in the "Releases" section in GitHub) and publishes the package to NPM (when all the tests are successful) with a semantic version number. - condition: <%- app.repositoryType === 'BitBucket' && release.useSemantic %> packages: - <<: *pkg_corp-semantic-release tasks: - name: semantic-release tasks: ['corp-semantic-release --changelogpreset angular-bitbucket --post-success "npm publish"'] - name: release tasks: ['verify', 'test:coverage', 'build', '<% if (config.testSystem) { %>test:system<% }%>', 'semantic-release'] description: Create production version of software, verify code, run unit tests then if everything is ok, release the package features: - Generates `CHANGELOG.md` - Bumps `package.json` - Tags the changes with the release - Requires conventional commit messages to be used - condition: <%- app.repositoryType === 'Other' && release.useSemantic %> packages: - <<: *pkg_corp-semantic-release tasks: - name: semantic-release tasks: ['corp-semantic-release --post-success "npm publish"'] - name: release tasks: ['verify', 'test:coverage', 'build', '<% if (config.testSystem) { %>test:system<% }%>', 'semantic-release'] description: Create production version of software, verify code, run unit tests then if everything is ok, release the package features: - Generates `CHANGELOG.md` - Bumps `package.json` - Tags the changes with the release - Requires conventional commit messages to be used - condition: <%- app.repositoryType === 'GitHub' && release.checkCodeCoverage %> tasks: - name: upload-coverage tasks: ['cat <%- paths.output.reportDir + resources.testUnit.coverageReportSubDir %><%- app.projectType === "node" ? "" : "lcov/" %>lcov.info | coveralls'] description: Uploads code-coverage metrics to Coveralls.io features: - Setup - https://coveralls.zendesk.com/hc/en-us/articles/201347419-Coveralls-currently-supports - Define an environment variable called COVERALLS_REPO_TOKEN in your build environment with the repo token from https://coveralls.io/github/<repo-name>/settings - In your CI configuration (e.g. `travis.yml`), call `npm run upload-coverage` if the build is successful. sampleApp: toolModules: - condition: <%- buildJS.framework.length === 0 && buildJS.sourceFormat === 'ES6' %> templateFiles: - src: noFramework/ES6/* dest: <%- paths.input.srcDir + resources.sampleApp.demoDir %> overwrite: true - src: noFramework/ES6/unitTest/* dest: <%- paths.input.unitTestDir %> overwrite: true serverProd: packages: - <<: *pkg_serve-https - <<: *pkg_serve tasks: - name: serve:prod tasks: ["<%- (config.serverProd && config.serverProd.protocol === 'https') ? 'npm run serve:prod:https' : 'npm run serve:prod:http' -%>"] description: <% if (config.serverProd) { %>Runs a production server on **<%= config.serverProd.protocol + '://' + config.serverProd.hostname + ':' + config.serverProd.port %>**<% } -%> features: - HTTP or HTTPS - name: serve:prod:https tasks: ["<% if (config.serverProd) { %><%- 'serve-https -p ' + serverProd.port + ' -d ' + paths.output.prodDir + ' --servername ' + serverProd.hostname -%><% } -%>"] - name: serve:prod:http tasks: ["<% if (config.serverProd) { %><%- 'serve -C --compress -p ' + serverProd.port + ' ' + paths.output.prodDir -%><% } -%>"] testUnit: packages: - <<: *pkg_chokidar-cli - <<: *pkg_mocha - <<: *pkg_mocha-multi-reporters - <<: *pkg_mocha-junit-reporter - <<: *pkg_nyc templateFiles: - src: nycrc.json.tpl dest: .nycrc overwrite: true - src: mocha.opts dest: <%- paths.config.configDir + resources.testUnit.configSubDir %>mocha.opts overwrite: true - src: reporters.json dest: <%- paths.config.configDir + resources.testUnit.configSubDir %>reporters.json overwrite: true tasks: - name: test tasks: ['npm run test:unit'] description: Alias for `npm run test:unit` task features: [] - name: test:unit tasks: ['cross-env NODE_ENV=test nyc mocha --opts <%- paths.config.configDir + resources.testUnit.configSubDir %>mocha.opts -w'] description: Run unit tests whenever JS source or tests change features: - Uses Mocha - Code coverage - Runs continuously (best to run in a separate window) - name: test:unit:once tasks: ['cross-env NODE_ENV=test nyc mocha --opts <%- paths.config.configDir + resources.testUnit.configSubDir %>mocha.opts'] description: Run unit tests once features: - Uses Mocha - Code coverage - name: test:check-coverage tasks: ['nyc check-coverage'] description: features: - name: test:coverage tasks: ['npm-run-all test:unit:once test:check-coverage --silent'] description: Run instrumented unit tests then verify coverage meets defined thresholds features: - Returns non-zero exit code when coverage does not meet thresholds (as defined in istanbul.js) testVisualRegression: # Only do this if visual regression is enabled condition: <%- config.testVisualRegression && config.testVisualRegression.enabled %> packages: - <<: *pkg_backstopjs - <<: *pkg_glob tasks: - name: test:visual tasks: ['cross-env NODE_ENV=test cd node_modules/backstopjs && npm run test -- --configPath=../../<%= paths.config.configDir + resources.testVisualRegression.configSubDir %>backstop.config.js'] description: Run visual regression tests against the *development* web server (the development server **must** be running) features: - "<% if (config.testVisualRegression) { %>You can create visual regression tests by placing them in the `<%- testVisualRegression.moduleTestDir %>` folder inside any of your module folders (e.g. `<%- paths.input.srcDir + resources.sampleApp.demoDir + testVisualRegression.moduleTestDir %>`)<% } %>" - "Example scenario:<pre>module.exports = {<br> label: 'My Homepage',<br> url: '/',<br> selectors: ['header', 'footer']<br>};</pre>" - name: test:visual:ref tasks: ['cross-env NODE_ENV=test cd node_modules/backstopjs && npm run reference -- --configPath=../../<%= paths.config.configDir + resources.testVisualRegression.configSubDir %>backstop.config.js'] description: Creates visual regression testing reference images which are subsequently used as the baseline for future tests. The development server **must** be running. features: [] templateFiles: - src: backstop.config.js.tpl dest: <%= paths.config.configDir + resources.testVisualRegression.configSubDir %>backstop.config.js overwrite: true verify: # Common packages packages: - <<: *pkg_chokidar-cli tasks: - name: verify tasks: # "--silent" makes it easier to see program errors - > <% var verifyCmd = (resources.verify.verifyTasks.length > 1 ? 'npm-run-all ' : 'npm run ') + resources.verify.verifyTasks.join(' '); -%><%- verifyCmd -%> --silent<% -%> description: Verify code style and syntax features: - Verifies source *and test code* aginst customisable rules (unlike Webpack loaders) - name: verify:watch tasks: - > <% var verifyWatchTasks = resources.verify.verifyTasks.map(taskName => taskName + ':watch'); var verifyCmdWatch = (verifyWatchTasks.length > 1 ? 'npm-run-all --parallel ' : 'npm run ') + verifyWatchTasks.join(' '); -%><%- verifyCmdWatch -%> --silent<% -%> description: Runs verify task whenever JS or CSS code is changed features: [] toolModules: - condition: <%- ['none', 'AirBnB', 'ESLint', 'Google', 'StandardJS'].indexOf(verify.jsCodingStandard) > -1 %> tasks: - name: verify:js tasks: - > <% var jsExtensions = resources.buildJS.sourceFormat[buildJS.sourceFormat].ext; var jsSourcePaths = [paths.input.srcDir + '**/*.', paths.input.unitTestDir + '**/*.', paths.config.configDir + '**/*.']; var completeJSPaths = []; jsSourcePaths.forEach(function(path) { jsExtensions.forEach(function(ext) { completeJSPaths.push(path + ext); }); }); -%>eslint -c <%- paths.config.configDir + resources.verify.configSubDir %>.eslintrc.js "<%- completeJSPaths.join('" "') -%>"<%- onSuccessCmd('verify:js success') -%> description: Verify Javascript code style and syntax - name: verify:js:fix tasks: - > <% var jsExtensions = resources.buildJS.sourceFormat[buildJS.sourceFormat].ext; var jsSourcePaths = [paths.input.srcDir + '**/*.', paths.input.unitTestDir + '**/*.', paths.config.configDir + '**/*.']; var completeJSPaths = []; jsSourcePaths.forEach(function(path) { jsExtensions.forEach(function(ext) { completeJSPaths.push(path + ext); }); }); -%>eslint --fix -c <%- paths.config.configDir + resources.verify.configSubDir %>.eslintrc.js "<%- completeJSPaths.join('" "') -%>"<%- onSuccessCmd('verify:js:fix success') -%> description: Verify Javascript code style and syntax and fix any errors that can be fixed automatically - name: verify:js:watch tasks: - > <% var jsExtensions = resources.buildJS.sourceFormat[buildJS.sourceFormat].ext; var jsSourcePaths = [paths.input.srcDir + '**/*.', paths.input.unitTestDir + '**/*.', paths.config.configDir + '**/*.']; var completeJSPaths = []; jsSourcePaths.forEach(function(path) { jsExtensions.forEach(function(ext) { completeJSPaths.push(path + ext); }); }); -%>chokidar '<%- completeJSPaths.join('\' \'') -%>' -c 'npm run verify:js:fix' --initial --silent<% -%> description: Verify Javascript code style and syntax and watch files for changes - condition: <%- ['TypeScript'].indexOf(verify.jsCodingStandard) > -1 %> tasks: - name: verify:js tasks: - > <% var jsExtensions = resources.buildJS.sourceFormat[buildJS.sourceFormat].ext; var jsSourcePaths = [paths.input.srcDir + '**/*.', paths.input.unitTestDir + '**/*.', paths.config.configDir + '**/*.']; var completeJSPaths = []; jsSourcePaths.forEach(function(path) { jsExtensions.forEach(function(ext) { completeJSPaths.push(path + ext); }); }); %>tslint -c <%- paths.config.configDir + resources.verify.configSubDir %>tslint.json "<%- completeJSPaths.join('" "') -%>"<%- onSuccessCmd('verify:js success') -%> description: Verify Typescript code style and syntax - name: verify:js:watch tasks: - > <% var jsExtensions = resources.buildJS.sourceFormat[buildJS.sourceFormat].ext; var jsSourcePaths = [paths.input.srcDir + '**/*.', paths.input.unitTestDir + '**/*.', paths.config.configDir + '**/*.']; var completeJSPaths = []; jsSourcePaths.forEach(function(path) { jsExtensions.forEach(function(ext) { completeJSPaths.push(path + ext); }); }); %>chokidar '<%- completeJSPaths.join('\' \'') -%>' -c 'npm run verify:js' --initial --silent<% -%> description: Verify Typescript code style and syntax and watch files for changes - condition: <%- config.buildCSS && buildCSS.sourceFormat === 'css' %> tasks: # dummy tasks to preserve task interface - name: verify:css tasks: - echo <%- onSuccessCmd('verify:css success') -%> - name: verify:css:watch tasks: - echo <%- onSuccessCmd('verify:css success') -%> - condition: <%- config.buildCSS && buildCSS.sourceFormat === 'sass' %> packages: - <<: *pkg_sass-lint tasks: - name: verify:css tasks: - sass-lint -c <%- paths.config.configDir + resources.verify.configSubDir %>sasslint.yml --verbose<%- onSuccessCmd('verify:css success') -%> description: Verify CSS code style and syntax - name: verify:css:watch tasks: - > <% var hasCSSConfig = !!resources.buildCSS && buildCSS.sourceFormat; if (hasCSSConfig) { var cssExtensions = resources.buildCSS.sourceFormat[buildCSS.sourceFormat].ext; var cssSourcePaths = [paths.input.srcDir + '**/*.']; var completeCSSPaths = []; cssSourcePaths.forEach(function(path) { cssExtensions.forEach(function(ext) { completeCSSPaths.push(path + ext); }); }); %>chokidar '<%- completeCSSPaths.join('\' \'') -%>' -c 'npm run verify:css' --initial --silent<% } -%> description: Verify CSS code style and syntax and watch files for changes - condition: <%- config.buildCSS && buildCSS.sourceFormat === 'stylus' %> packages: - <<: *pkg_stylint tasks: - name: verify:css tasks: - stylint -c <%- paths.config.configDir + resources.verify.configSubDir %>.stylintrc <%- paths.input.srcDir -%><%- onSuccessCmd('verify:css success') -%> description: Verify CSS code style and syntax - name: verify:css:watch tasks: - > <% var hasCSSConfig = !!resources.buildCSS && buildCSS.sourceFormat; if (hasCSSConfig) { var cssExtensions = resources.buildCSS.sourceFormat[buildCSS.sourceFormat].ext; var cssSourcePaths = [paths.input.srcDir + '**/*.']; var completeCSSPaths = []; cssSourcePaths.forEach(function(path) { cssExtensions.forEach(function(ext) { completeCSSPaths.push(path + ext); }); }); %>chokidar '<%- completeCSSPaths.join('\' \'') -%>' -c 'npm run verify:css' --initial --silent<% } -%> description: Verify CSS code style and syntax and watch files for changes