.gitignore000066400000000000000000000001241517073045000130450ustar00rootroot00000000000000/build /node_modules /*.log /yarn.lock /*.iws .idea/workspace.xml .idea/tasks.xml .gitmodules000066400000000000000000000021741517073045000132410ustar00rootroot00000000000000[submodule "corifeus-utils"] path=corifeus-utils url=https://github.com/patrikx3/corifeus-utils branch=master [submodule "corifeus-builder"] path=corifeus-builder url=https://github.com/patrikx3/corifeus-builder branch=master [submodule "corifeus-builder-angular"] path=corifeus-builder-angular url=https://github.com/patrikx3/corifeus-builder-angular branch=master [submodule "corifeus-server"] path=corifeus-server url=https://github.com/patrikx3/corifeus-server branch=master [submodule "corifeus-server-deployer"] path=corifeus-server-deployer url=https://github.com/patrikx3/corifeus-server-deployer branch=master [submodule "corifeus-web"] path=corifeus-web url=https://github.com/patrikx3/corifeus-web branch=master [submodule "corifeus-web-material"] path=corifeus-web-material url=https://github.com/patrikx3/corifeus-web-material branch=master [submodule "corifeus-app-web-pages"] path=corifeus-app-web-pages url=https://github.com/patrikx3/corifeus-app-web-pages branch=master [submodule "corifeus-app-server-patrikx3"] path=corifeus-app-server-patrikx3 url=https://github.com/patrikx3/corifeus-app-server-patrikx3 branch=master .idea/000077500000000000000000000000001517073045000120405ustar00rootroot00000000000000.idea/corifeus.iml000066400000000000000000000005201517073045000143570ustar00rootroot00000000000000 .idea/inspectionProfiles/000077500000000000000000000000001517073045000157175ustar00rootroot00000000000000.idea/inspectionProfiles/Project_Default.xml000066400000000000000000000003711517073045000215140ustar00rootroot00000000000000 .idea/modules.xml000066400000000000000000000033111517073045000142300ustar00rootroot00000000000000 .idea/vcs.xml000066400000000000000000000014641517073045000133620ustar00rootroot00000000000000 .npmignore000066400000000000000000000002501517073045000130540ustar00rootroot00000000000000/.idea /artifacts /build /Gemfile /_layouts /_site /_includes /test /node_modules /*.iml /*.ipr /*.iws /.travis.yml /.scrutinizer.yml /Gruntfile.js /corifeus-boot.json .scrutinizer.yml000066400000000000000000000005471517073045000142500ustar00rootroot00000000000000checks: javascript: true filter: excluded_paths: - test/* - node_modules/* - build/* - docs/* build: environment: node: 7.8 dependencies: before: - npm install -g grunt-cli tests: override: - command: 'grunt' coverage: file: 'build/coverage/clover.xml' format: 'clover' .travis.yml000066400000000000000000000001331517073045000131660ustar00rootroot00000000000000language: node_js node_js: - "7" - "node" before_script: - npm install grunt-cli -g Gruntfile.js000066400000000000000000000022451517073045000133600ustar00rootroot00000000000000// ramdisk // ramdisk 2 module.exports = (grunt) => { const _ = require('lodash'); const builder = require(`corifeus-builder`); const loader = new builder.loader(grunt); loader.js(); const lib = require('./src/lib') grunt.registerTask('cory-load-modules', async function() { const done = this.async(); let replace = ''; await lib.init(false); const pkgs = await lib.extractPackages(); const pkgNames = Object.keys(pkgs).sort(); pkgNames.forEach((pkgName) => { const pkg = pkgs[pkgName]; const desc = pkg.description ; replace += `[${desc}](https://github.com/patrikx3/${pkgName}) ` }) const config = grunt.config.get('cory-replace'); config['projects'] = { prefix: '[//]: #@corifeus-projects', postfix: '[//]: #@corifeus-projects:end', replace: replace, files: [ 'README.md', ] } grunt.config.set('cory-replace', config) done(); }); grunt.registerTask('default', ['cory-load-modules'].concat(builder.config.task.build.js)); } LICENSE000066400000000000000000000021401517073045000120620ustar00rootroot00000000000000MIT License Copyright (c) 2017 Patrik Laszlo / patrikx3 / https://patrikx3.tk 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.md000066400000000000000000000102741517073045000123430ustar00rootroot00000000000000[//]: #@corifeus-header [![Build Status](https://travis-ci.org/patrikx3/corifeus.svg?branch=master)](https://travis-ci.org/patrikx3/corifeus) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) --- # Corifeus Matrix ## Issues / Support This is an open source project. Time is a precious thing, so I have no time to give support and fix issues for someone else. I fix a bug, when I have an error that I need. If you got an issue, error or bug, I hope someone will have time to do it for you, otherwise, you are on you own. Though, if I know the solution, I will tell you. If you want to extend, fix bugs and add in new features on your own time, I help you , as ```patrikx3``` is an orgnization. I can add in anyone in no time. Not forking, you become a member, do not even need a pull merge request. ### Node Version Requirement ``` >=7.8.0 ``` ### Built on Node ``` v7.10.0 ``` The ```async``` and ```await``` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Description [//]: #@corifeus-header:end # About ... is a platform for core (auth / REST / CI), CMS, commercial and enterprise resource planning. #### [The name of the platform.](https://en.wikipedia.org/wiki/Coryphaeus) #### [Code style](artifacts/readme/code-style.md) #### [Architecture](artifacts/readme/arthictecture/overview.md) #### [Design Patterns](artifacts/readme/patterns.md) ## Scenarios web, android, ios, cli, rest, cordova, electron ## Code names Matrix, Spectrum, Support, Make, Prototype, Motor, Sailor, Memory, Forest, Amazing, **Bugtron, Reverse, Love, Halite, Micro, PHP, Sunday, Forty, Venture, Laste, Mócsing** ## Agent p3x-robot, p3x-robot-git-mirror ## Colors Brown and green, like the forest and blue like the sky. ## Frameworks, B2B Scrunitizer, Travis, Github, JSDoc, NPM, Docker, MIT License, Grunt, ES.NEXT, TypeScript, WebPack, Bower, ReactiveX ### Mixed Composable / Pluggable / Patterns / Extensibility / De-couple / Loose-based ## Projects [//]: #@corifeus-projects [Corifeus Matrix](https://github.com/patrikx3/corifeus) [Corifeus App Server P3X - Spectrum](https://github.com/patrikx3/corifeus-app-server-patrikx3) [Corifeus App Web Pages - Support](https://github.com/patrikx3/corifeus-app-web-pages) [Corifeus Builder - Make](https://github.com/patrikx3/corifeus-builder) [Corifeus Builder Angular - Prototype](https://github.com/patrikx3/corifeus-builder-angular) [Corifeus Server - Motor](https://github.com/patrikx3/corifeus-server) [Corifeus Server Deployer - Last](https://github.com/patrikx3/corifeus-server-deployer) [Corifeus Utils - Memory](https://github.com/patrikx3/corifeus-utils) [Corifeus Web - Forest](https://github.com/patrikx3/corifeus-web) [Corifeus Web Material - Amazing](https://github.com/patrikx3/corifeus-web-material) [//]: #@corifeus-projects:end # Install Requires minimum NodeJs 7.9.0, GIT and ```npm install -g npm-check-updates``` and ```npm install -g yarn``` ## Windows / Powershell ```powershell iwr https://raw.githubusercontent.com/patrikx3/corifeus/master/scripts/init.ps1 -UseBasicParsing | iex # or, add credit iwr https://git.patrikx3.tk/corifeus.git/raw/master/scripts/init.ps1 -UseBasicParsing | iex ``` ## \*nix / BSD / Bash / Curl ```bash curl -sL https://raw.githubusercontent.com/patrikx3/corifeus/master/scripts/init.sh | bash - # or curl -sL -u patrikx3 https://git.patrikx3.tk/corifeus.git/raw/master/scripts/init.sh | bash - ``` # Inception 2016\. December 25. # Sponsors [IntelliJ](https://www.jetbrains.com/buy/opensource/?product=idea) [//]: #@corifeus-footer --- [**CORIFEUS**](https://pages.corifeus.tk/corifeus) Build v1.0.1255-100 [Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk) [//]: #@corifeus-footer:end artifacts/000077500000000000000000000000001517073045000130405ustar00rootroot00000000000000artifacts/readme/000077500000000000000000000000001517073045000142755ustar00rootroot00000000000000artifacts/readme/arthictecture/000077500000000000000000000000001517073045000171435ustar00rootroot00000000000000artifacts/readme/arthictecture/overview.md000066400000000000000000000064571517073045000213470ustar00rootroot00000000000000[//]: #@corifeus-header [![Build Status](https://travis-ci.org/patrikx3/corifeus.svg?branch=master)](https://travis-ci.org/patrikx3/corifeus) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) --- # Corifeus Matrix ## Issues / Support This is an open source project. Time is a precious thing, so I have no time to give support and fix issues for someone else. I fix a bug, when I have an error that I need. If you got an issue, error or bug, I hope someone will have time to do it for you, otherwise, you are on you own. Though, if I know the solution, I will tell you. If you want to extend, fix bugs and add in new features on your own time, I help you , as ```patrikx3``` is an orgnization. I can add in anyone in no time. Not forking, you become a member, do not even need a pull merge request. ### Node Version Requirement ``` >=7.8.0 ``` ### Built on Node ``` v7.10.0 ``` The ```async``` and ```await``` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Description [//]: #@corifeus-header:end # Architecture ![Corifeus Architecture](https://patrikx3.tk/files/playground/corifeus-architecture/corifeus-p3x-tdd-component.svg) ## Interoperability * Client * Javascript _latest_ * TypeScript _latest_ * Server * NodeJs * JavaScript * Integration * Joomla * Wordpress * Drupal ## Version control systems * Git ## Documentation * JSDoc ## Template * HTML * Angular 2 * PDF * Handlebars ## Style * CSS * SASS * LESS - more users ## Data * MongoDB / Mongoose * XML * REST ## Development * Skeleton * Iterative * Refactored * Driven * Model * Test * Unit / Behavior / Should - find something simpler than Should, I just need simple asserts * Mocha / Karma / Protractor * **Only test the required specifications, don't test everything** ## Continuous integration / build * Grunt * Travis * Scrutinizer * Docker * WebPack ## Schema / Model * Mongoose * Uses multiple models * master * settings * role * user / role / authentication / categories / tags * commercial / product / order / invoice * erp ## Validation * Shared / Same for client and server ## Internationalization * Shared / Same for client and server ## Live [ReactiveX](http://reactivex.io/) [SocketIO](http://socket.io/) ## Deployment * Server * core * commercial * erp * Client * web angular 2 / angular material * core - login/profile * commercial - product/order/invoice * erp - stock/warehouse ## Scenarios * core + api/commercial + angular/commercial + web * core + api/erp + angular/erp + web * core + api/erp + angular/erp + cordova + ios * core + api/erp + angular/erp + cordova + android * server/commercial + CLI * server/erp + CLI * ... etc ... [//]: #@corifeus-footer --- [**CORIFEUS**](https://pages.corifeus.tk/corifeus) Build v1.0.1255-100 [Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk) [//]: #@corifeus-footer:endartifacts/readme/code-style.md000066400000000000000000000101251517073045000166660ustar00rootroot00000000000000[//]: #@corifeus-header [![Build Status](https://travis-ci.org/patrikx3/corifeus.svg?branch=master)](https://travis-ci.org/patrikx3/corifeus) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) --- # Corifeus Matrix ## Issues / Support This is an open source project. Time is a precious thing, so I have no time to give support and fix issues for someone else. I fix a bug, when I have an error that I need. If you got an issue, error or bug, I hope someone will have time to do it for you, otherwise, you are on you own. Though, if I know the solution, I will tell you. If you want to extend, fix bugs and add in new features on your own time, I help you , as ```patrikx3``` is an orgnization. I can add in anyone in no time. Not forking, you become a member, do not even need a pull merge request. ### Node Version Requirement ``` >=7.8.0 ``` ### Built on Node ``` v7.10.0 ``` The ```async``` and ```await``` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Description [//]: #@corifeus-header:end # Code style ```kabeb-case = meaning-only-lower-case-and-a-z-and-dash-and-numbers``` ```PascalCase = JustAlphaAndAlwaysCapitalWords``` ```camelCase = theFirstIsSmallTheRestIsCapital``` ## CSS Prefix ``` kabeb-case ``` **Prefix so that get away form namespace clashes.** ```.cory = corifeus``` ```css .cory-something { font-family: "Corifeus"; } ``` ## HTML Prefix ``` kabeb-case ``` **Prefix so that get away form namespace clashes.** It is both for tags and attributes. ``cory = corifeus`` ```html ``` ## Url ``` kabeb-case ``` ```bash https://localhost/very-long-sentance/is/just/kebab-case.html ``` ## Path ``` kabeb-case ``` ```bash /module-one/love/live/path.js /try/code-style/by/class.js ``` ## Filename ``` kabeb-case ``` ```bash // function camel-case.js // class pascal-case-is-kebab-as-well.js // html file kabeb-case.html // regular file kebab-case.any kabeb-case.js kabeb-case.pdf kabeb-case.html kabeb-case.css ``` ## Namespace ``` camelCase ``` The namespace = ```corifeus``` ```javascript // JavaScript global.corifeus.camelCase = () => console.log('camelCase'); global.corifeus.camelCase = class camelCaseClass {}; ``` ## Variables ``` camelCase ``` ```javascript // JavaScript const variableIsCool = 'camelCase'; let anotherVariable = false; var oldTypeVariable = 'cool'; ``` ## Functions ``` camelCase ``` ```javascript // JavaScript function justSimpleFunction() { console.log('alsoCamelCase') } ``` ## Prototype based class ``` camelCase ``` ```javascript // JavaScript function prototypeBasedClass() { console.log('likeAClassIsCamelCase'); } prototypeBasedClass.staticFunction = function() {} prototypeBasedClass.staticVariable = true; prototypeBasedClass.prototype.instanceFunction = function() {} prototypeBasedClass.prototype.instanceVariable = true; ``` ## Classes ``` camelCase ``` ```javascript // JavaScript class simpleClass { constructor() {} instanceFunctionCamelCase() {} get instanceProperty() { return true; } set instanceProperty(value) { this._instanceProperty = value; } static classMethod() { console.log('PascalCase'); } static get classProperty() { return 'PascalCase'; } } ``` ## Objects ``` camelCase ``` ```javascript // JavaScript const objects = { variableNow: camelCase, methodName: camelCase, NameOfTheClass: PascalCase, staticFuncitonName: camelCase.static, instance: camelCase.variable } ``` [//]: #@corifeus-footer --- [**CORIFEUS**](https://pages.corifeus.tk/corifeus) Build v1.0.1255-100 [Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk) [//]: #@corifeus-footer:endartifacts/readme/patterns.md000066400000000000000000000045671517073045000164730ustar00rootroot00000000000000[//]: #@corifeus-header [![Build Status](https://travis-ci.org/patrikx3/corifeus.svg?branch=master)](https://travis-ci.org/patrikx3/corifeus) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/patrikx3/corifeus/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/patrikx3/corifeus/?branch=master) --- # Corifeus Matrix ## Issues / Support This is an open source project. Time is a precious thing, so I have no time to give support and fix issues for someone else. I fix a bug, when I have an error that I need. If you got an issue, error or bug, I hope someone will have time to do it for you, otherwise, you are on you own. Though, if I know the solution, I will tell you. If you want to extend, fix bugs and add in new features on your own time, I help you , as ```patrikx3``` is an orgnization. I can add in anyone in no time. Not forking, you become a member, do not even need a pull merge request. ### Node Version Requirement ``` >=7.8.0 ``` ### Built on Node ``` v7.10.0 ``` The ```async``` and ```await``` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Description [//]: #@corifeus-header:end # Patterns * core - implemented in server / client * schema * validation * types * relations by schema * json schema * data * query * paginate / page * limit / max * sort * count * search / find * delete * disable * id * all * last * first * auth * login * logout * live / socket.io / reactivex / observable * model * entity * created * modified * version * disabled * deleted * validation * user * role * category / tag * client * notification / growl / smack - multiple! * angular * virtual list / like facebook list with live update * live / socket.io * form * validation * grid / list / thumbnail * pagination * query / search * sort [//]: #@corifeus-footer --- [**CORIFEUS**](https://pages.corifeus.tk/corifeus) Build v1.0.1255-100 [Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk) [//]: #@corifeus-footer:endcorifeus-app-server-patrikx3/000077500000000000000000000000001517073045000165245ustar00rootroot00000000000000corifeus-app-web-pages/000077500000000000000000000000001517073045000153255ustar00rootroot00000000000000corifeus-builder/000077500000000000000000000000001517073045000143235ustar00rootroot00000000000000corifeus-builder-angular/000077500000000000000000000000001517073045000157525ustar00rootroot00000000000000corifeus-server/000077500000000000000000000000001517073045000142035ustar00rootroot00000000000000corifeus-server-deployer/000077500000000000000000000000001517073045000160245ustar00rootroot00000000000000corifeus-utils/000077500000000000000000000000001517073045000140355ustar00rootroot00000000000000corifeus-web/000077500000000000000000000000001517073045000134525ustar00rootroot00000000000000corifeus-web-material/000077500000000000000000000000001517073045000152465ustar00rootroot00000000000000corifeus.iml000066400000000000000000000005171517073045000134050ustar00rootroot00000000000000 package.json000066400000000000000000000033141517073045000133470ustar00rootroot00000000000000{ "name": "corifeus", "version": "1.0.1258-100", "corifeus": { "icon": "fa fa-superpowers", "inception": "12/25/2016", "code": "Matrix", "cdn": true, "menu": [ { "name": "menu-corifeus-code-style", "link": "artifacts/readme/code-style.html" }, { "name": "menu-corifeus-architecture", "link": "artifacts/readme/arthictecture/overview.html" }, { "name": "menu-corifeus-patterns", "link": "artifacts/readme/patterns.html" }, { "name": "menu-corifeus-more-origin", "link": "https://en.wikipedia.org/wiki/Coryphaeus" } ] }, "description": "Corifeus Matrix", "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" }, "repository": { "type": "git", "url": "git+https://github.com/patrikx3/corifeus.git" }, "keywords": [ "corifeus", "one", "platform" ], "author": "Patrik Laszlo ", "license": "MIT", "bugs": { "url": "https://github.com/patrikx3/corifeus/issues" }, "homepage": "https://pages.corifeus.tk/corifeus", "devDependencies": { "corifeus-builder": "^1.7.605-49" }, "dependencies": { "commander": "^2.9.0", "corifeus-utils": "^1.1.269-54", "progress": "^2.0.0" }, "engines": { "node": ">=7.8.0" } }scripts/000077500000000000000000000000001517073045000125475ustar00rootroot00000000000000scripts/init.ps1000066400000000000000000000003731517073045000141420ustar00rootroot00000000000000 git clone https://github.com/patrikx3/corifeus pushd corifeus git checkout master git submodule update --init --recursive --remote git submodule foreach --recursive git checkout master #yarn install #&git submodule foreach --recursive yarn install scripts/init.sh000077500000000000000000000004161517073045000140520ustar00rootroot00000000000000#!/usr/bin/env bash git clone https://github.com/patrikx3/corifeus.git pushd corifeus git checkout master git submodule update --init --recursive --remote git submodule foreach --recursive git checkout master yarn install git submodule foreach --recursive yarn install scripts/link.js000077500000000000000000000002501517073045000140420ustar00rootroot00000000000000#!/usr/bin/env node const lib = require('../src/lib'); const start = async() => { await lib.init(); await lib.link(); console.log('DONE :)') } start();scripts/publish.js000077500000000000000000000002521517073045000145550ustar00rootroot00000000000000#!/usr/bin/env node const lib = require('../src/lib'); const start = async() => { await lib.init(); await lib.publish() console.log('DONE :)') } start();src/000077500000000000000000000000001517073045000116475ustar00rootroot00000000000000src/index.js000066400000000000000000000000431517073045000133110ustar00rootroot00000000000000module.exports = console.log('CI');src/lib.js000066400000000000000000000220121517073045000127500ustar00rootroot00000000000000 const progress = require('progress'); const fs = require('mz/fs'); const path = require('path') const commander = require('commander'); const utils = require('corifeus-utils'); const execRaw = require('child_process').exec; const pkg = require('../package.json'); /** * Load all modules in this project */ let loadModules = () => { const srcpath = `${process.cwd()}` const modules = fs.readdirSync(srcpath).filter(file => fs.statSync(path.join(srcpath, file)).isDirectory()).filter(dir => dir.startsWith('corifeus-')); modules.unshift('corifeus'); /* let modules = childProcess.execSync('git submodule--helper list').toString().split('\n').map((line) => { return line.split('\t')[1]; }) modules = modules.splice(0, modules.length -1 ); modules.unshift('corifeus'); */ return modules; } const allProjects = loadModules() let projects; const projectPath = (project) => { return `${__dirname}/../${project === 'corifeus' ? '' : project + '/' }`; } const getPkg = async (project) => { const buffer = await fs.readFile(`${projectPath(project)}package.json`); return JSON.parse(buffer.toString()); } const extractPackages = async function (projects = allProjects) { const pkgs = {}; await utils.array.forEachAsync(projects, async (project) => { pkgs[project] = await getPkg(project) }, true) return pkgs; }; let pkgs; // order is important const settings = { 'corifeus-utils': { publish: true, }, 'corifeus-builder': { publish: true, }, 'corifeus-server': { publish: true, }, 'corifeus-server-deployer': { publish: true, }, 'corifeus-builder-angular': { publish: true, }, 'corifeus-web': { publish: true, }, 'corifeus-web-material': { publish: true, }, } const loadPublishableChildren = () => { Object.keys(settings).forEach((publishable) => { const setting = settings[publishable]; const children = {}; Object.keys(pkgs).forEach((pkgName) => { const pkg = pkgs[pkgName]; const updateDependecies = (repo) => { if (pkg.hasOwnProperty(repo) && pkg[repo].hasOwnProperty(publishable)) { if (Object.keys(pkg[repo]).includes(publishable)) { children[pkgName] = true; } } } updateDependecies('dependencies', publishable); updateDependecies('devDependencies', publishable); setting.children = Object.keys(children); }) }) } const init = async (commanderEnabled = true) => { pkgs = await extractPackages() if (commanderEnabled) { commander .version(pkg.version) .usage('[options]') .option('-v, --verbose', 'Verbose') .option('-n, --npm', 'Npm to original registry') .option('-p, --projects ', 'The list of projects', (val) => { return val.split(','); }) .parse(process.argv); } projects = commander.projects || allProjects loadPublishableChildren(); module.exports.projects = projects } const exec = (project, command, bar) => { return new Promise((resolve, reject) => { const actualCommand = `${project === 'corifeus' ? '' : `pushd ${project}`} ${command} ${project === 'corifeus' ? '' : `popd`} ` if (bar) { bar.interrupt(actualCommand); } else { console.log(actualCommand); } const run = execRaw(`bash -c ' set -e ${actualCommand} '`, { stdio: `inherit`, }, (e) => { if (e) { console.error(e); return reject(e); } if (bar) { bar.tick({ token: `${project}` }) } return resolve(); }) run.stdout.on('data', (data) => { if (commander.verbose && bar) { bar.interrupt(data) } if (!bar) { console.log(data); } }); run.stderr.on('data', (data) => { if (bar) { bar.interrupt(data) } else { console.error(data); } }); }) } const newProgress = (status, total = projects.length) => { const bar = new progress(`${status} [:bar] :token`, { total: total, width: 27, clear: true }) bar.tick(0, { token: `${projects[0]}` }) return bar; } const grunt = async () => { let port = 10000; const promises = []; const barGrunt = newProgress('grunt'); await utils.array.forEachAsync(projects, (project) => { promises.push(exec(project, `grunt --cory-port=${++port}`, barGrunt)); }) await Promise.all(promises); } /** * Order is important * @returns {Promise.} */ const publish = async () => { let total = projects.length; const upgradeAbleCount = await getUpgradeAbleCount(); total = total + (total * upgradeAbleCount); const barPublish = newProgress('publish-upgrade', total); await utils.array.forEachAsync(projects, async (project) => { const setting = settings[project]; if (setting !== undefined && setting.hasOwnProperty('publish') ) { await exec(project, `${commander.npm ? '' : 'grunt cory-npm'} npm publish ${commander.npm ? ' --registry https://registry.npmjs.org' : ''}`, barPublish); await upgrade(barPublish) } else { barPublish.tick({ token: '...' }) } }, true) } const getUpgradable = async () => { const upgradeAble = {}; await utils.array.forEachAsync(projects, (project) => { const setting = settings[project]; if (setting !== undefined && setting.hasOwnProperty('publish') && setting.hasOwnProperty('children')) { setting.children.forEach((child) => { upgradeAble[child] = upgradeAble[child] || []; upgradeAble[child].push(project) }) } }) return upgradeAble; } const getUpgradeAbleCount = async() => { const upgradeAble = await getUpgradable(); const upgrades = Object.keys(upgradeAble); let total = upgrades.length; upgrades.forEach(() => total++); return total; } const upgrade = async (progresser) => { const upgradeAble = await getUpgradable(); const upgrades = Object.keys(upgradeAble); if (progresser === undefined) { const total = await getUpgradeAbleCount(); progresser = progresser || newProgress('upgrade', total); } const promises = []; await utils.array.forEachAsync(upgrades, async (project) => { progresser.tick({ token: project }) const pkgFile = `${projectPath(project)}package.json`; const pkg = await getPkg(project); await utils.array.forEachAsync(upgradeAble[project], async(linkUpdate) => { const updateDependecies = async (repo) => { if (pkg.hasOwnProperty(repo) && pkg[repo].hasOwnProperty(linkUpdate)) { const linkPkg = await getPkg(linkUpdate); pkg[repo][linkUpdate] = `^${linkPkg.version}`; } } await updateDependecies('dependencies', linkUpdate); await updateDependecies('devDependencies', linkUpdate); promises.push(fs.writeFile(pkgFile, JSON.stringify(pkg, null, 4))); progresser.interrupt(`${project} => new pkg ${linkUpdate}`); progresser.tick({ token: linkUpdate }) }) }) await Promise.all(promises); } const link = async() => { const upgradeAble = await getUpgradable(); const upgradeAbleKeys = Object.keys(upgradeAble); const projectsGenerated = projects.filter((project) => (settings[project] || {}).hasOwnProperty('children') ); let total = projectsGenerated.length + upgradeAbleKeys.length; const progress = newProgress('link', total); let promises = []; await utils.array.forEachAsync(projectsGenerated, (project) => { const setting = settings[project] || {}; if (setting.hasOwnProperty('publish') && setting.hasOwnProperty('children')) { promises.push( exec(project, `yarn unlink || true yarn link`, progress) ) } }) await Promise.all(promises); promises = []; await utils.array.forEachAsync(upgradeAbleKeys , (project) => { let command = `` upgradeAble[project].forEach((link) => { command += `yarn link ${link} `; }) promises.push(exec(project, command, progress)) }) await Promise.all(promises); } module.exports = { projects: projects, settings: settings, exec: exec, projectPath: projectPath, newProgress: newProgress, grunt: grunt, publish: publish, upgrade: upgrade, link: link, extractPackages: extractPackages, loadModules: loadModules, init: init }test/000077500000000000000000000000001517073045000120375ustar00rootroot00000000000000test/load-modules.js000077500000000000000000000001311517073045000147600ustar00rootroot00000000000000#!/usr/bin/env node const lib = require('../src/lib'); console.log(lib.loadModules());