How to Use CoffeeScript with Phoenix Framework? - coffeescript

I need to integrate a few CoffeeScript functions with my Phoenix application.
How do I get CoffeeScript files to compile and run alongside my application?
I know that phoenix uses Brunch for the asset pipeline - is there a brunch package or something for CoffeeScript?

The Phoenix "Static Assets" page has instructions on how to set this up. Scroll a little more than halfway down that page.
Basically:
Add coffee-script-brunch to package.json above javascript-brunch.
Run npm install.
Create .coffee files in web/static/js (make sure they are referenced in app.js).
I also had to restart the Phoenix server.

Related

How to start with protractor automation using jasmin

I am new to protractor. I started to automate a small application using protractor. My question is do we create the project straight away using package.json by mentioning dependencies or
Do we install selenium , protractor through command prompt then write scripts. Once all done and working fine, then build the project using package.json again?
Please some one clarify me.
Thanks in advance
Protractor is used for end to end testing of another web project
You can create a separate folder called e2e in your project folder.
You can use the same package.json file, but create a new configuration file for e2e.
In the npm scripts you can first, build the project first and then run the test script.
Finally, I would say that a separate project is not required, as they are part of the same application.
I have worked on a couple of protractor projects. Feel free to ask anything.
Hope this answers your question.
You can create a simple project by downloading angular CLI project onto your workspace.
You can refer to any angular CLI site or video to start with. You will get all needed folders to start with, like e2e, src, etc and files like package.json, protractor conf etc.

How to create a babel plugin for internal use

How do we use a babel plugin that is not already accepted in a babel repository? I had trouble finding this answer reading through the babel plugin documentation.
We are interested in writing a babel plugin for for...in loops to address a bug in ios9 (ios9 Safari miscalculating sum). Although we would be happy to contribute it to the babel community, I was also wondering if it doesn't get accepted or isn't ready for general consumption, how to start using and testing it locally.
It's possible to make use of custom babel plugins that you can host on git.
You can refer to https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md for learning how you can develop and test your babel plugin locally.
Once you have developed the plugin, you can add a dependency for it in your project's package.json file.
Note that if you plan to make the plugin repository private, you'd have to create a personal access token (for Github) to allow npm to fetch repository contents. In that case, the example entry in your package.json file would be as follows:
"babel-plugin-transform-for-of-loop": "git+https://{token}:x-oauth-basic#github.com/username/babel-plugin-transform-for-of-loop"
Whatever package name that you pick for your plugin, you will need to add a reference for it in the .babelrc file. For this example, it would be as follows:
{
...
"plugins": [
"babel-plugin-transform-for-of-loop"
]
}
With that done, you should simply run npm install and your plugin would become active for your project.

Distribute Dart framework outside of package directory as project template

I'm trying to create a Dart backend framework that developers can download as a dependancy and have the basic folder structure, Dart files and such generated for them in their own project. From what I understand, downloading a dependancy package only places files inside the package directory/ies (although, I may be wrong).
To get around this, I believe Dart can be used like a Bash script, and can place files in the project directory automatically through running the package's bin files in the terminal (illustrated in the Running a script in a dependency https://www.dartlang.org/tools/pub/cmd/pub-run.html).
Would this be the best way to achieve the desired result? Or is there an easier way to download a framework as a project template? (I'd also like to place similar scripts for generating controllers and such in the tools directory, and don't know if keeping this framework as a dependancy would be necessary after 'install').
Thank you for reading.
You can use pub global activate some_package to be able to use pub global run some_package:some_script or just some_script to allow to run a script contained in a Dart package without adding it to the dependencies.
I think this is the best way to distribute it.

Foundation 5 Production Environment Files

I've created a new foundation project using the foundation new myproject --libsass method.
Its just a simple static index.html (for the purpose of this question).
I've deployed it to a live server now, and I am wondering about the best way to structure this. I have omitted the node_modules & scss directories, and i'm left with the following:
bower_components/
css/
js/
index.html
bowerrc
bower.json
Gruntfile.js
humans.txt
package.json
README.md
bower_components is needed in its current form, unless I shuffle some files around, which is what I intend to do, but I'm checking if there is a better way of doing this, and that I haven't missed some magic terminal command to deploy to production.
As msturdy suggested in the comments, grunt is the way to go here. There are a lot of plugins out there, see a list on the official page.
If you want to have grunt "compile" your project into one specific folder which you can then for example push to a deployment server, you should do several things in grunt:
compile your scss
minify your javascript, that is making the files smaller, see jscompress for a demo of what it is. All your js-files from /bower_components which you include in your project should be in a vendor.js which is loaded first, and then a second js-file should contain your custom js from /js
save everything into a deployment folder.
(optional) automatically deploy to a server.
Take a look at these grunt tutorials for setting up your gruntfile.js, you'll want to have two tasks, one for just quickly compiling your scss, one for the whole deployment process:
grunt is not weird and hard
official tutorial
sitepoint tutorial
They show you how to do certain things and definitely how to write the gruntfile. Plugins you might want to use apart from your current libsass plugin are uglify and any plugin that lets you deploy your code via git, ftp or anything else. You can download all these plugins via npm by adding them to your package.json and doing npm install, refer to their websites for exact usage instruction.

Unable to add CordovaLib as a target dependency

I'm trying to the the phoneGap framework as a library, there is something called CordovaLib which suppose to support it. here are the instractions http://docs.phonegap.com/en/2.0.0/guide_cordova-webview_ios.md.html
I followed the steps completely, however on step 23 I can't find the CordovaLib to add, and if I skip it I can't import the CDVViewController.
It looks like a basic Xcode configuration issue, Can anyone help me with that?
[Update] i've installed 1.9.0 and it works fine. they did some changes in the way they link the Lib in 2.0.0 and change the instructions accordingly however it doesn't seem to work.
I have had trouble with adding the target dependency as well.
One possible workaround is to open the CordovaLib project and build. This will create the CordovaLib.a library that you need to replace the pre 2.0 framework. You can then copy that library into your project and add it as a library dependency in the build phase area.