Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extract the `yo` tool into it's own repo

  • Loading branch information...
commit a747e60b2fd36ca11bf1fd902b4eea5d406b5b1a 1 parent 1d20dfb
@sindresorhus sindresorhus authored
View
8 .npmignore
@@ -1,8 +0,0 @@
-.npmignore
-.editorconfig
-.jshintrc
-.gitattributes
-setup
-sublime
-test
-Gruntfile.js
View
9 .travis.yml
@@ -1,9 +0,0 @@
-language: node_js
-node_js:
- - 0.8
-notifications:
- irc:
- channels:
- - "irc.freenode.org#yeoman"
- template:
- - "%{repository}: %{message} -- %{build_url}"
View
56 Gruntfile.js
@@ -1,56 +0,0 @@
-var util = require('util');
-var path = require('path');
-
-module.exports = function( grunt ) {
- 'use strict';
-
- grunt.initConfig({
- lint: {
- options: {
- options: '<json:.jshintrc>',
- global: {
- process: true
- }
- },
- grunt: [
- 'Gruntfile.js',
- //'tasks/*.js',
- ],
- lib: [
- //'lib/{plugins,utils}/*.js',
- //'lib/generators/*.js'
- ],
- test: [
- //'test/**/*.js'
- ]
- },
- watch: {
- files: '<config:lint>',
- tasks: 'lint'
- }
- });
-
- // Disable lint for now until we upgrade to latest grunt with latest jshint
- grunt.registerTask( 'default', 'lint' );
-
- // Debugging helpers
- grunt.registerTask( 'list-helpers', 'List all grunt registered helpers', function( helper ) {
- var ls = grunt.log.wordlist( Object.keys( grunt.task._helpers ), grunt.util.linefeed );
-
- if ( !helper ) {
- return grunt.log.ok( ls );
- }
-
- grunt.log.subhead( helper + ' source:' ).writeln( grunt.task._helpers[ helper ] );
- });
-
- grunt.registerTask( 'list-tasks', 'List all grunt registered tasks', function( task ) {
- var ls = grunt.log.wordlist( Object.keys( grunt.task._tasks ), grunt.util.linefeed );
-
- if ( !task ) {
- return grunt.log.ok( ls );
- }
-
- grunt.log.subhead( task + ' source:' ).writeln( util.inspect( grunt.task._tasks[ task ] ) );
- });
-};
View
52 bin/help.txt
@@ -1,52 +0,0 @@
-
-                                                      
-                                                          
-                                                            
-                                                              
-                                                              
-                                                             
-                                                             
-                                                             
-                                                            
-                                                            
-                                                           
-                                                                 
-                                                                
-                                                              
-                                                                
-                                                                 
-                                                                
-                                                               
-                                                            
-                                                             
-                                                                 
-                                                                
-                                                                
-                                                          
-                                                          
-                                                          
-                                                         
-                                                         
-                                                         
-                                                             
-                                                               
-                                                                  
-                                                                    
-                                                                   
-                                                                 
-                                                               
-                                                            
-                                                         
-                                                    
- 
-
-Usage: <%= 'yo'.bold.red %> <%= '<generator>'.yellow %> [arguments] [--help]
-
-The <%= 'webapp'.yellow %> generator is bundled, while others can be installed with <%= 'npm install -g <generator-name>'.bold %>
-
-Officially supported generators:
-<%= 'webapp angular ember backbone chromeapp chrome-extension bootstrap mocha jasmine testacular'.yellow %>
-
-See a list of all available generators with <%= 'npm search yeoman-generator'.bold %>
-
-Now just run <%= 'yo'.bold.red %> <%= 'webapp'.yellow %> and have a great day :)
View
107 bin/yo
@@ -1,107 +0,0 @@
-#!/usr/bin/env node
-'use strict';
-var fs = require('fs');
-var path = require('path');
-var execFile = require('child_process').execFile;
-var nopt = require('nopt');
-var colors = require('colors');
-var _ = require('lodash');
-var pkg = require('../package.json');
-var updateNotifier = require('update-notifier');
-var Insight = require('insight');
-
-var helpScreen = _.template(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf8'));
-var opts = nopt({
- help: Boolean
-}, {
- h: '--help'
-});
-var args = opts.argv.remain;
-var cmd = args[0];
-
-var insight = new Insight({
- trackingCode: 'UA-31537568-1',
- packageName: pkg.name,
- packageVersion: pkg.version
-});
-
-/*jshint multistr:true */
-var insightMsg = '\
-=========================================================================='.grey + '\n\
-We\'re constantly looking for ways to make '.yellow + pkg.name.bold.red + ' better! \n\
-May we anonymously report usage statistics to improve the tool over time? \n\
-More info: yeoman.io/insight.html & http://yeoman.io'.yellow + '\n\
-=========================================================================='.grey;
-
-
-function init() {
- var env = require('yeoman-generator')();
-
- // register each built-in generator individually
- env.plugins('node_modules', __dirname);
-
- // alias any single namespace to `*:all` and `webapp` namespace specifically
- // to webapp:app.
- env.alias(/^([^:]+)$/, '$1:all');
- env.alias(/^([^:]+)$/, '$1:app');
-
- // lookup for every namespaces, within the environments.paths and lookups
- env.lookup('*:*');
-
- if (opts.help) {
- return console.log(env.help('yo'));
- }
-
- env.on('end', function () {
- console.log('done running sir');
- });
-
- env.on('error', function (err) {
- console.error('Error', process.argv.slice(2).join(' '), '\n');
- console.error(opts.debug ? err.stack : err.message);
- process.exit(err.code || 1);
- });
-
- // Note: at some point, nopt needs to know about the generator options, the
- // one that will be triggered by the below args. Maybe the nopt parsing
- // should be done internally, from the args.
- env.run(args, opts);
-}
-
-function pre() {
- if (opts.version) {
- return console.log(pkg.version);
- }
-
- if (!cmd) {
- return console.log(helpScreen());
- }
-
- init();
-}
-
-// TODO: Update docs to flag `--no-insight`
-if (!process.env.yeoman_test && opts.insight !== false) {
- if (insight.optOut === undefined) {
- insight.optOut = false;
- insight.track('downloaded');
- insight.askPermission(insightMsg, pre);
- return;
- }
- // only track the two first subcommands
- // TODO: Enable this before release
- //insight.track.apply(insight, args.slice(0, 2));
-}
-
-// TODO: Update docs to flag `--no-update-notifier`
-if (!process.env.yeoman_test && opts['update-notifier'] !== false) {
- var notifier = updateNotifier({
- packagePath: '../package',
- });
-
- if (notifier.update) {
- notifier.notify(true);
- }
-}
-
-pre();
View
5 changelog.md
@@ -1,3 +1,8 @@
+### 1.0
+
+See the [migration doc](https://github.com/yeoman/yeoman/wiki/Migrate-from-0.9.6-to-1.0).
+
+
### 0.9.5 - 2012-11-05
- [#627](https://github.com/yeoman/yeoman/issues/627)
View
53 man/bower.1
@@ -1,53 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-BOWER" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-bower\fR \-\- Specifics of yeoman\'s bower handling
-.
-.SH "SYNOPSIS"
-.
-.nf
-yeoman install
-yeoman uninstall
-yeoman update
-yeoman list
-yeoman search
-yeoman lookup
-.
-.fi
-.
-.SH "DESCRIPTION"
-These commands \.\.\.
-.
-.IP "\(bu" 4
-install: Install a package from the clientside package registry
-.
-.IP "\(bu" 4
-uninstall: Uninstall the package
-.
-.IP "\(bu" 4
-update: Update a package to the latest version
-.
-.IP "\(bu" 4
-list: List the packages currently installed
-.
-.IP "\(bu" 4
-search: Query the registry for matching package names
-.
-.IP "\(bu" 4
-lookup: Look up info on a particular package
-.
-.IP "" 0
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-faq(1)
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
25 man/build.1
@@ -1,25 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-BUILD" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-build\fR \-\- Build an optimized version of your app, ready to deploy
-.
-.SH "SYNOPSIS"
-.
-.nf
-yeoman build
-.
-.fi
-.
-.SH "DESCRIPTION"
-This command \.\.\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
24 man/faq.1
@@ -1,24 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-FAQ" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-faq\fR \-\- Frequently Asked Questions
-.
-.SH "But Whyyyyyyy?"
-That\'s not really a question\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman(1)
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "\(bu" 4
-yeoman\-gruntfile(1)
-.
-.IP "" 0
-
View
25 man/folders.1
@@ -1,25 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-FOLDERS" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-folders\fR \-\- Folder Structures Used by yeoman
-.
-.SH "DESCRIPTION"
-When you generate a new application or trigger a new build, yeoman puts various
-things on your computer\.
-.
-.P
-This document will tell you what it puts where\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-faq(1)
-.
-.IP "\(bu" 4
-yeoman\-gruntfile(1)
-.
-.IP "" 0
-
View
26 man/gruntfile.1
@@ -1,26 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-GRUNTFILE" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-gruntfile\fR \-\- Specifics of yeoman\'s Gruntfile handling
-.
-.SH "DESCRIPTION"
-This document is all you need to know about what\'s required in your \fBGruntfile\.js\fR file\.
-.
-.P
-A lot of the behavior described in this document is affected by the config
-settings described in Grunt\'s Gettint Started guide:
-https://github\.com/gruntjs/grunt/blob/master/docs/getting_started\.md
-.
-.SH "DEFAULT VALUES"
-\|\.\.\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-faq(1)
-.
-.IP "" 0
-
View
25 man/init.1
@@ -1,25 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-INIT" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-init\fR \-\- Initialize and scaffold a new project
-.
-.SH "SYNOPSIS"
-.
-.nf
-yeoman init
-.
-.fi
-.
-.SH "DESCRIPTION"
-This command \.\.\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
19 man/insight.1
@@ -1,19 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-INSIGHT" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-insight\fR \-\- Specifics of yeoman insight
-.
-.SH "DESCRIPTION"
-This document is all you need to know about what\'s done with insight, how it
-works, what it does, and how you can configure its behaviour\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
25 man/serve.1
@@ -1,25 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-SERVER" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-server\fR \-\- Launch a preview server
-.
-.SH "SYNOPSIS"
-.
-.nf
-yeoman server
-.
-.fi
-.
-.SH "DESCRIPTION"
-This command \.\.\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
25 man/server.1
@@ -1,25 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-SERVER" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-server\fR \-\- Launch a preview server
-.
-.SH "SYNOPSIS"
-.
-.nf
-yeoman server
-.
-.fi
-.
-.SH "DESCRIPTION"
-This command \.\.\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
25 man/test.1
@@ -1,25 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN\-TEST" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman-test\fR \-\- Runs a test suite in a headless PhantomJS
-.
-.SH "SYNOPSIS"
-.
-.nf
-yeoman test
-.
-.fi
-.
-.SH "DESCRIPTION"
-This command \.\.\.
-.
-.SH "SEE ALSO"
-.
-.IP "\(bu" 4
-yeoman\-folders(1)
-.
-.IP "" 0
-
View
151 man/yeoman.1
@@ -1,151 +0,0 @@
-.\" Generated with Ronnjs 0.3.8
-.\" http://github.com/kapouer/ronnjs/
-.
-.TH "YEOMAN" "1" "July 2012" "" ""
-.
-.SH "NAME"
-\fByeoman\fR \-\- Yeoman CLI tool
-.
-.SH "What am I?"
-Yeoman is a robust and opinionated client\-side stack, comprised of tools and
-frameworks that can help developers quickly build beautiful web applications\.
-We take care of providing everything needed to get started without any of the
-normal headaches associated with a manual setup\.
-.
-.P
-Yeoman is fast, performant and is optimized to work best in modern browsers\.
-.
-.P
-For more information about the project, see \fIhttp://yeoman\.io\fR\|\.
-.
-.SH "Installing"
-.
-.IP "\(bu" 4
-Clone this repo and \fBcd\fR into it
-.
-.IP "\(bu" 4
-Run the following command at the terminal:
-.
-.IP "" 0
-.
-.P
-\fBshell
-\|\./setup/install\.sh\fR
-.
-.IP "\(bu" 4
-Navigate to a new directory and run \fByeoman init\fR to make sure everything is
-working as expected\.
-.
-.IP "" 0
-.
-.SS "Trouble\-shooting"
-If for any reason you experience exceptions after the yeoman installation
-process above, you may find the following steps resolve these issues:
-.
-.P
-\fB
-$ cd yeoman/cli
-$ sudo npm install \-g
-# when complete then run\.\.
-$ sudo npm link\fR
-.
-.SH "Running"
-Here\'s a small shell script that you can save as \fBserver\.sh\fR which opens and
-servers the current directory on the port specified:
-.
-.P
-\fB\fR`shell
-port=$1
-if [ $# \-ne 1 ]
-then
- port=8000
-fi
-.
-.P
-if [ $(uname \-s) == "Darwin" ]
-then
- open=open
-else
- open=xdg\-open
-fi
-.
-.P
-$open http://localhost:$port && python \-m SimpleHTTPServer $port; \fB\fR`
-.
-.P
-For example, run this guy as:
-.
-.P
-\fBshell
-\|\./server\.sh 8000\fR
-.
-.SH "Documentation"
-The current documentation for Yeoman can be found here \fIhttp://yeoman\.github\.com/docs\fR\|\. If you are a new contributor and require
-access to this repository, feel free to ask\.
-.
-.SH "Browser Support"
-Yeoman supports:
-.
-.IP "\(bu" 4
-Modern browsers (latest versions of Chrome, Safari, Firefox, Opera and IE10)
-.
-.IP "\(bu" 4
-Chrome on Android
-.
-.IP "\(bu" 4
-Mobile Safari
-.
-.IP "" 0
-.
-.SH "Contribute"
-.
-.SS "Repos"
-.
-.IP "\(bu" 4
-Yeoman (CLI, Insights) \fIhttp://github\.com/yeoman/yeoman\fR
-.
-.IP "\(bu" 4
-Yeoman I/O Holding Page \fIhttp://github\.com/yeoman/yeoman\.io\fR
-.
-.IP "\(bu" 4
-Yeoman I/O Site \fIhttp://github\.com/yeoman/yeoman\.io\fR(site branch)
-.
-.IP "\(bu" 4
-Yeoman Docs \fIhttp://github\.com/yeoman/docs\fR
-.
-.IP "" 0
-.
-.SS "Style Guide"
-This project follows the jQuery Style
-Guide \fIhttp://docs\.jquery\.com/JQuery_Core_Style_Guidelines\fR with an exception
-of two space indentation and multiple var statements\. Please ensure any pull
-requests follow this closely\. If you notice existing code which doesn\'t follow
-these practices, feel free to shout and we will address this\.
-.
-.SH "About"
-Yeoman is an open\-source project by Google which builds on top of a number of
-open\-source solutions\. These include Grunt, Twitter Bootstrap and Compass\.
-Version 1 of the project features the combined efforts of:
-.
-.IP "\(bu" 4
-Paul Irish
-.
-.IP "\(bu" 4
-Addy Osmani
-.
-.IP "\(bu" 4
-Mickael Daniel
-.
-.IP "\(bu" 4
-Sindre Sorhus
-.
-.IP "\(bu" 4
-Eric Bidelman \fIhttp://ericbidelman\.com\fR
-.
-.IP "" 0
-.
-.P
-and other developers\.
-.
-.P
-We will be aiming to officially release the project in late July, 2012\.
View
57 package.json
@@ -1,57 +0,0 @@
-{
- "name": "yo",
- "version": "1.0.0-beta.1",
- "description": "Yo is a CLI tool for scaffolding out Yeoman projects",
- "keywords": [
- "front-end",
- "development",
- "dev",
- "build",
- "web",
- "tool",
- "cli",
- "scaffold",
- "stack"
- ],
- "homepage": "http://yeoman.io",
- "bugs": "https://github.com/yeoman/yeoman/issues",
- "author": "Chrome Developer Relations",
- "bin": {
- "yo": "bin/yo"
- },
- "directories": {
- "man": "man"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/yeoman/yeoman.git"
- },
- "scripts": {
- "test": "mocha test/test-*.js",
- "manpages": "./scripts/docs-build"
- },
- "dependencies": {
- "yeoman-generator": "https://github.com/yeoman/generator/archive/master.tar.gz",
- "generator-webapp": "https://github.com/yeoman/generator-webapp/archive/master.tar.gz",
- "generator-mocha": "http://github.com/yeoman/generator-mocha/archive/master.tar.gz",
- "colors": "~0.6.0",
- "nopt": "~2.1.1",
- "lodash": "~1.0.0-rc.3",
- "update-notifier": "~0.1.2",
- "insight": "~0.1.0"
- },
- "devDependencies": {
- "mocha": "~1.8.1",
- "ronn": "~0.3.8",
- "grunt": "~0.4.0rc7"
- },
- "engines": {
- "node": ">=0.8.0"
- },
- "preferGlobal": true,
- "licenses": [
- {
- "type": "BSD"
- }
- ]
-}
View
18 scripts/docs-build
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-
-DOCS_FILES=$(find doc/*.md)
-MAN_FOLDER=man/
-RONN=./node_modules/.bin/ronn
-
-mkdir -p $MAN_FOLDER
-
-function ronnify {
- $RONN --roff $1 > $2
-}
-
-for file in $DOCS_FILES; do
- docpath=${file/doc/man}
- ronnify $file ${docpath/.md/.1}
-done
-
View
34 scripts/pre-commit
@@ -1,34 +0,0 @@
-#!/usr/bin/env node
-
-//
-// Consider adding this to your local .git/hooks/pre-commit. To
-// install (or update):
-//
-// cat scripts/pre-commit > .git/hooks/pre-commit
-// chmod +x .git/hooks/pre-commit
-//
-//
-// Does two thing before allowing the commit:
-//
-// * runs `grunt lint`
-// * runs `npm test`
-//
-
-var spawn = require('child_process').spawn;
-
-run('grunt lint').on('next', run.bind({}, 'npm test'));
-
-function run(args) {
- args = args.split(' ');
- var cmd = args.shift();
- var ch = spawn(cmd, args);
- ch.stdout.pipe(process.stdout);
- ch.stderr.pipe(process.stderr);
- ch.on('exit', function (code) {
- if(code) process.exit(code);
- var end = !ch.emit('next');
- if()
- });
- return ch;
-}
-
View
79 test/fixtures/usemin.html
@@ -1,79 +0,0 @@
-<!DOCTYPE html>
-<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
-<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
-<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
-<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <title></title>
- <meta name="description" content="">
- <meta name="viewport" content="width=device-width">
-
- <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
-
-
- <link rel="stylesheet" href="styles/main.css">
- <script src="scripts/vendor/modernizr.min.js"></script>
- </head>
- <body>
- <div class="container" style="margin-top:50px">
- <div class="hero-unit">
- <h1>Wotcha!</h1>
- <p>You now have</p>
- <ul>
- <li>HTML5 Boilerplate</li>
- <li>Twitter Bootstrap</li>
- <li>Twitter Bootstrap plugins</li>
- <li>RequireJS</li>
- <li>Support for ES6 Modules</li>
- </ul>
- <p>installed.</p>
- <h3>Enjoy coding! - Yeoman</h3>
- </div>
- </div>
-
- <!--[if lt IE 7]>
- <p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
- <![endif]-->
-
- <!-- Add your site or application content here -->
-
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
- <script>window.jQuery || document.write('<script src="scripts/vendor/jquery.min.js"><\/script>')</script>
-
-
-
- <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
- <script>
- var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
- (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
- g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
- s.parentNode.insertBefore(g,s)}(document,'script'));
- </script>
-
- <!-- build:js /scripts/plugins.js -->
- <script src="scripts/vendor/bootstrap/bootstrap-affix.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-alert.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-dropdown.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-tooltip.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-modal.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-transition.js"></script>
-
- <script src="scripts/vendor/bootstrap/bootstrap-button.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-popover.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-typeahead.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-carousel.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-scrollspy.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-collapse.js"></script>
- <script src="scripts/vendor/bootstrap/bootstrap-tab.js"></script>
- <!-- endbuild -->
-
- <!-- build:js scripts/amd-app.js -->
- <script data-main="scripts/main" src="scripts/vendor/require.js"></script>
- <!-- endbuild -->
-
- <img src="images/test.png">
- <img src="images/misc/test.png">
-</body>
-</html>
View
160 test/helpers/index.js
@@ -1,160 +0,0 @@
-
-var fs = require('fs');
-var path = require('path');
-var spawn = require('child_process').spawn;
-var rimraf = require('rimraf');
-var mkdirp = require('mkdirp');
-var which = require('which');
-var Runnable = require('./runnable');
-
-// top level exports
-var helpers = module.exports;
-
-// path to the yeoman bin entry point
-var yeomanpath = path.join(__dirname, '../../bin/yeoman');
-
-// specific flag to ensure we bypass insight prompt, even when these
-// tests are not run within an npm scripts (eg direct use of mocha)
-var env = process.env;
-env.yeoman_test = true;
-
-// Top level helper for running specific command on the yeoman cli. Returns a
-// Runnable object with API for asserting stdout output, entering prompts and
-// so on.
-//
-// - cmds - A String specifying the list of command to run
-//
-// Example:
-//
-// var yeoman = helpers.run('init --force');
-// yeoman.prompt(/Woud you like/, 'Y');
-// yeoman.end(done);
-//
-// Returns a new Runnable object.
-helpers.run = function run(cmds, opts) {
- return new Runnable([process.execPath, yeomanpath, cmds].join(' '), opts);
-};
-
-// Removes, creates and cd into the specified directory. If the current working
-// directory is the same as the specified one, then acts as a noop. Meant to be
-// used once per mocha suite.
-//
-// - dir - the directory path to create
-//
-// Example:
-//
-// before(helpers.directory('.test'));
-//
-// Returns a function suitable to use with mocha's before/after hooks.
-helpers.directory = function directory(dir) {
- return function directory(done) {
- process.chdir(path.join(__dirname, '../..'));
- rimraf(dir, function(err) {
- if(err) return done(err);
- mkdirp(dir, function(err) {
- if(err) return done(err);
- process.chdir(dir);
- done();
- });
- });
- };
-};
-
-
-// Meant to be used with mocha handlers like before / beforeEach, etc. Creates
-// and manage a yeoman child process, providing the child instance in the mocha
-// context as `self.child`, collecting output for both stdout / stderr as
-// `self.stdout` and `self.stderr`
-//
-// - cmds - A String specifying the list of command to run
-// - takeOver - (Optional) A Boolean that when set to true will create the
-// child and forget, allowing user to interract with the child
-// instance (collecting output, writing to stding, listening to
-// exit)
-//
-// Example:
-//
-// before(helpers.yeoman('foo'));
-//
-// describe('when I run foo', function() {
-// it('should run foo and expose child process and stdout / stderr output', function() {
-// console.log(this.stdout);
-// console.log(this.stderr);
-//
-// });
-// });
-//
-//
-// Returns a function suitable to use with mocha hooks.
-helpers.yeoman = function (cmds, takeOver) {
- var args = [yeomanpath].concat(cmds.split(' ')),
- options = { env: env };
-
- if(takeOver) return spawn(process.execPath, args, options);
-
- return function yeoman(done) {
- var child = this.child = spawn(process.execPath, args, options);
- var out = this.stdout = '';
- var err = this.stderr = '';
- child.stdout.on('data', function(chunk) {
- out += chunk;
- });
- child.stderr.on('data', function(chunk) {
- err += chunk;
- });
- child.on('end', done);
- };
-};
-
-// Generates a new Gruntfile.js in the current working directory based on
-// `options` hash passed in. Same as other helpers, meant to be use as a mocha handler.
-//
-// - options - Grunt configuration
-//
-// Example
-//
-// before(helpers.gruntfile({
-// foo: {
-// bar: '<config.baz>'
-// }
-// }));
-//
-// Returns a function suitable to use with mocha hooks.
-helpers.gruntfile = function(options, taskMap) {
- return function gruntfile(done) {
- var config = 'grunt.initConfig(' + JSON.stringify(options, null, 2) + ');';
- config = config.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
-
- var tasks = Object.keys(taskMap || {}).map(function(key) {
- return '\ngrunt.registerTask(\'' + key + '\', ' + taskMap[key] + ');';
- }).join('\n');
-
- var out = [
- 'module.exports = function(grunt) {',
- config,
- tasks,
- '};'
- ];
-
- fs.writeFile('Gruntfile.js', out.join('\n'), done);
- };
-};
-
-
-// Mocha before helper. Takes a command String to be checked against `which`
-// package, and a callback to call on completion, most likely the mocha async
-// `done` callback.
-//
-// Setups the relevant Boolean flag on the test context.
-//
-helpers.installed = function installed(command, cb) {
- return function installed(done) {
- var ctx = this;
- which(command, function(err) {
- ctx[command] = !err;
- done();
- });
- };
-};
View
198 test/helpers/runnable.js
@@ -1,198 +0,0 @@
-var spawn = require('child_process').spawn,
- events = require('events'),
- util = require('util');
-
-//
-// Main assertion thingy. First rough work.
-//
-// Thx to @visionmedia, based off supertest's Runnable object:
-// https://github.com/visionmedia/supertest/blob/master/lib/Runnable.js
-//
-
-
-module.exports = Runnable;
-
-// Initialize a new `Runnable` with the given `options` Hash object.
-
-function Runnable(cmds, options) {
- this.options = options || {};
- this._body = null;
- this._status = 0;
- this._command = '';
- this._prompts = [];
- this._expects = [];
- this.use(cmds);
-}
-
-// inherits from EventEmitter
-
-util.inherits(Runnable, events.EventEmitter);
-
-// Setup CLI command.
-Runnable.prototype.use = function use(command) {
- this._command = command;
- return this;
-};
-
-
-//
-// Expectations:
-//
-// .expect(0)
-// .expect(0, fn)
-// .expect(0, body)
-// .expect('Some body')
-// .expect('Some body', fn)
-//
-
-Runnable.prototype.expect = function expect(a, b){
- var self = this;
-
- // status
- if (typeof a === 'number') {
- this._status = a;
- // body
- if (b && typeof b !== 'function') this.addExpectation(b);
- else if(typeof b === 'function') this.end(b);
- return this;
- }
-
- this.addExpectation(a);
-
- // callback
- if (typeof b === 'function') this.end(b);
-
- return this;
-};
-
-// Adds a new expectation to the list of expected result. Can be either a
-// regexp or a string, in which case direct match (body === stdout)
-Runnable.prototype.addExpectation = function addExpectation(match) {
- this._expects.push(match);
-};
-
-
-// Adds a new prompt hook to the list of expected prompts, automatically
-// writes the `answer` string provided to child's stdin when the
-// `matcher` RegExp or String match a given prompt in child stdout.
-Runnable.prototype.prompt = function prompt(matcher, answer) {
- matcher = matcher instanceof RegExp ? matcher : new RegExp(matcher, 'i');
- this._prompts.push({
- matcher: matcher,
- answer: (answer || '') + '\n'
- });
- return this;
-};
-
-// Defer invoking `.end()` until the command is done running.
-Runnable.prototype.end = function end(fn) {
- var self = this;
- fn = fn || function() {};
-
- this.run(function(err, code, stdout, stderr) {
- if(err) return fn(err, stdout, stderr);
-
- self.emit('done');
- self.emit('end');
-
- self.assert({
- status: code,
- text: (stdout || stderr)
- }, fn);
- });
-
- return this;
-};
-
-// Add topic to current (or root)
-Runnable.prototype.run = function run(fn) {
- var self = this,
- cmds = this._command,
- opts = this.options;
-
- if(this._run) return fn(null, self.code, self.stdout, self.stderr);
- if(!cmds) return this.emit(new Error('Cannot run without a command. Use .use!'));
-
- cmds = cmds.split(' ');
-
- // Execute defined command with arguments and passed options
- var child = spawn(cmds.shift(), cmds, opts),
- write = child.stdin.write.bind(child.stdin);
-
- // mark this runnable as consumed
- this._run = true;
-
- // case of redirect options turned on, pipe back all stdout / stderr
- // output to parent process
- if(opts.redirect) {
- child.stdout.pipe(process.stdout);
- child.stderr.pipe(process.stderr);
- }
-
- self.stdout = '';
- child.stdout.setEncoding('utf8');
- child.stdout.on('data', function(chunk) {
- self.stdout += chunk;
- self.emit('data', chunk);
- self._prompts.forEach(function(prompt) {
- if(prompt.matcher.test(chunk)) {
- process.nextTick(write.bind(null, prompt.answer));
- }
- });
- });
-
- self.stderr = '';
- child.stderr.on('data', function(chunk) {
- self.stderr += chunk;
- });
-
- child.on('exit', function(code) {
- self.code = code;
- if(!code) return fn(null, code, self.stdout, self.stderr);
- var msg = 'Error executing "' + self._command + '". Code:' + code;
- var err = new Error(msg + '\n\n' + (self.stderr || self.stdout));
- err.code = code;
- fn(err, code, self.stdout, self.stderr);
- });
-
- return this;
-};
-
-
-// Perform assertions and invoke `fn(err)`.
-Runnable.prototype.assert = function assert(res, fn) {
- var status = this._status,
- expects = this._expects;
-
- // status
- if (status && res.status !== status) {
- return fn(new Error('expected ' + status + ', got ' + res.status), res);
- }
-
- // expectations
- var errors = [];
- expects.forEach(function(expect) {
- var isregexp = expect instanceof RegExp,
- expected = util.inspect(expect);
-
- // regexp
- if (isregexp) {
- if (!expect.test(res.text)) {
- return errors.push(expected);
- }
- } else if(!!~res.text.indexOf(expected)) {
- return errors.push(expected);
- }
- });
-
- if(!errors.length) return fn(null, res);
-
- var msg = 'Expected ' + util.inspect(res.text) + '\n to match:\n';
- msg += errors.map(function(expected) {
- return ' - ' + expected;
- }).join('\n');
-
- fn(new Error(msg), res);
-
-};
-
View
8 test/mocha.opts
@@ -1,8 +0,0 @@
---slow 1500
---timeout 50000
-
---reporter spec
-
---globals events
---globals AssertionError
---globals TAP_Global_Harness
View
106 test/test-bower.js
@@ -1,106 +0,0 @@
-/*globals describe, it, before, after, beforeEach, afterEach */
-var fs = require('fs'),
- path = require('path'),
- grunt = require('grunt'),
- assert = require('assert'),
- helpers = require('./helpers'),
- bower = require('bower').commands;
-
-// bower components to test out
-var components = ['jquery', 'backbone', 'spine'];
-// var components = ['jquery', 'backbone', 'ember', 'angular', 'canjs'];
-
-describe('Bower install packages', function() {
-
- before(helpers.directory('.test'));
-
- before(helpers.gruntfile({
- foo: {
- bar: '<config.baz>'
- }
- }));
-
- before(function(done) {
- var yeoman = helpers.run('init --force');
- yeoman
- // enter '\n' for both prompts, and grunt confirm
- .prompt(/would you like/i)
- .prompt(/Do you need to make any changes to the above before continuing?/)
- // check exit code
- .expect(0)
- // run and done
- .end(done);
- });
-
- components.forEach(function(name) {
- it('should install ' + name + ' with yeoman install ' + name, function(done) {
- console.log();
- helpers.run('install ' + name, { redirect: true })
- .expect(0)
- .end(done);
- });
-
-
- it('should have copied resolved components to app/components', function(done) {
- var ctx = this;
-
- fs.stat(path.join('app/components', name), done);
-
- /*
- bower.list({ map: true })
- .on('error', done)
- .on('data', function(results) {
-
- ctx.results = results;
- var pkg = results[name];
-
- var source = ctx[name] = pkg.source.main;
- var vendor = source.replace(/^components/, 'app/components');
- fs.stat(vendor, done);
-
-
- });
-
- */
- });
- });
-
- // These tests are failing, and specifically testing out some current issues
- // we might have.
-
- /* * /
- describe('should not override non "components" files in app/scripts/vendor', function(done) {
- ['esprima.js', 'hm.js', 'jquery.min.js', 'modernizr.min.js', 'require.js'].forEach(function(file) {
- it('like ' + file, function(done) {
- fs.stat(path.join('app/scripts/vendor', file), done);
- });
- });
- });
- /* */
-
- /* * /
- describe('should have updated the RequireJS configuration for paths', function() {
-
- before(function() {
- this.main = grunt.file.read('app/scripts/main.js');
- });
-
- components.forEach(function(name) {
- it('configuration for ' + name + ' is updated', function() {
- var source = this[name];
- // map the bower resolved package to be within vendor/
- var pathname = source.replace(/^components/, 'vendor').replace(path.extname(source), '');
-
- // assert string against lines, to gain diff output
- var pathline = this.main.split('\n').filter(function(line) {
- return line.indexOf(name + ':') !== -1;
- })[0];
-
- var pattern = name + ": '" + pathname + "',";
- assert.equal(pathline.trim(), pattern);
- });
- });
- });
- /* */
-
-});
View
229 test/test-build.js
@@ -1,229 +0,0 @@
-/*global describe, before, after, beforeEach, afterEach, describe, it */
-var fs = require('fs');
-var path = require('path');
-var grunt = require('grunt');
-var assert = require('assert');
-var helpers = require('./helpers');
-
-var opts = grunt.cli.options;
-opts.redirect = !opts.silent;
-
-// XXX Conform to coding guidelines, mostly literral spacing stuff
-
-describe('yeoman init && yeoman build', function() {
-
- before(helpers.directory('.test'));
-
- before(helpers.gruntfile({
- foo: {
- bar: '<config.baz>'
- }
- }));
-
- // Handle missing dependencies during test run, we only run compass /
- // manifest related test when necessary binaries are available. This helper
- // defines the respective boolean flag on the mocha test context, and used
- // within some of our tests to conditionnaly go through.
- before(helpers.installed('compass'));
- before(helpers.installed('phantomjs'));
-
- describe('When I run init app with default prompts', function(done) {
- before(function(done) {
- var yeoman = helpers.run('init --force', opts);
- yeoman
- // enter '\n' for both prompts, and grunt confirm
- .prompt(/would you like/i)
- .prompt(/Do you need to make any changes to the above before continuing?/)
- // check exit code
- .expect(0)
- // run and done
- .end(done);
- });
-
- it('should generate index.html with bootstrap plugins', function() {
- var index = grunt.file.read('app/index.html');
- assert.ok((/<!-- build:js scripts\/plugins.js -->/).test(index));
- assert.ok((/<!-- endbuild -->/).test(index));
-
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-affix.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-alert.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-dropdown.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-tooltip.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-modal.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-transition.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-button.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-popover.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-typeahead.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-carousel.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-scrollspy.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-collapse.js'));
- assert.ok(index.match('scripts/vendor/bootstrap/bootstrap-tab.js'));
- });
-
- it('should generate an app/ directory', function(done) {
- fs.stat('app/', done);
- });
-
- it('should generate a test/ directory', function(done) {
- fs.stat('test/', done);
- });
-
- it('should generate a test/spec/ directory', function(done) {
- fs.stat('test/spec/', done);
- });
-
- it('should generate a Gruntfile.js file', function(done) {
- fs.stat('Gruntfile.js', done);
- });
-
- describe('And I run a build', function() {
- before(function() {
- // setup some very basic coffee setup, to test out
- // coffee output
- grunt.file.write('app/scripts/foo.coffee', 'foo = "yeo"');
- });
-
- before(function(done) {
- // setup the runnable
- this.yeoman = helpers.run('build:test --no-color', opts)
- .expect(0)
- .end(done);
- });
-
- describe('mkdirs', function() {
- var dirs = ['index.html', 'images/', 'styles/', 'scripts/', 'templates'];
- dirs.forEach(function(filepath) {
- it('should copy ' + filepath + ' to the staging directory', function(done) {
- fs.stat(path.join('temp', filepath), done);
- });
- });
- });
-
-
- describe('coffee', function() {
- it('should go through coffee:dist', function() {
- // handled version file, get back filename via grunt globbing
- var foo = grunt.file.expandFiles('temp/scripts/*.foo.js')[0];
- assert.equal(grunt.file.read(foo), '(function() {\n var foo;\n\n foo = "yeo";\n\n}).call(this);\n');
- });
- });
-
- describe('compass', function() {
- it('should go through compass:dist', function() {
- if( !this.compass ) { return; }
- var main = grunt.file.expandFiles('temp/styles/*.main.css')[0];
- var body = grunt.file.read(main);
- assert.ok(/article,aside,details/.test(body));
- });
- });
-
- describe('img', function() {
- // TBD: setup some fixture, check that files in temp/images are smaller
- // than the one in app/images
- it('should go through img:dist');
- });
-
- describe('rjs', function() {
- it('should optimize scripts/main', function() {
- var file = grunt.file.expandFiles('temp/scripts/*.amd-app.js')[0];
- var body = grunt.file.read(file);
- assert.ok(/Hello from Yeoman!/, body);
- });
- });
-
- describe('concat', function() {
- it('should write plugins.js concat target', function() {
- var file = grunt.file.expandFiles('temp/scripts/*.plugins.js')[0];
- var body = grunt.file.read(file);
-
- // some of the expected bootstrap plugins
- ['affix', 'alert', 'dropdown', 'tooltip', 'modal', 'button'].forEach(function(str) {
- assert.ok(body.indexOf(str) !== -1);
- });
- });
-
- it('should write amd-app.js concat target', function() {
- var file = grunt.file.expandFiles('temp/scripts/*.amd-app.js')[0];
- var body = grunt.file.read(file);
-
- // some of the expected pattern in this optimized minified file
- ['Hello from Yeoman!', 'requirejs'].forEach(function(str) {
- assert.ok(body.indexOf(str) !== -1);
- });
- });
- });
-
- describe('rev', function() {
- describe('rev: should find and process the following files', function() {
- it('scripts/main.js >> {rev}.main.js', function() {
- var file = grunt.file.expandFiles('temp/scripts/*.main.js')[0];
- assert.ok(/[a-z0-9]+\.main\.js/.test(file));
- });
- it('scripts/vendor/bootstrap-alert.js >> {rev}.bootstrap-alert.js', function() {
- var file = grunt.file.expandFiles('temp/scripts/vendor/bootstrap/*.bootstrap-alert.js')[0];
- assert.ok(/[a-z0-9]+\.bootstrap-alert\.js/.test(file));
- });
- it('scripts/vendor/jquery.min.js >> {rev}.jquery.min.js', function() {
- var file = grunt.file.expandFiles('temp/scripts/vendor/*.jquery.min.js')[0];
- assert.ok(/[a-z0-9]+\.jquery\.min\.js/.test(file));
- });
- it('scripts/vendor/require.js >> {rev}.require.js', function() {
- var file = grunt.file.expandFiles('temp/scripts/vendor/*.require.js')[0];
- assert.ok(/[a-z0-9]+\.require\.js/.test(file));
- });
- });
- });
-
- describe('usemin', function() {
- before(function() {
- this.body = grunt.file.read('temp/index.html');
- });
-
- describe('usemin: should find and replace the following files', function() {
- it('scripts/vendor/modernizr.min.js', function() {
- var file = path.basename(grunt.file.expandFiles('temp/scripts/vendor/*.modernizr.min.js')[0]);
- assert.ok(this.body.indexOf(file) !== -1);
- });
- it('scripts/amp-app.js', function() {
- var file = path.basename(grunt.file.expandFiles('temp/scripts/*.amd-app.js')[0]);
- assert.ok(this.body.indexOf(file) !== -1);
- });
- it('styles/main.css', function() {
- if( !this.compass ) { return; }
- var file = path.basename(grunt.file.expandFiles('temp/styles/*.main.css')[0]);
- assert.ok(this.body.indexOf(file) !== -1);
- });
- });
- });
-
- describe('manifest', function() {
- it('should write to manifest.appcache', function() {
- if( !this.phantomjs ) { return; }
-
- var manifest = grunt.file.read('temp/manifest.appcache');
- assert.ok(/CACHE:/.test(manifest));
- assert.ok(/scripts\/[a-z0-9]+\.amd-app\.js/.test(manifest));
- assert.ok(/scripts\/[a-z0-9]+\.plugins\.js/.test(manifest));
- assert.ok(/scripts\/vendor\/[a-z0-9]+\.modernizr\.min\.js/.test(manifest));
-
- if( !this.compass ) { return; }
- assert.ok(/styles\/[a-z0-9]+\.main\.css/.test(manifest));
- });
- });
-
- });
-
- });
-
- describe('And when I launch a test server ', function() {
- it('should export the needed directories');
-// it('should export the needed directories', function(done) {
-// // setup the runnable, the actual run happens on last step
-// this.yeoman = helpers.run('server:test', opts);
-// this.yeoman
-// .expect(/\/test/)
-// .expect(/\/app/)
-// .end(done);
-// });
- });
-});
View
28 test/test-insight.py
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import unittest
-import os
-
-sys.path.append('../bin/')
-
-from yeomaninsight import main, Analytics
-
-class YeomanInsightTest(unittest.TestCase):
-
- def test_init_should_error_when_no_tracking_code_is_passed(self):
- self.assertRaises(Exception, Analytics, tracking_code='')
-
- def test_init_should_error_when_no_av_is_passed(self):
- self.assertRaises(Exception, Analytics, av='')
-
- def test_main_should_error_when_arguments_are_less_than_two(self):
- # temporally disables print function, because it's used on main.
- # just to keep the tests output clean.
- sys.stdout = open(os.devnull, 'w')
- self.assertRaises(SystemExit, main, args='')
- # restores print function.
- sys.stdout = sys.__stdout__
-
-if __name__ == '__main__':
- unittest.main()
View
42 test/test-server.js
@@ -1,42 +0,0 @@
-/*global describe, before, after, beforeEach, afterEach, describe, it */
-var helpers = require('./helpers');
-var grunt = require('grunt');
-var assert = require('assert');
-var fs = require('fs');
-
-describe('yeoman server', function() {
- before(helpers.directory('.test'));
-
- describe('When I run the app server with a customized task', function () {
- var options = {
- server: {
- app: 'testTask'
- }
- };
- var tasks = {
- 'testTask': function () {
- grunt.file.write('test_task/test.js', '"testing custom task"');
- }
- };
-
- before(helpers.gruntfile(options, tasks));
-
- before(function(done) {
- this.yeoman = helpers.run('server:app --no-color', {redirect: true})
- .expect(0)
- .end(done);
- });
-
- it('should generate a testTask directory', function(done) {
- fs.stat('test_task/', done);
- });
-
- it('should generate a test.js file', function(done) {
- fs.stat('test_task/test.js', done);
- });
-
- it('should write the content from the task to the test file', function() {
- assert.equal(grunt.file.read('test_task/test.js'), '"testing custom task"');
- });
- });
-});
View
137 test/test-usemin.js
@@ -1,137 +0,0 @@
-/*global describe, before, after, beforeEach, afterEach, describe, it */
-var fs = require('fs');
-var path = require('path');
-var grunt = require('grunt');
-var assert = require('assert');
-var helpers = require('./helpers');
-var usemin = require('../tasks/usemin.js');
-
-var opts = grunt.cli.options;
-opts.redirect = !opts.silent;
-
-// XXX Conform to coding guidelines, mostly literral spacing stuff
-describe('usemin', function() {
- before(helpers.directory('.test'));
- describe('replace helper', function() {
- it("should take into account path", function() {
- usemin.call(grunt,grunt);
-
- // Let's prepare our context: in index.html we do have references
- // to images/test.png and images/misc/test.png.
- // Usemin's replace is supposed to change this by files
- // found on the filesystem matching the same path, but
- // potentially prefixed
- // e.g images/test.pmg -> images/misc/23012.test.png
- grunt.file.mkdir('images');
- grunt.file.mkdir('images/misc');
- grunt.file.write('images/23012.test.png', "foo");
- grunt.file.write('images/misc/2a436.test.png', "foo");
-
- // Let's avoid cluttering the output
- grunt.log.muted = true;
- var content = grunt.file.read(path.join(__dirname,"fixtures/usemin.html"));
- var changed = grunt.helper('replace',content, /<img[^\>]+src=['"]([^"']+)["']/gm);
-
- // Check replace has performed its duty
- assert.ok( changed.match(/img[^\>]+src=['"]images\/23012\.test\.png["']/) );
- assert.ok( changed.match(/img[^\>]+src=['"]images\/misc\/2a436\.test\.png["']/) );
- });
- });
- describe('usemin:css', function() {
- it("should replace a block with link on furnished target", function() {
- grunt.log.muted = true;
- var block = " foo\nbar\nbaz";
- var content = "before block\n" + block + "\nafter block";
- var awaited = "before block\n <link rel=\"stylesheet\" href=\"foo\"/>\nafter block";
- var changed = grunt.helper('usemin:css', content, block, 'foo');
- assert.ok( changed == awaited );
- });
- });
-
- describe('usemin:post:css', function() {
- it("should replace img urls in css file", function() {
- var content = 'url(../images/test.png)';
- var awaited = 'url(../images/23012.test.png)';
- var changed = grunt.helper('usemin:post:css', content, 'css/23012.main.css');
- assert.ok( changed == awaited );
- });
- });
-
- describe('usemin:post:html', function() {
- before(function() {
- usemin.call(grunt,grunt);
- grunt.log.muted = true;
- grunt.file.mkdir('images');
- grunt.file.mkdir('css');
- });
-
- it('should skip external file', function() {
- grunt.file.write('images/23012.foo.png', "foo");
- var content = '<img src="//css/main.css">';
- var awaited = '<img src="//css/main.css">';
- var changed = grunt.helper('usemin:post:html', content);
- assert.ok( changed == awaited );
-
- });
-
- it('do not depend on tag position', function() {
- grunt.file.write('css/23012.main.css', "foo");
- var content = '<link href="css/main.css" rel="stylesheet"/><link rel="stylesheet" href="css/main.css"/>';
- var awaited = '<link href="css/23012.main.css" rel="stylesheet"/><link rel="stylesheet" href="css/23012.main.css"/>';
- var changed = grunt.helper('usemin:post:html', content);
- assert.ok( changed == awaited );
- });
-
- it('should treat files referenced from site root', function() {
- grunt.file.write('images/23012.foo.png', "foo");
- var content = '<img src="/images/foo.png">';
- var awaited = '<img src="/images/23012.foo.png">';
- var changed = grunt.helper('usemin:post:html', content);
- assert.ok( changed == awaited );
- });
-
- it('should also replace local reference in anchors', function() {
- grunt.file.write('images/23012.foo.png', "foo");
- var content = '<a href="http://foo/bar"></a><a href="ftp://bar"></a><a href="images/foo.png"></a><a href="/images/foo.png"></a><a href="#local"></a>';
- var awaited = '<a href="http://foo/bar"></a><a href="ftp://bar"></a><a href="images/23012.foo.png"></a><a href="/images/23012.foo.png"></a><a href="#local"></a>';
- var changed = grunt.helper('usemin:post:html', content);
- assert.ok( changed == awaited );
- });
-
- it('should also replace data-* links', function() {
- grunt.file.write('images/23012.foo.png', "foo");
- var content = '<a href="http://foo/bar"></a><a href="ftp://bar"></a><a href="images/foo.png"></a><a href="/images/foo.png"></a><a href="#local"></a><img data-thumb="/images/foo.png" /><img data-text="foo-bar" />';
- var awaited = '<a href="http://foo/bar"></a><a href="ftp://bar"></a><a href="images/23012.foo.png"></a><a href="/images/23012.foo.png"></a><a href="#local"></a><img data-thumb="/images/23012.foo.png" /><img data-text="foo-bar" />';
- var changed = grunt.helper('usemin:post:html', content);
- assert.ok( changed == awaited );
- });
-
- it('should handle properly the case of the root path (/)', function() {
- var content = '<a href="/">'
- var awaited = '<a href="/">';
- var changed = grunt.helper('usemin:post:html', content);
- assert.ok( changed == awaited );
- });
- });
- describe('usemin-handler', function() {
- it("should treat local references", function() {
- grunt.log.muted = true;
- usemin.call(grunt, grunt);
- helpers.gruntfile({'usemin-handler': {
- html: 'index.html'}
- });
- grunt.config.init();
- grunt.config('usemin-handler', {html: "index.html"});
- grunt.file.copy(path.join(__dirname,"fixtures/usemin.html"), "index.html");
- grunt.task.run('usemin-handler:html');
- grunt.task.start();
- // Grunt config related to concat should have been changed
- var concat_config = grunt.config('concat');
- // Actually the fixture index.html requires to concat stuff in '/scripts/plugins.js' ...
- // As this references a local file, the concat config should have a key named
- // 'scripts/plugins.js' (i.e. *without* the leading /)
- assert.ok('scripts/plugins.js' in concat_config);
- })
- });
-});
-
Please sign in to comment.
Something went wrong with that request. Please try again.