Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit b3a26be

Browse files
committedOct 2, 2019
Code from 30103383
1 parent 5f7d975 commit b3a26be

File tree

16 files changed

+633
-61
lines changed

16 files changed

+633
-61
lines changed
 

‎bin/tc-submission-cli.js

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
process.env.NODE_CONFIG_DIR = `${__dirname}/../config/`
33

44
const program = require('commander')
5-
const uploadSubmissionService = require('../src/services/uploadSubmissionService')
5+
const submit = require('../src/commands/submit')
6+
const pay = require('../src/commands/pay')
7+
const config = require('../src/commands/config')
68
const logger = require('../src/common/logger')
7-
const _ = require('lodash')
8-
const fs = require('fs')
99

1010
program
1111
.option('-u, --username <uname>', 'Topcoder username')
@@ -27,32 +27,36 @@ program.on('--help', () => {
2727
}`)
2828
})
2929

30-
program.parse(process.argv)
30+
program
31+
.command('submit')
32+
.description('Create a challenge submission')
33+
.action(() => {
34+
try {
35+
submit(program)
36+
} catch (error) {
37+
logger.error(error.message)
38+
}
39+
})
3140

32-
uploadSubmissionService.smart(process.cwd(), program)
33-
.then(async (responses) => {
34-
const log = {}
35-
_.each(responses, response => {
36-
const resp = JSON.parse(response.text)
37-
const submissionId = _.get(resp, 'id', undefined)
38-
const challengeId = _.get(resp, 'challengeId', undefined)
39-
if (submissionId && challengeId) {
40-
if (log[challengeId]) {
41-
log[challengeId].push(submissionId)
42-
} else {
43-
log[challengeId] = [submissionId]
44-
}
45-
}
46-
})
47-
const logTxt = _.join(_.map(_.keys(log), key => `challenge_${key}:\t${log[key]}`), '\n')
48-
logger.info(`Uploaded submissions:\n${logTxt}`)
49-
await fs.writeFileSync('topcoder-cli.log',
50-
`${Date.now()}:\n${logTxt}\n\n`,
51-
{ flag: 'a' })
52-
logger.info('Completed!')
53-
process.exit()
41+
program
42+
.command('config')
43+
.description('Set up/change globally configured config')
44+
.option('-l --list', 'Print out the config of the config file.')
45+
.option('-a --add <key> <value>', 'Adds a config to the config file.')
46+
.action((...args) => {
47+
try {
48+
config.handleSubCommand(args)
49+
} catch (error) {
50+
logger.error(error.message)
51+
}
5452
})
55-
.catch(err => {
56-
logger.error(err.message)
57-
process.exit(1)
53+
54+
program
55+
.command('pay')
56+
.description('Let copilot/managers process private task payments')
57+
.option('-o --copilot <payment>', 'copilot payment.')
58+
.action((...args) => {
59+
pay.handleCommand(args)
5860
})
61+
62+
program.parse(process.argv)

‎config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
77
TC_MEMBERS_API: process.env.TC_MEMBERS_API || 'https://api.topcoder-dev.com/v3/members',
88
SUBMISSION_API_URL: process.env.TEST_SUBMISSION_API_URL || 'https://api.topcoder-dev.com/v5',
9+
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token',
910
TC_AUTHN_URL: process.env.TC_AUTHN_URL || 'https://topcoder-dev.auth0.com/oauth/ro',
1011
TC_AUTHZ_URL: process.env.TC_AUTHZ_URL || 'https://api.topcoder-dev.com/v3/authorizations',
1112
TC_CLIENT_ID: process.env.TC_CLIENT_ID || 'JFDo7HMkf0q2CkVFHojy3zHWafziprhT', // for dev 'JFDo7HMkf0q2CkVFHojy3zHWafziprhT',

‎constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ module.exports = {
55
rc: {
66
name: '.topcoderrc'
77
},
8+
config: {
9+
name: '.tcconfig'
10+
},
811
submissionType: {
912
contestSubmission: 'Contest Submission'
1013
},

0 commit comments

Comments
 (0)