Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function generateConfig(sourceDir, cliOptions) {
/**
* @type { import("@nuxt/types").Configuration }
*/
const nuxtConfig = Object.assign(
{},
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)];
// Close function
const close = () => {
// In analyze mode wait for plugin
// emitting assets and opening browser
if (typeof nuxtConfig.build.analyze === "object") {
return;
}
process.exit(0);
};
try {
await builder.build();
close();
} catch (error) {
logger.fatal(error);
}
};
}
const nuxt = new Nuxt(nuxtConfig);
const builder = new Builder(nuxt);
const generator = new Generator(nuxt, builder);
const generateOptions = {
init: true,
build: true
};
try {
await generator.generate(generateOptions);
process.exit(0);
} catch (error) {
logger.fatal(error);
}
};
nuxt.hook("error", err => logger.fatal(err));
} 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) {
logger.fatal(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) {
logger.fatal(error);
}
});
};
if (answers.open) {
opener(filePath);
}
}
});
if (!error) {
logger.success(
`The Incident was successfully created.\n${createdFiles.join("\n")}`
);
} else {
logger.warn("There was an issue in creating the Incident.");
}
} catch (error) {
logger.fatal(error);
}
});
};