How to use corvid-local-logger - 10 common examples

To help you get started, we’ve selected a few corvid-local-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix-incubator / corvid / packages / corvid-cli / src / utils / exitProcess.js View on Github external
const exitWithSuccess = async message => {
  if (message) {
    console.log(chalk.green(message)); // eslint-disable-line no-console
  }
  await logger.close();
  await killAllChildProcesses();
  process.exit(0);
};
github wix-incubator / corvid / packages / corvid-cli / src / utils / exitProcess.js View on Github external
const exitWithError = async error => {
  if (error instanceof UserError) {
    const coloredErrorMessage = colorRedIfNotYetColored(error.message);
    console.error(coloredErrorMessage); // eslint-disable-line no-console
  } else if (error instanceof EditorError) {
    logger.error(error);
    if (error.userMessage) {
      const coloredErrorMessage = colorRedIfNotYetColored(error.userMessage);
      console.error(coloredErrorMessage); // eslint-disable-line no-console
    }
  } else {
    logger.error(error);
  }

  await logger.close();
  await killAllChildProcesses();
  process.exit(1);
};
github wix-incubator / corvid / packages / corvid-local-server / src / server.js View on Github external
async function startServer(siteRootPath, options) {
  logger.info(
    getMessage("Server_Start_Log", { path: path.resolve(siteRootPath) })
  );
  const siteSrcPath = projectPaths.siteSrcPath(siteRootPath);
  await fs.ensureDir(siteSrcPath);
  const isEmpty = await isEmptyDir(siteSrcPath);
  const isWix = await fs.exists(
    path.join(siteRootPath, ".corvid", "corvidrc.json")
  ); // TEMPORARY
  const siteBackupPath = projectPaths.backupPath(siteRootPath);
  const hasBackup = await fs.exists(siteBackupPath);

  if (hasBackup) {
    logger.info(getMessage("Server_Backup_Found_Log"));
    throw new UserError("BACKUP_FOLDER_EXISTS");
  }

  if (isEdit(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Edit_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_EDIT_NON_WIX_SITE");
    }
    if (isEmpty) {
      logger.info(getMessage("Server_Edit_Empty_Site_Log"));
      throw new UserError("CAN_NOT_EDIT_EMPTY_SITE");
    }
  }

  if (isClone(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Clone_Project_Not_Found_Log"));
github wix-incubator / corvid / packages / corvid-local-server / src / server.js View on Github external
const isEmpty = await isEmptyDir(siteSrcPath);
  const isWix = await fs.exists(
    path.join(siteRootPath, ".corvid", "corvidrc.json")
  ); // TEMPORARY
  const siteBackupPath = projectPaths.backupPath(siteRootPath);
  const hasBackup = await fs.exists(siteBackupPath);

  if (hasBackup) {
    logger.info(getMessage("Server_Backup_Found_Log"));
    throw new UserError("BACKUP_FOLDER_EXISTS");
  }

  if (isEdit(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Edit_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_EDIT_NON_WIX_SITE");
    }
    if (isEmpty) {
      logger.info(getMessage("Server_Edit_Empty_Site_Log"));
      throw new UserError("CAN_NOT_EDIT_EMPTY_SITE");
    }
  }

  if (isClone(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Clone_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_CLONE_NON_WIX_SITE");
    }
    if (!isEmpty) {
      logger.info(getMessage("Server_Clone_Project_Not_Empty_Site_Log"));
      throw new UserError("CAN_NOT_PULL_NON_EMPTY_SITE");
    }
github wix-incubator / corvid / packages / corvid-cli / src / cli.js View on Github external
const { killAllChildProcesses } = require("./utils/electron");

notifyOnUpdatedPackages();

// eslint-disable-next-line no-console
console.log(chalk.yellow(getMessage("Cli_Description_Yellow")));
// eslint-disable-next-line no-console
console.log(getMessage("Cli_Description"));
process.on("exit", () => killAllChildProcesses());
process.on("SIGINT", () => killAllChildProcesses());
process.on("SIGTERM", () => killAllChildProcesses());

const fullCommand = process.argv.slice(2).join(" ");

logger.info(`running [${fullCommand}]`);
logger.addSessionData({
  command: process.argv[2],
  fullCommand
});
sessionData.on(["msid", "uuid"], (metasiteId, userId) =>
  logger.addSessionData({ metasiteId, userId })
);

require("yargs")
  .usage("Usage: $0  [options]")
  .commandDir("commands")
  .help("help")
  .strict()
  .demandCommand().argv;
github wix-incubator / corvid / packages / corvid-local-server / src / server.js View on Github external
const siteBackupPath = projectPaths.backupPath(siteRootPath);
  const hasBackup = await fs.exists(siteBackupPath);

  if (hasBackup) {
    logger.info(getMessage("Server_Backup_Found_Log"));
    throw new UserError("BACKUP_FOLDER_EXISTS");
  }

  if (isEdit(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Edit_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_EDIT_NON_WIX_SITE");
    }
    if (isEmpty) {
      logger.info(getMessage("Server_Edit_Empty_Site_Log"));
      throw new UserError("CAN_NOT_EDIT_EMPTY_SITE");
    }
  }

  if (isClone(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Clone_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_CLONE_NON_WIX_SITE");
    }
    if (!isEmpty) {
      logger.info(getMessage("Server_Clone_Project_Not_Empty_Site_Log"));
      throw new UserError("CAN_NOT_PULL_NON_EMPTY_SITE");
    }
  }

  if (isPullForce(options)) {
    if (!isWix) {
github wix-incubator / corvid / packages / corvid-cli / src / apps / pull.js View on Github external
client.on("user-message", message => {
        logger.info(getMessage("Pull_User_Message_Log", { message }));
        console.log(message);
      });
github wix-incubator / corvid / packages / corvid-cli / src / apps / open-editor.js View on Github external
client.on("user-message", message => {
        logger.info(getMessage("OpenEditor_User_Message_Log", { message }));
        console.log(message);
      });
github wix-incubator / corvid / packages / corvid-local-server / src / server.js View on Github external
throw new UserError("CAN_NOT_EDIT_NON_WIX_SITE");
    }
    if (isEmpty) {
      logger.info(getMessage("Server_Edit_Empty_Site_Log"));
      throw new UserError("CAN_NOT_EDIT_EMPTY_SITE");
    }
  }

  if (isClone(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_Clone_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_CLONE_NON_WIX_SITE");
    }
    if (!isEmpty) {
      logger.info(getMessage("Server_Clone_Project_Not_Empty_Site_Log"));
      throw new UserError("CAN_NOT_PULL_NON_EMPTY_SITE");
    }
  }

  if (isPullForce(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_PullForce_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_PULL_NON_WIX_SITE");
    }
    await fs.emptyDir(siteSrcPath);
  }

  if (isPullMove(options)) {
    if (!isWix) {
      logger.info(getMessage("Server_PullMove_Project_Not_Found_Log"));
      throw new UserError("CAN_NOT_PULL_NON_WIX_SITE");
    }
github wix-incubator / corvid / packages / corvid-cli / src / utils / corvid-config.js View on Github external
fs.readFile(configFilePath(dir), (exc, config) => {
      if (exc) {
        if (exc.code === "ENOENT") {
          reject(
            new UserError(
              getMessage("CorvidConfig_No_Project_Error", {
                dir: path.resolve(dir)
              })
            )
          );
        } else {
          reject(exc);
        }
      } else {
        resolve(config);
      }
    });
  });