Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All coffee files when 'ember new' #65

Open
lnmunhoz opened this issue Mar 8, 2015 · 5 comments
Open

All coffee files when 'ember new' #65

lnmunhoz opened this issue Mar 8, 2015 · 5 comments

Comments

@lnmunhoz
Copy link

lnmunhoz commented Mar 8, 2015

When ember-cli creates a new project, all the main files already comes in common javascript. There's a way to create an extension for ember new to create the full project in coffee? Maybe something like ember new myApp --coffeescript

@kimroen
Copy link
Owner

kimroen commented Mar 8, 2015

Hi there, Lucas!

The way the ember new command works is to run all the things it needs to run, and then apply the app blueprint that comes with ember-cli. You can define your own app blueprint to run during this part by typing ember new myApp --blueprint=<url-for-my-blueprint>. We could certainly provide one that you could use for coffeescript-projects.

The problem with this though, and the reason we haven't done it, is that the app blueprint contains everything. The package.json, the starting folders, and lots of other things that aren't coffeescript-specific. I don't want to maintain a copy of that here and keep that up to date. You can see the blueprint here: https://github.com/ember-cli/ember-cli/tree/master/blueprints/app/files

Something I did think of though, that could be done:

We could provide a command that you can run after installing ember-cli-coffeescript that would ask you if you want to replace the js-files that comes with ember-cli with empty coffee-equivalents. Do you think that could be a solution? It could even run automatically when you install ember-cli-coffeescript.

The files in question would be app/app.js and app/router.js - I think those are the only ones? We could probably build upon that to add more things, but it's a start.

You would need to add a blueprint in the blueprints-folder and name it ember-cli-coffeescript. That way, it will automatically run when people run ember install:addon ember-cli-coffeescript.

If you'd like to take a shot at it, I'd love to accept a pull request with this. If not, I'll see if there's some time in the coming weeks.

@lnmunhoz
Copy link
Author

lnmunhoz commented Mar 9, 2015

Hey Kim!
I think your solution is much more simple than mine. Definitely is more easily to maintain and is a good approach. I can try to do this and send a PR, but I don't have idea of how to do it. What file I should modify to start creating this improvement for the installation of the addon?

Thank you!

@sdhull
Copy link

sdhull commented May 2, 2015

Is there an easy way to simply to convert js to coffee? Maybe that's the solution here.

@kimroen
Copy link
Owner

kimroen commented May 3, 2015

@sdhull Yeah, you do have libraries like js2coffee that converts that way. The problem is that these files contain import statements, and js2coffee doesn't handle these.

This:

import Ember from 'ember';

needs to become this:

`import Ember from 'ember'`

There will probably be even more cases of newer ES2015-syntax showing up in the default templates, and that will mean that it's even less likely that you can convert that way. I still think that a default blueprint and/or after-install commands is the way to go. This way, the experience of starting a new ember-cli project with coffeescript will be like this:

  1. ember new my-project
  2. ember install ember-cli-coffeescript
  3. Confirm that you want to overwrite app.js and router.js.

I didn't get the time to implement this this weekend, but I will try again when I find some.

@kimroen
Copy link
Owner

kimroen commented Mar 26, 2017

Now that CoffeeScript supports things like import and export, it could be that using js2coffee as suggested previously is feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants