Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = {
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")
);
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" },
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(
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;
}
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 {
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: [
const files = (await readdirP(dirPath)).map(f => path.join(dirPath, f));
const { postcss, path } = require("@statusfy/common");
const tailwindJS = path.join(__dirname, "tailwind.js");
module.exports = {
plugins: postcss.plugins(tailwindJS)
};
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,