<commit_before>// Generated on 2014-02-23 using generator-angular-fullstack 1.2.7
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function(grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },
    express: {
      options: {
        port: process.env.PORT || 9000
      },
      dev: {
        options: {
          script: 'server.js',
          debug: true
        }
      },
      prod: {
        options: {
          script: 'dist/server.js',
          node_env: 'production'
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= express.options.port %>'
      }
    },
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        files: [
          '<%= yeoman.app %>/views/{,*//*}*.{html,jade}',
          '{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*//*}*.js',
          '<%= yeoman.app %>/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}',
        ],

        options: {
          livereload: true
        }
      },
      express: {
        files: [
          'server.js',
          'lib/**/*.{js,json}'
        ],
        tasks: ['newer:jshint:server', 'express:dev', 'wait'],
        options: {
          livereload: true,
          nospawn: true //Without this option specified express won't be reloaded
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      server: {
        options: {
          jshintrc: 'lib/.jshintrc'
        },
        src: ['lib/{,*/}*.js']
      },
      all: [
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/views/*',
            '<%= yeoman.dist %>/public/*',
            '!<%= yeoman.dist %>/public/.git*',
          ]
        }]
      },
      heroku: {
        files: [{
          dot: true,
          src: [
            'heroku/*',
            '!heroku/.git*',
            '!heroku/Procfile'
          ]
        }]
      },
      server: '.tmp',
      docs: '.doc'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/views/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/public/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/public/styles/{,*/}*.css',
            '<%= yeoman.dist %>/public/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/public/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.app %>/views/index.html',
        '<%= yeoman.app %>/views/index.jade'
      ],
      options: {
        dest: '<%= yeoman.dist %>/public'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/views/{,*/}*.html',
        '<%= yeoman.dist %>/views/{,*/}*.jade'
      ],
      css: ['<%= yeoman.dist %>/public/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>/public']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/public/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/public/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          //collapseWhitespace: true,
          //collapseBooleanAttributes: true,
          //removeCommentsFromCDATA: true,
          //removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/views',
          src: ['*.html', 'partials/**/*.html'],
          dest: '<%= yeoman.dist %>/views'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/views/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>/public',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'images/{,*/}*.{webp}',
            'fonts/**/*'
          ]
        }, {
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/views',
          dest: '<%= yeoman.dist %>/views',
          src: '**/*.jade'
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/public/images',
          src: ['generated/*']
        }, {
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            'package.json',
            'server.js',
            'lib/**/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },

    jsdoc: {
      dist: {
        src: ['./lib/**/*.js', './app/scripts/**/*.js'],
        options: {
          destination: 'doc'
        }
      }
    },

    sloc: {
      'client': {
        files: {
          'app/scripts': ['**/*.js'],
          'app/styles': ['*.css'],
          'app/views': ['**/*.html']
        }
      },
      'server': {
        files: {
          'lib': ['*.js', './**/*.json'],
          './': ['server.js']
        }
      }
    }

  });

  // Used for delaying livereload until after server has restarted
  grunt.registerTask('wait', function() {
    grunt.log.ok('Waiting for server reload...');

    var done = this.async();

    setTimeout(function() {
      grunt.log.writeln('Done waiting!');
      done();
    }, 500);
  });

  grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
    this.async();
  });

  grunt.registerTask('serve', function(target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bower-install',
      'concurrent:server',
      'autoprefixer',
      'express:dev',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('server', function() {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('docs', ['clean:docs', 'jsdoc']);

  grunt.registerTask('heroku', function() {
    grunt.log.warn('The `heroku` task has been deprecated. Use `grunt build` to build for deployment.');
    grunt.task.run(['build']);
  });

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);

};
<commit_msg>removed rev from Grunt<commit_after>// Generated on 2014-02-23 using generator-angular-fullstack 1.2.7
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function(grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },
    express: {
      options: {
        port: process.env.PORT || 9000
      },
      dev: {
        options: {
          script: 'server.js',
          debug: true
        }
      },
      prod: {
        options: {
          script: 'dist/server.js',
          node_env: 'production'
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= express.options.port %>'
      }
    },
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        files: [
          '<%= yeoman.app %>/views/{,*//*}*.{html,jade}',
          '{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*//*}*.js',
          '<%= yeoman.app %>/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}',
        ],

        options: {
          livereload: true
        }
      },
      express: {
        files: [
          'server.js',
          'lib/**/*.{js,json}'
        ],
        tasks: ['newer:jshint:server', 'express:dev', 'wait'],
        options: {
          livereload: true,
          nospawn: true //Without this option specified express won't be reloaded
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      server: {
        options: {
          jshintrc: 'lib/.jshintrc'
        },
        src: ['lib/{,*/}*.js']
      },
      all: [
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/views/*',
            '<%= yeoman.dist %>/public/*',
            '!<%= yeoman.dist %>/public/.git*',
          ]
        }]
      },
      heroku: {
        files: [{
          dot: true,
          src: [
            'heroku/*',
            '!heroku/.git*',
            '!heroku/Procfile'
          ]
        }]
      },
      server: '.tmp',
      docs: '.doc'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/views/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/public/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/public/styles/{,*/}*.css',
            //'<%= yeoman.dist %>/public/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/public/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.app %>/views/index.html',
        '<%= yeoman.app %>/views/index.jade'
      ],
      options: {
        dest: '<%= yeoman.dist %>/public'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/views/{,*/}*.html',
        '<%= yeoman.dist %>/views/{,*/}*.jade'
      ],
      css: ['<%= yeoman.dist %>/public/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>/public']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/public/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/public/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          //collapseWhitespace: true,
          //collapseBooleanAttributes: true,
          //removeCommentsFromCDATA: true,
          //removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/views',
          src: ['*.html', 'partials/**/*.html'],
          dest: '<%= yeoman.dist %>/views'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/views/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>/public',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'images/{,*/}*.{webp}',
            'fonts/**/*'
          ]
        }, {
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/views',
          dest: '<%= yeoman.dist %>/views',
          src: '**/*.jade'
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/public/images',
          src: ['generated/*']
        }, {
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            'package.json',
            'server.js',
            'lib/**/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },

    jsdoc: {
      dist: {
        src: ['./lib/**/*.js', './app/scripts/**/*.js'],
        options: {
          destination: 'doc'
        }
      }
    },

    sloc: {
      'client': {
        files: {
          'app/scripts': ['**/*.js'],
          'app/styles': ['*.css'],
          'app/views': ['**/*.html']
        }
      },
      'server': {
        files: {
          'lib': ['*.js', './**/*.json'],
          './': ['server.js']
        }
      }
    }

  });

  // Used for delaying livereload until after server has restarted
  grunt.registerTask('wait', function() {
    grunt.log.ok('Waiting for server reload...');

    var done = this.async();

    setTimeout(function() {
      grunt.log.writeln('Done waiting!');
      done();
    }, 500);
  });

  grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
    this.async();
  });

  grunt.registerTask('serve', function(target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bower-install',
      'concurrent:server',
      'autoprefixer',
      'express:dev',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('server', function() {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('docs', ['clean:docs', 'jsdoc']);

  grunt.registerTask('heroku', function() {
    grunt.log.warn('The `heroku` task has been deprecated. Use `grunt build` to build for deployment.');
    grunt.task.run(['build']);
  });

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);

};
<|endoftext|>


<commit_before><commit_msg>copy word doc<commit_after><|endoftext|>


<commit_before>/* global module */

var path = require('path');

module.exports = function (grunt) {
	'use strict';

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		// is this task ever called?
		clean: {
			build: {
				src: [
					'out/',
					'src/goo.js'
				]
			},
			toc: {
				src: [
					'visual-test/index.html',
					'examples/index.html'
				]
			},
			docs: [
				'out-doc/'
			]
		},
		'build-pack': {
			fsmpack: {
				packPath: 'fsmpack',
				outBaseDir: 'out'
			},
			geometrypack: {
				packPath: 'geometrypack',
				outBaseDir: 'out'
			},
			quadpack: {
				packPath: 'quadpack',
				outBaseDir: 'out'
			},
			timelinepack: {
				packPath: 'timelinepack',
				outBaseDir: 'out'
			},
			debugpack: {
				packPath: 'debugpack',
				outBaseDir: 'out'
			},
			scriptpack: {
				packPath: 'scriptpack',
				outBaseDir: 'out'
			},
			p2pack: {
				packPath: 'addons/p2pack',
				outBaseDir: 'out'
			},
			box2dpack: {
				packPath: 'addons/box2dpack',
				outBaseDir: 'out'
			},
			terrainpack: {
				packPath: 'addons/terrainpack',
				outBaseDir: 'out'
			},
			ammopack: {
				packPath: 'addons/ammopack',
				outBaseDir: 'out'
			},
			cannonpack: {
				packPath: 'addons/cannonpack',
				outBaseDir: 'out'
			},
			waterpack: {
				packPath: 'addons/waterpack',
				outBaseDir: 'out'
			},
			animationpack: {
				packPath: 'animationpack',
				outBaseDir: 'out'
			},
			soundmanager2pack: {
				packPath: 'addons/soundmanager2pack',
				outBaseDir: 'out'
			},
			gamepadpack: {
				packPath: 'addons/gamepadpack',
				outBaseDir: 'out'
			},
			passpack: {
				packPath: 'passpack',
				outBaseDir: 'out'
			},
			gizmopack: {
				packPath: 'util/gizmopack',
				outBaseDir: 'out'
			}
		},
		'generate-toc': {
			'visual-test': {
				path: 'visual-test',
				title: 'Visual tests'
			},
			'examples': {
				path: 'examples',
				title: 'Examples'
			}
		},
		'build-custom': {
			myBundle: {
				outFile: 'bundle.js'
			}
		},
		karma: {
			unit: {
				configFile: 'test/unit/karma.conf.js',
				singleRun: true,
				browsers: ['Chrome'] // Phantom just doesn't have support for the goodies we've come to know and love
			}
		},
		shell: {
			jsdoc: {
				command: 'node tools/modoc/src/modoc.js src/goo tools/modoc/src/templates tools/modoc/src/statics out-doc'
			},
			update_webdriver: {
				options: {
					stdout: true
				},
				command: path.resolve('node_modules/webdriver-manager/bin/webdriver-manager') + ' update --standalone --chrome'
			},
			e2e: {
				command: 'node test/e2etesting/manualSpec.js'
			},
			'modoc-test': {
				command: 'node_modules/jasmine-node/bin/jasmine-node tools/modoc/test/spec'
			}
		},
		jshint: {
			all: ['src'],
			options: {
				jshintrc: '.jshintrc',
				force: true // Do not fail the task
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-requirejs');
	grunt.loadNpmTasks('grunt-wrap');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-karma');
	grunt.loadNpmTasks('grunt-shell');
	grunt.loadNpmTasks('grunt-contrib-jshint');

	grunt.loadTasks('tools/grunt_tasks');

	grunt.registerTask('default',	 ['minify']);
	grunt.registerTask('jsdoc',		 ['shell:jsdoc']);
	grunt.registerTask('minify',	 ['main-file', 'requirejs:build', 'wrap', 'build-pack']);
	grunt.registerTask('unittest',	 ['karma:unit']);
	grunt.registerTask('coverage',	 ['unittest']);
	grunt.registerTask('e2e',		 ['shell:e2e']);
	grunt.registerTask('test',		 ['unittest', 'e2e']);
	grunt.registerTask('modoc-test', ['shell:modoc-test']);
};
<commit_msg>More adaptations for windows<commit_after>/* global module */

var path = require('path');

module.exports = function (grunt) {
	'use strict';

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		// is this task ever called?
		clean: {
			build: {
				src: [
					'out/',
					'src/goo.js'
				]
			},
			toc: {
				src: [
					'visual-test/index.html',
					'examples/index.html'
				]
			},
			docs: [
				'out-doc/'
			]
		},
		'build-pack': {
			fsmpack: {
				packPath: 'fsmpack',
				outBaseDir: 'out'
			},
			geometrypack: {
				packPath: 'geometrypack',
				outBaseDir: 'out'
			},
			quadpack: {
				packPath: 'quadpack',
				outBaseDir: 'out'
			},
			timelinepack: {
				packPath: 'timelinepack',
				outBaseDir: 'out'
			},
			debugpack: {
				packPath: 'debugpack',
				outBaseDir: 'out'
			},
			scriptpack: {
				packPath: 'scriptpack',
				outBaseDir: 'out'
			},
			p2pack: {
				packPath: 'addons/p2pack',
				outBaseDir: 'out'
			},
			box2dpack: {
				packPath: 'addons/box2dpack',
				outBaseDir: 'out'
			},
			terrainpack: {
				packPath: 'addons/terrainpack',
				outBaseDir: 'out'
			},
			ammopack: {
				packPath: 'addons/ammopack',
				outBaseDir: 'out'
			},
			cannonpack: {
				packPath: 'addons/cannonpack',
				outBaseDir: 'out'
			},
			waterpack: {
				packPath: 'addons/waterpack',
				outBaseDir: 'out'
			},
			animationpack: {
				packPath: 'animationpack',
				outBaseDir: 'out'
			},
			soundmanager2pack: {
				packPath: 'addons/soundmanager2pack',
				outBaseDir: 'out'
			},
			gamepadpack: {
				packPath: 'addons/gamepadpack',
				outBaseDir: 'out'
			},
			passpack: {
				packPath: 'passpack',
				outBaseDir: 'out'
			},
			gizmopack: {
				packPath: 'util/gizmopack',
				outBaseDir: 'out'
			}
		},
		'generate-toc': {
			'visual-test': {
				path: 'visual-test',
				title: 'Visual tests'
			},
			'examples': {
				path: 'examples',
				title: 'Examples'
			}
		},
		'build-custom': {
			myBundle: {
				outFile: 'bundle.js'
			}
		},
		karma: {
			unit: {
				configFile: 'test/unit/karma.conf.js',
				singleRun: true,
				browsers: ['Chrome'] // Phantom just doesn't have support for the goodies we've come to know and love
			}
		},
		shell: {
			jsdoc: {
				command: 'node tools/modoc/src/modoc.js src/goo tools/modoc/src/templates tools/modoc/src/statics out-doc'
			},
			update_webdriver: {
				options: {
					stdout: true
				},
				command: path.resolve('node_modules/webdriver-manager/bin/webdriver-manager') + ' update --standalone --chrome'
			},
			e2e: {
				command: 'node test/e2etesting/manualSpec.js'
			},
			'modoc-test': {
				command: 'node node_modules/jasmine-node/bin/jasmine-node tools/modoc/test/spec'
			}
		},
		jshint: {
			all: ['src'],
			options: {
				jshintrc: '.jshintrc',
				force: true // Do not fail the task
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-requirejs');
	grunt.loadNpmTasks('grunt-wrap');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-karma');
	grunt.loadNpmTasks('grunt-shell');
	grunt.loadNpmTasks('grunt-contrib-jshint');

	grunt.loadTasks('tools/grunt_tasks');

	grunt.registerTask('default',	 ['minify']);
	grunt.registerTask('jsdoc',		 ['shell:jsdoc']);
	grunt.registerTask('minify',	 ['main-file', 'requirejs:build', 'wrap', 'build-pack']);
	grunt.registerTask('unittest',	 ['karma:unit']);
	grunt.registerTask('coverage',	 ['unittest']);
	grunt.registerTask('e2e',		 ['shell:e2e']);
	grunt.registerTask('test',		 ['unittest', 'e2e']);
	grunt.registerTask('modoc-test', ['shell:modoc-test']);
};
<|endoftext|>


<commit_before><commit_msg>Fixing Error: Unable to read .js file (Error code: EISDIR)<commit_after><|endoftext|>


<commit_before><commit_msg>resolved linting error<commit_after><|endoftext|>


<commit_before><commit_msg>Grunt: Fix singlequote in Gruntfile.js<commit_after><|endoftext|>


<commit_before>// ==UserScript==
// @name            Mamba search view new
// @author          olecom
// @namespace       mamba
// @description     Улучшенный поиск и фильтрация несимпатичных фотографий без рекламы
// @match           http://www.mamba.ru/*
// @match           http://www.mamba.ru/*/*
// @match           http://love.mail.ru/*
// @match           http://love.mail.ru/*/*
// @version         0.7
// ==/UserScript==

function uglify_js(w ,d ,con){
    var j ,el

    if(w.location.pathname === '/') return false

    w.addEventListener('load', on_load, true)
    j = setTimeout(on_load, 1234)

    try {// remove ads
        rm_class("MainBlockContainer", "MainBlockLeft")
        rm_class("MainBlockRight", "mordolenta")
    } catch(e){}

    try {// fix Firefox.noscript issue
        el = d.createElement("div"), el.setAttribute("id", "banner_xgemius")
        d.children[0].appendChild(el)
        el = null
    } catch(e){}

    return true

    function rm_class(p, c){
        d.getElementsByClassName(p)[0].removeChild(d.getElementsByClassName(c)[0])
    }

    function on_load(){
        var a ,ul ,oid ,i ,f
           ,page_timeout
           ,dev = !!con && !true// development/debug mode

        clearTimeout(j)
        w.removeEventListener('load', on_load, true)

if(dev) con.log('hi')

        // add buttons: forget, auto next, next
        try {
            a = d.getElementsByClassName("ui-userbar-empty")[0]
            if(!a){
                a = d.getElementsByClassName("lang-selector")[0]
                if(!a) return con.warn('No "ui-userbar-empty" or "lang-selector" found!')
            }
        } catch(e){
            con.log('Error: "ui-userbar-empty" or "lang-selector"')
            return con.dir(e)
        }

// forget button on anketa/user page
        if(w.location.href.match(/fromsearch/) || !w.location.href.match(/search[.]phtm/)){
            rm_class('anketa_bottom', 'b-people__similar')// remove ads
if(dev) con.log('anketa')

            for(i = 0, el = d.getElementsByClassName("b-anketa_inset-form"); i < el.length; i++){
                if(/[\d][\d][\d] см/.test(el[i].innerHTML)){// human height
                    oid = el[i].innerHTML.match(/[^><]* см/)[0]
                    break
                }
            }

            el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
            el.innerHTML = '
' + (oid ? oid : '') +
' Забыть анкету
' +
                           '
' +
                           '
' +
'Скрыть анкету в поиске; не понравилась' +
                           '

'

            el.onclick = function forget_item(){
                var id

                if(!/[/]mb[\d]*[/#?]/.test(w.location.href)){//text ID from URL
                // URL examples with text ID:
                // http://www.mamba.ru/mega_baba
                // http://www.mamba.ru/mega_baba?hit=10&fromsearch&sp=4
                // http://www.mamba.ru/mega_baba/albums?sp=4
                // http://www.mamba.ru/mega_baba/album_photos?album_id=1170973545&#closed
                // RE gets this part:  ^^^^^^^^^
                    id = w.location.href.replace(/http[s]*:[/][/][^/]*[/]([^/?#]*).*$/ ,'$1')
                } else {//numeric ID on page
                    id = d.getElementsByClassName("mb5 fl-l")[0].innerHTML
                          .replace(/ID: ([^,]*),.*$/,'$1')
                }
if(dev) con.log('forgetting "' + id + '": ' + localStorage[id])
                localStorage[id] = '_'
                this.innerHTML = ''
            }
            return a.parentElement.insertBefore(el, a)
        }
// autonext button
if(dev) con.log('searching')
        el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
        el.innerHTML = '
' +
                       (localStorage['anext'] ?
'Само дальше идёт' :
'Само дальше включить') +
                       '

' +
                       '
' +
'Автоматически переходить на следующую, если на странице только безынтересные анкеты' +
                       '

'
        el.onclick = function automatic_next_page(){
            var an = !localStorage['anext']
            localStorage['anext'] = an ? '+' : ''
            this.innerHTML = '
' + (an ?
'Само дальше идёт' :
'Само дальше включить') + '
'
if(dev) con.log('automatic next page: ' + (an ? 'yes' : 'no'))
            an ? on_keydown() : clearTimeout(page_timeout)
        }
        a.parentElement.insertBefore(el, a)

// next button
        el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
        el.innerHTML = '
Дальше
' +
                       '
' +
                       '
' +
'Перейти на следующую страницу, пометить все фотки (кроме выбраных) как безынтересные

' +
'Клавиши кроме [0]-[9], [пробел], [ввод], эквивалентны нажатию этой кнопки

' +
'Переход на следущую страницу через обычную листалку (снизу) ничего не помечает' +
                       '

'
        el.onclick = on_keydown
        a.parentElement.insertBefore(el, a)

        // scan and fade away items of "no interest"
        try {
            d.getElementsByClassName('MainBlockRight')[0].style.width = '100%'// some style
            ul = d.getElementsByClassName('MainBlockRightSearch')[0].children[0]
            if(!ul) return con.warn('No "MainBlockRightSearch" found!')
        } catch(e){ return con.log("MainBlockRightSearch"), con.dir(e) }

        w.scroll(0, 237)

        j = 0 ,f = false
        for(i = 0; i < ul.childElementCount; i++){
/*

                         | children[i]

                | children[0]

 | children[1]

                                        | children[0]  RE=^^^^^^^^^^
                     http://www.mamba.ru/mb0123456789?hit=10&fromsearch&sp=1
                                        RE=^^^^^^^^^^
                                   | children[0]

        ...

    ...

  */
            a = ul.children[i]
            a.style.width = '33%' ,a.style.margin = '0'// some style
            a.children[0].style['min-height'] = '168px'// some style
            a = a.children[0].children[1].children[0]
            if(/oid=/.test(a.href)){
                oid = a.href.replace(/.*oid=([^&]*).*$/ ,'$1')
            } else if(/[/]mb[\d]*[?]/.test(a.href)){
                oid = a.href.replace(/.*[/]mb([^?]*).*$/ ,'$1')
            } else {
                oid = a.href.replace(/.*[/]([^?]*).*$/ ,'$1')
            }
if(dev) con.log('id search: ' + oid)
            if(w.localStorage[oid] === '-' || w.localStorage[oid] === '_'){
                j += 1
                if(w.localStorage[oid] === '-'){
                    a.style.opacity = a.children[0].style.opacity = 0.8
                } else {
                    a.style.opacity = a.children[0].style.opacity = 0.4
                }
                a.onmouseover = function(){
                    this.style.opacity = this.children[0].style.opacity = 1
                }
                a.onmouseout = function(){
                    this.style.opacity = this.children[0].style.opacity = 0.8
                }
            } else {// forget inline
                el = d.createElement("a")
                el.innerHTML = 'Забыть'
                el.style.cursor = 'crosshair',el.style.color = 'red'
                el.onclick = function(id ,a ,el){ return function(){
if(dev) con.log('forgetting "' + id + '": ' + localStorage[id])
                     localStorage[id] = '_'
                     a.style.opacity = a.children[0].style.opacity = 0.4
                     el.innerHTML = ''
                }}(oid ,a ,el)
                a.parentNode.appendChild(el)
                if(!f) a.scrollIntoView(true) ,f = true// scroll to the first item
            }
            a.onmousedown = function(){// for marked and yet not marked items
                var t
                if(/oid=/.test(this.href)){
                    t = this.href.replace(/.*oid=([^&]*).*$/ ,'$1')
                } else if(/[/]mb[\d]*[?]/.test(this.href)){
                    t = this.href.replace(/.*[/]mb([^?]*).*$/ ,'$1')
                } else {
                    t = this.href.replace(/.*[/]([^?]*).*$/ ,'$1')
                }
if(dev) con.log('id clear: ' + t)

                localStorage[t] = '' // save or restore "interest"
                this.style.opacity = this.children[0].style.opacity = 1
                this.onmousedown = this.onmouseover = this.onmouseout = function(){}
            }
        }//for{}
if(dev && !j) con.log('all items in view')

        if(j === ul.childElementCount){// nothing to look at
            if(w.localStorage['anext']){
                page_timeout = setTimeout(on_keydown ,4096)// give some time for switch off action
            } else w.scroll(0, 99999)
        }
        w.addEventListener('keypress', on_keydown, true)

        return true

        function on_keydown(ev){
            for(i = 0; i < ul.childElementCount; i++){// scan and save "no interest"
                a = ul.children[i].children[0].children[1].children[0]
                if(/oid=/.test(a.href)){
                    oid = a.href.replace(/.*oid=([^&]*).*$/ ,'$1')
                } else if(/[/]mb[\d]*[?]/.test(a.href)){
                    oid = a.href.replace(/.*[/]mb([^?]*).*$/ ,'$1')
                } else {
                    oid = a.href.replace(/.*[/]([^?]*).*$/ ,'$1')
                }
if(dev) con.log('id n: ' + oid)
                if(w.localStorage[oid] === undefined){
                    w.localStorage[oid] = '-' // save "no interest"
                }
            }
            // direct calls and/or event handling
            if((!ev || !ev.charCode) ||
               (ev && ev.charCode && ev.charCode != 32 && (ev.charCode < 48 || ev.charCode > 57))
            ) try {
                if (ev && (13 == ev.keyCode || 9 == ev.keyCode)) return// Enter, Tab
                // space and numbers are normal keys
                // any other key will load next page if there is one
                w.location.href = d.getElementById("Paginator")
                    .getElementsByClassName('selected')[0]
                        .nextSibling.nextSibling.children[0].href
            } catch(e){
                localStorage['anext'] = '' // clear autonext, load the first page
                w.location = d.getElementById("Paginator").children[0].children[0].href
            }
        }
    }// on_load()
}

uglify_js(window ,document ,console)
<commit_msg>mamba_search_view_new: экспорт номеров анкет в буфер обмена<commit_after>// ==UserScript==
// @name            Mamba search view new
// @author          olecom
// @namespace       mamba
// @description     Улучшенный поиск и фильтрация несимпатичных фотографий без рекламы
// @match           http://www.mamba.ru/*
// @match           http://www.mamba.ru/*/*
// @match           http://love.mail.ru/*
// @match           http://love.mail.ru/*/*
// @version         0.7-pre
// ==/UserScript==

function uglify_js(w ,d ,con){
    var j ,el

    if(w.location.pathname === '/') return false

    w.addEventListener('load', on_load, true)
    j = setTimeout(on_load, 1234)

    try {// remove ads
        rm_class("MainBlockContainer", "MainBlockLeft")
        rm_class("MainBlockRight", "mordolenta")
    } catch(e){}

    try {// fix Firefox.noscript issue
        el = d.createElement("div"), el.setAttribute("id", "banner_xgemius")
        d.children[0].appendChild(el)
        el = null
    } catch(e){}

    return true

    function rm_class(p, c){
        d.getElementsByClassName(p)[0].removeChild(d.getElementsByClassName(c)[0])
    }

    function on_load(){
        var a ,ul ,oid ,i ,f
           ,page_timeout
           ,dev = !!con && !true// development/debug mode

        clearTimeout(j)
        w.removeEventListener('load', on_load, true)

if(dev) con.log('hi')

        // add buttons: forget, auto next, next
        try {
            a = d.getElementsByClassName("ui-userbar-empty")[0]
            if(!a){
                a = d.getElementsByClassName("lang-selector")[0]
                if(!a) return con.warn('No "ui-userbar-empty" or "lang-selector" found!')
            }
        } catch(e){
            con.log('Error: "ui-userbar-empty" or "lang-selector"')
            return con.dir(e)
        }
        w.addEventListener('keydown', on_keydown, true)
// export button
        el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
        el.innerHTML = '
Экспорт
' +
                       '
' +
                       '
' +
'Скопировать данные о просмотренных анкетах в буфер обмена
' +
'для переноса в другой профиль/браузер/сохранение в файл' +
                       '

'
        el.onclick = function prepare_export(){
            var s = '', t
            this.onclick = function(){}
            this.preCopyExportHTML = this.innerHTML
            this.innerHTML = '' +
'
Нажмите CTRL+C и ждите...' +
'  <textarea style="position:absolute; top:-12px; width:1px;height:1px;">' +
'     copy|paste' +
'  </textarea>' +
'
'
            el = this.children['0'].children['1']//textarea
            j = 0
            for(t in localStorage) if(t && '-' == localStorage[t]){
                s += t + '\n'
                j++
            }
            el.value = s
            el.focus()
            el.select()
            this.lengthExport = j.toString()
            el = this// -> on_keydown()
        }
        a.parentElement.insertBefore(el, a)

// forget button on anketa/user page
        if(w.location.href.match(/fromsearch/) || !w.location.href.match(/search[.]phtm/)){
            rm_class('anketa_bottom', 'b-people__similar')// remove ads
if(dev) con.log('anketa')

            for(i = 0, el = d.getElementsByClassName("b-anketa_inset-form"); i < el.length; i++){
                if(/[\d][\d][\d] см/.test(el[i].innerHTML)){// human height
                    oid = el[i].innerHTML.match(/[^><]* см/)[0]
                    break
                }
            }

            el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
            el.innerHTML = '
' + (oid ? oid : '') +
' Забыть анкету
' +
                           '
' +
                           '
' +
'Скрыть анкету в поиске; не понравилась' +
                           '

'

            el.onclick = function forget_item(){
                var id

                if(!/[/]mb[\d]*[/#?]/.test(w.location.href)){//text ID from URL
                // URL examples with text ID:
                // http://www.mamba.ru/mega_baba
                // http://www.mamba.ru/mega_baba?hit=10&fromsearch&sp=4
                // http://www.mamba.ru/mega_baba/albums?sp=4
                // http://www.mamba.ru/mega_baba/album_photos?album_id=1170973545&#closed
                // RE gets this part:  ^^^^^^^^^
                    id = w.location.href.replace(/http[s]*:[/][/][^/]*[/]([^/?#]*).*$/ ,'$1')
                } else {//numeric ID on page
                    id = d.getElementsByClassName("mb5 fl-l")[0].innerHTML
                          .replace(/ID: ([^,]*),.*$/,'$1')
                }
if(dev) con.log('forgetting "' + id + '": ' + localStorage[id])
                localStorage[id] = '_'
                this.innerHTML = ''
            }
            return a.parentElement.insertBefore(el, a)
        }
// autonext button
if(dev) con.log('searching')
        el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
        el.innerHTML = '
' +
                       (localStorage['anext'] ?
'Само дальше идёт' :
'Само дальше включить') +
                       '

' +
                       '
' +
'Автоматически переходить на следующую, если на странице только безынтересные анкеты' +
                       '

'
        el.onclick = function automatic_next_page(){
            var an = !localStorage['anext']
            localStorage['anext'] = an ? '+' : ''
            this.innerHTML = '
' + (an ?
'Само дальше идёт' :
'Само дальше включить') + '
'
if(dev) con.log('automatic next page: ' + (an ? 'yes' : 'no'))
            an ? on_keydown() : clearTimeout(page_timeout)
        }
        a.parentElement.insertBefore(el, a)

// next button
        el = d.createElement("div") ,el.setAttribute("class", "btn-group-item")
        el.innerHTML = '
Дальше
' +
                       '
' +
                       '
' +
'Перейти на следующую страницу, пометить все фотки (кроме выбраных) как безынтересные

' +
'Клавиши кроме [0]-[9], [пробел], [ввод], эквивалентны нажатию этой кнопки

' +
'Переход на следущую страницу через обычную листалку (снизу) ничего не помечает' +
                       '

'
        el.onclick = on_keydown
        a.parentElement.insertBefore(el, a)

        // scan and fade away items of "no interest"
        try {
            d.getElementsByClassName('MainBlockRight')[0].style.width = '100%'// some style
            ul = d.getElementsByClassName('MainBlockRightSearch')[0].children[0]
            if(!ul) return con.warn('No "MainBlockRightSearch" found!')
        } catch(e){ return con.log("MainBlockRightSearch"), con.dir(e) }

        w.scroll(0, 237)

        j = 0 ,f = false
        for(i = 0; i < ul.childElementCount; i++){
/*

                         | children[i]

                | children[0]

 | children[1]

                                        | children[0]  RE=^^^^^^^^^^
                     http://www.mamba.ru/mb0123456789?hit=10&fromsearch&sp=1
                                        RE=^^^^^^^^^^
                                   | children[0]

        ...

    ...

  */
            a = ul.children[i]
            a.style.width = '33%' ,a.style.margin = '0'// some style
            a.children[0].style['min-height'] = '168px'// some style
            a = a.children[0].children[1].children[0]
            if(/oid=/.test(a.href)){
                oid = a.href.replace(/.*oid=([^&]*).*$/ ,'$1')
            } else if(/[/]mb[\d]*[?]/.test(a.href)){
                oid = a.href.replace(/.*[/]mb([^?]*).*$/ ,'$1')
            } else {
                oid = a.href.replace(/.*[/]([^?]*).*$/ ,'$1')
            }
if(dev) con.log('id search: ' + oid)
            if(w.localStorage[oid] === '-' || w.localStorage[oid] === '_'){
                j += 1
                if(w.localStorage[oid] === '-'){
                    a.style.opacity = a.children[0].style.opacity = 0.8
                } else {
                    a.style.opacity = a.children[0].style.opacity = 0.4
                }
                a.onmouseover = function(){
                    this.style.opacity = this.children[0].style.opacity = 1
                }
                a.onmouseout = function(){
                    this.style.opacity = this.children[0].style.opacity = 0.8
                }
            } else {// forget inline
                el = d.createElement("a")
                el.innerHTML = 'Забыть'
                el.style.cursor = 'crosshair',el.style.color = 'red'
                el.onclick = function(id ,a ,el){ return function(){
if(dev) con.log('forgetting "' + id + '": ' + localStorage[id])
                     localStorage[id] = '_'
                     a.style.opacity = a.children[0].style.opacity = 0.4
                     el.innerHTML = ''
                }}(oid ,a ,el)
                a.parentNode.appendChild(el)
                if(!f) a.scrollIntoView(true) ,f = true// scroll to the first item
            }
            a.onmousedown = function(){// for marked and yet not marked items
                var t
                if(/oid=/.test(this.href)){
                    t = this.href.replace(/.*oid=([^&]*).*$/ ,'$1')
                } else if(/[/]mb[\d]*[?]/.test(this.href)){
                    t = this.href.replace(/.*[/]mb([^?]*).*$/ ,'$1')
                } else {
                    t = this.href.replace(/.*[/]([^?]*).*$/ ,'$1')
                }
if(dev) con.log('id clear: ' + t)

                localStorage[t] = '' // save or restore "interest"
                this.style.opacity = this.children[0].style.opacity = 1
                this.onmousedown = this.onmouseover = this.onmouseout = function(){}
            }
        }//for{}
if(dev && !j) con.log('all items in view')

        if(j === ul.childElementCount){// nothing to look at
            if(w.localStorage['anext']){
                page_timeout = setTimeout(on_keydown ,4096)// give some time for switch off action
            } else w.scroll(0, 99999)
        }

        return true

        function on_keydown(ev){
            if(el && el.preCopyExportHTML){
                if(ev.ctrlKey && (67 == ev.keyCode || 99 == ev.keyCode)){
                    setTimeout(function clean_export(){
                        el.children['0'].children['1'].remove()//selection in chrome
                        el.innerHTML = el.preCopyExportHTML.replace(
                            /Экспорт[^<]*/,
                            'Экспорт (в буфере обмена ' + el.lengthExport + ' шт.)'
                        )
                        el.preCopyExportHTML = el.lengthExport = ''
                        el = null
                    }, 12)
                }
                return
            }
            if(!ul || ev.altKey) return// export/import || keydown garbage

            for(i = 0; i < ul.childElementCount; i++){// scan and save "no interest"
                a = ul.children[i].children[0].children[1].children[0]
                if(/oid=/.test(a.href)){
                    oid = a.href.replace(/.*oid=([^&]*).*$/ ,'$1')
                } else if(/[/]mb[\d]*[?]/.test(a.href)){
                    oid = a.href.replace(/.*[/]mb([^?]*).*$/ ,'$1')
                } else {
                    oid = a.href.replace(/.*[/]([^?]*).*$/ ,'$1')
                }
if(dev) con.log('id n: ' + oid)
                if(w.localStorage[oid] === undefined){
                    w.localStorage[oid] = '-' // save "no interest"
                }
            }
            ul = null
            // direct calls and/or event handling
            if((!ev || !ev.charCode) ||
               (ev && ev.charCode && ev.charCode != 32 && (ev.charCode < 48 || ev.charCode > 57))
            ) try {
                if (ev && (13 == ev.keyCode || 9 == ev.keyCode)) return// Enter, Tab
                // space and numbers are normal keys
                // any other key will load next page if there is one
                w.location.href = d.getElementById("Paginator")
                    .getElementsByClassName('selected')[0]
                        .nextSibling.nextSibling.children[0].href
            } catch(e){
                localStorage['anext'] = '' // clear autonext, load the first page
                w.location = d.getElementById("Paginator").children[0].children[0].href
            }
        }
    }// on_load()
}

uglify_js(window ,document ,console)
<|endoftext|>


<commit_before>/**
  * priorityNav
  *
  * dependencies:
  * classlist
  * prepend
  * append
  * append
  * firstElementChild
  * getOuterWidth
  * pageXOffset
  * addEventListener
  */

function priorityNav (navClass, buttonText, restore, distory) {
  var restore = (
        typeof restore !== 'undefined' &&
        restore !== false &&
        restore !== null) ? restore : 0,
      distory = (
        typeof distory !== 'undefined' &&
        distory !== false &&
        distory !== null) ? distory : 0,
      nav = document.querySelector(navClass);

  // if (nav.length > 0) {
    nav.querySelector('ul').classList.add('visible-links');
    prepend(nav, '<button class="js-nav-toggle is-hidden" data-count="">' + buttonText + '</button>');
    append(nav, '

');

    var visibleContainer = nav.querySelector('.visible-links'),
        visibleItems = visibleContainer.children,
        hiddenContainer = nav.querySelector('.hidden-links'),
        btn = nav.querySelector('.js-nav-toggle');

    // get breakpoints
    var bp = [],
        bpV = [],
        bpH = [];
    for (var i = 0, len = visibleItems.length; i < len; i++) {
      var last = bp[bp.length - 1],
          thisWidth = getOuterWidth(visibleItems[i]),
          newWidth = (last) ? last + thisWidth : thisWidth;
      bp.push(newWidth);
      bpV.push(newWidth);
    }

    // update nav
    function updateNav () {
      var
          windowWidth = window.innerWidth,
          btnWidth = getOuterWidth(btn),
          outerWidth = getOuterWidth(nav),
          availableSpace = outerWidth - btnWidth,
          target,
          current;

      // get target, show/hide btn
      if (outerWidth >= bp[bp.length - 1] || windowWidth < restore) {
        availableSpace = outerWidth;
        btn.classList.add('is-hidden');

        target = bp.length;
      } else if (windowWidth < distory) {

      } else {
        btn.classList.remove('is-hidden');

        if (windowWidth < distory) {
          target = 0;
        } else {
          for (var i = 0, len = bp.length; i < len; i++) {
            if (availableSpace >= bp[i] && availableSpace < bp[i + 1]) {
              target = i + 1;
            } else if (availableSpace < bp[0]) {
              target = 0;
            }
          }
        }
      }
      // console.log(target);

      // set current
      var visibleItems = nav.querySelectorAll('.visible-links > li');
      current = (visibleItems.length) ? visibleItems.length : 0;
      // if (visibleItems.length) {
      // } else {
      //   current = 0;
      // }

      // update
      if (target > current) {
        var a = current;
        while (a < target) {
          var vlink = nav.querySelectorAll('.visible-links');
          var hlinks = nav.querySelectorAll('.hidden-links > li');

          append(vlink, hlinks[0]);
          a++;
        }
      } else if (target < current) {
        var a = current;
        while (a > target ) {
          var visibleItems = nav.querySelectorAll('.visible-links > li');
          var hlinks = nav.querySelectorAll('.hidden-links > li');

          prepend(hiddenContainer, visibleItems[visibleItems.length - 1]);
          a--;
        }
      }

      // update data-count
      var hlinks = nav.querySelectorAll('.hidden-links > li'),
          count;

      if (hlinks.length) {
        count = hlinks.length;
      } else {
        count = 0;
      }
      btn.setAttribute("data-count", count);
    }

    // run updateNav
    updateNav();
    window.addEventListener('resize', function () {
      updateNav();
    });

    // show / hide hidden-links
    btn.addEventListener('click', function () {
      nav.querySelector('.hidden-links').classList.toggle('is-hidden');
    });
  // } else {
  //   console.log('"' + navClass + '" can\'t be found.');
  // }
};<commit_msg>update<commit_after>/**
  * priorityNav
  *
  * dependencies:
  * classlist
  * prepend
  * append
  * append
  * firstElementChild
  * getOuterWidth
  * pageXOffset
  * addEventListener
  */

function priorityNav (navClass, buttonText, restore, distory) {
  var restore = (
        typeof restore !== 'undefined' &&
        restore !== false &&
        restore !== null) ? restore : 0,
      distory = (
        typeof distory !== 'undefined' &&
        distory !== false &&
        distory !== null) ? distory : 0,
      nav = document.querySelector(navClass);

  // if (nav.length > 0) {
    nav.querySelector('ul').classList.add('visible-links');
    prepend(nav, '<button class="js-nav-toggle is-hidden" data-count="">' + buttonText + '</button>');
    append(nav, '

');

    var visibleContainer = nav.querySelector('.visible-links'),
        visibleItems = visibleContainer.children,
        hiddenContainer = nav.querySelector('.hidden-links'),
        btn = nav.querySelector('.js-nav-toggle');

    // get breakpoints
    var bp = [],
        bpV = [],
        bpH = [];
    for (var i = 0, len = visibleItems.length; i < len; i++) {
      var last = bp[bp.length - 1],
          thisWidth = getOuterWidth(visibleItems[i]),
          newWidth = (last) ? last + thisWidth : thisWidth;
      bp.push(newWidth);
      bpV.push(newWidth);
    }

    // update nav
    function updateNav () {
      var
          windowWidth = window.innerWidth,
          btnWidth = getOuterWidth(btn),
          outerWidth = getOuterWidth(nav),
          availableSpace = outerWidth - btnWidth,
          target,
          current;

      // get target, show/hide btn
      if (outerWidth >= bp[bp.length - 1] || windowWidth < restore) {
        availableSpace = outerWidth;
        btn.classList.add('is-hidden');

        // if (bpV.length === bp.length) { return; }
        while(bpH.length > 0) {
          // bpV.push(bpH[0]);
          // bpH.shift();
        }
        target = bp.length;
      } else if (windowWidth < distory) {

      } else {
        btn.classList.remove('is-hidden');

        if (windowWidth < distory) {
          target = 0;
        } else {
          for (var i = 0, len = bp.length; i < len; i++) {
            if (availableSpace >= bp[i] && availableSpace < bp[i + 1]) {
              target = i + 1;
            } else if (availableSpace < bp[0]) {
              target = 0;
            }
          }
        }
      }
      // console.log(target);

      // set current
      var visibleItems = nav.querySelectorAll('.visible-links > li');
      current = (visibleItems.length) ? visibleItems.length : 0;
      // if (visibleItems.length) {
      // } else {
      //   current = 0;
      // }

      // update
      if (target > current) {
        var a = current;
        while (a < target) {
          var vlink = nav.querySelectorAll('.visible-links');
          var hlinks = nav.querySelectorAll('.hidden-links > li');

          append(vlink, hlinks[0]);
          a++;
        }
      } else if (target < current) {
        var a = current;
        while (a > target ) {
          var visibleItems = nav.querySelectorAll('.visible-links > li');
          var hlinks = nav.querySelectorAll('.hidden-links > li');

          prepend(hiddenContainer, visibleItems[visibleItems.length - 1]);
          a--;
        }
      }

      // update data-count
      var hlinks = nav.querySelectorAll('.hidden-links > li'),
          count;

      if (hlinks.length) {
        count = hlinks.length;
      } else {
        count = 0;
      }
      btn.setAttribute("data-count", count);
    }

    // run updateNav
    updateNav();
    window.addEventListener('resize', function () {
      updateNav();
    });

    // show / hide hidden-links
    btn.addEventListener('click', function () {
      nav.querySelector('.hidden-links').classList.toggle('is-hidden');
    });
  // } else {
  //   console.log('"' + navClass + '" can\'t be found.');
  // }
};<|endoftext|>


<commit_before>function fillSnapshotHistry(sh, size, startTime) {
	startTime = startTime || 0;
	for (var i = 0; i < size; i++) {
		sh.add(new Grape2D.Snapshot(startTime+i));
	}
}
module("SnapshotHistory test");
test("Add test", function(){
	var sh = new Grape2D.SnapshotHistory(10);
	sh.add(new Grape2D.Snapshot(55));
	sh.add(new Grape2D.Snapshot(58));
	var history = sh.getHistory();
	ok((history[0].time == 55) && (history[1].time == 58), "Add passed.");
	sh.add(new Grape2D.Snapshot(59));
	sh.add(new Grape2D.Snapshot(60));
	sh.add(new Grape2D.Snapshot(61));
	sh.add(new Grape2D.Snapshot(62));
	sh.add(new Grape2D.Snapshot(63));
	sh.add(new Grape2D.Snapshot(64));
	sh.add(new Grape2D.Snapshot(65));
	sh.add(new Grape2D.Snapshot(66));
	sh.add(new Grape2D.Snapshot(67));
	sh.add(new Grape2D.Snapshot(68));
	history = sh.getHistory();
	equal(history.length, 10, "History length has passed.");
	equal(history[0].time, 59, "Base entry has passed.");
	equal(history[sh.getCap()-1].time, 68, "Top entry has passed.");
});
test("GetBefore test", function(){
	var sh = new Grape2D.SnapshotHistory(10);
	fillSnapshotHistry(sh, 10, 5);
	equal(sh.getBefore(3), null, "Before firts passed.");
	equal(sh.getBefore(6).time, 5, "Before in the middle passed.");
	equal(sh.getBefore(19).time, 14, "Before at the end passed.");
});
test("GetAfter test", function(){
	var sh = new Grape2D.SnapshotHistory(10);
	fillSnapshotHistry(sh, 10, 5);
	console.log(sh);
	equal(sh.getAfter(3).time, 5, "After firts passed.");
	equal(sh.getAfter(6).time, 7, "After in the middle passed.");
	equal(sh.getAfter(19), null, "After at the end passed.");
});
test("Cap test", function() {
	var sh = new Grape2D.SnapshotHistory();
	equal(sh.getCap(), 10, "Default cap passed.");
	sh.setCap(5);
	equal(sh.getCap(), 5, "Set cap passed.");
	fillSnapshotHistry(sh, 5);
	sh.setCap(4);
	console.log(sh);
	ok((sh.getCap() == 4) && (sh.getHistory().length == 4), "Lowered cap passed.");
});<commit_msg>Removed console.log calls.<commit_after>function fillSnapshotHistry(sh, size, startTime) {
	startTime = startTime || 0;
	for (var i = 0; i < size; i++) {
		sh.add(new Grape2D.Snapshot(startTime+i));
	}
}
module("SnapshotHistory test");
test("Add test", function(){
	var sh = new Grape2D.SnapshotHistory(10);
	sh.add(new Grape2D.Snapshot(55));
	sh.add(new Grape2D.Snapshot(58));
	var history = sh.getHistory();
	ok((history[0].time == 55) && (history[1].time == 58), "Add passed.");
	sh.add(new Grape2D.Snapshot(59));
	sh.add(new Grape2D.Snapshot(60));
	sh.add(new Grape2D.Snapshot(61));
	sh.add(new Grape2D.Snapshot(62));
	sh.add(new Grape2D.Snapshot(63));
	sh.add(new Grape2D.Snapshot(64));
	sh.add(new Grape2D.Snapshot(65));
	sh.add(new Grape2D.Snapshot(66));
	sh.add(new Grape2D.Snapshot(67));
	sh.add(new Grape2D.Snapshot(68));
	history = sh.getHistory();
	equal(history.length, 10, "History length has passed.");
	equal(history[0].time, 59, "Base entry has passed.");
	equal(history[sh.getCap()-1].time, 68, "Top entry has passed.");
});
test("GetBefore test", function(){
	var sh = new Grape2D.SnapshotHistory(10);
	fillSnapshotHistry(sh, 10, 5);
	equal(sh.getBefore(3), null, "Before firts passed.");
	equal(sh.getBefore(6).time, 5, "Before in the middle passed.");
	equal(sh.getBefore(19).time, 14, "Before at the end passed.");
});
test("GetAfter test", function(){
	var sh = new Grape2D.SnapshotHistory(10);
	fillSnapshotHistry(sh, 10, 5);
	equal(sh.getAfter(3).time, 5, "After firts passed.");
	equal(sh.getAfter(6).time, 7, "After in the middle passed.");
	equal(sh.getAfter(19), null, "After at the end passed.");
});
test("Cap test", function() {
	var sh = new Grape2D.SnapshotHistory();
	equal(sh.getCap(), 10, "Default cap passed.");
	sh.setCap(5);
	equal(sh.getCap(), 5, "Set cap passed.");
	fillSnapshotHistry(sh, 5);
	sh.setCap(4);
	ok((sh.getCap() == 4) && (sh.getHistory().length == 4), "Lowered cap passed.");
});<|endoftext|>


<commit_before><commit_msg>check if data is array<commit_after><|endoftext|>


<commit_before><commit_msg>update app generator process<commit_after><|endoftext|>


<commit_before><commit_msg>do not hash short query strings since the hash is longer<commit_after><|endoftext|>


<commit_before>var express = require('express');
var r = module.exports = express.Router();

r.get('/session.json', function(req, res, next) {
  res.send(req.session);
});

var Board = require('./models/board');

r.get('/boards/:id', function(req, res, next) {
  Board.find({ id: '1' }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      res.send({ board: boards[0] });
    }
  });
});

// Deleting columns
r.delete('/boards/:id/columns/:col', function (req, res, next) {
  Board.find({ id: req.params.id }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      var board = boards[0];
      board.columns.splice(req.params.col, 1);
      Board.update({ _id: board._id }, { columns: board.columns }, function(err) {
        if (err) { res.send(500, err.message); }
        else { res.send({ board: board }); }
      });
    }
  });
});

// Deleting cards
r.delete('/boards/:id/columns/:col/cards/:row', function(req, res, next) {
  Board.find({ id: req.params.id }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      var board = boards[0];
      board.columns[req.params.col].cards.splice(req.params.row, 1);
      Board.update({ _id: board._id }, { columns: board.columns }, function(err) {
        if (err) { res.send(500, err.message); }
        else { res.send({ board: board }); }
      });
    }
  });
});

var _ = require('lodash');

// Importing cards from Github
r.post('/boards/:id/columns/:col/cards/import/github', function(req, res, next) {
  Board.find({ id: req.params.id }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      var board = boards[0];
      _.each(req.body.openIssues, function(issue) {
        board.columns[req.params.col].cards.push({
          title: issue.title
        });
      });
      Board.update({ _id: board._id }, { columns: board.columns }, function(err) {
        if (err) { res.send(500, err.message); }
        else { res.send({ board: { columns: board.columns } }) }
      });
    }
  });
})
<commit_msg>cards are issues<commit_after>var express = require('express');
var r = module.exports = express.Router();

r.get('/session.json', function(req, res, next) {
  res.send(req.session);
});

var Board = require('./models/board');

r.get('/boards/:id', function(req, res, next) {
  Board.find({ id: '1' }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      res.send({ board: boards[0] });
    }
  });
});

// Deleting columns
r.delete('/boards/:id/columns/:col', function (req, res, next) {
  Board.find({ id: req.params.id }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      var board = boards[0];
      board.columns.splice(req.params.col, 1);
      Board.update({ _id: board._id }, { columns: board.columns }, function(err) {
        if (err) { res.send(500, err.message); }
        else { res.send({ board: board }); }
      });
    }
  });
});

// Deleting cards
r.delete('/boards/:id/columns/:col/cards/:row', function(req, res, next) {
  Board.find({ id: req.params.id }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      var board = boards[0];
      board.columns[req.params.col].cards.splice(req.params.row, 1);
      Board.update({ _id: board._id }, { columns: board.columns }, function(err) {
        if (err) { res.send(500, err.message); }
        else { res.send({ board: board }); }
      });
    }
  });
});

var _ = require('lodash');

// Importing cards from Github
r.post('/boards/:id/columns/:col/cards/import/github', function(req, res, next) {
  Board.find({ id: req.params.id }, function(err, boards) {
    if (err) {
      res.send(500);
    } else if (boards.length === 0) {
      res.send(404);
    } else {
      var board = boards[0];
      _.each(req.body.openIssues, function(issue) {
        board.columns[req.params.col].cards.push(issue);
      });
      Board.update({ _id: board._id }, { columns: board.columns }, function(err) {
        if (err) { res.send(500, err.message); }
        else { res.send({ board: { columns: board.columns } }) }
      });
    }
  });
})
<|endoftext|>


<commit_before><commit_msg>add comment<commit_after><|endoftext|>


<commit_before>import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import path from 'path';
import http from 'http';
import { invert, isArray } from 'lodash';
import url from 'url';
import cookiesMiddleware from 'universal-cookie-express';
// eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies, import/extensions
import queryMap from 'persisted_queries.json';
import modules from './modules';

import websiteMiddleware from './middleware/website';
import graphiqlMiddleware from './middleware/graphiql';
import graphqlMiddleware from './middleware/graphql';
import addGraphQLSubscriptions from './api/subscriptions';
import { options as spinConfig } from '../../.spinrc.json';
import log from '../common/log';

// eslint-disable-next-line import/no-mutable-exports
let server;

const app = express();

app.use(cookiesMiddleware());

const { protocol, port, pathname, hostname } = url.parse(__BACKEND_URL__);
const serverPort = process.env.PORT || port;

// Don't rate limit heroku
app.enable('trust proxy');

if (__DEV__) {
  const corsOptions = {
    origin: `${protocol}//${hostname}:3000`,
    credentials: true
  };
  app.use(cors(corsOptions));
}

app.use(bodyParser.urlencoded({ limit: '50mb', extended: true, parameterLimit: 500000 }));
app.use(bodyParser.json({ limit: '50mb' }));

app.use(
  '/',
  express.static(path.join(spinConfig.frontendBuildDir, 'web'), {
    maxAge: '180 days'
  })
);

if (__DEV__) {
  app.use('/', express.static(spinConfig.dllBuildDir, { maxAge: '180 days' }));
}

if (__PERSIST_GQL__) {
  const invertedMap = invert(queryMap);

  app.use('/graphql', (req, resp, next) => {
    if (isArray(req.body)) {
      req.body = req.body.map(body => {
        return {
          query: invertedMap[body.id],
          ...body
        };
      });
      next();
    } else {
      if (!__DEV__ || (req.get('Referer') || '').indexOf('/graphiql') < 0) {
        resp.status(500).send('Unknown GraphQL query has been received, rejecting...');
      } else {
        next();
      }
    }
  });
}

for (const middleware of modules.middlewares) {
  app.use(middleware);
}
app.use(pathname, (...args) => graphqlMiddleware(...args));
app.use('/graphiql', (...args) => graphiqlMiddleware(...args));
app.use((...args) => websiteMiddleware(queryMap)(...args));

server = http.createServer(app);

addGraphQLSubscriptions(server);

server.listen(serverPort, () => {
  log.info(`API is now running on port ${serverPort}`);
});

server.on('close', () => {
  server = undefined;
});

if (module.hot) {
  module.hot.dispose(() => {
    try {
      if (server) {
        server.close();
      }
    } catch (error) {
      log(error.stack);
    }
  });
  module.hot.accept(['./middleware/website', './middleware/graphql']);
  module.hot.accept(['./api/subscriptions'], () => {
    try {
      addGraphQLSubscriptions(server);
    } catch (error) {
      log(error.stack);
    }
  });

  module.hot.accept();
}

export default server;
<commit_msg>Revert back body parser limit setting<commit_after>import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import path from 'path';
import http from 'http';
import { invert, isArray } from 'lodash';
import url from 'url';
import cookiesMiddleware from 'universal-cookie-express';
// eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies, import/extensions
import queryMap from 'persisted_queries.json';
import modules from './modules';

import websiteMiddleware from './middleware/website';
import graphiqlMiddleware from './middleware/graphiql';
import graphqlMiddleware from './middleware/graphql';
import addGraphQLSubscriptions from './api/subscriptions';
import { options as spinConfig } from '../../.spinrc.json';
import log from '../common/log';

// eslint-disable-next-line import/no-mutable-exports
let server;

const app = express();

app.use(cookiesMiddleware());

const { protocol, port, pathname, hostname } = url.parse(__BACKEND_URL__);
const serverPort = process.env.PORT || port;

// Don't rate limit heroku
app.enable('trust proxy');

if (__DEV__) {
  const corsOptions = {
    origin: `${protocol}//${hostname}:3000`,
    credentials: true
  };
  app.use(cors(corsOptions));
}

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.use(
  '/',
  express.static(path.join(spinConfig.frontendBuildDir, 'web'), {
    maxAge: '180 days'
  })
);

if (__DEV__) {
  app.use('/', express.static(spinConfig.dllBuildDir, { maxAge: '180 days' }));
}

if (__PERSIST_GQL__) {
  const invertedMap = invert(queryMap);

  app.use('/graphql', (req, resp, next) => {
    if (isArray(req.body)) {
      req.body = req.body.map(body => {
        return {
          query: invertedMap[body.id],
          ...body
        };
      });
      next();
    } else {
      if (!__DEV__ || (req.get('Referer') || '').indexOf('/graphiql') < 0) {
        resp.status(500).send('Unknown GraphQL query has been received, rejecting...');
      } else {
        next();
      }
    }
  });
}

for (const middleware of modules.middlewares) {
  app.use(middleware);
}
app.use(pathname, (...args) => graphqlMiddleware(...args));
app.use('/graphiql', (...args) => graphiqlMiddleware(...args));
app.use((...args) => websiteMiddleware(queryMap)(...args));

server = http.createServer(app);

addGraphQLSubscriptions(server);

server.listen(serverPort, () => {
  log.info(`API is now running on port ${serverPort}`);
});

server.on('close', () => {
  server = undefined;
});

if (module.hot) {
  module.hot.dispose(() => {
    try {
      if (server) {
        server.close();
      }
    } catch (error) {
      log(error.stack);
    }
  });
  module.hot.accept(['./middleware/website', './middleware/graphql']);
  module.hot.accept(['./api/subscriptions'], () => {
    try {
      addGraphQLSubscriptions(server);
    } catch (error) {
      log(error.stack);
    }
  });

  module.hot.accept();
}

export default server;
<|endoftext|>


<commit_before>/**
 * @constructor
 */
Melown.ControlMode.MapObserver = function(browser_) {
    this.browser_ = browser_;
    this.config_ = browser_.config_;

    this.coordsDeltas_ = [];
    this.orientationDeltas_ = [];
    this.viewExtentDeltas_ = [];

    this["drag"] = this.drag;
    this["wheel"] = this.wheel;
    this["tick"] = this.tick;
    this["reset"] = this.reset;
    this["keyup"] = this.keyup;
    this["keydown"] = this.keydown;
    this["keypress"] = this.keypress;
};

Melown.ControlMode.MapObserver.prototype.drag = function(event_) {
    var map_ = this.browser_.getMap();
    if (map_ == null) {
        return;
    }

    var pos_ = map_.getPosition();
    var coords_ = map_.getPositionCoords(pos_);
    var delta_ = event_.getDragDelta();
    var azimuthDistance_ = this.getAzimuthAndDistance(delta_[0], delta_[1]);

    var modifierKey_ = (this.browser_.controlMode_.altKey_
               || this.browser_.controlMode_.shiftKey_
               || this.browser_.controlMode_.ctrlKey_);

    if ((event_.getDragButton("left") && !modifierKey_)
        && this.config_.panAllowed_) { //pan

        if (map_.getPositionHeightMode(pos_) == "fix") {
            var pos2_ = map_.convertPositionHeightMode(pos_, "float", true);
            if (pos2_ != null) {
                pos_ = pos2_;
                this.setPosition(pos_);
            }
        } else {
            var azimuth_ = Melown.radians(azimuthDistance_[0]);
            var forward_ = [-Math.sin(azimuth_),
                            Math.cos(azimuth_),
                            azimuthDistance_[1], azimuthDistance_[0],
                            coords_[0], coords_[1]];

            this.coordsDeltas_.push(forward_);
            this.reduceFloatingHeight(0.9);
        }
    } else if ((event_.getDragButton("right") || modifierKey_)
               && this.config_.rotationAllowed_) { //rotate

        var sensitivity_ = 0.4;
        this.orientationDeltas_.push([-delta_[0] * sensitivity_,
                                      -delta_[1] * sensitivity_, 0]);
    }
};

Melown.ControlMode.MapObserver.prototype.wheel = function(event_) {
    var map_ = this.browser_.getMap();
    if (map_ == null || !this.config_.zoomAllowed_) {
        return;
    }

    var pos_ = map_.getPosition();
    var delta_ = event_.getWheelDelta();
    var factor_ = 1.0 + (delta_ > 0 ? -1 : 1)*0.05;

    this.viewExtentDeltas_.push(factor_);
    this.reduceFloatingHeight(0.8);
};

Melown.ControlMode.MapObserver.prototype.keyup = function(event_) {
};

Melown.ControlMode.MapObserver.prototype.keydown = function(event_) {
};

Melown.ControlMode.MapObserver.prototype.keypress = function(event_) {
};

Melown.ControlMode.MapObserver.prototype.setPosition = function(pos_) {
    pos_ = this.constrainPosition(pos_);
    var map_ = this.browser_.getMap();
    map_.setPosition(pos_);
};

Melown.ControlMode.MapObserver.prototype.constrainPosition = function(pos_) {

//    if (this.isNavigationSRSProjected()) {

//    } else {

        //reduce tilt whe you are far off the planet

        var map_ = this.browser_.getMap();
        var rf_ = map_.getReferenceFrame();
        var srs_ = map_.getSrsInfo(rf_["navigationSrs"]);

        var distance_ = map_.getPositionViewExtent(pos_) / Math.tan(Melown.radians(map_.getPositionFov(pos_)*0.5));

        if (srs_["a"]) {

            //var factor_ = Math.min(distance_ / (srs_["a"]*0.1), 1.0);
            var factor_ = Math.min(distance_ / (srs_["a"]*0.5), 1.0);
            var maxTilt_ = 20 + ((-90) - 20) * factor_;

            var o = map_.getPositionOrientation(pos_);

            //o[1] = o[1] + ((-90) - o[1]) * factor_;

            if (o[1] > maxTilt_) {
                o[1] = maxTilt_;
            }

            pos_ = map_.setPositionOrientation(pos_, o);
        }

        //get

  //  }

    return pos_;
};

Melown.ControlMode.MapObserver.prototype.reduceFloatingHeight = function(factor_) {
    var map_ = this.browser_.getMap();
    var pos_ = map_.getPosition();
    var coords_ = map_.getPositionCoords(pos_);

    if (map_.getPositionHeightMode(pos_) == "float") {
        if (coords_[2] != 0) {
            coords_[2] *= factor_;

            if (Math.abs(coords_[2]) < 0.1) {
                coords_[2] = 0;
            }

            pos_ = map_.setPositionCoords(pos_, coords_);
            this.setPosition(pos_);
        }
    }
};

Melown.ControlMode.MapObserver.prototype.isNavigationSRSProjected = function() {
    var map_ = this.browser_.getMap();
    var rf_ = map_.getReferenceFrame();
    var srs_ = map_.getSrsInfo(rf_["navigationSrs"]);
    return (srs_) ? (srs_["type"] == "projected") : false;
};

Melown.ControlMode.MapObserver.prototype.getAzimuthAndDistance = function(dx_, dy_) {
    var map_ = this.browser_.getMap();
    var pos_ = map_.getPosition();
    var viewExtent_ = map_.getPositionViewExtent(pos_);
    var fov_ = map_.getPositionFov(pos_)*0.5;

    var sensitivity_ = 0.5;
    var zoomFactor_ = ((viewExtent_ * Math.tan(Melown.radians(fov_))) / 800) * sensitivity_;
    dx_ *= zoomFactor_;
    dy_ *= zoomFactor_;

    var distance_ = Math.sqrt(dx_*dx_ + dy_*dy_);
    var azimuth_ = Melown.degrees(Math.atan2(dx_, dy_)) + map_.getPositionOrientation(pos_)[0];

    return [azimuth_, distance_];
};

Melown.ControlMode.MapObserver.prototype.tick = function(event_) {
    var map_ = this.browser_.getMap();
    if (map_ == null) {
        return;
    }

    var pos_ = map_.getPosition();
    var update_ = false;
    var inertia_ = [0.8, 0.8, 0.7];
    //var inertia_ = [0.95, 0.8, 0.8];
    //var inertia_ = [0, 0, 0];

    //process coords deltas
    if (this.coordsDeltas_.length > 0) {
        var deltas_ = this.coordsDeltas_;
        var forward_ = [0,0];
        var coords_ = map_.getPositionCoords(pos_);

        //get foward vector form coord deltas
        for (var i = 0; i < deltas_.length; i++) {
            var delta_ = deltas_[i];

            var coords2_ = [delta_[4], delta_[5]];

            var azimuth_ = delta_[3];
            azimuth_ += 0;//map_.getAzimuthCorrection(coords2_, coords_);
            azimuth_ = Melown.radians(azimuth_);

            //console.log("correction: " + map_.getAzimuthCorrection(coords2_, coords_) + " coords2: " + JSON.stringify(coords2_) + " coords: " + JSON.stringify(coords_));

            forward_[0] += -Math.sin(azimuth_) * delta_[2];
            forward_[1] += Math.cos(azimuth_) * delta_[2];

            /*
            forward_[0] += delta_[0] * delta_[2];
            forward_[1] += delta_[1] * delta_[2];
            */
            delta_[2] *= inertia_[0];

            //remove zero deltas
            if (delta_[2] < 0.01) {
                deltas_.splice(i, 1);
                i--;
            }
        }

        var distance_ = Math.sqrt(forward_[0]*forward_[0] + forward_[1]*forward_[1]);
        var azimuth_ = Melown.degrees(Math.atan2(forward_[0], forward_[1]));

        //console.log("tick: " + azimuth_ + " " + distance_);

        //apply final azimuth and distance
        var correction_ = map_.getPositionOrientation(pos_)[0];
        pos_ = map_.movePositionCoordsTo(pos_, (this.isNavigationSRSProjected() ? -1 : 1) * azimuth_, distance_);
        correction_ = map_.getPositionOrientation(pos_)[0] - correction_;

        //console.log("correction2: " + correction_);

        for (var i = 0; i < deltas_.length; i++) {
            var delta_ = deltas_[i];
            delta_[3] += correction_;
        }

        update_ = true;
    }

    //process coords deltas
    if (this.orientationDeltas_.length > 0) {
        var deltas_ = this.orientationDeltas_;
        var orientation_ = map_.getPositionOrientation(pos_);

        //apply detals to current orientation
        for (var i = 0; i < deltas_.length; i++) {
            var delta_ = deltas_[i];
            orientation_[0] += delta_[0];
            orientation_[1] += delta_[1];
            orientation_[2] += delta_[2];
            delta_[0] *= inertia_[1];
            delta_[1] *= inertia_[1];
            delta_[2] *= inertia_[1];

            //remove zero deltas
            if (delta_[0]*delta_[0] + delta_[1]*delta_[1] + delta_[2]*delta_[2] < 0.1) {
                deltas_.splice(i, 1);
                i--;
            }
        }

        //apply final orintation
        pos_ = map_.setPositionOrientation(pos_, orientation_);
        update_ = true;
    }

    //process view extents deltas
    if (this.viewExtentDeltas_.length > 0) {
        var deltas_ = this.viewExtentDeltas_;
        var viewExtent_ = map_.getPositionViewExtent(pos_);

        //apply detals to current orientation
        for (var i = 0; i < deltas_.length; i++) {
            viewExtent_ *= deltas_[i];
            deltas_[i] += (1 - deltas_[i]) * (1.0 - inertia_[2]);

            //remove zero deltas
            if (Math.abs(1 - deltas_[i]) < 0.001) {
                deltas_.splice(i, 1);
                i--;
            }
        }

        viewExtent_ = Math.max(1, viewExtent_);

        //apply final orintation
        pos_ = map_.setPositionViewExtent(pos_, viewExtent_);
        update_ = true;
    }

    //set new position
    if (update_) {
        this.setPosition(pos_);
    }

};

Melown.ControlMode.MapObserver.prototype.reset = function(config_) {
    this.coordsDeltas_ = [];
    this.orientationDeltas_ = [];
    this.viewExtentDeltas_ = [];
};

<commit_msg>simple fog density<commit_after>/**
 * @constructor
 */
Melown.ControlMode.MapObserver = function(browser_) {
    this.browser_ = browser_;
    this.config_ = browser_.config_;

    this.coordsDeltas_ = [];
    this.orientationDeltas_ = [];
    this.viewExtentDeltas_ = [];

    this["drag"] = this.drag;
    this["wheel"] = this.wheel;
    this["tick"] = this.tick;
    this["reset"] = this.reset;
    this["keyup"] = this.keyup;
    this["keydown"] = this.keydown;
    this["keypress"] = this.keypress;
};

Melown.ControlMode.MapObserver.prototype.drag = function(event_) {
    var map_ = this.browser_.getMap();
    if (map_ == null) {
        return;
    }

    var pos_ = map_.getPosition();
    var coords_ = map_.getPositionCoords(pos_);
    var delta_ = event_.getDragDelta();
    var azimuthDistance_ = this.getAzimuthAndDistance(delta_[0], delta_[1]);

    var modifierKey_ = (this.browser_.controlMode_.altKey_
               || this.browser_.controlMode_.shiftKey_
               || this.browser_.controlMode_.ctrlKey_);

    if ((event_.getDragButton("left") && !modifierKey_)
        && this.config_.panAllowed_) { //pan

        if (map_.getPositionHeightMode(pos_) == "fix") {
            var pos2_ = map_.convertPositionHeightMode(pos_, "float", true);
            if (pos2_ != null) {
                pos_ = pos2_;
                this.setPosition(pos_);
            }
        } else {
            var azimuth_ = Melown.radians(azimuthDistance_[0]);
            var forward_ = [-Math.sin(azimuth_),
                            Math.cos(azimuth_),
                            azimuthDistance_[1], azimuthDistance_[0],
                            coords_[0], coords_[1]];

            this.coordsDeltas_.push(forward_);
            this.reduceFloatingHeight(0.9);
        }
    } else if ((event_.getDragButton("right") || modifierKey_)
               && this.config_.rotationAllowed_) { //rotate

        var sensitivity_ = 0.4;
        this.orientationDeltas_.push([-delta_[0] * sensitivity_,
                                      -delta_[1] * sensitivity_, 0]);
    }
};

Melown.ControlMode.MapObserver.prototype.wheel = function(event_) {
    var map_ = this.browser_.getMap();
    if (map_ == null || !this.config_.zoomAllowed_) {
        return;
    }

    var pos_ = map_.getPosition();
    var delta_ = event_.getWheelDelta();
    var factor_ = 1.0 + (delta_ > 0 ? -1 : 1)*0.05;

    this.viewExtentDeltas_.push(factor_);
    this.reduceFloatingHeight(0.8);
};

Melown.ControlMode.MapObserver.prototype.keyup = function(event_) {
};

Melown.ControlMode.MapObserver.prototype.keydown = function(event_) {
};

Melown.ControlMode.MapObserver.prototype.keypress = function(event_) {
};

Melown.ControlMode.MapObserver.prototype.setPosition = function(pos_) {
    pos_ = this.constrainPosition(pos_);
    var map_ = this.browser_.getMap();
    map_.setPosition(pos_);
};

Melown.ControlMode.MapObserver.prototype.constrainPosition = function(pos_) {

//    if (this.isNavigationSRSProjected()) {

//    } else {

        //reduce tilt whe you are far off the planet

        var map_ = this.browser_.getMap();
        var rf_ = map_.getReferenceFrame();
        var srs_ = map_.getSrsInfo(rf_["navigationSrs"]);

        var distance_ = map_.getPositionViewExtent(pos_) / Math.tan(Melown.radians(map_.getPositionFov(pos_)*0.5));

        if (srs_["a"]) {

            //var factor_ = Math.min(distance_ / (srs_["a"]*0.1), 1.0);
            var factor_ = Math.min(distance_ / (srs_["a"]*0.5), 1.0);
            var maxTilt_ = 20 + ((-90) - 20) * factor_;

            var o = map_.getPositionOrientation(pos_);

            //o[1] = o[1] + ((-90) - o[1]) * factor_;

            if (o[1] > maxTilt_) {
                o[1] = maxTilt_;
            }

            pos_ = map_.setPositionOrientation(pos_, o);
        }

        //get

  //  }

/*
    var maxIter_ = 1000;

    var cameraMinDesiredDistance_ = this.cameraMinDesiredDistance_;
    var cameraConstrainDistance_ = this.cameraConstrainDistance_;

    if (this.ignoreTexelSize_ == true) {
        cameraConstrainDistance_ = 1;
        cameraMinDesiredDistance_ = 0.5;
    }

    var hmax_ = Math.max(Math.min(4000,cameraConstrainDistance_), (this.position_[2] * Math.tan(Vadstena.radians(3.0))));
    var cameraHeight_ = this.cameraHeight() - this.cameraHeightOffset_ - this.cameraHeightOffset2_;

    if (cameraHeight_ < hmax_) {

        if (this.position_[2] < hmax_) {

            var getFinalDistance = (function(start_, end_, level_) {

                var value_ = (start_ + end_) * 0.5;

                if (level_ > 20) {
                    return value_;
                } else {

                    this.position_[2] = value_;
                    this.updateCamera();

                    if ((this.cameraHeight() - this.cameraHeightOffset_ - this.cameraHeightOffset2_) < hmax_) {
                        return getFinalDistance(start_, value_, level_+1);
                    } else {
                        return getFinalDistance(value_, end_, level_+1);
                    }

                }

            }).bind(this);

            this.position_[2] = getFinalDistance(this.position_[2]+250, this.position_[2], 0);
            //this.position_[2] = getFinalDistance(this.position_[2]+cameraConstrainDistance_, this.position_[2], 0);

            this.updateCamera();

        } else {

            var getFinalOrientation = (function(start_, end_, level_) {

                var value_ = (start_ + end_) * 0.5;

                if (level_ > 20) {
                    return value_;
                } else {

                    this.orientation_[1] = value_;
                    this.updateCamera();

                    if ((this.cameraHeight() - this.cameraHeightOffset_ - this.cameraHeightOffset2_) < hmax_) {
                        return getFinalOrientation(start_, value_, level_+1);
                    } else {
                        return getFinalOrientation(value_, end_, level_+1);
                    }

                }

            }).bind(this);

            this.orientation_[1] = getFinalOrientation(-89, Math.min(-1, this.orientation_[1]), 0);
            this.updateCamera();

        }

    } else {

        var distance_ = cameraMinDesiredDistance_ * 0.5;

        var hmax2_ = Math.max(distance_, (this.position_[2] * (0.1*(20.0/distance_))));

        //apply cameraMinDesiredDistance_ directly
        if (cameraHeight_ >= hmax2_) {
            //this.cameraMinDistance_ = cameraMinDesiredDistance_;
            //cameraConstrainDistance_ = this.cameraMinDistance_ * 0.5;
        }
    }
*/
    return pos_;
};

Melown.ControlMode.MapObserver.prototype.reduceFloatingHeight = function(factor_) {
    var map_ = this.browser_.getMap();
    var pos_ = map_.getPosition();
    var coords_ = map_.getPositionCoords(pos_);

    if (map_.getPositionHeightMode(pos_) == "float") {
        if (coords_[2] != 0) {
            coords_[2] *= factor_;

            if (Math.abs(coords_[2]) < 0.1) {
                coords_[2] = 0;
            }

            pos_ = map_.setPositionCoords(pos_, coords_);
            this.setPosition(pos_);
        }
    }
};

Melown.ControlMode.MapObserver.prototype.isNavigationSRSProjected = function() {
    var map_ = this.browser_.getMap();
    var rf_ = map_.getReferenceFrame();
    var srs_ = map_.getSrsInfo(rf_["navigationSrs"]);
    return (srs_) ? (srs_["type"] == "projected") : false;
};

Melown.ControlMode.MapObserver.prototype.getAzimuthAndDistance = function(dx_, dy_) {
    var map_ = this.browser_.getMap();
    var pos_ = map_.getPosition();
    var viewExtent_ = map_.getPositionViewExtent(pos_);
    var fov_ = map_.getPositionFov(pos_)*0.5;

    var sensitivity_ = 0.5;
    var zoomFactor_ = ((viewExtent_ * Math.tan(Melown.radians(fov_))) / 800) * sensitivity_;
    dx_ *= zoomFactor_;
    dy_ *= zoomFactor_;

    var distance_ = Math.sqrt(dx_*dx_ + dy_*dy_);
    var azimuth_ = Melown.degrees(Math.atan2(dx_, dy_)) + map_.getPositionOrientation(pos_)[0];

    return [azimuth_, distance_];
};

Melown.ControlMode.MapObserver.prototype.tick = function(event_) {
    var map_ = this.browser_.getMap();
    if (map_ == null) {
        return;
    }

    var pos_ = map_.getPosition();
    var update_ = false;
    var inertia_ = [0.8, 0.8, 0.7];
    //var inertia_ = [0.95, 0.8, 0.8];
    //var inertia_ = [0, 0, 0];

    //process coords deltas
    if (this.coordsDeltas_.length > 0) {
        var deltas_ = this.coordsDeltas_;
        var forward_ = [0,0];
        var coords_ = map_.getPositionCoords(pos_);

        //get foward vector form coord deltas
        for (var i = 0; i < deltas_.length; i++) {
            var delta_ = deltas_[i];

            var coords2_ = [delta_[4], delta_[5]];

            var azimuth_ = delta_[3];
            azimuth_ += 0;//map_.getAzimuthCorrection(coords2_, coords_);
            azimuth_ = Melown.radians(azimuth_);

            //console.log("correction: " + map_.getAzimuthCorrection(coords2_, coords_) + " coords2: " + JSON.stringify(coords2_) + " coords: " + JSON.stringify(coords_));

            forward_[0] += -Math.sin(azimuth_) * delta_[2];
            forward_[1] += Math.cos(azimuth_) * delta_[2];

            /*
            forward_[0] += delta_[0] * delta_[2];
            forward_[1] += delta_[1] * delta_[2];
            */
            delta_[2] *= inertia_[0];

            //remove zero deltas
            if (delta_[2] < 0.01) {
                deltas_.splice(i, 1);
                i--;
            }
        }

        var distance_ = Math.sqrt(forward_[0]*forward_[0] + forward_[1]*forward_[1]);
        var azimuth_ = Melown.degrees(Math.atan2(forward_[0], forward_[1]));

        //console.log("tick: " + azimuth_ + " " + distance_);

        //apply final azimuth and distance
        var correction_ = map_.getPositionOrientation(pos_)[0];
        pos_ = map_.movePositionCoordsTo(pos_, (this.isNavigationSRSProjected() ? -1 : 1) * azimuth_, distance_);
        correction_ = map_.getPositionOrientation(pos_)[0] - correction_;

        //console.log("correction2: " + correction_);

        for (var i = 0; i < deltas_.length; i++) {
            var delta_ = deltas_[i];
            delta_[3] += correction_;
        }

        update_ = true;
    }

    //process coords deltas
    if (this.orientationDeltas_.length > 0) {
        var deltas_ = this.orientationDeltas_;
        var orientation_ = map_.getPositionOrientation(pos_);

        //apply detals to current orientation
        for (var i = 0; i < deltas_.length; i++) {
            var delta_ = deltas_[i];
            orientation_[0] += delta_[0];
            orientation_[1] += delta_[1];
            orientation_[2] += delta_[2];
            delta_[0] *= inertia_[1];
            delta_[1] *= inertia_[1];
            delta_[2] *= inertia_[1];

            //remove zero deltas
            if (delta_[0]*delta_[0] + delta_[1]*delta_[1] + delta_[2]*delta_[2] < 0.1) {
                deltas_.splice(i, 1);
                i--;
            }
        }

        //apply final orintation
        pos_ = map_.setPositionOrientation(pos_, orientation_);
        update_ = true;
    }

    //process view extents deltas
    if (this.viewExtentDeltas_.length > 0) {
        var deltas_ = this.viewExtentDeltas_;
        var viewExtent_ = map_.getPositionViewExtent(pos_);

        //apply detals to current orientation
        for (var i = 0; i < deltas_.length; i++) {
            viewExtent_ *= deltas_[i];
            deltas_[i] += (1 - deltas_[i]) * (1.0 - inertia_[2]);

            //remove zero deltas
            if (Math.abs(1 - deltas_[i]) < 0.001) {
                deltas_.splice(i, 1);
                i--;
            }
        }

        viewExtent_ = Math.max(1, viewExtent_);

        //apply final orintation
        pos_ = map_.setPositionViewExtent(pos_, viewExtent_);
        update_ = true;
    }

    //set new position
    if (update_) {
        this.setPosition(pos_);
    }

};

Melown.ControlMode.MapObserver.prototype.reset = function(config_) {
    this.coordsDeltas_ = [];
    this.orientationDeltas_ = [];
    this.viewExtentDeltas_ = [];
};

<|endoftext|>


<commit_before><commit_msg>Sets price to listing if there's no buy order<commit_after><|endoftext|>


<commit_before><commit_msg>Added type attr to route model<commit_after><|endoftext|>


<commit_before>const appendEnvIfNotProduction = (name) => {
  let suffix = "-development"

  if(typeof process.env === "object") {
    if(typeof process.env.NODE_ENV === "string") {
      if(process.env.NODE_ENV.trim() !== "") {
        suffix = ("-"+process.env.NODE_ENV.trim().toLowerCase()).replace("-production", "")
      }
    }
  }

  return name+suffix;
}

module.exports = {
    "apps": [
        {
            "name": appendEnvIfNotProduction("feeds"),
            "script": "server.js",
            "instances": 3,
            "env_preprod": {
                "NODE_ENV": "preprod"
            },
            "env_production": {
                "NODE_ENV": "production"
            }
        }
    ],
    "deploy": {
        "production" : {
          "user": "podcloud",
          "host": "eve.podradio.fr",
          "ref": "origin/master",
          "repo": "git@github.com:PodShows/podcloud-feeds.git",
          "path": "/home/podcloud/production/feeds",
          "pre-deploy-local": "ssh-keyscan eve.podradio.fr >> ~/.ssh/known_hosts",
          "post-deploy": "npm install && pm2 startOrReload ecosystem.config.js --env production",
          "env": {
            "NODE_ENV": "production"
          }
        },
        "preprod" : {
          "user": "podcloud",
          "host": "eve.podradio.fr",
          "ref": "origin/develop",
          "repo": "git@github.com:PodShows/podcloud-feeds.git",
          "path": "/home/podcloud/preprod/feeds",
          "pre-deploy-local": "ssh-keyscan eve.podradio.fr >> ~/.ssh/known_hosts",
          "post-deploy": "npm install && pm2 startOrReload ecosystem.config.js --env preprod",
          "env": {
            "NODE_ENV": "preprod"
          }
        }
    }
};
<commit_msg>deployment fix<commit_after>const appendEnvIfNotProduction = (name) => {
  let suffix = "-development"

  if(typeof process.env === "object") {
    if(typeof process.env.NODE_ENV === "string") {
      if(process.env.NODE_ENV.trim() !== "") {
        suffix = ("-"+process.env.NODE_ENV.trim().toLowerCase()).replace("-production", "")
      }
    }
  }

  return name+suffix;
}

module.exports = {
    "apps": [
        {
            "name": appendEnvIfNotProduction("feeds"),
            "script": "server.js",
            "instances": 3,
            "env_preprod": {
                "NODE_ENV": "preprod"
            },
            "env_production": {
                "NODE_ENV": "production"
            }
        }
    ],
    "deploy": {
        "production" : {
          "user": "podcloud",
          "host": "eve.podradio.fr",
          "ref": "origin/master",
          "repo": "git@github.com:PodShows/podcloud-feeds.git",
          "path": "/home/podcloud/production/feeds",
          "pre-deploy-local": "ssh-keyscan eve.podradio.fr >> ~/.ssh/known_hosts",
          "post-deploy": "npm install && NODE_ENV=production pm2 startOrReload ecosystem.config.js --env production",
          "env": {
            "NODE_ENV": "production"
          }
        },
        "preprod" : {
          "user": "podcloud",
          "host": "eve.podradio.fr",
          "ref": "origin/develop",
          "repo": "git@github.com:PodShows/podcloud-feeds.git",
          "path": "/home/podcloud/preprod/feeds",
          "pre-deploy-local": "ssh-keyscan eve.podradio.fr >> ~/.ssh/known_hosts",
          "post-deploy": "npm install && NODE_ENV=preprod pm2 startOrReload ecosystem.config.js --env preprod",
          "env": {
            "NODE_ENV": "preprod"
          }
        }
    }
};
<|endoftext|>