├── .gitignore ├── CONTRIBUTE.md ├── Gruntfile.js ├── README.md ├── dist ├── argsManager.js ├── generator-vulcanjs │ ├── generators │ │ ├── app │ │ │ └── index.js │ │ ├── component │ │ │ ├── index.js │ │ │ └── templates │ │ │ │ ├── classComponent.js │ │ │ │ ├── partials │ │ │ │ ├── registerComponent.js │ │ │ │ └── registerComponentImport.js │ │ │ │ └── pureFunctionComponent.js │ │ ├── list │ │ │ ├── index.js │ │ │ └── listers │ │ │ │ └── packages.js │ │ ├── module │ │ │ ├── fragments │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ └── fragments.js │ │ │ ├── index.js │ │ │ ├── mutations │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ └── mutations.js │ │ │ ├── resolvers │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ ├── partials │ │ │ │ │ ├── listResolver.js │ │ │ │ │ └── singleResolver.js │ │ │ │ │ └── resolvers.js │ │ │ ├── schema │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ ├── partials │ │ │ │ │ └── schemaProperty.js │ │ │ │ │ └── schema.js │ │ │ └── templates │ │ │ │ ├── collection.js │ │ │ │ ├── generic-test.js │ │ │ │ └── stories.js │ │ ├── package │ │ │ ├── index.js │ │ │ └── templates │ │ │ │ ├── client.js │ │ │ │ ├── collections.js │ │ │ │ ├── components.js │ │ │ │ ├── modules.index.js │ │ │ │ ├── package.js │ │ │ │ ├── routes.js │ │ │ │ ├── seed.js │ │ │ │ └── server.js │ │ ├── remove │ │ │ ├── index.js │ │ │ └── removers │ │ │ │ ├── module.js │ │ │ │ ├── package.js │ │ │ │ └── route.js │ │ ├── route │ │ │ └── index.js │ │ └── start │ │ │ └── index.js │ └── lib │ │ ├── VulcanGenerator.js │ │ ├── assertions.js │ │ ├── ast.js │ │ ├── common.js │ │ ├── filters.js │ │ ├── finalizers.js │ │ ├── lister.js │ │ ├── optionsManager.js │ │ ├── path-finder.js │ │ ├── questions.js │ │ ├── reducers.js │ │ ├── repairs.js │ │ ├── store.js │ │ ├── styles.js │ │ ├── ui-text.js │ │ └── validations.js └── index.js ├── media ├── logo-plain.png └── usage │ ├── create.gif │ ├── generate-component.gif │ ├── generate-custom-model.gif │ ├── generate-default-model.gif │ ├── generate-package.gif │ ├── generate-route.gif │ ├── list-packages.gif │ ├── list-routes.gif │ ├── remove-model.gif │ └── remove-package.gif ├── package-lock.json ├── package.json ├── src ├── .eslintrc.js ├── argsManager.js ├── generator-vulcanjs │ ├── .DS_Store │ ├── .gitignore │ ├── generators │ │ ├── app │ │ │ └── index.js │ │ ├── component │ │ │ ├── index.js │ │ │ └── templates │ │ │ │ ├── classComponent.js │ │ │ │ ├── partials │ │ │ │ ├── registerComponent.js │ │ │ │ └── registerComponentImport.js │ │ │ │ └── pureFunctionComponent.js │ │ ├── list │ │ │ ├── index.js │ │ │ └── listers │ │ │ │ └── packages.js │ │ ├── module │ │ │ ├── fragments │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ └── fragments.js │ │ │ ├── index.js │ │ │ ├── mutations │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ └── mutations.js │ │ │ ├── resolvers │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ ├── partials │ │ │ │ │ ├── listResolver.js │ │ │ │ │ └── singleResolver.js │ │ │ │ │ └── resolvers.js │ │ │ ├── schema │ │ │ │ ├── index.js │ │ │ │ └── templates │ │ │ │ │ ├── partials │ │ │ │ │ └── schemaProperty.js │ │ │ │ │ └── schema.js │ │ │ └── templates │ │ │ │ ├── collection.js │ │ │ │ ├── generic-test.js │ │ │ │ └── stories.js │ │ ├── package │ │ │ ├── index.js │ │ │ └── templates │ │ │ │ ├── client.js │ │ │ │ ├── collections.js │ │ │ │ ├── components.js │ │ │ │ ├── modules.index.js │ │ │ │ ├── package.js │ │ │ │ ├── routes.js │ │ │ │ ├── seed.js │ │ │ │ └── server.js │ │ ├── remove │ │ │ ├── index.js │ │ │ └── removers │ │ │ │ ├── module.js │ │ │ │ ├── package.js │ │ │ │ └── route.js │ │ ├── route │ │ │ └── index.js │ │ └── start │ │ │ └── index.js │ └── lib │ │ ├── VulcanGenerator.js │ │ ├── assertions.js │ │ ├── ast.js │ │ ├── common.js │ │ ├── filters.js │ │ ├── finalizers.js │ │ ├── lister.js │ │ ├── optionsManager.js │ │ ├── path-finder.js │ │ ├── questions.js │ │ ├── reducers.js │ │ ├── repairs.js │ │ ├── store.js │ │ ├── styles.js │ │ ├── ui-text.js │ │ └── validations.js └── index.js ├── test └── semi-automatic.sh └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | /nbproject 4 | -------------------------------------------------------------------------------- /CONTRIBUTE.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | - Once you pull the repo, don't forget to run `npm install`. 3 | - In the project root, run `npm run watch` 4 | - Do not work on the root. Make your changes in the `/src` directory. 5 | - Grunt will compile your code into the root directory (`/dist`). 6 | - PRs are always welcome! 7 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = (grunt) => { 2 | grunt.initConfig({ 3 | babel: { 4 | options: { 5 | // sourceMap: true, 6 | presets: ['es2015'], 7 | plugins: [ 8 | 'transform-object-rest-spread', 9 | // 'transform-es2015-modules-commonjs', 10 | 'transform-es2015-shorthand-properties', 11 | ], 12 | }, 13 | dist: { 14 | files: [{ 15 | expand: true, 16 | cwd: './src/', 17 | src: ['**/*.js', '!**/templates/**'], 18 | dest: './dist/', 19 | }], 20 | }, 21 | }, 22 | copy: { 23 | templates: { 24 | files: [{ 25 | expand: true, 26 | cwd: './src/generator-vulcanjs/', 27 | src: ['**/templates/**'], 28 | dest: './dist/generator-vulcanjs/', 29 | }], 30 | }, 31 | }, 32 | clean: { 33 | dist: { 34 | src: ['./dist'] 35 | } 36 | }, 37 | watch: { 38 | src: { 39 | files: ['src/**/*.*',], 40 | tasks: ['default'], 41 | options: { 42 | interrupt: true, 43 | }, 44 | }, 45 | }, 46 | }); 47 | 48 | grunt.loadNpmTasks('grunt-babel'); 49 | grunt.loadNpmTasks('grunt-contrib-clean'); 50 | grunt.loadNpmTasks('grunt-contrib-copy'); 51 | grunt.loadNpmTasks('grunt-contrib-watch'); 52 | 53 | grunt.registerTask( 54 | 'default', 55 | [ 56 | 'clean', 57 | 'babel', 58 | 'copy', 59 | 'chmod' 60 | ] 61 | ); 62 | grunt.registerTask('chmod', 'Fixes permissions', function() { 63 | var fs = require('fs'); 64 | fs.chmodSync('./dist/index.js', '775'); 65 | }); 66 | 67 | }; 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | vulcanjs-banner 4 |
5 | VulcanJS-cli 6 |
7 |

8 | 9 |

The official CLI scaffolding tool for VulcanJS.

10 | 11 | ## Warning 12 | 13 | This project is young. Use with caution. Always commit your code before using any program that modifies it. 14 | 15 | Last tested on [Vulcan 1.14] (except for custom mutations and resolvers) 16 | 17 | ## Table of Contents 18 | 19 | - [Warning](#warning) 20 | - [Table of Contents](#table-of-contents) 21 | - [Background](#background) 22 | - [Install](#install) 23 | - [Usage](#usage) 24 | - [Create](#create) 25 | - [Generate](#generate) 26 | - [Remove](#remove) 27 | - [List](#list) 28 | - [Maintainers](#maintainers) 29 | - [Contribute](#contribute) 30 | - [License](#license) 31 | 32 | ## Background 33 | 34 | VulcanJS is a full stack javascript framework, built on Meteor, React and GraphQL. If you aren't familiar with VulcanJS, we highly recommend that you check out the website and read the docs. 35 | 36 | With this cli, you'll be able to easily generate `packages`, `modules`, `components`, and `routes` for your VulcanJS project. 37 | 38 | ## Install 39 | 40 | Npm: 41 | 42 | ```sh 43 | $ npm install -g vulcanjs-cli 44 | ``` 45 | 46 | Yarn: 47 | 48 | ```sh 49 | $ yarn global add vulcanjs-cli 50 | ``` 51 | 52 | ## Usage 53 | 54 | ### Create 55 | 56 | Creates a new project with the given app name: 57 | 58 | ```sh 59 | $ vulcan create 60 | ``` 61 | 62 | ### Generate 63 | 64 | Generates a project component 65 | 66 | - Generate Package 67 | 68 | ```sh 69 | $ vulcan g package 70 | ``` 71 | 72 | - Generate Module 73 | 74 | ```sh 75 | $ vulcan g module 76 | ``` 77 | 78 | - Generate Component 79 | 80 | ```sh 81 | $ vulcan g component 82 | ``` 83 | 84 | - Generate Route 85 | 86 | ```sh 87 | $ vulcan g route 88 | ``` 89 | 90 | ### Remove 91 | 92 | - Remove Package 93 | 94 | ```sh 95 | $ vulcan remove package 96 | ``` 97 | 98 | - Remove Module 99 | 100 | ```sh 101 | $ vulcan remove module 102 | ``` 103 | 104 | ### List 105 | 106 | - List Packages 107 | 108 | ```sh 109 | $ vulcan list packages 110 | ``` 111 | 112 | - List Routes 113 | 114 | ```sh 115 | $ vulcan list routes 116 | ``` 117 | 118 | ## Maintainers 119 | 120 | [@mechanical-turk](https://github.com/mechanical-turk) 121 | 122 | [@albancrommer](https://github.com/albancrommer) 123 | 124 | [@SachaG](https://github.com/SachaG) 125 | 126 | [@eric-burel](https://github.com/eric-burel) 127 | 128 | ## Contribute 129 | 130 | See [CONTRIBUTE.md](./CONTRIBUTE.md)! 131 | 132 | This package is in very low maintenance mode. If you encounter a bug or have a suggestion, feel free to open an issue, but we won't guarantee any fix. 133 | 134 | PRs are always welcome however, even if incomplete or just a draft. 135 | 136 | ## License 137 | 138 | MIT © 2017 Kerem Kazan 139 | -------------------------------------------------------------------------------- /dist/argsManager.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var minimist = require('minimist'); 4 | var _ = require('lodash'); 5 | var chalk = require('chalk'); 6 | 7 | var recognizedActions = { 8 | generate: 'generate', 9 | g: 'generate', 10 | create: 'create', 11 | c: 'create', 12 | remove: 'remove', 13 | r: 'remove', 14 | list: 'list', 15 | l: 'list', 16 | un: 'unshallow', 17 | unshallow: 'unshallow', 18 | start: 'start' 19 | }; 20 | 21 | var genericProcessor = function genericProcessor(args) { 22 | var argsToProcess = args.slice(1); 23 | var action = { 24 | type: recognizedActions[args[0]], 25 | args: [] 26 | }; 27 | if (argsToProcess.length > 0) { 28 | action.component = argsToProcess[0]; 29 | } 30 | argsToProcess.shift(); 31 | if (argsToProcess.length > 0) { 32 | action.args = argsToProcess; 33 | } 34 | return action; 35 | }; 36 | 37 | var createProcessor = function createProcessor(args) { 38 | return { 39 | type: 'create', 40 | args: args.slice(1) 41 | }; 42 | }; 43 | 44 | var argsProcessors = { 45 | generate: genericProcessor, 46 | remove: genericProcessor, 47 | list: genericProcessor, 48 | create: createProcessor, 49 | start: genericProcessor 50 | }; 51 | 52 | function usage() { 53 | var values = _.uniq(_.values(recognizedActions)); 54 | console.log(chalk.green('\nvulcan usage:')); 55 | console.log(chalk.grey('\nSynopsis')); 56 | console.log(' vulcan <...>\n'); 57 | console.log(' Operation to perform '); 58 | console.log(' Asset type (contextual to action)'); 59 | console.log(' <...> Parameters. If not provided, interactively entered'); 60 | // console.log(chalk.grey('\nProject run')); 61 | // console.log(' vulcan start'); 62 | console.log(chalk.grey('\nProject initialisation')); 63 | console.log(' vulcan create '); 64 | // console.log(' vulcan unshallow '); 65 | console.log(chalk.grey('\nAssets creation')); 66 | console.log(' vulcan (generate|g) package '); 67 | console.log(' vulcan (generate|g) module '); 68 | console.log(' vulcan (generate|g) component '); 69 | console.log(' vulcan (generate|g) route '); 70 | console.log(chalk.grey('\nAssets removal')); 71 | console.log(' vulcan (remove|r) package'); 72 | console.log(' vulcan (remove|r) module'); 73 | console.log(chalk.grey('\nAssets listing')); 74 | console.log(' vulcan (list|l) packages'); 75 | process.exit(); 76 | } 77 | 78 | function getAction() { 79 | var args = minimist(process.argv.slice(2))._; 80 | 81 | if (!recognizedActions[args[0]]) { 82 | usage(); 83 | } 84 | var actionName = recognizedActions[args[0]]; 85 | var actionObj = argsProcessors[actionName](args); 86 | return actionObj; 87 | } 88 | 89 | module.exports = { 90 | getAction: getAction 91 | }; 92 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var chalk = require('chalk'); 14 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 15 | 16 | var STARTER_REPO_URL = 'https://github.com/VulcanJS/Vulcan-Starter.git'; 17 | 18 | module.exports = function (_VulcanGenerator) { 19 | _inherits(_class, _VulcanGenerator); 20 | 21 | function _class() { 22 | _classCallCheck(this, _class); 23 | 24 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 25 | } 26 | 27 | _createClass(_class, [{ 28 | key: '_registerArguments', 29 | value: function _registerArguments() { 30 | this._registerOptions('appName', 'doShallowClone', 'reactExtension', 'packageManager'); 31 | } 32 | }, { 33 | key: 'initializing', 34 | value: function initializing() { 35 | this._assert('notVulcan'); 36 | } 37 | }, { 38 | key: 'prompting', 39 | value: function prompting() { 40 | var _this2 = this; 41 | 42 | if (!this._canPrompt()) { 43 | return false; 44 | } 45 | var questions = []; 46 | if (this._needArg('appName')) { 47 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('appName'))); 48 | } 49 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('packageManager'))); 50 | return this.prompt(questions).then(function (answers) { 51 | _this2.props = { 52 | appName: _this2._finalize('appName', answers), 53 | packageManager: _this2._finalize('raw', 'packageManager', answers) 54 | }; 55 | }); 56 | } 57 | }, { 58 | key: 'writing', 59 | value: function writing() { 60 | if (!this._canInstall()) { 61 | return; 62 | } 63 | 64 | this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); 65 | this.spawnCommandSync('git', ['clone', STARTER_REPO_URL, this.props.appName]); 66 | this.destinationRoot(this.destinationPath(this.props.appName)); 67 | this.installDependencies({ 68 | npm: this.props.packageManager === 'npm', 69 | bower: false, 70 | yarn: this.props.packageManager === 'yarn' 71 | }); 72 | if (!this._canConfigure()) { 73 | return; 74 | } 75 | this._dispatch({ 76 | type: 'SET_IS_VULCAN_TRUE' 77 | }); 78 | this._dispatch({ 79 | type: 'SET_APP_NAME', 80 | appName: this.props.appName 81 | }); 82 | this._dispatch({ 83 | type: 'SET_PACKAGE_MANAGER', 84 | packageManager: this.props.packageManager 85 | }); 86 | this._commitStore(); 87 | } 88 | }, { 89 | key: 'end', 90 | value: function end() { 91 | this._end(); 92 | this.log(' '); 93 | this.log(chalk.green('Successfully generated vulcan code base. \n')); 94 | this.log(chalk.green('To run your new app: \n')); 95 | this.log(chalk.green(' cd ' + this.props.appName)); 96 | this.log(chalk.green(' ' + this.props.packageManager + ' start \n')); 97 | } 98 | }]); 99 | 100 | return _class; 101 | }(VulcanGenerator); 102 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/component/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 14 | var ast = require('../../lib/ast'); 15 | 16 | module.exports = function (_VulcanGenerator) { 17 | _inherits(_class, _VulcanGenerator); 18 | 19 | function _class() { 20 | _classCallCheck(this, _class); 21 | 22 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 23 | } 24 | 25 | _createClass(_class, [{ 26 | key: 'initializing', 27 | value: function initializing() { 28 | this._assert('isVulcan'); 29 | this._assert('hasNonZeroPackages'); 30 | } 31 | }, { 32 | key: '_registerArguments', 33 | value: function _registerArguments() { 34 | this._registerOptions('packageName', 'componentName'); 35 | } 36 | }, { 37 | key: 'prompting', 38 | value: function prompting() { 39 | var _this2 = this; 40 | 41 | if (!this._canPrompt()) { 42 | return false; 43 | } 44 | var questions = []; 45 | if (this._needArg('packageName')) { 46 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('packageNameList'))); 47 | } 48 | if (this._needArg('componentName')) { 49 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('componentName'))); 50 | } 51 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('componentType', 'isRegisterComponent'))); 52 | return this.prompt(questions).then(function (answers) { 53 | _this2.props = { 54 | packageName: _this2._finalize('packageName', answers), 55 | componentName: _this2._finalize('componentName', answers), 56 | componentFileName: _this2._finalize('componentFileName', answers), 57 | componentType: _this2._finalize('raw', 'componentType', answers), 58 | isRegister: _this2._finalize('raw', 'isRegister', answers) 59 | }; 60 | _this2.props.componentPath = _this2._finalize('componentPath', answers); 61 | }); 62 | } 63 | }, { 64 | key: '_writeComponent', 65 | value: function _writeComponent() { 66 | var templatePath = this.props.componentType === 'pure' ? this.templatePath('pureFunctionComponent.js') : this.templatePath('classComponent.js'); 67 | this.fs.copyTpl(templatePath, this._getPath({ isAbsolute: true }, 'components', this.props.componentFileName), this.props); 68 | } 69 | }, { 70 | key: '_updateComponentsIndex', 71 | value: function _updateComponentsIndex() { 72 | if (!this.props.isRegister) return; 73 | var componentsIndexPath = this._getPath({ isAbsolute: true }, 'componentsIndex'); 74 | var fileText = this.fs.read(componentsIndexPath); 75 | var fileWithImportText = ast.addImportStatement(fileText, '../components/' + this.props.componentFileName); 76 | this.fs.write(componentsIndexPath, fileWithImportText); 77 | } 78 | }, { 79 | key: 'writing', 80 | value: function writing() { 81 | if (!this._canWrite()) { 82 | return; 83 | } 84 | this._writeComponent(); 85 | this._updateComponentsIndex(); 86 | } 87 | }, { 88 | key: 'end', 89 | value: function end() { 90 | this._end(); 91 | } 92 | }]); 93 | 94 | return _class; 95 | }(VulcanGenerator); 96 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/component/templates/classComponent.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | <%if (isRegister) { %><% include ./partials/registerComponentImport.js -%><%} -%> 3 | 4 | class <%= componentName %> extends Component { 5 | render () { 6 | return ( 7 |
8 | Find me at <%= componentPath %> 9 |
10 | ); 11 | } 12 | } 13 | <%if (isRegister) { %><% include ./partials/registerComponent.js -%><%} -%> 14 | 15 | export default <%= componentName %>; 16 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/component/templates/partials/registerComponent.js: -------------------------------------------------------------------------------- 1 | registerComponent({name:'<%= componentName %>', component:<%= componentName %>}); 2 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/component/templates/partials/registerComponentImport.js: -------------------------------------------------------------------------------- 1 | import { registerComponent } from 'meteor/vulcan:core'; 2 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/component/templates/pureFunctionComponent.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | <%if (isRegister) { %><% include ./partials/registerComponentImport.js -%><%} -%> 3 | 4 | const <%= componentName %> = () => ( 5 |
6 | Find me at <%= componentPath %> 7 |
8 | ); 9 | <%if (isRegister) { %><% include ./partials/registerComponent.js -%><%} -%> 10 | 11 | export default <%= componentName %>; 12 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/list/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 12 | 13 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 14 | 15 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 16 | 17 | module.exports = function (_VulcanGenerator) { 18 | _inherits(_class, _VulcanGenerator); 19 | 20 | function _class() { 21 | _classCallCheck(this, _class); 22 | 23 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 24 | } 25 | 26 | _createClass(_class, [{ 27 | key: 'initializing', 28 | value: function initializing() { 29 | this._assert('isVulcan'); 30 | } 31 | }, { 32 | key: '_registerArguments', 33 | value: function _registerArguments() { 34 | this._registerOptions('vulcanjsListableComponent', 'packageName'); 35 | } 36 | }, { 37 | key: 'prompting', 38 | value: function prompting() { 39 | var _this2 = this; 40 | 41 | if (!this._canPrompt()) { 42 | return false; 43 | } 44 | var questions = []; 45 | if (!this.options.vulcanjsComponent) { 46 | questions = [].concat(_toConsumableArray(questions), [this._getQuestions('vulcanjsListableComponentsList')]); 47 | } 48 | return this.prompt(questions).then(function (answers) { 49 | _this2.props = { 50 | vulcanjsComponent: _this2._finalize('raw', 'vulcanjsComponent', answers) 51 | }; 52 | }); 53 | } 54 | }, { 55 | key: 'composing', 56 | value: function composing() { 57 | var lister = require.resolve('./listers/' + this.props.vulcanjsComponent); 58 | this.composeWith(lister, _extends({}, this.props, this.options, { 59 | dontAsk: true 60 | })); 61 | } 62 | }, { 63 | key: 'end', 64 | value: function end() { 65 | this._end(); 66 | } 67 | }]); 68 | 69 | return _class; 70 | }(VulcanGenerator); 71 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/list/listers/packages.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 8 | 9 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 10 | 11 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 12 | var nodePrint = require('node-print'); 13 | var makeLister = require('../../../lib/lister'); 14 | 15 | module.exports = function (_VulcanGenerator) { 16 | _inherits(_class, _VulcanGenerator); 17 | 18 | function _class() { 19 | _classCallCheck(this, _class); 20 | 21 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 22 | } 23 | 24 | _createClass(_class, [{ 25 | key: 'initializing', 26 | value: function initializing() { 27 | this._assert('isVulcan'); 28 | this._lister = makeLister.setup(this); 29 | } 30 | }, { 31 | key: 'prompting', 32 | value: function prompting() { 33 | var packageNames = this._lister.listPackages(); 34 | this.props = { 35 | packageNames: packageNames, 36 | prettyPackages: this._finalize('prettyPackages', packageNames) 37 | }; 38 | } 39 | }, { 40 | key: 'listing', 41 | value: function listing() { 42 | nodePrint.pt(this.props.prettyPackages); 43 | } 44 | }, { 45 | key: 'end', 46 | value: function end() { 47 | this._end(); 48 | } 49 | }]); 50 | 51 | return _class; 52 | }(VulcanGenerator); 53 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/fragments/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 14 | 15 | module.exports = function (_VulcanGenerator) { 16 | _inherits(_class, _VulcanGenerator); 17 | 18 | function _class() { 19 | _classCallCheck(this, _class); 20 | 21 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 22 | } 23 | 24 | _createClass(_class, [{ 25 | key: 'initializing', 26 | value: function initializing() { 27 | this._assert('isVulcan'); 28 | this._assert('hasNonZeroPackages'); 29 | } 30 | }, { 31 | key: '_registerArguments', 32 | value: function _registerArguments() { 33 | this._registerOptions('packageName', 'moduleName'); 34 | } 35 | }, { 36 | key: 'prompting', 37 | value: function prompting() { 38 | var _this2 = this; 39 | 40 | if (!this._canPrompt()) { 41 | return false; 42 | } 43 | var questions = this._getQuestions('packageNameWithNumModulesList', 'moduleNameList'); 44 | return this.prompt(questions).then(function (answers) { 45 | _this2.props = { 46 | packageName: _this2._finalize('packageName', answers), 47 | moduleName: _this2._finalize('moduleName', answers), 48 | typeName: _this2._finalize('typeName', answers), 49 | collectionName: _this2._finalize('collectionName', answers) 50 | }; 51 | }); 52 | } 53 | }, { 54 | key: '_writeFragments', 55 | value: function _writeFragments() { 56 | this.fs.copyTpl(this.templatePath('fragments.js'), this._getPath({ isAbsolute: true }, 'module', 'fragments.js'), this.props); 57 | } 58 | }, { 59 | key: '_writeTestFragments', 60 | value: function _writeTestFragments() { 61 | var testProps = _extends({}, this.props, { 62 | subjectName: 'fragments', 63 | subjectPath: '../../../lib/modules/' + this.props.moduleName + '/fragments' 64 | }); 65 | this.fs.copyTpl(this.templatePath('../../templates/generic-test.js'), this._getPath({ isAbsolute: true }, 'moduleTest', 'fragments.spec.js'), testProps); 66 | } 67 | }, { 68 | key: 'writing', 69 | value: function writing() { 70 | if (!this._canWrite()) { 71 | return; 72 | } 73 | this._writeFragments(); 74 | // this._writeTestFragments(); 75 | } 76 | }, { 77 | key: 'end', 78 | value: function end() { 79 | this._end(); 80 | } 81 | }]); 82 | 83 | return _class; 84 | }(VulcanGenerator); 85 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/fragments/templates/fragments.js: -------------------------------------------------------------------------------- 1 | import { registerFragment } from 'meteor/vulcan:core'; 2 | 3 | registerFragment(` 4 | fragment <%= collectionName %>Fragment on <%= typeName %> { 5 | _id 6 | createdAt 7 | } 8 | `); 9 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 12 | 13 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 14 | 15 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 16 | var ast = require('../../lib/ast'); 17 | 18 | module.exports = function (_VulcanGenerator) { 19 | _inherits(_class, _VulcanGenerator); 20 | 21 | function _class() { 22 | _classCallCheck(this, _class); 23 | 24 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 25 | } 26 | 27 | _createClass(_class, [{ 28 | key: 'initializing', 29 | value: function initializing() { 30 | this._assert('isVulcan'); 31 | this._assert('hasNonZeroPackages'); 32 | } 33 | }, { 34 | key: '_registerArguments', 35 | value: function _registerArguments() { 36 | this._registerOptions('packageName', 'moduleName'); 37 | } 38 | }, { 39 | key: 'prompting', 40 | value: function prompting() { 41 | var _this2 = this; 42 | 43 | if (!this._canPrompt()) { 44 | return false; 45 | } 46 | var questions = []; 47 | if (this._needArg('packageName')) { 48 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('packageNameList'))); 49 | } 50 | if (this._needArg('moduleName')) { 51 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('moduleName'))); 52 | } 53 | return this.prompt(questions).then(function (answers) { 54 | _this2.props = { 55 | packageName: _this2._finalize('packageName', answers), 56 | moduleName: _this2._finalize('moduleName', answers), 57 | collectionName: _this2._finalize('collectionName', answers), 58 | typeName: _this2._finalize('pascalModuleName', answers) 59 | }; 60 | _this2._composeGenerators(); 61 | }); 62 | } 63 | }, { 64 | key: '_composeGenerators', 65 | value: function _composeGenerators() { 66 | var _this3 = this; 67 | 68 | var moduleParts = ['fragments', 'schema']; 69 | moduleParts.forEach(function (modulePart) { 70 | var generator = require.resolve('./' + modulePart); 71 | var nextOptions = _extends({}, _this3.options, _this3.props, { 72 | dontAsk: true 73 | }); 74 | _this3.composeWith(generator, nextOptions); 75 | }); 76 | } 77 | }, { 78 | key: 'configuring', 79 | value: function configuring() { 80 | if (!this._canConfigure()) {} 81 | } 82 | }, { 83 | key: '_writeCollection', 84 | value: function _writeCollection() { 85 | this.fs.copyTpl(this.templatePath('collection.js'), this._getPath({ isAbsolute: true }, 'module', 'collection.js'), this.props); 86 | } 87 | }, { 88 | key: '_writeTestCollection', 89 | value: function _writeTestCollection() { 90 | var testProps = _extends({}, this.props, { 91 | subjectName: 'collection', 92 | subjectPath: '../../../lib/modules/' + this.props.moduleName + '/fragments' 93 | }); 94 | this.fs.copyTpl(this.templatePath('generic-test.js'), this._getPath({ isAbsolute: true }, 'moduleTest', 'collection.spec.js'), testProps); 95 | } 96 | }, { 97 | key: '_updateCollectionsIndex', 98 | value: function _updateCollectionsIndex() { 99 | var collectionsIndexPath = this._getPath({ isAbsolute: true }, 'collectionsIndex'); 100 | var fileText = this.fs.read(collectionsIndexPath); 101 | var fileWithImportText = ast.addImportStatement(fileText, './' + this.props.moduleName + '/collection.js'); 102 | this.fs.write(collectionsIndexPath, fileWithImportText); 103 | } 104 | }, { 105 | key: 'writing', 106 | value: function writing() { 107 | if (!this._canWrite()) { 108 | return; 109 | } 110 | this._writeCollection(); 111 | this._updateCollectionsIndex(); 112 | // this._writeTestCollection(); 113 | } 114 | }, { 115 | key: 'end', 116 | value: function end() { 117 | this._end(); 118 | } 119 | }]); 120 | 121 | return _class; 122 | }(VulcanGenerator); 123 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/mutations/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 14 | 15 | module.exports = function (_VulcanGenerator) { 16 | _inherits(_class, _VulcanGenerator); 17 | 18 | function _class() { 19 | _classCallCheck(this, _class); 20 | 21 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 22 | } 23 | 24 | _createClass(_class, [{ 25 | key: 'initializing', 26 | value: function initializing() { 27 | this._assert('isVulcan'); 28 | this._assert('hasNonZeroPackages'); 29 | } 30 | }, { 31 | key: '_registerArguments', 32 | value: function _registerArguments() { 33 | this._registerOptions('packageName', 'moduleName'); 34 | } 35 | }, { 36 | key: 'prompting', 37 | value: function prompting() { 38 | var _this2 = this; 39 | 40 | if (!this._canPrompt()) { 41 | return false; 42 | } 43 | var questions = this._getQuestions('packageNameWithNumModulesList', 'moduleNameList'); 44 | return this.prompt(questions).then(function (answers) { 45 | _this2.props = { 46 | packageName: _this2._finalize('packageName', answers), 47 | moduleName: _this2._finalize('moduleName', answers), 48 | collectionName: _this2._finalize('collectionName', answers), 49 | newMutationName: _this2._finalize('mutationName', 'new', answers), 50 | editMutationName: _this2._finalize('mutationName', 'edit', answers), 51 | removeMutationName: _this2._finalize('mutationName', 'remove', answers), 52 | newPermission: _this2._finalize('permissionName', ['new'], answers), 53 | editOwnPermission: _this2._finalize('permissionName', ['edit', 'own'], answers), 54 | editAllPermission: _this2._finalize('permissionName', ['edit', 'all'], answers), 55 | removeOwnPermission: _this2._finalize('permissionName', ['remove', 'own'], answers), 56 | removeAllPermission: _this2._finalize('permissionName', ['remove', 'all'], answers) 57 | }; 58 | }); 59 | } 60 | }, { 61 | key: '_writeMutations', 62 | value: function _writeMutations() { 63 | this.fs.copyTpl(this.templatePath('mutations.js'), this._getPath({ isAbsolute: true }, 'module', 'mutations.js'), this.props); 64 | } 65 | }, { 66 | key: '_writeTestMutations', 67 | value: function _writeTestMutations() { 68 | var testProps = _extends({}, this.props, { 69 | subjectName: 'mutations', 70 | subjectPath: '../../../lib/modules/' + this.props.moduleName + '/mutations' 71 | }); 72 | this.fs.copyTpl(this.templatePath('../../templates/generic-test.js'), this._getPath({ isAbsolute: true }, 'moduleTest', 'mutations.spec.js'), testProps); 73 | } 74 | }, { 75 | key: 'writing', 76 | value: function writing() { 77 | if (!this._canWrite()) { 78 | return; 79 | } 80 | this._writeMutations(); 81 | // this._writeTestMutations(); 82 | } 83 | }, { 84 | key: 'end', 85 | value: function end() { 86 | this._end(); 87 | } 88 | }]); 89 | 90 | return _class; 91 | }(VulcanGenerator); 92 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/mutations/templates/mutations.js: -------------------------------------------------------------------------------- 1 | import { 2 | createMutator, 3 | updateMutator, 4 | deleteMutator, 5 | Utils 6 | } from 'meteor/vulcan:core'; 7 | import Users from 'meteor/vulcan:users'; 8 | 9 | const mutations = { 10 | create: { 11 | name: '<%= newMutationName %>', 12 | check(user) { 13 | if (!user) return false; 14 | return Users.canDo(user, '<%= newPermission %>'); 15 | }, 16 | mutation(root, { document }, context) { 17 | Utils.performCheck(this.check, context.currentUser, document); 18 | return createMutator({ 19 | collection: context.<%= collectionName %>, 20 | document: document, 21 | currentUser: context.currentUser, 22 | validate: true, 23 | context, 24 | }); 25 | }, 26 | }, 27 | 28 | update: { 29 | name: '<%= editMutationName %>', 30 | check(user, document) { 31 | if (!user || !document) return false; 32 | return Users.owns(user, document) ? 33 | Users.canDo(user, '<%= editOwnPermission %>') : 34 | Users.canDo(user, `<%= editAllPermission %>`); 35 | }, 36 | mutation(root, { documentId, set, unset }, context) { 37 | const document = context.<%= collectionName %>.findOne(documentId); 38 | Utils.performCheck(this.check, context.currentUser, document); 39 | return updateMutator({ 40 | collection: context.<%= collectionName %>, 41 | documentId: documentId, 42 | set: set, 43 | unset: unset, 44 | currentUser: context.currentUser, 45 | validate: true, 46 | context, 47 | }); 48 | }, 49 | }, 50 | 51 | delete: { 52 | name: '<%= removeMutationName %>', 53 | check(user, document) { 54 | if (!user || !document) return false; 55 | return Users.owns(user, document) ? 56 | Users.canDo(user, '<%= removeOwnPermission %>') : 57 | Users.canDo(user, `<%= removeAllPermission %>`); 58 | }, 59 | mutation(root, { documentId }, context) { 60 | const document = context.<%= collectionName %>.findOne(documentId); 61 | Utils.performCheck(this.check, context.currentUser, document); 62 | return deleteMutator({ 63 | collection: context.<%= collectionName %>, 64 | documentId: documentId, 65 | currentUser: context.currentUser, 66 | validate: true, 67 | context, 68 | }); 69 | }, 70 | }, 71 | }; 72 | 73 | export default mutations; -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/resolvers/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 14 | 15 | module.exports = function (_VulcanGenerator) { 16 | _inherits(_class, _VulcanGenerator); 17 | 18 | function _class() { 19 | _classCallCheck(this, _class); 20 | 21 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 22 | } 23 | 24 | _createClass(_class, [{ 25 | key: 'initializing', 26 | value: function initializing() { 27 | this._assert('isVulcan'); 28 | this._assert('hasNonZeroPackages'); 29 | } 30 | }, { 31 | key: '_registerArguments', 32 | value: function _registerArguments() { 33 | this._registerOptions('packageName', 'moduleName'); 34 | } 35 | }, { 36 | key: 'prompting', 37 | value: function prompting() { 38 | var _this2 = this; 39 | 40 | if (!this._canPrompt()) { 41 | return false; 42 | } 43 | var questions = this._getQuestions('packageNameWithNumModulesList', 'moduleNameList' 44 | // 'defaultResolvers' 45 | ); 46 | return this.prompt(questions).then(function (answers) { 47 | _this2.props = { 48 | packageName: _this2._finalize('packageName', answers), 49 | moduleName: _this2._finalize('moduleName', answers), 50 | collectionName: _this2._finalize('collectionName', answers), 51 | listResolverName: _this2._finalize('resolverName', 'List', answers), 52 | singleResolverName: _this2._finalize('resolverName', 'Single', answers), 53 | totalResolverName: _this2._finalize('resolverName', 'Total', answers) 54 | }; 55 | }); 56 | } 57 | }, { 58 | key: '_writeResolvers', 59 | value: function _writeResolvers() { 60 | this.fs.copyTpl(this.templatePath('resolvers.js'), this._getPath({ isAbsolute: true }, 'module', 'resolvers.js'), this.props); 61 | } 62 | }, { 63 | key: '_writeTestResolvers', 64 | value: function _writeTestResolvers() { 65 | var testProps = _extends({}, this.props, { 66 | subjectName: 'resolvers', 67 | subjectPath: '../../../lib/modules/' + this.props.moduleName + '/resolvers' 68 | }); 69 | this.fs.copyTpl(this.templatePath('../../templates/generic-test.js'), this._getPath({ isAbsolute: true }, 'moduleTest', 'resolvers.spec.js'), testProps); 70 | } 71 | }, { 72 | key: 'writing', 73 | value: function writing() { 74 | if (!this._canWrite()) { 75 | return; 76 | } 77 | this._writeResolvers(); 78 | // this._writeTestResolvers(); 79 | } 80 | }, { 81 | key: 'end', 82 | value: function end() { 83 | this._end(); 84 | } 85 | }]); 86 | 87 | return _class; 88 | }(VulcanGenerator); 89 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/resolvers/templates/partials/listResolver.js: -------------------------------------------------------------------------------- 1 | multi: { 2 | name: '<%= listResolverName %>', 3 | resolver(root, {input = {}}, context, info) { 4 | // get selector and options from terms and perform Mongo query 5 | let { selector, options } = await Connectors.filter(collection, input, context); 6 | return { 7 | results: context.<%= collectionName %>.find(selector, options).fetch(); 8 | } 9 | }, 10 | }, 11 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/resolvers/templates/partials/singleResolver.js: -------------------------------------------------------------------------------- 1 | single: { 2 | name: '<%= singleResolverName %>', 3 | resolver(root, { _id }, context) { 4 | const document = context.<%= collectionName %>.findOne({ _id }); 5 | const result = context.Users.restrictViewableFields( 6 | context.currentUser, 7 | context.<%= collectionName %>, 8 | document 9 | ); 10 | return { result } 11 | }, 12 | }, 13 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/resolvers/templates/resolvers.js: -------------------------------------------------------------------------------- 1 | const resolvers = { 2 | multi: { 3 | name: '<%= listResolverName %>', 4 | resolver(root, {input = {}}, context, info) { 5 | // get selector and options from terms and perform Mongo query 6 | let { selector, options } = await Connectors.filter(collection, input, context); 7 | return { 8 | results: context.<%= collectionName %>.find(selector, options).fetch(); 9 | } 10 | }, 11 | }, 12 | single: { 13 | name: '<%= singleResolverName %>', 14 | resolver(root, { _id }, context) { 15 | const document = context.<%= collectionName %>.findOne({ _id }); 16 | const result = context.Users.restrictViewableFields( 17 | context.currentUser, 18 | context.<%= collectionName %>, 19 | document 20 | ); 21 | return { result } 22 | } 23 | } 24 | }; 25 | 26 | export default resolvers; 27 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/schema/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 14 | 15 | module.exports = function (_VulcanGenerator) { 16 | _inherits(_class, _VulcanGenerator); 17 | 18 | function _class() { 19 | _classCallCheck(this, _class); 20 | 21 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 22 | } 23 | 24 | _createClass(_class, [{ 25 | key: 'initializing', 26 | value: function initializing() { 27 | this._assert('isVulcan'); 28 | this._assert('hasNonZeroPackages'); 29 | } 30 | }, { 31 | key: '_registerArguments', 32 | value: function _registerArguments() { 33 | this._registerOptions('packageName', 'moduleName'); 34 | } 35 | }, { 36 | key: 'prompting', 37 | value: function prompting() { 38 | var _this2 = this; 39 | 40 | if (!this._canPrompt()) { 41 | return false; 42 | } 43 | var questions = this._getQuestions('packageNameWithNumModulesList', 'moduleNameList', 'isAddCustomSchemaProperty'); 44 | return this.prompt(questions).then(function (answers) { 45 | _this2.props = { 46 | packageName: _this2._finalize('packageName', answers), 47 | moduleName: _this2._finalize('moduleName', answers), 48 | isAddCustomSchemaProperty: _this2._finalize('raw', 'isAddCustomSchemaProperty', answers), 49 | customSchemaProperties: [] 50 | }; 51 | if (_this2.props.isAddCustomSchemaProperty) { 52 | return _this2._askCustomSchemaQuestion(); 53 | } 54 | }); 55 | } 56 | }, { 57 | key: '_askCustomSchemaQuestion', 58 | value: function _askCustomSchemaQuestion() { 59 | var _this3 = this; 60 | 61 | var customSchemaPropertyQuestions = this._getQuestions('schemaPropertyName', 'isSchemaPropertyHidden', 'schemaPropertyLabel', 'schemaPropertyType', 'isSchemaPropertyOptional', 'schemaPropertyViewableBy', 'schemaPropertyInsertableBy', 'schemaPropertyEditableBy', 'isAddAnotherCustomSchemaProperty'); 62 | return this.prompt(customSchemaPropertyQuestions).then(function (answers) { 63 | var customSchemaProperties = { 64 | name: _this3._finalize('raw', 'schemaPropertyName', answers), 65 | isHidden: _this3._finalize('raw', 'isSchemaPropertyHidden', answers), 66 | label: _this3._finalize('raw', 'schemaPropertyLabel', answers), 67 | type: _this3._finalize('raw', 'schemaPropertyType', answers), 68 | isOptional: _this3._finalize('raw', 'isSchemaPropertyOptional', answers), 69 | viewableBy: _this3._finalize('permissionTo', 'schemaPropertyViewableBy', answers), 70 | insertableBy: _this3._finalize('permissionTo', 'schemaPropertyInsertableBy', answers), 71 | editableBy: _this3._finalize('permissionTo', 'schemaPropertyEditableBy', answers) 72 | }; 73 | _this3.props.customSchemaProperties.push(customSchemaProperties); 74 | if (answers.isAddAnotherCustomSchemaProperty) { 75 | return _this3._askCustomSchemaQuestion(); 76 | } 77 | }); 78 | } 79 | }, { 80 | key: '_writeSchema', 81 | value: function _writeSchema() { 82 | this.fs.copyTpl(this.templatePath('schema.js'), this._getPath({ isAbsolute: true }, 'module', 'schema.js'), this.props); 83 | } 84 | }, { 85 | key: '_writeTestSchema', 86 | value: function _writeTestSchema() { 87 | var testFragmentsProps = _extends({}, this.props, { 88 | subjectName: 'schema', 89 | subjectPath: '../../../lib/modules/' + this.props.moduleName + '/schema' 90 | }); 91 | this.fs.copyTpl(this.templatePath('../../templates/generic-test.js'), this._getPath({ isAbsolute: true }, 'moduleTest', 'schema.spec.js'), testFragmentsProps); 92 | } 93 | }, { 94 | key: 'writing', 95 | value: function writing() { 96 | if (!this._canWrite()) { 97 | return; 98 | } 99 | this._writeSchema(); 100 | // this._writeTestSchema(); 101 | } 102 | }, { 103 | key: 'end', 104 | value: function end() { 105 | this._end(); 106 | } 107 | }]); 108 | 109 | return _class; 110 | }(VulcanGenerator); 111 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/schema/templates/partials/schemaProperty.js: -------------------------------------------------------------------------------- 1 | <%- name %> : { 2 | <% if (isHidden) { %> hidden: true <% } else { %> label: '<%= label %>' <% } %>, 3 | type: <%- type %>, 4 | optional: <%- isOptional %>, 5 | canRead: <%- viewableBy %>, 6 | canCreate: <%- insertableBy %>, 7 | canUpdate: <%- editableBy %>, 8 | }, 9 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/schema/templates/schema.js: -------------------------------------------------------------------------------- 1 | const schema = { 2 | // default properties 3 | 4 | _id: { 5 | type: String, 6 | optional: true, 7 | canRead: ['guests'], 8 | }, 9 | createdAt: { 10 | type: Date, 11 | optional: true, 12 | canRead: ['guests'], 13 | onCreate: ({ newDocument, currentUser}) => { 14 | return new Date(); 15 | } 16 | }, 17 | // userId: { 18 | // type: String, 19 | // optional: true, 20 | // canRead: ['guests'], 21 | // resolveAs: { 22 | // fieldName: 'user', 23 | // type: 'User', 24 | // resolver: (movie, args, context) => { 25 | // return context.Users.findOne({ _id: movie.userId }, { fields: context.Users.getViewableFields(context.currentUser, context.Users) }); 26 | // }, 27 | // addOriginalField: true 28 | // } 29 | // }, 30 | <% customSchemaProperties.forEach((schemaProperty) => { %> 31 | <%- include('./partials/schemaProperty.js', schemaProperty) %> 32 | <% }); %> 33 | }; 34 | 35 | export default schema; 36 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/templates/collection.js: -------------------------------------------------------------------------------- 1 | import { createCollection } from 'meteor/vulcan:core'; 2 | import schema from './schema.js'; 3 | import './fragments.js'; 4 | 5 | const <%= collectionName %> = createCollection({ 6 | collectionName: '<%= collectionName %>', 7 | typeName: '<%= typeName %>', 8 | schema, 9 | // resolvers: yourCustomResolvers // null to disable default resolvers generation 10 | // mutations: yourCustomMutations // null to disable default mutations generation 11 | permissions: { 12 | canRead: ['members'], 13 | canCreate: ['members'], 14 | canUpdate: ['owners', 'admins'], 15 | canDelete: ['owners', 'admins'] 16 | }, 17 | //callbacks: { 18 | // create: { 19 | // before: [] 20 | // } 21 | //}, 22 | //customFilters: [ 23 | // { 24 | // name: "_withRatings", 25 | // argument: "average: Int", 26 | // filter: ({ input, context, filterArguments }) => { 27 | // const { average } = filterArguments; 28 | // const { Reviews } = context; 29 | // // get all movies that have an average review score of X stars 30 | // const xStarReviewsMoviesIds = getMoviesByScore(average); 31 | // return { 32 | // selector: { _id: { $in: xStarReviewsMoviesIds } }, 33 | // options: {} 34 | // } 35 | // } 36 | // } 37 | //] 38 | 39 | }); 40 | 41 | 42 | 43 | export default <%= collectionName %>; 44 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/templates/generic-test.js: -------------------------------------------------------------------------------- 1 | import assert from 'assert'; 2 | import <%= subjectName %> from '<%= subjectPath %>'; 3 | 4 | describe('The <%= subjectName %> for: <%= moduleName %>', () => { 5 | it('should have some tests', () => { 6 | assert(false); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/module/templates/stories.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | storiesOf 4 | } from '@storybook/react'; 5 | 6 | storiesOf('<%= moduleName %>', module); 7 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/client.js: -------------------------------------------------------------------------------- 1 | import '../modules/index.js'; 2 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/collections.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/dist/generator-vulcanjs/generators/package/templates/collections.js -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/components.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/dist/generator-vulcanjs/generators/package/templates/components.js -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/modules.index.js: -------------------------------------------------------------------------------- 1 | import './collections.js'; 2 | import './routes'; 3 | import './components'; 4 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | name: '<%= packageName %>', 3 | }); 4 | 5 | Package.onUse((api) => { 6 | api.use([<%- vulcanDependencies.join(",\n"); %>]); 7 | 8 | api.mainModule('lib/server/main.js', 'server'); 9 | api.mainModule('lib/client/main.js', 'client'); 10 | }); 11 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/routes.js: -------------------------------------------------------------------------------- 1 | import { addRoute } from 'meteor/vulcan:core'; 2 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/seed.js: -------------------------------------------------------------------------------- 1 | import Users from 'meteor/vulcan:users'; 2 | import { createMutator } from 'meteor/vulcan:core'; 3 | 4 | const seedData = []; 5 | 6 | Meteor.startup(() => { 7 | // if (Users.find().count() === 0) { 8 | // createMutator({ 9 | // collection: Users, 10 | // document:{ 11 | // username: 'DemoUser', 12 | // email: 'dummyuser@gmail.com', 13 | // profile: { 14 | // isDummy: true 15 | // }, 16 | // } 17 | // }); 18 | // } 19 | }); 20 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/package/templates/server.js: -------------------------------------------------------------------------------- 1 | import '../modules'; 2 | import './seed'; 3 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/remove/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 6 | 7 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 8 | 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | 11 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 12 | 13 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 14 | 15 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 16 | var vulcanjsRemovableComponents = require('../../lib/common').vulcanjsRemovableComponents; 17 | 18 | module.exports = function (_VulcanGenerator) { 19 | _inherits(_class, _VulcanGenerator); 20 | 21 | function _class() { 22 | _classCallCheck(this, _class); 23 | 24 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 25 | } 26 | 27 | _createClass(_class, [{ 28 | key: 'initializing', 29 | value: function initializing() { 30 | this._assert('isVulcan'); 31 | this._assert('hasNonZeroPackages'); 32 | } 33 | }, { 34 | key: '_registerArguments', 35 | value: function _registerArguments() { 36 | this._registerOptions('vulcanjsRemovableComponent'); 37 | } 38 | }, { 39 | key: '_isComponentRemovable', 40 | value: function _isComponentRemovable() { 41 | return vulcanjsRemovableComponents.includes(this.options.vulcanjsComponent); 42 | } 43 | }, { 44 | key: 'prompting', 45 | value: function prompting() { 46 | var _this2 = this; 47 | 48 | if (!this._canPrompt()) { 49 | return false; 50 | } 51 | var questions = []; 52 | if (this._needArg('vulcanjsComponent') || !this._isComponentRemovable()) { 53 | questions = [].concat(_toConsumableArray(questions), _toConsumableArray(this._getQuestions('vulcanjsRemovableComponentsList'))); 54 | } 55 | return this.prompt(questions).then(function (answers) { 56 | _this2.props = { 57 | vulcanjsComponent: _this2._finalize('raw', 'vulcanjsComponent', answers) 58 | }; 59 | }); 60 | } 61 | }, { 62 | key: 'composing', 63 | value: function composing() { 64 | if (!this._canWrite()) { 65 | return false; 66 | } 67 | var remover = require.resolve('./removers/' + this.props.vulcanjsComponent); 68 | var nextOptions = _extends({}, this.options, this.props, { 69 | dontAsk: true 70 | }); 71 | return this.composeWith(remover, nextOptions); 72 | } 73 | }, { 74 | key: 'end', 75 | value: function end() { 76 | this._end(); 77 | } 78 | }]); 79 | 80 | return _class; 81 | }(VulcanGenerator); 82 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/remove/removers/module.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 8 | 9 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 10 | 11 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 12 | var ast = require('../../../lib/ast'); 13 | 14 | module.exports = function (_VulcanGenerator) { 15 | _inherits(_class, _VulcanGenerator); 16 | 17 | function _class() { 18 | _classCallCheck(this, _class); 19 | 20 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 21 | } 22 | 23 | _createClass(_class, [{ 24 | key: 'initializing', 25 | value: function initializing() { 26 | this._assert('isVulcan'); 27 | this._assert('hasNonZeroPackages'); 28 | } 29 | }, { 30 | key: '_registerArguments', 31 | value: function _registerArguments() { 32 | // TODO: add arguments for remove 33 | } 34 | }, { 35 | key: 'prompting', 36 | value: function prompting() { 37 | var _this2 = this; 38 | 39 | if (!this._canPrompt()) { 40 | return false; 41 | } 42 | var questions = this._getQuestions('packageNameWithNumModulesList', 'moduleNameList', 'isDelete'); 43 | return this.prompt(questions).then(function (answers) { 44 | _this2._assert('isDelete', answers.isDelete); 45 | _this2.props = { 46 | packageName: _this2._finalize('packageName', answers), 47 | moduleName: _this2._finalize('moduleName', answers) 48 | }; 49 | }); 50 | } 51 | }, { 52 | key: '_updateCollectionsIndex', 53 | value: function _updateCollectionsIndex() { 54 | var modulesCollectionsPath = this._getPath({ isAbsolute: true }, 'collectionsIndex'); 55 | var fileText = this.fs.read(collectionsIndexPath); 56 | var fileWithImportText = ast.removeImportStatement(fileText, './' + this.props.moduleName + '/collection.js'); 57 | this.fs.write(collectionsIndexPath, fileWithImportText); 58 | } 59 | }, { 60 | key: '_removeModuleDir', 61 | value: function _removeModuleDir() { 62 | var sourceDir = this._getPath({ isAbsolute: true }, 'module'); 63 | this.fs.delete(sourceDir); 64 | } 65 | }, { 66 | key: 'writing', 67 | value: function writing() { 68 | if (!this._canWrite()) { 69 | return false; 70 | } 71 | this._removeModuleDir(); 72 | this._updateCollectionsIndex(); 73 | } 74 | }, { 75 | key: 'end', 76 | value: function end() { 77 | this._end(); 78 | } 79 | }]); 80 | 81 | return _class; 82 | }(VulcanGenerator); 83 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/remove/removers/package.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 8 | 9 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 10 | 11 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 12 | 13 | module.exports = function (_VulcanGenerator) { 14 | _inherits(_class, _VulcanGenerator); 15 | 16 | function _class() { 17 | _classCallCheck(this, _class); 18 | 19 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 20 | } 21 | 22 | _createClass(_class, [{ 23 | key: 'initializing', 24 | value: function initializing() { 25 | this._assert('isVulcan'); 26 | this._assert('hasNonZeroPackages'); 27 | } 28 | }, { 29 | key: '_registerArguments', 30 | value: function _registerArguments() { 31 | // TODO: add arguments for remove 32 | } 33 | }, { 34 | key: 'prompting', 35 | value: function prompting() { 36 | var _this2 = this; 37 | 38 | if (!this._canPrompt()) { 39 | return false; 40 | } 41 | var questions = this._getQuestions('packageNameList', 'isDelete'); 42 | return this.prompt(questions).then(function (answers) { 43 | _this2._assert('isDelete', answers.isDelete); 44 | _this2.props = { 45 | packageName: _this2._finalize('packageName', answers) 46 | }; 47 | }); 48 | } 49 | }, { 50 | key: 'writing', 51 | value: function writing() { 52 | if (!this._canWrite()) { 53 | return false; 54 | } 55 | var sourceDir = this._getPath({ isAbsolute: true }, 'package'); 56 | this.fs.delete(sourceDir); 57 | } 58 | }, { 59 | key: 'end', 60 | value: function end() { 61 | this._end(); 62 | } 63 | }]); 64 | 65 | return _class; 66 | }(VulcanGenerator); 67 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/remove/removers/route.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 8 | 9 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 10 | 11 | var VulcanGenerator = require('../../../lib/VulcanGenerator'); 12 | var ast = require('../../../lib/ast'); 13 | 14 | module.exports = function (_VulcanGenerator) { 15 | _inherits(_class, _VulcanGenerator); 16 | 17 | function _class() { 18 | _classCallCheck(this, _class); 19 | 20 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 21 | } 22 | 23 | _createClass(_class, [{ 24 | key: 'initializing', 25 | value: function initializing() { 26 | this._assert('isVulcan'); 27 | this._assert('hasNonZeroPackages'); 28 | } 29 | }, { 30 | key: '_registerArguments', 31 | value: function _registerArguments() { 32 | // TODO: add arguments for remove 33 | } 34 | }, { 35 | key: 'prompting', 36 | value: function prompting() { 37 | var _this2 = this; 38 | 39 | if (!this._canPrompt()) { 40 | return false; 41 | } 42 | var questions = this._getQuestions('packageNameWithNumModulesList', 'routeNameList', 'isDelete'); 43 | return this.prompt(questions).then(function (answers) { 44 | _this2._assert('isDelete', answers.isDelete); 45 | _this2.props = { 46 | packageName: _this2._finalize('packageName', answers), 47 | routeName: _this2._finalize('raw', 'routeName', answers) 48 | }; 49 | }); 50 | } 51 | }, { 52 | key: '_updateRoutes', 53 | value: function _updateRoutes() { 54 | var routesPath = this._getPath({ isAbsolute: true }, 'routes'); 55 | var oldRoutes = this.fs.read(routesPath); 56 | var newRoutes = ast.removeRoute(oldRoutes, this.props.routeName); 57 | this.fs.write(routesPath, newRoutes); 58 | return true; 59 | } 60 | }, { 61 | key: 'writing', 62 | value: function writing() { 63 | if (!this._canWrite()) { 64 | return false; 65 | } 66 | this._updateRoutes(); 67 | } 68 | }, { 69 | key: 'end', 70 | value: function end() { 71 | this._end(); 72 | } 73 | }]); 74 | 75 | return _class; 76 | }(VulcanGenerator); 77 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/route/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 6 | 7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8 | 9 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 10 | 11 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 12 | 13 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 14 | var ast = require('../../lib/ast'); 15 | 16 | module.exports = function (_VulcanGenerator) { 17 | _inherits(_class, _VulcanGenerator); 18 | 19 | function _class() { 20 | _classCallCheck(this, _class); 21 | 22 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 23 | } 24 | 25 | _createClass(_class, [{ 26 | key: 'initializing', 27 | value: function initializing() { 28 | this._assert('isVulcan'); 29 | this._assert('hasNonZeroPackages'); 30 | } 31 | }, { 32 | key: '_registerArguments', 33 | value: function _registerArguments() { 34 | this._registerOptions('packageName', 'routeName', 'routePath', 'componentName', 'layoutName'); 35 | } 36 | }, { 37 | key: 'prompting', 38 | value: function prompting() { 39 | var _this2 = this; 40 | 41 | if (!this._canPrompt()) { 42 | return false; 43 | } 44 | var argsAndQuestions = [{ arg: 'packageName', question: 'packageNameList' }, { arg: 'routeName' }, { arg: 'routePath' }, { arg: 'componentName' }, { arg: 'layoutName' }]; 45 | var questions = argsAndQuestions.reduce(function (currentQuestions, _ref) { 46 | var arg = _ref.arg, 47 | question = _ref.question; 48 | 49 | if (_this2._needArg(arg)) { 50 | var questionName = question || arg; 51 | return [].concat(_toConsumableArray(currentQuestions), _toConsumableArray(_this2._getQuestions(questionName))); 52 | } 53 | return currentQuestions; 54 | }, []); 55 | return this.prompt(questions).then(function (answers) { 56 | _this2.props = { 57 | packageName: _this2._finalize('packageName', answers), 58 | componentName: _this2._finalize('componentName', answers), 59 | routeName: _this2._finalize('raw', 'routeName', answers), 60 | routePath: _this2._finalize('raw', 'routePath', answers), 61 | layoutName: _this2._finalize('raw', 'layoutName', answers), 62 | addRouteStatement: _this2._finalize('addRouteStatement', answers) 63 | }; 64 | }); 65 | } 66 | }, { 67 | key: '_updateRoutes', 68 | value: function _updateRoutes() { 69 | var routesPath = this._getPath({ isAbsolute: true }, 'routes'); 70 | 71 | var fileText = this.fs.read(routesPath); 72 | var fileTextWithWithImport = ast.appendCode(fileText, this.props.addRouteStatement); 73 | this.fs.write(routesPath, fileTextWithWithImport); 74 | } 75 | }, { 76 | key: 'configuring', 77 | value: function configuring() { 78 | if (!this._canConfigure()) {} 79 | } 80 | }, { 81 | key: 'writing', 82 | value: function writing() { 83 | if (!this._canWrite()) { 84 | return; 85 | } 86 | this._updateRoutes(); 87 | } 88 | }, { 89 | key: 'end', 90 | value: function end() { 91 | this._end(); 92 | } 93 | }]); 94 | 95 | return _class; 96 | }(VulcanGenerator); 97 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/generators/start/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 8 | 9 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 10 | 11 | var chalk = require('chalk'); 12 | var VulcanGenerator = require('../../lib/VulcanGenerator'); 13 | 14 | module.exports = function (_VulcanGenerator) { 15 | _inherits(_class, _VulcanGenerator); 16 | 17 | function _class() { 18 | _classCallCheck(this, _class); 19 | 20 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments)); 21 | } 22 | 23 | _createClass(_class, [{ 24 | key: 'default', 25 | value: function _default() { 26 | this.log(chalk.green('\nStarting your app... \n')); 27 | this.spawnCommandSync('meteor', ['run']); 28 | } 29 | }]); 30 | 31 | return _class; 32 | }(VulcanGenerator); 33 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/VulcanGenerator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 | 5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 | 7 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 8 | 9 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 10 | 11 | var Generator = require('yeoman-generator'); 12 | var beautify = require('gulp-beautify'); 13 | var questions = require('./questions'); 14 | var finalizers = require('./finalizers'); 15 | var makeAssertions = require('./assertions'); 16 | var storeFactory = require('./store'); 17 | var pathFinder = require('./path-finder'); 18 | var optionsManager = require('./optionsManager'); 19 | var chalk = require('chalk'); 20 | var gulpFilter = require('gulp-filter'); 21 | 22 | var store = void 0; 23 | var errors = void 0; 24 | module.exports = function (_Generator) { 25 | _inherits(VulcanGenerator, _Generator); 26 | 27 | function VulcanGenerator(args, options) { 28 | _classCallCheck(this, VulcanGenerator); 29 | 30 | var _this = _possibleConstructorReturn(this, (VulcanGenerator.__proto__ || Object.getPrototypeOf(VulcanGenerator)).call(this, args, options)); 31 | 32 | if (!store) { 33 | var allConfig = _this.config.getAll(); 34 | store = storeFactory.init(allConfig); 35 | } 36 | 37 | var assertions = makeAssertions.setup(_this); 38 | if (!errors) { 39 | errors = assertions.errors; 40 | } 41 | var beautified = beautify({ 42 | indent_size: 2, 43 | brace_style: 'collapse, preserve-inline' 44 | }); 45 | var jsxFilter = gulpFilter(['!**/*.jsx'], { restore: true }); 46 | _this.registerTransformStream([jsxFilter, beautified, jsxFilter.restore]); 47 | _this._assert = assertions.assert; 48 | _this._registerOptions = optionsManager.setup(_this); 49 | _this._finalize = finalizers.setup(_this); 50 | _this._getPath = pathFinder.setup(_this); 51 | _this._getQuestions = questions.setup(_this); 52 | _this._registerOptions('dontAsk'); 53 | _this._registerArguments(); 54 | _this.inputProps = {}; 55 | _this.props = {}; 56 | return _this; 57 | } 58 | 59 | /* 60 | Helper to test if a question is necessary 61 | */ 62 | 63 | 64 | _createClass(VulcanGenerator, [{ 65 | key: '_needArg', 66 | value: function _needArg(argument) { 67 | return typeof this.options[argument] === 'undefined'; 68 | } 69 | /* 70 | State management 71 | */ 72 | 73 | }, { 74 | key: '_commitStore', 75 | value: function _commitStore() { 76 | var _this2 = this; 77 | 78 | var storeKeys = Object.keys(store.getState()); 79 | storeKeys.forEach(function (key) { 80 | _this2.config.set(key, store.getState()[key]); 81 | }); 82 | } 83 | }, { 84 | key: '_dispatch', 85 | value: function _dispatch(action) { 86 | return store.dispatch(action); 87 | } 88 | 89 | /* 90 | Helpers that determine whether a task can be performed 91 | */ 92 | 93 | }, { 94 | key: '_canPrompt', 95 | value: function _canPrompt() { 96 | return this._hasNoErrors(); 97 | } 98 | }, { 99 | key: '_canWrite', 100 | value: function _canWrite() { 101 | return this._hasNoErrors(); 102 | } 103 | }, { 104 | key: '_canConfigure', 105 | value: function _canConfigure() { 106 | return this._hasNoErrors(); 107 | } 108 | }, { 109 | key: '_canInstall', 110 | value: function _canInstall() { 111 | return this._hasNoErrors(); 112 | } 113 | 114 | /* 115 | Error management 116 | */ 117 | 118 | }, { 119 | key: '_hasNoErrors', 120 | value: function _hasNoErrors() { 121 | var errorKeys = Object.keys(errors); 122 | return errorKeys.length === 0; 123 | } 124 | }, { 125 | key: '_logAllErrors', 126 | value: function _logAllErrors() { 127 | var _this3 = this; 128 | 129 | var errorKeys = Object.keys(errors); 130 | var errorsArr = errorKeys.map(function (errorKey) { 131 | return errors[errorKey]; 132 | }); 133 | errorsArr.forEach(function (error, index) { 134 | var errorNo = 'Error (' + index + ')'; 135 | var message = '\n' + errorNo + ': ' + chalk.red(error.message); 136 | _this3.log(message); 137 | // this.env.error(message); 138 | }); 139 | process.exit(1); 140 | } 141 | 142 | /* 143 | Life-cycle functions 144 | */ 145 | 146 | }, { 147 | key: '_end', 148 | value: function _end() { 149 | if (!this._hasNoErrors) { 150 | this._logAllErrors(); 151 | } 152 | } 153 | }, { 154 | key: '_registerArguments', 155 | value: function _registerArguments() {} 156 | }]); 157 | 158 | return VulcanGenerator; 159 | }(Generator); 160 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/assertions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var uiText = require('./ui-text'); 4 | var makeLister = require('./lister'); 5 | 6 | var errors = {}; 7 | 8 | function setup(generatorSetup) { 9 | var generator = generatorSetup; 10 | var lister = makeLister.setup(generator); 11 | 12 | function assert(assertion) { 13 | function isVulcan() { 14 | // TODO: not imlemented yet 15 | // Idea: check for a package.json file? 16 | // if (!store.is('vulcan')) { 17 | // errors.notVulcan = { 18 | // message: uiText.errors.notVulcan, 19 | // }; 20 | // } 21 | } 22 | 23 | function notVulcan() { 24 | // if (store.is('vulcan')) { 25 | // errors.isVulcan = { 26 | // message: uiText.errors.isVulcan, 27 | // }; 28 | // } 29 | } 30 | 31 | function isPackageExists(packageName) { 32 | if (!lister.packageExists(packageName)) { 33 | errors.notPackageExists = { 34 | message: uiText.errors.notPackageExists(packageName) 35 | }; 36 | } 37 | } 38 | 39 | function notPackageExists(packageName) { 40 | if (lister.packageExists(packageName)) { 41 | errors.isPackageExists = { 42 | message: uiText.errors.isPackageExists(packageName) 43 | }; 44 | } 45 | } 46 | 47 | function isModuleExists(packageName, moduleName) { 48 | if (!lister.moduleExists(packageName, moduleName)) { 49 | errors.notModuleExists = { 50 | message: uiText.errors.notModuleExists(packageName, moduleName) 51 | }; 52 | } 53 | } 54 | 55 | function notModuleExists(packageName, moduleName) { 56 | if (lister.moduleExists(packageName, moduleName)) { 57 | errors.isModuleExists = { 58 | message: uiText.errors.isModuleExists(packageName, moduleName) 59 | }; 60 | } 61 | } 62 | 63 | function hasNonZeroPackages() { 64 | var packageNames = lister.listPackages(); 65 | if (!packageNames.length) { 66 | errors.isZeroPackages = { 67 | message: uiText.errors.isZeroPackages 68 | }; 69 | } 70 | } 71 | 72 | function packageHasNonZeroModules(packageName) { 73 | this._assertIsPackageExists(packageName); 74 | if (!this._packageHasNonZeroModules(packageName)) { 75 | errors.hasZeroModules = { 76 | message: uiText.errors.hasZeroModules(packageName) 77 | }; 78 | } 79 | } 80 | 81 | function isDelete(isDeleting) { 82 | if (!isDeleting) { 83 | errors.hasZeroModules = { 84 | message: uiText.errors.isDelete 85 | }; 86 | } 87 | } 88 | 89 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 90 | args[_key - 1] = arguments[_key]; 91 | } 92 | 93 | switch (assertion) { 94 | case 'isVulcan': 95 | return isVulcan.apply(undefined, args); 96 | case 'isDelete': 97 | return isDelete.apply(undefined, args); 98 | case 'notVulcan': 99 | return notVulcan.apply(undefined, args); 100 | case 'isPackageExists': 101 | return isPackageExists.apply(undefined, args); 102 | case 'notPackageExists': 103 | return notPackageExists.apply(undefined, args); 104 | case 'isModuleExists': 105 | return isModuleExists.apply(undefined, args); 106 | case 'notModuleExists': 107 | return notModuleExists.apply(undefined, args); 108 | case 'hasNonZeroPackages': 109 | return hasNonZeroPackages.apply(undefined, args); 110 | case 'packageHasNonZeroModules': 111 | return packageHasNonZeroModules.apply(undefined, args); 112 | default: 113 | return undefined; 114 | } 115 | } 116 | return { assert: assert, errors: errors }; 117 | } 118 | 119 | module.exports = { 120 | setup: setup 121 | }; 122 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/ast.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 4 | 5 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 6 | 7 | var esprima = require('esprima'); 8 | var escodegen = require('escodegen-wallaby'); 9 | var find = require('lodash/find'); 10 | 11 | var getLastImportIndex = function getLastImportIndex(tree) { 12 | var lastIndex = -1; 13 | tree.body.forEach(function (node, index) { 14 | if (node.type === 'ImportDeclaration') { 15 | lastIndex = index; 16 | } 17 | }); 18 | return lastIndex; 19 | }; 20 | 21 | var parseAst = function parseAst(text) { 22 | return esprima.parseModule(text, { 23 | range: true, 24 | tokens: true, 25 | comment: true 26 | }); 27 | }; 28 | 29 | var generateCode = function generateCode(ast) { 30 | var astWithComments = escodegen.attachComments(ast, ast.comments, ast.tokens); 31 | return escodegen.generate(astWithComments, { 32 | comment: true, 33 | format: { index: { style: ' ' } } 34 | }); 35 | }; 36 | 37 | var parseModifyGenerate = function parseModifyGenerate(modifier) { 38 | return function (text) { 39 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 40 | args[_key - 1] = arguments[_key]; 41 | } 42 | 43 | var ast = parseAst(text); 44 | var newAst = modifier.apply(undefined, [ast].concat(args)); 45 | var generated = generateCode(newAst); 46 | return generated; 47 | }; 48 | }; 49 | 50 | var getImportStatement = function getImportStatement(importPath) { 51 | return 'import \'' + importPath + '\';'; 52 | }; 53 | 54 | var addImportStatement = function addImportStatement(tree, importPath) { 55 | var newTree = _extends({}, tree); 56 | var nextImportIndex = getLastImportIndex(tree) + 1; 57 | var statement = getImportStatement(importPath); 58 | var importNode = esprima.parseModule(statement); 59 | newTree.body = [].concat(_toConsumableArray([].concat(_toConsumableArray(tree.body)).slice(0, nextImportIndex)), [importNode.body[0]], _toConsumableArray([].concat(_toConsumableArray(tree.body)).slice(nextImportIndex, newTree.body.length))); 60 | return newTree; 61 | }; 62 | 63 | var appendCode = function appendCode(tree, code) { 64 | var newTree = _extends({}, tree); 65 | var newCodeAst = parseAst(code); 66 | var codeToPush = newCodeAst.body[0]; 67 | newTree.body.push(codeToPush); 68 | return newTree; 69 | }; 70 | 71 | var removeRoute = function removeRoute(tree, routeToRemove) { 72 | var newTree = _extends({}, tree); 73 | newTree.body = tree.body.filter(function (node) { 74 | if (node.type !== 'ExpressionStatement') return true; 75 | if (!node.expression) return true; 76 | var expression = node.expression; 77 | if (!expression.callee) return true; 78 | if (expression.callee.name !== 'addRoute') return true; 79 | var args = node.expression.arguments; 80 | // console.log(JSON.stringify(args, null, 2)); 81 | if (!args) return true; 82 | var properties = args[0].properties; 83 | if (!properties) return true; 84 | var namePropOfRoute = find(properties, { 85 | type: 'Property', 86 | key: { 87 | type: 'Identifier', 88 | name: 'name' 89 | } 90 | }); 91 | if (!namePropOfRoute.value) return true; 92 | if (!namePropOfRoute.value.value) return true; 93 | return namePropOfRoute.value.value !== routeToRemove; 94 | }); 95 | return newTree; 96 | }; 97 | 98 | var removeImportStatement = function removeImportStatement(tree, importPath) { 99 | var newTree = _extends({}, tree); 100 | newTree.body = tree.body.filter(function (node) { 101 | if (node.type !== 'ImportDeclaration') return true; 102 | var source = node.source; 103 | if (!source) return true; 104 | if (source.type !== 'Literal') return true; 105 | return source.value !== importPath; 106 | }); 107 | return newTree; 108 | }; 109 | 110 | module.exports = { 111 | getLastImportIndex: getLastImportIndex, 112 | addImportStatement: parseModifyGenerate(addImportStatement), 113 | appendCode: parseModifyGenerate(appendCode), 114 | removeRoute: parseModifyGenerate(removeRoute), 115 | removeImportStatement: parseModifyGenerate(removeImportStatement) 116 | }; 117 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/common.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var alphabeticalSort = function alphabeticalSort(a, b) { 4 | var aLower = a.toLowerCase(); 5 | var bLower = b.toLowerCase(); 6 | if (aLower < bLower) return -1; 7 | if (aLower > bLower) return 1; 8 | return 0; 9 | }; 10 | 11 | var numModulesSort = function numModulesSort(a, b) { 12 | var aHasNonZero = a.numModules > 0; 13 | var bHasNonZero = b.numModules > 0; 14 | if (aHasNonZero && bHasNonZero) return 0; 15 | if (!aHasNonZero && !bHasNonZero) return 0; 16 | if (!aHasNonZero && bHasNonZero) return 1; 17 | /* if (aHasNonZero && !bHasNonZero) */return -1; 18 | }; 19 | 20 | var getSetFromArr = function getSetFromArr(arr) { 21 | var set = {}; 22 | arr.forEach(function (elem) { 23 | set[elem] = true; 24 | }); 25 | return set; 26 | }; 27 | 28 | var reactExtensions = ['jsx', 'js']; 29 | 30 | var cloningOptions = ['fast', 'complete']; 31 | 32 | var packageManagers = ['yarn', 'npm']; 33 | 34 | var visitorTypes = ['Guests', 'Members', 'Admins']; 35 | 36 | var schemaPropertyTypes = ['String', 'Number', 'Boolean', 'Array', 'Object', 'Custom']; 37 | 38 | var moduleParts = ['fragments', 'resolvers', 'mutations', 'schema']; 39 | 40 | var vulcanjsRemovableComponents = ['route', 'module', 'package']; 41 | 42 | var vulcanjsListableComponents = ['packages']; 43 | 44 | var allChoiceValue = '__vjs_all'; 45 | var allChoice = { name: '[ALL]', value: allChoiceValue }; 46 | 47 | var getDefaultChoiceIndex = function getDefaultChoiceIndex(choices, option) { 48 | var index = choices.findIndex(function (elem) { 49 | return elem === option; 50 | }); 51 | return Math.max(index, 0); 52 | }; 53 | 54 | var exposed = { 55 | alphabeticalSort: alphabeticalSort, 56 | numModulesSort: numModulesSort, 57 | reactExtensions: reactExtensions, 58 | packageManagers: packageManagers, 59 | visitorTypes: visitorTypes, 60 | schemaPropertyTypes: schemaPropertyTypes, 61 | getDefaultChoiceIndex: getDefaultChoiceIndex, 62 | getSetFromArr: getSetFromArr, 63 | vulcanjsRemovableComponents: vulcanjsRemovableComponents, 64 | vulcanjsListableComponents: vulcanjsListableComponents, 65 | moduleParts: moduleParts, 66 | allChoiceValue: allChoiceValue, 67 | allChoice: allChoice, 68 | cloningOptions: cloningOptions 69 | }; 70 | 71 | module.exports = exposed; 72 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/filters.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var dashify = require('dashify'); 4 | var camelCase = require('camelcase'); 5 | var pascalCase = require('pascal-case'); 6 | 7 | function packageName(toFilter) { 8 | return dashify(toFilter); 9 | } 10 | 11 | function appName(toFilter) { 12 | return dashify(toFilter); 13 | } 14 | 15 | function moduleName(toFilter) { 16 | return camelCase(toFilter); 17 | } 18 | 19 | function componentName(toFilter) { 20 | return pascalCase(toFilter); 21 | } 22 | 23 | function filter(filterType, toFilter) { 24 | switch (filterType) { 25 | case 'packageName': 26 | return packageName(toFilter); 27 | case 'appName': 28 | return appName(toFilter); 29 | case 'moduleName': 30 | return moduleName(toFilter); 31 | case 'componentName': 32 | return componentName(toFilter); 33 | default: 34 | return toFilter; 35 | } 36 | } 37 | 38 | module.exports = { 39 | filter: filter 40 | }; 41 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/lister.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 4 | 5 | /** 6 | * List and count elements of the application (packages, modules, routes etc.) 7 | */ 8 | var fs = require('fs'); 9 | var path = require('path'); 10 | var pathFinder = require('./path-finder'); 11 | var chalk = require('chalk'); 12 | 13 | function isDirectory(dirPath) { 14 | return fs.lstatSync(dirPath).isDirectory(); 15 | } 16 | function isNotPrivate(dirName) { 17 | return !/^_/.test(dirName); 18 | } 19 | function listFolders(dirPath) { 20 | try { 21 | var folderContent = fs.readdirSync(dirPath); 22 | var folders = folderContent.filter(function (folderName) { 23 | return isDirectory(path.join(dirPath, folderName)); 24 | }); 25 | var validFolders = folders.filter(isNotPrivate); 26 | return validFolders; 27 | } catch (err) { 28 | console.log(chalk.red('Could not find or open folder ' + dirPath)); 29 | console.log(err); 30 | return []; 31 | } 32 | } 33 | 34 | function setup(generatorSetup) { 35 | var getPath = pathFinder.setup(generatorSetup); 36 | 37 | function listPackages() { 38 | var appPackagesPath = getPath({ isAbsolute: true }, 'packages'); 39 | var folders = listFolders(appPackagesPath); 40 | return folders; 41 | } 42 | function listModules(pkgName) { 43 | var packageModulesPath = pathFinder.findModules(generatorSetup, { isAbsolute: true }, pkgName); 44 | return listFolders(packageModulesPath); 45 | } 46 | function listAllModules() { 47 | var packageNames = listPackages(); 48 | return packageNames.reduce(function (allModules, packageName) { 49 | return [].concat(_toConsumableArray(allModules), _toConsumableArray(listModules(packageName))); 50 | }, []); 51 | } 52 | function listPackagesWithNbModules() { 53 | var packages = listPackages(); 54 | return packages.map(function (pkgName) { 55 | return { 56 | name: pkgName, 57 | numModules: listFolders(pathFinder.findModules(generatorSetup, { isAbsolute: true }, pkgName)) 58 | }; 59 | }); 60 | } 61 | 62 | function countRoutes(pkgName) { 63 | var packageRoutesPath = pathFinder.findRoutes(generatorSetup, { isAbsolute: true }, pkgName); 64 | // TODO: handle errors if the filename has been modified 65 | try { 66 | var fileContent = fs.readFileSync(packageRoutesPath, { encoding: 'utf-8' }); 67 | var routesCount = (fileContent.match(/addRoute\(/g) || []).length; 68 | return routesCount; 69 | } catch (err) { 70 | console.log(chalk.red('Could not find or open routes definition for package ' + pkgName)); 71 | console.log(err); 72 | return -1; 73 | } 74 | } 75 | function countModules(pkgName) { 76 | return listModules(pkgName).length; 77 | } 78 | 79 | function packageExists(pkgName) { 80 | var packageNames = listPackages(); 81 | return packageNames.includes(pkgName); 82 | } 83 | 84 | function moduleExists(pkgName, moduleName) { 85 | var moduleNames = listModules(pkgName); 86 | return moduleNames.includes(moduleName); 87 | } 88 | 89 | return { 90 | listModules: listModules, 91 | listAllModules: listAllModules, 92 | listPackages: listPackages, 93 | listPackagesWithNbModules: listPackagesWithNbModules, 94 | countRoutes: countRoutes, 95 | countModules: countModules, 96 | packageExists: packageExists, 97 | moduleExists: moduleExists 98 | }; 99 | } 100 | 101 | module.exports = { setup: setup }; 102 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/optionsManager.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var uiText = require('./ui-text'); 4 | 5 | var allOptions = { 6 | appName: { 7 | type: String, 8 | required: false, 9 | alias: 'n', 10 | desc: uiText.descriptions.appName 11 | }, 12 | packageName: { 13 | type: String, 14 | required: false, 15 | alias: 'p', 16 | desc: uiText.descriptions.packageName 17 | }, 18 | moduleName: { 19 | type: String, 20 | required: false, 21 | alias: 'm', 22 | desc: uiText.descriptions.moduleName 23 | }, 24 | componentName: { 25 | type: String, 26 | required: false, 27 | alias: 'c', 28 | desc: uiText.descriptions.componentName 29 | }, 30 | layoutName: { 31 | type: String, 32 | required: false, 33 | alias: 'l', 34 | desc: uiText.descriptions.layoutName 35 | }, 36 | routeName: { 37 | type: String, 38 | required: false, 39 | alias: 'r', 40 | desc: uiText.descriptions.routeName 41 | }, 42 | routePath: { 43 | type: String, 44 | required: false, 45 | alias: 'rp', 46 | desc: uiText.descriptions.routePath 47 | }, 48 | packageManager: { 49 | type: String, 50 | required: false, 51 | alias: 'pm', 52 | desc: uiText.descriptions.packageManager 53 | }, 54 | dontAsk: { 55 | type: Boolean, 56 | required: false, 57 | alias: 'd', 58 | desc: uiText.descriptions.dontAsk 59 | }, 60 | vulcanjsRemovableComponent: { 61 | type: String, 62 | required: false, 63 | alias: 'vc', 64 | desc: uiText.descriptions.vulcanjsRemovableComponent 65 | }, 66 | vulcanjsListableComponent: { 67 | type: String, 68 | required: false, 69 | alias: 'vc', 70 | desc: uiText.descriptions.vulcanjsListableComponent 71 | } 72 | }; 73 | 74 | function setup(generatorSetup) { 75 | var generator = generatorSetup; 76 | function registerSingleOption(optionName) { 77 | generator.option(optionName, allOptions[optionName]); 78 | } 79 | function register() { 80 | for (var _len = arguments.length, optionNames = Array(_len), _key = 0; _key < _len; _key++) { 81 | optionNames[_key] = arguments[_key]; 82 | } 83 | 84 | optionNames.forEach(function (optionName) { 85 | registerSingleOption(optionName); 86 | }); 87 | } 88 | return register; 89 | } 90 | 91 | module.exports = { 92 | setup: setup, 93 | allOptions: allOptions 94 | }; 95 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/reducers.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Redux = require('redux'); 4 | var _ = require('lodash'); 5 | 6 | var appName = function appName() { 7 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 8 | var action = arguments[1]; 9 | 10 | switch (action.type) { 11 | case 'SET_APP_NAME': 12 | return action.appName; 13 | default: 14 | return state; 15 | } 16 | }; 17 | 18 | var isVulcan = function isVulcan() { 19 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 20 | var action = arguments[1]; 21 | 22 | switch (action.type) { 23 | case 'SET_IS_VULCAN_TRUE': 24 | return true; 25 | default: 26 | return state; 27 | } 28 | }; 29 | 30 | var packageManager = function packageManager() { 31 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'yarn'; 32 | var action = arguments[1]; 33 | 34 | switch (action.type) { 35 | case 'SET_PACKAGE_MANAGER': 36 | return action.packageManager; 37 | default: 38 | return state; 39 | } 40 | }; 41 | 42 | var reactExtension = function reactExtension() { 43 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'jsx'; 44 | var action = arguments[1]; 45 | 46 | switch (action.type) { 47 | case 'SET_REACT_EXTENSION': 48 | return action.reactExtension; 49 | default: 50 | return state; 51 | } 52 | }; 53 | 54 | var reducers = Redux.combineReducers({ 55 | appName: appName, 56 | isVulcan: isVulcan, 57 | packageManager: packageManager, 58 | reactExtension: reactExtension 59 | }); 60 | 61 | module.exports = reducers; 62 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/repairs.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var generator = void 0; 4 | 5 | function setup(generatorSetup) { 6 | generator = generatorSetup; 7 | } 8 | 9 | function repair(answers) {} 10 | 11 | module.exports = { 12 | setup: setup, 13 | repair: repair 14 | }; 15 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/store.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Redux = require('redux'); 4 | var logger = require('redux-node-logger'); 5 | var reducers = require('./reducers'); 6 | var filter = require('./filters').filter; 7 | var common = require('./common'); 8 | 9 | var store = {}; 10 | 11 | function init(savedState) { 12 | if (process.env.VULCANJS_SEE_REDUX_LOGS) { 13 | store = Redux.createStore(reducers, savedState, Redux.applyMiddleware(logger())); 14 | } else { 15 | store = Redux.createStore(reducers, savedState); 16 | } 17 | return store; 18 | } 19 | 20 | function is(checkType) { 21 | function vulcan() { 22 | return !!store.getState().isVulcan; 23 | } 24 | 25 | function packageExists(packageName) { 26 | var filteredPackageName = filter('packageName', packageName); 27 | return !!store.getState().packages[filteredPackageName]; 28 | } 29 | 30 | function moduleExists(packageName, moduleName) { 31 | var filteredModuleName = filter('moduleName', moduleName); 32 | return packageExists(packageName) && !!store.getState().packages[packageName].modules[filteredModuleName]; 33 | } 34 | 35 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 36 | args[_key - 1] = arguments[_key]; 37 | } 38 | 39 | switch (checkType) { 40 | case 'packageExists': 41 | return packageExists.apply(undefined, args); 42 | case 'moduleExists': 43 | return moduleExists.apply(undefined, args); 44 | case 'vulcan': 45 | return vulcan.apply(undefined, args); 46 | default: 47 | return undefined; 48 | } 49 | } 50 | 51 | function get(checkType) { 52 | function reactExtension() { 53 | return store.getState().reactExtension; 54 | } 55 | 56 | function packageNames() { 57 | var packages = store.getState().packages; 58 | var packageNamesToGet = Object.keys(packages); 59 | return packageNamesToGet.sort(common.alphabeticalSort); 60 | } 61 | 62 | function getPackage(packageName) { 63 | return store.getState().packages[packageName]; 64 | } 65 | 66 | function moduleNames(packageName) { 67 | var thePackage = getPackage(packageName); 68 | var modules = is('packageExists', packageName) ? thePackage.modules : {}; 69 | var moduleNamesToGet = Object.keys(modules); 70 | return moduleNamesToGet.sort(common.alphabeticalSort); 71 | } 72 | 73 | function packageNamesWithNumModules() { 74 | var packageNamesList = packageNames(); 75 | var packageNamesWithModules = packageNamesList.map(function (packageName) { 76 | return { 77 | name: packageName, 78 | numModules: moduleNames(packageName).length 79 | }; 80 | }); 81 | return packageNamesWithModules; 82 | } 83 | 84 | function routeNames(packageName) { 85 | var thePackage = getPackage(packageName); 86 | var theRoutes = thePackage.routes; 87 | var routeNamesToGet = Object.keys(theRoutes); 88 | return routeNamesToGet.sort(common.alphabeticalSort); 89 | } 90 | 91 | function getRoutes(packageName) { 92 | var thePackage = getPackage(packageName); 93 | var theRoutes = thePackage.routes; 94 | return routeNames(packageName).map(function (routeName) { 95 | return { 96 | name: routeName, 97 | content: theRoutes[routeName] 98 | }; 99 | }); 100 | } 101 | 102 | for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 103 | args[_key2 - 1] = arguments[_key2]; 104 | } 105 | 106 | switch (checkType) { 107 | case 'reactExtension': 108 | return reactExtension.apply(undefined, args); 109 | case 'packageNames': 110 | return packageNames.apply(undefined, args); 111 | case 'moduleNames': 112 | return moduleNames.apply(undefined, args); 113 | case 'routeNames': 114 | return routeNames.apply(undefined, args); 115 | case 'package': 116 | return getPackage.apply(undefined, args); 117 | case 'routes': 118 | return getRoutes.apply(undefined, args); 119 | case 'packageNamesWithNumModules': 120 | return packageNamesWithNumModules.apply(undefined, args); 121 | default: 122 | return undefined; 123 | } 124 | } 125 | 126 | function num(checkType) { 127 | function routes(packageName) { 128 | var routeNames = get('routeNames', packageName); 129 | return routeNames.length; 130 | } 131 | 132 | function modules(packageName) { 133 | var moduleNames = get('moduleNames', packageName); 134 | return moduleNames.length; 135 | } 136 | 137 | for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { 138 | args[_key3 - 1] = arguments[_key3]; 139 | } 140 | 141 | switch (checkType) { 142 | case 'routes': 143 | return routes.apply(undefined, args); 144 | case 'modules': 145 | return modules.apply(undefined, args); 146 | default: 147 | return undefined; 148 | } 149 | } 150 | 151 | function has(checkType) { 152 | function nonZeroPackages() { 153 | var packageNames = get('packageNames'); 154 | return Object.keys(packageNames).length > 0; 155 | } 156 | 157 | function nonZeroModulesInPackage(packageName) { 158 | if (!this._isPackageExists(packageName)) return false; 159 | var thePackage = this._getPackage(packageName); 160 | var moduleNames = Object.keys(thePackage.modules); 161 | return moduleNames.length > 0; 162 | } 163 | 164 | for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { 165 | args[_key4 - 1] = arguments[_key4]; 166 | } 167 | 168 | switch (checkType) { 169 | case 'nonZeroModulesInPackage': 170 | return nonZeroModulesInPackage.apply(undefined, args); 171 | case 'nonZeroPackages': 172 | return nonZeroPackages.apply(undefined, args); 173 | default: 174 | return undefined; 175 | } 176 | } 177 | 178 | module.exports = { 179 | init: init, 180 | is: is, 181 | has: has, 182 | get: get, 183 | num: num 184 | }; 185 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/styles.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var chalk = require('chalk'); 4 | 5 | module.exports = { 6 | h1: chalk.green 7 | }; 8 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/ui-text.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var chalk = require('chalk'); 4 | 5 | var descriptions = { 6 | appName: 'The name of your app', 7 | reactExtension: 'Default react component extension', 8 | packageManager: 'Preferred package manager', 9 | packageName: 'The name of the package', 10 | moduleName: 'The name of the module', 11 | componentName: 'The name of your component', 12 | routeName: 'The name of your route', 13 | routePath: 'The path of your route', 14 | layoutName: 'The layout that will wrap this route\'s component', 15 | isRegisterComponent: 'Set to true of you want to register the component to Vulcan.', 16 | isAddComponentToStoryBook: 'Set to true of you want to add the component to storybook.', 17 | componentType: 'The type of the component. Is it a pure function, or a class?', 18 | vulcanDependencies: 'The vulcan packages that your application depends on', 19 | isPackageAutoAdd: 'Set to true if you want your package to be added to .meteor/packages', 20 | dontAsk: 'Set to true if you want the generators to skip prompting for the arguments you have supplied from the command line', 21 | vulcanjsRemovableComponent: 'The part of the app that you want to remove', 22 | vulcanjsListableComponent: 'The part of the app that you want to list' 23 | }; 24 | 25 | var messages = { 26 | appName: 'App name', 27 | reactExtension: 'React extension', 28 | packageManager: 'Package manager', 29 | packageName: 'Package name', 30 | moduleName: 'Module name', 31 | componentName: 'Component name', 32 | isRegisterComponent: 'Register component', 33 | componentType: 'Component type', 34 | routeName: 'Route name', 35 | routePath: 'Route path', 36 | layoutName: 'Layout name', 37 | vulcanDependencies: 'Vulcan dependencies', 38 | isPackageAutoAdd: 'Add to .meteor/packages', 39 | storyBookSetupStatus: 'Looks like you havent set up your react storybook. Would you like to do it now?', 40 | isAddComponentToStoryBook: 'Add component to storybook', 41 | isAddCustomSchemaProperty: 'Add a custom property to the collection', 42 | isAddCustomMutations: 'Add custom mutations', 43 | isAddCustomResolvers: 'Add custom resolvers', 44 | isAddAnotherCustomSchemaProperty: 'Add another custom property to the collection', 45 | schemaPropertyName: 'Property name', 46 | isSchemaPropertyHidden: 'Property is hidden', 47 | schemaPropertyLabel: 'Property label', 48 | schemaPropertyType: 'Property type', 49 | isSchemaPropertyOptional: 'Property is optional', 50 | schemaPropertyViewableBy: 'Property viewable by', 51 | schemaPropertyInsertableBy: 'Property insertable by', 52 | schemaPropertyEditableBy: 'Property editable by', 53 | vulcanjsRemovableComponents: 'Part to remove', 54 | vulcanjsListableComponents: 'Part to list', 55 | isDelete: chalk.red('WARNING:') + ' You are about to destroy some code. Have you committed your code?' 56 | }; 57 | 58 | var errors = { 59 | notVulcan: 'This is not a Vulcan.js project directory. \nYou cannot run Vulcan.js generators outside of a Vulcan.js project directory.', 60 | isVulcan: 'You are already in a Vulcan.js project directory. \nYou may not run this command inside a Vulcan.js project directory.', 61 | notPackageExists: function notPackageExists(packageName) { 62 | return 'The package ' + packageName + ' does not exist. \nIf you\'d like to work on this package, you should create it first by running: ' + chalk.green('vulcan g package ' + packageName); 63 | }, 64 | isPackageExists: function isPackageExists(packageName) { 65 | return 'A package with the name: \'' + packageName + '\' already exists.'; 66 | }, 67 | notModuleExists: function notModuleExists(packageName, moduleName) { 68 | return 'A module with the name: \'' + moduleName + '\' under the package \'' + packageName + '\' does not exist. \nIf you\'d like to work on this module, you should first run ' + chalk.green('vulcan g module ' + packageName + ' ' + moduleName) + '.'; 69 | }, 70 | isModuleExists: function isModuleExists(packageName, moduleName) { 71 | return 'A module with the name \'' + moduleName + '\' under the package \'' + packageName + '\' already exists.'; 72 | }, 73 | isZeroPackages: 'The command you just ran requires at least 1 custom package to be present in your app. \nTo create a package, run ' + chalk.green('vulcan g package'), 74 | hasZeroModules: function hasZeroModules(packageName) { 75 | return 'The package \'' + packageName + ' has no modules.)}'; 76 | }, 77 | isEmpty: 'This cannot be empty.', 78 | isDelete: 'Cannot delete uncommitted code' 79 | }; 80 | 81 | module.exports = { 82 | descriptions: descriptions, 83 | messages: messages, 84 | errors: errors 85 | }; 86 | -------------------------------------------------------------------------------- /dist/generator-vulcanjs/lib/validations.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var uiText = require('./ui-text'); 4 | var makeLister = require('./lister'); 5 | 6 | function combineValidators() { 7 | for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { 8 | fns[_key] = arguments[_key]; 9 | } 10 | 11 | return function reducedValidator(input) { 12 | return fns.reduce(function (acc, curValidator) { 13 | if (typeof acc === 'string') return acc; 14 | return curValidator(input); 15 | }, true); 16 | }; 17 | } 18 | 19 | function setup(generatorSetup) { 20 | var generator = generatorSetup; 21 | var lister = makeLister.setup(generator); 22 | 23 | var assertNonEmpty = function assertNonEmpty(input) { 24 | if (input) return true; 25 | return uiText.errors.isEmpty; 26 | }; 27 | 28 | var assertNotPackageExists = function assertNotPackageExists(packageName) { 29 | if (!lister.packageExists(packageName)) return true; 30 | return uiText.errors.isPackageExists(packageName); 31 | }; 32 | 33 | var assertNotModuleExists = function assertNotModuleExists(packageName, moduleName) { 34 | if (!lister.moduleExists(packageName, moduleName)) return true; 35 | return uiText.errors.isModuleExists(packageName, moduleName); 36 | }; 37 | 38 | var generateNotModuleExists = function generateNotModuleExists(packageName) { 39 | return function (input) { 40 | return assertNotModuleExists(packageName, input); 41 | }; 42 | }; 43 | return { 44 | assertNonEmpty: assertNonEmpty, 45 | assertNotPackageExists: assertNotPackageExists, 46 | assertNotModuleExists: assertNotModuleExists, 47 | generateNotModuleExists: generateNotModuleExists 48 | }; 49 | } 50 | 51 | module.exports = { 52 | combineValidators: combineValidators, 53 | setup: setup 54 | }; 55 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | var yeoman = require('yeoman-environment'); 5 | var parseArgs = require('minimist'); 6 | 7 | var argsManager = require('./argsManager'); 8 | 9 | var appGenerator = require.resolve('./generator-vulcanjs/generators/app'); 10 | var packageGenerator = require.resolve('./generator-vulcanjs/generators/package'); 11 | var moduleGenerator = require.resolve('./generator-vulcanjs/generators/module'); 12 | var componentGenerator = require.resolve('./generator-vulcanjs/generators/component'); 13 | var routeGenerator = require.resolve('./generator-vulcanjs/generators/route'); 14 | var remover = require.resolve('./generator-vulcanjs/generators/remove'); 15 | var lister = require.resolve('./generator-vulcanjs/generators/list'); 16 | 17 | var env = yeoman.createEnv(); 18 | 19 | function runWithOptions(generator, extraOptions, callback) { 20 | var optionsForGenerators = parseArgs(process.argv.slice(2)); 21 | var finalOptions = {}; 22 | Object.assign(finalOptions, optionsForGenerators, extraOptions); 23 | return env.run(generator, finalOptions, callback); 24 | } 25 | 26 | var action = argsManager.getAction(); 27 | 28 | var componentNamesToGeneratorRegisters = { 29 | package: function _package() { 30 | env.register(packageGenerator, 'package'); 31 | }, 32 | app: function app() { 33 | env.register(appGenerator, 'app'); 34 | }, 35 | module: function module() { 36 | env.register(moduleGenerator, 'module'); 37 | }, 38 | component: function component() { 39 | env.register(componentGenerator, 'component'); 40 | }, 41 | route: function route() { 42 | env.register(routeGenerator, 'route'); 43 | }, 44 | remove: function remove() { 45 | env.register(remover, 'remove'); 46 | }, 47 | list: function list() { 48 | env.register(lister, 'list'); 49 | } 50 | }; 51 | 52 | function registerGenerator(componentName) { 53 | var registerFn = componentNamesToGeneratorRegisters[componentName]; 54 | registerFn(); 55 | } 56 | 57 | function run() { 58 | if (action.type === 'generate') { 59 | if (action.component === 'package') { 60 | registerGenerator('package'); 61 | return runWithOptions('package', { 62 | packageName: action.args[0] 63 | }); 64 | } else if (action.component === 'module') { 65 | registerGenerator('module'); 66 | return runWithOptions('module', { 67 | packageName: action.args[0], 68 | moduleName: action.args[1] 69 | }); 70 | } else if (action.component === 'component') { 71 | registerGenerator('component'); 72 | return runWithOptions('component', { 73 | packageName: action.args[0], 74 | componentName: action.args[1] 75 | }); 76 | } else if (action.component === 'route') { 77 | registerGenerator('route'); 78 | return runWithOptions('route', { 79 | packageName: action.args[0], 80 | routeName: action.args[1], 81 | routePath: action.args[2], 82 | componentName: action.args[3], 83 | layoutName: action.args[4] 84 | }); 85 | } 86 | } else if (action.type === 'remove') { 87 | registerGenerator('remove'); 88 | if (action.component === 'package') { 89 | return runWithOptions('remove', { 90 | vulcanjsComponent: 'package', 91 | packageName: action.args[0] 92 | }); 93 | } else if (action.component === 'module') { 94 | return runWithOptions('remove', { 95 | vulcanjsComponent: 'module', 96 | packageName: action.args[0], 97 | moduleName: action.args[1] 98 | }); 99 | } else if (action.component === 'route') { 100 | return runWithOptions('remove', { 101 | vulcanjsComponent: 'route', 102 | packageName: action.args[0], 103 | routeName: action.args[1] 104 | }); 105 | } 106 | return runWithOptions('remove'); 107 | } else if (action.type === 'create') { 108 | registerGenerator('app'); 109 | return runWithOptions('app', { 110 | appName: action.args[0] 111 | }); 112 | } else if (action.type === 'list') { 113 | registerGenerator('list'); 114 | return runWithOptions('list', { 115 | vulcanjsComponent: action.component, 116 | packageName: action.args[0] 117 | }); 118 | } else if (action.type === 'unshallow') { 119 | registerGenerator('unshallow'); 120 | return runWithOptions('unshallow', { 121 | vulcanjsComponent: action.component 122 | }); 123 | } 124 | } 125 | 126 | run(); 127 | -------------------------------------------------------------------------------- /media/logo-plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/logo-plain.png -------------------------------------------------------------------------------- /media/usage/create.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/create.gif -------------------------------------------------------------------------------- /media/usage/generate-component.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/generate-component.gif -------------------------------------------------------------------------------- /media/usage/generate-custom-model.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/generate-custom-model.gif -------------------------------------------------------------------------------- /media/usage/generate-default-model.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/generate-default-model.gif -------------------------------------------------------------------------------- /media/usage/generate-package.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/generate-package.gif -------------------------------------------------------------------------------- /media/usage/generate-route.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/generate-route.gif -------------------------------------------------------------------------------- /media/usage/list-packages.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/list-packages.gif -------------------------------------------------------------------------------- /media/usage/list-routes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/list-routes.gif -------------------------------------------------------------------------------- /media/usage/remove-model.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/remove-model.gif -------------------------------------------------------------------------------- /media/usage/remove-package.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/media/usage/remove-package.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vulcanjs-cli", 3 | "version": "3.3.1", 4 | "description": "The official cli scaffolding tool for VulcanJS", 5 | "bin": { 6 | "vulcan": "./dist/index.js" 7 | }, 8 | "scripts": { 9 | "watch": "grunt watch", 10 | "build": "grunt", 11 | "test": "./test/semi-automatic.sh" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/VulcanJS/vulcanjs-cli.git" 16 | }, 17 | "keywords": [ 18 | "vulcan", 19 | "generator", 20 | "scaffolding", 21 | "scaffolder", 22 | "scaffold" 23 | ], 24 | "author": "Kerem Kazan", 25 | "license": "ISC", 26 | "bugs": { 27 | "url": "https://github.com/VulcanJS/vulcanjs-cli/issues" 28 | }, 29 | "homepage": "https://github.com/VulcanJS/vulcanjs-cli#readme", 30 | "dependencies": { 31 | "argparse": "^1.0.9", 32 | "camelcase": "^4.1.0", 33 | "chalk": "^2.0.1", 34 | "dashify": "^0.2.2", 35 | "escodegen-wallaby": "^1.6.11", 36 | "eslint-config-airbnb-base": "^11.2.0", 37 | "esprima": "^4.0.0", 38 | "grunt": "^1.0.1", 39 | "gulp-beautify": "^2.0.1", 40 | "gulp-filter": "^5.0.1", 41 | "lodash": "^4.17.4", 42 | "minimist": "^1.2.0", 43 | "node-print": "^0.0.4", 44 | "pascal-case": "^2.0.1", 45 | "pluralize": "^6.0.0", 46 | "redux": "^3.7.1", 47 | "redux-node-logger": "^0.1.0", 48 | "yeoman-environment": "^2.0.0", 49 | "yeoman-generator": "^1.1.1" 50 | }, 51 | "devDependencies": { 52 | "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", 53 | "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", 54 | "babel-plugin-transform-object-rest-spread": "^6.23.0", 55 | "babel-preset-es2015": "^6.24.1", 56 | "eslint": "^4.18.2", 57 | "eslint-config-airbnb-base": "^11.2.0", 58 | "eslint-plugin-import": "^2.6.1", 59 | "grunt": "^1.0.1", 60 | "grunt-babel": "^6.0.0", 61 | "grunt-contrib-clean": "^1.1.0", 62 | "grunt-contrib-concat": "^1.0.1", 63 | "grunt-contrib-copy": "^1.0.0", 64 | "grunt-contrib-watch": "^1.0.0" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": "airbnb-base", 3 | "rules": { 4 | "space-before-function-paren": ["error", "always"], 5 | "comma-dangle": ["error", { 6 | "arrays": "always-multiline", 7 | "objects": "always-multiline", 8 | "imports": "ignore", 9 | "exports": "ignore", 10 | "functions": "never", 11 | }], 12 | "no-underscore-dangle": ["error", { 13 | "allowAfterThis": true, 14 | "allowAfterSuper": true, 15 | }], 16 | "arrow-parens": ["error", "always"], 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /src/argsManager.js: -------------------------------------------------------------------------------- 1 | const minimist = require('minimist'); 2 | const _ = require('lodash'); 3 | const chalk = require('chalk'); 4 | 5 | const recognizedActions = { 6 | generate: 'generate', 7 | g: 'generate', 8 | create: 'create', 9 | c: 'create', 10 | remove: 'remove', 11 | r: 'remove', 12 | list: 'list', 13 | l: 'list', 14 | un: 'unshallow', 15 | unshallow: 'unshallow', 16 | start: 'start', 17 | }; 18 | 19 | const genericProcessor = (args) => { 20 | const argsToProcess = args.slice(1); 21 | const action = { 22 | type: recognizedActions[args[0]], 23 | args: [], 24 | }; 25 | if (argsToProcess.length > 0) { 26 | action.component = argsToProcess[0]; 27 | } 28 | argsToProcess.shift(); 29 | if (argsToProcess.length > 0) { 30 | action.args = argsToProcess; 31 | } 32 | return action; 33 | }; 34 | 35 | const createProcessor = (args) => ({ 36 | type: 'create', 37 | args: args.slice(1), 38 | }); 39 | 40 | const argsProcessors = { 41 | generate: genericProcessor, 42 | remove: genericProcessor, 43 | list: genericProcessor, 44 | create: createProcessor, 45 | start: genericProcessor, 46 | }; 47 | 48 | function usage () { 49 | const values = _.uniq(_.values(recognizedActions)); 50 | console.log(chalk.green('\nvulcan usage:')); 51 | console.log(chalk.grey('\nSynopsis')); 52 | console.log(' vulcan <...>\n'); 53 | console.log(' Operation to perform '); 54 | console.log(' Asset type (contextual to action)'); 55 | console.log(' <...> Parameters. If not provided, interactively entered'); 56 | // console.log(chalk.grey('\nProject run')); 57 | // console.log(' vulcan start'); 58 | console.log(chalk.grey('\nProject initialisation')); 59 | console.log(' vulcan create '); 60 | // console.log(' vulcan unshallow '); 61 | console.log(chalk.grey('\nAssets creation')); 62 | console.log(' vulcan (generate|g) package '); 63 | console.log(' vulcan (generate|g) module '); 64 | console.log(' vulcan (generate|g) component '); 65 | console.log(' vulcan (generate|g) route '); 66 | console.log(chalk.grey('\nAssets removal')); 67 | console.log(' vulcan (remove|r) package'); 68 | console.log(' vulcan (remove|r) module'); 69 | console.log(chalk.grey('\nAssets listing')); 70 | console.log(' vulcan (list|l) packages'); 71 | process.exit(); 72 | } 73 | 74 | function getAction () { 75 | const args = minimist(process.argv.slice(2))._; 76 | 77 | if (!recognizedActions[args[0]]) { 78 | usage(); 79 | } 80 | const actionName = recognizedActions[args[0]]; 81 | const actionObj = argsProcessors[actionName](args); 82 | return actionObj; 83 | } 84 | 85 | module.exports = { 86 | getAction, 87 | }; 88 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/src/generator-vulcanjs/.DS_Store -------------------------------------------------------------------------------- /src/generator-vulcanjs/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/app/index.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 3 | 4 | const STARTER_REPO_URL = 'https://github.com/VulcanJS/Vulcan-Starter.git'; 5 | 6 | module.exports = class extends VulcanGenerator { 7 | _registerArguments () { 8 | this._registerOptions( 9 | 'appName', 10 | 'doShallowClone', 11 | 'reactExtension', 12 | 'packageManager' 13 | ); 14 | } 15 | 16 | initializing () { 17 | this._assert('notVulcan'); 18 | } 19 | 20 | prompting () { 21 | if (!this._canPrompt()) { 22 | return false; 23 | } 24 | let questions = []; 25 | if (this._needArg('appName')) { 26 | questions = [...questions, ...this._getQuestions( 27 | 'appName' 28 | )]; 29 | } 30 | questions = [...questions, ...this._getQuestions('packageManager')]; 31 | return this.prompt(questions).then((answers) => { 32 | this.props = { 33 | appName: this._finalize('appName', answers), 34 | packageManager: this._finalize('raw', 'packageManager', answers), 35 | }; 36 | }); 37 | } 38 | 39 | writing () { 40 | if (!this._canInstall()) { 41 | return; 42 | } 43 | 44 | this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); 45 | this.spawnCommandSync('git', [ 46 | 'clone', 47 | STARTER_REPO_URL, 48 | this.props.appName, 49 | ]); 50 | this.destinationRoot( 51 | this.destinationPath(this.props.appName) 52 | ); 53 | this.installDependencies({ 54 | npm: this.props.packageManager === 'npm', 55 | bower: false, 56 | yarn: this.props.packageManager === 'yarn', 57 | }); 58 | if (!this._canConfigure()) { 59 | return; 60 | } 61 | this._dispatch({ 62 | type: 'SET_IS_VULCAN_TRUE', 63 | }); 64 | this._dispatch({ 65 | type: 'SET_APP_NAME', 66 | appName: this.props.appName, 67 | }); 68 | this._dispatch({ 69 | type: 'SET_PACKAGE_MANAGER', 70 | packageManager: this.props.packageManager, 71 | }); 72 | this._commitStore(); 73 | } 74 | 75 | end () { 76 | this._end(); 77 | this.log(' '); 78 | this.log(chalk.green('Successfully generated vulcan code base. \n')); 79 | this.log(chalk.green('To run your new app: \n')); 80 | this.log(chalk.green(` cd ${this.props.appName}`)); 81 | this.log(chalk.green(` ${this.props.packageManager} start \n`)); 82 | } 83 | }; 84 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/component/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 2 | const ast = require('../../lib/ast'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing () { 6 | this._assert('isVulcan'); 7 | this._assert('hasNonZeroPackages'); 8 | } 9 | 10 | _registerArguments () { 11 | this._registerOptions('packageName', 'componentName'); 12 | } 13 | 14 | prompting () { 15 | if (!this._canPrompt()) { 16 | return false; 17 | } 18 | let questions = []; 19 | if (this._needArg('packageName')) { 20 | questions = [...questions, ...this._getQuestions('packageNameList')]; 21 | } 22 | if (this._needArg('componentName')) { 23 | questions = [...questions, ...this._getQuestions('componentName')]; 24 | } 25 | questions = [ 26 | ...questions, 27 | ...this._getQuestions('componentType', 'isRegisterComponent'), 28 | ]; 29 | return this.prompt(questions).then((answers) => { 30 | this.props = { 31 | packageName: this._finalize('packageName', answers), 32 | componentName: this._finalize('componentName', answers), 33 | componentFileName: this._finalize('componentFileName', answers), 34 | componentType: this._finalize('raw', 'componentType', answers), 35 | isRegister: this._finalize('raw', 'isRegister', answers), 36 | }; 37 | this.props.componentPath = this._finalize('componentPath', answers); 38 | }); 39 | } 40 | 41 | _writeComponent () { 42 | const templatePath = 43 | this.props.componentType === 'pure' 44 | ? this.templatePath('pureFunctionComponent.js') 45 | : this.templatePath('classComponent.js'); 46 | this.fs.copyTpl( 47 | templatePath, 48 | this._getPath( 49 | { isAbsolute: true }, 50 | 'components', 51 | this.props.componentFileName 52 | ), 53 | this.props 54 | ); 55 | } 56 | 57 | _updateComponentsIndex () { 58 | if (!this.props.isRegister) return; 59 | const componentsIndexPath = this._getPath( 60 | { isAbsolute: true }, 61 | 'componentsIndex' 62 | ); 63 | const fileText = this.fs.read(componentsIndexPath); 64 | const fileWithImportText = ast.addImportStatement( 65 | fileText, 66 | `../components/${this.props.componentFileName}` 67 | ); 68 | this.fs.write(componentsIndexPath, fileWithImportText); 69 | } 70 | 71 | writing () { 72 | if (!this._canWrite()) { 73 | return; 74 | } 75 | this._writeComponent(); 76 | this._updateComponentsIndex(); 77 | } 78 | 79 | end () { 80 | this._end(); 81 | } 82 | }; 83 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/component/templates/classComponent.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | <%if (isRegister) { %><% include ./partials/registerComponentImport.js -%><%} -%> 3 | 4 | class <%= componentName %> extends Component { 5 | render () { 6 | return ( 7 |
8 | Find me at <%= componentPath %> 9 |
10 | ); 11 | } 12 | } 13 | <%if (isRegister) { %><% include ./partials/registerComponent.js -%><%} -%> 14 | 15 | export default <%= componentName %>; 16 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/component/templates/partials/registerComponent.js: -------------------------------------------------------------------------------- 1 | registerComponent({name:'<%= componentName %>', component:<%= componentName %>}); 2 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/component/templates/partials/registerComponentImport.js: -------------------------------------------------------------------------------- 1 | import { registerComponent } from 'meteor/vulcan:core'; 2 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/component/templates/pureFunctionComponent.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | <%if (isRegister) { %><% include ./partials/registerComponentImport.js -%><%} -%> 3 | 4 | const <%= componentName %> = () => ( 5 |
6 | Find me at <%= componentPath %> 7 |
8 | ); 9 | <%if (isRegister) { %><% include ./partials/registerComponent.js -%><%} -%> 10 | 11 | export default <%= componentName %>; 12 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/list/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 2 | 3 | module.exports = class extends VulcanGenerator { 4 | initializing () { 5 | this._assert('isVulcan'); 6 | } 7 | 8 | _registerArguments () { 9 | this._registerOptions( 10 | 'vulcanjsListableComponent', 11 | 'packageName' 12 | ); 13 | } 14 | 15 | prompting () { 16 | if (!this._canPrompt()) { return false; } 17 | let questions = []; 18 | if (!this.options.vulcanjsComponent) { 19 | questions = [...questions, this._getQuestions( 20 | 'vulcanjsListableComponentsList' 21 | )]; 22 | } 23 | return this.prompt(questions) 24 | .then((answers) => { 25 | this.props = { 26 | vulcanjsComponent: this._finalize('raw', 'vulcanjsComponent', answers), 27 | }; 28 | }); 29 | } 30 | 31 | composing () { 32 | const lister = require.resolve(`./listers/${this.props.vulcanjsComponent}`); 33 | this.composeWith(lister, { 34 | ...this.props, 35 | ...this.options, 36 | dontAsk: true, 37 | }); 38 | } 39 | 40 | end () { 41 | this._end(); 42 | } 43 | }; 44 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/list/listers/packages.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | const nodePrint = require('node-print'); 3 | const makeLister = require('../../../lib/lister'); 4 | 5 | module.exports = class extends VulcanGenerator { 6 | initializing() { 7 | this._assert('isVulcan'); 8 | this._lister = makeLister.setup(this); 9 | } 10 | 11 | prompting() { 12 | const packageNames = this._lister.listPackages(); 13 | this.props = { 14 | packageNames, 15 | prettyPackages: this._finalize('prettyPackages', packageNames), 16 | }; 17 | } 18 | 19 | listing() { 20 | nodePrint.pt(this.props.prettyPackages); 21 | } 22 | 23 | end() { 24 | this._end(); 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/fragments/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | 3 | module.exports = class extends VulcanGenerator { 4 | initializing () { 5 | this._assert('isVulcan'); 6 | this._assert('hasNonZeroPackages'); 7 | } 8 | 9 | _registerArguments () { 10 | this._registerOptions( 11 | 'packageName', 12 | 'moduleName' 13 | ); 14 | } 15 | 16 | prompting () { 17 | if (!this._canPrompt()) { return false; } 18 | const questions = this._getQuestions( 19 | 'packageNameWithNumModulesList', 20 | 'moduleNameList' 21 | ); 22 | return this.prompt(questions) 23 | .then((answers) => { 24 | this.props = { 25 | packageName: this._finalize('packageName', answers), 26 | moduleName: this._finalize('moduleName', answers), 27 | typeName: this._finalize('typeName', answers), 28 | collectionName: this._finalize('collectionName', answers), 29 | }; 30 | }); 31 | } 32 | 33 | _writeFragments () { 34 | this.fs.copyTpl( 35 | this.templatePath('fragments.js'), 36 | this._getPath( 37 | { isAbsolute: true }, 38 | 'module', 39 | 'fragments.js' 40 | ), 41 | this.props 42 | ); 43 | } 44 | 45 | _writeTestFragments () { 46 | const testProps = { 47 | ...this.props, 48 | subjectName: 'fragments', 49 | subjectPath: `../../../lib/modules/${this.props.moduleName}/fragments`, 50 | }; 51 | this.fs.copyTpl( 52 | this.templatePath('../../templates/generic-test.js'), 53 | this._getPath( 54 | { isAbsolute: true }, 55 | 'moduleTest', 56 | 'fragments.spec.js' 57 | ), 58 | testProps 59 | ); 60 | } 61 | 62 | writing () { 63 | if (!this._canWrite()) { return; } 64 | this._writeFragments(); 65 | // this._writeTestFragments(); 66 | } 67 | 68 | end () { 69 | this._end(); 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/fragments/templates/fragments.js: -------------------------------------------------------------------------------- 1 | import { registerFragment } from 'meteor/vulcan:core'; 2 | 3 | registerFragment(` 4 | fragment <%= collectionName %>Fragment on <%= typeName %> { 5 | _id 6 | createdAt 7 | } 8 | `); 9 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 2 | const ast = require('../../lib/ast'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing() { 6 | this._assert('isVulcan'); 7 | this._assert('hasNonZeroPackages'); 8 | } 9 | 10 | _registerArguments() { 11 | this._registerOptions( 12 | 'packageName', 13 | 'moduleName' 14 | ); 15 | } 16 | 17 | prompting() { 18 | if (!this._canPrompt()) { return false; } 19 | let questions = []; 20 | if (this._needArg('packageName')) { 21 | questions = [...questions, ...this._getQuestions( 22 | 'packageNameList' 23 | )]; 24 | } 25 | if (this._needArg('moduleName')) { 26 | questions = [...questions, ...this._getQuestions('moduleName')]; 27 | } 28 | return this.prompt(questions) 29 | .then((answers) => { 30 | this.props = { 31 | packageName: this._finalize('packageName', answers), 32 | moduleName: this._finalize('moduleName', answers), 33 | collectionName: this._finalize('collectionName', answers), 34 | typeName: this._finalize('pascalModuleName', answers), 35 | }; 36 | this._composeGenerators(); 37 | }); 38 | } 39 | 40 | _composeGenerators() { 41 | const moduleParts = ['fragments', 'schema']; 42 | moduleParts.forEach((modulePart) => { 43 | const generator = require.resolve(`./${modulePart}`); 44 | const nextOptions = { 45 | ...this.options, 46 | ...this.props, 47 | dontAsk: true, 48 | }; 49 | this.composeWith(generator, nextOptions); 50 | }); 51 | } 52 | 53 | configuring() { 54 | if (!this._canConfigure()) { } 55 | } 56 | 57 | _writeCollection() { 58 | this.fs.copyTpl( 59 | this.templatePath('collection.js'), 60 | this._getPath( 61 | { isAbsolute: true }, 62 | 'module', 63 | 'collection.js' 64 | ), 65 | this.props 66 | ); 67 | } 68 | 69 | _writeTestCollection() { 70 | const testProps = { 71 | ...this.props, 72 | subjectName: 'collection', 73 | subjectPath: `../../../lib/modules/${this.props.moduleName}/fragments`, 74 | }; 75 | this.fs.copyTpl( 76 | this.templatePath('generic-test.js'), 77 | this._getPath( 78 | { isAbsolute: true }, 79 | 'moduleTest', 80 | 'collection.spec.js' 81 | ), 82 | testProps 83 | ); 84 | } 85 | 86 | _updateCollectionsIndex() { 87 | const collectionsIndexPath = this._getPath( 88 | { isAbsolute: true }, 89 | 'collectionsIndex' 90 | ); 91 | const fileText = this.fs.read(collectionsIndexPath); 92 | const fileWithImportText = ast.addImportStatement( 93 | fileText, 94 | `./${this.props.moduleName}/collection.js` 95 | ); 96 | this.fs.write( 97 | collectionsIndexPath, 98 | fileWithImportText 99 | ); 100 | } 101 | 102 | writing() { 103 | if (!this._canWrite()) { return; } 104 | this._writeCollection(); 105 | this._updateCollectionsIndex(); 106 | // this._writeTestCollection(); 107 | } 108 | 109 | end() { 110 | this._end(); 111 | } 112 | }; 113 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/mutations/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | 3 | module.exports = class extends VulcanGenerator { 4 | initializing() { 5 | this._assert('isVulcan'); 6 | this._assert('hasNonZeroPackages'); 7 | } 8 | 9 | _registerArguments() { 10 | this._registerOptions( 11 | 'packageName', 12 | 'moduleName' 13 | ); 14 | } 15 | 16 | prompting() { 17 | if (!this._canPrompt()) { return false; } 18 | const questions = this._getQuestions( 19 | 'packageNameWithNumModulesList', 20 | 'moduleNameList' 21 | ); 22 | return this.prompt(questions) 23 | .then((answers) => { 24 | this.props = { 25 | packageName: this._finalize('packageName', answers), 26 | moduleName: this._finalize('moduleName', answers), 27 | collectionName: this._finalize('collectionName', answers), 28 | newMutationName: this._finalize('mutationName', 'new', answers), 29 | editMutationName: this._finalize('mutationName', 'edit', answers), 30 | removeMutationName: this._finalize('mutationName', 'remove', answers), 31 | newPermission: this._finalize('permissionName', ['new'], answers), 32 | editOwnPermission: this._finalize('permissionName', ['edit', 'own'], answers), 33 | editAllPermission: this._finalize('permissionName', ['edit', 'all'], answers), 34 | removeOwnPermission: this._finalize('permissionName', ['remove', 'own'], answers), 35 | removeAllPermission: this._finalize('permissionName', ['remove', 'all'], answers), 36 | }; 37 | }); 38 | } 39 | 40 | _writeMutations() { 41 | this.fs.copyTpl( 42 | this.templatePath('mutations.js'), 43 | this._getPath( 44 | { isAbsolute: true }, 45 | 'module', 46 | 'mutations.js' 47 | ), 48 | this.props 49 | ); 50 | } 51 | 52 | _writeTestMutations() { 53 | const testProps = { 54 | ...this.props, 55 | subjectName: 'mutations', 56 | subjectPath: `../../../lib/modules/${this.props.moduleName}/mutations`, 57 | }; 58 | this.fs.copyTpl( 59 | this.templatePath('../../templates/generic-test.js'), 60 | this._getPath( 61 | { isAbsolute: true }, 62 | 'moduleTest', 63 | 'mutations.spec.js' 64 | ), 65 | testProps 66 | ); 67 | } 68 | 69 | writing() { 70 | if (!this._canWrite()) { return; } 71 | this._writeMutations(); 72 | // this._writeTestMutations(); 73 | } 74 | 75 | end() { 76 | this._end(); 77 | } 78 | }; 79 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/mutations/templates/mutations.js: -------------------------------------------------------------------------------- 1 | import { 2 | createMutator, 3 | updateMutator, 4 | deleteMutator, 5 | Utils 6 | } from 'meteor/vulcan:core'; 7 | import Users from 'meteor/vulcan:users'; 8 | 9 | const mutations = { 10 | create: { 11 | name: '<%= newMutationName %>', 12 | check(user) { 13 | if (!user) return false; 14 | return Users.canDo(user, '<%= newPermission %>'); 15 | }, 16 | mutation(root, { document }, context) { 17 | Utils.performCheck(this.check, context.currentUser, document); 18 | return createMutator({ 19 | collection: context.<%= collectionName %>, 20 | document: document, 21 | currentUser: context.currentUser, 22 | validate: true, 23 | context, 24 | }); 25 | }, 26 | }, 27 | 28 | update: { 29 | name: '<%= editMutationName %>', 30 | check(user, document) { 31 | if (!user || !document) return false; 32 | return Users.owns(user, document) ? 33 | Users.canDo(user, '<%= editOwnPermission %>') : 34 | Users.canDo(user, `<%= editAllPermission %>`); 35 | }, 36 | mutation(root, { documentId, set, unset }, context) { 37 | const document = context.<%= collectionName %>.findOne(documentId); 38 | Utils.performCheck(this.check, context.currentUser, document); 39 | return updateMutator({ 40 | collection: context.<%= collectionName %>, 41 | documentId: documentId, 42 | set: set, 43 | unset: unset, 44 | currentUser: context.currentUser, 45 | validate: true, 46 | context, 47 | }); 48 | }, 49 | }, 50 | 51 | delete: { 52 | name: '<%= removeMutationName %>', 53 | check(user, document) { 54 | if (!user || !document) return false; 55 | return Users.owns(user, document) ? 56 | Users.canDo(user, '<%= removeOwnPermission %>') : 57 | Users.canDo(user, `<%= removeAllPermission %>`); 58 | }, 59 | mutation(root, { documentId }, context) { 60 | const document = context.<%= collectionName %>.findOne(documentId); 61 | Utils.performCheck(this.check, context.currentUser, document); 62 | return deleteMutator({ 63 | collection: context.<%= collectionName %>, 64 | documentId: documentId, 65 | currentUser: context.currentUser, 66 | validate: true, 67 | context, 68 | }); 69 | }, 70 | }, 71 | }; 72 | 73 | export default mutations; -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/resolvers/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | 3 | module.exports = class extends VulcanGenerator { 4 | initializing () { 5 | this._assert('isVulcan'); 6 | this._assert('hasNonZeroPackages'); 7 | } 8 | 9 | _registerArguments () { 10 | this._registerOptions( 11 | 'packageName', 12 | 'moduleName' 13 | ); 14 | } 15 | 16 | prompting () { 17 | if (!this._canPrompt()) { return false; } 18 | const questions = this._getQuestions( 19 | 'packageNameWithNumModulesList', 20 | 'moduleNameList' 21 | // 'defaultResolvers' 22 | ); 23 | return this.prompt(questions) 24 | .then((answers) => { 25 | this.props = { 26 | packageName: this._finalize('packageName', answers), 27 | moduleName: this._finalize('moduleName', answers), 28 | collectionName: this._finalize('collectionName', answers), 29 | listResolverName: this._finalize('resolverName', 'List', answers), 30 | singleResolverName: this._finalize('resolverName', 'Single', answers), 31 | totalResolverName: this._finalize('resolverName', 'Total', answers), 32 | }; 33 | }); 34 | } 35 | 36 | _writeResolvers () { 37 | this.fs.copyTpl( 38 | this.templatePath('resolvers.js'), 39 | this._getPath( 40 | { isAbsolute: true }, 41 | 'module', 42 | 'resolvers.js' 43 | ), 44 | this.props 45 | ); 46 | } 47 | 48 | _writeTestResolvers () { 49 | const testProps = { 50 | ...this.props, 51 | subjectName: 'resolvers', 52 | subjectPath: `../../../lib/modules/${this.props.moduleName}/resolvers`, 53 | }; 54 | this.fs.copyTpl( 55 | this.templatePath('../../templates/generic-test.js'), 56 | this._getPath( 57 | { isAbsolute: true }, 58 | 'moduleTest', 59 | 'resolvers.spec.js' 60 | ), 61 | testProps 62 | ); 63 | } 64 | 65 | writing () { 66 | if (!this._canWrite()) { return; } 67 | this._writeResolvers(); 68 | // this._writeTestResolvers(); 69 | } 70 | 71 | end () { 72 | this._end(); 73 | } 74 | }; 75 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/resolvers/templates/partials/listResolver.js: -------------------------------------------------------------------------------- 1 | multi: { 2 | name: '<%= listResolverName %>', 3 | resolver(root, {input = {}}, context, info) { 4 | // get selector and options from terms and perform Mongo query 5 | let { selector, options } = await Connectors.filter(collection, input, context); 6 | return { 7 | results: context.<%= collectionName %>.find(selector, options).fetch(); 8 | } 9 | }, 10 | }, 11 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/resolvers/templates/partials/singleResolver.js: -------------------------------------------------------------------------------- 1 | single: { 2 | name: '<%= singleResolverName %>', 3 | resolver(root, { _id }, context) { 4 | const document = context.<%= collectionName %>.findOne({ _id }); 5 | const result = context.Users.restrictViewableFields( 6 | context.currentUser, 7 | context.<%= collectionName %>, 8 | document 9 | ); 10 | return { result } 11 | }, 12 | }, 13 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/resolvers/templates/resolvers.js: -------------------------------------------------------------------------------- 1 | const resolvers = { 2 | multi: { 3 | name: '<%= listResolverName %>', 4 | resolver(root, {input = {}}, context, info) { 5 | // get selector and options from terms and perform Mongo query 6 | let { selector, options } = await Connectors.filter(collection, input, context); 7 | return { 8 | results: context.<%= collectionName %>.find(selector, options).fetch(); 9 | } 10 | }, 11 | }, 12 | single: { 13 | name: '<%= singleResolverName %>', 14 | resolver(root, { _id }, context) { 15 | const document = context.<%= collectionName %>.findOne({ _id }); 16 | const result = context.Users.restrictViewableFields( 17 | context.currentUser, 18 | context.<%= collectionName %>, 19 | document 20 | ); 21 | return { result } 22 | } 23 | } 24 | }; 25 | 26 | export default resolvers; 27 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/schema/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | 3 | module.exports = class extends VulcanGenerator { 4 | initializing () { 5 | this._assert('isVulcan'); 6 | this._assert('hasNonZeroPackages'); 7 | } 8 | 9 | _registerArguments () { 10 | this._registerOptions( 11 | 'packageName', 12 | 'moduleName' 13 | ); 14 | } 15 | 16 | prompting () { 17 | if (!this._canPrompt()) { return false; } 18 | const questions = this._getQuestions( 19 | 'packageNameWithNumModulesList', 20 | 'moduleNameList', 21 | 'isAddCustomSchemaProperty' 22 | ); 23 | return this.prompt(questions) 24 | .then((answers) => { 25 | this.props = { 26 | packageName: this._finalize('packageName', answers), 27 | moduleName: this._finalize('moduleName', answers), 28 | isAddCustomSchemaProperty: this._finalize('raw', 'isAddCustomSchemaProperty', answers), 29 | customSchemaProperties: [], 30 | }; 31 | if (this.props.isAddCustomSchemaProperty) { 32 | return this._askCustomSchemaQuestion(); 33 | } 34 | }); 35 | } 36 | 37 | _askCustomSchemaQuestion () { 38 | const customSchemaPropertyQuestions = this._getQuestions( 39 | 'schemaPropertyName', 40 | 'isSchemaPropertyHidden', 41 | 'schemaPropertyLabel', 42 | 'schemaPropertyType', 43 | 'isSchemaPropertyOptional', 44 | 'schemaPropertyViewableBy', 45 | 'schemaPropertyInsertableBy', 46 | 'schemaPropertyEditableBy', 47 | 'isAddAnotherCustomSchemaProperty' 48 | ); 49 | return this.prompt(customSchemaPropertyQuestions) 50 | .then((answers) => { 51 | const customSchemaProperties = { 52 | name: this._finalize('raw', 'schemaPropertyName', answers), 53 | isHidden: this._finalize('raw', 'isSchemaPropertyHidden', answers), 54 | label: this._finalize('raw', 'schemaPropertyLabel', answers), 55 | type: this._finalize('raw', 'schemaPropertyType', answers), 56 | isOptional: this._finalize('raw', 'isSchemaPropertyOptional', answers), 57 | viewableBy: this._finalize('permissionTo', 'schemaPropertyViewableBy', answers), 58 | insertableBy: this._finalize('permissionTo', 'schemaPropertyInsertableBy', answers), 59 | editableBy: this._finalize('permissionTo', 'schemaPropertyEditableBy', answers), 60 | }; 61 | this.props.customSchemaProperties.push(customSchemaProperties); 62 | if (answers.isAddAnotherCustomSchemaProperty) { 63 | return this._askCustomSchemaQuestion(); 64 | } 65 | }); 66 | } 67 | 68 | _writeSchema () { 69 | this.fs.copyTpl( 70 | this.templatePath('schema.js'), 71 | this._getPath( 72 | { isAbsolute: true }, 73 | 'module', 74 | 'schema.js' 75 | ), 76 | this.props 77 | ); 78 | } 79 | 80 | _writeTestSchema () { 81 | const testFragmentsProps = { 82 | ...this.props, 83 | subjectName: 'schema', 84 | subjectPath: `../../../lib/modules/${this.props.moduleName}/schema`, 85 | }; 86 | this.fs.copyTpl( 87 | this.templatePath('../../templates/generic-test.js'), 88 | this._getPath( 89 | { isAbsolute: true }, 90 | 'moduleTest', 91 | 'schema.spec.js' 92 | ), 93 | testFragmentsProps 94 | ); 95 | } 96 | 97 | writing () { 98 | if (!this._canWrite()) { return; } 99 | this._writeSchema(); 100 | // this._writeTestSchema(); 101 | } 102 | 103 | end () { 104 | this._end(); 105 | } 106 | }; 107 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/schema/templates/partials/schemaProperty.js: -------------------------------------------------------------------------------- 1 | <%- name %> : { 2 | <% if (isHidden) { %> hidden: true <% } else { %> label: '<%= label %>' <% } %>, 3 | type: <%- type %>, 4 | optional: <%- isOptional %>, 5 | canRead: <%- viewableBy %>, 6 | canCreate: <%- insertableBy %>, 7 | canUpdate: <%- editableBy %>, 8 | }, 9 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/schema/templates/schema.js: -------------------------------------------------------------------------------- 1 | const schema = { 2 | // default properties 3 | 4 | _id: { 5 | type: String, 6 | optional: true, 7 | canRead: ['guests'], 8 | }, 9 | createdAt: { 10 | type: Date, 11 | optional: true, 12 | canRead: ['guests'], 13 | onCreate: ({ newDocument, currentUser}) => { 14 | return new Date(); 15 | } 16 | }, 17 | // userId: { 18 | // type: String, 19 | // optional: true, 20 | // canRead: ['guests'], 21 | // resolveAs: { 22 | // fieldName: 'user', 23 | // type: 'User', 24 | // resolver: (movie, args, context) => { 25 | // return context.Users.findOne({ _id: movie.userId }, { fields: context.Users.getViewableFields(context.currentUser, context.Users) }); 26 | // }, 27 | // addOriginalField: true 28 | // } 29 | // }, 30 | <% customSchemaProperties.forEach((schemaProperty) => { %> 31 | <%- include('./partials/schemaProperty.js', schemaProperty) %> 32 | <% }); %> 33 | }; 34 | 35 | export default schema; 36 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/templates/collection.js: -------------------------------------------------------------------------------- 1 | import { createCollection } from 'meteor/vulcan:core'; 2 | import schema from './schema.js'; 3 | import './fragments.js'; 4 | 5 | const <%= collectionName %> = createCollection({ 6 | collectionName: '<%= collectionName %>', 7 | typeName: '<%= typeName %>', 8 | schema, 9 | // resolvers: yourCustomResolvers // null to disable default resolvers generation 10 | // mutations: yourCustomMutations // null to disable default mutations generation 11 | permissions: { 12 | canRead: ['members'], 13 | canCreate: ['members'], 14 | canUpdate: ['owners', 'admins'], 15 | canDelete: ['owners', 'admins'] 16 | }, 17 | //callbacks: { 18 | // create: { 19 | // before: [] 20 | // } 21 | //}, 22 | //customFilters: [ 23 | // { 24 | // name: "_withRatings", 25 | // argument: "average: Int", 26 | // filter: ({ input, context, filterArguments }) => { 27 | // const { average } = filterArguments; 28 | // const { Reviews } = context; 29 | // // get all movies that have an average review score of X stars 30 | // const xStarReviewsMoviesIds = getMoviesByScore(average); 31 | // return { 32 | // selector: { _id: { $in: xStarReviewsMoviesIds } }, 33 | // options: {} 34 | // } 35 | // } 36 | // } 37 | //] 38 | 39 | }); 40 | 41 | 42 | 43 | export default <%= collectionName %>; 44 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/templates/generic-test.js: -------------------------------------------------------------------------------- 1 | import assert from 'assert'; 2 | import <%= subjectName %> from '<%= subjectPath %>'; 3 | 4 | describe('The <%= subjectName %> for: <%= moduleName %>', () => { 5 | it('should have some tests', () => { 6 | assert(false); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/module/templates/stories.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | storiesOf 4 | } from '@storybook/react'; 5 | 6 | storiesOf('<%= moduleName %>', module); 7 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/index.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing() { 6 | this._assert('isVulcan'); 7 | } 8 | 9 | _registerArguments() { 10 | this._registerOptions( 11 | 'packageName' 12 | ); 13 | } 14 | 15 | prompting() { 16 | if (!this._canPrompt()) { return false; } 17 | let questions = []; 18 | if (!this.options.packageName) { 19 | questions = [...questions, ...this._getQuestions( 20 | 'packageName' 21 | )]; 22 | } 23 | return this.prompt(questions).then((answers) => { 24 | this.props = { 25 | packageName: this._finalize('packageName', answers), 26 | vulcanDependencies: ['\'vulcan:core\''], 27 | isPackageAutoAdd: this._finalize('raw', 'isPackageAutoAdd', answers), 28 | }; 29 | this._assert('notPackageExists', this.props.packageName); 30 | }); 31 | } 32 | 33 | configuring() { 34 | if (!this._canConfigure()) { } 35 | } 36 | 37 | _writePackageJs() { 38 | this.fs.copyTpl( 39 | this.templatePath('package.js'), 40 | this._getPath( 41 | { isAbsolute: true }, 42 | 'package', 43 | 'package.js' 44 | ), 45 | this.props 46 | ); 47 | } 48 | 49 | _writeClientMain() { 50 | this.fs.copyTpl( 51 | this.templatePath('client.js'), 52 | this._getPath( 53 | { isAbsolute: true }, 54 | 'client', 55 | 'main.js' 56 | ), 57 | this.props 58 | ); 59 | } 60 | 61 | _writeServerMain() { 62 | this.fs.copyTpl( 63 | this.templatePath('server.js'), 64 | this._getPath( 65 | { isAbsolute: true }, 66 | 'server', 67 | 'main.js' 68 | ), 69 | this.props 70 | ); 71 | } 72 | 73 | _writeServerSeed() { 74 | this.fs.copyTpl( 75 | this.templatePath('seed.js'), 76 | this._getPath( 77 | { isAbsolute: true }, 78 | 'server', 79 | 'seed.js' 80 | ), 81 | this.props 82 | ); 83 | } 84 | 85 | _writeModulesIndex() { 86 | this.fs.copyTpl( 87 | this.templatePath('modules.index.js'), 88 | this._getPath( 89 | { isAbsolute: true }, 90 | 'modulesIndex' 91 | ), 92 | this.props 93 | ); 94 | } 95 | 96 | _writeCollectionsIndex() { 97 | this.fs.copyTpl( 98 | this.templatePath('collections.js'), 99 | this._getPath( 100 | { isAbsolute: true }, 101 | 'collectionsIndex' 102 | ), 103 | this.props 104 | ); 105 | } 106 | 107 | _writeComponentsIndex() { 108 | this.fs.copyTpl( 109 | this.templatePath('components.js'), 110 | this._getPath( 111 | { isAbsolute: true }, 112 | 'componentsIndex' 113 | ), 114 | this.props 115 | ); 116 | } 117 | 118 | _writeRoutes() { 119 | this.fs.copyTpl( 120 | this.templatePath('routes.js'), 121 | this._getPath( 122 | { isAbsolute: true }, 123 | 'routes' 124 | ), 125 | this.props 126 | ); 127 | } 128 | 129 | // _writeTestsIndex () { 130 | // this.fs.copyTpl( 131 | // this.templatePath('tests-index.js'), 132 | // this._getPath( 133 | // { isAbsolute: true }, 134 | // 'packageTests', 135 | // 'index.js' 136 | // ), 137 | // this.props 138 | // ); 139 | // } 140 | 141 | writing() { 142 | if (!this._canWrite()) { return; } 143 | this._writePackageJs(); 144 | this._writeClientMain(); 145 | this._writeServerMain(); 146 | this._writeServerSeed(); 147 | this._writeModulesIndex(); 148 | this._writeCollectionsIndex(); 149 | // this._writeTestsIndex(); 150 | this._writeComponentsIndex(); 151 | this._writeRoutes(); 152 | } 153 | 154 | end() { 155 | this._end(); 156 | this.log(`\nTo activate your packages, run: ${chalk.green(`meteor add ${this.props.packageName}`)}`); 157 | } 158 | }; 159 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/client.js: -------------------------------------------------------------------------------- 1 | import '../modules/index.js'; 2 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/collections.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/src/generator-vulcanjs/generators/package/templates/collections.js -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/components.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VulcanJS/vulcanjs-cli/edd93a2fb613011b032b5a90d9e4d003a2900459/src/generator-vulcanjs/generators/package/templates/components.js -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/modules.index.js: -------------------------------------------------------------------------------- 1 | import './collections.js'; 2 | import './routes'; 3 | import './components'; 4 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | name: '<%= packageName %>', 3 | }); 4 | 5 | Package.onUse((api) => { 6 | api.use([<%- vulcanDependencies.join(",\n"); %>]); 7 | 8 | api.mainModule('lib/server/main.js', 'server'); 9 | api.mainModule('lib/client/main.js', 'client'); 10 | }); 11 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/routes.js: -------------------------------------------------------------------------------- 1 | import { addRoute } from 'meteor/vulcan:core'; 2 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/seed.js: -------------------------------------------------------------------------------- 1 | import Users from 'meteor/vulcan:users'; 2 | import { createMutator } from 'meteor/vulcan:core'; 3 | 4 | const seedData = []; 5 | 6 | Meteor.startup(() => { 7 | // if (Users.find().count() === 0) { 8 | // createMutator({ 9 | // collection: Users, 10 | // document:{ 11 | // username: 'DemoUser', 12 | // email: 'dummyuser@gmail.com', 13 | // profile: { 14 | // isDummy: true 15 | // }, 16 | // } 17 | // }); 18 | // } 19 | }); 20 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/package/templates/server.js: -------------------------------------------------------------------------------- 1 | import '../modules'; 2 | import './seed'; 3 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/remove/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 2 | const vulcanjsRemovableComponents = require('../../lib/common').vulcanjsRemovableComponents; 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing () { 6 | this._assert('isVulcan'); 7 | this._assert('hasNonZeroPackages'); 8 | } 9 | 10 | _registerArguments () { 11 | this._registerOptions( 12 | 'vulcanjsRemovableComponent' 13 | ); 14 | } 15 | 16 | _isComponentRemovable () { 17 | return vulcanjsRemovableComponents.includes(this.options.vulcanjsComponent); 18 | } 19 | 20 | prompting () { 21 | if (!this._canPrompt()) { return false; } 22 | let questions = []; 23 | if (this._needArg('vulcanjsComponent') || !this._isComponentRemovable()) { 24 | questions = [...questions, ...this._getQuestions( 25 | 'vulcanjsRemovableComponentsList' 26 | )]; 27 | } 28 | return this.prompt(questions) 29 | .then((answers) => { 30 | this.props = { 31 | vulcanjsComponent: this._finalize('raw', 'vulcanjsComponent', answers), 32 | }; 33 | }); 34 | } 35 | 36 | composing () { 37 | if (!this._canWrite()) { return false; } 38 | const remover = require.resolve(`./removers/${this.props.vulcanjsComponent}`); 39 | const nextOptions = { 40 | ...this.options, 41 | ...this.props, 42 | dontAsk: true, 43 | }; 44 | return this.composeWith(remover, nextOptions); 45 | } 46 | 47 | end () { 48 | this._end(); 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/remove/removers/module.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | const ast = require('../../../lib/ast'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing () { 6 | this._assert('isVulcan'); 7 | this._assert('hasNonZeroPackages'); 8 | } 9 | 10 | _registerArguments () { 11 | // TODO: add arguments for remove 12 | } 13 | 14 | prompting () { 15 | if (!this._canPrompt()) { return false; } 16 | const questions = this._getQuestions( 17 | 'packageNameWithNumModulesList', 18 | 'moduleNameList', 19 | 'isDelete' 20 | ); 21 | return this.prompt(questions) 22 | .then((answers) => { 23 | this._assert('isDelete', answers.isDelete); 24 | this.props = { 25 | packageName: this._finalize('packageName', answers), 26 | moduleName: this._finalize('moduleName', answers), 27 | }; 28 | }); 29 | } 30 | 31 | _updateCollectionsIndex () { 32 | const modulesCollectionsPath = this._getPath( 33 | { isAbsolute: true }, 34 | 'collectionsIndex' 35 | ); 36 | const fileText = this.fs.read(collectionsIndexPath); 37 | const fileWithImportText = ast.removeImportStatement( 38 | fileText, 39 | `./${this.props.moduleName}/collection.js` 40 | ); 41 | this.fs.write( 42 | collectionsIndexPath, 43 | fileWithImportText 44 | ); 45 | } 46 | 47 | _removeModuleDir () { 48 | const sourceDir = this._getPath( 49 | { isAbsolute: true }, 50 | 'module' 51 | ); 52 | this.fs.delete(sourceDir); 53 | } 54 | 55 | writing () { 56 | if (!this._canWrite()) { return false; } 57 | this._removeModuleDir(); 58 | this._updateCollectionsIndex(); 59 | } 60 | 61 | end () { 62 | this._end(); 63 | } 64 | }; 65 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/remove/removers/package.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | 3 | module.exports = class extends VulcanGenerator { 4 | initializing () { 5 | this._assert('isVulcan'); 6 | this._assert('hasNonZeroPackages'); 7 | } 8 | 9 | _registerArguments () { 10 | // TODO: add arguments for remove 11 | } 12 | 13 | prompting () { 14 | if (!this._canPrompt()) { return false; } 15 | const questions = this._getQuestions( 16 | 'packageNameList', 17 | 'isDelete' 18 | ); 19 | return this.prompt(questions) 20 | .then((answers) => { 21 | this._assert('isDelete', answers.isDelete); 22 | this.props = { 23 | packageName: this._finalize('packageName', answers), 24 | }; 25 | }); 26 | } 27 | 28 | writing () { 29 | if (!this._canWrite()) { return false; } 30 | const sourceDir = this._getPath( 31 | { isAbsolute: true }, 32 | 'package' 33 | ); 34 | this.fs.delete(sourceDir); 35 | } 36 | 37 | end () { 38 | this._end(); 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/remove/removers/route.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../../lib/VulcanGenerator'); 2 | const ast = require('../../../lib/ast'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing () { 6 | this._assert('isVulcan'); 7 | this._assert('hasNonZeroPackages'); 8 | } 9 | 10 | _registerArguments () { 11 | // TODO: add arguments for remove 12 | } 13 | 14 | prompting () { 15 | if (!this._canPrompt()) { return false; } 16 | const questions = this._getQuestions( 17 | 'packageNameWithNumModulesList', 18 | 'routeNameList', 19 | 'isDelete' 20 | ); 21 | return this.prompt(questions) 22 | .then((answers) => { 23 | this._assert('isDelete', answers.isDelete); 24 | this.props = { 25 | packageName: this._finalize('packageName', answers), 26 | routeName: this._finalize('raw', 'routeName', answers), 27 | }; 28 | }); 29 | } 30 | 31 | _updateRoutes () { 32 | const routesPath = this._getPath( 33 | { isAbsolute: true }, 34 | 'routes' 35 | ); 36 | const oldRoutes = this.fs.read(routesPath); 37 | const newRoutes = ast.removeRoute(oldRoutes, this.props.routeName); 38 | this.fs.write( 39 | routesPath, 40 | newRoutes 41 | ); 42 | return true; 43 | } 44 | 45 | writing () { 46 | if (!this._canWrite()) { return false; } 47 | this._updateRoutes(); 48 | } 49 | 50 | end () { 51 | this._end(); 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/route/index.js: -------------------------------------------------------------------------------- 1 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 2 | const ast = require('../../lib/ast'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | initializing() { 6 | this._assert('isVulcan'); 7 | this._assert('hasNonZeroPackages'); 8 | } 9 | 10 | _registerArguments() { 11 | this._registerOptions( 12 | 'packageName', 13 | 'routeName', 14 | 'routePath', 15 | 'componentName', 16 | 'layoutName' 17 | ); 18 | } 19 | 20 | prompting() { 21 | if (!this._canPrompt()) { return false; } 22 | const argsAndQuestions = [ 23 | { arg: 'packageName', question: 'packageNameList' }, 24 | { arg: 'routeName' }, 25 | { arg: 'routePath' }, 26 | { arg: 'componentName' }, 27 | { arg: 'layoutName' }, 28 | ]; 29 | const questions = argsAndQuestions.reduce((currentQuestions, { arg, question }) => { 30 | if (this._needArg(arg)) { 31 | const questionName = question || arg; 32 | return [...currentQuestions, ...this._getQuestions(questionName)]; 33 | } 34 | return currentQuestions; 35 | }, []); 36 | return this.prompt(questions) 37 | .then((answers) => { 38 | this.props = { 39 | packageName: this._finalize('packageName', answers), 40 | componentName: this._finalize('componentName', answers), 41 | routeName: this._finalize('raw', 'routeName', answers), 42 | routePath: this._finalize('raw', 'routePath', answers), 43 | layoutName: this._finalize('raw', 'layoutName', answers), 44 | addRouteStatement: this._finalize('addRouteStatement', answers), 45 | }; 46 | }); 47 | } 48 | 49 | _updateRoutes() { 50 | const routesPath = this._getPath( 51 | { isAbsolute: true }, 52 | 'routes' 53 | ); 54 | 55 | const fileText = this.fs.read(routesPath); 56 | const fileTextWithWithImport = ast.appendCode( 57 | fileText, 58 | this.props.addRouteStatement 59 | ); 60 | this.fs.write( 61 | routesPath, 62 | fileTextWithWithImport 63 | ); 64 | } 65 | 66 | configuring() { 67 | if (!this._canConfigure()) { } 68 | } 69 | 70 | writing() { 71 | if (!this._canWrite()) { return; } 72 | this._updateRoutes(); 73 | } 74 | 75 | end() { 76 | this._end(); 77 | } 78 | }; 79 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/generators/start/index.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | const VulcanGenerator = require('../../lib/VulcanGenerator'); 3 | 4 | module.exports = class extends VulcanGenerator { 5 | 6 | default() { 7 | this.log(chalk.green('\nStarting your app... \n')); 8 | this.spawnCommandSync('meteor', ['run']); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/VulcanGenerator.js: -------------------------------------------------------------------------------- 1 | const Generator = require('yeoman-generator'); 2 | const beautify = require('gulp-beautify'); 3 | const questions = require('./questions'); 4 | const finalizers = require('./finalizers'); 5 | const makeAssertions = require('./assertions'); 6 | const storeFactory = require('./store'); 7 | const pathFinder = require('./path-finder'); 8 | const optionsManager = require('./optionsManager'); 9 | const chalk = require('chalk'); 10 | const gulpFilter = require('gulp-filter'); 11 | 12 | let store; 13 | let errors; 14 | module.exports = class VulcanGenerator extends Generator { 15 | constructor (args, options) { 16 | super(args, options); 17 | if (!store) { 18 | const allConfig = this.config.getAll(); 19 | store = storeFactory.init(allConfig); 20 | } 21 | 22 | const assertions = makeAssertions.setup(this); 23 | if (!errors) { 24 | errors = assertions.errors; 25 | } 26 | const beautified = beautify({ 27 | indent_size: 2, 28 | brace_style: 'collapse, preserve-inline', 29 | }); 30 | const jsxFilter = gulpFilter(['!**/*.jsx'], { restore: true }); 31 | this.registerTransformStream([ 32 | jsxFilter, 33 | beautified, 34 | jsxFilter.restore, 35 | ]); 36 | this._assert = assertions.assert; 37 | this._registerOptions = optionsManager.setup(this); 38 | this._finalize = finalizers.setup(this); 39 | this._getPath = pathFinder.setup(this); 40 | this._getQuestions = questions.setup(this); 41 | this._registerOptions('dontAsk'); 42 | this._registerArguments(); 43 | this.inputProps = {}; 44 | this.props = {}; 45 | } 46 | 47 | /* 48 | Helper to test if a question is necessary 49 | */ 50 | _needArg (argument) { 51 | return typeof this.options[argument] === 'undefined'; 52 | } 53 | /* 54 | State management 55 | */ 56 | 57 | _commitStore () { 58 | const storeKeys = Object.keys(store.getState()); 59 | storeKeys.forEach((key) => { 60 | this.config.set(key, store.getState()[key]); 61 | }); 62 | } 63 | 64 | _dispatch (action) { 65 | return store.dispatch(action); 66 | } 67 | 68 | /* 69 | Helpers that determine whether a task can be performed 70 | */ 71 | 72 | _canPrompt () { 73 | return this._hasNoErrors(); 74 | } 75 | 76 | _canWrite () { 77 | return this._hasNoErrors(); 78 | } 79 | 80 | _canConfigure () { 81 | return this._hasNoErrors(); 82 | } 83 | 84 | _canInstall () { 85 | return this._hasNoErrors(); 86 | } 87 | 88 | 89 | /* 90 | Error management 91 | */ 92 | 93 | _hasNoErrors () { 94 | const errorKeys = Object.keys(errors); 95 | return errorKeys.length === 0; 96 | } 97 | 98 | _logAllErrors () { 99 | const errorKeys = Object.keys(errors); 100 | const errorsArr = errorKeys.map((errorKey) => errors[errorKey]); 101 | errorsArr.forEach((error, index) => { 102 | const errorNo = `Error (${index})`; 103 | const message = `\n${errorNo}: ${chalk.red(error.message)}`; 104 | this.log(message); 105 | // this.env.error(message); 106 | }); 107 | process.exit(1); 108 | } 109 | 110 | /* 111 | Life-cycle functions 112 | */ 113 | 114 | _end () { 115 | if (!this._hasNoErrors) { this._logAllErrors(); } 116 | } 117 | 118 | _registerArguments () { } 119 | 120 | }; 121 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/assertions.js: -------------------------------------------------------------------------------- 1 | const uiText = require('./ui-text'); 2 | const makeLister = require('./lister'); 3 | 4 | const errors = {}; 5 | 6 | function setup (generatorSetup) { 7 | const generator = generatorSetup; 8 | const lister = makeLister.setup(generator); 9 | 10 | function assert (assertion, ...args) { 11 | function isVulcan () { 12 | // TODO: not imlemented yet 13 | // Idea: check for a package.json file? 14 | // if (!store.is('vulcan')) { 15 | // errors.notVulcan = { 16 | // message: uiText.errors.notVulcan, 17 | // }; 18 | // } 19 | } 20 | 21 | function notVulcan () { 22 | // if (store.is('vulcan')) { 23 | // errors.isVulcan = { 24 | // message: uiText.errors.isVulcan, 25 | // }; 26 | // } 27 | } 28 | 29 | function isPackageExists (packageName) { 30 | if (!lister.packageExists(packageName)) { 31 | errors.notPackageExists = { 32 | message: uiText.errors.notPackageExists(packageName), 33 | }; 34 | } 35 | } 36 | 37 | function notPackageExists (packageName) { 38 | if (lister.packageExists(packageName)) { 39 | errors.isPackageExists = { 40 | message: uiText.errors.isPackageExists(packageName), 41 | }; 42 | } 43 | } 44 | 45 | function isModuleExists (packageName, moduleName) { 46 | if (!lister.moduleExists(packageName, moduleName)) { 47 | errors.notModuleExists = { 48 | message: uiText.errors.notModuleExists(packageName, moduleName), 49 | }; 50 | } 51 | } 52 | 53 | function notModuleExists (packageName, moduleName) { 54 | if (lister.moduleExists(packageName, moduleName)) { 55 | errors.isModuleExists = { 56 | message: uiText.errors.isModuleExists(packageName, moduleName), 57 | }; 58 | } 59 | } 60 | 61 | function hasNonZeroPackages () { 62 | const packageNames = lister.listPackages(); 63 | if (!packageNames.length) { 64 | errors.isZeroPackages = { 65 | message: uiText.errors.isZeroPackages, 66 | }; 67 | } 68 | } 69 | 70 | function packageHasNonZeroModules (packageName) { 71 | this._assertIsPackageExists(packageName); 72 | if (!this._packageHasNonZeroModules(packageName)) { 73 | errors.hasZeroModules = { 74 | message: uiText.errors.hasZeroModules(packageName), 75 | }; 76 | } 77 | } 78 | 79 | function isDelete (isDeleting) { 80 | if (!isDeleting) { 81 | errors.hasZeroModules = { 82 | message: uiText.errors.isDelete, 83 | }; 84 | } 85 | } 86 | 87 | switch (assertion) { 88 | case 'isVulcan': return isVulcan(...args); 89 | case 'isDelete': return isDelete(...args); 90 | case 'notVulcan': return notVulcan(...args); 91 | case 'isPackageExists': return isPackageExists(...args); 92 | case 'notPackageExists': return notPackageExists(...args); 93 | case 'isModuleExists': return isModuleExists(...args); 94 | case 'notModuleExists': return notModuleExists(...args); 95 | case 'hasNonZeroPackages': return hasNonZeroPackages(...args); 96 | case 'packageHasNonZeroModules': return packageHasNonZeroModules(...args); 97 | default: return undefined; 98 | } 99 | } 100 | return { assert, errors }; 101 | } 102 | 103 | module.exports = { 104 | setup, 105 | }; 106 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/ast.js: -------------------------------------------------------------------------------- 1 | const esprima = require('esprima'); 2 | const escodegen = require('escodegen-wallaby'); 3 | const find = require('lodash/find'); 4 | 5 | const getLastImportIndex = (tree) => { 6 | let lastIndex = -1; 7 | tree.body.forEach((node, index) => { 8 | if (node.type === 'ImportDeclaration') { 9 | lastIndex = index; 10 | } 11 | }); 12 | return lastIndex; 13 | }; 14 | 15 | const parseAst = (text) => ( 16 | esprima.parseModule(text, { 17 | range: true, 18 | tokens: true, 19 | comment: true, 20 | }) 21 | ); 22 | 23 | const generateCode = (ast) => { 24 | const astWithComments = escodegen.attachComments( 25 | ast, 26 | ast.comments, 27 | ast.tokens 28 | ); 29 | return escodegen.generate( 30 | astWithComments, 31 | { 32 | comment: true, 33 | format: { index: { style: ' ' } }, 34 | } 35 | ); 36 | }; 37 | 38 | const parseModifyGenerate = (modifier) => (text, ...args) => { 39 | const ast = parseAst(text); 40 | const newAst = modifier(ast, ...args); 41 | const generated = generateCode(newAst); 42 | return generated; 43 | }; 44 | 45 | const getImportStatement = (importPath) => `import '${importPath}';`; 46 | 47 | const addImportStatement = (tree, importPath) => { 48 | const newTree = { ...tree }; 49 | const nextImportIndex = getLastImportIndex(tree) + 1; 50 | const statement = getImportStatement(importPath); 51 | const importNode = esprima.parseModule(statement); 52 | newTree.body = [ 53 | ...[...tree.body].slice(0, nextImportIndex), 54 | importNode.body[0], 55 | ...[...tree.body].slice(nextImportIndex, newTree.body.length), 56 | ]; 57 | return newTree; 58 | }; 59 | 60 | const appendCode = (tree, code) => { 61 | const newTree = { ...tree }; 62 | const newCodeAst = parseAst(code); 63 | const codeToPush = newCodeAst.body[0]; 64 | newTree.body.push(codeToPush); 65 | return newTree; 66 | }; 67 | 68 | const removeRoute = (tree, routeToRemove) => { 69 | const newTree = { ...tree }; 70 | newTree.body = tree.body.filter((node) => { 71 | if (node.type !== 'ExpressionStatement') return true; 72 | if (!node.expression) return true; 73 | const expression = node.expression; 74 | if (!expression.callee) return true; 75 | if (expression.callee.name !== 'addRoute') return true; 76 | const args = node.expression.arguments; 77 | // console.log(JSON.stringify(args, null, 2)); 78 | if (!args) return true; 79 | const properties = args[0].properties; 80 | if (!properties) return true; 81 | const namePropOfRoute = find(properties, { 82 | type: 'Property', 83 | key: { 84 | type: 'Identifier', 85 | name: 'name', 86 | }, 87 | }); 88 | if (!namePropOfRoute.value) return true; 89 | if (!namePropOfRoute.value.value) return true; 90 | return namePropOfRoute.value.value !== routeToRemove; 91 | }); 92 | return newTree; 93 | }; 94 | 95 | const removeImportStatement = (tree, importPath) => { 96 | const newTree = { ...tree }; 97 | newTree.body = tree.body.filter((node) => { 98 | if (node.type !== 'ImportDeclaration') return true; 99 | const source = node.source; 100 | if (!source) return true; 101 | if (source.type !== 'Literal') return true; 102 | return source.value !== importPath; 103 | }); 104 | return newTree; 105 | }; 106 | 107 | 108 | module.exports = { 109 | getLastImportIndex, 110 | addImportStatement: parseModifyGenerate(addImportStatement), 111 | appendCode: parseModifyGenerate(appendCode), 112 | removeRoute: parseModifyGenerate(removeRoute), 113 | removeImportStatement: parseModifyGenerate(removeImportStatement), 114 | }; 115 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/common.js: -------------------------------------------------------------------------------- 1 | const alphabeticalSort = (a, b) => { 2 | const aLower = a.toLowerCase(); 3 | const bLower = b.toLowerCase(); 4 | if (aLower < bLower) return -1; 5 | if (aLower > bLower) return 1; 6 | return 0; 7 | }; 8 | 9 | const numModulesSort = (a, b) => { 10 | const aHasNonZero = a.numModules > 0; 11 | const bHasNonZero = b.numModules > 0; 12 | if (aHasNonZero && bHasNonZero) return 0; 13 | if (!aHasNonZero && !bHasNonZero) return 0; 14 | if (!aHasNonZero && bHasNonZero) return 1; 15 | /* if (aHasNonZero && !bHasNonZero) */ return -1; 16 | }; 17 | 18 | const getSetFromArr = (arr) => { 19 | const set = {}; 20 | arr.forEach((elem) => { 21 | set[elem] = true; 22 | }); 23 | return set; 24 | }; 25 | 26 | const reactExtensions = ['jsx', 'js']; 27 | 28 | const cloningOptions = ['fast', 'complete']; 29 | 30 | const packageManagers = ['yarn', 'npm']; 31 | 32 | const visitorTypes = ['Guests', 'Members', 'Admins']; 33 | 34 | const schemaPropertyTypes = ['String', 'Number', 'Boolean', 'Array', 'Object', 'Custom']; 35 | 36 | const moduleParts = ['fragments', 'resolvers', 'mutations', 'schema']; 37 | 38 | const vulcanjsRemovableComponents = [ 39 | 'route', 40 | 'module', 41 | 'package', 42 | ]; 43 | 44 | const vulcanjsListableComponents = [ 45 | 'packages', 46 | //'routes', 47 | ]; 48 | 49 | const allChoiceValue = '__vjs_all'; 50 | const allChoice = { name: '[ALL]', value: allChoiceValue }; 51 | 52 | 53 | const getDefaultChoiceIndex = (choices, option) => { 54 | const index = choices.findIndex((elem) => elem === option); 55 | return Math.max(index, 0); 56 | }; 57 | 58 | const exposed = { 59 | alphabeticalSort, 60 | numModulesSort, 61 | reactExtensions, 62 | packageManagers, 63 | visitorTypes, 64 | schemaPropertyTypes, 65 | getDefaultChoiceIndex, 66 | getSetFromArr, 67 | vulcanjsRemovableComponents, 68 | vulcanjsListableComponents, 69 | moduleParts, 70 | allChoiceValue, 71 | allChoice, 72 | cloningOptions, 73 | }; 74 | 75 | module.exports = exposed; 76 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/filters.js: -------------------------------------------------------------------------------- 1 | const dashify = require('dashify'); 2 | const camelCase = require('camelcase'); 3 | const pascalCase = require('pascal-case'); 4 | 5 | function packageName(toFilter) { 6 | return dashify(toFilter); 7 | } 8 | 9 | function appName(toFilter) { 10 | return dashify(toFilter); 11 | } 12 | 13 | function moduleName(toFilter) { 14 | return camelCase(toFilter); 15 | } 16 | 17 | function componentName(toFilter) { 18 | return pascalCase(toFilter); 19 | } 20 | 21 | function filter(filterType, toFilter) { 22 | switch (filterType) { 23 | case 'packageName': return packageName(toFilter); 24 | case 'appName': return appName(toFilter); 25 | case 'moduleName': return moduleName(toFilter); 26 | case 'componentName': return componentName(toFilter); 27 | default: return toFilter; 28 | } 29 | } 30 | 31 | module.exports = { 32 | filter, 33 | }; 34 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/lister.js: -------------------------------------------------------------------------------- 1 | /** 2 | * List and count elements of the application (packages, modules, routes etc.) 3 | */ 4 | const fs = require('fs'); 5 | const path = require('path'); 6 | const pathFinder = require('./path-finder'); 7 | const chalk = require('chalk'); 8 | 9 | function isDirectory(dirPath) { 10 | return fs.lstatSync(dirPath).isDirectory(); 11 | } 12 | function isNotPrivate(dirName) { 13 | return !/^_/.test(dirName); 14 | } 15 | function listFolders(dirPath) { 16 | try { 17 | const folderContent = fs.readdirSync(dirPath); 18 | const folders = folderContent.filter((folderName) => isDirectory(path.join(dirPath, folderName))); 19 | const validFolders = folders.filter(isNotPrivate); 20 | return validFolders; 21 | } catch (err) { 22 | console.log(chalk.red(`Could not find or open folder ${dirPath}`)); 23 | console.log(err); 24 | return []; 25 | } 26 | } 27 | 28 | function setup(generatorSetup) { 29 | const getPath = pathFinder.setup(generatorSetup); 30 | 31 | function listPackages() { 32 | const appPackagesPath = getPath({ isAbsolute: true }, 'packages'); 33 | const folders = listFolders(appPackagesPath); 34 | return folders; 35 | } 36 | function listModules(pkgName) { 37 | const packageModulesPath = pathFinder.findModules(generatorSetup, { isAbsolute: true }, pkgName); 38 | return listFolders(packageModulesPath); 39 | } 40 | function listAllModules() { 41 | const packageNames = listPackages(); 42 | return packageNames.reduce((allModules, packageName) => [...allModules, ...listModules(packageName)], []); 43 | } 44 | function listPackagesWithNbModules() { 45 | const packages = listPackages(); 46 | return packages.map((pkgName) => ({ 47 | name: pkgName, 48 | numModules: listFolders(pathFinder.findModules(generatorSetup, { isAbsolute: true }, pkgName)), 49 | })); 50 | } 51 | 52 | function countRoutes(pkgName) { 53 | const packageRoutesPath = pathFinder.findRoutes(generatorSetup, { isAbsolute: true }, pkgName); 54 | // TODO: handle errors if the filename has been modified 55 | try { 56 | const fileContent = fs.readFileSync(packageRoutesPath, { encoding: 'utf-8' }); 57 | const routesCount = (fileContent.match(/addRoute\(/g) || []).length; 58 | return routesCount; 59 | } catch (err) { 60 | console.log(chalk.red(`Could not find or open routes definition for package ${pkgName}`)); 61 | console.log(err); 62 | return -1; 63 | } 64 | } 65 | function countModules(pkgName) { 66 | return listModules(pkgName).length; 67 | } 68 | 69 | function packageExists(pkgName) { 70 | const packageNames = listPackages(); 71 | return packageNames.includes(pkgName); 72 | } 73 | 74 | function moduleExists(pkgName, moduleName) { 75 | const moduleNames = listModules(pkgName); 76 | return moduleNames.includes(moduleName); 77 | } 78 | 79 | return { 80 | listModules, 81 | listAllModules, 82 | listPackages, 83 | listPackagesWithNbModules, 84 | countRoutes, 85 | countModules, 86 | packageExists, 87 | moduleExists, 88 | }; 89 | } 90 | 91 | module.exports = { setup } 92 | ; 93 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/optionsManager.js: -------------------------------------------------------------------------------- 1 | const uiText = require('./ui-text'); 2 | 3 | const allOptions = { 4 | appName: { 5 | type: String, 6 | required: false, 7 | alias: 'n', 8 | desc: uiText.descriptions.appName, 9 | }, 10 | packageName: { 11 | type: String, 12 | required: false, 13 | alias: 'p', 14 | desc: uiText.descriptions.packageName, 15 | }, 16 | moduleName: { 17 | type: String, 18 | required: false, 19 | alias: 'm', 20 | desc: uiText.descriptions.moduleName, 21 | }, 22 | componentName: { 23 | type: String, 24 | required: false, 25 | alias: 'c', 26 | desc: uiText.descriptions.componentName, 27 | }, 28 | layoutName: { 29 | type: String, 30 | required: false, 31 | alias: 'l', 32 | desc: uiText.descriptions.layoutName, 33 | }, 34 | routeName: { 35 | type: String, 36 | required: false, 37 | alias: 'r', 38 | desc: uiText.descriptions.routeName, 39 | }, 40 | routePath: { 41 | type: String, 42 | required: false, 43 | alias: 'rp', 44 | desc: uiText.descriptions.routePath, 45 | }, 46 | packageManager: { 47 | type: String, 48 | required: false, 49 | alias: 'pm', 50 | desc: uiText.descriptions.packageManager, 51 | }, 52 | dontAsk: { 53 | type: Boolean, 54 | required: false, 55 | alias: 'd', 56 | desc: uiText.descriptions.dontAsk, 57 | }, 58 | vulcanjsRemovableComponent: { 59 | type: String, 60 | required: false, 61 | alias: 'vc', 62 | desc: uiText.descriptions.vulcanjsRemovableComponent, 63 | }, 64 | vulcanjsListableComponent: { 65 | type: String, 66 | required: false, 67 | alias: 'vc', 68 | desc: uiText.descriptions.vulcanjsListableComponent, 69 | }, 70 | }; 71 | 72 | function setup (generatorSetup) { 73 | const generator = generatorSetup; 74 | function registerSingleOption (optionName) { 75 | generator.option( 76 | optionName, 77 | allOptions[optionName] 78 | ); 79 | } 80 | function register (...optionNames) { 81 | optionNames.forEach((optionName) => { 82 | registerSingleOption(optionName); 83 | }); 84 | } 85 | return register; 86 | } 87 | 88 | module.exports = { 89 | setup, 90 | allOptions, 91 | }; 92 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/reducers.js: -------------------------------------------------------------------------------- 1 | const Redux = require('redux'); 2 | const _ = require('lodash'); 3 | 4 | 5 | const appName = (state = '', action) => { 6 | switch (action.type) { 7 | case 'SET_APP_NAME': return action.appName; 8 | default: return state; 9 | } 10 | }; 11 | 12 | const isVulcan = (state = false, action) => { 13 | switch (action.type) { 14 | case 'SET_IS_VULCAN_TRUE': return true; 15 | default: return state; 16 | } 17 | }; 18 | 19 | const packageManager = (state = 'yarn', action) => { 20 | switch (action.type) { 21 | case 'SET_PACKAGE_MANAGER': return action.packageManager; 22 | default: return state; 23 | } 24 | }; 25 | 26 | const reactExtension = (state = 'jsx', action) => { 27 | switch (action.type) { 28 | case 'SET_REACT_EXTENSION': return action.reactExtension; 29 | default: return state; 30 | } 31 | }; 32 | 33 | 34 | const reducers = Redux.combineReducers({ 35 | appName, 36 | isVulcan, 37 | packageManager, 38 | reactExtension, 39 | }); 40 | 41 | module.exports = reducers; 42 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/repairs.js: -------------------------------------------------------------------------------- 1 | let generator; 2 | 3 | function setup (generatorSetup) { 4 | generator = generatorSetup; 5 | } 6 | 7 | function repair (answers) { 8 | 9 | } 10 | 11 | module.exports = { 12 | setup, 13 | repair, 14 | }; 15 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/store.js: -------------------------------------------------------------------------------- 1 | const Redux = require('redux'); 2 | const logger = require('redux-node-logger'); 3 | const reducers = require('./reducers'); 4 | const filter = require('./filters').filter; 5 | const common = require('./common'); 6 | 7 | let store = {}; 8 | 9 | function init (savedState) { 10 | if (process.env.VULCANJS_SEE_REDUX_LOGS) { 11 | store = Redux.createStore( 12 | reducers, 13 | savedState, 14 | Redux.applyMiddleware(logger()) 15 | ); 16 | } else { 17 | store = Redux.createStore( 18 | reducers, 19 | savedState 20 | ); 21 | } 22 | return store; 23 | } 24 | 25 | function is (checkType, ...args) { 26 | function vulcan () { 27 | return !!store.getState().isVulcan; 28 | } 29 | 30 | function packageExists (packageName) { 31 | const filteredPackageName = filter('packageName', packageName); 32 | return !!store.getState().packages[filteredPackageName]; 33 | } 34 | 35 | function moduleExists (packageName, moduleName) { 36 | const filteredModuleName = filter('moduleName', moduleName); 37 | return (packageExists(packageName)) && 38 | !!store.getState().packages[packageName].modules[filteredModuleName]; 39 | } 40 | 41 | switch (checkType) { 42 | case 'packageExists': return packageExists(...args); 43 | case 'moduleExists': return moduleExists(...args); 44 | case 'vulcan': return vulcan(...args); 45 | default: return undefined; 46 | } 47 | } 48 | 49 | function get (checkType, ...args) { 50 | function reactExtension () { 51 | return store.getState().reactExtension; 52 | } 53 | 54 | function packageNames () { 55 | const packages = store.getState().packages; 56 | const packageNamesToGet = Object.keys(packages); 57 | return packageNamesToGet.sort(common.alphabeticalSort); 58 | } 59 | 60 | function getPackage (packageName) { 61 | return store.getState().packages[packageName]; 62 | } 63 | 64 | function moduleNames (packageName) { 65 | const thePackage = getPackage(packageName); 66 | const modules = is('packageExists', packageName) ? 67 | thePackage.modules : 68 | {}; 69 | const moduleNamesToGet = Object.keys(modules); 70 | return moduleNamesToGet.sort(common.alphabeticalSort); 71 | } 72 | 73 | function packageNamesWithNumModules () { 74 | const packageNamesList = packageNames(); 75 | const packageNamesWithModules = packageNamesList.map((packageName) => ({ 76 | name: packageName, 77 | numModules: moduleNames(packageName).length, 78 | })); 79 | return packageNamesWithModules; 80 | } 81 | 82 | function routeNames (packageName) { 83 | const thePackage = getPackage(packageName); 84 | const theRoutes = thePackage.routes; 85 | const routeNamesToGet = Object.keys(theRoutes); 86 | return routeNamesToGet.sort(common.alphabeticalSort); 87 | } 88 | 89 | function getRoutes (packageName) { 90 | const thePackage = getPackage(packageName); 91 | const theRoutes = thePackage.routes; 92 | return routeNames(packageName).map((routeName) => ({ 93 | name: routeName, 94 | content: theRoutes[routeName], 95 | })); 96 | } 97 | 98 | switch (checkType) { 99 | case 'reactExtension': return reactExtension(...args); 100 | case 'packageNames': return packageNames(...args); 101 | case 'moduleNames': return moduleNames(...args); 102 | case 'routeNames': return routeNames(...args); 103 | case 'package': return getPackage(...args); 104 | case 'routes': return getRoutes(...args); 105 | case 'packageNamesWithNumModules': return packageNamesWithNumModules(...args); 106 | default: return undefined; 107 | } 108 | } 109 | 110 | function num (checkType, ...args) { 111 | function routes (packageName) { 112 | const routeNames = get('routeNames', packageName); 113 | return routeNames.length; 114 | } 115 | 116 | function modules (packageName) { 117 | const moduleNames = get('moduleNames', packageName); 118 | return moduleNames.length; 119 | } 120 | 121 | switch (checkType) { 122 | case 'routes': return routes(...args); 123 | case 'modules': return modules(...args); 124 | default: return undefined; 125 | } 126 | } 127 | 128 | function has (checkType, ...args) { 129 | function nonZeroPackages () { 130 | const packageNames = get('packageNames'); 131 | return Object.keys(packageNames).length > 0; 132 | } 133 | 134 | function nonZeroModulesInPackage (packageName) { 135 | if (!this._isPackageExists(packageName)) return false; 136 | const thePackage = this._getPackage(packageName); 137 | const moduleNames = Object.keys(thePackage.modules); 138 | return moduleNames.length > 0; 139 | } 140 | 141 | switch (checkType) { 142 | case 'nonZeroModulesInPackage': return nonZeroModulesInPackage(...args); 143 | case 'nonZeroPackages': return nonZeroPackages(...args); 144 | default: return undefined; 145 | } 146 | } 147 | 148 | module.exports = { 149 | init, 150 | is, 151 | has, 152 | get, 153 | num, 154 | }; 155 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/styles.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | 3 | module.exports = { 4 | h1: chalk.green, 5 | }; 6 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/ui-text.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | 3 | const descriptions = { 4 | appName: 'The name of your app', 5 | reactExtension: 'Default react component extension', 6 | packageManager: 'Preferred package manager', 7 | packageName: 'The name of the package', 8 | moduleName: 'The name of the module', 9 | componentName: 'The name of your component', 10 | routeName: 'The name of your route', 11 | routePath: 'The path of your route', 12 | layoutName: 'The layout that will wrap this route\'s component', 13 | isRegisterComponent: 'Set to true of you want to register the component to Vulcan.', 14 | isAddComponentToStoryBook: 'Set to true of you want to add the component to storybook.', 15 | componentType: 'The type of the component. Is it a pure function, or a class?', 16 | vulcanDependencies: 'The vulcan packages that your application depends on', 17 | isPackageAutoAdd: 'Set to true if you want your package to be added to .meteor/packages', 18 | dontAsk: 'Set to true if you want the generators to skip prompting for the arguments you have supplied from the command line', 19 | vulcanjsRemovableComponent: 'The part of the app that you want to remove', 20 | vulcanjsListableComponent: 'The part of the app that you want to list', 21 | }; 22 | 23 | const messages = { 24 | appName: 'App name', 25 | reactExtension: 'React extension', 26 | packageManager: 'Package manager', 27 | packageName: 'Package name', 28 | moduleName: 'Module name', 29 | componentName: 'Component name', 30 | isRegisterComponent: 'Register component', 31 | componentType: 'Component type', 32 | routeName: 'Route name', 33 | routePath: 'Route path', 34 | layoutName: 'Layout name', 35 | vulcanDependencies: 'Vulcan dependencies', 36 | isPackageAutoAdd: 'Add to .meteor/packages', 37 | storyBookSetupStatus: 'Looks like you havent set up your react storybook. Would you like to do it now?', 38 | isAddComponentToStoryBook: 'Add component to storybook', 39 | isAddCustomSchemaProperty: 'Add a custom property to the collection', 40 | isAddCustomMutations: 'Add custom mutations', 41 | isAddCustomResolvers: 'Add custom resolvers', 42 | isAddAnotherCustomSchemaProperty: 'Add another custom property to the collection', 43 | schemaPropertyName: 'Property name', 44 | isSchemaPropertyHidden: 'Property is hidden', 45 | schemaPropertyLabel: 'Property label', 46 | schemaPropertyType: 'Property type', 47 | isSchemaPropertyOptional: 'Property is optional', 48 | schemaPropertyViewableBy: 'Property viewable by', 49 | schemaPropertyInsertableBy: 'Property insertable by', 50 | schemaPropertyEditableBy: 'Property editable by', 51 | vulcanjsRemovableComponents: 'Part to remove', 52 | vulcanjsListableComponents: 'Part to list', 53 | isDelete: `${chalk.red('WARNING:')} You are about to destroy some code. Have you committed your code?`, 54 | }; 55 | 56 | const errors = { 57 | notVulcan: 'This is not a Vulcan.js project directory. \nYou cannot run Vulcan.js generators outside of a Vulcan.js project directory.', 58 | isVulcan: 'You are already in a Vulcan.js project directory. \nYou may not run this command inside a Vulcan.js project directory.', 59 | notPackageExists: (packageName) => (`The package ${packageName} does not exist. \nIf you'd like to work on this package, you should create it first by running: ${chalk.green(`vulcan g package ${packageName}`)}`), 60 | isPackageExists: (packageName) => `A package with the name: '${packageName}' already exists.`, 61 | notModuleExists: (packageName, moduleName) => (`A module with the name: '${moduleName}' under the package '${packageName}' does not exist. \nIf you'd like to work on this module, you should first run ${chalk.green(`vulcan g module ${packageName} ${moduleName}`)}.`), 62 | isModuleExists: (packageName, moduleName) => (`A module with the name '${moduleName}' under the package '${packageName}' already exists.`), 63 | isZeroPackages: `The command you just ran requires at least 1 custom package to be present in your app. \nTo create a package, run ${chalk.green('vulcan g package')}`, 64 | hasZeroModules: (packageName) => `The package '${packageName} has no modules.)}`, 65 | isEmpty: 'This cannot be empty.', 66 | isDelete: 'Cannot delete uncommitted code', 67 | }; 68 | 69 | module.exports = { 70 | descriptions, 71 | messages, 72 | errors, 73 | }; 74 | -------------------------------------------------------------------------------- /src/generator-vulcanjs/lib/validations.js: -------------------------------------------------------------------------------- 1 | const uiText = require('./ui-text'); 2 | const makeLister = require('./lister'); 3 | 4 | function combineValidators(...fns) { 5 | return function reducedValidator(input) { 6 | return fns.reduce( 7 | (acc, curValidator) => { 8 | if (typeof acc === 'string') return acc; 9 | return curValidator(input); 10 | }, 11 | true 12 | ); 13 | }; 14 | } 15 | 16 | function setup(generatorSetup) { 17 | const generator = generatorSetup; 18 | const lister = makeLister.setup(generator); 19 | 20 | const assertNonEmpty = (input) => { 21 | if (input) return true; 22 | return uiText.errors.isEmpty; 23 | }; 24 | 25 | const assertNotPackageExists = (packageName) => { 26 | if (!lister.packageExists(packageName)) return true; 27 | return uiText.errors.isPackageExists(packageName); 28 | }; 29 | 30 | const assertNotModuleExists = (packageName, moduleName) => { 31 | if (!lister.moduleExists(packageName, moduleName)) return true; 32 | return uiText.errors.isModuleExists(packageName, moduleName); 33 | }; 34 | 35 | const generateNotModuleExists = (packageName) => ( 36 | (input) => assertNotModuleExists(packageName, input) 37 | ); 38 | return { 39 | assertNonEmpty, 40 | assertNotPackageExists, 41 | assertNotModuleExists, 42 | generateNotModuleExists, 43 | }; 44 | } 45 | 46 | module.exports = { 47 | combineValidators, 48 | setup, 49 | }; 50 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const yeoman = require('yeoman-environment'); 4 | const parseArgs = require('minimist'); 5 | 6 | const argsManager = require('./argsManager'); 7 | 8 | const appGenerator = require.resolve('./generator-vulcanjs/generators/app'); 9 | const packageGenerator = require.resolve('./generator-vulcanjs/generators/package'); 10 | const moduleGenerator = require.resolve('./generator-vulcanjs/generators/module'); 11 | const componentGenerator = require.resolve('./generator-vulcanjs/generators/component'); 12 | const routeGenerator = require.resolve('./generator-vulcanjs/generators/route'); 13 | const remover = require.resolve('./generator-vulcanjs/generators/remove'); 14 | const lister = require.resolve('./generator-vulcanjs/generators/list'); 15 | 16 | const env = yeoman.createEnv(); 17 | 18 | function runWithOptions (generator, extraOptions, callback) { 19 | const optionsForGenerators = parseArgs(process.argv.slice(2)); 20 | const finalOptions = {}; 21 | Object.assign(finalOptions, optionsForGenerators, extraOptions); 22 | return env.run(generator, finalOptions, callback); 23 | } 24 | 25 | const action = argsManager.getAction(); 26 | 27 | const componentNamesToGeneratorRegisters = { 28 | package: () => { env.register(packageGenerator, 'package'); }, 29 | app: () => { env.register(appGenerator, 'app'); }, 30 | module: () => { env.register(moduleGenerator, 'module'); }, 31 | component: () => { env.register(componentGenerator, 'component'); }, 32 | route: () => { env.register(routeGenerator, 'route'); }, 33 | remove: () => { env.register(remover, 'remove'); }, 34 | list: () => { env.register(lister, 'list'); }, 35 | }; 36 | 37 | function registerGenerator (componentName) { 38 | const registerFn = componentNamesToGeneratorRegisters[componentName]; 39 | registerFn(); 40 | } 41 | 42 | function run () { 43 | if (action.type === 'generate') { 44 | if (action.component === 'package') { 45 | registerGenerator('package'); 46 | return runWithOptions('package', { 47 | packageName: action.args[0], 48 | }); 49 | } else if (action.component === 'module') { 50 | registerGenerator('module'); 51 | return runWithOptions('module', { 52 | packageName: action.args[0], 53 | moduleName: action.args[1], 54 | }); 55 | } else if (action.component === 'component') { 56 | registerGenerator('component'); 57 | return runWithOptions('component', { 58 | packageName: action.args[0], 59 | componentName: action.args[1], 60 | }); 61 | } else if (action.component === 'route') { 62 | registerGenerator('route'); 63 | return runWithOptions('route', { 64 | packageName: action.args[0], 65 | routeName: action.args[1], 66 | routePath: action.args[2], 67 | componentName: action.args[3], 68 | layoutName: action.args[4], 69 | }); 70 | } 71 | } else if (action.type === 'remove') { 72 | registerGenerator('remove'); 73 | if (action.component === 'package') { 74 | return runWithOptions('remove', { 75 | vulcanjsComponent: 'package', 76 | packageName: action.args[0], 77 | }); 78 | } else if (action.component === 'module') { 79 | return runWithOptions('remove', { 80 | vulcanjsComponent: 'module', 81 | packageName: action.args[0], 82 | moduleName: action.args[1], 83 | }); 84 | } else if (action.component === 'route') { 85 | return runWithOptions('remove', { 86 | vulcanjsComponent: 'route', 87 | packageName: action.args[0], 88 | routeName: action.args[1], 89 | }); 90 | } 91 | return runWithOptions('remove'); 92 | } else if (action.type === 'create') { 93 | registerGenerator('app'); 94 | return runWithOptions('app', { 95 | appName: action.args[0], 96 | }); 97 | } else if (action.type === 'list') { 98 | registerGenerator('list'); 99 | return runWithOptions('list', { 100 | vulcanjsComponent: action.component, 101 | packageName: action.args[0], 102 | }); 103 | } else if (action.type === 'unshallow') { 104 | registerGenerator('unshallow'); 105 | return runWithOptions('unshallow', { 106 | vulcanjsComponent: action.component, 107 | }); 108 | } 109 | } 110 | 111 | run(); 112 | -------------------------------------------------------------------------------- /test/semi-automatic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Will create a demo app in the ../_demo-app folder" 3 | cd ../ 4 | vulcan create _demo-app 5 | cd _demo-app 6 | npm i 7 | echo "Create package zoo" 8 | vulcan g package zoo 9 | echo "Create modules gorilla, lion, zebra" 10 | vulcan generate module zoo gorilla 11 | vulcan g module zoo lion 12 | vulcan g module zoo zebra 13 | echo "Create module dog and delete it" 14 | vulcan g module zoo dog 15 | vulcan remove module zoo dog 16 | 17 | echo "Create components" 18 | vulcan g component zoo GorillaHome 19 | vulcan g component zoo LionMane 20 | vulcan g component zoo ZebraStrips 21 | 22 | echo "Create route gorilla Home" 23 | vulcan g route zoo gorilla-home /gorilla-home GorillaHome DefaultLayout 24 | #echo "Create component ZebraFangs and delete it" 25 | #vulcan g component zoo ZebraFrangs 26 | #vulcan r components zoo ZebraFangs 27 | 28 | echo "Create package poacher and delete it" 29 | vulcan g package poacher 30 | vulcan r package poacher 31 | 32 | echo "Packages summary" 33 | vulcan list packages 34 | meteor add zoo 35 | meteor remove getting-started 36 | npm run start --------------------------------------------------------------------------------