Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
};
};
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 = {
checkFiles.forEach(file => {
if (fs.existsSync(path.join(outDir, file))) {
logger.error(`Make sure your destination directory is empty.\n${outDir}`);
process.exit(0);
}
});
for (let j = 0; j < locales.length; j++) {
const locale = locales[j];
const localeIncidentPath = path.join(
contentDir,
config.defaultLocale !== locale ? locale : "",
incident.name
);
const exists = await fse.pathExists(localeIncidentPath);
if (exists) {
try {
await fse.remove(localeIncidentPath);
deletedFiles.push(localeIncidentPath);
} catch (error) {
logger.error(error);
}
} else {
logger.warn(`This file couldn't be found:\n${localeIncidentPath}`);
}
}
if (deletedFiles.length > 0) {
const prefix =
deletedFiles.length === 1
? "This file was successfully deleted"
: "These files were successfully deleted";
logger.success(`${prefix}: \n${deletedFiles.join("\n")}`);
}
}
} catch (error) {
const copyPublicFiles = async (src, dest) => {
if (src) {
logger.debug(`Copying public files ${dest}`);
try {
await fse.copy(src, dest);
} catch (error) {
logger.error(`Couldn't copy public files ${dest}`);
logger.error(error);
}
}
};
const copyPublicFiles = async (src, dest) => {
if (src) {
logger.debug(`Copying public files ${dest}`);
try {
await fse.copy(src, dest);
} catch (error) {
logger.error(`Couldn't copy public files ${dest}`);
logger.error(error);
}
}
};
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,
`${content}\n\n`
);
createdFiles.push(path.relative(contentPath, filePath));
if (answers.open) {
opener(filePath);
}
}
});
.catch(err => {
logger.error(err);
});
};
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";
logger.success(`${prefix}: \n${updatedFiles.join("\n")}`);
}
}
} catch (error) {
if (!incident.modified) {
try {
incident.modified = new Date(
getGitLastUpdatedTimeStamp(filePath)
).toISOString();
} catch (error) {
incident.modified = null;
}
}
allIncidents.push(incident);
}
}
} catch (error) {
logger.error(error);
}
}
return allIncidents;
};