sproutcore / build-tools

SproutCore Build Tools
12 stars 7 forks source link

What to insert exactly when sc_static refers to an unknown file? #14

Open mauritslamers opened 10 years ago

mauritslamers commented 10 years ago

When performing sc_static replacement of the tests application, it turns out it is referring to a picture which doesn't exist in the app.

For now, the BT will display a message to stdout (terminal), and replace sc_static with an empty string, but should perhaps also a developer warning be inserted as well?

dcporter commented 10 years ago

I believe Abbot goes exactly that route. The terminal message is the only developer warning that's available, I believe. Not sure how you would insert one into the code.

mauritslamers commented 10 years ago

By adding a SC.warn() line after the image url in debug mode (devserver mode). That will cause the dev warning to also show in the browser console.

dcporter commented 10 years ago

Unless it's at the beginning of a multiline command…

mauritslamers commented 10 years ago

or defined as value in a key-value list. There is one option still, which is to add it as last line of the offending file...

topherfangio commented 10 years ago

I like the last line of the file option, especially if you can add the original line to the message. Do you have a rough idea of how many times this occurs in a freshly generated SC app?

If it's in the neighborhood of 5-10, I'd say the message will be useful. If it's like 100, then we may want to consider a different approach so that we don't have a massive amount of output that the end-developer can't assist with.

Just some thoughts :-)

dcporter commented 10 years ago

It's in the neighborhood of zero, until the developer messes something up. Then it's usually one at a time.

dcporter commented 10 years ago

I'm not sure about needing to put it in the same file. How would it handle sc_static calls in CSS files, for example? I'm not sure they need to be, though – just say what the missing filename was, and folks can search their code for it.

And we can include some information about the now-required framework_name: prefix – "The following static files were referenced via sc_static() but were not found. If you are referencing a file in another framework, you must prefix it with 'other_framework_name:'."

topherfangio commented 10 years ago

That's a good point about the CSS. Can we just keep track of all of the instances where something is missing and add it at the end of the app's main.js/core.js (or just inject it into the output stream)?

I'm still not sure I understand quite how everything is working at the moment so please excuse and stupidity :-)

mauritslamers commented 10 years ago

In a dev server situation it is not too difficult to gather these warnings and attach them to the index.html in the form of a script giving a set of warnings, which then can also be used for other warnings

topherfangio commented 10 years ago

+1 - Sounds like a reasonable plan to me.