diff --git a/website/package.json b/website/package.json index 8a233939d7..e050e3271f 100644 --- a/website/package.json +++ b/website/package.json @@ -15,8 +15,7 @@ "sails-hook-organics": "^2.2.2", "sails-hook-orm": "^4.0.2", "sails-hook-sockets": "^3.0.0", - "sails-postgresql": "^5.0.0", - "yaml": "1.10.2" + "sails-postgresql": "^5.0.0" }, "devDependencies": { "eslint": "5.16.0", @@ -24,7 +23,8 @@ "htmlhint": "0.11.0", "lesshint": "6.3.6", "marked": "4.0.10", - "sails-hook-grunt": "^4.0.0" + "sails-hook-grunt": "^4.0.0", + "yaml": "1.10.2" }, "scripts": { "custom-tests": "echo \"(No other custom tests yet.)\" && echo", diff --git a/website/scripts/create-issues-for-todays-rituals.js b/website/scripts/create-issues-for-todays-rituals.js index cc71a58dd6..9faf00bca1 100644 --- a/website/scripts/create-issues-for-todays-rituals.js +++ b/website/scripts/create-issues-for-todays-rituals.js @@ -13,33 +13,17 @@ module.exports = { fn: async function ({ dry }) { - let path = require('path'); - let YAML = require('yaml'); - let topLvlRepoPath = path.resolve(sails.config.appPath, '../'); + if (!_.isObject(sails.config.builtStaticContent) || !_.isObject(sails.config.builtStaticContent.rituals)) { + throw new Error('Missing, incomplete, or invalid configuration. Could not create issues for todays rituals, please try running `sails run build-static-content` and try running this script again.'); + } + let baseHeaders = {// (for github api) 'User-Agent': 'Fleetie pie', 'Authorization': `token ${sails.config.custom.githubAccessToken}` }; - // Find all the files in the top level /handbook folder and it's sub-folders - let FILES_IN_HANDBOOK_FOLDER = await sails.helpers.fs.ls.with({ - dir: path.join(topLvlRepoPath, '/handbook'), - depth: 3 - }); - // Filter the list of filenames to get the rituals YAML files. - let ritualYamlPaths = FILES_IN_HANDBOOK_FOLDER.filter((filePath)=>{ - return _.endsWith(filePath, 'rituals.yml'); - }); - for (let ritualSource of ritualYamlPaths) { - // Load rituals - let pathToRituals = path.resolve(topLvlRepoPath, ritualSource); - let rituals = []; - let ritualsYml = await sails.helpers.fs.read(pathToRituals); - try { - rituals = YAML.parse(ritualsYml, { prettyErrors: true }); - } catch (err) { - throw new Error(`Could not parse the YAMl for rituals at ${pathToRituals} on line ${err.linePos.start.line}. To resolve, make sure the YAML is valid, and try again: ` + err.stack); - } + for (let ritualSource in sails.config.builtStaticContent.rituals) { + let rituals = sails.config.builtStaticContent.rituals[ritualSource]; for (let ritual of rituals) { // For each ritual, we'll: // - Convert the ritual's frequency into milliseconds.