Open steveszc opened 7 years ago
Can confirm - I got this as well.
@steveszc excited to see you kicking the tires! Any feedback you can provide is super helpful!
First off, you shouldn't need to restart denali server
manually - it should automatically pick up the changed files. I assume in your case you killed the server to run the generate command, but just in case, figured I'd mention it.
Any chance there's some additional stack trace here? Looks like we are calling one of the inflection methods with an undefined value rather than a string. Seeing where that call is coming from would be super helpful.
I think I know where this is occurring, although after looking at the source nothing immediately jumps out at me as to what exactly the problem is.
After running denali generate resource <name>
and getting the above error, looking in app/config/routes.js
shows an added resource, but without any name: this.resource()
. My thought is, then, that the error happens in the addRoute
part of the resource blueprint.
So I'm not getting this error any more, not sure why. The resource is still not being added correctly though and I did get a number of errors when running denali destroy resource <name>
I was able to reproduce this tonight when creating a new resource. Here was my scenario:
denali generate resource member
/Users/jamesdixon/Projects/healthgenie/api/app/models/member.js has 1 errors and 0 warnings.
1: 'attr' is defined but never used. (no-unused-vars) at line 1:10
import { attr /* , hasOne, hasMany */ } from 'denali';
✔ api build complete (0.036s)
/Users/jamesdixon/Projects/healthgenie/api/node_modules/inflection/lib/inflection.js:594
var ignore = ( inflector.indexOf( skip, str.toLowerCase()) > -1 );
^
TypeError: Cannot read property 'toLowerCase' of undefined
at Object._apply_rules (/Users/jamesdixon/Projects/healthgenie/api/node_modules/inflection/lib/inflection.js:594:52)
at Object.pluralize (/Users/jamesdixon/Projects/healthgenie/api/node_modules/inflection/lib/inflection.js:670:24)
at Router.resource (/Users/daw/projects/oss/denali/denali/lib/runtime/router.ts:373:18)
at ApiApplication.drawRoutes [as _routes] (/Users/jamesdixon/Projects/healthgenie/api/config/routes.js:4:10)
at ApiApplication.compileRouter (/Users/daw/projects/oss/denali/denali/lib/runtime/application.ts:167:10)
at ApiApplication.Application (/Users/daw/projects/oss/denali/denali/lib/runtime/application.ts:98:10)
at ApiApplication (/Users/jamesdixon/Projects/healthgenie/api/app/application.js:3:16)
at Object.<anonymous> (/Users/jamesdixon/Projects/healthgenie/api/app/index.js:7:19)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:423:7)
at startup (bootstrap_node.js:147:9)
Server crashed. waiting for changes to restart ...
I then decided to kill the server and restart it, but the same error appears. Unfortunately, I can't get any further due to this error.
Denali CLI 0.0.11 Denali 0.0.26 Node 7.10.0 OS X 10.12
@jamesdixon could you paste what you have in your config/routes.js
file? It looks like the inflection library is trying to operate on a string that is undefined, so I'm guessing we are passing in the wrong thing to the router methods.
Moving this to the backlog pending a response. Happy to bump it back up if there's interest / activity.
/Users/iradchenko/sandbox/core/node_modules/inflection/lib/inflection.js:594
var ignore = ( inflector.indexOf( skip, str.toLowerCase()) > -1 );
^
TypeError: Cannot read property 'toLowerCase' of undefined
at Object._apply_rules (/Users/iradchenko/sandbox/core/node_modules/inflection/lib/inflection.js:594:52)
at Object.pluralize (/Users/iradchenko/sandbox/core/node_modules/inflection/lib/inflection.js:670:24)
at Router.resource (/Users/daw/projects/oss/denali/denali/lib/runtime/router.ts:317:18)
at drawRoutes (/Users/iradchenko/sandbox/core/config/routes.js:4:10)
at CoreApplication.compileRouter (/Users/daw/projects/oss/denali/denali/lib/runtime/application.ts:190:5)
at CoreApplication.Application (/Users/daw/projects/oss/denali/denali/lib/runtime/application.ts:113:10)
at CoreApplication (/Users/iradchenko/sandbox/core/app/application.js:3:16)
at Object.<anonymous> (/Users/iradchenko/sandbox/core/app/index.js:7:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
export default function drawRoutes(router) {
router.get('/', 'index');
router.resource();
}
Looks like denali generate resource <name>
doesn't set the name in the routes.
I spun up a fresh denali app (denali-cli v0.0.11, denali v0.0.26) following the quickstart. I ran
denali generate resource post
and when I restartdenali server
I get the following error.