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

Commit fe7910e

Browse files
first commit
0 parents  commit fe7910e

File tree

4,720 files changed

+606258
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,720 files changed

+606258
-0
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: standard

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.nyc_output
2+
coverage
3+
.topcoderrc

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
tc-submission-cli
2+
===
3+
4+
# Dependencies
5+
- nodejs https://nodejs.org/en/ (v10)
6+
- npm https://www.npmjs.com/ (v6)
7+
8+
# Configuration
9+
Configuration for the application is at `config/default.js`.
10+
The following parameters can be set in config files or in env variables:
11+
12+
| Property | Environment varible | Default value | Description |
13+
| --- | --- | --- | --- |
14+
| LOG_LEVEL | LOG_LEVEL | info | control log level |
15+
| SUBMISSION_API_URL | TEST_SUBMISSION_API_URL | https://api.topcoder.com/v5/submissions | the TC submission API URL |
16+
| TC_AUTHN_URL | TC_AUTHN_URL | https://topcoder.auth0.com/oauth/ro | API that is used to fetch JWT token v2 |
17+
| TC_AUTHZ_URL | TC_AUTHZ_URL | https://api.topcoder.com/v3/authorizations | API that is used to fetch JWT token v3 |
18+
| TC_CLIENT_ID | TC_CLIENT_ID | 6ZwZEUo2ZK4c50aLPpgupeg5v2Ffxp9P | TC client ID |
19+
| TC_CLIENT_V2CONNECTION | CLIENT_V2CONNECTION | LDAP | TC client connection protocol |
20+
21+
# Publish the package to npm
22+
- Create a npm account on https://www.npmjs.com/signup if you don't have one.
23+
- Use the account to sign in via cli: `npm login`
24+
- In the root directory of the project, run `npm publish --access=public` to publish the package to npm registry.
25+
26+
## Notes
27+
- In rare cases the module name would have been used by others. You may need to change the value of the `name` field in `package.json`
28+
to a unique one.
29+
- When you make changes to your code and want to update the package you'll need to update the version of the package.
30+
After that, run `npm publish` again to republish the package.
31+
- If you want to remove the package from npm registry anyway, run `npm unpublish --force` under the root directory of the project.
32+
33+
# Installation
34+
35+
- After you published the package to npm registry you can then install the package via npm-cli:
36+
37+
``` node
38+
npm install -g <your package name here>
39+
```
40+
41+
# Usage
42+
43+
First, install the package, and then run `tc-submission-cli` command on the root directory of your project with `.topcoderrc` file.
44+
It'll then automatically zip all files under the root directory recursively(except the .topcoderrc file itself) and finally upload the zip file to the TC challenge as a submission.
45+
46+
An example `.topcoderrc` file should conform to at least the following structure.
47+
48+
``` jsonr
49+
{
50+
"challengeIds": [
51+
"30095545" // at least one item here
52+
],
53+
"username": "TonyJ",
54+
"password": "appirio123"
55+
}
56+
```
57+
58+
# test
59+
60+
## Prepare
61+
- Install dependencies `npm install`
62+
63+
## Unit test
64+
To run unit tests alone
65+
66+
```bash
67+
npm run test
68+
```
69+
70+
To run unit tests with coverage report
71+
72+
```bash
73+
npm run test:cov
74+
```

bin/cli.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
process.env.NODE_CONFIG_DIR = `${__dirname}/../config/`
3+
4+
const uploadSubmissionService = require('../src/services/uploadSubmissionService')
5+
const logger = require('../src/common/logger')
6+
7+
uploadSubmissionService.smart(process.cwd())
8+
.then(() => {
9+
logger.info('done!')
10+
process.exit()
11+
})
12+
.catch(err => {
13+
logger.error(err.message)
14+
process.exit(1)
15+
})

config/default.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Configuration here.
3+
*/
4+
5+
module.exports = {
6+
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
7+
TC_MEMBERS_API: process.env.TC_MEMBERS_API || 'https://api.topcoder-dev.com/v3/members',
8+
SUBMISSION_API_URL: process.env.TEST_SUBMISSION_API_URL || 'https://api.topcoder-dev.com/v5/submissions',
9+
TC_AUTHN_URL: process.env.TC_AUTHN_URL || 'https://topcoder-dev.auth0.com/oauth/ro',
10+
TC_AUTHZ_URL: process.env.TC_AUTHZ_URL || 'https://api.topcoder-dev.com/v3/authorizations',
11+
TC_CLIENT_ID: process.env.TC_CLIENT_ID || 'JFDo7HMkf0q2CkVFHojy3zHWafziprhT', // for prod '6ZwZEUo2ZK4c50aLPpgupeg5v2Ffxp9P',
12+
TC_CLIENT_V2CONNECTION: process.env.CLIENT_V2CONNECTION || 'TC-User-Database'
13+
}

constants.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Constants here.
3+
*/
4+
module.exports = {
5+
rc: {
6+
name: '.topcoderrc'
7+
},
8+
submissionType: {
9+
contestSubmission: 'Contest Submission'
10+
},
11+
cacheControl: {
12+
noCache: 'no-cache'
13+
},
14+
contentType: {
15+
json: 'application/json',
16+
zip: 'application/zip'
17+
},
18+
sso: false,
19+
scope: 'openid profile offline_access',
20+
responseType: 'token',
21+
grantType: 'password',
22+
device: 'Browser'
23+
}

node_modules/.bin/_mocha

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/atob

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/esparse

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/esvalidate

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/flat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/handlebars

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/he

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/js-yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/jsesc

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/json5

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mime

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mkdirp

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/mocha

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/nyc

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/parser

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/rimraf

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/semver

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uglifyjs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/which

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@babel/code-frame/LICENSE

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@babel/code-frame/README.md

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)