How to use the @statusfy/common.path.join 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 / 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(
github bazzite / statusfy / packages / @statusfy / core / lib / config / load.js View on Github external
module.exports = function loadConfig(sourceDir) {
  const configFiles = ["config.yml", "config.toml", "config.js"];
  let configContent = {};
  let errors = [];

  // resolve configContent
  // eslint-disable-next-line no-unused-vars
  for (const configFile of configFiles) {
    const configPath = path.join(sourceDir, configFile);

    if (fse.existsSync(configPath)) {
      configContent = parseConfig(configPath);
      break;
    }
  }

  // Replace user's systems
  if (configContent.content && configContent.content.systems) {
    defaultConfig.content.systems = configContent.content.systems;
  }

  // Replace user's locales
  if (configContent.locales) {
    defaultConfig.locales = configContent.locales;
  }
github bazzite / statusfy / packages / @statusfy / core / lib / content / database.js View on Github external
const getIncidents = async siteConfig => {
  const incidents = {};
  const scheduled = {};

  // Retrieve incidents for each language
  for (let i = 0; i < siteConfig.locales.length; i++) {
    const locale = siteConfig.locales[i];
    const cacheKey = `incidents-${locale.code}`;
    let localeIncidents = cache.get(cacheKey);

    if (!localeIncidents) {
      let contentPath = path.join(siteConfig.sourceDir, siteConfig.content.dir);

      if (locale.code !== siteConfig.defaultLocale) {
        contentPath = path.join(contentPath, locale.code);
      }

      localeIncidents = await readFileIncidents(contentPath);
    }

    incidents[locale.code] = localeIncidents.filter(i => {
      if (i.severity === "under-maintenance" && i.scheduled && i.duration) {
        return new Date(i.scheduled) < new Date();
      } else {
        return true;
      }
    });
    scheduled[locale.code] = localeIncidents.filter(i => {
      if (i.severity === "under-maintenance" && i.scheduled && i.duration) {
        return new Date(i.scheduled) >= new Date();
      } else {
github bazzite / statusfy / packages / website / nuxt.config.js View on Github external
const buildCode = `${pkg.version}-${(
  process.env.COMMIT_REF || String(new Date().getTime())
).substring(0, 7)}`
const title = 'Statusfy'
const description = 'A marvelous open source Status Page system'
const mainColor = '#3e4e88'
const secondColor = '#eff0f4'
const baseHost = 'https://statusfy.co'
const twitterUserEn = 'BazziteTech'
const twitterUserEs = 'BazziteEs'
const tailwindJS = path.join(__dirname, 'tailwind.js')

module.exports = {
  mode: 'universal',
  modulesDir: [
    path.join(__dirname, 'node_modules'),
    path.join(__dirname, '..', '..', 'node_modules')
  ],
  env: {
    mainColor,
    secondColor,
    baseHost,
    twitterUserEn,
    twitterUserEs
  },
  /*
   ** Headers of the page
   */
  head: {
    titleTemplate: '%s | Statusfy',
    title,
    meta: [
github bazzite / statusfy / packages / @statusfy / core / lib / content / database.js View on Github external
      const files = (await readdirP(dirPath)).map(f => path.join(dirPath, f));
github bazzite / statusfy / packages / @statusfy / core / postcss.config.js View on Github external
const { postcss, path } = require("@statusfy/common");

const tailwindJS = path.join(__dirname, "tailwind.js");

module.exports = {
  plugins: postcss.plugins(tailwindJS)
};
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,