How to use @statusfy/common - 10 common examples

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 / config / generate.js View on Github external
module.exports = function generateConfig(sourceDir, cliOptions) {
  /**
   * @type { import("@nuxt/types").Configuration }
   */
  const nuxtConfig = Object.assign(
    {},
    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)];
github bazzite / statusfy / packages / @statusfy / core / lib / build.js View on Github external
// Close function
  const close = () => {
    // In analyze mode wait for plugin
    // emitting assets and opening browser
    if (typeof nuxtConfig.build.analyze === "object") {
      return;
    }

    process.exit(0);
  };

  try {
    await builder.build();
    close();
  } catch (error) {
    logger.fatal(error);
  }
};
github bazzite / statusfy / packages / @statusfy / core / lib / init.js View on Github external
// Avoid overwrite user files
  const checkFiles = ["package.json", "config.js", "config.yml", "config.toml"];

  checkFiles.forEach(file => {
    if (fs.existsSync(path.join(outDir, file))) {
      logger.error(`Make sure your destination directory is empty.\n${outDir}`);
      process.exit(0);
    }
  });

  // Prompt questions
  if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) {
    logger.warn("Remember to make sure your destination directory is empty.");
  }

  logger.info("Please answer the following questions:");

  inquirer.prompt(questions).then(answers => {
    const languageInfo = localeCode.getLanguages([answers.lang])[0];
    const config = JSON.parse(
      configTemplate({
        options: {
          title: answers.title,
          name: slugify(answers.title),
          description: answers.description,
          language: {
            code: languageInfo.code.split("-")[0],
            iso: languageInfo.code,
            name: languageInfo.nativeName
          },
          frontMatterFormat: answers.incidentFormat
        }
github bazzite / statusfy / packages / @statusfy / core / lib / init.js View on Github external
}
  ];

  // Avoid overwrite user files
  const checkFiles = ["package.json", "config.js", "config.yml", "config.toml"];

  checkFiles.forEach(file => {
    if (fs.existsSync(path.join(outDir, file))) {
      logger.error(`Make sure your destination directory is empty.\n${outDir}`);
      process.exit(0);
    }
  });

  // Prompt questions
  if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0) {
    logger.warn("Remember to make sure your destination directory is empty.");
  }

  logger.info("Please answer the following questions:");

  inquirer.prompt(questions).then(answers => {
    const languageInfo = localeCode.getLanguages([answers.lang])[0];
    const config = JSON.parse(
      configTemplate({
        options: {
          title: answers.title,
          name: slugify(answers.title),
          description: answers.description,
          language: {
            code: languageInfo.code.split("-")[0],
            iso: languageInfo.code,
            name: languageInfo.nativeName
github bazzite / statusfy / packages / @statusfy / core / nuxt.config.js View on Github external
const { path, postcss } = require("@statusfy/common");

const pkg = require("./package");

const langDir = "locales/";
const mainColor = "#000000";
const iconSizes = [16, 120, 144, 152, 192, 384, 512];
const modulesDir = [path.join(__dirname, "node_modules")];
const tailwindJS = path.resolve(__dirname, "tailwind.js");

// Hack: allow to execute using lerna/yarn workspaces on testing
if (process.env.STATUSFY_LERNA) {
  modulesDir.push(
    path.relative(
      __dirname,
      path.join(__dirname, "..", "..", "..", "node_modules")
    )
  );
}

/**
 * @type { import("@nuxt/types").Configuration }
 */
const config = {
github bazzite / statusfy / packages / @statusfy / core / lib / init.js View on Github external
configContent = `module.exports = ${JSON.stringify(config, null, "  ")}`;
      configPath = path.join(outDir, "config.js");
    } else if (answers.configFormat === "yaml") {
      configContent = yaml.stringify(config);
      configPath = path.join(outDir, "config.yml");
    } else if (answers.configFormat === "toml") {
      configContent = tomlify.toToml(config, { space: 2 });
      configPath = path.join(outDir, "config.toml");
    }

    fse.outputFileSync(configPath, configContent);

    // Default locale
    fse.copySync(
      path.join(__dirname, "init", "README-locales.md"),
      path.join(outDir, "locales", "README.md")
    );
    fse.outputJsonSync(
      path.join(outDir, "locales", `${config.defaultLocale}.json`),
      {
        title: config.title,
        description: config.description
      },
      { spaces: "  " }
    );

    // Content directory
    fse.copySync(
      path.join(__dirname, "init", "README-content.md"),
      path.join(outDir, "content", "README.md")
    );
github bazzite / statusfy / packages / @statusfy / core / nuxt.config.js View on Github external
const mainColor = "#000000";
const iconSizes = [16, 120, 144, 152, 192, 384, 512];
const modulesDir = [path.join(__dirname, "node_modules")];

// Hack: allow to execute using lerna/yarn workspaces on testing
if (process.env.STATUSFY_LERNA) {
  modulesDir.push(
    path.relative(
      __dirname,
      path.join(__dirname, "..", "..", "..", "node_modules")
    )
  );
}

module.exports = {
  srcDir: path.join(__dirname, "./client/"),
  modulesDir,
  mode: "universal",
  /*
  ** Environment variables
  */
  env: {
    isDev: process.env.NODE_ENV !== "production"
  },
  /*
  ** Headers of the page
  */
  head: {
    title: pkg.name,
    meta: [
      { charset: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
github bazzite / statusfy / packages / @statusfy / core / lib / init.js View on Github external
iso: languageInfo.code,
            name: languageInfo.nativeName
          },
          frontMatterFormat: answers.incidentFormat
        }
      })
    );

    /* Write files */
    // Main Config
    let configContent;
    let configPath;

    if (answers.configFormat === "javascript") {
      configContent = `module.exports = ${JSON.stringify(config, null, "  ")}`;
      configPath = path.join(outDir, "config.js");
    } else if (answers.configFormat === "yaml") {
      configContent = yaml.stringify(config);
      configPath = path.join(outDir, "config.yml");
    } else if (answers.configFormat === "toml") {
      configContent = tomlify.toToml(config, { space: 2 });
      configPath = path.join(outDir, "config.toml");
    }

    fse.outputFileSync(configPath, configContent);

    // Default locale
    fse.copySync(
      path.join(__dirname, "init", "README-locales.md"),
      path.join(outDir, "locales", "README.md")
    );
    fse.outputJsonSync(