.github/000077500000000000000000000000001516653250100124225ustar00rootroot00000000000000.github/workflows/000077500000000000000000000000001516653250100144575ustar00rootroot00000000000000.github/workflows/build.yml000066400000000000000000000016761516653250100163130ustar00rootroot00000000000000# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: build on: schedule: - cron: '0 0 1 * *' push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: ['lts/*'] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm i -g grunt-cli - run: npm install - run: grunt .gitignore000066400000000000000000000003371516653250100130550ustar00rootroot00000000000000/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 .ncurc.json000066400000000000000000000000511516653250100131410ustar00rootroot00000000000000{ "reject": [ "glob" ] } .npmignore000066400000000000000000000002631516653250100130620ustar00rootroot00000000000000/.idea /artifacts /build /test /node_modules /*.iml /*.ipr /*.iws /.travis.yml /.scrutinizer.yml /Gruntfile.js /*.lock *.log /corifeus-boot.json /.github /secure /.github /.vscodeGruntfile.js000066400000000000000000000036351516653250100133660ustar00rootroot00000000000000module.exports = (grunt) => { const builder = require('./src'); const fs = require('fs'); const mz = require('mz'); const loader = new builder.loader(grunt); loader.js({}); 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 \`\`\`js `; 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'); }LICENSE000066400000000000000000000020131516653250100120630ustar00rootroot00000000000000MIT License 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.md000066400000000000000000000114061516653250100123430ustar00rootroot00000000000000[//]: #@corifeus-header [![NPM](https://img.shields.io/npm/v/corifeus-builder.svg)](https://www.npmjs.com/package/corifeus-builder) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://paypal.me/patrikx3) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Corifeus @ Facebook](https://img.shields.io/badge/Facebook-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m780749701-41bcade28c1ea8154eda7cca.svg)](https://stats.uptimerobot.com/9ggnzcWrw) --- # πŸ—οΈ Corifeus Builder v2024.4.132 **Bugs are evidentβ„’ - MATRIX️** ### NodeJS LTS is supported ### Built on NodeJs version ```txt v20.12.0 ``` # 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 } } ``` ### ECMA versions `src/utils/config.js` ## 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-npm" task Running "clean:cory-build" (clean) task >> 1 path cleaned. 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 --- πŸ™ This is an open-source project. Star this repository, if you like it, or even donate to maintain the servers and the development. Thank you so much! Possible, this server, rarely, is down, please, hang on for 15-30 minutes and the server will be back up. All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://corifeus.com)) could have minor errors, since I am developing in my free time. However, it is usually stable. **Note about versioning:** Versions are cut in Major.Minor.Patch schema. Major is always the current year. Minor is either 4 (January - June) or 10 (July - December). Patch is incremental by every build. If there is a breaking change, it should be noted in the readme. --- [**CORIFEUS-BUILDER**](https://corifeus.com/corifeus-builder) Build v2024.4.132 [![NPM](https://img.shields.io/npm/v/corifeus-builder.svg)](https://www.npmjs.com/package/corifeus-builder) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [//]: #@corifeus-footer:end artifacts/000077500000000000000000000000001516653250100130425ustar00rootroot00000000000000artifacts/readme/000077500000000000000000000000001516653250100142775ustar00rootroot00000000000000artifacts/readme/builds/000077500000000000000000000000001516653250100155615ustar00rootroot00000000000000artifacts/readme/builds/folders.md000066400000000000000000000031351516653250100175430ustar00rootroot00000000000000[//]: #@corifeus-header # πŸ—οΈ Corifeus Builder [//]: #@corifeus-header:end # Folders Skeleton folders ```js bin/ build/ build/browser/ build/node/ src/ test/ ``` [//]: #@corifeus-footer --- πŸ™ This is an open-source project. Star this repository, if you like it, or even donate to maintain the servers and the development. Thank you so much! Possible, this server, rarely, is down, please, hang on for 15-30 minutes and the server will be back up. All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://corifeus.com)) could have minor errors, since I am developing in my free time. However, it is usually stable. **Note about versioning:** Versions are cut in Major.Minor.Patch schema. Major is always the current year. Minor is either 4 (January - June) or 10 (July - December). Patch is incremental by every build. If there is a breaking change, it should be noted in the readme. --- [**CORIFEUS-BUILDER**](https://corifeus.com/corifeus-builder) Build v2024.4.132 [![NPM](https://img.shields.io/npm/v/corifeus-builder.svg)](https://www.npmjs.com/package/corifeus-builder) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [//]: #@corifeus-footer:endartifacts/readme/builds/tasks.md000066400000000000000000000035151516653250100172340ustar00rootroot00000000000000[//]: #@corifeus-header # πŸ—οΈ Corifeus Builder [//]: #@corifeus-header:end # Tasks Skeleton tasks ```js clean:cory-build copy:cory-build copy:cory-run cory-angular-hook-lib cory-generate-tasks cory-inject cory-json2scss cory-noop cory-npm cory-raw-npm-angular cory-replace cory-replace:footer cory-replace:footerMain cory-replace:header cory-replace:headerMain cory:kill cory:license cory:upgrade ``` [//]: #@corifeus-footer --- πŸ™ This is an open-source project. Star this repository, if you like it, or even donate to maintain the servers and the development. Thank you so much! Possible, this server, rarely, is down, please, hang on for 15-30 minutes and the server will be back up. All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://corifeus.com)) could have minor errors, since I am developing in my free time. However, it is usually stable. **Note about versioning:** Versions are cut in Major.Minor.Patch schema. Major is always the current year. Minor is either 4 (January - June) or 10 (July - December). Patch is incremental by every build. If there is a breaking change, it should be noted in the readme. --- [**CORIFEUS-BUILDER**](https://corifeus.com/corifeus-builder) Build v2024.4.132 [![NPM](https://img.shields.io/npm/v/corifeus-builder.svg)](https://www.npmjs.com/package/corifeus-builder) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [//]: #@corifeus-footer:endindex.js000066400000000000000000000000421516653250100125230ustar00rootroot00000000000000module.exports = require('./src');package.json000066400000000000000000000033621516653250100133540ustar00rootroot00000000000000{ "name": "corifeus-builder", "version": "2024.4.132", "corifeus": { "icon": "fas fa-gavel", "code": "Make", "publish": true, "nodejs": "v20.12.0", "reponame": "corifeus-builder", "opencollective": false, "build": true }, "description": "πŸ—οΈ Corifeus Builder", "main": "src/index.js", "directories": { "test": "test" }, "scripts": { "test": "grunt && mocha ./test/mocha/*.js ./test/mocha/task/*.js" }, "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://corifeus.com/corifeus-builder", "dependencies": { "corifeus-utils": "^2024.4.118", "download": "^8.0.0", "extract-zip": "^2.0.1", "fs-extra": "^11.2.0", "github-api": "^3.4.0", "glob": "^8.0.3", "glob-promise": "^6.0.5", "grunt": "^1.6.1", "grunt-contrib-clean": "^2.0.1", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-htmlmin": "^3.1.0", "grunt-contrib-watch": "^1.1.0", "jit-grunt": "^0.10.0", "lodash": "^4.17.21", "mkdirp": "^3.0.1", "mocha": "^10.4.0", "mz": "^2.7.0", "npm": "^10.5.0", "npm-check-updates": "^16.14.18", "should": "^13.2.3", "time-grunt": "^2.0.0", "yaml": "^2.4.1" }, "devDependencies": { "twemoji": "^14.0.2" }, "engines": { "node": ">=12.13.0" } }src/000077500000000000000000000000001516653250100116515ustar00rootroot00000000000000src/config/000077500000000000000000000000001516653250100131165ustar00rootroot00000000000000src/config/folder/000077500000000000000000000000001516653250100143715ustar00rootroot00000000000000src/config/folder/index.js000066400000000000000000000015661516653250100160460ustar00rootroot00000000000000const folderBuild = 'build/'; const folderBuildBrowser = folderBuild + 'browser/'; const folderBuildNode = folderBuild + 'node/'; const folderBin = 'bin/'; const folderSrc = 'src/'; const folderTest = 'test/'; const folderFilesAll = [ 'Gruntfile.js', 'src/**/*.*', 'test/**/*.*', ]; const folderFilesDoc = folderFilesAll; /** * @module Grunt * @namespace Grunt/grunt/folder */ module.exports = { src: { root: folderSrc }, bin: { root: folderBin }, files: { all: folderFilesAll, doc: folderFilesDoc }, build: { root: folderBuild, /* jsdoc: { root: folderBuildJsdoc }, */ node: { root: folderBuildNode }, browser: { root: folderBuildBrowser } }, test: { root: folderTest, } }; src/config/grunt/000077500000000000000000000000001516653250100142555ustar00rootroot00000000000000src/config/grunt/index.js000066400000000000000000000000441516653250100157200ustar00rootroot00000000000000module.exports.js = require('./js');src/config/grunt/js/000077500000000000000000000000001516653250100146715ustar00rootroot00000000000000src/config/grunt/js/index.js000066400000000000000000000010301516653250100163300ustar00rootroot00000000000000const 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 } }, */ clean: { 'cory-build': [ folder.build.root ] }, } return result; }; src/config/index.js000066400000000000000000000004711516653250100145650ustar00rootroot00000000000000const 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/000077500000000000000000000000001516653250100140605ustar00rootroot00000000000000src/config/task/index.js000066400000000000000000000013141516653250100155240ustar00rootroot00000000000000const fs = require('fs'); const folder = require('../folder'); const taskBuildEmpty = [ 'cory-npm', 'clean', 'cory-replace', 'cory:license', ] const taskBuild = [ 'cory-npm', 'clean', /*, 'jsdoc'*/ 'cory-replace', 'cory:license', ]; const taskTest = [ ]; const runAll = taskBuild.slice(); runAll.push('watch:cory-js-all'); const runTest = taskTest.slice(); module.exports = { build: { js: taskBuild, empty: taskBuildEmpty, }, run: { js: runAll, jsTest: [], // jsDoc: ['jsdoc', 'watch:cory-doc'] }, watch: { jsAll: taskBuild, jsTest: taskTest, }, test: { jsTest: taskTest, } }; src/git.js000066400000000000000000000014721516653250100127760ustar00rootroot00000000000000const 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.js000066400000000000000000000002561516653250100133210ustar00rootroot00000000000000require('corifeus-utils'); module.exports = { config: require('./config'), loader: require('./loader'), task: require('./task'), utils: require('./utils') } src/loader.js000066400000000000000000000060351516653250100134610ustar00rootroot00000000000000const task = require('./task/index'); const folder = require('./config/folder/index'); const _ = require('lodash'); const utils = require('corifeus-utils'); const fs = require('fs'); const path = require('path') const fsPromise = require('fs').promises class loader { constructor(grunt) { this.grunt = grunt this.configJit = { // jshint: 'grunt-contrib-jshint', 'htmlmin': 'grunt-contrib-htmlmin', clean: 'grunt-contrib-clean', watch: 'grunt-contrib-watch', // jsdoc: 'grunt-contrib-jsdoc', }; } load(options) { let pkg = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`, 'utf8')); pkg.corifeus = pkg.corifeus || {}; let originalPkg = JSON.stringify(pkg) 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) { options.replacer = { type: 'p3x', } } require('./replaces')(options, pkg); grunt.config.merge(config); Object.keys(task).forEach((taskItem) => task[taskItem](grunt)) grunt.registerTask('cory:kill', function () { process.exit(1); }); grunt.registerTask('cory:upgrade', function () { const upgrade = require('./utils/upgrade') upgrade({ grunt: grunt, gruntThis: this, defaultOptions: options, }); }) grunt.registerTask('cory:license', function () { const license = require('./utils').license() fs.writeFileSync(`${process.cwd()}/LICENSE`, license) }) grunt.registerTask('cory-angular-hook-lib', async function () { const done = this.async(); try { const rootPkgName = require(`${process.cwd()}/package.json`) const pkgName = path.resolve(`./projects/${rootPkgName.corifeus.reponame}/package.json`) let pkg = require(pkgName) pkg.name = rootPkgName.name pkg.corifeus = { install: false } const data = JSON.stringify(pkg, null, 4) await fsPromise.writeFile(pkgName, data) done() } catch (e) { done(e) } }); // should be at the end require('jit-grunt')(grunt, options.jit); require('time-grunt')(grunt); if (originalPkg !== JSON.stringify(pkg)) { fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(pkg, null, 4)) } } js(options) { options = options || {}; this.load(options); } empty(options) { options = options || {}; options.empty = true; this.load(options); } } module.exports = loader; src/replaces.js000066400000000000000000000312461516653250100140130ustar00rootroot00000000000000const fs = require('fs'); const _ = require('lodash'); module.exports = (options, pkg) => { 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; } let commonBuild = `[![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://paypal.me/patrikx3) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Corifeus @ Facebook](https://img.shields.io/badge/Facebook-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) ` if (pkg.corifeus && pkg.corifeus.publish === true) { // ![https://www.npmjs.com/package/${pkg.name}](https://img.shields.io/npm/v/${pkg.name}.svg) commonBuild = `[![NPM](https://img.shields.io/npm/v/${pkg.name}.svg)](https://www.npmjs.com/package/${pkg.name}) ` + commonBuild } let opencollectiveHeader = '' let opencollectiveFooter = '' pkg.corifeus.opencollective = false; if (options.replacer.hasOwnProperty('opencollective') && options.replacer.opencollective === true) { pkg.corifeus.opencollective = true; pkg.collective = { type: "opencollective", url: `https://opencollective.com/${pkg.name}` } opencollectiveHeader = ` [![Backers on Open Collective](https://opencollective.com/\${pkg.name}/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/\${pkg.name}/sponsors/badge.svg)](#sponsors)` opencollectiveFooter = ` # Open collective ## Contributors This project exists thanks to all the people who contribute. ## Backers Thank you to all our backers! πŸ™ [Become a backer](https://opencollective.com/\${pkg.name}#backer) ## Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. πŸ™ [Become a sponsor](https://opencollective.com/\${pkg.name}#sponsor) ` } 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 } let defaultFooterNpm = `` if (pkg.corifeus && pkg.corifeus.publish === true) { // ![https://www.npmjs.com/package/${pkg.name}](https://img.shields.io/npm/v/${pkg.name}.svg) defaultFooterNpm = `[![NPM](https://img.shields.io/npm/v/${pkg.name}.svg)](https://www.npmjs.com/package/${pkg.name}) ` } const defaultFooter = { footer: true, replace: ` --- πŸ™ This is an open-source project. Star this repository, if you like it, or even donate to maintain the servers and the development. Thank you so much! Possible, this server, rarely, is down, please, hang on for 15-30 minutes and the server will be back up. All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://corifeus.com)) could have minor errors, since I am developing in my free time. However, it is usually stable. **Note about versioning:** Versions are cut in Major.Minor.Patch schema. Major is always the current year. Minor is either 4 (January - June) or 10 (July - December). Patch is incremental by every build. If there is a breaking change, it should be noted in the readme. --- [**\${pkg.name.toUpperCase()}**](https://corifeus.com/\${git.repo === 'corifeus' ? 'matrix' : git.repo}) Build v\${pkg.version} ${defaultFooterNpm}[![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) ${opencollectiveFooter} `, files: replaceFiles }; let angularVersion = ''; let nodeJsInfo = ` ### NodeJS LTS is supported ### Built on NodeJs version \`\`\`txt ${process.version} \`\`\` `; if (options.replacer.hasOwnProperty('nodejsinfo') && options.replacer.nodejsinfo === false) { nodeJsInfo = ''; } const angularPkgPath = `${process.cwd()}/node_modules/@angular/core/package.json`; if (fs.existsSync(angularPkgPath)) { const angularPkg = JSON.parse(fs.readFileSync(angularPkgPath).toString()); angularVersion = ` # Built on Angular \`\`\`text ${angularPkg.version} \`\`\` ` } const hideNodeVersion = options.hasOwnProperty('replacer') && options.replacer.node === false; let hideBuild = options.hasOwnProperty('replacer') && options.replacer.build === false; pkg.corifeus.build = !hideBuild; // let build = hideBuild ? '' : `[![Build Status](https://travis-ci.com/patrikx3/\${git.repo}.svg?branch=master)](https://travis-ci.com/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 build = commonBuild // https://api.travis-ci.com/patrikx3/redis-ui-material.svg?branch=master /* build += hideBuild ? '' : `[![Build Status](https://api.travis-ci.com/patrikx3/\${git.repo}.svg?branch=master)](https://travis-ci.com/patrikx3/\${git.repo}) [![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m780749701-41bcade28c1ea8154eda7cca.svg)](https://stats.uptimerobot.com/9ggnzcWrw) ` */ // https://github.com/patrikx3/onenote/workflows/build/badge.svg build += hideBuild ? '' : `[![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m780749701-41bcade28c1ea8154eda7cca.svg)](https://stats.uptimerobot.com/9ggnzcWrw) ` build += opencollectiveHeader // below is to add additional status const domainInfo = ` **Bugs are evidentβ„’ - MATRIX️** ` let nodeVersion = hideNodeVersion ? `# \${pkg.description} v\${pkg.version} ${domainInfo} # Description ` : `# \${pkg.description} v\${pkg.version} ${domainInfo} ${nodeJsInfo} ${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} ${build.trim() === '' ? '' : '---'} ${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': case 'openwrt': let nonEmptyBuild = ''; if (!options.empty) { /* nonEmptyBuild = `[![Build Status](https://travis-ci.com/patrikx3/\${git.repo}.svg?branch=master)](https://travis-ci.com/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} ` */ nonEmptyBuild = `[![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m780749701-41bcade28c1ea8154eda7cca.svg)](https://stats.uptimerobot.com/9ggnzcWrw) # \${pkg.description} ` } if (replacer === 'openwrt') { nonEmptyBuild += ` ` } options.config['cory-replace'] = { headerMain: { header: true, /* [![Trello](https://img.shields.io/badge/Trello-p3x-026aa7.svg)](https://trello.com/b/gqKHzZGy/p3x) */ replace: ` ${commonBuild} ${nonEmptyBuild} `, 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-dl/\${pkg.name}.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/\${pkg.name}/) ` + append } */ } src/task/000077500000000000000000000000001516653250100126135ustar00rootroot00000000000000src/task/generate-tasks.js000066400000000000000000000015521516653250100160710ustar00rootroot00000000000000const 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 \`\`\`js ${tasks.sort().join(` `)} \`\`\` `; fs.writeFileSync(`artifacts/readme/builds/tasks.md`, template); }) } src/task/index.js000066400000000000000000000004521516653250100142610ustar00rootroot00000000000000module.exports = { "npm": require('./npm'), "noop": require('./noop'), "replace": require('./replace'), "json2scss": require('./json2scss'), "generate-tasks": require('./generate-tasks'), "raw-npm-angular": require('./raw-npm-angular'), "inject": require('./inject'), } src/task/inject/000077500000000000000000000000001516653250100140675ustar00rootroot00000000000000src/task/inject/index.js000066400000000000000000000010731516653250100155350ustar00rootroot00000000000000const 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 { const done = this.async() try { Object.keys(config).forEach((item) => { exec(grunt, config[item]); }); done() } catch(e) { done(e) } } }) } src/task/inject/inject.js000066400000000000000000000030521516653250100157010ustar00rootroot00000000000000const 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); if (done) { done() } }; src/task/json2scss/000077500000000000000000000000001516653250100145425ustar00rootroot00000000000000src/task/json2scss/index.js000066400000000000000000000006321516653250100162100ustar00rootroot00000000000000const 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.js000066400000000000000000000033711516653250100170330ustar00rootroot00000000000000const 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.js000066400000000000000000000002211516653250100141170ustar00rootroot00000000000000module.exports = (grunt) => { grunt.registerTask('cory-noop', () => { grunt.log.write('Corifeus Builder Noop - just empty') }) } src/task/npm/000077500000000000000000000000001516653250100134055ustar00rootroot00000000000000src/task/npm/index.js000066400000000000000000000005271516653250100150560ustar00rootroot00000000000000const 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.js000066400000000000000000000046771516653250100145530ustar00rootroot00000000000000const fs = require('fs').promises; 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 date = new Date(); version[0] = date.getFullYear() const previousVersionYear = parseInt(version[0]) const previousVersionDate = parseInt(version[1]) const currentMonth = date.getMonth() + 1 if (currentMonth <= 6) { version[1] = 4 } else { version[1] = 10 } 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)) ? '100' : element; }) //console.log('previousVersionDate', previousVersionDate, 'version[1]', version[1]) if (previousVersionDate === parseInt(version[1]) && previousVersionYear === parseInt(version[0])) { version[2] = parseInt(version[2]) + 1 } else { version[2] = 100 } if (parseInt(version[2]) < 100) { version[2] = 100 } /* const subVersion = version[2].split('-'); subVersion[0] = date.getDate() if (subVersion[1] === undefined) { subVersion[1] = 0; } subVersion[1] = parseInt(subVersion[1]) + 1; const originalVersion = pkg.version.split('.') const originalSubVersion = version[2].split('-'); if (`${originalVersion[0]}.${originalVersion[1]}.${originalSubVersion[0]}` !== `${version[0]}.${version[1]}.${subVersion[0]}`) { subVersion[1] = 0 } version[2] = subVersion.join('-'); */ pkg.version = version.join('.'); if (!pkg.hasOwnProperty('corifeus')) { pkg.corifeus = {}; } const prefix = pkg.corifeus.prefix || ''; const postfix = pkg.corifeus.postfix || ''; pkg.name = `${prefix}${repo}${postfix}`; // pkg.engines = { "node" : `>=${process.versions.node}` }; pkg.engines = {"node": `>=12.13.0`}; pkg.homepage = `https://corifeus.com/${repo === 'corifeus' ? 'matrix' : repo }`; pkg.corifeus.nodejs = process.version pkg.corifeus.reponame = repo; const newPkgFile = JSON.stringify(pkg, null, 4); await fs.writeFile(pkgFile, newPkgFile) return pkg; } src/task/raw-npm-angular.js000066400000000000000000000011641516653250100161630ustar00rootroot00000000000000const fs = require('fs').promises; module.exports = (grunt) => { grunt.registerTask('cory-raw-npm-angular', async function () { const done = this.async(); try { const angularPkg = require(process.cwd() + '/node_modules/@angular/core/package.json'); const pkgFile = process.cwd() + '/package.json'; const pkg = JSON.parse((await fs.readFile(pkgFile)).toString()); pkg.corifeus.angular = angularPkg.version await fs.writeFile(pkgFile, JSON.stringify(pkg, null, 4)) done(); } catch (e) { done(e) } }); } src/task/replace/000077500000000000000000000000001516653250100142265ustar00rootroot00000000000000src/task/replace/index.js000066400000000000000000000011111516653250100156650ustar00rootroot00000000000000const exec = require('./replace'); module.exports = (grunt) => { grunt.registerTask('cory-replace', async function (target) { const config = grunt.config.get('cory-replace'); if (target !== undefined) { exec(grunt, config[target], this.async()); } else { const done = this.async() try { for(let item of Object.keys(config)) { await exec(grunt, config[item]); } done() } catch(e) { done(e) } } }) } src/task/replace/replace.js000066400000000000000000000036221516653250100162020ustar00rootroot00000000000000const 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) => { 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); }) if (done) { done() } }; src/utils/000077500000000000000000000000001516653250100130115ustar00rootroot00000000000000src/utils/angular/000077500000000000000000000000001516653250100144425ustar00rootroot00000000000000src/utils/angular/post-lib-build.js000077500000000000000000000021731516653250100176340ustar00rootroot00000000000000#!/usr/bin/env node const fs = require('fs').promises const execAsync = async () => { const rootPkgName = `${process.cwd()}/package.json` const rootPkg = require(rootPkgName) const pkgName = `${process.cwd()}/dist/${rootPkg.corifeus.reponame}/package.json` let pkg = require(pkgName) pkg.devDependencies = pkg.devDependencies || {} pkg.name = rootPkg.name pkg.devDependencies['corifeus-builder'] = rootPkg.devDependencies['corifeus-builder'] pkg.corifeus = { publish: true } delete rootPkg.devDependencies delete rootPkg.dependencies delete rootPkg.corifeus delete rootPkg.scripts delete rootPkg.private pkg = Object.assign(pkg, rootPkg) const data = JSON.stringify(pkg, null, 4) await fs.writeFile(pkgName, data) //const finalRootPkg = JSON.parse((await fs.readFile(rootPkgName)).toString()) //finalRootPkg.dependencies['p3x-interceptor'] = `npm:p3x-angular-http-cache-interceptor@^${finalRootPkg.version}` //const finalRootPkgNameData = JSON.stringify(finalRootPkg, null, 4) //await fs.writeFile(rootPkgName, finalRootPkgNameData) } execAsync() src/utils/appimage/000077500000000000000000000000001516653250100145745ustar00rootroot00000000000000src/utils/appimage/after-all-artifact-build.js000066400000000000000000000116511516653250100216750ustar00rootroot00000000000000const fs = require('fs-extra') const {chdir} = require('process') const path = require('path') const exec = require('./lib').exec const escapeStringRegexp = require('../escape-string-regexp'); module.exports = async function (context) { if (context.artifactPaths[0].toLowerCase().includes('arm')) { return } if (!context.artifactPaths[0].toLowerCase().endsWith('appimage') && !context.artifactPaths[0].toLowerCase().endsWith('deb')) { return; } if (process.env.hasOwnProperty('TRAVIS')) { return } if (/^win/i.test(process.platform)) { return } //console.log(context) const originalDir = process.cwd() const dirname = context.outDir chdir(dirname) //const packageDir = 'squashfs-root' let downloaded = false const appimagetool = 'appimagetool'; const assetsUploads = context.artifactPaths /* for(let artifact of context.artifactPaths) { if (artifact.toLowerCase().endsWith('appimage')) { if (downloaded === false) { // https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-armhf.AppImage - armv7l // https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-aarch64.AppImage - arm64 await exec( "curl", [ "--fail", "--location", "--output", appimagetool, `https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage`, ], ); await exec("chmod", ["+x", appimagetool]); downloaded = true } artifact = artifact.replace(/(\s+)/g, '\\$1') await exec('rm', ['-rf', packageDir]) // await exec('chmod', ['+x', artifact]) await exec(artifact, ['--appimage-extract']) const shFile = path.join(packageDir, "./AppRun"); const shContentOriginal = fs.readFileSync(shFile).toString(); const searchValue = `exec "$BIN"`; const replaceWith = `${searchValue} --no-sandbox`; let count = 0; const content = shContentOriginal.replace( new RegExp(escapeStringRegexp(searchValue), "g"), () => (count++, replaceWith), ); if (content === shContentOriginal || count !== 2) { throw new Error(`Failed to patch content of the "${shFile}" file`); } fs.writeFileSync(shFile, content); // await exec('rm', ['-rf', artifact]) const uploadArtifact = artifact.replace(/ /g, '-') await exec(dirname + '/' + appimagetool, [ '-n', '--comp', 'xz', packageDir, uploadArtifact, ]) assetsUploads.unshift( path.basename(uploadArtifact) ) } } await exec('find',[ `-iname "* *.AppImage"`, `-delete` ]) */ const githubToken = fs.readFileSync(`${originalDir}/secure/token.txt`).toString().trim() const GitHub = require('github-api'); var gh = new GitHub({ username: 'p3x-robot', token: githubToken /* also acceptable: token: 'MY_OAUTH_TOKEN' */ }); const pkg = require(`${originalDir}/package.json`) const repo = await gh.getRepo('patrikx3', pkg.corifeus.reponame) const result = await repo.createRelease({ "tag_name": 'v' + pkg.version, "target_commitish": "master", "name": pkg.version, "body": ` https://github.com/patrikx3/${pkg.corifeus.reponame}/blob/master/change-log.md#v${pkg.version.replace(/\./g, '')} [![Snapcraft](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/${pkg.name}#cory-non-external) `, "draft": true, "prerelease": false }) const upload_url = result.data.upload_url.replace('{?name,label}', '') fs.writeFileSync(`${originalDir}/secure/upload-url.txt`, upload_url) /// console.log('results', result) for (let uploadAsset of assetsUploads) { uploadAsset = path.basename(uploadAsset) const args = [ `--request POST`, `--data-binary @"${dirname + '/' + uploadAsset}"`, `-H "Authorization: token ${githubToken}"`, `-H "Content-Type: application/octet-stream"`, `${upload_url}?name=${uploadAsset}`, //``, ] if (uploadAsset.endsWith('yml')) { await exec('cat', [ dirname + '/' + uploadAsset ]) } console.info('curl args', args) await exec('curl', args) } //await exec('rm', ['-rf', packageDir]) chdir(originalDir) console.log(` AppImage-s are upgraded with the --no-sandbox flag. `) } src/utils/appimage/lib.js000066400000000000000000000022401516653250100156760ustar00rootroot00000000000000 const {spawn} = require('child_process') const exec = async function exec(cmd, args = []) { const child = spawn(cmd, args, {shell: true}) redirectOutputFor(child) await waitFor(child) } const redirectOutputFor = (child) => { const printStdout = (data) => { process.stdout.write(data.toString()) } const printStderr = (data) => { process.stderr.write(data.toString()) } child.stdout.on('data', printStdout) child.stderr.on('data', printStderr) child.once('close', () => { child.stdout.off('data', printStdout) child.stderr.off('data', printStderr) }) } const waitFor = async function (child) { return new Promise((resolve) => { child.once('close', () => resolve()) }) } const execSync = require('child_process').execSync const sha512 = (filename) => { const output = execSync(`sha512sum ${filename} | cut -f1 | xxd -r -p | base64`) //console.log(output) let sha512 = output.toString().split('\n').join('').trim() //sha512 = sha512.substring(0, sha512.length - 1) //console.log(sha512) return sha512 } module.exports.sha512 = sha512 module.exports.exec = exec src/utils/appimage/post-build.js000066400000000000000000000046251516653250100172230ustar00rootroot00000000000000const fs = require('fs-extra') const exec = require('./lib').exec const yaml = require('yaml') const sha512 = require('./lib').sha512 const run = async() => { const glob = require('glob') if (process.env.hasOwnProperty('TRAVIS')) { return } const originalDir = process.cwd() const dirname = originalDir + '/' + 'dist' const githubToken = fs.readFileSync(`${originalDir}/secure/token.txt`).toString().trim() const GitHub = require('github-api'); var gh = new GitHub({ username: 'p3x-robot', token: githubToken /* also acceptable: token: 'MY_OAUTH_TOKEN' */ }); const pkg = require(`${originalDir}/package.json`) const repo = await gh.getRepo('patrikx3', pkg.corifeus.reponame) const releases = await repo.listReleases() const assetsUploads = [ 'latest-linux.yml', // 'latest-linux-ia32.yml', ] const upload_url = releases.data[0].upload_url.replace('{?name,label}', '') for (let uploadAsset of assetsUploads) { const files = glob.sync( [ './dist/*.AppImage', // './dist/*.deb', // './dist/*.rpm' ] ) for (let file of files) { let ymlFile if (file.includes('i386')) { ymlFile = `${process.cwd()}/dist/latest-linux-ia32.yml` } else { ymlFile = `${process.cwd()}/dist/latest-linux.yml` } let ymlData = yaml.parse(fs.readFileSync(ymlFile).toString()) const sha512Data = sha512(file) ymlData.files[0].sha512 = sha512Data ymlData.sha512 = sha512Data ymlData = yaml.stringify(ymlData) //console.log(sha512Data, ymlData) fs.writeFileSync(ymlFile, ymlData) } const args = [ `--request POST`, `--data-binary @${dirname + '/' + uploadAsset}`, `-H "Authorization: token ${githubToken}"`, `-H "Content-Type: application/octet-stream"`, `${upload_url}?name=${uploadAsset}`, //``, ] if (uploadAsset.endsWith('yml')) { await exec('cat', [ dirname + '/' + uploadAsset ]) } console.info('curl args', args) await exec('curl', args) } console.log(` YAMLs uploaded. `) } run() src/utils/appimage/test.js000066400000000000000000000001511516653250100161060ustar00rootroot00000000000000const sha512 = require('./lib').sha512 sha512(`${process.cwd()}/dist/P3X-OneNote-2019.10.248.AppImage`) src/utils/config.js000066400000000000000000000001021516653250100146050ustar00rootroot00000000000000const config = { ecma: 2023 } module.exports.config = config src/utils/escape-string-regexp.js000066400000000000000000000007371516653250100174120ustar00rootroot00000000000000module.exports = string => { if (typeof string !== 'string') { throw new TypeError('Expected a string'); } // Escape characters with special meaning either inside or outside character sets. // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. return string .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') .replace(/-/g, '\\x2d'); }; src/utils/index.js000066400000000000000000000102121516653250100144520ustar00rootroot00000000000000const fs = require('fs'); const _ = require('lodash'); const path = require('path'); const cwd = process.cwd(); const win32 = process.platform === 'win32'; const commandAddon = win32 ? '.cmd' : '' const gruntSpawnErrorHandler = (options) => { const {result, code, grunt} = options; grunt.log.error(`Error code: ${code}`); grunt.log.error(String(result)); } const spawn = (options, spawnOptions) => { return new Promise((resolve, reject) => { const {grunt, gruntThis} = options; spawnOptions.opts = { shell: true, stdio: 'inherit' }; // grunt.log.writeln(JSON.stringify(spawnOptions, null, 4), typeof spawnOptions.cmd) grunt.log.ok(`${spawnOptions.grunt ? 'grunt' : path.basename(spawnOptions.cmd)} ${spawnOptions.args.join(' ')} done as:`) if (spawnOptions.grunt !== undefined || spawnOptions.cmd === 'grunt') { spawnOptions.args = spawnOptions.args || []; if (!Array.isArray(spawnOptions.args)) { spawnOptions.args = [ spawnOptions.args ] } spawnOptions.args.push('--grunt-corifeus-time-disable') } // grunt.log.writeln(JSON.stringify(spawnOptions, null, 4)) grunt.util.spawn(spawnOptions, function (error, result, code) { if (error) { gruntSpawnErrorHandler({ grunt: grunt, result: result, code: code, error: error, }) reject(error) return; } resolve({ output: result, code: code, }) }) }) } const gruntMerge = (grunt, gruntInitConfig, config) => { // Define the configuration for all the tasks const currentGruntConfig = grunt.config.get(); const thisGruntConfig = _.merge(gruntInitConfig, config) const resultGruntConfig = _.merge(currentGruntConfig, thisGruntConfig) grunt.config.merge(resultGruntConfig) } const osIndependentPath = (path) => { return path.replace(/\\/g, '/') } const injectorRelativePathGenerator = (options) => { const {filePath} = options; let {srcDir} = options; srcDir = srcDir.replace(/^\/+/g, '').replace(/\/+$/g, ''); const relative = osIndependentPath(path.relative(`${cwd}/${srcDir}/`, `${cwd}${filePath}`)); return relative; } const license = () => { //const pkg = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`, 'utf8').toString()); const license = `MIT License 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.` /* @license ${pkg.name} v${pkg.version} ${pkg.description} ${pkg.homepage} Copyright (c) ${new Date().getFullYear()} Patrik Laszlo / P3X / Corifeus and contributors. `; */ return license } module.exports.gruntMerge = gruntMerge module.exports.gruntSpawnErrorHandler = gruntSpawnErrorHandler; module.exports.spawn = spawn; module.exports.commandAddon = commandAddon; module.exports.osIndependentPath = osIndependentPath; module.exports.injectorRelativePathGenerator = injectorRelativePathGenerator module.exports.win32 = win32; module.exports.license = license src/utils/twemoji-install.js000066400000000000000000000032001516653250100164640ustar00rootroot00000000000000const utils = require('corifeus-utils') const fsExtra = require('fs-extra') const download = require('download'); const extract = require('extract-zip') const consolePrefix = `[CORIFEUS-BUILDER] [twemoji-install]` const start = async () => { if (await fsExtra.pathExists('node_modules/twemoji/twemoji-master')) { await fsExtra.remove('node_modules/twemoji/twemoji-master') } console.log(consolePrefix, 'start downloading twemoji git repo') await download('https://github.com/twitter/twemoji/archive/master.zip', `${process.cwd()}/node_modules/twemoji/`); console.log(consolePrefix, 'done downloading twemoji git repo') console.log(consolePrefix, 'extract twemoji files') await extract('node_modules/twemoji/twemoji-master.zip', { dir: `${process.cwd()}/node_modules/twemoji/` }) console.log(consolePrefix, 'done extract twemoji files') console.log(consolePrefix, 'copy files to appropriate path and cleanup') //await utils.childProcess.exec('curl -L https://github.com/twitter/twemoji/archive/master.zip --output node_modules/twemoji/master.zip', true) //await utils.childProcess.exec('unzip node_modules/twemoji/master.zip -d node_modules/twemoji/', true) if (await fsExtra.pathExists('node_modules/twemoji/2/svg')) { await fsExtra.remove('node_modules/twemoji/2/svg') } await fsExtra.move('node_modules/twemoji/twemoji-master/assets/svg', 'node_modules/twemoji/2/svg') await fsExtra.remove('node_modules/twemoji/twemoji-master') await fsExtra.remove('node_modules/twemoji/twemoji-master.zip') console.log(consolePrefix, 'done files to appropriate path and cleanup') } start() src/utils/upgrade.js000066400000000000000000000017721516653250100150050ustar00rootroot00000000000000require('corifeus-utils'); const gruntUtil = require('../utils'); const cwd = process.cwd(); const path = require('path'); const upgrade = async (options) => { const {grunt, gruntThis} = options; const done = gruntThis.async(); try { const command = { cmd: path.resolve(`${cwd}/node_modules/.bin/ncu${gruntUtil.commandAddon}`), args: [ '--upgradeAll', `--packageFile ` + path.resolve(`${cwd}/package.json`), ] } // grunt.log.writeln(`Executing`, JSON.stringify(command, null, 4)) await gruntUtil.spawn(options, command) await gruntUtil.spawn(options, { cmd: `${cwd}/node_modules/.bin/npm${gruntUtil.commandAddon}`, args: [ 'install', '--non-interactive', '--verbose', //'--no-progress', ] }) done(); } catch (error) { done(error) } } module.exports = upgrade; test/000077500000000000000000000000001516653250100120415ustar00rootroot00000000000000test/data/000077500000000000000000000000001516653250100127525ustar00rootroot00000000000000test/data/json2scss/000077500000000000000000000000001516653250100147015ustar00rootroot00000000000000test/data/json2scss/expect.scss000066400000000000000000000002541516653250100170670ustar00rootroot00000000000000$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.json000066400000000000000000000001541516653250100163550ustar00rootroot00000000000000{ "one": 1, "one-2": 2, "cool": [1, 2,3], "weird": { "cool": "cool", "not-cool": "bad" } }test/data/json2scss/two.json000066400000000000000000000001611516653250100164030ustar00rootroot00000000000000{ "one2": 1, "one-3": 2, "cool3": [1, 2,3], "weird2": { "cool2": "cool", "not-cool3": "bad" } }test/data/replace/000077500000000000000000000000001516653250100143655ustar00rootroot00000000000000test/data/replace/template/000077500000000000000000000000001516653250100162005ustar00rootroot00000000000000test/data/replace/template/replace-empty.txt000066400000000000000000000000001516653250100214760ustar00rootroot00000000000000test/data/replace/template/replace-header.txt000066400000000000000000000000061516653250100215760ustar00rootroot00000000000000headertest/mocha/000077500000000000000000000000001516653250100131305ustar00rootroot00000000000000test/mocha/async-await.js000066400000000000000000000005451516653250100157120ustar00rootroot00000000000000const 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.js000066400000000000000000000013541516653250100142540ustar00rootroot00000000000000const 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/000077500000000000000000000000001516653250100140725ustar00rootroot00000000000000test/mocha/task/json2scss.js000066400000000000000000000011631516653250100163600ustar00rootroot00000000000000const 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.js000066400000000000000000000033561516653250100152310ustar00rootroot00000000000000const 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.js000066400000000000000000000020521516653250100160420ustar00rootroot00000000000000const 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); }); });