How to use the @statusfy/common.logger.error function in @statusfy/common

To help you get started, we’ve selected a few @statusfy/common 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 bazzite / statusfy / packages / @statusfy / core / lib / config / load.js View on Github external
const config = defaultsDeep(configContent, defaultConfig);
  config.sourceDir = sourceDir;

  if (!config.name) {
    config.name = slugify(config.title);
  }

  if (!config.short_title) {
    config.short_title = config.title;
  }

  // Run Validation
  try {
    errors = validateConfig(config);
  } catch (error) {
    logger.error(error);
    process.exit(1);
  }

  return {
    config,
    errors
  };
};
github bazzite / statusfy / packages / @statusfy / core / lib / config / generate.js View on Github external
esm(path.join(__dirname, "../../nuxt.config.js"))
  );
  const loadedConfig = loadConfig(sourceDir);

  const siteConfig = loadedConfig.config;
  const siteConfigErrors = loadedConfig.errors;

  try {
    if (siteConfigErrors && siteConfigErrors.length > 0) {
      logger.fatal(
        `Your site configuration is invalid:\n${siteConfigErrors.join("\n")}`
      );
      process.exit(1);
    }
  } catch (error) {
    logger.error(error);
    process.exit(1);
  }

  // General
  nuxtConfig.dev = !(process.env.NODE_ENV === "production");
  nuxtConfig.rootDir = path.join(__dirname, "..", "..");
  nuxtConfig.buildDir = path.join(sourceDir, ".statusfy");
  nuxtConfig.modulesDir.push(path.join(sourceDir, "node_modules"));
  nuxtConfig.modulesDir = [...new Set(nuxtConfig.modulesDir)];

  // Style
  nuxtConfig.loading.color = colors.black;
  nuxtConfig.meta.theme_color = colors.black;

  // Statusfy module configuration
  nuxtConfig.server = {
github bazzite / statusfy / packages / @statusfy / core / lib / init.js View on Github external
checkFiles.forEach(file => {
    if (fs.existsSync(path.join(outDir, file))) {
      logger.error(`Make sure your destination directory is empty.\n${outDir}`);
      process.exit(0);
    }
  });
github bazzite / statusfy / packages / @statusfy / core / lib / delete-incident.js View on Github external
for (let j = 0; j < locales.length; j++) {
          const locale = locales[j];
          const localeIncidentPath = path.join(
            contentDir,
            config.defaultLocale !== locale ? locale : "",
            incident.name
          );
          const exists = await fse.pathExists(localeIncidentPath);

          if (exists) {
            try {
              await fse.remove(localeIncidentPath);
              deletedFiles.push(localeIncidentPath);
            } catch (error) {
              logger.error(error);
            }
          } else {
            logger.warn(`This file couldn't be found:\n${localeIncidentPath}`);
          }
        }

        if (deletedFiles.length > 0) {
          const prefix =
            deletedFiles.length === 1
              ? "This file was successfully deleted"
              : "These files were successfully deleted";

          logger.success(`${prefix}: \n${deletedFiles.join("\n")}`);
        }
      }
    } catch (error) {
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
const copyPublicFiles = async (src, dest) => {
  if (src) {
    logger.debug(`Copying public files ${dest}`);

    try {
      await fse.copy(src, dest);
    } catch (error) {
      logger.error(`Couldn't copy public files ${dest}`);
      logger.error(error);
    }
  }
};
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
const copyPublicFiles = async (src, dest) => {
  if (src) {
    logger.debug(`Copying public files ${dest}`);

    try {
      await fse.copy(src, dest);
    } catch (error) {
      logger.error(`Couldn't copy public files ${dest}`);
      logger.error(error);
    }
  }
};
github bazzite / statusfy / packages / @statusfy / core / lib / new-incident.js View on Github external
config.locales.forEach(locale => {
        const contentPath = path.join(sourceDir, config.content.dir);
        let filePath;

        if (locale.code === config.defaultLocale) {
          filePath = path.join(contentPath, fileName + ".md");
        } else {
          filePath = path.join(contentPath, locale.code, fileName + ".md");
        }

        if (fs.existsSync(filePath)) {
          logger.error(
            `An incident with a similar title already exists.\n${filePath}`
          );
          error = true;
        } else {
          fse.outputFileSync(
            filePath,
            `${content}\n\n`
          );

          createdFiles.push(path.relative(contentPath, filePath));

          if (answers.open) {
            opener(filePath);
          }
        }
      });
github bazzite / statusfy / packages / @statusfy / core / lib / update-incident.js View on Github external
severity,
                affectedsystems,
                resolved
              };

              const content = generateIncident(
                newMatter,
                data.content,
                config.content.frontMatterFormat
              );

              await fse.writeFile(localeIncidentPath, content);

              updatedFiles.push(localeIncidentPath);
            } catch (error) {
              logger.error(error);
            }
          } else {
            logger.warn(`This file couldn't be found:\n${localeIncidentPath}`);
          }
        }

        if (updatedFiles.length > 0) {
          const prefix =
            updatedFiles.length === 1
              ? "This file was successfully updated"
              : "These files were successfully updated";

          logger.success(`${prefix}: \n${updatedFiles.join("\n")}`);
        }
      }
    } catch (error) {
github bazzite / statusfy / packages / @statusfy / core / lib / content / database.js View on Github external
if (!incident.modified) {
            try {
              incident.modified = new Date(
                getGitLastUpdatedTimeStamp(filePath)
              ).toISOString();
            } catch (error) {
              incident.modified = null;
            }
          }

          allIncidents.push(incident);
        }
      }
    } catch (error) {
      logger.error(error);
    }
  }

  return allIncidents;
};