How to use the @statusfy/common.Dates 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 / update-incident.js View on Github external
const {
  logger,
  fse,
  grayMatter,
  LRU,
  path,
  Dates
} = require("@statusfy/common");
const loadConfig = require("./config/load");
const {
  getIncidentsFromProject,
  generateIncident
} = require("./utils/functions");

const cache = new LRU();
const dates = Dates();

const getIncidentData = async filePath => {
  const key = `data:${filePath}`;
  let data = cache.get(key);

  if (!data) {
    const fileContent = await fse.readFile(filePath);
    data = grayMatter.parse(fileContent);

    cache.set(key, data);
  }

  return data;
};

/* eslint-disable require-await */
github bazzite / statusfy / packages / @statusfy / core / lib / new-incident.js View on Github external
const fs = require("fs");
const inquirer = require("inquirer");
const opener = require("opener");

const { logger, fse, slugify, path, Dates } = require("@statusfy/common");
const loadConfig = require("./config/load");
const { generateIncident } = require("./utils/functions");

const dates = Dates();

/* eslint-disable require-await */
module.exports = async function newIncident(sourceDir, cliOptions = {}) {
  process.env.NODE_ENV = "development";

  // Generate configuration
  const config = loadConfig(sourceDir).config;

  const questions = [
    {
      type: "input",
      name: "title",
      message: "What is the cause of the incident?",
      validate: value => {
        if (value.length > 0) {
          return true;
github bazzite / statusfy / packages / @statusfy / core / lib / content / calendar.js View on Github external
const url = require("url");
const ics = require("ics");
const { Dates } = require("@statusfy/common");

const createDatabase = require("./database");

const dates = Dates();

const extractDate = value => {
  return [
    value.year(),
    value.month() + 1,
    value.date(),
    value.hour(),
    value.minute(),
    value.second()
  ];
};

module.exports = async function calendar(siteConfig, lang) {
  const database = await createDatabase(siteConfig);
  /* eslint-disable node/no-deprecated-api */
  const { host } = url.parse(siteConfig.baseUrl);
github bazzite / statusfy / packages / @statusfy / core / lib / content / sitemap.js View on Github external
const sm = require("sitemap");
const { Dates } = require("@statusfy/common");

const createDatabase = require("./database");

const dates = Dates();

module.exports = async function sitemap(siteConfig) {
  const database = await createDatabase(siteConfig);

  const sitemap = sm.createSitemap({
    hostname: siteConfig.baseUrl,
    cacheTime: 86400, // 1 day
    xslUrl: "/sitemap.xsl"
  });

  siteConfig.locales.forEach(locale => {
    const prefix =
      locale.code === siteConfig.defaultLocale ? "" : `/${locale.code}`;
    const fixedPages = ["/", "/history"];
    const base = {
      changefreq: "daily",
github bazzite / statusfy / packages / @statusfy / core / lib / content / database.js View on Github external
const { readdir, stat, readFile } = require("fs");
const { promisify } = require("util");
const spawn = require("cross-spawn");
const drop = require("lodash.drop");
const sortBy = require("lodash.sortby");

const createMarkdown = require("@statusfy/markdown");
const { logger, hash, path, fse, LRU, Dates } = require("@statusfy/common");

const dates = Dates();
const readdirP = promisify(readdir);
const statP = promisify(stat);
const readFileP = promisify(readFile);

const md = createMarkdown();
const cache = new LRU({
  max: 1000,
  maxAge: process.env.NODE_ENV !== "development" ? 1000 * 60 * 60 : 1
});

const getGitLastUpdatedTimeStamp = filepath => {
  const { stdout } = spawn.sync("git", ["log", "-1", "--format=%ct", filepath]);

  return parseInt(stdout.toString("utf-8")) * 1000;
};