Giter Club home page Giter Club logo

generator-dojo's Introduction

Dojo generator Build Status

A Dojo application generator for Yeoman.

Getting started

  • Make sure you have yo and generator-dojo installed:

    npm install -g yo generator-dojo
  • Make a new directory and traverse into it:

    mkdir my-app && cd $_
  • Run yo dojo, optionally passing an application name (the application name and AMD package will default to the directory you are currently in):

    yo dojo [app-name]

Application layout

generator-dojo will scaffold out a Dojo application using best practices for web development. This means the directory structure for development will be in the same structure as it would be after building for production:

src/
    dojo/
    dijit/
    dgrid/
    ...
    my-app/
    index.html

Because of this structure, a Dojo application is completely agnostic to the server which delivers it in both development and production environments and requires little to no configuration of the server. It will work equally as well with nginx as it would with Apache Tomcat.

Generators

Dojo

Sets up a new Dojo application, generating all of the boilerplate to get started. The application generator also optionally installs Dijit, DojoX, dgrid, and Stylus.

Example:

yo dojo

Test

Generates a unit or functional test for Intern and places it in src/<appname>/tests/<test name>.{js,html}. Optionally receives a --functional flag. If the flag is passed, a functional test is generated, otherwise a unit test is generated.

Example:

yo dojo:test --functional widgets/functional/MyWidget

Produces src/<appname>/tests/widgets/functional/MyWidget.js and src/<appname>/tests/widgets/functional/MyWidget.html.

Example:

yo dojo:test widgets/MyWidget

Produces src/<appname>/tests/widgets/MyWidget.js.

Grunt tasks

The default Gruntfile.js defines some common tasks for your Dojo application:

default

Compiles and watches for changes to changes in stylus files, compiling them if necessary.

build

Compiles your application into the dist directory using the Dojo build tool. The dist directory can then be copied, zipped, tarred, warred, etc. to a production server without the need for complex configuration of the server: it's just a directory of static files!

server

Serves up the src directory as the root directory of localhost:8888 (this can be configured using the connect.options.port option in Gruntfile.js). This also watches for changes to stylus files, compiling them if necessary.

server also takes an optional target flag. If this flag is dist, a build will run and the dist directory will be served as the root directory of localhost:8888:

grunt server:dist

intern

Runs unit and functional tests using Intern. Intern allows web developers to run unit and functional tests in various versions of browsers from the command line.

This task takes an optional target flag. If this flag is local, only local non-browser tests will be run. If this flag is remote, only remote tests will be run using Selenium (via SauceLabs or your own Selenium server). If this flag is not passed, both non-browser and remote tests will be run.

clean

Removes the dist directory (if one exists) to clean up after a build.

License

generator-dojo is available under the terms of the New BSD License. All code, with the exception of portions generated from Yeoman's generator-generator, is developed under the terms of the Dojo Foundation CLA.

© 2013 Bryan Forbes http://www.reigndropsfall.net
All rights reserved.

generator-dojo's People

Contributors

bryanforbes avatar modcoms avatar nicknisi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator-dojo's Issues

grunt build

I followed the instructions under Getting started.

npm install -g yo generator-dojo
mkdir dojo03 && cd $_
yo dojo dojo03
grunt server
grunt build

Regardless if I choose Shrinksafe, Closure oder Uglify the build stops with:

Building Dojo...
Error
Warning: Task "dojo:dist" failed. Use --force to continue.

using --force does not help.

The server seems to work:

grunt server
curl localhost:8888

results in

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8">
        <title>Dojo Application</title>

        <link rel="stylesheet" href="dojo03/resources/main.css">
</head>
<body class="claro">
        <script src="dojoConfig.js"></script>
        <script src="dojo/dojo.js" async></script>
</body>
</html>

Errors in build-report.txt:

error(307) Failed to evaluate module tagged as pure AMD (fell back to processing with regular expressions).
    module: dojo03/tests/dojoConfig; error: ReferenceError: location is not defined
error(356) The optimizer threw an exception; the module probably contains syntax errors.
    module identifier: dojo/dojo; exception: TypeError: object is not a function
    module identifier: dojo03/main; exception: TypeError: object is not a function

Whitespace collapsing is dangerous

When using Dojo declarative syntax for writing methods developer can write inline JavaScript comments, e.g.:

<script type="dojo/method" data-dojo-event="getChildren" data-dojo-args="object">
     // Supply a getChildren() method to store for the data model where
     // children objects point to their parent (aka relational model)
     return this.query({parent: this.getIdentity(object)});
</script>

(full example at http://livedocs.dojotoolkit.org/dijit/Tree-examples#id3 )

When spaces are being collapsed, such multiline code becomes single line of commented code, e.g.

<script [...]> // Supply [...] // children [...] return this.query({parent: this.getIdentity(object)}); </script>

which may lead to runtime errors about undefined variables (since now function doesn't return anything).

Spaces should be collapsed in smarter way taking in account such Dojo features.

Feature Request: Maqetta Directory Layout

Would it be possible to add an option to make the generator compatible with the Maqetta directory structure, that one could easily download the files, add it to the src directory and run the build?

Fatal error: spawn OK on Win7

When running the grunt build task I get the error: Fatal error: spawn OK, but only on Windows 7. On a Windows 8 system it works.

By using the verbose flag, I was able to figure out that the error occurs when it comes to processing the build profile.

Unfortunately I can't get more information to specify the problem. All I know so far is, that setting action to release leads to it.

Thanks!

Install bower dependencies in a bower_components folder?

Is it possible to configure this to install the bower_components in their own folder, than build it accordingly?

Also, when I'm trying to add a new component (LESS in this case), I'm getting the following error during the build --

 Module not tagged as pure AMD yet it contains AMD API applications

What are the steps for adding new components? I realize some of this may be more dojo-question oriented than just this generator -- thought it would be a good place to reach out though!

Thanks again for this app -- it's been a lifesaver!

HTML lang attribute causes built application to fail on startup with some widgets

Hello,

When I use the dijit/Dialog in my web page like this

<div class="dijitHidden">
    <div data-dojo-type="dijit/Dialog" id="myDialog" title="Name and Address">
        My Sample Dialog
    </div>
</div>

And then use just the parser to parse the html file and show the dialog in my main.js file:

define([
    'exports', 'dojo/ready', 'dojo/parser', 'dijit/registry', 'dijit/Dialog'
], function (widgettest, ready, parser, registry) {
    widgettest.init = function () {
    };

    ready(function() {
        parser.parse();
        registry.byId('myDialog').show();
        console.log('ready');
    });
});

The application is working fine in the "not compiled" version running with grunt server and shows the dialog on startup. But when I try to run it built with grunt server:dist, it won't show any error, but also the dialog isn't shown.

After replacing the compressed js files with uncompressed ones I've find out that the parser fails to parse the page, as it cannot find the localisation resources for the dialog (some reference in the code was resulting in undefined).

A simple fix to this issue was to change the lang attribute in the html page from:

<html lang="en">

to

<html lang="en-us">

The dialog was then working fine also in the built version of the application.

I'm not sure whether this is a problem in the dojo build or the component itself, but it was quite annoying to have built application not working with absolutely no error shown. Would it be possible to change this also directly in the generator to avoid the issue?

Can't get custom builds to work

Directly after yo dojo:

./build.sh -p ../../../profiles/myapp.profile.js --release
processing profile resource /Users/dirk/work/myapp/profiles/myapp.profile.js
discovering resources...
starting reading resources...
starting processing raw resource content...
starting tokenizing resource...
starting processing resource tokens...
starting parsing resource...
error(324) Error while transforming resource. resource: /Users/dirk/work/myapp/dojo/dojo.js; transform: 0; error: Error: ENOENT, open '/Users/dirk/work/myapp/dojo/dojo.js'

Using --dojoConfig:

./build.sh --dojoConfig ../../dojoConfig.js --release

dojo/dojox/dijit are minified in the release folder, but myapp is not.

Hopefully I'm just poking the bear the wrong way, but I can't seem to find a permutation of ./build.sh that works.

Grunt Build failing

Hey guys,

This repo is a lifesaver! Thank you in advance for your work on this :)

However, when I'm trying to run 'grunt build' it keeps failing (error while building dojo). This is the error:

 starting executing global optimizations...
 starting writing resources...
 starting cleaning up...
 waiting for the optimizer runner to finish...
 starting reporting...
 Report written to /Users/me/git-projects/yo-dojo/dist/build-report.txt
 Process finished normally.
     errors: 31
     warnings: 22
     build time: 64.222 seconds
 >> Error     
 Warning: Task "dojo:dist" failed. Use --force to continue.

Here's the build-report.txt file -- https://gist.github.com/streetlight/8844052

Hope this helps!

how to consume an app

if i use generator-dojo to make an app, then i share that app with someone, what is the minimum to get the app started? (assume they might not even have grunt, bower, yo - just node and npm)

The grunt server task has stylus hardcoded

Hello,

the grunt server task has stylus:compile and watch:stylus as nonconditional dependencies:

grunt.task.run([
    'stylus:compile',
    'connect:test',
    'watch:stylus'
]);

So if I choose not to include stylus in my build, when running the generator, the grunt server task will fail:

$ grunt server
Running "server" task
Warning: Task "stylus:compile" not found. Use --force to continue.

Aborted due to warnings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.