.gitignore000066400000000000000000000003601516517553300130600ustar00rootroot00000000000000/build /node_modules /*.log /*.iws .idea/workspace.xml .idea/tasks.xml .idea/profiles_settings.xml .idea/inspectionProfiles/Project_Default.xml .idea/inspectionProfiles/profiles_settings.xml node_modules/.yarn-integrity package-lock.json .idea/000077500000000000000000000000001516517553300120515ustar00rootroot00000000000000.idea/codeStyleSettings.xml000066400000000000000000000004251516517553300162500ustar00rootroot00000000000000 .idea/corifeus-builder.iml000066400000000000000000000005201516517553300160140ustar00rootroot00000000000000 .idea/misc.xml000066400000000000000000000002561516517553300135310ustar00rootroot00000000000000 .idea/modules.xml000066400000000000000000000004341516517553300142440ustar00rootroot00000000000000 .idea/vcs.xml000066400000000000000000000002471516517553300133710ustar00rootroot00000000000000 .npmignore000066400000000000000000000002221516517553300130640ustar00rootroot00000000000000/.idea /artifacts /build /test /node_modules /*.iml /*.ipr /*.iws /.travis.yml /.scrutinizer.yml /Gruntfile.js /*.lock *.log /corifeus-boot.json .scrutinizer.yml000066400000000000000000000010061516517553300142500ustar00rootroot00000000000000checks: javascript: true filter: excluded_paths: - test/* - node_modules/* - build/* - docs/* build: cache: disabled: true environment: google_chrome: use_latest: true dependencies: before: - export LATEST=$(nvm ls-remote | tail -1) - nvm install $LATEST # - nvm use $LATEST - npm install -g grunt-cli tests: override: - command: 'grunt' coverage: file: 'build/coverage/clover.xml' format: 'clover' .travis.yml000066400000000000000000000001231516517553300131760ustar00rootroot00000000000000language: node_js node_js: - "node" before_script: - npm install grunt-cli -g Gruntfile.js000066400000000000000000000037371516517553300134000ustar00rootroot00000000000000module.exports = (grunt) => { const builder = require('./src'); const fs = require('fs'); const mz = require('mz'); const loader = new builder.loader(grunt); loader.js({ replacer: { npmio: true } }); grunt.registerTask('generate-folder', 'Generate the actual files' , function(target) { const folder = builder.config.folder; const items = {}; const recursive = (recursiveFolder) => { if (typeof(recursiveFolder) === 'string') { items[recursiveFolder] = true; return; } if (recursiveFolder instanceof Array) { //items[recursiveFolder.join(', ')] = true; return; } Object.keys(recursiveFolder).forEach((element) => { const result = recursiveFolder[element]; if (result.hasOwnProperty('root')) { items[result.root] = true; } recursive(result); }) } recursive(folder); const folders = Object.keys(items); let template = ` # Folders Skeleton folders \`\`\`javscript `; folders.sort().forEach((element) => template += `${element} `); template += '```'; fs.writeFileSync(`artifacts/readme/builds/folders.md`,template); }) grunt.registerTask('debug', function() { const done = this.async(); mz.child_process.exec('git config --list').then(function (stdout) { const result = stdout.join(''); grunt.log.write(result); done(); }) }) grunt.registerTask('default', [/*'debug',*/ 'generate-folder', 'cory-generate-tasks'].concat(builder.config.task.build.js)); // grunt.registerTask('default', ['debug'].concat(builder.config.task.build.js)); //grunt.registerTask('run', builder.config.task.run.js); grunt.registerTask('run', 'watch:cory-js-test'); }LICENSE000066400000000000000000000021411516517553300120740ustar00rootroot00000000000000MIT License Copyright (c) 2017 Patrik Laszlo / patrikx3 / https://patrikx3.com and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. README.md000066400000000000000000000220541516517553300123530ustar00rootroot00000000000000[//]: #@corifeus-header [![Build Status](https://travis-ci.org/patrikx3/corifeus-builder.svg?branch=master)](https://travis-ci.org/patrikx3/corifeus-builder) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/corifeus-builder/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus-builder/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/corifeus-builder/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus-builder/?branch=master) [![NPM](https://nodei.co/npm/corifeus-builder.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/corifeus-builder/) --- # Corifeus Builder - Make v1.7.1184-295 This is an open source project. Just code. If you like this code, please add a star in GitHub and you really like, you can donate as well. Thanks you so much! Given, I have my own server, with dynamic IP address, it could happen that the server for about max 5 minutes can not be reachable for the dynamic DNS or very rarely I backup with Clonzilla the SSD or something with the electricity (too much hoovering or cleaning - but I worked on it, so should not happen again), but for some reason, it is not reachable please hang on for 5-30 minutes and it will be back for sure. All my domains (patrikx3.com and corifeus.com) could have errors right now, since I am developing in my free time and you can catch glitches, but usually it is stable (imagine updating everything always, which is weird). ### Node Version Requirement ``` >=8.9.0 ``` ### Built on Node ``` v9.4.0 ``` The ```async``` and ```await``` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Description [//]: #@corifeus-header:end To provide a global library for testing, documentation, building and a shared common library. It uses JS and TypeScript. It is the builder for a few ```p3x``` libs and the whole ```Corifeus Platform```. Is uses grunt / webpack / jshint / karma / protractor / angular / mocha / istanbul coverage, and a few additional helpers for building like ```json2css```, automatic ```npm versioning``` end ```file replacer``` for adding in ```build date/version, git, repo name``` etc... # Version ```grunt cory-npm``` Generates automated version. Major and minor is kept. Build and commit is automatic. Major.Minor.Build-Commit # Tasks See [tasks](artifacts/readme/builds/tasks.md). # Folders [Folders](artifacts/readme/builds/folders.md) the system using. # Example package.json Name is based on the ```git``` repo name, plus a prefix, so all generated. (Was ```angular-compile```, in ```NPM``` it is ```p3x-angular-compile```, also the prefix is not required, in other libs is not used like ```Corifeus```.) ```json { "name": "p3x-angular-compile", "version": "1.1.114-203", "corifeus": { "time": "5/6/2017, 5:02:36 PM", "icon": "fa fa-gavel", "time-stamp": 1494082956181, "code": "Make", "publish": true } } ``` ## Example output ```text patrikx3@workstation ~/ramdisk/persistence/content/.p3x-ramdisk-link/Projects/patrikx3/corifeus/corifeus-builder $ grunt Running "generate-folder" task Running "cory-generate-tasks" task Running "cory-ensure-protractor" task Protractor is not on the path Running "cory-npm" task Running "clean:cory-build" (clean) task >> 1 path cleaned. Running "mocha_istanbul:cory-coverage" (mocha_istanbul) task async/await ✓ main (752ms) src/git commit: 35 branch: master date: 1495185080 repo: corifeus-builder ✓ branch / data / commit / repo src/task/json2scss ✓ default src/task/npm/exec new name: corifeus-builder old name: corifeus-builder new version: 1.7.572-36 old version: 1.7.571-36 ✓ default src/task/replace ✓ default 5 passing (832ms) -----------------------|----------|----------|----------|----------|----------------| File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines | -----------------------|----------|----------|----------|----------|----------------| All files | 52.87 | 28.26 | 31.48 | 52.48 | | src | 29.11 | 2.78 | 33.33 | 26.67 | | git.js | 100 | 50 | 100 | 100 | 10 | index.js | 100 | 100 | 100 | 100 | | loader.js | 8.2 | 0 | 0 | 8.33 |... 221,225,226 | src/config | 71.43 | 100 | 0 | 71.43 | | index.js | 71.43 | 100 | 0 | 71.43 | 5,6 | src/config/folder | 100 | 100 | 100 | 100 | | index.js | 100 | 100 | 100 | 100 | | src/config/grunt | 100 | 100 | 100 | 100 | | index.js | 100 | 100 | 100 | 100 | | src/config/grunt/js | 60 | 100 | 0 | 60 | | index.js | 60 | 100 | 0 | 60 | 6,101 | src/config/grunt/ts | 46.15 | 100 | 0 | 46.15 | | index.js | 46.15 | 100 | 0 | 46.15 |... 24,46,48,63 | src/config/task | 88.46 | 50 | 100 | 88.46 | | index.js | 88.46 | 50 | 100 | 88.46 | 46,47,50 | src/task | 18.42 | 0 | 0 | 18.42 | | ensure-protractor.js | 16.67 | 0 | 0 | 16.67 |... 26,28,30,31 | generate-tasks.js | 12.5 | 0 | 0 | 12.5 |... 19,20,24,34 | index.js | 100 | 100 | 100 | 100 | | noop.js | 33.33 | 100 | 0 | 33.33 | 2,3 | src/task/inject | 22.73 | 0 | 0 | 22.73 | | index.js | 25 | 0 | 0 | 25 | 4,5,6,7,9,10 | inject.js | 22.22 | 0 | 0 | 22.22 |... 47,48,49,51 | src/task/json2scss | 80.49 | 75 | 62.5 | 80.49 | | index.js | 25 | 0 | 0 | 25 | 4,6,7,8,10,11 | json2scss.js | 93.94 | 85.71 | 100 | 93.94 | 16,32 | src/task/npm | 73.68 | 60 | 50 | 72.97 | | index.js | 25 | 100 | 0 | 25 | 4,5,6,7,8,10 | npm.js | 86.67 | 60 | 100 | 86.21 | 20,21,33,41 | src/task/replace | 71.05 | 62.5 | 40 | 71.05 | | index.js | 25 | 0 | 0 | 25 | 5,7,8,9,11,12 | replace.js | 83.33 | 83.33 | 57.14 | 83.33 | 65,67,69,70,74 | -----------------------|----------|----------|----------|----------|----------------| =============================== Coverage summary =============================== Statements : 52.87% ( 184/348 ) Branches : 28.26% ( 26/92 ) Functions : 31.48% ( 17/54 ) Lines : 52.48% ( 180/343 ) ================================================================================ >> Done. Check coverage folder. Running "cory-replace" task Replaced: artifacts/readme/builds/folders.md, Pre: #@corifeus-header, Post: #@corifeus-header:end Replaced: artifacts/readme/builds/tasks.md, Pre: #@corifeus-header, Post: #@corifeus-header:end Replaced: README.md, Pre: #@corifeus-header, Post: #@corifeus-header:end Replaced: artifacts/readme/builds/folders.md, Pre: #@corifeus-footer, Post: #@corifeus-footer:end Replaced: artifacts/readme/builds/tasks.md, Pre: #@corifeus-footer, Post: #@corifeus-footer:end Replaced: README.md, Pre: #@corifeus-footer, Post: #@corifeus-footer:end Done. Execution Time (2017-05-19 11:41:05 UTC+2) mocha_istanbul:cory-coverage 2.1s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 97% Total 2.1s ``` # Await / Async Until it works for await/async, removed from **JSDoc**. [//]: #@corifeus-footer --- [**CORIFEUS-BUILDER**](https://pages.corifeus.com/corifeus-builder) Build v1.7.1184-295 [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LFRV89WPRMMVE&lc=HU&item_name=Patrik%20Laszlo&item_number=patrikx3¤cy_code=HUF&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) ## Sponsor [![JetBrains](https://www.patrikx3.com/images/jetbrains-logo.svg)](https://www.jetbrains.com/) [//]: #@corifeus-footer:endartifacts/000077500000000000000000000000001516517553300130515ustar00rootroot00000000000000artifacts/readme/000077500000000000000000000000001516517553300143065ustar00rootroot00000000000000artifacts/readme/builds/000077500000000000000000000000001516517553300155705ustar00rootroot00000000000000artifacts/readme/builds/folders.md000066400000000000000000000022361516517553300175530ustar00rootroot00000000000000[//]: #@corifeus-header ## Corifeus Builder - Make --- [//]: #@corifeus-header:end # Folders Skeleton folders ```javscript bin/ build/ build/browser/ build/coverage-node/ build/coverage/ build/jsdoc/ build/node/ build/typedoc/ src/ test/ test/angular-karma/ test/angular-protractor/ test/angular-webpack/ test/mocha/ ``` [//]: #@corifeus-footer --- [**CORIFEUS-BUILDER**](https://pages.corifeus.com/corifeus-builder) Build v1.7.1184-295 [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LFRV89WPRMMVE&lc=HU&item_name=Patrik%20Laszlo&item_number=patrikx3¤cy_code=HUF&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) ## Sponsor [![JetBrains](https://www.patrikx3.com/images/jetbrains-logo.svg)](https://www.jetbrains.com/) [//]: #@corifeus-footer:endartifacts/readme/builds/tasks.md000066400000000000000000000025471516517553300172470ustar00rootroot00000000000000[//]: #@corifeus-header ## Corifeus Builder - Make --- [//]: #@corifeus-header:end # Tasks Skeleton tasks ```javscript clean:cory-build copy:cory-build copy:cory-run cory-build-run cory-ensure-protractor cory-generate-tasks cory-inject cory-json2scss cory-noop cory-npm cory-replace cory-replace:footer cory-replace:footerMain cory-replace:header cory-replace:headerMain cory-test jshint:files mochaTest:cory-test-js mocha_istanbul:cory-coverage watch:cory-js-all watch:cory-js-doc watch:cory-js-test watch:cory-wait ``` [//]: #@corifeus-footer --- [**CORIFEUS-BUILDER**](https://pages.corifeus.com/corifeus-builder) Build v1.7.1184-295 [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LFRV89WPRMMVE&lc=HU&item_name=Patrik%20Laszlo&item_number=patrikx3¤cy_code=HUF&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) ## Sponsor [![JetBrains](https://www.patrikx3.com/images/jetbrains-logo.svg)](https://www.jetbrains.com/) [//]: #@corifeus-footer:endcorifeus-builder.iml000066400000000000000000000005171516517553300150420ustar00rootroot00000000000000 index.js000066400000000000000000000000421516517553300125320ustar00rootroot00000000000000module.exports = require('./src');package.json000066400000000000000000000034611516517553300133630ustar00rootroot00000000000000{ "name": "corifeus-builder", "version": "1.7.1184-295", "corifeus": { "icon": "fa fa-gavel", "code": "Make", "publish": true, "nodejs": "v9.4.0" }, "description": "Corifeus Builder - Make", "main": "src/index.js", "directories": { "test": "test" }, "scripts": { "test": "grunt", "coverage": "istanbul cover node_modules/mocha/bin/_mocha --report clover -- -R spec test/mocha/**/*.js", "ng-start": "webpack-dev-server --inline --progress --port 8080", "ng-test": "karma start", "ng-build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail" }, "repository": { "type": "git", "url": "git+https://github.com/patrikx3/corifeus-builder.git" }, "keywords": [ "corifeus", "builder" ], "author": "Patrik Laszlo ", "license": "MIT", "bugs": { "url": "https://github.com/patrikx3/corifeus-builder/issues" }, "homepage": "https://pages.corifeus.com/corifeus-builder", "dependencies": { "corifeus-utils": "^1.1.793-280", "fs-extra": "^5.0.0", "grunt": "^1.0.1", "grunt-contrib-clean": "^1.1.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-jshint": "^1.1.0", "grunt-contrib-watch": "^1.0.0", "grunt-mocha-istanbul": "^5.0.2", "grunt-mocha-test": "^0.13.3", "istanbul": "^1.1.0-alpha.1", "jit-grunt": "^0.10.0", "mocha": "^5.0.0", "mz": "^2.7.0", "should": "^13.2.1", "time-grunt": "^1.4.0" }, "dependencies-removed": { "grunt-jsdoc": "^2.1.0", "ink-docstrap": "^1.3.0" }, "devDependencies": {}, "engines": { "node": ">=8.9.0" } }src/000077500000000000000000000000001516517553300116605ustar00rootroot00000000000000src/config/000077500000000000000000000000001516517553300131255ustar00rootroot00000000000000src/config/folder/000077500000000000000000000000001516517553300144005ustar00rootroot00000000000000src/config/folder/index.js000066400000000000000000000036071516517553300160530ustar00rootroot00000000000000const folderBuild = 'build/'; const folderBuildCoverage = folderBuild + 'coverage/'; const folderBuildCoverageNode = folderBuild + 'coverage-node/'; const folderBuildJsdoc = folderBuild + 'jsdoc/'; const folderBuildTypedoc = folderBuild + 'typedoc/'; const folderBuildBrowser = folderBuild + 'browser/'; const folderBuildNode = folderBuild + 'node/'; const folderBin = 'bin/'; const folderSrc = 'src/'; const folderTest = 'test/'; const folderTestMocha = folderTest + 'mocha/'; const folderTestAngular = folderTest + 'angular-webpack/'; const folderTestAngularKarma = folderTest + 'angular-karma/'; const folderTestAngularProtractor = folderTest + 'angular-protractor/'; const folderFilesAll = [ 'Gruntfile.js', 'src/**/*.*', 'test/**/*.*', ]; const folderFilesMocha = [ folderTestMocha + '**/*.*' ]; const folderFilesDoc = folderFilesAll; /** * @module Grunt * @namespace Grunt/grunt/folder */ module.exports = { src: { root: folderSrc }, bin: { root: folderBin }, files: { all: folderFilesAll, mocha: folderFilesMocha, doc: folderFilesDoc }, build: { root: folderBuild, jsdoc: { root: folderBuildJsdoc }, typedoc: { root: folderBuildTypedoc }, coverage: { root: folderBuildCoverage }, coverageNode: { root: folderBuildCoverageNode }, node: { root: folderBuildNode }, browser: { root: folderBuildBrowser } }, test: { root: folderTest, angularWebpack: { root: folderTestAngular }, angularKarma: { root: folderTestAngularKarma }, angularProtractor: { root: folderTestAngularProtractor }, mocha: { root: folderTestMocha } } };src/config/grunt/000077500000000000000000000000001516517553300142645ustar00rootroot00000000000000src/config/grunt/index.js000066400000000000000000000000441516517553300157270ustar00rootroot00000000000000module.exports.js = require('./js');src/config/grunt/js/000077500000000000000000000000001516517553300147005ustar00rootroot00000000000000src/config/grunt/js/index.js000066400000000000000000000055761516517553300163620ustar00rootroot00000000000000const folder = require('../../folder'); const task = require('../../task'); module.exports = (grunt) => { const result = { copy: { 'cory-run': { }, 'cory-build': { } }, jshint: { files: folder.files.all, options: { "asi": true, "esversion": 6 } }, mochaTest: { 'cory-test-js': { src: folder.files.mocha }, }, mocha_istanbul: { 'cory-coverage': { src: [ // `${process.cwd()}/${folder.bin.root}` , `${process.cwd()}/${folder.src.root}` , `${process.cwd()}/${folder.test.mocha.root}`, ], // the folder, not the files options: { mochaOptions: ['--exit'], mask: '**/*.js', includes: [ // `${process.cwd()}/${folder.bin.root}**` , `${process.cwd()}/${folder.src.root}**` , `${process.cwd()}/${folder.test.mocha.root}**`, ], /* to add more local files, outside directories mochaOptions: [ 'cli.js' ], */ coverageFolder: folder.build.coverage.root, reportFormats: [ 'clover', 'html', 'text' ] } } }, clean: { 'cory-build': [ folder.build.root ] }, watch: { 'cory-wait': { options: { reload: false }, files: folder.files.all, tasks: [] }, 'cory-js-all': { options: { reload: true }, files: folder.files.all, tasks: task.watch.jsAll }, 'cory-js-test': { options: { reload: true }, files: folder.files.all, tasks: task.watch.jsTest }, 'cory-js-doc': { files: folder.files.all, tasks: task.watch.doc }, }, /* jsdoc: { 'cory-dist': { src: folder.files.doc, options: { destination: folder.build.jsdoc.root, template : "node_modules/ink-docstrap/template", configure : "node_modules/ink-docstrap/template/jsdoc.conf.json", plugins: ["node_modules/jsdoc-strip-async-await"] } } }, */ } return result; }; src/config/grunt/ts/000077500000000000000000000000001516517553300147125ustar00rootroot00000000000000src/config/grunt/ts/index.js000066400000000000000000000033271516517553300163640ustar00rootroot00000000000000const folder = require('../../folder'); const jsConfig = require('../js'); const _ = require('lodash'); const path = require('path'); const _root = path.resolve(process.cwd()); module.exports = () => { const tsSrc = { options: require(`${_root}/tsconfig.json`).compilerOptions, files: [{ src: [ `${folder.src.root}/**/*.ts`, `!${folder.src.root}/.baseDir.ts`, `!${folder.src.root}/_all.d.ts`, ], dest: folder.build.node.root }] }; const tsBuild = Object.assign({}, tsSrc); tsBuild.options.sourceMap = false; const config = { copy: { 'cory-build-ts': { files: [ { src: './package.json', dest: folder.build.root }, { src: './data/**/*.*', dest: folder.build.root } ] } }, ts: { run: tsSrc, build: tsBuild }, }; const result = _.merge(config, jsConfig()); result.mocha_istanbul['cory-coverage-ts'] = { src: [ folder.build.node.root, folder.test.mocha.root ], // the folder, not the files options: { mask: '**/*.js', coverageFolder: folder.build.coverageNode.root, reportFormats: [ 'clover', 'html', 'text' ] } }; throw new Error('Please fix TypeScript module here above (mocha_istanbul settings changed, check js settings, simple)'); // return result; } src/config/index.js000066400000000000000000000004701516517553300145730ustar00rootroot00000000000000const path = require('path'); const _root = path.resolve(process.cwd()); module.exports.root = function(args) { args = Array.prototype.slice.call(arguments, 0); return path.join.apply(path, [_root].concat(args)); }; module.exports.folder = require('./folder'); module.exports.task = require('./task'); src/config/task/000077500000000000000000000000001516517553300140675ustar00rootroot00000000000000src/config/task/index.js000066400000000000000000000043571516517553300155450ustar00rootroot00000000000000const fs = require('fs'); const folder = require('../folder'); const taskBuildEmpty = [ 'cory-npm', 'clean', 'cory-replace' ] const taskBuild = [ 'cory-ensure-protractor', 'cory-npm', 'clean', 'mocha_istanbul:cory-coverage', /*, 'jsdoc'*/ 'cory-replace' ]; const tasBuildTs = [ 'cory-ensure-protractor', 'cory-npm', 'clean', 'copy:cory-build-ts', 'ts:build', 'mocha_istanbul:cory-coverage-ts', /*, 'jsdoc'*/ 'cory-replace' ]; const taskBuildAngular = [ 'cory-ensure-protractor', 'cory-npm', 'cory-npm-angular', 'clean', 'copy:cory-build', ]; const taskBuildAngularAot = taskBuildAngular.slice(); taskBuildAngularAot.push('webpack:cory-build-aot'); let taskBuildAngularAotJit = taskBuildAngular.slice(); taskBuildAngularAotJit.push('cory-compile-angular'); taskBuildAngularAotJit.push('webpack:cory-build-aot-jit'); taskBuildAngular.push('webpack:cory-build'); if (fs.existsSync(folder.test.angularProtractor.root)) { taskBuildAngular.push('connect:cory-angular'); taskBuildAngular.push('protractor:cory-angular-chrome'); } if (fs.existsSync(folder.test.angularKarma.root)) { taskBuildAngular.push('karma:cory-angular'); } taskBuildAngular.push('cory-replace'); taskBuildAngularAot.push('cory-replace'); taskBuildAngularAotJit.push('cory-replace'); const taskTest = ['jshint', 'mochaTest']; const runAll = taskBuild.slice(); runAll.push('watch:cory-js-all'); const runTest = taskTest.slice(); runTest.push('watch:cory-doc'); module.exports = { build: { js: taskBuild, angular: taskBuildAngular, angularAot: taskBuildAngularAot, angularAotJit: taskBuildAngularAotJit, ts: tasBuildTs, empty: taskBuildEmpty, }, run: { angular: [ 'clean', 'copy:cory-run', 'cory-npm', 'webpack-dev-server:cory-run' ], js: runAll, jsTest: ['mochaTest'], jsDoc: ['jsdoc', 'watch:cory-doc'] }, watch: { jsAll: taskBuild, jsTest: taskTest, jsDoc: ['jsdoc'] }, test: { jsTest: taskTest, angularKarma: [ 'clean', 'copy:cory-run', 'cory-npm', ] } }; src/git.js000066400000000000000000000014741516517553300130070ustar00rootroot00000000000000const exec = require('mz/child_process').exec; const commit = exec('git rev-list --all --count').then((stdout) => parseInt(stdout.join('').toString())); const date = exec('git log -1 --format=%at').then((stdout) => parseInt(stdout.join('').toString())); const branch = exec('git rev-parse --abbrev-ref HEAD').then((stdout) => stdout.join('').toString().trim()); const repo = exec('git config remote.origin.url').then((stdout) => { const data = stdout.join('').toString().split('/'); let repo = data[ data.length -1 ].trim(); const remove = '.git'; if (repo.toLowerCase().endsWith(remove)) { repo = repo.substr(0, repo.length - remove.length ); } return repo; }); const settings = { "branch": branch, "date": date, "commit": commit, "repo": repo }; module.exports = settings; src/index.js000066400000000000000000000002201516517553300133170ustar00rootroot00000000000000require('corifeus-utils'); module.exports = { config: require('./config'), loader: require('./loader'), task: require('./task'), } src/loader.js000066400000000000000000000253111516517553300134660ustar00rootroot00000000000000const task = require('./task/index'); const folder = require('./config/folder/index'); const _ = require('lodash'); const utils = require('corifeus-utils'); const fs = require('fs'); class loader { constructor(grunt) { this.grunt = grunt this.configJit = { jshint: 'grunt-contrib-jshint', mochaTest: 'grunt-mocha-test', mocha_istanbul: 'grunt-mocha-istanbul', clean: 'grunt-contrib-clean', watch: 'grunt-contrib-watch', jsdoc: 'grunt-contrib-jsdoc', }; } load(options) { const grunt = this.grunt; options = options || {}; options.jit = _.merge(this.configJit, options.jit || {}) options.config = _.merge(require('./config/grunt/js/index')(grunt), options.config) const config = options.config; if (options.empty ) { delete options.config['mocha_istanbul']; options.replacer = { type: 'p3x', } } options.replacer = options.replacer || {} let replacer = 'corifeus'; if (typeof(options.replacer) === 'string') { replacer = options.replacer; } else if (options.replacer.hasOwnProperty('type')) { replacer = options.replacer.type; } const replaceFiles = [ 'artifacts/**/*.md', 'docs/**/*.md', '*.md', '!node_modules', '!build', '!LICENSE.md', '!readme.md', '!README.md', ] const defaultHeader = { header: true, replace: ` ## \${pkg.description} --- `, files: replaceFiles } const defaultFooter = { footer: true, replace: ` --- [**\${pkg.name.toUpperCase()}**](https://pages.corifeus.com/\${git.repo}) Build v\${pkg.version} [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LFRV89WPRMMVE&lc=HU&item_name=Patrik%20Laszlo&item_number=patrikx3¤cy_code=HUF&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) ## Sponsor [![JetBrains](https://www.patrikx3.com/images/jetbrains-logo.svg)](https://www.jetbrains.com/) `, files: replaceFiles }; let angularVersion = ''; const angularPkgPath = `${process.cwd()}/node_modules/@angular/common/package.json`; if (fs.existsSync(angularPkgPath)) { const angularPkg = JSON.parse(fs.readFileSync(angularPkgPath).toString()); angularVersion = ` # Built on Angular \`\`\`${angularPkg.version}\`\`\` ` } const hideNodeVersion = options.hasOwnProperty('replacer') && options.replacer.node === false; let hideBuild = options.hasOwnProperty('replacer') && options.replacer.build === false; let build = hideBuild ? '' : `[![Build Status](https://travis-ci.org/patrikx3/\${git.repo}.svg?branch=master)](https://travis-ci.org/patrikx3/\${git.repo}) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/?branch=master)` let nodeVersion = hideNodeVersion ? `# \${pkg.description} v\${pkg.version} # Description ` : `# \${pkg.description} v\${pkg.version} This is an open source project. Just code. If you like this code, please add a star in GitHub and you really like, you can donate as well. Thanks you so much! Given, I have my own server, with dynamic IP address, it could happen that the server for about max 5 minutes can not be reachable for the dynamic DNS or very rarely I backup with Clonzilla the SSD or something with the electricity (too much hoovering or cleaning - but I worked on it, so should not happen again), but for some reason, it is not reachable please hang on for 5-30 minutes and it will be back for sure. All my domains (patrikx3.com and corifeus.com) could have errors right now, since I am developing in my free time and you can catch glitches, but usually it is stable (imagine updating everything always, which is weird). ### Node Version Requirement \`\`\` \${pkg.engines.node} \`\`\` ### Built on Node \`\`\` ${process.version} \`\`\` The \`\`\`async\`\`\` and \`\`\`await\`\`\` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ ${angularVersion} # Description ` const footerMain = _.clone(defaultFooter); footerMain.files = [ 'readme.md', 'README.md', ]; switch(replacer) { case 'corifeus': options.config['cory-replace'] = { headerMain: { header: true, replace: ` ${build} --- ${nodeVersion} `, files: [ 'readme.md', 'README.md', ] }, footerMain: footerMain, header: defaultHeader, footer: defaultFooter } break; case 'p3x': let nonEmptyP3x = ''; if (!options.empty) { nonEmptyP3x = `${build} --- ` } options.config['cory-replace'] = { headerMain: { header: true, /* [![Trello](https://img.shields.io/badge/Trello-p3x-026aa7.svg)](https://trello.com/b/gqKHzZGy/p3x) */ replace: ` ${nonEmptyP3x} ${nodeVersion} `, files: [ 'readme.md', 'README.md', ] }, footerMain: footerMain, header: defaultHeader, footer: defaultFooter }; break; case 'build': case 'lede': let nonEmptyLede = ''; if (!options.empty) { nonEmptyLede = `[![Build Status](https://travis-ci.org/patrikx3/\${git.repo}.svg?branch=master)](https://travis-ci.org/patrikx3/\${git.repo}) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/\${git.repo}/?branch=master) # \${pkg.description} ` } options.config['cory-replace'] = { headerMain: { header: true, /* [![Trello](https://img.shields.io/badge/Trello-p3x-026aa7.svg)](https://trello.com/b/gqKHzZGy/p3x) */ replace: ` ${nonEmptyLede} `, files: [ 'readme.md', 'README.md', ] }, footerMain: footerMain, header: defaultHeader, footer: defaultFooter }; break; case 'home': options.config['cory-replace'] = { header: { header: true, replace: ` ## \${pkg.description} --- `, files: [ 'readme.md', 'README.md', ] }, footer: defaultFooter, } break; default: throw new Error(`unknown replacer ${options.replacer}`) } if (options.replacer.hasOwnProperty('npmio') && options.replacer.npmio === true && options.config['cory-replace'].hasOwnProperty('headerMain')) { const replace = options.config['cory-replace'].headerMain.replace; const append = replace.substring(replace.indexOf('---')); options.config['cory-replace'].headerMain.replace = replace.substring(0, replace.indexOf('---')) + ` [![NPM](https://nodei.co/npm/\${pkg.name}.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/\${pkg.name}/) ` + append } grunt.config.merge(config); Object.keys(task).forEach((taskItem) => task[taskItem](grunt)) grunt.registerTask('cory-test', (target) => { switch(target) { case 'js-mocha': grunt.task.run([ 'mochaTest', 'watch:cory-js-test' ]) break; case 'angular-protractor': grunt.task.run([ 'connect:cory-angular', 'protractor:cory-angular-chrome', ]); break; case 'angular-karma': grunt.task.run([ 'karma:cory-angular-run', 'watch:cory-angular-karma' ]); break; } }); grunt.registerTask('cory-build-run', (target) => { switch(target) { case 'angular': grunt.task.run(config.task.run.angular); break; case 'js': grunt.task.run(config.task.run.js); break; } }); // should be at the end require('jit-grunt')(grunt, options.jit); require('time-grunt')(grunt); } js(options) { options = options || {}; this.load(options); } empty(options) { options = options || {}; options.empty = true; this.load(options); } ts(options) { options = options || {}; options.config = _.merge(require('./config/grunt/ts/index')(), options.config || {}), this.load(options); } } module.exports = loader;src/task/000077500000000000000000000000001516517553300126225ustar00rootroot00000000000000src/task/ensure-protractor.js000066400000000000000000000022061516517553300166560ustar00rootroot00000000000000const fs = require('mz/fs'); const execSync = require('child_process').execSync; module.exports = (grunt) => { grunt.registerTask('cory-ensure-protractor', async function () { const done = this.async(); if ( fs.existsSync('./node_modules/protractor/bin/webdriver-manager') && !fs.existsSync('./node_modules/webdriver-manager/selenium/update-config.json') ) { grunt.log.write('Protractor found on the path') try { execSync('node ./node_modules/protractor/bin/webdriver-manager update', { stdio: `inherit` }) grunt.log.write('') done(); } catch(e) { grunt.log.write('') done(e) } } else { if (fs.existsSync('./node_modules/webdriver-manager/selenium/update-config.json')) { grunt.log.write('Protractor is already installed') } else { grunt.log.write('Protractor is not on the path') } grunt.log.write('') done() } }) }src/task/generate-tasks.js000066400000000000000000000015561516517553300161040ustar00rootroot00000000000000const fs = require('fs'); module.exports = (grunt) => { grunt.registerTask('cory-generate-tasks', function () { const config = grunt.config.get(); const tasks = []; Object.keys(config).forEach((item) => { Object.keys(config[item]).forEach((sub) => { if (sub === 'options') { return; } tasks.push(`${item}:${sub}`); }) }) for(let taskName in grunt.task._tasks) { const task = grunt.task._tasks[taskName]; if (taskName.startsWith('cory')) { tasks.push(`${taskName}`); } } const template = ` # Tasks Skeleton tasks \`\`\`javscript ${tasks.sort().join(` `)} \`\`\` `; fs.writeFileSync(`artifacts/readme/builds/tasks.md`,template); }) }src/task/index.js000066400000000000000000000004561516517553300142740ustar00rootroot00000000000000module.exports = { "npm": require('./npm'), "noop": require('./noop'), "replace": require('./replace'), "json2scss": require('./json2scss'), "generate-tasks": require('./generate-tasks'), "ensure-protractor": require('./ensure-protractor'), "inject": require('./inject'), } src/task/inject/000077500000000000000000000000001516517553300140765ustar00rootroot00000000000000src/task/inject/index.js000066400000000000000000000006561516517553300155520ustar00rootroot00000000000000const exec = require('./inject'); module.exports = (grunt) => { grunt.registerTask('cory-inject', function (target) { const config = grunt.config.get('cory-inject'); if (target !== undefined) { exec(grunt, config[target], this.async()); } else { Object.keys(config).forEach((item) => { exec(grunt, config[item], this.async()); }); } }) }src/task/inject/inject.js000066400000000000000000000030221516517553300157050ustar00rootroot00000000000000const fs = require('fs'); const _ = require('lodash'); const git = require('../../git'); const process = require('process'); const path = require('path'); const utils = require('corifeus-utils') const replaces = { prefix: '//corifeus-inject', postfix: '//corifeus-inject:end', } module.exports = (grunt, inConfig, done) => { const config = Object.assign({}, inConfig); if (!config.hasOwnProperty('prefix')) { config.prefix = replaces.prefix } if (!config.hasOwnProperty('postfix')) { config.postfix = replaces.postfix } console.log('Config', config); const dest = path.dirname(`${process.cwd()}/${config.dest}`); console.log(`Destination: ${dest}`) const files = grunt.file.expand(config.files) let inject = ''; const template = _.template(config.template); let index = 0; files.forEach((file) => { if (index > 0) { inject += '\n'; } index++; console.log(`Injectable: ${file}`) const relative = path.relative(dest, file).replace(/\\/g, '/') console.log(`Relative file: ${relative}`) inject += `${template({file: relative})}` }) console.log(`Inject result:`, inject); const destFile = path.resolve(config.dest); let data = fs.readFileSync(destFile ).toString(); config.replace = inject; data = utils.string.inject(data, config); grunt.log.writeln(`Injected: ${destFile}, Pre: ${config.prefix}, Post: ${config.postfix}`); fs.writeFileSync(destFile , data); done() }; src/task/json2scss/000077500000000000000000000000001516517553300145515ustar00rootroot00000000000000src/task/json2scss/index.js000066400000000000000000000006321516517553300162170ustar00rootroot00000000000000const exec = require('./json2scss'); module.exports = (grunt) => { grunt.registerTask('cory-json2scss', function (target) { const config = grunt.config.get('cory-json2scss'); if (target !== undefined) { exec(grunt, config[target]); } else { Object.keys(config).forEach((git) => { exec(grunt, config[git]); }); } }) }src/task/json2scss/json2scss.js000066400000000000000000000033711516517553300170420ustar00rootroot00000000000000const fs = require('fs'); const _ = require('lodash'); module.exports = (grunt, inConfig) => { const files = grunt.file.expand(inConfig.files); let dest = ''; files.forEach((file) => { const json = JSON.parse(fs.readFileSync(file).toString()); const resurive = (element, root) => { if (root === undefined) { root = '$'; if (inConfig.hasOwnProperty('prefix')) { root += `${inConfig.prefix}-`; } } else { root += '-'; } Object.keys(element).forEach((key) => { const actualKey = root + key; let actualElement = element[key]; if (actualElement instanceof Array) { let list = ''; actualElement.forEach((arrayElement, arrayIndex) => { if (arrayIndex > 0) { list += ' , '; } if (typeof arrayElement === 'string') { arrayElement = '"' + arrayElement + '"'; } list += arrayElement; }) dest += `${actualKey}: ${list};\r\n`; } else if (typeof actualElement === 'object') { resurive(actualElement, actualKey); } else { if (typeof actualElement === 'string') { actualElement = '"' + actualElement + '"'; } dest += `${actualKey}: ${actualElement};\r\n`; } }); } resurive(json); }) fs.writeFileSync(inConfig.dest, dest); return dest; }; src/task/noop.js000066400000000000000000000002241516517553300141310ustar00rootroot00000000000000 module.exports = (grunt) => { grunt.registerTask('cory-noop', () => { grunt.log.write('Corifeus Builder Noop - just empty') }) }src/task/npm/000077500000000000000000000000001516517553300134145ustar00rootroot00000000000000src/task/npm/index.js000066400000000000000000000005071516517553300150630ustar00rootroot00000000000000const exec = require('./npm'); module.exports = (grunt) => { grunt.registerTask('cory-npm', function() { const done = this.async(); const pkgFile = process.cwd() + '/package.json'; exec(pkgFile) .then(() => done() ) .catch((error) => { done(error); }); }) }src/task/npm/npm.js000066400000000000000000000025061516517553300145470ustar00rootroot00000000000000const fs = require('mz/fs'); const git = require('../../git'); module.exports = async (pkgFile) => { const result = await Promise.all([ git.commit, git.repo, fs.readFile(pkgFile) ]); const commit = result[0]; const repo = result[1]; const pkg = JSON.parse(result[2].toString()); let version = pkg.version.split('.'); const size = 3; if (version.length < size) { const extend = Array(size - version.length ).fill('0'); version = version.concat(extend); } version = version.map((element) => { return !Number.isInteger(parseInt(element)) ? '0' : element; }) const subVersion = version[2].split('-'); subVersion[0] = parseInt(subVersion[0]) + 1; subVersion[1] = commit + 1; if (subVersion[1] === undefined) { subVersion[1] = 0; } version[2] = subVersion.join('-'); pkg.version = version.join('.'); if (!pkg.hasOwnProperty('corifeus')) { pkg.corifeus = {}; } const prefix = pkg.corifeus.prefix || ''; pkg.name = `${prefix}${repo}`; pkg.engines = { "node" : ">=8.9.0" }; pkg.homepage = `https://pages.corifeus.com/${repo}`; pkg.corifeus.nodejs = process.version const newPkgFile = JSON.stringify(pkg, null, 4); await fs.writeFile(pkgFile, newPkgFile) return pkg; } src/task/replace/000077500000000000000000000000001516517553300142355ustar00rootroot00000000000000src/task/replace/index.js000066400000000000000000000006601516517553300157040ustar00rootroot00000000000000const exec = require('./replace'); module.exports = (grunt) => { grunt.registerTask('cory-replace', function (target) { const config = grunt.config.get('cory-replace'); if (target !== undefined) { exec(grunt, config[target], this.async()); } else { Object.keys(config).forEach((git) => { exec(grunt, config[git], this.async()); }); } }) }src/task/replace/replace.js000066400000000000000000000041301516517553300162040ustar00rootroot00000000000000const fs = require('fs'); const _ = require('lodash'); const git = require('../../git'); const process = require('process'); const path = require('path'); const utils = require('corifeus-utils') const replaces = { header: { prefix: '[//]: #@corifeus-header', postfix: '[//]: #@corifeus-header:end', }, footer: { prefix: '[//]: #@corifeus-footer', postfix: '[//]: #@corifeus-footer:end', } } module.exports = async (grunt, inConfig, done) => { try { const config = Object.assign({}, inConfig); ['header', 'footer'].forEach((type) => { if (config.hasOwnProperty(type) && config[type]) { ['prefix', 'postfix'].forEach((fix) => { if (!config.hasOwnProperty(fix)) { config[fix] = replaces[type][fix]; } }) } else { config[type] = false; } }) // console.log(config); const files = grunt.file.expand(config.files); // console.log(files); const gitData = { branch: undefined, date: undefined, commit: undefined, repo: undefined }; const result = await Promise.all([ git.branch, git.date, git.commit, git.repo ]) gitData.branch = result[0]; gitData.date = result[1]; gitData.commit = result[2]; gitData.repo = result[3]; config.replace = _.template(config.replace)({ git: gitData, pkg: require(`${process.cwd()}/package.json`) }); files .map((file) => fs.readFileSync(file).toString()) .forEach((data, index) => { data = utils.string.inject(data, config); grunt.log.writeln(`Replaced: ${files[index]}, Pre: ${config.prefix.replace('[//]:', '')}, Post: ${config.postfix.replace('[//]:', '')}`); fs.writeFileSync(files[index], data); }) done(); } catch (error) { done(error); } }; test/000077500000000000000000000000001516517553300120505ustar00rootroot00000000000000test/data/000077500000000000000000000000001516517553300127615ustar00rootroot00000000000000test/data/json2scss/000077500000000000000000000000001516517553300147105ustar00rootroot00000000000000test/data/json2scss/expect.scss000066400000000000000000000002541516517553300170760ustar00rootroot00000000000000$one: 1; $one-2: 2; $cool: 1 , 2 , 3; $weird-cool: "cool"; $weird-not-cool: "bad"; $one2: 1; $one-3: 2; $cool3: 1 , 2 , 3; $weird2-cool2: "cool"; $weird2-not-cool3: "bad"; test/data/json2scss/one.json000066400000000000000000000001541516517553300163640ustar00rootroot00000000000000{ "one": 1, "one-2": 2, "cool": [1, 2,3], "weird": { "cool": "cool", "not-cool": "bad" } }test/data/json2scss/two.json000066400000000000000000000001611516517553300164120ustar00rootroot00000000000000{ "one2": 1, "one-3": 2, "cool3": [1, 2,3], "weird2": { "cool2": "cool", "not-cool3": "bad" } }test/data/replace/000077500000000000000000000000001516517553300143745ustar00rootroot00000000000000test/data/replace/template/000077500000000000000000000000001516517553300162075ustar00rootroot00000000000000test/data/replace/template/replace-empty.txt000066400000000000000000000000001516517553300215050ustar00rootroot00000000000000test/data/replace/template/replace-header.txt000066400000000000000000000000061516517553300216050ustar00rootroot00000000000000headertest/mocha/000077500000000000000000000000001516517553300131375ustar00rootroot00000000000000test/mocha/async-await.js000066400000000000000000000005451516517553300157210ustar00rootroot00000000000000const should = require('should'); describe('async/await', async function() { it('main', async () => { const asyncFunc = async () => { return new Promise((resolve) => { setTimeout(() => resolve(true), 750); }) } let result = await asyncFunc(); should.equal(result, true) }) })test/mocha/git.js000066400000000000000000000013541516517553300142630ustar00rootroot00000000000000const should = require('should'); const git = require('../../src/git'); describe('src/git', () => { it('branch / data / commit / repo', async () => { const result = await Promise.all([ git.commit, git.branch, git.date, git.repo ]); const commit = result[0]; const branch = result[1]; const date = result[2]; const repo = result[3]; commit.should.be.a.Number(); branch.should.be.a.String(); date.should.be.a.Number(); repo.should.be.a.String(); console.log(`commit: ${commit}`); console.log(`branch: ${branch}`); console.log(`date: ${date}`); console.log(`repo: ${repo}`); }) })test/mocha/task/000077500000000000000000000000001516517553300141015ustar00rootroot00000000000000test/mocha/task/json2scss.js000066400000000000000000000011601516517553300163640ustar00rootroot00000000000000const should = require('should'); const exec = require('../../../src/task/json2scss/json2scss'); const fs = require('fs'); const mkdirp = require('mkdirp'); const grunt = require('grunt'); describe('src/task/json2scss', () => { it('default', () => { const folderBuild = 'build/mocha/json2scss/'; if (!fs.existsSync(folderBuild)) { mkdirp.sync(folderBuild); } const config = { files: [ 'test/data/json2scss/*.json' ], dest: `${folderBuild}json2scss.scss` }; const result = exec(grunt, config); }); });test/mocha/task/npm.js000066400000000000000000000033561516517553300152400ustar00rootroot00000000000000const should = require('should'); const git = require('../../../src/git'); const exec = require('../../../src/task/npm/npm'); const fs = require('mz/fs'); const process = require('process'); const path = require('path'); describe('src/task/npm/exec', async () => { it('default', async () => { const fileName = path.resolve(`${process.cwd()}/package.json`); let originalData; let originalJson; const gitData = { branch: undefined, date: undefined, commit: undefined, repo: undefined }; try { const result = await Promise.all([ fs.readFile(fileName), git.branch, git.date, git.commit, git.repo ]) originalData = result[0].toString(); originalJson = JSON.parse(originalData); gitData.branch = result[1]; gitData.date = result[2]; gitData.commit = result[3]; gitData.repo = result[4]; const newJson = await exec(fileName); console.log(`new name: ${newJson.name}`); console.log(`old name: ${originalJson.name}`); originalJson.name.should.be.equal(newJson.name); console.log(`new version: ${newJson.version}`); console.log(`old version: ${originalJson.version}`); newJson.version.should.not.equal(originalJson.version); await fs.writeFile(fileName, originalData); const data = await fs.readFile(fileName); originalData.should.be.equal(data.toString()); } catch (error) { await fs.writeFile(fileName, originalData) throw error; } }); });test/mocha/task/replace.js000066400000000000000000000020471516517553300160550ustar00rootroot00000000000000const should = require('should'); const exec = require('../../../src/task/replace/replace'); const fs = require('mz/fs'); const process = require('process'); const path = require('path'); const mkdirp = require('mkdirp'); const grunt = require('grunt'); describe('src/task/replace', () => { it('default', (done) => { const folderTemplates = 'test/data/replace/template/'; const folderBuild = 'build/mocha/replace/'; const configHeader = { header: true, replace: `test`, files: [ `${folderBuild}/**/*.` ] }; const files = fs.readdirSync(folderTemplates); const datas = files.map((file) => { return fs.readFileSync(`${folderTemplates}/${file}`).toString(); }) if (!fs.existsSync(folderBuild)) { mkdirp.sync(folderBuild); } datas.forEach((data, index) => { fs.writeFileSync(`${folderBuild}${files[index]}`, data); }) exec(grunt, configHeader, done); }); });tsconfig.json000066400000000000000000000005031516517553300135760ustar00rootroot00000000000000{ "compilerOptions": { "skipLibCheck": true, "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es2015"], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true } }