Takes all app javascript files, angular templates and concats and minifies them
435019
function () {
                var stream = new $.streamqueue({
                    objectMode: true
                });

                //Optionally injected additional javascript sourcecode
                injectIntoStream(stream, options.injectInto.js.pre);

                // App files without vendor files
                stream.queue(gulp.src(options.files.jsNoVendor));

                //Angular template files
                stream.queue(
                    gulp.src(options.files.partials)
                        .pipe($.htmlMinify())
                        .pipe($.angularTemplatecache(options.templateCacheOptions))
                );

                //Optionally injected additional javascript sourcecode
                injectIntoStream(stream, options.injectInto.js.post);

                return stream
                    .done()
                    .pipe($.angularFilesort())
                    .pipe($.concat(options.output.js.app))
                    .pipe($.generateOutPipe(options.paths.build, options.output.js.path, 'app.js', options.rev, $.jsMinify)());
            }
1072474
function bundler(loader, options, modules) {
  var stack    = modules.slice(0);
  var mods     = [];
  var finished = {};

  function processModule(mod) {
    if (finished.hasOwnProperty(mod.id)) {
      return;
    }

    mod = loader.getModule(mod.id);

    // browser pack chunk
    var browserpack = {
      id     : mod.id,
      source : mod.source,
      deps   : {}
    };

    // Gather up all dependencies
    var i, length, dep;
    for (i = 0, length = mod.deps.length; i < length; i++) {
      dep = mod.deps[i];
      stack.push(dep);
      browserpack.deps[dep.id] = dep.id;
    }

    finished[mod.id] = browserpack;
    mods.unshift(browserpack);
  }

  // Process all modules
  while (stack.length) {
    processModule(stack.pop());
  }

  var stream = browserPack(options).setEncoding("utf8");
  var promise = pstream(stream);

  stream.end(JSON.stringify(mods));
  return promise;
}
357051
function handleDemoIndexFile() {
      files.index.contentsPromise.then(function(contents) {
        demoContainer = angular.element(
          '<div class="demo-content ' + ngModule + '">'
        );

        var isStandalone = !!ngModule;
        var demoScope;
        var demoCompileService;
        if (isStandalone) {
          angular.bootstrap(demoContainer[0], [ngModule]);
          demoScope = demoContainer.scope();
          demoCompileService = demoContainer.injector().get('$compile');
          scope.$on('$destroy', function() {
            demoScope.$destroy();
          });

        } else {
          demoScope = scope.$new();
          demoCompileService = $compile;
        }

        // Once everything is loaded, put the demo into the DOM
        $q.all([
          handleDemoStyles(),
          handleDemoTemplates()
        ]).finally(function() {
          demoScope.$evalAsync(function() {
            element.append(demoContainer);
            demoContainer.html(contents);
            demoCompileService(demoContainer.contents())(demoScope);
          });
        });
      });

    }
817559
function execute() {

    if (dryRun) {
        console.log(`In ${destDir}, this script would...`);
    } else {
        console.log(`Generating API documentation using TypeDoc...`);
    }

    const packages = path.resolve(rootDir, srcDir);

    glob(packages, {realpath:true}, function(error, srcFiles) {
       
        srcFiles.forEach((srcPath) => {    
            
            var valid = true;

            var packageName = srcPath
                .split(path.sep)
                .pop();

            excludedPackages.forEach((excludedPackageName) => {
                if (packageName === excludedPackageName) {
                    console.log(chalk.yellow(`...skip generating TypeDoc API files for ${packageName}`));
                    valid = false;
                }
            });

            if(valid) {
                dryRun ? console.log(`...generate TypeDoc API files for ${packageName}`) : createAPIFiles(packageName, srcPath);
            }

        });

    });
}
218508
function(props) {
        var files = {};
        // Include all template files by default.
        helpers.expand({filter: 'isFile', dot: true}, [pathPrefix + '**']).forEach(function(obj) {
          // Get the source filepath relative to the template root.
          var src = obj.rel.slice(pathPrefix.length);
          // Get the destination filepath.
          var dest = init.renames[src];
          // Create a property for this file, but use src if dest evaulates
          // to false
          var processed = (dest) ? grunt.template.process(dest, {data: props, delimiters: 'init'}) : false;
          processed = (processed === 'false' || processed === '') ? false : processed;
          files[(processed) ? processed : src] = obj.rel;
        });
        // Exclude files with a value of false in rename.json.
        var exclusions = Object.keys(init.renames).filter(function(key) {
          var processed = (init.renames[key]) ? 
            grunt.template.process(init.renames[key], {data: props, delimiters: 'init'}) : false;
          processed = (processed === 'false' || processed === '') ? false : processed;
          return (processed === false);
        }).map(function(key) {
          return pathPrefix + key;
        });
        // Exclude all exclusion files by deleting them from the files object.
        if (exclusions.length > 0) {
          helpers.expand({filter: 'isFile', dot: true}, exclusions).forEach(function(obj) {
            // Get the source filepath relative to the template root.
            var src = obj.rel.slice(pathPrefix.length);
            // And remove that file from the files list.
            delete files[src];
          });
        }
        return files;
      }
563990
function () {
      this.cfg = {};

      // Copy from prompt settings
      Object.keys(this.settings).forEach(function (key) {
        this.cfg[key] = this.settings[key];
      }.bind(this));

      // Boolean config
      options.forEach(function (option) {
        var name = option.name;
        option.choices.forEach(function (choice) {
          var value = choice.value;
          switch (option.type) {
            case 'list':
              this.cfg[value] = value === this.cfg[name];
              break;
            case 'checkbox':
              this.cfg[value] = _.includes(this.cfg[name], value);
              break;
          }
        }.bind(this));
      }.bind(this));

      // Extra config
      this.cfg.slugName = _s.slugify(this.cfg.name);
      this.cfg.testing = this.cfg.mocha || this.cfg.jasmine;
      this.cfg.cssSourceMap = (this.cfg.css && this.cfg.autoprefixer) ||
                              this.cfg.sass ||
                              (this.cfg.less && (this.cfg.autoprefixer || this.cfg.cssmin));
      this.cfg.jsSourceMap = this.cfg.coffee;
    }
853773
function buildJS(src, filename, dest, applyHeader, forceIncludePaths) {
  dest = dest || config.dist.jsPath;
  applyHeader = applyHeader || false;
  forceIncludePaths = forceIncludePaths || false;

  return gulp.src(src)
    .pipe(gulpif(
      forceIncludePaths,
      include({
        includePaths: [
          path.dirname(src),
          __dirname,
          config.packagesPath
        ]
      }),
      include()
    ))
    .on('error', console.log) // eslint-disable-line no-console
    .pipe(babel())
    .pipe(uglify({
      output: {
        // try to preserve non-standard headers (e.g. from objectFitPolyfill)
        comments: /^(!|---)/
      }
    }))
    .pipe(gulpif(applyHeader, header(config.prj.header, {
      config: config
    })))
    .pipe(rename(filename))
    .pipe(gulp.dest(dest));
}
1026863
function prepareAppScriptsInfo(docDom) {
        // read index file, and getting target ts files.
        var appScripts = [];
        var $appScripts = $(docDom).find('script[type="lazy"]');
        var findAppJs = false;

        $appScripts.each(function () {
            var $scripts = getScriptElements($(this));
            $scripts.each(function () {
                var src = $(this).attr('src');
                if (src.match(/app.js$/i)) {
                    findAppJs = true;
                }
                appScripts.push(path.join(grunt.config.get('tmpdir'), src).replace(/\.js$/i, '.ts'));
            });
        });

        if (!findAppJs) {
            grunt.config.set('app_js_suffix', '-all');
        }

        // set app_scripts
        grunt.config.set('app_scripts', appScripts);
    }
40307
function copyJS() {
    let tasks = [];
    Object.keys(config).forEach((key) => {
        let val = config[key];
        tasks.push(gulp.src(val.src).pipe(gulp.dest(val.dest)));
    });

    return merge(tasks);
}
906419
function setup() {
    module('material.core', function($provide) {
      var $mdCompiler = { compile: angular.noop };
      $compilerSpy = spyOn($mdCompiler, 'compile');
      $themingSpy = jasmine.createSpy('$mdTheming');

      $provide.value('$mdCompiler', $mdCompiler);
      $provide.value('$mdTheming', $themingSpy);
    });
    inject(function($q, $compile, _$rootScope_, _$timeout_, _$material_) {
      $rootScope = _$rootScope_;
      $timeout = _$timeout_;
      $material = _$material_;

      $compilerSpy.and.callFake(function(opts) {
        var el = $compile(opts.template || "<div></div>");
        return $q(function(resolve){
          resolve({
            link: el,
            locals: {}
          });
          !$rootScope.$$phase && $rootScope.$apply();
        });
      });
    });
  }
697396
function concatPackages (packages, outDir, minified) {
  if (! outDir) outDir = path.join('.', 'build');

  if (!fs.existsSync(outDir)) fs.mkdirSync(outDir);
  var jsFileName = path.join(outDir, 'build.js');
  if (fs.existsSync(jsFileName)){
    fs.truncateSync(jsFileName, 0);
  }
  var cssFileName = path.join(outDir, 'build.css');
  if (fs.existsSync(cssFileName)){
    fs.truncateSync(cssFileName, 0);
  }
  _.each(packages, function (pack, i, l) {
    concatPackage(pack, outDir, minified);
  });
}
221892
function minifyApp(appNameMap, appContentMap) {
  let file = config.distDir + 'app.wxss';
  if (!utils.isFile(file)) {
    return;
  }
  let minified = new CleanCSS({ keepBreaks: true }).minify(fs.readFileSync(file, 'utf8')).styles;
  minified = minified.replace(/::?(after|before|first\-child|last\-child)/g, ':$1');
  let finalCssContent = '';
  minified.split('\n').forEach((line) => {
    let index = line.indexOf('{');
    let selectors = line.substr(0, index).split(',');
    let content = line.substr(index);

    selectors.forEach((selector) => {
      if (selector[0] !== '.') {
        finalCssContent += selector + content + '\n';
        return;
      }
      let className = selector.substr(1);
      if (!appNameMap[className]) {
        appNameMap[className] = {
          id: '',
          contents: []
        };
      }
      appNameMap[className].contents.push(content);
      if (!appContentMap[content]) {
        appContentMap[content] = [];
      }
      appContentMap[content].push(className);
    });
  });

  return function () {
    //console.log(appNameMap, appContentMap);
    console.log('minify'.green, path.normalize('dist/app.wxss').blue);
    for (let key in appNameMap) {
      let matchs = key.match(/(.*):+(after|before|first\-child|last\-child)$/);
      if (matchs && appNameMap[matchs[1]] && appNameMap[matchs[1]].id) {
        appNameMap[key].id = appNameMap[matchs[1]].id + ':' + matchs[2];
      }
    }
    for (let c in appContentMap) {
      let keys = [];
      appContentMap[c].forEach((key) => {
        if (appNameMap[key].id) {
          keys.push('.' + appNameMap[key].id);
          console.log(('\t.' + key).blue, '->', ('.' + appNameMap[key].id).cyan);
        } else if (config.classNames && config.classNames[key]) {
          keys.push('.' + key);
          console.log(('\t.' + key).blue, '->', ('.' + key).cyan);
        }
      });
      if (keys.length) {
        finalCssContent += keys.join(',') + c + '\n';
      }
    }
    finalCssContent = new CleanCSS({ keepBreaks: true }).minify(finalCssContent).styles;
    fs.writeFileSync(file, finalCssContent);
  };
}
57797
function copyHooks() {
		var src = path.join(__dirname, 'hooks');
		var dest = path.join(process.env.PWD, 'hooks');

		return pify(fs.copy.bind(fs), Promise)(path.join(__dirname, 'platforms.json'), path.join(dest, 'platforms.json'))
			.then(function () {
				memFsEditor.copyTpl(src, dest, options);

				return pify(memFsEditor.commit.bind(memFsEditor))();
			})
			.then(function () {
				// Make all the scripts executable in the Cordova project
				fs.readdirSync(src).forEach(function (hook) {
					var hookPath = path.join(dest, hook);

					fs.readdirSync(hookPath).forEach(function (script) {
						fs.chmodSync(path.join(hookPath, script), '755');
					});
				});
			});
	}
715801
function scripts (watch) {
  var bundler = browserify('./app/client.js', {
    debug: true,
    cache: {}
  });

  if (watch) {
    bundler = watchify(bundler)
  }

  bundler.require('./environment.json', {
    expose: 'environment'
  });

  exposeJS('./app').forEach(function (file) {
    bundler.require(file.path, {
      expose: file.expose
    });
  });

  bundler.transform(reactify);
  bundler.transform({ global: true }, envify);
  bundler.transform({ global: true }, uglifyify);

  /**
   * build application
   * @param {string} file
   */
  function rebundle (file) {
    var stream = bundler.bundle();
    if (file) {
      console.log('[gulp]', chalk.cyan('[watchify] rebundled due to:'), chalk.green(file));
    }

    console.log('[gulp]', chalk.cyan('[watchify] assets'), chalk.red('building'));
    stream
      .on('error', handleError('Browserify'))
      .pipe(source('isomorphic.js'))
      .pipe(buffer())
      .pipe(replace('{{ISOMORPHIC_ENV}}', args.name))
      .pipe(gulpIf(args.uglify, uglify()))
      .pipe(gulp.dest('./public')).on("end", function () {
        console.log('[gulp]', chalk.cyan('[watchify] assets'), chalk.green('complete'));
      });
  };

  bundler.on('update', rebundle);
  return rebundle();
}
64081
function buildExampleScripts(dev) {

  var dest = EXAMPLE_DIST_PATH;

  var opts = dev ? watchify.args : {};
  opts.debug = dev ? true : false;
  opts.hasExports = true;

  return function() {

    var common = browserify(opts),
      bundle = browserify(opts).require('./' + SRC_PATH + '/' + PACKAGE_FILE, { expose: PACKAGE_NAME }),
      example = browserify(opts).exclude(PACKAGE_NAME).add('./' + EXAMPLE_SRC_PATH + '/' + EXAMPLE_APP);

    DEPENDENCIES.forEach(function(pkg) {
      common.require(pkg);
      bundle.exclude(pkg);
      example.exclude(pkg);
    });

    if (dev) {
      watchBundle(common, 'common.js', dest);
      watchBundle(bundle, 'bundle.js', dest);
      watchBundle(example, 'app.js', dest);
    }

    return merge(
      doBundle(common, 'common.js', dest),
      doBundle(bundle, 'bundle.js', dest),
      doBundle(example, 'app.js', dest)
    );

  }

}
1274764
function IncludeMiddleware(options) {
  var self = this;

  // Initialize with passed in configuration or empty arrays.
  self.globalStyles = (options && options.globalStyles) ? options.globalStyles : [];
  self.globalScripts = (options && options.globalScripts) ? options.globalScripts : [];
  self.sectionDefinition = (options && options.sectionDefinition) ? options.sectionDefinition : [];
  self.pageDefinition = (options && options.pageDefinition) ? options.pageDefinition : [];

  // Initialize minified files.
  self.minified = (options && options.minified) ? options.minified : false;
  self.dirName = (options && options.dirName) ? (options.dirName) : null;
  
  // Objects that hold cached css and js files both full and minified.
  self.scriptFiles = {};
  self.styleFiles = {};

  // This looks really ugly. But the point here is to read all the css files that
  // are defined anywhere into memory, minify them in order to get them ready to 
  // go for actual requests.
  if (self.minified && self.dirName) {

    // Get a listing of folders underneath the directory given.
    self.dirs = getFoldersRecursive(self.dirName);

    // Loop through defined global styles.
    self.globalStyles.forEach(function(element, index, array) {
      var source = minify.readAndMinifyCSS(self.dirName + '/' + self.globalStyles[index], self.dirs);
      self.styleFiles[self.globalStyles[index]] = source;
    });

    // Loop through defined global scripts.
    self.globalScripts.forEach(function(element, index, array) {
      var source = minify.readAndMinifyJS(self.dirName + '/' + self.globalScripts[index]);
      self.scriptFiles[self.globalScripts[index]] = source;
    });

    // Loop through defined section definitions.
    self.sectionDefinition.forEach(function(sectionElement, sectionIndex, sectionArray) {

      // styles
      self.sectionDefinition[sectionIndex].styles.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyCSS(self.dirName + '/' + self.sectionDefinition[sectionIndex].styles[i], self.dirs);
        self.styleFiles[self.sectionDefinition[sectionIndex].styles[i]] = source;
      });

      // scripts
      self.sectionDefinition[sectionIndex].scripts.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyJS(self.dirName + '/' + self.sectionDefinition[sectionIndex].scripts[i]);
        self.scriptFiles[self.sectionDefinition[sectionIndex].scripts[i]] = source;
      });

    });

    // Loop through defined page definitions.
    self.pageDefinition.forEach(function(pageElement, pageIndex, pageArray) {

      // styles
      self.pageDefinition[pageIndex].styles.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyCSS(self.dirName + '/' + self.pageDefinition[pageIndex].styles[i], self.dirs);
        self.styleFiles[self.pageDefinition[pageIndex].styles[i]] = source;
      });

      // scripts
      self.pageDefinition[pageIndex].scripts.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyJS(self.dirName + '/' + self.pageDefinition[pageIndex].scripts[i]);
        self.scriptFiles[self.pageDefinition[pageIndex].scripts[i]] = source;
      });

    });

  }

  /**
   * Express middleware function that gets imports for the current 
   * page and attaches them to `res.locals` object, then calls next(). 
   */
  self.mwFn = function(req, res, next) {
    var imports = self.getImports(url.parse(req.url).pathname);
    res.locals.scripts = imports.scripts;
    res.locals.styles = imports.styles;
    next();
  };

  /**
   * 
   */
  self.mwFnMinified = function(req, res, next) {
    var imports = self.getImports(url.parse(req.url).pathname);
    res.locals.scripts = imports.scripts;
    res.locals.styles = imports.styles;

    res.locals.cssSource = '';
    res.locals.cssSourceMin = '';
    res.locals.jsSource = '';
    res.locals.jsSourceMin = '';

    res.locals.styles.forEach(function(el, index, arr) {
      res.locals.cssSource += self.styleFiles[res.locals.styles[index]].full;
      res.locals.cssSourceMin += self.styleFiles[res.locals.styles[index]].min;
    });

    res.locals.scripts.forEach(function(el, index, arr) {
      res.locals.jsSource += self.scriptFiles[res.locals.scripts[index]].full;
      res.locals.jsSourceMin += self.scriptFiles[res.locals.scripts[index]].min;
    });

    next();
  };

  /**
   * Takes in a url and finds a section configuration from what was 
   * passed in earlier. At this time it can only return 1 section 
   * configuration, or null if none are found.
   * 
   * // TODO: ability to return multiple section configs? 
   */
  self.getSectionConfig = function(url) {
    if (!url) return null;

    for (var i = 0; i < self.sectionDefinition.length; i++) {
      if (url.indexOf(self.sectionDefinition[i].url) > -1) {
        return self.sectionDefinition[i];
      }
    }
    return null;
  };

  /**
   * Breaks down the url and each of the page definitions that were
   * passed in, and determines if there's a match. This function can 
   * currently only return one page config. 
   * 
   * TODO: ability to return multiple page configs?
   */
  self.getPageConfig = function(url) {
      if (!url) return null;
      var urlParts = url.split("/");

      for (var i = 0; i < self.pageDefinition.length; i++) {
          var itPageParts = self.pageDefinition[i].url.split("/");

          if (urlParts.length === itPageParts.length) {
              var match = true;

              for (var j = 0; j < itPageParts.length; j++) {
                  if (itPageParts[j] === ":") continue;
                  if (itPageParts[j] !== urlParts[j]) match = false;
              }

              if (match) {
                return self.pageDefinition[i];
              }
          }
      }
      return null;
  };

  /**
   * Top-level function that uses `getSectionConfig` and `getPageConfig`.
   * This function combines all of the imports that should go with the
   * page including each of the three layers (global, section and page). 
   */
  self.getImports = function(url) {
    var styles = self.globalStyles;
    var scripts = self.globalScripts;

    // Find section, append styles and scripts if section found.
    var sectionConfig = self.getSectionConfig(url);
    if (sectionConfig) {
      if (sectionConfig.styles && Array.isArray(sectionConfig.styles))
        styles = styles.concat(sectionConfig.styles);
      if (sectionConfig.scripts && Array.isArray(sectionConfig.scripts))
        scripts = scripts.concat(sectionConfig.scripts);
    }

    // Find page, append styles and scripts if page found.
    var pageConfig = self.getPageConfig(url);
    if (pageConfig) {
      if (pageConfig.styles && Array.isArray(pageConfig.styles))
        styles = styles.concat(pageConfig.styles);
      if (pageConfig.scripts && Array.isArray(pageConfig.scripts))
        scripts = scripts.concat(pageConfig.scripts);
    }

    // Return the entire list of styles, scripts and configs.
    return {
      styles: styles,
      scripts: scripts,
      pageConfig: pageConfig,
      sectionConfig: sectionConfig
    };
  };

  // Return myself.
  return self;
}
807400
function(files, props, options) {
        options = grunt.utils._.defaults(options || {}, {
          process: function(contents) {
            return grunt.template.process(contents, props, 'init');
          }
        });
        Object.keys(files).forEach(function(destpath) {
          var o = Object.create(options);
          var srcpath = files[destpath];
          // If srcpath is relative, match it against options.noProcess if
          // necessary, then make srcpath absolute.
          var relpath;
          if (srcpath && !grunt.file.isPathAbsolute(srcpath)) {
            if (o.noProcess) {
              relpath = srcpath.slice(pathPrefix.length);
              o.noProcess = grunt.file.isMatch(o.noProcess, relpath);
            }
            srcpath = grunt.task.getFile(srcpath);
          }
          // Copy!
          init.copy(srcpath, destpath, o);
        });
      }