How to use the @statusfy/common.fse.writeFile 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 / client / modules / statusfy / index.js View on Github external
// eslint-disable-next-line no-unused-vars
      for (const locale of statusfyOptions.locales) {
        const lang = locale.code;
        const calPath = path.join(
          this.options.generate.dir,
          "calendars",
          `scheduled.${locale.code}.ics`
        );

        const content = await createCalendar(statusfyOptions.siteConfig, lang);

        // Ensure no calendar file exists
        await fse.remove(calPath);
        await fse.ensureFile(calPath);

        await fse.writeFile(calPath, content);

        logger.success(`Generated /calendars/scheduled.${locale.code}.ics`);
      }
    }
  });
};
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
"feeds",
          `incidents.${locale.code}.xml`
        );
        const atomPath = path.join(
          this.options.generate.dir,
          "feeds",
          `incidents.${locale.code}.atom`
        );

        // Ensure no feed file exists
        await fse.remove(rssPath);
        await fse.ensureFile(rssPath);
        await fse.remove(atomPath);
        await fse.ensureFile(atomPath);

        await fse.writeFile(rssPath, feeds.rss());
        await fse.writeFile(atomPath, feeds.atom());

        logger.success(`Generated /feeds/incidents.${locale.code}.xml`);
        logger.success(`Generated /feeds/incidents.${locale.code}.atom`);
      }
    }

    /* Calendars */
    if (
      statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.icalendar
    ) {
      // eslint-disable-next-line no-unused-vars
      for (const locale of statusfyOptions.locales) {
        const lang = locale.code;
        const calPath = path.join(
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
`incidents.${locale.code}.xml`
        );
        const atomPath = path.join(
          this.options.generate.dir,
          "feeds",
          `incidents.${locale.code}.atom`
        );

        // Ensure no feed file exists
        await fse.remove(rssPath);
        await fse.ensureFile(rssPath);
        await fse.remove(atomPath);
        await fse.ensureFile(atomPath);

        await fse.writeFile(rssPath, feeds.rss());
        await fse.writeFile(atomPath, feeds.atom());

        logger.success(`Generated /feeds/incidents.${locale.code}.xml`);
        logger.success(`Generated /feeds/incidents.${locale.code}.atom`);
      }
    }

    /* Calendars */
    if (
      statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.icalendar
    ) {
      // eslint-disable-next-line no-unused-vars
      for (const locale of statusfyOptions.locales) {
        const lang = locale.code;
        const calPath = path.join(
          this.options.generate.dir,
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
this.nuxt.hook("generate:done", async generator => {
    await copyPublicFiles(
      statusfyOptions.publicFilesPath,
      this.options.generate.dir
    );

    /* Sitemap */
    const sitemap = await createSitemap(statusfyOptions.siteConfig);
    const xmlPath = path.join(this.options.generate.dir, "sitemap.xml");

    // Ensure no sitemap file exists
    await fse.remove(xmlPath);
    await fse.ensureFile(xmlPath);

    await fse.writeFile(xmlPath, sitemap);

    logger.success("Generated /sitemap.xml");

    /* Feeds */
    if (
      statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.feeds
    ) {
      // eslint-disable-next-line no-unused-vars
      for (const locale of statusfyOptions.locales) {
        const feeds = await createFeeds(
          statusfyOptions.siteConfig,
          locale.code
        );

        const rssPath = path.join(
github bazzite / statusfy / packages / @statusfy / core / lib / update-incident.js View on Github external
const data = await getIncidentData(localeIncidentPath);
              const newMatter = {
                ...data.data,
                modified,
                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";