This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
55 lines (44 loc) · 1.69 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env node
'use strict'
const commander = require('commander')
const spinner = require('ora')('Initializing...').start()
const options = require('./src/options')
const asana = require('./src/asana')
const clubhouse = require('./src/clubhouse')
for (const o of options) {
commander.option(o.flag, o.description)
}
// Required for automated help to work
commander.parse(process.argv)
// Invoke the main program routine
run()
// ----------------------------------------------------------------------------
// Main program routine that builds Clubhouse Project Stories
// from Asana Project Tasks
// ----------------------------------------------------------------------------
async function run () {
// Initialize Asana and Clubhouse libraries
asana.init(commander.asanaToken)
clubhouse.init(commander.clubhouseToken)
// Fetch all Asana Tasks for this project import
spinner.text = 'Fetching Tasks from Asana Project'
let stories = await asana.getTasks(commander.from)
// Include Asana subtasks for each task, if any
spinner.text = 'Fetching Subtasks for each Asana Task'
for (const story of stories) {
story.tasks = await asana.getSubtasks(story)
}
// Include Asana comments for each task, if any
spinner.text = 'Fetching Comments from parent Tasks'
for (const story of stories) {
story.comments = await asana.getComments(story)
}
// Create a new Clubhouse Story for each Asana Task
spinner.text = 'Creating stories in your Clubhouse project'
for (const story of stories) {
delete story.asanaId
story.project_id = commander.to
clubhouse.createStory(story)
}
spinner.succeed(`Finished migrating ${stories.length} Asana Tasks to Clubhouse Stories!`)
}