Skip to content

Commit

Permalink
Website: update create-issues-from-todays-rituals script to work in…
Browse files Browse the repository at this point in the history
… 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`
  • Loading branch information
eashaw authored Mar 19, 2024
1 parent c6d5151 commit 61544f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
6 changes: 3 additions & 3 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"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",
"grunt": "1.0.4",
"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",
Expand Down
28 changes: 6 additions & 22 deletions website/scripts/create-issues-for-todays-rituals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 61544f4

Please sign in to comment.