clubhouse-cli
Advanced tools
Comparing version 0.10.1 to 0.10.2
{ | ||
"name": "clubhouse-cli", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "A command line tool for viewing, creating and updating clubhouse.io stories", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -31,2 +31,13 @@ const chalk = require('chalk'); | ||
const project = projects[index]; | ||
let created_at = false; | ||
if (program.created) | ||
created_at = parseDateComparator(program.created); | ||
let updated_at = false; | ||
if (program.updated) | ||
updated_at = parseDateComparator(program.updated); | ||
let regexLabel = new RegExp(program.label, 'i'); | ||
let regexState = new RegExp(program.state, 'i'); | ||
let regexOwner = new RegExp(program.owner, 'i'); | ||
let regexText = new RegExp(program.text, 'i'); | ||
let regexType = new RegExp(program.type, 'i'); | ||
const filtered = stories.map(story => { | ||
@@ -48,22 +59,28 @@ story.project = project; | ||
.map(l => `${l.id},${l.name}`).join(',') + '') | ||
.match(new RegExp(program.label, 'i'))) { | ||
.match(regexLabel)) { | ||
return false; | ||
} | ||
if (!(s.workflow_state_id + ' ' + s.state.name) | ||
.match(new RegExp(program.state, 'i'))) { | ||
.match(regexState)) { | ||
return false; | ||
} | ||
if (program.owner) { | ||
const ownerMatch = new RegExp(program.owner, 'i'); | ||
return s.owners.filter(o => { | ||
const owned = s.owners.filter(o => { | ||
return !!`${o.profile.name} ${o.profile.mention_name}` | ||
.match(ownerMatch); | ||
.match(regexOwner); | ||
}).length > 0; | ||
if (!owned) return false; | ||
} | ||
if (!s.name.match(new RegExp(program.text, 'i'))) { | ||
if (!s.name.match(regexText)) { | ||
return false; | ||
} | ||
if (!s.story_type.match(new RegExp(program.type, 'i'))) { | ||
if (!s.story_type.match(regexType)) { | ||
return false; | ||
} | ||
if (created_at && !created_at(s.created_at)) { | ||
return false; | ||
} | ||
if (updated_at && !updated_at(s.updated_at)) { | ||
return false; | ||
} | ||
return true; | ||
@@ -99,3 +116,21 @@ }); | ||
const parseDateComparator = (arg) => { | ||
const match = arg.match(/[0-9].*/) || { index: 0, '0': { length: 12 } }; | ||
const parsedDate = new Date(arg.slice(match.index)); | ||
const comparator = arg.slice(0, match.index); | ||
return (date) => { | ||
switch(comparator) { | ||
case '<': | ||
return new Date(date) < parsedDate; | ||
case '>': | ||
return new Date(date) > parsedDate; | ||
case '=': | ||
default: | ||
return new Date(date.slice(0, match[0].length)).getTime() | ||
== parsedDate.getTime(); | ||
} | ||
}; | ||
}; | ||
module.exports = { | ||
@@ -102,0 +137,0 @@ listStories, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44176
220