-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
502 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
version: 1.{build} | ||
skip_tags: true | ||
pull_requests: | ||
do_not_increment_build_number: true | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
"use strict"; | ||
|
||
const contestConfig = require("../util/config/readCtConfig"); | ||
const contestConfig = require("../util/config/contestConfig"); | ||
|
||
module.exports = contestConfig.config(); | ||
module.exports = contestConfig.read(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
const validUrl = require("valid-url"); | ||
const Judger = require("../../driver/kon"); | ||
const contestConfig = require("../../util/config/contestConfig"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Kon addition prompt | ||
*/ | ||
async function addKonPrompt(init = []) { | ||
const _probList = contestConfig.read().probList; | ||
const { url, prob } = await enquirer.prompt([ | ||
{ | ||
type: "input", | ||
name: "url", | ||
message: "URL", | ||
// hint: "http:// or https:// url", | ||
validate: (val) => !!validUrl.isWebUri(val) | ||
}, | ||
{ | ||
type: "multiselect", | ||
name: "prob", | ||
message: "Problems handled by this Kon", | ||
hint: "If none are chosen, Wafter will understand Kon accept all", | ||
choices: _probList | ||
} | ||
]); | ||
const newList = init; | ||
newList.push(new Judger(url, prob)); | ||
return newList; | ||
} | ||
|
||
module.exports = addKonPrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Kon management prompt | ||
*/ | ||
async function manKonPrompt(init = []) { | ||
const cached = init.reduce((obj, kon) => { | ||
obj[kon.url] = kon; | ||
return obj; | ||
}, {}); | ||
const _konList = init.map((x) => ({ | ||
name: x.url, | ||
hint: x.prob && x.prob.length > 0 ? JSON.stringify(x.prob) : "*" | ||
})); | ||
const { konList } = await enquirer.prompt({ | ||
type: "multiselect", | ||
name: "konList", | ||
message: "Manage Kon in use:", | ||
initial: _konList, | ||
choices: _konList | ||
}); | ||
return konList.map((x) => cached[x]); | ||
} | ||
|
||
module.exports = manKonPrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const Console = require("console"); | ||
const Enquirer = require("enquirer"); | ||
|
||
const KonConfig = require("../util/config/KonConfig"); | ||
|
||
const add = require("./KonConfig/add"); | ||
const manage = require("./KonConfig/manage"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Prompt for contest's option | ||
*/ | ||
async function KonOptionsPrompt() { | ||
let KonOptionsContainer = { | ||
"Add Kon": add, | ||
"Manage Kon": manage | ||
}; | ||
|
||
let KonOptionsChoices = [ | ||
"Add Kon", | ||
{ name: "Manage Kon", disabled: KonConfig.read().length === 0 } | ||
]; | ||
|
||
const { choice } = await enquirer.prompt({ | ||
type: "select", | ||
name: "choice", | ||
message: "Kon's Pair Options", | ||
choices: KonOptionsChoices | ||
}); | ||
const jsonized = JSON.parse(JSON.stringify(KonConfig.read())); | ||
return KonOptionsContainer[choice](jsonized) | ||
.then((newData) => { | ||
KonConfig.update(newData); | ||
Console.log("Kon's pair configuration saved"); | ||
}) | ||
.catch((err) => { | ||
Console.log( | ||
`Kon's pair configuration was not saved${ | ||
err.message ? `: ${err.message}` : "" | ||
}` | ||
); | ||
}); | ||
} | ||
|
||
module.exports = KonOptionsPrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Control Code Extension prompt | ||
*/ | ||
async function acePrompt(init = {}) { | ||
let _ace = init.allowedCodeExt; | ||
|
||
// Temporary solution: create list of language, then filter non-included | ||
const langList = [".C", ".CPP", ".JAVA", ".KT", ".PAS", ".PY"]; | ||
const initAce = langList.filter((x) => _ace.indexOf(x) > -1); | ||
const leftAce = _ace.filter((x) => langList.indexOf(x) === -1); | ||
const { ace } = await enquirer.prompt({ | ||
type: "multiselect", | ||
name: "ace", | ||
message: "Set allowed code extension", | ||
hint: "Use <space> to select, <return> to submit", | ||
initial: initAce, | ||
choices: [ | ||
{ name: ".C", hint: "- C" }, | ||
{ name: ".CPP", hint: "- C++" }, | ||
{ name: ".JAVA", hint: "- Java" }, | ||
{ name: ".KT", hint: "- Kotlin" }, | ||
{ name: ".PAS", hint: "- Pascal" }, | ||
{ name: ".PY", hint: "- Python" } | ||
] | ||
}); | ||
return { allowedCodeExt: ace.concat(leftAce) }; | ||
} | ||
|
||
module.exports = acePrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Problem management prompt | ||
*/ | ||
async function manProbPrompt(init = {}) { | ||
let _probList = init.probList; | ||
const { probList } = await enquirer.prompt({ | ||
type: "multiselect", | ||
name: "probList", | ||
message: "Manage problems in contest:", | ||
initial: _probList, | ||
choices: _probList | ||
}); | ||
return { probList }; | ||
} | ||
|
||
module.exports = manProbPrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
const score = require("../../util/score"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Contest mode prompt | ||
*/ | ||
async function modePrompt(init = {}) { | ||
const _mode = score.hasOwnProperty(init.mode) ? init.mode : null; | ||
const { mode } = await enquirer.prompt({ | ||
type: "select", | ||
name: "mode", | ||
message: "Contest mode:", | ||
initial: _mode, | ||
choices: Object.keys(score) | ||
}); | ||
return { mode }; | ||
} | ||
|
||
module.exports = modePrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Contest name prompt | ||
*/ | ||
async function namePrompt(init = {}) { | ||
const _name = init.name; | ||
const { name } = await enquirer.prompt({ | ||
type: "input", | ||
name: "name", | ||
initial: _name, | ||
message: "Contest name:" | ||
}); | ||
|
||
return { name }; | ||
} | ||
|
||
module.exports = namePrompt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
|
||
const Enquirer = require("enquirer"); | ||
|
||
const enquirer = new Enquirer(); | ||
|
||
/** | ||
* Contest problem addition prompt | ||
*/ | ||
async function probListPrompt(init = {}) { | ||
let _probList = init.probList; | ||
const { probList } = await enquirer.prompt({ | ||
type: "list", | ||
name: "probList", | ||
message: "Add problem to contest:" | ||
}); | ||
_probList = _probList.concat(probList); | ||
return { probList: _probList }; | ||
} | ||
|
||
module.exports = probListPrompt; |
Oops, something went wrong.