Skip to content
This repository
Newer
Older
100644 1005 lines (849 sloc) 29.205 kb
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
1 // Load the basic Geddy toolkit
2 require('../lib/geddy')
3
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
4 // Dependencies
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
5 var cwd = process.cwd()
6 , fs = require('fs')
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
7 , path = require('path')
d278a7e8 »
2012-08-15 Get example app working with external model lib
8 , utils = require('../lib/utils')
7ae4e055 »
2012-11-01 Added generator for auth
9 , Adapter = require('../lib/template/adapters')
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
10 , geddyPassport = 'geddy-passport@0.0.x'
7ae4e055 »
2012-11-01 Added generator for auth
11 , getRouterPath
3900a2bd »
2012-12-17 Closes #215 Added a geddy routes command that takes an optional route
12 , getRoutes
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
13 , addRoute
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
14 , mixinJSONData;
7ae4e055 »
2012-11-01 Added generator for auth
15
16 getRouterPath = function () {
17 var beginPath
18 , jsRouter = path.normalize('config/router.js')
19 , coffeeRouter = path.normalize('config/router.coffee')
20 , routerPath;
21 // Check if the router file exists
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
22 beginPath = path.join(cwd, 'config');
7ae4e055 »
2012-11-01 Added generator for auth
23 utils.file.searchParentPath(jsRouter, function (err) {
24 if (err) {
25 var jsErr = err;
26 // If jsEnvironment wasn't found, try finding coffee variant
27 utils.file.searchParentPath(coffeeRouter, beginPath, function (err) {
28 if (err) {
29 throw jsErr;
30 } else {
31 routerPath = coffeeRouter;
32 }
33 });
34 } else {
35 routerPath = jsRouter;
36 }
37 });
38 return routerPath;
39 };
40
3900a2bd »
2012-12-17 Closes #215 Added a geddy routes command that takes an optional route
41 getRoutes = function (resource) {
42 if (!resource) {
43 return geddy.router.toString();
44 }
45
46 var rts = []
47 , _rt
48 , i;
49
50 // If a full route name was given add it to the list(e,g,. users.index)
51 if (resource.match(/.+\..+/)) {
52 var res = resource.split('.')
53 , cont = res[0]
54 , action = res[1];
55
56 for (i in geddy.router.routes) {
57 _rt = geddy.router.routes[i];
58
59 if (_rt.params.controller.match(cont) &&
60 _rt.params.action.match(action)) {
61 rts.push(_rt);
62 }
63 }
64 }
65 else {
66 for (i in geddy.router.routes) {
67 _rt = geddy.router.routes[i];
68
69 if (_rt.params.controller.match(resource) ||
70 _rt.params.action.match(resource)) {
71 rts.push(_rt);
72 }
73 }
74 }
75
76 return rts.map(function (rt) {
77 return rt.toString();
78 }).join('\n');
79 };
80
7ae4e055 »
2012-11-01 Added generator for auth
81 addRoute = function (routerPath, newRoute) {
82 var text = fs.readFileSync(routerPath, 'utf8')
83 , routerArr;
84 // Don't add the same route over and over
85 if (text.indexOf(newRoute) == -1) {
86 // Add the new resource route just above the export
87 routerArr = text.split('exports.router');
88 routerArr[0] += newRoute + '\n';
89
90 text = routerArr.join('exports.router');
91 fs.writeFileSync(routerPath, text, 'utf8');
92 return true;
93 }
94 else {
95 return false;
96 }
97 };
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
98
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
99 mixinJSONData = function (file, obj) {
100 var data = obj || {};
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
101
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
102 if (utils.file.existsSync(file)) {
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
103 try {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
104 var content = JSON.parse(fs.readFileSync(file, 'utf8'));
105 utils.object.merge(content, data);
106 fs.writeFileSync(file, JSON.stringify(content, null, 2));
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
107 }
108 catch (e) {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
109 throw new Error("Could not parse " + file);
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
110 }
111 }
112 else {
3620c044 »
2013-02-15 Fixes typo
113 console.log("There is no file " + file + " to add data to.");
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
114 }
115 };
116
d278a7e8 »
2012-08-15 Get example app working with external model lib
117 namespace('env', function () {
3e0c059f »
2012-09-28 Added basic console feature
118 task('init', function (environment) {
d278a7e8 »
2012-08-15 Get example app working with external model lib
119 jake.addListener('complete', function (e) {
120 jake.Task['env:cleanup'].invoke();
121 });
9e1fe046 »
2012-08-16 Got generators working.
122
3e0c059f »
2012-09-28 Added basic console feature
123 geddy.config = require('../lib/config').readConfig({
124 environment: environment || 'development'
125 });
9e1fe046 »
2012-08-16 Got generators working.
126 geddy.model = require('model');
127
5da7b94e »
2012-08-20 Cleaned up env init process a little more
128 require('../lib/init').init(geddy, function () {
9e1fe046 »
2012-08-16 Got generators working.
129 complete();
130 });
131 }, {async: true});
d278a7e8 »
2012-08-15 Get example app working with external model lib
132
133 task('cleanup', function () {
134 // Disconnect all the adapters
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
135 var adapters = geddy.model.loadedAdapters
136 , adapter;
137
d278a7e8 »
2012-08-15 Get example app working with external model lib
138 for (var p in adapters) {
48fb464a »
2012-08-16 Fixed DB adapter connect/disconnect
139 adapter = adapters[p];
140 if (typeof adapter.disconnect == 'function') {
141 adapter.disconnect();
142 }
d278a7e8 »
2012-08-15 Get example app working with external model lib
143 }
144 });
145
3e0c059f »
2012-09-28 Added basic console feature
146 });
147
148 namespace('console', function () {
149 task('start', ['env:init'], {async: true}, function (environment) {
150 var env = environment || 'development'
151 , t = jake.Task['env:init'];
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
152
3e0c059f »
2012-09-28 Added basic console feature
153 t.addListener('complete', function () {
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
154 var repl = require('repl')
155 , rl;
156
157 rl = repl.start({
158 prompt: '>>> '
159 , input: process.stdin
160 , output: process.stdout
3e0c059f »
2012-09-28 Added basic console feature
161 });
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
162
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
163 rl.on('close', function () {
164 console.log('Exiting...');
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
165 return complete();
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
166 })
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
167
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
168 rl.context.capture = function (err, data) {
169 return rl.context.results = {
170 err: err
171 , data: data
172 };
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
173 };
174
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
175 rl.context.echo = function (err, data) {
176 rl.context.capture(err, data);
177 if (err) {
178 console.log('Error: ', err);
179 }
180
181 if (data) {
182 if (data.length) {
183 for (var i in data) {
184 if (data[i] && data[i].toData) {
185 console.log(data[i].toData());
186 } else {
187 console.log(data[i]);
188 }
189 }
190 }
191 else {
192 if (data && data.toData) {
193 console.log(data.toData());
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
194 } else {
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
195 console.log(data);
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
196 }
197 }
198 } else {
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
199 console.log('No data');
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
200 }
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
201 };
3900a2bd »
2012-12-17 Closes #215 Added a geddy routes command that takes an optional route
202
203 rl.context.routes = function (resource) {
204 console.log(getRoutes(resource));
205 };
bb901853 »
2012-11-04 Closes #252, Replace readline REPL with repl REPL, which does autocom…
206 });
f0c7bc1f »
2012-09-28 added echo and capture helper funtions to the console
207
3e0c059f »
2012-09-28 Added basic console feature
208 t.invoke(env);
209 });
210 });
d278a7e8 »
2012-08-15 Get example app working with external model lib
211
3900a2bd »
2012-12-17 Closes #215 Added a geddy routes command that takes an optional route
212 namespace('routes', function () {
213
214 task('show', ['env:init'], {async: true}, function (resource) {
215 console.log('Showing route results for "' + resource + '"');
216 console.log(getRoutes(resource));
217 });
218
219 });
220
d278a7e8 »
2012-08-15 Get example app working with external model lib
221 namespace('db', function () {
48fb464a »
2012-08-16 Fixed DB adapter connect/disconnect
222 task('createTable', ['env:init'], function (name) {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
223
9e1fe046 »
2012-08-16 Got generators working.
224 var modelName
48fb464a »
2012-08-16 Fixed DB adapter connect/disconnect
225 , createTable
d278a7e8 »
2012-08-15 Get example app working with external model lib
226 , adapters
9e1fe046 »
2012-08-16 Got generators working.
227 , adapter;
228
229 if (typeof name == 'string') {
c7f64c5e »
2013-02-05 Can't use commas with new embeddable Jake
230 if (name.indexOf('%') > -1) {
231 modelNames = name.split('%');
9e1fe046 »
2012-08-16 Got generators working.
232 }
233 else {
234 modelNames = [name];
235 }
236 }
237 else {
238 modelNames = name;
239 }
240
d278a7e8 »
2012-08-15 Get example app working with external model lib
241 createTable = function () {
48fb464a »
2012-08-16 Fixed DB adapter connect/disconnect
242 if ((m = modelNames.shift())) {
9e1fe046 »
2012-08-16 Got generators working.
243
244 // Make sure this is a correct model-name
245 m = utils.string.getInflections(m).constructor.singular;
246 if (!geddy.model[m]) {
247 throw new Error(m + ' is not a known model.');
248 }
249
d278a7e8 »
2012-08-15 Get example app working with external model lib
250 adapter = geddy.model.adapters[m];
9e1fe046 »
2012-08-16 Got generators working.
251 if (adapter) {
252 console.log('Creating table for ' + m);
253 adapter.createTable(m, function (err, data) {
254 if (err) { throw err }
255 createTable();
256 });
257 }
258 else {
d278a7e8 »
2012-08-15 Get example app working with external model lib
259 createTable();
9e1fe046 »
2012-08-16 Got generators working.
260 }
d278a7e8 »
2012-08-15 Get example app working with external model lib
261 }
262 else {
263 complete();
264 }
265 };
266 createTable();
48fb464a »
2012-08-16 Fixed DB adapter connect/disconnect
267 }, {async: true});
268
d192f149 »
2013-03-06 'retrofit' task should just be init for SQL DBs
269 task('init', ['env:init'], function () {
48fb464a »
2012-08-16 Fixed DB adapter connect/disconnect
270 var modelNames = Object.keys(geddy.model.descriptionRegistry)
271 , createTask = jake.Task['db:createTable'];
272 createTask.once('complete', function () {
273 complete();
274 });
275 createTask.invoke(modelNames);
d278a7e8 »
2012-08-15 Get example app working with external model lib
276 }, {async: true});
277
278 });
279
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
280 namespace('gen', function () {
281
b262b1c3 »
2012-08-28 Default ID attribute is now 'int', if scaffold model template the def…
282 var _writeTemplate = function (name, filename, dirname, opts) {
283 var options = opts || {}
284 , names = utils.string.getInflections(name)
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
285 , text = fs.readFileSync(path.join(__dirname, filename + '.ejs'), 'utf8').toString()
cf999eaa »
2012-07-06 Deleted bare controller template
286 , bare = options.bare || false // Default to full controller
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
287 , adapter
288 , templContent
9ec7c3a2 »
2012-09-24 Changed the generator to create the directory in case it doesn't exis…
289 , fileDir
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
290 , filePath;
291
292 // Render with the right model name
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
293 adapter = new Adapter({engine: 'ejs', template: text});
294 templContent = adapter.render({names: names, bare: bare, properties: options.properties});
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
295
296 // Write file
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
297 fileDir = dirname;
fc704022 »
2012-09-25 Removed usage of fs.existsSync for compatibility with node 0.6 and ch…
298 if (!utils.file.existsSync(fileDir)) {
299 fs.mkdirSync(fileDir);
300 }
9ec7c3a2 »
2012-09-24 Changed the generator to create the directory in case it doesn't exis…
301
302 filePath = path.join(fileDir, names.filename[options.inflection] + '.js');
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
303 fs.writeFileSync(filePath, templContent, 'utf8');
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
304
a0820314 »
2012-07-11 Updated readme to reflect new generators
305 console.log('[Added] ' + filePath);
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
306 };
307
edf26c75 »
2012-08-16 Formatting
308 var _formatModelProperties = function (properties) {
515a929c »
2012-11-10 Closes #259, Fix error where no properties at all would throw when co…
309 var obj = {default: {name: '', type: ''}};
9e1fe046 »
2012-08-16 Got generators working.
310 if (!properties) {
515a929c »
2012-11-10 Closes #259, Fix error where no properties at all would throw when co…
311 return obj;
9e1fe046 »
2012-08-16 Got generators working.
312 }
515a929c »
2012-11-10 Closes #259, Fix error where no properties at all would throw when co…
313 obj['default'].name = 'id';
89831d28 »
2012-11-10 Default to string ID type instead of int for generators.
314 obj['default'].type = 'string';
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
315
d3f4d449 »
2012-10-01 Spaces aren't legal inside passed Jake params.
316 var itemsArr = properties.split('%')
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
317 , name
318 , type
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
319 , args
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
320 , i
321 , value;
322
26600c53 »
2012-07-24 Just made a few loop optimizations for Array loops
323 i = -1;
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
324 while (++i < itemsArr.length) {
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
325 value = itemsArr[i];
dd3a65ba »
2012-10-19 Don't allow nodel property names to be CamelCased
326 name = utils.string.camelize(value.replace(/:.*/g, ''));
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
327 type = value.replace(/[a-zA-Z]*:?/, '');
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
328 args = type.replace(/[a-zA-Z]*:?/, '');
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
329
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
330 // Take off any args on the type
331 type = type.replace(/:.*/g, '');
332
9e1fe046 »
2012-08-16 Got generators working.
333 // Defaults and aliases
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
334 if (!type) {
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
335 type = 'string';
9e2a69d7 »
2012-08-25 If text attribute is given it switches to string, also took out place…
336 }
d9489a2a »
2012-10-07 Closes 210, Generators will use `name` and `title` properties as the …
337 if (args === 'def') {
338 args = 'default';
339 }
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
340
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
341 switch (type) {
f835d2fb »
2012-08-26 Move type checks for generatirs into a switch statement so can be eas…
342 case 'text':
343 type = 'string';
344 break;
345 case 'integer':
346 type = 'int';
347 break;
348 case 'bool':
349 type = 'boolean';
350 break;
351 case 'default':
352 case 'def':
353 type = 'string';
354 args = 'default';
355 break;
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
356 }
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
357
bc021706 »
2012-10-14 Closes #230, Don't manually add the ID attribute into the model prope…
358 // Manage properties that deal with changing default properties
d9489a2a »
2012-10-07 Closes 210, Generators will use `name` and `title` properties as the …
359 if (args === 'default') {
bc021706 »
2012-10-14 Closes #230, Don't manually add the ID attribute into the model prope…
360 // Reset old default property to it's own property, only if it's not
361 // already the default
362 if (name !== obj['default'].name) {
363 // If the new default item already exists then delete it
364 if (obj[name]) {
365 delete obj[name];
366 }
367
368 obj[obj['default'].name] = obj[obj['default'].name] || obj['default'];
369 }
d9489a2a »
2012-10-07 Closes 210, Generators will use `name` and `title` properties as the …
370
371 // Add new default property
372 obj['default'] = {name: name, type: type};
373 continue;
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
374 }
375
d9489a2a »
2012-10-07 Closes 210, Generators will use `name` and `title` properties as the …
376 // If ID property is given and it matches the default
377 // then rewrite the default with the new ID property
378 if (name === 'id' && obj['default'].name === 'id') {
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
379 obj['default'] = {name: name, type: type};
d9489a2a »
2012-10-07 Closes 210, Generators will use `name` and `title` properties as the …
380 continue;
9e1fe046 »
2012-08-16 Got generators working.
381 }
d9489a2a »
2012-10-07 Closes 210, Generators will use `name` and `title` properties as the …
382
383 // If the name is name or title then set them to default, otherwise add
384 // the property normally
385 if (name === 'name' || name === 'title') {
386 // Reset old default to it's own property
387 obj[obj['default'].name] = obj[obj['default'].name] || obj['default'];
388
389 // Add new default property
390 obj['default'] = {name: name, type: type};
391 } else {
392 obj[name] = {name: name, type: type};
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
393 }
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
394 }
395
9925793b »
2012-07-19 Added default option to model property arguments as @TechWraith sugge…
396 return obj;
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
397 };
398
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
399 // Creates a new Geddy app scaffold
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
400 task('app', function (name, engine, realtime) {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
401 var basePath = path.join(__dirname, 'base')
402 , mkdirs
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
403 , cps
404 , text
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
405 , adapter;
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
406
9e1fe046 »
2012-08-16 Got generators working.
407 if (!name) {
408 throw new Error('No app name specified.');
409 }
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
410 if (!engine || engine == 'default') {
9e1fe046 »
2012-08-16 Got generators working.
411 engine = 'ejs';
412 }
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
413 if (realtime == 'default') {
414 realtime = false;
415 }
416
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
417 mkdirs = [
418 ''
419 , 'config'
420 , 'app/models'
421 , 'app/controllers'
422 , 'app/helpers'
423 , 'lib'
424 , 'log'
425 , 'node_modules'
426 , 'test'
427 ];
428 cps = [
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
429 (realtime) ? ['realtime/views/' + engine, 'app/views'] : ['views/' + engine, 'app/views']
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
430 , ['public', '']
431 , ['router.js', 'config']
432 , ['init.js', 'config']
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
433 , (realtime) ? ['realtime/environment.js', 'config'] : ['environment.js', 'config']
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
434 , ['development.js', 'config']
435 , ['production.js', 'config']
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
436 , ['secrets.json', 'config']
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
437 , ['main.js', 'app/controllers']
438 , ['application.js', 'app/controllers']
439 , ['favicon.ico', 'public']
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
440 , ['gitignore.txt', '.gitignore']
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
441 ];
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
442
edf26c75 »
2012-08-16 Formatting
443 mkdirs.forEach(function (dir) {
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
444 jake.mkdirP(path.join(name, dir));
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
445 });
edf26c75 »
2012-08-16 Formatting
446 cps.forEach(function (cp) {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
447 jake.cpR(path.join(basePath, cp[0]), path.join(name, cp[1]), {silent: true});
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
448 });
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
449
944267c5 »
2012-10-29 RT-MVC: added build init step, copied socket.io into all realtime app…
450 // one offs
451 if (realtime) {
452 jake.cpR(path.join(__dirname, '..', 'node_modules', 'socket.io' ), path.join(name, 'node_modules'), {silent: true});
453 }
454
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
455 // Compile Jakefile
456 text = fs.readFileSync(path.join(basePath, 'Jakefile.ejs'), 'utf8').toString();
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
457 adapter = new Adapter({engine: 'ejs', template: text});
458 fs.writeFileSync(path.join(name, 'Jakefile'), adapter.render({appName: name}), 'utf8');
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
459
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
460 // Compile package.json
461 text = fs.readFileSync(path.join(basePath, 'package.json.ejs'), 'utf8').toString();
462 adapter = new Adapter({engine: 'ejs', template: text});
463 fs.writeFileSync(path.join(name, 'package.json'), adapter.render({appName: name}), 'utf8');
464
465 // Add engine to package.json if it's not EJS
466 if (engine !== 'ejs') {
467 // Change to handlebars as we use it behind the scenes
468 if (engine === 'mustache') {
469 engine = 'handlebars';
470 }
471 var data = {dependencies: {}};
472 data.dependencies[engine] = "*";
473
474 mixinJSONData(path.join(name, 'package.json'), data);
475 }
476
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
477 console.log('Created app ' + name + '.');
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
478 });
479
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
480 // Creates a resource with a model, controller and a resource route
edf26c75 »
2012-08-16 Formatting
481 task('resource', function (name, modelProperties) {
9e1fe046 »
2012-08-16 Got generators working.
482 var names
483 , modelTask = jake.Task['gen:model'];
a0820314 »
2012-07-11 Updated readme to reflect new generators
484
9e1fe046 »
2012-08-16 Got generators working.
485 if (!name) {
486 throw new Error('No resource name specified.');
487 }
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
488
9e1fe046 »
2012-08-16 Got generators working.
489 modelTask.on('complete', function () {
490 jake.Task['gen:controller'].invoke(name);
491 jake.Task['gen:route'].invoke(name);
492 names = utils.string.getInflections(name);
493 // Create views folder but not actions
494 jake.mkdirP(path.join('app', 'views', names.filename.plural));
495 console.log('[Added] ' + names.filename.plural + ' view directory');
496 complete();
497 });
498 modelTask.invoke(name, modelProperties);
a0820314 »
2012-07-11 Updated readme to reflect new generators
499
9e1fe046 »
2012-08-16 Got generators working.
500 }, {async: true});
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
501
502 // Creates a full scaffold with views, a model, controller and a resource route
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
503 task('scaffold', function (name, realtime, engine, modelProperties) {
9e1fe046 »
2012-08-16 Got generators working.
504 var modelTask = jake.Task['gen:model'];
505
506 if (!name) {
507 throw new Error('No scaffold name specified.');
508 }
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
509 if (!engine || engine == 'default') {
9e1fe046 »
2012-08-16 Got generators working.
510 engine = 'ejs';
511 }
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
512 if (!realtime || realtime == 'default') {
513 realtime = false;
514 }
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
515
9e1fe046 »
2012-08-16 Got generators working.
516 modelTask.on('complete', function () {
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
517 jake.Task['gen:test'].invoke(name,
518 {properties: modelProperties});
9e1fe046 »
2012-08-16 Got generators working.
519 jake.Task['gen:controllerScaffold'].invoke(name,
520 {properties: modelProperties});
521 jake.Task['gen:route'].invoke(name);
522 jake.Task['gen:viewsScaffold'].invoke(name,
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
523 {engine: engine, properties: modelProperties, realtime: realtime});
9e1fe046 »
2012-08-16 Got generators working.
524 complete();
693a0fe0 »
2012-07-24 Created a file utils function that will search for a dir/file in up t…
525 });
b262b1c3 »
2012-08-28 Default ID attribute is now 'int', if scaffold model template the def…
526 modelTask.invoke(name, modelProperties, 'scaffold');
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
527
9e1fe046 »
2012-08-16 Got generators working.
528 }, {async: true});
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
529
b262b1c3 »
2012-08-28 Default ID attribute is now 'int', if scaffold model template the def…
530 task('model', function (name, properties, modelPath) {
9e1fe046 »
2012-08-16 Got generators working.
531 var createTableTask;
532 if (!name) {
533 throw new Error('No model name specified.');
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
534 }
b262b1c3 »
2012-08-28 Default ID attribute is now 'int', if scaffold model template the def…
535 if (!modelPath) {
536 modelPath = 'resource';
537 }
538 modelPath += '/model';
a0820314 »
2012-07-11 Updated readme to reflect new generators
539
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
540 _writeTemplate(name, modelPath, path.join('app', 'models'), {
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
541 inflection: 'singular'
542 , properties: _formatModelProperties(properties)
543 });
a0820314 »
2012-07-11 Updated readme to reflect new generators
544
9e1fe046 »
2012-08-16 Got generators working.
545 // Try to create a table -- should be a no-op if an
546 // appropriate DB adapter can't be found
547 createTableTask = jake.Task['db:createTable'];
548 createTableTask.on('complete', function () {
549 complete();
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
550 });
9e1fe046 »
2012-08-16 Got generators working.
551 createTableTask.invoke(name);
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
552
9e1fe046 »
2012-08-16 Got generators working.
553 }, {async: true});
a0820314 »
2012-07-11 Updated readme to reflect new generators
554
9e1fe046 »
2012-08-16 Got generators working.
555 task('controller', function (name) {
556 if (!name) {
557 throw new Error('No controller name specified.');
558 }
559
e7a7bda0 »
2013-01-13 Remove the require for child_process since we don't use it anymore
560
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
561 _writeTemplate(name, 'resource/controller', path.join('app', 'controllers'),
9e1fe046 »
2012-08-16 Got generators working.
562 {inflection: 'plural', bare: false});
a0820314 »
2012-07-11 Updated readme to reflect new generators
563 });
564
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
565 task('test', function (name) {
566 if (!name) {
567 throw new Error('No test name specified.');
568 }
569
570 _writeTemplate(name, 'resource/test', 'test',
571 {inflection: 'singular'});
572 });
573
9e1fe046 »
2012-08-16 Got generators working.
574 task('controllerScaffold', function (name, options) {
575 if (!name) {
576 throw new Error('No controller name specified.');
577 }
a0820314 »
2012-07-11 Updated readme to reflect new generators
578 options = options || {};
579
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
580 _writeTemplate(name, 'scaffold/controller', path.join('app', 'controllers'), {
a0820314 »
2012-07-11 Updated readme to reflect new generators
581 inflection: 'plural'
582 , bare: false
583 , properties: _formatModelProperties(options.properties)
584 });
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
585 });
586
9e1fe046 »
2012-08-16 Got generators working.
587 task('bareController', function (name, engine) {
588 if (!name) {
589 throw new Error('No controller name specified.');
590 }
e7a7bda0 »
2013-01-13 Remove the require for child_process since we don't use it anymore
591 if (!engine || engine == 'default') {
9e1fe046 »
2012-08-16 Got generators working.
592 engine = 'ejs';
593 }
a0820314 »
2012-07-11 Updated readme to reflect new generators
594
109ee592 »
2012-10-05 Added Jakefile, test dir to app, test stubs to scaffolds.
595 _writeTemplate(name, 'resource/controller', path.join('app', 'controllers'),
596 {inflection: 'plural', bare: true});
a0820314 »
2012-07-11 Updated readme to reflect new generators
597 jake.Task['gen:route'].invoke(name, {bare: true});
598 jake.Task['gen:views'].invoke(name, {bare: true, engine: engine});
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
599 });
600
9e1fe046 »
2012-08-16 Got generators working.
601 task('route', function (name, options) {
602 if (!name) {
603 throw new Error('No route name specified.');
604 }
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
605 options = options || {};
606
d92f1576 »
2012-08-02 Get generators working
607 var names = utils.string.getInflections(name)
7ae4e055 »
2012-11-01 Added generator for auth
608 , routerPath = getRouterPath()
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
609 , routeType = options.bare ? 'Bare' : 'Resource'
7ae4e055 »
2012-11-01 Added generator for auth
610 , newRoute;
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
611
6967867a »
2012-08-16 Misc. fixes to get generators working
612 if (routerPath) {
613 if (routerPath.match('.coffee')) {
614 if (options.bare) {
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
615 newRoute = 'router.match(\'/' + names.filename.plural +
616 '\').to controller: \'' + names.constructor.plural +
617 '\', action: \'index\'';
baa8cdf8 »
2012-07-25 Updated /site to reflect new features related to generators and templ…
618 } else {
619 newRoute = 'router.resource \'' + names.filename.plural + '\'';
620 }
6967867a »
2012-08-16 Misc. fixes to get generators working
621 } else if (routerPath.match('.js')) {
622 if (options.bare) {
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
623 newRoute = 'router.match(\'/' + names.filename.plural +
624 '\').to({controller: \'' + names.constructor.plural +
625 '\', action: \'index\'});';
baa8cdf8 »
2012-07-25 Updated /site to reflect new features related to generators and templ…
626 } else {
627 newRoute = 'router.resource(\'' + names.filename.plural + '\');';
628 }
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
629 }
630
7ae4e055 »
2012-11-01 Added generator for auth
631 if (addRoute(routerPath, newRoute)) {
a0820314 »
2012-07-11 Updated readme to reflect new generators
632 console.log('[Added] ' + routeType + ' ' + names.filename.plural +
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
633 ' route added to ' + routerPath);
634 }
635 else {
a0820314 »
2012-07-11 Updated readme to reflect new generators
636 console.log(routeType + ' ' + names.filename.plural + ' route already defined in ' +
637 routerPath);
1282075d »
2012-07-09 Fix old Fleegix lib code for template adapters
638 }
7ae4e055 »
2012-11-01 Added generator for auth
639 }
640 else {
baa8cdf8 »
2012-07-25 Updated /site to reflect new features related to generators and templ…
641 console.log('There is no router file to add routes too');
642 }
7ae4e055 »
2012-11-01 Added generator for auth
643
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
644 });
645
9e1fe046 »
2012-08-16 Got generators working.
646 task('views', function (name, options) {
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
647 if (!name) {
648 throw new Error('No view name specified.');
649 }
a0820314 »
2012-07-11 Updated readme to reflect new generators
650
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
651 options = options || {};
652
a0820314 »
2012-07-11 Updated readme to reflect new generators
653 // Option defaults
654 options.engine = options.engine || 'ejs';
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
655
d92f1576 »
2012-08-02 Get generators working
656 var names = utils.string.getInflections(name)
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
657 , engine = options.engine
658 , appViewDir = path.join('app', 'views', names.filename.plural)
659 , templateViewDir = path.join(__dirname, 'views', engine)
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
660 , cmds = []
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
661 , ext = '.html'
662 , appLayoutPath
663 , actions
664 , addActionView;
665
666 // Set extension based on engine option
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
667 switch (engine) {
668 case 'ejs':
669 ext += '.ejs';
670 break;
671 case 'jade':
672 ext += '.jade';
673 break;
674 case 'handlebars':
675 ext += '.hbs';
676 break;
677 case 'mustache':
678 ext += '.ms';
679 break;
680 }
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
681
682 // Set application layout path
683 appLayoutPath = path.join('app', 'views', 'layouts', 'application');
684 // Copy template view to application path
edf26c75 »
2012-08-16 Formatting
685 addActionView = function (action) {
dc80e705 »
2013-01-27 Add ejs extension to copy and make it silent when copying over a new app
686 jake.cpR(path.join(templateViewDir, action + ext + '.ejs'), appViewDir, {silent: true});
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
687 };
688
689 jake.mkdirP(appViewDir);
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
690 jake.mkdirP('app/views/layouts');
691 addActionView('index');
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
692
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
693 // Add views for the other CRUD actions when doing a full-on resource
6967867a »
2012-08-16 Misc. fixes to get generators working
694 if (!options.bare) {
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
695 ['add', 'edit', 'show'].forEach(function (action) {
696 addActionView(action);
697 });
698 }
699
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
700 // Create default layout if one doesn't exist
701 // Hack: There should be a better way to detect if a application layout exists
6967867a »
2012-08-16 Misc. fixes to get generators working
702 if (!utils.file.existsSync(appLayoutPath + '.html.ejs') && !utils.file.existsSync(appLayoutPath + '.html.jade') &&
703 !utils.file.existsSync(appLayoutPath + '.html.hbs') && !utils.file.existsSync(appLayoutPath + '.html.ms')) {
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
704 // Copy template layout file to apps application layout file
dc80e705 »
2013-01-27 Add ejs extension to copy and make it silent when copying over a new app
705 jake.cpR(path.join(templateViewDir, 'layout' + ext + '.ejs'), appLayoutPath + ext, {silent: true});
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
706 }
707
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
708 // Add engine to package.json if it's not EJS
709 if (engine !== 'ejs') {
710 // Change to handlebars as we use it behind the scenes
711 if (engine === 'mustache') {
712 engine = 'handlebars';
713 }
714 var data = {dependencies: {}};
715 data.dependencies[engine] = "*";
716
717 mixinJSONData('package.json', data);
718 }
719
a0820314 »
2012-07-11 Updated readme to reflect new generators
720 console.log('[Added] View templates');
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
721 });
722
edf26c75 »
2012-08-16 Formatting
723 task('viewsScaffold', function (name, options) {
6967867a »
2012-08-16 Misc. fixes to get generators working
724 if (!name) {
693a0fe0 »
2012-07-24 Created a file utils function that will search for a dir/file in up t…
725 throw new Error('No view name specified.');
726 }
a0820314 »
2012-07-11 Updated readme to reflect new generators
727
728 options = options || {};
729
730 // Option defaults
731 options.engine = options.engine || 'ejs';
732
d92f1576 »
2012-08-02 Get generators working
733 var names = utils.string.getInflections(name)
a0820314 »
2012-07-11 Updated readme to reflect new generators
734 , engine = options.engine
735 , appViewDir = path.join('app', 'views', names.filename.plural)
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
736 , templateViewDir
a0820314 »
2012-07-11 Updated readme to reflect new generators
737 , cmds = []
738 , ext = '.html'
739 , appLayoutPath
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
740 , layoutViewPath
a0820314 »
2012-07-11 Updated readme to reflect new generators
741 , actions
742 , addActionView
ca35849c »
2012-11-08 Closes #250, Add realtime code generation to the other template langu…
743 , viewPath
a0820314 »
2012-07-11 Updated readme to reflect new generators
744 , text
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
745 , adapter
746 , templContent;
a0820314 »
2012-07-11 Updated readme to reflect new generators
747
748 // Set extension based on engine option
d9fe3bb5 »
2012-09-25 Get rid of all the syntax differences, well most of them.
749 switch (engine) {
750 case 'ejs':
751 ext += '.ejs';
752 break;
753 case 'jade':
754 ext += '.jade';
755 break;
756 case 'handlebars':
757 ext += '.hbs';
758 break;
759 case 'mustache':
760 ext += '.ms';
761 break;
762 }
a0820314 »
2012-07-11 Updated readme to reflect new generators
763
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
764 // Get view path
057bd49b »
2012-10-27 RT-MVC: Real time app generation and resource scaffolding is working
765 templateViewDir = options.realtime ?
766 path.join(__dirname, 'scaffold', 'realtime', 'views', engine) :
767 path.join(__dirname, 'scaffold', 'views', engine);
768
769
a0820314 »
2012-07-11 Updated readme to reflect new generators
770 // Set application layout path
771 appLayoutPath = path.join('app', 'views', 'layouts', 'application');
772
773 // Function to compile the template
edf26c75 »
2012-08-16 Formatting
774 addActionView = function (action) {
ca35849c »
2012-11-08 Closes #250, Add realtime code generation to the other template langu…
775 viewPath = path.join(templateViewDir, action + ext + '.ejs');
776 if (!utils.file.existsSync(viewPath)) {
777 return;
778 }
779 text = fs.readFileSync(viewPath).toString();
a0820314 »
2012-07-11 Updated readme to reflect new generators
780
781 // Compile template text
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
782 adapter = new Adapter({engine: 'ejs', template: text});
783 templContent = adapter.render({names: names, properties: _formatModelProperties(options.properties)});
a0820314 »
2012-07-11 Updated readme to reflect new generators
784
785 // Write file
786 fs.writeFileSync(path.join(appViewDir, action + ext),
2e8e3fb5 »
2012-10-24 Remove the third party dependency Templato(which was rewritten in JS …
787 templContent.replace(/<@/g, '<%').replace(/@>/g, '%>'), 'utf8');
a0820314 »
2012-07-11 Updated readme to reflect new generators
788 };
789
790 jake.mkdirP(appViewDir);
791 jake.mkdirP('app/views/layouts');
792
793 // Add views for the other CRUD actions when doing a full-on resource
9f7a3843 »
2012-10-31 Closes #246, Generator: Put form into a partial for add and edit acti…
794 ['index', 'add', 'show', 'edit', 'form'].forEach(function (action) {
a0820314 »
2012-07-11 Updated readme to reflect new generators
795 addActionView(action);
796 });
797
798 // Create default layout if one doesn't exist
799 // Hack: There should be a better way to detect if a application layout exists
6967867a »
2012-08-16 Misc. fixes to get generators working
800 if (!utils.file.existsSync(appLayoutPath + '.html.ejs') && !utils.file.existsSync(appLayoutPath + '.html.jade') &&
801 !utils.file.existsSync(appLayoutPath + '.html.hbs') && !utils.file.existsSync(appLayoutPath + '.html.ms')) {
a0820314 »
2012-07-11 Updated readme to reflect new generators
802 // Copy template layout file to apps application layout file
dc80e705 »
2013-01-27 Add ejs extension to copy and make it silent when copying over a new app
803 jake.cpR(path.join(templateViewDir, 'layout' + ext + '.ejs'), appLayoutPath + ext, {silent: true});
a0820314 »
2012-07-11 Updated readme to reflect new generators
804 }
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
805
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
806 // Add engine to package.json if it's not EJS
807 if (engine !== 'ejs') {
808 // Change to handlebars as we use it behind the scenes
809 if (engine === 'mustache') {
810 engine = 'handlebars';
811 }
812 var data = {dependencies: {}};
813 data.dependencies[engine] = "*";
814
815 mixinJSONData('package.json', data);
816 }
817
a0820314 »
2012-07-11 Updated readme to reflect new generators
818 console.log('[Added] View templates');
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
819 });
820
ae3f611a »
2012-07-02 Created app and resource generators for Jade, Handlebars and Mustache
821 // Generate a new application secret in environment.js
9e1fe046 »
2012-08-16 Got generators working.
822 task('secret', function () {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
823 var secretsFile = path.join(cwd, 'config', 'secrets.json')
824 , secret = utils.string.uuid(128);
825
826 mixinJSONData(secretsFile, {secret: secret});
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
827 console.log('Added app-secret to config/secrets.json.\n' +
828 'DO NOT add this file into your revision control.\n' +
829 'DO make a backup of it, keep it someplace safe.');
c389ea99 »
2012-06-23 Move generator Jake tasks into a separate Jakefile.
830 });
831
832 });
7ae4e055 »
2012-11-01 Added generator for auth
833
834 namespace('auth', function () {
835
aa49bd92 »
2012-11-10 Added generator for auth:update
836 task('update', {async: true}, function () {
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
837 var updatePath = path.join('geddy-passport', 'app', 'helpers', 'passport')
838 , from
839 , to;
840
841 console.log('Updating passport helpers from', geddyPassport);
842 jake.exec('npm uninstall ' + geddyPassport +
843 ' && npm install ' + geddyPassport, function () {
844 from = path.join(cwd, 'node_modules', updatePath);
845 to = path.join(cwd, 'app', 'helpers');
846
847 jake.rmRf(path.join(cwd, 'passport'), {silent: true});
aa49bd92 »
2012-11-10 Added generator for auth:update
848 jake.cpR(from, to, {silent: true});
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
849
850 console.log("\nCleaning up...");
851 jake.exec('npm uninstall ' + geddyPassport, function () {
aa49bd92 »
2012-11-10 Added generator for auth:update
852 complete();
853 });
854 }, {printStdout: true});
855 });
856
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
857 task('init', {async: true}, function (engine) {
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
858 var readline = require('readline')
859 , fromBase = path.join(cwd, 'node_modules', 'geddy-passport')
860 , install = false
861 , rl, installPackages, passportCopy;
862
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
863 if (!engine || engine == 'default') {
864 engine = 'ejs';
865 }
866
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
867 // Create and start the prompt
868 rl = readline.createInterface({
869 input: process.stdin
870 , output: process.stdout
871 });
872 rl.setPrompt("WARNING: This command will create/overwrite files in your app.\n" +
873 "Do you wish to continue?(yes|no)\n\n");
7ae4e055 »
2012-11-01 Added generator for auth
874 rl.prompt();
875
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
876 rl.on('line', function (line) {
b786fafd »
2012-11-28 Closes #273 Add template engine to package.json if you change the
877 if (line === 'yes' || line === 'y') {
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
878 install = true;
7ae4e055 »
2012-11-01 Added generator for auth
879 }
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
880
7ae4e055 »
2012-11-01 Added generator for auth
881 rl.close();
882 });
883
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
884 rl.on('close', function () {
885 if (!install) {
886 return;
887 }
7ae4e055 »
2012-11-01 Added generator for auth
888
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
889 console.log('Installing', geddyPassport);
890 jake.exec('npm uninstall ' + geddyPassport +
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
891 ' && npm install ' + geddyPassport, installPackages, {printStdout: true});
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
892 });
7ae4e055 »
2012-11-01 Added generator for auth
893
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
894 // Gets the package versions from geddy-passport's package.json
895 // and installs them, then calls passportCopy
896 installPackages = function () {
897 var deps = require(path.join(fromBase, 'package')).dependencies
898 , packages = ''
899 , k;
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
900
dc80e705 »
2013-01-27 Add ejs extension to copy and make it silent when copying over a new app
901 mixinJSONData(path.join(cwd, 'package.json'), {dependencies: deps});
902
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
903 for (k in deps) {
904 packages += k + '@' + deps[k] + ' ';
905 }
7dbdced1 »
2012-11-03 Use secrets.json for secrets and keys, instead of environment.js
906
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
907 console.log("\nInstalling", packages);
908 jake.exec('npm uninstall ' + packages +
909 ' && npm install ' + packages, passportCopy, {printStdout: true});
910 };
911
912 // Copy the contents of geddy-passport into the application
913 passportCopy = function () {
914 var list = require(path.join(fromBase, 'file_list'))
915 , routerPath = getRouterPath()
916 , newRoute
917 , from
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
918 , to
dc80e705 »
2013-01-27 Add ejs extension to copy and make it silent when copying over a new app
919 , p
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
920 , i;
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
921
922 // Copy files to the application
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
923 for (i = 0; i < list.length; i++) {
924 item = list[i];
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
925 from = path.join(fromBase, item);
926 to = path.dirname(path.join(cwd, item));
927
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
928 if (item.match('/app/views')) {
929 // If the view is not for the given engine, skip it
930 if (!item.match(engine)) {
931 continue;
932 }
933
934 to = to.replace(engine, "");
935 }
936
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
937 jake.mkdirP(to);
dc80e705 »
2013-01-27 Add ejs extension to copy and make it silent when copying over a new app
938 console.log('Creating file:', path.join(to, path.basename(item)));
939
940 // Delete any existing interferring templates
941 if (item.match('/app/views')) {
942 ['.jade', '.ejs', '.ms', '.mustache', '.hbs', '.handlebars'].forEach(function (ext) {
943 p = path.basename(item, path.extname(item)) + ext;
944
945 jake.rmRf(path.join(to, p), {silent: true});
946 });
947 }
948
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
949 jake.cpR(from, to, {silent: true});
c189922d »
2013-01-15 Include engine in auth:init, auth:init will now use the give engines
950 }
564357ec »
2012-11-01 Integrated generator with CLI, did some cleanup
951
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
952 // Add new routes to router
953 if (routerPath) {
954 // CoffeeScript routes
955 if (routerPath.match('.coffee')) {
956 newRoute = "router.get('/login').to 'Main.login'\n" +
957 "router.get('/logout').to 'Main.logout'\n" +
958 "router.post('/auth/local').to 'Auth.local'\n" +
959 "router.get('/auth/twitter').to 'Auth.twitter'\n" +
960 "router.get('/auth/twitter/callback').to 'Auth.twitterCallback'\n" +
961 "router.get('/auth/facebook').to 'Auth.facebook'\n" +
962 "router.get('/auth/facebook/callback').to 'Auth.facebookCallback'\n" +
963 "router.get('/auth/yammer').to 'Auth.yammer'\n" +
964 "router.get('/auth/yammer/callback').to 'Auth.yammerCallback'\n" +
965 "router.resource 'users'";
966 } else {
967 newRoute = "router.get('/login').to('Main.login');\n" +
968 "router.get('/logout').to('Main.logout');\n" +
969 "router.post('/auth/local').to('Auth.local');\n" +
970 "router.get('/auth/twitter').to('Auth.twitter');\n" +
971 "router.get('/auth/twitter/callback').to('Auth.twitterCallback');\n" +
972 "router.get('/auth/facebook').to('Auth.facebook');\n" +
973 "router.get('/auth/facebook/callback').to('Auth.facebookCallback');\n" +
974 "router.get('/auth/yammer').to('Auth.yammer');\n" +
975 "router.get('/auth/yammer/callback').to('Auth.yammerCallback');\n" +
976 "router.resource('users');";
977 }
978
979 if (addRoute(routerPath, "\n" + newRoute)) {
980 console.log('\nAdded authentication routes:\n' + newRoute);
981 } else {
982 console.log('\nAuthentication routes already defined in', routerPath);
983 }
7ae4e055 »
2012-11-01 Added generator for auth
984 }
a9d96ec6 »
2013-01-15 Include auth in usage dialog.
985 else {
986 console.log('\nThere is no router file to add routes too.');
987 }
988
989 // Create secrets and copy the secrets template
990 console.log("\nCreating secrets.json file with stubbed-out Passport config.");
991 jake.cpR(path.join(fromBase, 'config', 'secrets.json.template'),
992 path.join(cwd, 'config', 'secrets.json'), {silent: true});
993 jake.Task['gen:secret'].invoke();
994
995 // Remove geddy-passport as it isn't needed anymore
996 console.log('\nCleaning up...');
997 jake.exec('npm uninstall geddy-passport', function () {
998 console.log('Please set up your Passport config in config/secrets.json');
999 complete();
1000 });
1001 };
7ae4e055 »
2012-11-01 Added generator for auth
1002 });
1003
1004 });
Something went wrong with that request. Please try again.