How to use the corvid-local-logger.UserError function in corvid-local-logger

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-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-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-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);
      }
    });
  });
github wix-incubator / corvid / packages / corvid-local-server / src / server.js View on Github external
const startInCloneMode = (
  siteRootPath,
  options = { override: false, move: false }
) => {
  if (options.override && options.move) {
    throw new UserError(getMessage("Server_Override_And_Move_Error"));
  }
  let type = "CLONE";
  if (options.move) {
    type = "MOVE_PULL";
  }
  if (options.override) {
    type = "FORCE_PULL";
  }
  return startServer(siteRootPath, {
    type
  });
};
const startInEditMode = siteRootPath =>
github wix-incubator / corvid / packages / corvid-cli / src / commands / pull.js View on Github external
error: error => {
          spinner.fail();
          const errorMessage = getMessage(error);
          if (errorMessage) {
            if (error === "CAN_NOT_PULL_NON_EMPTY_SITE") {
              reject(
                new UserError(`${chalk.red(
                  getMessage("Pull_Command_Not_Empty_Red_Log")
                )}

                ${chalk(getMessage("Pull_Command_Not_Empty_Log"))}`)
              );
            } else {
              reject(new UserError(errorMessage));
            }
          } else {
            reject(new Error(error));
          }
        }
      },
github wix-incubator / corvid / packages / corvid-cli / src / commands / pull.js View on Github external
error: error => {
          spinner.fail();
          const errorMessage = getMessage(error);
          if (errorMessage) {
            if (error === "CAN_NOT_PULL_NON_EMPTY_SITE") {
              reject(
                new UserError(`${chalk.red(
                  getMessage("Pull_Command_Not_Empty_Red_Log")
                )}

                ${chalk(getMessage("Pull_Command_Not_Empty_Log"))}`)
              );
            } else {
              reject(new UserError(errorMessage));
            }
          } else {
            reject(new Error(error));
          }
        }
      },
github wix-incubator / corvid / packages / corvid-local-server / src / server.js View on Github external
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");
    }
    const snapshotFolder = path.join(
      siteRootPath,
      ".corvid",
      "snapshots",
      Date.now().toString()
    );