Logs the results of the latest compilation of the project
@param {Project} project
@return {Promise<void>}
189842
function checkProjectCompilations(project) {
	return waitForCompletion(project)
	.then(() => {
		for (const platform in project.compilations) {
			if (!project.compilations.hasOwnProperty(platform)) {
				continue;
			}
			const compilation = project.compilations[platform];
			if (compilation.isReady()) {
				console.info(compilation.platform + " compilation from " + project.name + " project: " + project.id + " is completed.");
			} else if (compilation.isErred()) {
				console.error(compilation.platform + " compilation from " + project.name + " project: " + project.id + " is erred.");
				console.error("ERROR LOG of the " + compilation.platform + " platform:");
				console.error(compilation.error);
			} else {
				console.error(compilation.platform + " compilation from " + project.name + " project: " + project.id +
					" was ignored. Status: " + compilation.status + ".");
			}
		}
		return undefined;
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
1046560
function usage() {
        console.log("Audit installed packages and their dependencies to identify known");
        console.log("vulnerabilities.");
        console.log();
        console.log("If a package.json file is specified as an argument, only the dependencies in");
        console.log("the package file will be audited.");
        console.log();
        console.log(colors.bold.yellow("Limitations"));
        console.log();
        console.log("As this program depends on the OSS Index database, network access is");
        console.log("required. Connection problems with OSS Index will result in an exception.");
        console.log();
        console.log("The vulnerabilities do not always indicate all (or any) of the affected");
        console.log("versions it is best to read the vulnerability text itself to determine");
        console.log("whether any particular version is known to be vulnerable.");
}
1218988
function handler(opts) {
	Object.assign(values, opts);

	let templateMeta;
	let metalsmith;

	return Promise.resolve()

		// Resolve project name & folder
		.then(() => {
			values.inPlace = false;
			if (!values.projectName || values.projectName === ".") {
				values.inPlace = true;
				values.projectName = path.relative("../", process.cwd());
			}
			values.projectPath = path.resolve(values.projectName);
		})
		// check for template mapping
		.then(() => {
			return new Promise((resolve, reject) => {
				const configPath = path.join(os.homedir(), ".moleculer-templates.json");
				fs.exists(configPath, configExists => {
					if (configExists) {
						fs.readFile(configPath, (err, config) => {
							if (err) {
								reject(`Error reading config file from ${configPath}`);
							}
							values.aliasedTemplates = JSON.parse(config);
							resolve();
						});
					} else {
						resolve();
					}
				});
			});
		})
		// Resolve template URL from name
		.then(() => {
			let { templateName, templateRepo, aliasedTemplates } = values;
			if (aliasedTemplates[templateName]) {
				templateName = aliasedTemplates[templateName];
			}

			if (/^[./]|(^[a-zA-Z]:)/.test(templateName)) {
				values.tmp = path.isAbsolute(templateName) ? templateName : path.normalize(path.join(process.cwd(), templateName));

				console.log("Local template:", values.tmp);
			} else {

				if (templateName.indexOf("/") === -1) {
					templateRepo = `moleculerjs/moleculer-template-${templateName}`;
				} else {
					templateRepo = templateName;
				}

				values.templateRepo = templateRepo;
				values.tmp = getTempDir(templateName, true);

				console.log("Template repo:", templateRepo);
			}
		})

		// Download template
		.then(() => {
			if (values.templateRepo) {
				return new Promise((resolve, reject) => {
					let spinner = ora("Downloading template");
					spinner.start();
					download(values.templateRepo, values.tmp, {}, err => {
						spinner.stop();

						if (err)
							return reject(`Failed to download repo from '${values.templateRepo}'!`, err);

						resolve();
					});

				});
			}
		})

		// Prompt questions
		.then(() => {
			const { tmp } = values;
			if (fs.existsSync(path.join(tmp, "meta.js"))) {
				templateMeta = require(path.join(tmp, "meta.js"))(values);
				if (templateMeta.questions) {
					return inquirer.prompt(templateMeta.questions).then(answers => Object.assign(values, answers));
				}
			} else {
				templateMeta = {};
			}
		})

		// Check target directory
		.then(() => {
			if (fs.existsSync(values.projectPath)) {
                if (templateMeta.promptForProjectOverwrite === false) return;
				return inquirer.prompt([{
					type: "confirm",
					name: "continue",
					message: chalk.yellow.bold(`The '${values.projectName} directory is exists! Continue?`),
					default: false
				}]).then(answers => {
					if (!answers.continue)
						process.exit(0);
				});
			} else {
				console.log(`Create '${values.projectName}' folder...`);
				mkdirp(values.projectPath);
			}
		})

		// Build template
		.then(() => {
			return new Promise((resolve, reject) => {
				metalsmith = Metalsmith(values.tmp);
				Object.assign(metalsmith.metadata(), values);

				// Register custom template helpers
				if (templateMeta.helpers)
					Object.keys(templateMeta.helpers).map(key => Handlebars.registerHelper(key, templateMeta.helpers[key]));

				// metalsmith.before
				if (templateMeta.metalsmith && _.isFunction(templateMeta.metalsmith.before))
					templateMeta.metalsmith.before.call(templateMeta, metalsmith);

				metalsmith
					.use(filterFiles(templateMeta.filters, templateMeta.skip))
					.use(renderTemplate(templateMeta.skipInterpolation));

				// metalsmith.after
				if (templateMeta.metalsmith && _.isFunction(templateMeta.metalsmith.after))
					templateMeta.metalsmith.after.call(templateMeta, metalsmith);

				// Build
				metalsmith
					.clean(false)
					.source(values.templateDir)
					.destination(values.projectPath)
					.build(err => {
						if (err)
							return reject(err);

						// metalsmith.complete
						if (templateMeta.metalsmith && _.isFunction(templateMeta.metalsmith.complete))
							templateMeta.metalsmith.complete.call(templateMeta, metalsmith);

						resolve();
					});

			});
		})

		// Run 'npm install'
		.then(() => {
			return inquirer.prompt([{
				type: "confirm",
				name: "install",
				message: "Would you like to run 'npm install'?",
				default: true
			}]).then(({ install }) => {
				if (install) {
					console.log("\nRunning 'npm install'...");
					return exeq([
						"cd " + values.projectPath,
						"npm install"
					]);
				}
			});
		})

		// Show completeMessage
		.then(() => {
			return new Promise((resolve, reject) => {
				if (templateMeta.completeMessage)
					render(templateMeta.completeMessage, metalsmith.metadata(), (err, res) => {
						if (err)
							return reject(err);

						console.log(chalk.green.bold("\n" + res.split(/\r?\n/g).map(line => "   " + line).join("\n")));


						resolve();
					});
				else {
					console.log(chalk.green.bold("\nDone!"));
					resolve();
				}

			});
		})

		// Error handler
		.catch(err => fail(err));
}
22386
function buildServer() {
  console.log();
  console.log(`${chalk.cyan('SERVER-SIDE')}`);
  console.log('===========================================================');
  fs.emptyDirSync(paths.appServerBuild);
  console.log('Creating a server-side production build...');

  let compiler = webpack(serverlize(paths, config));
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      if (err) {
        return reject(err);
      } 
      const messages = formatWebpackMessages(stats.toJson({}, true));
      if (messages.errors.length) {
        // Only keep the first error. Others are often indicative
        // of the same problem, but confuse the reader with noise.
        if (messages.errors.length > 1) {
          messages.errors.length = 1;
        }
        return reject(new Error(messages.errors.join('\n\n')));
      }
      if (
        process.env.CI &&
        (typeof process.env.CI !== 'string' ||
          process.env.CI.toLowerCase() !== 'false') &&
        messages.warnings.length
      ) {
        console.log(
          chalk.yellow(
            '\nTreating warnings as errors because process.env.CI = true.\n' +
              'Most CI servers set it automatically.\n'
          )
        );
        return reject(new Error(messages.warnings.join('\n\n')));
      }
      return resolve({
        stats,
        warnings: messages.warnings,
      });
    });
  }).then(
    ({ stats, warnings }) => {
      if (warnings.length) {
        console.log(chalk.yellow('Compiled with warnings.\n'));
        console.log(warnings.join('\n\n'));
        console.log(
          '\nSearch for the ' +
            chalk.underline(chalk.yellow('keywords')) +
            ' to learn more about each warning.'
        );
        console.log(
          'To ignore, add ' +
            chalk.cyan('// eslint-disable-next-line') +
            ' to the line before.\n'
        );
      } else {
        console.log(chalk.green('Compiled successfully.\n'));
      }
      console.log(`The ${chalk.cyan(path.relative(process.cwd(), paths.appServerBuild))} folder is ready.`);
      console.log(`You may run it in ${chalk.cyan('node')} environment`);
      console.log();
      console.log(`  ${chalk.cyan('node')} ${chalk.cyan(path.relative(process.cwd(), paths.appServerBuild))}`);
      console.log();
    },
    err => {
      console.log(chalk.red('Failed to compile.\n'));
      printBuildError(err);
      process.exit(1);
    }
  );
}
1311493
function log(err, pkg, tree) {
      var list
        ;

      if (err) {
        throw err;
      }

      // puts the list in the correct order
      list = reduceTree(tree);
      // pop off the bottom (this local package)
      list.pop();

      installAll(list);
    }
1263384
function(version) {
  var result;
  /** local */
  var ensure = function(key) {
    return function(r) {
      if (r && !r[key]) { throw new Error('result missing ' + key); }
      return r;
    };
  };
  return plugins.first(function(plugin) {
    return Promise.resolve()
    .then(function() { return plugin.match(version); })
    .then(ensure('command'))
    .then(ensure('version'))
    .then(function(r) { return (result = r); });
  })
  .then(function(plugin) {
    return result && _.extend({ plugin: plugin }, result);
  });
}
26916
function dist() {
  process.env.NODE_ENV = 'production';
  return clean().then(() => {
    return Promise.all([
      compile({minify: true, checkTypes: false, isProdBuild: true}),
    ]).then(() => {
      // Push main "min" files to root to make them available to npm package.
      fs.copySync('./dist/activities.min.js', './activities.min.js');
      fs.copySync('./dist/activities.min.js.map', './activities.min.js.map');
      // Check types now.
      return compile({minify: true, checkTypes: true});
    }).then(() => {
      return rollupActivities('./index.js', 'activities.js');
    }).then(() => {
      return rollupActivities('./index-ports.js', 'activity-ports.js');
    }).then(() => {
      return rollupActivities('./index-hosts.js', 'activity-hosts.js');
    });
  });
}
804258
function transpileAot() {
  // https://stackoverflow.com/questions/36897877/gulp-error-the-following-tasks-did-not-complete-did-you-forget-to-signal-async
  return new Promise(function(resolve, reject) {
    // Need to capture the exit code
    exec('node_modules/.bin/ngc -p tsconfig-aot.json', function (err, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);
      if (err !== null) {
        process.exit(1);
      }
    });
    resolve();
  });
}
1216993
function bindServe() {
  return new Promise((resolve, reject) => {

    // Logging "warnings" but not rejecting test
    webpackServer.stderr.on('data', data => log(data));
    webpackServer.stdout.on('data', data => {
      const dataAsString = log(data);
      if (dataAsString.indexOf('webpack: Compiled successfully.') > -1) {
        resolve(_port);
      }
      if (dataAsString.indexOf('webpack: Failed to compile.') > -1) {
        reject(dataAsString);
      }
    });
  });
}
941175
function compile(emit) {
    self.bundler.run(function(err, stats) {

      // Error handling
      if (err || stats.compilation.errors.length) {

        // Over time we expect webpack's resolution system to change. We choose to attempt
        // package installations by catching errors so as to maximize forward-compability.
        // Should the error reporting format change, we will need to update our resolution system.
        var errors = stats.toJson({ errorDetails: true }).errors;
        var recompile = errors.reduce(function(recompile, err) {
          if (Resolver.isMissingModuleError(err))
            recompile = Resolver.installPackageFromError(err);
          return recompile;
        }, false);
        if (recompile) return compile();

        if (err) global.shipp.logger.error(err);
        if (stats.compilation.errors.length) global.shipp.logger.error(stats.toString({ errorDetails: true }));

        return;

      }

      global.shipp.log("Bundled", self.path);
      if (emit) global.shipp.emit("route:refresh", { route: self.path });

    });
  }
911766
function (version) {
        return __awaiter(this, void 0, void 0, function* () {
            let versions = yield ForestInternal.queryVersionCache();
            for (let ver of versions) {
                if (ver.expanded === version) {
                    return Promise.resolve(ver);
                }
            }
            throw new ForestError(Errors.VersionNoExactMatch, `Local cache does not contain ${version}`);
        });
    }
85516
function downloadProjectCompilationsWithId(projectId, outputDir) {
	return fetchProject(projectId)
	.then((project) => {
		return downloadProjectCompilations(project, outputDir);
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
756285
function build(previousSizeMap) {
  console.log('Creating an optimized production build...');
  webpack(config).run((err, stats) => {
    if (err) {
      printErrors('Failed to compile.', [err]);
      process.exit(1);
    }

    if (stats.compilation.errors.length) {
      printErrors('Failed to compile.', stats.compilation.errors);
      process.exit(1);
    }

    if (process.env.CI && stats.compilation.warnings.length) {
      printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings);
      process.exit(1);
    }

    console.log(chalk.green('Compiled successfully.'));
    console.log();

    console.log('File sizes after gzip:');
    console.log();
    printFileSizes(stats, previousSizeMap);
    console.log();

    const openCommand = process.platform === 'win32' ? 'start' : 'open';
    const appPackage = require(paths.appPackageJson);
    const publicUrl = paths.publicUrl;
    const publicPath = config.output.publicPath;
    const publicPathname = url.parse(publicPath).pathname;
    if (publicUrl && publicUrl.indexOf('.github.io/') !== -1) {
      // "homepage": "http://user.github.io/project"
      console.log(`The project was built assuming it is hosted at ${chalk.green(publicPathname)}.`);
      console.log(`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`);
      console.log();
      console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
      console.log(`To publish it at ${chalk.green(publicUrl)}, run:`);
      // If script deploy has been added to package.json, skip the instructions
      if (typeof appPackage.scripts.deploy === 'undefined') {
        console.log();
        if (useYarn) {
          console.log(`  ${chalk.cyan('yarn')} add --dev gh-pages`);
        } else {
          console.log(`  ${chalk.cyan('npm')} install --save-dev gh-pages`);
        }
        console.log();
        console.log(`Add the following script in your ${chalk.cyan('package.json')}.`);
        console.log();
        console.log(`    ${chalk.dim('// ...')}`);
        console.log(`    ${chalk.yellow('"scripts"')}: {`);
        console.log(`      ${chalk.dim('// ...')}`);
        console.log(`      ${chalk.yellow('"predeploy"')}: ${chalk.yellow('"npm run build",')}`);
        console.log(`      ${chalk.yellow('"deploy"')}: ${chalk.yellow('"gh-pages -d build"')}`);
        console.log('    }');
        console.log();
        console.log('Then run:');
      }
      console.log();
      console.log(`  ${chalk.cyan(useYarn ? 'yarn' : 'npm')} run deploy`);
      console.log();
    } else if (publicPath !== '/') {
      // "homepage": "http://mywebsite.com/project"
      console.log(`The project was built assuming it is hosted at ${chalk.green(publicPath)}.`);
      console.log(`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`);
      console.log();
      console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
      console.log();
    } else {
      if (publicUrl) {
        // "homepage": "http://mywebsite.com"
        console.log(`The project was built assuming it is hosted at ${chalk.green(publicUrl)}.`);
        console.log(`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`);
        console.log();
      } else {
        // no homepage
        console.log('The project was built assuming it is hosted at the server root.');
        console.log(`To override this, specify the ${chalk.green('homepage')} in your ${chalk.cyan('package.json')}.`);
        console.log('For example, add this to build it for GitHub Pages:');
        console.log();
        console.log(`  ${chalk.green('"homepage"')}${chalk.cyan(': ')}${chalk.green('"http://myname.github.io/myapp"')}${chalk.cyan(',')}`);
        console.log();
      }
      const build = path.relative(process.cwd(), paths.appBuild);
      console.log(`The ${chalk.cyan(build)} folder is ready to be deployed.`);
      console.log('You may also serve it locally with a static server:');
      console.log();
      if (useYarn) {
        console.log(`  ${chalk.cyan('yarn')} global add pushstate-server`);
      } else {
        console.log(`  ${chalk.cyan('npm')} install -g pushstate-server`);
      }
      console.log(`  ${chalk.cyan('pushstate-server')} ${build}`);
      console.log(`  ${chalk.cyan(openCommand)} http://localhost:${process.env.PORT || 9000}`);
      console.log();
    }
  });
}
286444
function log(patch) {
		var mw = (patch || core.base());
		mw.enabled = true;
		// let's be gentle
		if (console) {
			mw.writeln = function (str) {
				if (mw.enabled) {
					console.log(String(str));
				}
			};
		}
		else {
			mw.writeln = function (/*str*/) {
				// ignore?
			};
		}
		if (!patch) {
			mw.toString = function () {
				return '<miniwrite-log>';
			};
		}
		return mw;
	}
547307
function checkProjectCompilationsWithId(projectId) {
	return fetchProject(projectId)
	.then((project) => {
		return checkProjectCompilations(project);
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
1063761
function (msg) {

            if (!isLog()) {
                return undefined;
            }

            if (msg) {
                console.log(_utils.now() + " " + msg);
                this.log2file(msg);
            }
        }
156631
function(done, packageAll) {

      // Detect any new file or modified files.
      var metadataAction = force.evaluateProjectFiles(opt, packageAll);

      // Clear the meta data output directory.
      force.deletePackageOutput(opt, false);

      // Check to see if any file changes were detected.
      if (Object.keys(metadataAction).length == 0) {
        // Silently return without an error when forcePackageContinueSilent is true
        if (opt.forcePackageContinueSilent) {
          done();
          return;
        }

        var msg = 'No new or modified files detected.';

        // Throw a gulp error to note no file changes detected.
        if (gutil !== undefined && gutil !== null)
          throw new gutil.PluginError(gulpPluginName, msg, { showProperties: false, showStack: false });

        // Return an error to gulp.
        console.log(msg);
        done(msg);

        return;
      }

      // Generate package folder structure.
      force.generatePackageStructure(opt, metadataAction);

      done();

    }