mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 00:45:19 +00:00
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:
parent
c6d5151198
commit
61544f4bea
6
website/package.json
vendored
6
website/package.json
vendored
@ -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",
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user