Website: update create-issues-from-todays-rituals script to work in production (#17680)

Closes: #17678

Changes:
- Updated the `create-issues-from-todays-rituals` to create GH issues
using rituals from website's configuration instead of the ritual.yml
files in the `handbook/` folder
- Moved `yaml` to `devDependencies` in `webiste/package.json`
This commit is contained in:
Eric 2024-03-19 10:02:50 -05:00 committed by GitHub
parent c6d5151198
commit 61544f4bea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 25 deletions

View File

@ -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",

View File

@ -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.