|
| 1 | +/** |
| 2 | + * Generate an array of files to expect from a set of options |
| 3 | + * |
| 4 | + * @param {Object} options - generator options |
| 5 | + * @return {Array} - array of files |
| 6 | + * |
| 7 | + */ |
| 8 | +export function app(options) { |
| 9 | + var mapping = { |
| 10 | + stylesheet: { |
| 11 | + sass: 'scss', |
| 12 | + stylus: 'styl', |
| 13 | + less: 'less', |
| 14 | + css: 'css' |
| 15 | + }, |
| 16 | + markup: { |
| 17 | + jade: 'jade', |
| 18 | + html: 'html' |
| 19 | + }, |
| 20 | + script: { |
| 21 | + js: 'js', |
| 22 | + ts: 'ts' |
| 23 | + } |
| 24 | + }, |
| 25 | + files = []; |
| 26 | + |
| 27 | + /** |
| 28 | + * Generate an array of OAuth files based on type |
| 29 | + * |
| 30 | + * @param {String} type - type of oauth |
| 31 | + * @return {Array} - array of files |
| 32 | + * |
| 33 | + */ |
| 34 | + var oauthFiles = function(type) { |
| 35 | + return [ |
| 36 | + 'server/auth/' + type + '/index.js', |
| 37 | + 'server/auth/' + type + '/passport.js', |
| 38 | + ]; |
| 39 | + }; |
| 40 | + |
| 41 | + |
| 42 | + var script = mapping.script[options.transpiler === 'ts' ? 'ts' : 'js'], |
| 43 | + markup = mapping.markup[options.markup], |
| 44 | + stylesheet = mapping.stylesheet[options.stylesheet], |
| 45 | + models = options.models ? options.models : options.odms[0]; |
| 46 | + |
| 47 | + /* Core Files */ |
| 48 | + files = files.concat([ |
| 49 | + 'client/.htaccess', |
| 50 | + 'client/favicon.ico', |
| 51 | + 'client/robots.txt', |
| 52 | + 'client/index.html', |
| 53 | + 'client/app/app.' + script, |
| 54 | + 'client/app/app.' + stylesheet, |
| 55 | + 'client/app/main/main.' + script, |
| 56 | + 'client/app/main/main.' + markup, |
| 57 | + 'client/app/main/main.' + stylesheet, |
| 58 | + 'client/app/main/main.controller.' + script, |
| 59 | + 'client/app/main/main.controller.spec.' + script, |
| 60 | + 'client/assets/images/yeoman.png', |
| 61 | + 'client/components/footer/footer.' + stylesheet, |
| 62 | + 'client/components/footer/footer.' + markup, |
| 63 | + 'client/components/footer/footer.directive.' + script, |
| 64 | + 'client/components/navbar/navbar.' + markup, |
| 65 | + 'client/components/navbar/navbar.controller.' + script, |
| 66 | + 'client/components/navbar/navbar.directive.' + script, |
| 67 | + 'client/components/util/util.module.' + script, |
| 68 | + 'client/components/util/util.service.' + script, |
| 69 | + 'server/.jshintrc', |
| 70 | + 'server/.jshintrc-spec', |
| 71 | + 'server/app.js', |
| 72 | + 'server/index.js', |
| 73 | + 'server/routes.js', |
| 74 | + 'server/api/thing/index.js', |
| 75 | + 'server/api/thing/index.spec.js', |
| 76 | + 'server/api/thing/thing.controller.js', |
| 77 | + 'server/api/thing/thing.integration.js', |
| 78 | + 'server/components/errors/index.js', |
| 79 | + 'server/config/local.env.js', |
| 80 | + 'server/config/local.env.sample.js', |
| 81 | + 'server/config/express.js', |
| 82 | + 'server/config/environment/index.js', |
| 83 | + 'server/config/environment/development.js', |
| 84 | + 'server/config/environment/production.js', |
| 85 | + 'server/config/environment/test.js', |
| 86 | + 'server/config/environment/shared.js', |
| 87 | + 'server/views/404.' + markup, |
| 88 | + 'e2e/main/main.po.js', |
| 89 | + 'e2e/main/main.spec.js', |
| 90 | + 'e2e/components/navbar/navbar.po.js', |
| 91 | + '.babelrc', |
| 92 | + '.bowerrc', |
| 93 | + '.buildignore', |
| 94 | + '.editorconfig', |
| 95 | + '.gitattributes', |
| 96 | + '.gitignore', |
| 97 | + '.travis.yml', |
| 98 | + '.jscsrc', |
| 99 | + '.yo-rc.json', |
| 100 | + 'Gruntfile.js', |
| 101 | + 'package.json', |
| 102 | + 'bower.json', |
| 103 | + 'karma.conf.js', |
| 104 | + 'mocha.conf.js', |
| 105 | + 'protractor.conf.js', |
| 106 | + 'README.md' |
| 107 | + ]); |
| 108 | + |
| 109 | + /* TypeScript */ |
| 110 | + if (options.transpiler === 'ts') { |
| 111 | + files = files.concat([ |
| 112 | + 'tsconfig.client.test.json', |
| 113 | + 'tsconfig.client.json', |
| 114 | + 'tsd.json', |
| 115 | + 'tsd_test.json', |
| 116 | + 'client/tslint.json' |
| 117 | + ]); |
| 118 | + } else { |
| 119 | + files = files.concat([ |
| 120 | + 'client/.jshintrc' |
| 121 | + ]); |
| 122 | + } |
| 123 | + |
| 124 | + /* Ui-Router */ |
| 125 | + if (options.router === 'uirouter') { |
| 126 | + files = files.concat([ |
| 127 | + 'client/components/ui-router/ui-router.mock.' + script |
| 128 | + ]); |
| 129 | + } |
| 130 | + |
| 131 | + /* Ui-Bootstrap */ |
| 132 | + if (options.uibootstrap) { |
| 133 | + files = files.concat([ |
| 134 | + 'client/components/modal/modal.' + markup, |
| 135 | + 'client/components/modal/modal.' + stylesheet, |
| 136 | + 'client/components/modal/modal.service.' + script |
| 137 | + ]); |
| 138 | + } |
| 139 | + |
| 140 | + /* Models - Mongoose or Sequelize */ |
| 141 | + if (models) { |
| 142 | + files = files.concat([ |
| 143 | + 'server/api/thing/thing.model.js', |
| 144 | + 'server/api/thing/thing.events.js', |
| 145 | + 'server/config/seed.js' |
| 146 | + ]); |
| 147 | + } |
| 148 | + |
| 149 | + /* Sequelize */ |
| 150 | + if (options.odms.indexOf('sequelize') !== -1) { |
| 151 | + files = files.concat([ |
| 152 | + 'server/sqldb/index.js' |
| 153 | + ]); |
| 154 | + } |
| 155 | + |
| 156 | + /* Authentication */ |
| 157 | + if (options.auth) { |
| 158 | + files = files.concat([ |
| 159 | + 'client/app/account/account.' + script, |
| 160 | + 'client/app/account/login/login.' + markup, |
| 161 | + 'client/app/account/login/login.controller.' + script, |
| 162 | + 'client/app/account/settings/settings.' + markup, |
| 163 | + 'client/app/account/settings/settings.controller.' + script, |
| 164 | + 'client/app/account/signup/signup.' + markup, |
| 165 | + 'client/app/account/signup/signup.controller.' + script, |
| 166 | + 'client/app/admin/admin.' + markup, |
| 167 | + 'client/app/admin/admin.' + stylesheet, |
| 168 | + 'client/app/admin/admin.module.' + script, |
| 169 | + 'client/app/admin/admin.router.' + script, |
| 170 | + 'client/app/admin/admin.controller.' + script, |
| 171 | + 'client/components/auth/auth.module.' + script, |
| 172 | + 'client/components/auth/auth.service.' + script, |
| 173 | + 'client/components/auth/interceptor.service.' + script, |
| 174 | + 'client/components/auth/router.decorator.' + script, |
| 175 | + 'client/components/auth/user.service.' + script, |
| 176 | + 'client/components/mongoose-error/mongoose-error.directive.' + script, |
| 177 | + 'server/api/user/index.js', |
| 178 | + 'server/api/user/index.spec.js', |
| 179 | + 'server/api/user/user.controller.js', |
| 180 | + 'server/api/user/user.integration.js', |
| 181 | + 'server/api/user/user.model.js', |
| 182 | + 'server/api/user/user.model.spec.js', |
| 183 | + 'server/api/user/user.events.js', |
| 184 | + 'server/auth/index.js', |
| 185 | + 'server/auth/auth.service.js', |
| 186 | + 'server/auth/local/index.js', |
| 187 | + 'server/auth/local/passport.js', |
| 188 | + 'e2e/account/login/login.po.js', |
| 189 | + 'e2e/account/login/login.spec.js', |
| 190 | + 'e2e/account/logout/logout.spec.js', |
| 191 | + 'e2e/account/signup/signup.po.js', |
| 192 | + 'e2e/account/signup/signup.spec.js' |
| 193 | + ]); |
| 194 | + } |
| 195 | + |
| 196 | + if (options.oauth && options.oauth.length) { |
| 197 | + /* OAuth (see oauthFiles function above) */ |
| 198 | + options.oauth.forEach(function(type, i) { |
| 199 | + files = files.concat(oauthFiles(type.replace('Auth', ''))); |
| 200 | + }); |
| 201 | + |
| 202 | + |
| 203 | + files = files.concat([ |
| 204 | + 'client/components/oauth-buttons/oauth-buttons.' + stylesheet, |
| 205 | + 'client/components/oauth-buttons/oauth-buttons.' + markup, |
| 206 | + 'client/components/oauth-buttons/oauth-buttons.controller.' + script, |
| 207 | + 'client/components/oauth-buttons/oauth-buttons.controller.spec.' + script, |
| 208 | + 'client/components/oauth-buttons/oauth-buttons.directive.' + script, |
| 209 | + 'client/components/oauth-buttons/oauth-buttons.directive.spec.' + script, |
| 210 | + 'e2e/components/oauth-buttons/oauth-buttons.po.js' |
| 211 | + ]); |
| 212 | + } |
| 213 | + |
| 214 | + /* Socket.IO */ |
| 215 | + if (options.socketio) { |
| 216 | + files = files.concat([ |
| 217 | + 'client/components/socket/socket.service.' + script, |
| 218 | + 'client/components/socket/socket.mock.' + script, |
| 219 | + 'server/api/thing/thing.socket.js', |
| 220 | + 'server/config/socketio.js' |
| 221 | + ]); |
| 222 | + } |
| 223 | + |
| 224 | + return files; |
| 225 | +} |
| 226 | + |
| 227 | +export function endpoint(name, options) { |
| 228 | + return [ |
| 229 | + `server/api/${name}/index.js`, |
| 230 | + `server/api/${name}/index.spec.js`, |
| 231 | + `server/api/${name}/bar.controller.js`, |
| 232 | + `server/api/${name}/bar.events.js`, |
| 233 | + `server/api/${name}/bar.integration.js`, |
| 234 | + `server/api/${name}/bar.model.js`, |
| 235 | + `server/api/${name}/bar.socket.js` |
| 236 | + ]; |
| 237 | +} |
0 commit comments